@aeternity/aepp-sdk 11.0.0 → 12.1.0
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/LICENSE +1 -1
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -22
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +2 -1
- package/dist/aepp-sdk.browser.js.LICENSE.txt +1 -0
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +20764 -1
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdk.d.ts +37 -0
- package/es/AeSdk.mjs +81 -0
- package/es/AeSdk.mjs.map +1 -0
- package/es/AeSdkAepp.d.ts +70 -0
- package/es/AeSdkAepp.mjs +176 -0
- package/es/AeSdkAepp.mjs.map +1 -0
- package/es/AeSdkBase.d.ts +213 -0
- package/es/AeSdkBase.mjs +314 -0
- package/es/AeSdkBase.mjs.map +1 -0
- package/es/AeSdkWallet.d.ts +104 -0
- package/es/AeSdkWallet.mjs +326 -0
- package/es/AeSdkWallet.mjs.map +1 -0
- package/es/Node.d.ts +41 -0
- package/es/Node.mjs +147 -0
- package/es/Node.mjs.map +1 -0
- package/es/account/Base.d.ts +68 -0
- package/es/account/Base.mjs +123 -0
- package/es/account/Base.mjs.map +1 -0
- package/es/account/Memory.d.ts +26 -0
- package/es/account/Memory.mjs +103 -0
- package/es/account/Memory.mjs.map +1 -0
- package/es/account/Rpc.d.ts +27 -0
- package/es/account/Rpc.mjs +80 -0
- package/es/account/Rpc.mjs.map +1 -0
- package/es/aens.d.ts +222 -0
- package/es/aens.mjs +338 -0
- package/es/aens.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection/Browser.d.ts +33 -0
- package/es/aepp-wallet-communication/connection/Browser.mjs +73 -0
- package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +18 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +58 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +146 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection-proxy.d.ts +11 -0
- package/{src/utils/crypto-ts.ts → es/aepp-wallet-communication/connection-proxy.mjs} +16 -11
- package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -0
- package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +169 -0
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -0
- package/es/aepp-wallet-communication/rpc/types.d.ts +77 -0
- package/es/aepp-wallet-communication/rpc/types.mjs +3 -0
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -0
- package/es/aepp-wallet-communication/schema.d.ts +105 -46
- package/es/aepp-wallet-communication/schema.mjs +251 -0
- package/es/aepp-wallet-communication/schema.mjs.map +1 -0
- package/es/aepp-wallet-communication/wallet-detector.d.ts +25 -0
- package/es/aepp-wallet-communication/wallet-detector.mjs +62 -0
- package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
- package/es/apis/compiler/compiler.d.ts +92 -0
- package/es/apis/compiler/compiler.mjs +576 -0
- package/es/apis/compiler/compiler.mjs.map +1 -0
- package/es/apis/compiler/index.d.ts +2 -0
- package/es/apis/compiler/index.mjs +3 -0
- package/es/apis/compiler/index.mjs.map +1 -0
- package/es/apis/compiler/models/index.d.ts +248 -0
- package/es/apis/compiler/models/index.mjs +48 -0
- package/es/apis/compiler/models/index.mjs.map +1 -0
- package/es/apis/compiler/models/mappers.d.ts +23 -0
- package/es/apis/compiler/models/mappers.mjs +585 -0
- package/es/apis/compiler/models/mappers.mjs.map +1 -0
- package/es/apis/compiler/models/parameters.d.ts +13 -0
- package/es/apis/compiler/models/parameters.mjs +71 -0
- package/es/apis/compiler/models/parameters.mjs.map +1 -0
- package/es/apis/node/index.d.ts +2 -0
- package/es/apis/node/index.mjs +3 -0
- package/es/apis/node/index.mjs.map +1 -0
- package/es/apis/node/models/index.d.ts +1065 -0
- package/es/apis/node/models/index.mjs +2 -0
- package/es/apis/node/models/index.mjs.map +1 -0
- package/es/apis/node/models/mappers.d.ts +95 -0
- package/es/apis/node/models/mappers.mjs +4166 -0
- package/es/apis/node/models/mappers.mjs.map +1 -0
- package/es/apis/node/models/parameters.d.ts +17 -0
- package/es/apis/node/models/parameters.mjs +165 -0
- package/es/apis/node/models/parameters.mjs.map +1 -0
- package/es/apis/node/node.d.ts +215 -0
- package/es/apis/node/node.mjs +1165 -0
- package/es/apis/node/node.mjs.map +1 -0
- package/es/chain.d.ts +248 -0
- package/es/chain.mjs +560 -0
- package/es/chain.mjs.map +1 -0
- package/es/channel/handlers.d.ts +34 -0
- package/es/channel/handlers.mjs +164 -131
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/index.d.ts +625 -0
- package/es/channel/index.mjs +897 -902
- package/es/channel/index.mjs.map +1 -1
- package/es/channel/internal.d.ts +101 -0
- package/es/channel/internal.mjs +138 -88
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Compiler.d.ts +18 -0
- package/es/contract/Compiler.mjs +68 -0
- package/es/contract/Compiler.mjs.map +1 -0
- package/es/contract/aci.d.ts +127 -0
- package/es/contract/aci.mjs +225 -193
- package/es/contract/aci.mjs.map +1 -1
- package/es/contract/ga.d.ts +69 -0
- package/es/contract/ga.mjs +195 -0
- package/es/contract/ga.mjs.map +1 -0
- package/es/contract/methods.d.ts +71 -0
- package/es/contract/methods.mjs +104 -0
- package/es/contract/methods.mjs.map +1 -0
- package/es/deprecated/index.d.ts +143 -0
- package/es/deprecated/index.mjs +162 -0
- package/es/deprecated/index.mjs.map +1 -0
- package/es/deprecated/methods.d.ts +18 -0
- package/es/deprecated/methods.mjs +26 -0
- package/es/deprecated/methods.mjs.map +1 -0
- package/es/index.d.ts +35 -0
- package/es/index.mjs +35 -40
- package/es/index.mjs.map +1 -1
- package/es/oracle.d.ts +161 -0
- package/es/oracle.mjs +306 -0
- package/es/oracle.mjs.map +1 -0
- package/es/spend.d.ts +62 -0
- package/es/spend.mjs +111 -0
- package/es/spend.mjs.map +1 -0
- package/es/tx/builder/address.d.ts +25 -0
- package/es/tx/builder/address.mjs +45 -0
- package/es/tx/builder/address.mjs.map +1 -0
- package/es/tx/builder/constants.d.ts +70 -0
- package/es/tx/builder/constants.mjs +122 -0
- package/es/tx/builder/constants.mjs.map +1 -0
- package/es/tx/builder/field-types/coin-amount.d.ts +13 -0
- package/es/tx/builder/field-types/coin-amount.mjs +26 -0
- package/es/tx/builder/field-types/coin-amount.mjs.map +1 -0
- package/es/tx/builder/field-types/deposit.d.ts +15 -0
- package/es/tx/builder/field-types/deposit.mjs +19 -0
- package/es/tx/builder/field-types/deposit.mjs.map +1 -0
- package/es/tx/builder/field-types/fee.d.ts +25 -0
- package/es/tx/builder/field-types/fee.mjs +150 -0
- package/es/tx/builder/field-types/fee.mjs.map +1 -0
- package/es/tx/builder/field-types/field.d.ts +6 -0
- package/es/tx/builder/field-types/field.mjs +15 -0
- package/es/tx/builder/field-types/field.mjs.map +1 -0
- package/es/tx/builder/field-types/gas-limit.d.ts +12 -0
- package/es/tx/builder/field-types/gas-limit.mjs +33 -0
- package/es/tx/builder/field-types/gas-limit.mjs.map +1 -0
- package/es/tx/builder/field-types/gas-price.d.ts +8 -0
- package/es/tx/builder/field-types/gas-price.mjs +18 -0
- package/es/tx/builder/field-types/gas-price.mjs.map +1 -0
- package/es/tx/builder/field-types/index.d.ts +70 -0
- package/es/tx/builder/field-types/index.mjs +25 -0
- package/es/tx/builder/field-types/index.mjs.map +1 -0
- package/es/tx/builder/field-types/name-fee.d.ts +20 -0
- package/es/tx/builder/field-types/name-fee.mjs +24 -0
- package/es/tx/builder/field-types/name-fee.mjs.map +1 -0
- package/es/tx/builder/field-types/name-id.d.ts +14 -0
- package/es/tx/builder/field-types/name-id.mjs +19 -0
- package/es/tx/builder/field-types/name-id.mjs.map +1 -0
- package/es/tx/builder/field-types/name.d.ts +13 -0
- package/es/tx/builder/field-types/name.mjs +18 -0
- package/es/tx/builder/field-types/name.mjs.map +1 -0
- package/es/tx/builder/field-types/short-u-int.d.ts +6 -0
- package/es/tx/builder/field-types/short-u-int.mjs +12 -0
- package/es/tx/builder/field-types/short-u-int.mjs.map +1 -0
- package/es/tx/builder/field-types/u-int.d.ts +8 -0
- package/es/tx/builder/field-types/u-int.mjs +14 -0
- package/es/tx/builder/field-types/u-int.mjs.map +1 -0
- package/es/tx/builder/helpers.d.ts +125 -0
- package/es/tx/builder/helpers.mjs +94 -240
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +88 -0
- package/es/tx/builder/index.mjs +167 -358
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +1201 -0
- package/es/tx/builder/schema.mjs +175 -664
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/index.d.ts +64 -0
- package/es/tx/index.mjs +151 -265
- package/es/tx/index.mjs.map +1 -1
- package/es/tx/validator.d.ts +20 -0
- package/es/tx/validator.mjs +104 -124
- package/es/tx/validator.mjs.map +1 -1
- package/es/typings/@aeternity__argon2-browser/index.d.mjs +2 -0
- package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -0
- package/es/typings/@aeternity__uuid/index.d.mjs +2 -0
- package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -0
- package/es/typings/bip32-path/index.d.mjs +2 -0
- package/es/typings/bip32-path/index.d.mjs.map +1 -0
- package/es/typings/blakejs/index.d.mjs.map +1 -1
- package/es/typings/sha-js/index.d.mjs +2 -0
- package/es/typings/sha-js/index.d.mjs.map +1 -0
- package/es/typings/tweetnacl-auth/index.d.mjs +2 -0
- package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -0
- package/es/utils/amount-formatter.d.ts +42 -0
- package/es/utils/amount-formatter.mjs +36 -49
- package/es/utils/amount-formatter.mjs.map +1 -1
- package/es/utils/autorest.d.ts +6 -0
- package/es/utils/autorest.mjs +97 -0
- package/es/utils/autorest.mjs.map +1 -0
- package/es/utils/bignumber.d.ts +13 -0
- package/es/utils/bignumber.mjs +11 -8
- package/es/utils/bignumber.mjs.map +1 -1
- package/es/{bytes.d.ts → utils/bytes.d.ts} +10 -13
- package/es/utils/bytes.mjs +11 -15
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/crypto.d.ts +88 -0
- package/es/utils/crypto.mjs +64 -108
- package/es/utils/crypto.mjs.map +1 -1
- package/es/utils/encoder-types.d.ts +61 -0
- package/es/utils/encoder-types.mjs +36 -0
- package/es/utils/encoder-types.mjs.map +1 -0
- package/es/utils/encoder.d.ts +25 -0
- package/es/utils/encoder.mjs +118 -0
- package/es/utils/encoder.mjs.map +1 -0
- package/es/{errors.d.ts → utils/errors.d.ts} +246 -59
- package/es/utils/errors.mjs +313 -136
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/hd-wallet.d.ts +50 -0
- package/es/utils/hd-wallet.mjs +86 -45
- package/es/utils/hd-wallet.mjs.map +1 -1
- package/es/utils/json-big.d.ts +5 -0
- package/es/utils/json-big.mjs +12 -16
- package/es/utils/json-big.mjs.map +1 -1
- package/es/utils/keystore.d.ts +51 -0
- package/es/utils/keystore.mjs +101 -194
- package/es/utils/keystore.mjs.map +1 -1
- package/es/{mptree.d.ts → utils/mptree.d.ts} +6 -9
- package/es/utils/mptree.mjs +22 -18
- package/es/utils/mptree.mjs.map +1 -1
- package/es/utils/other.d.ts +20 -0
- package/es/utils/other.mjs +32 -35
- package/es/utils/other.mjs.map +1 -1
- package/es/utils/semver-satisfies.d.ts +1 -0
- package/es/utils/semver-satisfies.mjs +2 -2
- package/es/utils/semver-satisfies.mjs.map +1 -1
- package/es/utils/string.d.ts +24 -0
- package/es/utils/string.mjs +8 -10
- package/es/utils/string.mjs.map +1 -1
- package/package.json +56 -42
- package/src/AeSdk.ts +68 -0
- package/src/AeSdkAepp.ts +176 -0
- package/src/AeSdkBase.ts +338 -0
- package/src/AeSdkWallet.ts +348 -0
- package/src/Node.ts +173 -0
- package/src/account/Base.ts +124 -0
- package/src/account/Memory.ts +98 -0
- package/src/account/Rpc.ts +69 -0
- package/src/aens.ts +407 -0
- package/src/aepp-wallet-communication/connection/Browser.ts +71 -0
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +59 -0
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +122 -0
- package/{es/utils/crypto-ts.mjs → src/aepp-wallet-communication/connection-proxy.ts} +18 -18
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +143 -0
- package/src/aepp-wallet-communication/rpc/types.ts +66 -0
- package/src/aepp-wallet-communication/schema.ts +224 -0
- package/src/aepp-wallet-communication/wallet-detector.ts +72 -0
- package/src/apis/compiler/code-model-v4.yaml +2649 -0
- package/src/apis/compiler/compiler.ts +585 -0
- package/src/apis/compiler/index.ts +2 -0
- package/src/apis/compiler/models/index.ts +301 -0
- package/src/apis/compiler/models/mappers.ts +583 -0
- package/src/apis/compiler/models/parameters.ts +93 -0
- package/src/apis/node/code-model-v4.yaml +10080 -0
- package/src/apis/node/index.ts +2 -0
- package/src/apis/node/models/index.ts +1257 -0
- package/src/apis/node/models/mappers.ts +4280 -0
- package/src/apis/node/models/parameters.ts +188 -0
- package/src/apis/node/node.ts +1299 -0
- package/src/chain.ts +502 -0
- package/src/channel/handlers.ts +817 -0
- package/src/channel/index.ts +1025 -0
- package/src/channel/internal.ts +361 -0
- package/src/contract/Compiler.ts +67 -0
- package/src/contract/aci.ts +538 -0
- package/src/contract/ga.ts +199 -0
- package/src/contract/methods.ts +123 -0
- package/src/deprecated/index.ts +170 -0
- package/src/deprecated/methods.ts +25 -0
- package/src/index.ts +56 -0
- package/src/oracle.ts +364 -0
- package/src/spend.ts +164 -0
- package/src/tx/builder/address.ts +50 -0
- package/src/tx/builder/constants.ts +126 -0
- package/src/tx/builder/field-types/coin-amount.ts +27 -0
- package/src/tx/builder/field-types/deposit.ts +21 -0
- package/src/tx/builder/field-types/fee.ts +143 -0
- package/src/tx/builder/field-types/field.ts +9 -0
- package/src/tx/builder/field-types/gas-limit.ts +41 -0
- package/src/tx/builder/field-types/gas-price.ts +16 -0
- package/src/tx/builder/field-types/index.ts +45 -0
- package/src/tx/builder/field-types/name-fee.ts +32 -0
- package/src/tx/builder/field-types/name-id.ts +20 -0
- package/src/tx/builder/field-types/name.ts +18 -0
- package/src/tx/builder/field-types/short-u-int.ts +11 -0
- package/src/tx/builder/field-types/u-int.ts +16 -0
- package/src/tx/builder/helpers.ts +248 -0
- package/src/tx/builder/index.ts +400 -0
- package/src/tx/builder/schema.ts +727 -0
- package/src/tx/index.ts +192 -0
- package/src/tx/validator.ts +230 -0
- package/src/typings/@aeternity__argon2-browser/index.d.ts +3 -0
- package/src/typings/@aeternity__uuid/index.d.ts +5 -0
- package/src/typings/bip32-path/index.d.ts +33 -0
- package/src/typings/blakejs/index.d.ts +4 -32
- package/src/typings/sha-js/index.d.ts +5 -0
- package/src/typings/tweetnacl-auth/index.d.ts +14 -0
- package/src/utils/amount-formatter.ts +56 -69
- package/src/utils/autorest.ts +93 -0
- package/src/utils/bignumber.ts +11 -12
- package/src/utils/bytes.ts +29 -31
- package/src/utils/crypto.ts +205 -0
- package/src/utils/encoder-types.ts +63 -0
- package/src/utils/encoder.ts +146 -0
- package/src/utils/errors.ts +482 -366
- package/src/utils/hd-wallet.ts +166 -0
- package/src/utils/json-big.ts +27 -0
- package/src/utils/keystore.ts +182 -0
- package/src/utils/mptree.ts +64 -61
- package/src/utils/other.ts +34 -41
- package/src/utils/semver-satisfies.ts +15 -11
- package/src/utils/string.ts +18 -20
- package/es/account/base.mjs +0 -179
- package/es/account/base.mjs.map +0 -1
- package/es/account/memory.mjs +0 -99
- package/es/account/memory.mjs.map +0 -1
- package/es/account/multiple.mjs +0 -179
- package/es/account/multiple.mjs.map +0 -1
- package/es/ae/aens.mjs +0 -404
- package/es/ae/aens.mjs.map +0 -1
- package/es/ae/aepp.mjs +0 -45
- package/es/ae/aepp.mjs.map +0 -1
- package/es/ae/contract.mjs +0 -159
- package/es/ae/contract.mjs.map +0 -1
- package/es/ae/index.mjs +0 -207
- package/es/ae/index.mjs.map +0 -1
- package/es/ae/oracle.mjs +0 -339
- package/es/ae/oracle.mjs.map +0 -1
- package/es/ae/universal.mjs +0 -45
- package/es/ae/universal.mjs.map +0 -1
- package/es/ae/wallet.mjs +0 -50
- package/es/ae/wallet.mjs.map +0 -1
- package/es/amount-formatter.d.ts +0 -58
- package/es/bignumber.d.ts +0 -18
- package/es/chain/index.mjs +0 -272
- package/es/chain/index.mjs.map +0 -1
- package/es/chain/node.mjs +0 -442
- package/es/chain/node.mjs.map +0 -1
- package/es/contract/compiler.mjs +0 -115
- package/es/contract/compiler.mjs.map +0 -1
- package/es/contract/ga/helpers.mjs +0 -30
- package/es/contract/ga/helpers.mjs.map +0 -1
- package/es/contract/ga/index.mjs +0 -178
- package/es/contract/ga/index.mjs.map +0 -1
- package/es/crypto-ts.d.ts +0 -9
- package/es/node-pool/index.mjs +0 -188
- package/es/node-pool/index.mjs.map +0 -1
- package/es/node.mjs +0 -133
- package/es/node.mjs.map +0 -1
- package/es/other.d.ts +0 -31
- package/es/semver-satisfies.d.ts +0 -1
- package/es/string.d.ts +0 -26
- package/es/tx/builder/field-types.mjs +0 -74
- package/es/tx/builder/field-types.mjs.map +0 -1
- package/es/tx/tx-object.mjs +0 -283
- package/es/tx/tx-object.mjs.map +0 -1
- package/es/tx/tx.mjs +0 -938
- package/es/tx/tx.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs +0 -132
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs +0 -183
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/index.mjs +0 -87
- package/es/utils/aepp-wallet-communication/connection/index.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/content-script-bridge.mjs +0 -98
- package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/helpers.mjs +0 -92
- package/es/utils/aepp-wallet-communication/helpers.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +0 -375
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs +0 -275
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs +0 -541
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/schema.mjs +0 -102
- package/es/utils/aepp-wallet-communication/schema.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/wallet-detector.mjs +0 -110
- package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +0 -1
- package/es/utils/async-init.mjs +0 -64
- package/es/utils/async-init.mjs.map +0 -1
- package/es/utils/crypto-ts.mjs.map +0 -1
- package/es/utils/swagger.mjs +0 -164
- package/es/utils/swagger.mjs.map +0 -1
- package/src/account/base.js +0 -153
- package/src/account/memory.js +0 -83
- package/src/account/multiple.js +0 -162
- package/src/ae/aens.js +0 -361
- package/src/ae/aepp.js +0 -45
- package/src/ae/contract.js +0 -148
- package/src/ae/index.js +0 -168
- package/src/ae/oracle.js +0 -311
- package/src/ae/universal.js +0 -47
- package/src/ae/wallet.js +0 -50
- package/src/chain/index.js +0 -269
- package/src/chain/node.js +0 -320
- package/src/channel/handlers.js +0 -673
- package/src/channel/index.js +0 -898
- package/src/channel/internal.js +0 -237
- package/src/contract/aci.js +0 -376
- package/src/contract/compiler.js +0 -100
- package/src/contract/ga/helpers.js +0 -19
- package/src/contract/ga/index.js +0 -150
- package/src/index.js +0 -89
- package/src/node-pool/index.js +0 -172
- package/src/node.js +0 -116
- package/src/tx/builder/field-types.js +0 -61
- package/src/tx/builder/helpers.js +0 -380
- package/src/tx/builder/index.js +0 -465
- package/src/tx/builder/schema.js +0 -1197
- package/src/tx/index.js +0 -301
- package/src/tx/tx-object.js +0 -187
- package/src/tx/tx.js +0 -631
- package/src/tx/validator.js +0 -181
- package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -119
- package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -165
- package/src/utils/aepp-wallet-communication/connection/index.js +0 -85
- package/src/utils/aepp-wallet-communication/content-script-bridge.js +0 -86
- package/src/utils/aepp-wallet-communication/helpers.js +0 -60
- package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -294
- package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -232
- package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -401
- package/src/utils/aepp-wallet-communication/schema.ts +0 -80
- package/src/utils/aepp-wallet-communication/wallet-detector.js +0 -92
- package/src/utils/async-init.js +0 -45
- package/src/utils/crypto.js +0 -229
- package/src/utils/hd-wallet.js +0 -100
- package/src/utils/json-big.js +0 -26
- package/src/utils/keystore.js +0 -219
- package/src/utils/swagger.js +0 -156
package/es/tx/builder/index.mjs
CHANGED
|
@@ -1,35 +1,31 @@
|
|
|
1
1
|
import _buffer from "buffer";
|
|
2
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
2
3
|
const {
|
|
3
4
|
Buffer: _Buffer
|
|
4
5
|
} = _buffer;
|
|
5
|
-
import BigNumber from 'bignumber.js';
|
|
6
6
|
import _rlp from 'rlp';
|
|
7
7
|
const {
|
|
8
8
|
decode: rlpDecode,
|
|
9
9
|
encode: rlpEncode
|
|
10
10
|
} = _rlp;
|
|
11
|
-
import {
|
|
11
|
+
import { decode, encode, Encoding } from "../../utils/encoder.mjs";
|
|
12
|
+
import { AE_AMOUNT_FORMATS } from "../../utils/amount-formatter.mjs";
|
|
12
13
|
import { hash } from "../../utils/crypto.mjs";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { FIELD_TYPES, TX_SCHEMA } from "./schema.mjs";
|
|
15
|
+
import { Tag } from "./constants.mjs";
|
|
16
|
+
import { buildContractId, buildPointers, readInt, readPointers, writeInt } from "./helpers.mjs";
|
|
17
|
+
import { readId, writeId } from "./address.mjs";
|
|
16
18
|
import { toBytes } from "../../utils/bytes.mjs";
|
|
17
19
|
import MPTree from "../../utils/mptree.mjs";
|
|
18
|
-
import { InvalidTxParamsError, SchemaNotFoundError } from "../../utils/errors.mjs";
|
|
20
|
+
import { ArgumentError, DecodeError, InvalidTxParamsError, SchemaNotFoundError } from "../../utils/errors.mjs";
|
|
21
|
+
import { isKeyOfObject } from "../../utils/other.mjs";
|
|
22
|
+
|
|
19
23
|
/**
|
|
20
24
|
* JavaScript-based Transaction builder
|
|
21
|
-
* @module @aeternity/aepp-sdk/es/tx/builder
|
|
22
|
-
* @export TxBuilder
|
|
23
|
-
* @example import { TxBuilder } from '@aeternity/aepp-sdk'
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
-
const ORACLE_TTL_TYPES = {
|
|
27
|
-
delta: 'delta',
|
|
28
|
-
block: 'block'
|
|
29
|
-
}; // SERIALIZE AND DESERIALIZE PART
|
|
30
|
-
|
|
26
|
+
// SERIALIZE AND DESERIALIZE PART
|
|
31
27
|
function deserializeField(value, type, prefix) {
|
|
32
|
-
if (
|
|
28
|
+
if (value == null) return '';
|
|
33
29
|
|
|
34
30
|
switch (type) {
|
|
35
31
|
case FIELD_TYPES.ctVersion:
|
|
@@ -41,8 +37,8 @@ function deserializeField(value, type, prefix) {
|
|
|
41
37
|
};
|
|
42
38
|
}
|
|
43
39
|
|
|
44
|
-
case FIELD_TYPES.
|
|
45
|
-
case FIELD_TYPES.
|
|
40
|
+
case FIELD_TYPES.abiVersion:
|
|
41
|
+
case FIELD_TYPES.ttlType:
|
|
46
42
|
return readInt(value);
|
|
47
43
|
|
|
48
44
|
case FIELD_TYPES.id:
|
|
@@ -58,22 +54,24 @@ function deserializeField(value, type, prefix) {
|
|
|
58
54
|
return encode(value, prefix);
|
|
59
55
|
|
|
60
56
|
case FIELD_TYPES.stateTree:
|
|
61
|
-
return encode(value,
|
|
57
|
+
return encode(value, Encoding.StateTrees);
|
|
62
58
|
|
|
63
59
|
case FIELD_TYPES.string:
|
|
64
60
|
return value.toString();
|
|
65
61
|
|
|
66
62
|
case FIELD_TYPES.payload:
|
|
67
|
-
return encode(value,
|
|
63
|
+
return encode(value, Encoding.Bytearray);
|
|
68
64
|
|
|
69
65
|
case FIELD_TYPES.pointers:
|
|
70
66
|
return readPointers(value);
|
|
71
67
|
|
|
72
68
|
case FIELD_TYPES.rlpBinary:
|
|
73
|
-
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
70
|
+
return unpackTx(encode(value, Encoding.Transaction));
|
|
74
71
|
|
|
75
72
|
case FIELD_TYPES.rlpBinaries:
|
|
76
|
-
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
74
|
+
return value.map(v => unpackTx(encode(v, Encoding.Transaction)));
|
|
77
75
|
|
|
78
76
|
case FIELD_TYPES.rawBinary:
|
|
79
77
|
return value;
|
|
@@ -82,7 +80,8 @@ function deserializeField(value, type, prefix) {
|
|
|
82
80
|
return value.toString('hex');
|
|
83
81
|
|
|
84
82
|
case FIELD_TYPES.offChainUpdates:
|
|
85
|
-
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
84
|
+
return value.map(v => unpackTx(encode(v, Encoding.Transaction)));
|
|
86
85
|
|
|
87
86
|
case FIELD_TYPES.callStack:
|
|
88
87
|
// TODO: fix this
|
|
@@ -119,17 +118,17 @@ function deserializeField(value, type, prefix) {
|
|
|
119
118
|
}, {});
|
|
120
119
|
|
|
121
120
|
default:
|
|
122
|
-
if (type
|
|
123
|
-
return value;
|
|
121
|
+
if (typeof type === 'number') return value;
|
|
122
|
+
return type.deserialize(value);
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
function serializeField(value, type,
|
|
126
|
+
function serializeField(value, type, params) {
|
|
128
127
|
var _value$rlpEncoded;
|
|
129
128
|
|
|
130
129
|
switch (type) {
|
|
131
|
-
case FIELD_TYPES.
|
|
132
|
-
case FIELD_TYPES.
|
|
130
|
+
case FIELD_TYPES.abiVersion:
|
|
131
|
+
case FIELD_TYPES.ttlType:
|
|
133
132
|
return writeInt(value);
|
|
134
133
|
|
|
135
134
|
case FIELD_TYPES.id:
|
|
@@ -139,13 +138,13 @@ function serializeField(value, type, prefix, params) {
|
|
|
139
138
|
return value.map(writeId);
|
|
140
139
|
|
|
141
140
|
case FIELD_TYPES.bool:
|
|
142
|
-
return _Buffer.from([value ? 1 : 0]);
|
|
141
|
+
return _Buffer.from([value === true ? 1 : 0]);
|
|
143
142
|
|
|
144
143
|
case FIELD_TYPES.binary:
|
|
145
|
-
return decode(value
|
|
144
|
+
return decode(value);
|
|
146
145
|
|
|
147
146
|
case FIELD_TYPES.stateTree:
|
|
148
|
-
return decode(value
|
|
147
|
+
return decode(value);
|
|
149
148
|
|
|
150
149
|
case FIELD_TYPES.hex:
|
|
151
150
|
return _Buffer.from(value, 'hex');
|
|
@@ -154,7 +153,7 @@ function serializeField(value, type, prefix, params) {
|
|
|
154
153
|
return value.map(_Buffer.from);
|
|
155
154
|
|
|
156
155
|
case FIELD_TYPES.payload:
|
|
157
|
-
return typeof value === 'string' && value.split('_')[0] === 'ba' ? decode(value
|
|
156
|
+
return typeof value === 'string' && value.split('_')[0] === 'ba' ? decode(value) : toBytes(value);
|
|
158
157
|
|
|
159
158
|
case FIELD_TYPES.string:
|
|
160
159
|
return toBytes(value);
|
|
@@ -187,49 +186,43 @@ function serializeField(value, type, prefix, params) {
|
|
|
187
186
|
}
|
|
188
187
|
|
|
189
188
|
default:
|
|
190
|
-
if (type
|
|
191
|
-
|
|
189
|
+
if (typeof type === 'number') return value; // @ts-expect-error will be solved after removing the whole serializeField function
|
|
190
|
+
|
|
191
|
+
return type.serialize(value, params);
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
function validateField(value, type, prefix) {
|
|
196
196
|
// All fields are required
|
|
197
|
-
if (value
|
|
197
|
+
if (value == null) return 'Field is required'; // Validate type of value
|
|
198
198
|
|
|
199
199
|
switch (type) {
|
|
200
|
-
case FIELD_TYPES.amount:
|
|
201
|
-
case FIELD_TYPES.int:
|
|
202
|
-
{
|
|
203
|
-
if (isNaN(value) && !BigNumber.isBigNumber(value)) {
|
|
204
|
-
return `${value} is not of type Number or BigNumber`;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if (new BigNumber(value).lt(0)) return `${value} must be >= 0`;
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
200
|
case FIELD_TYPES.id:
|
|
212
201
|
{
|
|
213
202
|
const prefixes = Array.isArray(prefix) ? prefix : [prefix];
|
|
214
203
|
|
|
215
|
-
if (!prefixes.
|
|
216
|
-
|
|
204
|
+
if (!_includesInstanceProperty(prefixes).call(prefixes, value.split('_')[0])) {
|
|
205
|
+
if (prefix == null) {
|
|
206
|
+
return `'${String(value)}' prefix doesn't exist'`;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return `'${String(value)}' prefix doesn't match expected prefix '${prefix.toString()}'`;
|
|
217
210
|
}
|
|
218
211
|
|
|
219
|
-
return;
|
|
212
|
+
return undefined;
|
|
220
213
|
}
|
|
221
214
|
|
|
222
215
|
case FIELD_TYPES.ctVersion:
|
|
223
|
-
if (!(value
|
|
216
|
+
if (!(Boolean(value.abiVersion) && Boolean(value.vmVersion))) {
|
|
224
217
|
return 'Value must be an object with "vmVersion" and "abiVersion" fields';
|
|
225
218
|
}
|
|
226
219
|
|
|
227
|
-
return;
|
|
220
|
+
return undefined;
|
|
228
221
|
|
|
229
222
|
case FIELD_TYPES.pointers:
|
|
230
223
|
if (!Array.isArray(value)) return 'Value must be of type Array';
|
|
231
224
|
|
|
232
|
-
if (value.some(p => !(p
|
|
225
|
+
if (value.some(p => !(Boolean(p.key) && Boolean(p.id)))) {
|
|
233
226
|
return 'Value must contains only object\'s like \'{key: "account_pubkey", id: "ak_lkamsflkalsdalksdlasdlasdlamd"}\'';
|
|
234
227
|
}
|
|
235
228
|
|
|
@@ -237,308 +230,118 @@ function validateField(value, type, prefix) {
|
|
|
237
230
|
return `Expected 32 pointers or less, got ${value.length} instead`;
|
|
238
231
|
}
|
|
239
232
|
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
function transformParams(params, schema) {
|
|
244
|
-
let {
|
|
245
|
-
denomination
|
|
246
|
-
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
247
|
-
params = schema.filter(_ref2 => {
|
|
248
|
-
let [_, t] = _ref2;
|
|
249
|
-
return t === FIELD_TYPES.amount;
|
|
250
|
-
}).reduce((acc, _ref3) => {
|
|
251
|
-
let [key] = _ref3;
|
|
252
|
-
return { ...params,
|
|
253
|
-
[key]: formatAmount(params[key], {
|
|
254
|
-
denomination
|
|
255
|
-
})
|
|
256
|
-
};
|
|
257
|
-
}, params);
|
|
258
|
-
const schemaKeys = schema.map(_ref4 => {
|
|
259
|
-
let [k] = _ref4;
|
|
260
|
-
return k;
|
|
261
|
-
});
|
|
262
|
-
return Object.entries(params).reduce((acc, _ref5) => {
|
|
263
|
-
let [key, value] = _ref5;
|
|
264
|
-
if (schemaKeys.includes(key)) acc[key] = value;
|
|
265
|
-
|
|
266
|
-
if (['oracleTtl', 'queryTtl', 'responseTtl'].includes(key)) {
|
|
267
|
-
acc[`${key}Type`] = value.type === ORACLE_TTL_TYPES.delta ? 0 : 1;
|
|
268
|
-
acc[`${key}Value`] = value.value;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
return acc;
|
|
272
|
-
}, {});
|
|
273
|
-
} // INTERFACE
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
function getOracleRelativeTtl(params, txType) {
|
|
277
|
-
const ttlKey = {
|
|
278
|
-
[TX_TYPE.oracleRegister]: 'oracleTtl',
|
|
279
|
-
[TX_TYPE.oracleExtend]: 'oracleTtl',
|
|
280
|
-
[TX_TYPE.oracleQuery]: 'queryTtl',
|
|
281
|
-
[TX_TYPE.oracleResponse]: 'responseTtl'
|
|
282
|
-
}[txType];
|
|
233
|
+
return undefined;
|
|
283
234
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
return 1;
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Calculate min fee
|
|
292
|
-
* @function
|
|
293
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/index
|
|
294
|
-
* @rtype (txType, { gas = 0, params }) => String
|
|
295
|
-
* @param {String} txType - Transaction type
|
|
296
|
-
* @param {Options} options - Options object
|
|
297
|
-
* @param {String|Number} options.gas - Gas amount
|
|
298
|
-
* @param {Object} options.params - Tx params
|
|
299
|
-
* @return {String|Number}
|
|
300
|
-
* @example calculateMinFee('spendTx', { gas, params })
|
|
301
|
-
*/
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
export function calculateMinFee(txType, _ref6) {
|
|
305
|
-
let {
|
|
306
|
-
gas = 0,
|
|
307
|
-
params,
|
|
308
|
-
vsn
|
|
309
|
-
} = _ref6;
|
|
310
|
-
const multiplier = BigNumber(1e9); // 10^9 GAS_PRICE
|
|
311
|
-
|
|
312
|
-
if (!params) return BigNumber(DEFAULT_FEE).times(multiplier).toString(10);
|
|
313
|
-
let actualFee = buildFee(txType, {
|
|
314
|
-
params: { ...params,
|
|
315
|
-
fee: 0
|
|
316
|
-
},
|
|
317
|
-
multiplier,
|
|
318
|
-
gas,
|
|
319
|
-
vsn
|
|
320
|
-
});
|
|
321
|
-
let expected = BigNumber(0);
|
|
322
|
-
|
|
323
|
-
while (!actualFee.eq(expected)) {
|
|
324
|
-
actualFee = buildFee(txType, {
|
|
325
|
-
params: { ...params,
|
|
326
|
-
fee: actualFee
|
|
327
|
-
},
|
|
328
|
-
multiplier,
|
|
329
|
-
gas,
|
|
330
|
-
vsn
|
|
331
|
-
});
|
|
332
|
-
expected = actualFee;
|
|
235
|
+
default:
|
|
236
|
+
return undefined;
|
|
333
237
|
}
|
|
334
|
-
|
|
335
|
-
return expected.toString(10);
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Calculate fee based on tx type and params
|
|
339
|
-
* @param txType
|
|
340
|
-
* @param params
|
|
341
|
-
* @param gas
|
|
342
|
-
* @param multiplier
|
|
343
|
-
* @param vsn
|
|
344
|
-
* @return {BigNumber}
|
|
345
|
-
*/
|
|
346
|
-
|
|
347
|
-
function buildFee(txType, _ref7) {
|
|
348
|
-
let {
|
|
349
|
-
params,
|
|
350
|
-
gas = 0,
|
|
351
|
-
multiplier,
|
|
352
|
-
vsn
|
|
353
|
-
} = _ref7;
|
|
354
|
-
const {
|
|
355
|
-
rlpEncoded: txWithOutFee
|
|
356
|
-
} = buildTx({ ...params
|
|
357
|
-
}, txType, {
|
|
358
|
-
vsn
|
|
359
|
-
});
|
|
360
|
-
const txSize = txWithOutFee.length;
|
|
361
|
-
return TX_FEE_BASE_GAS(txType).plus(TX_FEE_OTHER_GAS(txType, txSize, {
|
|
362
|
-
relativeTtl: getOracleRelativeTtl(params, txType),
|
|
363
|
-
innerTxSize: [TX_TYPE.gaMeta, TX_TYPE.payingFor].includes(txType) ? params.tx.tx.encodedTx.rlpEncoded.length : 0
|
|
364
|
-
})).times(multiplier);
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* Calculate fee
|
|
368
|
-
* @function
|
|
369
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder
|
|
370
|
-
* @rtype (fee, txType, gas = 0) => String
|
|
371
|
-
* @param {String|Number} fee - fee
|
|
372
|
-
* @param {String} txType - Transaction type
|
|
373
|
-
* @param {Options} options - Options object
|
|
374
|
-
* @param {String|Number} options.gas - Gas amount
|
|
375
|
-
* @param {Object} options.params - Tx params
|
|
376
|
-
* @return {String|Number}
|
|
377
|
-
* @example calculateFee(null, 'spendTx', { gas, params })
|
|
378
|
-
*/
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
export function calculateFee() {
|
|
382
|
-
let fee = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
383
|
-
let txType = arguments.length > 1 ? arguments[1] : undefined;
|
|
384
|
-
let {
|
|
385
|
-
gas = 0,
|
|
386
|
-
params,
|
|
387
|
-
showWarning = true,
|
|
388
|
-
vsn
|
|
389
|
-
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
390
|
-
if (!params && showWarning) console.warn(`Can't build transaction fee, we will use DEFAULT_FEE(${DEFAULT_FEE})`);
|
|
391
|
-
return fee || calculateMinFee(txType, {
|
|
392
|
-
params,
|
|
393
|
-
gas,
|
|
394
|
-
vsn
|
|
395
|
-
});
|
|
396
238
|
}
|
|
397
239
|
/**
|
|
398
240
|
* Validate transaction params
|
|
399
|
-
* @
|
|
400
|
-
* @
|
|
401
|
-
* @param
|
|
402
|
-
* @param
|
|
403
|
-
* @
|
|
404
|
-
* @return {Object} Object with validation errors
|
|
241
|
+
* @category transaction builder
|
|
242
|
+
* @param params - Object with tx params
|
|
243
|
+
* @param schema - Transaction schema
|
|
244
|
+
* @param excludeKeys - Array of keys to exclude for validation
|
|
245
|
+
* @returns Object with validation errors
|
|
405
246
|
*/
|
|
406
247
|
|
|
407
|
-
|
|
248
|
+
|
|
249
|
+
export function validateParams(params, schema, _ref2) {
|
|
408
250
|
let {
|
|
409
251
|
excludeKeys = []
|
|
410
|
-
} =
|
|
252
|
+
} = _ref2;
|
|
411
253
|
return Object.fromEntries(schema // TODO: allow optional keys in schema
|
|
412
|
-
.filter(
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
254
|
+
.filter(_ref3 => {
|
|
255
|
+
var _context;
|
|
256
|
+
|
|
257
|
+
let [key] = _ref3;
|
|
258
|
+
return !_includesInstanceProperty(excludeKeys).call(excludeKeys, key) && !_includesInstanceProperty(_context = ['payload', 'nameFee', 'deposit', 'gasPrice', 'fee', 'gasLimit']).call(_context, key);
|
|
259
|
+
}).map(_ref4 => {
|
|
260
|
+
let [key, type, prefix] = _ref4;
|
|
417
261
|
return [key, validateField(params[key], type, prefix)];
|
|
418
|
-
}).filter(
|
|
419
|
-
let [, message] =
|
|
262
|
+
}).filter(_ref5 => {
|
|
263
|
+
let [, message] = _ref5;
|
|
420
264
|
return message;
|
|
421
265
|
}));
|
|
422
266
|
}
|
|
423
|
-
/**
|
|
424
|
-
* Build binary transaction
|
|
425
|
-
* @function
|
|
426
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder
|
|
427
|
-
* @param {Object} params Object with tx params
|
|
428
|
-
* @param {Array} schema Transaction schema
|
|
429
|
-
* @param {Object} [options={}] options
|
|
430
|
-
* @param {String[]} [options.excludeKeys=[]] Array of keys to exclude for validation and build
|
|
431
|
-
* @param {String} [options.denomination='aettos'] Denomination of amounts
|
|
432
|
-
* @throws {Error} Validation error
|
|
433
|
-
* @return {Array} Array with binary fields of transaction
|
|
434
|
-
*/
|
|
435
|
-
|
|
436
|
-
export function buildRawTx(params, schema) {
|
|
437
|
-
let {
|
|
438
|
-
excludeKeys = [],
|
|
439
|
-
denomination = AE_AMOUNT_FORMATS.AETTOS
|
|
440
|
-
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
441
|
-
const filteredSchema = schema.filter(_ref12 => {
|
|
442
|
-
let [key] = _ref12;
|
|
443
|
-
return !excludeKeys.includes(key);
|
|
444
|
-
}); // Transform `amount` type fields to `aettos`
|
|
445
|
-
|
|
446
|
-
params = transformParams(params, filteredSchema, {
|
|
447
|
-
denomination
|
|
448
|
-
}); // Validation
|
|
449
|
-
|
|
450
|
-
const valid = validateParams(params, schema, {
|
|
451
|
-
excludeKeys
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
if (Object.keys(valid).length) {
|
|
455
|
-
throw new InvalidTxParamsError('Transaction build error. ' + JSON.stringify(valid));
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
return filteredSchema.map(_ref13 => {
|
|
459
|
-
let [key, fieldType, prefix] = _ref13;
|
|
460
|
-
return serializeField(params[key], fieldType, prefix, params);
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
267
|
/**
|
|
464
268
|
* Unpack binary transaction
|
|
465
|
-
* @
|
|
466
|
-
* @
|
|
467
|
-
* @param
|
|
468
|
-
* @
|
|
469
|
-
* @return {Object} Object with transaction field's
|
|
269
|
+
* @category transaction builder
|
|
270
|
+
* @param binary - Array with binary transaction field's
|
|
271
|
+
* @param schema - Transaction schema
|
|
272
|
+
* @returns Object with transaction field's
|
|
470
273
|
*/
|
|
471
274
|
|
|
472
275
|
export function unpackRawTx(binary, schema) {
|
|
473
|
-
return schema.reduce((acc,
|
|
474
|
-
let [key, fieldType, prefix] =
|
|
276
|
+
return schema.reduce((acc, _ref6, index) => {
|
|
277
|
+
let [key, fieldType, prefix] = _ref6;
|
|
475
278
|
return Object.assign(acc, {
|
|
476
279
|
[key]: deserializeField(binary[index], fieldType, prefix)
|
|
477
280
|
});
|
|
478
281
|
}, {});
|
|
479
282
|
}
|
|
480
283
|
/**
|
|
481
|
-
*
|
|
482
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder
|
|
483
|
-
* @param {{ vsn: String, objId: Number, type: String }}
|
|
484
|
-
* @throws {Error} Schema not found error
|
|
485
|
-
* @return {Object} Schema
|
|
284
|
+
* @category transaction builder
|
|
486
285
|
*/
|
|
487
286
|
|
|
488
|
-
const getSchema = _ref15 => {
|
|
489
|
-
let {
|
|
490
|
-
vsn,
|
|
491
|
-
objId,
|
|
492
|
-
type
|
|
493
|
-
} = _ref15;
|
|
494
|
-
const isDeserialize = !!objId;
|
|
495
|
-
const firstKey = isDeserialize ? objId : type;
|
|
496
|
-
const schema = isDeserialize ? TX_DESERIALIZATION_SCHEMA : TX_SERIALIZATION_SCHEMA;
|
|
497
|
-
|
|
498
|
-
if (!schema[firstKey]) {
|
|
499
|
-
throw new SchemaNotFoundError(`Transaction ${isDeserialize ? 'deserialization' : 'serialization'} not implemented for ${isDeserialize ? 'tag ' + objId : type}`);
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
if (!schema[firstKey][vsn]) {
|
|
503
|
-
throw new SchemaNotFoundError(`Transaction ${isDeserialize ? 'deserialization' : 'serialization'} not implemented for ${isDeserialize ? 'tag ' + objId : type} version ${vsn}`);
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
return schema[firstKey][vsn];
|
|
507
|
-
};
|
|
508
287
|
/**
|
|
509
288
|
* Build transaction hash
|
|
510
|
-
* @
|
|
511
|
-
* @
|
|
512
|
-
* @param
|
|
513
|
-
* @param
|
|
514
|
-
* @param
|
|
515
|
-
* @param
|
|
516
|
-
* @param
|
|
517
|
-
* @throws {
|
|
518
|
-
* @returns
|
|
519
|
-
* @returns
|
|
520
|
-
* @returns
|
|
521
|
-
* @returns
|
|
289
|
+
* @category transaction builder
|
|
290
|
+
* @param _params - Object with tx params
|
|
291
|
+
* @param type - Transaction type
|
|
292
|
+
* @param options - options
|
|
293
|
+
* @param options.excludeKeys - Array of keys to exclude for validation and build
|
|
294
|
+
* @param options.denomination - Denomination of amounts
|
|
295
|
+
* @param options.prefix - Prefix of transaction
|
|
296
|
+
* @throws {@link InvalidTxParamsError}
|
|
297
|
+
* @returns object
|
|
298
|
+
* @returns object.tx Base64Check transaction hash with 'tx_' prefix
|
|
299
|
+
* @returns object.rlpEncoded rlp encoded transaction
|
|
300
|
+
* @returns object.binary binary transaction
|
|
522
301
|
*/
|
|
302
|
+
export function buildTx(_params, type) {
|
|
303
|
+
var _vsn;
|
|
523
304
|
|
|
524
|
-
|
|
525
|
-
export function buildTx(params, type) {
|
|
526
305
|
let {
|
|
527
306
|
excludeKeys = [],
|
|
528
|
-
prefix =
|
|
529
|
-
vsn
|
|
307
|
+
prefix = Encoding.Transaction,
|
|
308
|
+
vsn,
|
|
530
309
|
denomination = AE_AMOUNT_FORMATS.AETTOS
|
|
531
310
|
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
311
|
+
const schemas = TX_SCHEMA[type];
|
|
312
|
+
(_vsn = vsn) !== null && _vsn !== void 0 ? _vsn : vsn = Math.max(...Object.keys(schemas).map(a => +a));
|
|
313
|
+
if (!isKeyOfObject(vsn, schemas)) throw new SchemaNotFoundError('serialization', Tag[type], vsn);
|
|
314
|
+
const schema = schemas[vsn];
|
|
315
|
+
const params = _params;
|
|
316
|
+
params.VSN = vsn;
|
|
317
|
+
params.tag = type;
|
|
318
|
+
params.denomination = denomination;
|
|
319
|
+
const filteredSchema = schema.filter(_ref7 => {
|
|
320
|
+
let [key] = _ref7;
|
|
321
|
+
return !_includesInstanceProperty(excludeKeys).call(excludeKeys, key);
|
|
322
|
+
}); // Validation
|
|
323
|
+
|
|
324
|
+
const valid = validateParams(params, schema, {
|
|
325
|
+
excludeKeys
|
|
535
326
|
});
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
|
|
327
|
+
|
|
328
|
+
if (Object.keys(valid).length > 0) {
|
|
329
|
+
throw new InvalidTxParamsError(`Transaction build error. ${JSON.stringify(valid)}`);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const binary = filteredSchema.map(_ref8 => {
|
|
333
|
+
let [key, fieldType] = _ref8;
|
|
334
|
+
return serializeField(params[key], fieldType, { ...params,
|
|
335
|
+
txType: type,
|
|
336
|
+
rebuildTx: overrideParams => buildTx({ ...params,
|
|
337
|
+
...overrideParams
|
|
338
|
+
}, type, {
|
|
339
|
+
excludeKeys,
|
|
340
|
+
prefix: Encoding.Transaction,
|
|
341
|
+
vsn,
|
|
342
|
+
denomination
|
|
343
|
+
})
|
|
344
|
+
});
|
|
542
345
|
}).filter(e => e !== undefined);
|
|
543
346
|
const rlpEncoded = rlpEncode(binary);
|
|
544
347
|
const tx = encode(rlpEncoded, prefix);
|
|
@@ -550,57 +353,63 @@ export function buildTx(params, type) {
|
|
|
550
353
|
};
|
|
551
354
|
}
|
|
552
355
|
/**
|
|
553
|
-
*
|
|
554
|
-
* @function
|
|
555
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder
|
|
556
|
-
* @param {String|Buffer} encodedTx String or RLP encoded transaction array
|
|
557
|
-
* (if fromRlpBinary flag is true)
|
|
558
|
-
* @param {Boolean} fromRlpBinary Unpack from RLP encoded transaction (default: false)
|
|
559
|
-
* @param {String} prefix - Prefix of data
|
|
560
|
-
* @returns {Object} object
|
|
561
|
-
* @returns {Object} object.tx Object with transaction param's
|
|
562
|
-
* @returns {Buffer} object.rlpEncoded rlp encoded transaction
|
|
563
|
-
* @returns {Array<Buffer>} object.binary binary transaction
|
|
356
|
+
* @category transaction builder
|
|
564
357
|
*/
|
|
565
358
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
359
|
+
/**
|
|
360
|
+
* Unpack transaction hash
|
|
361
|
+
* @category transaction builder
|
|
362
|
+
* @param encodedTx - Transaction to unpack
|
|
363
|
+
* @param txType - Expected transaction type
|
|
364
|
+
* @returns object
|
|
365
|
+
* @returns object.tx Object with transaction param's
|
|
366
|
+
* @returns object.txType Transaction type
|
|
367
|
+
*/
|
|
368
|
+
export function unpackTx(encodedTx, txType) {
|
|
369
|
+
const rlpEncoded = decode(encodedTx);
|
|
570
370
|
const binary = rlpDecode(rlpEncoded);
|
|
571
|
-
const objId = readInt(binary[0]);
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
371
|
+
const objId = +readInt(binary[0]);
|
|
372
|
+
if (!isKeyOfObject(objId, TX_SCHEMA)) throw new DecodeError(`Unknown transaction tag: ${objId}`);
|
|
373
|
+
if (txType != null && txType !== objId) throw new DecodeError(`Expected transaction to have ${Tag[txType]} tag, got ${Tag[objId]} instead`);
|
|
374
|
+
const vsn = +readInt(binary[1]);
|
|
375
|
+
if (!isKeyOfObject(vsn, TX_SCHEMA[objId])) throw new SchemaNotFoundError('deserialization', `tag ${objId}`, vsn);
|
|
376
|
+
const schema = TX_SCHEMA[objId][vsn];
|
|
577
377
|
return {
|
|
578
|
-
txType:
|
|
378
|
+
txType: objId,
|
|
579
379
|
tx: unpackRawTx(binary, schema),
|
|
580
|
-
rlpEncoded
|
|
581
|
-
binary
|
|
380
|
+
rlpEncoded
|
|
582
381
|
};
|
|
583
382
|
}
|
|
584
383
|
/**
|
|
585
384
|
* Build a transaction hash
|
|
586
|
-
* @
|
|
587
|
-
* @
|
|
588
|
-
* @
|
|
589
|
-
* @return {String} Transaction hash
|
|
385
|
+
* @category transaction builder
|
|
386
|
+
* @param rawTx - base64 or rlp encoded transaction
|
|
387
|
+
* @returns Transaction hash
|
|
590
388
|
*/
|
|
591
389
|
|
|
592
390
|
export function buildTxHash(rawTx) {
|
|
593
|
-
const data = typeof rawTx === 'string' && rawTx.startsWith('tx_') ? decode(rawTx
|
|
594
|
-
return encode(hash(data),
|
|
391
|
+
const data = typeof rawTx === 'string' && rawTx.startsWith('tx_') ? decode(rawTx) : rawTx;
|
|
392
|
+
return encode(hash(data), Encoding.TxHash);
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Build a contract public key by contractCreateTx or gaAttach
|
|
396
|
+
* @category contract
|
|
397
|
+
* @param contractTx - Transaction
|
|
398
|
+
* @returns Contract public key
|
|
399
|
+
*/
|
|
400
|
+
|
|
401
|
+
export function buildContractIdByContractTx(contractTx) {
|
|
402
|
+
var _context2;
|
|
403
|
+
|
|
404
|
+
const {
|
|
405
|
+
txType,
|
|
406
|
+
tx
|
|
407
|
+
} = unpackTx(contractTx);
|
|
408
|
+
|
|
409
|
+
if (!_includesInstanceProperty(_context2 = [Tag.ContractCreateTx, Tag.GaAttachTx]).call(_context2, txType)) {
|
|
410
|
+
throw new ArgumentError('contractCreateTx', 'a contractCreateTx or gaAttach', txType);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return buildContractId(tx.ownerId, +tx.nonce);
|
|
595
414
|
}
|
|
596
|
-
export default {
|
|
597
|
-
calculateMinFee,
|
|
598
|
-
calculateFee,
|
|
599
|
-
unpackTx,
|
|
600
|
-
unpackRawTx,
|
|
601
|
-
buildTx,
|
|
602
|
-
buildRawTx,
|
|
603
|
-
validateParams,
|
|
604
|
-
buildTxHash
|
|
605
|
-
};
|
|
606
415
|
//# sourceMappingURL=index.mjs.map
|