Skip to content

Commit

Permalink
use wallet v0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
popenta committed Oct 31, 2023
1 parent e31d00b commit fecb99d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions multiversx_sdk_cli/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ def __init__(self,

def sign_transaction(self, transaction: ITransaction) -> str:
assert self.signer is not None
return self.signer.sign(transaction).hex()
return self.signer.sign(transaction.serialize_for_signing()).hex()

def sign_message(self, data: bytes) -> str:
assert self.signer is not None
message = MessageV1(data)
signature = self.signer.sign(message)
signature = self.signer.sign(message.serialize_for_signing())

logger.debug(f"Account.sign_message(): raw_data_to_sign = {data.hex()}, message_data_to_sign = {message.serialize_for_signing().hex()}, signature = {signature.hex()}")
return signature.hex()
Expand Down
6 changes: 2 additions & 4 deletions multiversx_sdk_cli/delegation/staking_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path
from typing import Any

from multiversx_sdk_core import Address, ArbitraryMessage
from multiversx_sdk_core import Address

Check warning on line 5 in multiversx_sdk_cli/delegation/staking_provider.py

View workflow job for this annotation

GitHub Actions / runner / mypy

[mypy] reported by reviewdog 🐶 See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports Raw Output: /home/runner/work/mx-sdk-py-cli/mx-sdk-py-cli/multiversx_sdk_cli/delegation/staking_provider.py:5:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
from multiversx_sdk_wallet.validator_pem import ValidatorPEM
from multiversx_sdk_wallet.validator_signer import ValidatorSigner

Expand Down Expand Up @@ -52,9 +52,7 @@ def prepare_args_for_add_nodes(args: Any):
pem_file = ValidatorPEM.from_file(validator_pem)

validator_signer = ValidatorSigner(pem_file.secret_key)
message = ArbitraryMessage(bytes.fromhex(account.address.hex()))

signed_message = validator_signer.sign(message).hex()
signed_message = validator_signer.sign(account.address.pubkey).hex()

add_nodes_data += f"@{pem_file.secret_key.generate_public_key().hex()}@{signed_message}"

Expand Down
2 changes: 1 addition & 1 deletion multiversx_sdk_cli/sign_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def verify_signature(self) -> bool:
verifier = UserVerifier.from_address(Address.from_bech32(self.address))
verifiable_message = MessageV1.from_string(self.message)
verifiable_message.signature = bytes.fromhex(self.signature)
is_signed = verifier.verify(verifiable_message)
is_signed = verifier.verify(verifiable_message.serialize_for_signing(), verifiable_message.signature)
return is_signed

def to_dictionary(self) -> Dict[str, str]:
Expand Down
6 changes: 2 additions & 4 deletions multiversx_sdk_cli/validators/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path
from typing import Any, List, Tuple, Union

from multiversx_sdk_core import Address, ArbitraryMessage
from multiversx_sdk_core import Address
from multiversx_sdk_wallet.validator_pem import ValidatorPEM
from multiversx_sdk_wallet.validator_signer import ValidatorSigner

Expand Down Expand Up @@ -60,9 +60,7 @@ def prepare_transaction_data_for_stake(node_operator_address: Address, validator
pem_file = ValidatorPEM.from_file(validator_pem)

validator_signer = ValidatorSigner(pem_file.secret_key)
message = ArbitraryMessage(bytes.fromhex(node_operator_address.hex()))

signed_message = validator_signer.sign(message).hex()
signed_message = validator_signer.sign(node_operator_address.pubkey).hex()

call_arguments.append(f"0x{pem_file.secret_key.generate_public_key().hex()}")
call_arguments.append(f"0x{signed_message}")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies = [
"requests-cache",
"rich==13.3.4",
"multiversx-sdk-network-providers>=0.11.0",
"multiversx-sdk-wallet>=0.7.0, <0.8.0",
"multiversx-sdk-wallet>=0.8.0",
"multiversx-sdk-core>=0.5.0"
]

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ rich==13.3.4

multiversx-sdk-core==0.6.0
multiversx-sdk-network-providers>=0.11.0
multiversx-sdk-wallet>=0.7.0, < 0.8.0
multiversx-sdk-wallet>=0.8.0

0 comments on commit fecb99d

Please sign in to comment.