@aeternity/aepp-sdk 12.1.3 → 13.0.0-alpha.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/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 +6580 -8859
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdk.d.ts +7 -3
- package/es/AeSdk.mjs +17 -22
- package/es/AeSdk.mjs.map +1 -1
- package/es/AeSdkAepp.d.ts +6 -5
- package/es/AeSdkAepp.mjs +7 -30
- package/es/AeSdkAepp.mjs.map +1 -1
- package/es/AeSdkBase.d.ts +18 -140
- package/es/AeSdkBase.mjs +27 -185
- package/es/AeSdkBase.mjs.map +1 -1
- package/es/AeSdkMethods.d.ts +124 -0
- package/es/AeSdkMethods.mjs +122 -0
- package/es/AeSdkMethods.mjs.map +1 -0
- package/es/AeSdkWallet.d.ts +7 -21
- package/es/AeSdkWallet.mjs +38 -86
- package/es/AeSdkWallet.mjs.map +1 -1
- package/es/Node.d.ts +7 -12
- package/es/Node.mjs +34 -47
- package/es/Node.mjs.map +1 -1
- package/es/account/Base.d.ts +24 -40
- package/es/account/Base.mjs +1 -101
- package/es/account/Base.mjs.map +1 -1
- package/es/account/Generalized.d.ts +16 -0
- package/es/account/Generalized.mjs +111 -0
- package/es/account/Generalized.mjs.map +1 -0
- package/es/account/Ledger.d.ts +28 -0
- package/es/account/Ledger.mjs +101 -0
- package/es/account/Ledger.mjs.map +1 -0
- package/es/account/LedgerFactory.d.ts +39 -0
- package/es/account/LedgerFactory.mjs +81 -0
- package/es/account/LedgerFactory.mjs.map +1 -0
- package/es/account/Memory.d.ts +13 -17
- package/es/account/Memory.mjs +43 -65
- package/es/account/Memory.mjs.map +1 -1
- package/es/account/Rpc.d.ts +6 -8
- package/es/account/Rpc.mjs +14 -32
- package/es/account/Rpc.mjs.map +1 -1
- package/es/aens.d.ts +3 -3
- package/es/aens.mjs +42 -41
- package/es/aens.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/Browser.mjs +9 -13
- package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +3 -7
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +1 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -31
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +3 -3
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +4 -41
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/types.d.ts +7 -1
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
- package/es/aepp-wallet-communication/schema.mjs +14 -68
- package/es/aepp-wallet-communication/schema.mjs.map +1 -1
- package/es/aepp-wallet-communication/wallet-detector.mjs +0 -3
- package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
- package/es/apis/compiler/compiler.d.ts +23 -29
- package/es/apis/compiler/compiler.mjs +128 -189
- package/es/apis/compiler/compiler.mjs.map +1 -1
- package/es/apis/compiler/index.mjs.map +1 -1
- package/es/apis/compiler/models/index.d.ts +82 -135
- package/es/apis/compiler/models/index.mjs +1 -47
- package/es/apis/compiler/models/index.mjs.map +1 -1
- package/es/apis/compiler/models/mappers.d.ts +8 -8
- package/es/apis/compiler/models/mappers.mjs +165 -183
- package/es/apis/compiler/models/mappers.mjs.map +1 -1
- package/es/apis/compiler/models/parameters.d.ts +0 -1
- package/es/apis/compiler/models/parameters.mjs +5 -9
- package/es/apis/compiler/models/parameters.mjs.map +1 -1
- package/es/apis/node/index.mjs.map +1 -1
- package/es/apis/node/models/index.d.ts +48 -48
- package/es/apis/node/models/mappers.mjs +12 -6
- package/es/apis/node/models/mappers.mjs.map +1 -1
- package/es/apis/node/models/parameters.mjs.map +1 -1
- package/es/apis/node/node.mjs +43 -84
- package/es/apis/node/node.mjs.map +1 -1
- package/es/chain.d.ts +1 -1
- package/es/chain.mjs +33 -58
- package/es/chain.mjs.map +1 -1
- package/es/channel/Base.d.ts +195 -0
- package/es/channel/Base.mjs +290 -0
- package/es/channel/Base.mjs.map +1 -0
- package/es/channel/Contract.d.ts +247 -0
- package/es/channel/Contract.mjs +420 -0
- package/es/channel/Contract.mjs.map +1 -0
- package/es/channel/Spend.d.ts +217 -0
- package/es/channel/Spend.mjs +383 -0
- package/es/channel/Spend.mjs.map +1 -0
- package/es/channel/handlers.d.ts +8 -21
- package/es/channel/handlers.mjs +141 -891
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/internal.d.ts +27 -21
- package/es/channel/internal.mjs +98 -190
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/{Compiler.d.ts → CompilerHttp.d.ts} +3 -3
- package/es/contract/{Compiler.mjs → CompilerHttp.mjs} +8 -13
- package/es/contract/CompilerHttp.mjs.map +1 -0
- package/es/contract/Contract.d.ts +235 -0
- package/es/contract/Contract.mjs +534 -0
- package/es/contract/Contract.mjs.map +1 -0
- package/es/contract/ga.d.ts +7 -33
- package/es/contract/ga.mjs +20 -112
- package/es/contract/ga.mjs.map +1 -1
- package/es/index.d.ts +9 -6
- package/es/index.mjs +8 -6
- package/es/index.mjs.map +1 -1
- package/es/oracle.d.ts +5 -5
- package/es/oracle.mjs +33 -39
- package/es/oracle.mjs.map +1 -1
- package/es/spend.d.ts +3 -3
- package/es/spend.mjs +17 -20
- package/es/spend.mjs.map +1 -1
- package/es/tx/builder/constants.d.ts +2 -1
- package/es/tx/builder/constants.mjs +12 -12
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types/address.d.ts +15 -0
- package/es/tx/builder/field-types/address.mjs +42 -0
- package/es/tx/builder/field-types/address.mjs.map +1 -0
- package/es/tx/builder/field-types/addresses.d.ts +6 -0
- package/es/tx/builder/field-types/addresses.mjs +13 -0
- package/es/tx/builder/field-types/addresses.mjs.map +1 -0
- package/es/tx/builder/field-types/coin-amount.d.ts +1 -2
- package/es/tx/builder/field-types/coin-amount.mjs +4 -12
- package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
- package/es/tx/builder/field-types/deposit.d.ts +0 -1
- package/es/tx/builder/field-types/deposit.mjs +2 -4
- package/es/tx/builder/field-types/deposit.mjs.map +1 -1
- package/es/tx/builder/field-types/enumeration.d.ts +5 -0
- package/es/tx/builder/field-types/enumeration.mjs +21 -0
- package/es/tx/builder/field-types/enumeration.mjs.map +1 -0
- package/es/tx/builder/field-types/fee.d.ts +1 -9
- package/es/tx/builder/field-types/fee.mjs +9 -25
- package/es/tx/builder/field-types/fee.mjs.map +1 -1
- package/es/tx/builder/field-types/field.mjs +0 -2
- package/es/tx/builder/field-types/field.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-limit.mjs +4 -9
- package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-price.d.ts +1 -2
- package/es/tx/builder/field-types/gas-price.mjs +3 -7
- package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
- package/es/tx/builder/field-types/index.d.ts +23 -11
- package/es/tx/builder/field-types/index.mjs +10 -3
- package/es/tx/builder/field-types/index.mjs.map +1 -1
- package/es/tx/builder/field-types/name-fee.d.ts +0 -1
- package/es/tx/builder/field-types/name-fee.mjs +3 -5
- package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
- package/es/tx/builder/field-types/name-id.d.ts +1 -4
- package/es/tx/builder/field-types/name-id.mjs +4 -10
- package/es/tx/builder/field-types/name-id.mjs.map +1 -1
- package/es/tx/builder/field-types/name.mjs +0 -2
- package/es/tx/builder/field-types/name.mjs.map +1 -1
- package/es/tx/builder/field-types/pointers.d.ts +23 -0
- package/es/tx/builder/field-types/pointers.mjs +36 -0
- package/es/tx/builder/field-types/pointers.mjs.map +1 -0
- package/es/tx/builder/field-types/short-u-int.mjs +0 -2
- package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
- package/es/tx/builder/field-types/u-int.d.ts +1 -1
- package/es/tx/builder/field-types/u-int.mjs +3 -4
- package/es/tx/builder/field-types/u-int.mjs.map +1 -1
- package/es/tx/builder/helpers.d.ts +2 -32
- package/es/tx/builder/helpers.mjs +19 -71
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +1 -21
- package/es/tx/builder/index.mjs +29 -148
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +336 -176
- package/es/tx/builder/schema.mjs +71 -78
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/index.d.ts +3 -33
- package/es/tx/index.mjs +26 -43
- package/es/tx/index.mjs.map +1 -1
- package/es/tx/validator.d.ts +2 -2
- package/es/tx/validator.mjs +86 -59
- package/es/tx/validator.mjs.map +1 -1
- package/es/typings/{@aeternity__argon2-browser → @aeternity__aepp-calldata}/index.d.mjs +0 -0
- package/es/typings/@aeternity__aepp-calldata/index.d.mjs.map +1 -0
- package/es/utils/amount-formatter.mjs +4 -10
- package/es/utils/amount-formatter.mjs.map +1 -1
- package/es/utils/autorest.d.ts +1 -0
- package/es/utils/autorest.mjs +17 -19
- package/es/utils/autorest.mjs.map +1 -1
- package/es/utils/bignumber.mjs +4 -7
- package/es/utils/bignumber.mjs.map +1 -1
- package/es/utils/bytes.d.ts +0 -17
- package/es/utils/bytes.mjs +6 -35
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/crypto.d.ts +15 -8
- package/es/utils/crypto.mjs +40 -40
- package/es/utils/crypto.mjs.map +1 -1
- package/es/utils/encoder-types.d.ts +28 -28
- package/es/utils/encoder-types.mjs +0 -1
- package/es/utils/encoder-types.mjs.map +1 -1
- package/es/utils/encoder.d.ts +0 -1
- package/es/utils/encoder.mjs +7 -15
- package/es/utils/encoder.mjs.map +1 -1
- package/es/utils/errors.d.ts +12 -6
- package/es/utils/errors.mjs +87 -163
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/hd-wallet.d.ts +27 -19
- package/es/utils/hd-wallet.mjs +42 -26
- package/es/utils/hd-wallet.mjs.map +1 -1
- package/es/utils/json-big.mjs +0 -8
- package/es/utils/json-big.mjs.map +1 -1
- package/es/utils/keystore.d.ts +2 -0
- package/es/utils/keystore.mjs +37 -36
- package/es/utils/keystore.mjs.map +1 -1
- package/es/utils/mptree.d.ts +1 -1
- package/es/utils/mptree.mjs +4 -26
- package/es/utils/mptree.mjs.map +1 -1
- package/es/utils/other.d.ts +3 -1
- package/es/utils/other.mjs +11 -7
- package/es/utils/other.mjs.map +1 -1
- package/es/utils/semver-satisfies.mjs +0 -3
- package/es/utils/semver-satisfies.mjs.map +1 -1
- package/es/utils/string.d.ts +0 -12
- package/es/utils/string.mjs +1 -21
- package/es/utils/string.mjs.map +1 -1
- package/package.json +86 -47
- package/src/AeSdk.ts +15 -11
- package/src/AeSdkAepp.ts +9 -7
- package/src/AeSdkBase.ts +28 -202
- package/src/AeSdkMethods.ts +170 -0
- package/src/AeSdkWallet.ts +16 -47
- package/src/Node.ts +11 -15
- package/src/account/Base.ts +29 -75
- package/src/account/Generalized.ts +98 -0
- package/src/account/Ledger.ts +131 -0
- package/src/account/LedgerFactory.ts +86 -0
- package/src/account/Memory.ts +46 -60
- package/src/account/Rpc.ts +17 -26
- package/src/aens.ts +10 -9
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +5 -4
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +3 -3
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +2 -2
- package/src/aepp-wallet-communication/rpc/types.ts +11 -1
- package/src/aepp-wallet-communication/schema.ts +18 -18
- package/src/apis/compiler/code-model-v4.yaml +681 -888
- package/src/apis/compiler/compiler.ts +113 -154
- package/src/apis/compiler/models/index.ts +80 -140
- package/src/apis/compiler/models/mappers.ts +165 -183
- package/src/apis/compiler/models/parameters.ts +6 -12
- package/src/chain.ts +6 -3
- package/src/channel/Base.ts +327 -0
- package/src/channel/Contract.ts +487 -0
- package/src/channel/Spend.ts +403 -0
- package/src/channel/handlers.ts +154 -573
- package/src/channel/internal.ts +113 -142
- package/src/contract/{Compiler.ts → CompilerHttp.ts} +5 -5
- package/src/contract/Contract.ts +620 -0
- package/src/contract/ga.ts +18 -104
- package/src/index.ts +9 -8
- package/src/oracle.ts +7 -7
- package/src/spend.ts +5 -13
- package/src/tx/builder/constants.ts +1 -0
- package/src/tx/builder/field-types/address.ts +52 -0
- package/src/tx/builder/field-types/addresses.ts +18 -0
- package/src/tx/builder/field-types/coin-amount.ts +2 -8
- package/src/tx/builder/field-types/enumeration.ts +21 -0
- package/src/tx/builder/field-types/fee.ts +1 -3
- package/src/tx/builder/field-types/gas-limit.ts +2 -2
- package/src/tx/builder/field-types/gas-price.ts +0 -2
- package/src/tx/builder/field-types/index.ts +16 -6
- package/src/tx/builder/field-types/name-fee.ts +1 -1
- package/src/tx/builder/field-types/name-id.ts +7 -10
- package/src/tx/builder/field-types/pointers.ts +41 -0
- package/src/tx/builder/field-types/u-int.ts +3 -2
- package/src/tx/builder/helpers.ts +10 -60
- package/src/tx/builder/index.ts +6 -65
- package/src/tx/builder/schema.ts +89 -100
- package/src/tx/index.ts +19 -15
- package/src/tx/validator.ts +36 -18
- package/src/typings/@aeternity__aepp-calldata/index.d.ts +20 -0
- package/src/utils/autorest.ts +16 -1
- package/src/utils/bytes.ts +5 -33
- package/src/utils/crypto.ts +23 -16
- package/src/utils/encoder.ts +0 -1
- package/src/utils/errors.ts +18 -12
- package/src/utils/hd-wallet.ts +30 -9
- package/src/utils/keystore.ts +24 -21
- package/src/utils/other.ts +16 -1
- package/src/utils/string.ts +0 -20
- package/types-legacy/ts4.2/AeSdk.d.ts +41 -0
- package/types-legacy/ts4.2/AeSdkAepp.d.ts +71 -0
- package/types-legacy/ts4.2/AeSdkBase.d.ts +91 -0
- package/types-legacy/ts4.2/AeSdkMethods.d.ts +141 -0
- package/types-legacy/ts4.2/AeSdkWallet.d.ts +90 -0
- package/types-legacy/ts4.2/Node.d.ts +78 -0
- package/types-legacy/ts4.2/account/Base.d.ts +52 -0
- package/types-legacy/ts4.2/account/Generalized.d.ts +16 -0
- package/types-legacy/ts4.2/account/Ledger.d.ts +28 -0
- package/types-legacy/ts4.2/account/LedgerFactory.d.ts +39 -0
- package/types-legacy/ts4.2/account/Memory.d.ts +22 -0
- package/types-legacy/ts4.2/account/Rpc.d.ts +25 -0
- package/types-legacy/ts4.2/aens.d.ts +222 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/connection/Browser.d.ts +33 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +18 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/connection-proxy.d.ts +11 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +83 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +133 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/wallet-detector.d.ts +25 -0
- package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +86 -0
- package/types-legacy/ts4.2/apis/compiler/index.d.ts +2 -0
- package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +195 -0
- package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +23 -0
- package/types-legacy/ts4.2/apis/compiler/models/parameters.d.ts +12 -0
- package/types-legacy/ts4.2/apis/node/index.d.ts +2 -0
- package/types-legacy/ts4.2/apis/node/models/index.d.ts +1065 -0
- package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +95 -0
- package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +17 -0
- package/types-legacy/ts4.2/apis/node/node.d.ts +215 -0
- package/types-legacy/ts4.2/chain.d.ts +248 -0
- package/types-legacy/ts4.2/channel/Base.d.ts +194 -0
- package/types-legacy/ts4.2/channel/Contract.d.ts +247 -0
- package/types-legacy/ts4.2/channel/Spend.d.ts +217 -0
- package/types-legacy/ts4.2/channel/handlers.d.ts +21 -0
- package/types-legacy/ts4.2/channel/internal.d.ts +107 -0
- package/types-legacy/ts4.2/contract/CompilerHttp.d.ts +18 -0
- package/types-legacy/ts4.2/contract/Contract.d.ts +237 -0
- package/types-legacy/ts4.2/contract/ga.d.ts +43 -0
- package/types-legacy/ts4.2/globals.d.ts +16 -0
- package/types-legacy/ts4.2/index.d.ts +39 -0
- package/types-legacy/ts4.2/oracle.d.ts +161 -0
- package/types-legacy/ts4.2/spend.d.ts +62 -0
- package/types-legacy/ts4.2/tx/builder/constants.d.ts +71 -0
- package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +22 -0
- package/types-legacy/ts4.2/tx/builder/field-types/addresses.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +12 -0
- package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +14 -0
- package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +5 -0
- package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +17 -0
- package/types-legacy/ts4.2/tx/builder/field-types/field.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +12 -0
- package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +7 -0
- package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +85 -0
- package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +19 -0
- package/types-legacy/ts4.2/tx/builder/field-types/name-id.d.ts +11 -0
- package/types-legacy/ts4.2/tx/builder/field-types/name.d.ts +13 -0
- package/types-legacy/ts4.2/tx/builder/field-types/pointers.d.ts +26 -0
- package/types-legacy/ts4.2/tx/builder/field-types/short-u-int.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +8 -0
- package/types-legacy/ts4.2/tx/builder/helpers.d.ts +112 -0
- package/types-legacy/ts4.2/tx/builder/index.d.ts +68 -0
- package/types-legacy/ts4.2/tx/builder/schema.d.ts +2963 -0
- package/types-legacy/ts4.2/tx/index.d.ts +34 -0
- package/types-legacy/ts4.2/tx/validator.d.ts +20 -0
- package/types-legacy/ts4.2/utils/amount-formatter.d.ts +42 -0
- package/types-legacy/ts4.2/utils/autorest.d.ts +7 -0
- package/types-legacy/ts4.2/utils/bignumber.d.ts +13 -0
- package/types-legacy/ts4.2/utils/bytes.d.ts +9 -0
- package/types-legacy/ts4.2/utils/crypto.d.ts +95 -0
- package/types-legacy/ts4.2/utils/encoder-types.d.ts +61 -0
- package/types-legacy/ts4.2/utils/encoder.d.ts +24 -0
- package/types-legacy/ts4.2/utils/errors.d.ts +480 -0
- package/types-legacy/ts4.2/utils/hd-wallet.d.ts +65 -0
- package/types-legacy/ts4.2/utils/json-big.d.ts +5 -0
- package/types-legacy/ts4.2/utils/keystore.d.ts +53 -0
- package/types-legacy/ts4.2/utils/mptree.d.ts +32 -0
- package/types-legacy/ts4.2/utils/other.d.ts +31 -0
- package/types-legacy/ts4.2/utils/semver-satisfies.d.ts +1 -0
- package/types-legacy/ts4.2/utils/string.d.ts +12 -0
- package/types-legacy/ts4.5/AeSdk.d.ts +41 -0
- package/types-legacy/ts4.5/AeSdkAepp.d.ts +71 -0
- package/types-legacy/ts4.5/AeSdkBase.d.ts +91 -0
- package/types-legacy/ts4.5/AeSdkMethods.d.ts +141 -0
- package/types-legacy/ts4.5/AeSdkWallet.d.ts +90 -0
- package/types-legacy/ts4.5/Node.d.ts +78 -0
- package/types-legacy/ts4.5/account/Base.d.ts +52 -0
- package/types-legacy/ts4.5/account/Generalized.d.ts +16 -0
- package/types-legacy/ts4.5/account/Ledger.d.ts +28 -0
- package/types-legacy/ts4.5/account/LedgerFactory.d.ts +39 -0
- package/types-legacy/ts4.5/account/Memory.d.ts +22 -0
- package/types-legacy/ts4.5/account/Rpc.d.ts +25 -0
- package/types-legacy/ts4.5/aens.d.ts +222 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/connection/Browser.d.ts +33 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +18 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/connection-proxy.d.ts +11 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +83 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +133 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/wallet-detector.d.ts +25 -0
- package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +86 -0
- package/types-legacy/ts4.5/apis/compiler/index.d.ts +2 -0
- package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +195 -0
- package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +23 -0
- package/types-legacy/ts4.5/apis/compiler/models/parameters.d.ts +12 -0
- package/types-legacy/ts4.5/apis/node/index.d.ts +2 -0
- package/types-legacy/ts4.5/apis/node/models/index.d.ts +1065 -0
- package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +95 -0
- package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +17 -0
- package/types-legacy/ts4.5/apis/node/node.d.ts +215 -0
- package/types-legacy/ts4.5/chain.d.ts +248 -0
- package/types-legacy/ts4.5/channel/Base.d.ts +194 -0
- package/types-legacy/ts4.5/channel/Contract.d.ts +247 -0
- package/types-legacy/ts4.5/channel/Spend.d.ts +217 -0
- package/types-legacy/ts4.5/channel/handlers.d.ts +21 -0
- package/types-legacy/ts4.5/channel/internal.d.ts +107 -0
- package/types-legacy/ts4.5/contract/CompilerHttp.d.ts +18 -0
- package/types-legacy/ts4.5/contract/Contract.d.ts +237 -0
- package/types-legacy/ts4.5/contract/ga.d.ts +43 -0
- package/types-legacy/ts4.5/index.d.ts +38 -0
- package/types-legacy/ts4.5/oracle.d.ts +161 -0
- package/types-legacy/ts4.5/spend.d.ts +62 -0
- package/types-legacy/ts4.5/tx/builder/constants.d.ts +71 -0
- package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +22 -0
- package/types-legacy/ts4.5/tx/builder/field-types/addresses.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +12 -0
- package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +14 -0
- package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +5 -0
- package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +17 -0
- package/types-legacy/ts4.5/tx/builder/field-types/field.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +12 -0
- package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +7 -0
- package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +85 -0
- package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +19 -0
- package/types-legacy/ts4.5/tx/builder/field-types/name-id.d.ts +11 -0
- package/types-legacy/ts4.5/tx/builder/field-types/name.d.ts +13 -0
- package/types-legacy/ts4.5/tx/builder/field-types/pointers.d.ts +26 -0
- package/types-legacy/ts4.5/tx/builder/field-types/short-u-int.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +8 -0
- package/types-legacy/ts4.5/tx/builder/helpers.d.ts +112 -0
- package/types-legacy/ts4.5/tx/builder/index.d.ts +68 -0
- package/types-legacy/ts4.5/tx/builder/schema.d.ts +2963 -0
- package/types-legacy/ts4.5/tx/index.d.ts +34 -0
- package/types-legacy/ts4.5/tx/validator.d.ts +20 -0
- package/types-legacy/ts4.5/utils/amount-formatter.d.ts +42 -0
- package/types-legacy/ts4.5/utils/autorest.d.ts +7 -0
- package/types-legacy/ts4.5/utils/bignumber.d.ts +13 -0
- package/types-legacy/ts4.5/utils/bytes.d.ts +9 -0
- package/types-legacy/ts4.5/utils/crypto.d.ts +95 -0
- package/types-legacy/ts4.5/utils/encoder-types.d.ts +61 -0
- package/types-legacy/ts4.5/utils/encoder.d.ts +24 -0
- package/types-legacy/ts4.5/utils/errors.d.ts +480 -0
- package/types-legacy/ts4.5/utils/hd-wallet.d.ts +65 -0
- package/types-legacy/ts4.5/utils/json-big.d.ts +5 -0
- package/types-legacy/ts4.5/utils/keystore.d.ts +53 -0
- package/types-legacy/ts4.5/utils/mptree.d.ts +32 -0
- package/types-legacy/ts4.5/utils/other.d.ts +31 -0
- package/types-legacy/ts4.5/utils/semver-satisfies.d.ts +1 -0
- package/types-legacy/ts4.5/utils/string.d.ts +12 -0
- package/es/channel/index.d.ts +0 -625
- package/es/channel/index.mjs +0 -975
- package/es/channel/index.mjs.map +0 -1
- package/es/contract/Compiler.mjs.map +0 -1
- package/es/contract/aci.d.ts +0 -127
- package/es/contract/aci.mjs +0 -508
- package/es/contract/aci.mjs.map +0 -1
- package/es/contract/methods.d.ts +0 -71
- package/es/contract/methods.mjs +0 -104
- package/es/contract/methods.mjs.map +0 -1
- package/es/deprecated/index.d.ts +0 -143
- package/es/deprecated/index.mjs +0 -162
- package/es/deprecated/index.mjs.map +0 -1
- package/es/deprecated/methods.d.ts +0 -18
- package/es/deprecated/methods.mjs +0 -26
- package/es/deprecated/methods.mjs.map +0 -1
- package/es/tx/builder/address.d.ts +0 -25
- package/es/tx/builder/address.mjs +0 -45
- package/es/tx/builder/address.mjs.map +0 -1
- package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +0 -1
- package/src/channel/index.ts +0 -1025
- package/src/contract/aci.ts +0 -537
- package/src/contract/methods.ts +0 -123
- package/src/deprecated/index.ts +0 -172
- package/src/deprecated/methods.ts +0 -25
- package/src/tx/builder/address.ts +0 -50
- package/src/typings/@aeternity__argon2-browser/index.d.ts +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Contract.mjs","names":["snakeToPascal","MIN_GAS_PRICE","Tag","signAndNotify","awaitingCompletion","channelClosed","channelOpen","handleUnexpectedMessage","notify","call","changeState","emit","Channel","ChannelSpend","UnexpectedChannelMessageError","unpackTx","encodeContractAddress","snakeToPascalObjKeys","obj","Object","entries","reduce","result","key","val","ChannelContract","initialize","options","_initialize","createContract","sign","code","callData","deposit","vmVersion","abiVersion","enqueueAction","call_data","vm_version","abi_version","handler","_","message","state","method","params","data","tx","_2","message2","state2","round","SignedTx","encodedTx","addressKey","_options","role","owner","resolve","accepted","address","signedTx","callContract","amount","contract","contract_id","updates","forceProgress","gasLimit","gasPrice","onOnChainTx","gas_price","gas","info","type","callContractStatic","getContractCall","caller","caller_id","getContractState","pubkey","cleanContractCalls","reject"],"sources":["../../src/channel/Contract.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 */\nimport BigNumber from 'bignumber.js';\nimport { snakeToPascal } from '../utils/string';\nimport { MIN_GAS_PRICE, Tag } from '../tx/builder/constants';\nimport {\n signAndNotify,\n awaitingCompletion,\n channelClosed,\n channelOpen,\n handleUnexpectedMessage,\n} from './handlers';\nimport {\n notify, call, SignTx, ChannelState, ChannelOptions, ChannelMessage, ChannelFsm, changeState, emit,\n} from './internal';\nimport { Encoded } from '../utils/encoder';\nimport { ContractCallReturnType } from '../apis/node';\nimport { ContractCallObject } from '../contract/Contract';\nimport Channel from './Base';\nimport ChannelSpend from './Spend';\nimport { UnexpectedChannelMessageError } from '../utils/errors';\nimport { unpackTx } from '../tx/builder';\nimport { encodeContractAddress } from '../utils/crypto';\n\nfunction snakeToPascalObjKeys<Type>(obj: object): Type {\n return Object.entries(obj).reduce((result, [key, val]) => ({\n ...result,\n [snakeToPascal(key)]: val,\n }), {}) as Type;\n}\n\ninterface CallContractOptions {\n amount?: number | BigNumber;\n callData?: Encoded.ContractBytearray;\n abiVersion?: number;\n contract?: Encoded.ContractAddress;\n returnValue?: any;\n gasUsed?: number | BigNumber;\n gasPrice?: number | BigNumber;\n height?: number;\n callerNonce?: number;\n log?: any;\n returnType?: ContractCallReturnType;\n}\n\ninterface Contract {\n abiVersion: number;\n active: boolean;\n deposit: number | BigNumber;\n id: string;\n ownerId: string;\n referrerIds: string[];\n vmVersion: number;\n}\n\nexport default class ChannelContract extends ChannelSpend {\n static override async initialize(options: ChannelOptions): Promise<ChannelContract> {\n return Channel._initialize(new ChannelContract(), options);\n }\n\n /**\n * Trigger create contract update\n *\n * The create contract update is creating a contract inside the channel's internal state tree.\n * The update is a change to be applied on top of the latest state.\n *\n * That would create a contract with the poster being the owner of it. Poster commits initially\n * a deposit amount of coins to the new contract.\n *\n * @param options - Options\n * @param options.code - Api encoded compiled AEVM byte code\n * @param options.callData - Api encoded compiled AEVM call data for the code\n * @param options.deposit - Initial amount the owner of the contract commits to it\n * @param options.vmVersion - Version of the Virtual Machine\n * @param options.abiVersion - Version of the Application Binary Interface\n * @param sign - Function which verifies and signs create contract transaction\n * @example\n * ```js\n * channel.createContract({\n * code: 'cb_HKtpipK4aCgYb17wZ...',\n * callData: 'cb_1111111111111111...',\n * deposit: 10,\n * vmVersion: 3,\n * abiVersion: 1\n * }).then(({ accepted, signedTx, address }) => {\n * if (accepted) {\n * console.log('New contract has been created')\n * console.log('Contract address:', address)\n * } else {\n * console.log('New contract has been rejected')\n * }\n * })\n * ```\n */\n async createContract(\n {\n code, callData, deposit, vmVersion, abiVersion,\n }: {\n code: Encoded.ContractBytearray;\n callData: Encoded.ContractBytearray;\n deposit: number | BigNumber;\n vmVersion: number;\n abiVersion: number;\n },\n sign: SignTx,\n ): Promise<{\n accepted: boolean; signedTx: Encoded.Transaction; address: Encoded.ContractAddress;\n }> {\n return this.enqueueAction(() => {\n notify(this, 'channels.update.new_contract', {\n code,\n call_data: callData,\n deposit,\n vm_version: vmVersion,\n abi_version: abiVersion,\n });\n return {\n handler: async (\n _: Channel,\n message: ChannelMessage,\n state: ChannelState,\n ): Promise<ChannelFsm> => {\n if (message.method !== 'channels.sign.update') {\n return handleUnexpectedMessage(this, message, state);\n }\n await signAndNotify(\n this,\n 'channels.update',\n message.params.data,\n async (tx) => state.sign(tx),\n );\n return {\n handler: (\n _2: Channel,\n message2: ChannelMessage,\n state2: ChannelState,\n ): ChannelFsm => (\n awaitingCompletion(this, message2, state2, () => {\n const { round } = unpackTx(message2.params.data.state, Tag.SignedTx)\n .tx.encodedTx.tx;\n const addressKey = this._options.role === 'initiator'\n ? 'initiatorId' : 'responderId';\n const owner = this._options[addressKey];\n changeState(this, message2.params.data.state);\n state2.resolve({\n accepted: true,\n address: encodeContractAddress(owner, round),\n signedTx: message2.params.data.state,\n });\n return { handler: channelOpen };\n })\n ),\n state,\n };\n },\n state: { sign },\n };\n });\n }\n\n /**\n * Trigger call a contract update\n *\n * The call contract update is calling a preexisting contract inside the channel's\n * internal state tree. The update is a change to be applied on top of the latest state.\n *\n * That would call a contract with the poster being the caller of it. Poster commits\n * an amount of coins to the contract.\n *\n * The call would also create a call object inside the channel state tree. It contains\n * the result of the contract call.\n *\n * It is worth mentioning that the gas is not consumed, because this is an off-chain\n * contract call. It would be consumed if it were an on-chain one. This could happen\n * if a call with a similar computation amount is to be forced on-chain.\n *\n * @param options - Options\n * @param options.amount - Amount the caller of the contract commits to it\n * @param options.callData - ABI encoded compiled AEVM call data for the code\n * @param options.contract - Address of the contract to call\n * @param options.abiVersion - Version of the ABI\n * @param sign - Function which verifies and signs contract call transaction\n * @example\n * ```js\n * channel.callContract({\n * contract: 'ct_9sRA9AVE4BYTAkh5RNfJYmwQe1NZ4MErasQLXZkFWG43TPBqa',\n * callData: 'cb_1111111111111111...',\n * amount: 0,\n * abiVersion: 1\n * }).then(({ accepted, signedTx }) => {\n * if (accepted) {\n * console.log('Contract called succesfully')\n * } else {\n * console.log('Contract call has been rejected')\n * }\n * })\n * ```\n */\n async callContract(\n {\n amount, callData, contract, abiVersion,\n }: CallContractOptions,\n sign: SignTx,\n ): Promise<{ accepted: boolean; signedTx: Encoded.Transaction }> {\n return this.enqueueAction(() => {\n notify(this, 'channels.update.call_contract', {\n amount,\n call_data: callData,\n contract_id: contract,\n abi_version: abiVersion,\n });\n return {\n handler: async (\n _: Channel,\n message: ChannelMessage,\n state: ChannelState,\n ): Promise<ChannelFsm> => {\n if (message.method !== 'channels.sign.update') {\n return handleUnexpectedMessage(this, message, state);\n }\n await signAndNotify(\n this,\n 'channels.update',\n message.params.data,\n async (tx) => state.sign(tx, { updates: message.params.data.updates }),\n );\n return {\n handler: (\n _2: Channel,\n message2: ChannelMessage,\n state2: ChannelState,\n ): ChannelFsm => (\n awaitingCompletion(this, message2, state2, () => {\n changeState(this, message2.params.data.state);\n state2.resolve({ accepted: true, signedTx: message2.params.data.state });\n return { handler: channelOpen };\n })\n ),\n state,\n };\n },\n state: { sign },\n };\n });\n }\n\n /**\n * Trigger a force progress contract call\n * This call is going on-chain\n * @param options - Options\n * @param options.amount - Amount the caller of the contract commits to it\n * @param options.callData - ABI encoded compiled AEVM call data for the code\n * @param options.contract - Address of the contract to call\n * @param options.abiVersion - Version of the ABI\n * @param options.gasPrice=1000000000]\n * @param options.gasLimit=1000000]\n * @param sign - Function which verifies and signs contract force progress transaction\n * @param callbacks - Callbacks\n * @example\n * ```js\n * channel.forceProgress({\n * contract: 'ct_9sRA9AVE4BYTAkh5RNfJYmwQe1NZ4MErasQLXZkFWG43TPBqa',\n * callData: 'cb_1111111111111111...',\n * amount: 0,\n * abiVersion: 1,\n * gasPrice: 1000005554\n * }).then(({ accepted, signedTx }) => {\n * if (accepted) {\n * console.log('Contract force progress call successful')\n * } else {\n * console.log('Contract force progress call has been rejected')\n * }\n * })\n * ```\n */\n async forceProgress(\n {\n amount, callData, contract, abiVersion, gasLimit = 1000000, gasPrice = MIN_GAS_PRICE,\n }: {\n amount: number;\n callData: Encoded.ContractBytearray;\n contract: Encoded.ContractAddress;\n abiVersion: number;\n gasLimit?: number;\n gasPrice?: number;\n },\n sign: SignTx,\n { onOnChainTx }: Pick<ChannelState, 'onOnChainTx'> = {},\n ): Promise<{\n accepted: boolean;\n signedTx: Encoded.Transaction;\n tx: Encoded.Transaction | Uint8Array;\n }> {\n return this.enqueueAction(() => {\n notify(this, 'channels.force_progress', {\n amount,\n call_data: callData,\n contract_id: contract,\n abi_version: abiVersion,\n gas_price: gasPrice,\n gas: gasLimit,\n });\n return {\n handler: async (\n _: Channel,\n message: ChannelMessage,\n state: ChannelState,\n ): Promise<ChannelFsm> => {\n if (message.method !== 'channels.sign.force_progress_tx') {\n return handleUnexpectedMessage(this, message, state);\n }\n await signAndNotify(\n this,\n 'channels.force_progress_sign',\n message.params.data,\n async (tx) => state.sign(tx, { updates: message.params.data.updates }),\n );\n return {\n handler: (\n _2: Channel,\n message2: ChannelMessage,\n state2: ChannelState,\n ): ChannelFsm => {\n if (message2.method === 'channels.on_chain_tx') {\n state2.onOnChainTx?.(message2.params.data.tx);\n emit(this, 'onChainTx', message2.params.data.tx, {\n info: message2.params.data.info,\n type: message2.params.data.type,\n });\n state2.resolve({ accepted: true, tx: message2.params.data.tx });\n // TODO: shouldn't be unexpected message in this case\n }\n return handleUnexpectedMessage(this, message2, state2);\n },\n state,\n };\n },\n state: { sign, onOnChainTx },\n };\n });\n }\n\n /**\n * Call contract using dry-run\n *\n * In order to get the result of a potential contract call, one might need to\n * dry-run a contract call. It takes the exact same arguments as a call would\n * and returns the call object.\n *\n * The call is executed in the channel's state, but it does not impact the state\n * whatsoever. It uses as an environment the latest channel's state and the current\n * top of the blockchain as seen by the node.\n *\n * @param options - Options\n * @param options.amount - Amount the caller of the contract commits to it\n * @param options.callData - ABI encoded compiled AEVM call data for the code\n * @param options.contract - Address of the contract to call\n * @param options.abiVersion - Version of the ABI\n * @example\n * ```js\n * channel.callContractStatic({\n * contract: 'ct_9sRA9AVE4BYTAkh5RNfJYmwQe1NZ4MErasQLXZkFWG43TPBqa',\n * callData: 'cb_1111111111111111...',\n * amount: 0,\n * abiVersion: 1\n * }).then(({ returnValue, gasUsed }) => {\n * console.log('Returned value:', returnValue)\n * console.log('Gas used:', gasUsed)\n * })\n * ```\n */\n async callContractStatic(\n {\n amount, callData, contract, abiVersion,\n }: {\n amount: number;\n callData: Encoded.ContractBytearray;\n contract: Encoded.ContractAddress;\n abiVersion: number;\n },\n ): Promise<CallContractOptions> {\n return snakeToPascalObjKeys(await call(this, 'channels.dry_run.call_contract', {\n amount,\n call_data: callData,\n contract_id: contract,\n abi_version: abiVersion,\n }));\n }\n\n /**\n * Get contract call result\n *\n * The combination of a caller, contract and a round of execution determines the\n * contract call. Providing an incorrect set of those results in an error response.\n *\n * @param options - Options\n * @param options.caller - Address of contract caller\n * @param options.contract - Address of the contract\n * @param options.round - Round when contract was called\n * @example\n * ```js\n * channel.getContractCall({\n * caller: 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',\n * contract: 'ct_9sRA9AVE4BYTAkh5RNfJYmwQe1NZ4MErasQLXZkFWG43TPBqa',\n * round: 3\n * }).then(({ returnType, returnValue }) => {\n * if (returnType === 'ok') console.log(returnValue)\n * })\n * ```\n */\n async getContractCall(\n { caller, contract, round }: {\n caller: Encoded.AccountAddress;\n contract: Encoded.ContractAddress;\n round: number;\n },\n ): Promise<ContractCallObject> {\n return snakeToPascalObjKeys(\n await call(this, 'channels.get.contract_call', {\n caller_id: caller,\n contract_id: contract,\n round,\n }),\n );\n }\n\n /**\n * Get the latest contract state\n *\n * @param contract - Address of the contract\n * @example\n * ```js\n * channel.getContractState(\n * 'ct_9sRA9AVE4BYTAkh5RNfJYmwQe1NZ4MErasQLXZkFWG43TPBqa'\n * ).then(({ contract }) => {\n * console.log('deposit:', contract.deposit)\n * })\n * ```\n */\n async getContractState(\n contract: Encoded.ContractAddress,\n ): Promise<{ contract: Contract; contractState: object }> {\n const result = await call(this, 'channels.get.contract', { pubkey: contract });\n return snakeToPascalObjKeys({\n ...result,\n contract: snakeToPascalObjKeys(result.contract),\n });\n }\n\n /**\n * Clean up all locally stored contract calls\n *\n * Contract calls are kept locally in order for the participant to be able to look them up.\n * They consume memory and in order for the participant to free it - one can prune all messages.\n * This cleans up all locally stored contract calls and those will no longer be available for\n * fetching and inspection.\n */\n async cleanContractCalls(): Promise<void> {\n return this.enqueueAction(() => {\n notify(this, 'channels.clean_contract_calls');\n return {\n handler(_: Channel, message: ChannelMessage, state: ChannelState): ChannelFsm {\n if (message.method === 'channels.calls_pruned.reply') {\n state.resolve();\n return { handler: channelOpen };\n }\n state.reject(new UnexpectedChannelMessageError('Unexpected message received'));\n return { handler: channelClosed };\n },\n };\n });\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAfA,SAiBSA,aAAa;AAAA,SACbC,aAAa,EAAEC,GAAG;AAAA,SAEzBC,aAAa,EACbC,kBAAkB,EAClBC,aAAa,EACbC,WAAW,EACXC,uBAAuB;AAAA,SAGvB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AAEnC;UAAc,CAAC;QACnC;MACF,CAAC;IACH,CAAC,CAAC;EACJ;AACF"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
import { SignTx, ChannelState } from './internal';
|
|
3
|
+
import { Encoded } from '../utils/encoder';
|
|
4
|
+
import Channel from './Base';
|
|
5
|
+
export default class ChannelSpend extends Channel {
|
|
6
|
+
/**
|
|
7
|
+
* Trigger a transfer update
|
|
8
|
+
*
|
|
9
|
+
* The transfer update is moving coins from one channel account to another.
|
|
10
|
+
* The update is a change to be applied on top of the latest state.
|
|
11
|
+
*
|
|
12
|
+
* Sender and receiver are the channel parties. Both the initiator and responder
|
|
13
|
+
* can take those roles. Any public key outside the channel is considered invalid.
|
|
14
|
+
*
|
|
15
|
+
* @param from - Sender's public address
|
|
16
|
+
* @param to - Receiver's public address
|
|
17
|
+
* @param amount - Transaction amount
|
|
18
|
+
* @param sign - Function which verifies and signs offchain transaction
|
|
19
|
+
* @param metadata - Metadata
|
|
20
|
+
|
|
21
|
+
* @example
|
|
22
|
+
* ```js
|
|
23
|
+
* channel.update(
|
|
24
|
+
* 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',
|
|
25
|
+
* 'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E',
|
|
26
|
+
* 10,
|
|
27
|
+
* async (tx) => await account.signTransaction(tx)
|
|
28
|
+
* ).then(({ accepted, signedTx }) =>
|
|
29
|
+
* if (accepted) {
|
|
30
|
+
* console.log('Update has been accepted')
|
|
31
|
+
* }
|
|
32
|
+
* )
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
update(from: Encoded.AccountAddress, to: Encoded.AccountAddress, amount: number | BigNumber, sign: SignTx, metadata?: string[]): Promise<{
|
|
36
|
+
accepted: boolean;
|
|
37
|
+
signedTx?: Encoded.Transaction;
|
|
38
|
+
errorCode?: number;
|
|
39
|
+
errorMessage?: string;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Get proof of inclusion
|
|
43
|
+
*
|
|
44
|
+
* If a certain address of an account or a contract is not found
|
|
45
|
+
* in the state tree - the response is an error.
|
|
46
|
+
*
|
|
47
|
+
* @param addresses - Addresses
|
|
48
|
+
* @param addresses.accounts - List of account addresses to include in poi
|
|
49
|
+
* @param addresses.contracts - List of contract addresses to include in poi
|
|
50
|
+
* @example
|
|
51
|
+
* ```js
|
|
52
|
+
* channel.poi({
|
|
53
|
+
* accounts: [
|
|
54
|
+
* 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',
|
|
55
|
+
* 'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E'
|
|
56
|
+
* ],
|
|
57
|
+
* contracts: ['ct_2dCUAWYZdrWfACz3a2faJeKVTVrfDYxCQHCqAt5zM15f3u2UfA']
|
|
58
|
+
* }).then(poi => console.log(poi))
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
poi({ accounts, contracts }: {
|
|
62
|
+
accounts: Encoded.AccountAddress[];
|
|
63
|
+
contracts?: Encoded.ContractAddress[];
|
|
64
|
+
}): Promise<Encoded.Poi>;
|
|
65
|
+
/**
|
|
66
|
+
* Get balances
|
|
67
|
+
*
|
|
68
|
+
* The accounts param contains a list of addresses to fetch balances of.
|
|
69
|
+
* Those can be either account balances or a contract ones, encoded as an account addresses.
|
|
70
|
+
*
|
|
71
|
+
* If a certain account address had not being found in the state tree - it is simply
|
|
72
|
+
* skipped in the response.
|
|
73
|
+
*
|
|
74
|
+
* @param accounts - List of addresses to fetch balances from
|
|
75
|
+
* @example
|
|
76
|
+
* ```js
|
|
77
|
+
* channel.balances([
|
|
78
|
+
* 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',
|
|
79
|
+
* 'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E'
|
|
80
|
+
* 'ct_2dCUAWYZdrWfACz3a2faJeKVTVrfDYxCQHCqAt5zM15f3u2UfA'
|
|
81
|
+
* ]).then(balances =>
|
|
82
|
+
* console.log(balances['ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH'])
|
|
83
|
+
* )
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
balances(accounts: Encoded.AccountAddress[]): Promise<{
|
|
87
|
+
[key: Encoded.AccountAddress]: string;
|
|
88
|
+
}>;
|
|
89
|
+
private awaitingActionTx;
|
|
90
|
+
/**
|
|
91
|
+
* Withdraw coins from the channel
|
|
92
|
+
*
|
|
93
|
+
* After the channel had been opened any of the participants can initiate a withdrawal.
|
|
94
|
+
* The process closely resembles the update. The most notable difference is that the
|
|
95
|
+
* transaction has been co-signed: it is channel_withdraw_tx and after the procedure
|
|
96
|
+
* is finished - it is being posted on-chain.
|
|
97
|
+
*
|
|
98
|
+
* Any of the participants can initiate a withdrawal. The only requirements are:
|
|
99
|
+
*
|
|
100
|
+
* - Channel is already opened
|
|
101
|
+
* - No off-chain update/deposit/withdrawal is currently being performed
|
|
102
|
+
* - Channel is not being closed or in a solo closing state
|
|
103
|
+
* - The withdrawal amount must be equal to or greater than zero, and cannot exceed
|
|
104
|
+
* the available balance on the channel (minus the channel_reserve)
|
|
105
|
+
*
|
|
106
|
+
* After the other party had signed the withdraw transaction, the transaction is posted
|
|
107
|
+
* on-chain and onOnChainTx callback is called with on-chain transaction as first argument.
|
|
108
|
+
* After computing transaction hash it can be tracked on the chain: entering the mempool,
|
|
109
|
+
* block inclusion and a number of confirmations.
|
|
110
|
+
*
|
|
111
|
+
* After the minimum_depth block confirmations onOwnWithdrawLocked callback is called
|
|
112
|
+
* (without any arguments).
|
|
113
|
+
*
|
|
114
|
+
* When the other party had confirmed that the block height needed is reached
|
|
115
|
+
* onWithdrawLocked callback is called (without any arguments).
|
|
116
|
+
*
|
|
117
|
+
* @param amount - Amount of coins to withdraw
|
|
118
|
+
* @param sign - Function which verifies and signs withdraw transaction
|
|
119
|
+
* @param callbacks - Callbacks
|
|
120
|
+
* @param callbacks.onOnChainTx - Called when withdraw transaction has been posted
|
|
121
|
+
* on chain
|
|
122
|
+
* @param callbacks.onOwnWithdrawLocked
|
|
123
|
+
* @param callbacks.onWithdrawLocked
|
|
124
|
+
* @example
|
|
125
|
+
* ```js
|
|
126
|
+
* channel.withdraw(
|
|
127
|
+
* 100,
|
|
128
|
+
* async (tx) => await account.signTransaction(tx),
|
|
129
|
+
* { onOnChainTx: (tx) => console.log('on_chain_tx', tx) }
|
|
130
|
+
* ).then(({ accepted, signedTx }) => {
|
|
131
|
+
* if (accepted) {
|
|
132
|
+
* console.log('Withdrawal has been accepted')
|
|
133
|
+
* } else {
|
|
134
|
+
* console.log('Withdrawal has been rejected')
|
|
135
|
+
* }
|
|
136
|
+
* })
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
withdraw(amount: number | BigNumber, sign: SignTx, { onOnChainTx, onOwnWithdrawLocked, onWithdrawLocked }?: Pick<ChannelState, 'onOnChainTx' | 'onOwnWithdrawLocked' | 'onWithdrawLocked'>): Promise<{
|
|
140
|
+
accepted: boolean;
|
|
141
|
+
signedTx: Encoded.Transaction;
|
|
142
|
+
}>;
|
|
143
|
+
/**
|
|
144
|
+
* Deposit coins into the channel
|
|
145
|
+
*
|
|
146
|
+
* After the channel had been opened any of the participants can initiate a deposit.
|
|
147
|
+
* The process closely resembles the update. The most notable difference is that the
|
|
148
|
+
* transaction has been co-signed: it is channel_deposit_tx and after the procedure
|
|
149
|
+
* is finished - it is being posted on-chain.
|
|
150
|
+
*
|
|
151
|
+
* Any of the participants can initiate a deposit. The only requirements are:
|
|
152
|
+
*
|
|
153
|
+
* - Channel is already opened
|
|
154
|
+
* - No off-chain update/deposit/withdrawal is currently being performed
|
|
155
|
+
* - Channel is not being closed or in a solo closing state
|
|
156
|
+
* - The deposit amount must be equal to or greater than zero, and cannot exceed
|
|
157
|
+
* the available balance on the channel (minus the channel_reserve)
|
|
158
|
+
*
|
|
159
|
+
* After the other party had signed the deposit transaction, the transaction is posted
|
|
160
|
+
* on-chain and onOnChainTx callback is called with on-chain transaction as first argument.
|
|
161
|
+
* After computing transaction hash it can be tracked on the chain: entering the mempool,
|
|
162
|
+
* block inclusion and a number of confirmations.
|
|
163
|
+
*
|
|
164
|
+
* After the minimum_depth block confirmations onOwnDepositLocked callback is called
|
|
165
|
+
* (without any arguments).
|
|
166
|
+
*
|
|
167
|
+
* When the other party had confirmed that the block height needed is reached
|
|
168
|
+
* onDepositLocked callback is called (without any arguments).
|
|
169
|
+
*
|
|
170
|
+
* @param amount - Amount of coins to deposit
|
|
171
|
+
* @param sign - Function which verifies and signs deposit transaction
|
|
172
|
+
* @param callbacks - Callbacks
|
|
173
|
+
* @param callbacks.onOnChainTx - Called when deposit transaction has been posted
|
|
174
|
+
* on chain
|
|
175
|
+
* @param callbacks.onOwnDepositLocked
|
|
176
|
+
* @param callbacks.onDepositLocked
|
|
177
|
+
* @example
|
|
178
|
+
* ```js
|
|
179
|
+
* channel.deposit(
|
|
180
|
+
* 100,
|
|
181
|
+
* async (tx) => await account.signTransaction(tx),
|
|
182
|
+
* { onOnChainTx: (tx) => console.log('on_chain_tx', tx) }
|
|
183
|
+
* ).then(({ accepted, state }) => {
|
|
184
|
+
* if (accepted) {
|
|
185
|
+
* console.log('Deposit has been accepted')
|
|
186
|
+
* console.log('The new state is:', state)
|
|
187
|
+
* } else {
|
|
188
|
+
* console.log('Deposit has been rejected')
|
|
189
|
+
* }
|
|
190
|
+
* })
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
deposit(amount: number | BigNumber, sign: SignTx, { onOnChainTx, onOwnDepositLocked, onDepositLocked }?: Pick<ChannelState, 'onOnChainTx' | 'onOwnDepositLocked' | 'onDepositLocked'>): Promise<{
|
|
194
|
+
accepted: boolean;
|
|
195
|
+
state: ChannelState;
|
|
196
|
+
}>;
|
|
197
|
+
/**
|
|
198
|
+
* Send generic message
|
|
199
|
+
*
|
|
200
|
+
* If message is an object it will be serialized into JSON string
|
|
201
|
+
* before sending.
|
|
202
|
+
*
|
|
203
|
+
* If there is ongoing update that has not yet been finished the message
|
|
204
|
+
* will be sent after that update is finalized.
|
|
205
|
+
*
|
|
206
|
+
* @param message - Message
|
|
207
|
+
* @param recipient - Address of the recipient
|
|
208
|
+
* @example
|
|
209
|
+
* ```js
|
|
210
|
+
* channel.sendMessage(
|
|
211
|
+
* 'hello world',
|
|
212
|
+
* 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH'
|
|
213
|
+
* )
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
sendMessage(message: string | object, recipient: Encoded.AccountAddress): Promise<void>;
|
|
217
|
+
}
|
|
@@ -0,0 +1,383 @@
|
|
|
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
|
+
import { notify, call, changeState } from "./internal.mjs";
|
|
18
|
+
import { pause } from "../utils/other.mjs";
|
|
19
|
+
import Channel from "./Base.mjs";
|
|
20
|
+
import { ChannelConnectionError } from "../utils/errors.mjs";
|
|
21
|
+
import { awaitingCompletion, channelOpen, handleUnexpectedMessage, signAndNotify } from "./handlers.mjs";
|
|
22
|
+
export default class ChannelSpend extends Channel {
|
|
23
|
+
/**
|
|
24
|
+
* Trigger a transfer update
|
|
25
|
+
*
|
|
26
|
+
* The transfer update is moving coins from one channel account to another.
|
|
27
|
+
* The update is a change to be applied on top of the latest state.
|
|
28
|
+
*
|
|
29
|
+
* Sender and receiver are the channel parties. Both the initiator and responder
|
|
30
|
+
* can take those roles. Any public key outside the channel is considered invalid.
|
|
31
|
+
*
|
|
32
|
+
* @param from - Sender's public address
|
|
33
|
+
* @param to - Receiver's public address
|
|
34
|
+
* @param amount - Transaction amount
|
|
35
|
+
* @param sign - Function which verifies and signs offchain transaction
|
|
36
|
+
* @param metadata - Metadata
|
|
37
|
+
* @example
|
|
38
|
+
* ```js
|
|
39
|
+
* channel.update(
|
|
40
|
+
* 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',
|
|
41
|
+
* 'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E',
|
|
42
|
+
* 10,
|
|
43
|
+
* async (tx) => await account.signTransaction(tx)
|
|
44
|
+
* ).then(({ accepted, signedTx }) =>
|
|
45
|
+
* if (accepted) {
|
|
46
|
+
* console.log('Update has been accepted')
|
|
47
|
+
* }
|
|
48
|
+
* )
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
async update(from, to, amount, sign) {
|
|
52
|
+
let metadata = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
53
|
+
return this.enqueueAction(() => {
|
|
54
|
+
notify(this, 'channels.update.new', {
|
|
55
|
+
from,
|
|
56
|
+
to,
|
|
57
|
+
amount,
|
|
58
|
+
meta: metadata
|
|
59
|
+
});
|
|
60
|
+
const awaitingOffChainTx = async (_, message, state) => {
|
|
61
|
+
if (message.method === 'channels.sign.update') {
|
|
62
|
+
const isError = await signAndNotify(this, 'channels.update', message.params.data, async tx => sign(tx, {
|
|
63
|
+
updates: message.params.data.updates
|
|
64
|
+
}));
|
|
65
|
+
if (isError) return {
|
|
66
|
+
handler: awaitingOffChainTx,
|
|
67
|
+
state
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
handler: (_2, message2) => awaitingCompletion(this, message2, state, () => {
|
|
71
|
+
changeState(this, message2.params.data.state);
|
|
72
|
+
state.resolve({
|
|
73
|
+
accepted: true,
|
|
74
|
+
signedTx: message2.params.data.state
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
handler: channelOpen
|
|
78
|
+
};
|
|
79
|
+
}),
|
|
80
|
+
state
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (message.method === 'channels.error') {
|
|
84
|
+
state.reject(new ChannelConnectionError(message.data.message));
|
|
85
|
+
return {
|
|
86
|
+
handler: channelOpen
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return awaitingCompletion(this, message, state);
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
handler: awaitingOffChainTx
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Get proof of inclusion
|
|
99
|
+
*
|
|
100
|
+
* If a certain address of an account or a contract is not found
|
|
101
|
+
* in the state tree - the response is an error.
|
|
102
|
+
*
|
|
103
|
+
* @param addresses - Addresses
|
|
104
|
+
* @param addresses.accounts - List of account addresses to include in poi
|
|
105
|
+
* @param addresses.contracts - List of contract addresses to include in poi
|
|
106
|
+
* @example
|
|
107
|
+
* ```js
|
|
108
|
+
* channel.poi({
|
|
109
|
+
* accounts: [
|
|
110
|
+
* 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',
|
|
111
|
+
* 'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E'
|
|
112
|
+
* ],
|
|
113
|
+
* contracts: ['ct_2dCUAWYZdrWfACz3a2faJeKVTVrfDYxCQHCqAt5zM15f3u2UfA']
|
|
114
|
+
* }).then(poi => console.log(poi))
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
async poi(_ref) {
|
|
118
|
+
let {
|
|
119
|
+
accounts,
|
|
120
|
+
contracts
|
|
121
|
+
} = _ref;
|
|
122
|
+
return (await call(this, 'channels.get.poi', {
|
|
123
|
+
accounts,
|
|
124
|
+
contracts
|
|
125
|
+
})).poi;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Get balances
|
|
130
|
+
*
|
|
131
|
+
* The accounts param contains a list of addresses to fetch balances of.
|
|
132
|
+
* Those can be either account balances or a contract ones, encoded as an account addresses.
|
|
133
|
+
*
|
|
134
|
+
* If a certain account address had not being found in the state tree - it is simply
|
|
135
|
+
* skipped in the response.
|
|
136
|
+
*
|
|
137
|
+
* @param accounts - List of addresses to fetch balances from
|
|
138
|
+
* @example
|
|
139
|
+
* ```js
|
|
140
|
+
* channel.balances([
|
|
141
|
+
* 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',
|
|
142
|
+
* 'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E'
|
|
143
|
+
* 'ct_2dCUAWYZdrWfACz3a2faJeKVTVrfDYxCQHCqAt5zM15f3u2UfA'
|
|
144
|
+
* ]).then(balances =>
|
|
145
|
+
* console.log(balances['ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH'])
|
|
146
|
+
* )
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
async balances(accounts) {
|
|
150
|
+
return Object.fromEntries((await call(this, 'channels.get.balances', {
|
|
151
|
+
accounts
|
|
152
|
+
})).map(item => [item.account, item.balance]));
|
|
153
|
+
}
|
|
154
|
+
async awaitingActionTx(action, message, state) {
|
|
155
|
+
if (message.method !== `channels.sign.${action}_tx`) {
|
|
156
|
+
return handleUnexpectedMessage(this, message, state);
|
|
157
|
+
}
|
|
158
|
+
const awaitingActionCompletion = (_, message2) => {
|
|
159
|
+
if (message2.method === 'channels.on_chain_tx') {
|
|
160
|
+
var _state$onOnChainTx;
|
|
161
|
+
(_state$onOnChainTx = state.onOnChainTx) === null || _state$onOnChainTx === void 0 ? void 0 : _state$onOnChainTx.call(state, message2.params.data.tx);
|
|
162
|
+
return {
|
|
163
|
+
handler: awaitingActionCompletion,
|
|
164
|
+
state
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
if (message2.method === 'channels.info' && [`own_${action}_locked`, `${action}_locked`].includes(message2.params.data.event)) {
|
|
168
|
+
var _state;
|
|
169
|
+
const Action = action === 'deposit' ? 'Deposit' : 'Withdraw';
|
|
170
|
+
const isOwn = message2.params.data.event.startsWith('own_');
|
|
171
|
+
(_state = state[`on${isOwn ? 'Own' : ''}${Action}Locked`]) === null || _state === void 0 ? void 0 : _state.call(state);
|
|
172
|
+
return {
|
|
173
|
+
handler: awaitingActionCompletion,
|
|
174
|
+
state
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
return awaitingCompletion(this, message2, state, () => {
|
|
178
|
+
changeState(this, message2.params.data.state);
|
|
179
|
+
state.resolve({
|
|
180
|
+
accepted: true,
|
|
181
|
+
signedTx: message2.params.data.state
|
|
182
|
+
});
|
|
183
|
+
return {
|
|
184
|
+
handler: channelOpen
|
|
185
|
+
};
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
const {
|
|
189
|
+
sign
|
|
190
|
+
} = state;
|
|
191
|
+
await signAndNotify(this, `channels.${action}_tx`, message.params.data, async tx => sign(tx, {
|
|
192
|
+
updates: message.params.data.updates
|
|
193
|
+
}));
|
|
194
|
+
return {
|
|
195
|
+
handler: awaitingActionCompletion,
|
|
196
|
+
state
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Withdraw coins from the channel
|
|
202
|
+
*
|
|
203
|
+
* After the channel had been opened any of the participants can initiate a withdrawal.
|
|
204
|
+
* The process closely resembles the update. The most notable difference is that the
|
|
205
|
+
* transaction has been co-signed: it is channel_withdraw_tx and after the procedure
|
|
206
|
+
* is finished - it is being posted on-chain.
|
|
207
|
+
*
|
|
208
|
+
* Any of the participants can initiate a withdrawal. The only requirements are:
|
|
209
|
+
*
|
|
210
|
+
* - Channel is already opened
|
|
211
|
+
* - No off-chain update/deposit/withdrawal is currently being performed
|
|
212
|
+
* - Channel is not being closed or in a solo closing state
|
|
213
|
+
* - The withdrawal amount must be equal to or greater than zero, and cannot exceed
|
|
214
|
+
* the available balance on the channel (minus the channel_reserve)
|
|
215
|
+
*
|
|
216
|
+
* After the other party had signed the withdraw transaction, the transaction is posted
|
|
217
|
+
* on-chain and onOnChainTx callback is called with on-chain transaction as first argument.
|
|
218
|
+
* After computing transaction hash it can be tracked on the chain: entering the mempool,
|
|
219
|
+
* block inclusion and a number of confirmations.
|
|
220
|
+
*
|
|
221
|
+
* After the minimum_depth block confirmations onOwnWithdrawLocked callback is called
|
|
222
|
+
* (without any arguments).
|
|
223
|
+
*
|
|
224
|
+
* When the other party had confirmed that the block height needed is reached
|
|
225
|
+
* onWithdrawLocked callback is called (without any arguments).
|
|
226
|
+
*
|
|
227
|
+
* @param amount - Amount of coins to withdraw
|
|
228
|
+
* @param sign - Function which verifies and signs withdraw transaction
|
|
229
|
+
* @param callbacks - Callbacks
|
|
230
|
+
* @param callbacks.onOnChainTx - Called when withdraw transaction has been posted
|
|
231
|
+
* on chain
|
|
232
|
+
* @param callbacks.onOwnWithdrawLocked
|
|
233
|
+
* @param callbacks.onWithdrawLocked
|
|
234
|
+
* @example
|
|
235
|
+
* ```js
|
|
236
|
+
* channel.withdraw(
|
|
237
|
+
* 100,
|
|
238
|
+
* async (tx) => await account.signTransaction(tx),
|
|
239
|
+
* { onOnChainTx: (tx) => console.log('on_chain_tx', tx) }
|
|
240
|
+
* ).then(({ accepted, signedTx }) => {
|
|
241
|
+
* if (accepted) {
|
|
242
|
+
* console.log('Withdrawal has been accepted')
|
|
243
|
+
* } else {
|
|
244
|
+
* console.log('Withdrawal has been rejected')
|
|
245
|
+
* }
|
|
246
|
+
* })
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
async withdraw(amount, sign) {
|
|
250
|
+
let {
|
|
251
|
+
onOnChainTx,
|
|
252
|
+
onOwnWithdrawLocked,
|
|
253
|
+
onWithdrawLocked
|
|
254
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
255
|
+
return this.enqueueAction(() => {
|
|
256
|
+
notify(this, 'channels.withdraw', {
|
|
257
|
+
amount
|
|
258
|
+
});
|
|
259
|
+
return {
|
|
260
|
+
handler: async (_, message, state) => this.awaitingActionTx('withdraw', message, state),
|
|
261
|
+
state: {
|
|
262
|
+
sign,
|
|
263
|
+
onOnChainTx,
|
|
264
|
+
onOwnWithdrawLocked,
|
|
265
|
+
onWithdrawLocked
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Deposit coins into the channel
|
|
273
|
+
*
|
|
274
|
+
* After the channel had been opened any of the participants can initiate a deposit.
|
|
275
|
+
* The process closely resembles the update. The most notable difference is that the
|
|
276
|
+
* transaction has been co-signed: it is channel_deposit_tx and after the procedure
|
|
277
|
+
* is finished - it is being posted on-chain.
|
|
278
|
+
*
|
|
279
|
+
* Any of the participants can initiate a deposit. The only requirements are:
|
|
280
|
+
*
|
|
281
|
+
* - Channel is already opened
|
|
282
|
+
* - No off-chain update/deposit/withdrawal is currently being performed
|
|
283
|
+
* - Channel is not being closed or in a solo closing state
|
|
284
|
+
* - The deposit amount must be equal to or greater than zero, and cannot exceed
|
|
285
|
+
* the available balance on the channel (minus the channel_reserve)
|
|
286
|
+
*
|
|
287
|
+
* After the other party had signed the deposit transaction, the transaction is posted
|
|
288
|
+
* on-chain and onOnChainTx callback is called with on-chain transaction as first argument.
|
|
289
|
+
* After computing transaction hash it can be tracked on the chain: entering the mempool,
|
|
290
|
+
* block inclusion and a number of confirmations.
|
|
291
|
+
*
|
|
292
|
+
* After the minimum_depth block confirmations onOwnDepositLocked callback is called
|
|
293
|
+
* (without any arguments).
|
|
294
|
+
*
|
|
295
|
+
* When the other party had confirmed that the block height needed is reached
|
|
296
|
+
* onDepositLocked callback is called (without any arguments).
|
|
297
|
+
*
|
|
298
|
+
* @param amount - Amount of coins to deposit
|
|
299
|
+
* @param sign - Function which verifies and signs deposit transaction
|
|
300
|
+
* @param callbacks - Callbacks
|
|
301
|
+
* @param callbacks.onOnChainTx - Called when deposit transaction has been posted
|
|
302
|
+
* on chain
|
|
303
|
+
* @param callbacks.onOwnDepositLocked
|
|
304
|
+
* @param callbacks.onDepositLocked
|
|
305
|
+
* @example
|
|
306
|
+
* ```js
|
|
307
|
+
* channel.deposit(
|
|
308
|
+
* 100,
|
|
309
|
+
* async (tx) => await account.signTransaction(tx),
|
|
310
|
+
* { onOnChainTx: (tx) => console.log('on_chain_tx', tx) }
|
|
311
|
+
* ).then(({ accepted, state }) => {
|
|
312
|
+
* if (accepted) {
|
|
313
|
+
* console.log('Deposit has been accepted')
|
|
314
|
+
* console.log('The new state is:', state)
|
|
315
|
+
* } else {
|
|
316
|
+
* console.log('Deposit has been rejected')
|
|
317
|
+
* }
|
|
318
|
+
* })
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
321
|
+
async deposit(amount, sign) {
|
|
322
|
+
let {
|
|
323
|
+
onOnChainTx,
|
|
324
|
+
onOwnDepositLocked,
|
|
325
|
+
onDepositLocked
|
|
326
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
327
|
+
return this.enqueueAction(() => {
|
|
328
|
+
notify(this, 'channels.deposit', {
|
|
329
|
+
amount
|
|
330
|
+
});
|
|
331
|
+
return {
|
|
332
|
+
handler: async (_, message, state) => this.awaitingActionTx('deposit', message, state),
|
|
333
|
+
state: {
|
|
334
|
+
sign,
|
|
335
|
+
onOnChainTx,
|
|
336
|
+
onOwnDepositLocked,
|
|
337
|
+
onDepositLocked
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Send generic message
|
|
345
|
+
*
|
|
346
|
+
* If message is an object it will be serialized into JSON string
|
|
347
|
+
* before sending.
|
|
348
|
+
*
|
|
349
|
+
* If there is ongoing update that has not yet been finished the message
|
|
350
|
+
* will be sent after that update is finalized.
|
|
351
|
+
*
|
|
352
|
+
* @param message - Message
|
|
353
|
+
* @param recipient - Address of the recipient
|
|
354
|
+
* @example
|
|
355
|
+
* ```js
|
|
356
|
+
* channel.sendMessage(
|
|
357
|
+
* 'hello world',
|
|
358
|
+
* 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH'
|
|
359
|
+
* )
|
|
360
|
+
* ```
|
|
361
|
+
*/
|
|
362
|
+
async sendMessage(message, recipient) {
|
|
363
|
+
const info = typeof message === 'object' ? JSON.stringify(message) : message;
|
|
364
|
+
if (this.status() === 'connecting') {
|
|
365
|
+
await new Promise(resolve => {
|
|
366
|
+
const onStatusChanged = status => {
|
|
367
|
+
if (status === 'connecting') return;
|
|
368
|
+
resolve();
|
|
369
|
+
this.off('statusChanged', onStatusChanged);
|
|
370
|
+
};
|
|
371
|
+
this.on('statusChanged', onStatusChanged);
|
|
372
|
+
});
|
|
373
|
+
// For some reason we can't immediately send a message when connection is
|
|
374
|
+
// established. Thus we wait 500ms which seems to work.
|
|
375
|
+
await pause(500);
|
|
376
|
+
}
|
|
377
|
+
notify(this, 'channels.message', {
|
|
378
|
+
info,
|
|
379
|
+
to: recipient
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
//# sourceMappingURL=Spend.mjs.map
|