@aeternity/aepp-sdk 13.0.0-alpha.0 → 13.0.0-beta.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/bin/aesophia_cli +0 -0
- package/dist/aepp-sdk.browser-script.js +1 -1
- 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 +5595 -2249
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdk.mjs.map +1 -1
- package/es/AeSdkAepp.mjs.map +1 -1
- package/es/AeSdkBase.d.ts +3 -3
- package/es/AeSdkBase.mjs +4 -0
- package/es/AeSdkBase.mjs.map +1 -1
- package/es/AeSdkMethods.d.ts +12 -14
- package/es/AeSdkMethods.mjs +6 -8
- package/es/AeSdkMethods.mjs.map +1 -1
- package/es/AeSdkWallet.mjs +1 -1
- package/es/AeSdkWallet.mjs.map +1 -1
- package/es/Node.d.ts +9 -4
- package/es/Node.mjs +12 -6
- package/es/Node.mjs.map +1 -1
- package/es/account/Base.d.ts +13 -8
- package/es/account/Base.mjs +0 -17
- package/es/account/Base.mjs.map +1 -1
- package/es/account/Generalized.mjs +14 -25
- package/es/account/Generalized.mjs.map +1 -1
- package/es/account/Ledger.mjs +2 -1
- package/es/account/Ledger.mjs.map +1 -1
- package/es/account/LedgerFactory.mjs.map +1 -1
- package/es/account/Memory.d.ts +2 -1
- package/es/account/Memory.mjs +11 -22
- package/es/account/Memory.mjs.map +1 -1
- package/es/account/Rpc.mjs.map +1 -1
- package/es/aens.d.ts +12 -14
- package/es/aens.mjs +22 -32
- package/es/aens.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/Browser.mjs +0 -16
- package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +19 -20
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -16
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection-proxy.mjs +0 -17
- package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -6
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/types.d.ts +6 -2
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
- package/es/aepp-wallet-communication/schema.mjs.map +1 -1
- package/es/aepp-wallet-communication/wallet-detector.mjs +0 -16
- package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
- package/es/apis/compiler/compiler.d.ts +1 -1
- package/es/apis/compiler/compiler.mjs +4 -20
- package/es/apis/compiler/compiler.mjs.map +1 -1
- package/es/apis/compiler/models/index.d.ts +3 -2
- package/es/apis/compiler/models/index.mjs.map +1 -1
- package/es/apis/compiler/models/mappers.d.ts +1 -1
- package/es/apis/compiler/models/mappers.mjs +19 -2
- package/es/apis/compiler/models/mappers.mjs.map +1 -1
- package/es/apis/node/models/index.d.ts +15 -15
- package/es/apis/node/models/index.mjs.map +1 -1
- package/es/apis/node/models/mappers.d.ts +1 -1
- package/es/apis/node/models/mappers.mjs +2 -1
- package/es/apis/node/models/mappers.mjs.map +1 -1
- package/es/apis/node/models/parameters.d.ts +2 -2
- package/es/apis/node/models/parameters.mjs +2 -2
- package/es/apis/node/models/parameters.mjs.map +1 -1
- package/es/apis/node/node.mjs +3 -19
- package/es/apis/node/node.mjs.map +1 -1
- package/es/chain.d.ts +17 -9
- package/es/chain.mjs +23 -23
- package/es/chain.mjs.map +1 -1
- package/es/channel/Base.d.ts +27 -9
- package/es/channel/Base.mjs +27 -27
- package/es/channel/Base.mjs.map +1 -1
- package/es/channel/Contract.d.ts +8 -7
- package/es/channel/Contract.mjs +8 -21
- package/es/channel/Contract.mjs.map +1 -1
- package/es/channel/Spend.d.ts +5 -1
- package/es/channel/Spend.mjs +4 -18
- package/es/channel/Spend.mjs.map +1 -1
- package/es/channel/handlers.mjs +16 -26
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/internal.d.ts +19 -2
- package/es/channel/internal.mjs +22 -20
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Contract.d.ts +43 -123
- package/es/contract/Contract.mjs +230 -250
- package/es/contract/Contract.mjs.map +1 -1
- package/es/contract/compiler/Base.d.ts +74 -0
- package/es/contract/compiler/Base.mjs +5 -0
- package/es/contract/compiler/Base.mjs.map +1 -0
- package/es/contract/compiler/Cli.d.ts +23 -0
- package/es/contract/compiler/Cli.mjs +149 -0
- package/es/contract/compiler/Cli.mjs.map +1 -0
- package/es/contract/compiler/Http.d.ts +32 -0
- package/es/contract/compiler/Http.mjs +94 -0
- package/es/contract/compiler/Http.mjs.map +1 -0
- package/es/contract/compiler/HttpNode.d.ts +17 -0
- package/es/contract/compiler/HttpNode.mjs +26 -0
- package/es/contract/compiler/HttpNode.mjs.map +1 -0
- package/es/contract/compiler/getFileSystem.d.ts +6 -0
- package/es/contract/compiler/getFileSystem.mjs +40 -0
- package/es/contract/compiler/getFileSystem.mjs.map +1 -0
- package/es/contract/delegation-signature.d.ts +43 -0
- package/es/contract/delegation-signature.mjs +45 -0
- package/es/contract/delegation-signature.mjs.map +1 -0
- package/es/contract/ga.d.ts +27 -10
- package/es/contract/ga.mjs +63 -29
- package/es/contract/ga.mjs.map +1 -1
- package/es/index-browser.d.ts +40 -0
- package/es/index-browser.mjs +41 -0
- package/es/index-browser.mjs.map +1 -0
- package/es/index.d.ts +4 -38
- package/es/index.mjs +4 -53
- package/es/index.mjs.map +1 -1
- package/es/oracle.d.ts +12 -17
- package/es/oracle.mjs +29 -49
- package/es/oracle.mjs.map +1 -1
- package/es/spend.d.ts +19 -27
- package/es/spend.mjs +21 -46
- package/es/spend.mjs.map +1 -1
- package/es/tx/builder/SchemaTypes.d.ts +37 -0
- package/es/tx/builder/SchemaTypes.mjs +2 -0
- package/es/tx/builder/SchemaTypes.mjs.map +1 -0
- package/es/tx/builder/constants.d.ts +31 -2
- package/es/tx/builder/constants.mjs +34 -3
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types/abi-version.d.ts +19 -0
- package/es/tx/builder/field-types/abi-version.mjs +40 -0
- package/es/tx/builder/field-types/abi-version.mjs.map +1 -0
- package/es/tx/builder/field-types/address.d.ts +5 -6
- package/es/tx/builder/field-types/address.mjs +17 -8
- package/es/tx/builder/field-types/address.mjs.map +1 -1
- package/es/tx/builder/field-types/array.d.ts +7 -0
- package/es/tx/builder/field-types/array.mjs +11 -0
- package/es/tx/builder/field-types/array.mjs.map +1 -0
- package/es/tx/builder/field-types/boolean.d.ts +6 -0
- package/es/tx/builder/field-types/boolean.mjs +13 -0
- package/es/tx/builder/field-types/boolean.mjs.map +1 -0
- package/es/tx/builder/field-types/coin-amount.d.ts +4 -5
- package/es/tx/builder/field-types/coin-amount.mjs +4 -5
- package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
- package/es/tx/builder/field-types/ct-version.d.ts +49 -0
- package/es/tx/builder/field-types/ct-version.mjs +76 -0
- package/es/tx/builder/field-types/ct-version.mjs.map +1 -0
- package/es/tx/builder/field-types/deposit.d.ts +3 -2
- package/es/tx/builder/field-types/deposit.mjs +3 -2
- package/es/tx/builder/field-types/deposit.mjs.map +1 -1
- package/es/tx/builder/field-types/encoded.d.ts +6 -0
- package/es/tx/builder/field-types/encoded.mjs +21 -0
- package/es/tx/builder/field-types/encoded.mjs.map +1 -0
- package/es/tx/builder/field-types/entry.d.ts +11 -0
- package/es/tx/builder/field-types/entry.mjs +34 -0
- package/es/tx/builder/field-types/entry.mjs.map +1 -0
- package/es/tx/builder/field-types/enumeration.d.ts +5 -3
- package/es/tx/builder/field-types/enumeration.mjs +11 -2
- package/es/tx/builder/field-types/enumeration.mjs.map +1 -1
- package/es/tx/builder/field-types/fee.d.ts +12 -7
- package/es/tx/builder/field-types/fee.mjs +28 -20
- package/es/tx/builder/field-types/fee.mjs.map +1 -1
- package/es/tx/builder/field-types/field.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-limit.d.ts +7 -3
- package/es/tx/builder/field-types/gas-limit.mjs +13 -8
- package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-price.d.ts +3 -1
- package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
- package/es/tx/builder/field-types/index.d.ts +107 -30
- package/es/tx/builder/field-types/index.mjs +38 -12
- package/es/tx/builder/field-types/index.mjs.map +1 -1
- package/es/tx/builder/field-types/map.d.ts +13 -0
- package/es/tx/builder/field-types/map.mjs +49 -0
- package/es/tx/builder/field-types/map.mjs.map +1 -0
- package/es/tx/builder/field-types/mptree.d.ts +42 -0
- package/es/tx/builder/field-types/mptree.mjs +266 -0
- package/es/tx/builder/field-types/mptree.mjs.map +1 -0
- package/es/tx/builder/field-types/name-fee.d.ts +2 -3
- package/es/tx/builder/field-types/name-fee.mjs +2 -2
- package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
- package/es/tx/builder/field-types/name-id.mjs +2 -1
- package/es/tx/builder/field-types/name-id.mjs.map +1 -1
- package/es/tx/builder/field-types/name.mjs.map +1 -1
- package/es/tx/builder/field-types/nonce.d.ts +14 -0
- package/es/tx/builder/field-types/nonce.mjs +29 -0
- package/es/tx/builder/field-types/nonce.mjs.map +1 -0
- package/es/tx/builder/field-types/pointers.mjs +2 -2
- package/es/tx/builder/field-types/pointers.mjs.map +1 -1
- package/es/tx/builder/field-types/raw.d.ts +6 -0
- package/es/tx/builder/field-types/raw.mjs +13 -0
- package/es/tx/builder/field-types/raw.mjs.map +1 -0
- package/es/tx/builder/field-types/short-u-int-const.d.ts +7 -0
- package/es/tx/builder/field-types/short-u-int-const.mjs +20 -0
- package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -0
- package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
- package/es/tx/builder/field-types/string.d.ts +6 -0
- package/es/tx/builder/field-types/string.mjs +10 -0
- package/es/tx/builder/field-types/string.mjs.map +1 -0
- package/es/tx/builder/field-types/ttl.d.ts +11 -0
- package/es/tx/builder/field-types/ttl.mjs +21 -0
- package/es/tx/builder/field-types/ttl.mjs.map +1 -0
- package/es/tx/builder/field-types/u-int.d.ts +1 -2
- package/es/tx/builder/field-types/u-int.mjs.map +1 -1
- package/es/tx/builder/field-types/wrapped.d.ts +14 -0
- package/es/tx/builder/field-types/wrapped.mjs +22 -0
- package/es/tx/builder/field-types/wrapped.mjs.map +1 -0
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +18 -36
- package/es/tx/builder/index.mjs +65 -236
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +2734 -1324
- package/es/tx/builder/schema.generated.d.ts +2011 -0
- package/es/tx/builder/schema.generated.mjs +2 -0
- package/es/tx/builder/schema.generated.mjs.map +1 -0
- package/es/tx/builder/schema.mjs +459 -223
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/execution-cost.d.ts +35 -0
- package/es/tx/execution-cost.mjs +123 -0
- package/es/tx/execution-cost.mjs.map +1 -0
- package/es/tx/transaction-signer.d.ts +6 -0
- package/es/tx/transaction-signer.mjs +27 -0
- package/es/tx/transaction-signer.mjs.map +1 -0
- package/es/tx/validator.d.ts +3 -5
- package/es/tx/validator.mjs +91 -153
- package/es/tx/validator.mjs.map +1 -1
- package/es/utils/amount-formatter.mjs +0 -16
- package/es/utils/amount-formatter.mjs.map +1 -1
- package/es/utils/autorest.d.ts +3 -2
- package/es/utils/autorest.mjs +43 -11
- package/es/utils/autorest.mjs.map +1 -1
- package/es/utils/bytes.mjs +1 -17
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/crypto.mjs +0 -16
- package/es/utils/crypto.mjs.map +1 -1
- package/es/utils/encoder.mjs.map +1 -1
- package/es/utils/errors.d.ts +16 -38
- package/es/utils/errors.mjs +3 -43
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/hd-wallet.mjs.map +1 -1
- package/es/utils/json-big.mjs.map +1 -1
- package/es/utils/keystore.mjs.map +1 -1
- package/es/utils/other.mjs.map +1 -1
- package/es/utils/semver-satisfies.mjs.map +1 -1
- package/es/utils/string.mjs +0 -17
- package/es/utils/string.mjs.map +1 -1
- package/package.json +52 -40
- package/src/AeSdkBase.ts +6 -3
- package/src/AeSdkMethods.ts +12 -18
- package/src/AeSdkWallet.ts +1 -1
- package/src/Node.ts +23 -9
- package/src/account/Base.ts +13 -24
- package/src/account/Generalized.ts +9 -24
- package/src/account/Ledger.ts +1 -1
- package/src/account/Memory.ts +15 -22
- package/src/aens.ts +34 -49
- package/src/aepp-wallet-communication/connection/Browser.ts +0 -17
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +18 -24
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +0 -17
- package/src/aepp-wallet-communication/connection-proxy.ts +0 -17
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +2 -2
- package/src/aepp-wallet-communication/rpc/types.ts +6 -2
- package/src/aepp-wallet-communication/wallet-detector.ts +0 -17
- package/src/apis/compiler/compiler.ts +3 -27
- package/src/apis/compiler/models/index.ts +3 -2
- package/src/apis/compiler/models/mappers.ts +15 -2
- package/src/apis/node/models/index.ts +16 -15
- package/src/apis/node/models/mappers.ts +2 -1
- package/src/apis/node/models/parameters.ts +2 -2
- package/src/apis/node/node.ts +3 -27
- package/src/chain.ts +33 -30
- package/src/channel/Base.ts +39 -31
- package/src/channel/Contract.ts +18 -32
- package/src/channel/Spend.ts +8 -18
- package/src/channel/handlers.ts +14 -26
- package/src/channel/internal.ts +41 -23
- package/src/contract/Contract.ts +188 -228
- package/src/contract/compiler/Base.ts +87 -0
- package/src/contract/compiler/Cli.ts +128 -0
- package/src/contract/compiler/Http.ts +105 -0
- package/src/contract/compiler/HttpNode.ts +26 -0
- package/src/contract/compiler/getFileSystem.ts +42 -0
- package/src/contract/delegation-signature.ts +56 -0
- package/src/contract/ga.ts +61 -37
- package/src/index-browser.ts +50 -0
- package/src/index.ts +4 -56
- package/src/oracle.ts +47 -57
- package/src/spend.ts +34 -68
- package/src/tx/builder/SchemaTypes.ts +79 -0
- package/src/tx/builder/constants.ts +34 -3
- package/src/tx/builder/field-types/abi-version.ts +44 -0
- package/src/tx/builder/field-types/address.ts +23 -13
- package/src/tx/builder/field-types/array.ts +19 -0
- package/src/tx/builder/field-types/boolean.ts +9 -0
- package/src/tx/builder/field-types/coin-amount.ts +8 -5
- package/src/tx/builder/field-types/ct-version.ts +83 -0
- package/src/tx/builder/field-types/deposit.ts +4 -2
- package/src/tx/builder/field-types/encoded.ts +27 -0
- package/src/tx/builder/field-types/entry.ts +36 -0
- package/src/tx/builder/field-types/enumeration.ts +15 -4
- package/src/tx/builder/field-types/fee.ts +41 -19
- package/src/tx/builder/field-types/gas-limit.ts +13 -8
- package/src/tx/builder/field-types/index.ts +60 -17
- package/src/tx/builder/field-types/map.ts +45 -0
- package/src/tx/builder/field-types/mptree.ts +243 -0
- package/src/tx/builder/field-types/name-fee.ts +3 -3
- package/src/tx/builder/field-types/name-id.ts +1 -1
- package/src/tx/builder/field-types/nonce.ts +40 -0
- package/src/tx/builder/field-types/pointers.ts +2 -2
- package/src/tx/builder/field-types/raw.ts +9 -0
- package/src/tx/builder/field-types/short-u-int-const.ts +30 -0
- package/src/tx/builder/field-types/string.ts +11 -0
- package/src/tx/builder/field-types/ttl.ts +24 -0
- package/src/tx/builder/field-types/u-int.ts +1 -3
- package/src/tx/builder/field-types/wrapped.ts +32 -0
- package/src/tx/builder/index.ts +82 -280
- package/src/tx/builder/schema.generated.ts +2013 -0
- package/src/tx/builder/schema.ts +536 -666
- package/src/tx/execution-cost.ts +146 -0
- package/src/tx/transaction-signer.ts +27 -0
- package/src/tx/validator.ts +100 -154
- package/src/utils/amount-formatter.ts +0 -16
- package/src/utils/autorest.ts +52 -11
- package/src/utils/bytes.ts +1 -17
- package/src/utils/crypto.ts +0 -16
- package/src/utils/errors.ts +18 -56
- package/src/utils/string.ts +0 -17
- package/types-legacy/ts4.2/AeSdkBase.d.ts +3 -3
- package/types-legacy/ts4.2/AeSdkMethods.d.ts +12 -14
- package/types-legacy/ts4.2/Node.d.ts +8 -4
- package/types-legacy/ts4.2/account/Base.d.ts +13 -8
- package/types-legacy/ts4.2/account/Memory.d.ts +2 -1
- package/types-legacy/ts4.2/aens.d.ts +12 -14
- package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +6 -2
- package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +1 -1
- package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +3 -2
- package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +1 -1
- package/types-legacy/ts4.2/apis/node/models/index.d.ts +15 -15
- package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +1 -1
- package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +2 -2
- package/types-legacy/ts4.2/chain.d.ts +17 -9
- package/types-legacy/ts4.2/channel/Base.d.ts +27 -9
- package/types-legacy/ts4.2/channel/Contract.d.ts +8 -7
- package/types-legacy/ts4.2/channel/Spend.d.ts +5 -1
- package/types-legacy/ts4.2/channel/internal.d.ts +22 -2
- package/types-legacy/ts4.2/contract/Contract.d.ts +42 -122
- package/types-legacy/ts4.2/contract/compiler/Base.d.ts +74 -0
- package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +23 -0
- package/types-legacy/ts4.2/contract/compiler/Http.d.ts +32 -0
- package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +17 -0
- package/types-legacy/ts4.2/contract/compiler/getFileSystem.d.ts +6 -0
- package/types-legacy/ts4.2/contract/delegation-signature.d.ts +43 -0
- package/types-legacy/ts4.2/contract/ga.d.ts +27 -10
- package/types-legacy/ts4.2/index-browser.d.ts +40 -0
- package/types-legacy/ts4.2/index.d.ts +4 -38
- package/types-legacy/ts4.2/oracle.d.ts +12 -17
- package/types-legacy/ts4.2/spend.d.ts +19 -27
- package/types-legacy/ts4.2/tx/builder/SchemaTypes.d.ts +37 -0
- package/types-legacy/ts4.2/tx/builder/constants.d.ts +31 -2
- package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +19 -0
- package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +11 -12
- package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +7 -0
- package/types-legacy/ts4.2/tx/builder/field-types/boolean.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +4 -5
- package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +72 -0
- package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +3 -2
- package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/entry.d.ts +11 -0
- package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +5 -3
- package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +12 -7
- package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +7 -3
- package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +3 -1
- package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +113 -30
- package/types-legacy/ts4.2/tx/builder/field-types/map.d.ts +13 -0
- package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +48 -0
- package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +2 -3
- package/types-legacy/ts4.2/tx/builder/field-types/nonce.d.ts +14 -0
- package/types-legacy/ts4.2/tx/builder/field-types/raw.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +7 -0
- package/types-legacy/ts4.2/tx/builder/field-types/string.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +11 -0
- package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +1 -2
- package/types-legacy/ts4.2/tx/builder/field-types/wrapped.d.ts +14 -0
- package/types-legacy/ts4.2/tx/builder/index.d.ts +21 -36
- package/types-legacy/ts4.2/tx/builder/schema.d.ts +2971 -2926
- package/types-legacy/ts4.2/tx/builder/schema.generated.d.ts +2011 -0
- package/types-legacy/ts4.2/tx/execution-cost.d.ts +35 -0
- package/types-legacy/ts4.2/tx/transaction-signer.d.ts +6 -0
- package/types-legacy/ts4.2/tx/validator.d.ts +3 -5
- package/types-legacy/ts4.2/utils/autorest.d.ts +3 -2
- package/types-legacy/ts4.2/utils/errors.d.ts +16 -38
- package/types-legacy/ts4.5/AeSdkBase.d.ts +3 -3
- package/types-legacy/ts4.5/AeSdkMethods.d.ts +12 -14
- package/types-legacy/ts4.5/Node.d.ts +8 -4
- package/types-legacy/ts4.5/account/Base.d.ts +13 -8
- package/types-legacy/ts4.5/account/Memory.d.ts +2 -1
- package/types-legacy/ts4.5/aens.d.ts +12 -14
- package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +6 -2
- package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +1 -1
- package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +3 -2
- package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +1 -1
- package/types-legacy/ts4.5/apis/node/models/index.d.ts +15 -15
- package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +1 -1
- package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +2 -2
- package/types-legacy/ts4.5/chain.d.ts +17 -9
- package/types-legacy/ts4.5/channel/Base.d.ts +27 -9
- package/types-legacy/ts4.5/channel/Contract.d.ts +8 -7
- package/types-legacy/ts4.5/channel/Spend.d.ts +5 -1
- package/types-legacy/ts4.5/channel/internal.d.ts +22 -2
- package/types-legacy/ts4.5/contract/Contract.d.ts +42 -122
- package/types-legacy/ts4.5/contract/compiler/Base.d.ts +74 -0
- package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +23 -0
- package/types-legacy/ts4.5/contract/compiler/Http.d.ts +32 -0
- package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +17 -0
- package/types-legacy/ts4.5/contract/compiler/getFileSystem.d.ts +6 -0
- package/types-legacy/ts4.5/contract/delegation-signature.d.ts +43 -0
- package/types-legacy/ts4.5/contract/ga.d.ts +27 -10
- package/types-legacy/ts4.5/index-browser.d.ts +40 -0
- package/types-legacy/ts4.5/index.d.ts +4 -38
- package/types-legacy/ts4.5/oracle.d.ts +12 -17
- package/types-legacy/ts4.5/spend.d.ts +19 -27
- package/types-legacy/ts4.5/tx/builder/SchemaTypes.d.ts +37 -0
- package/types-legacy/ts4.5/tx/builder/constants.d.ts +31 -2
- package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +19 -0
- package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +11 -12
- package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +7 -0
- package/types-legacy/ts4.5/tx/builder/field-types/boolean.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +4 -5
- package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +72 -0
- package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +3 -2
- package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/entry.d.ts +11 -0
- package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +5 -3
- package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +12 -7
- package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +7 -3
- package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +3 -1
- package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +113 -30
- package/types-legacy/ts4.5/tx/builder/field-types/map.d.ts +13 -0
- package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +48 -0
- package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +2 -3
- package/types-legacy/ts4.5/tx/builder/field-types/nonce.d.ts +14 -0
- package/types-legacy/ts4.5/tx/builder/field-types/raw.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +7 -0
- package/types-legacy/ts4.5/tx/builder/field-types/string.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +11 -0
- package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +1 -2
- package/types-legacy/ts4.5/tx/builder/field-types/wrapped.d.ts +14 -0
- package/types-legacy/ts4.5/tx/builder/index.d.ts +21 -36
- package/types-legacy/ts4.5/tx/builder/schema.d.ts +2971 -2926
- package/types-legacy/ts4.5/tx/builder/schema.generated.d.ts +2011 -0
- package/types-legacy/ts4.5/tx/execution-cost.d.ts +35 -0
- package/types-legacy/ts4.5/tx/transaction-signer.d.ts +6 -0
- package/types-legacy/ts4.5/tx/validator.d.ts +3 -5
- package/types-legacy/ts4.5/utils/autorest.d.ts +3 -2
- package/types-legacy/ts4.5/utils/errors.d.ts +16 -38
- package/es/contract/CompilerHttp.d.ts +0 -18
- package/es/contract/CompilerHttp.mjs +0 -63
- package/es/contract/CompilerHttp.mjs.map +0 -1
- package/es/tx/builder/field-types/addresses.d.ts +0 -6
- package/es/tx/builder/field-types/addresses.mjs +0 -13
- package/es/tx/builder/field-types/addresses.mjs.map +0 -1
- package/es/tx/index.d.ts +0 -34
- package/es/tx/index.mjs +0 -172
- package/es/tx/index.mjs.map +0 -1
- package/es/utils/mptree.d.ts +0 -26
- package/es/utils/mptree.mjs +0 -143
- package/es/utils/mptree.mjs.map +0 -1
- package/src/apis/compiler/code-model-v4.yaml +0 -2442
- package/src/apis/node/code-model-v4.yaml +0 -10080
- package/src/contract/CompilerHttp.ts +0 -67
- package/src/tx/builder/field-types/addresses.ts +0 -18
- package/src/tx/index.ts +0 -196
- package/src/utils/mptree.ts +0 -145
- package/types-legacy/ts4.2/contract/CompilerHttp.d.ts +0 -18
- package/types-legacy/ts4.2/tx/builder/field-types/addresses.d.ts +0 -6
- package/types-legacy/ts4.2/tx/index.d.ts +0 -34
- package/types-legacy/ts4.2/utils/mptree.d.ts +0 -32
- package/types-legacy/ts4.5/contract/CompilerHttp.d.ts +0 -18
- package/types-legacy/ts4.5/tx/builder/field-types/addresses.d.ts +0 -6
- package/types-legacy/ts4.5/tx/index.d.ts +0 -34
- package/types-legacy/ts4.5/utils/mptree.d.ts +0 -32
package/es/index.d.ts
CHANGED
|
@@ -1,38 +1,4 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export * from './tx';
|
|
6
|
-
export * from './tx/builder';
|
|
7
|
-
export * from './tx/builder/helpers';
|
|
8
|
-
export * from './tx/builder/constants';
|
|
9
|
-
export * from './tx/builder/schema';
|
|
10
|
-
export * from './utils/amount-formatter';
|
|
11
|
-
export * from './utils/hd-wallet';
|
|
12
|
-
export { encode, decode, Encoding } from './utils/encoder';
|
|
13
|
-
export * from './aens';
|
|
14
|
-
export { default as Contract } from './contract/Contract';
|
|
15
|
-
export type { ContractMethodsBase } from './contract/Contract';
|
|
16
|
-
export * from './oracle';
|
|
17
|
-
export * from './spend';
|
|
18
|
-
export * from './contract/ga';
|
|
19
|
-
export { default as AeSdkMethods } from './AeSdkMethods';
|
|
20
|
-
export { default as AeSdkBase } from './AeSdkBase';
|
|
21
|
-
export { default as AeSdk } from './AeSdk';
|
|
22
|
-
export { default as AeSdkAepp } from './AeSdkAepp';
|
|
23
|
-
export { default as AeSdkWallet } from './AeSdkWallet';
|
|
24
|
-
export { default as Node } from './Node';
|
|
25
|
-
export { default as verifyTransaction } from './tx/validator';
|
|
26
|
-
export { default as AccountBase } from './account/Base';
|
|
27
|
-
export { default as MemoryAccount } from './account/Memory';
|
|
28
|
-
export { default as AccountGeneralized } from './account/Generalized';
|
|
29
|
-
export { default as AccountLedger } from './account/Ledger';
|
|
30
|
-
export { default as AccountLedgerFactory } from './account/LedgerFactory';
|
|
31
|
-
export { default as CompilerHttp } from './contract/CompilerHttp';
|
|
32
|
-
export { default as Channel } from './channel/Contract';
|
|
33
|
-
export { default as connectionProxy } from './aepp-wallet-communication/connection-proxy';
|
|
34
|
-
export * from './aepp-wallet-communication/schema';
|
|
35
|
-
export { default as walletDetector } from './aepp-wallet-communication/wallet-detector';
|
|
36
|
-
export { default as BrowserRuntimeConnection } from './aepp-wallet-communication/connection/BrowserRuntime';
|
|
37
|
-
export { default as BrowserWindowMessageConnection } from './aepp-wallet-communication/connection/BrowserWindowMessage';
|
|
38
|
-
export * from './utils/errors';
|
|
1
|
+
export * from './index-browser';
|
|
2
|
+
export { default as CompilerCli } from './contract/compiler/Cli';
|
|
3
|
+
export { default as getFileSystem } from './contract/compiler/getFileSystem';
|
|
4
|
+
export { default as CompilerHttpNode } from './contract/compiler/HttpNode';
|
package/es/index.mjs
CHANGED
|
@@ -1,54 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
export * from "./chain.mjs";
|
|
18
|
-
export * from "./utils/crypto.mjs";
|
|
19
|
-
export * from "./utils/keystore.mjs";
|
|
20
|
-
export * from "./utils/bytes.mjs";
|
|
21
|
-
export * from "./tx/index.mjs";
|
|
22
|
-
export * from "./tx/builder/index.mjs";
|
|
23
|
-
export * from "./tx/builder/helpers.mjs";
|
|
24
|
-
export * from "./tx/builder/constants.mjs";
|
|
25
|
-
export * from "./tx/builder/schema.mjs";
|
|
26
|
-
export * from "./utils/amount-formatter.mjs";
|
|
27
|
-
export * from "./utils/hd-wallet.mjs";
|
|
28
|
-
export { encode, decode, Encoding } from "./utils/encoder.mjs";
|
|
29
|
-
export * from "./aens.mjs";
|
|
30
|
-
export { default as Contract } from "./contract/Contract.mjs";
|
|
31
|
-
export * from "./oracle.mjs";
|
|
32
|
-
export * from "./spend.mjs";
|
|
33
|
-
export * from "./contract/ga.mjs";
|
|
34
|
-
export { default as AeSdkMethods } from "./AeSdkMethods.mjs";
|
|
35
|
-
export { default as AeSdkBase } from "./AeSdkBase.mjs";
|
|
36
|
-
export { default as AeSdk } from "./AeSdk.mjs";
|
|
37
|
-
export { default as AeSdkAepp } from "./AeSdkAepp.mjs";
|
|
38
|
-
export { default as AeSdkWallet } from "./AeSdkWallet.mjs";
|
|
39
|
-
export { default as Node } from "./Node.mjs";
|
|
40
|
-
export { default as verifyTransaction } from "./tx/validator.mjs";
|
|
41
|
-
export { default as AccountBase } from "./account/Base.mjs";
|
|
42
|
-
export { default as MemoryAccount } from "./account/Memory.mjs";
|
|
43
|
-
export { default as AccountGeneralized } from "./account/Generalized.mjs";
|
|
44
|
-
export { default as AccountLedger } from "./account/Ledger.mjs";
|
|
45
|
-
export { default as AccountLedgerFactory } from "./account/LedgerFactory.mjs";
|
|
46
|
-
export { default as CompilerHttp } from "./contract/CompilerHttp.mjs";
|
|
47
|
-
export { default as Channel } from "./channel/Contract.mjs";
|
|
48
|
-
export { default as connectionProxy } from "./aepp-wallet-communication/connection-proxy.mjs";
|
|
49
|
-
export * from "./aepp-wallet-communication/schema.mjs";
|
|
50
|
-
export { default as walletDetector } from "./aepp-wallet-communication/wallet-detector.mjs";
|
|
51
|
-
export { default as BrowserRuntimeConnection } from "./aepp-wallet-communication/connection/BrowserRuntime.mjs";
|
|
52
|
-
export { default as BrowserWindowMessageConnection } from "./aepp-wallet-communication/connection/BrowserWindowMessage.mjs";
|
|
53
|
-
export * from "./utils/errors.mjs";
|
|
1
|
+
export * from "./index-browser.mjs";
|
|
2
|
+
export { default as CompilerCli } from "./contract/compiler/Cli.mjs";
|
|
3
|
+
export { default as getFileSystem } from "./contract/compiler/getFileSystem.mjs";
|
|
4
|
+
export { default as CompilerHttpNode } from "./contract/compiler/HttpNode.mjs";
|
|
54
5
|
//# sourceMappingURL=index.mjs.map
|
package/es/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["default","CompilerCli","getFileSystem","CompilerHttpNode"],"sources":["../src/index.ts"],"sourcesContent":["export * from './index-browser';\n\nexport { default as CompilerCli } from './contract/compiler/Cli';\nexport { default as getFileSystem } from './contract/compiler/getFileSystem';\nexport { default as CompilerHttpNode } from './contract/compiler/HttpNode';\n"],"mappings":";SAESA,OAAO,IAAIC,WAAW;AAAA,SACtBD,OAAO,IAAIE,aAAa;AAAA,SACxBF,OAAO,IAAIG,gBAAgB"}
|
package/es/oracle.d.ts
CHANGED
|
@@ -5,13 +5,11 @@
|
|
|
5
5
|
* https://github.com/aeternity/protocol/blob/master/ORACLE.md in the protocol
|
|
6
6
|
* repository.
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import { send, SendOptions } from './spend';
|
|
8
|
+
import { BuildTxOptions } from './tx/builder';
|
|
10
9
|
import { ORACLE_TTL_TYPES } from './tx/builder/schema';
|
|
11
10
|
import { Tag } from './tx/builder/constants';
|
|
12
11
|
import { Encoded } from './utils/encoder';
|
|
13
|
-
import { _getPollInterval } from './chain';
|
|
14
|
-
import { BuildTxOptions } from './tx';
|
|
12
|
+
import { _getPollInterval, sendTransaction, SendTransactionOptions } from './chain';
|
|
15
13
|
import Node from './Node';
|
|
16
14
|
import AccountBase from './account/Base';
|
|
17
15
|
type OracleQueries = Awaited<ReturnType<Node['getOracleQueriesByPubkey']>>['oracleQueries'];
|
|
@@ -25,7 +23,7 @@ type OracleQueries = Awaited<ReturnType<Node['getOracleQueriesByPubkey']>>['orac
|
|
|
25
23
|
* @param options.onNode - Node to use
|
|
26
24
|
* @returns Callback to stop polling function
|
|
27
25
|
*/
|
|
28
|
-
export declare function pollForQueries(oracleId: Encoded.OracleAddress, onQuery: (
|
|
26
|
+
export declare function pollForQueries(oracleId: Encoded.OracleAddress, onQuery: (query: OracleQueries[number]) => void, { interval, onNode, ...options }: {
|
|
29
27
|
interval?: number;
|
|
30
28
|
onNode: Node;
|
|
31
29
|
} & Parameters<typeof _getPollInterval>[1]): () => void;
|
|
@@ -55,7 +53,7 @@ export declare function getQueryObject(oracleId: Encoded.OracleAddress, queryId:
|
|
|
55
53
|
interface GetQueryObjectReturnType extends Awaited<ReturnType<Node['getOracleQueryByPubkeyAndQueryId']>> {
|
|
56
54
|
decodedQuery: string;
|
|
57
55
|
decodedResponse: string;
|
|
58
|
-
respond: (response: string, options?: Parameters<typeof respondToQuery>[
|
|
56
|
+
respond: (response: string, options?: Parameters<typeof respondToQuery>[2]) => ReturnType<typeof respondToQuery>;
|
|
59
57
|
pollForResponse: (options?: Parameters<typeof pollForQueryResponse>[2]) => ReturnType<typeof pollForQueryResponse>;
|
|
60
58
|
}
|
|
61
59
|
/**
|
|
@@ -71,8 +69,8 @@ interface GetQueryObjectReturnType extends Awaited<ReturnType<Node['getOracleQue
|
|
|
71
69
|
* @param options.ttl - Transaction time to leave
|
|
72
70
|
* @returns Query object
|
|
73
71
|
*/
|
|
74
|
-
export declare function postQueryToOracle(oracleId: Encoded.OracleAddress, query: string, options: PostQueryToOracleOptions): Promise<Awaited<ReturnType<typeof
|
|
75
|
-
type PostQueryToOracleOptionsType = Parameters<typeof
|
|
72
|
+
export declare function postQueryToOracle(oracleId: Encoded.OracleAddress, query: string, options: PostQueryToOracleOptions): Promise<Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getQueryObject>>>;
|
|
73
|
+
type PostQueryToOracleOptionsType = Parameters<typeof sendTransaction>[1] & Parameters<typeof getQueryObject>[2] & BuildTxOptions<Tag.OracleQueryTx, 'oracleId' | 'senderId' | 'query' | 'queryTtlType' | 'queryTtlValue' | 'responseTtlType' | 'responseTtlValue'> & {
|
|
76
74
|
queryTtlType?: ORACLE_TTL_TYPES;
|
|
77
75
|
queryTtlValue?: number;
|
|
78
76
|
responseTtlType?: ORACLE_TTL_TYPES;
|
|
@@ -83,7 +81,6 @@ interface PostQueryToOracleOptions extends PostQueryToOracleOptionsType {
|
|
|
83
81
|
/**
|
|
84
82
|
* Extend oracle ttl
|
|
85
83
|
* @category oracle
|
|
86
|
-
* @param oracleId - Oracle public key
|
|
87
84
|
* @param options - Options object
|
|
88
85
|
* @param options.fee - fee Transaction fee
|
|
89
86
|
* @param options.ttl - Transaction time to leave
|
|
@@ -91,8 +88,8 @@ interface PostQueryToOracleOptions extends PostQueryToOracleOptionsType {
|
|
|
91
88
|
* @param options.oracleTtlValue - Oracle time to leave for extend
|
|
92
89
|
* @returns Oracle object
|
|
93
90
|
*/
|
|
94
|
-
export declare function extendOracleTtl(
|
|
95
|
-
type ExtendOracleTtlOptionsType =
|
|
91
|
+
export declare function extendOracleTtl(options: ExtendOracleTtlOptions): Promise<Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getOracleObject>>>;
|
|
92
|
+
type ExtendOracleTtlOptionsType = SendTransactionOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<Tag.OracleExtendTx, 'oracleTtlType' | 'oracleTtlValue' | 'callerId' | 'oracleId'> & {
|
|
96
93
|
oracleTtlType?: ORACLE_TTL_TYPES;
|
|
97
94
|
oracleTtlValue?: number;
|
|
98
95
|
};
|
|
@@ -101,7 +98,6 @@ interface ExtendOracleTtlOptions extends ExtendOracleTtlOptionsType {
|
|
|
101
98
|
/**
|
|
102
99
|
* Extend oracle ttl
|
|
103
100
|
* @category oracle
|
|
104
|
-
* @param oracleId - Oracle public key
|
|
105
101
|
* @param queryId - Oracle query id
|
|
106
102
|
* @param response - Oracle query response
|
|
107
103
|
* @param options - Options object
|
|
@@ -110,8 +106,8 @@ interface ExtendOracleTtlOptions extends ExtendOracleTtlOptionsType {
|
|
|
110
106
|
* @param options.ttl - Transaction time to leave
|
|
111
107
|
* @returns Oracle object
|
|
112
108
|
*/
|
|
113
|
-
export declare function respondToQuery(
|
|
114
|
-
type RespondToQueryOptionsType =
|
|
109
|
+
export declare function respondToQuery(queryId: Encoded.OracleQueryId, response: string, options: RespondToQueryOptions): Promise<Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getOracleObject>>>;
|
|
110
|
+
type RespondToQueryOptionsType = SendTransactionOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<Tag.OracleResponseTx, 'callerId' | 'oracleId' | 'queryId' | 'response' | 'responseTtlType' | 'responseTtlValue'> & {
|
|
115
111
|
responseTtlType?: ORACLE_TTL_TYPES;
|
|
116
112
|
responseTtlValue?: number;
|
|
117
113
|
};
|
|
@@ -150,9 +146,8 @@ interface GetOracleObjectReturnType extends Awaited<ReturnType<Node['getOracleBy
|
|
|
150
146
|
* @param options.ttl - Transaction time to leave
|
|
151
147
|
* @returns Oracle object
|
|
152
148
|
*/
|
|
153
|
-
export declare function registerOracle(queryFormat: string, responseFormat: string, options: RegisterOracleOptions): Promise<Awaited<ReturnType<typeof
|
|
154
|
-
type RegisterOracleOptionsType =
|
|
155
|
-
queryFee?: number | string | BigNumber;
|
|
149
|
+
export declare function registerOracle(queryFormat: string, responseFormat: string, options: RegisterOracleOptions): Promise<Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getOracleObject>>>;
|
|
150
|
+
type RegisterOracleOptionsType = SendTransactionOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<Tag.OracleRegisterTx, 'accountId' | 'queryFormat' | 'responseFormat' | 'oracleTtlType' | 'oracleTtlValue'> & {
|
|
156
151
|
oracleTtlType?: ORACLE_TTL_TYPES;
|
|
157
152
|
oracleTtlValue?: number;
|
|
158
153
|
};
|
package/es/oracle.mjs
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
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
1
|
/**
|
|
18
2
|
* Oracle methods - routines to interact with the æternity oracle system
|
|
19
3
|
*
|
|
@@ -21,16 +5,14 @@
|
|
|
21
5
|
* https://github.com/aeternity/protocol/blob/master/ORACLE.md in the protocol
|
|
22
6
|
* repository.
|
|
23
7
|
*/
|
|
24
|
-
import { send } from "./spend.mjs";
|
|
25
8
|
import { mapObject, pause } from "./utils/other.mjs";
|
|
26
9
|
import { oracleQueryId } from "./tx/builder/helpers.mjs";
|
|
27
|
-
import { unpackTx } from "./tx/builder/index.mjs";
|
|
28
|
-
import { ORACLE_TTL,
|
|
10
|
+
import { unpackTx, buildTxAsync } from "./tx/builder/index.mjs";
|
|
11
|
+
import { ORACLE_TTL, QUERY_TTL, RESPONSE_TTL } from "./tx/builder/schema.mjs";
|
|
29
12
|
import { Tag } from "./tx/builder/constants.mjs";
|
|
30
13
|
import { RequestTimedOutError } from "./utils/errors.mjs";
|
|
31
14
|
import { decode, encode, Encoding } from "./utils/encoder.mjs";
|
|
32
|
-
import { _getPollInterval, getHeight } from "./chain.mjs";
|
|
33
|
-
import { _buildTx } from "./tx/index.mjs";
|
|
15
|
+
import { _getPollInterval, getHeight, sendTransaction } from "./chain.mjs";
|
|
34
16
|
/**
|
|
35
17
|
* Poll for oracle queries
|
|
36
18
|
* @category oracle
|
|
@@ -58,13 +40,10 @@ export function pollForQueries(oracleId, onQuery, _ref) {
|
|
|
58
40
|
} = _ref2;
|
|
59
41
|
return !knownQueryIds.has(id);
|
|
60
42
|
});
|
|
61
|
-
queries.forEach(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
} = _ref3;
|
|
65
|
-
return knownQueryIds.add(id);
|
|
43
|
+
queries.forEach(query => {
|
|
44
|
+
knownQueryIds.add(query.id);
|
|
45
|
+
onQuery(query);
|
|
66
46
|
});
|
|
67
|
-
if (queries.length > 0) onQuery(queries);
|
|
68
47
|
};
|
|
69
48
|
let stopped = false;
|
|
70
49
|
|
|
@@ -92,13 +71,13 @@ export function pollForQueries(oracleId, onQuery, _ref) {
|
|
|
92
71
|
* @param options.onNode - Node to use
|
|
93
72
|
* @returns OracleQuery object
|
|
94
73
|
*/
|
|
95
|
-
export async function pollForQueryResponse(oracleId, queryId,
|
|
74
|
+
export async function pollForQueryResponse(oracleId, queryId, _ref3) {
|
|
96
75
|
var _interval2;
|
|
97
76
|
let {
|
|
98
77
|
interval,
|
|
99
78
|
onNode,
|
|
100
79
|
...options
|
|
101
|
-
} =
|
|
80
|
+
} = _ref3;
|
|
102
81
|
(_interval2 = interval) !== null && _interval2 !== void 0 ? _interval2 : interval = _getPollInterval('microblock', options);
|
|
103
82
|
let height;
|
|
104
83
|
let ttl;
|
|
@@ -134,7 +113,7 @@ export async function getQueryObject(oracleId, queryId, options) {
|
|
|
134
113
|
decodedResponse: decode(record.response).toString(),
|
|
135
114
|
respond: async (response, opt) =>
|
|
136
115
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
137
|
-
respondToQuery(
|
|
116
|
+
respondToQuery(queryId, response, {
|
|
138
117
|
...options,
|
|
139
118
|
...opt
|
|
140
119
|
}),
|
|
@@ -161,29 +140,29 @@ export async function postQueryToOracle(oracleId, query, options) {
|
|
|
161
140
|
var _options$queryFee;
|
|
162
141
|
(_options$queryFee = options.queryFee) !== null && _options$queryFee !== void 0 ? _options$queryFee : options.queryFee = (await options.onNode.getOracleByPubkey(oracleId)).queryFee.toString();
|
|
163
142
|
const senderId = options.onAccount.address;
|
|
164
|
-
const oracleQueryTx = await
|
|
143
|
+
const oracleQueryTx = await buildTxAsync({
|
|
165
144
|
queryTtlType: QUERY_TTL.type,
|
|
166
145
|
queryTtlValue: QUERY_TTL.value,
|
|
167
146
|
responseTtlType: RESPONSE_TTL.type,
|
|
168
147
|
responseTtlValue: RESPONSE_TTL.value,
|
|
169
148
|
...options,
|
|
149
|
+
tag: Tag.OracleQueryTx,
|
|
170
150
|
oracleId,
|
|
171
151
|
senderId,
|
|
172
152
|
query
|
|
173
153
|
});
|
|
174
154
|
const {
|
|
175
155
|
nonce
|
|
176
|
-
} = unpackTx(oracleQueryTx, Tag.OracleQueryTx)
|
|
156
|
+
} = unpackTx(oracleQueryTx, Tag.OracleQueryTx);
|
|
177
157
|
const queryId = oracleQueryId(senderId, nonce, oracleId);
|
|
178
158
|
return {
|
|
179
|
-
...(await
|
|
159
|
+
...(await sendTransaction(oracleQueryTx, options)),
|
|
180
160
|
...(await getQueryObject(oracleId, queryId, options))
|
|
181
161
|
};
|
|
182
162
|
}
|
|
183
163
|
/**
|
|
184
164
|
* Extend oracle ttl
|
|
185
165
|
* @category oracle
|
|
186
|
-
* @param oracleId - Oracle public key
|
|
187
166
|
* @param options - Options object
|
|
188
167
|
* @param options.fee - fee Transaction fee
|
|
189
168
|
* @param options.ttl - Transaction time to leave
|
|
@@ -191,16 +170,17 @@ export async function postQueryToOracle(oracleId, query, options) {
|
|
|
191
170
|
* @param options.oracleTtlValue - Oracle time to leave for extend
|
|
192
171
|
* @returns Oracle object
|
|
193
172
|
*/
|
|
194
|
-
export async function extendOracleTtl(
|
|
195
|
-
const
|
|
173
|
+
export async function extendOracleTtl(options) {
|
|
174
|
+
const oracleId = encode(decode(options.onAccount.address), Encoding.OracleAddress);
|
|
175
|
+
const oracleExtendTx = await buildTxAsync({
|
|
196
176
|
oracleTtlType: ORACLE_TTL.type,
|
|
197
177
|
oracleTtlValue: ORACLE_TTL.value,
|
|
198
178
|
...options,
|
|
199
|
-
|
|
179
|
+
tag: Tag.OracleExtendTx,
|
|
200
180
|
oracleId
|
|
201
181
|
});
|
|
202
182
|
return {
|
|
203
|
-
...(await
|
|
183
|
+
...(await sendTransaction(oracleExtendTx, options)),
|
|
204
184
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
205
185
|
...(await getOracleObject(oracleId, options))
|
|
206
186
|
};
|
|
@@ -208,7 +188,6 @@ export async function extendOracleTtl(oracleId, options) {
|
|
|
208
188
|
/**
|
|
209
189
|
* Extend oracle ttl
|
|
210
190
|
* @category oracle
|
|
211
|
-
* @param oracleId - Oracle public key
|
|
212
191
|
* @param queryId - Oracle query id
|
|
213
192
|
* @param response - Oracle query response
|
|
214
193
|
* @param options - Options object
|
|
@@ -217,18 +196,19 @@ export async function extendOracleTtl(oracleId, options) {
|
|
|
217
196
|
* @param options.ttl - Transaction time to leave
|
|
218
197
|
* @returns Oracle object
|
|
219
198
|
*/
|
|
220
|
-
export async function respondToQuery(
|
|
221
|
-
const
|
|
199
|
+
export async function respondToQuery(queryId, response, options) {
|
|
200
|
+
const oracleId = encode(decode(options.onAccount.address), Encoding.OracleAddress);
|
|
201
|
+
const oracleRespondTx = await buildTxAsync({
|
|
222
202
|
responseTtlType: RESPONSE_TTL.type,
|
|
223
203
|
responseTtlValue: RESPONSE_TTL.value,
|
|
224
204
|
...options,
|
|
225
|
-
|
|
205
|
+
tag: Tag.OracleResponseTx,
|
|
226
206
|
oracleId,
|
|
227
207
|
queryId,
|
|
228
208
|
response
|
|
229
209
|
});
|
|
230
210
|
return {
|
|
231
|
-
...(await
|
|
211
|
+
...(await sendTransaction(oracleRespondTx, options)),
|
|
232
212
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
233
213
|
...(await getOracleObject(oracleId, options))
|
|
234
214
|
};
|
|
@@ -250,8 +230,8 @@ export async function getOracleObject(oracleId, options) {
|
|
|
250
230
|
respondToQuery,
|
|
251
231
|
extendOracle: extendOracleTtl,
|
|
252
232
|
getQuery: getQueryObject
|
|
253
|
-
},
|
|
254
|
-
let [name, handler] =
|
|
233
|
+
}, _ref4 => {
|
|
234
|
+
let [name, handler] = _ref4;
|
|
255
235
|
return [name, function () {
|
|
256
236
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
257
237
|
args[_key] = arguments[_key];
|
|
@@ -263,7 +243,7 @@ export async function getOracleObject(oracleId, options) {
|
|
|
263
243
|
...lastArg
|
|
264
244
|
});
|
|
265
245
|
} else args.push(options);
|
|
266
|
-
return handler(oracleId, ...args);
|
|
246
|
+
return handler(...(['extendOracle', 'respondToQuery'].includes(name) ? [] : [oracleId]), ...args);
|
|
267
247
|
}];
|
|
268
248
|
})
|
|
269
249
|
};
|
|
@@ -283,17 +263,17 @@ export async function getOracleObject(oracleId, options) {
|
|
|
283
263
|
*/
|
|
284
264
|
export async function registerOracle(queryFormat, responseFormat, options) {
|
|
285
265
|
const accountId = options.onAccount.address;
|
|
286
|
-
const oracleRegisterTx = await
|
|
287
|
-
queryFee: QUERY_FEE,
|
|
266
|
+
const oracleRegisterTx = await buildTxAsync({
|
|
288
267
|
oracleTtlValue: ORACLE_TTL.value,
|
|
289
268
|
oracleTtlType: ORACLE_TTL.type,
|
|
290
269
|
...options,
|
|
270
|
+
tag: Tag.OracleRegisterTx,
|
|
291
271
|
accountId,
|
|
292
272
|
queryFormat,
|
|
293
273
|
responseFormat
|
|
294
274
|
});
|
|
295
275
|
return {
|
|
296
|
-
...(await
|
|
276
|
+
...(await sendTransaction(oracleRegisterTx, options)),
|
|
297
277
|
...(await getOracleObject(encode(decode(accountId), Encoding.OracleAddress), options))
|
|
298
278
|
};
|
|
299
279
|
}
|
package/es/oracle.mjs.map
CHANGED
|
@@ -1 +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","getHeight","_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","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, getHeight } 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 ({ response, ttl } = await onNode.getOracleQueryByPubkeyAndQueryId(oracleId, queryId));\n const responseBuffer = decode(response as Encoded.OracleResponse);\n if (responseBuffer.length > 0) return responseBuffer.toString();\n await pause(interval);\n height = await getHeight({ onNode });\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 = options.onAccount.address;\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: options.onAccount.address,\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: options.onAccount.address,\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 = options.onAccount.address;\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;AANA,SASSA,IAAI;AAAA,SACJC,SAAS,EAAEC,KAAK;AAAA,SAChBC,aAAa;AAAA,SACbC,QAAQ;AAAA,SAEfC,UAAU,EAEVC,SAAS,EACTC,SAAS,EACTC,YAAY;AAAA,SAELC,GAAG;AAAA,SACHC,oBAAoB;AAAA,SAE3BC,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAE1BC,gBAAgB,EAAEC,SAAS;AAAA,SAC3BC,QAAQ;AAMjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAc,CAC5BC,QAA+B,EAC/BC,OAAyC,QAG7B;EAAA;EAAA,IAFZ;IAAEC,QAAQ;IAAEC,MAAM;IAAE,GAAGC;EACgB,CAAC;EAExC,aAAAF,QAAQ,iDAARA,QAAQ,GAAKN,gBAAgB,CAAC,YAAY,EAAEQ,OAAO,CAAC;EACpD,MAAMC,aAAa,GAAG,IAAIC,GAAG,EAAE;EAC/B,MAAMC,eAAe,GAAG,YAA2B;IAAA;IACjD,MAAMC,OAAO,GAAG,0BAAC,CAAC,MAAML,MAAM,CAACM,wBAAwB,CAACT,QAAQ,CAAC,EAAEU,aAAa,yEAAI,EAAE,EACnFC,MAAM,CAAC;MAAA,IAAC;QAAEC;MAAG,CAAC;MAAA,OAAK,CAACP,aAAa,CAACQ,GAAG,CAACD,EAAE,CAAC;IAAA,EAAC;IAC7CJ,OAAO,CAACM,O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,KAAKC,MAAM,EAAE;UACpFA,MAAM,CAACC,MAAM,CAACH,OAAO,EAAE;YAAE,GAAGlE,OAAO;YAAE,GAAGkE;UAAQ,CAAC,CAAC;QACpD,CAAC,MAAMD,IAAI,CAACK,IAAI,CAACtE,OAAO,CAAC;QACzB,OAAOgE,OAAO,CAACpE,QAAQ,EAAE,GAAGqE,IAAI,CAAC;MACnC,CAAC,CACF;IAAA;EAEL,CAAC;AACH;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeM,cAAc,CAClCC,WAAmB,EACnBC,cAAsB,EACtBzE,OAA8B,EAC2D;EACzF,MAAM0E,SAAS,GAAG1E,OAAO,CAACsC,SAAS,CAACC,OAAO;EAC3C,MAAMoC,gBAAgB,GAAG,MAAMjF,QAAQ,CAACP,GAAG,CAACyF,gBAAgB,EAAE;IAC5DzC,QAAQ,EAAEnD,SAAS;IACnBsE,cAAc,EAAEvE,UAAU,CAAC8D,KAAK;IAChCQ,aAAa,EAAEtE,UAAU,CAAC4D,IAAI;IAC9B,GAAG3C,OAAO;IACV0E,SAAS;IACTF,WAAW;IACXC;EACF,CAAC,CAAC;EACF,OAAO;IACL,IAAG,MAAM/F,IAAI,CAACiG,gBAAgB,EAAE3E,OAAO,CAAC;IACxC,IAAG,MAAMwD,eAAe,CAAClE,MAAM,CAACD,MAAM,CAACqF,SAAS,CAAC,EAAEnF,QAAQ,CAACsF,aAAa,CAAC,EAAE7E,OAAO,CAAC;EACtF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"oracle.mjs","names":["mapObject","pause","oracleQueryId","unpackTx","buildTxAsync","ORACLE_TTL","QUERY_TTL","RESPONSE_TTL","Tag","RequestTimedOutError","decode","encode","Encoding","_getPollInterval","getHeight","sendTransaction","pollForQueries","oracleId","onQuery","_ref","_interval","interval","onNode","options","knownQueryIds","Set","checkNewQueries","_await$onNode$getOrac","queries","getOracleQueriesByPubkey","oracleQueries","filter","_ref2","id","has","forEach","query","add","stopped","catch","console","error","pollForQueryResponse","queryId","_ref3","_interval2","height","ttl","response","getOracleQueryByPubkeyAndQueryId","responseBuffer","length","toString","getQueryObject","record","decodedQuery","decodedResponse","respond","opt","respondToQuery","pollForResponse","postQueryToOracle","_options$queryFee","queryFee","getOracleByPubkey","senderId","onAccount","address","oracleQueryTx","queryTtlType","type","queryTtlValue","value","responseTtlType","responseTtlValue","tag","OracleQueryTx","nonce","extendOracleTtl","OracleAddress","oracleExtendTx","oracleTtlType","oracleTtlValue","OracleExtendTx","getOracleObject","oracleRespondTx","OracleResponseTx","pollQueries","postQuery","extendOracle","getQuery","_ref4","name","handler","_len","arguments","args","Array","_key","lastArg","constructor","Object","assign","push","includes","registerOracle","queryFormat","responseFormat","accountId","oracleRegisterTx","OracleRegisterTx"],"sources":["../src/oracle.ts"],"sourcesContent":["/**\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 { mapObject, pause } from './utils/other';\nimport { oracleQueryId } from './tx/builder/helpers';\nimport { unpackTx, buildTxAsync, BuildTxOptions } from './tx/builder';\nimport {\n ORACLE_TTL,\n ORACLE_TTL_TYPES,\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 {\n _getPollInterval, getHeight, sendTransaction, SendTransactionOptions,\n} from './chain';\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: (query: OracleQueries[number]) => 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((query) => {\n knownQueryIds.add(query.id);\n onQuery(query);\n });\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 ({ response, ttl } = await onNode.getOracleQueryByPubkeyAndQueryId(oracleId, queryId));\n const responseBuffer = decode(response as Encoded.OracleResponse);\n if (responseBuffer.length > 0) return responseBuffer.toString();\n await pause(interval);\n height = await getHeight({ onNode });\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(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>[2]) =>\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<\n Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getQueryObject>>\n > {\n options.queryFee ??= (await options.onNode.getOracleByPubkey(oracleId)).queryFee.toString();\n const senderId = options.onAccount.address;\n\n const oracleQueryTx = await buildTxAsync({\n queryTtlType: QUERY_TTL.type,\n queryTtlValue: QUERY_TTL.value,\n responseTtlType: RESPONSE_TTL.type,\n responseTtlValue: RESPONSE_TTL.value,\n ...options,\n tag: Tag.OracleQueryTx,\n oracleId,\n senderId,\n query,\n });\n const { nonce } = unpackTx(oracleQueryTx, Tag.OracleQueryTx);\n const queryId = oracleQueryId(senderId, nonce, oracleId);\n return {\n ...await sendTransaction(oracleQueryTx, options),\n ...await getQueryObject(oracleId, queryId, options),\n };\n}\n\ntype PostQueryToOracleOptionsType = Parameters<typeof sendTransaction>[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 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(options: ExtendOracleTtlOptions): Promise<\nAwaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getOracleObject>>\n> {\n const oracleId = encode(decode(options.onAccount.address), Encoding.OracleAddress);\n const oracleExtendTx = await buildTxAsync({\n oracleTtlType: ORACLE_TTL.type,\n oracleTtlValue: ORACLE_TTL.value,\n ...options,\n tag: Tag.OracleExtendTx,\n oracleId,\n });\n return {\n ...await sendTransaction(oracleExtendTx, options),\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n ...await getOracleObject(oracleId, options),\n };\n}\n\ntype ExtendOracleTtlOptionsType = SendTransactionOptions & 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 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 queryId: Encoded.OracleQueryId,\n response: string,\n options: RespondToQueryOptions,\n): Promise<\n Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getOracleObject>>\n > {\n const oracleId = encode(decode(options.onAccount.address), Encoding.OracleAddress);\n const oracleRespondTx = await buildTxAsync({\n responseTtlType: RESPONSE_TTL.type,\n responseTtlValue: RESPONSE_TTL.value,\n ...options,\n tag: Tag.OracleResponseTx,\n oracleId,\n queryId,\n response,\n });\n return {\n ...await sendTransaction(oracleRespondTx, options),\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n ...await getOracleObject(oracleId, options),\n };\n}\n\ntype RespondToQueryOptionsType = SendTransactionOptions & 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(\n ...['extendOracle', 'respondToQuery'].includes(name) ? [] : [oracleId],\n ...args,\n );\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<\n Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getOracleObject>>\n > {\n const accountId = options.onAccount.address;\n const oracleRegisterTx = await buildTxAsync({\n oracleTtlValue: ORACLE_TTL.value,\n oracleTtlType: ORACLE_TTL.type,\n ...options,\n tag: Tag.OracleRegisterTx,\n accountId,\n queryFormat,\n responseFormat,\n });\n return {\n ...await sendTransaction(oracleRegisterTx, options),\n ...await getOracleObject(encode(decode(accountId), Encoding.OracleAddress), options),\n };\n}\n\ntype RegisterOracleOptionsType = SendTransactionOptions & Parameters<typeof getOracleObject>[1]\n& BuildTxOptions<Tag.OracleRegisterTx, 'accountId' | 'queryFormat' | 'responseFormat' | 'oracleTtlType' | 'oracleTtlValue'>\n& {\n oracleTtlType?: ORACLE_TTL_TYPES;\n oracleTtlValue?: number;\n};\ninterface RegisterOracleOptions extends RegisterOracleOptionsType {}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AANA,SAQSA,SAAS,EAAEC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d.ts
CHANGED
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
import { sendTransaction, resolveName } from './chain';
|
|
2
|
-
import { BuildTxOptions } from './tx';
|
|
1
|
+
import { sendTransaction, resolveName, SendTransactionOptions } from './chain';
|
|
2
|
+
import { BuildTxOptions } from './tx/builder';
|
|
3
3
|
import { Encoded } from './utils/encoder';
|
|
4
4
|
import { Tag, AensName } from './tx/builder/constants';
|
|
5
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
|
-
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
6
|
/**
|
|
24
7
|
* Send coins to another account
|
|
25
8
|
* @category chain
|
|
@@ -28,24 +11,33 @@ interface SendReturnType extends Awaited<ReturnType<typeof sendTransaction>> {
|
|
|
28
11
|
* @param options - Options
|
|
29
12
|
* @returns Transaction
|
|
30
13
|
*/
|
|
31
|
-
export declare function spend(amount: number | string, recipientIdOrName: Encoded.AccountAddress | AensName, options: SpendOptions): ReturnType<typeof
|
|
14
|
+
export declare function spend(amount: number | string, recipientIdOrName: Encoded.AccountAddress | AensName, options: SpendOptions): ReturnType<typeof sendTransaction>;
|
|
32
15
|
type SpendOptionsType = BuildTxOptions<Tag.SpendTx, 'senderId' | 'recipientId' | 'amount'> & Parameters<typeof resolveName>[2] & {
|
|
33
16
|
onAccount: AccountBase;
|
|
34
|
-
} &
|
|
17
|
+
} & SendTransactionOptions;
|
|
35
18
|
interface SpendOptions extends SpendOptionsType {
|
|
36
19
|
}
|
|
37
20
|
/**
|
|
38
|
-
*
|
|
21
|
+
* Spend a fraction of coin balance to another account. Useful if needed to drain account balance
|
|
22
|
+
* completely, sending funds to another account (with fraction set to 1).
|
|
39
23
|
* @category chain
|
|
40
24
|
* @param fraction - Fraction of balance to spend (between 0 and 1)
|
|
41
25
|
* @param recipientIdOrName - Address or name of recipient account
|
|
42
26
|
* @param options - Options
|
|
43
|
-
* @
|
|
27
|
+
* @example
|
|
28
|
+
* ```js
|
|
29
|
+
* // `fraction` * 100 = % of AE to be transferred (e.g. `0.42` for 42% or `1` for 100%)
|
|
30
|
+
* const { blockHeight } = await aeSdk.transferFunds(
|
|
31
|
+
* 0.42,
|
|
32
|
+
* 'ak_21A27UVVt3hDkBE5J7rhhqnH5YNb4Y1dqo4PnSybrH85pnWo7E',
|
|
33
|
+
* );
|
|
34
|
+
* console.log('Transaction mined at', blockHeight);
|
|
35
|
+
* ```
|
|
44
36
|
*/
|
|
45
|
-
export declare function transferFunds(fraction: number | string, recipientIdOrName: AensName | Encoded.AccountAddress, options: TransferFundsOptions): ReturnType<typeof
|
|
37
|
+
export declare function transferFunds(fraction: number | string, recipientIdOrName: AensName | Encoded.AccountAddress, options: TransferFundsOptions): ReturnType<typeof sendTransaction>;
|
|
46
38
|
type TransferFundsOptionsType = BuildTxOptions<Tag.SpendTx, 'senderId' | 'recipientId' | 'amount'> & Parameters<typeof resolveName>[2] & {
|
|
47
39
|
onAccount: AccountBase;
|
|
48
|
-
} &
|
|
40
|
+
} & SendTransactionOptions;
|
|
49
41
|
interface TransferFundsOptions extends TransferFundsOptionsType {
|
|
50
42
|
}
|
|
51
43
|
/**
|
|
@@ -55,8 +47,8 @@ interface TransferFundsOptions extends TransferFundsOptionsType {
|
|
|
55
47
|
* @param options - Options
|
|
56
48
|
* @returns Object Transaction
|
|
57
49
|
*/
|
|
58
|
-
export declare function payForTransaction(transaction: Encoded.Transaction, options: PayForTransactionOptions): ReturnType<typeof
|
|
59
|
-
interface PayForTransactionOptions extends BuildTxOptions<Tag.PayingForTx, 'payerId' | 'tx'>,
|
|
50
|
+
export declare function payForTransaction(transaction: Encoded.Transaction, options: PayForTransactionOptions): ReturnType<typeof sendTransaction>;
|
|
51
|
+
interface PayForTransactionOptions extends BuildTxOptions<Tag.PayingForTx, 'payerId' | 'tx' | 'onNode'>, SendTransactionOptions {
|
|
60
52
|
onAccount: AccountBase;
|
|
61
53
|
}
|
|
62
54
|
export {};
|