From 8d28624706b95e04eec4fbdab9b96c88a98bd673 Mon Sep 17 00:00:00 2001 From: janniksam Date: Sun, 21 Jan 2024 15:15:52 +0100 Subject: [PATCH 1/3] impl --- xsuite/abis/adder.abi.json | 76 ++ xsuite/abis/bonding-curve-contract.abi.json | 309 +++++ xsuite/abis/check-pause.abi.json | 63 + xsuite/abis/crowdfunding-esdt.abi.json | 140 +++ xsuite/abis/crypto-bubbles.abi.json | 195 ++++ xsuite/abis/crypto-zombies.abi.json | 295 +++++ xsuite/abis/digital-cash.abi.json | 216 ++++ xsuite/abis/empty.abi.json | 31 + xsuite/abis/esdt-transfer-with-fee.abi.json | 159 +++ xsuite/abis/factorial.abi.json | 50 + xsuite/abis/fractional-nfts.abi.json | 90 ++ xsuite/abis/kitty-auction.abi.json | 229 ++++ xsuite/abis/kitty-genetic-alg.abi.json | 120 ++ xsuite/abis/kitty-ownership.abi.json | 456 ++++++++ xsuite/abis/liquid-locking.abi.json | 270 +++++ xsuite/abis/lottery-esdt.abi.json | 239 ++++ xsuite/abis/multisig-full.abi.json | 1010 +++++++++++++++++ xsuite/abis/multisig-view.abi.json | 611 ++++++++++ xsuite/abis/multisig.abi.json | 840 ++++++++++++++ .../multiversx-price-aggregator-sc.abi.json | 412 +++++++ xsuite/abis/multiversx-wegld-swap-sc.abi.json | 118 ++ xsuite/abis/mvx-game-sc.abi.json | 338 ++++++ xsuite/abis/mystery-box.abi.json | 302 +++++ xsuite/abis/nft-escrow.abi.json | 189 +++ xsuite/abis/nft-minter.abi.json | 140 +++ xsuite/abis/nft-storage-prepay.abi.json | 128 +++ xsuite/abis/order-book-factory.abi.json | 78 ++ xsuite/abis/order-book-pair.abi.json | 408 +++++++ xsuite/abis/paymaster.abi.json | 56 + xsuite/abis/ping-pong-egld.abi.json | 247 ++++ xsuite/abis/proxy-pause.abi.json | 111 ++ xsuite/abis/rewards-distribution.abi.json | 267 +++++ xsuite/abis/seed-nft-minter.abi.json | 201 ++++ xsuite/abis/token-release.abi.json | 220 ++++ xsuite/build_wasms.sh | 9 + xsuite/contracts/.gitignore | 1 + xsuite/contracts/datatypes/Cargo.toml | 8 + xsuite/contracts/datatypes/meta/Cargo.toml | 11 + xsuite/contracts/datatypes/meta/src/main.rs | 3 + xsuite/contracts/datatypes/multiversx.json | 3 + .../datatypes/output/datatypes.abi.json | 488 ++++++++ .../contracts/datatypes/output/datatypes.wasm | Bin 0 -> 11950 bytes xsuite/contracts/datatypes/src/lib.rs | 224 ++++ .../datatypes/src/types/data_types.rs | 76 ++ xsuite/contracts/datatypes/src/types/mod.rs | 1 + xsuite/contracts/datatypes/wasm/Cargo.lock | 258 +++++ xsuite/contracts/datatypes/wasm/Cargo.toml | 30 + xsuite/contracts/datatypes/wasm/src/lib.rs | 29 + xsuite/src/cli/cmd.test.ts | 1 + xsuite/src/cli/cmd.ts | 2 + xsuite/src/cli/generateproxy/decoders.ts | 126 ++ xsuite/src/cli/generateproxy/encoders.ts | 123 ++ xsuite/src/cli/generateproxy/endpoints.ts | 74 ++ .../cli/generateproxy/generateproxy.test.ts | 298 +++++ xsuite/src/cli/generateproxy/generateproxy.ts | 43 + xsuite/src/cli/generateproxy/types.ts | 119 ++ xsuite/src/cli/generateproxy/utils.test.ts | 21 + xsuite/src/cli/generateproxy/utils.ts | 26 + 58 files changed, 10588 insertions(+) create mode 100644 xsuite/abis/adder.abi.json create mode 100644 xsuite/abis/bonding-curve-contract.abi.json create mode 100644 xsuite/abis/check-pause.abi.json create mode 100644 xsuite/abis/crowdfunding-esdt.abi.json create mode 100644 xsuite/abis/crypto-bubbles.abi.json create mode 100644 xsuite/abis/crypto-zombies.abi.json create mode 100644 xsuite/abis/digital-cash.abi.json create mode 100644 xsuite/abis/empty.abi.json create mode 100644 xsuite/abis/esdt-transfer-with-fee.abi.json create mode 100644 xsuite/abis/factorial.abi.json create mode 100644 xsuite/abis/fractional-nfts.abi.json create mode 100644 xsuite/abis/kitty-auction.abi.json create mode 100644 xsuite/abis/kitty-genetic-alg.abi.json create mode 100644 xsuite/abis/kitty-ownership.abi.json create mode 100644 xsuite/abis/liquid-locking.abi.json create mode 100644 xsuite/abis/lottery-esdt.abi.json create mode 100644 xsuite/abis/multisig-full.abi.json create mode 100644 xsuite/abis/multisig-view.abi.json create mode 100644 xsuite/abis/multisig.abi.json create mode 100644 xsuite/abis/multiversx-price-aggregator-sc.abi.json create mode 100644 xsuite/abis/multiversx-wegld-swap-sc.abi.json create mode 100644 xsuite/abis/mvx-game-sc.abi.json create mode 100644 xsuite/abis/mystery-box.abi.json create mode 100644 xsuite/abis/nft-escrow.abi.json create mode 100644 xsuite/abis/nft-minter.abi.json create mode 100644 xsuite/abis/nft-storage-prepay.abi.json create mode 100644 xsuite/abis/order-book-factory.abi.json create mode 100644 xsuite/abis/order-book-pair.abi.json create mode 100644 xsuite/abis/paymaster.abi.json create mode 100644 xsuite/abis/ping-pong-egld.abi.json create mode 100644 xsuite/abis/proxy-pause.abi.json create mode 100644 xsuite/abis/rewards-distribution.abi.json create mode 100644 xsuite/abis/seed-nft-minter.abi.json create mode 100644 xsuite/abis/token-release.abi.json create mode 100644 xsuite/contracts/datatypes/Cargo.toml create mode 100644 xsuite/contracts/datatypes/meta/Cargo.toml create mode 100644 xsuite/contracts/datatypes/meta/src/main.rs create mode 100644 xsuite/contracts/datatypes/multiversx.json create mode 100644 xsuite/contracts/datatypes/output/datatypes.abi.json create mode 100755 xsuite/contracts/datatypes/output/datatypes.wasm create mode 100644 xsuite/contracts/datatypes/src/lib.rs create mode 100644 xsuite/contracts/datatypes/src/types/data_types.rs create mode 100644 xsuite/contracts/datatypes/src/types/mod.rs create mode 100644 xsuite/contracts/datatypes/wasm/Cargo.lock create mode 100644 xsuite/contracts/datatypes/wasm/Cargo.toml create mode 100644 xsuite/contracts/datatypes/wasm/src/lib.rs create mode 100644 xsuite/src/cli/generateproxy/decoders.ts create mode 100644 xsuite/src/cli/generateproxy/encoders.ts create mode 100644 xsuite/src/cli/generateproxy/endpoints.ts create mode 100644 xsuite/src/cli/generateproxy/generateproxy.test.ts create mode 100644 xsuite/src/cli/generateproxy/generateproxy.ts create mode 100644 xsuite/src/cli/generateproxy/types.ts create mode 100644 xsuite/src/cli/generateproxy/utils.test.ts create mode 100644 xsuite/src/cli/generateproxy/utils.ts diff --git a/xsuite/abis/adder.abi.json b/xsuite/abis/adder.abi.json new file mode 100644 index 00000000..5c1f5011 --- /dev/null +++ b/xsuite/abis/adder.abi.json @@ -0,0 +1,76 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "adder", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "docs": [ + "One of the simplest smart contracts possible,", + "it holds a single variable in storage, which anyone can increment." + ], + "name": "Adder", + "constructor": { + "inputs": [ + { + "name": "initial_value", + "type": "BigUint" + } + ], + "outputs": [] + }, + "endpoints": [ + { + "name": "getSum", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "upgrade", + "mutability": "mutable", + "inputs": [ + { + "name": "new_value", + "type": "BigUint" + } + ], + "outputs": [] + }, + { + "docs": [ + "Add desired amount to the storage variable." + ], + "name": "add", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [ + { + "name": "value", + "type": "BigUint" + } + ], + "outputs": [] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": {} +} diff --git a/xsuite/abis/bonding-curve-contract.abi.json b/xsuite/abis/bonding-curve-contract.abi.json new file mode 100644 index 00000000..96f48f9d --- /dev/null +++ b/xsuite/abis/bonding-curve-contract.abi.json @@ -0,0 +1,309 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "bonding-curve-contract", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "Contract", + "constructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "sellToken", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [], + "outputs": [] + }, + { + "name": "buyToken", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [ + { + "name": "requested_amount", + "type": "BigUint" + }, + { + "name": "requested_token", + "type": "TokenIdentifier" + }, + { + "name": "requested_nonce", + "type": "optional", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "deposit", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [ + { + "name": "payment_token", + "type": "optional", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "setBondingCurve", + "mutability": "mutable", + "inputs": [ + { + "name": "identifier", + "type": "TokenIdentifier" + }, + { + "name": "function", + "type": "FunctionSelector" + }, + { + "name": "sell_availability", + "type": "bool" + } + ], + "outputs": [] + }, + { + "name": "claim", + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "view_buy_price", + "mutability": "readonly", + "inputs": [ + { + "name": "amount", + "type": "BigUint" + }, + { + "name": "identifier", + "type": "TokenIdentifier" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "view_sell_price", + "mutability": "readonly", + "inputs": [ + { + "name": "amount", + "type": "BigUint" + }, + { + "name": "identifier", + "type": "TokenIdentifier" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "getTokenAvailability", + "mutability": "readonly", + "inputs": [ + { + "name": "identifier", + "type": "TokenIdentifier" + } + ], + "outputs": [ + { + "type": "variadic>", + "multi_result": true + } + ] + }, + { + "name": "setLocalRoles", + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + }, + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "roles", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "unsetLocalRoles", + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + }, + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "roles", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [] + } + ], + "events": [ + { + "identifier": "buy-token", + "inputs": [ + { + "name": "user", + "type": "Address", + "indexed": true + }, + { + "name": "amount", + "type": "BigUint" + } + ] + }, + { + "identifier": "sell-token", + "inputs": [ + { + "name": "user", + "type": "Address", + "indexed": true + }, + { + "name": "amount", + "type": "BigUint" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "EsdtLocalRole": { + "type": "enum", + "variants": [ + { + "name": "None", + "discriminant": 0 + }, + { + "name": "Mint", + "discriminant": 1 + }, + { + "name": "Burn", + "discriminant": 2 + }, + { + "name": "NftCreate", + "discriminant": 3 + }, + { + "name": "NftAddQuantity", + "discriminant": 4 + }, + { + "name": "NftBurn", + "discriminant": 5 + }, + { + "name": "NftAddUri", + "discriminant": 6 + }, + { + "name": "NftUpdateAttributes", + "discriminant": 7 + }, + { + "name": "Transfer", + "discriminant": 8 + } + ] + }, + "FunctionSelector": { + "type": "enum", + "variants": [ + { + "name": "Linear", + "discriminant": 0, + "fields": [ + { + "name": "0", + "type": "LinearFunction" + } + ] + }, + { + "name": "CustomExample", + "discriminant": 1, + "fields": [ + { + "name": "0", + "type": "BigUint" + } + ] + }, + { + "name": "None", + "discriminant": 2 + } + ] + }, + "LinearFunction": { + "type": "struct", + "fields": [ + { + "name": "initial_price", + "type": "BigUint" + }, + { + "name": "linear_coefficient", + "type": "BigUint" + } + ] + } + } +} diff --git a/xsuite/abis/check-pause.abi.json b/xsuite/abis/check-pause.abi.json new file mode 100644 index 00000000..77b03e0c --- /dev/null +++ b/xsuite/abis/check-pause.abi.json @@ -0,0 +1,63 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "check-pause", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "CheckPauseContract", + "constructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "checkPause", + "mutability": "mutable", + "inputs": [], + "outputs": [ + { + "type": "bool" + } + ] + }, + { + "name": "pause", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "unpause", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "isPaused", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "bool" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": {} +} diff --git a/xsuite/abis/crowdfunding-esdt.abi.json b/xsuite/abis/crowdfunding-esdt.abi.json new file mode 100644 index 00000000..1d4a773a --- /dev/null +++ b/xsuite/abis/crowdfunding-esdt.abi.json @@ -0,0 +1,140 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "crowdfunding-esdt", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "Crowdfunding", + "constructor": { + "inputs": [ + { + "name": "target", + "type": "BigUint" + }, + { + "name": "deadline", + "type": "u64" + }, + { + "name": "token_identifier", + "type": "EgldOrEsdtTokenIdentifier" + } + ], + "outputs": [] + }, + "endpoints": [ + { + "name": "fund", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [], + "outputs": [] + }, + { + "name": "status", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "Status" + } + ] + }, + { + "name": "getCurrentFunds", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "claim", + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "getTarget", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "getDeadline", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "name": "getDeposit", + "mutability": "readonly", + "inputs": [ + { + "name": "donor", + "type": "Address" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "getCrowdfundingTokenIdentifier", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "EgldOrEsdtTokenIdentifier" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "Status": { + "type": "enum", + "variants": [ + { + "name": "FundingPeriod", + "discriminant": 0 + }, + { + "name": "Successful", + "discriminant": 1 + }, + { + "name": "Failed", + "discriminant": 2 + } + ] + } + } +} diff --git a/xsuite/abis/crypto-bubbles.abi.json b/xsuite/abis/crypto-bubbles.abi.json new file mode 100644 index 00000000..3679c773 --- /dev/null +++ b/xsuite/abis/crypto-bubbles.abi.json @@ -0,0 +1,195 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "crypto-bubbles", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "CryptoBubbles", + "constructor": { + "docs": [ + "constructor function", + "is called immediately after the contract is created" + ], + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "docs": [ + "player adds funds" + ], + "name": "topUp", + "mutability": "mutable", + "payableInTokens": [ + "EGLD" + ], + "inputs": [], + "outputs": [] + }, + { + "docs": [ + "player withdraws funds" + ], + "name": "withdraw", + "mutability": "mutable", + "inputs": [ + { + "name": "amount", + "type": "BigUint" + } + ], + "outputs": [] + }, + { + "name": "joinGame", + "mutability": "mutable", + "payableInTokens": [ + "EGLD" + ], + "inputs": [ + { + "name": "game_index", + "type": "BigUint" + } + ], + "outputs": [] + }, + { + "name": "rewardWinner", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "game_index", + "type": "BigUint" + }, + { + "name": "winner", + "type": "Address" + }, + { + "name": "prize", + "type": "BigUint" + } + ], + "outputs": [] + }, + { + "name": "rewardAndSendToWallet", + "mutability": "mutable", + "inputs": [ + { + "name": "game_index", + "type": "BigUint" + }, + { + "name": "winner", + "type": "Address" + }, + { + "name": "prize", + "type": "BigUint" + } + ], + "outputs": [] + }, + { + "name": "balanceOf", + "mutability": "readonly", + "inputs": [ + { + "name": "player", + "type": "Address" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + } + ], + "events": [ + { + "identifier": "top_up", + "inputs": [ + { + "name": "player", + "type": "Address", + "indexed": true + }, + { + "name": "amount", + "type": "BigUint" + } + ] + }, + { + "identifier": "withdraw", + "inputs": [ + { + "name": "player", + "type": "Address", + "indexed": true + }, + { + "name": "amount", + "type": "BigUint" + } + ] + }, + { + "identifier": "player_joins_game", + "inputs": [ + { + "name": "game_index", + "type": "BigUint", + "indexed": true + }, + { + "name": "player", + "type": "Address", + "indexed": true + }, + { + "name": "bet", + "type": "BigUint" + } + ] + }, + { + "identifier": "reward_winner", + "inputs": [ + { + "name": "game_index", + "type": "BigUint", + "indexed": true + }, + { + "name": "winner", + "type": "Address", + "indexed": true + }, + { + "name": "prize", + "type": "BigUint" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": {} +} diff --git a/xsuite/abis/crypto-zombies.abi.json b/xsuite/abis/crypto-zombies.abi.json new file mode 100644 index 00000000..6ab4d02e --- /dev/null +++ b/xsuite/abis/crypto-zombies.abi.json @@ -0,0 +1,295 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "crypto-zombies", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "CryptoZombies", + "constructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "set_crypto_kitties_sc_address", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "generate_random_dna", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "name": "create_random_zombie", + "mutability": "mutable", + "inputs": [ + { + "name": "name", + "type": "bytes" + } + ], + "outputs": [] + }, + { + "name": "is_ready", + "mutability": "readonly", + "inputs": [ + { + "name": "zombie_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "bool" + } + ] + }, + { + "name": "feed_on_kitty", + "mutability": "mutable", + "inputs": [ + { + "name": "zombie_id", + "type": "u32" + }, + { + "name": "kitty_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "name": "dna_digits", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u8" + } + ] + }, + { + "name": "zombies_count", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "name": "zombies", + "mutability": "readonly", + "inputs": [ + { + "name": "id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "Zombie" + } + ] + }, + { + "name": "zombie_owner", + "mutability": "readonly", + "inputs": [ + { + "name": "id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "Address" + } + ] + }, + { + "name": "crypto_kitties_sc_address", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "Address" + } + ] + }, + { + "name": "cooldown_time", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "name": "owned_zombies", + "mutability": "readonly", + "inputs": [ + { + "name": "owner", + "type": "Address" + } + ], + "outputs": [ + { + "type": "variadic", + "multi_result": true + } + ] + }, + { + "name": "level_up", + "mutability": "mutable", + "payableInTokens": [ + "EGLD" + ], + "inputs": [ + { + "name": "zombie_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "name": "withdraw", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "change_name", + "mutability": "mutable", + "inputs": [ + { + "name": "zombie_id", + "type": "u32" + }, + { + "name": "name", + "type": "bytes" + } + ], + "outputs": [] + }, + { + "name": "change_dna", + "mutability": "mutable", + "inputs": [ + { + "name": "zombie_id", + "type": "u32" + }, + { + "name": "dna", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "attack", + "mutability": "mutable", + "inputs": [ + { + "name": "zombie_id", + "type": "u32" + }, + { + "name": "target_id", + "type": "u32" + } + ], + "outputs": [] + } + ], + "events": [ + { + "identifier": "new_zombie_event", + "inputs": [ + { + "name": "zombie_id", + "type": "u32", + "indexed": true + }, + { + "name": "name", + "type": "bytes" + }, + { + "name": "dna", + "type": "u64", + "indexed": true + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": true, + "types": { + "Zombie": { + "type": "struct", + "fields": [ + { + "name": "name", + "type": "bytes" + }, + { + "name": "dna", + "type": "u64" + }, + { + "name": "level", + "type": "u16" + }, + { + "name": "ready_time", + "type": "u64" + }, + { + "name": "win_count", + "type": "u32" + }, + { + "name": "loss_count", + "type": "u32" + } + ] + } + } +} diff --git a/xsuite/abis/digital-cash.abi.json b/xsuite/abis/digital-cash.abi.json new file mode 100644 index 00000000..f77d73d9 --- /dev/null +++ b/xsuite/abis/digital-cash.abi.json @@ -0,0 +1,216 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "digital-cash", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "DigitalCash", + "constructor": { + "inputs": [ + { + "name": "fee", + "type": "BigUint" + } + ], + "outputs": [] + }, + "endpoints": [ + { + "name": "fund", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [ + { + "name": "address", + "type": "Address" + }, + { + "name": "valability", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "withdraw", + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "claim", + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + }, + { + "name": "signature", + "type": "array64" + } + ], + "outputs": [] + }, + { + "name": "claimFees", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "depositFees", + "mutability": "mutable", + "payableInTokens": [ + "EGLD" + ], + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "forward", + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + }, + { + "name": "forward_address", + "type": "Address" + }, + { + "name": "signature", + "type": "array64" + } + ], + "outputs": [] + }, + { + "name": "getAmount", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + }, + { + "name": "token", + "type": "EgldOrEsdtTokenIdentifier" + }, + { + "name": "nonce", + "type": "u64" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "deposit", + "mutability": "readonly", + "inputs": [ + { + "name": "donor", + "type": "Address" + } + ], + "outputs": [ + { + "type": "DepositInfo" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "DepositInfo": { + "type": "struct", + "fields": [ + { + "name": "depositor_address", + "type": "Address" + }, + { + "name": "esdt_funds", + "type": "List" + }, + { + "name": "egld_funds", + "type": "BigUint" + }, + { + "name": "valability", + "type": "u64" + }, + { + "name": "expiration_round", + "type": "u64" + }, + { + "name": "fees", + "type": "Fee" + } + ] + }, + "EsdtTokenPayment": { + "type": "struct", + "fields": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "token_nonce", + "type": "u64" + }, + { + "name": "amount", + "type": "BigUint" + } + ] + }, + "Fee": { + "type": "struct", + "fields": [ + { + "name": "num_token_to_transfer", + "type": "u32" + }, + { + "name": "value", + "type": "BigUint" + } + ] + } + } +} diff --git a/xsuite/abis/empty.abi.json b/xsuite/abis/empty.abi.json new file mode 100644 index 00000000..2f8a0e16 --- /dev/null +++ b/xsuite/abis/empty.abi.json @@ -0,0 +1,31 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "empty", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "docs": [ + "An empty contract. To be used as a template when starting a new contract from scratch." + ], + "name": "EmptyContract", + "constructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [], + "esdtAttributes": [], + "hasCallback": false, + "types": {} +} diff --git a/xsuite/abis/esdt-transfer-with-fee.abi.json b/xsuite/abis/esdt-transfer-with-fee.abi.json new file mode 100644 index 00000000..c00032dd --- /dev/null +++ b/xsuite/abis/esdt-transfer-with-fee.abi.json @@ -0,0 +1,159 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "esdt-transfer-with-fee", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "EsdtTransferWithFee", + "constructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "setExactValueFee", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "fee_token", + "type": "TokenIdentifier" + }, + { + "name": "fee_amount", + "type": "BigUint" + }, + { + "name": "token", + "type": "TokenIdentifier" + } + ], + "outputs": [] + }, + { + "name": "setPercentageFee", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "fee", + "type": "u32" + }, + { + "name": "token", + "type": "TokenIdentifier" + } + ], + "outputs": [] + }, + { + "name": "claimFees", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "transfer", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "getTokenFee", + "mutability": "readonly", + "inputs": [ + { + "name": "token", + "type": "TokenIdentifier" + } + ], + "outputs": [ + { + "type": "Fee" + } + ] + }, + { + "name": "getPaidFees", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic,BigUint>>", + "multi_result": true + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "EsdtTokenPayment": { + "type": "struct", + "fields": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "token_nonce", + "type": "u64" + }, + { + "name": "amount", + "type": "BigUint" + } + ] + }, + "Fee": { + "type": "enum", + "variants": [ + { + "name": "Unset", + "discriminant": 0 + }, + { + "name": "ExactValue", + "discriminant": 1, + "fields": [ + { + "name": "0", + "type": "EsdtTokenPayment" + } + ] + }, + { + "name": "Percentage", + "discriminant": 2, + "fields": [ + { + "name": "0", + "type": "u32" + } + ] + } + ] + } + } +} diff --git a/xsuite/abis/factorial.abi.json b/xsuite/abis/factorial.abi.json new file mode 100644 index 00000000..a5d36067 --- /dev/null +++ b/xsuite/abis/factorial.abi.json @@ -0,0 +1,50 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "factorial", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "Factorial", + "constructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "upgrade", + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "factorial", + "mutability": "mutable", + "inputs": [ + { + "name": "value", + "type": "BigUint" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": {} +} diff --git a/xsuite/abis/fractional-nfts.abi.json b/xsuite/abis/fractional-nfts.abi.json new file mode 100644 index 00000000..0a9e8ba4 --- /dev/null +++ b/xsuite/abis/fractional-nfts.abi.json @@ -0,0 +1,90 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "fractional-nfts", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "FractionalNfts", + "constructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "claimRoyaltiesFromMarketplace", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "marketplace_address", + "type": "Address" + }, + { + "name": "token_id", + "type": "TokenIdentifier" + }, + { + "name": "token_nonce", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "fractionalizeNFT", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [ + { + "name": "initial_fractional_amount", + "type": "BigUint" + }, + { + "name": "name", + "type": "bytes" + }, + { + "name": "attributes", + "type": "bytes" + } + ], + "outputs": [] + }, + { + "name": "unFractionalizeNFT", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [], + "outputs": [] + }, + { + "name": "getFractionalToken", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "TokenIdentifier" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": true, + "types": {} +} diff --git a/xsuite/abis/kitty-auction.abi.json b/xsuite/abis/kitty-auction.abi.json new file mode 100644 index 00000000..e4e087be --- /dev/null +++ b/xsuite/abis/kitty-auction.abi.json @@ -0,0 +1,229 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "kitty-auction", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "KittyAuction", + "constructor": { + "inputs": [ + { + "name": "gen_zero_kitty_starting_price", + "type": "BigUint" + }, + { + "name": "gen_zero_kitty_ending_price", + "type": "BigUint" + }, + { + "name": "gen_zero_kitty_auction_duration", + "type": "u64" + }, + { + "name": "opt_kitty_ownership_contract_address", + "type": "optional
", + "multi_arg": true + } + ], + "outputs": [] + }, + "endpoints": [ + { + "name": "setKittyOwnershipContractAddress", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "createAndAuctionGenZeroKitty", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "isUpForAuction", + "mutability": "readonly", + "inputs": [ + { + "name": "kitty_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "bool" + } + ] + }, + { + "name": "getAuctionStatus", + "mutability": "readonly", + "inputs": [ + { + "name": "kitty_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "Auction" + } + ] + }, + { + "name": "getCurrentWinningBid", + "mutability": "readonly", + "inputs": [ + { + "name": "kitty_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "createSaleAuction", + "mutability": "mutable", + "inputs": [ + { + "name": "kitty_id", + "type": "u32" + }, + { + "name": "starting_price", + "type": "BigUint" + }, + { + "name": "ending_price", + "type": "BigUint" + }, + { + "name": "duration", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "createSiringAuction", + "mutability": "mutable", + "inputs": [ + { + "name": "kitty_id", + "type": "u32" + }, + { + "name": "starting_price", + "type": "BigUint" + }, + { + "name": "ending_price", + "type": "BigUint" + }, + { + "name": "duration", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "bid", + "mutability": "mutable", + "payableInTokens": [ + "EGLD" + ], + "inputs": [ + { + "name": "kitty_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "name": "endAuction", + "mutability": "mutable", + "inputs": [ + { + "name": "kitty_id", + "type": "u32" + } + ], + "outputs": [] + } + ], + "esdtAttributes": [], + "hasCallback": true, + "types": { + "Auction": { + "type": "struct", + "fields": [ + { + "name": "auction_type", + "type": "AuctionType" + }, + { + "name": "starting_price", + "type": "BigUint" + }, + { + "name": "ending_price", + "type": "BigUint" + }, + { + "name": "deadline", + "type": "u64" + }, + { + "name": "kitty_owner", + "type": "Address" + }, + { + "name": "current_bid", + "type": "BigUint" + }, + { + "name": "current_winner", + "type": "Address" + } + ] + }, + "AuctionType": { + "type": "enum", + "variants": [ + { + "name": "Selling", + "discriminant": 0 + }, + { + "name": "Siring", + "discriminant": 1 + } + ] + } + } +} diff --git a/xsuite/abis/kitty-genetic-alg.abi.json b/xsuite/abis/kitty-genetic-alg.abi.json new file mode 100644 index 00000000..4ec92fef --- /dev/null +++ b/xsuite/abis/kitty-genetic-alg.abi.json @@ -0,0 +1,120 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "kitty-genetic-alg", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "KittyGeneticAlg", + "constructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "generateKittyGenes", + "mutability": "mutable", + "inputs": [ + { + "name": "matron", + "type": "Kitty" + }, + { + "name": "sire", + "type": "Kitty" + } + ], + "outputs": [ + { + "type": "KittyGenes" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "Color": { + "type": "struct", + "fields": [ + { + "name": "r", + "type": "u8" + }, + { + "name": "g", + "type": "u8" + }, + { + "name": "b", + "type": "u8" + } + ] + }, + "Kitty": { + "type": "struct", + "fields": [ + { + "name": "genes", + "type": "KittyGenes" + }, + { + "name": "birth_time", + "type": "u64" + }, + { + "name": "cooldown_end", + "type": "u64" + }, + { + "name": "matron_id", + "type": "u32" + }, + { + "name": "sire_id", + "type": "u32" + }, + { + "name": "siring_with_id", + "type": "u32" + }, + { + "name": "nr_children", + "type": "u16" + }, + { + "name": "generation", + "type": "u16" + } + ] + }, + "KittyGenes": { + "type": "struct", + "fields": [ + { + "name": "fur_color", + "type": "Color" + }, + { + "name": "eye_color", + "type": "Color" + }, + { + "name": "meow_power", + "type": "u8" + } + ] + } + } +} diff --git a/xsuite/abis/kitty-ownership.abi.json b/xsuite/abis/kitty-ownership.abi.json new file mode 100644 index 00000000..5ffb6e8c --- /dev/null +++ b/xsuite/abis/kitty-ownership.abi.json @@ -0,0 +1,456 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "kitty-ownership", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "KittyOwnership", + "constructor": { + "inputs": [ + { + "name": "birth_fee", + "type": "BigUint" + }, + { + "name": "opt_gene_science_contract_address", + "type": "optional
", + "multi_arg": true + }, + { + "name": "opt_kitty_auction_contract_address", + "type": "optional
", + "multi_arg": true + } + ], + "outputs": [] + }, + "endpoints": [ + { + "name": "setGeneScienceContractAddress", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "setKittyAuctionContractAddress", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "claim", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "totalSupply", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "name": "balanceOf", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "name": "ownerOf", + "mutability": "readonly", + "inputs": [ + { + "name": "kitty_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "Address" + } + ] + }, + { + "name": "approve", + "mutability": "mutable", + "inputs": [ + { + "name": "to", + "type": "Address" + }, + { + "name": "kitty_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "name": "transfer", + "mutability": "mutable", + "inputs": [ + { + "name": "to", + "type": "Address" + }, + { + "name": "kitty_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "name": "transfer_from", + "mutability": "mutable", + "inputs": [ + { + "name": "from", + "type": "Address" + }, + { + "name": "to", + "type": "Address" + }, + { + "name": "kitty_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "name": "tokensOfOwner", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "variadic", + "multi_result": true + } + ] + }, + { + "name": "allowAuctioning", + "mutability": "mutable", + "inputs": [ + { + "name": "by", + "type": "Address" + }, + { + "name": "kitty_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "name": "approveSiringAndReturnKitty", + "mutability": "mutable", + "inputs": [ + { + "name": "approved_address", + "type": "Address" + }, + { + "name": "kitty_owner", + "type": "Address" + }, + { + "name": "kitty_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "name": "createGenZeroKitty", + "mutability": "mutable", + "inputs": [], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "name": "getKittyById", + "mutability": "readonly", + "inputs": [ + { + "name": "kitty_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "Kitty" + } + ] + }, + { + "name": "isReadyToBreed", + "mutability": "readonly", + "inputs": [ + { + "name": "kitty_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "bool" + } + ] + }, + { + "name": "isPregnant", + "mutability": "readonly", + "inputs": [ + { + "name": "kitty_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "bool" + } + ] + }, + { + "name": "canBreedWith", + "mutability": "readonly", + "inputs": [ + { + "name": "matron_id", + "type": "u32" + }, + { + "name": "sire_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "bool" + } + ] + }, + { + "name": "approveSiring", + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + }, + { + "name": "kitty_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "name": "breedWith", + "mutability": "mutable", + "payableInTokens": [ + "EGLD" + ], + "inputs": [ + { + "name": "matron_id", + "type": "u32" + }, + { + "name": "sire_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "name": "giveBirth", + "mutability": "mutable", + "inputs": [ + { + "name": "matron_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "name": "birthFee", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "BigUint" + } + ] + } + ], + "events": [ + { + "identifier": "transfer", + "inputs": [ + { + "name": "from", + "type": "Address", + "indexed": true + }, + { + "name": "to", + "type": "Address", + "indexed": true + }, + { + "name": "token_id", + "type": "u32", + "indexed": true + } + ] + }, + { + "identifier": "approve", + "inputs": [ + { + "name": "owner", + "type": "Address", + "indexed": true + }, + { + "name": "approved", + "type": "Address", + "indexed": true + }, + { + "name": "token_id", + "type": "u32", + "indexed": true + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": true, + "types": { + "Color": { + "type": "struct", + "fields": [ + { + "name": "r", + "type": "u8" + }, + { + "name": "g", + "type": "u8" + }, + { + "name": "b", + "type": "u8" + } + ] + }, + "Kitty": { + "type": "struct", + "fields": [ + { + "name": "genes", + "type": "KittyGenes" + }, + { + "name": "birth_time", + "type": "u64" + }, + { + "name": "cooldown_end", + "type": "u64" + }, + { + "name": "matron_id", + "type": "u32" + }, + { + "name": "sire_id", + "type": "u32" + }, + { + "name": "siring_with_id", + "type": "u32" + }, + { + "name": "nr_children", + "type": "u16" + }, + { + "name": "generation", + "type": "u16" + } + ] + }, + "KittyGenes": { + "type": "struct", + "fields": [ + { + "name": "fur_color", + "type": "Color" + }, + { + "name": "eye_color", + "type": "Color" + }, + { + "name": "meow_power", + "type": "u8" + } + ] + } + } +} diff --git a/xsuite/abis/liquid-locking.abi.json b/xsuite/abis/liquid-locking.abi.json new file mode 100644 index 00000000..bc372aba --- /dev/null +++ b/xsuite/abis/liquid-locking.abi.json @@ -0,0 +1,270 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "liquid-locking", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "LiquidLocking", + "constructor": { + "inputs": [ + { + "name": "unbond_period", + "type": "u64" + } + ], + "outputs": [] + }, + "endpoints": [ + { + "name": "upgrade", + "mutability": "mutable", + "inputs": [ + { + "name": "unbond_period", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "set_unbond_period", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "unbond_period", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "whitelist_token", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "token", + "type": "TokenIdentifier" + } + ], + "outputs": [] + }, + { + "name": "blacklist_token", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "token", + "type": "TokenIdentifier" + } + ], + "outputs": [] + }, + { + "name": "lock", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [], + "outputs": [] + }, + { + "name": "unlock", + "mutability": "mutable", + "inputs": [ + { + "name": "tokens", + "type": "List" + } + ], + "outputs": [] + }, + { + "name": "unbond", + "mutability": "mutable", + "inputs": [ + { + "name": "tokens", + "type": "List" + } + ], + "outputs": [] + }, + { + "name": "lockedTokenAmounts", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "List" + } + ] + }, + { + "name": "unlockedTokenAmounts", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "List" + } + ] + }, + { + "name": "lockedTokens", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "variadic", + "multi_result": true + } + ] + }, + { + "name": "unlockedTokens", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "variadic", + "multi_result": true + } + ] + }, + { + "name": "whitelistedTokens", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic", + "multi_result": true + } + ] + }, + { + "name": "unbondPeriod", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u64" + } + ] + } + ], + "events": [ + { + "identifier": "lock", + "inputs": [ + { + "name": "user", + "type": "Address", + "indexed": true + }, + { + "name": "tokens", + "type": "List" + } + ] + }, + { + "identifier": "unlock", + "inputs": [ + { + "name": "user", + "type": "Address", + "indexed": true + }, + { + "name": "tokens", + "type": "List" + } + ] + }, + { + "identifier": "unbond", + "inputs": [ + { + "name": "user", + "type": "Address", + "indexed": true + }, + { + "name": "tokens", + "type": "List" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "EsdtTokenPayment": { + "type": "struct", + "fields": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "token_nonce", + "type": "u64" + }, + { + "name": "amount", + "type": "BigUint" + } + ] + }, + "UnlockedToken": { + "type": "struct", + "fields": [ + { + "name": "token", + "type": "EsdtTokenPayment" + }, + { + "name": "unbond_epoch", + "type": "u64" + } + ] + } + } +} diff --git a/xsuite/abis/lottery-esdt.abi.json b/xsuite/abis/lottery-esdt.abi.json new file mode 100644 index 00000000..9a45b075 --- /dev/null +++ b/xsuite/abis/lottery-esdt.abi.json @@ -0,0 +1,239 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "lottery-esdt", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "Lottery", + "constructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "start", + "mutability": "mutable", + "inputs": [ + { + "name": "lottery_name", + "type": "bytes" + }, + { + "name": "token_identifier", + "type": "EgldOrEsdtTokenIdentifier" + }, + { + "name": "ticket_price", + "type": "BigUint" + }, + { + "name": "opt_total_tickets", + "type": "Option" + }, + { + "name": "opt_deadline", + "type": "Option" + }, + { + "name": "opt_max_entries_per_user", + "type": "Option" + }, + { + "name": "opt_prize_distribution", + "type": "Option" + }, + { + "name": "opt_whitelist", + "type": "Option>" + }, + { + "name": "opt_burn_percentage", + "type": "optional", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "createLotteryPool", + "mutability": "mutable", + "inputs": [ + { + "name": "lottery_name", + "type": "bytes" + }, + { + "name": "token_identifier", + "type": "EgldOrEsdtTokenIdentifier" + }, + { + "name": "ticket_price", + "type": "BigUint" + }, + { + "name": "opt_total_tickets", + "type": "Option" + }, + { + "name": "opt_deadline", + "type": "Option" + }, + { + "name": "opt_max_entries_per_user", + "type": "Option" + }, + { + "name": "opt_prize_distribution", + "type": "Option" + }, + { + "name": "opt_whitelist", + "type": "Option>" + }, + { + "name": "opt_burn_percentage", + "type": "optional", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "buy_ticket", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [ + { + "name": "lottery_name", + "type": "bytes" + } + ], + "outputs": [] + }, + { + "name": "determine_winner", + "mutability": "mutable", + "inputs": [ + { + "name": "lottery_name", + "type": "bytes" + } + ], + "outputs": [] + }, + { + "name": "status", + "mutability": "readonly", + "inputs": [ + { + "name": "lottery_name", + "type": "bytes" + } + ], + "outputs": [ + { + "type": "Status" + } + ] + }, + { + "name": "getLotteryInfo", + "mutability": "readonly", + "inputs": [ + { + "name": "lottery_name", + "type": "bytes" + } + ], + "outputs": [ + { + "type": "LotteryInfo" + } + ] + }, + { + "name": "getLotteryWhitelist", + "mutability": "readonly", + "inputs": [ + { + "name": "lottery_name", + "type": "bytes" + } + ], + "outputs": [ + { + "type": "variadic
", + "multi_result": true + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "LotteryInfo": { + "type": "struct", + "fields": [ + { + "name": "token_identifier", + "type": "EgldOrEsdtTokenIdentifier" + }, + { + "name": "ticket_price", + "type": "BigUint" + }, + { + "name": "tickets_left", + "type": "u32" + }, + { + "name": "deadline", + "type": "u64" + }, + { + "name": "max_entries_per_user", + "type": "u32" + }, + { + "name": "prize_distribution", + "type": "bytes" + }, + { + "name": "prize_pool", + "type": "BigUint" + } + ] + }, + "Status": { + "type": "enum", + "variants": [ + { + "name": "Inactive", + "discriminant": 0 + }, + { + "name": "Running", + "discriminant": 1 + }, + { + "name": "Ended", + "discriminant": 2 + } + ] + } + } +} diff --git a/xsuite/abis/multisig-full.abi.json b/xsuite/abis/multisig-full.abi.json new file mode 100644 index 00000000..a6c59b53 --- /dev/null +++ b/xsuite/abis/multisig-full.abi.json @@ -0,0 +1,1010 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "multisig", + "version": "1.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "docs": [ + "Multi-signature smart contract implementation.", + "Acts like a wallet that needs multiple signers for any action performed.", + "See the readme file for more detailed documentation." + ], + "name": "Multisig", + "constructor": { + "inputs": [ + { + "name": "quorum", + "type": "u32" + }, + { + "name": "board", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + "endpoints": [ + { + "name": "upgrade", + "mutability": "mutable", + "inputs": [ + { + "name": "quorum", + "type": "u32" + }, + { + "name": "board", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "docs": [ + "Allows the contract to receive funds even if it is marked as unpayable in the protocol." + ], + "name": "deposit", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [], + "outputs": [] + }, + { + "docs": [ + "Returns `true` (`1`) if the user has signed the action.", + "Does not check whether or not the user is still a board member and the signature valid." + ], + "name": "signed", + "mutability": "readonly", + "inputs": [ + { + "name": "user", + "type": "Address" + }, + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "bool" + } + ] + }, + { + "docs": [ + "Used by board members to sign actions." + ], + "name": "sign", + "mutability": "mutable", + "inputs": [ + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "docs": [ + "Board members can withdraw their signatures if they no longer desire for the action to be executed.", + "Actions that are left with no valid signatures can be then deleted to free up storage." + ], + "name": "unsign", + "mutability": "mutable", + "inputs": [ + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "docs": [ + "Clears storage pertaining to an action that is no longer supposed to be executed.", + "Any signatures that the action received must first be removed, via `unsign`.", + "Otherwise this endpoint would be prone to abuse." + ], + "name": "discardAction", + "mutability": "mutable", + "inputs": [ + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "docs": [ + "Minimum number of signatures needed to perform any action." + ], + "name": "getQuorum", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "docs": [ + "Denormalized board member count.", + "It is kept in sync with the user list by the contract." + ], + "name": "getNumBoardMembers", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "docs": [ + "Denormalized proposer count.", + "It is kept in sync with the user list by the contract." + ], + "name": "getNumProposers", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "docs": [ + "The index of the last proposed action.", + "0 means that no action was ever proposed yet." + ], + "name": "getActionLastIndex", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "docs": [ + "Initiates board member addition process.", + "Can also be used to promote a proposer to board member." + ], + "name": "proposeAddBoardMember", + "mutability": "mutable", + "inputs": [ + { + "name": "board_member_address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "docs": [ + "Initiates proposer addition process..", + "Can also be used to demote a board member to proposer." + ], + "name": "proposeAddProposer", + "mutability": "mutable", + "inputs": [ + { + "name": "proposer_address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "docs": [ + "Removes user regardless of whether it is a board member or proposer." + ], + "name": "proposeRemoveUser", + "mutability": "mutable", + "inputs": [ + { + "name": "user_address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "name": "proposeChangeQuorum", + "mutability": "mutable", + "inputs": [ + { + "name": "new_quorum", + "type": "u32" + } + ], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "docs": [ + "Propose a transaction in which the contract will perform a transfer-execute call.", + "Can send EGLD without calling anything.", + "Can call smart contract endpoints directly.", + "Doesn't really work with builtin functions." + ], + "name": "proposeTransferExecute", + "mutability": "mutable", + "inputs": [ + { + "name": "to", + "type": "Address" + }, + { + "name": "egld_amount", + "type": "BigUint" + }, + { + "name": "function_call", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "docs": [ + "Propose a transaction in which the contract will perform a transfer-execute call.", + "Can call smart contract endpoints directly.", + "Can use ESDTTransfer/ESDTNFTTransfer/MultiESDTTransfer to send tokens, while also optionally calling endpoints.", + "Works well with builtin functions.", + "Cannot simply send EGLD directly without calling anything." + ], + "name": "proposeAsyncCall", + "mutability": "mutable", + "inputs": [ + { + "name": "to", + "type": "Address" + }, + { + "name": "egld_amount", + "type": "BigUint" + }, + { + "name": "function_call", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "name": "proposeSCDeployFromSource", + "mutability": "mutable", + "inputs": [ + { + "name": "amount", + "type": "BigUint" + }, + { + "name": "source", + "type": "Address" + }, + { + "name": "code_metadata", + "type": "CodeMetadata" + }, + { + "name": "arguments", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "name": "proposeSCUpgradeFromSource", + "mutability": "mutable", + "inputs": [ + { + "name": "sc_address", + "type": "Address" + }, + { + "name": "amount", + "type": "BigUint" + }, + { + "name": "source", + "type": "Address" + }, + { + "name": "code_metadata", + "type": "CodeMetadata" + }, + { + "name": "arguments", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "docs": [ + "Returns `true` (`1`) if `getActionValidSignerCount >= getQuorum`." + ], + "name": "quorumReached", + "mutability": "readonly", + "inputs": [ + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "bool" + } + ] + }, + { + "docs": [ + "Proposers and board members use this to launch signed actions." + ], + "name": "performAction", + "mutability": "mutable", + "inputs": [ + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "optional
", + "multi_result": true + } + ] + }, + { + "name": "dnsRegister", + "onlyOwner": true, + "mutability": "mutable", + "payableInTokens": [ + "EGLD" + ], + "inputs": [ + { + "name": "dns_address", + "type": "Address" + }, + { + "name": "name", + "type": "bytes" + } + ], + "outputs": [] + }, + { + "docs": [ + "Iterates through all actions and retrieves those that are still pending.", + "Serialized full action data:", + "- the action id", + "- the serialized action data", + "- (number of signers followed by) list of signer addresses." + ], + "name": "getPendingActionFullInfo", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic", + "multi_result": true + } + ], + "labels": [ + "multisig-external-view" + ] + }, + { + "docs": [ + "Indicates user rights.", + "`0` = no rights,", + "`1` = can propose, but not sign,", + "`2` = can propose and sign." + ], + "name": "userRole", + "mutability": "readonly", + "inputs": [ + { + "name": "user", + "type": "Address" + } + ], + "outputs": [ + { + "type": "UserRole" + } + ], + "labels": [ + "multisig-external-view" + ] + }, + { + "docs": [ + "Lists all users that can sign actions." + ], + "name": "getAllBoardMembers", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic
", + "multi_result": true + } + ], + "labels": [ + "multisig-external-view" + ] + }, + { + "docs": [ + "Lists all proposers that are not board members." + ], + "name": "getAllProposers", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic
", + "multi_result": true + } + ], + "labels": [ + "multisig-external-view" + ] + }, + { + "docs": [ + "Serialized action data of an action with index." + ], + "name": "getActionData", + "mutability": "readonly", + "inputs": [ + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "Action" + } + ], + "labels": [ + "multisig-external-view" + ] + }, + { + "docs": [ + "Gets addresses of all users who signed an action.", + "Does not check if those users are still board members or not,", + "so the result may contain invalid signers." + ], + "name": "getActionSigners", + "mutability": "readonly", + "inputs": [ + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "List
" + } + ], + "labels": [ + "multisig-external-view" + ] + }, + { + "docs": [ + "Gets addresses of all users who signed an action and are still board members.", + "All these signatures are currently valid." + ], + "name": "getActionSignerCount", + "mutability": "readonly", + "inputs": [ + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "u32" + } + ], + "labels": [ + "multisig-external-view" + ] + }, + { + "docs": [ + "It is possible for board members to lose their role.", + "They are not automatically removed from all actions when doing so,", + "therefore the contract needs to re-check every time when actions are performed.", + "This function is used to validate the signers before performing an action.", + "It also makes it easy to check before performing an action." + ], + "name": "getActionValidSignerCount", + "mutability": "readonly", + "inputs": [ + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "u32" + } + ], + "labels": [ + "multisig-external-view" + ] + } + ], + "events": [ + { + "identifier": "asyncCallSuccess", + "inputs": [ + { + "name": "results", + "type": "variadic", + "indexed": true + } + ] + }, + { + "identifier": "asyncCallError", + "inputs": [ + { + "name": "err_code", + "type": "u32", + "indexed": true + }, + { + "name": "err_message", + "type": "bytes", + "indexed": true + } + ] + }, + { + "identifier": "startPerformAction", + "inputs": [ + { + "name": "data", + "type": "ActionFullInfo" + } + ] + }, + { + "identifier": "performChangeUser", + "inputs": [ + { + "name": "action_id", + "type": "u32", + "indexed": true + }, + { + "name": "changed_user", + "type": "Address", + "indexed": true + }, + { + "name": "old_role", + "type": "UserRole", + "indexed": true + }, + { + "name": "new_role", + "type": "UserRole", + "indexed": true + } + ] + }, + { + "identifier": "performChangeQuorum", + "inputs": [ + { + "name": "action_id", + "type": "u32", + "indexed": true + }, + { + "name": "new_quorum", + "type": "u32", + "indexed": true + } + ] + }, + { + "identifier": "performAsyncCall", + "inputs": [ + { + "name": "action_id", + "type": "u32", + "indexed": true + }, + { + "name": "to", + "type": "Address", + "indexed": true + }, + { + "name": "egld_value", + "type": "BigUint", + "indexed": true + }, + { + "name": "gas", + "type": "u64", + "indexed": true + }, + { + "name": "endpoint", + "type": "bytes", + "indexed": true + }, + { + "name": "arguments", + "type": "variadic", + "indexed": true + } + ] + }, + { + "identifier": "performTransferExecute", + "inputs": [ + { + "name": "action_id", + "type": "u32", + "indexed": true + }, + { + "name": "to", + "type": "Address", + "indexed": true + }, + { + "name": "egld_value", + "type": "BigUint", + "indexed": true + }, + { + "name": "gas", + "type": "u64", + "indexed": true + }, + { + "name": "endpoint", + "type": "bytes", + "indexed": true + }, + { + "name": "arguments", + "type": "variadic", + "indexed": true + } + ] + }, + { + "identifier": "performDeployFromSource", + "inputs": [ + { + "name": "action_id", + "type": "u32", + "indexed": true + }, + { + "name": "egld_value", + "type": "BigUint", + "indexed": true + }, + { + "name": "source_address", + "type": "Address", + "indexed": true + }, + { + "name": "code_metadata", + "type": "CodeMetadata", + "indexed": true + }, + { + "name": "gas", + "type": "u64", + "indexed": true + }, + { + "name": "arguments", + "type": "variadic", + "indexed": true + } + ] + }, + { + "identifier": "performUpgradeFromSource", + "inputs": [ + { + "name": "action_id", + "type": "u32", + "indexed": true + }, + { + "name": "target_address", + "type": "Address", + "indexed": true + }, + { + "name": "egld_value", + "type": "BigUint", + "indexed": true + }, + { + "name": "source_address", + "type": "Address", + "indexed": true + }, + { + "name": "code_metadata", + "type": "CodeMetadata", + "indexed": true + }, + { + "name": "gas", + "type": "u64", + "indexed": true + }, + { + "name": "arguments", + "type": "variadic", + "indexed": true + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": true, + "types": { + "Action": { + "type": "enum", + "variants": [ + { + "name": "Nothing", + "discriminant": 0 + }, + { + "name": "AddBoardMember", + "discriminant": 1, + "fields": [ + { + "name": "0", + "type": "Address" + } + ] + }, + { + "name": "AddProposer", + "discriminant": 2, + "fields": [ + { + "name": "0", + "type": "Address" + } + ] + }, + { + "name": "RemoveUser", + "discriminant": 3, + "fields": [ + { + "name": "0", + "type": "Address" + } + ] + }, + { + "name": "ChangeQuorum", + "discriminant": 4, + "fields": [ + { + "name": "0", + "type": "u32" + } + ] + }, + { + "name": "SendTransferExecute", + "discriminant": 5, + "fields": [ + { + "name": "0", + "type": "CallActionData" + } + ] + }, + { + "name": "SendAsyncCall", + "discriminant": 6, + "fields": [ + { + "name": "0", + "type": "CallActionData" + } + ] + }, + { + "name": "SCDeployFromSource", + "discriminant": 7, + "fields": [ + { + "name": "amount", + "type": "BigUint" + }, + { + "name": "source", + "type": "Address" + }, + { + "name": "code_metadata", + "type": "CodeMetadata" + }, + { + "name": "arguments", + "type": "List" + } + ] + }, + { + "name": "SCUpgradeFromSource", + "discriminant": 8, + "fields": [ + { + "name": "sc_address", + "type": "Address" + }, + { + "name": "amount", + "type": "BigUint" + }, + { + "name": "source", + "type": "Address" + }, + { + "name": "code_metadata", + "type": "CodeMetadata" + }, + { + "name": "arguments", + "type": "List" + } + ] + } + ] + }, + "ActionFullInfo": { + "type": "struct", + "docs": [ + "Not used internally, just to retrieve results via endpoint." + ], + "fields": [ + { + "name": "action_id", + "type": "u32" + }, + { + "name": "action_data", + "type": "Action" + }, + { + "name": "signers", + "type": "List
" + } + ] + }, + "CallActionData": { + "type": "struct", + "fields": [ + { + "name": "to", + "type": "Address" + }, + { + "name": "egld_amount", + "type": "BigUint" + }, + { + "name": "endpoint_name", + "type": "bytes" + }, + { + "name": "arguments", + "type": "List" + } + ] + }, + "UserRole": { + "type": "enum", + "variants": [ + { + "name": "None", + "discriminant": 0 + }, + { + "name": "Proposer", + "discriminant": 1 + }, + { + "name": "BoardMember", + "discriminant": 2 + } + ] + } + } +} diff --git a/xsuite/abis/multisig-view.abi.json b/xsuite/abis/multisig-view.abi.json new file mode 100644 index 00000000..b6cc6ec6 --- /dev/null +++ b/xsuite/abis/multisig-view.abi.json @@ -0,0 +1,611 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "multisig", + "version": "1.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "docs": [ + "Multi-signature smart contract implementation.", + "Acts like a wallet that needs multiple signers for any action performed.", + "See the readme file for more detailed documentation." + ], + "name": "Multisig", + "constructor": { + "docs": [ + "The external view init prepares a contract that looks in another contract's storage.", + "It takes a single argument, the other contract's address", + "You won't find this constructors' definition in the contract, it gets injected automatically by the framework. See `multiversx_sc::external_view_contract`." + ], + "inputs": [ + { + "name": "target_contract_address", + "type": "Address" + } + ], + "outputs": [] + }, + "endpoints": [ + { + "docs": [ + "Iterates through all actions and retrieves those that are still pending.", + "Serialized full action data:", + "- the action id", + "- the serialized action data", + "- (number of signers followed by) list of signer addresses." + ], + "name": "getPendingActionFullInfo", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic", + "multi_result": true + } + ], + "labels": [ + "multisig-external-view" + ] + }, + { + "docs": [ + "Indicates user rights.", + "`0` = no rights,", + "`1` = can propose, but not sign,", + "`2` = can propose and sign." + ], + "name": "userRole", + "mutability": "readonly", + "inputs": [ + { + "name": "user", + "type": "Address" + } + ], + "outputs": [ + { + "type": "UserRole" + } + ], + "labels": [ + "multisig-external-view" + ] + }, + { + "docs": [ + "Lists all users that can sign actions." + ], + "name": "getAllBoardMembers", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic
", + "multi_result": true + } + ], + "labels": [ + "multisig-external-view" + ] + }, + { + "docs": [ + "Lists all proposers that are not board members." + ], + "name": "getAllProposers", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic
", + "multi_result": true + } + ], + "labels": [ + "multisig-external-view" + ] + }, + { + "docs": [ + "Serialized action data of an action with index." + ], + "name": "getActionData", + "mutability": "readonly", + "inputs": [ + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "Action" + } + ], + "labels": [ + "multisig-external-view" + ] + }, + { + "docs": [ + "Gets addresses of all users who signed an action.", + "Does not check if those users are still board members or not,", + "so the result may contain invalid signers." + ], + "name": "getActionSigners", + "mutability": "readonly", + "inputs": [ + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "List
" + } + ], + "labels": [ + "multisig-external-view" + ] + }, + { + "docs": [ + "Gets addresses of all users who signed an action and are still board members.", + "All these signatures are currently valid." + ], + "name": "getActionSignerCount", + "mutability": "readonly", + "inputs": [ + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "u32" + } + ], + "labels": [ + "multisig-external-view" + ] + }, + { + "docs": [ + "It is possible for board members to lose their role.", + "They are not automatically removed from all actions when doing so,", + "therefore the contract needs to re-check every time when actions are performed.", + "This function is used to validate the signers before performing an action.", + "It also makes it easy to check before performing an action." + ], + "name": "getActionValidSignerCount", + "mutability": "readonly", + "inputs": [ + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "u32" + } + ], + "labels": [ + "multisig-external-view" + ] + } + ], + "events": [ + { + "identifier": "asyncCallSuccess", + "inputs": [ + { + "name": "results", + "type": "variadic", + "indexed": true + } + ] + }, + { + "identifier": "asyncCallError", + "inputs": [ + { + "name": "err_code", + "type": "u32", + "indexed": true + }, + { + "name": "err_message", + "type": "bytes", + "indexed": true + } + ] + }, + { + "identifier": "startPerformAction", + "inputs": [ + { + "name": "data", + "type": "ActionFullInfo" + } + ] + }, + { + "identifier": "performChangeUser", + "inputs": [ + { + "name": "action_id", + "type": "u32", + "indexed": true + }, + { + "name": "changed_user", + "type": "Address", + "indexed": true + }, + { + "name": "old_role", + "type": "UserRole", + "indexed": true + }, + { + "name": "new_role", + "type": "UserRole", + "indexed": true + } + ] + }, + { + "identifier": "performChangeQuorum", + "inputs": [ + { + "name": "action_id", + "type": "u32", + "indexed": true + }, + { + "name": "new_quorum", + "type": "u32", + "indexed": true + } + ] + }, + { + "identifier": "performAsyncCall", + "inputs": [ + { + "name": "action_id", + "type": "u32", + "indexed": true + }, + { + "name": "to", + "type": "Address", + "indexed": true + }, + { + "name": "egld_value", + "type": "BigUint", + "indexed": true + }, + { + "name": "gas", + "type": "u64", + "indexed": true + }, + { + "name": "endpoint", + "type": "bytes", + "indexed": true + }, + { + "name": "arguments", + "type": "variadic", + "indexed": true + } + ] + }, + { + "identifier": "performTransferExecute", + "inputs": [ + { + "name": "action_id", + "type": "u32", + "indexed": true + }, + { + "name": "to", + "type": "Address", + "indexed": true + }, + { + "name": "egld_value", + "type": "BigUint", + "indexed": true + }, + { + "name": "gas", + "type": "u64", + "indexed": true + }, + { + "name": "endpoint", + "type": "bytes", + "indexed": true + }, + { + "name": "arguments", + "type": "variadic", + "indexed": true + } + ] + }, + { + "identifier": "performDeployFromSource", + "inputs": [ + { + "name": "action_id", + "type": "u32", + "indexed": true + }, + { + "name": "egld_value", + "type": "BigUint", + "indexed": true + }, + { + "name": "source_address", + "type": "Address", + "indexed": true + }, + { + "name": "code_metadata", + "type": "CodeMetadata", + "indexed": true + }, + { + "name": "gas", + "type": "u64", + "indexed": true + }, + { + "name": "arguments", + "type": "variadic", + "indexed": true + } + ] + }, + { + "identifier": "performUpgradeFromSource", + "inputs": [ + { + "name": "action_id", + "type": "u32", + "indexed": true + }, + { + "name": "target_address", + "type": "Address", + "indexed": true + }, + { + "name": "egld_value", + "type": "BigUint", + "indexed": true + }, + { + "name": "source_address", + "type": "Address", + "indexed": true + }, + { + "name": "code_metadata", + "type": "CodeMetadata", + "indexed": true + }, + { + "name": "gas", + "type": "u64", + "indexed": true + }, + { + "name": "arguments", + "type": "variadic", + "indexed": true + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "Action": { + "type": "enum", + "variants": [ + { + "name": "Nothing", + "discriminant": 0 + }, + { + "name": "AddBoardMember", + "discriminant": 1, + "fields": [ + { + "name": "0", + "type": "Address" + } + ] + }, + { + "name": "AddProposer", + "discriminant": 2, + "fields": [ + { + "name": "0", + "type": "Address" + } + ] + }, + { + "name": "RemoveUser", + "discriminant": 3, + "fields": [ + { + "name": "0", + "type": "Address" + } + ] + }, + { + "name": "ChangeQuorum", + "discriminant": 4, + "fields": [ + { + "name": "0", + "type": "u32" + } + ] + }, + { + "name": "SendTransferExecute", + "discriminant": 5, + "fields": [ + { + "name": "0", + "type": "CallActionData" + } + ] + }, + { + "name": "SendAsyncCall", + "discriminant": 6, + "fields": [ + { + "name": "0", + "type": "CallActionData" + } + ] + }, + { + "name": "SCDeployFromSource", + "discriminant": 7, + "fields": [ + { + "name": "amount", + "type": "BigUint" + }, + { + "name": "source", + "type": "Address" + }, + { + "name": "code_metadata", + "type": "CodeMetadata" + }, + { + "name": "arguments", + "type": "List" + } + ] + }, + { + "name": "SCUpgradeFromSource", + "discriminant": 8, + "fields": [ + { + "name": "sc_address", + "type": "Address" + }, + { + "name": "amount", + "type": "BigUint" + }, + { + "name": "source", + "type": "Address" + }, + { + "name": "code_metadata", + "type": "CodeMetadata" + }, + { + "name": "arguments", + "type": "List" + } + ] + } + ] + }, + "ActionFullInfo": { + "type": "struct", + "docs": [ + "Not used internally, just to retrieve results via endpoint." + ], + "fields": [ + { + "name": "action_id", + "type": "u32" + }, + { + "name": "action_data", + "type": "Action" + }, + { + "name": "signers", + "type": "List
" + } + ] + }, + "CallActionData": { + "type": "struct", + "fields": [ + { + "name": "to", + "type": "Address" + }, + { + "name": "egld_amount", + "type": "BigUint" + }, + { + "name": "endpoint_name", + "type": "bytes" + }, + { + "name": "arguments", + "type": "List" + } + ] + }, + "UserRole": { + "type": "enum", + "variants": [ + { + "name": "None", + "discriminant": 0 + }, + { + "name": "Proposer", + "discriminant": 1 + }, + { + "name": "BoardMember", + "discriminant": 2 + } + ] + } + } +} diff --git a/xsuite/abis/multisig.abi.json b/xsuite/abis/multisig.abi.json new file mode 100644 index 00000000..3c0d1f15 --- /dev/null +++ b/xsuite/abis/multisig.abi.json @@ -0,0 +1,840 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "multisig", + "version": "1.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "docs": [ + "Multi-signature smart contract implementation.", + "Acts like a wallet that needs multiple signers for any action performed.", + "See the readme file for more detailed documentation." + ], + "name": "Multisig", + "constructor": { + "inputs": [ + { + "name": "quorum", + "type": "u32" + }, + { + "name": "board", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + "endpoints": [ + { + "name": "upgrade", + "mutability": "mutable", + "inputs": [ + { + "name": "quorum", + "type": "u32" + }, + { + "name": "board", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "docs": [ + "Allows the contract to receive funds even if it is marked as unpayable in the protocol." + ], + "name": "deposit", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [], + "outputs": [] + }, + { + "docs": [ + "Returns `true` (`1`) if the user has signed the action.", + "Does not check whether or not the user is still a board member and the signature valid." + ], + "name": "signed", + "mutability": "readonly", + "inputs": [ + { + "name": "user", + "type": "Address" + }, + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "bool" + } + ] + }, + { + "docs": [ + "Used by board members to sign actions." + ], + "name": "sign", + "mutability": "mutable", + "inputs": [ + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "docs": [ + "Board members can withdraw their signatures if they no longer desire for the action to be executed.", + "Actions that are left with no valid signatures can be then deleted to free up storage." + ], + "name": "unsign", + "mutability": "mutable", + "inputs": [ + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "docs": [ + "Clears storage pertaining to an action that is no longer supposed to be executed.", + "Any signatures that the action received must first be removed, via `unsign`.", + "Otherwise this endpoint would be prone to abuse." + ], + "name": "discardAction", + "mutability": "mutable", + "inputs": [ + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "docs": [ + "Minimum number of signatures needed to perform any action." + ], + "name": "getQuorum", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "docs": [ + "Denormalized board member count.", + "It is kept in sync with the user list by the contract." + ], + "name": "getNumBoardMembers", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "docs": [ + "Denormalized proposer count.", + "It is kept in sync with the user list by the contract." + ], + "name": "getNumProposers", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "docs": [ + "The index of the last proposed action.", + "0 means that no action was ever proposed yet." + ], + "name": "getActionLastIndex", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "docs": [ + "Initiates board member addition process.", + "Can also be used to promote a proposer to board member." + ], + "name": "proposeAddBoardMember", + "mutability": "mutable", + "inputs": [ + { + "name": "board_member_address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "docs": [ + "Initiates proposer addition process..", + "Can also be used to demote a board member to proposer." + ], + "name": "proposeAddProposer", + "mutability": "mutable", + "inputs": [ + { + "name": "proposer_address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "docs": [ + "Removes user regardless of whether it is a board member or proposer." + ], + "name": "proposeRemoveUser", + "mutability": "mutable", + "inputs": [ + { + "name": "user_address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "name": "proposeChangeQuorum", + "mutability": "mutable", + "inputs": [ + { + "name": "new_quorum", + "type": "u32" + } + ], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "docs": [ + "Propose a transaction in which the contract will perform a transfer-execute call.", + "Can send EGLD without calling anything.", + "Can call smart contract endpoints directly.", + "Doesn't really work with builtin functions." + ], + "name": "proposeTransferExecute", + "mutability": "mutable", + "inputs": [ + { + "name": "to", + "type": "Address" + }, + { + "name": "egld_amount", + "type": "BigUint" + }, + { + "name": "function_call", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "docs": [ + "Propose a transaction in which the contract will perform a transfer-execute call.", + "Can call smart contract endpoints directly.", + "Can use ESDTTransfer/ESDTNFTTransfer/MultiESDTTransfer to send tokens, while also optionally calling endpoints.", + "Works well with builtin functions.", + "Cannot simply send EGLD directly without calling anything." + ], + "name": "proposeAsyncCall", + "mutability": "mutable", + "inputs": [ + { + "name": "to", + "type": "Address" + }, + { + "name": "egld_amount", + "type": "BigUint" + }, + { + "name": "function_call", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "name": "proposeSCDeployFromSource", + "mutability": "mutable", + "inputs": [ + { + "name": "amount", + "type": "BigUint" + }, + { + "name": "source", + "type": "Address" + }, + { + "name": "code_metadata", + "type": "CodeMetadata" + }, + { + "name": "arguments", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "name": "proposeSCUpgradeFromSource", + "mutability": "mutable", + "inputs": [ + { + "name": "sc_address", + "type": "Address" + }, + { + "name": "amount", + "type": "BigUint" + }, + { + "name": "source", + "type": "Address" + }, + { + "name": "code_metadata", + "type": "CodeMetadata" + }, + { + "name": "arguments", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "docs": [ + "Returns `true` (`1`) if `getActionValidSignerCount >= getQuorum`." + ], + "name": "quorumReached", + "mutability": "readonly", + "inputs": [ + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "bool" + } + ] + }, + { + "docs": [ + "Proposers and board members use this to launch signed actions." + ], + "name": "performAction", + "mutability": "mutable", + "inputs": [ + { + "name": "action_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "optional
", + "multi_result": true + } + ] + }, + { + "name": "dnsRegister", + "onlyOwner": true, + "mutability": "mutable", + "payableInTokens": [ + "EGLD" + ], + "inputs": [ + { + "name": "dns_address", + "type": "Address" + }, + { + "name": "name", + "type": "bytes" + } + ], + "outputs": [] + } + ], + "events": [ + { + "identifier": "asyncCallSuccess", + "inputs": [ + { + "name": "results", + "type": "variadic", + "indexed": true + } + ] + }, + { + "identifier": "asyncCallError", + "inputs": [ + { + "name": "err_code", + "type": "u32", + "indexed": true + }, + { + "name": "err_message", + "type": "bytes", + "indexed": true + } + ] + }, + { + "identifier": "startPerformAction", + "inputs": [ + { + "name": "data", + "type": "ActionFullInfo" + } + ] + }, + { + "identifier": "performChangeUser", + "inputs": [ + { + "name": "action_id", + "type": "u32", + "indexed": true + }, + { + "name": "changed_user", + "type": "Address", + "indexed": true + }, + { + "name": "old_role", + "type": "UserRole", + "indexed": true + }, + { + "name": "new_role", + "type": "UserRole", + "indexed": true + } + ] + }, + { + "identifier": "performChangeQuorum", + "inputs": [ + { + "name": "action_id", + "type": "u32", + "indexed": true + }, + { + "name": "new_quorum", + "type": "u32", + "indexed": true + } + ] + }, + { + "identifier": "performAsyncCall", + "inputs": [ + { + "name": "action_id", + "type": "u32", + "indexed": true + }, + { + "name": "to", + "type": "Address", + "indexed": true + }, + { + "name": "egld_value", + "type": "BigUint", + "indexed": true + }, + { + "name": "gas", + "type": "u64", + "indexed": true + }, + { + "name": "endpoint", + "type": "bytes", + "indexed": true + }, + { + "name": "arguments", + "type": "variadic", + "indexed": true + } + ] + }, + { + "identifier": "performTransferExecute", + "inputs": [ + { + "name": "action_id", + "type": "u32", + "indexed": true + }, + { + "name": "to", + "type": "Address", + "indexed": true + }, + { + "name": "egld_value", + "type": "BigUint", + "indexed": true + }, + { + "name": "gas", + "type": "u64", + "indexed": true + }, + { + "name": "endpoint", + "type": "bytes", + "indexed": true + }, + { + "name": "arguments", + "type": "variadic", + "indexed": true + } + ] + }, + { + "identifier": "performDeployFromSource", + "inputs": [ + { + "name": "action_id", + "type": "u32", + "indexed": true + }, + { + "name": "egld_value", + "type": "BigUint", + "indexed": true + }, + { + "name": "source_address", + "type": "Address", + "indexed": true + }, + { + "name": "code_metadata", + "type": "CodeMetadata", + "indexed": true + }, + { + "name": "gas", + "type": "u64", + "indexed": true + }, + { + "name": "arguments", + "type": "variadic", + "indexed": true + } + ] + }, + { + "identifier": "performUpgradeFromSource", + "inputs": [ + { + "name": "action_id", + "type": "u32", + "indexed": true + }, + { + "name": "target_address", + "type": "Address", + "indexed": true + }, + { + "name": "egld_value", + "type": "BigUint", + "indexed": true + }, + { + "name": "source_address", + "type": "Address", + "indexed": true + }, + { + "name": "code_metadata", + "type": "CodeMetadata", + "indexed": true + }, + { + "name": "gas", + "type": "u64", + "indexed": true + }, + { + "name": "arguments", + "type": "variadic", + "indexed": true + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": true, + "types": { + "Action": { + "type": "enum", + "variants": [ + { + "name": "Nothing", + "discriminant": 0 + }, + { + "name": "AddBoardMember", + "discriminant": 1, + "fields": [ + { + "name": "0", + "type": "Address" + } + ] + }, + { + "name": "AddProposer", + "discriminant": 2, + "fields": [ + { + "name": "0", + "type": "Address" + } + ] + }, + { + "name": "RemoveUser", + "discriminant": 3, + "fields": [ + { + "name": "0", + "type": "Address" + } + ] + }, + { + "name": "ChangeQuorum", + "discriminant": 4, + "fields": [ + { + "name": "0", + "type": "u32" + } + ] + }, + { + "name": "SendTransferExecute", + "discriminant": 5, + "fields": [ + { + "name": "0", + "type": "CallActionData" + } + ] + }, + { + "name": "SendAsyncCall", + "discriminant": 6, + "fields": [ + { + "name": "0", + "type": "CallActionData" + } + ] + }, + { + "name": "SCDeployFromSource", + "discriminant": 7, + "fields": [ + { + "name": "amount", + "type": "BigUint" + }, + { + "name": "source", + "type": "Address" + }, + { + "name": "code_metadata", + "type": "CodeMetadata" + }, + { + "name": "arguments", + "type": "List" + } + ] + }, + { + "name": "SCUpgradeFromSource", + "discriminant": 8, + "fields": [ + { + "name": "sc_address", + "type": "Address" + }, + { + "name": "amount", + "type": "BigUint" + }, + { + "name": "source", + "type": "Address" + }, + { + "name": "code_metadata", + "type": "CodeMetadata" + }, + { + "name": "arguments", + "type": "List" + } + ] + } + ] + }, + "ActionFullInfo": { + "type": "struct", + "docs": [ + "Not used internally, just to retrieve results via endpoint." + ], + "fields": [ + { + "name": "action_id", + "type": "u32" + }, + { + "name": "action_data", + "type": "Action" + }, + { + "name": "signers", + "type": "List
" + } + ] + }, + "CallActionData": { + "type": "struct", + "fields": [ + { + "name": "to", + "type": "Address" + }, + { + "name": "egld_amount", + "type": "BigUint" + }, + { + "name": "endpoint_name", + "type": "bytes" + }, + { + "name": "arguments", + "type": "List" + } + ] + }, + "UserRole": { + "type": "enum", + "variants": [ + { + "name": "None", + "discriminant": 0 + }, + { + "name": "Proposer", + "discriminant": 1 + }, + { + "name": "BoardMember", + "discriminant": 2 + } + ] + } + } +} diff --git a/xsuite/abis/multiversx-price-aggregator-sc.abi.json b/xsuite/abis/multiversx-price-aggregator-sc.abi.json new file mode 100644 index 00000000..0eca908f --- /dev/null +++ b/xsuite/abis/multiversx-price-aggregator-sc.abi.json @@ -0,0 +1,412 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "multiversx-price-aggregator-sc", + "version": "0.45.2" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "PriceAggregator", + "constructor": { + "inputs": [ + { + "name": "staking_token", + "type": "EgldOrEsdtTokenIdentifier" + }, + { + "name": "staking_amount", + "type": "BigUint" + }, + { + "name": "slash_amount", + "type": "BigUint" + }, + { + "name": "slash_quorum", + "type": "u32" + }, + { + "name": "submission_count", + "type": "u32" + }, + { + "name": "oracles", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + "endpoints": [ + { + "name": "addOracles", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "oracles", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "docs": [ + "Also receives submission count,", + "so the owner does not have to update it manually with setSubmissionCount before this call" + ], + "name": "removeOracles", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "submission_count", + "type": "u32" + }, + { + "name": "oracles", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "submit", + "mutability": "mutable", + "inputs": [ + { + "name": "from", + "type": "bytes" + }, + { + "name": "to", + "type": "bytes" + }, + { + "name": "submission_timestamp", + "type": "u64" + }, + { + "name": "price", + "type": "BigUint" + }, + { + "name": "decimals", + "type": "u8" + } + ], + "outputs": [] + }, + { + "name": "submitBatch", + "mutability": "mutable", + "inputs": [ + { + "name": "submissions", + "type": "variadic>", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "latestRoundData", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic", + "multi_result": true + } + ] + }, + { + "name": "latestPriceFeed", + "mutability": "readonly", + "inputs": [ + { + "name": "from", + "type": "bytes" + }, + { + "name": "to", + "type": "bytes" + } + ], + "outputs": [ + { + "type": "u32" + }, + { + "type": "bytes" + }, + { + "type": "bytes" + }, + { + "type": "u64" + }, + { + "type": "BigUint" + }, + { + "type": "u8" + } + ] + }, + { + "name": "latestPriceFeedOptional", + "mutability": "readonly", + "inputs": [ + { + "name": "from", + "type": "bytes" + }, + { + "name": "to", + "type": "bytes" + } + ], + "outputs": [ + { + "type": "optional>", + "multi_result": true + } + ] + }, + { + "name": "setSubmissionCount", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "submission_count", + "type": "u32" + } + ], + "outputs": [] + }, + { + "name": "getOracles", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic
", + "multi_result": true + } + ] + }, + { + "name": "setPairDecimals", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "from", + "type": "bytes" + }, + { + "name": "to", + "type": "bytes" + }, + { + "name": "decimals", + "type": "u8" + } + ], + "outputs": [] + }, + { + "name": "getPairDecimals", + "mutability": "readonly", + "inputs": [ + { + "name": "from", + "type": "bytes" + }, + { + "name": "to", + "type": "bytes" + } + ], + "outputs": [ + { + "type": "u8" + } + ] + }, + { + "name": "submission_count", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "name": "pause", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "unpause", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "isPaused", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "bool" + } + ] + }, + { + "name": "stake", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [], + "outputs": [] + }, + { + "name": "unstake", + "mutability": "mutable", + "inputs": [ + { + "name": "unstake_amount", + "type": "BigUint" + } + ], + "outputs": [] + }, + { + "name": "voteSlashMember", + "mutability": "mutable", + "inputs": [ + { + "name": "member_to_slash", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "slashMember", + "mutability": "mutable", + "inputs": [ + { + "name": "member_to_slash", + "type": "Address" + } + ], + "outputs": [] + } + ], + "events": [ + { + "identifier": "new_round", + "inputs": [ + { + "name": "from", + "type": "bytes", + "indexed": true + }, + { + "name": "to", + "type": "bytes", + "indexed": true + }, + { + "name": "epoch", + "type": "u64", + "indexed": true + }, + { + "name": "new_round_event", + "type": "NewRoundEvent" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "NewRoundEvent": { + "type": "struct", + "fields": [ + { + "name": "price", + "type": "BigUint" + }, + { + "name": "timestamp", + "type": "u64" + }, + { + "name": "decimals", + "type": "u8" + }, + { + "name": "block", + "type": "u64" + }, + { + "name": "epoch", + "type": "u64" + } + ] + }, + "PriceFeed": { + "type": "struct", + "fields": [ + { + "name": "round_id", + "type": "u32" + }, + { + "name": "from", + "type": "bytes" + }, + { + "name": "to", + "type": "bytes" + }, + { + "name": "timestamp", + "type": "u64" + }, + { + "name": "price", + "type": "BigUint" + }, + { + "name": "decimals", + "type": "u8" + } + ] + } + } +} diff --git a/xsuite/abis/multiversx-wegld-swap-sc.abi.json b/xsuite/abis/multiversx-wegld-swap-sc.abi.json new file mode 100644 index 00000000..bc186c79 --- /dev/null +++ b/xsuite/abis/multiversx-wegld-swap-sc.abi.json @@ -0,0 +1,118 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "multiversx-wegld-swap-sc", + "version": "0.45.2" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "EgldEsdtSwap", + "constructor": { + "inputs": [ + { + "name": "wrapped_egld_token_id", + "type": "TokenIdentifier" + } + ], + "outputs": [] + }, + "endpoints": [ + { + "name": "wrapEgld", + "mutability": "mutable", + "payableInTokens": [ + "EGLD" + ], + "inputs": [], + "outputs": [ + { + "type": "EsdtTokenPayment" + } + ] + }, + { + "name": "unwrapEgld", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [], + "outputs": [] + }, + { + "name": "getLockedEgldBalance", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "getWrappedEgldTokenId", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "TokenIdentifier" + } + ] + }, + { + "name": "pause", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "unpause", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "isPaused", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "bool" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "EsdtTokenPayment": { + "type": "struct", + "fields": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "token_nonce", + "type": "u64" + }, + { + "name": "amount", + "type": "BigUint" + } + ] + } + } +} diff --git a/xsuite/abis/mvx-game-sc.abi.json b/xsuite/abis/mvx-game-sc.abi.json new file mode 100644 index 00000000..1bb8cf3d --- /dev/null +++ b/xsuite/abis/mvx-game-sc.abi.json @@ -0,0 +1,338 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "mvx-game-sc", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "MvxGameSc", + "constructor": { + "inputs": [ + { + "name": "enabled_opt", + "type": "optional", + "multi_arg": true + }, + { + "name": "game_start_fee_opt", + "type": "optional", + "multi_arg": true + }, + { + "name": "token_id_opt", + "type": "optional", + "multi_arg": true + } + ], + "outputs": [] + }, + "endpoints": [ + { + "name": "createGame", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [ + { + "name": "waiting_time", + "type": "u64" + }, + { + "name": "number_of_players_min", + "type": "u64" + }, + { + "name": "number_of_players_max", + "type": "u64" + }, + { + "name": "wager", + "type": "BigUint" + } + ], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "name": "joinGame", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [ + { + "name": "game_id", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "claimBackWager", + "mutability": "mutable", + "inputs": [ + { + "name": "game_id", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "getTokenId", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "EgldOrEsdtTokenIdentifier" + } + ] + }, + { + "name": "getGameStartFee", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "getEnabled", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "bool" + } + ] + }, + { + "name": "isUserAdmin", + "mutability": "readonly", + "inputs": [ + { + "name": "user", + "type": "Address" + } + ], + "outputs": [ + { + "type": "bool" + } + ] + }, + { + "name": "getLastGameId", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "name": "getGameSettings", + "mutability": "readonly", + "inputs": [ + { + "name": "game_id", + "type": "u64" + } + ], + "outputs": [ + { + "type": "GameSettings" + } + ] + }, + { + "name": "getGameIdBySettings", + "mutability": "readonly", + "inputs": [ + { + "name": "game_settings", + "type": "GameSettings" + } + ], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "name": "getPlayers", + "mutability": "readonly", + "inputs": [ + { + "name": "game_id", + "type": "u64" + } + ], + "outputs": [ + { + "type": "variadic
", + "multi_result": true + } + ] + }, + { + "name": "getGamesPerUser", + "mutability": "readonly", + "inputs": [ + { + "name": "user", + "type": "Address" + } + ], + "outputs": [ + { + "type": "variadic", + "multi_result": true + } + ] + }, + { + "name": "sendReward", + "mutability": "mutable", + "inputs": [ + { + "name": "game_id", + "type": "u64" + }, + { + "name": "winners", + "type": "optional>>", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "enableSC", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "disableSC", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "setTokenId", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "token_id", + "type": "EgldOrEsdtTokenIdentifier" + } + ], + "outputs": [] + }, + { + "name": "setGameStartFee", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "amount", + "type": "BigUint" + } + ], + "outputs": [] + }, + { + "name": "setAdmin", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "user", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "removeAdmin", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "user", + "type": "Address" + } + ], + "outputs": [] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "GameSettings": { + "type": "struct", + "fields": [ + { + "name": "time_limit", + "type": "u64" + }, + { + "name": "number_of_players_min", + "type": "u64" + }, + { + "name": "number_of_players_max", + "type": "u64" + }, + { + "name": "wager", + "type": "BigUint" + }, + { + "name": "creator", + "type": "Address" + }, + { + "name": "status", + "type": "Status" + } + ] + }, + "Status": { + "type": "enum", + "variants": [ + { + "name": "Valid", + "discriminant": 0 + }, + { + "name": "Invalid", + "discriminant": 1 + } + ] + } + } +} diff --git a/xsuite/abis/mystery-box.abi.json b/xsuite/abis/mystery-box.abi.json new file mode 100644 index 00000000..0aba5f94 --- /dev/null +++ b/xsuite/abis/mystery-box.abi.json @@ -0,0 +1,302 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "mystery-box", + "version": "0.0.1" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "MysteryBox", + "constructor": { + "inputs": [ + { + "name": "mystery_box_token_id", + "type": "TokenIdentifier" + } + ], + "outputs": [] + }, + "endpoints": [ + { + "name": "setupMysteryBox", + "mutability": "mutable", + "inputs": [ + { + "name": "winning_rates_list", + "type": "variadic>", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "updateMysteryBoxUris", + "mutability": "mutable", + "inputs": [ + { + "name": "uris", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "createMysteryBox", + "mutability": "mutable", + "inputs": [ + { + "name": "amount", + "type": "BigUint" + } + ], + "outputs": [ + { + "type": "EsdtTokenPayment" + } + ] + }, + { + "name": "openMysteryBox", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [], + "outputs": [] + }, + { + "name": "getMysteryBoxTokenIdentifier", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "TokenIdentifier" + } + ] + }, + { + "name": "getGlobalCooldownEpoch", + "mutability": "readonly", + "inputs": [ + { + "name": "reward", + "type": "RewardType" + } + ], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "name": "getWinningRates", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "List" + } + ] + }, + { + "name": "getMysteryBoxUris", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "List" + } + ] + }, + { + "name": "isAdmin", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "bool" + } + ] + }, + { + "name": "addAdmin", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "removeAdmin", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "getAdmins", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic
", + "multi_result": true + } + ] + } + ], + "events": [ + { + "identifier": "create_mystery_box", + "inputs": [ + { + "name": "user", + "type": "Address", + "indexed": true + }, + { + "name": "current_epoch", + "type": "u64", + "indexed": true + }, + { + "name": "payment", + "type": "EsdtTokenPayment", + "indexed": true + }, + { + "name": "reward", + "type": "List" + } + ] + }, + { + "identifier": "open_mystery_box", + "inputs": [ + { + "name": "caller", + "type": "Address", + "indexed": true + }, + { + "name": "epoch", + "type": "u64", + "indexed": true + }, + { + "name": "reward", + "type": "Reward" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "EsdtTokenPayment": { + "type": "struct", + "fields": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "token_nonce", + "type": "u64" + }, + { + "name": "amount", + "type": "BigUint" + } + ] + }, + "Reward": { + "type": "struct", + "fields": [ + { + "name": "reward_type", + "type": "RewardType" + }, + { + "name": "reward_token_id", + "type": "EgldOrEsdtTokenIdentifier" + }, + { + "name": "value", + "type": "BigUint" + }, + { + "name": "description", + "type": "bytes" + }, + { + "name": "percentage_chance", + "type": "u64" + }, + { + "name": "epochs_cooldown", + "type": "u64" + } + ] + }, + "RewardType": { + "type": "enum", + "variants": [ + { + "name": "None", + "discriminant": 0 + }, + { + "name": "ExperiencePoints", + "discriminant": 1 + }, + { + "name": "MysteryBox", + "discriminant": 2 + }, + { + "name": "SFT", + "discriminant": 3 + }, + { + "name": "PercentValue", + "discriminant": 4 + }, + { + "name": "FixedValue", + "discriminant": 5 + }, + { + "name": "CustomReward", + "discriminant": 6 + } + ] + } + } +} diff --git a/xsuite/abis/nft-escrow.abi.json b/xsuite/abis/nft-escrow.abi.json new file mode 100644 index 00000000..aba0ff26 --- /dev/null +++ b/xsuite/abis/nft-escrow.abi.json @@ -0,0 +1,189 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "nft-escrow", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "NftEscrowContract", + "constructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "escrow", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [ + { + "name": "wanted_nft", + "type": "TokenIdentifier" + }, + { + "name": "wanted_nonce", + "type": "u64" + }, + { + "name": "wanted_address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "name": "cancel", + "mutability": "mutable", + "inputs": [ + { + "name": "offer_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "name": "accept", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [ + { + "name": "offer_id", + "type": "u32" + } + ], + "outputs": [] + }, + { + "name": "getCreatedOffers", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "variadic>", + "multi_result": true + } + ] + }, + { + "name": "getWantedOffers", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "variadic>", + "multi_result": true + } + ] + }, + { + "name": "created_offers", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "variadic", + "multi_result": true + } + ] + }, + { + "name": "wanted_offers", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "variadic", + "multi_result": true + } + ] + }, + { + "name": "offers", + "mutability": "readonly", + "inputs": [ + { + "name": "id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "Offer" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "Offer": { + "type": "struct", + "fields": [ + { + "name": "creator", + "type": "Address" + }, + { + "name": "nft", + "type": "TokenIdentifier" + }, + { + "name": "nonce", + "type": "u64" + }, + { + "name": "wanted_nft", + "type": "TokenIdentifier" + }, + { + "name": "wanted_nonce", + "type": "u64" + }, + { + "name": "wanted_address", + "type": "Address" + } + ] + } + } +} diff --git a/xsuite/abis/nft-minter.abi.json b/xsuite/abis/nft-minter.abi.json new file mode 100644 index 00000000..b0d9ef04 --- /dev/null +++ b/xsuite/abis/nft-minter.abi.json @@ -0,0 +1,140 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "nft-minter", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "NftMinter", + "constructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "createNft", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "name", + "type": "bytes" + }, + { + "name": "royalties", + "type": "BigUint" + }, + { + "name": "uri", + "type": "bytes" + }, + { + "name": "selling_price", + "type": "BigUint" + }, + { + "name": "opt_token_used_as_payment", + "type": "optional", + "multi_arg": true + }, + { + "name": "opt_token_used_as_payment_nonce", + "type": "optional", + "multi_arg": true + } + ], + "outputs": [], + "allow_multiple_var_args": true + }, + { + "name": "claimRoyaltiesFromMarketplace", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "marketplace_address", + "type": "Address" + }, + { + "name": "token_id", + "type": "TokenIdentifier" + }, + { + "name": "token_nonce", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "issueToken", + "onlyOwner": true, + "mutability": "mutable", + "payableInTokens": [ + "EGLD" + ], + "inputs": [ + { + "name": "token_name", + "type": "bytes" + }, + { + "name": "token_ticker", + "type": "bytes" + } + ], + "outputs": [] + }, + { + "name": "setLocalRoles", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "buyNft", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [ + { + "name": "nft_nonce", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "getNftPrice", + "mutability": "readonly", + "inputs": [ + { + "name": "nft_nonce", + "type": "u64" + } + ], + "outputs": [ + { + "type": "optional>", + "multi_result": true + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": true, + "types": {} +} diff --git a/xsuite/abis/nft-storage-prepay.abi.json b/xsuite/abis/nft-storage-prepay.abi.json new file mode 100644 index 00000000..5afe2e47 --- /dev/null +++ b/xsuite/abis/nft-storage-prepay.abi.json @@ -0,0 +1,128 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "nft-storage-prepay", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "NftStoragePrepay", + "constructor": { + "inputs": [ + { + "name": "cost_per_byte", + "type": "BigUint" + } + ], + "outputs": [] + }, + "endpoints": [ + { + "name": "setCostPerByte", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "cost_per_byte", + "type": "BigUint" + } + ], + "outputs": [] + }, + { + "name": "reserveFunds", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + }, + { + "name": "file_size", + "type": "BigUint" + } + ], + "outputs": [] + }, + { + "name": "claim", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "depositPaymentForStorage", + "mutability": "mutable", + "payableInTokens": [ + "EGLD" + ], + "inputs": [], + "outputs": [] + }, + { + "docs": [ + "defaults to max amount" + ], + "name": "withdraw", + "mutability": "mutable", + "inputs": [ + { + "name": "opt_amount", + "type": "optional", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "getCostForSize", + "mutability": "readonly", + "inputs": [ + { + "name": "file_size", + "type": "BigUint" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "getDepositAmount", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "getCostPerByte", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "BigUint" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": {} +} diff --git a/xsuite/abis/order-book-factory.abi.json b/xsuite/abis/order-book-factory.abi.json new file mode 100644 index 00000000..a9b2dd27 --- /dev/null +++ b/xsuite/abis/order-book-factory.abi.json @@ -0,0 +1,78 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "order-book-factory", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "Factory", + "constructor": { + "inputs": [ + { + "name": "pair_template_address", + "type": "Address" + } + ], + "outputs": [] + }, + "endpoints": [ + { + "name": "createPair", + "mutability": "mutable", + "inputs": [ + { + "name": "token_id_pair", + "type": "TokenIdPair" + } + ], + "outputs": [ + { + "type": "Address" + } + ] + }, + { + "name": "getPair", + "mutability": "readonly", + "inputs": [ + { + "name": "token_id_pair", + "type": "TokenIdPair" + } + ], + "outputs": [ + { + "type": "Option
" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "TokenIdPair": { + "type": "struct", + "fields": [ + { + "name": "first_token_id", + "type": "TokenIdentifier" + }, + { + "name": "second_token_id", + "type": "TokenIdentifier" + } + ] + } + } +} diff --git a/xsuite/abis/order-book-pair.abi.json b/xsuite/abis/order-book-pair.abi.json new file mode 100644 index 00000000..5ce211bd --- /dev/null +++ b/xsuite/abis/order-book-pair.abi.json @@ -0,0 +1,408 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "order-book-pair", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "Pair", + "constructor": { + "inputs": [ + { + "name": "first_token_id", + "type": "TokenIdentifier" + }, + { + "name": "second_token_id", + "type": "TokenIdentifier" + } + ], + "outputs": [] + }, + "endpoints": [ + { + "name": "createBuyOrder", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [ + { + "name": "params", + "type": "OrderInputParams" + } + ], + "outputs": [] + }, + { + "name": "createSellOrder", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [ + { + "name": "params", + "type": "OrderInputParams" + } + ], + "outputs": [] + }, + { + "name": "matchOrders", + "mutability": "mutable", + "inputs": [ + { + "name": "order_ids", + "type": "List" + } + ], + "outputs": [] + }, + { + "name": "cancelOrders", + "mutability": "mutable", + "inputs": [ + { + "name": "order_ids", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "cancelAllOrders", + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "freeOrders", + "mutability": "mutable", + "inputs": [ + { + "name": "order_ids", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "startGlobalOperation", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "stopGlobalOperation", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "getAddressOrderIds", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "variadic", + "multi_result": true + } + ] + }, + { + "name": "getOrderIdCounter", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "name": "getOrderById", + "mutability": "readonly", + "inputs": [ + { + "name": "id", + "type": "u64" + } + ], + "outputs": [ + { + "type": "Order" + } + ] + }, + { + "name": "getFirstTokenId", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "TokenIdentifier" + } + ] + }, + { + "name": "getSecondTokenId", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "TokenIdentifier" + } + ] + } + ], + "events": [ + { + "identifier": "order", + "inputs": [ + { + "name": "caller", + "type": "Address", + "indexed": true + }, + { + "name": "epoch", + "type": "u64", + "indexed": true + }, + { + "name": "order_type", + "type": "OrderType", + "indexed": true + }, + { + "name": "order", + "type": "Order" + } + ] + }, + { + "identifier": "cancel_order", + "inputs": [ + { + "name": "caller", + "type": "Address", + "indexed": true + }, + { + "name": "epoch", + "type": "u64", + "indexed": true + }, + { + "name": "order_type", + "type": "OrderType", + "indexed": true + }, + { + "name": "order_id", + "type": "u64", + "indexed": true + } + ] + }, + { + "identifier": "match_order", + "inputs": [ + { + "name": "caller", + "type": "Address", + "indexed": true + }, + { + "name": "epoch", + "type": "u64", + "indexed": true + }, + { + "name": "order_type", + "type": "OrderType", + "indexed": true + }, + { + "name": "order_id", + "type": "u64", + "indexed": true + }, + { + "name": "order_creator", + "type": "Address", + "indexed": true + } + ] + }, + { + "identifier": "free_order", + "inputs": [ + { + "name": "caller", + "type": "Address", + "indexed": true + }, + { + "name": "epoch", + "type": "u64", + "indexed": true + }, + { + "name": "order_type", + "type": "OrderType", + "indexed": true + }, + { + "name": "order_id", + "type": "u64", + "indexed": true + }, + { + "name": "order_creator", + "type": "Address", + "indexed": true + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "DealConfig": { + "type": "struct", + "fields": [ + { + "name": "match_provider_percent", + "type": "u64" + } + ] + }, + "FeeConfig": { + "type": "struct", + "fields": [ + { + "name": "fee_type", + "type": "FeeConfigEnum" + }, + { + "name": "fixed_fee", + "type": "BigUint" + }, + { + "name": "percent_fee", + "type": "u64" + } + ] + }, + "FeeConfigEnum": { + "type": "enum", + "variants": [ + { + "name": "Fixed", + "discriminant": 0 + }, + { + "name": "Percent", + "discriminant": 1 + } + ] + }, + "Order": { + "type": "struct", + "fields": [ + { + "name": "id", + "type": "u64" + }, + { + "name": "creator", + "type": "Address" + }, + { + "name": "match_provider", + "type": "Address" + }, + { + "name": "input_amount", + "type": "BigUint" + }, + { + "name": "output_amount", + "type": "BigUint" + }, + { + "name": "fee_config", + "type": "FeeConfig" + }, + { + "name": "deal_config", + "type": "DealConfig" + }, + { + "name": "create_epoch", + "type": "u64" + }, + { + "name": "order_type", + "type": "OrderType" + } + ] + }, + "OrderInputParams": { + "type": "struct", + "fields": [ + { + "name": "amount", + "type": "BigUint" + }, + { + "name": "match_provider", + "type": "Address" + }, + { + "name": "fee_config", + "type": "FeeConfig" + }, + { + "name": "deal_config", + "type": "DealConfig" + } + ] + }, + "OrderType": { + "type": "enum", + "variants": [ + { + "name": "Buy", + "discriminant": 0 + }, + { + "name": "Sell", + "discriminant": 1 + } + ] + } + } +} diff --git a/xsuite/abis/paymaster.abi.json b/xsuite/abis/paymaster.abi.json new file mode 100644 index 00000000..3fefbbe3 --- /dev/null +++ b/xsuite/abis/paymaster.abi.json @@ -0,0 +1,56 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "paymaster", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "PaymasterContract", + "constructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "forwardExecution", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [ + { + "name": "relayer_addr", + "type": "Address" + }, + { + "name": "dest", + "type": "Address" + }, + { + "name": "endpoint_name", + "type": "bytes" + }, + { + "name": "endpoint_args", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [] + } + ], + "esdtAttributes": [], + "hasCallback": true, + "types": {} +} diff --git a/xsuite/abis/ping-pong-egld.abi.json b/xsuite/abis/ping-pong-egld.abi.json new file mode 100644 index 00000000..b59d7ed6 --- /dev/null +++ b/xsuite/abis/ping-pong-egld.abi.json @@ -0,0 +1,247 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "ping-pong-egld", + "version": "0.0.2" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "docs": [ + "A contract that allows anyone to send a fixed sum, locks it for a while and then allows users to take it back.", + "Sending funds to the contract is called \"ping\".", + "Taking the same funds back is called \"pong\".", + "", + "Restrictions:", + "- `ping` can be called only after the contract is activated. By default the contract is activated on deploy.", + "- Users can only `ping` once, ever.", + "- Only the set amount can be `ping`-ed, no more, no less.", + "- The contract can optionally have a maximum cap. No more users can `ping` after the cap has been reached.", + "- The `ping` endpoint optionally accepts", + "- `pong` can only be called after the contract expired (a certain duration has passed since activation).", + "- `pongAll` can be used to send to all users to `ping`-ed. If it runs low on gas, it will interrupt itself.", + "It can be continued anytime." + ], + "name": "PingPong", + "constructor": { + "docs": [ + "Necessary configuration when deploying:", + "`ping_amount` - the exact EGLD amounf that needs to be sent when `ping`-ing.", + "`duration_in_seconds` - how much time (in seconds) until contract expires.", + "`opt_activation_timestamp` - optionally specify the contract to only actvivate at a later date.", + "`max_funds` - optional funding cap, no more funds than this can be added to the contract." + ], + "inputs": [ + { + "name": "ping_amount", + "type": "BigUint" + }, + { + "name": "duration_in_seconds", + "type": "u64" + }, + { + "name": "opt_activation_timestamp", + "type": "Option" + }, + { + "name": "max_funds", + "type": "optional", + "multi_arg": true + } + ], + "outputs": [] + }, + "endpoints": [ + { + "docs": [ + "User sends some EGLD to be locked in the contract for a period of time.", + "Optional `_data` argument is ignored." + ], + "name": "ping", + "mutability": "mutable", + "payableInTokens": [ + "EGLD" + ], + "inputs": [ + { + "name": "_data", + "type": "ignore", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "docs": [ + "User can take back funds from the contract.", + "Can only be called after expiration." + ], + "name": "pong", + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "docs": [ + "Send back funds to all users who pinged.", + "Returns", + "- `completed` if everything finished", + "- `interrupted` if run out of gas midway.", + "Can only be called after expiration." + ], + "name": "pongAll", + "mutability": "mutable", + "inputs": [], + "outputs": [ + { + "type": "OperationCompletionStatus" + } + ] + }, + { + "docs": [ + "Lists the addresses of all users that have `ping`-ed,", + "in the order they have `ping`-ed" + ], + "name": "getUserAddresses", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic
", + "multi_result": true + } + ] + }, + { + "name": "getPingAmount", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "getDeadline", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "docs": [ + "Block timestamp of the block where the contract got activated.", + "If not specified in the constructor it is the the deploy block timestamp." + ], + "name": "getActivationTimestamp", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "docs": [ + "Optional funding cap." + ], + "name": "getMaxFunds", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "Option" + } + ] + }, + { + "docs": [ + "State of user funds.", + "0 - user unknown, never `ping`-ed", + "1 - `ping`-ed", + "2 - `pong`-ed" + ], + "name": "getUserStatus", + "mutability": "readonly", + "inputs": [ + { + "name": "user_id", + "type": "u32" + } + ], + "outputs": [ + { + "type": "UserStatus" + } + ] + }, + { + "docs": [ + "Part of the `pongAll` status, the last user to be processed.", + "0 if never called `pongAll` or `pongAll` completed.." + ], + "name": "pongAllLastUser", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u32" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "OperationCompletionStatus": { + "type": "explicit-enum", + "variants": [ + { + "docs": [ + "indicates that operation was completed" + ], + "name": "completed" + }, + { + "docs": [ + "indicates that operation was interrupted prematurely, due to low gas" + ], + "name": "interrupted" + } + ] + }, + "UserStatus": { + "type": "enum", + "variants": [ + { + "name": "New", + "discriminant": 0 + }, + { + "name": "Registered", + "discriminant": 1 + }, + { + "name": "Withdrawn", + "discriminant": 2 + } + ] + } + } +} diff --git a/xsuite/abis/proxy-pause.abi.json b/xsuite/abis/proxy-pause.abi.json new file mode 100644 index 00000000..5e4c5904 --- /dev/null +++ b/xsuite/abis/proxy-pause.abi.json @@ -0,0 +1,111 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "proxy-pause", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "PauseProxy", + "constructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "addContracts", + "mutability": "mutable", + "inputs": [ + { + "name": "contracts", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "removeContracts", + "mutability": "mutable", + "inputs": [ + { + "name": "contracts", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "addOwners", + "mutability": "mutable", + "inputs": [ + { + "name": "owners", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "removeOwners", + "mutability": "mutable", + "inputs": [ + { + "name": "owners", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "pause", + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "unpause", + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "owners", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic
", + "multi_result": true + } + ] + }, + { + "name": "contracts", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic
", + "multi_result": true + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": {} +} diff --git a/xsuite/abis/rewards-distribution.abi.json b/xsuite/abis/rewards-distribution.abi.json new file mode 100644 index 00000000..01d21b94 --- /dev/null +++ b/xsuite/abis/rewards-distribution.abi.json @@ -0,0 +1,267 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "rewards-distribution", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "RewardsDistribution", + "constructor": { + "inputs": [ + { + "name": "seed_nft_minter_address", + "type": "Address" + }, + { + "name": "brackets", + "type": "List" + } + ], + "outputs": [] + }, + "endpoints": [ + { + "name": "depositRoyalties", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [], + "outputs": [] + }, + { + "name": "raffle", + "mutability": "mutable", + "inputs": [], + "outputs": [ + { + "type": "OperationCompletionStatus" + } + ] + }, + { + "name": "claimRewards", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [ + { + "name": "raffle_id_start", + "type": "u64" + }, + { + "name": "raffle_id_end", + "type": "u64" + }, + { + "name": "reward_tokens", + "type": "variadic>", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "computeClaimableAmount", + "mutability": "readonly", + "inputs": [ + { + "name": "raffle_id", + "type": "u64" + }, + { + "name": "reward_token_id", + "type": "EgldOrEsdtTokenIdentifier" + }, + { + "name": "reward_token_nonce", + "type": "u64" + }, + { + "name": "nft_nonce", + "type": "u64" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "getRaffleId", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "name": "getCompletedRaffleIdCount", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "name": "getRoyalties", + "mutability": "readonly", + "inputs": [ + { + "name": "raffle_id", + "type": "u64" + }, + { + "name": "reward_token_id", + "type": "EgldOrEsdtTokenIdentifier" + }, + { + "name": "reward_token_nonce", + "type": "u64" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "getNftRewardPercent", + "mutability": "readonly", + "inputs": [ + { + "name": "raffle_id", + "type": "u64" + }, + { + "name": "nft_nonce", + "type": "u64" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "getWasClaimed", + "mutability": "readonly", + "inputs": [ + { + "name": "raffle_id", + "type": "u64" + }, + { + "name": "reward_token_id", + "type": "EgldOrEsdtTokenIdentifier" + }, + { + "name": "reward_token_nonce", + "type": "u64" + }, + { + "name": "nft_nonce", + "type": "u64" + } + ], + "outputs": [ + { + "type": "bool" + } + ] + }, + { + "name": "getSeedNftMinterAddress", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "Address" + } + ] + }, + { + "name": "getBrackets", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "List" + } + ] + }, + { + "name": "getLastRaffleEpoch", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "name": "getNftTokenId", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "TokenIdentifier" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "Bracket": { + "type": "struct", + "fields": [ + { + "name": "index_percent", + "type": "u64" + }, + { + "name": "bracket_reward_percent", + "type": "u64" + } + ] + }, + "OperationCompletionStatus": { + "type": "explicit-enum", + "variants": [ + { + "docs": [ + "indicates that operation was completed" + ], + "name": "completed" + }, + { + "docs": [ + "indicates that operation was interrupted prematurely, due to low gas" + ], + "name": "interrupted" + } + ] + } + } +} diff --git a/xsuite/abis/seed-nft-minter.abi.json b/xsuite/abis/seed-nft-minter.abi.json new file mode 100644 index 00000000..fe5840b0 --- /dev/null +++ b/xsuite/abis/seed-nft-minter.abi.json @@ -0,0 +1,201 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "seed-nft-minter", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "SeedNftMinter", + "constructor": { + "inputs": [ + { + "name": "marketplaces", + "type": "List
" + }, + { + "name": "distribution", + "type": "List" + } + ], + "outputs": [] + }, + "endpoints": [ + { + "name": "createNft", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "name", + "type": "bytes" + }, + { + "name": "royalties", + "type": "BigUint" + }, + { + "name": "uri", + "type": "bytes" + }, + { + "name": "selling_price", + "type": "BigUint" + }, + { + "name": "opt_token_used_as_payment", + "type": "optional", + "multi_arg": true + }, + { + "name": "opt_token_used_as_payment_nonce", + "type": "optional", + "multi_arg": true + } + ], + "outputs": [], + "allow_multiple_var_args": true + }, + { + "name": "claimAndDistribute", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "token_id", + "type": "EgldOrEsdtTokenIdentifier" + }, + { + "name": "token_nonce", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "getMarketplaces", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic
", + "multi_result": true + } + ] + }, + { + "name": "getNftCount", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "name": "getDistributionRules", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "List" + } + ] + }, + { + "name": "issueToken", + "onlyOwner": true, + "mutability": "mutable", + "payableInTokens": [ + "EGLD" + ], + "inputs": [ + { + "name": "token_display_name", + "type": "bytes" + }, + { + "name": "token_ticker", + "type": "bytes" + } + ], + "outputs": [] + }, + { + "name": "buyNft", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [ + { + "name": "nft_nonce", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "getNftPrice", + "mutability": "readonly", + "inputs": [ + { + "name": "nft_nonce", + "type": "u64" + } + ], + "outputs": [ + { + "type": "optional>", + "multi_result": true + } + ] + }, + { + "name": "getNftTokenId", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "TokenIdentifier" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": true, + "types": { + "Distribution": { + "type": "struct", + "fields": [ + { + "name": "address", + "type": "Address" + }, + { + "name": "percentage", + "type": "u64" + }, + { + "name": "endpoint", + "type": "bytes" + }, + { + "name": "gas_limit", + "type": "u64" + } + ] + } + } +} diff --git a/xsuite/abis/token-release.abi.json b/xsuite/abis/token-release.abi.json new file mode 100644 index 00000000..eab12de5 --- /dev/null +++ b/xsuite/abis/token-release.abi.json @@ -0,0 +1,220 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "token-release", + "version": "0.0.1" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "TokenRelease", + "constructor": { + "inputs": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + } + ], + "outputs": [] + }, + "endpoints": [ + { + "name": "addFixedAmountGroup", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "group_identifier", + "type": "bytes" + }, + { + "name": "group_total_amount", + "type": "BigUint" + }, + { + "name": "period_unlock_amount", + "type": "BigUint" + }, + { + "name": "release_period", + "type": "u64" + }, + { + "name": "release_ticks", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "addPercentageBasedGroup", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "group_identifier", + "type": "bytes" + }, + { + "name": "group_total_amount", + "type": "BigUint" + }, + { + "name": "period_unlock_percentage", + "type": "u8" + }, + { + "name": "release_period", + "type": "u64" + }, + { + "name": "release_ticks", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "removeGroup", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "group_identifier", + "type": "bytes" + } + ], + "outputs": [] + }, + { + "name": "addUserGroup", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + }, + { + "name": "group_identifier", + "type": "bytes" + } + ], + "outputs": [] + }, + { + "name": "removeUser", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "requestAddressChange", + "mutability": "mutable", + "inputs": [ + { + "name": "new_address", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "approveAddressChange", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "user_address", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "endSetupPeriod", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "claimTokens", + "mutability": "mutable", + "inputs": [], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "verify_address_change", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "Address" + } + ] + }, + { + "name": "get_claimable_tokens", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "getTokenIdentifier", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "TokenIdentifier" + } + ] + }, + { + "name": "getTokenTotalSupply", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "BigUint" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": {} +} diff --git a/xsuite/build_wasms.sh b/xsuite/build_wasms.sh index 6f46e598..c10ecbbd 100644 --- a/xsuite/build_wasms.sh +++ b/xsuite/build_wasms.sh @@ -21,4 +21,13 @@ do fi done +for file in **/*.abi.json +do + if [ -f "$file" ]; then + destination=$SOURCE_DIR/$file + mkdir -p "$(dirname "$destination")" + cp "$file" "$destination" + fi +done + shopt -u globstar dotglob diff --git a/xsuite/contracts/.gitignore b/xsuite/contracts/.gitignore index 0e609b2c..c5b708b7 100644 --- a/xsuite/contracts/.gitignore +++ b/xsuite/contracts/.gitignore @@ -1,2 +1,3 @@ */output/* !*/output/*.wasm +!*/output/datatypes.abi.json diff --git a/xsuite/contracts/datatypes/Cargo.toml b/xsuite/contracts/datatypes/Cargo.toml new file mode 100644 index 00000000..5d45779e --- /dev/null +++ b/xsuite/contracts/datatypes/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "datatypes" +version = "0.0.0" +edition = "2021" +publish = false + +[dependencies.multiversx-sc] +version = "0.45.1" diff --git a/xsuite/contracts/datatypes/meta/Cargo.toml b/xsuite/contracts/datatypes/meta/Cargo.toml new file mode 100644 index 00000000..77a6887a --- /dev/null +++ b/xsuite/contracts/datatypes/meta/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "datatypes-meta" +version = "0.0.0" +edition = "2021" +publish = false + +[dependencies.datatypes] +path = ".." + +[dependencies.multiversx-sc-meta] +version = "0.45.1" diff --git a/xsuite/contracts/datatypes/meta/src/main.rs b/xsuite/contracts/datatypes/meta/src/main.rs new file mode 100644 index 00000000..1c7f266e --- /dev/null +++ b/xsuite/contracts/datatypes/meta/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + multiversx_sc_meta::cli_main::(); +} diff --git a/xsuite/contracts/datatypes/multiversx.json b/xsuite/contracts/datatypes/multiversx.json new file mode 100644 index 00000000..73655396 --- /dev/null +++ b/xsuite/contracts/datatypes/multiversx.json @@ -0,0 +1,3 @@ +{ + "language": "rust" +} \ No newline at end of file diff --git a/xsuite/contracts/datatypes/output/datatypes.abi.json b/xsuite/contracts/datatypes/output/datatypes.abi.json new file mode 100644 index 00000000..b09c1fdd --- /dev/null +++ b/xsuite/contracts/datatypes/output/datatypes.abi.json @@ -0,0 +1,488 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.72.0-nightly", + "commitHash": "8c74a5d27c644a0f7a22bb2fa8dd3ff8257bc220", + "commitDate": "2023-06-14", + "channel": "Nightly", + "short": "rustc 1.72.0-nightly (8c74a5d27 2023-06-14)" + }, + "contractCrate": { + "name": "datatypes", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "name": "DataTypes", + "constructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "getPrimitiveDataTypes", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "PrimitiveDataTypes" + } + ] + }, + { + "name": "getManagedDataTypes", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "ManagedDataTypes" + } + ] + }, + { + "name": "getOptionDataTypes", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "OptionDataTypes" + } + ] + }, + { + "name": "getArrayDataTypes", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "ArrayDataTypes" + } + ] + }, + { + "name": "getOtherDataTypes", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "OtherDataTypes" + } + ] + }, + { + "name": "setPrimitiveDataTypes", + "mutability": "mutable", + "inputs": [ + { + "name": "data", + "type": "PrimitiveDataTypes" + } + ], + "outputs": [ + { + "type": "PrimitiveDataTypes" + } + ] + }, + { + "name": "setManagedDataTypes", + "mutability": "mutable", + "inputs": [ + { + "name": "data", + "type": "ManagedDataTypes" + } + ], + "outputs": [ + { + "type": "ManagedDataTypes" + } + ] + }, + { + "name": "setOptionDataTypes", + "mutability": "mutable", + "inputs": [ + { + "name": "data", + "type": "OptionDataTypes" + } + ], + "outputs": [ + { + "type": "OptionDataTypes" + } + ] + }, + { + "name": "setArrayrDataTypes", + "mutability": "mutable", + "inputs": [ + { + "name": "data", + "type": "ArrayDataTypes" + } + ], + "outputs": [ + { + "type": "ArrayDataTypes" + } + ] + }, + { + "name": "setOtherDataTypes", + "mutability": "mutable", + "inputs": [ + { + "name": "data", + "type": "OtherDataTypes" + } + ], + "outputs": [ + { + "type": "OtherDataTypes" + } + ] + }, + { + "name": "getOptionalValue1stArg", + "mutability": "readonly", + "inputs": [ + { + "name": "optional_value_arg", + "type": "optional", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "optional", + "multi_result": true + } + ] + }, + { + "name": "getOptionalValue2ndArg", + "mutability": "readonly", + "inputs": [ + { + "name": "required_arg", + "type": "u8" + }, + { + "name": "optional_value_arg", + "type": "optional", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "u8" + }, + { + "type": "optional", + "multi_result": true + } + ] + }, + { + "name": "getSingleValueMapper", + "mutability": "readonly", + "inputs": [ + { + "name": "input", + "type": "u8" + } + ], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "name": "getVecMapper", + "mutability": "readonly", + "inputs": [ + { + "name": "input", + "type": "u8" + } + ], + "outputs": [ + { + "type": "variadic", + "multi_result": true + } + ] + }, + { + "name": "getSetMapper", + "mutability": "readonly", + "inputs": [ + { + "name": "input", + "type": "u8" + } + ], + "outputs": [ + { + "type": "variadic", + "multi_result": true + } + ] + }, + { + "name": "getUnorderedSetMapper", + "mutability": "readonly", + "inputs": [ + { + "name": "input", + "type": "u8" + } + ], + "outputs": [ + { + "type": "variadic", + "multi_result": true + } + ] + }, + { + "name": "getMapMapper", + "mutability": "readonly", + "inputs": [ + { + "name": "input", + "type": "u8" + } + ], + "outputs": [ + { + "type": "variadic>", + "multi_result": true + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "ArrayDataTypes": { + "type": "struct", + "fields": [ + { + "name": "managed_vec_of_u16", + "type": "List" + }, + { + "name": "managed_vec_of_subtype", + "type": "List" + }, + { + "name": "fixed_array", + "type": "array5" + }, + { + "name": "fixed_array_complex", + "type": "array3" + }, + { + "name": "tuples", + "type": "tuple" + }, + { + "name": "tuples_complex", + "type": "tuple" + } + ] + }, + "EgldOrEsdtTokenPayment": { + "type": "struct", + "fields": [ + { + "name": "token_identifier", + "type": "EgldOrEsdtTokenIdentifier" + }, + { + "name": "token_nonce", + "type": "u64" + }, + { + "name": "amount", + "type": "BigUint" + } + ] + }, + "EsdtTokenPayment": { + "type": "struct", + "fields": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "token_nonce", + "type": "u64" + }, + { + "name": "amount", + "type": "BigUint" + } + ] + }, + "MaintenanceStatus": { + "type": "enum", + "variants": [ + { + "name": "NotSet", + "discriminant": 0 + }, + { + "name": "InMaintenance", + "discriminant": 1 + }, + { + "name": "NotInMaintenance", + "discriminant": 2 + } + ] + }, + "ManagedDataTypes": { + "type": "struct", + "fields": [ + { + "name": "managed_buffer", + "type": "bytes" + }, + { + "name": "big_unsigned_integer", + "type": "BigUint" + }, + { + "name": "big_integer", + "type": "BigInt" + }, + { + "name": "address", + "type": "Address" + }, + { + "name": "token_identifer", + "type": "TokenIdentifier" + }, + { + "name": "egld_or_esdt_token_identifer", + "type": "EgldOrEsdtTokenIdentifier" + }, + { + "name": "esdt_token_payment", + "type": "EsdtTokenPayment" + }, + { + "name": "egld_or_esdt_token_payment", + "type": "EgldOrEsdtTokenPayment" + } + ] + }, + "OptionDataTypes": { + "type": "struct", + "fields": [ + { + "name": "option_of_biguint_set", + "type": "Option" + }, + { + "name": "option_of_biguint_not_set", + "type": "Option" + }, + { + "name": "option_of_subtype_set", + "type": "Option" + }, + { + "name": "option_of_subtype_not_set", + "type": "Option" + } + ] + }, + "OtherDataTypes": { + "type": "struct", + "fields": [ + { + "name": "custom_type", + "type": "SubType" + } + ] + }, + "PrimitiveDataTypes": { + "type": "struct", + "fields": [ + { + "name": "boolean", + "type": "bool" + }, + { + "name": "unsigned8", + "type": "u8" + }, + { + "name": "unsigned16", + "type": "u16" + }, + { + "name": "unsigned32", + "type": "u32" + }, + { + "name": "unsigned64", + "type": "u64" + }, + { + "name": "unsigned_size", + "type": "u32" + }, + { + "name": "signed8", + "type": "i8" + }, + { + "name": "signed16", + "type": "i16" + }, + { + "name": "signed32", + "type": "i32" + }, + { + "name": "signed64", + "type": "i64" + }, + { + "name": "signed_size", + "type": "i32" + }, + { + "name": "enumeration", + "type": "MaintenanceStatus" + } + ] + }, + "SubType": { + "type": "struct", + "fields": [ + { + "name": "big_unsigned_integer", + "type": "BigUint" + }, + { + "name": "address", + "type": "Address" + } + ] + } + } +} diff --git a/xsuite/contracts/datatypes/output/datatypes.wasm b/xsuite/contracts/datatypes/output/datatypes.wasm new file mode 100755 index 0000000000000000000000000000000000000000..3ffcbc87637be4c74b9a6edb825029a699b5b46c GIT binary patch literal 11950 zcmcJVeT-aJb-?ev@6GJ&zS-Std*f_2ro0(8$tL(KiDR2}684S1lE#VMI^iRMZZ^AP zd%x}3wSyse7i>%@Uulslq=J-INTw~2f?Bnu5~8h&C`Blhsuoq1K>UT&s!FB)5mgBH zcg}rpc6Mz;rK+}e=Du_9J@NO&4mknFHE0)d|~-ybD7V* zdrY?gd*>VHPn~MEj!Z91FP$+?V4HK;(dKg2I(>e=xv*>^nYg1^+*+J(D6(f3mZncH zG^fJ6pPyKmINh8&c`%!rYBiUZOx%etJA1adFx9xY+*~p}VIp4-j)}R$t=3{I?6@sI z=;_69%*l>J5;?J0Z3IpK>E`lN=jRJrmrPlpx8Fc)CzfKiIAJ{_J^9|JnlA=q13BQ} z;@OMBz{$Dk$)@R&b9_F9w2n0wPA}&|?9ai7yMyCG+(8sUYK6E@E-$u_-m%4rT%219 z6k$T{QwRmFUqAJ%4a7(Vd z<1a2WTkG^!(7|Dyynpzme(TEKI9D>L%~Z-JiZO0iu9zO@Ov#ltCB{U~#c^z6(`8D0 zZf00AQK`#Rx=Q8Pv7+0QN|CEXB?gr)7gc+EBjc((#TCJ4>`nfaB5R`Z)@a3MtE-h{ z#biHwUB6cUp^|jH7HuuhH|G~y7oCYQ?ParSZ^KMZw5I2$m!~f@4^1pjJbm#jmiQ67 zg^4GFC9Z)#YBvKues+0!abXR5*=_=wwOSJw*ML_PczpRxv$Y2Nn7wW3rsrL?TbQ`v zypP+>fH$7^vO@K|4&0xxn`G_!1Ao(QZ4*2(_pXV#^UeF0#DUExZ=88xVM=B`We3=E za(dzP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|)XFj^noGf7a^UQI@l!ML}zq}k@+n^N6&np-8H>(qK z`3|^kHP4-&=69Ooj3-{0oXQ#p4;?Ch-^e HJ;wh4L%{{0 literal 0 HcmV?d00001 diff --git a/xsuite/contracts/datatypes/src/lib.rs b/xsuite/contracts/datatypes/src/lib.rs new file mode 100644 index 00000000..7776a55c --- /dev/null +++ b/xsuite/contracts/datatypes/src/lib.rs @@ -0,0 +1,224 @@ +#![no_std] + +use crate::types::data_types::{ + ArrayDataTypes, MaintenanceStatus, ManagedDataTypes, OptionDataTypes, OtherDataTypes, + PrimitiveDataTypes, SubType, +}; + +multiversx_sc::imports!(); + +mod types; + +#[multiversx_sc::contract] +pub trait DataTypes { + #[init] + fn init(&self) { + self.single_value_mapper(0).set(1); + self.single_value_mapper(1).set(2); + self.vec_mapper(0).push(&1); + self.vec_mapper(0).push(&2); + self.vec_mapper(1).push(&10); + self.vec_mapper(1).push(&11); + self.set_mapper(0).insert(1); + self.set_mapper(0).insert(2); + self.set_mapper(0).insert(3); + self.set_mapper(1).insert(5); + self.set_mapper(1).insert(6); + self.set_mapper(1).insert(7); + self.unordered_set_mapper(0).insert(1); + self.unordered_set_mapper(0).insert(2); + self.unordered_set_mapper(1).insert(5); + self.unordered_set_mapper(1).insert(6); + self.map_mapper(0).insert(0, 1); + self.map_mapper(0).insert(1, 2); + self.map_mapper(1).insert(1, 10); + self.map_mapper(1).insert(2, 11); + } + + #[view(getPrimitiveDataTypes)] + fn get_primitive_datatypes(&self) -> PrimitiveDataTypes { + let types = PrimitiveDataTypes { + boolean: true, + unsigned8: 10, + unsigned16: 1000, + unsigned32: 100000, + unsigned64: 1000000000000000000, + unsigned_size: 200000, + signed8: 5, + signed16: 500, + signed32: 50000, + signed64: 500000000000000000, + signed_size: 300000, + enumeration: MaintenanceStatus::InMaintenance, + }; + return types; + } + + #[view(getManagedDataTypes)] + fn get_managed_datatypes(&self) -> ManagedDataTypes { + let types = ManagedDataTypes { + managed_buffer: ManagedBuffer::from("abcd"), + big_unsigned_integer: BigUint::from(20000000000u64), + big_integer: BigInt::from(10000000000i64), + // big_float: BigInt::from(10000000000i64), + address: self.blockchain().get_sc_address(), + token_identifer: TokenIdentifier::from("ABCDEF-123456"), + egld_or_esdt_token_identifer: EgldOrEsdtTokenIdentifier::esdt("ABCDEF-123456"), + esdt_token_payment: EsdtTokenPayment::new( + TokenIdentifier::from("ABCDEF-123456"), + 120, + BigUint::from(1000000u64), + ), + egld_or_esdt_token_payment: EgldOrEsdtTokenPayment::new( + EgldOrEsdtTokenIdentifier::esdt("ABCDEF-123456"), + 360, + BigUint::from(2000000u64), + ), + }; + return types; + } + + #[view(getOptionDataTypes)] + fn get_option_datatypes(&self) -> OptionDataTypes { + let types = OptionDataTypes { + option_of_biguint_set: Option::Some(BigUint::from(420u64)), + option_of_biguint_not_set: Option::None, + option_of_subtype_set: Option::Some(SubType { + big_unsigned_integer: BigUint::from(12u8), + address: self.blockchain().get_sc_address(), + }), + option_of_subtype_not_set: Option::None, + }; + return types; + } + + #[view(getArrayDataTypes)] + fn get_array_datatypes(&self) -> ArrayDataTypes { + let types = ArrayDataTypes { + managed_vec_of_u16: self.get_sample_mvec(), + managed_vec_of_subtype: self.get_sample_mvec_complex(), + fixed_array: [1, 2, 3, 4, 5], + fixed_array_complex: [ + SubType { + address: self.blockchain().get_sc_address(), + big_unsigned_integer: BigUint::from(100000000u64), + }, + SubType { + address: self.blockchain().get_sc_address(), + big_unsigned_integer: BigUint::from(200000000u64), + }, + SubType { + address: self.blockchain().get_sc_address(), + big_unsigned_integer: BigUint::from(300000000u64), + }, + ], + tuples: (10, 300), + tuples_complex: ( + 20, + SubType { + address: self.blockchain().get_sc_address(), + big_unsigned_integer: BigUint::from(300000000u64), + }, + ), + }; + return types; + } + + #[view(getOtherDataTypes)] + fn get_other_datatypes(&self) -> OtherDataTypes { + let types = OtherDataTypes { + custom_type: SubType { + address: self.blockchain().get_sc_address(), + big_unsigned_integer: BigUint::from(100000000u64), + }, + }; + return types; + } + + #[endpoint(setPrimitiveDataTypes)] + fn set_primitive_datatypes(&self, data: PrimitiveDataTypes) -> PrimitiveDataTypes { + data + } + + #[endpoint(setManagedDataTypes)] + fn set_managed_datatypes( + &self, + data: ManagedDataTypes, + ) -> ManagedDataTypes { + data + } + + #[endpoint(setOptionDataTypes)] + fn set_option_datatypes(&self, data: OptionDataTypes) -> OptionDataTypes { + data + } + + #[endpoint(setArrayrDataTypes)] + fn set_array_datatypes(&self, data: ArrayDataTypes) -> ArrayDataTypes { + data + } + + #[endpoint(setOtherDataTypes)] + fn set_other_datatypes(&self, data: OtherDataTypes) -> OtherDataTypes { + data + } + + #[view(getOptionalValue1stArg)] + fn get_optional_value_1st_arg( + &self, + optional_value_arg: OptionalValue, + ) -> OptionalValue { + optional_value_arg + } + + #[view(getOptionalValue2ndArg)] + fn get_optional_value_2nd_arg( + &self, + required_arg: u8, + optional_value_arg: OptionalValue, + ) -> MultiValue2> { + let result = MultiValue2::from((required_arg, optional_value_arg)); + result + } + + #[view(getSingleValueMapper)] + #[storage_mapper("single_value_mapper")] + fn single_value_mapper(&self, input: u8) -> SingleValueMapper; + + #[view(getVecMapper)] + #[storage_mapper("vec_mapper")] + fn vec_mapper(&self, input: u8) -> VecMapper; + + #[view(getSetMapper)] + #[storage_mapper("set_mapper")] + fn set_mapper(&self, input: u8) -> SetMapper; + + #[view(getUnorderedSetMapper)] + #[storage_mapper("unordered_set_mapper")] + fn unordered_set_mapper(&self, input: u8) -> UnorderedSetMapper; + + #[view(getMapMapper)] + #[storage_mapper("map_mapper")] + fn map_mapper(&self, input: u8) -> MapMapper; + + fn get_sample_mvec(&self) -> ManagedVec { + let mut vec = ManagedVec::new(); + vec.push(12u16); + vec.push(26u16); + vec.push(3u16); + return vec; + } + + fn get_sample_mvec_complex(&self) -> ManagedVec> { + let mut vec = ManagedVec::new(); + vec.push(SubType { + address: self.blockchain().get_sc_address(), + big_unsigned_integer: BigUint::from(14u8), + }); + vec.push(SubType { + address: self.blockchain().get_owner_address(), + big_unsigned_integer: BigUint::from(133u8), + }); + return vec; + } +} diff --git a/xsuite/contracts/datatypes/src/types/data_types.rs b/xsuite/contracts/datatypes/src/types/data_types.rs new file mode 100644 index 00000000..751bfcdf --- /dev/null +++ b/xsuite/contracts/datatypes/src/types/data_types.rs @@ -0,0 +1,76 @@ +use multiversx_sc::{ + api::ManagedTypeApi, + types::{ + BigInt, BigUint, EgldOrEsdtTokenIdentifier, EgldOrEsdtTokenPayment, EsdtTokenPayment, + ManagedAddress, ManagedBuffer, ManagedVec, TokenIdentifier, + }, +}; + +multiversx_sc::derive_imports!(); + +#[repr(u8)] +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, TypeAbi, PartialEq)] +pub enum MaintenanceStatus { + NotSet = 0, + InMaintenance = 1, + NotInMaintenance = 2, +} + +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, TypeAbi, ManagedVecItem)] +pub struct SubType { + pub big_unsigned_integer: BigUint, + pub address: ManagedAddress, +} + +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, TypeAbi)] +pub struct PrimitiveDataTypes { + pub boolean: bool, + pub unsigned8: u8, + pub unsigned16: u16, + pub unsigned32: u32, + pub unsigned64: u64, + pub unsigned_size: usize, + pub signed8: i8, + pub signed16: i16, + pub signed32: i32, + pub signed64: i64, + pub signed_size: isize, + pub enumeration: MaintenanceStatus, +} + +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, TypeAbi)] +pub struct ManagedDataTypes { + pub managed_buffer: ManagedBuffer, + pub big_unsigned_integer: BigUint, + pub big_integer: BigInt, + // pub big_float: BigFloat, + pub address: ManagedAddress, + pub token_identifer: TokenIdentifier, + pub egld_or_esdt_token_identifer: EgldOrEsdtTokenIdentifier, + pub esdt_token_payment: EsdtTokenPayment, + pub egld_or_esdt_token_payment: EgldOrEsdtTokenPayment, +} + +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, TypeAbi)] +pub struct OptionDataTypes { + pub option_of_biguint_set: Option>, + pub option_of_biguint_not_set: Option>, + pub option_of_subtype_set: Option>, + pub option_of_subtype_not_set: Option>, +} + +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, TypeAbi)] +pub struct ArrayDataTypes { + pub managed_vec_of_u16: ManagedVec, + pub managed_vec_of_subtype: ManagedVec>, + pub fixed_array: [u8; 5], + pub fixed_array_complex: [SubType; 3], + pub tuples: (u8, u16), + pub tuples_complex: (u8, SubType), +} + +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, TypeAbi)] +pub struct OtherDataTypes { + pub custom_type: SubType, + // pub complex_enum: ComplexEnum, +} diff --git a/xsuite/contracts/datatypes/src/types/mod.rs b/xsuite/contracts/datatypes/src/types/mod.rs new file mode 100644 index 00000000..9d8d4233 --- /dev/null +++ b/xsuite/contracts/datatypes/src/types/mod.rs @@ -0,0 +1 @@ +pub mod data_types; diff --git a/xsuite/contracts/datatypes/wasm/Cargo.lock b/xsuite/contracts/datatypes/wasm/Cargo.lock new file mode 100644 index 00000000..ffc59e1a --- /dev/null +++ b/xsuite/contracts/datatypes/wasm/Cargo.lock @@ -0,0 +1,258 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "datatypes" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "datatypes-wasm" +version = "0.0.0" +dependencies = [ + "datatypes", + "multiversx-sc-wasm-adapter", +] + +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[package]] +name = "hashbrown" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +dependencies = [ + "ahash", + "allocator-api2", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "multiversx-sc" +version = "0.45.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f11b51d6a2ab0218585ed58e100c5ac2218de09490fbfc4243b5ecd0ca7f5cbc" +dependencies = [ + "bitflags", + "hashbrown", + "hex-literal", + "multiversx-sc-codec", + "multiversx-sc-derive", + "num-traits", +] + +[[package]] +name = "multiversx-sc-codec" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327b0ad1c3477cab0d7c84391439ba302238f738ef3c6e1fcd18e247fba84875" +dependencies = [ + "arrayvec", + "multiversx-sc-codec-derive", +] + +[[package]] +name = "multiversx-sc-codec-derive" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f444038e0043b8eda816b26952479c2aca3c4a643580f4337f71fb362a586db5" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "multiversx-sc-derive" +version = "0.45.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784f0fc505806102fe6f808b368e12fcb13096dd73c5678f09c5663230724d6f" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "radix_trie", + "syn 1.0.109", +] + +[[package]] +name = "multiversx-sc-wasm-adapter" +version = "0.45.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5afb8b8cc380eabd82dc8f9b02afbab3dce16fc2b5de1dbc601fcfcf261278ba" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "nibble_vec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" +dependencies = [ + "smallvec", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "proc-macro2" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radix_trie" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd" +dependencies = [ + "endian-type", + "nibble_vec", +] + +[[package]] +name = "smallvec" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "zerocopy" +version = "0.7.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] diff --git a/xsuite/contracts/datatypes/wasm/Cargo.toml b/xsuite/contracts/datatypes/wasm/Cargo.toml new file mode 100644 index 00000000..a23bc4ce --- /dev/null +++ b/xsuite/contracts/datatypes/wasm/Cargo.toml @@ -0,0 +1,30 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + +[package] +name = "datatypes-wasm" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["cdylib"] + +[profile.release] +codegen-units = 1 +opt-level = "z" +lto = true +debug = false +panic = "abort" + +[dependencies.datatypes] +path = ".." + +[dependencies.multiversx-sc-wasm-adapter] +version = "0.45.1" + +[workspace] +members = ["."] diff --git a/xsuite/contracts/datatypes/wasm/src/lib.rs b/xsuite/contracts/datatypes/wasm/src/lib.rs new file mode 100644 index 00000000..cc1b917c --- /dev/null +++ b/xsuite/contracts/datatypes/wasm/src/lib.rs @@ -0,0 +1,29 @@ +// Code generated by the multiversx-sc build system. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +// Init: 1 +// Endpoints: 1 +// Async Callback (empty): 1 +// Total number of exported functions: 3 + +#![no_std] + +// Configuration that works with rustc < 1.73.0. +// TODO: Recommended rustc version: 1.73.0 or newer. +#![feature(lang_items)] + +multiversx_sc_wasm_adapter::allocator!(); +multiversx_sc_wasm_adapter::panic_handler!(); + +multiversx_sc_wasm_adapter::endpoints! { + datatypes + ( + init => init + getAllDataTypes => get_all_datatypes + ) +} + +multiversx_sc_wasm_adapter::async_callback_empty! {} diff --git a/xsuite/src/cli/cmd.test.ts b/xsuite/src/cli/cmd.test.ts index 1672e672..af7f31b8 100644 --- a/xsuite/src/cli/cmd.test.ts +++ b/xsuite/src/cli/cmd.test.ts @@ -14,6 +14,7 @@ import { rustToolchain, rustTarget, rustKey } from "./helpers"; const cwd = process.cwd(); let tmpDir: string; const pemPath = path.resolve("wallets", "wallet.pem"); + const keyKeystorePath = path.resolve("wallets", "keystore_key.json"); const mneKeystorePath = path.resolve("wallets", "keystore_mnemonic.json"); diff --git a/xsuite/src/cli/cmd.ts b/xsuite/src/cli/cmd.ts index 6d63ecc1..3b518695 100644 --- a/xsuite/src/cli/cmd.ts +++ b/xsuite/src/cli/cmd.ts @@ -1,6 +1,7 @@ import { Command } from "commander"; import { pkgVersion } from "../_pkg"; import { registerBuildCmd } from "./buildAction"; +import { registerGenerateProxy } from "./generateproxy/generateproxy"; import { registerInstallRustCmd } from "./installRustCmd"; import { registerInstallRustKeyCmd } from "./installRustKeyCmd"; import { registerNewCmd } from "./newCmd"; @@ -22,5 +23,6 @@ export const getCommand = () => { registerTestScenCmd(cmd); registerNewWalletCmd(cmd); registerRequestXegldCmd(cmd); + registerGenerateProxy(cmd); return cmd; }; diff --git a/xsuite/src/cli/generateproxy/decoders.ts b/xsuite/src/cli/generateproxy/decoders.ts new file mode 100644 index 00000000..27a90311 --- /dev/null +++ b/xsuite/src/cli/generateproxy/decoders.ts @@ -0,0 +1,126 @@ +export const generateAbiDecoders = (abi: any) => { + const code = Object.entries(abi.types) + .map((type) => generateTypeDecoder(type)) + .join("\n"); + + return code; +}; + +const generateTypeDecoder = (typeDefinition: any) => { + switch (typeDefinition[1].type) { + case "struct": + return generateStructDecoder(typeDefinition); + case "enum": + case "explicit-enum": + return generateEnumDecoder(typeDefinition); + default: + throw Error(`Type ${typeDefinition[1].type} is not supported`); + } +}; + +const generateStructDecoder = (structDefinition: any) => { + return `export const ${structDefinition[0]}Decoder = () => d.Tuple({ + ${generateFieldsDecoder(structDefinition[1].fields).join("\n ")} +}); + +export const decode${structDefinition[0]} = (encodedData: string): ${ + structDefinition[0] + } => { + return ${structDefinition[0]}Decoder().topDecode(encodedData); +} +`; +}; + +const generateFieldsDecoder = (fieldDefinitions: any) => { + return fieldDefinitions.map((f: any) => `${f.name}: ${mapType(f.type)},`); +}; + +const generateEnumDecoder = (enumDefinition: any) => { + return `export const ${enumDefinition[0]}Decoder = () => d.U8().then((v) => { + const enumValue: ${enumDefinition[0]} = Number(v); + return enumValue; +}); +`; +}; + +export const mapType = (abiType: string): string => { + // handling List + const listMatch = abiType.match(/^List<(.+)>$/); + if (listMatch) { + const innerTypeDecoder: any = mapType(listMatch[1]); + return `d.List(${innerTypeDecoder})`; + } + + // handling Option + const optionMatch = abiType.match(/^Option<(.+)>$/); + if (optionMatch) { + const innerTypeDecoder: any = mapType(optionMatch[1]); + return `d.Option(${innerTypeDecoder})`; + } + + // handling optional + const optionalMatch = abiType.match(/^optional<(.+)>$/); + if (optionalMatch) { + const innerTypeDecoder: any = mapType(optionalMatch[1]); + return `${innerTypeDecoder}`; + } + + // handling tuples + const tupleMatch = abiType.match(/^tuple<(.+)>$/); + if (tupleMatch) { + const innerTypesSeperatedByComma: string = tupleMatch[1]; + // todo splitting + const innerDecoders = innerTypesSeperatedByComma + .split(",") + .map((t) => mapType(t.trim())); + return `d.Tuple(${innerDecoders})`; + } + + // handling arrayN + const arrayNMatch = abiType.match(/^array(\d+)<(.+)>$/); + if (arrayNMatch) { + const arrayLength = Number(arrayNMatch[1]); + const innerType = mapType(arrayNMatch[2]); + const innerTypes: string[] = []; + for (let i = 0; i < arrayLength; i++) { + innerTypes.push(innerType); + } + return `d.Tuple(${innerTypes.join(", ")})`; + } + + // Add mappings for MVX specific types or custom mappings as needed + switch (abiType) { + case "bool": { + return "d.Bool()"; + } + case "u8": + return "d.U8().toNum()"; + case "u16": + return "d.U16().toNum()"; + case "u32": + return "d.U32().toNum()"; + case "u64": + return "d.U64()"; + case "i8": + return "d.I8().toNum()"; + case "i16": + return "d.I16().toNum()"; + case "i32": + return "d.I32().toNum()"; + case "i64": + return "d.I64()"; + case "BigUint": + return "d.U()"; + case "BigInt": + return "d.I()"; + case "Address": + return "d.Addr()"; + case "TokenIdentifier": + case "EgldOrEsdtTokenIdentifier": + return "d.Str()"; + case "bytes": + return "d.Buffer()"; + default: + return `${abiType}Decoder()`; + } +}; diff --git a/xsuite/src/cli/generateproxy/encoders.ts b/xsuite/src/cli/generateproxy/encoders.ts new file mode 100644 index 00000000..ba487c82 --- /dev/null +++ b/xsuite/src/cli/generateproxy/encoders.ts @@ -0,0 +1,123 @@ +export const generateAbiEncoders = (abi: any) => { + const code = Object.entries(abi.types) + .map((type) => generateTypeEncoder(type)) + .join("\n"); + + return code; +}; + +const generateTypeEncoder = (typeDefinition: any) => { + switch (typeDefinition[1].type) { + case "struct": + return generateStructEncoder(typeDefinition); + case "enum": + case "explicit-enum": + return generateEnumEncoder(typeDefinition); + default: + throw Error(`Type ${typeDefinition[1].type} is not supported`); + } +}; + +const generateStructEncoder = (structDefinition: any) => { + return `export const ${structDefinition[0]}Encoder = (data: ${ + structDefinition[0] + }) => e.Tuple( + ${generateFieldsEncoder(structDefinition[1].fields).join("\n ")} +); + +export const encode${structDefinition[0]} = (data: ${ + structDefinition[0] + }): Encodable => { + return ${structDefinition[0]}Encoder(data); +} +`; +}; + +const generateFieldsEncoder = (fieldDefinitions: any) => { + return fieldDefinitions.map( + (f: any) => `${mapType("data." + f.name, f.type)},`, + ); +}; + +const generateEnumEncoder = (enumDefinition: any) => { + return `export const ${enumDefinition[0]}Encoder = (data: ${enumDefinition[0]}) => e.U8(data); +`; +}; + +export const mapType = (abiFieldName: string, abiFieldType: string): string => { + // handling List + const listMatch = abiFieldType.match(/^List<(.+)>$/); + if (listMatch) { + const innerTypeEncoder: any = mapType("d", listMatch[1]); + return `e.List(...${abiFieldName}.map(d => ${innerTypeEncoder}))`; + } + + // handling Option + const optionMatch = abiFieldType.match(/^Option<(.+)>$/); + if (optionMatch) { + const innerTypeEncoder: any = mapType(abiFieldName, optionMatch[1]); + return `e.Option(${abiFieldName} !== null ? ${innerTypeEncoder} : null)`; + } + + // handling optional + const optionalMatch = abiFieldType.match(/^optional<(.+)>$/); + if (optionalMatch) { + const innerTypeEncoder: any = mapType(abiFieldName, optionalMatch[1]); + return `${abiFieldName} !== null ? ${innerTypeEncoder} : undefined`; + } + + // handling tuples + const tupleMatch = abiFieldType.match(/^tuple<(.+)>$/); + if (tupleMatch) { + // todo splitting + const innerTypes: string[] = tupleMatch[1].split(",").map((p) => p.trim()); + const innerEncoders = []; + for (let i = 0; i < innerTypes.length; i++) { + innerEncoders.push(mapType(`${abiFieldName}[${i}]`, innerTypes[i])); + } + return `e.Tuple(${innerEncoders.join(", ")})`; + } + + // handling arrayN + const arrayNMatch = abiFieldType.match(/^array(\d+)<(.+)>$/); + if (arrayNMatch) { + const innerEncoders = mapType("d", arrayNMatch[2]); + return `e.Tuple(...${abiFieldName}.map(d => ${innerEncoders}))`; + } + + // Add mappings for MVX specific types or custom mappings as needed + switch (abiFieldType) { + case "bool": { + return `e.Bool(${abiFieldName})`; + } + case "u8": + return `e.U8(${abiFieldName})`; + case "u16": + return `e.U16(${abiFieldName})`; + case "u32": + return `e.U32(${abiFieldName})`; + case "u64": + return `e.U64(${abiFieldName})`; + case "i8": + return `e.I8(${abiFieldName})`; + case "i16": + return `e.I16(${abiFieldName})`; + case "i32": + return `e.I32(${abiFieldName})`; + case "i64": + return `e.I64(${abiFieldName})`; + case "BigUint": + return `e.U(${abiFieldName})`; + case "BigInt": + return `e.I(${abiFieldName})`; + case "Address": + return `e.Addr(${abiFieldName})`; + case "TokenIdentifier": + case "EgldOrEsdtTokenIdentifier": + return `e.Str(${abiFieldName})`; + case "bytes": + return `e.Buffer(${abiFieldName})`; + default: + return `${abiFieldType}Encoder(${abiFieldName})`; + } +}; diff --git a/xsuite/src/cli/generateproxy/endpoints.ts b/xsuite/src/cli/generateproxy/endpoints.ts new file mode 100644 index 00000000..e4adac32 --- /dev/null +++ b/xsuite/src/cli/generateproxy/endpoints.ts @@ -0,0 +1,74 @@ +import { mapType as mapDecoderType } from "./decoders"; +import { mapType as mapEncoderType } from "./encoders"; +import { mapType } from "./types"; + +export const generateAbiEndpoints = (abi: any) => { + const code = Object.entries(abi.endpoints) + .map((e) => generateEndpoint(e[1])) + .join("\n"); + + return code; +}; + +const generateEndpoint = (endpoint: any) => { + const args = buildArguments(endpoint.inputs).join(", "); + const inputRequestArguments = buildEncodedInput(endpoint.inputs); + const outputDecoders = buildDecodedOutput(endpoint.outputs); + + return `export const ${endpoint.name}Builder = () => ({ + functionName: "${endpoint.name}", + encodeInput: (${args}) => { + return ${inputRequestArguments}; + }, + decodeOutput: (data: string[]) => + { + ${outputDecoders} + } +}); +`; +}; + +const buildArguments = (inputs: any) => { + return inputs.map((input: any) => `${input.name}: ${mapType(input.type)}`); +}; + +const buildEncodedInput = (inputs: any) => { + const requestParts = inputs.map( + (input: any) => `${mapEncoderType(input.name, input.type)}`, + ); + + if (requestParts.length === 0) { + return "undefined"; + } + if (requestParts.length === 1) { + return `[ ${requestParts[0]} ].filter(p => p !== undefined)`; + } + + return `[ ${requestParts.join(", ")} ].filter(p => p !== undefined)`; +}; + +const buildDecodedOutput = (outputs: any) => { + if (outputs.length === 0) { + return "return null;"; + } + + const matchVariadic = outputs[0].type.match(/^variadic<(.+)>$/); + if (matchVariadic) { + const innerType = matchVariadic[1]; + return `return data.map(item => ${mapDecoderType( + innerType, + )}.topDecode(item));`; + } + + const responseDecoders = outputs.map( + (output: any) => `${mapDecoderType(output.type)}`, + ); + + if (responseDecoders.length === 1) { + return `return data.length === 0 ? null : ${responseDecoders[0]}.topDecode(data[0]);`; + } + + const decoders = responseDecoders.join(", "); + return `const decoders = [ ${decoders} ]; + return decoders.map((d, i) => i >= data.length ? null : d.fromTop(data[i]));`; +}; diff --git a/xsuite/src/cli/generateproxy/generateproxy.test.ts b/xsuite/src/cli/generateproxy/generateproxy.test.ts new file mode 100644 index 00000000..8cff0a9a --- /dev/null +++ b/xsuite/src/cli/generateproxy/generateproxy.test.ts @@ -0,0 +1,298 @@ +import fs from "node:fs"; +import path from "node:path"; +import { test, beforeEach, afterEach, expect } from "@jest/globals"; +import { Encodable } from "../../data/Encodable"; +import { SContract, SWallet, SWorld } from "../../world"; +import { getCommand } from "../cmd"; + +const abiDir = path.resolve("abis"); +const tmpDir = "/tmp/xsuite-tests"; + +const dataTypesAbiPath = path.resolve( + "contracts/datatypes/output", + "datatypes.abi.json", +); +const dataTypesWasmPath = path.resolve( + "contracts/datatypes/output", + "datatypes.wasm", +); + +beforeEach(() => { + if (fs.existsSync(tmpDir)) { + fs.rmSync(tmpDir, { recursive: true, force: true }); + } + fs.mkdirSync(tmpDir); + process.chdir(tmpDir); +}); + +afterEach(() => { + // fs.rmSync(tmpDir, { recursive: true, force: true }); + // process.chdir(cwd); +}); + +test("generateproxy test abis", async () => { + const files = fs.readdirSync(abiDir); + files.forEach(async (file) => { + const filePath = path.resolve(abiDir, file); + await run( + `generateproxy --from-abi ${filePath} --output=${tmpDir}/${file}.ts`, + ); + }); +}); + +test("generateproxy generates types for datatypes smart contract", async () => { + const targetFilePath = `${tmpDir}/datatypes.ts`; + await run( + `generateproxy --from-abi ${dataTypesAbiPath} --output=${targetFilePath}`, + ); + + const world = await SWorld.start(); + try { + const owner = await world.createWallet({ + balance: 10n ** 18n, + }); + const deployedContract = await owner.deployContract({ + code: `file:${dataTypesWasmPath}`, + codeMetadata: [], + gasLimit: 15_000_000, + }); + + const generatedCode = await import(targetFilePath); + + const testCases = loadGenerateProxyTestCases( + deployedContract.contract, + owner, + ); + + for (let i = 0; i < testCases.length; i++) { + const testCase = testCases[0]; + const getResponse = await world.query({ + callee: deployedContract.contract, + funcName: `get${testCase.type}`, + funcArgs: [], + }); + + const decodedType = generatedCode[`decode${testCase.type}`]( + getResponse.returnData[0], + ); + + expect(decodedType).toStrictEqual(testCase.result); + + const encodedData: Encodable = + generatedCode[`encode${testCase.type}`](decodedType); + + const setResponse = await owner.callContract({ + callee: deployedContract.contract, + funcName: `set${testCase.type}`, + funcArgs: [encodedData], + gasLimit: 10_000_000, + }); + + expect(setResponse.returnData[0]).toBe(getResponse.returnData[0]); + } + } finally { + await world.terminate(); + } +}); + +test("generateproxy proccesses optional properly", async () => { + const targetFilePath = `${tmpDir}/datatypes.ts`; + await run( + `generateproxy --from-abi ${dataTypesAbiPath} --output=${targetFilePath}`, + ); + + const generatedCode = await import(targetFilePath); + const builder = generatedCode.getOptionalValue1stArgBuilder(); + await queryAndVerify(builder, [null], null); + await queryAndVerify(builder, [0], 0); + await queryAndVerify(builder, [1], 1); + + const builder2 = generatedCode.getOptionalValue2ndArgBuilder(); + await queryAndVerify(builder2, [0, null], [0, null]); + await queryAndVerify(builder2, [0, 0], [0, 0]); + await queryAndVerify(builder2, [0, 1], [0, 1]); +}); + +test("generateproxy processes VecMapper properly", async () => { + const targetFilePath = `${tmpDir}/datatypes.ts`; + await run( + `generateproxy --from-abi ${dataTypesAbiPath} --output=${targetFilePath}`, + ); + + const generatedCode = await import(targetFilePath); + const builder = generatedCode.getVecMapperBuilder(); + await queryAndVerify(builder, [0], [1n, 2n]); + await queryAndVerify(builder, [1], [10n, 11n]); +}); + +test("generateproxy processes SetMapper properly", async () => { + const targetFilePath = `${tmpDir}/datatypes.ts`; + await run( + `generateproxy --from-abi ${dataTypesAbiPath} --output=${targetFilePath}`, + ); + + const generatedCode = await import(targetFilePath); + const builder = generatedCode.getSetMapperBuilder(); + await queryAndVerify(builder, [0], [1n, 2n, 3n]); + await queryAndVerify(builder, [1], [5n, 6n, 7n]); +}); + +test("generateproxy processes UnorderedSetMapper properly", async () => { + const targetFilePath = `${tmpDir}/datatypes.ts`; + await run( + `generateproxy --from-abi ${dataTypesAbiPath} --output=${targetFilePath}`, + ); + + const generatedCode = await import(targetFilePath); + const builder = generatedCode.getUnorderedSetMapperBuilder(); + await queryAndVerify(builder, [0], [1n, 2n]); + await queryAndVerify(builder, [1], [5n, 6n]); +}); + +test("generateproxy processes MapMapper properly", async () => { + const targetFilePath = `${tmpDir}/datatypes.ts`; + await run( + `generateproxy --from-abi ${dataTypesAbiPath} --output=${targetFilePath}`, + ); + + const generatedCode = await import(targetFilePath); + const builder = generatedCode.getMapMapperBuilder(); + await queryAndVerify(builder, [0], [1n, 2n]); + await queryAndVerify(builder, [1], [5n, 6n]); +}); + +const queryAndVerify = async ( + builder: any, + input: any[], + expectedOutput: any, +) => { + const world = await SWorld.start(); + try { + const owner = await world.createWallet({ + balance: 10n ** 18n, + }); + + const deployedContract = await owner.deployContract({ + code: `file:${dataTypesWasmPath}`, + codeMetadata: [], + gasLimit: 15_000_000, + }); + + const funcArgs = builder.encodeInput(...input); + const response = await world.query({ + callee: deployedContract.contract, + funcName: builder.functionName, + funcArgs, + }); + + const decodedData = builder.decodeOutput(response.returnData); + expect(decodedData).toStrictEqual(expectedOutput); + } finally { + await world.terminate(); + } +}; + +const loadGenerateProxyTestCases = (contract: SContract, owner: SWallet) => [ + { + type: "PrimitiveDataTypes", + result: { + boolean: true, + unsigned16: 1000, + unsigned32: 100000, + unsigned64: 1000000000000000000n, + unsigned8: 10, + unsigned_size: 200000, + signed16: 500, + signed32: 50000, + signed64: 500000000000000000n, + signed8: 5, + signed_size: 300000, + enumeration: 1, + }, + }, + { + type: "ManagedDataTypes", + result: { + managed_buffer: new TextEncoder().encode("abcd"), + big_integer: 10000000000n, + big_unsigned_integer: 20000000000n, + address: contract.toString(), + token_identifer: "ABCDEF-123456", + esdt_token_payment: { + amount: 1000000n, + token_identifier: "ABCDEF-123456", + token_nonce: 120n, + }, + egld_or_esdt_token_identifer: "ABCDEF-123456", + egld_or_esdt_token_payment: { + amount: 2000000n, + token_identifier: "ABCDEF-123456", + token_nonce: 360n, + }, + }, + }, + { + type: "OptionDataTypes", + result: { + option_of_biguint_set: 420n, + option_of_biguint_not_set: null, + option_of_subtype_set: { + address: contract.toString(), + big_unsigned_integer: 12n, + }, + option_of_subtype_not_set: null, + }, + }, + { + type: "ArrayDataTypes", + result: { + managed_vec_of_u16: [12, 26, 3], + managed_vec_of_subtype: [ + { + address: contract.toString(), + big_unsigned_integer: 14n, + }, + { + address: owner.toString(), + big_unsigned_integer: 133n, + }, + ], + fixed_array: [1, 2, 3, 4, 5], + fixed_array_complex: [ + { + address: contract.toString(), + big_unsigned_integer: 100000000n, + }, + { + address: contract.toString(), + big_unsigned_integer: 200000000n, + }, + { + address: contract.toString(), + big_unsigned_integer: 300000000n, + }, + ], + tuples: [10, 300], + tuples_complex: [ + 20, + { + address: contract.toString(), + big_unsigned_integer: 300000000n, + }, + ], + }, + }, + { + type: "OtherDataTypes", + result: { + custom_type: { + address: + "erd1qqqqqqqqqqqqqqqqqqqqqqqqqyqqqqqqqqqqqqqqqqqqqqqqqqqq8u9arm", + big_unsigned_integer: 100000000n, + }, + }, + }, +]; + +const run = (c: string) => + getCommand().parseAsync(c.split(" "), { from: "user" }); diff --git a/xsuite/src/cli/generateproxy/generateproxy.ts b/xsuite/src/cli/generateproxy/generateproxy.ts new file mode 100644 index 00000000..c6d09289 --- /dev/null +++ b/xsuite/src/cli/generateproxy/generateproxy.ts @@ -0,0 +1,43 @@ +import fs from "node:fs"; +import { Command } from "commander"; +import { generateAbiDecoders } from "./decoders"; +import { generateAbiEncoders } from "./encoders"; +import { generateAbiEndpoints } from "./endpoints"; +import { generateAbiTypes } from "./types"; + +export const registerGenerateProxy = (cmd: Command) => { + cmd + .command("generateproxy") + .requiredOption("--from-abi ", "abi path") + .requiredOption("--output ", "output path") + .description( + "Generate the required encoders, decoders, endpoints and interfaces from the provided abi.", + ) + .action(action); +}; + +const action = async ({ + fromAbi: abiFilePath, + output: outputFilePath, +}: { + fromAbi: string; + output: string; +}) => { + // Read and parse the ABI JSON from file + const abiJson = JSON.parse(fs.readFileSync(abiFilePath, "utf-8")); + + let code = `import { d } from "xsuite"; +import { e } from "xsuite"; +import { Encodable } from "xsuite/dist/data/Encodable"; + +`; + code += generateAbiTypes(abiJson); + code += "\n"; + code += generateAbiDecoders(abiJson); + code += "\n"; + code += generateAbiEncoders(abiJson); + code += "\n"; + code += generateAbiEndpoints(abiJson); + + fs.writeFileSync(outputFilePath, code); +}; diff --git a/xsuite/src/cli/generateproxy/types.ts b/xsuite/src/cli/generateproxy/types.ts new file mode 100644 index 00000000..256e63c1 --- /dev/null +++ b/xsuite/src/cli/generateproxy/types.ts @@ -0,0 +1,119 @@ +export const generateAbiTypes = (abi: any) => { + const code = Object.entries(abi.types) + .map((type) => generateType(type)) + .join("\n"); + + return code; +}; + +const generateType = (typeDefinition: any) => { + switch (typeDefinition[1].type) { + case "struct": + return generateInterface(typeDefinition); + case "enum": + return generateEnum(typeDefinition); + case "explicit-enum": + return generateExplicitEnum(typeDefinition); + default: + throw Error(`Type ${typeDefinition[1].type} is not supported`); + } +}; + +const generateInterface = (typeDefinition: any) => { + return `export interface ${typeDefinition[0]} { + ${generateFields(typeDefinition[1].fields).join("\n ")} +} +`; +}; + +const generateFields = (fieldDefinitions: any) => { + return fieldDefinitions.map((f: any) => `${f.name}: ${mapType(f.type)},`); +}; + +const generateEnum = (enumDefinition: any) => { + return `export enum ${enumDefinition[0]} { + ${generateEnumVariants(enumDefinition[1].variants).join("\n ")} +} +`; +}; + +const generateEnumVariants = (variantDefinitions: any) => { + return variantDefinitions.map((v: any) => `${v.name} = ${v.discriminant},`); +}; + +const generateExplicitEnum = (enumDefinition: any) => { + return `export enum ${enumDefinition[0]} { + ${generateExplicitEnumVariants(enumDefinition[1].variants).join("\n ")} +} +`; +}; + +const generateExplicitEnumVariants = (variantDefinitions: any) => { + return variantDefinitions.map((v: any) => `${v.name}, // ${v.docs}`); +}; + +export const mapType = (abiType: string): string => { + // handling List + const listMatch = abiType.match(/^List<(.+)>$/); + if (listMatch) { + const innerType: any = mapType(listMatch[1]); + return `${innerType}[]`; + } + + // handling Option + const optionMatch = abiType.match(/^(Option|optional)<(.+)>$/); + if (optionMatch) { + const innerType: any = mapType(optionMatch[2]); + return `(${innerType} | null)`; + } + + // handling tuples + const tupleMatch = abiType.match(/^tuple<(.+)>$/); + if (tupleMatch) { + const innerTypesSeperatedByComma: string = tupleMatch[1]; + const innerTypes = innerTypesSeperatedByComma + .split(",") + .map((t) => mapType(t.trim())); + return `readonly [${innerTypes.join(", ")}]`; + } + + // handling arrayN + const arrayNMatch = abiType.match(/^array(\d+)<(.+)>$/); + if (arrayNMatch) { + const arrayLength = Number(arrayNMatch[1]); + const innerType = mapType(arrayNMatch[2]); + const innerTypes: string[] = []; + for (let i = 0; i < arrayLength; i++) { + innerTypes.push(innerType); + } + return `readonly [${innerTypes.join(", ")}]`; + } + + // Add mappings for MVX specific types or custom mappings as needed + switch (abiType) { + case "bool": { + return "boolean"; + } + case "u8": + case "u16": + case "u32": + case "i8": + case "i16": + case "i32": + return "number"; + case "u64": + case "i64": + case "BigUint": + case "BigInt": + return "bigint"; + case "Address": + return "string"; + case "TokenIdentifier": + case "EgldOrEsdtTokenIdentifier": + return "string"; + case "bytes": + return "Uint8Array"; + default: + return abiType; + } +}; diff --git a/xsuite/src/cli/generateproxy/utils.test.ts b/xsuite/src/cli/generateproxy/utils.test.ts new file mode 100644 index 00000000..3a5d5d02 --- /dev/null +++ b/xsuite/src/cli/generateproxy/utils.test.ts @@ -0,0 +1,21 @@ +import { test, expect } from "@jest/globals"; +import { splitCommaSeperatedArgs } from "./utils"; + +test("splitCommaSeperatedArgs splits 'tuple,BigUint'", () => { + const commaseperatedTypes = "tuple,BigUint"; + expect(splitCommaSeperatedArgs(commaseperatedTypes)).toStrictEqual([ + "tuple", + "BigUint", + ]); +}); + +test("splitCommaSeperatedArgs splits 'BigUint,u8,BigUInt,Tuple,TokenIdentifier,u16>'", () => { + const commaseperatedTypes = + "BigUint,u8,BigUint,tuple,TokenIdentifier,u16>"; + expect(splitCommaSeperatedArgs(commaseperatedTypes)).toStrictEqual([ + "BigUint", + "u8", + "BigUint", + "tuple,TokenIdentifier,u16>", + ]); +}); diff --git a/xsuite/src/cli/generateproxy/utils.ts b/xsuite/src/cli/generateproxy/utils.ts new file mode 100644 index 00000000..bce16f25 --- /dev/null +++ b/xsuite/src/cli/generateproxy/utils.ts @@ -0,0 +1,26 @@ +export const splitCommaSeperatedArgs = (input: string) => { + const result = []; + let currentSegment = ""; + let angleBracketCount = 0; + + for (const char of input) { + if (char === "," && angleBracketCount === 0) { + result.push(currentSegment); + currentSegment = ""; + } else { + currentSegment += char; + + if (char === "<") { + angleBracketCount++; + } else if (char === ">") { + angleBracketCount--; + } + } + } + + if (currentSegment !== "") { + result.push(currentSegment); + } + + return result; +}; From e80a157fa80d0d75619e617ef99e254dec4a24f9 Mon Sep 17 00:00:00 2001 From: janniksam Date: Fri, 26 Jan 2024 22:13:47 +0100 Subject: [PATCH 2/3] currentstate --- xsuite/cli.js | 0 .../datatypes/output/datatypes.abi.json | 146 +++++++++- .../contracts/datatypes/output/datatypes.wasm | Bin 11950 -> 14695 bytes xsuite/contracts/datatypes/src/lib.rs | 64 ++++- .../datatypes/src/types/data_types.rs | 5 +- xsuite/src/cli/cmd.test.ts | 1 - xsuite/src/cli/generateproxy/abi.ts | 57 ++++ .../abis/supported}/adder.abi.json | 0 .../bonding-curve-contract.abi.json | 0 .../abis/supported}/check-pause.abi.json | 0 .../supported}/crowdfunding-esdt.abi.json | 0 .../abis/supported}/crypto-bubbles.abi.json | 0 .../abis/supported}/crypto-zombies.abi.json | 0 .../abis/supported}/digital-cash.abi.json | 0 .../abis/supported}/empty.abi.json | 0 .../esdt-transfer-with-fee.abi.json | 0 .../abis/supported}/factorial.abi.json | 0 .../abis/supported}/fractional-nfts.abi.json | 0 .../abis/supported}/kitty-auction.abi.json | 0 .../supported}/kitty-genetic-alg.abi.json | 0 .../abis/supported}/kitty-ownership.abi.json | 0 .../abis/supported}/liquid-locking.abi.json | 0 .../abis/supported}/lottery-esdt.abi.json | 0 .../abis/supported}/multisig-full.abi.json | 0 .../abis/supported}/multisig-view.abi.json | 0 .../abis/supported}/multisig.abi.json | 0 .../multiversx-price-aggregator-sc.abi.json | 0 .../multiversx-wegld-swap-sc.abi.json | 0 .../abis/supported}/mvx-game-sc.abi.json | 0 .../abis/supported}/mystery-box.abi.json | 0 .../abis/supported}/nft-escrow.abi.json | 0 .../supported}/nft-storage-prepay.abi.json | 0 .../supported}/order-book-factory.abi.json | 0 .../abis/supported}/order-book-pair.abi.json | 0 .../abis/supported}/paymaster.abi.json | 0 .../abis/supported}/ping-pong-egld.abi.json | 0 .../abis/supported}/proxy-pause.abi.json | 0 .../supported}/rewards-distribution.abi.json | 0 .../abis/supported}/token-release.abi.json | 0 .../abis/unsupported}/nft-minter.abi.json | 0 .../unsupported}/seed-nft-minter.abi.json | 0 .../unsupported/type_not_supported.abi.json | 19 ++ xsuite/src/cli/generateproxy/decoders.ts | 67 +++-- xsuite/src/cli/generateproxy/encoders.ts | 69 +++-- .../src/cli/generateproxy/endpointinputs.ts | 85 ++++++ .../src/cli/generateproxy/endpointoutputs.ts | 82 ++++++ xsuite/src/cli/generateproxy/endpoints.ts | 91 +++---- .../cli/generateproxy/generateproxy.test.ts | 257 +++++++++++++++--- xsuite/src/cli/generateproxy/generateproxy.ts | 11 +- .../AbstractMultiValueHandler.ts | 17 ++ .../multiHandlers/IgnoreHandler.ts | 13 + .../multiHandlers/MultiHandler.ts | 35 +++ .../multiHandlers/OptionalHandler.ts | 57 ++++ .../multiHandlers/VariadicHandler.ts | 103 +++++++ xsuite/src/cli/generateproxy/types.ts | 62 +++-- xsuite/src/cli/generateproxy/utils.test.ts | 16 +- xsuite/src/cli/generateproxy/utils.ts | 2 +- 57 files changed, 1077 insertions(+), 182 deletions(-) mode change 100644 => 100755 xsuite/cli.js create mode 100644 xsuite/src/cli/generateproxy/abi.ts rename xsuite/{abis => src/cli/generateproxy/abis/supported}/adder.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/bonding-curve-contract.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/check-pause.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/crowdfunding-esdt.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/crypto-bubbles.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/crypto-zombies.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/digital-cash.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/empty.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/esdt-transfer-with-fee.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/factorial.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/fractional-nfts.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/kitty-auction.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/kitty-genetic-alg.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/kitty-ownership.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/liquid-locking.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/lottery-esdt.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/multisig-full.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/multisig-view.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/multisig.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/multiversx-price-aggregator-sc.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/multiversx-wegld-swap-sc.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/mvx-game-sc.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/mystery-box.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/nft-escrow.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/nft-storage-prepay.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/order-book-factory.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/order-book-pair.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/paymaster.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/ping-pong-egld.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/proxy-pause.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/rewards-distribution.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/supported}/token-release.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/unsupported}/nft-minter.abi.json (100%) rename xsuite/{abis => src/cli/generateproxy/abis/unsupported}/seed-nft-minter.abi.json (100%) create mode 100644 xsuite/src/cli/generateproxy/abis/unsupported/type_not_supported.abi.json create mode 100644 xsuite/src/cli/generateproxy/endpointinputs.ts create mode 100644 xsuite/src/cli/generateproxy/endpointoutputs.ts create mode 100644 xsuite/src/cli/generateproxy/multiHandlers/AbstractMultiValueHandler.ts create mode 100644 xsuite/src/cli/generateproxy/multiHandlers/IgnoreHandler.ts create mode 100644 xsuite/src/cli/generateproxy/multiHandlers/MultiHandler.ts create mode 100644 xsuite/src/cli/generateproxy/multiHandlers/OptionalHandler.ts create mode 100644 xsuite/src/cli/generateproxy/multiHandlers/VariadicHandler.ts diff --git a/xsuite/cli.js b/xsuite/cli.js old mode 100644 new mode 100755 diff --git a/xsuite/contracts/datatypes/output/datatypes.abi.json b/xsuite/contracts/datatypes/output/datatypes.abi.json index b09c1fdd..9814f7a4 100644 --- a/xsuite/contracts/datatypes/output/datatypes.abi.json +++ b/xsuite/contracts/datatypes/output/datatypes.abi.json @@ -118,7 +118,7 @@ ] }, { - "name": "setArrayrDataTypes", + "name": "setArrayDataTypes", "mutability": "mutable", "inputs": [ { @@ -164,6 +164,25 @@ } ] }, + { + "name": "getPrimitiveMultiValue2", + "mutability": "readonly", + "inputs": [ + { + "name": "multivalue", + "type": "multi", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "u8" + }, + { + "type": "Address" + } + ] + }, { "name": "getOptionalValue2ndArg", "mutability": "readonly", @@ -188,6 +207,111 @@ } ] }, + { + "name": "getOptionalMultiValueEncoded", + "mutability": "readonly", + "inputs": [ + { + "name": "_id", + "type": "u64" + }, + { + "name": "value", + "type": "optional>>", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "optional>>", + "multi_result": true + } + ] + }, + { + "name": "getOptionalMultiValue3", + "mutability": "readonly", + "inputs": [ + { + "name": "_id", + "type": "u64" + }, + { + "name": "value", + "type": "optional>", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "optional>", + "multi_result": true + } + ] + }, + { + "name": "getMultiValueEncoded", + "mutability": "readonly", + "inputs": [ + { + "name": "_id", + "type": "u64" + }, + { + "name": "value", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "variadic
", + "multi_result": true + } + ] + }, + { + "name": "getMultiValueEncodedWithMultiValue2", + "mutability": "readonly", + "inputs": [ + { + "name": "_id", + "type": "u64" + }, + { + "name": "value", + "type": "variadic>", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "variadic>", + "multi_result": true + } + ] + }, + { + "name": "getIgnoreValue", + "mutability": "readonly", + "inputs": [ + { + "name": "_id", + "type": "u64" + }, + { + "name": "value", + "type": "ignore", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "ignore", + "multi_result": true + } + ] + }, { "name": "getSingleValueMapper", "mutability": "readonly", @@ -266,6 +390,22 @@ "multi_result": true } ] + }, + { + "name": "getMapMapperComplex", + "mutability": "readonly", + "inputs": [ + { + "name": "input", + "type": "u8" + } + ], + "outputs": [ + { + "type": "variadic>>", + "multi_result": true + } + ] } ], "esdtAttributes": [], @@ -415,6 +555,10 @@ { "name": "custom_type", "type": "SubType" + }, + { + "name": "code_metadata", + "type": "CodeMetadata" } ] }, diff --git a/xsuite/contracts/datatypes/output/datatypes.wasm b/xsuite/contracts/datatypes/output/datatypes.wasm index 3ffcbc87637be4c74b9a6edb825029a699b5b46c..d5594ae8a2082142ab856f16798a9d672659d6b8 100755 GIT binary patch literal 14695 zcmc(mX^>sVRmZ#g-uLFs+*#Vz*d9+5xbH^MqZqYkJ|=(vz&IKjl}$bcQBR z4TPD`hc(Z$=K0vI4*u1&hDEmQUbD=3e$BX#*2a_0;<@1`XHMO}x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mcx7cNZ9 zO;4qKo^MX%KUq$vnv;uD&9o^$D^5r59o6NhnlGlsiY3|4uU;>%L0)WuE?qc3|3b5s zE}mMOSUYg(%wlW#@X=$3cFxO>A*XgOaLV}f)XwSU=KRj-g;R?GGB>?2yR=hD0y@?F z0LRJid)Lu5n(mxyE`VrUk+t|)XFj^noGf7a^UQI@l!ML}zq}k@+n^N6&np-8H>(qK z`3|^kHP4-&=69Ooj3-{0oXQ#p4;?Ch-^e HJ;wh4L%{{0 diff --git a/xsuite/contracts/datatypes/src/lib.rs b/xsuite/contracts/datatypes/src/lib.rs index 7776a55c..ff81427f 100644 --- a/xsuite/contracts/datatypes/src/lib.rs +++ b/xsuite/contracts/datatypes/src/lib.rs @@ -33,6 +33,14 @@ pub trait DataTypes { self.map_mapper(0).insert(1, 2); self.map_mapper(1).insert(1, 10); self.map_mapper(1).insert(2, 11); + self.map_mapper_complex(0) + .insert(0, (0, BigUint::from(12u16), 4)); + self.map_mapper_complex(0) + .insert(1, (1, BigUint::from(24u16), 5)); + self.map_mapper_complex(1) + .insert(0, (2, BigUint::from(48u16), 6)); + self.map_mapper_complex(1) + .insert(1, (3, BigUint::from(72u16), 7)); } #[view(getPrimitiveDataTypes)] @@ -131,6 +139,7 @@ pub trait DataTypes { address: self.blockchain().get_sc_address(), big_unsigned_integer: BigUint::from(100000000u64), }, + code_metadata: CodeMetadata::UPGRADEABLE, }; return types; } @@ -153,7 +162,7 @@ pub trait DataTypes { data } - #[endpoint(setArrayrDataTypes)] + #[endpoint(setArrayDataTypes)] fn set_array_datatypes(&self, data: ArrayDataTypes) -> ArrayDataTypes { data } @@ -171,6 +180,14 @@ pub trait DataTypes { optional_value_arg } + #[view(getPrimitiveMultiValue2)] + fn get_primitive_mutlivalue2( + &self, + multivalue: MultiValue2, + ) -> MultiValue2 { + multivalue + } + #[view(getOptionalValue2ndArg)] fn get_optional_value_2nd_arg( &self, @@ -181,6 +198,47 @@ pub trait DataTypes { result } + #[view(getOptionalMultiValueEncoded)] + fn get_optional_multi_value_encoded( + &self, + _id: u64, + value: OptionalValue>, + ) -> OptionalValue> { + value + } + + #[view(getOptionalMultiValue3)] + fn get_optional_multi_value_3( + &self, + _id: u64, + value: OptionalValue>, + ) -> OptionalValue> { + value + } + + #[view(getMultiValueEncoded)] + fn get_multi_value_encoded( + &self, + _id: u64, + value: MultiValueEncoded, + ) -> MultiValueEncoded { + value + } + + #[view(getMultiValueEncodedWithMultiValue2)] + fn get_multi_value_encoded_with_multivalue2( + &self, + _id: u64, + value: MultiValueEncoded>, + ) -> MultiValueEncoded> { + value + } + + #[view(getIgnoreValue)] + fn get_ignore_value(&self, _id: u64, value: IgnoreValue) -> IgnoreValue { + value + } + #[view(getSingleValueMapper)] #[storage_mapper("single_value_mapper")] fn single_value_mapper(&self, input: u8) -> SingleValueMapper; @@ -201,6 +259,10 @@ pub trait DataTypes { #[storage_mapper("map_mapper")] fn map_mapper(&self, input: u8) -> MapMapper; + #[view(getMapMapperComplex)] + #[storage_mapper("map_mapper_complex")] + fn map_mapper_complex(&self, input: u8) -> MapMapper; + fn get_sample_mvec(&self) -> ManagedVec { let mut vec = ManagedVec::new(); vec.push(12u16); diff --git a/xsuite/contracts/datatypes/src/types/data_types.rs b/xsuite/contracts/datatypes/src/types/data_types.rs index 751bfcdf..54a7e050 100644 --- a/xsuite/contracts/datatypes/src/types/data_types.rs +++ b/xsuite/contracts/datatypes/src/types/data_types.rs @@ -1,8 +1,8 @@ use multiversx_sc::{ api::ManagedTypeApi, types::{ - BigInt, BigUint, EgldOrEsdtTokenIdentifier, EgldOrEsdtTokenPayment, EsdtTokenPayment, - ManagedAddress, ManagedBuffer, ManagedVec, TokenIdentifier, + BigInt, BigUint, CodeMetadata, EgldOrEsdtTokenIdentifier, EgldOrEsdtTokenPayment, + EsdtTokenPayment, ManagedAddress, ManagedBuffer, ManagedVec, TokenIdentifier, }, }; @@ -73,4 +73,5 @@ pub struct ArrayDataTypes { pub struct OtherDataTypes { pub custom_type: SubType, // pub complex_enum: ComplexEnum, + pub code_metadata: CodeMetadata, } diff --git a/xsuite/src/cli/cmd.test.ts b/xsuite/src/cli/cmd.test.ts index af7f31b8..1672e672 100644 --- a/xsuite/src/cli/cmd.test.ts +++ b/xsuite/src/cli/cmd.test.ts @@ -14,7 +14,6 @@ import { rustToolchain, rustTarget, rustKey } from "./helpers"; const cwd = process.cwd(); let tmpDir: string; const pemPath = path.resolve("wallets", "wallet.pem"); - const keyKeystorePath = path.resolve("wallets", "keystore_key.json"); const mneKeystorePath = path.resolve("wallets", "keystore_mnemonic.json"); diff --git a/xsuite/src/cli/generateproxy/abi.ts b/xsuite/src/cli/generateproxy/abi.ts new file mode 100644 index 00000000..59aa6245 --- /dev/null +++ b/xsuite/src/cli/generateproxy/abi.ts @@ -0,0 +1,57 @@ +export interface AbiDefinition { + types: ContractTypeDefinition; + endpoints?: EndpointDefinition[]; +} + +export interface EndpointDefinition { + name: string; + mutability?: EndpointMutability; + onlyOwner?: boolean; + docs?: string[]; + inputs: InputDefinition[]; + outputs: OutputDefinition[]; + payableInTokens?: string[]; +} + +export interface InputDefinition { + name: string; + type: string; + multi_arg?: boolean; +} + +export enum EndpointMutability { + mutable = "mutable", + readonly = "readonly", +} + +export interface OutputDefinition { + type: string; + multi_result?: boolean; +} + +export interface FieldDefinition { + name: string; + type: string; + docs?: string[]; +} + +export interface ContractTypeDefinition { + [key: string]: TypeDefinition; +} + +export enum ContractType { + struct = "struct", + enum = "enum", + explicitEnum = "explicit-enum", +} + +export interface TypeDefinition { + type: ContractType; + fields?: FieldDefinition[]; + variants?: { + name: string; + discriminant: string | number; + fields?: FieldDefinition[]; + docs?: string[]; + }[]; +} diff --git a/xsuite/abis/adder.abi.json b/xsuite/src/cli/generateproxy/abis/supported/adder.abi.json similarity index 100% rename from xsuite/abis/adder.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/adder.abi.json diff --git a/xsuite/abis/bonding-curve-contract.abi.json b/xsuite/src/cli/generateproxy/abis/supported/bonding-curve-contract.abi.json similarity index 100% rename from xsuite/abis/bonding-curve-contract.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/bonding-curve-contract.abi.json diff --git a/xsuite/abis/check-pause.abi.json b/xsuite/src/cli/generateproxy/abis/supported/check-pause.abi.json similarity index 100% rename from xsuite/abis/check-pause.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/check-pause.abi.json diff --git a/xsuite/abis/crowdfunding-esdt.abi.json b/xsuite/src/cli/generateproxy/abis/supported/crowdfunding-esdt.abi.json similarity index 100% rename from xsuite/abis/crowdfunding-esdt.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/crowdfunding-esdt.abi.json diff --git a/xsuite/abis/crypto-bubbles.abi.json b/xsuite/src/cli/generateproxy/abis/supported/crypto-bubbles.abi.json similarity index 100% rename from xsuite/abis/crypto-bubbles.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/crypto-bubbles.abi.json diff --git a/xsuite/abis/crypto-zombies.abi.json b/xsuite/src/cli/generateproxy/abis/supported/crypto-zombies.abi.json similarity index 100% rename from xsuite/abis/crypto-zombies.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/crypto-zombies.abi.json diff --git a/xsuite/abis/digital-cash.abi.json b/xsuite/src/cli/generateproxy/abis/supported/digital-cash.abi.json similarity index 100% rename from xsuite/abis/digital-cash.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/digital-cash.abi.json diff --git a/xsuite/abis/empty.abi.json b/xsuite/src/cli/generateproxy/abis/supported/empty.abi.json similarity index 100% rename from xsuite/abis/empty.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/empty.abi.json diff --git a/xsuite/abis/esdt-transfer-with-fee.abi.json b/xsuite/src/cli/generateproxy/abis/supported/esdt-transfer-with-fee.abi.json similarity index 100% rename from xsuite/abis/esdt-transfer-with-fee.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/esdt-transfer-with-fee.abi.json diff --git a/xsuite/abis/factorial.abi.json b/xsuite/src/cli/generateproxy/abis/supported/factorial.abi.json similarity index 100% rename from xsuite/abis/factorial.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/factorial.abi.json diff --git a/xsuite/abis/fractional-nfts.abi.json b/xsuite/src/cli/generateproxy/abis/supported/fractional-nfts.abi.json similarity index 100% rename from xsuite/abis/fractional-nfts.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/fractional-nfts.abi.json diff --git a/xsuite/abis/kitty-auction.abi.json b/xsuite/src/cli/generateproxy/abis/supported/kitty-auction.abi.json similarity index 100% rename from xsuite/abis/kitty-auction.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/kitty-auction.abi.json diff --git a/xsuite/abis/kitty-genetic-alg.abi.json b/xsuite/src/cli/generateproxy/abis/supported/kitty-genetic-alg.abi.json similarity index 100% rename from xsuite/abis/kitty-genetic-alg.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/kitty-genetic-alg.abi.json diff --git a/xsuite/abis/kitty-ownership.abi.json b/xsuite/src/cli/generateproxy/abis/supported/kitty-ownership.abi.json similarity index 100% rename from xsuite/abis/kitty-ownership.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/kitty-ownership.abi.json diff --git a/xsuite/abis/liquid-locking.abi.json b/xsuite/src/cli/generateproxy/abis/supported/liquid-locking.abi.json similarity index 100% rename from xsuite/abis/liquid-locking.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/liquid-locking.abi.json diff --git a/xsuite/abis/lottery-esdt.abi.json b/xsuite/src/cli/generateproxy/abis/supported/lottery-esdt.abi.json similarity index 100% rename from xsuite/abis/lottery-esdt.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/lottery-esdt.abi.json diff --git a/xsuite/abis/multisig-full.abi.json b/xsuite/src/cli/generateproxy/abis/supported/multisig-full.abi.json similarity index 100% rename from xsuite/abis/multisig-full.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/multisig-full.abi.json diff --git a/xsuite/abis/multisig-view.abi.json b/xsuite/src/cli/generateproxy/abis/supported/multisig-view.abi.json similarity index 100% rename from xsuite/abis/multisig-view.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/multisig-view.abi.json diff --git a/xsuite/abis/multisig.abi.json b/xsuite/src/cli/generateproxy/abis/supported/multisig.abi.json similarity index 100% rename from xsuite/abis/multisig.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/multisig.abi.json diff --git a/xsuite/abis/multiversx-price-aggregator-sc.abi.json b/xsuite/src/cli/generateproxy/abis/supported/multiversx-price-aggregator-sc.abi.json similarity index 100% rename from xsuite/abis/multiversx-price-aggregator-sc.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/multiversx-price-aggregator-sc.abi.json diff --git a/xsuite/abis/multiversx-wegld-swap-sc.abi.json b/xsuite/src/cli/generateproxy/abis/supported/multiversx-wegld-swap-sc.abi.json similarity index 100% rename from xsuite/abis/multiversx-wegld-swap-sc.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/multiversx-wegld-swap-sc.abi.json diff --git a/xsuite/abis/mvx-game-sc.abi.json b/xsuite/src/cli/generateproxy/abis/supported/mvx-game-sc.abi.json similarity index 100% rename from xsuite/abis/mvx-game-sc.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/mvx-game-sc.abi.json diff --git a/xsuite/abis/mystery-box.abi.json b/xsuite/src/cli/generateproxy/abis/supported/mystery-box.abi.json similarity index 100% rename from xsuite/abis/mystery-box.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/mystery-box.abi.json diff --git a/xsuite/abis/nft-escrow.abi.json b/xsuite/src/cli/generateproxy/abis/supported/nft-escrow.abi.json similarity index 100% rename from xsuite/abis/nft-escrow.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/nft-escrow.abi.json diff --git a/xsuite/abis/nft-storage-prepay.abi.json b/xsuite/src/cli/generateproxy/abis/supported/nft-storage-prepay.abi.json similarity index 100% rename from xsuite/abis/nft-storage-prepay.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/nft-storage-prepay.abi.json diff --git a/xsuite/abis/order-book-factory.abi.json b/xsuite/src/cli/generateproxy/abis/supported/order-book-factory.abi.json similarity index 100% rename from xsuite/abis/order-book-factory.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/order-book-factory.abi.json diff --git a/xsuite/abis/order-book-pair.abi.json b/xsuite/src/cli/generateproxy/abis/supported/order-book-pair.abi.json similarity index 100% rename from xsuite/abis/order-book-pair.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/order-book-pair.abi.json diff --git a/xsuite/abis/paymaster.abi.json b/xsuite/src/cli/generateproxy/abis/supported/paymaster.abi.json similarity index 100% rename from xsuite/abis/paymaster.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/paymaster.abi.json diff --git a/xsuite/abis/ping-pong-egld.abi.json b/xsuite/src/cli/generateproxy/abis/supported/ping-pong-egld.abi.json similarity index 100% rename from xsuite/abis/ping-pong-egld.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/ping-pong-egld.abi.json diff --git a/xsuite/abis/proxy-pause.abi.json b/xsuite/src/cli/generateproxy/abis/supported/proxy-pause.abi.json similarity index 100% rename from xsuite/abis/proxy-pause.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/proxy-pause.abi.json diff --git a/xsuite/abis/rewards-distribution.abi.json b/xsuite/src/cli/generateproxy/abis/supported/rewards-distribution.abi.json similarity index 100% rename from xsuite/abis/rewards-distribution.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/rewards-distribution.abi.json diff --git a/xsuite/abis/token-release.abi.json b/xsuite/src/cli/generateproxy/abis/supported/token-release.abi.json similarity index 100% rename from xsuite/abis/token-release.abi.json rename to xsuite/src/cli/generateproxy/abis/supported/token-release.abi.json diff --git a/xsuite/abis/nft-minter.abi.json b/xsuite/src/cli/generateproxy/abis/unsupported/nft-minter.abi.json similarity index 100% rename from xsuite/abis/nft-minter.abi.json rename to xsuite/src/cli/generateproxy/abis/unsupported/nft-minter.abi.json diff --git a/xsuite/abis/seed-nft-minter.abi.json b/xsuite/src/cli/generateproxy/abis/unsupported/seed-nft-minter.abi.json similarity index 100% rename from xsuite/abis/seed-nft-minter.abi.json rename to xsuite/src/cli/generateproxy/abis/unsupported/seed-nft-minter.abi.json diff --git a/xsuite/src/cli/generateproxy/abis/unsupported/type_not_supported.abi.json b/xsuite/src/cli/generateproxy/abis/unsupported/type_not_supported.abi.json new file mode 100644 index 00000000..e4de7cc3 --- /dev/null +++ b/xsuite/src/cli/generateproxy/abis/unsupported/type_not_supported.abi.json @@ -0,0 +1,19 @@ +{ + "name": "NotSupportedType", + "constructor": {}, + "endpoints": [ + { + "name": "ping", + "mutability": "mutable", + "inputs": [ + { + "name": "_data", + "type": "NOTSUPPORTEDTYPE", + "multi_arg": true + } + ], + "outputs": [] + } + ], + "types": {} +} \ No newline at end of file diff --git a/xsuite/src/cli/generateproxy/decoders.ts b/xsuite/src/cli/generateproxy/decoders.ts index 27a90311..99014c9b 100644 --- a/xsuite/src/cli/generateproxy/decoders.ts +++ b/xsuite/src/cli/generateproxy/decoders.ts @@ -1,15 +1,21 @@ -export const generateAbiDecoders = (abi: any) => { +import { AbiDefinition, TypeDefinition, FieldDefinition } from "./abi"; +import { splitCommaSeparatedArgs } from "./utils"; + +export const generateAbiDecoders = (abi: AbiDefinition) => { const code = Object.entries(abi.types) - .map((type) => generateTypeDecoder(type)) + .map((type) => generateTypeDecoder(type, abi)) .join("\n"); return code; }; -const generateTypeDecoder = (typeDefinition: any) => { +const generateTypeDecoder = ( + typeDefinition: [string, TypeDefinition], + abi: AbiDefinition, +) => { switch (typeDefinition[1].type) { case "struct": - return generateStructDecoder(typeDefinition); + return generateStructDecoder(typeDefinition, abi); case "enum": case "explicit-enum": return generateEnumDecoder(typeDefinition); @@ -18,24 +24,27 @@ const generateTypeDecoder = (typeDefinition: any) => { } }; -const generateStructDecoder = (structDefinition: any) => { +const generateStructDecoder = ( + structDefinition: [string, TypeDefinition], + abi: AbiDefinition, +) => { return `export const ${structDefinition[0]}Decoder = () => d.Tuple({ - ${generateFieldsDecoder(structDefinition[1].fields).join("\n ")} + ${generateFieldsDecoder(structDefinition[1].fields ?? [], abi).join("\n ")} }); - -export const decode${structDefinition[0]} = (encodedData: string): ${ - structDefinition[0] - } => { - return ${structDefinition[0]}Decoder().topDecode(encodedData); -} `; }; -const generateFieldsDecoder = (fieldDefinitions: any) => { - return fieldDefinitions.map((f: any) => `${f.name}: ${mapType(f.type)},`); +const generateFieldsDecoder = ( + fieldDefinitions: FieldDefinition[], + abi: AbiDefinition, +) => { + return ( + fieldDefinitions?.map((f: any) => `${f.name}: ${mapType(f.type, abi)},`) ?? + [] + ); }; -const generateEnumDecoder = (enumDefinition: any) => { +const generateEnumDecoder = (enumDefinition: [string, TypeDefinition]) => { return `export const ${enumDefinition[0]}Decoder = () => d.U8().then((v) => { const enumValue: ${enumDefinition[0]} = Number(v); return enumValue; @@ -43,36 +52,28 @@ const generateEnumDecoder = (enumDefinition: any) => { `; }; -export const mapType = (abiType: string): string => { +export const mapType = (abiType: string, abi: AbiDefinition): string => { // handling List const listMatch = abiType.match(/^List<(.+)>$/); if (listMatch) { - const innerTypeDecoder: any = mapType(listMatch[1]); + const innerTypeDecoder: any = mapType(listMatch[1], abi); return `d.List(${innerTypeDecoder})`; } // handling Option const optionMatch = abiType.match(/^Option<(.+)>$/); if (optionMatch) { - const innerTypeDecoder: any = mapType(optionMatch[1]); + const innerTypeDecoder: any = mapType(optionMatch[1], abi); return `d.Option(${innerTypeDecoder})`; } - // handling optional - const optionalMatch = abiType.match(/^optional<(.+)>$/); - if (optionalMatch) { - const innerTypeDecoder: any = mapType(optionalMatch[1]); - return `${innerTypeDecoder}`; - } - // handling tuples const tupleMatch = abiType.match(/^tuple<(.+)>$/); if (tupleMatch) { const innerTypesSeperatedByComma: string = tupleMatch[1]; - // todo splitting - const innerDecoders = innerTypesSeperatedByComma - .split(",") - .map((t) => mapType(t.trim())); + const innerDecoders = splitCommaSeparatedArgs( + innerTypesSeperatedByComma, + ).map((t) => mapType(t.trim(), abi)); return `d.Tuple(${innerDecoders})`; } @@ -80,7 +81,7 @@ export const mapType = (abiType: string): string => { const arrayNMatch = abiType.match(/^array(\d+)<(.+)>$/); if (arrayNMatch) { const arrayLength = Number(arrayNMatch[1]); - const innerType = mapType(arrayNMatch[2]); + const innerType = mapType(arrayNMatch[2], abi); const innerTypes: string[] = []; for (let i = 0; i < arrayLength; i++) { innerTypes.push(innerType); @@ -96,6 +97,7 @@ export const mapType = (abiType: string): string => { case "u8": return "d.U8().toNum()"; case "u16": + case "CodeMetadata": return "d.U16().toNum()"; case "u32": return "d.U32().toNum()"; @@ -121,6 +123,11 @@ export const mapType = (abiType: string): string => { case "bytes": return "d.Buffer()"; default: + if (abi.types[abiType] === undefined) { + throw Error( + `Type ${abiType} is currently not supported by the xsuite framework.`, + ); + } return `${abiType}Decoder()`; } }; diff --git a/xsuite/src/cli/generateproxy/encoders.ts b/xsuite/src/cli/generateproxy/encoders.ts index ba487c82..16b2c956 100644 --- a/xsuite/src/cli/generateproxy/encoders.ts +++ b/xsuite/src/cli/generateproxy/encoders.ts @@ -1,15 +1,21 @@ -export const generateAbiEncoders = (abi: any) => { +import { AbiDefinition, FieldDefinition, TypeDefinition } from "./abi"; +import { splitCommaSeparatedArgs } from "./utils"; + +export const generateAbiEncoders = (abi: AbiDefinition) => { const code = Object.entries(abi.types) - .map((type) => generateTypeEncoder(type)) + .map((type) => generateTypeEncoder(type, abi)) .join("\n"); return code; }; -const generateTypeEncoder = (typeDefinition: any) => { +const generateTypeEncoder = ( + typeDefinition: [string, TypeDefinition], + abi: AbiDefinition, +) => { switch (typeDefinition[1].type) { case "struct": - return generateStructEncoder(typeDefinition); + return generateStructEncoder(typeDefinition, abi); case "enum": case "explicit-enum": return generateEnumEncoder(typeDefinition); @@ -18,62 +24,61 @@ const generateTypeEncoder = (typeDefinition: any) => { } }; -const generateStructEncoder = (structDefinition: any) => { +const generateStructEncoder = ( + structDefinition: [string, TypeDefinition], + abi: AbiDefinition, +) => { return `export const ${structDefinition[0]}Encoder = (data: ${ structDefinition[0] }) => e.Tuple( - ${generateFieldsEncoder(structDefinition[1].fields).join("\n ")} + ${generateFieldsEncoder(structDefinition[1].fields ?? [], abi).join("\n ")} ); - -export const encode${structDefinition[0]} = (data: ${ - structDefinition[0] - }): Encodable => { - return ${structDefinition[0]}Encoder(data); -} `; }; -const generateFieldsEncoder = (fieldDefinitions: any) => { +const generateFieldsEncoder = ( + fieldDefinitions: FieldDefinition[], + abi: AbiDefinition, +) => { return fieldDefinitions.map( - (f: any) => `${mapType("data." + f.name, f.type)},`, + (f: any) => `${mapType("data." + f.name, f.type, abi)},`, ); }; -const generateEnumEncoder = (enumDefinition: any) => { +const generateEnumEncoder = (enumDefinition: [string, TypeDefinition]) => { return `export const ${enumDefinition[0]}Encoder = (data: ${enumDefinition[0]}) => e.U8(data); `; }; -export const mapType = (abiFieldName: string, abiFieldType: string): string => { +export const mapType = ( + abiFieldName: string, + abiFieldType: string, + abi: AbiDefinition, +): string => { // handling List const listMatch = abiFieldType.match(/^List<(.+)>$/); if (listMatch) { - const innerTypeEncoder: any = mapType("d", listMatch[1]); + const innerTypeEncoder: any = mapType("d", listMatch[1], abi); return `e.List(...${abiFieldName}.map(d => ${innerTypeEncoder}))`; } // handling Option const optionMatch = abiFieldType.match(/^Option<(.+)>$/); if (optionMatch) { - const innerTypeEncoder: any = mapType(abiFieldName, optionMatch[1]); + const innerTypeEncoder: any = mapType(abiFieldName, optionMatch[1], abi); return `e.Option(${abiFieldName} !== null ? ${innerTypeEncoder} : null)`; } - // handling optional - const optionalMatch = abiFieldType.match(/^optional<(.+)>$/); - if (optionalMatch) { - const innerTypeEncoder: any = mapType(abiFieldName, optionalMatch[1]); - return `${abiFieldName} !== null ? ${innerTypeEncoder} : undefined`; - } - // handling tuples const tupleMatch = abiFieldType.match(/^tuple<(.+)>$/); if (tupleMatch) { - // todo splitting - const innerTypes: string[] = tupleMatch[1].split(",").map((p) => p.trim()); + const innerTypesCommaSeparated = tupleMatch[1]; + const innerTypes = splitCommaSeparatedArgs(innerTypesCommaSeparated).map( + (p) => p.trim(), + ); const innerEncoders = []; for (let i = 0; i < innerTypes.length; i++) { - innerEncoders.push(mapType(`${abiFieldName}[${i}]`, innerTypes[i])); + innerEncoders.push(mapType(`${abiFieldName}[${i}]`, innerTypes[i], abi)); } return `e.Tuple(${innerEncoders.join(", ")})`; } @@ -81,7 +86,7 @@ export const mapType = (abiFieldName: string, abiFieldType: string): string => { // handling arrayN const arrayNMatch = abiFieldType.match(/^array(\d+)<(.+)>$/); if (arrayNMatch) { - const innerEncoders = mapType("d", arrayNMatch[2]); + const innerEncoders = mapType("d", arrayNMatch[2], abi); return `e.Tuple(...${abiFieldName}.map(d => ${innerEncoders}))`; } @@ -93,6 +98,7 @@ export const mapType = (abiFieldName: string, abiFieldType: string): string => { case "u8": return `e.U8(${abiFieldName})`; case "u16": + case "CodeMetadata": return `e.U16(${abiFieldName})`; case "u32": return `e.U32(${abiFieldName})`; @@ -118,6 +124,11 @@ export const mapType = (abiFieldName: string, abiFieldType: string): string => { case "bytes": return `e.Buffer(${abiFieldName})`; default: + if (abi.types[abiFieldType] === undefined) { + throw Error( + `Type ${abiFieldType} is currently not supported by the xsuite framework.`, + ); + } return `${abiFieldType}Encoder(${abiFieldName})`; } }; diff --git a/xsuite/src/cli/generateproxy/endpointinputs.ts b/xsuite/src/cli/generateproxy/endpointinputs.ts new file mode 100644 index 00000000..ef0027e6 --- /dev/null +++ b/xsuite/src/cli/generateproxy/endpointinputs.ts @@ -0,0 +1,85 @@ +import { AbiDefinition, InputDefinition } from "./abi"; +import { mapType as mapEncoderType } from "./encoders"; +import { IgnoreHandler } from "./multiHandlers/IgnoreHandler"; +import { MultiHandler } from "./multiHandlers/MultiHandler"; +import { OptionalHandler } from "./multiHandlers/OptionalHandler"; +import { VariadicHandler } from "./multiHandlers/VariadicHandler"; +import { mapType } from "./types"; + +export const buildArguments = ( + inputs: InputDefinition[], + abi: AbiDefinition, +) => { + return inputs.map((input: any) => { + const mappedType = mapType(input.type, abi); + if (mappedType === "undefined") { + return `${input.name}?: ${mappedType}`; + } + return `${input.name}: ${mappedType}`; + }); +}; + +export const buildEncodedInput = ( + inputs: InputDefinition[], + abi: AbiDefinition, +) => { + if (inputs.length === 0) { + return "return undefined;"; + } + + const processingInputs: string[] = []; + for (let i = 0; i < inputs.length - 1; i++) { + const mappedType = mapEncoderType(inputs[i].name, inputs[i].type, abi); + processingInputs.push(mappedType); + } + + const lastInput = inputs[inputs.length - 1]; + if (lastInput.multi_arg !== true) { + const mappedType = mapEncoderType(lastInput.name, lastInput.type, abi); + processingInputs.push(mappedType); + + const allEncoders = processingInputs.join(", "); + return `return [ ${allEncoders} ].filter(p => p !== undefined);`; + } else { + const standardEncoders = processingInputs + .map((p) => `encoders.push(${p})`) + .join("\n"); + const multiValueEncoders = encodeMultiArgument(lastInput, abi); + return `const encoders = []; + ${standardEncoders} + ${multiValueEncoders} + return encoders;`; + } +}; + +const encodeMultiArgument = ( + multiInput: InputDefinition, + abi: AbiDefinition, +) => { + // handling multi + const multiMatch = multiInput.type.match(/^multi<(.+)>$/); + if (multiMatch) { + const multiContent = multiMatch[1]; + return new MultiHandler(abi).encode(multiInput.name, multiContent); + } + + // handling variadic + const variadicMatch = multiInput.type.match(/^variadic<(.+)>$/); + if (variadicMatch) { + const variadicContent = variadicMatch[1]; + return new VariadicHandler(abi).encode(multiInput.name, variadicContent); + } + + // handling optional + const optionalMatch = multiInput.type.match(/^optional<(.+)>$/); + if (optionalMatch) { + const optionalContent = optionalMatch[1]; + return new OptionalHandler(abi).encode(multiInput.name, optionalContent); + } + + if (multiInput.type === "ignore") { + return new IgnoreHandler(abi).encode(multiInput.name, ""); + } + + throw Error(`MultiArgument ${multiInput.type} is currently not supported.`); +}; diff --git a/xsuite/src/cli/generateproxy/endpointoutputs.ts b/xsuite/src/cli/generateproxy/endpointoutputs.ts new file mode 100644 index 00000000..3203053e --- /dev/null +++ b/xsuite/src/cli/generateproxy/endpointoutputs.ts @@ -0,0 +1,82 @@ +import { AbiDefinition, OutputDefinition } from "./abi"; +import { mapType as mapDecoderType } from "./decoders"; +import { IgnoreHandler } from "./multiHandlers/IgnoreHandler"; +import { OptionalHandler } from "./multiHandlers/OptionalHandler"; +import { VariadicHandler } from "./multiHandlers/VariadicHandler"; +import { mapType } from "./types"; + +export const buildResponseType = ( + outputs: OutputDefinition[], + abi: AbiDefinition, +) => { + if (outputs.length === 0) { + return "null"; + } + + if (outputs.length === 1) { + return `${mapType(outputs[0].type, abi)}`; + } + + return `[ ${outputs.map((o) => mapType(o.type, abi)).join(", ")} ]`; +}; + +export const buildDecodedResponse = ( + outputs: OutputDefinition[], + abi: AbiDefinition, +) => { + if (outputs.length === 0) { + return "return null;"; + } + + const decoders: string[] = []; + + outputs.forEach((output, index) => { + if (output.multi_result !== true) { + const mappedType = mapDecoderType(output.type, abi); + decoders.push(`${mappedType}.fromTop(data[${index}])`); + } else { + const multiDecoder = handleMultiResult(index, output, abi); + decoders.push(multiDecoder); + } + }); + + if (decoders.length === 1) { + return `return ${decoders[0]};`; + } + + return `return [ + ${decoders.join(`, + `)} + ];`; +}; + +const handleMultiResult = ( + multiValueStartIndex: number, + multiOutput: OutputDefinition, + abi: AbiDefinition, +) => { + const matchVariadic = multiOutput.type.match(/^variadic<(.+)>$/); + if (matchVariadic) { + const contentOfVariadic = matchVariadic[1]; + return new VariadicHandler(abi).decode( + multiValueStartIndex, + contentOfVariadic, + ); + } + + // handling optional + const optionalMatch = multiOutput.type.match(/^optional<(.+)>$/); + if (optionalMatch) { + const optionalContent = optionalMatch[1]; + return new OptionalHandler(abi).decode( + multiValueStartIndex, + optionalContent, + ); + } + + if (multiOutput.type === "ignore") { + return new IgnoreHandler(abi).decode(multiValueStartIndex, ""); + } + + throw Error(`MultiResult ${multiOutput.type} is currently not supported.`); +}; diff --git a/xsuite/src/cli/generateproxy/endpoints.ts b/xsuite/src/cli/generateproxy/endpoints.ts index e4adac32..2fc8af15 100644 --- a/xsuite/src/cli/generateproxy/endpoints.ts +++ b/xsuite/src/cli/generateproxy/endpoints.ts @@ -1,74 +1,63 @@ -import { mapType as mapDecoderType } from "./decoders"; -import { mapType as mapEncoderType } from "./encoders"; -import { mapType } from "./types"; - -export const generateAbiEndpoints = (abi: any) => { - const code = Object.entries(abi.endpoints) - .map((e) => generateEndpoint(e[1])) - .join("\n"); +import { AbiDefinition, EndpointDefinition } from "./abi"; +import { buildArguments, buildEncodedInput } from "./endpointinputs"; +import { buildDecodedResponse, buildResponseType } from "./endpointoutputs"; +export const generateAbiEndpoints = (abi: AbiDefinition) => { + const code = abi.endpoints?.map((e) => generateEndpoint(e, abi)).join("\n"); return code; }; -const generateEndpoint = (endpoint: any) => { - const args = buildArguments(endpoint.inputs).join(", "); - const inputRequestArguments = buildEncodedInput(endpoint.inputs); - const outputDecoders = buildDecodedOutput(endpoint.outputs); +const generateEndpoint = (endpoint: EndpointDefinition, abi: AbiDefinition) => { + ensureCompatibility(endpoint); + + const args = buildArguments(endpoint.inputs, abi).join(", "); + const inputEncoders = buildEncodedInput(endpoint.inputs, abi); + + const responseType = buildResponseType(endpoint.outputs, abi); + const decodedResponse = buildDecodedResponse(endpoint.outputs, abi); return `export const ${endpoint.name}Builder = () => ({ functionName: "${endpoint.name}", encodeInput: (${args}) => { - return ${inputRequestArguments}; + ${inputEncoders} }, - decodeOutput: (data: string[]) => + decodeOutput: (data: string[]): ${responseType} => { - ${outputDecoders} + ${decodedResponse} } }); `; }; -const buildArguments = (inputs: any) => { - return inputs.map((input: any) => `${input.name}: ${mapType(input.type)}`); -}; - -const buildEncodedInput = (inputs: any) => { - const requestParts = inputs.map( - (input: any) => `${mapEncoderType(input.name, input.type)}`, - ); - - if (requestParts.length === 0) { - return "undefined"; +const ensureCompatibility = (endpoint: EndpointDefinition) => { + const multiArgs = endpoint.inputs.filter((p) => p.multi_arg === true).length; + if (multiArgs > 1) { + throw Error( + `The endpoint ${endpoint.name} contains multiple multi_args, which is currently not supported by the xsuite framework.`, + ); } - if (requestParts.length === 1) { - return `[ ${requestParts[0]} ].filter(p => p !== undefined)`; - } - - return `[ ${requestParts.join(", ")} ].filter(p => p !== undefined)`; -}; -const buildDecodedOutput = (outputs: any) => { - if (outputs.length === 0) { - return "return null;"; + if (multiArgs === 1 && endpoint.inputs.slice(-1)[0].multi_arg !== true) { + throw Error( + `The endpoint ${endpoint.name} contains a multi_arg that isn't positioned at the last position. This is not supported.`, + ); } - const matchVariadic = outputs[0].type.match(/^variadic<(.+)>$/); - if (matchVariadic) { - const innerType = matchVariadic[1]; - return `return data.map(item => ${mapDecoderType( - innerType, - )}.topDecode(item));`; + const multiResults = endpoint.outputs.filter( + (p) => p.multi_result === true, + ).length; + if (multiResults > 1) { + throw Error( + `The endpoint ${endpoint.name} contains multiple multi_results, which is currently not supported by the xsuite framework.`, + ); } - const responseDecoders = outputs.map( - (output: any) => `${mapDecoderType(output.type)}`, - ); - - if (responseDecoders.length === 1) { - return `return data.length === 0 ? null : ${responseDecoders[0]}.topDecode(data[0]);`; + if ( + multiResults === 1 && + endpoint.outputs.slice(-1)[0].multi_result !== true + ) { + throw Error( + `The endpoint ${endpoint.name} contains a multi_result that isn't positioned at the last position. This is not supported.`, + ); } - - const decoders = responseDecoders.join(", "); - return `const decoders = [ ${decoders} ]; - return decoders.map((d, i) => i >= data.length ? null : d.fromTop(data[i]));`; }; diff --git a/xsuite/src/cli/generateproxy/generateproxy.test.ts b/xsuite/src/cli/generateproxy/generateproxy.test.ts index 8cff0a9a..eddc380f 100644 --- a/xsuite/src/cli/generateproxy/generateproxy.test.ts +++ b/xsuite/src/cli/generateproxy/generateproxy.test.ts @@ -1,46 +1,66 @@ import fs from "node:fs"; import path from "node:path"; -import { test, beforeEach, afterEach, expect } from "@jest/globals"; -import { Encodable } from "../../data/Encodable"; + +import { test, beforeEach, afterEach, expect } from "vitest"; import { SContract, SWallet, SWorld } from "../../world"; import { getCommand } from "../cmd"; -const abiDir = path.resolve("abis"); -const tmpDir = "/tmp/xsuite-tests"; - +const abiDirSupported = path.resolve(__dirname, "abis/supported"); +const abiDirUnsupported = path.resolve(__dirname, "abis/unsupported"); const dataTypesAbiPath = path.resolve( - "contracts/datatypes/output", + __dirname, + "../../../contracts/datatypes/output", "datatypes.abi.json", ); const dataTypesWasmPath = path.resolve( - "contracts/datatypes/output", + __dirname, + "../../../contracts/datatypes/output", "datatypes.wasm", ); +let tmpDir: string; + beforeEach(() => { - if (fs.existsSync(tmpDir)) { - fs.rmSync(tmpDir, { recursive: true, force: true }); - } - fs.mkdirSync(tmpDir); - process.chdir(tmpDir); + tmpDir = fs.mkdtempSync("/tmp/xsuite-tests-"); }); afterEach(() => { - // fs.rmSync(tmpDir, { recursive: true, force: true }); - // process.chdir(cwd); + fs.rmSync(tmpDir, { recursive: true, force: true }); +}); + +test("generateproxy throws, when a type is not supported", async () => { + const targetFilePath = `${tmpDir}/datatypes.ts`; + await expect(() => + run( + `generateproxy --from-abi ${abiDirUnsupported}/type_not_supported.abi.json --output=${targetFilePath}`, + ), + ).rejects.toThrow( + "Type NOTSUPPORTEDTYPE is currently not supported by the xsuite framework.", + ); +}); + +test("generateproxy throws, when two multivalues are given", async () => { + const targetFilePath = `${tmpDir}/datatypes.ts`; + await expect(() => + run( + `generateproxy --from-abi ${abiDirUnsupported}/nft-minter.abi.json --output=${targetFilePath}`, + ), + ).rejects.toThrow( + "The endpoint createNft contains multiple multi_args, which is currently not supported by the xsuite framework.", + ); }); test("generateproxy test abis", async () => { - const files = fs.readdirSync(abiDir); + const files = fs.readdirSync(abiDirSupported); files.forEach(async (file) => { - const filePath = path.resolve(abiDir, file); + const filePath = path.resolve(abiDirSupported, file); await run( `generateproxy --from-abi ${filePath} --output=${tmpDir}/${file}.ts`, ); }); }); -test("generateproxy generates types for datatypes smart contract", async () => { +test("generateproxy generates functional endpoints for a given abi", async () => { const targetFilePath = `${tmpDir}/datatypes.ts`; await run( `generateproxy --from-abi ${dataTypesAbiPath} --output=${targetFilePath}`, @@ -54,7 +74,7 @@ test("generateproxy generates types for datatypes smart contract", async () => { const deployedContract = await owner.deployContract({ code: `file:${dataTypesWasmPath}`, codeMetadata: [], - gasLimit: 15_000_000, + gasLimit: 20_000_000, }); const generatedCode = await import(targetFilePath); @@ -65,36 +85,49 @@ test("generateproxy generates types for datatypes smart contract", async () => { ); for (let i = 0; i < testCases.length; i++) { - const testCase = testCases[0]; - const getResponse = await world.query({ - callee: deployedContract.contract, - funcName: `get${testCase.type}`, - funcArgs: [], - }); + const testCase = testCases[i]; - const decodedType = generatedCode[`decode${testCase.type}`]( - getResponse.returnData[0], - ); + const getBuilder = generatedCode[`get${testCase.type}Builder`](); + const setBuilder = generatedCode[`set${testCase.type}Builder`](); - expect(decodedType).toStrictEqual(testCase.result); + const queryResponse = await world.query({ + callee: deployedContract.contract, + funcName: getBuilder.functionName, + funcArgs: getBuilder.encodeInput(), + }); - const encodedData: Encodable = - generatedCode[`encode${testCase.type}`](decodedType); + const decodedData = getBuilder.decodeOutput(queryResponse.returnData); + expect(decodedData).toStrictEqual(testCase.result); const setResponse = await owner.callContract({ callee: deployedContract.contract, - funcName: `set${testCase.type}`, - funcArgs: [encodedData], - gasLimit: 10_000_000, + funcName: setBuilder.functionName, + funcArgs: setBuilder.encodeInput(decodedData), + gasLimit: 20_000_000, }); - expect(setResponse.returnData[0]).toBe(getResponse.returnData[0]); + expect(setResponse.returnData).toStrictEqual(queryResponse.returnData); } } finally { await world.terminate(); } }); +test("generateproxy proccesses multivalue2 properly", async () => { + const targetFilePath = `${tmpDir}/datatypes.ts`; + await run( + `generateproxy --from-abi ${dataTypesAbiPath} --output=${targetFilePath}`, + ); + + const generatedCode = await import(targetFilePath); + const builder = generatedCode.getPrimitiveMultiValue2Builder(); + await queryAndVerify( + builder, + [[0, "erd1gnnva3r3x490s9ap0s53u2edht6zpnxhrwtcty7ljf3hmasxenjqw5hux8"]], + [0, "erd1gnnva3r3x490s9ap0s53u2edht6zpnxhrwtcty7ljf3hmasxenjqw5hux8"], + ); +}); + test("generateproxy proccesses optional properly", async () => { const targetFilePath = `${tmpDir}/datatypes.ts`; await run( @@ -113,6 +146,112 @@ test("generateproxy proccesses optional properly", async () => { await queryAndVerify(builder2, [0, 1], [0, 1]); }); +test("generateproxy optional> properly", async () => { + const targetFilePath = `${tmpDir}/datatypes.ts`; + await run( + `generateproxy --from-abi ${dataTypesAbiPath} --output=${targetFilePath}`, + ); + + const generatedCode = await import(targetFilePath); + const builder = generatedCode.getOptionalMultiValueEncodedBuilder(); + await queryAndVerify( + builder, + [ + 77n, + [ + ["erd1gnnva3r3x490s9ap0s53u2edht6zpnxhrwtcty7ljf3hmasxenjqw5hux8", 10n], + ["erd1zznu64h9npj9640qljhjstdt7luw47vehglavfs28f796y7acuns7c8f2t", 90n], + ], + ], + [ + ["erd1gnnva3r3x490s9ap0s53u2edht6zpnxhrwtcty7ljf3hmasxenjqw5hux8", 10n], + ["erd1zznu64h9npj9640qljhjstdt7luw47vehglavfs28f796y7acuns7c8f2t", 90n], + ], + ); + await queryAndVerify(builder, [77n, null], null); + await queryAndVerify(builder, [77n, []], null); +}); + +test("generateproxy optional> properly", async () => { + const targetFilePath = `${tmpDir}/datatypes.ts`; + await run( + `generateproxy --from-abi ${dataTypesAbiPath} --output=${targetFilePath}`, + ); + + const generatedCode = await import(targetFilePath); + const builder = generatedCode.getOptionalMultiValue3Builder(); + await queryAndVerify(builder, [77n, [1, 30n, 2]], [1, 30n, 2]); + await queryAndVerify(builder, [77n, null], null); +}); + +test("generateproxy multivalueencoded properly", async () => { + const targetFilePath = `${tmpDir}/datatypes.ts`; + await run( + `generateproxy --from-abi ${dataTypesAbiPath} --output=${targetFilePath}`, + ); + + const generatedCode = await import(targetFilePath); + const builder = generatedCode.getMultiValueEncodedBuilder(); + await queryAndVerify( + builder, + [ + 77n, + [ + "erd1gnnva3r3x490s9ap0s53u2edht6zpnxhrwtcty7ljf3hmasxenjqw5hux8", + "erd1zznu64h9npj9640qljhjstdt7luw47vehglavfs28f796y7acuns7c8f2t", + ], + ], + [ + "erd1gnnva3r3x490s9ap0s53u2edht6zpnxhrwtcty7ljf3hmasxenjqw5hux8", + "erd1zznu64h9npj9640qljhjstdt7luw47vehglavfs28f796y7acuns7c8f2t", + ], + ); + await queryAndVerify( + builder, + [77n, ["erd1zznu64h9npj9640qljhjstdt7luw47vehglavfs28f796y7acuns7c8f2t"]], + ["erd1zznu64h9npj9640qljhjstdt7luw47vehglavfs28f796y7acuns7c8f2t"], + ); + await queryAndVerify(builder, [77n, []], []); +}); + +test("generateproxy multivalueencoded> properly", async () => { + const targetFilePath = `${tmpDir}/datatypes.ts`; + await run( + `generateproxy --from-abi ${dataTypesAbiPath} --output=${targetFilePath}`, + ); + + const generatedCode = await import(targetFilePath); + const builder = generatedCode.getMultiValueEncodedWithMultiValue2Builder(); + await queryAndVerify( + builder, + [ + 77n, + [ + [37, "erd1gnnva3r3x490s9ap0s53u2edht6zpnxhrwtcty7ljf3hmasxenjqw5hux8"], + [180, "erd1zznu64h9npj9640qljhjstdt7luw47vehglavfs28f796y7acuns7c8f2t"], + ], + ], + [ + [37, "erd1gnnva3r3x490s9ap0s53u2edht6zpnxhrwtcty7ljf3hmasxenjqw5hux8"], + [180, "erd1zznu64h9npj9640qljhjstdt7luw47vehglavfs28f796y7acuns7c8f2t"], + ], + ); + await queryAndVerify(builder, [77n, []], []); +}); + +test("generateproxy processes IgnoreValue properly", async () => { + const targetFilePath = `${tmpDir}/datatypes.ts`; + await run( + `generateproxy --from-abi ${dataTypesAbiPath} --output=${targetFilePath}`, + ); + + const generatedCode = await import(targetFilePath); + const builder = generatedCode.getIgnoreValueBuilder(); + await queryAndVerify(builder, [0], undefined); + await queryAndVerify(builder, [1, "ignored"], undefined); + await queryAndVerify(builder, [1, ["ignored", 12]], undefined); +}); + test("generateproxy processes VecMapper properly", async () => { const targetFilePath = `${tmpDir}/datatypes.ts`; await run( @@ -149,7 +288,7 @@ test("generateproxy processes UnorderedSetMapper properly", async () => { await queryAndVerify(builder, [1], [5n, 6n]); }); -test("generateproxy processes MapMapper properly", async () => { +test("generateproxy processes a simple MapMapper properly", async () => { const targetFilePath = `${tmpDir}/datatypes.ts`; await run( `generateproxy --from-abi ${dataTypesAbiPath} --output=${targetFilePath}`, @@ -157,8 +296,49 @@ test("generateproxy processes MapMapper properly", async () => { const generatedCode = await import(targetFilePath); const builder = generatedCode.getMapMapperBuilder(); - await queryAndVerify(builder, [0], [1n, 2n]); - await queryAndVerify(builder, [1], [5n, 6n]); + await queryAndVerify( + builder, + [0], + [ + [0, 1], + [1, 2], + ], + ); + await queryAndVerify( + builder, + [1], + [ + [1, 10], + [2, 11], + ], + ); + await queryAndVerify(builder, [2], []); +}); + +test("generateproxy processes a complex MapMapper properly", async () => { + const targetFilePath = `${tmpDir}/datatypes.ts`; + await run( + `generateproxy --from-abi ${dataTypesAbiPath} --output=${targetFilePath}`, + ); + + const generatedCode = await import(targetFilePath); + const builder = generatedCode.getMapMapperComplexBuilder(); + await queryAndVerify( + builder, + [0], + [ + [0, [0, 12n, 4]], + [1, [1, 24n, 5]], + ], + ); + await queryAndVerify( + builder, + [1], + [ + [0, [2, 48n, 6]], + [1, [3, 72n, 7]], + ], + ); }); const queryAndVerify = async ( @@ -175,7 +355,7 @@ const queryAndVerify = async ( const deployedContract = await owner.deployContract({ code: `file:${dataTypesWasmPath}`, codeMetadata: [], - gasLimit: 15_000_000, + gasLimit: 20_000_000, }); const funcArgs = builder.encodeInput(...input); @@ -290,6 +470,7 @@ const loadGenerateProxyTestCases = (contract: SContract, owner: SWallet) => [ "erd1qqqqqqqqqqqqqqqqqqqqqqqqqyqqqqqqqqqqqqqqqqqqqqqqqqqq8u9arm", big_unsigned_integer: 100000000n, }, + code_metadata: 256, }, }, ]; diff --git a/xsuite/src/cli/generateproxy/generateproxy.ts b/xsuite/src/cli/generateproxy/generateproxy.ts index c6d09289..c0bc66ef 100644 --- a/xsuite/src/cli/generateproxy/generateproxy.ts +++ b/xsuite/src/cli/generateproxy/generateproxy.ts @@ -1,5 +1,7 @@ import fs from "node:fs"; import { Command } from "commander"; +import * as prettier from "prettier"; +import { AbiDefinition } from "./abi"; import { generateAbiDecoders } from "./decoders"; import { generateAbiEncoders } from "./encoders"; import { generateAbiEndpoints } from "./endpoints"; @@ -24,7 +26,9 @@ const action = async ({ output: string; }) => { // Read and parse the ABI JSON from file - const abiJson = JSON.parse(fs.readFileSync(abiFilePath, "utf-8")); + const abiJson: AbiDefinition = JSON.parse( + fs.readFileSync(abiFilePath, "utf-8"), + ); let code = `import { d } from "xsuite"; import { e } from "xsuite"; @@ -39,5 +43,10 @@ import { Encodable } from "xsuite/dist/data/Encodable"; code += "\n"; code += generateAbiEndpoints(abiJson); + code = await prettier.format(code, { + parser: "typescript", + trailingComma: "all", + }); + fs.writeFileSync(outputFilePath, code); }; diff --git a/xsuite/src/cli/generateproxy/multiHandlers/AbstractMultiValueHandler.ts b/xsuite/src/cli/generateproxy/multiHandlers/AbstractMultiValueHandler.ts new file mode 100644 index 00000000..83291792 --- /dev/null +++ b/xsuite/src/cli/generateproxy/multiHandlers/AbstractMultiValueHandler.ts @@ -0,0 +1,17 @@ +import { AbiDefinition } from "../abi"; + +export abstract class AbstractMultiValueHandler { + constructor(protected abi: AbiDefinition) {} + + encode(inputName: string, toEncode: string) { + return this._encode(inputName, toEncode); + } + + abstract _encode(inputName: string, toEncode: string): string; + + decode(multiValueStartIndex: number, toDecode: string): string { + return this._decode(multiValueStartIndex, toDecode); + } + + abstract _decode(multiValueStartIndex: number, toDecode: string): string; +} diff --git a/xsuite/src/cli/generateproxy/multiHandlers/IgnoreHandler.ts b/xsuite/src/cli/generateproxy/multiHandlers/IgnoreHandler.ts new file mode 100644 index 00000000..409aaf5c --- /dev/null +++ b/xsuite/src/cli/generateproxy/multiHandlers/IgnoreHandler.ts @@ -0,0 +1,13 @@ +import { AbstractMultiValueHandler } from "./AbstractMultiValueHandler"; + +export class IgnoreHandler extends AbstractMultiValueHandler { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _encode(_inputName: string, _toEncode: string): string { + return ""; + } + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _decode(_multiValueStartIndex: number, _toDecode: string): string { + return "undefined;"; + } +} diff --git a/xsuite/src/cli/generateproxy/multiHandlers/MultiHandler.ts b/xsuite/src/cli/generateproxy/multiHandlers/MultiHandler.ts new file mode 100644 index 00000000..26a2427d --- /dev/null +++ b/xsuite/src/cli/generateproxy/multiHandlers/MultiHandler.ts @@ -0,0 +1,35 @@ +import { mapType as mapDecoderType } from "../decoders"; +import { mapType as mapEncoderType } from "../encoders"; +import { splitCommaSeparatedArgs } from "../utils"; +import { AbstractMultiValueHandler } from "./AbstractMultiValueHandler"; + +export class MultiHandler extends AbstractMultiValueHandler { + _encode(inputName: string, multiContent: string): string { + const innerTypesEncoders = splitCommaSeparatedArgs(multiContent).map( + (innerType, index) => + `encoders.push(${mapEncoderType( + `${inputName}[${index}]`, + innerType, + this.abi, + )});`, + ).join(` + `); + + return `if(${inputName} !== null) + { + ${innerTypesEncoders} + }`; + } + + _decode(multiValueStartIndex: number, mutliContent: string): string { + const innerTypeDecoders = splitCommaSeparatedArgs(mutliContent).map( + (innerType, index) => + `${mapDecoderType(innerType, this.abi)}.fromTop(data[${ + index + multiValueStartIndex + }])`, + ); + + const innerTypeDecodersJoined = innerTypeDecoders.join(", "); + return `[ ${innerTypeDecodersJoined} ]`; + } +} diff --git a/xsuite/src/cli/generateproxy/multiHandlers/OptionalHandler.ts b/xsuite/src/cli/generateproxy/multiHandlers/OptionalHandler.ts new file mode 100644 index 00000000..6c3513a2 --- /dev/null +++ b/xsuite/src/cli/generateproxy/multiHandlers/OptionalHandler.ts @@ -0,0 +1,57 @@ +import { mapType as mapDecoderType } from "../decoders"; +import { mapType as mapEncoderType } from "../encoders"; +import { AbstractMultiValueHandler } from "./AbstractMultiValueHandler"; +import { MultiHandler } from "./MultiHandler"; +import { VariadicHandler } from "./VariadicHandler"; + +export class OptionalHandler extends AbstractMultiValueHandler { + _encode(inputName: string, optionalContent: string): string { + const variadicMatch = optionalContent.match(/^variadic<(.+)>$/); + if (variadicMatch) { + const variadicContent = variadicMatch[1]; + return new VariadicHandler(this.abi).encode(inputName, variadicContent); + } + + const multiMatch = optionalContent.match(/^multi<(.+)>$/); + if (multiMatch) { + const multiContent = multiMatch[1]; + return new MultiHandler(this.abi).encode(inputName, multiContent); + } + + const innerEncoderType = mapEncoderType( + inputName, + optionalContent, + this.abi, + ); + + return `if(${inputName} !== null) { + encoders.push(${innerEncoderType}); + }`; + } + + _decode(multiValueStartIndex: number, optionalContent: string): string { + const variadicInsideOptionalMatch = + optionalContent.match(/^variadic<(.+)>$/); + if (variadicInsideOptionalMatch) { + const variadicInsideOptionalContent = variadicInsideOptionalMatch[1]; + const variadicDecoder = new VariadicHandler(this.abi).decode( + multiValueStartIndex, + variadicInsideOptionalContent, + ); + return `data.length > ${multiValueStartIndex} ? ${variadicDecoder} : null`; + } + + const multiInsideOptionalMatch = optionalContent.match(/^multi<(.+)>$/); + if (multiInsideOptionalMatch) { + const multiInsideOptionalContent = multiInsideOptionalMatch[1]; + const multiDecoder = new MultiHandler(this.abi).decode( + multiValueStartIndex, + multiInsideOptionalContent, + ); + return `data.length > ${multiValueStartIndex} ? ${multiDecoder} : null`; + } + + const optionalDecoder = mapDecoderType(optionalContent, this.abi); + return `data.length > ${multiValueStartIndex} ? ${optionalDecoder}.fromTop(data[${multiValueStartIndex}]) : null`; + } +} diff --git a/xsuite/src/cli/generateproxy/multiHandlers/VariadicHandler.ts b/xsuite/src/cli/generateproxy/multiHandlers/VariadicHandler.ts new file mode 100644 index 00000000..be467c49 --- /dev/null +++ b/xsuite/src/cli/generateproxy/multiHandlers/VariadicHandler.ts @@ -0,0 +1,103 @@ +import { mapType as mapDecoderType } from "../decoders"; +import { mapType as mapEncoderType } from "../encoders"; +import { mapType } from "../types"; +import { splitCommaSeparatedArgs } from "../utils"; +import { AbstractMultiValueHandler } from "./AbstractMultiValueHandler"; +import { MultiHandler } from "./MultiHandler"; + +export class VariadicHandler extends AbstractMultiValueHandler { + _encode(inputName: string, variadicContent: string): string { + const multiMatch = variadicContent.match(/^multi<(.+)>$/); + if (multiMatch) { + const variadicMultiContent = multiMatch[1]; + return this.encodeArrayOfMulti(variadicMultiContent, inputName); + } + + return this.encodeArrayOfTypes(inputName, variadicContent); + } + + _decode(multiValueStartIndex: number, variadicContent: string): string { + const contentOfVariadicMulti = variadicContent.match(/^multi<(.+)>$/); + if (contentOfVariadicMulti) { + return this.buildDecodersWithAnArrayOfAlternatingTypes( + multiValueStartIndex, + contentOfVariadicMulti, + ); + } + + return `data.slice(${multiValueStartIndex}).map(item => ${mapDecoderType( + variadicContent, + this.abi, + )}.fromTop(item))`; + } + + private buildDecodersWithAnArrayOfAlternatingTypes( + multiValueStartIndex: number, + matchVariadicMulti: RegExpMatchArray, + ) { + const innerTypesCommaSeparated = matchVariadicMulti[1]; + const innerTypesDecoders = splitCommaSeparatedArgs( + innerTypesCommaSeparated, + ).map((innerType) => mapDecoderType(innerType, this.abi)); + + const decoders = `data + .slice(${multiValueStartIndex}) + .reduce((result: any[], current, index) => { + const chunkIndex = Math.floor(index / ${innerTypesDecoders.length}); + (result[chunkIndex] = result[chunkIndex] || []).push(current); + return result; + }, []).map((p: string[]) => { + return [ + ${innerTypesDecoders.map( + (itd, index) => `${itd}.fromTop(p[${index}]),`, + ).join(` + `)} + ]})`; + return `data.length > ${multiValueStartIndex} + ? ${decoders} + : []`; + } + + private encodeArrayOfMulti(variadicMultiContent: string, inputName: string) { + const innerTypesEncoder = splitCommaSeparatedArgs(variadicMultiContent).map( + (innerType) => + `(toEncode: ${mapType(innerType, this.abi)}) => ${mapEncoderType( + "toEncode", + innerType, + this.abi, + )}`, + ); + + const innerTypesEncoderFactories = innerTypesEncoder.join(", "); + const multiHandler = new MultiHandler(this.abi); + const encoder = multiHandler.encode( + "multiValueToEncode", + variadicMultiContent, + ); + return `if(${inputName} !== null && ${inputName}.length > 0) + { + const innerEncoders: ((arg: any) => Encodable)[] = [ ${innerTypesEncoderFactories} ]; + for(let i = 0; i < ${inputName}.length; i++) + { + const multiValueToEncode = ${inputName}[i]; + ${encoder} + } + }`; + } + + private encodeArrayOfTypes(inputName: string, variadicContent: string) { + const lastValueEncoder = mapEncoderType( + `${inputName}[i]`, + variadicContent, + this.abi, + ); + return `if(${inputName} !== null && ${inputName}.length > 0) + { + for(let i = 0; i < ${inputName}.length; i++) + { + const encoder = ${lastValueEncoder}; + encoders.push(encoder); + } + }`; + } +} diff --git a/xsuite/src/cli/generateproxy/types.ts b/xsuite/src/cli/generateproxy/types.ts index 256e63c1..ad0c44a3 100644 --- a/xsuite/src/cli/generateproxy/types.ts +++ b/xsuite/src/cli/generateproxy/types.ts @@ -1,15 +1,21 @@ -export const generateAbiTypes = (abi: any) => { +import { AbiDefinition, FieldDefinition, TypeDefinition } from "./abi"; +import { splitCommaSeparatedArgs } from "./utils"; + +export const generateAbiTypes = (abi: AbiDefinition) => { const code = Object.entries(abi.types) - .map((type) => generateType(type)) + .map((type) => generateType(type, abi)) .join("\n"); return code; }; -const generateType = (typeDefinition: any) => { +const generateType = ( + typeDefinition: [string, TypeDefinition], + abi: AbiDefinition, +) => { switch (typeDefinition[1].type) { case "struct": - return generateInterface(typeDefinition); + return generateInterface(typeDefinition, abi); case "enum": return generateEnum(typeDefinition); case "explicit-enum": @@ -19,15 +25,23 @@ const generateType = (typeDefinition: any) => { } }; -const generateInterface = (typeDefinition: any) => { +const generateInterface = ( + typeDefinition: [string, TypeDefinition], + abi: AbiDefinition, +) => { return `export interface ${typeDefinition[0]} { - ${generateFields(typeDefinition[1].fields).join("\n ")} + ${generateFields(typeDefinition[1].fields ?? [], abi).join("\n ")} } `; }; -const generateFields = (fieldDefinitions: any) => { - return fieldDefinitions.map((f: any) => `${f.name}: ${mapType(f.type)},`); +const generateFields = ( + fieldDefinitions: FieldDefinition[], + abi: AbiDefinition, +) => { + return fieldDefinitions.map( + (f: any) => `${f.name}: ${mapType(f.type, abi)},`, + ); }; const generateEnum = (enumDefinition: any) => { @@ -52,28 +66,32 @@ const generateExplicitEnumVariants = (variantDefinitions: any) => { return variantDefinitions.map((v: any) => `${v.name}, // ${v.docs}`); }; -export const mapType = (abiType: string): string => { +export const mapType = (abiType: string, abi: AbiDefinition): string => { + if (abiType === "ignore") { + return "undefined"; + } + // handling List - const listMatch = abiType.match(/^List<(.+)>$/); + const listMatch = abiType.match(/^(List|variadic)<(.+)>$/); if (listMatch) { - const innerType: any = mapType(listMatch[1]); - return `${innerType}[]`; + const innerType: any = mapType(listMatch[2], abi); + return `(${innerType})[]`; } // handling Option const optionMatch = abiType.match(/^(Option|optional)<(.+)>$/); if (optionMatch) { - const innerType: any = mapType(optionMatch[2]); + const innerType: any = mapType(optionMatch[2], abi); return `(${innerType} | null)`; } // handling tuples - const tupleMatch = abiType.match(/^tuple<(.+)>$/); + const tupleMatch = abiType.match(/^(tuple|multi)<(.+)>$/); if (tupleMatch) { - const innerTypesSeperatedByComma: string = tupleMatch[1]; - const innerTypes = innerTypesSeperatedByComma - .split(",") - .map((t) => mapType(t.trim())); + const innerTypesSeperatedByComma: string = tupleMatch[2]; + const innerTypes = splitCommaSeparatedArgs(innerTypesSeperatedByComma).map( + (t) => mapType(t.trim(), abi), + ); return `readonly [${innerTypes.join(", ")}]`; } @@ -81,7 +99,7 @@ export const mapType = (abiType: string): string => { const arrayNMatch = abiType.match(/^array(\d+)<(.+)>$/); if (arrayNMatch) { const arrayLength = Number(arrayNMatch[1]); - const innerType = mapType(arrayNMatch[2]); + const innerType = mapType(arrayNMatch[2], abi); const innerTypes: string[] = []; for (let i = 0; i < arrayLength; i++) { innerTypes.push(innerType); @@ -100,6 +118,7 @@ export const mapType = (abiType: string): string => { case "i8": case "i16": case "i32": + case "CodeMetadata": return "number"; case "u64": case "i64": @@ -114,6 +133,11 @@ export const mapType = (abiType: string): string => { case "bytes": return "Uint8Array"; default: + if (abi.types[abiType] === undefined) { + throw Error( + `Type ${abiType} is currently not supported by the xsuite framework.`, + ); + } return abiType; } }; diff --git a/xsuite/src/cli/generateproxy/utils.test.ts b/xsuite/src/cli/generateproxy/utils.test.ts index 3a5d5d02..664b308f 100644 --- a/xsuite/src/cli/generateproxy/utils.test.ts +++ b/xsuite/src/cli/generateproxy/utils.test.ts @@ -1,18 +1,18 @@ -import { test, expect } from "@jest/globals"; -import { splitCommaSeperatedArgs } from "./utils"; +import { test, expect } from "vitest"; +import { splitCommaSeparatedArgs } from "./utils"; -test("splitCommaSeperatedArgs splits 'tuple,BigUint'", () => { - const commaseperatedTypes = "tuple,BigUint"; - expect(splitCommaSeperatedArgs(commaseperatedTypes)).toStrictEqual([ +test("splitCommaSeparatedArgs splits 'tuple,BigUint'", () => { + const commaSeparatedTypes = "tuple,BigUint"; + expect(splitCommaSeparatedArgs(commaSeparatedTypes)).toStrictEqual([ "tuple", "BigUint", ]); }); -test("splitCommaSeperatedArgs splits 'BigUint,u8,BigUInt,Tuple,TokenIdentifier,u16>'", () => { - const commaseperatedTypes = +test("splitCommaSeparatedArgs splits 'BigUint,u8,BigUInt,Tuple,TokenIdentifier,u16>'", () => { + const commaSeparatedTypes = "BigUint,u8,BigUint,tuple,TokenIdentifier,u16>"; - expect(splitCommaSeperatedArgs(commaseperatedTypes)).toStrictEqual([ + expect(splitCommaSeparatedArgs(commaSeparatedTypes)).toStrictEqual([ "BigUint", "u8", "BigUint", diff --git a/xsuite/src/cli/generateproxy/utils.ts b/xsuite/src/cli/generateproxy/utils.ts index bce16f25..53629506 100644 --- a/xsuite/src/cli/generateproxy/utils.ts +++ b/xsuite/src/cli/generateproxy/utils.ts @@ -1,4 +1,4 @@ -export const splitCommaSeperatedArgs = (input: string) => { +export const splitCommaSeparatedArgs = (input: string) => { const result = []; let currentSegment = ""; let angleBracketCount = 0; From 37b2b5663a073f746be0966701abce42522ea296 Mon Sep 17 00:00:00 2001 From: janniksam Date: Sun, 11 Feb 2024 12:14:28 +0100 Subject: [PATCH 3/3] update crates --- xsuite/contracts/.gitignore | 1 + xsuite/contracts/datatypes/Cargo.lock | 163 ++ xsuite/contracts/datatypes/Cargo.toml | 2 +- xsuite/contracts/datatypes/meta/Cargo.lock | 1753 +++++++++++++++++ xsuite/contracts/datatypes/meta/Cargo.toml | 2 +- .../datatypes/output/datatypes.abi.json | 25 +- .../contracts/datatypes/output/datatypes.wasm | Bin 14695 -> 14980 bytes xsuite/contracts/datatypes/src/lib.rs | 8 + xsuite/contracts/datatypes/wasm/Cargo.lock | 122 +- xsuite/contracts/datatypes/wasm/Cargo.toml | 2 +- .../abis/unsupported/complex_enum.abi.json | 116 ++ xsuite/src/cli/generateproxy/decoders.ts | 18 +- .../cli/generateproxy/generateproxy.test.ts | 50 +- xsuite/src/cli/generateproxy/utils.test.ts | 18 +- xsuite/src/cli/generateproxy/utils.ts | 18 + 15 files changed, 2184 insertions(+), 114 deletions(-) create mode 100644 xsuite/contracts/datatypes/Cargo.lock create mode 100644 xsuite/contracts/datatypes/meta/Cargo.lock create mode 100644 xsuite/src/cli/generateproxy/abis/unsupported/complex_enum.abi.json diff --git a/xsuite/contracts/.gitignore b/xsuite/contracts/.gitignore index c5b708b7..6963c236 100644 --- a/xsuite/contracts/.gitignore +++ b/xsuite/contracts/.gitignore @@ -1,3 +1,4 @@ */output/* +*/target/* !*/output/*.wasm !*/output/datatypes.abi.json diff --git a/xsuite/contracts/datatypes/Cargo.lock b/xsuite/contracts/datatypes/Cargo.lock new file mode 100644 index 00000000..25cd8055 --- /dev/null +++ b/xsuite/contracts/datatypes/Cargo.lock @@ -0,0 +1,163 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + +[[package]] +name = "datatypes" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "multiversx-sc" +version = "0.47.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40b69a83a9423be4b543edee969205aa43ef4397c48b965a65bad857e022db5c" +dependencies = [ + "bitflags", + "hex-literal", + "multiversx-sc-codec", + "multiversx-sc-derive", + "num-traits", +] + +[[package]] +name = "multiversx-sc-codec" +version = "0.18.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1da6db65170105c9495848c5e4ba388abb1f9201ff2ca362056c9328f36b7760" +dependencies = [ + "arrayvec", + "multiversx-sc-codec-derive", +] + +[[package]] +name = "multiversx-sc-codec-derive" +version = "0.18.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "631c4d4b37fc94659c8d6cf559c21b68c68899095201de2e1b779fccad7b0b03" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "multiversx-sc-derive" +version = "0.47.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5fe6400e2f4e57f7c9c00ad76108794aa962657cf62b4d4f49b99f02d9a6ba5" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "radix_trie", + "syn", +] + +[[package]] +name = "nibble_vec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" +dependencies = [ + "smallvec", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radix_trie" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd" +dependencies = [ + "endian-type", + "nibble_vec", +] + +[[package]] +name = "smallvec" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" + +[[package]] +name = "syn" +version = "2.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" diff --git a/xsuite/contracts/datatypes/Cargo.toml b/xsuite/contracts/datatypes/Cargo.toml index 5d45779e..2bd08a08 100644 --- a/xsuite/contracts/datatypes/Cargo.toml +++ b/xsuite/contracts/datatypes/Cargo.toml @@ -5,4 +5,4 @@ edition = "2021" publish = false [dependencies.multiversx-sc] -version = "0.45.1" +version = "0.47.4" diff --git a/xsuite/contracts/datatypes/meta/Cargo.lock b/xsuite/contracts/datatypes/meta/Cargo.lock new file mode 100644 index 00000000..239eca72 --- /dev/null +++ b/xsuite/contracts/datatypes/meta/Cargo.lock @@ -0,0 +1,1753 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + +[[package]] +name = "anyhow" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + +[[package]] +name = "bstr" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "colored" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" +dependencies = [ + "lazy_static", + "windows-sys 0.48.0", +] + +[[package]] +name = "common-path" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2382f75942f4b3be3690fe4f86365e9c853c1587d6ee58212cebf6e2a9ccd101" + +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "copy_dir" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "543d1dd138ef086e2ff05e3a48cf9da045da2033d16f8538fd76b86cd49b2ca3" +dependencies = [ + "walkdir", +] + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + +[[package]] +name = "datatypes" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "datatypes-meta" +version = "0.0.0" +dependencies = [ + "datatypes", + "multiversx-sc-meta", +] + +[[package]] +name = "encoding_rs" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "fastrand" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + +[[package]] +name = "flate2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-core", + "futures-io", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "globset" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "h2" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "http" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "ignore" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" +dependencies = [ + "crossbeam-deque", + "globset", + "log", + "memchr", + "regex-automata", + "same-file", + "walkdir", + "winapi-util", +] + +[[package]] +name = "indexmap" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "ipnet" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" + +[[package]] +name = "itoa" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" + +[[package]] +name = "js-sys" +version = "0.3.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" + +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "multiversx-sc" +version = "0.47.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40b69a83a9423be4b543edee969205aa43ef4397c48b965a65bad857e022db5c" +dependencies = [ + "bitflags 2.4.2", + "hex-literal", + "multiversx-sc-codec", + "multiversx-sc-derive", + "num-traits", +] + +[[package]] +name = "multiversx-sc-codec" +version = "0.18.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1da6db65170105c9495848c5e4ba388abb1f9201ff2ca362056c9328f36b7760" +dependencies = [ + "arrayvec", + "multiversx-sc-codec-derive", + "num-bigint", +] + +[[package]] +name = "multiversx-sc-codec-derive" +version = "0.18.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "631c4d4b37fc94659c8d6cf559c21b68c68899095201de2e1b779fccad7b0b03" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "multiversx-sc-derive" +version = "0.47.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5fe6400e2f4e57f7c9c00ad76108794aa962657cf62b4d4f49b99f02d9a6ba5" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "radix_trie", + "syn", +] + +[[package]] +name = "multiversx-sc-meta" +version = "0.47.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12dec6cc0735acb48fce290b367c9d22684103055f00a7dec057840fc134973d" +dependencies = [ + "clap", + "colored", + "common-path", + "convert_case", + "copy_dir", + "hex", + "lazy_static", + "multiversx-sc", + "pathdiff", + "reqwest", + "ruplacer", + "rustc_version", + "semver", + "serde", + "serde_json", + "toml", + "wasmparser", + "wasmprinter", + "zip", +] + +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nibble_vec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" +dependencies = [ + "smallvec", +] + +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "openssl" +version = "0.10.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" +dependencies = [ + "bitflags 2.4.2", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radix_trie" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd" +dependencies = [ + "endian-type", + "nibble_vec", +] + +[[package]] +name = "regex" +version = "1.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "reqwest" +version = "0.11.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "ruplacer" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58a26a1b15ff113d31d139357f7422708312978ed69cd5dd47e36d1b80b7eaf3" +dependencies = [ + "Inflector", + "anyhow", + "clap", + "colored", + "ignore", + "regex", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.38.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +dependencies = [ + "bitflags 2.4.2", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64", +] + +[[package]] +name = "ryu" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "schannel" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "security-framework" +version = "2.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" + +[[package]] +name = "serde" +version = "1.0.196" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.196" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.113" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_spanned" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" + +[[package]] +name = "socket2" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "strsim" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" + +[[package]] +name = "syn" +version = "2.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys 0.52.0", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "pin-project-lite", + "socket2", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "toml" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9ffdf896f8daaabf9b66ba8e77ea1ed5ed0f72821b398aba62352e95062951" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" + +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "walkdir" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" + +[[package]] +name = "wasmparser" +version = "0.121.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99ffe16b4aa1ebab8724f61c9ee38cd5481c89caf10bf1a5af9eab8f0c2e6c05" +dependencies = [ + "bitflags 2.4.2", + "indexmap", + "semver", +] + +[[package]] +name = "wasmprinter" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4a76a9228f2e6653f0b3d912b2f3a9b6ac79c690e5642c9ee2dfd914c545cf0" +dependencies = [ + "anyhow", + "wasmparser", +] + +[[package]] +name = "web-sys" +version = "0.3.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + +[[package]] +name = "winnow" +version = "0.5.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "zip" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +dependencies = [ + "byteorder", + "crc32fast", + "crossbeam-utils", + "flate2", +] diff --git a/xsuite/contracts/datatypes/meta/Cargo.toml b/xsuite/contracts/datatypes/meta/Cargo.toml index 77a6887a..ede66ab8 100644 --- a/xsuite/contracts/datatypes/meta/Cargo.toml +++ b/xsuite/contracts/datatypes/meta/Cargo.toml @@ -8,4 +8,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.45.1" +version = "0.47.4" diff --git a/xsuite/contracts/datatypes/output/datatypes.abi.json b/xsuite/contracts/datatypes/output/datatypes.abi.json index 9814f7a4..6e25cbd4 100644 --- a/xsuite/contracts/datatypes/output/datatypes.abi.json +++ b/xsuite/contracts/datatypes/output/datatypes.abi.json @@ -1,11 +1,11 @@ { "buildInfo": { "rustc": { - "version": "1.72.0-nightly", - "commitHash": "8c74a5d27c644a0f7a22bb2fa8dd3ff8257bc220", - "commitDate": "2023-06-14", + "version": "1.76.0-nightly", + "commitHash": "d86d65bbc19b928387f68427fcc3a0da498d8a19", + "commitDate": "2023-12-10", "channel": "Nightly", - "short": "rustc 1.72.0-nightly (8c74a5d27 2023-06-14)" + "short": "rustc 1.76.0-nightly (d86d65bbc 2023-12-10)" }, "contractCrate": { "name": "datatypes", @@ -13,7 +13,7 @@ }, "framework": { "name": "multiversx-sc", - "version": "0.45.2" + "version": "0.47.4" } }, "name": "DataTypes", @@ -327,6 +327,21 @@ } ] }, + { + "name": "getSingleValueMapperComplex", + "mutability": "readonly", + "inputs": [ + { + "name": "input", + "type": "u8" + } + ], + "outputs": [ + { + "type": "SubType" + } + ] + }, { "name": "getVecMapper", "mutability": "readonly", diff --git a/xsuite/contracts/datatypes/output/datatypes.wasm b/xsuite/contracts/datatypes/output/datatypes.wasm index d5594ae8a2082142ab856f16798a9d672659d6b8..f8a3a82a24f7e52fd12333e7be7428cfb79291e2 100755 GIT binary patch literal 14980 zcmcheYj9jweZbE-_wH(?tH+70B#PpOyBj6Q;CCF`we!$jzY?%x7dt>9)KRRBEyk*p>fwhQGrPv8#%GTjCw(^*eKXU?>$>LtsoC)(Q;jhb$+$m0IyHKvF?L{k zHa0fXn4LATbT7-7?QYCvGe=GxZ%oaF`NcqX;zVO=tbTT`F>5-*ihLtBA3e5nW@dUO zY~@>9?P*LMnadHoarXG=v14ElhytZ1s6Bf%HxzU4XPoU&~WS29rHz;|l`;&GV-TO|= zjZaUtdOu~ap*NeE89m$T{IquNn>*T=X>~qpubsUjyg#F1q)GYSQ^)4Ub$o;Q+~tclOpVE+KeH>^ zwrj1~Idyn?3?K9PMJrq5x0y?}pOvkiV#V{em;QT?OrhQi-h4r49vGiGaxC=h9mV;~ zm_N5SGV`+j?bF9k9BVvczG%A{erw}!KK)Djen5Dt%U@7Q-w&Lz#taUyIq+qj$gF(g zS8~bc@5TOKwUxtou=?oXN%J*(^OcBs+xXnk7KIzk^S0~Ip)pkI5WX|A$)Q6>8>1%< zJv2Joh+NlykA2dvF>WNasoNWmq%Mv3_E>+TN#y_3&|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cL|m9Wbafx*@p+;=LrnNlIBM_U0cFV`8*{ zx-s;}hEllmF)&G-m?lVZN=wn?oLx)l;>|u7pf&VuPvEB=FYAvnPXCj2_4o-_%&3Ay z;b}!IK~BB}wPj;nR<;PGz0XtDsGB3?>Wj8Us~&CvyvpjmZcYfkKd)cL2CB}xNWH1P z5b&$d2ce&%bXg<`5kuZSKrXr|hiKR?mS8=h{DUOG2h2uiZ#5>Qd4sceID^)VQCkl( zm8oPuZlg6^olFk|$+Q%jVo)j2x5*4JUE~Hn7y`jI$Rw&7?h!HI|0M?H#=7MtJ(dgt z%u)cPY+9P4%Mna4;0;BUt0O+;s$;#-YHQ26z<&^7DRS`Jne4TsM>`BLL_7>)>lFKbEWVn ztHW&M3C3%?SW`L(aou_q210_8>=RcwB)Q3C(t&!Q3d8Yllt=OMAF{>ZO39^yZJ^@i zegAHw+wfsD&9GfHAI}zi=5oOcE5i*m9SVu+AK=z3+v~ z`X~XAT6V4Uz|qvfn;X!^x4&Xb!jP|Us^mhvv_W5er7u7_iSgX{3E!0x}!gC$vgV{ zwtQme;V}KF&NF#6V@2!v^Q!Z`o@bT;moJ`Oc(SvcFFn;8=xw<2^wRR`(ff`a*|VTO zV42>t$Sx;lruWROb{6)`EIzdqd*){r=T`Ovl<1xAJj-_aGqFv09nSa6cNU+Vnr0{d z3MuD>Kf43)i2!_=KNl)n=Q=0LR&Vsg$@n)gE8&lBPK3S6NoT9Sr#aCB5oidL^tUey z`pcp4wiNy>YHGd&0DG1@XU@*>$2ccwPd#~Zx@g~X SingleValueMapper; + #[view(getSingleValueMapperComplex)] + #[storage_mapper("single_value_mapper_complex")] + fn single_value_mapper_complex(&self, input: u8) -> SingleValueMapper>; + #[view(getVecMapper)] #[storage_mapper("vec_mapper")] fn vec_mapper(&self, input: u8) -> VecMapper; diff --git a/xsuite/contracts/datatypes/wasm/Cargo.lock b/xsuite/contracts/datatypes/wasm/Cargo.lock index ffc59e1a..0df9334c 100644 --- a/xsuite/contracts/datatypes/wasm/Cargo.lock +++ b/xsuite/contracts/datatypes/wasm/Cargo.lock @@ -2,24 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "ahash" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "allocator-api2" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" - [[package]] name = "arrayvec" version = "0.7.4" @@ -34,15 +16,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "cfg-if" -version = "1.0.0" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "datatypes" @@ -65,16 +41,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" -[[package]] -name = "hashbrown" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" -dependencies = [ - "ahash", - "allocator-api2", -] - [[package]] name = "hex" version = "0.4.3" @@ -89,12 +55,11 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-sc" -version = "0.45.1" +version = "0.47.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f11b51d6a2ab0218585ed58e100c5ac2218de09490fbfc4243b5ecd0ca7f5cbc" +checksum = "40b69a83a9423be4b543edee969205aa43ef4397c48b965a65bad857e022db5c" dependencies = [ "bitflags", - "hashbrown", "hex-literal", "multiversx-sc-codec", "multiversx-sc-derive", @@ -103,9 +68,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.18.2" +version = "0.18.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327b0ad1c3477cab0d7c84391439ba302238f738ef3c6e1fcd18e247fba84875" +checksum = "1da6db65170105c9495848c5e4ba388abb1f9201ff2ca362056c9328f36b7760" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -113,34 +78,34 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.18.2" +version = "0.18.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f444038e0043b8eda816b26952479c2aca3c4a643580f4337f71fb362a586db5" +checksum = "631c4d4b37fc94659c8d6cf559c21b68c68899095201de2e1b779fccad7b0b03" dependencies = [ "hex", "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] name = "multiversx-sc-derive" -version = "0.45.1" +version = "0.47.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784f0fc505806102fe6f808b368e12fcb13096dd73c5678f09c5663230724d6f" +checksum = "d5fe6400e2f4e57f7c9c00ad76108794aa962657cf62b4d4f49b99f02d9a6ba5" dependencies = [ "hex", "proc-macro2", "quote", "radix_trie", - "syn 1.0.109", + "syn", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.45.1" +version = "0.47.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5afb8b8cc380eabd82dc8f9b02afbab3dce16fc2b5de1dbc601fcfcf261278ba" +checksum = "304900b34dfae6fd5baddd4c98345f1b7fa7e839257dac961023733be40dd81e" dependencies = [ "multiversx-sc", ] @@ -163,26 +128,20 @@ dependencies = [ "autocfg", ] -[[package]] -name = "once_cell" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" - [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -199,26 +158,15 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.2" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "syn" -version = "1.0.109" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -230,29 +178,3 @@ name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "zerocopy" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] diff --git a/xsuite/contracts/datatypes/wasm/Cargo.toml b/xsuite/contracts/datatypes/wasm/Cargo.toml index a23bc4ce..16522a0e 100644 --- a/xsuite/contracts/datatypes/wasm/Cargo.toml +++ b/xsuite/contracts/datatypes/wasm/Cargo.toml @@ -24,7 +24,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.45.1" +version = "0.47.4" [workspace] members = ["."] diff --git a/xsuite/src/cli/generateproxy/abis/unsupported/complex_enum.abi.json b/xsuite/src/cli/generateproxy/abis/unsupported/complex_enum.abi.json new file mode 100644 index 00000000..f0b254d7 --- /dev/null +++ b/xsuite/src/cli/generateproxy/abis/unsupported/complex_enum.abi.json @@ -0,0 +1,116 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.76.0-nightly", + "commitHash": "d86d65bbc19b928387f68427fcc3a0da498d8a19", + "commitDate": "2023-12-10", + "channel": "Nightly", + "short": "rustc 1.76.0-nightly (d86d65bbc 2023-12-10)" + }, + "contractCrate": { + "name": "datatypes", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.47.4" + } + }, + "name": "DataTypes", + "constructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "getOtherDataTypes", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "OtherDataTypes" + } + ] + }, + { + "name": "setOtherDataTypes", + "mutability": "mutable", + "inputs": [ + { + "name": "data", + "type": "OtherDataTypes" + } + ], + "outputs": [ + { + "type": "OtherDataTypes" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "ComplexEnum": { + "type": "enum", + "variants": [ + { + "name": "Default", + "discriminant": 0 + }, + { + "name": "Struct", + "discriminant": 1, + "fields": [ + { + "name": "int", + "type": "u16" + }, + { + "name": "another_byte", + "type": "u8" + }, + { + "name": "uint_32", + "type": "u32" + }, + { + "name": "uint_64", + "type": "u64" + } + ] + } + ] + }, + "OtherDataTypes": { + "type": "struct", + "fields": [ + { + "name": "custom_type", + "type": "SubType" + }, + { + "name": "complex_enum", + "type": "ComplexEnum" + }, + { + "name": "code_metadata", + "type": "CodeMetadata" + } + ] + }, + "SubType": { + "type": "struct", + "fields": [ + { + "name": "big_unsigned_integer", + "type": "BigUint" + }, + { + "name": "address", + "type": "Address" + } + ] + } + } +} \ No newline at end of file diff --git a/xsuite/src/cli/generateproxy/decoders.ts b/xsuite/src/cli/generateproxy/decoders.ts index 99014c9b..ae04f0cf 100644 --- a/xsuite/src/cli/generateproxy/decoders.ts +++ b/xsuite/src/cli/generateproxy/decoders.ts @@ -45,10 +45,20 @@ const generateFieldsDecoder = ( }; const generateEnumDecoder = (enumDefinition: [string, TypeDefinition]) => { - return `export const ${enumDefinition[0]}Decoder = () => d.U8().then((v) => { - const enumValue: ${enumDefinition[0]} = Number(v); - return enumValue; -}); + const hasFields = + enumDefinition[1].variants?.filter((p) => p.fields?.length ?? 0 > 0) + ?.length ?? 0 > 0; + if (hasFields) { + throw Error( + "Complex enums are currently not supported by the xsuite framework.", + ); + } + + return ` + export const ${enumDefinition[0]}Decoder = () => d.U8().then((v) => { + const enumValue: ${enumDefinition[0]} = Number(v); + return enumValue; + }); `; }; diff --git a/xsuite/src/cli/generateproxy/generateproxy.test.ts b/xsuite/src/cli/generateproxy/generateproxy.test.ts index eddc380f..5ab7a7ae 100644 --- a/xsuite/src/cli/generateproxy/generateproxy.test.ts +++ b/xsuite/src/cli/generateproxy/generateproxy.test.ts @@ -4,6 +4,7 @@ import path from "node:path"; import { test, beforeEach, afterEach, expect } from "vitest"; import { SContract, SWallet, SWorld } from "../../world"; import { getCommand } from "../cmd"; +import { replaceInObject } from "./utils"; const abiDirSupported = path.resolve(__dirname, "abis/supported"); const abiDirUnsupported = path.resolve(__dirname, "abis/unsupported"); @@ -50,6 +51,17 @@ test("generateproxy throws, when two multivalues are given", async () => { ); }); +test("generateproxy throws, when a complex enum type is provided", async () => { + const targetFilePath = `${tmpDir}/datatypes.ts`; + await expect(() => + run( + `generateproxy --from-abi ${abiDirUnsupported}/complex_enum.abi.json --output=${targetFilePath}`, + ), + ).rejects.toThrow( + "Complex enums are currently not supported by the xsuite framework.", + ); +}); + test("generateproxy test abis", async () => { const files = fs.readdirSync(abiDirSupported); files.forEach(async (file) => { @@ -252,6 +264,38 @@ test("generateproxy processes IgnoreValue properly", async () => { await queryAndVerify(builder, [1, ["ignored", 12]], undefined); }); +test("generateproxy processes SingleValueMapper properly", async () => { + const targetFilePath = `${tmpDir}/datatypes.ts`; + await run( + `generateproxy --from-abi ${dataTypesAbiPath} --output=${targetFilePath}`, + ); + + const generatedCode = await import(targetFilePath); + const builder = generatedCode.getSingleValueMapperBuilder(); + await queryAndVerify(builder, [0], 1n); + await queryAndVerify(builder, [1], 2n); + await queryAndVerify(builder, [2], 0n); +}); + +test("generateproxy processes SingleValueMapper with Complex Type properly", async () => { + const targetFilePath = `${tmpDir}/datatypes.ts`; + await run( + `generateproxy --from-abi ${dataTypesAbiPath} --output=${targetFilePath}`, + ); + + const generatedCode = await import(targetFilePath); + const builder = generatedCode.getSingleValueMapperComplexBuilder(); + await queryAndVerify(builder, [0], { + address: "%contract%", + big_unsigned_integer: 12n, + }); + await expect( + async () => await queryAndVerify(builder, [1], null), + ).rejects.toThrow( + /(Query failed: 4 - storage decode error: input too short - Result:)/, + ); +}); + test("generateproxy processes VecMapper properly", async () => { const targetFilePath = `${tmpDir}/datatypes.ts`; await run( @@ -366,7 +410,11 @@ const queryAndVerify = async ( }); const decodedData = builder.decodeOutput(response.returnData); - expect(decodedData).toStrictEqual(expectedOutput); + const expected = replaceInObject(expectedOutput, [ + ["%owner%", owner.toString()], + ["%contract%", deployedContract.contract.toString()], + ]); + expect(decodedData).toStrictEqual(expected); } finally { await world.terminate(); } diff --git a/xsuite/src/cli/generateproxy/utils.test.ts b/xsuite/src/cli/generateproxy/utils.test.ts index 664b308f..aa32b561 100644 --- a/xsuite/src/cli/generateproxy/utils.test.ts +++ b/xsuite/src/cli/generateproxy/utils.test.ts @@ -1,5 +1,5 @@ import { test, expect } from "vitest"; -import { splitCommaSeparatedArgs } from "./utils"; +import { replaceInObject, splitCommaSeparatedArgs } from "./utils"; test("splitCommaSeparatedArgs splits 'tuple,BigUint'", () => { const commaSeparatedTypes = "tuple,BigUint"; @@ -19,3 +19,19 @@ test("splitCommaSeparatedArgs splits 'BigUint,u8,BigUInt,Tuple,TokenIdentifier,u16>", ]); }); + +test("replaceInObject replaces strings", () => { + const input = { + test: { + foo: "test123", + bar: "test124", + }, + }; + + expect(replaceInObject(input, [["test123", "1337"]])).toStrictEqual({ + test: { + foo: "1337", + bar: "test124", + }, + }); +}); diff --git a/xsuite/src/cli/generateproxy/utils.ts b/xsuite/src/cli/generateproxy/utils.ts index 53629506..59cec2cc 100644 --- a/xsuite/src/cli/generateproxy/utils.ts +++ b/xsuite/src/cli/generateproxy/utils.ts @@ -24,3 +24,21 @@ export const splitCommaSeparatedArgs = (input: string) => { return result; }; + +export const replaceInObject = ( + obj: any, + replacements: [toReplace: string, replaceValue: string][], +) => { + if (typeof obj === "object") { + for (const keys in obj) { + if (typeof obj[keys] === "object") { + replaceInObject(obj[keys], replacements); + } else if (typeof obj[keys] === "string") { + replacements.forEach((r) => { + obj[keys] = obj[keys].replace(r[0], r[1]); + }); + } + } + } + return obj; +};