diff --git a/Cargo.lock b/Cargo.lock index 1a8a720..cc1643d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1028,8 +1028,8 @@ dependencies = [ [[package]] name = "nekoton" -version = "0.13.1" -source = "git+https://github.com/broxus/nekoton.git#9b79453fdf276df45474d858d7789e48d0faaeee" +version = "0.14.0" +source = "git+https://github.com/broxus/nekoton.git#3e5b1cad8c9d03bf999de2323cbfdc392e73da6d" dependencies = [ "anyhow", "async-trait", @@ -1074,8 +1074,8 @@ dependencies = [ [[package]] name = "nekoton-abi" -version = "0.13.0" -source = "git+https://github.com/broxus/nekoton.git#9b79453fdf276df45474d858d7789e48d0faaeee" +version = "0.14.0" +source = "git+https://github.com/broxus/nekoton.git#3e5b1cad8c9d03bf999de2323cbfdc392e73da6d" dependencies = [ "anyhow", "base64 0.13.1", @@ -1101,8 +1101,8 @@ dependencies = [ [[package]] name = "nekoton-contracts" -version = "0.13.0" -source = "git+https://github.com/broxus/nekoton.git#9b79453fdf276df45474d858d7789e48d0faaeee" +version = "0.14.0" +source = "git+https://github.com/broxus/nekoton.git#3e5b1cad8c9d03bf999de2323cbfdc392e73da6d" dependencies = [ "anyhow", "nekoton-abi", @@ -1118,8 +1118,8 @@ dependencies = [ [[package]] name = "nekoton-derive" -version = "0.13.0" -source = "git+https://github.com/broxus/nekoton.git#9b79453fdf276df45474d858d7789e48d0faaeee" +version = "0.14.0" +source = "git+https://github.com/broxus/nekoton.git#3e5b1cad8c9d03bf999de2323cbfdc392e73da6d" dependencies = [ "either", "proc-macro2", @@ -1129,8 +1129,8 @@ dependencies = [ [[package]] name = "nekoton-jetton" -version = "0.13.0" -source = "git+https://github.com/broxus/nekoton.git#9b79453fdf276df45474d858d7789e48d0faaeee" +version = "0.14.0" +source = "git+https://github.com/broxus/nekoton.git#3e5b1cad8c9d03bf999de2323cbfdc392e73da6d" dependencies = [ "anyhow", "lazy_static", @@ -1147,7 +1147,7 @@ dependencies = [ [[package]] name = "nekoton-proto" version = "0.1.0" -source = "git+https://github.com/broxus/nekoton.git#9b79453fdf276df45474d858d7789e48d0faaeee" +source = "git+https://github.com/broxus/nekoton.git#3e5b1cad8c9d03bf999de2323cbfdc392e73da6d" dependencies = [ "anyhow", "nekoton-abi", @@ -1158,7 +1158,7 @@ dependencies = [ [[package]] name = "nekoton-python" -version = "0.1.24" +version = "0.1.25" dependencies = [ "ahash", "anyhow", @@ -1198,8 +1198,8 @@ dependencies = [ [[package]] name = "nekoton-transport" -version = "0.13.0" -source = "git+https://github.com/broxus/nekoton.git#9b79453fdf276df45474d858d7789e48d0faaeee" +version = "0.14.0" +source = "git+https://github.com/broxus/nekoton.git#3e5b1cad8c9d03bf999de2323cbfdc392e73da6d" dependencies = [ "anyhow", "async-trait", @@ -1217,8 +1217,8 @@ dependencies = [ [[package]] name = "nekoton-utils" -version = "0.13.0" -source = "git+https://github.com/broxus/nekoton.git#9b79453fdf276df45474d858d7789e48d0faaeee" +version = "0.14.0" +source = "git+https://github.com/broxus/nekoton.git#3e5b1cad8c9d03bf999de2323cbfdc392e73da6d" dependencies = [ "anyhow", "base64 0.13.1", @@ -2151,7 +2151,7 @@ dependencies = [ [[package]] name = "ton_abi" version = "2.1.0" -source = "git+https://github.com/broxus/ton-labs-abi.git#7d84f87a1799b727e33f9b09c8e38c764fbd5c68" +source = "git+https://github.com/broxus/ton-labs-abi.git#30d7d79e594b4f5c58d8d5d73bf0e5243e456b98" dependencies = [ "anyhow", "base64 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index 4bbd586..9b989b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nekoton-python" -version = "0.1.24" +version = "0.1.25" edition = "2021" [lib] diff --git a/src/abi.rs b/src/abi.rs index ac91be2..07a0427 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -663,6 +663,13 @@ impl FunctionAbi { ) -> PyResult { use nt::abi::FunctionExt; + // Insert answer id if none, just in case the responsible method is called. + for answer_id in ["_answer_id", "answerId"] { + if !input.contains(answer_id)? { + input.set_item(answer_id, 0)?; + } + } + let input = parse_tokens(&self.0.inputs, input)?; let clock = match clock { Some(clock) => clock.as_ref(), diff --git a/tests/configuration.abi.json b/tests/configuration.abi.json new file mode 100644 index 0000000..d0d50b2 --- /dev/null +++ b/tests/configuration.abi.json @@ -0,0 +1,314 @@ +{ + "ABI version": 2, + "version": "2.7", + "header": ["time", "expire"], + "functions": [ + { + "name": "constructor", + "input_id": "0x46725d47", + "externalMsg": false, + "inputs": [ + { "name": "_owner", "type": "address" }, + { "name": "_meta", "type": "cell" }, + { "name": "_flags", "type": "uint64" } + ], + "outputs": [] + }, + { + "name": "getDetails", + "input_id": "0x7736ef05", + "externalMsg": false, + "inputs": [{ "name": "answerId", "type": "uint32" }], + "outputs": [ + { + "name": "_basicConfiguration", + "type": "tuple", + "components": [ + { "name": "eventABI", "type": "bytes" }, + { "name": "staking", "type": "address" }, + { "name": "eventInitialBalance", "type": "uint64" }, + { "name": "eventCode", "type": "cell" } + ] + }, + { + "name": "_networkConfiguration", + "type": "tuple", + "components": [ + { "name": "chainId", "type": "uint32" }, + { "name": "eventEmitter", "type": "uint160" }, + { "name": "eventBlocksToConfirm", "type": "uint16" }, + { "name": "proxy", "type": "address" }, + { "name": "startBlockNumber", "type": "uint32" }, + { "name": "endBlockNumber", "type": "uint32" } + ] + }, + { "name": "_meta", "type": "cell" } + ] + }, + { + "name": "getType", + "input_id": "0x45857ed5", + "externalMsg": false, + "inputs": [{ "name": "answerId", "type": "uint32" }], + "outputs": [{ "name": "_type", "type": "uint8" }] + }, + { + "name": "getFlags", + "input_id": "0x22fd713e", + "externalMsg": false, + "inputs": [{ "name": "answerId", "type": "uint32" }], + "outputs": [{ "name": "_flags", "type": "uint64" }] + }, + { + "name": "getEventAction", + "input_id": "0x721ddfd7", + "externalMsg": false, + "inputs": [{ "name": "answerId", "type": "uint32" }], + "outputs": [{ "name": "_eventAction", "type": "uint8" }] + }, + { + "name": "setMeta", + "input_id": "0x3942f649", + "externalMsg": false, + "inputs": [{ "name": "_meta", "type": "cell" }], + "outputs": [] + }, + { + "name": "setEndBlockNumber", + "input_id": "0x63d4926f", + "externalMsg": false, + "inputs": [{ "name": "endBlockNumber", "type": "uint32" }], + "outputs": [] + }, + { + "name": "setFlags", + "input_id": "0x156c8d8e", + "externalMsg": false, + "inputs": [{ "name": "_flags", "type": "uint64" }], + "outputs": [] + }, + { + "name": "setEventInitialBalance", + "input_id": "0x6c492301", + "externalMsg": false, + "inputs": [{ "name": "eventInitialBalance", "type": "uint64" }], + "outputs": [] + }, + { + "name": "deployEvent", + "input_id": "0x44e882be", + "externalMsg": false, + "inputs": [ + { + "name": "eventVoteData", + "type": "tuple", + "components": [ + { "name": "eventTransaction", "type": "uint256" }, + { "name": "eventIndex", "type": "uint32" }, + { "name": "eventData", "type": "cell" }, + { "name": "eventBlockNumber", "type": "uint32" }, + { "name": "eventBlock", "type": "uint256" } + ] + } + ], + "outputs": [] + }, + { + "name": "deployEvents", + "input_id": "0x7be7e773", + "externalMsg": false, + "inputs": [ + { + "name": "eventsVoteData", + "type": "tuple[]", + "components": [ + { "name": "eventTransaction", "type": "uint256" }, + { "name": "eventIndex", "type": "uint32" }, + { "name": "eventData", "type": "cell" }, + { "name": "eventBlockNumber", "type": "uint32" }, + { "name": "eventBlock", "type": "uint256" } + ] + }, + { "name": "values", "type": "varuint16[]" } + ], + "outputs": [] + }, + { + "name": "deriveEventAddress", + "input_id": "0x0602efa4", + "externalMsg": false, + "inputs": [ + { "name": "answerId", "type": "uint32" }, + { + "name": "eventVoteData", + "type": "tuple", + "components": [ + { "name": "eventTransaction", "type": "uint256" }, + { "name": "eventIndex", "type": "uint32" }, + { "name": "eventData", "type": "cell" }, + { "name": "eventBlockNumber", "type": "uint32" }, + { "name": "eventBlock", "type": "uint256" } + ] + } + ], + "outputs": [{ "name": "eventContract", "type": "address" }] + }, + { + "name": "onEventConfirmed", + "input_id": "0x0088b721", + "externalMsg": false, + "inputs": [ + { + "name": "eventInitData", + "type": "tuple", + "components": [ + { + "name": "voteData", + "type": "tuple", + "components": [ + { "name": "eventTransaction", "type": "uint256" }, + { "name": "eventIndex", "type": "uint32" }, + { "name": "eventData", "type": "cell" }, + { "name": "eventBlockNumber", "type": "uint32" }, + { "name": "eventBlock", "type": "uint256" } + ] + }, + { "name": "configuration", "type": "address" }, + { "name": "staking", "type": "address" }, + { "name": "chainId", "type": "uint32" } + ] + }, + { "name": "gasBackAddress", "type": "address" } + ], + "outputs": [] + }, + { + "name": "onEventConfirmedExtended", + "input_id": "0x0d46d0cf", + "externalMsg": false, + "inputs": [ + { + "name": "eventInitData", + "type": "tuple", + "components": [ + { + "name": "voteData", + "type": "tuple", + "components": [ + { "name": "eventTransaction", "type": "uint256" }, + { "name": "eventIndex", "type": "uint32" }, + { "name": "eventData", "type": "cell" }, + { "name": "eventBlockNumber", "type": "uint32" }, + { "name": "eventBlock", "type": "uint256" } + ] + }, + { "name": "configuration", "type": "address" }, + { "name": "staking", "type": "address" }, + { "name": "chainId", "type": "uint32" } + ] + }, + { "name": "_meta", "type": "cell" }, + { "name": "gasBackAddress", "type": "address" } + ], + "outputs": [] + }, + { + "name": "onEVMEventCancelled", + "input_id": "0x3abbeb9d", + "externalMsg": false, + "inputs": [ + { + "name": "_eventInitData", + "type": "tuple", + "components": [ + { + "name": "voteData", + "type": "tuple", + "components": [ + { "name": "eventTransaction", "type": "uint256" }, + { "name": "eventIndex", "type": "uint32" }, + { "name": "eventData", "type": "cell" }, + { "name": "eventBlockNumber", "type": "uint32" }, + { "name": "eventBlock", "type": "uint256" } + ] + }, + { "name": "configuration", "type": "address" }, + { "name": "staking", "type": "address" }, + { "name": "chainId", "type": "uint32" } + ] + }, + { "name": "_withdrawPayload", "type": "cell" } + ], + "outputs": [] + }, + { + "name": "owner", + "input_id": "0x5f0bcfde", + "output_id": "0xdf0bcfde", + "externalMsg": true, + "inputs": [], + "outputs": [{ "name": "value0", "type": "address" }] + }, + { + "name": "transferOwnership", + "input_id": "0x0e04d29e", + "externalMsg": false, + "inputs": [{ "name": "newOwner", "type": "address" }], + "outputs": [] + }, + { + "name": "renounceOwnership", + "input_id": "0x671538fe", + "externalMsg": false, + "inputs": [], + "outputs": [] + } + ], + "getters": [], + "events": [ + { + "name": "OwnershipTransferred", + "inputs": [ + { "name": "previousOwner", "type": "address" }, + { "name": "newOwner", "type": "address" } + ] + }, + { + "name": "NewEventContract", + "inputs": [{ "name": "eventContract", "type": "address" }] + } + ], + "fields": [ + { "init": true, "name": "_pubkey", "type": "fixedbytes32" }, + { "init": false, "name": "_timestamp", "type": "uint64" }, + { "init": false, "name": "_constructorFlag", "type": "bool" }, + { "init": false, "name": "_owner", "type": "address" }, + { + "init": true, + "name": "basicConfiguration", + "type": "tuple", + "components": [ + { "name": "eventABI", "type": "bytes" }, + { "name": "staking", "type": "address" }, + { "name": "eventInitialBalance", "type": "uint64" }, + { "name": "eventCode", "type": "cell" } + ] + }, + { + "init": true, + "name": "networkConfiguration", + "type": "tuple", + "components": [ + { "name": "chainId", "type": "uint32" }, + { "name": "eventEmitter", "type": "uint160" }, + { "name": "eventBlocksToConfirm", "type": "uint16" }, + { "name": "proxy", "type": "address" }, + { "name": "startBlockNumber", "type": "uint32" }, + { "name": "endBlockNumber", "type": "uint32" } + ] + }, + { "init": true, "name": "eventAction", "type": "uint8" }, + { "init": false, "name": "flags", "type": "uint64" }, + { "init": false, "name": "meta", "type": "cell" } + ] +} diff --git a/tests/new_run_local.py b/tests/new_run_local.py new file mode 100644 index 0000000..2b04032 --- /dev/null +++ b/tests/new_run_local.py @@ -0,0 +1,27 @@ +import asyncio +import os +import nekoton as nt + +dirname = os.path.dirname(__file__) + + +async def main(): + transport = nt.JrpcTransport(endpoint="https://jrpc-new.venom.foundation") + await transport.check_connection() + + config = await transport.get_blockchain_config() + + account = await transport.get_account_state( + nt.Address("0:4bc8cc502bb130d5a64a5a291cbd25399923c652d07f1e5cd446f483fe30de26") + ) + assert account is not None + + configuration_abi = nt.ContractAbi.from_file( + os.path.join(dirname, "configuration.abi.json") + ) + details = configuration_abi.function("getDetails").call(account, {}, config=config) + print(details.output) + + +if __name__ == "__main__": + asyncio.run(main())