@aeternity/aepp-sdk 11.0.1 → 12.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -22
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +2 -1
- package/dist/aepp-sdk.browser.js.LICENSE.txt +1 -0
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +20765 -1
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdk.d.ts +37 -0
- package/es/AeSdk.mjs +81 -0
- package/es/AeSdk.mjs.map +1 -0
- package/es/AeSdkAepp.d.ts +70 -0
- package/es/AeSdkAepp.mjs +176 -0
- package/es/AeSdkAepp.mjs.map +1 -0
- package/es/AeSdkBase.d.ts +213 -0
- package/es/AeSdkBase.mjs +314 -0
- package/es/AeSdkBase.mjs.map +1 -0
- package/es/AeSdkWallet.d.ts +104 -0
- package/es/AeSdkWallet.mjs +326 -0
- package/es/AeSdkWallet.mjs.map +1 -0
- package/es/Node.d.ts +41 -0
- package/es/Node.mjs +147 -0
- package/es/Node.mjs.map +1 -0
- package/es/account/Base.d.ts +68 -0
- package/es/account/Base.mjs +123 -0
- package/es/account/Base.mjs.map +1 -0
- package/es/account/Memory.d.ts +26 -0
- package/es/account/Memory.mjs +103 -0
- package/es/account/Memory.mjs.map +1 -0
- package/es/account/Rpc.d.ts +27 -0
- package/es/account/Rpc.mjs +80 -0
- package/es/account/Rpc.mjs.map +1 -0
- package/es/aens.d.ts +222 -0
- package/es/aens.mjs +338 -0
- package/es/aens.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection/Browser.d.ts +33 -0
- package/es/aepp-wallet-communication/connection/Browser.mjs +73 -0
- package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +18 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +58 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +146 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection-proxy.d.ts +11 -0
- package/{src/utils/crypto-ts.ts → es/aepp-wallet-communication/connection-proxy.mjs} +16 -11
- package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -0
- package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +169 -0
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -0
- package/es/aepp-wallet-communication/rpc/types.d.ts +77 -0
- package/es/aepp-wallet-communication/rpc/types.mjs +3 -0
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -0
- package/es/aepp-wallet-communication/schema.d.ts +105 -46
- package/es/aepp-wallet-communication/schema.mjs +251 -0
- package/es/aepp-wallet-communication/schema.mjs.map +1 -0
- package/es/aepp-wallet-communication/wallet-detector.d.ts +25 -0
- package/es/aepp-wallet-communication/wallet-detector.mjs +62 -0
- package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
- package/es/apis/compiler/compiler.d.ts +92 -0
- package/es/apis/compiler/compiler.mjs +576 -0
- package/es/apis/compiler/compiler.mjs.map +1 -0
- package/es/apis/compiler/index.d.ts +2 -0
- package/es/apis/compiler/index.mjs +3 -0
- package/es/apis/compiler/index.mjs.map +1 -0
- package/es/apis/compiler/models/index.d.ts +248 -0
- package/es/apis/compiler/models/index.mjs +48 -0
- package/es/apis/compiler/models/index.mjs.map +1 -0
- package/es/apis/compiler/models/mappers.d.ts +23 -0
- package/es/apis/compiler/models/mappers.mjs +585 -0
- package/es/apis/compiler/models/mappers.mjs.map +1 -0
- package/es/apis/compiler/models/parameters.d.ts +13 -0
- package/es/apis/compiler/models/parameters.mjs +71 -0
- package/es/apis/compiler/models/parameters.mjs.map +1 -0
- package/es/apis/node/index.d.ts +2 -0
- package/es/apis/node/index.mjs +3 -0
- package/es/apis/node/index.mjs.map +1 -0
- package/es/apis/node/models/index.d.ts +1065 -0
- package/es/apis/node/models/index.mjs +2 -0
- package/es/apis/node/models/index.mjs.map +1 -0
- package/es/apis/node/models/mappers.d.ts +95 -0
- package/es/apis/node/models/mappers.mjs +4166 -0
- package/es/apis/node/models/mappers.mjs.map +1 -0
- package/es/apis/node/models/parameters.d.ts +17 -0
- package/es/apis/node/models/parameters.mjs +165 -0
- package/es/apis/node/models/parameters.mjs.map +1 -0
- package/es/apis/node/node.d.ts +215 -0
- package/es/apis/node/node.mjs +1165 -0
- package/es/apis/node/node.mjs.map +1 -0
- package/es/chain.d.ts +248 -0
- package/es/chain.mjs +560 -0
- package/es/chain.mjs.map +1 -0
- package/es/channel/handlers.d.ts +34 -0
- package/es/channel/handlers.mjs +164 -131
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/index.d.ts +625 -0
- package/es/channel/index.mjs +897 -902
- package/es/channel/index.mjs.map +1 -1
- package/es/channel/internal.d.ts +101 -0
- package/es/channel/internal.mjs +136 -85
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Compiler.d.ts +18 -0
- package/es/contract/Compiler.mjs +68 -0
- package/es/contract/Compiler.mjs.map +1 -0
- package/es/contract/aci.d.ts +127 -0
- package/es/contract/aci.mjs +225 -193
- package/es/contract/aci.mjs.map +1 -1
- package/es/contract/ga.d.ts +69 -0
- package/es/contract/ga.mjs +195 -0
- package/es/contract/ga.mjs.map +1 -0
- package/es/contract/methods.d.ts +71 -0
- package/es/contract/methods.mjs +104 -0
- package/es/contract/methods.mjs.map +1 -0
- package/es/deprecated/index.d.ts +143 -0
- package/es/deprecated/index.mjs +162 -0
- package/es/deprecated/index.mjs.map +1 -0
- package/es/deprecated/methods.d.ts +18 -0
- package/es/deprecated/methods.mjs +26 -0
- package/es/deprecated/methods.mjs.map +1 -0
- package/es/index.d.ts +35 -0
- package/es/index.mjs +35 -40
- package/es/index.mjs.map +1 -1
- package/es/oracle.d.ts +161 -0
- package/es/oracle.mjs +306 -0
- package/es/oracle.mjs.map +1 -0
- package/es/spend.d.ts +62 -0
- package/es/spend.mjs +111 -0
- package/es/spend.mjs.map +1 -0
- package/es/tx/builder/address.d.ts +25 -0
- package/es/tx/builder/address.mjs +45 -0
- package/es/tx/builder/address.mjs.map +1 -0
- package/es/tx/builder/constants.d.ts +70 -0
- package/es/tx/builder/constants.mjs +61 -47
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types/coin-amount.d.ts +13 -0
- package/es/tx/builder/field-types/coin-amount.mjs +26 -0
- package/es/tx/builder/field-types/coin-amount.mjs.map +1 -0
- package/es/tx/builder/field-types/deposit.d.ts +15 -0
- package/es/tx/builder/field-types/deposit.mjs +19 -0
- package/es/tx/builder/field-types/deposit.mjs.map +1 -0
- package/es/tx/builder/field-types/fee.d.ts +25 -0
- package/es/tx/builder/field-types/fee.mjs +150 -0
- package/es/tx/builder/field-types/fee.mjs.map +1 -0
- package/es/tx/builder/field-types/field.d.ts +6 -0
- package/es/tx/builder/field-types/field.mjs +15 -0
- package/es/tx/builder/field-types/field.mjs.map +1 -0
- package/es/tx/builder/field-types/gas-limit.d.ts +12 -0
- package/es/tx/builder/field-types/gas-limit.mjs +33 -0
- package/es/tx/builder/field-types/gas-limit.mjs.map +1 -0
- package/es/tx/builder/field-types/gas-price.d.ts +8 -0
- package/es/tx/builder/field-types/gas-price.mjs +18 -0
- package/es/tx/builder/field-types/gas-price.mjs.map +1 -0
- package/es/tx/builder/field-types/index.d.ts +70 -0
- package/es/tx/builder/field-types/index.mjs +25 -0
- package/es/tx/builder/field-types/index.mjs.map +1 -0
- package/es/tx/builder/field-types/name-fee.d.ts +20 -0
- package/es/tx/builder/field-types/name-fee.mjs +24 -0
- package/es/tx/builder/field-types/name-fee.mjs.map +1 -0
- package/es/tx/builder/field-types/name-id.d.ts +14 -0
- package/es/tx/builder/field-types/name-id.mjs +19 -0
- package/es/tx/builder/field-types/name-id.mjs.map +1 -0
- package/es/tx/builder/field-types/name.d.ts +13 -0
- package/es/tx/builder/field-types/name.mjs +18 -0
- package/es/tx/builder/field-types/name.mjs.map +1 -0
- package/es/tx/builder/field-types/short-u-int.d.ts +6 -0
- package/es/tx/builder/field-types/short-u-int.mjs +12 -0
- package/es/tx/builder/field-types/short-u-int.mjs.map +1 -0
- package/es/tx/builder/field-types/u-int.d.ts +8 -0
- package/es/tx/builder/field-types/u-int.mjs +14 -0
- package/es/tx/builder/field-types/u-int.mjs.map +1 -0
- package/es/tx/builder/helpers.d.ts +125 -0
- package/es/tx/builder/helpers.mjs +94 -198
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +88 -0
- package/es/tx/builder/index.mjs +167 -358
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +1201 -0
- package/es/tx/builder/schema.mjs +175 -561
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/index.d.ts +64 -0
- package/es/tx/index.mjs +151 -265
- package/es/tx/index.mjs.map +1 -1
- package/es/tx/validator.d.ts +20 -0
- package/es/tx/validator.mjs +104 -124
- package/es/tx/validator.mjs.map +1 -1
- package/es/typings/@aeternity__argon2-browser/index.d.mjs +2 -0
- package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -0
- package/es/typings/@aeternity__uuid/index.d.mjs +2 -0
- package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -0
- package/es/typings/bip32-path/index.d.mjs +2 -0
- package/es/typings/bip32-path/index.d.mjs.map +1 -0
- package/es/typings/blakejs/index.d.mjs.map +1 -1
- package/es/typings/sha-js/index.d.mjs +2 -0
- package/es/typings/sha-js/index.d.mjs.map +1 -0
- package/es/typings/tweetnacl-auth/index.d.mjs +2 -0
- package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -0
- package/es/utils/amount-formatter.d.ts +42 -0
- package/es/utils/amount-formatter.mjs +36 -49
- package/es/utils/amount-formatter.mjs.map +1 -1
- package/es/utils/autorest.d.ts +6 -0
- package/es/utils/autorest.mjs +97 -0
- package/es/utils/autorest.mjs.map +1 -0
- package/es/utils/bignumber.d.ts +13 -0
- package/es/utils/bignumber.mjs +11 -8
- package/es/utils/bignumber.mjs.map +1 -1
- package/es/{bytes.d.ts → utils/bytes.d.ts} +10 -13
- package/es/utils/bytes.mjs +11 -15
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/crypto.d.ts +88 -0
- package/es/utils/crypto.mjs +64 -98
- package/es/utils/crypto.mjs.map +1 -1
- package/es/utils/encoder-types.d.ts +61 -0
- package/es/utils/encoder-types.mjs +36 -0
- package/es/utils/encoder-types.mjs.map +1 -0
- package/es/utils/encoder.d.ts +25 -0
- package/es/utils/encoder.mjs +71 -59
- package/es/utils/encoder.mjs.map +1 -1
- package/es/{errors.d.ts → utils/errors.d.ts} +246 -59
- package/es/utils/errors.mjs +313 -136
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/hd-wallet.d.ts +50 -0
- package/es/utils/hd-wallet.mjs +86 -45
- package/es/utils/hd-wallet.mjs.map +1 -1
- package/es/utils/json-big.d.ts +5 -0
- package/es/utils/json-big.mjs +12 -16
- package/es/utils/json-big.mjs.map +1 -1
- package/es/utils/keystore.d.ts +51 -0
- package/es/utils/keystore.mjs +101 -194
- package/es/utils/keystore.mjs.map +1 -1
- package/es/{mptree.d.ts → utils/mptree.d.ts} +6 -9
- package/es/utils/mptree.mjs +22 -18
- package/es/utils/mptree.mjs.map +1 -1
- package/es/utils/other.d.ts +20 -0
- package/es/utils/other.mjs +32 -35
- package/es/utils/other.mjs.map +1 -1
- package/es/utils/semver-satisfies.d.ts +1 -0
- package/es/utils/semver-satisfies.mjs +2 -2
- package/es/utils/semver-satisfies.mjs.map +1 -1
- package/es/utils/string.d.ts +24 -0
- package/es/utils/string.mjs +8 -10
- package/es/utils/string.mjs.map +1 -1
- package/package.json +55 -43
- package/src/AeSdk.ts +68 -0
- package/src/AeSdkAepp.ts +176 -0
- package/src/AeSdkBase.ts +338 -0
- package/src/AeSdkWallet.ts +348 -0
- package/src/Node.ts +173 -0
- package/src/account/Base.ts +124 -0
- package/src/account/Memory.ts +98 -0
- package/src/account/Rpc.ts +69 -0
- package/src/aens.ts +407 -0
- package/src/aepp-wallet-communication/connection/Browser.ts +71 -0
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +59 -0
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +122 -0
- package/{es/utils/crypto-ts.mjs → src/aepp-wallet-communication/connection-proxy.ts} +18 -18
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +143 -0
- package/src/aepp-wallet-communication/rpc/types.ts +66 -0
- package/src/aepp-wallet-communication/schema.ts +224 -0
- package/src/aepp-wallet-communication/wallet-detector.ts +72 -0
- package/src/apis/compiler/code-model-v4.yaml +2649 -0
- package/src/apis/compiler/compiler.ts +585 -0
- package/src/apis/compiler/index.ts +2 -0
- package/src/apis/compiler/models/index.ts +301 -0
- package/src/apis/compiler/models/mappers.ts +583 -0
- package/src/apis/compiler/models/parameters.ts +93 -0
- package/src/apis/node/code-model-v4.yaml +10080 -0
- package/src/apis/node/index.ts +2 -0
- package/src/apis/node/models/index.ts +1257 -0
- package/src/apis/node/models/mappers.ts +4280 -0
- package/src/apis/node/models/parameters.ts +188 -0
- package/src/apis/node/node.ts +1299 -0
- package/src/chain.ts +502 -0
- package/src/channel/handlers.ts +817 -0
- package/src/channel/index.ts +1025 -0
- package/src/channel/internal.ts +361 -0
- package/src/contract/Compiler.ts +67 -0
- package/src/contract/aci.ts +538 -0
- package/src/contract/ga.ts +199 -0
- package/src/contract/methods.ts +123 -0
- package/src/deprecated/index.ts +172 -0
- package/src/deprecated/methods.ts +25 -0
- package/src/index.ts +56 -0
- package/src/oracle.ts +364 -0
- package/src/spend.ts +164 -0
- package/src/tx/builder/address.ts +50 -0
- package/src/tx/builder/constants.ts +126 -0
- package/src/tx/builder/field-types/coin-amount.ts +27 -0
- package/src/tx/builder/field-types/deposit.ts +21 -0
- package/src/tx/builder/field-types/fee.ts +143 -0
- package/src/tx/builder/field-types/field.ts +9 -0
- package/src/tx/builder/field-types/gas-limit.ts +41 -0
- package/src/tx/builder/field-types/gas-price.ts +16 -0
- package/src/tx/builder/field-types/index.ts +45 -0
- package/src/tx/builder/field-types/name-fee.ts +32 -0
- package/src/tx/builder/field-types/name-id.ts +20 -0
- package/src/tx/builder/field-types/name.ts +18 -0
- package/src/tx/builder/field-types/short-u-int.ts +11 -0
- package/src/tx/builder/field-types/u-int.ts +16 -0
- package/src/tx/builder/helpers.ts +248 -0
- package/src/tx/builder/index.ts +400 -0
- package/src/tx/builder/schema.ts +727 -0
- package/src/tx/index.ts +192 -0
- package/src/tx/validator.ts +230 -0
- package/src/typings/@aeternity__argon2-browser/index.d.ts +3 -0
- package/src/typings/@aeternity__uuid/index.d.ts +5 -0
- package/src/typings/bip32-path/index.d.ts +33 -0
- package/src/typings/blakejs/index.d.ts +4 -32
- package/src/typings/sha-js/index.d.ts +5 -0
- package/src/typings/tweetnacl-auth/index.d.ts +14 -0
- package/src/utils/amount-formatter.ts +56 -69
- package/src/utils/autorest.ts +93 -0
- package/src/utils/bignumber.ts +11 -12
- package/src/utils/bytes.ts +29 -31
- package/src/utils/crypto.ts +205 -0
- package/src/utils/encoder-types.ts +63 -0
- package/src/utils/encoder.ts +116 -71
- package/src/utils/errors.ts +482 -366
- package/src/utils/hd-wallet.ts +166 -0
- package/src/utils/json-big.ts +27 -0
- package/src/utils/keystore.ts +182 -0
- package/src/utils/mptree.ts +64 -61
- package/src/utils/other.ts +34 -41
- package/src/utils/semver-satisfies.ts +15 -11
- package/src/utils/string.ts +18 -20
- package/es/account/base.mjs +0 -179
- package/es/account/base.mjs.map +0 -1
- package/es/account/memory.mjs +0 -99
- package/es/account/memory.mjs.map +0 -1
- package/es/account/multiple.mjs +0 -179
- package/es/account/multiple.mjs.map +0 -1
- package/es/ae/aens.mjs +0 -404
- package/es/ae/aens.mjs.map +0 -1
- package/es/ae/aepp.mjs +0 -45
- package/es/ae/aepp.mjs.map +0 -1
- package/es/ae/contract.mjs +0 -159
- package/es/ae/contract.mjs.map +0 -1
- package/es/ae/index.mjs +0 -207
- package/es/ae/index.mjs.map +0 -1
- package/es/ae/oracle.mjs +0 -339
- package/es/ae/oracle.mjs.map +0 -1
- package/es/ae/universal.mjs +0 -45
- package/es/ae/universal.mjs.map +0 -1
- package/es/ae/wallet.mjs +0 -50
- package/es/ae/wallet.mjs.map +0 -1
- package/es/amount-formatter.d.ts +0 -58
- package/es/bignumber.d.ts +0 -18
- package/es/chain/index.mjs +0 -272
- package/es/chain/index.mjs.map +0 -1
- package/es/chain/node.mjs +0 -442
- package/es/chain/node.mjs.map +0 -1
- package/es/contract/compiler.mjs +0 -115
- package/es/contract/compiler.mjs.map +0 -1
- package/es/contract/ga/helpers.mjs +0 -30
- package/es/contract/ga/helpers.mjs.map +0 -1
- package/es/contract/ga/index.mjs +0 -178
- package/es/contract/ga/index.mjs.map +0 -1
- package/es/crypto-ts.d.ts +0 -9
- package/es/encoder.d.ts +0 -26
- package/es/node-pool/index.mjs +0 -188
- package/es/node-pool/index.mjs.map +0 -1
- package/es/node.mjs +0 -133
- package/es/node.mjs.map +0 -1
- package/es/other.d.ts +0 -31
- package/es/semver-satisfies.d.ts +0 -1
- package/es/string.d.ts +0 -26
- package/es/tx/builder/field-types.mjs +0 -74
- package/es/tx/builder/field-types.mjs.map +0 -1
- package/es/tx/tx-object.mjs +0 -283
- package/es/tx/tx-object.mjs.map +0 -1
- package/es/tx/tx.mjs +0 -938
- package/es/tx/tx.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs +0 -132
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs +0 -183
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/index.mjs +0 -87
- package/es/utils/aepp-wallet-communication/connection/index.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/content-script-bridge.mjs +0 -98
- package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/helpers.mjs +0 -92
- package/es/utils/aepp-wallet-communication/helpers.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +0 -375
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs +0 -275
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs +0 -541
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/schema.mjs +0 -102
- package/es/utils/aepp-wallet-communication/schema.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/wallet-detector.mjs +0 -110
- package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +0 -1
- package/es/utils/async-init.mjs +0 -64
- package/es/utils/async-init.mjs.map +0 -1
- package/es/utils/crypto-ts.mjs.map +0 -1
- package/es/utils/swagger.mjs +0 -164
- package/es/utils/swagger.mjs.map +0 -1
- package/src/account/base.js +0 -153
- package/src/account/memory.js +0 -83
- package/src/account/multiple.js +0 -162
- package/src/ae/aens.js +0 -361
- package/src/ae/aepp.js +0 -45
- package/src/ae/contract.js +0 -148
- package/src/ae/index.js +0 -168
- package/src/ae/oracle.js +0 -311
- package/src/ae/universal.js +0 -47
- package/src/ae/wallet.js +0 -50
- package/src/chain/index.js +0 -269
- package/src/chain/node.js +0 -320
- package/src/channel/handlers.js +0 -673
- package/src/channel/index.js +0 -903
- package/src/channel/internal.js +0 -236
- package/src/contract/aci.js +0 -376
- package/src/contract/compiler.js +0 -100
- package/src/contract/ga/helpers.js +0 -19
- package/src/contract/ga/index.js +0 -150
- package/src/index.js +0 -89
- package/src/node-pool/index.js +0 -172
- package/src/node.js +0 -116
- package/src/tx/builder/constants.js +0 -100
- package/src/tx/builder/field-types.js +0 -61
- package/src/tx/builder/helpers.js +0 -334
- package/src/tx/builder/index.js +0 -465
- package/src/tx/builder/schema.js +0 -1100
- package/src/tx/index.js +0 -301
- package/src/tx/tx-object.js +0 -187
- package/src/tx/tx.js +0 -631
- package/src/tx/validator.js +0 -181
- package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -119
- package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -165
- package/src/utils/aepp-wallet-communication/connection/index.js +0 -85
- package/src/utils/aepp-wallet-communication/content-script-bridge.js +0 -86
- package/src/utils/aepp-wallet-communication/helpers.js +0 -60
- package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -294
- package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -232
- package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -401
- package/src/utils/aepp-wallet-communication/schema.ts +0 -80
- package/src/utils/aepp-wallet-communication/wallet-detector.js +0 -92
- package/src/utils/async-init.js +0 -45
- package/src/utils/crypto.js +0 -219
- package/src/utils/hd-wallet.js +0 -100
- package/src/utils/json-big.js +0 -26
- package/src/utils/keystore.js +0 -219
- package/src/utils/swagger.js +0 -156
package/es/oracle.d.ts
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Oracle methods - routines to interact with the æternity oracle system
|
|
3
|
+
*
|
|
4
|
+
* The high-level description of the oracle system is
|
|
5
|
+
* https://github.com/aeternity/protocol/blob/master/ORACLE.md in the protocol
|
|
6
|
+
* repository.
|
|
7
|
+
*/
|
|
8
|
+
import BigNumber from 'bignumber.js';
|
|
9
|
+
import { send, SendOptions } from './spend';
|
|
10
|
+
import { ORACLE_TTL_TYPES } from './tx/builder/schema';
|
|
11
|
+
import { Tag } from './tx/builder/constants';
|
|
12
|
+
import { Encoded } from './utils/encoder';
|
|
13
|
+
import { _getPollInterval } from './chain';
|
|
14
|
+
import { BuildTxOptions } from './tx';
|
|
15
|
+
import Node from './Node';
|
|
16
|
+
import AccountBase from './account/Base';
|
|
17
|
+
declare type OracleQueries = Awaited<ReturnType<Node['getOracleQueriesByPubkey']>>['oracleQueries'];
|
|
18
|
+
/**
|
|
19
|
+
* Poll for oracle queries
|
|
20
|
+
* @category oracle
|
|
21
|
+
* @param oracleId - Oracle public key
|
|
22
|
+
* @param onQuery - OnQuery callback
|
|
23
|
+
* @param options - Options object
|
|
24
|
+
* @param options.interval - Poll interval(default: 5000)
|
|
25
|
+
* @param options.onNode - Node to use
|
|
26
|
+
* @returns Callback to stop polling function
|
|
27
|
+
*/
|
|
28
|
+
export declare function pollForQueries(oracleId: Encoded.OracleAddress, onQuery: (queries: OracleQueries) => void, { interval, onNode, ...options }: {
|
|
29
|
+
interval?: number;
|
|
30
|
+
onNode: Node;
|
|
31
|
+
} & Parameters<typeof _getPollInterval>[1]): () => void;
|
|
32
|
+
/**
|
|
33
|
+
* Poll for oracle query response
|
|
34
|
+
* @category oracle
|
|
35
|
+
* @param oracleId - Oracle public key
|
|
36
|
+
* @param queryId - Oracle Query id
|
|
37
|
+
* @param options - Options object
|
|
38
|
+
* @param options.interval - Poll interval
|
|
39
|
+
* @param options.onNode - Node to use
|
|
40
|
+
* @returns OracleQuery object
|
|
41
|
+
*/
|
|
42
|
+
export declare function pollForQueryResponse(oracleId: Encoded.OracleAddress, queryId: Encoded.OracleQueryId, { interval, onNode, ...options }: {
|
|
43
|
+
interval?: number;
|
|
44
|
+
onNode: Node;
|
|
45
|
+
} & Parameters<typeof _getPollInterval>[1]): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Constructor for OracleQuery Object (helper object for using OracleQuery)
|
|
48
|
+
* @category oracle
|
|
49
|
+
* @param oracleId - Oracle public key
|
|
50
|
+
* @param queryId - Oracle Query id
|
|
51
|
+
* @param options - Options
|
|
52
|
+
* @returns OracleQuery object
|
|
53
|
+
*/
|
|
54
|
+
export declare function getQueryObject(oracleId: Encoded.OracleAddress, queryId: Encoded.OracleQueryId, options: RespondToQueryOptions & Parameters<typeof pollForQueryResponse>[2]): Promise<GetQueryObjectReturnType>;
|
|
55
|
+
interface GetQueryObjectReturnType extends Awaited<ReturnType<Node['getOracleQueryByPubkeyAndQueryId']>> {
|
|
56
|
+
decodedQuery: string;
|
|
57
|
+
decodedResponse: string;
|
|
58
|
+
respond: (response: string, options?: Parameters<typeof respondToQuery>[3]) => ReturnType<typeof respondToQuery>;
|
|
59
|
+
pollForResponse: (options?: Parameters<typeof pollForQueryResponse>[2]) => ReturnType<typeof pollForQueryResponse>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Post query to oracle
|
|
63
|
+
* @category oracle
|
|
64
|
+
* @param oracleId - Oracle public key
|
|
65
|
+
* @param query - Oracle query object
|
|
66
|
+
* @param options - Options object
|
|
67
|
+
* @param options.queryTtl - queryTtl Oracle query time to leave
|
|
68
|
+
* @param options.responseTtl - queryFee Oracle query response time to leave
|
|
69
|
+
* @param options.queryFee - queryFee Oracle query fee
|
|
70
|
+
* @param options.fee - fee Transaction fee
|
|
71
|
+
* @param options.ttl - Transaction time to leave
|
|
72
|
+
* @returns Query object
|
|
73
|
+
*/
|
|
74
|
+
export declare function postQueryToOracle(oracleId: Encoded.OracleAddress, query: string, options: PostQueryToOracleOptions): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getQueryObject>>>;
|
|
75
|
+
declare type PostQueryToOracleOptionsType = Parameters<typeof send>[1] & Parameters<typeof getQueryObject>[2] & BuildTxOptions<Tag.OracleQueryTx, 'oracleId' | 'senderId' | 'query' | 'queryTtlType' | 'queryTtlValue' | 'responseTtlType' | 'responseTtlValue'> & {
|
|
76
|
+
queryTtlType?: ORACLE_TTL_TYPES;
|
|
77
|
+
queryTtlValue?: number;
|
|
78
|
+
responseTtlType?: ORACLE_TTL_TYPES;
|
|
79
|
+
responseTtlValue?: number;
|
|
80
|
+
};
|
|
81
|
+
interface PostQueryToOracleOptions extends PostQueryToOracleOptionsType {
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Extend oracle ttl
|
|
85
|
+
* @category oracle
|
|
86
|
+
* @param oracleId - Oracle public key
|
|
87
|
+
* @param options - Options object
|
|
88
|
+
* @param options.fee - fee Transaction fee
|
|
89
|
+
* @param options.ttl - Transaction time to leave
|
|
90
|
+
* @param options.oracleTtlType - Oracle time to leave for extend
|
|
91
|
+
* @param options.oracleTtlValue - Oracle time to leave for extend
|
|
92
|
+
* @returns Oracle object
|
|
93
|
+
*/
|
|
94
|
+
export declare function extendOracleTtl(oracleId: Encoded.OracleAddress, options: ExtendOracleTtlOptions): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getOracleObject>>>;
|
|
95
|
+
declare type ExtendOracleTtlOptionsType = SendOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<Tag.OracleExtendTx, 'oracleTtlType' | 'oracleTtlValue' | 'callerId' | 'oracleId'> & {
|
|
96
|
+
oracleTtlType?: ORACLE_TTL_TYPES;
|
|
97
|
+
oracleTtlValue?: number;
|
|
98
|
+
};
|
|
99
|
+
interface ExtendOracleTtlOptions extends ExtendOracleTtlOptionsType {
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Extend oracle ttl
|
|
103
|
+
* @category oracle
|
|
104
|
+
* @param oracleId - Oracle public key
|
|
105
|
+
* @param queryId - Oracle query id
|
|
106
|
+
* @param response - Oracle query response
|
|
107
|
+
* @param options - Options object
|
|
108
|
+
* @param options.responseTtl - responseTtl Query response time to leave
|
|
109
|
+
* @param options.fee - Transaction fee
|
|
110
|
+
* @param options.ttl - Transaction time to leave
|
|
111
|
+
* @returns Oracle object
|
|
112
|
+
*/
|
|
113
|
+
export declare function respondToQuery(oracleId: Encoded.OracleAddress, queryId: Encoded.OracleQueryId, response: string, options: RespondToQueryOptions): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getOracleObject>>>;
|
|
114
|
+
declare type RespondToQueryOptionsType = SendOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<Tag.OracleResponseTx, 'callerId' | 'oracleId' | 'queryId' | 'response' | 'responseTtlType' | 'responseTtlValue'> & {
|
|
115
|
+
responseTtlType?: ORACLE_TTL_TYPES;
|
|
116
|
+
responseTtlValue?: number;
|
|
117
|
+
};
|
|
118
|
+
interface RespondToQueryOptions extends RespondToQueryOptionsType {
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Constructor for Oracle Object (helper object for using Oracle)
|
|
122
|
+
* @category oracle
|
|
123
|
+
* @param oracleId - Oracle public key
|
|
124
|
+
* @param options - Options
|
|
125
|
+
* @returns Oracle object
|
|
126
|
+
*/
|
|
127
|
+
export declare function getOracleObject(oracleId: Encoded.OracleAddress, options: {
|
|
128
|
+
onNode: Node;
|
|
129
|
+
onAccount: AccountBase;
|
|
130
|
+
}): Promise<GetOracleObjectReturnType>;
|
|
131
|
+
interface GetOracleObjectReturnType extends Awaited<ReturnType<Node['getOracleByPubkey']>> {
|
|
132
|
+
id: Encoded.OracleAddress;
|
|
133
|
+
queries: OracleQueries;
|
|
134
|
+
pollQueries: (cb: Parameters<typeof pollForQueries>[1]) => ReturnType<typeof pollForQueries>;
|
|
135
|
+
postQuery: Function;
|
|
136
|
+
respondToQuery: Function;
|
|
137
|
+
extendOracle: Function;
|
|
138
|
+
getQuery: Function;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Register oracle
|
|
142
|
+
* @category oracle
|
|
143
|
+
* @param queryFormat - Format of query
|
|
144
|
+
* @param responseFormat - Format of query response
|
|
145
|
+
* @param options - Options
|
|
146
|
+
* @param options.queryFee - Oracle query Fee
|
|
147
|
+
* @param options - Options object
|
|
148
|
+
* @param options.abiVersion - Always 0 (do not use virtual machine)
|
|
149
|
+
* @param options.fee - Transaction fee
|
|
150
|
+
* @param options.ttl - Transaction time to leave
|
|
151
|
+
* @returns Oracle object
|
|
152
|
+
*/
|
|
153
|
+
export declare function registerOracle(queryFormat: string, responseFormat: string, options: RegisterOracleOptions): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getOracleObject>>>;
|
|
154
|
+
declare type RegisterOracleOptionsType = SendOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<Tag.OracleRegisterTx, 'accountId' | 'queryFormat' | 'responseFormat' | 'queryFee' | 'oracleTtlType' | 'oracleTtlValue'> & {
|
|
155
|
+
queryFee?: number | string | BigNumber;
|
|
156
|
+
oracleTtlType?: ORACLE_TTL_TYPES;
|
|
157
|
+
oracleTtlValue?: number;
|
|
158
|
+
};
|
|
159
|
+
interface RegisterOracleOptions extends RegisterOracleOptionsType {
|
|
160
|
+
}
|
|
161
|
+
export {};
|
package/es/oracle.mjs
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ISC License (ISC)
|
|
3
|
+
* Copyright (c) 2022 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
|
+
* Oracle methods - routines to interact with the æternity oracle system
|
|
20
|
+
*
|
|
21
|
+
* The high-level description of the oracle system is
|
|
22
|
+
* https://github.com/aeternity/protocol/blob/master/ORACLE.md in the protocol
|
|
23
|
+
* repository.
|
|
24
|
+
*/
|
|
25
|
+
import { send } from "./spend.mjs";
|
|
26
|
+
import { mapObject, pause } from "./utils/other.mjs";
|
|
27
|
+
import { oracleQueryId } from "./tx/builder/helpers.mjs";
|
|
28
|
+
import { unpackTx } from "./tx/builder/index.mjs";
|
|
29
|
+
import { ORACLE_TTL, QUERY_FEE, QUERY_TTL, RESPONSE_TTL } from "./tx/builder/schema.mjs";
|
|
30
|
+
import { Tag } from "./tx/builder/constants.mjs";
|
|
31
|
+
import { RequestTimedOutError } from "./utils/errors.mjs";
|
|
32
|
+
import { decode, encode, Encoding } from "./utils/encoder.mjs";
|
|
33
|
+
import { _getPollInterval } from "./chain.mjs";
|
|
34
|
+
import { _buildTx } from "./tx/index.mjs";
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Poll for oracle queries
|
|
38
|
+
* @category oracle
|
|
39
|
+
* @param oracleId - Oracle public key
|
|
40
|
+
* @param onQuery - OnQuery callback
|
|
41
|
+
* @param options - Options object
|
|
42
|
+
* @param options.interval - Poll interval(default: 5000)
|
|
43
|
+
* @param options.onNode - Node to use
|
|
44
|
+
* @returns Callback to stop polling function
|
|
45
|
+
*/
|
|
46
|
+
export function pollForQueries(oracleId, onQuery, _ref) {
|
|
47
|
+
var _interval;
|
|
48
|
+
|
|
49
|
+
let {
|
|
50
|
+
interval,
|
|
51
|
+
onNode,
|
|
52
|
+
...options
|
|
53
|
+
} = _ref;
|
|
54
|
+
(_interval = interval) !== null && _interval !== void 0 ? _interval : interval = _getPollInterval('microblock', options);
|
|
55
|
+
const knownQueryIds = new Set();
|
|
56
|
+
|
|
57
|
+
const checkNewQueries = async () => {
|
|
58
|
+
var _await$onNode$getOrac;
|
|
59
|
+
|
|
60
|
+
const queries = ((_await$onNode$getOrac = (await onNode.getOracleQueriesByPubkey(oracleId)).oracleQueries) !== null && _await$onNode$getOrac !== void 0 ? _await$onNode$getOrac : []).filter(_ref2 => {
|
|
61
|
+
let {
|
|
62
|
+
id
|
|
63
|
+
} = _ref2;
|
|
64
|
+
return !knownQueryIds.has(id);
|
|
65
|
+
});
|
|
66
|
+
queries.forEach(_ref3 => {
|
|
67
|
+
let {
|
|
68
|
+
id
|
|
69
|
+
} = _ref3;
|
|
70
|
+
return knownQueryIds.add(id);
|
|
71
|
+
});
|
|
72
|
+
if (queries.length > 0) onQuery(queries);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
let stopped = false; // eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
76
|
+
|
|
77
|
+
(async () => {
|
|
78
|
+
while (!stopped) {
|
|
79
|
+
// eslint-disable-line no-unmodified-loop-condition
|
|
80
|
+
// TODO: allow to handle this error somehow
|
|
81
|
+
await checkNewQueries().catch(console.error);
|
|
82
|
+
await pause(interval);
|
|
83
|
+
}
|
|
84
|
+
})();
|
|
85
|
+
|
|
86
|
+
return () => {
|
|
87
|
+
stopped = true;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Poll for oracle query response
|
|
92
|
+
* @category oracle
|
|
93
|
+
* @param oracleId - Oracle public key
|
|
94
|
+
* @param queryId - Oracle Query id
|
|
95
|
+
* @param options - Options object
|
|
96
|
+
* @param options.interval - Poll interval
|
|
97
|
+
* @param options.onNode - Node to use
|
|
98
|
+
* @returns OracleQuery object
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
export async function pollForQueryResponse(oracleId, queryId, _ref4) {
|
|
102
|
+
var _interval2;
|
|
103
|
+
|
|
104
|
+
let {
|
|
105
|
+
interval,
|
|
106
|
+
onNode,
|
|
107
|
+
...options
|
|
108
|
+
} = _ref4;
|
|
109
|
+
(_interval2 = interval) !== null && _interval2 !== void 0 ? _interval2 : interval = _getPollInterval('microblock', options);
|
|
110
|
+
let height;
|
|
111
|
+
let ttl;
|
|
112
|
+
let response;
|
|
113
|
+
|
|
114
|
+
do {
|
|
115
|
+
if (height != null) await pause(interval);
|
|
116
|
+
({
|
|
117
|
+
response,
|
|
118
|
+
ttl
|
|
119
|
+
} = await onNode.getOracleQueryByPubkeyAndQueryId(oracleId, queryId));
|
|
120
|
+
const responseBuffer = decode(response);
|
|
121
|
+
if (responseBuffer.length > 0) return responseBuffer.toString();
|
|
122
|
+
height = await this.getHeight();
|
|
123
|
+
} while (ttl >= height);
|
|
124
|
+
|
|
125
|
+
throw new RequestTimedOutError(height);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Constructor for OracleQuery Object (helper object for using OracleQuery)
|
|
129
|
+
* @category oracle
|
|
130
|
+
* @param oracleId - Oracle public key
|
|
131
|
+
* @param queryId - Oracle Query id
|
|
132
|
+
* @param options - Options
|
|
133
|
+
* @returns OracleQuery object
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
export async function getQueryObject(oracleId, queryId, options) {
|
|
137
|
+
const record = await options.onNode.getOracleQueryByPubkeyAndQueryId(oracleId, queryId);
|
|
138
|
+
return { ...record,
|
|
139
|
+
decodedQuery: decode(record.query).toString(),
|
|
140
|
+
decodedResponse: decode(record.response).toString(),
|
|
141
|
+
respond: async (response, opt) => // eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
142
|
+
respondToQuery(oracleId, queryId, response, { ...options,
|
|
143
|
+
...opt
|
|
144
|
+
}),
|
|
145
|
+
pollForResponse: async opt => pollForQueryResponse(oracleId, queryId, { ...options,
|
|
146
|
+
...opt
|
|
147
|
+
})
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Post query to oracle
|
|
153
|
+
* @category oracle
|
|
154
|
+
* @param oracleId - Oracle public key
|
|
155
|
+
* @param query - Oracle query object
|
|
156
|
+
* @param options - Options object
|
|
157
|
+
* @param options.queryTtl - queryTtl Oracle query time to leave
|
|
158
|
+
* @param options.responseTtl - queryFee Oracle query response time to leave
|
|
159
|
+
* @param options.queryFee - queryFee Oracle query fee
|
|
160
|
+
* @param options.fee - fee Transaction fee
|
|
161
|
+
* @param options.ttl - Transaction time to leave
|
|
162
|
+
* @returns Query object
|
|
163
|
+
*/
|
|
164
|
+
export async function postQueryToOracle(oracleId, query, options) {
|
|
165
|
+
var _options$queryFee;
|
|
166
|
+
|
|
167
|
+
(_options$queryFee = options.queryFee) !== null && _options$queryFee !== void 0 ? _options$queryFee : options.queryFee = (await options.onNode.getOracleByPubkey(oracleId)).queryFee.toString();
|
|
168
|
+
const senderId = await options.onAccount.address(options);
|
|
169
|
+
const oracleQueryTx = await _buildTx(Tag.OracleQueryTx, {
|
|
170
|
+
queryTtlType: QUERY_TTL.type,
|
|
171
|
+
queryTtlValue: QUERY_TTL.value,
|
|
172
|
+
responseTtlType: RESPONSE_TTL.type,
|
|
173
|
+
responseTtlValue: RESPONSE_TTL.value,
|
|
174
|
+
...options,
|
|
175
|
+
oracleId,
|
|
176
|
+
senderId,
|
|
177
|
+
query
|
|
178
|
+
});
|
|
179
|
+
const {
|
|
180
|
+
nonce
|
|
181
|
+
} = unpackTx(oracleQueryTx, Tag.OracleQueryTx).tx;
|
|
182
|
+
const queryId = oracleQueryId(senderId, nonce, oracleId);
|
|
183
|
+
return { ...(await send(oracleQueryTx, options)),
|
|
184
|
+
...(await getQueryObject(oracleId, queryId, options))
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Extend oracle ttl
|
|
190
|
+
* @category oracle
|
|
191
|
+
* @param oracleId - Oracle public key
|
|
192
|
+
* @param options - Options object
|
|
193
|
+
* @param options.fee - fee Transaction fee
|
|
194
|
+
* @param options.ttl - Transaction time to leave
|
|
195
|
+
* @param options.oracleTtlType - Oracle time to leave for extend
|
|
196
|
+
* @param options.oracleTtlValue - Oracle time to leave for extend
|
|
197
|
+
* @returns Oracle object
|
|
198
|
+
*/
|
|
199
|
+
export async function extendOracleTtl(oracleId, options) {
|
|
200
|
+
const oracleExtendTx = await _buildTx(Tag.OracleExtendTx, {
|
|
201
|
+
oracleTtlType: ORACLE_TTL.type,
|
|
202
|
+
oracleTtlValue: ORACLE_TTL.value,
|
|
203
|
+
...options,
|
|
204
|
+
callerId: await options.onAccount.address(options),
|
|
205
|
+
oracleId
|
|
206
|
+
});
|
|
207
|
+
return { ...(await send(oracleExtendTx, options)),
|
|
208
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
209
|
+
...(await getOracleObject(oracleId, options))
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Extend oracle ttl
|
|
215
|
+
* @category oracle
|
|
216
|
+
* @param oracleId - Oracle public key
|
|
217
|
+
* @param queryId - Oracle query id
|
|
218
|
+
* @param response - Oracle query response
|
|
219
|
+
* @param options - Options object
|
|
220
|
+
* @param options.responseTtl - responseTtl Query response time to leave
|
|
221
|
+
* @param options.fee - Transaction fee
|
|
222
|
+
* @param options.ttl - Transaction time to leave
|
|
223
|
+
* @returns Oracle object
|
|
224
|
+
*/
|
|
225
|
+
export async function respondToQuery(oracleId, queryId, response, options) {
|
|
226
|
+
const oracleRespondTx = await _buildTx(Tag.OracleResponseTx, {
|
|
227
|
+
responseTtlType: RESPONSE_TTL.type,
|
|
228
|
+
responseTtlValue: RESPONSE_TTL.value,
|
|
229
|
+
...options,
|
|
230
|
+
callerId: await options.onAccount.address(options),
|
|
231
|
+
oracleId,
|
|
232
|
+
queryId,
|
|
233
|
+
response
|
|
234
|
+
});
|
|
235
|
+
return { ...(await send(oracleRespondTx, options)),
|
|
236
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
237
|
+
...(await getOracleObject(oracleId, options))
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Constructor for Oracle Object (helper object for using Oracle)
|
|
243
|
+
* @category oracle
|
|
244
|
+
* @param oracleId - Oracle public key
|
|
245
|
+
* @param options - Options
|
|
246
|
+
* @returns Oracle object
|
|
247
|
+
*/
|
|
248
|
+
export async function getOracleObject(oracleId, options) {
|
|
249
|
+
return { ...(await options.onNode.getOracleByPubkey(oracleId)),
|
|
250
|
+
queries: (await options.onNode.getOracleQueriesByPubkey(oracleId)).oracleQueries,
|
|
251
|
+
...mapObject({
|
|
252
|
+
pollQueries: pollForQueries,
|
|
253
|
+
postQuery: postQueryToOracle,
|
|
254
|
+
respondToQuery,
|
|
255
|
+
extendOracle: extendOracleTtl,
|
|
256
|
+
getQuery: getQueryObject
|
|
257
|
+
}, _ref5 => {
|
|
258
|
+
let [name, handler] = _ref5;
|
|
259
|
+
return [name, function () {
|
|
260
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
261
|
+
args[_key] = arguments[_key];
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const lastArg = args[args.length - 1];
|
|
265
|
+
|
|
266
|
+
if (lastArg != null && typeof lastArg === 'object' && lastArg.constructor === Object) {
|
|
267
|
+
Object.assign(lastArg, { ...options,
|
|
268
|
+
...lastArg
|
|
269
|
+
});
|
|
270
|
+
} else args.push(options);
|
|
271
|
+
|
|
272
|
+
return handler(oracleId, ...args);
|
|
273
|
+
}];
|
|
274
|
+
})
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Register oracle
|
|
280
|
+
* @category oracle
|
|
281
|
+
* @param queryFormat - Format of query
|
|
282
|
+
* @param responseFormat - Format of query response
|
|
283
|
+
* @param options - Options
|
|
284
|
+
* @param options.queryFee - Oracle query Fee
|
|
285
|
+
* @param options - Options object
|
|
286
|
+
* @param options.abiVersion - Always 0 (do not use virtual machine)
|
|
287
|
+
* @param options.fee - Transaction fee
|
|
288
|
+
* @param options.ttl - Transaction time to leave
|
|
289
|
+
* @returns Oracle object
|
|
290
|
+
*/
|
|
291
|
+
export async function registerOracle(queryFormat, responseFormat, options) {
|
|
292
|
+
const accountId = await options.onAccount.address(options);
|
|
293
|
+
const oracleRegisterTx = await _buildTx(Tag.OracleRegisterTx, {
|
|
294
|
+
queryFee: QUERY_FEE,
|
|
295
|
+
oracleTtlValue: ORACLE_TTL.value,
|
|
296
|
+
oracleTtlType: ORACLE_TTL.type,
|
|
297
|
+
...options,
|
|
298
|
+
accountId,
|
|
299
|
+
queryFormat,
|
|
300
|
+
responseFormat
|
|
301
|
+
});
|
|
302
|
+
return { ...(await send(oracleRegisterTx, options)),
|
|
303
|
+
...(await getOracleObject(encode(decode(accountId), Encoding.OracleAddress), options))
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=oracle.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oracle.mjs","names":["send","mapObject","pause","oracleQueryId","unpackTx","ORACLE_TTL","QUERY_FEE","QUERY_TTL","RESPONSE_TTL","Tag","RequestTimedOutError","decode","encode","Encoding","_getPollInterval","_buildTx","pollForQueries","oracleId","onQuery","interval","onNode","options","knownQueryIds","Set","checkNewQueries","queries","getOracleQueriesByPubkey","oracleQueries","filter","id","has","forEach","add","length","stopped","catch","console","error","pollForQueryResponse","queryId","height","ttl","response","getOracleQueryByPubkeyAndQueryId","responseBuffer","toString","getHeight","getQueryObject","record","decodedQuery","query","decodedResponse","respond","opt","respondToQuery","pollForResponse","postQueryToOracle","queryFee","getOracleByPubkey","senderId","onAccount","address","oracleQueryTx","OracleQueryTx","queryTtlType","type","queryTtlValue","value","responseTtlType","responseTtlValue","nonce","tx","extendOracleTtl","oracleExtendTx","OracleExtendTx","oracleTtlType","oracleTtlValue","callerId","getOracleObject","oracleRespondTx","OracleResponseTx","pollQueries","postQuery","extendOracle","getQuery","name","handler","args","lastArg","constructor","Object","assign","push","registerOracle","queryFormat","responseFormat","accountId","oracleRegisterTx","OracleRegisterTx","OracleAddress"],"sources":["../src/oracle.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2022 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 * Oracle methods - routines to interact with the æternity oracle system\n *\n * The high-level description of the oracle system is\n * https://github.com/aeternity/protocol/blob/master/ORACLE.md in the protocol\n * repository.\n */\n\nimport BigNumber from 'bignumber.js';\nimport { send, SendOptions } from './spend';\nimport { mapObject, pause } from './utils/other';\nimport { oracleQueryId } from './tx/builder/helpers';\nimport { unpackTx } from './tx/builder';\nimport {\n ORACLE_TTL,\n ORACLE_TTL_TYPES,\n QUERY_FEE,\n QUERY_TTL,\n RESPONSE_TTL,\n} from './tx/builder/schema';\nimport { Tag } from './tx/builder/constants';\nimport { RequestTimedOutError } from './utils/errors';\nimport {\n decode, encode, Encoded, Encoding,\n} from './utils/encoder';\nimport { _getPollInterval } from './chain';\nimport { _buildTx, BuildTxOptions } from './tx';\nimport Node from './Node';\nimport AccountBase from './account/Base';\n\ntype OracleQueries = Awaited<ReturnType<Node['getOracleQueriesByPubkey']>>['oracleQueries'];\n\n/**\n * Poll for oracle queries\n * @category oracle\n * @param oracleId - Oracle public key\n * @param onQuery - OnQuery callback\n * @param options - Options object\n * @param options.interval - Poll interval(default: 5000)\n * @param options.onNode - Node to use\n * @returns Callback to stop polling function\n */\nexport function pollForQueries(\n oracleId: Encoded.OracleAddress,\n onQuery: (queries: OracleQueries) => void,\n { interval, onNode, ...options }: { interval?: number; onNode: Node }\n & Parameters<typeof _getPollInterval>[1],\n): () => void {\n interval ??= _getPollInterval('microblock', options);\n const knownQueryIds = new Set();\n const checkNewQueries = async (): Promise<void> => {\n const queries = ((await onNode.getOracleQueriesByPubkey(oracleId)).oracleQueries ?? [])\n .filter(({ id }) => !knownQueryIds.has(id));\n queries.forEach(({ id }) => knownQueryIds.add(id));\n if (queries.length > 0) onQuery(queries);\n };\n\n let stopped = false;\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n (async () => {\n while (!stopped) { // eslint-disable-line no-unmodified-loop-condition\n // TODO: allow to handle this error somehow\n await checkNewQueries().catch(console.error);\n await pause(interval);\n }\n })();\n return () => { stopped = true; };\n}\n\n/**\n * Poll for oracle query response\n * @category oracle\n * @param oracleId - Oracle public key\n * @param queryId - Oracle Query id\n * @param options - Options object\n * @param options.interval - Poll interval\n * @param options.onNode - Node to use\n * @returns OracleQuery object\n */\nexport async function pollForQueryResponse(\n oracleId: Encoded.OracleAddress,\n queryId: Encoded.OracleQueryId,\n { interval, onNode, ...options }:\n { interval?: number; onNode: Node } & Parameters<typeof _getPollInterval>[1],\n): Promise<string> {\n interval ??= _getPollInterval('microblock', options);\n let height;\n let ttl;\n let response;\n do {\n if (height != null) await pause(interval);\n ({ response, ttl } = await onNode.getOracleQueryByPubkeyAndQueryId(oracleId, queryId));\n const responseBuffer = decode(response as Encoded.OracleResponse);\n if (responseBuffer.length > 0) return responseBuffer.toString();\n height = await this.getHeight();\n } while (ttl >= height);\n throw new RequestTimedOutError(height);\n}\n\n/**\n * Constructor for OracleQuery Object (helper object for using OracleQuery)\n * @category oracle\n * @param oracleId - Oracle public key\n * @param queryId - Oracle Query id\n * @param options - Options\n * @returns OracleQuery object\n */\nexport async function getQueryObject(\n oracleId: Encoded.OracleAddress,\n queryId: Encoded.OracleQueryId,\n options: RespondToQueryOptions & Parameters<typeof pollForQueryResponse>[2],\n): Promise<GetQueryObjectReturnType> {\n const record = await options.onNode.getOracleQueryByPubkeyAndQueryId(oracleId, queryId);\n return {\n ...record,\n decodedQuery: decode(record.query as Encoded.OracleQueryId).toString(),\n decodedResponse: decode(record.response as Encoded.OracleResponse).toString(),\n respond: async (response, opt) => (\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n respondToQuery(oracleId, queryId, response, { ...options, ...opt })\n ),\n pollForResponse: async (opt) => pollForQueryResponse(oracleId, queryId, { ...options, ...opt }),\n };\n}\n\ninterface GetQueryObjectReturnType extends Awaited<ReturnType<Node['getOracleQueryByPubkeyAndQueryId']>> {\n decodedQuery: string;\n decodedResponse: string;\n respond: (response: string, options?: Parameters<typeof respondToQuery>[3]) =>\n ReturnType<typeof respondToQuery>;\n pollForResponse: (options?: Parameters<typeof pollForQueryResponse>[2]) =>\n ReturnType<typeof pollForQueryResponse>;\n}\n\n/**\n * Post query to oracle\n * @category oracle\n * @param oracleId - Oracle public key\n * @param query - Oracle query object\n * @param options - Options object\n * @param options.queryTtl - queryTtl Oracle query time to leave\n * @param options.responseTtl - queryFee Oracle query response time to leave\n * @param options.queryFee - queryFee Oracle query fee\n * @param options.fee - fee Transaction fee\n * @param options.ttl - Transaction time to leave\n * @returns Query object\n */\nexport async function postQueryToOracle(\n oracleId: Encoded.OracleAddress,\n query: string,\n options: PostQueryToOracleOptions,\n): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getQueryObject>>> {\n options.queryFee ??= (await options.onNode.getOracleByPubkey(oracleId)).queryFee.toString();\n const senderId = await options.onAccount.address(options);\n\n const oracleQueryTx = await _buildTx(Tag.OracleQueryTx, {\n queryTtlType: QUERY_TTL.type,\n queryTtlValue: QUERY_TTL.value,\n responseTtlType: RESPONSE_TTL.type,\n responseTtlValue: RESPONSE_TTL.value,\n ...options,\n oracleId,\n senderId,\n query,\n });\n const { nonce } = unpackTx(oracleQueryTx, Tag.OracleQueryTx).tx;\n const queryId = oracleQueryId(senderId, nonce, oracleId);\n return {\n ...await send(oracleQueryTx, options),\n ...await getQueryObject(oracleId, queryId, options),\n };\n}\n\ntype PostQueryToOracleOptionsType = Parameters<typeof send>[1]\n& Parameters<typeof getQueryObject>[2]\n& BuildTxOptions<Tag.OracleQueryTx, 'oracleId' | 'senderId' | 'query' | 'queryTtlType' | 'queryTtlValue' | 'responseTtlType' | 'responseTtlValue'>\n& {\n queryTtlType?: ORACLE_TTL_TYPES;\n queryTtlValue?: number;\n responseTtlType?: ORACLE_TTL_TYPES;\n responseTtlValue?: number;\n};\ninterface PostQueryToOracleOptions extends PostQueryToOracleOptionsType {}\n\n/**\n * Extend oracle ttl\n * @category oracle\n * @param oracleId - Oracle public key\n * @param options - Options object\n * @param options.fee - fee Transaction fee\n * @param options.ttl - Transaction time to leave\n * @param options.oracleTtlType - Oracle time to leave for extend\n * @param options.oracleTtlValue - Oracle time to leave for extend\n * @returns Oracle object\n */\nexport async function extendOracleTtl(\n oracleId: Encoded.OracleAddress,\n options: ExtendOracleTtlOptions,\n): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getOracleObject>>> {\n const oracleExtendTx = await _buildTx(Tag.OracleExtendTx, {\n oracleTtlType: ORACLE_TTL.type,\n oracleTtlValue: ORACLE_TTL.value,\n ...options,\n callerId: await options.onAccount.address(options),\n oracleId,\n });\n return {\n ...await send(oracleExtendTx, options),\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n ...await getOracleObject(oracleId, options),\n };\n}\n\ntype ExtendOracleTtlOptionsType = SendOptions & Parameters<typeof getOracleObject>[1]\n& BuildTxOptions<Tag.OracleExtendTx, 'oracleTtlType' | 'oracleTtlValue' | 'callerId' | 'oracleId'>\n& { oracleTtlType?: ORACLE_TTL_TYPES; oracleTtlValue?: number };\ninterface ExtendOracleTtlOptions extends ExtendOracleTtlOptionsType {}\n\n/**\n * Extend oracle ttl\n * @category oracle\n * @param oracleId - Oracle public key\n * @param queryId - Oracle query id\n * @param response - Oracle query response\n * @param options - Options object\n * @param options.responseTtl - responseTtl Query response time to leave\n * @param options.fee - Transaction fee\n * @param options.ttl - Transaction time to leave\n * @returns Oracle object\n */\nexport async function respondToQuery(\n oracleId: Encoded.OracleAddress,\n queryId: Encoded.OracleQueryId,\n response: string,\n options: RespondToQueryOptions,\n): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getOracleObject>>> {\n const oracleRespondTx = await _buildTx(Tag.OracleResponseTx, {\n responseTtlType: RESPONSE_TTL.type,\n responseTtlValue: RESPONSE_TTL.value,\n ...options,\n callerId: await options.onAccount.address(options),\n oracleId,\n queryId,\n response,\n });\n return {\n ...await send(oracleRespondTx, options),\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n ...await getOracleObject(oracleId, options),\n };\n}\n\ntype RespondToQueryOptionsType = SendOptions & Parameters<typeof getOracleObject>[1]\n& BuildTxOptions<Tag.OracleResponseTx, 'callerId' | 'oracleId' | 'queryId' | 'response' | 'responseTtlType' | 'responseTtlValue'>\n& { responseTtlType?: ORACLE_TTL_TYPES; responseTtlValue?: number };\ninterface RespondToQueryOptions extends RespondToQueryOptionsType {}\n\n/**\n * Constructor for Oracle Object (helper object for using Oracle)\n * @category oracle\n * @param oracleId - Oracle public key\n * @param options - Options\n * @returns Oracle object\n */\nexport async function getOracleObject(\n oracleId: Encoded.OracleAddress,\n options: { onNode: Node; onAccount: AccountBase },\n): Promise<GetOracleObjectReturnType> {\n return {\n ...await options.onNode.getOracleByPubkey(oracleId),\n queries: (await options.onNode.getOracleQueriesByPubkey(oracleId)).oracleQueries,\n ...mapObject<Function, Function>(\n {\n pollQueries: pollForQueries,\n postQuery: postQueryToOracle,\n respondToQuery,\n extendOracle: extendOracleTtl,\n getQuery: getQueryObject,\n },\n ([name, handler]) => [\n name,\n (...args: any) => {\n const lastArg = args[args.length - 1];\n if (lastArg != null && typeof lastArg === 'object' && lastArg.constructor === Object) {\n Object.assign(lastArg, { ...options, ...lastArg });\n } else args.push(options);\n return handler(oracleId, ...args);\n },\n ],\n ),\n } as any;\n}\n\ninterface GetOracleObjectReturnType extends Awaited<ReturnType<Node['getOracleByPubkey']>> {\n id: Encoded.OracleAddress;\n queries: OracleQueries;\n // TODO: replace getOracleObject with a class\n pollQueries: (cb: Parameters<typeof pollForQueries>[1]) => ReturnType<typeof pollForQueries>;\n postQuery: Function;\n respondToQuery: Function;\n extendOracle: Function;\n getQuery: Function;\n}\n\n/**\n * Register oracle\n * @category oracle\n * @param queryFormat - Format of query\n * @param responseFormat - Format of query response\n * @param options - Options\n * @param options.queryFee - Oracle query Fee\n * @param options - Options object\n * @param options.abiVersion - Always 0 (do not use virtual machine)\n * @param options.fee - Transaction fee\n * @param options.ttl - Transaction time to leave\n * @returns Oracle object\n */\nexport async function registerOracle(\n queryFormat: string,\n responseFormat: string,\n options: RegisterOracleOptions,\n): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getOracleObject>>> {\n const accountId = await options.onAccount.address(options);\n const oracleRegisterTx = await _buildTx(Tag.OracleRegisterTx, {\n queryFee: QUERY_FEE,\n oracleTtlValue: ORACLE_TTL.value,\n oracleTtlType: ORACLE_TTL.type,\n ...options,\n accountId,\n queryFormat,\n responseFormat,\n });\n return {\n ...await send(oracleRegisterTx, options),\n ...await getOracleObject(encode(decode(accountId), Encoding.OracleAddress), options),\n };\n}\n\ntype RegisterOracleOptionsType = SendOptions & Parameters<typeof getOracleObject>[1]\n& BuildTxOptions<Tag.OracleRegisterTx, 'accountId' | 'queryFormat' | 'responseFormat' | 'queryFee' | 'oracleTtlType' | 'oracleTtlValue'>\n& {\n queryFee?: number | string | BigNumber;\n oracleTtlType?: ORACLE_TTL_TYPES;\n oracleTtlValue?: number;\n};\ninterface RegisterOracleOptions extends RegisterOracleOptionsType {}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;SAGSA,I;SACAC,S,EAAWC,K;SACXC,a;SACAC,Q;SAEPC,U,EAEAC,S,EACAC,S,EACAC,Y;SAEOC,G;SACAC,oB;SAEPC,M,EAAQC,M,EAAiBC,Q;SAElBC,gB;SACAC,Q;;AAMT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAT,CACLC,QADK,EAELC,OAFK,QAKO;EAAA;;EAAA,IAFZ;IAAEC,QAAF;IAAYC,MAAZ;IAAoB,GAAGC;EAAvB,CAEY;EACZ,aAAAF,QAAQ,UAAR,uCAAAA,QAAQ,GAAKL,gBAAgB,CAAC,YAAD,EAAeO,OAAf,CAA7B;EACA,MAAMC,aAAa,GAAG,IAAIC,GAAJ,EAAtB;;EACA,MAAMC,eAAe,GAAG,YAA2B;IAAA;;IACjD,MAAMC,OAAO,GAAG,0BAAC,CAAC,MAAML,MAAM,CAACM,wBAAP,CAAgCT,QAAhC,CAAP,EAAkDU,aAAnD,yEAAoE,EAApE,EACbC,MADa,CACN;MAAA,IAAC;QAAEC;MAAF,CAAD;MAAA,OAAY,CAACP,aAAa,CAACQ,GAAd,CAAkBD,EAAlB,CAAb;IAAA,CADM,CAAhB;IAEAJ,OAAO,CAACM,OAAR,CAAgB;MAAA,IAAC;QAAEF;MAAF,CAAD;MAAA,OAAYP,aAAa,CAACU,GAAd,CAAkBH,EAAlB,CAAZ;IAAA,CAAhB;IACA,IAAIJ,OAAO,CAACQ,MAA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,QAAtC,IAAkDA,OAAO,CAACC,WAAR,KAAwBC,MAA9E,EAAsF;UACpFA,MAAM,CAACC,MAAP,CAAcH,OAAd,EAAuB,EAAE,GAAGnE,OAAL;YAAc,GAAGmE;UAAjB,CAAvB;QACD,CAFD,MAEOD,IAAI,CAACK,IAAL,CAAUvE,OAAV;;QACP,OAAOiE,OAAO,CAACrE,QAAD,EAAW,GAAGsE,IAAd,CAAd;MACD,CARkB,CAArB;IAAA,CARU;EAHP,CAAP;AAuBD;;AAaD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeM,cAAf,CACLC,WADK,EAELC,cAFK,EAGL1E,OAHK,EAIoF;EACzF,MAAM2E,SAAS,GAAG,MAAM3E,OAAO,CAACuC,SAAR,CAAkBC,OAAlB,CAA0BxC,OAA1B,CAAxB;EACA,MAAM4E,gBAAgB,GAAG,MAAMlF,QAAQ,CAACN,GAAG,CAACyF,gBAAL,EAAuB;IAC5DzC,QAAQ,EAAEnD,SADkD;IAE5DsE,cAAc,EAAEvE,UAAU,CAAC8D,KAFiC;IAG5DQ,aAAa,EAAEtE,UAAU,CAAC4D,IAHkC;IAI5D,GAAG5C,OAJyD;IAK5D2E,SAL4D;IAM5DF,WAN4D;IAO5DC;EAP4D,CAAvB,CAAvC;EASA,OAAO,EACL,IAAG,MAAM/F,IAAI,CAACiG,gBAAD,EAAmB5E,OAAnB,CAAb,CADK;IAEL,IAAG,MAAMyD,eAAe,CAAClE,MAAM,CAACD,MAAM,CAACqF,SAAD,CAAP,EAAoBnF,QAAQ,CAACsF,aAA7B,CAAP,EAAoD9E,OAApD,CAAxB;EAFK,CAAP;AAID"}
|
package/es/spend.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { sendTransaction, resolveName } from './chain';
|
|
2
|
+
import { BuildTxOptions } from './tx';
|
|
3
|
+
import { Encoded } from './utils/encoder';
|
|
4
|
+
import { Tag, AensName } from './tx/builder/constants';
|
|
5
|
+
import AccountBase from './account/Base';
|
|
6
|
+
/**
|
|
7
|
+
* Sign and post a transaction to the chain
|
|
8
|
+
* @category chain
|
|
9
|
+
* @param tx - Transaction
|
|
10
|
+
* @param options - Options
|
|
11
|
+
* @param options.verify - Verify transaction before broadcast, throw error if not
|
|
12
|
+
* valid
|
|
13
|
+
* @returns Transaction
|
|
14
|
+
*/
|
|
15
|
+
export declare function send(tx: Encoded.Transaction, options: SendOptions): Promise<SendReturnType>;
|
|
16
|
+
declare type SendOptionsType = Parameters<AccountBase['signTransaction']>[1] & Parameters<typeof sendTransaction>[1] & {
|
|
17
|
+
onAccount: AccountBase;
|
|
18
|
+
};
|
|
19
|
+
export interface SendOptions extends SendOptionsType {
|
|
20
|
+
}
|
|
21
|
+
interface SendReturnType extends Awaited<ReturnType<typeof sendTransaction>> {
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Send coins to another account
|
|
25
|
+
* @category chain
|
|
26
|
+
* @param amount - Amount to spend
|
|
27
|
+
* @param recipientIdOrName - Address or name of recipient account
|
|
28
|
+
* @param options - Options
|
|
29
|
+
* @returns Transaction
|
|
30
|
+
*/
|
|
31
|
+
export declare function spend(amount: number | string, recipientIdOrName: Encoded.AccountAddress | AensName, options: SpendOptions): ReturnType<typeof send>;
|
|
32
|
+
declare type SpendOptionsType = BuildTxOptions<Tag.SpendTx, 'senderId' | 'recipientId' | 'amount'> & Parameters<typeof resolveName>[2] & {
|
|
33
|
+
onAccount: AccountBase;
|
|
34
|
+
} & SendOptions;
|
|
35
|
+
interface SpendOptions extends SpendOptionsType {
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Send a fraction of coin balance to another account
|
|
39
|
+
* @category chain
|
|
40
|
+
* @param fraction - Fraction of balance to spend (between 0 and 1)
|
|
41
|
+
* @param recipientIdOrName - Address or name of recipient account
|
|
42
|
+
* @param options - Options
|
|
43
|
+
* @returns Transaction
|
|
44
|
+
*/
|
|
45
|
+
export declare function transferFunds(fraction: number | string, recipientIdOrName: AensName | Encoded.AccountAddress, options: TransferFundsOptions): ReturnType<typeof send>;
|
|
46
|
+
declare type TransferFundsOptionsType = BuildTxOptions<Tag.SpendTx, 'senderId' | 'recipientId' | 'amount'> & Parameters<typeof resolveName>[2] & {
|
|
47
|
+
onAccount: AccountBase;
|
|
48
|
+
} & SendOptions;
|
|
49
|
+
interface TransferFundsOptions extends TransferFundsOptionsType {
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Submit transaction of another account paying for it (fee and gas)
|
|
53
|
+
* @category chain
|
|
54
|
+
* @param transaction - tx_<base64>-encoded transaction
|
|
55
|
+
* @param options - Options
|
|
56
|
+
* @returns Object Transaction
|
|
57
|
+
*/
|
|
58
|
+
export declare function payForTransaction(transaction: Encoded.Transaction, options: PayForTransactionOptions): ReturnType<typeof send>;
|
|
59
|
+
interface PayForTransactionOptions extends BuildTxOptions<Tag.PayingForTx, 'payerId' | 'tx'>, SendOptions {
|
|
60
|
+
onAccount: AccountBase;
|
|
61
|
+
}
|
|
62
|
+
export {};
|