multiversx / mx-sdk-py-wallet

Wallet components of sdk-py.
MIT License
3 stars 2 forks source link

Migration support: "v0.7.0" to "v0.8.0" #26

Open popenta opened 9 months ago

popenta commented 9 months ago

sdk-py-wallet v0.8.0 contains a few breaking changes compared to the previous version.

arbitrary message

The class ArbitraryMessage was removed.

popenta commented 9 months ago

user signer && validator signer

When using the UserSigner.sign(), instead of passing it an object of type ISignable the function should simply get a parameter of type bytes. The same change occurred for ValidatorSigner.sign(), as well.

e.g.

from multiversx_sdk_core import MessageV1

signer = UserSigner.from_pem_file(Path("./testwallets/alice.pem"))
message = MessageV1.from_string("hello")
message.signature = signer.sign(message.data)
popenta commented 9 months ago

user verifier && validator verifier

When using the UserVerifier.verify() instead of having an object of type IVerifiable, the method now has two parameters, the first one is the message that you want to verify, of type bytes and the second one is the signature, of type bytes, as well. The same change occurred for the ValidatorVerifier.verify().

e.g.

from multiversx_sdk_core import Address
from multiversx_sdk_wallet import UserVerifier

alice = Address.from_bech32("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th")
alice_verifier = UserVerifier.from_address(alice)

print(f"Is signature of Alice?", alice_verifier.verify(message.data, message.signature))