@pezkuwi/api-contract 16.5.6 → 16.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/Abi/index.d.ts +31 -0
- package/build/Abi/index.js +359 -0
- package/build/Abi/toLatestCompatible.d.ts +15 -0
- package/build/Abi/toLatestCompatible.js +30 -0
- package/build/Abi/toV1.d.ts +3 -0
- package/build/Abi/toV1.js +21 -0
- package/build/Abi/toV2.d.ts +3 -0
- package/build/Abi/toV2.js +27 -0
- package/build/Abi/toV3.d.ts +3 -0
- package/build/Abi/toV3.js +10 -0
- package/build/Abi/toV4.d.ts +3 -0
- package/build/Abi/toV4.js +10 -0
- package/build/LICENSE +201 -0
- package/build/README.md +3 -0
- package/build/augment.d.ts +1 -0
- package/build/augment.js +1 -0
- package/build/base/Base.d.ts +13 -0
- package/build/base/Base.js +40 -0
- package/build/base/Blueprint.d.ts +24 -0
- package/build/base/Blueprint.js +51 -0
- package/build/base/Code.d.ts +22 -0
- package/build/base/Code.js +74 -0
- package/build/base/Contract.d.ts +25 -0
- package/build/base/Contract.js +127 -0
- package/build/base/index.d.ts +3 -0
- package/build/base/index.js +3 -0
- package/build/base/mock.d.ts +3 -0
- package/build/base/mock.js +38 -0
- package/build/base/types.d.ts +25 -0
- package/build/base/types.js +1 -0
- package/build/base/util.d.ts +16 -0
- package/build/base/util.js +33 -0
- package/build/bundle-pezkuwi-api-contract.js +1238 -0
- package/build/bundle.d.ts +4 -0
- package/build/bundle.js +4 -0
- package/build/cjs/Abi/index.d.ts +31 -0
- package/build/cjs/Abi/index.js +363 -0
- package/build/cjs/Abi/toLatestCompatible.d.ts +15 -0
- package/build/cjs/Abi/toLatestCompatible.js +36 -0
- package/build/cjs/Abi/toV1.d.ts +3 -0
- package/build/cjs/Abi/toV1.js +24 -0
- package/build/cjs/Abi/toV2.d.ts +3 -0
- package/build/cjs/Abi/toV2.js +30 -0
- package/build/cjs/Abi/toV3.d.ts +3 -0
- package/build/cjs/Abi/toV3.js +13 -0
- package/build/cjs/Abi/toV4.d.ts +3 -0
- package/build/cjs/Abi/toV4.js +13 -0
- package/build/cjs/augment.d.ts +1 -0
- package/build/cjs/augment.js +3 -0
- package/build/cjs/base/Base.d.ts +13 -0
- package/build/cjs/base/Base.js +44 -0
- package/build/cjs/base/Blueprint.d.ts +24 -0
- package/build/cjs/base/Blueprint.js +57 -0
- package/build/cjs/base/Code.d.ts +22 -0
- package/build/cjs/base/Code.js +80 -0
- package/build/cjs/base/Contract.d.ts +25 -0
- package/build/cjs/base/Contract.js +133 -0
- package/build/cjs/base/index.d.ts +3 -0
- package/build/cjs/base/index.js +14 -0
- package/build/cjs/base/mock.d.ts +3 -0
- package/build/cjs/base/mock.js +41 -0
- package/build/cjs/base/types.d.ts +25 -0
- package/build/cjs/base/types.js +2 -0
- package/build/cjs/base/util.d.ts +16 -0
- package/build/cjs/base/util.js +42 -0
- package/build/cjs/bundle.d.ts +4 -0
- package/build/cjs/bundle.js +10 -0
- package/build/cjs/index.d.ts +2 -0
- package/build/cjs/index.js +5 -0
- package/build/cjs/package.json +3 -0
- package/build/cjs/packageDetect.d.ts +1 -0
- package/build/cjs/packageDetect.js +7 -0
- package/build/cjs/packageInfo.d.ts +6 -0
- package/build/cjs/packageInfo.js +4 -0
- package/build/cjs/promise/index.d.ts +13 -0
- package/build/cjs/promise/index.js +23 -0
- package/build/cjs/promise/types.d.ts +3 -0
- package/build/cjs/promise/types.js +2 -0
- package/build/cjs/rx/index.d.ts +13 -0
- package/build/cjs/rx/index.js +23 -0
- package/build/cjs/rx/types.d.ts +3 -0
- package/build/cjs/rx/types.js +2 -0
- package/build/cjs/types.d.ts +79 -0
- package/build/cjs/types.js +2 -0
- package/build/cjs/util.d.ts +5 -0
- package/build/cjs/util.js +13 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +2 -0
- package/build/package.json +408 -0
- package/build/packageDetect.d.ts +1 -0
- package/build/packageDetect.js +5 -0
- package/build/packageInfo.d.ts +6 -0
- package/build/packageInfo.js +1 -0
- package/build/promise/index.d.ts +13 -0
- package/build/promise/index.js +17 -0
- package/build/promise/types.d.ts +3 -0
- package/build/promise/types.js +1 -0
- package/build/rx/index.d.ts +13 -0
- package/build/rx/index.js +17 -0
- package/build/rx/types.d.ts +3 -0
- package/build/rx/types.js +1 -0
- package/build/types.d.ts +79 -0
- package/build/types.js +1 -0
- package/build/util.d.ts +5 -0
- package/build/util.js +10 -0
- package/build-deno/Abi/index.ts +475 -0
- package/build-deno/Abi/toLatestCompatible.ts +47 -0
- package/build-deno/Abi/toV1.ts +33 -0
- package/build-deno/Abi/toV2.ts +56 -0
- package/build-deno/Abi/toV3.ts +16 -0
- package/build-deno/Abi/toV4.ts +19 -0
- package/build-deno/README.md +3 -0
- package/build-deno/augment.ts +2 -0
- package/build-deno/base/Base.ts +50 -0
- package/build-deno/base/Blueprint.ts +88 -0
- package/build-deno/base/Code.ts +140 -0
- package/build-deno/base/Contract.ts +194 -0
- package/build-deno/base/index.ts +4 -0
- package/build-deno/base/mock.ts +46 -0
- package/build-deno/base/types.ts +38 -0
- package/build-deno/base/util.ts +54 -0
- package/build-deno/bundle.ts +6 -0
- package/build-deno/checkTypes.manual.ts +42 -0
- package/build-deno/index.ts +4 -0
- package/build-deno/mod.ts +2 -0
- package/build-deno/packageDetect.ts +9 -0
- package/build-deno/packageInfo.ts +3 -0
- package/build-deno/promise/index.ts +28 -0
- package/build-deno/promise/types.ts +5 -0
- package/build-deno/rx/index.ts +28 -0
- package/build-deno/rx/types.ts +5 -0
- package/build-deno/test/contracts/index.ts +18 -0
- package/build-deno/test/contracts/ink/index.ts +11 -0
- package/build-deno/test/contracts/ink/v0/accumulator.wasm +0 -0
- package/build-deno/test/contracts/ink/v0/adder.wasm +0 -0
- package/build-deno/test/contracts/ink/v0/delegator.wasm +0 -0
- package/build-deno/test/contracts/ink/v0/dns.wasm +0 -0
- package/build-deno/test/contracts/ink/v0/erc20.wasm +0 -0
- package/build-deno/test/contracts/ink/v0/erc721.wasm +0 -0
- package/build-deno/test/contracts/ink/v0/flipper.wasm +0 -0
- package/build-deno/test/contracts/ink/v0/incrementer.wasm +0 -0
- package/build-deno/test/contracts/ink/v0/index.ts +9 -0
- package/build-deno/test/contracts/ink/v0/multisig_plain.wasm +0 -0
- package/build-deno/test/contracts/ink/v0/subber.wasm +0 -0
- package/build-deno/test/contracts/ink/v0/trait-flipper.wasm +0 -0
- package/build-deno/test/contracts/ink/v1/index.ts +3 -0
- package/build-deno/test/contracts/ink/v2/index.ts +3 -0
- package/build-deno/test/contracts/ink/v3/index.ts +3 -0
- package/build-deno/test/contracts/ink/v4/erc20.wasm +0 -0
- package/build-deno/test/contracts/ink/v4/flipper.wasm +0 -0
- package/build-deno/test/contracts/ink/v4/index.ts +5 -0
- package/build-deno/test/contracts/ink/v5/erc20.wasm +0 -0
- package/build-deno/test/contracts/ink/v5/flipper.wasm +0 -0
- package/build-deno/test/contracts/ink/v5/index.ts +6 -0
- package/build-deno/test/contracts/ink/v6/erc20.polkavm +0 -0
- package/build-deno/test/contracts/ink/v6/index.ts +3 -0
- package/build-deno/test/contracts/solang/index.ts +5 -0
- package/build-deno/test/contracts/solang/v0/index.ts +2 -0
- package/build-deno/test/contracts/solang/v0/ints256.sol +13 -0
- package/build-deno/test/contracts/solang/v0/ints256.wasm +0 -0
- package/build-deno/test/contracts/user/index.ts +7 -0
- package/build-deno/test/contracts/user/v0/assetTransfer.wasm +0 -0
- package/build-deno/test/contracts/user/v0/enumExample.wasm +0 -0
- package/build-deno/test/contracts/user/v0/index.ts +5 -0
- package/build-deno/test/contracts/user/v3/index.ts +2 -0
- package/build-deno/test/contracts/user/v4/index.ts +2 -0
- package/build-deno/test/contracts/util.ts +12 -0
- package/build-deno/types.ts +95 -0
- package/build-deno/util.ts +18 -0
- package/build-tsc/Abi/index.d.ts +31 -0
- package/build-tsc/Abi/toLatestCompatible.d.ts +15 -0
- package/build-tsc/Abi/toV1.d.ts +3 -0
- package/build-tsc/Abi/toV2.d.ts +3 -0
- package/build-tsc/Abi/toV3.d.ts +3 -0
- package/build-tsc/Abi/toV4.d.ts +3 -0
- package/build-tsc/augment.d.ts +1 -0
- package/build-tsc/base/Base.d.ts +13 -0
- package/build-tsc/base/Blueprint.d.ts +24 -0
- package/build-tsc/base/Code.d.ts +22 -0
- package/build-tsc/base/Contract.d.ts +25 -0
- package/build-tsc/base/index.d.ts +3 -0
- package/build-tsc/base/mock.d.ts +3 -0
- package/build-tsc/base/types.d.ts +25 -0
- package/build-tsc/base/util.d.ts +16 -0
- package/build-tsc/bundle.d.ts +4 -0
- package/build-tsc/index.d.ts +2 -0
- package/build-tsc/packageDetect.d.ts +1 -0
- package/build-tsc/packageInfo.d.ts +6 -0
- package/build-tsc/promise/index.d.ts +13 -0
- package/build-tsc/promise/types.d.ts +3 -0
- package/build-tsc/rx/index.d.ts +13 -0
- package/build-tsc/rx/types.d.ts +3 -0
- package/build-tsc/types.d.ts +79 -0
- package/build-tsc/util.d.ts +5 -0
- package/build-tsc-cjs/Abi/index.js +363 -0
- package/build-tsc-cjs/Abi/toLatestCompatible.js +36 -0
- package/build-tsc-cjs/Abi/toV1.js +24 -0
- package/build-tsc-cjs/Abi/toV2.js +30 -0
- package/build-tsc-cjs/Abi/toV3.js +13 -0
- package/build-tsc-cjs/Abi/toV4.js +13 -0
- package/build-tsc-cjs/augment.js +3 -0
- package/build-tsc-cjs/base/Base.js +44 -0
- package/build-tsc-cjs/base/Blueprint.js +57 -0
- package/build-tsc-cjs/base/Code.js +80 -0
- package/build-tsc-cjs/base/Contract.js +133 -0
- package/build-tsc-cjs/base/index.js +14 -0
- package/build-tsc-cjs/base/mock.js +41 -0
- package/build-tsc-cjs/base/types.js +2 -0
- package/build-tsc-cjs/base/util.js +42 -0
- package/build-tsc-cjs/bundle.js +10 -0
- package/build-tsc-cjs/index.js +5 -0
- package/build-tsc-cjs/packageDetect.js +7 -0
- package/build-tsc-cjs/packageInfo.js +4 -0
- package/build-tsc-cjs/promise/index.js +23 -0
- package/build-tsc-cjs/promise/types.js +2 -0
- package/build-tsc-cjs/rx/index.js +23 -0
- package/build-tsc-cjs/rx/types.js +2 -0
- package/build-tsc-cjs/types.js +2 -0
- package/build-tsc-cjs/util.js +13 -0
- package/build-tsc-esm/Abi/index.js +359 -0
- package/build-tsc-esm/Abi/toLatestCompatible.js +30 -0
- package/build-tsc-esm/Abi/toV1.js +21 -0
- package/build-tsc-esm/Abi/toV2.js +27 -0
- package/build-tsc-esm/Abi/toV3.js +10 -0
- package/build-tsc-esm/Abi/toV4.js +10 -0
- package/build-tsc-esm/augment.js +1 -0
- package/build-tsc-esm/base/Base.js +40 -0
- package/build-tsc-esm/base/Blueprint.js +51 -0
- package/build-tsc-esm/base/Code.js +74 -0
- package/build-tsc-esm/base/Contract.js +127 -0
- package/build-tsc-esm/base/index.js +3 -0
- package/build-tsc-esm/base/mock.js +38 -0
- package/build-tsc-esm/base/types.js +1 -0
- package/build-tsc-esm/base/util.js +33 -0
- package/build-tsc-esm/bundle.js +4 -0
- package/build-tsc-esm/index.js +2 -0
- package/build-tsc-esm/packageDetect.js +5 -0
- package/build-tsc-esm/packageInfo.js +1 -0
- package/build-tsc-esm/promise/index.js +17 -0
- package/build-tsc-esm/promise/types.js +1 -0
- package/build-tsc-esm/rx/index.js +17 -0
- package/build-tsc-esm/rx/types.js +1 -0
- package/build-tsc-esm/types.js +1 -0
- package/build-tsc-esm/util.js +10 -0
- package/bundle-pezkuwi-api-contract.js +1 -1
- package/cjs/packageInfo.js +1 -1
- package/package.json +6 -6
- package/packageInfo.js +1 -1
- package/src/Abi/Abi.spec.ts +235 -0
- package/src/Abi/index.ts +477 -0
- package/src/Abi/toLatestCompatible.spec.ts +219 -0
- package/src/Abi/toLatestCompatible.ts +52 -0
- package/src/Abi/toV1.ts +35 -0
- package/src/Abi/toV2.ts +58 -0
- package/src/Abi/toV3.ts +18 -0
- package/src/Abi/toV4.ts +21 -0
- package/src/augment.ts +4 -0
- package/src/base/Base.ts +52 -0
- package/src/base/Blueprint.ts +90 -0
- package/src/base/Code.spec.ts +47 -0
- package/src/base/Code.ts +142 -0
- package/src/base/Contract.ts +197 -0
- package/src/base/index.ts +6 -0
- package/src/base/mock.ts +48 -0
- package/src/base/types.ts +40 -0
- package/src/base/util.ts +56 -0
- package/src/bundle.ts +10 -0
- package/src/checkTypes.manual.ts +45 -0
- package/src/index.ts +6 -0
- package/src/mod.ts +4 -0
- package/src/packageDetect.ts +13 -0
- package/src/packageInfo.ts +6 -0
- package/src/promise/index.ts +28 -0
- package/src/promise/types.ts +7 -0
- package/src/rx/index.ts +28 -0
- package/src/rx/types.ts +7 -0
- package/src/test/compare/ink_v0_delegator.test.json +47 -0
- package/src/test/compare/ink_v0_dns.test.json +232 -0
- package/src/test/compare/ink_v0_erc20.test.json +253 -0
- package/src/test/compare/ink_v0_erc721.test.json +415 -0
- package/src/test/compare/ink_v0_flipper.test.json +9 -0
- package/src/test/compare/ink_v0_flipperBundle.test.json +9 -0
- package/src/test/compare/ink_v0_incrementer.test.json +9 -0
- package/src/test/compare/ink_v0_multisigPlain.test.json +562 -0
- package/src/test/compare/ink_v1_flipper.test.json +9 -0
- package/src/test/compare/ink_v1_psp22.test.json +531 -0
- package/src/test/compare/ink_v2_erc20.test.json +205 -0
- package/src/test/compare/ink_v2_flipper.test.json +9 -0
- package/src/test/compare/ink_v3_flipper.test.json +9 -0
- package/src/test/compare/ink_v3_traitErc20.test.json +205 -0
- package/src/test/compare/ink_v4_erc20Contract.test.json +253 -0
- package/src/test/compare/ink_v4_erc20Metadata.test.json +253 -0
- package/src/test/compare/ink_v4_flipperContract.test.json +155 -0
- package/src/test/compare/ink_v4_flipperMetadata.test.json +155 -0
- package/src/test/compare/ink_v5_erc20.test.json +370 -0
- package/src/test/compare/ink_v5_erc20AnonymousTransferMetadata.test.json +370 -0
- package/src/test/compare/ink_v5_erc20Contract.test.json +370 -0
- package/src/test/compare/ink_v5_erc20Metadata.test.json +370 -0
- package/src/test/compare/ink_v5_flipperContract.test.json +174 -0
- package/src/test/compare/ink_v5_flipperMetadata.test.json +174 -0
- package/src/test/compare/ink_v6_erc20Contract.test.json +418 -0
- package/src/test/compare/ink_v6_erc20Metadata.test.json +418 -0
- package/src/test/compare/solang_v0_ints256.test.json +9 -0
- package/src/test/compare/user_v0_assetTransfer.test.json +54 -0
- package/src/test/compare/user_v0_enumExample.test.json +303 -0
- package/src/test/compare/user_v0_recursive.test.json +27 -0
- package/src/test/compare/user_v0_withString.test.json +260 -0
- package/src/test/compare/user_v3_ask.test.json +71 -0
- package/src/test/compare/user_v4_events.test.json +1328 -0
- package/src/test/contracts/index.ts +20 -0
- package/src/test/contracts/ink/index.ts +13 -0
- package/src/test/contracts/ink/v0/accumulator.wasm +0 -0
- package/src/test/contracts/ink/v0/adder.wasm +0 -0
- package/src/test/contracts/ink/v0/delegator.json +252 -0
- package/src/test/contracts/ink/v0/delegator.wasm +0 -0
- package/src/test/contracts/ink/v0/dns.json +713 -0
- package/src/test/contracts/ink/v0/dns.wasm +0 -0
- package/src/test/contracts/ink/v0/erc20.json +704 -0
- package/src/test/contracts/ink/v0/erc20.wasm +0 -0
- package/src/test/contracts/ink/v0/erc721.json +1197 -0
- package/src/test/contracts/ink/v0/erc721.wasm +0 -0
- package/src/test/contracts/ink/v0/flipper.contract.json +107 -0
- package/src/test/contracts/ink/v0/flipper.json +106 -0
- package/src/test/contracts/ink/v0/flipper.wasm +0 -0
- package/src/test/contracts/ink/v0/incrementer.json +108 -0
- package/src/test/contracts/ink/v0/incrementer.wasm +0 -0
- package/src/test/contracts/ink/v0/index.ts +11 -0
- package/src/test/contracts/ink/v0/multisig_plain.json +1466 -0
- package/src/test/contracts/ink/v0/multisig_plain.wasm +0 -0
- package/src/test/contracts/ink/v0/subber.wasm +0 -0
- package/src/test/contracts/ink/v0/trait-flipper.json +103 -0
- package/src/test/contracts/ink/v0/trait-flipper.wasm +0 -0
- package/src/test/contracts/ink/v1/flipper.contract.json +111 -0
- package/src/test/contracts/ink/v1/index.ts +6 -0
- package/src/test/contracts/ink/v1/psp22_minter_pauser.contract.json +1722 -0
- package/src/test/contracts/ink/v2/erc20.contract.json +630 -0
- package/src/test/contracts/ink/v2/flipper.contract.json +103 -0
- package/src/test/contracts/ink/v2/index.ts +5 -0
- package/src/test/contracts/ink/v3/flipper.contract.json +105 -0
- package/src/test/contracts/ink/v3/index.ts +6 -0
- package/src/test/contracts/ink/v3/trait_erc20.contract.json +631 -0
- package/src/test/contracts/ink/v4/erc20.contract.json +1 -0
- package/src/test/contracts/ink/v4/erc20.json +821 -0
- package/src/test/contracts/ink/v4/erc20.wasm +0 -0
- package/src/test/contracts/ink/v4/flipper.contract.json +1 -0
- package/src/test/contracts/ink/v4/flipper.json +396 -0
- package/src/test/contracts/ink/v4/flipper.wasm +0 -0
- package/src/test/contracts/ink/v4/index.ts +7 -0
- package/src/test/contracts/ink/v5/erc20.contract.json +1 -0
- package/src/test/contracts/ink/v5/erc20.json +1025 -0
- package/src/test/contracts/ink/v5/erc20.wasm +0 -0
- package/src/test/contracts/ink/v5/erc20_anonymous_transfer.json +1025 -0
- package/src/test/contracts/ink/v5/flipper.contract.json +1 -0
- package/src/test/contracts/ink/v5/flipper.json +420 -0
- package/src/test/contracts/ink/v5/flipper.wasm +0 -0
- package/src/test/contracts/ink/v5/index.ts +8 -0
- package/src/test/contracts/ink/v6/erc20.contract.json +1 -0
- package/src/test/contracts/ink/v6/erc20.json +1081 -0
- package/src/test/contracts/ink/v6/erc20.polkavm +0 -0
- package/src/test/contracts/ink/v6/index.ts +5 -0
- package/src/test/contracts/solang/index.ts +7 -0
- package/src/test/contracts/solang/v0/index.ts +4 -0
- package/src/test/contracts/solang/v0/ints256.json +113 -0
- package/src/test/contracts/solang/v0/ints256.sol +13 -0
- package/src/test/contracts/solang/v0/ints256.wasm +0 -0
- package/src/test/contracts/user/index.ts +9 -0
- package/src/test/contracts/user/v0/assetTransfer.json +299 -0
- package/src/test/contracts/user/v0/assetTransfer.wasm +0 -0
- package/src/test/contracts/user/v0/enumExample.json +528 -0
- package/src/test/contracts/user/v0/enumExample.wasm +0 -0
- package/src/test/contracts/user/v0/index.ts +7 -0
- package/src/test/contracts/user/v0/recursive.contract.json +1 -0
- package/src/test/contracts/user/v0/withString.json +777 -0
- package/src/test/contracts/user/v3/ask.json +550 -0
- package/src/test/contracts/user/v3/index.ts +4 -0
- package/src/test/contracts/user/v4/events.contract.json +2990 -0
- package/src/test/contracts/user/v4/index.ts +4 -0
- package/src/test/contracts/util.ts +14 -0
- package/src/types.ts +98 -0
- package/src/util.ts +20 -0
- package/tsconfig.build.json +22 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.spec.json +26 -0
- package/tsconfig.spec.tsbuildinfo +1 -0
|
@@ -0,0 +1,1238 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@pezkuwi/types'), require('@pezkuwi/util'), require('@pezkuwi/api'), require('@pezkuwi/util-crypto')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@pezkuwi/types', '@pezkuwi/util', '@pezkuwi/api', '@pezkuwi/util-crypto'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.pezkuwiApiContract = {}, global.pezkuwiTypes, global.pezkuwiUtil, global.pezkuwiApi, global.pezkuwiUtilCrypto));
|
|
5
|
+
})(this, (function (exports, types, util, api, utilCrypto) { 'use strict';
|
|
6
|
+
|
|
7
|
+
const global = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : window;
|
|
8
|
+
|
|
9
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
10
|
+
var TypeDefInfo;
|
|
11
|
+
(function (TypeDefInfo) {
|
|
12
|
+
TypeDefInfo[TypeDefInfo["BTreeMap"] = 0] = "BTreeMap";
|
|
13
|
+
TypeDefInfo[TypeDefInfo["BTreeSet"] = 1] = "BTreeSet";
|
|
14
|
+
TypeDefInfo[TypeDefInfo["Compact"] = 2] = "Compact";
|
|
15
|
+
TypeDefInfo[TypeDefInfo["DoNotConstruct"] = 3] = "DoNotConstruct";
|
|
16
|
+
TypeDefInfo[TypeDefInfo["Enum"] = 4] = "Enum";
|
|
17
|
+
TypeDefInfo[TypeDefInfo["HashMap"] = 5] = "HashMap";
|
|
18
|
+
TypeDefInfo[TypeDefInfo["Int"] = 6] = "Int";
|
|
19
|
+
TypeDefInfo[TypeDefInfo["Linkage"] = 7] = "Linkage";
|
|
20
|
+
TypeDefInfo[TypeDefInfo["Null"] = 8] = "Null";
|
|
21
|
+
TypeDefInfo[TypeDefInfo["Option"] = 9] = "Option";
|
|
22
|
+
TypeDefInfo[TypeDefInfo["Plain"] = 10] = "Plain";
|
|
23
|
+
TypeDefInfo[TypeDefInfo["Range"] = 11] = "Range";
|
|
24
|
+
TypeDefInfo[TypeDefInfo["RangeInclusive"] = 12] = "RangeInclusive";
|
|
25
|
+
TypeDefInfo[TypeDefInfo["Result"] = 13] = "Result";
|
|
26
|
+
TypeDefInfo[TypeDefInfo["Set"] = 14] = "Set";
|
|
27
|
+
TypeDefInfo[TypeDefInfo["Si"] = 15] = "Si";
|
|
28
|
+
TypeDefInfo[TypeDefInfo["Struct"] = 16] = "Struct";
|
|
29
|
+
TypeDefInfo[TypeDefInfo["Tuple"] = 17] = "Tuple";
|
|
30
|
+
TypeDefInfo[TypeDefInfo["UInt"] = 18] = "UInt";
|
|
31
|
+
TypeDefInfo[TypeDefInfo["Vec"] = 19] = "Vec";
|
|
32
|
+
TypeDefInfo[TypeDefInfo["VecFixed"] = 20] = "VecFixed";
|
|
33
|
+
TypeDefInfo[TypeDefInfo["WrapperKeepOpaque"] = 21] = "WrapperKeepOpaque";
|
|
34
|
+
TypeDefInfo[TypeDefInfo["WrapperOpaque"] = 22] = "WrapperOpaque";
|
|
35
|
+
})(TypeDefInfo || (TypeDefInfo = {}));
|
|
36
|
+
|
|
37
|
+
function v0ToV1Names(all) {
|
|
38
|
+
return all.map((e) => util.objectSpread({}, e, {
|
|
39
|
+
name: Array.isArray(e.name)
|
|
40
|
+
? e.name
|
|
41
|
+
: [e.name]
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
function v0ToV1(registry, v0) {
|
|
45
|
+
if (!v0.metadataVersion.length) {
|
|
46
|
+
throw new Error('Invalid format for V0 (detected) contract metadata');
|
|
47
|
+
}
|
|
48
|
+
return registry.createType('ContractMetadataV1', util.objectSpread({}, v0, {
|
|
49
|
+
spec: util.objectSpread({}, v0.spec, {
|
|
50
|
+
constructors: v0ToV1Names(v0.spec.constructors),
|
|
51
|
+
messages: v0ToV1Names(v0.spec.messages)
|
|
52
|
+
}),
|
|
53
|
+
types: types.convertSiV0toV1(registry, v0.types)
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const ARG_TYPES = {
|
|
58
|
+
ContractConstructorSpec: 'ContractMessageParamSpecV2',
|
|
59
|
+
ContractEventSpec: 'ContractEventParamSpecV2',
|
|
60
|
+
ContractMessageSpec: 'ContractMessageParamSpecV2'
|
|
61
|
+
};
|
|
62
|
+
function v1ToV2Label(entry) {
|
|
63
|
+
return util.objectSpread({}, entry, {
|
|
64
|
+
label: Array.isArray(entry.name)
|
|
65
|
+
? entry.name.join('::')
|
|
66
|
+
: entry.name
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function v1ToV2Labels(registry, outType, all) {
|
|
70
|
+
return all.map((e) => registry.createType(`${outType}V2`, util.objectSpread(v1ToV2Label(e), {
|
|
71
|
+
args: e.args.map((a) => registry.createType(ARG_TYPES[outType], v1ToV2Label(a)))
|
|
72
|
+
})));
|
|
73
|
+
}
|
|
74
|
+
function v1ToV2(registry, v1) {
|
|
75
|
+
return registry.createType('ContractMetadataV2', util.objectSpread({}, v1, {
|
|
76
|
+
spec: util.objectSpread({}, v1.spec, {
|
|
77
|
+
constructors: v1ToV2Labels(registry, 'ContractConstructorSpec', v1.spec.constructors),
|
|
78
|
+
events: v1ToV2Labels(registry, 'ContractEventSpec', v1.spec.events),
|
|
79
|
+
messages: v1ToV2Labels(registry, 'ContractMessageSpec', v1.spec.messages)
|
|
80
|
+
})
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function v2ToV3(registry, v2) {
|
|
85
|
+
return registry.createType('ContractMetadataV3', util.objectSpread({}, v2, {
|
|
86
|
+
spec: util.objectSpread({}, v2.spec, {
|
|
87
|
+
constructors: v2.spec.constructors.map((c) =>
|
|
88
|
+
registry.createType('ContractConstructorSpecV3', util.objectSpread({}, c, { payable: true })))
|
|
89
|
+
})
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function v3ToV4(registry, v3) {
|
|
94
|
+
return registry.createType('ContractMetadataV4', util.objectSpread({}, v3, {
|
|
95
|
+
spec: util.objectSpread({}, v3.spec, {
|
|
96
|
+
constructors: v3.spec.constructors.map((c) => registry.createType('ContractConstructorSpecV4', util.objectSpread({}, c))),
|
|
97
|
+
messages: v3.spec.messages.map((m) => registry.createType('ContractMessageSpecV3', util.objectSpread({}, m)))
|
|
98
|
+
}),
|
|
99
|
+
version: registry.createType('Text', '4')
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const enumVersions = ['V6', 'V5', 'V4', 'V3', 'V2', 'V1'];
|
|
104
|
+
function createConverter(next, step) {
|
|
105
|
+
return (registry, input) => next(registry, step(registry, input));
|
|
106
|
+
}
|
|
107
|
+
function v6ToLatestCompatible(_registry, v6) {
|
|
108
|
+
return v6;
|
|
109
|
+
}
|
|
110
|
+
function v5ToLatestCompatible(_registry, v5) {
|
|
111
|
+
return v5;
|
|
112
|
+
}
|
|
113
|
+
function v4ToLatestCompatible(_registry, v4) {
|
|
114
|
+
return v4;
|
|
115
|
+
}
|
|
116
|
+
const v3ToLatestCompatible = createConverter(v4ToLatestCompatible, v3ToV4);
|
|
117
|
+
const v2ToLatestCompatible = createConverter(v3ToLatestCompatible, v2ToV3);
|
|
118
|
+
const v1ToLatestCompatible = createConverter(v2ToLatestCompatible, v1ToV2);
|
|
119
|
+
const v0ToLatestCompatible = createConverter(v1ToLatestCompatible, v0ToV1);
|
|
120
|
+
const convertVersions = [
|
|
121
|
+
['V6', v6ToLatestCompatible],
|
|
122
|
+
['V5', v5ToLatestCompatible],
|
|
123
|
+
['V4', v4ToLatestCompatible],
|
|
124
|
+
['V3', v3ToLatestCompatible],
|
|
125
|
+
['V2', v2ToLatestCompatible],
|
|
126
|
+
['V1', v1ToLatestCompatible],
|
|
127
|
+
['V0', v0ToLatestCompatible]
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
const l$1 = util.logger('Abi');
|
|
131
|
+
const PRIMITIVE_ALWAYS = ['AccountId', 'AccountId20', 'AccountIndex', 'Address', 'Balance'];
|
|
132
|
+
function findMessage(list, messageOrId) {
|
|
133
|
+
const message = util.isNumber(messageOrId)
|
|
134
|
+
? list[messageOrId]
|
|
135
|
+
: util.isString(messageOrId)
|
|
136
|
+
? list.find(({ identifier }) => [identifier, util.stringCamelCase(identifier)].includes(messageOrId.toString()))
|
|
137
|
+
: messageOrId;
|
|
138
|
+
return util.assertReturn(message, () => `Attempted to call an invalid contract interface, ${util.stringify(messageOrId)}`);
|
|
139
|
+
}
|
|
140
|
+
function getMetadata(registry, json) {
|
|
141
|
+
const vx = enumVersions.find((v) => util.isObject(json[v]));
|
|
142
|
+
const jsonVersion = json.version;
|
|
143
|
+
if (!vx && jsonVersion && !enumVersions.find((v) => v === `V${jsonVersion}`)) {
|
|
144
|
+
throw new Error(`Unable to handle version ${jsonVersion}`);
|
|
145
|
+
}
|
|
146
|
+
const metadata = registry.createType('ContractMetadata', vx
|
|
147
|
+
? { [vx]: json[vx] }
|
|
148
|
+
: jsonVersion
|
|
149
|
+
? { [`V${jsonVersion}`]: json }
|
|
150
|
+
: { V0: json });
|
|
151
|
+
const converter = convertVersions.find(([v]) => metadata[`is${v}`]);
|
|
152
|
+
if (!converter) {
|
|
153
|
+
throw new Error(`Unable to convert ABI with version ${metadata.type} to a supported version`);
|
|
154
|
+
}
|
|
155
|
+
const upgradedMetadata = converter[1](registry, metadata[`as${converter[0]}`]);
|
|
156
|
+
return upgradedMetadata;
|
|
157
|
+
}
|
|
158
|
+
function isRevive(json) {
|
|
159
|
+
const source = json['source'];
|
|
160
|
+
const version = json['version'];
|
|
161
|
+
const hasContractBinary = typeof source === 'object' &&
|
|
162
|
+
source !== null &&
|
|
163
|
+
'contract_binary' in source;
|
|
164
|
+
const hasVersion = typeof version === 'number' && version >= 6;
|
|
165
|
+
return hasContractBinary || hasVersion;
|
|
166
|
+
}
|
|
167
|
+
function parseJson(json, chainProperties) {
|
|
168
|
+
const registry = new types.TypeRegistry();
|
|
169
|
+
const revive = isRevive(json);
|
|
170
|
+
const typeName = revive ? 'ContractReviveProjectInfo' : 'ContractProjectInfo';
|
|
171
|
+
const info = registry.createType(typeName, json);
|
|
172
|
+
const metadata = getMetadata(registry, json);
|
|
173
|
+
const lookup = registry.createType('PortableRegistry', { types: metadata.types }, true);
|
|
174
|
+
registry.setLookup(lookup);
|
|
175
|
+
if (chainProperties) {
|
|
176
|
+
registry.setChainProperties(chainProperties);
|
|
177
|
+
}
|
|
178
|
+
lookup.types.forEach(({ id }) => lookup.getTypeDef(id));
|
|
179
|
+
return [json, registry, metadata, info, revive];
|
|
180
|
+
}
|
|
181
|
+
function isTypeSpec(value) {
|
|
182
|
+
return !!value && value instanceof Map && !util.isUndefined(value.type) && !util.isUndefined(value.displayName);
|
|
183
|
+
}
|
|
184
|
+
function isOption(value) {
|
|
185
|
+
return !!value && value instanceof types.Option;
|
|
186
|
+
}
|
|
187
|
+
class Abi {
|
|
188
|
+
events;
|
|
189
|
+
constructors;
|
|
190
|
+
info;
|
|
191
|
+
json;
|
|
192
|
+
messages;
|
|
193
|
+
metadata;
|
|
194
|
+
registry;
|
|
195
|
+
environment = new Map();
|
|
196
|
+
isRevive;
|
|
197
|
+
constructor(abiJson, chainProperties) {
|
|
198
|
+
[this.json, this.registry, this.metadata, this.info, this.isRevive] = parseJson(util.isString(abiJson)
|
|
199
|
+
? JSON.parse(abiJson)
|
|
200
|
+
: abiJson, chainProperties);
|
|
201
|
+
this.constructors = this.metadata.spec.constructors.map((spec, index) => this.#createMessage(spec, index, {
|
|
202
|
+
isConstructor: true,
|
|
203
|
+
isDefault: spec.default.isTrue,
|
|
204
|
+
isPayable: spec.payable.isTrue,
|
|
205
|
+
returnType: spec.returnType.isSome
|
|
206
|
+
? this.registry.lookup.getTypeDef(spec.returnType.unwrap().type)
|
|
207
|
+
: null
|
|
208
|
+
}));
|
|
209
|
+
this.events = this.metadata.spec.events.map((_, index) => this.#createEvent(index));
|
|
210
|
+
this.messages = this.metadata.spec.messages.map((spec, index) => this.#createMessage(spec, index, {
|
|
211
|
+
isDefault: spec.default.isTrue,
|
|
212
|
+
isMutating: spec.mutates.isTrue,
|
|
213
|
+
isPayable: spec.payable.isTrue,
|
|
214
|
+
returnType: spec.returnType.isSome
|
|
215
|
+
? this.registry.lookup.getTypeDef(spec.returnType.unwrap().type)
|
|
216
|
+
: null
|
|
217
|
+
}));
|
|
218
|
+
for (const [key, opt] of this.metadata.spec.environment.entries()) {
|
|
219
|
+
if (isOption(opt)) {
|
|
220
|
+
if (opt.isSome) {
|
|
221
|
+
const value = opt.unwrap();
|
|
222
|
+
if (util.isBn(value)) {
|
|
223
|
+
this.environment.set(key, value);
|
|
224
|
+
}
|
|
225
|
+
else if (isTypeSpec(value)) {
|
|
226
|
+
this.environment.set(key, this.registry.lookup.getTypeDef(value.type));
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
throw new Error(`Invalid environment definition for ${key}:: Expected either Number or ContractTypeSpec`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
throw new Error(`Expected Option<*> definition for ${key} in ContractEnvironment`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
decodeEvent(record) {
|
|
239
|
+
switch (this.metadata.version.toString()) {
|
|
240
|
+
case '4':
|
|
241
|
+
return this.#decodeEventV4(record);
|
|
242
|
+
case '5':
|
|
243
|
+
return this.#decodeEventV5(record);
|
|
244
|
+
default:
|
|
245
|
+
return this.#decodeEventV6(record);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
#decodeEventV6 = (record) => {
|
|
249
|
+
const topics = record.event.data[2];
|
|
250
|
+
const signatureTopic = topics[0];
|
|
251
|
+
const data = record.event.data[1];
|
|
252
|
+
if (signatureTopic) {
|
|
253
|
+
const event = this.events.find((e) => e.signatureTopic !== undefined && e.signatureTopic !== null && e.signatureTopic === signatureTopic.toHex());
|
|
254
|
+
if (event) {
|
|
255
|
+
return event.fromU8a(data);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
const amountOfTopics = topics.length;
|
|
259
|
+
const potentialEvents = this.events.filter((e) => {
|
|
260
|
+
if (e.signatureTopic !== null && e.signatureTopic !== undefined) {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
const amountIndexed = e.args.filter((a) => a.indexed).length;
|
|
264
|
+
if (amountIndexed !== amountOfTopics) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
return true;
|
|
268
|
+
});
|
|
269
|
+
if (potentialEvents.length === 1) {
|
|
270
|
+
return potentialEvents[0].fromU8a(data);
|
|
271
|
+
}
|
|
272
|
+
throw new Error('Unable to determine event');
|
|
273
|
+
};
|
|
274
|
+
#decodeEventV5 = (record) => {
|
|
275
|
+
const signatureTopic = record.topics[0];
|
|
276
|
+
const data = record.event.data[1];
|
|
277
|
+
if (signatureTopic) {
|
|
278
|
+
const event = this.events.find((e) => e.signatureTopic !== undefined && e.signatureTopic !== null && e.signatureTopic === signatureTopic.toHex());
|
|
279
|
+
if (event) {
|
|
280
|
+
return event.fromU8a(data);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
const amountOfTopics = record.topics.length;
|
|
284
|
+
const potentialEvents = this.events.filter((e) => {
|
|
285
|
+
if (e.signatureTopic !== null && e.signatureTopic !== undefined) {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
const amountIndexed = e.args.filter((a) => a.indexed).length;
|
|
289
|
+
if (amountIndexed !== amountOfTopics) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
return true;
|
|
293
|
+
});
|
|
294
|
+
if (potentialEvents.length === 1) {
|
|
295
|
+
return potentialEvents[0].fromU8a(data);
|
|
296
|
+
}
|
|
297
|
+
throw new Error('Unable to determine event');
|
|
298
|
+
};
|
|
299
|
+
#decodeEventV4 = (record) => {
|
|
300
|
+
const data = record.event.data[1];
|
|
301
|
+
const index = data[0];
|
|
302
|
+
const event = this.events[index];
|
|
303
|
+
if (!event) {
|
|
304
|
+
throw new Error(`Unable to find event with index ${index}`);
|
|
305
|
+
}
|
|
306
|
+
return event.fromU8a(data.subarray(1));
|
|
307
|
+
};
|
|
308
|
+
decodeConstructor(data) {
|
|
309
|
+
return this.#decodeMessage('message', this.constructors, data);
|
|
310
|
+
}
|
|
311
|
+
decodeMessage(data) {
|
|
312
|
+
return this.#decodeMessage('message', this.messages, data);
|
|
313
|
+
}
|
|
314
|
+
findConstructor(constructorOrId) {
|
|
315
|
+
return findMessage(this.constructors, constructorOrId);
|
|
316
|
+
}
|
|
317
|
+
findMessage(messageOrId) {
|
|
318
|
+
return findMessage(this.messages, messageOrId);
|
|
319
|
+
}
|
|
320
|
+
#createArgs = (args, spec) => {
|
|
321
|
+
return args.map(({ label, type }, index) => {
|
|
322
|
+
try {
|
|
323
|
+
if (!util.isObject(type)) {
|
|
324
|
+
throw new Error('Invalid type definition found');
|
|
325
|
+
}
|
|
326
|
+
const displayName = type.displayName.length
|
|
327
|
+
? type.displayName[type.displayName.length - 1].toString()
|
|
328
|
+
: undefined;
|
|
329
|
+
const camelName = util.stringCamelCase(label);
|
|
330
|
+
if (displayName && PRIMITIVE_ALWAYS.includes(displayName)) {
|
|
331
|
+
return {
|
|
332
|
+
name: camelName,
|
|
333
|
+
type: {
|
|
334
|
+
info: TypeDefInfo.Plain,
|
|
335
|
+
type: displayName
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
const typeDef = this.registry.lookup.getTypeDef(type.type);
|
|
340
|
+
return {
|
|
341
|
+
name: camelName,
|
|
342
|
+
type: displayName && !typeDef.type.startsWith(displayName)
|
|
343
|
+
? { displayName, ...typeDef }
|
|
344
|
+
: typeDef
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
catch (error) {
|
|
348
|
+
l$1.error(`Error expanding argument ${index} in ${util.stringify(spec)}`);
|
|
349
|
+
throw error;
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
};
|
|
353
|
+
#createMessageParams = (args, spec) => {
|
|
354
|
+
return this.#createArgs(args, spec);
|
|
355
|
+
};
|
|
356
|
+
#createEventParams = (args, spec) => {
|
|
357
|
+
const params = this.#createArgs(args, spec);
|
|
358
|
+
return params.map((p, index) => ({ ...p, indexed: args[index].indexed.toPrimitive() }));
|
|
359
|
+
};
|
|
360
|
+
#createEvent = (index) => {
|
|
361
|
+
switch (this.metadata.version.toString()) {
|
|
362
|
+
case '4':
|
|
363
|
+
return this.#createEventV4(this.metadata.spec.events[index], index);
|
|
364
|
+
default:
|
|
365
|
+
return this.#createEventV5(this.metadata.spec.events[index], index);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
#createEventV5 = (spec, index) => {
|
|
369
|
+
const args = this.#createEventParams(spec.args, spec);
|
|
370
|
+
const event = {
|
|
371
|
+
args,
|
|
372
|
+
docs: spec.docs.map((d) => d.toString()),
|
|
373
|
+
fromU8a: (data) => ({
|
|
374
|
+
args: this.#decodeArgs(args, data),
|
|
375
|
+
event
|
|
376
|
+
}),
|
|
377
|
+
identifier: [spec.module_path, spec.label].join('::'),
|
|
378
|
+
index,
|
|
379
|
+
signatureTopic: spec.signature_topic.isSome ? spec.signature_topic.unwrap().toHex() : null
|
|
380
|
+
};
|
|
381
|
+
return event;
|
|
382
|
+
};
|
|
383
|
+
#createEventV4 = (spec, index) => {
|
|
384
|
+
const args = this.#createEventParams(spec.args, spec);
|
|
385
|
+
const event = {
|
|
386
|
+
args,
|
|
387
|
+
docs: spec.docs.map((d) => d.toString()),
|
|
388
|
+
fromU8a: (data) => ({
|
|
389
|
+
args: this.#decodeArgs(args, data),
|
|
390
|
+
event
|
|
391
|
+
}),
|
|
392
|
+
identifier: spec.label.toString(),
|
|
393
|
+
index
|
|
394
|
+
};
|
|
395
|
+
return event;
|
|
396
|
+
};
|
|
397
|
+
#createMessage = (spec, index, add = {}) => {
|
|
398
|
+
const args = this.#createMessageParams(spec.args, spec);
|
|
399
|
+
const identifier = spec.label.toString();
|
|
400
|
+
const message = {
|
|
401
|
+
...add,
|
|
402
|
+
args,
|
|
403
|
+
docs: spec.docs.map((d) => d.toString()),
|
|
404
|
+
fromU8a: (data) => ({
|
|
405
|
+
args: this.#decodeArgs(args, data),
|
|
406
|
+
message
|
|
407
|
+
}),
|
|
408
|
+
identifier,
|
|
409
|
+
index,
|
|
410
|
+
isDefault: spec.default.isTrue,
|
|
411
|
+
method: util.stringCamelCase(identifier),
|
|
412
|
+
path: identifier.split('::').map((s) => util.stringCamelCase(s)),
|
|
413
|
+
selector: spec.selector,
|
|
414
|
+
toU8a: (params) => this.#encodeMessageArgs(spec, args, params)
|
|
415
|
+
};
|
|
416
|
+
return message;
|
|
417
|
+
};
|
|
418
|
+
#decodeArgs = (args, data) => {
|
|
419
|
+
let offset = 0;
|
|
420
|
+
return args.map(({ type: { lookupName, type } }) => {
|
|
421
|
+
const value = this.registry.createType(lookupName || type, data.subarray(offset));
|
|
422
|
+
offset += value.encodedLength;
|
|
423
|
+
return value;
|
|
424
|
+
});
|
|
425
|
+
};
|
|
426
|
+
#decodeMessage = (type, list, data) => {
|
|
427
|
+
const [, trimmed] = util.compactStripLength(data);
|
|
428
|
+
const selector = trimmed.subarray(0, 4);
|
|
429
|
+
const message = list.find((m) => m.selector.eq(selector));
|
|
430
|
+
if (!message) {
|
|
431
|
+
throw new Error(`Unable to find ${type} with selector ${util.u8aToHex(selector)}`);
|
|
432
|
+
}
|
|
433
|
+
return message.fromU8a(trimmed.subarray(4));
|
|
434
|
+
};
|
|
435
|
+
#encodeMessageArgs = ({ label, selector }, args, data) => {
|
|
436
|
+
if (data.length !== args.length) {
|
|
437
|
+
throw new Error(`Expected ${args.length} arguments to contract message '${label.toString()}', found ${data.length}`);
|
|
438
|
+
}
|
|
439
|
+
return util.compactAddLength(util.u8aConcat(this.registry.createType('ContractSelector', selector).toU8a(), ...args.map(({ type: { lookupName, type } }, index) => this.registry.createType(lookupName || type, data[index]).toU8a())));
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
const packageInfo = { name: '@pezkuwi/api-contract', path: (({ url: (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bundle-pezkuwi-api-contract.js', document.baseURI).href)) }) && (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bundle-pezkuwi-api-contract.js', document.baseURI).href))) ? new URL((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bundle-pezkuwi-api-contract.js', document.baseURI).href))).pathname.substring(0, new URL((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bundle-pezkuwi-api-contract.js', document.baseURI).href))).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '16.5.8' };
|
|
444
|
+
|
|
445
|
+
function applyOnEvent(result, types, fn, isRevive) {
|
|
446
|
+
if (result.isInBlock || result.isFinalized) {
|
|
447
|
+
const section = isRevive ? 'revive' : 'contracts';
|
|
448
|
+
const records = result.filterRecords(section, types);
|
|
449
|
+
if (records.length) {
|
|
450
|
+
return fn(records);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
return undefined;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
class Base {
|
|
457
|
+
abi;
|
|
458
|
+
api;
|
|
459
|
+
_decorateMethod;
|
|
460
|
+
_isWeightV1;
|
|
461
|
+
_isRevive;
|
|
462
|
+
constructor(api, abi, decorateMethod) {
|
|
463
|
+
if (!api || !api.isConnected || !api.tx) {
|
|
464
|
+
throw new Error('Your API has not been initialized correctly and is not connected to a chain');
|
|
465
|
+
}
|
|
466
|
+
this.abi = abi instanceof Abi
|
|
467
|
+
? abi
|
|
468
|
+
: new Abi(abi, api.registry.getChainProperties());
|
|
469
|
+
this.api = api;
|
|
470
|
+
this._decorateMethod = decorateMethod;
|
|
471
|
+
this._isWeightV1 = !api.registry.createType('Weight').proofSize;
|
|
472
|
+
this._isRevive = this.abi.isRevive;
|
|
473
|
+
if (this._isRevive) {
|
|
474
|
+
if (!api.tx.revive || !util.isFunction(api.tx.revive.instantiateWithCode) || api.tx.revive.instantiateWithCode.meta.args.length !== 6) {
|
|
475
|
+
throw new Error('The runtime does not expose api.tx.revive.instantiateWithCode with storageDepositLimit');
|
|
476
|
+
}
|
|
477
|
+
else if (!api.call.reviveApi || !util.isFunction(api.call.reviveApi.call)) {
|
|
478
|
+
throw new Error('Your runtime does not expose the api.call.reviveApi.call runtime interfaces');
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
if (!api.tx.contracts || !util.isFunction(api.tx.contracts.instantiateWithCode) || api.tx.contracts.instantiateWithCode.meta.args.length !== 6) {
|
|
483
|
+
throw new Error('The runtime does not expose api.tx.contracts.instantiateWithCode with storageDepositLimit');
|
|
484
|
+
}
|
|
485
|
+
else if (!api.call.contractsApi || !util.isFunction(api.call.contractsApi.call)) {
|
|
486
|
+
throw new Error('Your runtime does not expose the api.call.contractsApi.call runtime interfaces');
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
get registry() {
|
|
491
|
+
return this.api.registry;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
var extendStatics = function(d, b) {
|
|
496
|
+
extendStatics = Object.setPrototypeOf ||
|
|
497
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
498
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
499
|
+
return extendStatics(d, b);
|
|
500
|
+
};
|
|
501
|
+
function __extends(d, b) {
|
|
502
|
+
if (typeof b !== "function" && b !== null)
|
|
503
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
504
|
+
extendStatics(d, b);
|
|
505
|
+
function __() { this.constructor = d; }
|
|
506
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
507
|
+
}
|
|
508
|
+
function __values(o) {
|
|
509
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
510
|
+
if (m) return m.call(o);
|
|
511
|
+
if (o && typeof o.length === "number") return {
|
|
512
|
+
next: function () {
|
|
513
|
+
if (o && i >= o.length) o = void 0;
|
|
514
|
+
return { value: o && o[i++], done: !o };
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
518
|
+
}
|
|
519
|
+
function __read(o, n) {
|
|
520
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
521
|
+
if (!m) return o;
|
|
522
|
+
var i = m.call(o), r, ar = [], e;
|
|
523
|
+
try {
|
|
524
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
525
|
+
}
|
|
526
|
+
catch (error) { e = { error: error }; }
|
|
527
|
+
finally {
|
|
528
|
+
try {
|
|
529
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
530
|
+
}
|
|
531
|
+
finally { if (e) throw e.error; }
|
|
532
|
+
}
|
|
533
|
+
return ar;
|
|
534
|
+
}
|
|
535
|
+
function __spreadArray(to, from, pack) {
|
|
536
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
537
|
+
if (ar || !(i in from)) {
|
|
538
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
539
|
+
ar[i] = from[i];
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
543
|
+
}
|
|
544
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
545
|
+
var e = new Error(message);
|
|
546
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
function isFunction(value) {
|
|
550
|
+
return typeof value === 'function';
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
function createErrorClass(createImpl) {
|
|
554
|
+
var _super = function (instance) {
|
|
555
|
+
Error.call(instance);
|
|
556
|
+
instance.stack = new Error().stack;
|
|
557
|
+
};
|
|
558
|
+
var ctorFunc = createImpl(_super);
|
|
559
|
+
ctorFunc.prototype = Object.create(Error.prototype);
|
|
560
|
+
ctorFunc.prototype.constructor = ctorFunc;
|
|
561
|
+
return ctorFunc;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
var UnsubscriptionError = createErrorClass(function (_super) {
|
|
565
|
+
return function UnsubscriptionErrorImpl(errors) {
|
|
566
|
+
_super(this);
|
|
567
|
+
this.message = errors
|
|
568
|
+
? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ')
|
|
569
|
+
: '';
|
|
570
|
+
this.name = 'UnsubscriptionError';
|
|
571
|
+
this.errors = errors;
|
|
572
|
+
};
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
function arrRemove(arr, item) {
|
|
576
|
+
if (arr) {
|
|
577
|
+
var index = arr.indexOf(item);
|
|
578
|
+
0 <= index && arr.splice(index, 1);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
var Subscription = (function () {
|
|
583
|
+
function Subscription(initialTeardown) {
|
|
584
|
+
this.initialTeardown = initialTeardown;
|
|
585
|
+
this.closed = false;
|
|
586
|
+
this._parentage = null;
|
|
587
|
+
this._finalizers = null;
|
|
588
|
+
}
|
|
589
|
+
Subscription.prototype.unsubscribe = function () {
|
|
590
|
+
var e_1, _a, e_2, _b;
|
|
591
|
+
var errors;
|
|
592
|
+
if (!this.closed) {
|
|
593
|
+
this.closed = true;
|
|
594
|
+
var _parentage = this._parentage;
|
|
595
|
+
if (_parentage) {
|
|
596
|
+
this._parentage = null;
|
|
597
|
+
if (Array.isArray(_parentage)) {
|
|
598
|
+
try {
|
|
599
|
+
for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
|
|
600
|
+
var parent_1 = _parentage_1_1.value;
|
|
601
|
+
parent_1.remove(this);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
605
|
+
finally {
|
|
606
|
+
try {
|
|
607
|
+
if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);
|
|
608
|
+
}
|
|
609
|
+
finally { if (e_1) throw e_1.error; }
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
_parentage.remove(this);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
var initialFinalizer = this.initialTeardown;
|
|
617
|
+
if (isFunction(initialFinalizer)) {
|
|
618
|
+
try {
|
|
619
|
+
initialFinalizer();
|
|
620
|
+
}
|
|
621
|
+
catch (e) {
|
|
622
|
+
errors = e instanceof UnsubscriptionError ? e.errors : [e];
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
var _finalizers = this._finalizers;
|
|
626
|
+
if (_finalizers) {
|
|
627
|
+
this._finalizers = null;
|
|
628
|
+
try {
|
|
629
|
+
for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
|
|
630
|
+
var finalizer = _finalizers_1_1.value;
|
|
631
|
+
try {
|
|
632
|
+
execFinalizer(finalizer);
|
|
633
|
+
}
|
|
634
|
+
catch (err) {
|
|
635
|
+
errors = errors !== null && errors !== void 0 ? errors : [];
|
|
636
|
+
if (err instanceof UnsubscriptionError) {
|
|
637
|
+
errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
errors.push(err);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
646
|
+
finally {
|
|
647
|
+
try {
|
|
648
|
+
if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
|
|
649
|
+
}
|
|
650
|
+
finally { if (e_2) throw e_2.error; }
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
if (errors) {
|
|
654
|
+
throw new UnsubscriptionError(errors);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
Subscription.prototype.add = function (teardown) {
|
|
659
|
+
var _a;
|
|
660
|
+
if (teardown && teardown !== this) {
|
|
661
|
+
if (this.closed) {
|
|
662
|
+
execFinalizer(teardown);
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
if (teardown instanceof Subscription) {
|
|
666
|
+
if (teardown.closed || teardown._hasParent(this)) {
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
teardown._addParent(this);
|
|
670
|
+
}
|
|
671
|
+
(this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
Subscription.prototype._hasParent = function (parent) {
|
|
676
|
+
var _parentage = this._parentage;
|
|
677
|
+
return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
|
|
678
|
+
};
|
|
679
|
+
Subscription.prototype._addParent = function (parent) {
|
|
680
|
+
var _parentage = this._parentage;
|
|
681
|
+
this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
|
|
682
|
+
};
|
|
683
|
+
Subscription.prototype._removeParent = function (parent) {
|
|
684
|
+
var _parentage = this._parentage;
|
|
685
|
+
if (_parentage === parent) {
|
|
686
|
+
this._parentage = null;
|
|
687
|
+
}
|
|
688
|
+
else if (Array.isArray(_parentage)) {
|
|
689
|
+
arrRemove(_parentage, parent);
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
Subscription.prototype.remove = function (teardown) {
|
|
693
|
+
var _finalizers = this._finalizers;
|
|
694
|
+
_finalizers && arrRemove(_finalizers, teardown);
|
|
695
|
+
if (teardown instanceof Subscription) {
|
|
696
|
+
teardown._removeParent(this);
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
Subscription.EMPTY = (function () {
|
|
700
|
+
var empty = new Subscription();
|
|
701
|
+
empty.closed = true;
|
|
702
|
+
return empty;
|
|
703
|
+
})();
|
|
704
|
+
return Subscription;
|
|
705
|
+
}());
|
|
706
|
+
Subscription.EMPTY;
|
|
707
|
+
function isSubscription(value) {
|
|
708
|
+
return (value instanceof Subscription ||
|
|
709
|
+
(value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
|
|
710
|
+
}
|
|
711
|
+
function execFinalizer(finalizer) {
|
|
712
|
+
if (isFunction(finalizer)) {
|
|
713
|
+
finalizer();
|
|
714
|
+
}
|
|
715
|
+
else {
|
|
716
|
+
finalizer.unsubscribe();
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
var timeoutProvider = {
|
|
721
|
+
setTimeout: function (handler, timeout) {
|
|
722
|
+
var args = [];
|
|
723
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
724
|
+
args[_i - 2] = arguments[_i];
|
|
725
|
+
}
|
|
726
|
+
return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
727
|
+
},
|
|
728
|
+
clearTimeout: function (handle) {
|
|
729
|
+
return (clearTimeout)(handle);
|
|
730
|
+
},
|
|
731
|
+
delegate: undefined,
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
function reportUnhandledError(err) {
|
|
735
|
+
timeoutProvider.setTimeout(function () {
|
|
736
|
+
{
|
|
737
|
+
throw err;
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
function noop() { }
|
|
743
|
+
|
|
744
|
+
var Subscriber = (function (_super) {
|
|
745
|
+
__extends(Subscriber, _super);
|
|
746
|
+
function Subscriber(destination) {
|
|
747
|
+
var _this = _super.call(this) || this;
|
|
748
|
+
_this.isStopped = false;
|
|
749
|
+
if (destination) {
|
|
750
|
+
_this.destination = destination;
|
|
751
|
+
if (isSubscription(destination)) {
|
|
752
|
+
destination.add(_this);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
else {
|
|
756
|
+
_this.destination = EMPTY_OBSERVER;
|
|
757
|
+
}
|
|
758
|
+
return _this;
|
|
759
|
+
}
|
|
760
|
+
Subscriber.create = function (next, error, complete) {
|
|
761
|
+
return new SafeSubscriber(next, error, complete);
|
|
762
|
+
};
|
|
763
|
+
Subscriber.prototype.next = function (value) {
|
|
764
|
+
if (this.isStopped) ;
|
|
765
|
+
else {
|
|
766
|
+
this._next(value);
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
Subscriber.prototype.error = function (err) {
|
|
770
|
+
if (this.isStopped) ;
|
|
771
|
+
else {
|
|
772
|
+
this.isStopped = true;
|
|
773
|
+
this._error(err);
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
Subscriber.prototype.complete = function () {
|
|
777
|
+
if (this.isStopped) ;
|
|
778
|
+
else {
|
|
779
|
+
this.isStopped = true;
|
|
780
|
+
this._complete();
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
Subscriber.prototype.unsubscribe = function () {
|
|
784
|
+
if (!this.closed) {
|
|
785
|
+
this.isStopped = true;
|
|
786
|
+
_super.prototype.unsubscribe.call(this);
|
|
787
|
+
this.destination = null;
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
Subscriber.prototype._next = function (value) {
|
|
791
|
+
this.destination.next(value);
|
|
792
|
+
};
|
|
793
|
+
Subscriber.prototype._error = function (err) {
|
|
794
|
+
try {
|
|
795
|
+
this.destination.error(err);
|
|
796
|
+
}
|
|
797
|
+
finally {
|
|
798
|
+
this.unsubscribe();
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
Subscriber.prototype._complete = function () {
|
|
802
|
+
try {
|
|
803
|
+
this.destination.complete();
|
|
804
|
+
}
|
|
805
|
+
finally {
|
|
806
|
+
this.unsubscribe();
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
return Subscriber;
|
|
810
|
+
}(Subscription));
|
|
811
|
+
var ConsumerObserver = (function () {
|
|
812
|
+
function ConsumerObserver(partialObserver) {
|
|
813
|
+
this.partialObserver = partialObserver;
|
|
814
|
+
}
|
|
815
|
+
ConsumerObserver.prototype.next = function (value) {
|
|
816
|
+
var partialObserver = this.partialObserver;
|
|
817
|
+
if (partialObserver.next) {
|
|
818
|
+
try {
|
|
819
|
+
partialObserver.next(value);
|
|
820
|
+
}
|
|
821
|
+
catch (error) {
|
|
822
|
+
handleUnhandledError(error);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
ConsumerObserver.prototype.error = function (err) {
|
|
827
|
+
var partialObserver = this.partialObserver;
|
|
828
|
+
if (partialObserver.error) {
|
|
829
|
+
try {
|
|
830
|
+
partialObserver.error(err);
|
|
831
|
+
}
|
|
832
|
+
catch (error) {
|
|
833
|
+
handleUnhandledError(error);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
else {
|
|
837
|
+
handleUnhandledError(err);
|
|
838
|
+
}
|
|
839
|
+
};
|
|
840
|
+
ConsumerObserver.prototype.complete = function () {
|
|
841
|
+
var partialObserver = this.partialObserver;
|
|
842
|
+
if (partialObserver.complete) {
|
|
843
|
+
try {
|
|
844
|
+
partialObserver.complete();
|
|
845
|
+
}
|
|
846
|
+
catch (error) {
|
|
847
|
+
handleUnhandledError(error);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
return ConsumerObserver;
|
|
852
|
+
}());
|
|
853
|
+
var SafeSubscriber = (function (_super) {
|
|
854
|
+
__extends(SafeSubscriber, _super);
|
|
855
|
+
function SafeSubscriber(observerOrNext, error, complete) {
|
|
856
|
+
var _this = _super.call(this) || this;
|
|
857
|
+
var partialObserver;
|
|
858
|
+
if (isFunction(observerOrNext) || !observerOrNext) {
|
|
859
|
+
partialObserver = {
|
|
860
|
+
next: (observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined),
|
|
861
|
+
error: error !== null && error !== void 0 ? error : undefined,
|
|
862
|
+
complete: complete !== null && complete !== void 0 ? complete : undefined,
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
else {
|
|
866
|
+
{
|
|
867
|
+
partialObserver = observerOrNext;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
_this.destination = new ConsumerObserver(partialObserver);
|
|
871
|
+
return _this;
|
|
872
|
+
}
|
|
873
|
+
return SafeSubscriber;
|
|
874
|
+
}(Subscriber));
|
|
875
|
+
function handleUnhandledError(error) {
|
|
876
|
+
{
|
|
877
|
+
reportUnhandledError(error);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
function defaultErrorHandler(err) {
|
|
881
|
+
throw err;
|
|
882
|
+
}
|
|
883
|
+
var EMPTY_OBSERVER = {
|
|
884
|
+
closed: true,
|
|
885
|
+
next: noop,
|
|
886
|
+
error: defaultErrorHandler,
|
|
887
|
+
complete: noop,
|
|
888
|
+
};
|
|
889
|
+
|
|
890
|
+
function hasLift(source) {
|
|
891
|
+
return isFunction(source === null || source === void 0 ? void 0 : source.lift);
|
|
892
|
+
}
|
|
893
|
+
function operate(init) {
|
|
894
|
+
return function (source) {
|
|
895
|
+
if (hasLift(source)) {
|
|
896
|
+
return source.lift(function (liftedSource) {
|
|
897
|
+
try {
|
|
898
|
+
return init(liftedSource, this);
|
|
899
|
+
}
|
|
900
|
+
catch (err) {
|
|
901
|
+
this.error(err);
|
|
902
|
+
}
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
throw new TypeError('Unable to lift unknown Observable type');
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
|
|
910
|
+
return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
|
|
911
|
+
}
|
|
912
|
+
var OperatorSubscriber = (function (_super) {
|
|
913
|
+
__extends(OperatorSubscriber, _super);
|
|
914
|
+
function OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
|
|
915
|
+
var _this = _super.call(this, destination) || this;
|
|
916
|
+
_this.onFinalize = onFinalize;
|
|
917
|
+
_this.shouldUnsubscribe = shouldUnsubscribe;
|
|
918
|
+
_this._next = onNext
|
|
919
|
+
? function (value) {
|
|
920
|
+
try {
|
|
921
|
+
onNext(value);
|
|
922
|
+
}
|
|
923
|
+
catch (err) {
|
|
924
|
+
destination.error(err);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
: _super.prototype._next;
|
|
928
|
+
_this._error = onError
|
|
929
|
+
? function (err) {
|
|
930
|
+
try {
|
|
931
|
+
onError(err);
|
|
932
|
+
}
|
|
933
|
+
catch (err) {
|
|
934
|
+
destination.error(err);
|
|
935
|
+
}
|
|
936
|
+
finally {
|
|
937
|
+
this.unsubscribe();
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
: _super.prototype._error;
|
|
941
|
+
_this._complete = onComplete
|
|
942
|
+
? function () {
|
|
943
|
+
try {
|
|
944
|
+
onComplete();
|
|
945
|
+
}
|
|
946
|
+
catch (err) {
|
|
947
|
+
destination.error(err);
|
|
948
|
+
}
|
|
949
|
+
finally {
|
|
950
|
+
this.unsubscribe();
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
: _super.prototype._complete;
|
|
954
|
+
return _this;
|
|
955
|
+
}
|
|
956
|
+
OperatorSubscriber.prototype.unsubscribe = function () {
|
|
957
|
+
var _a;
|
|
958
|
+
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
|
|
959
|
+
var closed_1 = this.closed;
|
|
960
|
+
_super.prototype.unsubscribe.call(this);
|
|
961
|
+
!closed_1 && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
962
|
+
}
|
|
963
|
+
};
|
|
964
|
+
return OperatorSubscriber;
|
|
965
|
+
}(Subscriber));
|
|
966
|
+
|
|
967
|
+
function map(project, thisArg) {
|
|
968
|
+
return operate(function (source, subscriber) {
|
|
969
|
+
var index = 0;
|
|
970
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
971
|
+
subscriber.next(project.call(thisArg, value, index++));
|
|
972
|
+
}));
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
const EMPTY_SALT = new Uint8Array();
|
|
977
|
+
function withMeta(meta, creator) {
|
|
978
|
+
creator.meta = meta;
|
|
979
|
+
return creator;
|
|
980
|
+
}
|
|
981
|
+
function createBluePrintTx(meta, fn) {
|
|
982
|
+
return withMeta(meta, (options, ...params) => fn(options, params));
|
|
983
|
+
}
|
|
984
|
+
function encodeSalt(salt = utilCrypto.randomAsU8a()) {
|
|
985
|
+
return salt instanceof types.Bytes
|
|
986
|
+
? salt
|
|
987
|
+
: salt?.length
|
|
988
|
+
? util.compactAddLength(util.u8aToU8a(salt))
|
|
989
|
+
: EMPTY_SALT;
|
|
990
|
+
}
|
|
991
|
+
function convertWeight(weight) {
|
|
992
|
+
const [refTime, proofSize] = isWeightV2(weight)
|
|
993
|
+
? [weight.refTime.toBn(), weight.proofSize.toBn()]
|
|
994
|
+
: [util.bnToBn(weight), undefined];
|
|
995
|
+
return {
|
|
996
|
+
v1Weight: refTime,
|
|
997
|
+
v2Weight: { proofSize, refTime }
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
function isWeightV2(weight) {
|
|
1001
|
+
return !!weight.proofSize;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
const MAX_CALL_GAS = new util.BN(5_000_000_000_000).isub(util.BN_ONE);
|
|
1005
|
+
const l = util.logger('Contract');
|
|
1006
|
+
function createQuery(meta, fn) {
|
|
1007
|
+
return withMeta(meta, (origin, options, ...params) => fn(origin, options, params));
|
|
1008
|
+
}
|
|
1009
|
+
function createTx(meta, fn) {
|
|
1010
|
+
return withMeta(meta, (options, ...params) => fn(options, params));
|
|
1011
|
+
}
|
|
1012
|
+
class ContractSubmittableResult extends api.SubmittableResult {
|
|
1013
|
+
contractEvents;
|
|
1014
|
+
constructor(result, contractEvents) {
|
|
1015
|
+
super(result);
|
|
1016
|
+
this.contractEvents = contractEvents;
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
class Contract extends Base {
|
|
1020
|
+
address;
|
|
1021
|
+
#query = {};
|
|
1022
|
+
#tx = {};
|
|
1023
|
+
constructor(api, abi, address, decorateMethod) {
|
|
1024
|
+
super(api, abi, decorateMethod);
|
|
1025
|
+
this.address = this.registry.createType(this._isRevive ? 'AccountId20' : 'AccountId', address);
|
|
1026
|
+
this.abi.messages.forEach((m) => {
|
|
1027
|
+
if (util.isUndefined(this.#tx[m.method])) {
|
|
1028
|
+
this.#tx[m.method] = createTx(m, (o, p) => this.#exec(m, o, p));
|
|
1029
|
+
}
|
|
1030
|
+
if (util.isUndefined(this.#query[m.method])) {
|
|
1031
|
+
this.#query[m.method] = createQuery(m, (f, o, p) => this.#read(m, o, p).send(f));
|
|
1032
|
+
}
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
1035
|
+
get query() {
|
|
1036
|
+
return this.#query;
|
|
1037
|
+
}
|
|
1038
|
+
get tx() {
|
|
1039
|
+
return this.#tx;
|
|
1040
|
+
}
|
|
1041
|
+
#getGas = (_gasLimit, isCall = false) => {
|
|
1042
|
+
const weight = convertWeight(_gasLimit);
|
|
1043
|
+
if (weight.v1Weight.gt(util.BN_ZERO)) {
|
|
1044
|
+
return weight;
|
|
1045
|
+
}
|
|
1046
|
+
return convertWeight(isCall
|
|
1047
|
+
? MAX_CALL_GAS
|
|
1048
|
+
: convertWeight(this.api.consts.system.blockWeights
|
|
1049
|
+
? this.api.consts.system.blockWeights.maxBlock
|
|
1050
|
+
: this.api.consts.system['maximumBlockWeight']).v1Weight.muln(64).div(util.BN_HUNDRED));
|
|
1051
|
+
};
|
|
1052
|
+
#exec = (messageOrId, { gasLimit = util.BN_ZERO, storageDepositLimit = null, value = util.BN_ZERO }, params) => {
|
|
1053
|
+
const palletTx = this._isRevive ? this.api.tx.revive : this.api.tx.contracts;
|
|
1054
|
+
return palletTx.call(this.address, value,
|
|
1055
|
+
this._isWeightV1
|
|
1056
|
+
? convertWeight(gasLimit).v1Weight
|
|
1057
|
+
: convertWeight(gasLimit).v2Weight, storageDepositLimit, this.abi.findMessage(messageOrId).toU8a(params)).withResultTransform((result) =>
|
|
1058
|
+
new ContractSubmittableResult(result, applyOnEvent(result, ['ContractEmitted', 'ContractExecution'], (records) => records
|
|
1059
|
+
.filter((record) => {
|
|
1060
|
+
try {
|
|
1061
|
+
const contractAddress = record.event.data[0];
|
|
1062
|
+
if (this.address.eq(contractAddress)) {
|
|
1063
|
+
return true;
|
|
1064
|
+
}
|
|
1065
|
+
l.debug(`Skipping event from different contract ${contractAddress.toString()} (this contract: ${this.address.toString()})`);
|
|
1066
|
+
return false;
|
|
1067
|
+
}
|
|
1068
|
+
catch (error) {
|
|
1069
|
+
l.warn(`Unable to extract contract address from event: ${error.message}`);
|
|
1070
|
+
return false;
|
|
1071
|
+
}
|
|
1072
|
+
})
|
|
1073
|
+
.map((record) => {
|
|
1074
|
+
try {
|
|
1075
|
+
return this.abi.decodeEvent(record);
|
|
1076
|
+
}
|
|
1077
|
+
catch (error) {
|
|
1078
|
+
l.error(`Unable to decode contract event: ${error.message}`);
|
|
1079
|
+
return null;
|
|
1080
|
+
}
|
|
1081
|
+
})
|
|
1082
|
+
.filter((decoded) => !!decoded), this._isRevive)));
|
|
1083
|
+
};
|
|
1084
|
+
#read = (messageOrId, { gasLimit = util.BN_ZERO, storageDepositLimit = null, value = util.BN_ZERO }, params) => {
|
|
1085
|
+
const message = this.abi.findMessage(messageOrId);
|
|
1086
|
+
return {
|
|
1087
|
+
send: this._decorateMethod((origin) => (this._isRevive
|
|
1088
|
+
? this.api.rx.call.reviveApi.call
|
|
1089
|
+
: this.api.rx.call.contractsApi.call)(origin, this.address, value,
|
|
1090
|
+
this._isWeightV1
|
|
1091
|
+
? this.#getGas(gasLimit, true).v1Weight
|
|
1092
|
+
: this.#getGas(gasLimit, true).v2Weight, storageDepositLimit, message.toU8a(params)).pipe(map(({ debugMessage, gasConsumed, gasRequired, result, storageDeposit }) => ({
|
|
1093
|
+
debugMessage,
|
|
1094
|
+
gasConsumed,
|
|
1095
|
+
gasRequired: gasRequired && !convertWeight(gasRequired).v1Weight.isZero()
|
|
1096
|
+
? gasRequired
|
|
1097
|
+
: gasConsumed,
|
|
1098
|
+
output: result.isOk && message.returnType
|
|
1099
|
+
? this.abi.registry.createTypeUnsafe(message.returnType.lookupName || message.returnType.type, [result.asOk.data.toU8a(true)], { isPedantic: true })
|
|
1100
|
+
: null,
|
|
1101
|
+
result,
|
|
1102
|
+
storageDeposit
|
|
1103
|
+
}))))
|
|
1104
|
+
};
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
class BlueprintSubmittableResult extends api.SubmittableResult {
|
|
1109
|
+
contract;
|
|
1110
|
+
constructor(result, contract) {
|
|
1111
|
+
super(result);
|
|
1112
|
+
this.contract = contract;
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
class Blueprint extends Base {
|
|
1116
|
+
codeHash;
|
|
1117
|
+
#tx = {};
|
|
1118
|
+
constructor(api, abi, codeHash, decorateMethod) {
|
|
1119
|
+
super(api, abi, decorateMethod);
|
|
1120
|
+
this.codeHash = this.registry.createType('Hash', codeHash);
|
|
1121
|
+
this.abi.constructors.forEach((c) => {
|
|
1122
|
+
if (util.isUndefined(this.#tx[c.method])) {
|
|
1123
|
+
this.#tx[c.method] = createBluePrintTx(c, (o, p) => this.#deploy(c, o, p));
|
|
1124
|
+
}
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1127
|
+
get tx() {
|
|
1128
|
+
return this.#tx;
|
|
1129
|
+
}
|
|
1130
|
+
#deploy = (constructorOrId, { gasLimit = util.BN_ZERO, salt, storageDepositLimit = null, value = util.BN_ZERO }, params) => {
|
|
1131
|
+
const palletTx = this._isRevive
|
|
1132
|
+
? this.api.tx.revive
|
|
1133
|
+
: this.api.tx.contracts;
|
|
1134
|
+
return palletTx.instantiate(value,
|
|
1135
|
+
this._isWeightV1
|
|
1136
|
+
? convertWeight(gasLimit).v1Weight
|
|
1137
|
+
: convertWeight(gasLimit).v2Weight, storageDepositLimit, this.codeHash, this.abi.findConstructor(constructorOrId).toU8a(params), encodeSalt(salt)).withResultTransform((result) => new BlueprintSubmittableResult(result, applyOnEvent(result, ['Instantiated'], ([record]) => new Contract(this.api, this.abi, record.event.data[1], this._decorateMethod), this._isRevive)));
|
|
1138
|
+
};
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
class CodeSubmittableResult extends api.SubmittableResult {
|
|
1142
|
+
blueprint;
|
|
1143
|
+
contract;
|
|
1144
|
+
constructor(result, blueprint, contract) {
|
|
1145
|
+
super(result);
|
|
1146
|
+
this.blueprint = blueprint;
|
|
1147
|
+
this.contract = contract;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
function isValidCode(code) {
|
|
1151
|
+
return util.isWasm(code) || util.isRiscV(code);
|
|
1152
|
+
}
|
|
1153
|
+
class Code extends Base {
|
|
1154
|
+
code;
|
|
1155
|
+
#tx = {};
|
|
1156
|
+
constructor(api, abi, wasm, decorateMethod) {
|
|
1157
|
+
super(api, abi, decorateMethod);
|
|
1158
|
+
this.code = isValidCode(this.abi.info.source.wasm)
|
|
1159
|
+
? this.abi.info.source.wasm
|
|
1160
|
+
: util.u8aToU8a(wasm);
|
|
1161
|
+
if (!isValidCode(this.code)) {
|
|
1162
|
+
throw new Error('Invalid code provided');
|
|
1163
|
+
}
|
|
1164
|
+
this.abi.constructors.forEach((c) => {
|
|
1165
|
+
if (util.isUndefined(this.#tx[c.method])) {
|
|
1166
|
+
this.#tx[c.method] = createBluePrintTx(c, (o, p) => this.#instantiate(c, o, p));
|
|
1167
|
+
}
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
get tx() {
|
|
1171
|
+
return this.#tx;
|
|
1172
|
+
}
|
|
1173
|
+
#instantiate = (constructorOrId, { gasLimit = util.BN_ZERO, salt, storageDepositLimit = null, value = util.BN_ZERO }, params) => {
|
|
1174
|
+
const palletTx = this._isRevive ? this.api.tx.revive : this.api.tx.contracts;
|
|
1175
|
+
if (this._isRevive) {
|
|
1176
|
+
return palletTx.instantiateWithCode(value,
|
|
1177
|
+
this._isWeightV1
|
|
1178
|
+
? convertWeight(gasLimit).v1Weight
|
|
1179
|
+
: convertWeight(gasLimit).v2Weight, storageDepositLimit, util.compactAddLength(this.code), this.abi.findConstructor(constructorOrId).toU8a(params), encodeSalt(salt)).withResultTransform((result) => new CodeSubmittableResult(result, ...(applyOnEvent(result, ['Instantiated'], (records) => records.reduce(([blueprint, contract], { event }) => this.api.events.revive['Instantiated'].is(event)
|
|
1180
|
+
? [
|
|
1181
|
+
blueprint,
|
|
1182
|
+
new Contract(this.api, this.abi, event.data[1], this._decorateMethod)
|
|
1183
|
+
]
|
|
1184
|
+
: [blueprint, contract], [undefined, undefined]), this._isRevive) || [undefined, undefined])));
|
|
1185
|
+
}
|
|
1186
|
+
return palletTx.instantiateWithCode(value,
|
|
1187
|
+
this._isWeightV1
|
|
1188
|
+
? convertWeight(gasLimit).v1Weight
|
|
1189
|
+
: convertWeight(gasLimit).v2Weight, storageDepositLimit, util.compactAddLength(this.code), this.abi.findConstructor(constructorOrId).toU8a(params), encodeSalt(salt)).withResultTransform((result) => new CodeSubmittableResult(result, ...(applyOnEvent(result, ['CodeStored', 'Instantiated'], (records) => records.reduce(([blueprint, contract], { event }) => this.api.events.contracts.Instantiated.is(event)
|
|
1190
|
+
? [blueprint, new Contract(this.api, this.abi, event.data[1], this._decorateMethod)]
|
|
1191
|
+
: this.api.events.contracts.CodeStored.is(event)
|
|
1192
|
+
? [new Blueprint(this.api, this.abi, event.data[0], this._decorateMethod), contract]
|
|
1193
|
+
: [blueprint, contract], [undefined, undefined]), this._isRevive) || [undefined, undefined])));
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
class BlueprintPromise extends Blueprint {
|
|
1198
|
+
constructor(api$1, abi, codeHash) {
|
|
1199
|
+
super(api$1, abi, codeHash, api.toPromiseMethod);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
class CodePromise extends Code {
|
|
1203
|
+
constructor(api$1, abi, wasm) {
|
|
1204
|
+
super(api$1, abi, wasm, api.toPromiseMethod);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
class ContractPromise extends Contract {
|
|
1208
|
+
constructor(api$1, abi, address) {
|
|
1209
|
+
super(api$1, abi, address, api.toPromiseMethod);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
class BlueprintRx extends Blueprint {
|
|
1214
|
+
constructor(api$1, abi, codeHash) {
|
|
1215
|
+
super(api$1, abi, codeHash, api.toRxMethod);
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
class CodeRx extends Code {
|
|
1219
|
+
constructor(api$1, abi, wasm) {
|
|
1220
|
+
super(api$1, abi, wasm, api.toRxMethod);
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
class ContractRx extends Contract {
|
|
1224
|
+
constructor(api$1, abi, address) {
|
|
1225
|
+
super(api$1, abi, address, api.toRxMethod);
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
exports.Abi = Abi;
|
|
1230
|
+
exports.BlueprintPromise = BlueprintPromise;
|
|
1231
|
+
exports.BlueprintRx = BlueprintRx;
|
|
1232
|
+
exports.CodePromise = CodePromise;
|
|
1233
|
+
exports.CodeRx = CodeRx;
|
|
1234
|
+
exports.ContractPromise = ContractPromise;
|
|
1235
|
+
exports.ContractRx = ContractRx;
|
|
1236
|
+
exports.packageInfo = packageInfo;
|
|
1237
|
+
|
|
1238
|
+
}));
|