@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/chain/index.js
DELETED
|
@@ -1,256 +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
|
-
* Chain module
|
|
20
|
-
* @module @aeternity/aepp-sdk/es/chain
|
|
21
|
-
* @export Chain
|
|
22
|
-
* @example import { Chain } from '@aeternity/aepp-sdk'
|
|
23
|
-
*/
|
|
24
|
-
import stampit from '@stamp/it';
|
|
25
|
-
import { required } from '@stamp/required';
|
|
26
|
-
/**
|
|
27
|
-
* Basic Chain Stamp
|
|
28
|
-
*
|
|
29
|
-
* Attempting to create instances from the Stamp without overwriting all
|
|
30
|
-
* abstract methods using composition will result in an exception.
|
|
31
|
-
* @function
|
|
32
|
-
* @alias module:@aeternity/aepp-sdk/es/chain
|
|
33
|
-
* @rtype Stamp
|
|
34
|
-
* @param {Object} [options={}] - Initializer object
|
|
35
|
-
* @return {Object} Chain instance
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
const Chain = stampit({
|
|
39
|
-
deepProps: {
|
|
40
|
-
Ae: {
|
|
41
|
-
defaults: {
|
|
42
|
-
waitMined: true,
|
|
43
|
-
verify: true
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}, required({
|
|
48
|
-
methods: {
|
|
49
|
-
sendTransaction: required,
|
|
50
|
-
height: required,
|
|
51
|
-
awaitHeight: required,
|
|
52
|
-
topBlock: required,
|
|
53
|
-
poll: required,
|
|
54
|
-
balance: required,
|
|
55
|
-
getBalance: required,
|
|
56
|
-
tx: required,
|
|
57
|
-
getTxInfo: required,
|
|
58
|
-
mempool: required,
|
|
59
|
-
txDryRun: required,
|
|
60
|
-
getAccount: required
|
|
61
|
-
}
|
|
62
|
-
}));
|
|
63
|
-
/**
|
|
64
|
-
* Submit a signed transaction for mining
|
|
65
|
-
* @function sendTransaction
|
|
66
|
-
* @instance
|
|
67
|
-
* @abstract
|
|
68
|
-
* @category async
|
|
69
|
-
* @rtype (tx: String, options?: Object) => tx: Promise[Object]|txHash: Promise[String]
|
|
70
|
-
* @param {String} tx - Transaction to submit
|
|
71
|
-
* @param {String} [options={}] - Options to pass to the implementation
|
|
72
|
-
* @param {String} [options.verify=true] - Verify transaction before broadcast.
|
|
73
|
-
* @return {Object} Transaction
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Obtain current height of the chain
|
|
78
|
-
* @function height
|
|
79
|
-
* @instance
|
|
80
|
-
* @abstract
|
|
81
|
-
* @category async
|
|
82
|
-
* @rtype () => height: Number
|
|
83
|
-
* @return {Number} Current chain height
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Wait for the chain to reach a specific height
|
|
88
|
-
* @function awaitHeight
|
|
89
|
-
* @instance
|
|
90
|
-
* @abstract
|
|
91
|
-
* @category async
|
|
92
|
-
* @rtype (height: Number, options?: Object) => height: Number
|
|
93
|
-
* @param {Object} [options={}] - Options
|
|
94
|
-
* @param {Number} options.interval - Interval (in ms) at which to poll the chain
|
|
95
|
-
* @param {Number} options.attempts - Number of polling attempts after which to fail
|
|
96
|
-
* @return {Number} Current chain height
|
|
97
|
-
*/
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Wait for a transaction to be mined
|
|
101
|
-
* @function poll
|
|
102
|
-
* @instance
|
|
103
|
-
* @abstract
|
|
104
|
-
* @category async
|
|
105
|
-
* @rtype (th: String, options?: Object) => tx: Object
|
|
106
|
-
* @param {Object} [options={}] - Options
|
|
107
|
-
* @param {Number} options.interval - Interval (in ms) at which to poll the chain
|
|
108
|
-
* @param {Number} options.blocks - Number of blocks mined after which to fail
|
|
109
|
-
* @return {Object} The transaction as it was mined
|
|
110
|
-
*/
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Request the balance of specified account
|
|
114
|
-
* @function balance
|
|
115
|
-
* @instance
|
|
116
|
-
* @abstract
|
|
117
|
-
* @category async
|
|
118
|
-
* @rtype (address: String, options?: Object) => balance: Number
|
|
119
|
-
* @param {String} address - The public account address to obtain the balance for
|
|
120
|
-
* @param {Object} [options={}] - Options
|
|
121
|
-
* @param {Number} options.height - The chain height at which to obtain the balance for (default:
|
|
122
|
-
* top of chain)
|
|
123
|
-
* @param {String} options.hash - The block hash on which to obtain the balance for (default: top
|
|
124
|
-
* of chain)
|
|
125
|
-
* @return {Object} The transaction as it was mined
|
|
126
|
-
*/
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Obtain a transaction based on its hash
|
|
130
|
-
* @function tx
|
|
131
|
-
* @instance
|
|
132
|
-
* @abstract
|
|
133
|
-
* @category async
|
|
134
|
-
* @rtype (hash: String, info = false) => tx: Object
|
|
135
|
-
* @param {String} hash - Transaction hash
|
|
136
|
-
* @param {Boolean} info - Retrieve additional transaction date. Works only for (ContractCreate and
|
|
137
|
-
* ContractCall transaction's)
|
|
138
|
-
* @return {Object} Transaction
|
|
139
|
-
*/
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Obtain a transaction info based on its hash
|
|
143
|
-
* @function getTxInfo
|
|
144
|
-
* @instance
|
|
145
|
-
* @abstract
|
|
146
|
-
* @category async
|
|
147
|
-
* @rtype (hash: String) => tx: Object
|
|
148
|
-
* @param {String} hash - Transaction hash
|
|
149
|
-
* @return {Object} Transaction
|
|
150
|
-
*/
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Obtain transaction's from mempool
|
|
154
|
-
* @function mempool
|
|
155
|
-
* @instance
|
|
156
|
-
* @abstract
|
|
157
|
-
* @category async
|
|
158
|
-
* @rtype () => txs: [...Object]
|
|
159
|
-
* @return {Object[]} Transactions
|
|
160
|
-
*/
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Obtain current generation
|
|
164
|
-
* @function getCurrentGeneration
|
|
165
|
-
* @instance
|
|
166
|
-
* @abstract
|
|
167
|
-
* @category async
|
|
168
|
-
* @rtype () => generation: Object
|
|
169
|
-
* @return {Object} Current Generation
|
|
170
|
-
*/
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Get generation by hash or height
|
|
174
|
-
* @function getGeneration
|
|
175
|
-
* @instance
|
|
176
|
-
* @abstract
|
|
177
|
-
* @category async
|
|
178
|
-
* @rtype (hashOrHeight) => generation: Object
|
|
179
|
-
* @param {String|Number} hashOrHeight - Generation hash or height
|
|
180
|
-
* @return {Object} Generation
|
|
181
|
-
*/
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Wait for transaction confirmation
|
|
185
|
-
* @function waitForTxConfirm
|
|
186
|
-
* @instance
|
|
187
|
-
* @abstract
|
|
188
|
-
* @category async
|
|
189
|
-
* @rtype (txHash: String, { confirm: Number | Boolean } = { confirm: 3 }) => Promise<Number>
|
|
190
|
-
* @param {String} txHash - Transaction hash
|
|
191
|
-
* @param {Object} [options] - options
|
|
192
|
-
* @param {Number} [options.confirm=3] - Number of blocks to wait for transaction confirmation
|
|
193
|
-
* @return {Promise<Number>} Current Height
|
|
194
|
-
*/
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Get micro block transactions
|
|
198
|
-
* @function getMicroBlockTransactions
|
|
199
|
-
* @instance
|
|
200
|
-
* @abstract
|
|
201
|
-
* @category async
|
|
202
|
-
* @rtype (hash) => txs: [...Object]
|
|
203
|
-
* @return {Object[]} Transactions
|
|
204
|
-
*/
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Get key block
|
|
208
|
-
* @function getKeyBlock
|
|
209
|
-
* @instance
|
|
210
|
-
* @abstract
|
|
211
|
-
* @category async
|
|
212
|
-
* @rtype (hashOrHeight) => keyBlock: Object
|
|
213
|
-
* @return {Object} Key Block
|
|
214
|
-
*/
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Get micro block header
|
|
218
|
-
* @function getMicroBlockHeader
|
|
219
|
-
* @instance
|
|
220
|
-
* @abstract
|
|
221
|
-
* @category async
|
|
222
|
-
* @rtype (hash) => header: Object
|
|
223
|
-
* @return {Object} Micro block header
|
|
224
|
-
*/
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Get account by account public key
|
|
228
|
-
* @function getAccount
|
|
229
|
-
* @instance
|
|
230
|
-
* @abstract
|
|
231
|
-
* @category async
|
|
232
|
-
* @rtype (address, { hash, height }) => account: Object
|
|
233
|
-
* @param {String} address - Account public key
|
|
234
|
-
* @param {Object} [options={}] - Options
|
|
235
|
-
* @param {Number} [options.height] - Get account on specific block by block height
|
|
236
|
-
* @param {String} [options.hash] - Get account on specific block by block hash
|
|
237
|
-
* @return {Object} Account
|
|
238
|
-
*/
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Transaction dry-run
|
|
242
|
-
* @function txDryRun
|
|
243
|
-
* @instance
|
|
244
|
-
* @abstract
|
|
245
|
-
* @category async
|
|
246
|
-
* @rtype (tx, accountAddress, options) => result: Object
|
|
247
|
-
* @param {String} tx - transaction to execute
|
|
248
|
-
* @param {String} accountAddress - address that will be used to execute transaction
|
|
249
|
-
* @param {String|Number} [options.top] - hash of block on which to make dry-run
|
|
250
|
-
* @param {Boolean} [options.txEvents] - collect and return on-chain tx events that would result
|
|
251
|
-
* from the call
|
|
252
|
-
* @return {Object} Result
|
|
253
|
-
*/
|
|
254
|
-
|
|
255
|
-
export default Chain;
|
|
256
|
-
//# sourceMappingURL=index.js.map
|
package/es/chain/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/chain/index.js"],"names":["stampit","required","Chain","deepProps","Ae","defaults","waitMined","verify","methods","sendTransaction","height","awaitHeight","topBlock","poll","balance","getBalance","tx","getTxInfo","mempool","txDryRun","getAccount"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,OAAP,MAAoB,WAApB;AACA,SAASC,QAAT,QAAyB,iBAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,KAAK,GAAGF,OAAO,CAAC;AACpBG,EAAAA,SAAS,EAAE;AAAEC,IAAAA,EAAE,EAAE;AAAEC,MAAAA,QAAQ,EAAE;AAAEC,QAAAA,SAAS,EAAE,IAAb;AAAmBC,QAAAA,MAAM,EAAE;AAA3B;AAAZ;AAAN;AADS,CAAD,EAElBN,QAAQ,CAAC;AACVO,EAAAA,OAAO,EAAE;AACPC,IAAAA,eAAe,EAAER,QADV;AAEPS,IAAAA,MAAM,EAAET,QAFD;AAGPU,IAAAA,WAAW,EAAEV,QAHN;AAIPW,IAAAA,QAAQ,EAAEX,QAJH;AAKPY,IAAAA,IAAI,EAAEZ,QALC;AAMPa,IAAAA,OAAO,EAAEb,QANF;AAOPc,IAAAA,UAAU,EAAEd,QAPL;AAQPe,IAAAA,EAAE,EAAEf,QARG;AASPgB,IAAAA,SAAS,EAAEhB,QATJ;AAUPiB,IAAAA,OAAO,EAAEjB,QAVF;AAWPkB,IAAAA,QAAQ,EAAElB,QAXH;AAYPmB,IAAAA,UAAU,EAAEnB;AAZL;AADC,CAAD,CAFU,CAArB;AAmBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAeC,KAAf","sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2018 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * Chain module\n * @module @aeternity/aepp-sdk/es/chain\n * @export Chain\n * @example import { Chain } from '@aeternity/aepp-sdk'\n */\n\nimport stampit from '@stamp/it'\nimport { required } from '@stamp/required'\n\n/**\n * Basic Chain Stamp\n *\n * Attempting to create instances from the Stamp without overwriting all\n * abstract methods using composition will result in an exception.\n * @function\n * @alias module:@aeternity/aepp-sdk/es/chain\n * @rtype Stamp\n * @param {Object} [options={}] - Initializer object\n * @return {Object} Chain instance\n */\nconst Chain = stampit({\n deepProps: { Ae: { defaults: { waitMined: true, verify: true } } }\n}, required({\n methods: {\n sendTransaction: required,\n height: required,\n awaitHeight: required,\n topBlock: required,\n poll: required,\n balance: required,\n getBalance: required,\n tx: required,\n getTxInfo: required,\n mempool: required,\n txDryRun: required,\n getAccount: required\n }\n}))\n\n/**\n * Submit a signed transaction for mining\n * @function sendTransaction\n * @instance\n * @abstract\n * @category async\n * @rtype (tx: String, options?: Object) => tx: Promise[Object]|txHash: Promise[String]\n * @param {String} tx - Transaction to submit\n * @param {String} [options={}] - Options to pass to the implementation\n * @param {String} [options.verify=true] - Verify transaction before broadcast.\n * @return {Object} Transaction\n */\n\n/**\n * Obtain current height of the chain\n * @function height\n * @instance\n * @abstract\n * @category async\n * @rtype () => height: Number\n * @return {Number} Current chain height\n */\n\n/**\n * Wait for the chain to reach a specific height\n * @function awaitHeight\n * @instance\n * @abstract\n * @category async\n * @rtype (height: Number, options?: Object) => height: Number\n * @param {Object} [options={}] - Options\n * @param {Number} options.interval - Interval (in ms) at which to poll the chain\n * @param {Number} options.attempts - Number of polling attempts after which to fail\n * @return {Number} Current chain height\n */\n\n/**\n * Wait for a transaction to be mined\n * @function poll\n * @instance\n * @abstract\n * @category async\n * @rtype (th: String, options?: Object) => tx: Object\n * @param {Object} [options={}] - Options\n * @param {Number} options.interval - Interval (in ms) at which to poll the chain\n * @param {Number} options.blocks - Number of blocks mined after which to fail\n * @return {Object} The transaction as it was mined\n */\n\n/**\n * Request the balance of specified account\n * @function balance\n * @instance\n * @abstract\n * @category async\n * @rtype (address: String, options?: Object) => balance: Number\n * @param {String} address - The public account address to obtain the balance for\n * @param {Object} [options={}] - Options\n * @param {Number} options.height - The chain height at which to obtain the balance for (default:\n * top of chain)\n * @param {String} options.hash - The block hash on which to obtain the balance for (default: top\n * of chain)\n * @return {Object} The transaction as it was mined\n */\n\n/**\n * Obtain a transaction based on its hash\n * @function tx\n * @instance\n * @abstract\n * @category async\n * @rtype (hash: String, info = false) => tx: Object\n * @param {String} hash - Transaction hash\n * @param {Boolean} info - Retrieve additional transaction date. Works only for (ContractCreate and\n * ContractCall transaction's)\n * @return {Object} Transaction\n */\n\n/**\n * Obtain a transaction info based on its hash\n * @function getTxInfo\n * @instance\n * @abstract\n * @category async\n * @rtype (hash: String) => tx: Object\n * @param {String} hash - Transaction hash\n * @return {Object} Transaction\n */\n\n/**\n * Obtain transaction's from mempool\n * @function mempool\n * @instance\n * @abstract\n * @category async\n * @rtype () => txs: [...Object]\n * @return {Object[]} Transactions\n */\n\n/**\n * Obtain current generation\n * @function getCurrentGeneration\n * @instance\n * @abstract\n * @category async\n * @rtype () => generation: Object\n * @return {Object} Current Generation\n */\n\n/**\n * Get generation by hash or height\n * @function getGeneration\n * @instance\n * @abstract\n * @category async\n * @rtype (hashOrHeight) => generation: Object\n * @param {String|Number} hashOrHeight - Generation hash or height\n * @return {Object} Generation\n */\n\n/**\n * Wait for transaction confirmation\n * @function waitForTxConfirm\n * @instance\n * @abstract\n * @category async\n * @rtype (txHash: String, { confirm: Number | Boolean } = { confirm: 3 }) => Promise<Number>\n * @param {String} txHash - Transaction hash\n * @param {Object} [options] - options\n * @param {Number} [options.confirm=3] - Number of blocks to wait for transaction confirmation\n * @return {Promise<Number>} Current Height\n */\n\n/**\n * Get micro block transactions\n * @function getMicroBlockTransactions\n * @instance\n * @abstract\n * @category async\n * @rtype (hash) => txs: [...Object]\n * @return {Object[]} Transactions\n */\n\n/**\n * Get key block\n * @function getKeyBlock\n * @instance\n * @abstract\n * @category async\n * @rtype (hashOrHeight) => keyBlock: Object\n * @return {Object} Key Block\n */\n\n/**\n * Get micro block header\n * @function getMicroBlockHeader\n * @instance\n * @abstract\n * @category async\n * @rtype (hash) => header: Object\n * @return {Object} Micro block header\n */\n\n/**\n * Get account by account public key\n * @function getAccount\n * @instance\n * @abstract\n * @category async\n * @rtype (address, { hash, height }) => account: Object\n * @param {String} address - Account public key\n * @param {Object} [options={}] - Options\n * @param {Number} [options.height] - Get account on specific block by block height\n * @param {String} [options.hash] - Get account on specific block by block hash\n * @return {Object} Account\n */\n\n/**\n * Transaction dry-run\n * @function txDryRun\n * @instance\n * @abstract\n * @category async\n * @rtype (tx, accountAddress, options) => result: Object\n * @param {String} tx - transaction to execute\n * @param {String} accountAddress - address that will be used to execute transaction\n * @param {String|Number} [options.top] - hash of block on which to make dry-run\n * @param {Boolean} [options.txEvents] - collect and return on-chain tx events that would result\n * from the call\n * @return {Object} Result\n */\n\nexport default Chain\n"],"file":"index.js"}
|
package/es/chain/node.js
DELETED
|
@@ -1,394 +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
|
-
import Chain from './';
|
|
18
|
-
import { AE_AMOUNT_FORMATS, formatAmount } from '../utils/amount-formatter';
|
|
19
|
-
import verifyTransaction from '../tx/validator';
|
|
20
|
-
import NodePool from '../node-pool';
|
|
21
|
-
import { pause } from '../utils/other';
|
|
22
|
-
import { isNameValid, produceNameId, decode } from '../tx/builder/helpers';
|
|
23
|
-
import { DRY_RUN_ACCOUNT } from '../tx/builder/schema';
|
|
24
|
-
/**
|
|
25
|
-
* ChainNode module
|
|
26
|
-
*
|
|
27
|
-
* This is the complement to {@link module:@aeternity/aepp-sdk/es/chain}.
|
|
28
|
-
* @module @aeternity/aepp-sdk/es/chain/node
|
|
29
|
-
* @export ChainNode
|
|
30
|
-
* @example import { ChainNode } from '@aeternity/aepp-sdk'
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
async function sendTransaction(tx) {
|
|
34
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
35
|
-
const {
|
|
36
|
-
waitMined,
|
|
37
|
-
verify
|
|
38
|
-
} = { ...this.Ae.defaults,
|
|
39
|
-
...options
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
if (verify) {
|
|
43
|
-
const validation = await verifyTransaction(tx, this.selectedNode.instance);
|
|
44
|
-
|
|
45
|
-
if (validation.length) {
|
|
46
|
-
const message = 'Transaction verification errors: ' + validation.map(v => v.message).join(', ');
|
|
47
|
-
throw Object.assign(new Error(message), {
|
|
48
|
-
code: 'TX_VERIFICATION_ERROR',
|
|
49
|
-
validation,
|
|
50
|
-
transaction: tx
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
const {
|
|
57
|
-
txHash
|
|
58
|
-
} = await this.api.postTransaction({
|
|
59
|
-
tx
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
if (waitMined) {
|
|
63
|
-
const txData = { ...(await this.poll(txHash, options)),
|
|
64
|
-
rawTx: tx
|
|
65
|
-
}; // wait for transaction confirmation
|
|
66
|
-
|
|
67
|
-
if (options.confirm) {
|
|
68
|
-
return { ...txData,
|
|
69
|
-
confirmationHeight: await this.waitForTxConfirm(txHash, options)
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return txData;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
hash: txHash,
|
|
78
|
-
rawTx: tx
|
|
79
|
-
};
|
|
80
|
-
} catch (error) {
|
|
81
|
-
throw Object.assign(error, {
|
|
82
|
-
rawTx: tx,
|
|
83
|
-
verifyTx: () => verifyTransaction(tx, this.selectedNode.instance)
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async function waitForTxConfirm(txHash) {
|
|
89
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
90
|
-
confirm: 3
|
|
91
|
-
};
|
|
92
|
-
options.confirm = options.confirm === true ? 3 : options.confirm;
|
|
93
|
-
const {
|
|
94
|
-
blockHeight
|
|
95
|
-
} = await this.tx(txHash);
|
|
96
|
-
const height = await this.awaitHeight(blockHeight + options.confirm, options);
|
|
97
|
-
const {
|
|
98
|
-
blockHeight: newBlockHeight
|
|
99
|
-
} = await this.tx(txHash);
|
|
100
|
-
|
|
101
|
-
switch (newBlockHeight) {
|
|
102
|
-
case -1:
|
|
103
|
-
throw new Error(`Transaction ${txHash} is removed from chain`);
|
|
104
|
-
|
|
105
|
-
case blockHeight:
|
|
106
|
-
return height;
|
|
107
|
-
|
|
108
|
-
default:
|
|
109
|
-
return waitForTxConfirm(txHash, options);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async function getAccount(address) {
|
|
114
|
-
let {
|
|
115
|
-
height,
|
|
116
|
-
hash
|
|
117
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
118
|
-
if (height) return this.api.getAccountByPubkeyAndHeight(address, height);
|
|
119
|
-
if (hash) return this.api.getAccountByPubkeyAndHash(address, hash);
|
|
120
|
-
return this.api.getAccountByPubkey(address);
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* @function
|
|
124
|
-
* @deprecated
|
|
125
|
-
*/
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
async function balance(address) {
|
|
129
|
-
let {
|
|
130
|
-
height,
|
|
131
|
-
hash,
|
|
132
|
-
format = AE_AMOUNT_FORMATS.AETTOS
|
|
133
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
134
|
-
const {
|
|
135
|
-
balance
|
|
136
|
-
} = await this.getAccount(address, {
|
|
137
|
-
hash,
|
|
138
|
-
height
|
|
139
|
-
});
|
|
140
|
-
return formatAmount(balance, {
|
|
141
|
-
targetDenomination: format
|
|
142
|
-
}).toString();
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
async function getBalance(address) {
|
|
146
|
-
let {
|
|
147
|
-
height,
|
|
148
|
-
hash,
|
|
149
|
-
format = AE_AMOUNT_FORMATS.AETTOS
|
|
150
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
151
|
-
const {
|
|
152
|
-
balance
|
|
153
|
-
} = await this.getAccount(address, {
|
|
154
|
-
hash,
|
|
155
|
-
height
|
|
156
|
-
}).catch(_ => ({
|
|
157
|
-
balance: 0
|
|
158
|
-
}));
|
|
159
|
-
return formatAmount(balance, {
|
|
160
|
-
targetDenomination: format
|
|
161
|
-
}).toString();
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
async function tx(hash) {
|
|
165
|
-
let info = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
166
|
-
const tx = await this.api.getTransactionByHash(hash);
|
|
167
|
-
|
|
168
|
-
if (['ContractCreateTx', 'ContractCallTx', 'ChannelForceProgressTx'].includes(tx.tx.type) && info && tx.blockHeight !== -1) {
|
|
169
|
-
try {
|
|
170
|
-
return { ...tx,
|
|
171
|
-
...(await this.getTxInfo(hash))
|
|
172
|
-
};
|
|
173
|
-
} catch (e) {}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return tx;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
async function height() {
|
|
180
|
-
try {
|
|
181
|
-
if (!this._heightPromise) {
|
|
182
|
-
this._heightPromise = this.api.getCurrentKeyBlockHeight();
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return (await this._heightPromise).height;
|
|
186
|
-
} finally {
|
|
187
|
-
delete this._heightPromise;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
async function awaitHeight(height) {
|
|
192
|
-
let {
|
|
193
|
-
interval = 5000,
|
|
194
|
-
attempts = 20
|
|
195
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
196
|
-
let currentHeight;
|
|
197
|
-
|
|
198
|
-
for (let i = 0; i < attempts; i++) {
|
|
199
|
-
if (i) await pause(interval);
|
|
200
|
-
currentHeight = await this.height();
|
|
201
|
-
if (currentHeight >= height) return currentHeight;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
throw new Error(`Giving up after ${(attempts - 1) * interval}ms, current height: ${currentHeight}, desired height: ${height}`);
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* @deprecated
|
|
208
|
-
*/
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
async function topBlock() {
|
|
212
|
-
return this.api.getTopHeader();
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
async function poll(th) {
|
|
216
|
-
let {
|
|
217
|
-
blocks = 10,
|
|
218
|
-
interval = 500,
|
|
219
|
-
allowUnsynced = false
|
|
220
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
221
|
-
const max = (await this.height()) + blocks;
|
|
222
|
-
|
|
223
|
-
do {
|
|
224
|
-
const tx = await this.tx(th).catch(_ => null);
|
|
225
|
-
|
|
226
|
-
if (tx && (tx.blockHeight !== -1 || allowUnsynced && tx.height)) {
|
|
227
|
-
return tx;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
await pause(interval);
|
|
231
|
-
} while ((await this.height()) < max);
|
|
232
|
-
|
|
233
|
-
throw new Error(`Giving up after ${blocks} blocks mined, transaction hash: ${th}`);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
async function getTxInfo(hash) {
|
|
237
|
-
const result = await this.api.getTransactionInfoByHash(hash);
|
|
238
|
-
return result.callInfo || result;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
async function mempool() {
|
|
242
|
-
return this.api.getPendingTransactions();
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
async function getCurrentGeneration() {
|
|
246
|
-
return this.api.getCurrentGeneration();
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
async function getGeneration(hashOrHeight) {
|
|
250
|
-
if (typeof hashOrHeight === 'string') return this.api.getGenerationByHash(hashOrHeight);
|
|
251
|
-
if (typeof hashOrHeight === 'number') return this.api.getGenerationByHeight(hashOrHeight);
|
|
252
|
-
throw new Error('Invalid param, param must be hash or height');
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
async function getMicroBlockTransactions(hash) {
|
|
256
|
-
return (await this.api.getMicroBlockTransactionsByHash(hash)).transactions;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
async function getKeyBlock(hashOrHeight) {
|
|
260
|
-
if (typeof hashOrHeight === 'string') return this.api.getKeyBlockByHash(hashOrHeight);
|
|
261
|
-
if (typeof hashOrHeight === 'number') return this.api.getKeyBlockByHeight(hashOrHeight);
|
|
262
|
-
throw new Error('Invalid param, param must be hash or height');
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
async function getMicroBlockHeader(hash) {
|
|
266
|
-
return this.api.getMicroBlockHeaderByHash(hash);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
async function txDryRun(tx, accountAddress, options) {
|
|
270
|
-
const {
|
|
271
|
-
results: [{
|
|
272
|
-
result,
|
|
273
|
-
reason,
|
|
274
|
-
...resultPayload
|
|
275
|
-
}],
|
|
276
|
-
...other
|
|
277
|
-
} = await this.api.protectedDryRunTxs({ ...options,
|
|
278
|
-
txs: [{
|
|
279
|
-
tx
|
|
280
|
-
}],
|
|
281
|
-
accounts: [{
|
|
282
|
-
pubKey: accountAddress,
|
|
283
|
-
amount: DRY_RUN_ACCOUNT.amount
|
|
284
|
-
}]
|
|
285
|
-
});
|
|
286
|
-
if (result === 'ok') return { ...resultPayload,
|
|
287
|
-
...other
|
|
288
|
-
};
|
|
289
|
-
throw Object.assign(new Error('Dry run error, ' + reason), {
|
|
290
|
-
tx,
|
|
291
|
-
accountAddress,
|
|
292
|
-
options
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
async function getContractByteCode(contractId) {
|
|
297
|
-
return this.api.getContractCode(contractId);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
async function getContract(contractId) {
|
|
301
|
-
return this.api.getContract(contractId);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
async function getName(name) {
|
|
305
|
-
return this.api.getNameEntryByName(name);
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Resolve AENS name and return name hash
|
|
309
|
-
* @param {String} nameOrId
|
|
310
|
-
* @param {String} key in AENS pointers record
|
|
311
|
-
* @param {Object} [options]
|
|
312
|
-
* @param {Boolean} [options.verify] To ensure that name exist and have a corresponding pointer
|
|
313
|
-
* // TODO: avoid that to don't trust to current api gateway
|
|
314
|
-
* @param {Boolean} [options.resolveByNode] Enables pointer resolving using node
|
|
315
|
-
* @return {String} Address or AENS name hash
|
|
316
|
-
*/
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
async function resolveName(nameOrId, key) {
|
|
320
|
-
let {
|
|
321
|
-
verify,
|
|
322
|
-
resolveByNode
|
|
323
|
-
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
324
|
-
|
|
325
|
-
if (!nameOrId || typeof nameOrId !== 'string') {
|
|
326
|
-
throw new Error(`Name or address should be a string: ${nameOrId}`);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
try {
|
|
330
|
-
decode(nameOrId);
|
|
331
|
-
return nameOrId;
|
|
332
|
-
} catch (error) {}
|
|
333
|
-
|
|
334
|
-
if (isNameValid(nameOrId)) {
|
|
335
|
-
if (verify || resolveByNode) {
|
|
336
|
-
const name = await this.api.getNameEntryByName(nameOrId).catch(_ => null);
|
|
337
|
-
if (!name) throw new Error(`Name not found: ${nameOrId}`);
|
|
338
|
-
const pointer = name.pointers.find(pointer => pointer.key === key);
|
|
339
|
-
|
|
340
|
-
if (!pointer) {
|
|
341
|
-
throw new Error(`Name ${nameOrId} don't have pointers for ${key}`);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
if (resolveByNode) return pointer.id;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
return produceNameId(nameOrId);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
throw new Error(`Invalid name or address: ${nameOrId}`);
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* ChainNode Stamp
|
|
354
|
-
*
|
|
355
|
-
* This is implementation of {@link module:@aeternity/aepp-sdk/es/chain--Chain}
|
|
356
|
-
* composed with {@link module:@aeternity/aepp-sdk/es/contract/node--ContractNodeAPI} and
|
|
357
|
-
* {@link module:@aeternity/aepp-sdk/es/oracle/node--OracleNodeAPI}
|
|
358
|
-
* @function
|
|
359
|
-
* @alias module:@aeternity/aepp-sdk/es/chain/node
|
|
360
|
-
* @rtype Stamp
|
|
361
|
-
* @param {Object} [options={}] - Initializer object
|
|
362
|
-
* @return {Object} ChainNode instance
|
|
363
|
-
* @example ChainNode({url: 'https://testnet.aeternity.io/'})
|
|
364
|
-
*/
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
const ChainNode = Chain.compose(NodePool, {
|
|
368
|
-
methods: {
|
|
369
|
-
sendTransaction,
|
|
370
|
-
balance,
|
|
371
|
-
getBalance,
|
|
372
|
-
getAccount,
|
|
373
|
-
topBlock,
|
|
374
|
-
tx,
|
|
375
|
-
height,
|
|
376
|
-
awaitHeight,
|
|
377
|
-
poll,
|
|
378
|
-
getTxInfo,
|
|
379
|
-
mempool,
|
|
380
|
-
getCurrentGeneration,
|
|
381
|
-
getGeneration,
|
|
382
|
-
getMicroBlockHeader,
|
|
383
|
-
getMicroBlockTransactions,
|
|
384
|
-
getKeyBlock,
|
|
385
|
-
txDryRun,
|
|
386
|
-
getContractByteCode,
|
|
387
|
-
getContract,
|
|
388
|
-
getName,
|
|
389
|
-
waitForTxConfirm,
|
|
390
|
-
resolveName
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
export default ChainNode;
|
|
394
|
-
//# sourceMappingURL=node.js.map
|