@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
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import _buffer from "buffer";
|
|
2
|
-
const {
|
|
3
|
-
Buffer: _Buffer
|
|
4
|
-
} = _buffer;
|
|
5
|
-
import { writeId, readId, isNameValid, produceNameId, ensureNameValid, getMinimumNameFee, readInt, writeInt } from "./helpers.mjs";
|
|
6
|
-
import { InsufficientNameFeeError, IllegalArgumentError } from "../../utils/errors.mjs";
|
|
7
|
-
export class Field {
|
|
8
|
-
static serialize(value) {
|
|
9
|
-
return value;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
static deserialize(value) {
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
export class Name extends Field {
|
|
18
|
-
static serialize(value) {
|
|
19
|
-
ensureNameValid(value);
|
|
20
|
-
return _Buffer.from(value);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
static deserialize(value) {
|
|
24
|
-
return value.toString();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
export class NameId extends Field {
|
|
29
|
-
static serialize(value) {
|
|
30
|
-
return writeId(isNameValid(value) ? produceNameId(value) : value);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static deserialize(value) {
|
|
34
|
-
return readId(value);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
export class NameFee extends Field {
|
|
39
|
-
static serialize(value, _ref) {
|
|
40
|
-
var _value;
|
|
41
|
-
|
|
42
|
-
let {
|
|
43
|
-
name
|
|
44
|
-
} = _ref;
|
|
45
|
-
const minNameFee = getMinimumNameFee(name);
|
|
46
|
-
(_value = value) !== null && _value !== void 0 ? _value : value = minNameFee;
|
|
47
|
-
|
|
48
|
-
if (minNameFee.gt(value)) {
|
|
49
|
-
throw new InsufficientNameFeeError(value, minNameFee);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return writeInt(value);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
static deserialize(value) {
|
|
56
|
-
return readInt(value);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
export class Deposit extends Field {
|
|
61
|
-
static serialize(value, _ref2) {
|
|
62
|
-
let {
|
|
63
|
-
name
|
|
64
|
-
} = _ref2;
|
|
65
|
-
if (+value) throw new IllegalArgumentError(`Contract deposit is not refundable, so it should be equal 0, got ${value} instead`);
|
|
66
|
-
return writeInt(0);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
static deserialize(value) {
|
|
70
|
-
return readInt(value);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=field-types.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/tx/builder/field-types.js"],"names":["writeId","readId","isNameValid","produceNameId","ensureNameValid","getMinimumNameFee","readInt","writeInt","InsufficientNameFeeError","IllegalArgumentError","Field","serialize","value","deserialize","Name","from","toString","NameId","NameFee","name","minNameFee","gt","Deposit"],"mappings":";;;;SACEA,O,EAASC,M,EAAQC,W,EAAaC,a,EAAeC,e,EAAiBC,iB,EAAmBC,O,EAASC,Q;SAEnFC,wB,EAA0BC,oB;AAEnC,OAAO,MAAMC,KAAN,CAAY;AACD,SAATC,SAAS,CAAEC,KAAF,EAAS;AACvB,WAAOA,KAAP;AACD;;AAEiB,SAAXC,WAAW,CAAED,KAAF,EAAS;AACzB,WAAOA,KAAP;AACD;;AAPgB;AAUnB,OAAO,MAAME,IAAN,SAAmBJ,KAAnB,CAAyB;AACd,SAATC,SAAS,CAAEC,KAAF,EAAS;AACvBR,IAAAA,eAAe,CAACQ,KAAD,CAAf;AACA,WAAO,QAAOG,IAAP,CAAYH,KAAZ,CAAP;AACD;;AAEiB,SAAXC,WAAW,CAAED,KAAF,EAAS;AACzB,WAAOA,KAAK,CAACI,QAAN,EAAP;AACD;;AAR6B;AAWhC,OAAO,MAAMC,MAAN,SAAqBP,KAArB,CAA2B;AAChB,SAATC,SAAS,CAAEC,KAAF,EAAS;AACvB,WAAOZ,OAAO,CAACE,WAAW,CAACU,KAAD,CAAX,GAAqBT,aAAa,CAACS,KAAD,CAAlC,GAA4CA,KAA7C,CAAd;AACD;;AAEiB,SAAXC,WAAW,CAAED,KAAF,EAAS;AACzB,WAAOX,MAAM,CAACW,KAAD,CAAb;AACD;;AAP+B;AAUlC,OAAO,MAAMM,OAAN,SAAsBR,KAAtB,CAA4B;AACjB,SAATC,SAAS,CAAEC,KAAF,QAAmB;AAAA;;AAAA,QAAV;AAAEO,MAAAA;AAAF,KAAU;AACjC,UAAMC,UAAU,GAAGf,iBAAiB,CAACc,IAAD,CAApC;AACA,cAAAP,KAAK,UAAL,iCAAAA,KAAK,GAAKQ,UAAV;;AACA,QAAIA,UAAU,CAACC,EAAX,CAAcT,KAAd,CAAJ,EAA0B;AACxB,YAAM,IAAIJ,wBAAJ,CAA6BI,KAA7B,EAAoCQ,UAApC,CAAN;AACD;;AACD,WAAOb,QAAQ,CAACK,KAAD,CAAf;AACD;;AAEiB,SAAXC,WAAW,CAAED,KAAF,EAAS;AACzB,WAAON,OAAO,CAACM,KAAD,CAAd;AACD;;AAZgC;AAenC,OAAO,MAAMU,OAAN,SAAsBZ,KAAtB,CAA4B;AACjB,SAATC,SAAS,CAAEC,KAAF,SAAmB;AAAA,QAAV;AAAEO,MAAAA;AAAF,KAAU;AACjC,QAAI,CAACP,KAAL,EAAY,MAAM,IAAIH,oBAAJ,CAA0B,oEAAmEG,KAAM,UAAnG,CAAN;AACZ,WAAOL,QAAQ,CAAC,CAAD,CAAf;AACD;;AAEiB,SAAXM,WAAW,CAAED,KAAF,EAAS;AACzB,WAAON,OAAO,CAACM,KAAD,CAAd;AACD;;AARgC","sourcesContent":["import {\n writeId, readId, isNameValid, produceNameId, ensureNameValid, getMinimumNameFee, readInt, writeInt\n} from './helpers'\nimport { InsufficientNameFeeError, IllegalArgumentError } from '../../utils/errors'\n\nexport class Field {\n static serialize (value) {\n return value\n }\n\n static deserialize (value) {\n return value\n }\n}\n\nexport class Name extends Field {\n static serialize (value) {\n ensureNameValid(value)\n return Buffer.from(value)\n }\n\n static deserialize (value) {\n return value.toString()\n }\n}\n\nexport class NameId extends Field {\n static serialize (value) {\n return writeId(isNameValid(value) ? produceNameId(value) : value)\n }\n\n static deserialize (value) {\n return readId(value)\n }\n}\n\nexport class NameFee extends Field {\n static serialize (value, { name }) {\n const minNameFee = getMinimumNameFee(name)\n value ??= minNameFee\n if (minNameFee.gt(value)) {\n throw new InsufficientNameFeeError(value, minNameFee)\n }\n return writeInt(value)\n }\n\n static deserialize (value) {\n return readInt(value)\n }\n}\n\nexport class Deposit extends Field {\n static serialize (value, { name }) {\n if (+value) throw new IllegalArgumentError(`Contract deposit is not refundable, so it should be equal 0, got ${value} instead`)\n return writeInt(0)\n }\n\n static deserialize (value) {\n return readInt(value)\n }\n}\n"],"file":"field-types.mjs"}
|
package/es/tx/tx-object.mjs
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import _buffer from "buffer";
|
|
2
|
-
const {
|
|
3
|
-
Buffer: _Buffer
|
|
4
|
-
} = _buffer;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* TxObject module
|
|
8
|
-
* @module @aeternity/aepp-sdk/es/tx/tx-object
|
|
9
|
-
* @export TxObject
|
|
10
|
-
* @example import TxObject from '@aeternity/aepp-sdk/es/tx/tx-object'
|
|
11
|
-
*/
|
|
12
|
-
import stampit from '@stamp/it';
|
|
13
|
-
import { buildTx, calculateFee, unpackTx } from "./builder/index.mjs";
|
|
14
|
-
import { TX_TYPE } from "./builder/schema.mjs";
|
|
15
|
-
import { encode } from "./builder/helpers.mjs";
|
|
16
|
-
import { isHex } from "../utils/string.mjs";
|
|
17
|
-
import { InvalidTxError, TypeError, UnknownTxError, InvalidSignatureError } from "../utils/errors.mjs";
|
|
18
|
-
/**
|
|
19
|
-
* Build transaction from object
|
|
20
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/tx-object
|
|
21
|
-
* @param {String} type Transaction type
|
|
22
|
-
* @param {Object} params Transaction params
|
|
23
|
-
* @param {Object} [options={}] Options
|
|
24
|
-
* @throws {Error} Arguments validation error's
|
|
25
|
-
* @return {{
|
|
26
|
-
* encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, params: Object, type: String
|
|
27
|
-
* }}
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
const buildTransaction = function (type, params) {
|
|
31
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
32
|
-
if (typeof params !== 'object') throw new TypeError('tx "params" should be an object');
|
|
33
|
-
if (typeof type !== 'string' || !Object.values(TX_TYPE).includes(type)) throw new UnknownTxError(`Unknown transaction type ${type}`);
|
|
34
|
-
const fee = calculateFee(params.fee, type, {
|
|
35
|
-
gas: params.gas,
|
|
36
|
-
params,
|
|
37
|
-
vsn: params.vsn
|
|
38
|
-
});
|
|
39
|
-
const {
|
|
40
|
-
rlpEncoded,
|
|
41
|
-
binary,
|
|
42
|
-
tx: encodedTx,
|
|
43
|
-
txObject
|
|
44
|
-
} = buildTx({ ...params,
|
|
45
|
-
fee
|
|
46
|
-
}, type, {
|
|
47
|
-
vsn: params.vsn,
|
|
48
|
-
...options
|
|
49
|
-
});
|
|
50
|
-
return {
|
|
51
|
-
rlpEncoded,
|
|
52
|
-
binary,
|
|
53
|
-
encodedTx,
|
|
54
|
-
params: txObject,
|
|
55
|
-
type
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Unpack transaction from RLP encoded binary or base64c string
|
|
60
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/tx-object
|
|
61
|
-
* @param {Uint8Array|String} tx RLP encoded binary or base64c(rlpBinary) string
|
|
62
|
-
* @throws {Error} Arguments validation error's
|
|
63
|
-
* @return {{
|
|
64
|
-
* encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, type: String, params: Object
|
|
65
|
-
* }}
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const unpackTransaction = tx => {
|
|
70
|
-
if (!tx) throw new InvalidTxError(`Invalid transaction: ${tx}`);
|
|
71
|
-
|
|
72
|
-
if (typeof tx === 'string') {
|
|
73
|
-
const {
|
|
74
|
-
txType: type,
|
|
75
|
-
tx: params,
|
|
76
|
-
rlpEncoded,
|
|
77
|
-
binary
|
|
78
|
-
} = unpackTx(tx);
|
|
79
|
-
return {
|
|
80
|
-
encodedTx: tx,
|
|
81
|
-
type,
|
|
82
|
-
params,
|
|
83
|
-
rlpEncoded,
|
|
84
|
-
binary
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (tx instanceof Uint8Array) {
|
|
89
|
-
const {
|
|
90
|
-
txType: type,
|
|
91
|
-
tx: params,
|
|
92
|
-
rlpEncoded,
|
|
93
|
-
binary
|
|
94
|
-
} = unpackTx(tx, true);
|
|
95
|
-
return {
|
|
96
|
-
encodedTx: encode(tx, 'tx'),
|
|
97
|
-
type,
|
|
98
|
-
params,
|
|
99
|
-
rlpEncoded,
|
|
100
|
-
binary
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
throw new InvalidTxError(`"tx" should be a string or Uint8Array, got ${tx} instead`);
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* Helper which build or unpack transaction base on constructor arguments
|
|
108
|
-
* Need to provide one of arguments: [tx] -> unpack flow or [params, type] -> build flow
|
|
109
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/tx-object
|
|
110
|
-
* @param {Buffer|String} [tx] Transaction rlp binary or vase64c string
|
|
111
|
-
* @param {Object} params Transaction params
|
|
112
|
-
* @param {String} type Transaction type
|
|
113
|
-
* @param {Object} [options={}] Options
|
|
114
|
-
* @throws {Error} Arguments validation error's
|
|
115
|
-
* @return {{
|
|
116
|
-
* encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, type: String, params: Object
|
|
117
|
-
* }}
|
|
118
|
-
*/
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const initTransaction = function () {
|
|
122
|
-
let {
|
|
123
|
-
tx,
|
|
124
|
-
params,
|
|
125
|
-
type,
|
|
126
|
-
options = {}
|
|
127
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
128
|
-
if (params && type) return buildTransaction(type, params, options);
|
|
129
|
-
if (tx) return unpackTransaction(tx);
|
|
130
|
-
throw new InvalidTxError('Invalid TxObject arguments. Please provide one of { tx: "tx_asdasd23..." } or { type: "spendTx", params: {...} }');
|
|
131
|
-
};
|
|
132
|
-
/**
|
|
133
|
-
* Transaction Validator Stamp
|
|
134
|
-
* This stamp give us possibility to unpack and validate some of transaction properties,
|
|
135
|
-
* to make sure we can post it to the chain
|
|
136
|
-
* @function
|
|
137
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/tx-object
|
|
138
|
-
* @rtype Stamp
|
|
139
|
-
* @param {Object} [options={}] - Initializer object
|
|
140
|
-
* @param {Buffer|String} [options.tx] - Rlp binary or base64c transaction
|
|
141
|
-
* @param {Object} [options.params] - Transaction params
|
|
142
|
-
* @param {String} [options.type] - Transaction type
|
|
143
|
-
* @param {Object} [options.options] - Build options
|
|
144
|
-
* @return {Object} TxObject instance
|
|
145
|
-
* @example TxObject({ params: {...}, type: 'spendTx' })
|
|
146
|
-
*/
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
export const TxObject = stampit({
|
|
150
|
-
init() {
|
|
151
|
-
let {
|
|
152
|
-
tx,
|
|
153
|
-
params,
|
|
154
|
-
type,
|
|
155
|
-
options = {}
|
|
156
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
157
|
-
this.options = options;
|
|
158
|
-
this.signatures = [];
|
|
159
|
-
Object.assign(this, initTransaction({
|
|
160
|
-
tx,
|
|
161
|
-
params,
|
|
162
|
-
type,
|
|
163
|
-
options
|
|
164
|
-
}));
|
|
165
|
-
|
|
166
|
-
if (this.type === TX_TYPE.signed) {
|
|
167
|
-
const {
|
|
168
|
-
signatures,
|
|
169
|
-
encodedTx: {
|
|
170
|
-
txType,
|
|
171
|
-
tx
|
|
172
|
-
}
|
|
173
|
-
} = this.params;
|
|
174
|
-
this.signatures = signatures;
|
|
175
|
-
this.params = tx;
|
|
176
|
-
this.type = txType;
|
|
177
|
-
this.isSigned = true;
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
|
|
181
|
-
statics: {
|
|
182
|
-
/**
|
|
183
|
-
* Create txObject from base64c RLP encoded transaction string with 'tx_' prefix
|
|
184
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/tx-object
|
|
185
|
-
* @static
|
|
186
|
-
* @param {String} tx Transaction string (tx_23fsdgsdfg...)
|
|
187
|
-
* @return {TxObject}
|
|
188
|
-
*/
|
|
189
|
-
fromString: tx => TxObject({
|
|
190
|
-
tx
|
|
191
|
-
}),
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Create txObject from transaction RLP binary
|
|
195
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/tx-object
|
|
196
|
-
* @static
|
|
197
|
-
* @param {Buffer} tx Transaction RLP binary
|
|
198
|
-
* @return {TxObject}
|
|
199
|
-
*/
|
|
200
|
-
fromRlp: tx => TxObject({
|
|
201
|
-
tx
|
|
202
|
-
})
|
|
203
|
-
},
|
|
204
|
-
methods: {
|
|
205
|
-
/**
|
|
206
|
-
* Rebuild transaction with new params and recalculate fee
|
|
207
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/tx-object
|
|
208
|
-
* @param {Object} props Transaction properties for update
|
|
209
|
-
* @param options
|
|
210
|
-
* @return {TxObject}
|
|
211
|
-
*/
|
|
212
|
-
setProp() {
|
|
213
|
-
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
214
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
215
|
-
if (typeof props !== 'object') throw new TypeError('Props should be an object');
|
|
216
|
-
this.isSigned = false;
|
|
217
|
-
this.signatures = [];
|
|
218
|
-
Object.assign(this, buildTransaction(this.type, { ...this.params,
|
|
219
|
-
...props,
|
|
220
|
-
fee: null
|
|
221
|
-
}, { ...this.options,
|
|
222
|
-
...options
|
|
223
|
-
}));
|
|
224
|
-
return this;
|
|
225
|
-
},
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Get signatures
|
|
229
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/tx-object
|
|
230
|
-
* @return {Array} Array of signatures
|
|
231
|
-
*/
|
|
232
|
-
getSignatures() {
|
|
233
|
-
return this.signatures;
|
|
234
|
-
},
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Add signature
|
|
238
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/tx-object
|
|
239
|
-
* @param {Buffer|String} signature Signature to add ( Can be: Buffer | Uint8Array | HexString )
|
|
240
|
-
* @return {void}
|
|
241
|
-
*/
|
|
242
|
-
addSignature(signature) {
|
|
243
|
-
signature = isHex(signature) ? _Buffer.from(signature, 'hex') : signature;
|
|
244
|
-
if (!_Buffer.isBuffer(signature) && !(signature instanceof Uint8Array)) throw new InvalidSignatureError('Invalid signature, signature must be of type Buffer or Uint8Array');
|
|
245
|
-
Object.assign(this, buildTransaction(TX_TYPE.signed, {
|
|
246
|
-
encodedTx: this.rlpEncoded,
|
|
247
|
-
signatures: [[...this.signatures, signature]]
|
|
248
|
-
}));
|
|
249
|
-
const {
|
|
250
|
-
signatures,
|
|
251
|
-
encodedTx: {
|
|
252
|
-
txType,
|
|
253
|
-
tx
|
|
254
|
-
}
|
|
255
|
-
} = this.params;
|
|
256
|
-
this.signatures = signatures;
|
|
257
|
-
this.params = tx;
|
|
258
|
-
this.type = txType;
|
|
259
|
-
this.isSigned = true;
|
|
260
|
-
},
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Calculate fee
|
|
264
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/tx-object
|
|
265
|
-
* @param {Object} props
|
|
266
|
-
* @return {String} fee
|
|
267
|
-
*/
|
|
268
|
-
calculateMinFee() {
|
|
269
|
-
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
270
|
-
const params = { ...this.params,
|
|
271
|
-
...props
|
|
272
|
-
};
|
|
273
|
-
return calculateFee(0, this.type, {
|
|
274
|
-
gas: params.gas,
|
|
275
|
-
params,
|
|
276
|
-
vsn: params.vsn
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
export default TxObject;
|
|
283
|
-
//# sourceMappingURL=tx-object.mjs.map
|
package/es/tx/tx-object.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tx/tx-object.js"],"names":["stampit","buildTx","calculateFee","unpackTx","TX_TYPE","encode","isHex","InvalidTxError","TypeError","UnknownTxError","InvalidSignatureError","buildTransaction","type","params","options","Object","values","includes","fee","gas","vsn","rlpEncoded","binary","tx","encodedTx","txObject","unpackTransaction","txType","Uint8Array","initTransaction","TxObject","init","signatures","assign","signed","isSigned","statics","fromString","fromRlp","methods","setProp","props","getSignatures","addSignature","signature","from","isBuffer","calculateMinFee"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,OAAP,MAAoB,WAApB;SACSC,O,EAASC,Y,EAAcC,Q;SACvBC,O;SACAC,M;SACAC,K;SACAC,c,EAAgBC,S,EAAWC,c,EAAgBC,qB;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,gBAAgB,GAAG,UAACC,IAAD,EAAOC,MAAP,EAAgC;AAAA,MAAjBC,OAAiB,uEAAP,EAAO;AACvD,MAAI,OAAOD,MAAP,KAAkB,QAAtB,EAAgC,MAAM,IAAIL,SAAJ,CAAc,iCAAd,CAAN;AAChC,MAAI,OAAOI,IAAP,KAAgB,QAAhB,IAA4B,CAACG,MAAM,CAACC,MAAP,CAAcZ,OAAd,EAAuBa,QAAvB,CAAgCL,IAAhC,CAAjC,EAAwE,MAAM,IAAIH,cAAJ,CAAoB,4BAA2BG,IAAK,EAApD,CAAN;AACxE,QAAMM,GAAG,GAAGhB,YAAY,CAACW,MAAM,CAACK,GAAR,EAAaN,IAAb,EAAmB;AAAEO,IAAAA,GAAG,EAAEN,MAAM,CAACM,GAAd;AAAmBN,IAAAA,MAAnB;AAA2BO,I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,EAAEP,MAAM,CAACO;AAAvC,OAAf,CAAnB;AACD;;AA5DM;AAhCqB,CAAD,CAAxB;AAgGP,eAAeU,QAAf","sourcesContent":["/**\n * TxObject module\n * @module @aeternity/aepp-sdk/es/tx/tx-object\n * @export TxObject\n * @example import TxObject from '@aeternity/aepp-sdk/es/tx/tx-object'\n */\nimport stampit from '@stamp/it'\nimport { buildTx, calculateFee, unpackTx } from './builder'\nimport { TX_TYPE } from './builder/schema'\nimport { encode } from './builder/helpers'\nimport { isHex } from '../utils/string'\nimport { InvalidTxError, TypeError, UnknownTxError, InvalidSignatureError } from '../utils/errors'\n\n/**\n * Build transaction from object\n * @alias module:@aeternity/aepp-sdk/es/tx/tx-object\n * @param {String} type Transaction type\n * @param {Object} params Transaction params\n * @param {Object} [options={}] Options\n * @throws {Error} Arguments validation error's\n * @return {{\n * encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, params: Object, type: String\n * }}\n */\nconst buildTransaction = (type, params, options = {}) => {\n if (typeof params !== 'object') throw new TypeError('tx \"params\" should be an object')\n if (typeof type !== 'string' || !Object.values(TX_TYPE).includes(type)) throw new UnknownTxError(`Unknown transaction type ${type}`)\n const fee = calculateFee(params.fee, type, { gas: params.gas, params, vsn: params.vsn })\n const { rlpEncoded, binary, tx: encodedTx, txObject } = buildTx(\n { ...params, fee }, type, { vsn: params.vsn, ...options }\n )\n return { rlpEncoded, binary, encodedTx, params: txObject, type }\n}\n\n/**\n * Unpack transaction from RLP encoded binary or base64c string\n * @alias module:@aeternity/aepp-sdk/es/tx/tx-object\n * @param {Uint8Array|String} tx RLP encoded binary or base64c(rlpBinary) string\n * @throws {Error} Arguments validation error's\n * @return {{\n * encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, type: String, params: Object\n * }}\n */\nconst unpackTransaction = (tx) => {\n if (!tx) throw new InvalidTxError(`Invalid transaction: ${tx}`)\n if (typeof tx === 'string') {\n const { txType: type, tx: params, rlpEncoded, binary } = unpackTx(tx)\n return { encodedTx: tx, type, params, rlpEncoded, binary }\n }\n if (tx instanceof Uint8Array) {\n const { txType: type, tx: params, rlpEncoded, binary } = unpackTx(tx, true)\n return { encodedTx: encode(tx, 'tx'), type, params, rlpEncoded, binary }\n }\n throw new InvalidTxError(`\"tx\" should be a string or Uint8Array, got ${tx} instead`)\n}\n\n/**\n * Helper which build or unpack transaction base on constructor arguments\n * Need to provide one of arguments: [tx] -> unpack flow or [params, type] -> build flow\n * @alias module:@aeternity/aepp-sdk/es/tx/tx-object\n * @param {Buffer|String} [tx] Transaction rlp binary or vase64c string\n * @param {Object} params Transaction params\n * @param {String} type Transaction type\n * @param {Object} [options={}] Options\n * @throws {Error} Arguments validation error's\n * @return {{\n * encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, type: String, params: Object\n * }}\n */\nconst initTransaction = ({ tx, params, type, options = {} } = {}) => {\n if (params && type) return buildTransaction(type, params, options)\n if (tx) return unpackTransaction(tx)\n throw new InvalidTxError('Invalid TxObject arguments. Please provide one of { tx: \"tx_asdasd23...\" } or { type: \"spendTx\", params: {...} }')\n}\n\n/**\n * Transaction Validator Stamp\n * This stamp give us possibility to unpack and validate some of transaction properties,\n * to make sure we can post it to the chain\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/tx-object\n * @rtype Stamp\n * @param {Object} [options={}] - Initializer object\n * @param {Buffer|String} [options.tx] - Rlp binary or base64c transaction\n * @param {Object} [options.params] - Transaction params\n * @param {String} [options.type] - Transaction type\n * @param {Object} [options.options] - Build options\n * @return {Object} TxObject instance\n * @example TxObject({ params: {...}, type: 'spendTx' })\n */\nexport const TxObject = stampit({\n init ({ tx, params, type, options = {} } = {}) {\n this.options = options\n this.signatures = []\n Object.assign(this, initTransaction({ tx, params, type, options }))\n\n if (this.type === TX_TYPE.signed) {\n const { signatures, encodedTx: { txType, tx } } = this.params\n this.signatures = signatures\n this.params = tx\n this.type = txType\n this.isSigned = true\n }\n },\n statics: {\n /**\n * Create txObject from base64c RLP encoded transaction string with 'tx_' prefix\n * @alias module:@aeternity/aepp-sdk/es/tx/tx-object\n * @static\n * @param {String} tx Transaction string (tx_23fsdgsdfg...)\n * @return {TxObject}\n */\n fromString: (tx) => TxObject({ tx }),\n /**\n * Create txObject from transaction RLP binary\n * @alias module:@aeternity/aepp-sdk/es/tx/tx-object\n * @static\n * @param {Buffer} tx Transaction RLP binary\n * @return {TxObject}\n */\n fromRlp: (tx) => TxObject({ tx })\n },\n methods: {\n /**\n * Rebuild transaction with new params and recalculate fee\n * @alias module:@aeternity/aepp-sdk/es/tx/tx-object\n * @param {Object} props Transaction properties for update\n * @param options\n * @return {TxObject}\n */\n setProp (props = {}, options = {}) {\n if (typeof props !== 'object') throw new TypeError('Props should be an object')\n this.isSigned = false\n this.signatures = []\n Object.assign(\n this,\n buildTransaction(\n this.type, { ...this.params, ...props, fee: null }, { ...this.options, ...options }\n )\n )\n return this\n },\n /**\n * Get signatures\n * @alias module:@aeternity/aepp-sdk/es/tx/tx-object\n * @return {Array} Array of signatures\n */\n getSignatures () {\n return this.signatures\n },\n /**\n * Add signature\n * @alias module:@aeternity/aepp-sdk/es/tx/tx-object\n * @param {Buffer|String} signature Signature to add ( Can be: Buffer | Uint8Array | HexString )\n * @return {void}\n */\n addSignature (signature) {\n signature = isHex(signature) ? Buffer.from(signature, 'hex') : signature\n if (!Buffer.isBuffer(signature) && !(signature instanceof Uint8Array)) throw new InvalidSignatureError('Invalid signature, signature must be of type Buffer or Uint8Array')\n Object.assign(\n this,\n buildTransaction(\n TX_TYPE.signed,\n { encodedTx: this.rlpEncoded, signatures: [[...this.signatures, signature]] }\n )\n )\n\n const { signatures, encodedTx: { txType, tx } } = this.params\n this.signatures = signatures\n this.params = tx\n this.type = txType\n this.isSigned = true\n },\n /**\n * Calculate fee\n * @alias module:@aeternity/aepp-sdk/es/tx/tx-object\n * @param {Object} props\n * @return {String} fee\n */\n calculateMinFee (props = {}) {\n const params = { ...this.params, ...props }\n return calculateFee(0, this.type, { gas: params.gas, params, vsn: params.vsn })\n }\n }\n})\n\nexport default TxObject\n"],"file":"tx-object.mjs"}
|