Skip to content

Commit

Permalink
Merge pull request #259 from multiversx/guardians-fixes
Browse files Browse the repository at this point in the history
Fix contract upgrade
  • Loading branch information
popenta authored May 22, 2023
2 parents f0437fc + c1ce072 commit 475f787
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 2 deletions.
2 changes: 1 addition & 1 deletion multiversx_sdk_cli/cli_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def upgrade(args: Any):
contract.address = Address(contract_address)
sender = _prepare_sender(args)

tx = contract.upgrade(sender, arguments, gas_price, gas_limit, value, chain, version, args.guardian_address, args.options)
tx = contract.upgrade(sender, arguments, gas_price, gas_limit, value, chain, version, args.guardian, args.options)

if args.guardian:
tx = cosign_transaction(tx, args.guardian_service_url, args.guardian_2fa_code)
Expand Down
90 changes: 90 additions & 0 deletions multiversx_sdk_cli/tests/test_cli_contracts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
from pathlib import Path
from multiversx_sdk_cli.cli import main


def test_contract_deploy():
parent = Path(__file__).parent
output_file = parent / "testdata-out" / "deploy.json"

main(
[
"contract",
"deploy",
"--bytecode",
f"{parent}/testdata/adder.wasm",
"--pem",
f"{parent}/testdata/testUser.pem",
"--proxy",
"https://testnet-api.multiversx.com",
"--chain",
"T",
"--recall-nonce",
"--gas-limit",
"5000000",
"--arguments",
"0",
"--outfile",
str(output_file),
]
)
assert Path.is_file(output_file) == True


def test_contract_upgrade():
parent = Path(__file__).parent
output_file = parent / "testdata-out" / "upgrade.json"
contract_address = "erd1qqqqqqqqqqqqqpgq5l9jl0j0gnqmm7hn82zaydwux3s5xuwkyq8srt5vsy"

main(
[
"contract",
"upgrade",
contract_address,
"--bytecode",
f"{parent}/testdata/adder.wasm",
"--pem",
f"{parent}/testdata/testUser.pem",
"--proxy",
"https://testnet-api.multiversx.com",
"--chain",
"T",
"--recall-nonce",
"--gas-limit",
"5000000",
"--arguments",
"0",
"--outfile",
str(output_file),
]
)
assert Path.is_file(output_file) == True


def test_contract_call():
parent = Path(__file__).parent
output_file = parent / "testdata-out" / "call.json"
contract_address = "erd1qqqqqqqqqqqqqpgq5l9jl0j0gnqmm7hn82zaydwux3s5xuwkyq8srt5vsy"

main(
[
"contract",
"call",
contract_address,
"--function",
"add",
"--pem",
f"{parent}/testdata/testUser.pem",
"--proxy",
"https://testnet-api.multiversx.com",
"--chain",
"T",
"--recall-nonce",
"--gas-limit",
"5000000",
"--arguments",
"5",
"--outfile",
str(output_file),
]
)
assert Path.is_file(output_file) == True
Binary file added multiversx_sdk_cli/tests/testdata/adder.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "multiversx-sdk-cli"
version = "6.2.0"
version = "6.2.1"
authors = [
{ name="MultiversX" },
]
Expand Down

0 comments on commit 475f787

Please sign in to comment.