Skip to content

Commit

Permalink
Merge pull request #354 from multiversx/use-latest-wallet-package
Browse files Browse the repository at this point in the history
Use latest wallet package
  • Loading branch information
popenta authored Nov 1, 2023
2 parents cf848c4 + 5fc04d7 commit bb229d4
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 17 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
changelog:
exclude:
labels:
- ignore-for-release-notes
categories:
- title: What's Changed
labels:
- "*"
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
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ classifiers = [
"Operating System :: OS Independent",
"Intended Audience :: Developers"
]

dependencies = [
"toml>=0.10.2",
"requests",
Expand All @@ -26,9 +27,9 @@ dependencies = [
"semver",
"requests-cache",
"rich==13.3.4",
"multiversx-sdk-network-providers>=0.11.0",
"multiversx-sdk-wallet>=0.7.0",
"multiversx-sdk-core>=0.5.0"
"multiversx-sdk-network-providers>=0.11.0,<0.12.0",
"multiversx-sdk-wallet>=0.8.0,<0.9.0",
"multiversx-sdk-core>=0.6.0,<0.7.0"
]

[tool.hatch.build]
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ semver
requests-cache
rich==13.3.4

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

0 comments on commit bb229d4

Please sign in to comment.