@aeternity/aepp-sdk 10.0.0 → 12.0.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/README.md +15 -14
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.LICENSE.txt +13 -40
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +1 -1
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +1 -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 +69 -0
- package/es/AeSdkAepp.mjs +175 -0
- package/es/AeSdkAepp.mjs.map +1 -0
- package/es/AeSdkBase.d.ts +212 -0
- package/es/AeSdkBase.mjs +310 -0
- package/es/AeSdkBase.mjs.map +1 -0
- package/es/AeSdkWallet.d.ts +103 -0
- package/es/AeSdkWallet.mjs +322 -0
- package/es/AeSdkWallet.mjs.map +1 -0
- package/es/Node.d.ts +44 -0
- package/es/Node.mjs +141 -0
- package/es/Node.mjs.map +1 -0
- package/es/account/Base.d.ts +65 -0
- package/es/account/Base.mjs +123 -0
- package/es/account/Base.mjs.map +1 -0
- package/es/account/Memory.d.ts +25 -0
- package/es/account/Memory.mjs +81 -0
- package/es/account/Memory.mjs.map +1 -0
- package/es/account/Rpc.d.ts +27 -0
- package/es/account/Rpc.mjs +79 -0
- package/es/account/Rpc.mjs.map +1 -0
- package/es/aens.d.ts +209 -0
- package/es/aens.mjs +332 -0
- package/es/aens.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection/Browser.d.ts +32 -0
- package/es/aepp-wallet-communication/connection/Browser.mjs +70 -0
- package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +17 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +57 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +35 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +142 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection-proxy.d.ts +10 -0
- package/{src/utils/crypto-ts.ts → es/aepp-wallet-communication/connection-proxy.mjs} +15 -11
- package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -0
- package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +33 -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 +118 -0
- package/es/aepp-wallet-communication/schema.mjs +214 -0
- package/es/aepp-wallet-communication/schema.mjs.map +1 -0
- package/es/aepp-wallet-communication/wallet-detector.d.ts +24 -0
- package/es/aepp-wallet-communication/wallet-detector.mjs +63 -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 +1061 -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 +4164 -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 +220 -0
- package/es/chain.mjs +524 -0
- package/es/chain.mjs.map +1 -0
- package/es/channel/handlers.d.ts +34 -0
- package/es/channel/{handlers.js → handlers.mjs} +163 -130
- package/es/channel/handlers.mjs.map +1 -0
- package/es/channel/index.d.ts +634 -0
- package/es/channel/index.mjs +978 -0
- package/es/channel/index.mjs.map +1 -0
- package/es/channel/internal.d.ts +100 -0
- package/es/channel/internal.mjs +328 -0
- package/es/channel/internal.mjs.map +1 -0
- package/es/contract/Compiler.d.ts +17 -0
- package/es/contract/Compiler.mjs +67 -0
- package/es/contract/Compiler.mjs.map +1 -0
- package/es/contract/aci.d.ts +125 -0
- package/es/contract/aci.mjs +496 -0
- package/es/contract/aci.mjs.map +1 -0
- package/es/contract/ga.d.ts +68 -0
- package/es/contract/ga.mjs +190 -0
- package/es/contract/ga.mjs.map +1 -0
- package/es/contract/methods.d.ts +68 -0
- package/es/contract/methods.mjs +101 -0
- package/es/contract/methods.mjs.map +1 -0
- package/es/index.d.ts +32 -0
- package/es/index.mjs +49 -0
- package/es/index.mjs.map +1 -0
- package/es/oracle.d.ts +154 -0
- package/es/oracle.mjs +288 -0
- package/es/oracle.mjs.map +1 -0
- package/es/spend.d.ts +61 -0
- package/es/spend.mjs +122 -0
- package/es/spend.mjs.map +1 -0
- package/es/tx/builder/constants.d.ts +41 -0
- package/es/tx/builder/constants.mjs +100 -0
- package/es/tx/builder/constants.mjs.map +1 -0
- package/es/tx/builder/field-types.d.ts +62 -0
- package/es/tx/builder/field-types.mjs +126 -0
- package/es/tx/builder/field-types.mjs.map +1 -0
- package/es/tx/builder/helpers.d.ts +131 -0
- package/es/tx/builder/helpers.mjs +223 -0
- package/es/tx/builder/helpers.mjs.map +1 -0
- package/es/tx/builder/index.d.ts +75 -0
- package/es/tx/builder/index.mjs +424 -0
- package/es/tx/builder/index.mjs.map +1 -0
- package/es/tx/builder/schema.d.ts +350 -0
- package/es/tx/builder/schema.mjs +320 -0
- package/es/tx/builder/schema.mjs.map +1 -0
- package/es/tx/index.d.ts +63 -0
- package/es/tx/index.mjs +209 -0
- package/es/tx/index.mjs.map +1 -0
- package/es/tx/min-fee.d.ts +20 -0
- package/es/tx/min-fee.mjs +148 -0
- package/es/tx/min-fee.mjs.map +1 -0
- package/es/tx/validator.d.ts +19 -0
- package/es/tx/validator.mjs +240 -0
- package/es/tx/validator.mjs.map +1 -0
- 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 +2 -0
- package/es/typings/blakejs/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.js → amount-formatter.mjs} +38 -44
- package/es/utils/amount-formatter.mjs.map +1 -0
- 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 +23 -0
- package/es/utils/bignumber.mjs.map +1 -0
- package/es/{bytes.d.ts → utils/bytes.d.ts} +10 -13
- package/es/utils/{bytes.js → bytes.mjs} +26 -22
- package/es/utils/bytes.mjs.map +1 -0
- package/es/utils/crypto.d.ts +103 -0
- package/es/utils/crypto.mjs +221 -0
- package/es/utils/crypto.mjs.map +1 -0
- package/es/utils/encoder.d.ts +26 -0
- package/es/utils/encoder.mjs +102 -0
- package/es/utils/encoder.mjs.map +1 -0
- package/es/utils/errors.d.ts +481 -0
- package/es/utils/errors.mjs +882 -0
- package/es/utils/errors.mjs.map +1 -0
- package/es/utils/hd-wallet.d.ts +34 -0
- package/es/utils/hd-wallet.mjs +122 -0
- package/es/utils/hd-wallet.mjs.map +1 -0
- package/es/utils/json-big.d.ts +5 -0
- package/es/utils/json-big.mjs +41 -0
- package/es/utils/json-big.mjs.map +1 -0
- package/es/utils/keystore.d.ts +51 -0
- package/es/utils/keystore.mjs +145 -0
- package/es/utils/keystore.mjs.map +1 -0
- package/es/{mptree.d.ts → utils/mptree.d.ts} +5 -8
- package/es/utils/{mptree.js → mptree.mjs} +33 -25
- package/es/utils/mptree.mjs.map +1 -0
- package/es/utils/other.d.ts +14 -0
- package/es/utils/other.mjs +28 -0
- package/es/utils/other.mjs.map +1 -0
- package/es/{semver-satisfies.d.ts → utils/semver-satisfies.d.ts} +0 -0
- package/es/utils/{semver-satisfies.js → semver-satisfies.mjs} +1 -1
- package/es/utils/semver-satisfies.mjs.map +1 -0
- package/es/utils/string.d.ts +24 -0
- package/es/utils/{string.js → string.mjs} +9 -11
- package/es/utils/string.mjs.map +1 -0
- package/package.json +67 -64
- package/src/AeSdk.ts +65 -0
- package/src/AeSdkAepp.ts +167 -0
- package/src/AeSdkBase.ts +320 -0
- package/src/AeSdkWallet.ts +332 -0
- package/src/Node.ts +167 -0
- package/src/account/Base.ts +114 -0
- package/src/account/Memory.ts +83 -0
- package/src/account/Rpc.ts +67 -0
- package/src/aens.ts +391 -0
- package/src/aepp-wallet-communication/connection/Browser.ts +68 -0
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +58 -0
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +111 -0
- package/{es/utils/crypto-ts.js → src/aepp-wallet-communication/connection-proxy.ts} +16 -9
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +137 -0
- package/src/aepp-wallet-communication/rpc/types.ts +66 -0
- package/src/aepp-wallet-communication/schema.ts +181 -0
- package/src/aepp-wallet-communication/wallet-detector.ts +71 -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 +10046 -0
- package/src/apis/node/index.ts +2 -0
- package/src/apis/node/models/index.ts +1253 -0
- package/src/apis/node/models/mappers.ts +4278 -0
- package/src/apis/node/models/parameters.ts +188 -0
- package/src/apis/node/node.ts +1299 -0
- package/src/chain.ts +444 -0
- package/src/channel/{handlers.js → handlers.ts} +238 -143
- package/src/channel/index.ts +991 -0
- package/src/channel/internal.ts +345 -0
- package/src/contract/Compiler.ts +66 -0
- package/src/contract/aci.ts +529 -0
- package/src/contract/ga.ts +178 -0
- package/src/contract/methods.ts +118 -0
- package/src/index.ts +51 -0
- package/src/oracle.ts +342 -0
- package/src/spend.ts +152 -0
- package/src/tx/builder/constants.ts +96 -0
- package/src/tx/builder/field-types.ts +111 -0
- package/src/tx/builder/helpers.ts +253 -0
- package/src/tx/builder/index.ts +394 -0
- package/src/tx/builder/schema.ts +771 -0
- package/src/tx/index.ts +199 -0
- package/src/tx/min-fee.ts +136 -0
- package/src/tx/validator.ts +226 -0
- package/src/typings/@aeternity__argon2-browser/index.d.ts +3 -0
- package/src/typings/@aeternity__uuid/index.d.ts +3 -0
- package/src/typings/bip32-path/index.d.ts +33 -0
- package/src/typings/tweetnacl-auth/index.d.ts +14 -0
- package/src/utils/amount-formatter.ts +29 -41
- package/src/utils/autorest.ts +90 -0
- package/src/utils/bignumber.ts +9 -19
- package/src/utils/bytes.ts +15 -16
- package/src/utils/crypto.ts +217 -0
- package/src/utils/encoder.ts +98 -0
- package/src/utils/errors.ts +817 -0
- package/src/utils/hd-wallet.ts +134 -0
- package/src/utils/json-big.ts +26 -0
- package/src/utils/keystore.ts +179 -0
- package/src/utils/mptree.ts +26 -20
- package/src/utils/other.ts +28 -43
- package/src/utils/string.ts +8 -10
- package/CHANGELOG.md +0 -1603
- package/es/account/base.js +0 -169
- package/es/account/base.js.map +0 -1
- package/es/account/memory.js +0 -84
- package/es/account/memory.js.map +0 -1
- package/es/account/multiple.js +0 -178
- package/es/account/multiple.js.map +0 -1
- package/es/ae/aens.js +0 -408
- package/es/ae/aens.js.map +0 -1
- package/es/ae/aepp.js +0 -45
- package/es/ae/aepp.js.map +0 -1
- package/es/ae/contract.js +0 -312
- package/es/ae/contract.js.map +0 -1
- package/es/ae/index.js +0 -206
- package/es/ae/index.js.map +0 -1
- package/es/ae/oracle.js +0 -322
- package/es/ae/oracle.js.map +0 -1
- package/es/ae/universal.js +0 -45
- package/es/ae/universal.js.map +0 -1
- package/es/ae/wallet.js +0 -50
- package/es/ae/wallet.js.map +0 -1
- package/es/amount-formatter.d.ts +0 -58
- package/es/bignumber.d.ts +0 -24
- package/es/chain/index.js +0 -256
- package/es/chain/index.js.map +0 -1
- package/es/chain/node.js +0 -394
- package/es/chain/node.js.map +0 -1
- package/es/channel/handlers.js.map +0 -1
- package/es/channel/index.js +0 -980
- package/es/channel/index.js.map +0 -1
- package/es/channel/internal.js +0 -266
- package/es/channel/internal.js.map +0 -1
- package/es/contract/aci/helpers.js +0 -298
- package/es/contract/aci/helpers.js.map +0 -1
- package/es/contract/aci/index.js +0 -361
- package/es/contract/aci/index.js.map +0 -1
- package/es/contract/aci/transformation.js +0 -66
- package/es/contract/aci/transformation.js.map +0 -1
- package/es/contract/compiler.js +0 -244
- package/es/contract/compiler.js.map +0 -1
- package/es/contract/ga/helpers.js +0 -22
- package/es/contract/ga/helpers.js.map +0 -1
- package/es/contract/ga/index.js +0 -170
- package/es/contract/ga/index.js.map +0 -1
- package/es/contract/index.js +0 -162
- package/es/contract/index.js.map +0 -1
- package/es/crypto-ts.d.ts +0 -9
- package/es/index.js +0 -57
- package/es/index.js.map +0 -1
- package/es/node-pool/index.js +0 -187
- package/es/node-pool/index.js.map +0 -1
- package/es/node.js +0 -132
- package/es/node.js.map +0 -1
- package/es/other.d.ts +0 -31
- package/es/string.d.ts +0 -26
- package/es/tx/builder/helpers.js +0 -305
- package/es/tx/builder/helpers.js.map +0 -1
- package/es/tx/builder/index.js +0 -595
- package/es/tx/builder/index.js.map +0 -1
- package/es/tx/builder/schema.js +0 -814
- package/es/tx/builder/schema.js.map +0 -1
- package/es/tx/index.js +0 -300
- package/es/tx/index.js.map +0 -1
- package/es/tx/tx-object.js +0 -276
- package/es/tx/tx-object.js.map +0 -1
- package/es/tx/tx.js +0 -937
- package/es/tx/tx.js.map +0 -1
- package/es/tx/validator.js +0 -208
- package/es/tx/validator.js.map +0 -1
- package/es/typings/blakejs/index.d.js +0 -2
- package/es/typings/blakejs/index.d.js.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -131
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -184
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/index.js +0 -84
- package/es/utils/aepp-wallet-communication/connection/index.js.map +0 -1
- package/es/utils/aepp-wallet-communication/content-script-bridge.js +0 -97
- package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +0 -1
- package/es/utils/aepp-wallet-communication/helpers.js +0 -103
- package/es/utils/aepp-wallet-communication/helpers.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -329
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -270
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -533
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +0 -1
- package/es/utils/aepp-wallet-communication/schema.js +0 -107
- package/es/utils/aepp-wallet-communication/schema.js.map +0 -1
- package/es/utils/aepp-wallet-communication/wallet-detector.js +0 -109
- package/es/utils/aepp-wallet-communication/wallet-detector.js.map +0 -1
- package/es/utils/amount-formatter.js.map +0 -1
- package/es/utils/async-init.js +0 -67
- package/es/utils/async-init.js.map +0 -1
- package/es/utils/bignumber.js +0 -28
- package/es/utils/bignumber.js.map +0 -1
- package/es/utils/bytes.js.map +0 -1
- package/es/utils/crypto-ts.js.map +0 -1
- package/es/utils/crypto.js +0 -304
- package/es/utils/crypto.js.map +0 -1
- package/es/utils/hd-wallet.js +0 -112
- package/es/utils/hd-wallet.js.map +0 -1
- package/es/utils/json-big.js +0 -45
- package/es/utils/json-big.js.map +0 -1
- package/es/utils/keystore.js +0 -228
- package/es/utils/keystore.js.map +0 -1
- package/es/utils/mptree.js.map +0 -1
- package/es/utils/other.js +0 -43
- package/es/utils/other.js.map +0 -1
- package/es/utils/semver-satisfies.js.map +0 -1
- package/es/utils/string.js.map +0 -1
- package/es/utils/swagger.js +0 -132
- package/es/utils/swagger.js.map +0 -1
- package/src/account/base.js +0 -153
- package/src/account/memory.js +0 -78
- package/src/account/multiple.js +0 -154
- package/src/ae/aens.js +0 -366
- package/src/ae/aepp.js +0 -45
- package/src/ae/contract.js +0 -285
- package/src/ae/index.js +0 -167
- package/src/ae/oracle.js +0 -296
- package/src/ae/universal.js +0 -47
- package/src/ae/wallet.js +0 -50
- package/src/chain/index.js +0 -250
- package/src/chain/node.js +0 -293
- package/src/channel/index.js +0 -898
- package/src/channel/internal.js +0 -231
- package/src/contract/aci/index.js +0 -317
- package/src/contract/aci/transformation.js +0 -72
- package/src/contract/compiler.js +0 -195
- package/src/contract/ga/helpers.js +0 -17
- package/src/contract/ga/index.js +0 -147
- package/src/contract/index.js +0 -163
- package/src/index.js +0 -90
- package/src/node-pool/index.js +0 -171
- package/src/node.js +0 -118
- package/src/tx/builder/helpers.js +0 -325
- package/src/tx/builder/index.js +0 -460
- package/src/tx/builder/schema.js +0 -1211
- package/src/tx/index.js +0 -301
- package/src/tx/tx-object.js +0 -186
- package/src/tx/tx.js +0 -622
- package/src/tx/validator.js +0 -161
- package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -114
- package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -161
- package/src/utils/aepp-wallet-communication/connection/index.js +0 -85
- package/src/utils/aepp-wallet-communication/content-script-bridge.js +0 -85
- package/src/utils/aepp-wallet-communication/helpers.js +0 -70
- package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -268
- package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -223
- package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -390
- package/src/utils/aepp-wallet-communication/schema.js +0 -108
- package/src/utils/aepp-wallet-communication/wallet-detector.js +0 -91
- package/src/utils/async-init.js +0 -41
- package/src/utils/crypto.js +0 -312
- package/src/utils/hd-wallet.js +0 -115
- package/src/utils/json-big.js +0 -26
- package/src/utils/keystore.js +0 -223
- package/src/utils/swagger.js +0 -133
package/es/tx/tx.js
DELETED
|
@@ -1,937 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* ISC License (ISC)
|
|
3
|
-
* Copyright (c) 2018 aeternity developers
|
|
4
|
-
*
|
|
5
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
* purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
* copyright notice and this permission notice appear in all copies.
|
|
8
|
-
*
|
|
9
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
-
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
-
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
-
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
-
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
-
* PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Transaction module
|
|
20
|
-
* @module @aeternity/aepp-sdk/es/tx/tx
|
|
21
|
-
* @export Transaction
|
|
22
|
-
* @example import { Transaction } from '@aeternity/aepp-sdk'
|
|
23
|
-
*/
|
|
24
|
-
import ChainNode from '../chain/node';
|
|
25
|
-
import Tx from './';
|
|
26
|
-
import { buildTx, calculateFee, unpackTx } from './builder';
|
|
27
|
-
import { ABI_VERSIONS, MIN_GAS_PRICE, PROTOCOL_VM_ABI, TX_TYPE, TX_TTL } from './builder/schema';
|
|
28
|
-
import { buildContractId } from './builder/helpers';
|
|
29
|
-
import { TxObject } from './tx-object';
|
|
30
|
-
|
|
31
|
-
async function spendTx(_ref) {
|
|
32
|
-
let {
|
|
33
|
-
senderId,
|
|
34
|
-
recipientId,
|
|
35
|
-
amount,
|
|
36
|
-
payload = ''
|
|
37
|
-
} = _ref;
|
|
38
|
-
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
39
|
-
const {
|
|
40
|
-
fee,
|
|
41
|
-
ttl,
|
|
42
|
-
nonce
|
|
43
|
-
} = await this.prepareTxParams(TX_TYPE.spend, {
|
|
44
|
-
senderId,
|
|
45
|
-
...arguments[0],
|
|
46
|
-
payload
|
|
47
|
-
}); // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
48
|
-
|
|
49
|
-
const {
|
|
50
|
-
tx
|
|
51
|
-
} = this.nativeMode ? {
|
|
52
|
-
tx: TxObject({
|
|
53
|
-
params: { ...arguments[0],
|
|
54
|
-
recipientId,
|
|
55
|
-
senderId,
|
|
56
|
-
nonce,
|
|
57
|
-
ttl,
|
|
58
|
-
payload
|
|
59
|
-
},
|
|
60
|
-
type: TX_TYPE.spend
|
|
61
|
-
}).encodedTx
|
|
62
|
-
} : await this.api.postSpend({ ...arguments[0],
|
|
63
|
-
amount: parseInt(amount),
|
|
64
|
-
recipientId,
|
|
65
|
-
senderId,
|
|
66
|
-
nonce,
|
|
67
|
-
ttl,
|
|
68
|
-
fee: parseInt(fee),
|
|
69
|
-
payload
|
|
70
|
-
});
|
|
71
|
-
return tx;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
async function namePreclaimTx(_ref2) {
|
|
75
|
-
let {
|
|
76
|
-
accountId,
|
|
77
|
-
commitmentId
|
|
78
|
-
} = _ref2;
|
|
79
|
-
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
80
|
-
const {
|
|
81
|
-
fee,
|
|
82
|
-
ttl,
|
|
83
|
-
nonce
|
|
84
|
-
} = await this.prepareTxParams(TX_TYPE.namePreClaim, {
|
|
85
|
-
senderId: accountId,
|
|
86
|
-
...arguments[0]
|
|
87
|
-
}); // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
88
|
-
|
|
89
|
-
const {
|
|
90
|
-
tx
|
|
91
|
-
} = this.nativeMode ? {
|
|
92
|
-
tx: TxObject({
|
|
93
|
-
params: { ...arguments[0],
|
|
94
|
-
nonce,
|
|
95
|
-
ttl,
|
|
96
|
-
fee
|
|
97
|
-
},
|
|
98
|
-
type: TX_TYPE.namePreClaim
|
|
99
|
-
}).encodedTx
|
|
100
|
-
} : await this.api.postNamePreclaim({ ...arguments[0],
|
|
101
|
-
nonce,
|
|
102
|
-
ttl,
|
|
103
|
-
fee: parseInt(fee)
|
|
104
|
-
});
|
|
105
|
-
return tx;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async function nameClaimTx(_ref3) {
|
|
109
|
-
let {
|
|
110
|
-
accountId,
|
|
111
|
-
name,
|
|
112
|
-
nameSalt,
|
|
113
|
-
vsn = 2
|
|
114
|
-
} = _ref3;
|
|
115
|
-
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
116
|
-
const {
|
|
117
|
-
fee,
|
|
118
|
-
ttl,
|
|
119
|
-
nonce
|
|
120
|
-
} = await this.prepareTxParams(TX_TYPE.nameClaim, {
|
|
121
|
-
senderId: accountId,
|
|
122
|
-
...arguments[0],
|
|
123
|
-
vsn
|
|
124
|
-
}); // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
125
|
-
|
|
126
|
-
const {
|
|
127
|
-
tx
|
|
128
|
-
} = this.nativeMode ? {
|
|
129
|
-
tx: TxObject({
|
|
130
|
-
params: { ...arguments[0],
|
|
131
|
-
nonce,
|
|
132
|
-
ttl,
|
|
133
|
-
fee,
|
|
134
|
-
vsn
|
|
135
|
-
},
|
|
136
|
-
type: TX_TYPE.nameClaim
|
|
137
|
-
}).encodedTx
|
|
138
|
-
} : await this.api.postNameClaim({ ...arguments[0],
|
|
139
|
-
nonce,
|
|
140
|
-
ttl,
|
|
141
|
-
fee: parseInt(fee)
|
|
142
|
-
});
|
|
143
|
-
return tx;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
async function nameTransferTx(_ref4) {
|
|
147
|
-
let {
|
|
148
|
-
accountId,
|
|
149
|
-
nameId,
|
|
150
|
-
recipientId
|
|
151
|
-
} = _ref4;
|
|
152
|
-
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
153
|
-
const {
|
|
154
|
-
fee,
|
|
155
|
-
ttl,
|
|
156
|
-
nonce
|
|
157
|
-
} = await this.prepareTxParams(TX_TYPE.nameTransfer, {
|
|
158
|
-
senderId: accountId,
|
|
159
|
-
...arguments[0]
|
|
160
|
-
}); // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
161
|
-
|
|
162
|
-
const {
|
|
163
|
-
tx
|
|
164
|
-
} = this.nativeMode ? {
|
|
165
|
-
tx: TxObject({
|
|
166
|
-
params: { ...arguments[0],
|
|
167
|
-
recipientId,
|
|
168
|
-
nonce,
|
|
169
|
-
ttl,
|
|
170
|
-
fee
|
|
171
|
-
},
|
|
172
|
-
type: TX_TYPE.nameTransfer
|
|
173
|
-
}).encodedTx
|
|
174
|
-
} : await this.api.postNameTransfer({ ...arguments[0],
|
|
175
|
-
recipientId,
|
|
176
|
-
nonce,
|
|
177
|
-
ttl,
|
|
178
|
-
fee: parseInt(fee)
|
|
179
|
-
});
|
|
180
|
-
return tx;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
async function nameUpdateTx(_ref5) {
|
|
184
|
-
let {
|
|
185
|
-
accountId,
|
|
186
|
-
nameId,
|
|
187
|
-
nameTtl,
|
|
188
|
-
pointers,
|
|
189
|
-
clientTtl
|
|
190
|
-
} = _ref5;
|
|
191
|
-
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
192
|
-
const {
|
|
193
|
-
fee,
|
|
194
|
-
ttl,
|
|
195
|
-
nonce
|
|
196
|
-
} = await this.prepareTxParams(TX_TYPE.nameUpdate, {
|
|
197
|
-
senderId: accountId,
|
|
198
|
-
...arguments[0]
|
|
199
|
-
}); // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
200
|
-
|
|
201
|
-
const {
|
|
202
|
-
tx
|
|
203
|
-
} = this.nativeMode ? {
|
|
204
|
-
tx: TxObject({
|
|
205
|
-
params: { ...arguments[0],
|
|
206
|
-
nonce,
|
|
207
|
-
ttl,
|
|
208
|
-
fee
|
|
209
|
-
},
|
|
210
|
-
type: TX_TYPE.nameUpdate
|
|
211
|
-
}).encodedTx
|
|
212
|
-
} : await this.api.postNameUpdate({ ...arguments[0],
|
|
213
|
-
nonce,
|
|
214
|
-
ttl,
|
|
215
|
-
fee: parseInt(fee)
|
|
216
|
-
});
|
|
217
|
-
return tx;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
async function nameRevokeTx(_ref6) {
|
|
221
|
-
let {
|
|
222
|
-
accountId,
|
|
223
|
-
nameId
|
|
224
|
-
} = _ref6;
|
|
225
|
-
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
226
|
-
const {
|
|
227
|
-
fee,
|
|
228
|
-
ttl,
|
|
229
|
-
nonce
|
|
230
|
-
} = await this.prepareTxParams(TX_TYPE.nameRevoke, {
|
|
231
|
-
senderId: accountId,
|
|
232
|
-
...arguments[0]
|
|
233
|
-
}); // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
234
|
-
|
|
235
|
-
const {
|
|
236
|
-
tx
|
|
237
|
-
} = this.nativeMode ? {
|
|
238
|
-
tx: TxObject({
|
|
239
|
-
params: { ...arguments[0],
|
|
240
|
-
nonce,
|
|
241
|
-
ttl,
|
|
242
|
-
fee
|
|
243
|
-
},
|
|
244
|
-
type: TX_TYPE.nameRevoke
|
|
245
|
-
}).encodedTx
|
|
246
|
-
} : await this.api.postNameRevoke({ ...arguments[0],
|
|
247
|
-
nonce,
|
|
248
|
-
ttl,
|
|
249
|
-
fee: parseInt(fee)
|
|
250
|
-
});
|
|
251
|
-
return tx;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
async function contractCreateTx(_ref7) {
|
|
255
|
-
let {
|
|
256
|
-
ownerId,
|
|
257
|
-
code,
|
|
258
|
-
vmVersion,
|
|
259
|
-
abiVersion,
|
|
260
|
-
deposit,
|
|
261
|
-
amount,
|
|
262
|
-
gas,
|
|
263
|
-
gasPrice = MIN_GAS_PRICE,
|
|
264
|
-
callData
|
|
265
|
-
} = _ref7;
|
|
266
|
-
// Get VM_ABI version
|
|
267
|
-
const ctVersion = this.getVmVersion(TX_TYPE.contractCreate, arguments[0]); // Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
268
|
-
|
|
269
|
-
const {
|
|
270
|
-
fee,
|
|
271
|
-
ttl,
|
|
272
|
-
nonce
|
|
273
|
-
} = await this.prepareTxParams(TX_TYPE.contractCreate, {
|
|
274
|
-
senderId: ownerId,
|
|
275
|
-
...arguments[0],
|
|
276
|
-
ctVersion,
|
|
277
|
-
gasPrice
|
|
278
|
-
}); // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
279
|
-
|
|
280
|
-
return this.nativeMode ? {
|
|
281
|
-
tx: TxObject({
|
|
282
|
-
params: { ...arguments[0],
|
|
283
|
-
nonce,
|
|
284
|
-
ttl,
|
|
285
|
-
fee,
|
|
286
|
-
ctVersion,
|
|
287
|
-
gasPrice
|
|
288
|
-
},
|
|
289
|
-
type: TX_TYPE.contractCreate
|
|
290
|
-
}).encodedTx,
|
|
291
|
-
contractId: buildContractId(ownerId, nonce)
|
|
292
|
-
} : this.api.postContractCreate({ ...arguments[0],
|
|
293
|
-
nonce,
|
|
294
|
-
ttl,
|
|
295
|
-
fee: parseInt(fee),
|
|
296
|
-
gas: parseInt(gas),
|
|
297
|
-
gasPrice,
|
|
298
|
-
vmVersion: ctVersion.vmVersion,
|
|
299
|
-
abiVersion: ctVersion.abiVersion
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
async function contractCallTx(_ref8) {
|
|
304
|
-
let {
|
|
305
|
-
callerId,
|
|
306
|
-
contractId,
|
|
307
|
-
abiVersion,
|
|
308
|
-
amount,
|
|
309
|
-
gas,
|
|
310
|
-
gasPrice = MIN_GAS_PRICE,
|
|
311
|
-
callData
|
|
312
|
-
} = _ref8;
|
|
313
|
-
const ctVersion = this.getVmVersion(TX_TYPE.contractCall, arguments[0]); // Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
314
|
-
|
|
315
|
-
const {
|
|
316
|
-
fee,
|
|
317
|
-
ttl,
|
|
318
|
-
nonce
|
|
319
|
-
} = await this.prepareTxParams(TX_TYPE.contractCall, {
|
|
320
|
-
senderId: callerId,
|
|
321
|
-
...arguments[0],
|
|
322
|
-
gasPrice,
|
|
323
|
-
abiVersion: ctVersion.abiVersion
|
|
324
|
-
}); // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
325
|
-
|
|
326
|
-
const {
|
|
327
|
-
tx
|
|
328
|
-
} = this.nativeMode ? {
|
|
329
|
-
tx: TxObject({
|
|
330
|
-
params: { ...arguments[0],
|
|
331
|
-
nonce,
|
|
332
|
-
ttl,
|
|
333
|
-
fee,
|
|
334
|
-
abiVersion: ctVersion.abiVersion,
|
|
335
|
-
gasPrice
|
|
336
|
-
},
|
|
337
|
-
type: TX_TYPE.contractCall
|
|
338
|
-
}).encodedTx
|
|
339
|
-
} : await this.api.postContractCall({ ...arguments[0],
|
|
340
|
-
nonce,
|
|
341
|
-
ttl,
|
|
342
|
-
fee: parseInt(fee),
|
|
343
|
-
gas: parseInt(gas),
|
|
344
|
-
gasPrice,
|
|
345
|
-
abiVersion: ctVersion.abiVersion
|
|
346
|
-
});
|
|
347
|
-
return tx;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
async function oracleRegisterTx(_ref9) {
|
|
351
|
-
let {
|
|
352
|
-
accountId,
|
|
353
|
-
queryFormat,
|
|
354
|
-
responseFormat,
|
|
355
|
-
queryFee,
|
|
356
|
-
oracleTtl,
|
|
357
|
-
abiVersion = ABI_VERSIONS.NO_ABI
|
|
358
|
-
} = _ref9;
|
|
359
|
-
// const { abiVersion: abi } = this.getVmVersion(TX_TYPE.oracleRegister, arguments[0])
|
|
360
|
-
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
361
|
-
const {
|
|
362
|
-
fee,
|
|
363
|
-
ttl,
|
|
364
|
-
nonce
|
|
365
|
-
} = await this.prepareTxParams(TX_TYPE.oracleRegister, {
|
|
366
|
-
senderId: accountId,
|
|
367
|
-
...arguments[0],
|
|
368
|
-
abiVersion
|
|
369
|
-
}); // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
370
|
-
|
|
371
|
-
const {
|
|
372
|
-
tx
|
|
373
|
-
} = this.nativeMode ? {
|
|
374
|
-
tx: TxObject({
|
|
375
|
-
params: {
|
|
376
|
-
accountId,
|
|
377
|
-
queryFee,
|
|
378
|
-
abiVersion,
|
|
379
|
-
fee,
|
|
380
|
-
oracleTtl,
|
|
381
|
-
nonce,
|
|
382
|
-
ttl,
|
|
383
|
-
queryFormat,
|
|
384
|
-
responseFormat
|
|
385
|
-
},
|
|
386
|
-
type: TX_TYPE.oracleRegister
|
|
387
|
-
}).encodedTx
|
|
388
|
-
} : await this.api.postOracleRegister({
|
|
389
|
-
accountId,
|
|
390
|
-
queryFee,
|
|
391
|
-
abiVersion,
|
|
392
|
-
fee: parseInt(fee),
|
|
393
|
-
oracleTtl,
|
|
394
|
-
nonce,
|
|
395
|
-
ttl,
|
|
396
|
-
queryFormat,
|
|
397
|
-
responseFormat
|
|
398
|
-
});
|
|
399
|
-
return tx;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
async function oracleExtendTx(_ref10) {
|
|
403
|
-
let {
|
|
404
|
-
oracleId,
|
|
405
|
-
callerId,
|
|
406
|
-
oracleTtl
|
|
407
|
-
} = _ref10;
|
|
408
|
-
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
409
|
-
const {
|
|
410
|
-
fee,
|
|
411
|
-
ttl,
|
|
412
|
-
nonce
|
|
413
|
-
} = await this.prepareTxParams(TX_TYPE.oracleExtend, {
|
|
414
|
-
senderId: callerId,
|
|
415
|
-
...arguments[0]
|
|
416
|
-
}); // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
417
|
-
|
|
418
|
-
const {
|
|
419
|
-
tx
|
|
420
|
-
} = this.nativeMode ? {
|
|
421
|
-
tx: TxObject({
|
|
422
|
-
params: {
|
|
423
|
-
oracleId,
|
|
424
|
-
fee,
|
|
425
|
-
oracleTtl,
|
|
426
|
-
nonce,
|
|
427
|
-
ttl
|
|
428
|
-
},
|
|
429
|
-
type: TX_TYPE.oracleExtend
|
|
430
|
-
}).encodedTx
|
|
431
|
-
} : await this.api.postOracleExtend({
|
|
432
|
-
oracleId,
|
|
433
|
-
fee: parseInt(fee),
|
|
434
|
-
oracleTtl,
|
|
435
|
-
nonce,
|
|
436
|
-
ttl
|
|
437
|
-
});
|
|
438
|
-
return tx;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
async function oraclePostQueryTx(_ref11) {
|
|
442
|
-
let {
|
|
443
|
-
oracleId,
|
|
444
|
-
responseTtl,
|
|
445
|
-
query,
|
|
446
|
-
queryTtl,
|
|
447
|
-
queryFee,
|
|
448
|
-
senderId
|
|
449
|
-
} = _ref11;
|
|
450
|
-
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
451
|
-
const {
|
|
452
|
-
fee,
|
|
453
|
-
ttl,
|
|
454
|
-
nonce
|
|
455
|
-
} = await this.prepareTxParams(TX_TYPE.oracleQuery, {
|
|
456
|
-
senderId,
|
|
457
|
-
...arguments[0]
|
|
458
|
-
}); // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
459
|
-
|
|
460
|
-
const {
|
|
461
|
-
tx
|
|
462
|
-
} = this.nativeMode ? {
|
|
463
|
-
tx: TxObject({
|
|
464
|
-
params: {
|
|
465
|
-
oracleId,
|
|
466
|
-
responseTtl,
|
|
467
|
-
query,
|
|
468
|
-
queryTtl,
|
|
469
|
-
fee,
|
|
470
|
-
queryFee,
|
|
471
|
-
ttl,
|
|
472
|
-
nonce,
|
|
473
|
-
senderId
|
|
474
|
-
},
|
|
475
|
-
type: TX_TYPE.oracleQuery
|
|
476
|
-
}).encodedTx
|
|
477
|
-
} : await this.api.postOracleQuery({
|
|
478
|
-
oracleId,
|
|
479
|
-
responseTtl,
|
|
480
|
-
query,
|
|
481
|
-
queryTtl,
|
|
482
|
-
fee: parseInt(fee),
|
|
483
|
-
queryFee,
|
|
484
|
-
ttl,
|
|
485
|
-
nonce,
|
|
486
|
-
senderId
|
|
487
|
-
});
|
|
488
|
-
return tx;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
async function oracleRespondTx(_ref12) {
|
|
492
|
-
let {
|
|
493
|
-
oracleId,
|
|
494
|
-
callerId,
|
|
495
|
-
responseTtl,
|
|
496
|
-
queryId,
|
|
497
|
-
response
|
|
498
|
-
} = _ref12;
|
|
499
|
-
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
500
|
-
const {
|
|
501
|
-
fee,
|
|
502
|
-
ttl,
|
|
503
|
-
nonce
|
|
504
|
-
} = await this.prepareTxParams(TX_TYPE.oracleResponse, {
|
|
505
|
-
senderId: callerId,
|
|
506
|
-
...arguments[0]
|
|
507
|
-
}); // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
508
|
-
|
|
509
|
-
const {
|
|
510
|
-
tx
|
|
511
|
-
} = this.nativeMode ? {
|
|
512
|
-
tx: TxObject({
|
|
513
|
-
params: {
|
|
514
|
-
oracleId,
|
|
515
|
-
responseTtl,
|
|
516
|
-
queryId,
|
|
517
|
-
response,
|
|
518
|
-
fee,
|
|
519
|
-
ttl,
|
|
520
|
-
nonce
|
|
521
|
-
},
|
|
522
|
-
type: TX_TYPE.oracleResponse
|
|
523
|
-
}).encodedTx
|
|
524
|
-
} : await this.api.postOracleRespond({
|
|
525
|
-
oracleId,
|
|
526
|
-
responseTtl,
|
|
527
|
-
queryId,
|
|
528
|
-
response,
|
|
529
|
-
fee: parseInt(fee),
|
|
530
|
-
ttl,
|
|
531
|
-
nonce
|
|
532
|
-
});
|
|
533
|
-
return tx;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
async function channelCloseSoloTx(_ref13) {
|
|
537
|
-
let {
|
|
538
|
-
channelId,
|
|
539
|
-
fromId,
|
|
540
|
-
payload,
|
|
541
|
-
poi
|
|
542
|
-
} = _ref13;
|
|
543
|
-
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
544
|
-
const {
|
|
545
|
-
fee,
|
|
546
|
-
ttl,
|
|
547
|
-
nonce
|
|
548
|
-
} = await this.prepareTxParams(TX_TYPE.channelCloseSolo, {
|
|
549
|
-
senderId: fromId,
|
|
550
|
-
...arguments[0],
|
|
551
|
-
payload
|
|
552
|
-
}); // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
553
|
-
|
|
554
|
-
const {
|
|
555
|
-
tx
|
|
556
|
-
} = this.nativeMode ? buildTx({ ...arguments[0],
|
|
557
|
-
channelId,
|
|
558
|
-
fromId,
|
|
559
|
-
payload,
|
|
560
|
-
poi,
|
|
561
|
-
ttl,
|
|
562
|
-
fee,
|
|
563
|
-
nonce
|
|
564
|
-
}, TX_TYPE.channelCloseSolo) : await this.api.postChannelCloseSolo({ ...arguments[0],
|
|
565
|
-
channelId,
|
|
566
|
-
fromId,
|
|
567
|
-
payload,
|
|
568
|
-
poi,
|
|
569
|
-
ttl,
|
|
570
|
-
fee: parseInt(fee),
|
|
571
|
-
nonce
|
|
572
|
-
});
|
|
573
|
-
return tx;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
async function channelSlashTx(_ref14) {
|
|
577
|
-
let {
|
|
578
|
-
channelId,
|
|
579
|
-
fromId,
|
|
580
|
-
payload,
|
|
581
|
-
poi
|
|
582
|
-
} = _ref14;
|
|
583
|
-
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
584
|
-
const {
|
|
585
|
-
fee,
|
|
586
|
-
ttl,
|
|
587
|
-
nonce
|
|
588
|
-
} = await this.prepareTxParams(TX_TYPE.channelSlash, {
|
|
589
|
-
senderId: fromId,
|
|
590
|
-
...arguments[0],
|
|
591
|
-
payload
|
|
592
|
-
}); // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
593
|
-
|
|
594
|
-
const {
|
|
595
|
-
tx
|
|
596
|
-
} = this.nativeMode ? buildTx({ ...arguments[0],
|
|
597
|
-
channelId,
|
|
598
|
-
fromId,
|
|
599
|
-
payload,
|
|
600
|
-
poi,
|
|
601
|
-
ttl,
|
|
602
|
-
fee,
|
|
603
|
-
nonce
|
|
604
|
-
}, TX_TYPE.channelSlash) : await this.api.postChannelSlash({ ...arguments[0],
|
|
605
|
-
channelId,
|
|
606
|
-
fromId,
|
|
607
|
-
payload,
|
|
608
|
-
poi,
|
|
609
|
-
ttl,
|
|
610
|
-
fee: parseInt(fee),
|
|
611
|
-
nonce
|
|
612
|
-
});
|
|
613
|
-
return tx;
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
async function channelSettleTx(_ref15) {
|
|
617
|
-
let {
|
|
618
|
-
channelId,
|
|
619
|
-
fromId,
|
|
620
|
-
initiatorAmountFinal,
|
|
621
|
-
responderAmountFinal
|
|
622
|
-
} = _ref15;
|
|
623
|
-
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
624
|
-
const {
|
|
625
|
-
fee,
|
|
626
|
-
ttl,
|
|
627
|
-
nonce
|
|
628
|
-
} = await this.prepareTxParams(TX_TYPE.channelSettle, {
|
|
629
|
-
senderId: fromId,
|
|
630
|
-
...arguments[0]
|
|
631
|
-
}); // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
632
|
-
|
|
633
|
-
const {
|
|
634
|
-
tx
|
|
635
|
-
} = this.nativeMode ? buildTx({ ...arguments[0],
|
|
636
|
-
channelId,
|
|
637
|
-
fromId,
|
|
638
|
-
initiatorAmountFinal,
|
|
639
|
-
responderAmountFinal,
|
|
640
|
-
ttl,
|
|
641
|
-
fee,
|
|
642
|
-
nonce
|
|
643
|
-
}, TX_TYPE.channelSettle) : await this.api.postChannelSettle({ ...arguments[0],
|
|
644
|
-
channelId,
|
|
645
|
-
fromId,
|
|
646
|
-
initiatorAmountFinal: parseInt(initiatorAmountFinal),
|
|
647
|
-
responderAmountFinal: parseInt(responderAmountFinal),
|
|
648
|
-
ttl,
|
|
649
|
-
fee: parseInt(fee),
|
|
650
|
-
nonce
|
|
651
|
-
});
|
|
652
|
-
return tx;
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
async function channelSnapshotSoloTx(_ref16) {
|
|
656
|
-
let {
|
|
657
|
-
channelId,
|
|
658
|
-
fromId,
|
|
659
|
-
payload
|
|
660
|
-
} = _ref16;
|
|
661
|
-
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
662
|
-
const {
|
|
663
|
-
fee,
|
|
664
|
-
ttl,
|
|
665
|
-
nonce
|
|
666
|
-
} = await this.prepareTxParams(TX_TYPE.channelSnapshotSolo, {
|
|
667
|
-
senderId: fromId,
|
|
668
|
-
...arguments[0],
|
|
669
|
-
payload
|
|
670
|
-
}); // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
671
|
-
|
|
672
|
-
const {
|
|
673
|
-
tx
|
|
674
|
-
} = this.nativeMode ? buildTx({ ...arguments[0],
|
|
675
|
-
channelId,
|
|
676
|
-
fromId,
|
|
677
|
-
payload,
|
|
678
|
-
ttl,
|
|
679
|
-
fee,
|
|
680
|
-
nonce
|
|
681
|
-
}, TX_TYPE.channelSnapshotSolo) : await this.api.postChannelSnapshotSolo({ ...arguments[0],
|
|
682
|
-
channelId,
|
|
683
|
-
fromId,
|
|
684
|
-
payload,
|
|
685
|
-
ttl,
|
|
686
|
-
fee: parseInt(fee),
|
|
687
|
-
nonce
|
|
688
|
-
});
|
|
689
|
-
return tx;
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
async function gaAttachTx(_ref17) {
|
|
693
|
-
let {
|
|
694
|
-
ownerId,
|
|
695
|
-
code,
|
|
696
|
-
vmVersion,
|
|
697
|
-
abiVersion,
|
|
698
|
-
authFun,
|
|
699
|
-
gas,
|
|
700
|
-
gasPrice = MIN_GAS_PRICE,
|
|
701
|
-
callData
|
|
702
|
-
} = _ref17;
|
|
703
|
-
// Get VM_ABI version
|
|
704
|
-
const ctVersion = this.getVmVersion(TX_TYPE.contractCreate, arguments[0]); // Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
705
|
-
|
|
706
|
-
const {
|
|
707
|
-
fee,
|
|
708
|
-
ttl,
|
|
709
|
-
nonce
|
|
710
|
-
} = await this.prepareTxParams(TX_TYPE.gaAttach, {
|
|
711
|
-
senderId: ownerId,
|
|
712
|
-
...arguments[0],
|
|
713
|
-
ctVersion,
|
|
714
|
-
gasPrice
|
|
715
|
-
}); // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
716
|
-
|
|
717
|
-
return {
|
|
718
|
-
tx: TxObject({
|
|
719
|
-
params: { ...arguments[0],
|
|
720
|
-
nonce,
|
|
721
|
-
ttl,
|
|
722
|
-
fee,
|
|
723
|
-
ctVersion,
|
|
724
|
-
gasPrice
|
|
725
|
-
},
|
|
726
|
-
type: TX_TYPE.gaAttach
|
|
727
|
-
}).encodedTx,
|
|
728
|
-
contractId: buildContractId(ownerId, nonce)
|
|
729
|
-
};
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
async function payingForTx(_ref18) {
|
|
733
|
-
let {
|
|
734
|
-
tx,
|
|
735
|
-
payerId,
|
|
736
|
-
...args
|
|
737
|
-
} = _ref18;
|
|
738
|
-
const params = {
|
|
739
|
-
tx: unpackTx(tx),
|
|
740
|
-
payerId
|
|
741
|
-
};
|
|
742
|
-
const {
|
|
743
|
-
fee,
|
|
744
|
-
nonce
|
|
745
|
-
} = await this.prepareTxParams(TX_TYPE.payingFor, { ...params,
|
|
746
|
-
...args,
|
|
747
|
-
senderId: payerId
|
|
748
|
-
});
|
|
749
|
-
return buildTx({ ...params,
|
|
750
|
-
...args,
|
|
751
|
-
fee,
|
|
752
|
-
nonce
|
|
753
|
-
}, TX_TYPE.payingFor).tx;
|
|
754
|
-
}
|
|
755
|
-
/**
|
|
756
|
-
* Validated vm/abi version or get default based on transaction type and NODE version
|
|
757
|
-
*
|
|
758
|
-
* @param {string} txType Type of transaction
|
|
759
|
-
* @param {object} vmAbi Object with vm and abi version fields
|
|
760
|
-
* @return {object} Object with vm/abi version ({ vmVersion: number, abiVersion: number })
|
|
761
|
-
*/
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
function getVmVersion(txType) {
|
|
765
|
-
let {
|
|
766
|
-
vmVersion,
|
|
767
|
-
abiVersion
|
|
768
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
769
|
-
const {
|
|
770
|
-
consensusProtocolVersion
|
|
771
|
-
} = this.getNodeInfo();
|
|
772
|
-
const supportedProtocol = PROTOCOL_VM_ABI[consensusProtocolVersion];
|
|
773
|
-
if (!supportedProtocol) throw new Error('Not supported consensus protocol version');
|
|
774
|
-
const protocolForTX = supportedProtocol[txType];
|
|
775
|
-
if (!protocolForTX) throw new Error('Not supported tx type');
|
|
776
|
-
abiVersion = abiVersion || protocolForTX.abiVersion[0];
|
|
777
|
-
vmVersion = vmVersion || protocolForTX.vmVersion[0];
|
|
778
|
-
|
|
779
|
-
if (!protocolForTX.vmVersion.includes(vmVersion)) {
|
|
780
|
-
throw new Error(`VM VERSION ${vmVersion} do not support by this node. Supported: [${protocolForTX.vmVersion}]`);
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
if (!protocolForTX.abiVersion.includes(abiVersion)) {
|
|
784
|
-
throw new Error(`ABI VERSION ${abiVersion} do not support by this node. Supported: [${protocolForTX.abiVersion}]`);
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
return {
|
|
788
|
-
vmVersion,
|
|
789
|
-
abiVersion
|
|
790
|
-
};
|
|
791
|
-
}
|
|
792
|
-
/**
|
|
793
|
-
* Compute the absolute ttl by adding the ttl to the current height of the chain
|
|
794
|
-
*
|
|
795
|
-
* @param {number} ttl
|
|
796
|
-
* @param {boolean} relative ttl is absolute or relative(default: true(relative))
|
|
797
|
-
* @return {number} Absolute Ttl
|
|
798
|
-
*/
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
async function calculateTtl() {
|
|
802
|
-
let ttl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : TX_TTL;
|
|
803
|
-
let relative = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
804
|
-
if (ttl === 0) return 0;
|
|
805
|
-
if (ttl < 0) throw new Error('ttl must be greater than 0');
|
|
806
|
-
|
|
807
|
-
if (relative) {
|
|
808
|
-
const {
|
|
809
|
-
height
|
|
810
|
-
} = await this.api.getCurrentKeyBlock();
|
|
811
|
-
return +height + ttl;
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
return ttl;
|
|
815
|
-
}
|
|
816
|
-
/**
|
|
817
|
-
* Get the next nonce to be used for a transaction for an account
|
|
818
|
-
*
|
|
819
|
-
* @param {string} accountId
|
|
820
|
-
* @param {number} nonce
|
|
821
|
-
* @return {number} Next Nonce
|
|
822
|
-
*/
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
async function getAccountNonce(accountId, nonce) {
|
|
826
|
-
if (nonce) return nonce;
|
|
827
|
-
const {
|
|
828
|
-
nonce: accountNonce
|
|
829
|
-
} = await this.api.getAccountByPubkey(accountId).catch(() => ({
|
|
830
|
-
nonce: 0
|
|
831
|
-
}));
|
|
832
|
-
return accountNonce + 1;
|
|
833
|
-
}
|
|
834
|
-
/**
|
|
835
|
-
* Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
836
|
-
*
|
|
837
|
-
* @param {String} txType Type of transaction
|
|
838
|
-
* @param {Object} params Object which contains all tx data
|
|
839
|
-
* @return {Object} { ttl, nonce, fee } Object with account nonce, absolute ttl and transaction fee
|
|
840
|
-
*/
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
async function prepareTxParams(txType, _ref19) {
|
|
844
|
-
let {
|
|
845
|
-
senderId,
|
|
846
|
-
nonce: n,
|
|
847
|
-
ttl: t,
|
|
848
|
-
fee: f,
|
|
849
|
-
gas,
|
|
850
|
-
absoluteTtl,
|
|
851
|
-
vsn,
|
|
852
|
-
strategy
|
|
853
|
-
} = _ref19;
|
|
854
|
-
n = n || (await this.api.getAccountNextNonce(senderId, {
|
|
855
|
-
strategy
|
|
856
|
-
}).catch(e => ({
|
|
857
|
-
nextNonce: 1
|
|
858
|
-
}))).nextNonce;
|
|
859
|
-
const ttl = await calculateTtl.call(this, t, !absoluteTtl);
|
|
860
|
-
const fee = calculateFee(f, txType, {
|
|
861
|
-
showWarning: this.showWarning,
|
|
862
|
-
gas,
|
|
863
|
-
params: { ...arguments[1],
|
|
864
|
-
nonce: n,
|
|
865
|
-
ttl
|
|
866
|
-
},
|
|
867
|
-
vsn
|
|
868
|
-
});
|
|
869
|
-
return {
|
|
870
|
-
fee,
|
|
871
|
-
ttl,
|
|
872
|
-
nonce: n
|
|
873
|
-
};
|
|
874
|
-
}
|
|
875
|
-
/**
|
|
876
|
-
* Transaction Stamp
|
|
877
|
-
*
|
|
878
|
-
* This is implementation of [Tx](api/tx.md) relays
|
|
879
|
-
* the creation of transactions to {@link module:@aeternity/aepp-sdk/es/Node}.
|
|
880
|
-
* This stamp provide ability to create native transaction's,
|
|
881
|
-
* or transaction's using Node API.
|
|
882
|
-
* As there is no built-in security between Node and client communication,
|
|
883
|
-
* creating transaction using {@link module:@aeternity/aepp-sdk/es/Node} API
|
|
884
|
-
* must never be used for production but can be very useful to verify other
|
|
885
|
-
* implementations.
|
|
886
|
-
* @function
|
|
887
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/tx
|
|
888
|
-
* @rtype Stamp
|
|
889
|
-
* @param {Object} [options={}] - Initializer object
|
|
890
|
-
* @param {Boolean} [options.nativeMode=true] options.nativeMode - Use Native build of transaction's
|
|
891
|
-
* @param {String} options.url - Node url
|
|
892
|
-
* @param {String} options.internalUrl - Node internal url
|
|
893
|
-
* @return {Object} Transaction instance
|
|
894
|
-
* @example Transaction({url: 'https://testnet.aeternity.io/'})
|
|
895
|
-
*/
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
const Transaction = ChainNode.compose(Tx, {
|
|
899
|
-
init(_ref20) {
|
|
900
|
-
let {
|
|
901
|
-
nativeMode = true,
|
|
902
|
-
showWarning = false
|
|
903
|
-
} = _ref20;
|
|
904
|
-
this.nativeMode = nativeMode;
|
|
905
|
-
this.showWarning = showWarning;
|
|
906
|
-
},
|
|
907
|
-
|
|
908
|
-
props: {
|
|
909
|
-
nativeMode: true,
|
|
910
|
-
showWarning: false
|
|
911
|
-
},
|
|
912
|
-
methods: {
|
|
913
|
-
spendTx,
|
|
914
|
-
namePreclaimTx,
|
|
915
|
-
nameClaimTx,
|
|
916
|
-
nameTransferTx,
|
|
917
|
-
nameUpdateTx,
|
|
918
|
-
nameRevokeTx,
|
|
919
|
-
contractCreateTx,
|
|
920
|
-
contractCallTx,
|
|
921
|
-
prepareTxParams,
|
|
922
|
-
oracleRegisterTx,
|
|
923
|
-
oracleExtendTx,
|
|
924
|
-
oraclePostQueryTx,
|
|
925
|
-
oracleRespondTx,
|
|
926
|
-
channelCloseSoloTx,
|
|
927
|
-
channelSlashTx,
|
|
928
|
-
channelSettleTx,
|
|
929
|
-
channelSnapshotSoloTx,
|
|
930
|
-
gaAttachTx,
|
|
931
|
-
payingForTx,
|
|
932
|
-
getAccountNonce,
|
|
933
|
-
getVmVersion
|
|
934
|
-
}
|
|
935
|
-
});
|
|
936
|
-
export default Transaction;
|
|
937
|
-
//# sourceMappingURL=tx.js.map
|