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

Merge main into feat/next #465

Merged
merged 102 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
2d6e151
Merge pull request #447 from multiversx/feat/next
popenta Sep 30, 2024
1a6a270
Spica / gateway: upwards & backwards compatibility.
andreibancioiu Oct 10, 2024
2ed0645
Merge pull request #452 from multiversx/spica-proxy
andreibancioiu Oct 11, 2024
c32d328
Added cli validators test in pytest and CI for localnet dependent tests.
cristure Oct 24, 2024
84efeb2
Added fixture for proxy polling.
cristure Oct 24, 2024
1685f02
try different endpoint for polling.
cristure Oct 24, 2024
f4e9c73
adding debug command.
cristure Oct 24, 2024
315e3b0
more debugging.
cristure Oct 24, 2024
39be1b4
make localnet run in background.
cristure Oct 24, 2024
18d6c71
added Dockerfile and integrated CI with docker.
cristure Oct 24, 2024
3f825a2
add checkout.
cristure Oct 24, 2024
99a198d
install python dependencies in order to trigger the tests.
cristure Oct 24, 2024
3d2be36
rename to localhost. possible issue with the loopback interface.
cristure Oct 24, 2024
beef139
debug commands
cristure Oct 24, 2024
95f1a15
more debugging.
cristure Oct 24, 2024
23b9961
add a sleep for debugging.
cristure Oct 24, 2024
ef9cdb2
trying to debug docker publishing in GHA.
cristure Oct 24, 2024
5043947
cosmetic changes
cristure Oct 24, 2024
4953eaa
move sleep above.
cristure Oct 24, 2024
a5ccb03
more debugging.
cristure Oct 24, 2024
7e889f1
increase timeout to 10 mins.
cristure Oct 24, 2024
0af4d95
check logs of docker localnet inside worker.
cristure Oct 24, 2024
05a7e57
fix CI and dockerfile by installing build-essential in the docker con…
cristure Oct 24, 2024
ec17dda
adding verbose command.
cristure Oct 24, 2024
1a4fe12
Fix deploy localnet job.
cristure Oct 25, 2024
900530f
fix whitespaces in multi-line command.
cristure Oct 25, 2024
17a08cf
fixing docker image and localnet setup.
cristure Oct 25, 2024
8359cbb
adding separate validators json file for docker tests.
cristure Oct 25, 2024
b43c31a
fixing Dockerfile
cristure Oct 25, 2024
bbe93e7
fix paths for validators_docker.json
cristure Oct 25, 2024
ad7e421
fix paths in validators_docker.json
cristure Oct 25, 2024
bfe909f
fix validators_docker.json
cristure Oct 25, 2024
83b76aa
fix yaml file.
cristure Oct 25, 2024
8804754
fix yaml file, round 2.
cristure Oct 25, 2024
d3d0d5c
add debug commands.
cristure Oct 25, 2024
9f9b8c0
debug home directory inside runner.
cristure Oct 25, 2024
79392ad
fix paths.
cristure Oct 25, 2024
d3f707d
more debugging.
cristure Oct 25, 2024
adaf45a
fix more paths.
cristure Oct 25, 2024
28fa958
add debug sleep.
cristure Oct 25, 2024
0e46464
cosmetic changes.
cristure Oct 25, 2024
7045c32
fix yaml file.
cristure Oct 25, 2024
d07aa7c
remove relayed v3 related code and tests
popenta Oct 25, 2024
d1f7988
Merge pull request #455 from multiversx/remove-relayed-v3
popenta Oct 29, 2024
a39a121
use newest sdk and add client name
popenta Nov 1, 2024
8cdb2d7
update to latest sdk-py
popenta Nov 1, 2024
2a77e9d
Merge pull request #456 from multiversx/fix-egld-in-multi-transfer
popenta Nov 1, 2024
5f0f807
remove docker
cristure Nov 4, 2024
7a1c8cb
fix mxpy commands in CI.
cristure Nov 4, 2024
6d2888e
cosmetic changes.
cristure Nov 4, 2024
685ca9e
debug strings
cristure Nov 4, 2024
7bdab1a
more debug commands.
cristure Nov 4, 2024
343ba6b
fix CI tests and remove docker naming.
cristure Nov 4, 2024
bf164f6
remove polling.
cristure Nov 4, 2024
e8137fa
cosmetic changes.
cristure Nov 4, 2024
3fb2a0e
fix unused fixture.
cristure Nov 4, 2024
af2c955
remove polling fixture.
cristure Nov 4, 2024
c7d799f
more debugging.
cristure Nov 4, 2024
5a274c4
show log in CI.
cristure Nov 4, 2024
42c1260
more debugging in CI.
cristure Nov 4, 2024
1ba5d85
more debugging in CI.
cristure Nov 4, 2024
25760e9
check logs in CI.
cristure Nov 4, 2024
fe180f0
rewrite setting up commands.
cristure Nov 4, 2024
61bf291
debug.
cristure Nov 4, 2024
4ce863e
more commands.
cristure Nov 4, 2024
380c08b
make nohup run in background.
cristure Nov 4, 2024
58e29a0
debug localnet config.
cristure Nov 4, 2024
31b6563
more debugging paths.
cristure Nov 4, 2024
92e6386
fix paths for ci validator keys file.
cristure Nov 4, 2024
e8c89e1
clean remaining commented code.
cristure Nov 4, 2024
0080690
added conftest and strict markers.
cristure Nov 4, 2024
69404f0
modified skip on windows marker.
cristure Nov 5, 2024
c2adbf2
fix skip_on_windows marker
cristure Nov 5, 2024
1b1a414
fix windows build
cristure Nov 5, 2024
4067411
remove duplicated bash tests and added teardown for localnet tests.
cristure Nov 5, 2024
572725d
Revert "remove duplicated bash tests and added teardown for localnet …
cristure Nov 5, 2024
eb42289
bring back bash tests as they are used in other tests.
cristure Nov 5, 2024
10ffa3c
added teardown for localnet.
cristure Nov 5, 2024
d382db0
clean unused bash tests.
cristure Nov 5, 2024
7ab16ba
remove cli tests for windows.
cristure Nov 6, 2024
ca1d4fd
remove deleted shell scripts.
cristure Nov 6, 2024
8d2ee9a
removed unnecessary shell scripts.
cristure Nov 19, 2024
a3e08ce
relayed v3 implementation
popenta Nov 22, 2024
ccfb060
relay previously saved transaction
popenta Nov 25, 2024
b6751a3
regenerate CLI.md file
popenta Nov 25, 2024
69b6526
add address hrp as a config entry
popenta Nov 29, 2024
7cf6564
reference latest sdk-py
popenta Dec 2, 2024
0ee9036
use default value for hrp argument
popenta Dec 2, 2024
e467c0e
Merge pull request #458 from multiversx/TOOL-379-custom-hrp
popenta Dec 2, 2024
3260310
fix hardcoded address to use config hrp
popenta Dec 3, 2024
7aa66a1
Merge pull request #459 from multiversx/fix-hardcoded-validators-address
popenta Dec 3, 2024
ba26691
Merge branch 'main' into new-relayed-v3
popenta Dec 5, 2024
6f0ae29
add more detailed description
popenta Dec 5, 2024
b080e02
Merge pull request #457 from multiversx/new-relayed-v3
popenta Dec 6, 2024
c0005af
Merge pull request #454 from multiversx/validators_pytest
cristure Dec 20, 2024
6f6c042
Update README.md
andreibancioiu Dec 20, 2024
90a6cac
Merge pull request #460 from multiversx/readme-patch-1
andreibancioiu Dec 20, 2024
c8b7313
set correct options for ledger accounts
popenta Jan 9, 2025
6d8fa48
bump version
popenta Jan 9, 2025
ff6dd67
Merge pull request #461 from multiversx/fix-signing-with-ledger
popenta Jan 15, 2025
f4eff47
call sign-multiple-transactions when cosigning txs using TCS
popenta Jan 21, 2025
3ac2fe2
Merge pull request #463 from multiversx/use-sign-multiple-tcs-endpoint
popenta Jan 21, 2025
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
11 changes: 1 addition & 10 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,4 @@ jobs:
shell: bash
run: |
export PYTHONPATH=.
pytest -m "not skip_on_windows" .
- name: Run CLI tests
shell: bash
run: |
export PROXY=https://testnet-gateway.multiversx.com
export CHAIN_ID=T
cd ./multiversx_sdk_cli/tests
source ./test_cli_tx.sh && testAll || return 1
source ./test_cli_dns.sh && testOffline || return 1
source ./test_cli_validators.sh && testAll || return 1
pytest -m "not skip_on_windows and not require_localnet" .
5 changes: 0 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,3 @@ jobs:
run: |
export PYTHONPATH=.
pytest .
- name: Run CLI tests
run: |
cd ./multiversx_sdk_cli/tests
source ./test_cli_contracts.sh && testAll || return 1
source ./test_cli_dns.sh && testOffline || return 1
55 changes: 55 additions & 0 deletions .github/workflows/test-localnet-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Test localnet-dependent tests

on:
pull_request:
branches: [main, feat/*]
workflow_dispatch:

env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

jobs:
localnet:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.11]

steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip3 install -r requirements.txt
pip3 install -r ./requirements-dev.txt --upgrade

- name: Set up MultiversX localnet
run: |
mkdir -p ~/multiversx-sdk
export PYTHONPATH=.
python3 -m multiversx_sdk_cli.cli localnet prerequisites --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml
python3 -m multiversx_sdk_cli.cli localnet build --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml

# "Go" and artifacts from "GOPATH/pkg/mod" are not needed anymore.
sudo rm -rf ~/multiversx-sdk/golang

python3 -m multiversx_sdk_cli.cli localnet clean --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml
python3 -m multiversx_sdk_cli.cli localnet config --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml
nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml > localnet.log 2>&1 & echo $! > localnet.pid
sleep 120

- name: Test localnet dependent tests
run: |
pytest -m require_localnet .
python3 -m multiversx_sdk_cli.cli localnet clean --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml
357 changes: 223 additions & 134 deletions CLI.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Python Command Line Tools for interacting with Multivers<sup>X</sup>.
[CLI](CLI.md)

## Distribution
[mxpy-up](https://docs.multiversx.com/sdk-and-tools/sdk-py/installing-mxpy/) and [PyPi](https://pypi.org/project/multiversx-sdk-cli/#history)
[pipx](https://docs.multiversx.com/sdk-and-tools/sdk-py/installing-mxpy/) [(PyPi)](https://pypi.org/project/multiversx-sdk-cli/#history)

## Development setup

Expand Down
8 changes: 5 additions & 3 deletions multiversx_sdk_cli/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from pathlib import Path
from typing import Any, Optional, Protocol

from multiversx_sdk import (Address, Message, MessageComputer,

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": 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": module is installed, but missing library stubs or py.typed marker [import-untyped]
TransactionComputer, UserSigner)
from multiversx_sdk.network_providers.accounts import AccountOnNetwork

Check failure on line 7 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:7: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_cli.constants import DEFAULT_HRP
from multiversx_sdk_cli.config import get_address_hrp
from multiversx_sdk_cli.interfaces import IAccount, IAddress, ITransaction
from multiversx_sdk_cli.ledger.config import compare_versions
from multiversx_sdk_cli.ledger.ledger_app_handler import \
Expand Down Expand Up @@ -61,20 +61,20 @@
if pem_file:
pem_path = Path(pem_file).expanduser().resolve()
self.signer = UserSigner.from_pem_file(pem_path, pem_index)
self.address = Address(self.signer.get_pubkey().buffer, DEFAULT_HRP)
self.address = Address(self.signer.get_pubkey().buffer, get_address_hrp())
elif key_file and password:
key_file_path = Path(key_file).expanduser().resolve()
self.signer = UserSigner.from_wallet(key_file_path, password)
self.address = Address(self.signer.get_pubkey().buffer, DEFAULT_HRP)
self.address = Address(self.signer.get_pubkey().buffer, get_address_hrp())

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

transaction_computer = TransactionComputer()
if transaction.options & TX_HASH_SIGN_OPTIONS == TX_HASH_SIGN_OPTIONS:
return self.signer.sign(transaction_computer.compute_hash_for_signing(transaction)).hex()

Check failure on line 75 in multiversx_sdk_cli/accounts.py

View workflow job for this annotation

GitHub Actions / runner / mypy

[mypy] reported by reviewdog 🐶 Returning Any from function declared to return "str" [no-any-return] Raw Output: /home/runner/work/mx-sdk-py-cli/mx-sdk-py-cli/multiversx_sdk_cli/accounts.py:75:13: error: Returning Any from function declared to return "str" [no-any-return]

return self.signer.sign(transaction_computer.compute_bytes_for_signing(transaction)).hex()

Check failure on line 77 in multiversx_sdk_cli/accounts.py

View workflow job for this annotation

GitHub Actions / runner / mypy

[mypy] reported by reviewdog 🐶 Returning Any from function declared to return "str" [no-any-return] Raw Output: /home/runner/work/mx-sdk-py-cli/mx-sdk-py-cli/multiversx_sdk_cli/accounts.py:77:9: error: Returning Any from function declared to return "str" [no-any-return]

def sign_message(self, data: bytes) -> str:
assert self.signer is not None
Expand All @@ -96,6 +96,8 @@
def sign_transaction(self, transaction: ITransaction) -> str:
ledger_version = do_get_ledger_version()
should_use_hash_signing = compare_versions(ledger_version, SIGN_USING_HASH_VERSION) >= 0

# TODO: This check will be removed in the next major release.
if should_use_hash_signing:
transaction.version = TX_HASH_SIGN_VERSION
transaction.options = transaction.options | TX_HASH_SIGN_OPTIONS
Expand Down
3 changes: 3 additions & 0 deletions multiversx_sdk_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Any, List

import argcomplete
from multiversx_sdk import LibraryConfig
from rich.logging import RichHandler

import multiversx_sdk_cli.cli_accounts
Expand Down Expand Up @@ -53,6 +54,8 @@ def _do_main(cli_args: List[str]):
logging.basicConfig(level="INFO", format='%(name)s: %(message)s', handlers=[RichHandler(show_time=False, rich_tracebacks=True)])

verify_deprecated_entries_in_config_file()
default_hrp = config.get_address_hrp()
LibraryConfig.default_address_hrp = default_hrp

if not hasattr(args, "func"):
parser.print_help()
Expand Down
4 changes: 3 additions & 1 deletion multiversx_sdk_cli/cli_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from multiversx_sdk import Address, ProxyNetworkProvider

from multiversx_sdk_cli import cli_shared, utils
from multiversx_sdk_cli.config import get_config_for_network_providers

logger = logging.getLogger("cli.accounts")

Expand Down Expand Up @@ -33,7 +34,8 @@ def _add_address_arg(sub: Any):
def get_account(args: Any):
proxy_url = args.proxy
address = args.address
proxy = ProxyNetworkProvider(proxy_url)
config = get_config_for_network_providers()
proxy = ProxyNetworkProvider(url=proxy_url, config=config)
account = proxy.get_account(Address.new_from_bech32(address))

if args.balance:
Expand Down
16 changes: 6 additions & 10 deletions multiversx_sdk_cli/cli_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from multiversx_sdk_cli import cli_shared, projects, utils
from multiversx_sdk_cli.cli_output import CLIOutputBuilder
from multiversx_sdk_cli.config import get_config_for_network_providers
from multiversx_sdk_cli.constants import NUMBER_OF_SHARDS
from multiversx_sdk_cli.contract_verification import \
trigger_contract_verification
Expand Down Expand Up @@ -100,7 +101,7 @@ def setup_parser(args: List[str], subparsers: Any) -> Any:
cli_shared.add_tx_args(args, sub, with_receiver=False, with_data=False)
_add_function_arg(sub)
_add_arguments_arg(sub)
_add_token_transfers_args(sub)
cli_shared.add_token_transfers_args(sub)
sub.add_argument("--wait-result", action="store_true", default=False,
help="signal to wait for the transaction result - only valid if --send is set")
sub.add_argument("--timeout", default=100, help="max num of seconds to wait for result"
Expand Down Expand Up @@ -243,12 +244,6 @@ def _add_arguments_arg(sub: Any):
"E.g. [{ 'to': 'erd1...', 'amount': 10000000000 }]")


def _add_token_transfers_args(sub: Any):
sub.add_argument("--token-transfers", nargs='+',
help="token transfers for transfer & execute, as [token, amount] "
"E.g. --token-transfers NFT-123456-0a 1 ESDT-987654 100000000")


def _add_metadata_arg(sub: Any):
sub.add_argument("--metadata-not-upgradeable", dest="metadata_upgradeable", action="store_false",
help="‼ mark the contract as NOT upgradeable (default: upgradeable)")
Expand Down Expand Up @@ -448,14 +443,15 @@ def query(args: Any):
args.chain = ""
cli_shared.prepare_chain_id_in_args(args)

config = TransactionsFactoryConfig(args.chain)
factory_config = TransactionsFactoryConfig(args.chain)
abi = Abi.load(Path(args.abi)) if args.abi else None
contract = SmartContract(config, abi)
contract = SmartContract(factory_config, abi)

arguments, should_prepare_args = _get_contract_arguments(args)
contract_address = Address.new_from_bech32(args.contract)

proxy = ProxyNetworkProvider(args.proxy)
network_provider_config = get_config_for_network_providers()
proxy = ProxyNetworkProvider(url=args.proxy, config=network_provider_config)
function = args.function

result = contract.query_contract(
Expand Down
4 changes: 3 additions & 1 deletion multiversx_sdk_cli/cli_delegation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from multiversx_sdk import ProxyNetworkProvider, TransactionsFactoryConfig

from multiversx_sdk_cli import cli_shared, errors, utils
from multiversx_sdk_cli.config import get_config_for_network_providers
from multiversx_sdk_cli.delegation import DelegationOperations


Expand Down Expand Up @@ -209,7 +210,8 @@ def do_create_delegation_contract(args: Any):
def get_contract_address_by_deploy_tx_hash(args: Any):
args = utils.as_object(args)

proxy = ProxyNetworkProvider(args.proxy)
config = get_config_for_network_providers()
proxy = ProxyNetworkProvider(url=args.proxy, config=config)

transaction = proxy.get_transaction(args.create_tx_hash)
transaction_events = transaction.logs.events
Expand Down
21 changes: 14 additions & 7 deletions multiversx_sdk_cli/cli_dns.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from typing import Any, List

from multiversx_sdk import Address, ProxyNetworkProvider
from multiversx_sdk import ProxyNetworkProvider
from prettytable import PrettyTable

from multiversx_sdk_cli import cli_shared
from multiversx_sdk_cli.constants import ADDRESS_ZERO_BECH32
from multiversx_sdk_cli.config import get_config_for_network_providers
from multiversx_sdk_cli.constants import ADDRESS_ZERO_HEX
from multiversx_sdk_cli.dns import (compute_dns_address_for_shard_id,
dns_address_for_name, name_hash, register,
registration_cost, resolve, validate_name,
Expand Down Expand Up @@ -79,14 +80,17 @@ def _ensure_proxy_is_provided(args: Any):
def dns_resolve(args: Any):
_ensure_proxy_is_provided(args)

addr = resolve(args.name, ProxyNetworkProvider(args.proxy))
if addr.to_hex() != Address.new_from_bech32(ADDRESS_ZERO_BECH32).to_hex():
config = get_config_for_network_providers()
addr = resolve(args.name, ProxyNetworkProvider(url=args.proxy, config=config))
if addr.to_hex() != ADDRESS_ZERO_HEX:
print(addr.to_bech32())


def dns_validate_name(args: Any):
_ensure_proxy_is_provided(args)
validate_name(args.name, args.shard_id, ProxyNetworkProvider(args.proxy))

config = get_config_for_network_providers()
validate_name(args.name, args.shard_id, ProxyNetworkProvider(url=args.proxy, config=config))


def get_name_hash(args: Any):
Expand All @@ -107,13 +111,16 @@ def get_dns_address_for_name_hex(args: Any):

def get_registration_cost(args: Any):
_ensure_proxy_is_provided(args)
print(registration_cost(args.shard_id, ProxyNetworkProvider(args.proxy)))

config = get_config_for_network_providers()
print(registration_cost(args.shard_id, ProxyNetworkProvider(url=args.proxy, config=config)))


def get_version(args: Any):
_ensure_proxy_is_provided(args)

proxy = ProxyNetworkProvider(args.proxy)
config = get_config_for_network_providers()
proxy = ProxyNetworkProvider(url=args.proxy, config=config)
if args.all:
t = PrettyTable(['Shard ID', 'Contract address (bech32)', 'Contract address (hex)', 'Version'])
for shard_id in range(0, 256):
Expand Down
Loading
Loading