Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use latest wallet package #354

Merged
merged 10 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2,8 +2,8 @@
from pathlib import Path
from typing import Any, Optional, Protocol

from multiversx_sdk_core import Address, MessageV1

Check failure on line 5 in multiversx_sdk_cli/accounts.py

View workflow job for this annotation

GitHub Actions / runner / mypy

[mypy] reported by reviewdog 🐶 Skipping analyzing "multiversx_sdk_core": module is installed, but missing library stubs or py.typed marker [import-untyped] Raw Output: /home/runner/work/mx-sdk-py-cli/mx-sdk-py-cli/multiversx_sdk_cli/accounts.py:5:1: error: Skipping analyzing "multiversx_sdk_core": module is installed, but missing library stubs or py.typed marker [import-untyped]
from multiversx_sdk_network_providers.accounts import AccountOnNetwork

Check failure on line 6 in multiversx_sdk_cli/accounts.py

View workflow job for this annotation

GitHub Actions / runner / mypy

[mypy] reported by reviewdog 🐶 Skipping analyzing "multiversx_sdk_network_providers.accounts": module is installed, but missing library stubs or py.typed marker [import-untyped] Raw Output: /home/runner/work/mx-sdk-py-cli/mx-sdk-py-cli/multiversx_sdk_cli/accounts.py:6:1: error: Skipping analyzing "multiversx_sdk_network_providers.accounts": module is installed, but missing library stubs or py.typed marker [import-untyped]
from multiversx_sdk_wallet import UserSigner

from multiversx_sdk_cli.constants import DEFAULT_HRP
Expand Down Expand Up @@ -69,12 +69,12 @@

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 @@
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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 here we do not use MessageV1, correct.


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
@@ -1,6 +1,6 @@
from typing import Dict

from multiversx_sdk_core import Address, MessageV1

Check failure on line 3 in multiversx_sdk_cli/sign_verify.py

View workflow job for this annotation

GitHub Actions / runner / mypy

[mypy] reported by reviewdog 🐶 Skipping analyzing "multiversx_sdk_core": module is installed, but missing library stubs or py.typed marker [import-untyped] Raw Output: /home/runner/work/mx-sdk-py-cli/mx-sdk-py-cli/multiversx_sdk_cli/sign_verify.py:3:1: error: Skipping analyzing "multiversx_sdk_core": module is installed, but missing library stubs or py.typed marker [import-untyped]
from multiversx_sdk_wallet import UserVerifier

from multiversx_sdk_cli.accounts import Account
Expand All @@ -23,7 +23,7 @@
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
3 changes: 2 additions & 1 deletion 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 @@ -27,7 +28,7 @@ dependencies = [
"requests-cache",
"rich==13.3.4",
"multiversx-sdk-network-providers>=0.11.0",
"multiversx-sdk-wallet>=0.7.0",
"multiversx-sdk-wallet>=0.8.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we should protect against breaking changes, and add upper bounds, as well. Perhaps for all our libraries?

In requirements.txt, as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done for our libraries

"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
multiversx-sdk-wallet>=0.8.0
Loading