Skip to content

Commit

Permalink
Merge pull request #106 from multiversx/hotfix-11
Browse files Browse the repository at this point in the history
Handle "null" values on event fields (they happen sometimes)
  • Loading branch information
andreibancioiu authored Oct 14, 2024
2 parents 4b77938 + 4f3c1b9 commit 205adfb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions multiversx_sdk/abi/abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ def _create_prototype(self, type_formula: TypeFormula) -> Any:
return I16Value()
if name == "i32":
return I32Value()
if name == "i64":
return I64Value()
if name == "BigUint":
return BigUIntValue()
if name == "BigInt":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,21 @@ def test_parse_esdt_safe_deposit_event_without_first_topic():

@pytest.mark.networkInteraction
def test_multisig_start_perform_action():
api = ApiNetworkProvider("https://testnet-api.multiversx.com")
api = ApiNetworkProvider("https://devnet-api.multiversx.com")
converter = TransactionsConverter()

transaction_on_network = api.get_transaction("6e893154a3100a3a1ca3cf7ab52a66bb7dab81d2f288943e27cac71a5c437b19")
# Test was set up as follows:
# Deploy multisig
# mxpy contract deploy --bytecode=./multisig-full.wasm --gas-limit=100000000 --recall-nonce --arguments 2 erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx --proxy=https://devnet-gateway.multiversx.com --pem=erd1test.pem --send
# Call "proposeTransferExecute"
# mxpy contract call erd1qqqqqqqqqqqqqpgqnquyu4atwjz89p8vd8k0k7sz5qaeyfj2396qmek84v --function proposeTransferExecute --gas-limit=20000000 --recall-nonce --arguments erd1r69gk66fmedhhcg24g2c5kn2f2a5k4kvpr6jfw67dn2lyydd8cfswy6ede 1000000000000000000 0x00 --proxy=https://devnet-gateway.multiversx.com --pem=alice.pem --send
# Call "sign"
# mxpy contract call erd1qqqqqqqqqqqqqpgqnquyu4atwjz89p8vd8k0k7sz5qaeyfj2396qmek84v --function sign --gas-limit=20000000 --recall-nonce --arguments 1 --proxy=https://devnet-gateway.multiversx.com --pem=bob.pem --send
# Call "deposit"
# mxpy contract call erd1qqqqqqqqqqqqqpgqnquyu4atwjz89p8vd8k0k7sz5qaeyfj2396qmek84v --function deposit --gas-limit=20000000 --recall-nonce --value 1000000000000000000 --proxy=https://devnet-gateway.multiversx.com --pem=alice.pem --send
# Call "performAction"
# mxpy contract call erd1qqqqqqqqqqqqqpgqnquyu4atwjz89p8vd8k0k7sz5qaeyfj2396qmek84v --function performAction --gas-limit=20000000 --recall-nonce --arguments 1 --proxy=https://devnet-gateway.multiversx.com --pem=alice.pem --send
transaction_on_network = api.get_transaction("6651b983d494d69d94ce3efb3ae1604480af7c17780ab58daa09a9e5cc1d86c8")
transaction_outcome = converter.transaction_on_network_to_outcome(transaction_on_network)

abi = Abi.load(testdata / "multisig-full.abi.json")
Expand All @@ -251,6 +262,6 @@ def test_multisig_start_perform_action():
'__discriminant__': 5
},
),
signers=[Address.new_from_bech32("erd1uwef0vsxup3p84fmg3szjs0ae3d9qx0sn5eqe5ayerlgk34cczpsqm2nrl").get_public_key(),
Address.new_from_bech32("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th").get_public_key()]
signers=[Address.new_from_bech32("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th").get_public_key(),
Address.new_from_bech32("erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx").get_public_key()]
)
4 changes: 2 additions & 2 deletions multiversx_sdk/network_providers/transaction_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ def from_http_response(response: Dict[str, Any]) -> 'TransactionEvent':
result.address = Address.new_from_bech32(address) if address else EmptyAddress()

result.identifier = response.get('identifier', '')
topics = response.get('topics', [])
topics = response.get('topics') or []
result.topics = [TransactionEventTopic(item) for item in topics]

raw_data = base64.b64decode(response.get('responseData', b''))
result.data_payload = TransactionEventData(raw_data)
result.data = raw_data.decode()

additional_data: Any = response.get("additionalData", [])
additional_data: Any = response.get("additionalData") or []
if additional_data is None:
additional_data = []
result.additional_data = [TransactionEventData(base64.b64decode(data)) for data in additional_data]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ allow-direct-references = true

[project]
name = "multiversx-sdk"
version = "0.13.1"
version = "0.13.2"
authors = [
{ name="MultiversX" },
]
Expand Down

0 comments on commit 205adfb

Please sign in to comment.