@aeternity/aepp-sdk 11.0.0 → 12.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -22
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +2 -1
- package/dist/aepp-sdk.browser.js.LICENSE.txt +1 -0
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +20764 -1
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdk.d.ts +37 -0
- package/es/AeSdk.mjs +81 -0
- package/es/AeSdk.mjs.map +1 -0
- package/es/AeSdkAepp.d.ts +70 -0
- package/es/AeSdkAepp.mjs +176 -0
- package/es/AeSdkAepp.mjs.map +1 -0
- package/es/AeSdkBase.d.ts +213 -0
- package/es/AeSdkBase.mjs +314 -0
- package/es/AeSdkBase.mjs.map +1 -0
- package/es/AeSdkWallet.d.ts +104 -0
- package/es/AeSdkWallet.mjs +326 -0
- package/es/AeSdkWallet.mjs.map +1 -0
- package/es/Node.d.ts +41 -0
- package/es/Node.mjs +147 -0
- package/es/Node.mjs.map +1 -0
- package/es/account/Base.d.ts +68 -0
- package/es/account/Base.mjs +123 -0
- package/es/account/Base.mjs.map +1 -0
- package/es/account/Memory.d.ts +26 -0
- package/es/account/Memory.mjs +103 -0
- package/es/account/Memory.mjs.map +1 -0
- package/es/account/Rpc.d.ts +27 -0
- package/es/account/Rpc.mjs +80 -0
- package/es/account/Rpc.mjs.map +1 -0
- package/es/aens.d.ts +222 -0
- package/es/aens.mjs +338 -0
- package/es/aens.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection/Browser.d.ts +33 -0
- package/es/aepp-wallet-communication/connection/Browser.mjs +73 -0
- package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +18 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +58 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +146 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection-proxy.d.ts +11 -0
- package/{src/utils/crypto-ts.ts → es/aepp-wallet-communication/connection-proxy.mjs} +16 -11
- package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -0
- package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +169 -0
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -0
- package/es/aepp-wallet-communication/rpc/types.d.ts +77 -0
- package/es/aepp-wallet-communication/rpc/types.mjs +3 -0
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -0
- package/es/aepp-wallet-communication/schema.d.ts +105 -46
- package/es/aepp-wallet-communication/schema.mjs +251 -0
- package/es/aepp-wallet-communication/schema.mjs.map +1 -0
- package/es/aepp-wallet-communication/wallet-detector.d.ts +25 -0
- package/es/aepp-wallet-communication/wallet-detector.mjs +62 -0
- package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
- package/es/apis/compiler/compiler.d.ts +92 -0
- package/es/apis/compiler/compiler.mjs +576 -0
- package/es/apis/compiler/compiler.mjs.map +1 -0
- package/es/apis/compiler/index.d.ts +2 -0
- package/es/apis/compiler/index.mjs +3 -0
- package/es/apis/compiler/index.mjs.map +1 -0
- package/es/apis/compiler/models/index.d.ts +248 -0
- package/es/apis/compiler/models/index.mjs +48 -0
- package/es/apis/compiler/models/index.mjs.map +1 -0
- package/es/apis/compiler/models/mappers.d.ts +23 -0
- package/es/apis/compiler/models/mappers.mjs +585 -0
- package/es/apis/compiler/models/mappers.mjs.map +1 -0
- package/es/apis/compiler/models/parameters.d.ts +13 -0
- package/es/apis/compiler/models/parameters.mjs +71 -0
- package/es/apis/compiler/models/parameters.mjs.map +1 -0
- package/es/apis/node/index.d.ts +2 -0
- package/es/apis/node/index.mjs +3 -0
- package/es/apis/node/index.mjs.map +1 -0
- package/es/apis/node/models/index.d.ts +1065 -0
- package/es/apis/node/models/index.mjs +2 -0
- package/es/apis/node/models/index.mjs.map +1 -0
- package/es/apis/node/models/mappers.d.ts +95 -0
- package/es/apis/node/models/mappers.mjs +4166 -0
- package/es/apis/node/models/mappers.mjs.map +1 -0
- package/es/apis/node/models/parameters.d.ts +17 -0
- package/es/apis/node/models/parameters.mjs +165 -0
- package/es/apis/node/models/parameters.mjs.map +1 -0
- package/es/apis/node/node.d.ts +215 -0
- package/es/apis/node/node.mjs +1165 -0
- package/es/apis/node/node.mjs.map +1 -0
- package/es/chain.d.ts +248 -0
- package/es/chain.mjs +560 -0
- package/es/chain.mjs.map +1 -0
- package/es/channel/handlers.d.ts +34 -0
- package/es/channel/handlers.mjs +164 -131
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/index.d.ts +625 -0
- package/es/channel/index.mjs +897 -902
- package/es/channel/index.mjs.map +1 -1
- package/es/channel/internal.d.ts +101 -0
- package/es/channel/internal.mjs +138 -88
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Compiler.d.ts +18 -0
- package/es/contract/Compiler.mjs +68 -0
- package/es/contract/Compiler.mjs.map +1 -0
- package/es/contract/aci.d.ts +127 -0
- package/es/contract/aci.mjs +225 -193
- package/es/contract/aci.mjs.map +1 -1
- package/es/contract/ga.d.ts +69 -0
- package/es/contract/ga.mjs +195 -0
- package/es/contract/ga.mjs.map +1 -0
- package/es/contract/methods.d.ts +71 -0
- package/es/contract/methods.mjs +104 -0
- package/es/contract/methods.mjs.map +1 -0
- package/es/deprecated/index.d.ts +143 -0
- package/es/deprecated/index.mjs +162 -0
- package/es/deprecated/index.mjs.map +1 -0
- package/es/deprecated/methods.d.ts +18 -0
- package/es/deprecated/methods.mjs +26 -0
- package/es/deprecated/methods.mjs.map +1 -0
- package/es/index.d.ts +35 -0
- package/es/index.mjs +35 -40
- package/es/index.mjs.map +1 -1
- package/es/oracle.d.ts +161 -0
- package/es/oracle.mjs +306 -0
- package/es/oracle.mjs.map +1 -0
- package/es/spend.d.ts +62 -0
- package/es/spend.mjs +111 -0
- package/es/spend.mjs.map +1 -0
- package/es/tx/builder/address.d.ts +25 -0
- package/es/tx/builder/address.mjs +45 -0
- package/es/tx/builder/address.mjs.map +1 -0
- package/es/tx/builder/constants.d.ts +70 -0
- package/es/tx/builder/constants.mjs +122 -0
- package/es/tx/builder/constants.mjs.map +1 -0
- package/es/tx/builder/field-types/coin-amount.d.ts +13 -0
- package/es/tx/builder/field-types/coin-amount.mjs +26 -0
- package/es/tx/builder/field-types/coin-amount.mjs.map +1 -0
- package/es/tx/builder/field-types/deposit.d.ts +15 -0
- package/es/tx/builder/field-types/deposit.mjs +19 -0
- package/es/tx/builder/field-types/deposit.mjs.map +1 -0
- package/es/tx/builder/field-types/fee.d.ts +25 -0
- package/es/tx/builder/field-types/fee.mjs +150 -0
- package/es/tx/builder/field-types/fee.mjs.map +1 -0
- package/es/tx/builder/field-types/field.d.ts +6 -0
- package/es/tx/builder/field-types/field.mjs +15 -0
- package/es/tx/builder/field-types/field.mjs.map +1 -0
- package/es/tx/builder/field-types/gas-limit.d.ts +12 -0
- package/es/tx/builder/field-types/gas-limit.mjs +33 -0
- package/es/tx/builder/field-types/gas-limit.mjs.map +1 -0
- package/es/tx/builder/field-types/gas-price.d.ts +8 -0
- package/es/tx/builder/field-types/gas-price.mjs +18 -0
- package/es/tx/builder/field-types/gas-price.mjs.map +1 -0
- package/es/tx/builder/field-types/index.d.ts +70 -0
- package/es/tx/builder/field-types/index.mjs +25 -0
- package/es/tx/builder/field-types/index.mjs.map +1 -0
- package/es/tx/builder/field-types/name-fee.d.ts +20 -0
- package/es/tx/builder/field-types/name-fee.mjs +24 -0
- package/es/tx/builder/field-types/name-fee.mjs.map +1 -0
- package/es/tx/builder/field-types/name-id.d.ts +14 -0
- package/es/tx/builder/field-types/name-id.mjs +19 -0
- package/es/tx/builder/field-types/name-id.mjs.map +1 -0
- package/es/tx/builder/field-types/name.d.ts +13 -0
- package/es/tx/builder/field-types/name.mjs +18 -0
- package/es/tx/builder/field-types/name.mjs.map +1 -0
- package/es/tx/builder/field-types/short-u-int.d.ts +6 -0
- package/es/tx/builder/field-types/short-u-int.mjs +12 -0
- package/es/tx/builder/field-types/short-u-int.mjs.map +1 -0
- package/es/tx/builder/field-types/u-int.d.ts +8 -0
- package/es/tx/builder/field-types/u-int.mjs +14 -0
- package/es/tx/builder/field-types/u-int.mjs.map +1 -0
- package/es/tx/builder/helpers.d.ts +125 -0
- package/es/tx/builder/helpers.mjs +94 -240
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +88 -0
- package/es/tx/builder/index.mjs +167 -358
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +1201 -0
- package/es/tx/builder/schema.mjs +175 -664
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/index.d.ts +64 -0
- package/es/tx/index.mjs +151 -265
- package/es/tx/index.mjs.map +1 -1
- package/es/tx/validator.d.ts +20 -0
- package/es/tx/validator.mjs +104 -124
- package/es/tx/validator.mjs.map +1 -1
- package/es/typings/@aeternity__argon2-browser/index.d.mjs +2 -0
- package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -0
- package/es/typings/@aeternity__uuid/index.d.mjs +2 -0
- package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -0
- package/es/typings/bip32-path/index.d.mjs +2 -0
- package/es/typings/bip32-path/index.d.mjs.map +1 -0
- package/es/typings/blakejs/index.d.mjs.map +1 -1
- package/es/typings/sha-js/index.d.mjs +2 -0
- package/es/typings/sha-js/index.d.mjs.map +1 -0
- package/es/typings/tweetnacl-auth/index.d.mjs +2 -0
- package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -0
- package/es/utils/amount-formatter.d.ts +42 -0
- package/es/utils/amount-formatter.mjs +36 -49
- package/es/utils/amount-formatter.mjs.map +1 -1
- package/es/utils/autorest.d.ts +6 -0
- package/es/utils/autorest.mjs +97 -0
- package/es/utils/autorest.mjs.map +1 -0
- package/es/utils/bignumber.d.ts +13 -0
- package/es/utils/bignumber.mjs +11 -8
- package/es/utils/bignumber.mjs.map +1 -1
- package/es/{bytes.d.ts → utils/bytes.d.ts} +10 -13
- package/es/utils/bytes.mjs +11 -15
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/crypto.d.ts +88 -0
- package/es/utils/crypto.mjs +64 -108
- package/es/utils/crypto.mjs.map +1 -1
- package/es/utils/encoder-types.d.ts +61 -0
- package/es/utils/encoder-types.mjs +36 -0
- package/es/utils/encoder-types.mjs.map +1 -0
- package/es/utils/encoder.d.ts +25 -0
- package/es/utils/encoder.mjs +118 -0
- package/es/utils/encoder.mjs.map +1 -0
- package/es/{errors.d.ts → utils/errors.d.ts} +246 -59
- package/es/utils/errors.mjs +313 -136
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/hd-wallet.d.ts +50 -0
- package/es/utils/hd-wallet.mjs +86 -45
- package/es/utils/hd-wallet.mjs.map +1 -1
- package/es/utils/json-big.d.ts +5 -0
- package/es/utils/json-big.mjs +12 -16
- package/es/utils/json-big.mjs.map +1 -1
- package/es/utils/keystore.d.ts +51 -0
- package/es/utils/keystore.mjs +101 -194
- package/es/utils/keystore.mjs.map +1 -1
- package/es/{mptree.d.ts → utils/mptree.d.ts} +6 -9
- package/es/utils/mptree.mjs +22 -18
- package/es/utils/mptree.mjs.map +1 -1
- package/es/utils/other.d.ts +20 -0
- package/es/utils/other.mjs +32 -35
- package/es/utils/other.mjs.map +1 -1
- package/es/utils/semver-satisfies.d.ts +1 -0
- package/es/utils/semver-satisfies.mjs +2 -2
- package/es/utils/semver-satisfies.mjs.map +1 -1
- package/es/utils/string.d.ts +24 -0
- package/es/utils/string.mjs +8 -10
- package/es/utils/string.mjs.map +1 -1
- package/package.json +56 -42
- package/src/AeSdk.ts +68 -0
- package/src/AeSdkAepp.ts +176 -0
- package/src/AeSdkBase.ts +338 -0
- package/src/AeSdkWallet.ts +348 -0
- package/src/Node.ts +173 -0
- package/src/account/Base.ts +124 -0
- package/src/account/Memory.ts +98 -0
- package/src/account/Rpc.ts +69 -0
- package/src/aens.ts +407 -0
- package/src/aepp-wallet-communication/connection/Browser.ts +71 -0
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +59 -0
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +122 -0
- package/{es/utils/crypto-ts.mjs → src/aepp-wallet-communication/connection-proxy.ts} +18 -18
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +143 -0
- package/src/aepp-wallet-communication/rpc/types.ts +66 -0
- package/src/aepp-wallet-communication/schema.ts +224 -0
- package/src/aepp-wallet-communication/wallet-detector.ts +72 -0
- package/src/apis/compiler/code-model-v4.yaml +2649 -0
- package/src/apis/compiler/compiler.ts +585 -0
- package/src/apis/compiler/index.ts +2 -0
- package/src/apis/compiler/models/index.ts +301 -0
- package/src/apis/compiler/models/mappers.ts +583 -0
- package/src/apis/compiler/models/parameters.ts +93 -0
- package/src/apis/node/code-model-v4.yaml +10080 -0
- package/src/apis/node/index.ts +2 -0
- package/src/apis/node/models/index.ts +1257 -0
- package/src/apis/node/models/mappers.ts +4280 -0
- package/src/apis/node/models/parameters.ts +188 -0
- package/src/apis/node/node.ts +1299 -0
- package/src/chain.ts +502 -0
- package/src/channel/handlers.ts +817 -0
- package/src/channel/index.ts +1025 -0
- package/src/channel/internal.ts +361 -0
- package/src/contract/Compiler.ts +67 -0
- package/src/contract/aci.ts +538 -0
- package/src/contract/ga.ts +199 -0
- package/src/contract/methods.ts +123 -0
- package/src/deprecated/index.ts +170 -0
- package/src/deprecated/methods.ts +25 -0
- package/src/index.ts +56 -0
- package/src/oracle.ts +364 -0
- package/src/spend.ts +164 -0
- package/src/tx/builder/address.ts +50 -0
- package/src/tx/builder/constants.ts +126 -0
- package/src/tx/builder/field-types/coin-amount.ts +27 -0
- package/src/tx/builder/field-types/deposit.ts +21 -0
- package/src/tx/builder/field-types/fee.ts +143 -0
- package/src/tx/builder/field-types/field.ts +9 -0
- package/src/tx/builder/field-types/gas-limit.ts +41 -0
- package/src/tx/builder/field-types/gas-price.ts +16 -0
- package/src/tx/builder/field-types/index.ts +45 -0
- package/src/tx/builder/field-types/name-fee.ts +32 -0
- package/src/tx/builder/field-types/name-id.ts +20 -0
- package/src/tx/builder/field-types/name.ts +18 -0
- package/src/tx/builder/field-types/short-u-int.ts +11 -0
- package/src/tx/builder/field-types/u-int.ts +16 -0
- package/src/tx/builder/helpers.ts +248 -0
- package/src/tx/builder/index.ts +400 -0
- package/src/tx/builder/schema.ts +727 -0
- package/src/tx/index.ts +192 -0
- package/src/tx/validator.ts +230 -0
- package/src/typings/@aeternity__argon2-browser/index.d.ts +3 -0
- package/src/typings/@aeternity__uuid/index.d.ts +5 -0
- package/src/typings/bip32-path/index.d.ts +33 -0
- package/src/typings/blakejs/index.d.ts +4 -32
- package/src/typings/sha-js/index.d.ts +5 -0
- package/src/typings/tweetnacl-auth/index.d.ts +14 -0
- package/src/utils/amount-formatter.ts +56 -69
- package/src/utils/autorest.ts +93 -0
- package/src/utils/bignumber.ts +11 -12
- package/src/utils/bytes.ts +29 -31
- package/src/utils/crypto.ts +205 -0
- package/src/utils/encoder-types.ts +63 -0
- package/src/utils/encoder.ts +146 -0
- package/src/utils/errors.ts +482 -366
- package/src/utils/hd-wallet.ts +166 -0
- package/src/utils/json-big.ts +27 -0
- package/src/utils/keystore.ts +182 -0
- package/src/utils/mptree.ts +64 -61
- package/src/utils/other.ts +34 -41
- package/src/utils/semver-satisfies.ts +15 -11
- package/src/utils/string.ts +18 -20
- package/es/account/base.mjs +0 -179
- package/es/account/base.mjs.map +0 -1
- package/es/account/memory.mjs +0 -99
- package/es/account/memory.mjs.map +0 -1
- package/es/account/multiple.mjs +0 -179
- package/es/account/multiple.mjs.map +0 -1
- package/es/ae/aens.mjs +0 -404
- package/es/ae/aens.mjs.map +0 -1
- package/es/ae/aepp.mjs +0 -45
- package/es/ae/aepp.mjs.map +0 -1
- package/es/ae/contract.mjs +0 -159
- package/es/ae/contract.mjs.map +0 -1
- package/es/ae/index.mjs +0 -207
- package/es/ae/index.mjs.map +0 -1
- package/es/ae/oracle.mjs +0 -339
- package/es/ae/oracle.mjs.map +0 -1
- package/es/ae/universal.mjs +0 -45
- package/es/ae/universal.mjs.map +0 -1
- package/es/ae/wallet.mjs +0 -50
- package/es/ae/wallet.mjs.map +0 -1
- package/es/amount-formatter.d.ts +0 -58
- package/es/bignumber.d.ts +0 -18
- package/es/chain/index.mjs +0 -272
- package/es/chain/index.mjs.map +0 -1
- package/es/chain/node.mjs +0 -442
- package/es/chain/node.mjs.map +0 -1
- package/es/contract/compiler.mjs +0 -115
- package/es/contract/compiler.mjs.map +0 -1
- package/es/contract/ga/helpers.mjs +0 -30
- package/es/contract/ga/helpers.mjs.map +0 -1
- package/es/contract/ga/index.mjs +0 -178
- package/es/contract/ga/index.mjs.map +0 -1
- package/es/crypto-ts.d.ts +0 -9
- package/es/node-pool/index.mjs +0 -188
- package/es/node-pool/index.mjs.map +0 -1
- package/es/node.mjs +0 -133
- package/es/node.mjs.map +0 -1
- package/es/other.d.ts +0 -31
- package/es/semver-satisfies.d.ts +0 -1
- package/es/string.d.ts +0 -26
- package/es/tx/builder/field-types.mjs +0 -74
- package/es/tx/builder/field-types.mjs.map +0 -1
- package/es/tx/tx-object.mjs +0 -283
- package/es/tx/tx-object.mjs.map +0 -1
- package/es/tx/tx.mjs +0 -938
- package/es/tx/tx.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs +0 -132
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs +0 -183
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/index.mjs +0 -87
- package/es/utils/aepp-wallet-communication/connection/index.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/content-script-bridge.mjs +0 -98
- package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/helpers.mjs +0 -92
- package/es/utils/aepp-wallet-communication/helpers.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +0 -375
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs +0 -275
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs +0 -541
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/schema.mjs +0 -102
- package/es/utils/aepp-wallet-communication/schema.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/wallet-detector.mjs +0 -110
- package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +0 -1
- package/es/utils/async-init.mjs +0 -64
- package/es/utils/async-init.mjs.map +0 -1
- package/es/utils/crypto-ts.mjs.map +0 -1
- package/es/utils/swagger.mjs +0 -164
- package/es/utils/swagger.mjs.map +0 -1
- package/src/account/base.js +0 -153
- package/src/account/memory.js +0 -83
- package/src/account/multiple.js +0 -162
- package/src/ae/aens.js +0 -361
- package/src/ae/aepp.js +0 -45
- package/src/ae/contract.js +0 -148
- package/src/ae/index.js +0 -168
- package/src/ae/oracle.js +0 -311
- package/src/ae/universal.js +0 -47
- package/src/ae/wallet.js +0 -50
- package/src/chain/index.js +0 -269
- package/src/chain/node.js +0 -320
- package/src/channel/handlers.js +0 -673
- package/src/channel/index.js +0 -898
- package/src/channel/internal.js +0 -237
- package/src/contract/aci.js +0 -376
- package/src/contract/compiler.js +0 -100
- package/src/contract/ga/helpers.js +0 -19
- package/src/contract/ga/index.js +0 -150
- package/src/index.js +0 -89
- package/src/node-pool/index.js +0 -172
- package/src/node.js +0 -116
- package/src/tx/builder/field-types.js +0 -61
- package/src/tx/builder/helpers.js +0 -380
- package/src/tx/builder/index.js +0 -465
- package/src/tx/builder/schema.js +0 -1197
- package/src/tx/index.js +0 -301
- package/src/tx/tx-object.js +0 -187
- package/src/tx/tx.js +0 -631
- package/src/tx/validator.js +0 -181
- package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -119
- package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -165
- package/src/utils/aepp-wallet-communication/connection/index.js +0 -85
- package/src/utils/aepp-wallet-communication/content-script-bridge.js +0 -86
- package/src/utils/aepp-wallet-communication/helpers.js +0 -60
- package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -294
- package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -232
- package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -401
- package/src/utils/aepp-wallet-communication/schema.ts +0 -80
- package/src/utils/aepp-wallet-communication/wallet-detector.js +0 -92
- package/src/utils/async-init.js +0 -45
- package/src/utils/crypto.js +0 -229
- package/src/utils/hd-wallet.js +0 -100
- package/src/utils/json-big.js +0 -26
- package/src/utils/keystore.js +0 -219
- package/src/utils/swagger.js +0 -156
package/es/channel/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/channel/index.js"],"names":["AsyncInit","snakeToPascal","buildTx","unpackTx","TX_TYPE","handlers","eventEmitters","status","channelStatus","state","channelState","initialize","enqueueAction","send","channelId","call","disconnect","channelDisconnect","fsmId","channelFsmId","snakeToPascalObjKeys","obj","Object","entries","reduce","result","key","val","on","event","callback","get","off","removeListener","round","txType","tx","encodedTx","channelCreate","channelOffChain","channelWithdraw","channelDeposit","parseInt","id","update","from","to","amount","sign","metadata","Promise","resolve","reject","channel","handler","channelOpen","jsonrpc","method","params","meta","awaitingOffChainTx","poi","accounts","contracts","balances","fromEntries","map","item","account","balance","leave","awaitingLeave","shutdown","awaitingShutdownTx","withdraw","onOnChainTx","onOwnWithdrawLocked","onWithdrawLocked","awaitingWithdrawTx","deposit","onOwnDepositLocked","onDepositLocked","awaitingDepositTx","createContract","code","callData","vmVersion","abiVersion","call_data","vm_version","abi_version","awaitingNewContractTx","callContract","contract","contract_id","awaitingCallContractUpdateTx","forceProgress","gas","gasPrice","nonce","gas_price","awaitingCallContractForceProgressUpdate","callContractStatic","getContractCall","caller","caller_id","getContractState","pubkey","cleanContractCalls","awaitingCallsPruned","sendMessage","message","recipient","info","JSON","stringify","doSend","onStatusChanged","setTimeout","reconnect","options","txParams","Channel","reconnectTx","channelReconnect","compose","init","methods","statics"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;OAEOA,S;SACEC,a;SACAC,O,EAASC,Q;SACTC,O;OACF,KAAKC,Q;SAEVC,a,EACAC,MAAM,IAAIC,a,EACVC,KAAK,IAAIC,Y,EACTC,U,EACAC,a,EACAC,I,EACAC,S,EACAC,I,EACAC,UAAU,IAAIC,iB,EACdC,KAAK,IAAIC,Y;;AAGX,SAASC,oBAAT,CAA+BC,GAA/B,EAAoC;AAClC,SAAOC,MAAM,CAACC,OAAP,CAAeF,GAAf,EAAoBG,MAApB,CAA2B,CAACC,MAAD;AAAA,QAAS,CAACC,GAAD,EAAMC,GAAN,CAAT;AAAA,WAAyB,EACzD,GAAGF,MADsD;AAEzD,OAACxB,aAAa,CAACyB,GAAD,CAAd,GAAsBC;AAFmC,KAAzB;AAAA,GAA3B,EAGH,EAHG,CAAP;AAID;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA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FO;AAGPzB,IAAAA,MAHO;AAIPE,IAAAA,KAJO;AAKPyB,IAAAA,KALO;AAMPS,IAAAA,EANO;AAOPzB,IAAAA,KAPO;AAQP0B,IAAAA,MARO;AASPiB,IAAAA,GATO;AAUPG,IAAAA,QAVO;AAWPM,IAAAA,KAXO;AAYPE,IAAAA,QAZO;AAaPsC,IAAAA,WAbO;AAcPpC,IAAAA,QAdO;AAePK,IAAAA,OAfO;AAgBPI,IAAAA,cAhBO;AAiBPS,IAAAA,YAjBO;AAkBPU,IAAAA,kBAlBO;AAmBPC,IAAAA,eAnBO;AAoBPG,IAAAA,gBApBO;AAqBP1F,IAAAA,UArBO;AAsBP4F,IAAAA,kBAtBO;AAuBPZ,IAAAA;AAvBO,GAJuB;AA6BhCgC,EAAAA,OAAO,EAAE;AACPT,IAAAA;AADO;AA7BuB,CAAlB,CAAhB;AAkCA,eAAeG,OAAf","sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2018 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * Channel module\n * @module @aeternity/aepp-sdk/es/channel/index\n * @export Channel\n * @example import { Channel } from '@aeternity/aepp-sdk'\n */\n\nimport AsyncInit from '../utils/async-init'\nimport { snakeToPascal } from '../utils/string'\nimport { buildTx, unpackTx } from '../tx/builder'\nimport { TX_TYPE } from '../tx/builder/schema'\nimport * as handlers from './handlers'\nimport {\n eventEmitters,\n status as channelStatus,\n state as channelState,\n initialize,\n enqueueAction,\n send,\n channelId,\n call,\n disconnect as channelDisconnect,\n fsmId as channelFsmId\n} from './internal'\n\nfunction snakeToPascalObjKeys (obj) {\n return Object.entries(obj).reduce((result, [key, val]) => ({\n ...result,\n [snakeToPascal(key)]: val\n }), {})\n}\n\n/**\n * Register event listener function\n *\n * Possible events:\n *\n * - \"error\"\n * - \"onChainTx\"\n * - \"ownWithdrawLocked\"\n * - \"withdrawLocked\"\n * - \"ownDepositLocked\"\n * - \"depositLocked\"\n *\n * @param {String} event - Event name\n * @param {Function} callback - Callback function\n */\nfunction on (event, callback) {\n eventEmitters.get(this).on(event, callback)\n}\n\n/**\n * Remove event listener function\n *\n * @param {String} event - Event name\n * @param {Function} callback - Callback function\n */\nfunction off (event, callback) {\n eventEmitters.get(this).removeListener(event, callback)\n}\n\n/**\n * Close the connection\n */\nfunction disconnect () {\n return channelDisconnect(this)\n}\n\n/**\n * Get current status\n *\n * @return {String}\n */\nfunction status () {\n return channelStatus.get(this)\n}\n\n/**\n * Get current state\n *\n * @return {Promise<Object>}\n */\nasync function state () {\n return snakeToPascalObjKeys(await call(this, 'channels.get.offchain_state', {}))\n}\n\n/**\n * Get current round\n *\n * If round cannot be determined (for example when channel has not been opened)\n * it will return `null`.\n *\n * @return {Number}\n */\nfunction round () {\n const state = channelState.get(this)\n if (!state) {\n return null\n }\n const { txType, tx } = unpackTx(channelState.get(this)).tx.encodedTx\n switch (txType) {\n case TX_TYPE.channelCreate:\n return 1\n case TX_TYPE.channelOffChain:\n case TX_TYPE.channelWithdraw:\n case TX_TYPE.channelDeposit:\n return parseInt(tx.round, 10)\n default:\n return null\n }\n}\n\n/**\n * Get channel id\n *\n * @return {String}\n */\nfunction id () {\n return channelId.get(this)\n}\n\n/**\n * Get channel's fsm id\n *\n * @return {String}\n */\nfunction fsmId () {\n return channelFsmId.get(this)\n}\n\n/**\n * Trigger a transfer update\n *\n * The transfer update is moving tokens from one channel account to another.\n * The update is a change to be applied on top of the latest state.\n *\n * Sender and receiver are the channel parties. Both the initiator and responder\n * can take those roles. Any public key outside of the channel is considered invalid.\n *\n * @param {String} from - Sender's public address\n * @param {String} to - Receiver's public address\n * @param {Number} amount - Transaction amount\n * @param {Function} sign - Function which verifies and signs offchain transaction\n * @param {Array<String>} metadata\n * @return {Promise<Object>}\n * @example channel.update(\n * 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',\n * 'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E',\n * 10,\n * async (tx) => await account.signTransaction(tx)\n * ).then(({ accepted, signedTx }) =>\n * if (accepted) {\n * console.log('Update has been accepted')\n * }\n * )\n */\nfunction update (from, to, amount, sign, metadata) {\n return new Promise((resolve, reject) => {\n enqueueAction(\n this,\n (channel, state) => state.handler === handlers.channelOpen,\n (channel, state) => {\n send(channel, {\n jsonrpc: '2.0',\n method: 'channels.update.new',\n params: { from, to, amount, meta: metadata }\n })\n return {\n handler: handlers.awaitingOffChainTx,\n state: {\n resolve,\n reject,\n sign\n }\n }\n }\n )\n })\n}\n\n/**\n * Get proof of inclusion\n *\n * If a certain address of an account or a contract is not found\n * in the state tree - the response is an error.\n *\n * @param {Object} addresses\n * @param {Array<String>} [addresses.accounts] - List of account addresses to include in poi\n * @param {Array<String>} [addresses.contracts] - List of contract addresses to include in poi\n * @return {Promise<String>}\n * @example channel.poi({\n * accounts: [\n * 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',\n * 'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E'\n * ],\n * contracts: ['ct_2dCUAWYZdrWfACz3a2faJeKVTVrfDYxCQHCqAt5zM15f3u2UfA']\n * }).then(poi => console.log(poi))\n */\nasync function poi ({ accounts, contracts }) {\n return (await call(this, 'channels.get.poi', { accounts, contracts })).poi\n}\n\n/**\n * Get balances\n *\n * The accounts paramcontains a list of addresses to fetch balances of.\n * Those can be either account balances or a contract ones, encoded as an account addresses.\n *\n * If a certain account address had not being found in the state tree - it is simply\n * skipped in the response.\n *\n * @param {Array<String>} accounts - List of addresses to fetch balances from\n * @return {Promise<Object>}\n * @example channel.balances([\n * 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',\n * 'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E'\n * 'ct_2dCUAWYZdrWfACz3a2faJeKVTVrfDYxCQHCqAt5zM15f3u2UfA'\n * ]).then(balances =>\n * console.log(balances['ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH'])\n * )\n */\nasync function balances (accounts) {\n return Object.fromEntries(\n (await call(this, 'channels.get.balances', { accounts }))\n .map(item => [item.account, item.balance])\n )\n}\n\n/**\n * Leave channel\n *\n * It is possible to leave a channel and then later reestablish the channel\n * off-chain state and continue operation. When a leave method is called,\n * the channel fsm passes it on to the peer fsm, reports the current mutually\n * signed state and then terminates.\n *\n * The channel can be reestablished by instantiating another Channel instance\n * with two extra params: existingChannelId and offchainTx (returned from leave\n * method as channelId and signedTx respectively).\n *\n * @return {Promise<Object>}\n * @example channel.leave().then(({ channelId, signedTx }) => {\n * console.log(channelId)\n * console.log(signedTx)\n * })\n */\nfunction leave () {\n return new Promise((resolve, reject) => {\n enqueueAction(\n this,\n (channel, state) => state.handler === handlers.channelOpen,\n (channel, state) => {\n send(channel, { jsonrpc: '2.0', method: 'channels.leave', params: {} })\n return {\n handler: handlers.awaitingLeave,\n state: { resolve, reject }\n }\n })\n })\n}\n\n/**\n * Trigger mutual close\n *\n * At any moment after the channel is opened, a closing procedure can be triggered.\n * This can be done by either of the parties. The process is similar to the off-chain updates.\n *\n * @param {Function} sign - Function which verifies and signs mutual close transaction\n * @return {Promise<String>}\n * @example channel.shutdown(\n * async (tx) => await account.signTransaction(tx)\n * ).then(tx => console.log('on_chain_tx', tx))\n */\nfunction shutdown (sign) {\n return new Promise((resolve, reject) => {\n enqueueAction(\n this,\n (channel, state) => state.handler === handlers.channelOpen,\n (channel, state) => {\n send(channel, { jsonrpc: '2.0', method: 'channels.shutdown', params: {} })\n return {\n handler: handlers.awaitingShutdownTx,\n state: {\n sign,\n resolve,\n reject\n }\n }\n }\n )\n })\n}\n\n/**\n * Withdraw tokens from the channel\n *\n * After the channel had been opened any of the participants can initiate a withdrawal.\n * The process closely resembles the update. The most notable difference is that the\n * transaction has been co-signed: it is channel_withdraw_tx and after the procedure\n * is finished - it is being posted on-chain.\n *\n * Any of the participants can initiate a withdrawal. The only requirements are:\n *\n * - Channel is already opened\n * - No off-chain update/deposit/withdrawal is currently being performed\n * - Channel is not being closed or in a solo closing state\n * - The withdrawal amount must be equal to or greater than zero, and cannot exceed\n * the available balance on the channel (minus the channel_reserve)\n *\n * After the other party had signed the withdraw transaction, the transaction is posted\n * on-chain and onOnChainTx callback is called with on-chain transaction as first argument.\n * After computing transaction hash it can be tracked on the chain: entering the mempool,\n * block inclusion and a number of confirmations.\n *\n * After the minimum_depth block confirmations onOwnWithdrawLocked callback is called\n * (without any arguments).\n *\n * When the other party had confirmed that the block height needed is reached\n * onWithdrawLocked callback is called (without any arguments).\n *\n * @param {Number} amount - Amount of tokens to withdraw\n * @param {Function} sign - Function which verifies and signs withdraw transaction\n * @param {Object} [callbacks]\n * @param {Function} [callbacks.onOnChainTx] - Called when withdraw transaction has been posted\n * on chain\n * @param {Function} [callbacks.onOwnWithdrawLocked]\n * @param {Function} [callbacks.onWithdrawLocked]\n * @return {Promise<Object>}\n * @example channel.withdraw(\n * 100,\n * async (tx) => await account.signTransaction(tx),\n * { onOnChainTx: (tx) => console.log('on_chain_tx', tx) }\n * ).then(({ accepted, signedTx }) => {\n * if (accepted) {\n * console.log('Withdrawal has been accepted')\n * } else {\n * console.log('Withdrawal has been rejected')\n * }\n * })\n */\nfunction withdraw (amount, sign, { onOnChainTx, onOwnWithdrawLocked, onWithdrawLocked } = {}) {\n return new Promise((resolve, reject) => {\n enqueueAction(\n this,\n (channel, state) => state.handler === handlers.channelOpen,\n (channel, state) => {\n send(channel, { jsonrpc: '2.0', method: 'channels.withdraw', params: { amount } })\n return {\n handler: handlers.awaitingWithdrawTx,\n state: {\n sign,\n resolve,\n reject,\n onOnChainTx,\n onOwnWithdrawLocked,\n onWithdrawLocked\n }\n }\n }\n )\n })\n}\n\n/**\n * Deposit tokens into the channel\n *\n * After the channel had been opened any of the participants can initiate a deposit.\n * The process closely resembles the update. The most notable difference is that the\n * transaction has been co-signed: it is channel_deposit_tx and after the procedure\n * is finished - it is being posted on-chain.\n *\n * Any of the participants can initiate a deposit. The only requirements are:\n *\n * - Channel is already opened\n * - No off-chain update/deposit/withdrawal is currently being performed\n * - Channel is not being closed or in a solo closing state\n * - The deposit amount must be equal to or greater than zero, and cannot exceed\n * the available balance on the channel (minus the channel_reserve)\n *\n * After the other party had signed the deposit transaction, the transaction is posted\n * on-chain and onOnChainTx callback is called with on-chain transaction as first argument.\n * After computing transaction hash it can be tracked on the chain: entering the mempool,\n * block inclusion and a number of confirmations.\n *\n * After the minimum_depth block confirmations onOwnDepositLocked callback is called\n * (without any arguments).\n *\n * When the other party had confirmed that the block height needed is reached\n * onDepositLocked callback is called (without any arguments).\n *\n * @param {Number} amount - Amount of tokens to deposit\n * @param {Function} sign - Function which verifies and signs deposit transaction\n * @param {Object} [callbacks]\n * @param {Function} [callbacks.onOnChainTx] - Called when deposit transaction has been posted\n * on chain\n * @param {Function} [callbacks.onOwnDepositLocked]\n * @param {Function} [callbacks.onDepositLocked]\n * @return {Promise<Object>}\n * @example channel.deposit(\n * 100,\n * async (tx) => await account.signTransaction(tx),\n * { onOnChainTx: (tx) => console.log('on_chain_tx', tx) }\n * ).then(({ accepted, state }) => {\n * if (accepted) {\n * console.log('Deposit has been accepted')\n * console.log('The new state is:', state)\n * } else {\n * console.log('Deposit has been rejected')\n * }\n * })\n */\nfunction deposit (amount, sign, { onOnChainTx, onOwnDepositLocked, onDepositLocked } = {}) {\n return new Promise((resolve, reject) => {\n enqueueAction(\n this,\n (channel, state) => state.handler === handlers.channelOpen,\n (channel, state) => {\n send(channel, { jsonrpc: '2.0', method: 'channels.deposit', params: { amount } })\n return {\n handler: handlers.awaitingDepositTx,\n state: {\n sign,\n resolve,\n reject,\n onOnChainTx,\n onOwnDepositLocked,\n onDepositLocked\n }\n }\n }\n )\n })\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 tokens to the new contract.\n *\n * @param {Object} options\n * @param {String} options.code - Api encoded compiled AEVM byte code\n * @param {String} options.callData - Api encoded compiled AEVM call data for the code\n * @param {Number} options.deposit - Initial amount the owner of the contract commits to it\n * @param {Number} options.vmVersion - Version of the Virtual Machine\n * @param {Number} options.abiVersion - Version of the Application Binary Interface\n * @param {Function} sign - Function which verifies and signs create contract transaction\n * @return {Promise<Object>}\n * @example 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 */\nfunction createContract ({ code, callData, deposit, vmVersion, abiVersion }, sign) {\n return new Promise((resolve, reject) => {\n enqueueAction(\n this,\n (channel, state) => state.handler === handlers.channelOpen,\n (channel, state) => {\n send(channel, {\n jsonrpc: '2.0',\n method: 'channels.update.new_contract',\n params: {\n code,\n call_data: callData,\n deposit,\n vm_version: vmVersion,\n abi_version: abiVersion\n }\n })\n return {\n handler: handlers.awaitingNewContractTx,\n state: {\n sign,\n resolve,\n reject\n }\n }\n }\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 tokens 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 a on-chain one. This could happen\n * if a call with a similar computation amount is to be forced on-chain.\n *\n * @param {Object} options\n * @param {String} [options.amount] - Amount the caller of the contract commits to it\n * @param {String} [options.callData] - ABI encoded compiled AEVM call data for the code\n * @param {Number} [options.contract] - Address of the contract to call\n * @param {Number} [options.abiVersion] - Version of the ABI\n * @param {Function} sign - Function which verifies and signs contract call transaction\n * @return {Promise<Object>}\n * @example 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 */\nfunction callContract ({ amount, callData, contract, abiVersion }, sign) {\n return new Promise((resolve, reject) => {\n enqueueAction(\n this,\n (channel, state) => state.handler === handlers.channelOpen,\n (channel, state) => {\n send(channel, {\n jsonrpc: '2.0',\n method: 'channels.update.call_contract',\n params: {\n amount,\n call_data: callData,\n contract_id: contract,\n abi_version: abiVersion\n }\n })\n return {\n handler: handlers.awaitingCallContractUpdateTx,\n state: { resolve, reject, sign }\n }\n }\n )\n })\n}\n\n/**\n * Trigger a force progress contract call\n * This call is going on-chain\n * @param {Object} options\n * @param {String} [options.amount] - Amount the caller of the contract commits to it\n * @param {String} [options.callData] - ABI encoded compiled AEVM call data for the code\n * @param {Number} [options.contract] - Address of the contract to call\n * @param {Number} [options.abiVersion] - Version of the ABI\n * @param {Number} [options.gasPrice=1000000000] - Gas price\n * @param {Number} [options.gas=1000000] - Gas limit\n * @param {Function} sign - Function which verifies and signs contract force progress transaction\n * @param {{ onOnChainTxL: Function }} callbacks\n * @return {Promise<Object>}\n * @example 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 */\nfunction forceProgress (\n { amount, callData, contract, abiVersion, gas = 1000000, gasPrice = 1000000000, nonce },\n sign,\n { onOnChainTx } = {}\n) {\n return new Promise((resolve, reject) => {\n enqueueAction(\n this,\n (channel, state) => state.handler === handlers.channelOpen,\n (channel, state) => {\n send(channel, {\n jsonrpc: '2.0',\n method: 'channels.force_progress',\n params: {\n amount,\n call_data: callData,\n contract_id: contract,\n abi_version: abiVersion,\n gas_price: gasPrice,\n gas\n }\n })\n return {\n handler: handlers.awaitingCallContractForceProgressUpdate,\n state: { resolve, reject, sign, onOnChainTx }\n }\n }\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 {Object} options\n * @param {String} [options.amount] - Amount the caller of the contract commits to it\n * @param {String} [options.callData] - ABI encoded compiled AEVM call data for the code\n * @param {Number} [options.contract] - Address of the contract to call\n * @param {Number} [options.abiVersion] - Version of the ABI\n * @return {Promise<Object>}\n * @example 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 */\nasync function callContractStatic ({ amount, callData, contract, abiVersion }) {\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 {Object} options\n * @param {String} [options.caller] - Address of contract caller\n * @param {String} [options.contract] - Address of the contract\n * @param {Number} [options.round] - Round when contract was called\n * @return {Promise<Object>}\n * @example 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 */\nasync function getContractCall ({ caller, contract, round }) {\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 contract latest state\n *\n * @param {String} contract - Address of the contract\n * @return {Promise<Object>}\n * @example channel.getContractState(\n * 'ct_9sRA9AVE4BYTAkh5RNfJYmwQe1NZ4MErasQLXZkFWG43TPBqa'\n * ).then(({ contract }) => {\n * console.log('deposit:', contract.deposit)\n * })\n */\nasync function getContractState (contract) {\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 * @return {Promise}\n */\nfunction cleanContractCalls () {\n return new Promise((resolve, reject) => {\n enqueueAction(\n this,\n (channel, state) => state.handler === handlers.channelOpen,\n (channel, state) => {\n send(channel, {\n jsonrpc: '2.0',\n method: 'channels.clean_contract_calls',\n params: {}\n })\n return {\n handler: handlers.awaitingCallsPruned,\n state: { resolve, reject }\n }\n }\n )\n })\n}\n\n/**\n * Send generic message\n *\n * If message is an object it will be serialized into JSON string\n * before sending.\n *\n * If there is ongoing update that has not yet been finished the message\n * will be sent after that update is finalized.\n *\n * @param {String|Object} message\n * @param {String} recipient - Address of the recipient\n * @example channel.sendMessage(\n * 'hello world',\n * 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH'\n * )\n */\nfunction sendMessage (message, recipient) {\n let info = message\n if (typeof message === 'object') {\n info = JSON.stringify(message)\n }\n const doSend = (channel) => send(channel, {\n jsonrpc: '2.0',\n method: 'channels.message',\n params: { info, to: recipient }\n })\n if (this.status() === 'connecting') {\n const onStatusChanged = (status) => {\n if (status !== 'connecting') {\n // For some reason we can't immediately send a message when connection is\n // established. Thus we wait 500ms which seems to work.\n setTimeout(() => doSend(this), 500)\n this.off('statusChanged', onStatusChanged)\n }\n }\n this.on('statusChanged', onStatusChanged)\n } else {\n doSend(this)\n }\n}\n\nasync function reconnect (options, txParams) {\n const { sign } = options\n\n return Channel({\n ...options,\n reconnectTx: await sign('reconnect', buildTx(txParams, TX_TYPE.channelReconnect).tx)\n })\n}\n\n/**\n * Channel\n *\n * @function\n * @alias module:@aeternity/aepp-sdk/es/channel/index\n * @rtype Channel\n * @param {Object} options - Channel params\n * @param {String} options.url - Channel url (for example: \"ws://localhost:3001\")\n * @param {String} options.role - Participant role (\"initiator\" or \"responder\")\n * @param {String} options.initiatorId - Initiator's public key\n * @param {String} options.responderId - Responder's public key\n * @param {Number} options.pushAmount - Initial deposit in favour of the responder by the initiator\n * @param {Number} options.initiatorAmount - Amount of tokens the initiator has committed to\n * the channel\n * @param {Number} options.responderAmount - Amount of tokens the responder has committed to\n * the channel\n * @param {Number} options.channelReserve - The minimum amount both peers need to maintain\n * @param {Number} [options.ttl] - Minimum block height to include the channel_create_tx\n * @param {String} options.host - Host of the responder's node\n * @param {Number} options.port - The port of the responders node\n * @param {Number} options.lockPeriod - Amount of blocks for disputing a solo close\n * @param {Number} [options.existingChannelId] - Existing channel id (required if reestablishing a\n * channel)\n * @param {Number} [options.offchainTx] - Offchain transaction (required if reestablishing\n * a channel)\n * @param {Number} [options.timeoutIdle] - The time waiting for a new event to be initiated\n * (default: 600000)\n * @param {Number} [options.timeoutFundingCreate] - The time waiting for the initiator to produce\n * the create channel transaction after the noise session had been established (default: 120000)\n * @param {Number} [options.timeoutFundingSign] - The time frame the other client has to sign an\n * off-chain update after our client had initiated and signed it. This applies only for double\n * signed on-chain intended updates: channel create transaction, deposit, withdrawal and etc.\n * (default: 120000)\n * @param {Number} [options.timeoutFundingLock] - The time frame the other client has to confirm an\n * on-chain transaction reaching maturity (passing minimum depth) after the local node has detected\n * this. This applies only for double signed on-chain intended updates: channel create transaction,\n * deposit, withdrawal and etc. (default: 360000)\n * @param {Number} [options.timeoutSign] - The time frame the client has to return a signed\n * off-chain update or to decline it. This applies for all off-chain updates (default: 500000)\n * @param {Number} [options.timeoutAccept] - The time frame the other client has to react to an\n * event. This applies for all off-chain updates that are not meant to land on-chain, as well as\n * some special cases: opening a noise connection, mutual closing acknowledgement and\n * reestablishing an existing channel (default: 120000)\n * @param {Number} [options.timeoutInitialized] - the time frame the responder has to accept an\n * incoming noise session. Applicable only for initiator (default: timeout_accept's value)\n * @param {Number} [options.timeoutAwaitingOpen] - The time frame the initiator has to start an\n * outgoing noise session to the responder's node. Applicable only for responder (default:\n * timeout_idle's value)\n * @param {Number} [options.debug=false] - Log websocket communication\n * @param {Function} options.sign - Function which verifies and signs transactions\n * @return {Promise<Object>} Channel instance\n * @example Channel({\n * url: 'ws://localhost:3001',\n * role: 'initiator'\n * initiatorId: 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',\n * responderId: 'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E',\n * initiatorAmount: 1e18,\n * responderAmount: 1e18,\n * pushAmount: 0,\n * channelReserve: 0,\n * ttl: 1000,\n * host: 'localhost',\n * port: 3002,\n * lockPeriod: 10,\n * async sign (tag, tx) => await account.signTransaction(tx)\n * })\n */\nconst Channel = AsyncInit.compose({\n async init (options) {\n initialize(this, options)\n },\n methods: {\n on,\n off,\n status,\n state,\n round,\n id,\n fsmId,\n update,\n poi,\n balances,\n leave,\n shutdown,\n sendMessage,\n withdraw,\n deposit,\n createContract,\n callContract,\n callContractStatic,\n getContractCall,\n getContractState,\n disconnect,\n cleanContractCalls,\n forceProgress\n },\n statics: {\n reconnect\n }\n})\n\nexport default Channel\n"],"file":"index.mjs"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["snakeToPascal","buildTx","unpackTx","MIN_GAS_PRICE","Tag","handlers","eventEmitters","status","channelStatus","state","channelState","initialize","enqueueAction","send","channelId","call","disconnect","channelDisconnect","fsmId","channelFsmId","UnknownChannelStateError","ChannelError","pause","snakeToPascalObjKeys","obj","Object","entries","reduce","result","key","val","Channel","options","channel","existingFsmId","awaitingReconnection","awaitingConnection","channelOpen","on","eventName","callback","eventEmitter","get","off","removeListener","round","txType","tx","SignedTx","encodedTx","ChannelCreateTx","ChannelOffChainTx","ChannelWithdrawTx","ChannelDepositTx","id","update","from","to","amount","sign","metadata","Promise","resolve","reject","_channel","handler","jsonrpc","method","params","meta","awaitingOffChainTx","poi","accounts","contracts","balances","fromEntries","map","item","account","balance","leave","awaitingLeave","shutdown","awaitingShutdownTx","withdraw","onOnChainTx","onOwnWithdrawLocked","onWithdrawLocked","awaitingWithdrawTx","deposit","onOwnDepositLocked","onDepositLocked","awaitingDepositTx","createContract","code","callData","vmVersion","abiVersion","call_data","vm_version","abi_version","awaitingNewContractTx","callContract","contract","contract_id","awaitingCallContractUpdateTx","forceProgress","gasLimit","gasPrice","gas_price","gas","awaitingCallContractForceProgressUpdate","callContractStatic","getContractCall","caller","caller_id","getContractState","pubkey","cleanContractCalls","awaitingCallsPruned","sendMessage","message","recipient","info","JSON","stringify","onStatusChanged","reconnect","txParams","reconnectTx","ChannelClientReconnectTx"],"sources":["../../src/channel/index.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2018 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\nimport BigNumber from 'bignumber.js';\nimport { snakeToPascal } from '../utils/string';\nimport { buildTx, unpackTx } from '../tx/builder';\nimport { MIN_GAS_PRICE, Tag } from '../tx/builder/constants';\nimport * as handlers from './handlers';\nimport {\n eventEmitters,\n status as channelStatus,\n state as channelState,\n initialize,\n enqueueAction,\n send,\n channelId,\n call,\n disconnect as channelDisconnect,\n fsmId as channelFsmId,\n SignTx,\n ChannelOptions,\n ChannelState,\n} from './internal';\nimport { UnknownChannelStateError, ChannelError } from '../utils/errors';\nimport { Encoded } from '../utils/encoder';\nimport { ContractCallReturnType } from '../apis/node';\nimport { pause } from '../utils/other';\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\ntype EventCallback = (...args: any[]) => void;\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\n/**\n * Channel\n * @example\n * ```js\n * await Channel.initialize({\n * url: 'ws://localhost:3001',\n * role: 'initiator'\n * initiatorId: 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',\n * responderId: 'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E',\n * initiatorAmount: 1e18,\n * responderAmount: 1e18,\n * pushAmount: 0,\n * channelReserve: 0,\n * ttl: 1000,\n * host: 'localhost',\n * port: 3002,\n * lockPeriod: 10,\n * async sign (tag, tx) => await account.signTransaction(tx)\n * })\n * ```\n */\nexport default class Channel {\n /**\n * @param options - Channel params\n * @param options.url - Channel url (for example: \"ws://localhost:3001\")\n * @param options.role - Participant role (\"initiator\" or \"responder\")\n * @param options.initiatorId - Initiator's public key\n * @param options.responderId - Responder's public key\n * @param options.pushAmount - Initial deposit in favour of the responder by the initiator\n * @param options.initiatorAmount - Amount of coins the initiator has committed to\n * the channel\n * @param options.responderAmount - Amount of coins the responder has committed to\n * the channel\n * @param options.channelReserve - The minimum amount both peers need to maintain\n * @param options.ttl - Minimum block height to include the channel_create_tx\n * @param options.host - Host of the responder's node\n * @param options.port - The port of the responders node\n * @param options.lockPeriod - Amount of blocks for disputing a solo close\n * @param options.existingChannelId - Existing channel id (required if reestablishing a\n * channel)\n * @param options.offchainTx - Offchain transaction (required if reestablishing\n * a channel)\n * @param options.timeoutIdle - The time waiting for a new event to be initiated\n * (default: 600000)\n * @param options.timeoutFundingCreate - The time waiting for the initiator to produce\n * the create channel transaction after the noise session had been established (default: 120000)\n * @param options.timeoutFundingSign - The time frame the other client has to sign an\n * off-chain update after our client had initiated and signed it. This applies only for double\n * signed on-chain intended updates: channel create transaction, deposit, withdrawal and etc.\n * (default: 120000)\n * @param options.timeoutFundingLock - The time frame the other client has to confirm an\n * on-chain transaction reaching maturity (passing minimum depth) after the local node has\n * detected this. This applies only for double signed on-chain intended updates: channel create\n * transaction, deposit, withdrawal and etc. (default: 360000)\n * @param options.timeoutSign - The time frame the client has to return a signed\n * off-chain update or to decline it. This applies for all off-chain updates (default: 500000)\n * @param options.timeoutAccept - The time frame the other client has to react to an\n * event. This applies for all off-chain updates that are not meant to land on-chain, as well as\n * some special cases: opening a noise connection, mutual closing acknowledgement and\n * reestablishing an existing channel (default: 120000)\n * @param options.timeoutInitialized - the time frame the responder has to accept an\n * incoming noise session. Applicable only for initiator (default: timeout_accept's value)\n * @param options.timeoutAwaitingOpen - The time frame the initiator has to start an\n * outgoing noise session to the responder's node. Applicable only for responder (default:\n * timeout_idle's value)\n * @param options.debug=false - Log websocket communication\n * @param options.sign - Function which verifies and signs transactions\n */\n static async initialize(options: ChannelOptions): Promise<Channel> {\n const channel = new Channel();\n await initialize(\n channel,\n options.existingFsmId != null ? handlers.awaitingReconnection : handlers.awaitingConnection,\n handlers.channelOpen,\n options,\n );\n return channel;\n }\n\n /**\n * Register event listener function\n *\n * Possible events:\n *\n * - \"error\"\n * - \"onChainTx\"\n * - \"ownWithdrawLocked\"\n * - \"withdrawLocked\"\n * - \"ownDepositLocked\"\n * - \"depositLocked\"\n *\n * TODO: the event list looks outdated\n *\n * @param eventName - Event name\n * @param callback - Callback function\n */\n // TODO define specific callback type depending on the event name\n on(eventName: string, callback: EventCallback): void {\n const eventEmitter = eventEmitters.get(this);\n if (eventEmitter == null) throw new UnknownChannelStateError();\n eventEmitter.on(eventName, callback);\n }\n\n /**\n * Remove event listener function\n * @param eventName - Event name\n * @param callback - Callback function\n */\n off(eventName: string, callback: EventCallback): void {\n const eventEmitter = eventEmitters.get(this);\n if (eventEmitter == null) throw new UnknownChannelStateError();\n eventEmitter.removeListener(eventName, callback);\n }\n\n /**\n * Close the connection\n */\n disconnect(): void {\n return channelDisconnect(this);\n }\n\n /**\n * Get current status\n *\n */\n status(): string {\n const status = channelStatus.get(this);\n if (status == null) throw new UnknownChannelStateError();\n return status;\n }\n\n /**\n * Get current state\n */\n async state(): Promise<ChannelState> {\n return snakeToPascalObjKeys(await call(this, 'channels.get.offchain_state', {}));\n }\n\n /**\n * Get current round\n *\n * If round cannot be determined (for example when channel has not been opened)\n * it will return `null`.\n *\n */\n round(): number | null {\n const state = channelState.get(this);\n if (state == null) {\n return null;\n }\n const { txType, tx } = unpackTx(state, Tag.SignedTx).tx.encodedTx;\n switch (txType) {\n case Tag.ChannelCreateTx:\n return 1;\n case Tag.ChannelOffChainTx:\n case Tag.ChannelWithdrawTx:\n case Tag.ChannelDepositTx:\n return tx.round;\n default:\n return null;\n }\n }\n\n /**\n * Get channel id\n *\n */\n id(): string {\n const id = channelId.get(this);\n if (id == null) throw new ChannelError('Channel is not initialized');\n return id;\n }\n\n /**\n * Get channel's fsm id\n *\n */\n fsmId(): string {\n const id = channelFsmId.get(this);\n if (id == null) throw new ChannelError('Channel is not initialized');\n return id;\n }\n\n /**\n * Trigger a transfer update\n *\n * The transfer update is moving coins from one channel account to another.\n * The update is a change to be applied on top of the latest state.\n *\n * Sender and receiver are the channel parties. Both the initiator and responder\n * can take those roles. Any public key outside the channel is considered invalid.\n *\n * @param from - Sender's public address\n * @param to - Receiver's public address\n * @param amount - Transaction amount\n * @param sign - Function which verifies and signs offchain transaction\n * @param metadata - Metadata\n\n * @example\n * ```js\n * channel.update(\n * 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',\n * 'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E',\n * 10,\n * async (tx) => await account.signTransaction(tx)\n * ).then(({ accepted, signedTx }) =>\n * if (accepted) {\n * console.log('Update has been accepted')\n * }\n * )\n * ```\n */\n async update(\n from: Encoded.AccountAddress,\n to: Encoded.AccountAddress,\n amount: number | BigNumber,\n sign: SignTx,\n metadata: string[] = [],\n ): Promise<{\n accepted: boolean;\n signedTx?: Encoded.Transaction;\n errorCode?: number;\n errorMessage?: string;\n }> {\n return new Promise((resolve, reject) => {\n enqueueAction(\n this,\n (_channel, state) => state?.handler === handlers.channelOpen,\n (channel) => {\n send(channel, {\n jsonrpc: '2.0',\n method: 'channels.update.new',\n params: {\n from, to, amount, meta: metadata,\n },\n });\n return {\n handler: handlers.awaitingOffChainTx,\n state: {\n resolve,\n reject,\n sign,\n },\n };\n },\n );\n });\n }\n\n /**\n * Get proof of inclusion\n *\n * If a certain address of an account or a contract is not found\n * in the state tree - the response is an error.\n *\n * @param addresses - Addresses\n * @param addresses.accounts - List of account addresses to include in poi\n * @param addresses.contracts - List of contract addresses to include in poi\n * @example\n * ```js\n * channel.poi({\n * accounts: [\n * 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',\n * 'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E'\n * ],\n * contracts: ['ct_2dCUAWYZdrWfACz3a2faJeKVTVrfDYxCQHCqAt5zM15f3u2UfA']\n * }).then(poi => console.log(poi))\n * ```\n */\n async poi(\n { accounts, contracts }: {\n accounts: Encoded.AccountAddress[];\n contracts?: Encoded.ContractAddress[];\n },\n ): Promise<Encoded.Poi> {\n return (await call(this, 'channels.get.poi', { accounts, contracts })).poi;\n }\n\n /**\n * Get balances\n *\n * The accounts param contains a list of addresses to fetch balances of.\n * Those can be either account balances or a contract ones, encoded as an account addresses.\n *\n * If a certain account address had not being found in the state tree - it is simply\n * skipped in the response.\n *\n * @param accounts - List of addresses to fetch balances from\n * @example\n * ```js\n * channel.balances([\n * 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',\n * 'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E'\n * 'ct_2dCUAWYZdrWfACz3a2faJeKVTVrfDYxCQHCqAt5zM15f3u2UfA'\n * ]).then(balances =>\n * console.log(balances['ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH'])\n * )\n * ```\n */\n async balances(\n accounts: Encoded.AccountAddress[],\n ): Promise<{ [key: Encoded.AccountAddress]: string }> {\n return Object.fromEntries(\n (await call(this, 'channels.get.balances', { accounts }))\n .map((item: {\n account: Encoded.AccountAddress;\n balance: string;\n }) => [item.account, item.balance]),\n );\n }\n\n /**\n * Leave channel\n *\n * It is possible to leave a channel and then later reestablish the channel\n * off-chain state and continue operation. When a leave method is called,\n * the channel fsm passes it on to the peer fsm, reports the current mutually\n * signed state and then terminates.\n *\n * The channel can be reestablished by instantiating another Channel instance\n * with two extra params: existingChannelId and offchainTx (returned from leave\n * method as channelId and signedTx respectively).\n *\n * @example\n * ```js\n * channel.leave().then(({ channelId, signedTx }) => {\n * console.log(channelId)\n * console.log(signedTx)\n * })\n * ```\n */\n async leave(): Promise<{ channelId: string; signedTx: Encoded.Transaction }> {\n return new Promise((resolve, reject) => {\n enqueueAction(\n this,\n (channel, state) => state?.handler === handlers.channelOpen,\n (channel) => {\n send(channel, { jsonrpc: '2.0', method: 'channels.leave', params: {} });\n return {\n handler: handlers.awaitingLeave,\n state: { resolve, reject },\n };\n },\n );\n });\n }\n\n /**\n * Trigger mutual close\n *\n * At any moment after the channel is opened, a closing procedure can be triggered.\n * This can be done by either of the parties. The process is similar to the off-chain updates.\n *\n * @param sign - Function which verifies and signs mutual close transaction\n * @example\n * ```js\n * channel.shutdown(\n * async (tx) => await account.signTransaction(tx)\n * ).then(tx => console.log('on_chain_tx', tx))\n * ```\n */\n async shutdown(sign: Function): Promise<Encoded.Transaction> {\n return new Promise((resolve, reject) => {\n enqueueAction(\n this,\n (_channel, state) => state?.handler === handlers.channelOpen,\n (channel) => {\n send(channel, { jsonrpc: '2.0', method: 'channels.shutdown', params: {} });\n return {\n handler: handlers.awaitingShutdownTx,\n state: {\n sign,\n resolve,\n reject,\n },\n };\n },\n );\n });\n }\n\n /**\n * Withdraw coins from the channel\n *\n * After the channel had been opened any of the participants can initiate a withdrawal.\n * The process closely resembles the update. The most notable difference is that the\n * transaction has been co-signed: it is channel_withdraw_tx and after the procedure\n * is finished - it is being posted on-chain.\n *\n * Any of the participants can initiate a withdrawal. The only requirements are:\n *\n * - Channel is already opened\n * - No off-chain update/deposit/withdrawal is currently being performed\n * - Channel is not being closed or in a solo closing state\n * - The withdrawal amount must be equal to or greater than zero, and cannot exceed\n * the available balance on the channel (minus the channel_reserve)\n *\n * After the other party had signed the withdraw transaction, the transaction is posted\n * on-chain and onOnChainTx callback is called with on-chain transaction as first argument.\n * After computing transaction hash it can be tracked on the chain: entering the mempool,\n * block inclusion and a number of confirmations.\n *\n * After the minimum_depth block confirmations onOwnWithdrawLocked callback is called\n * (without any arguments).\n *\n * When the other party had confirmed that the block height needed is reached\n * onWithdrawLocked callback is called (without any arguments).\n *\n * @param amount - Amount of coins to withdraw\n * @param sign - Function which verifies and signs withdraw transaction\n * @param callbacks - Callbacks\n * @param callbacks.onOnChainTx - Called when withdraw transaction has been posted\n * on chain\n * @param callbacks.onOwnWithdrawLocked\n * @param callbacks.onWithdrawLocked\n * @example\n * ```js\n * channel.withdraw(\n * 100,\n * async (tx) => await account.signTransaction(tx),\n * { onOnChainTx: (tx) => console.log('on_chain_tx', tx) }\n * ).then(({ accepted, signedTx }) => {\n * if (accepted) {\n * console.log('Withdrawal has been accepted')\n * } else {\n * console.log('Withdrawal has been rejected')\n * }\n * })\n * ```\n */\n async withdraw(\n amount: number | BigNumber,\n sign: SignTx,\n { onOnChainTx, onOwnWithdrawLocked, onWithdrawLocked }:\n Pick<ChannelState, 'onOnChainTx' | 'onOwnWithdrawLocked' | 'onWithdrawLocked'> = {},\n ): Promise<{ accepted: boolean; signedTx: Encoded.Transaction }> {\n return new Promise((resolve, reject) => {\n enqueueAction(\n this,\n (_channel, state) => state?.handler === handlers.channelOpen,\n (channel) => {\n send(channel, { jsonrpc: '2.0', method: 'channels.withdraw', params: { amount } });\n return {\n handler: handlers.awaitingWithdrawTx,\n state: {\n sign,\n resolve,\n reject,\n onOnChainTx,\n onOwnWithdrawLocked,\n onWithdrawLocked,\n },\n };\n },\n );\n });\n }\n\n /**\n * Deposit coins into the channel\n *\n * After the channel had been opened any of the participants can initiate a deposit.\n * The process closely resembles the update. The most notable difference is that the\n * transaction has been co-signed: it is channel_deposit_tx and after the procedure\n * is finished - it is being posted on-chain.\n *\n * Any of the participants can initiate a deposit. The only requirements are:\n *\n * - Channel is already opened\n * - No off-chain update/deposit/withdrawal is currently being performed\n * - Channel is not being closed or in a solo closing state\n * - The deposit amount must be equal to or greater than zero, and cannot exceed\n * the available balance on the channel (minus the channel_reserve)\n *\n * After the other party had signed the deposit transaction, the transaction is posted\n * on-chain and onOnChainTx callback is called with on-chain transaction as first argument.\n * After computing transaction hash it can be tracked on the chain: entering the mempool,\n * block inclusion and a number of confirmations.\n *\n * After the minimum_depth block confirmations onOwnDepositLocked callback is called\n * (without any arguments).\n *\n * When the other party had confirmed that the block height needed is reached\n * onDepositLocked callback is called (without any arguments).\n *\n * @param amount - Amount of coins to deposit\n * @param sign - Function which verifies and signs deposit transaction\n * @param callbacks - Callbacks\n * @param callbacks.onOnChainTx - Called when deposit transaction has been posted\n * on chain\n * @param callbacks.onOwnDepositLocked\n * @param callbacks.onDepositLocked\n * @example\n * ```js\n * channel.deposit(\n * 100,\n * async (tx) => await account.signTransaction(tx),\n * { onOnChainTx: (tx) => console.log('on_chain_tx', tx) }\n * ).then(({ accepted, state }) => {\n * if (accepted) {\n * console.log('Deposit has been accepted')\n * console.log('The new state is:', state)\n * } else {\n * console.log('Deposit has been rejected')\n * }\n * })\n * ```\n */\n async deposit(\n amount: number | BigNumber,\n sign: SignTx,\n { onOnChainTx, onOwnDepositLocked, onDepositLocked }:\n Pick<ChannelState, 'onOnChainTx' | 'onOwnDepositLocked' | 'onDepositLocked'> = {},\n ): Promise<{ accepted: boolean; state: ChannelState }> {\n return new Promise((resolve, reject) => {\n enqueueAction(\n this,\n (_channel, state) => state?.handler === handlers.channelOpen,\n (channel) => {\n send(channel, { jsonrpc: '2.0', method: 'channels.deposit', params: { amount } });\n return {\n handler: handlers.awaitingDepositTx,\n state: {\n sign,\n resolve,\n reject,\n onOnChainTx,\n onOwnDepositLocked,\n onDepositLocked,\n },\n };\n },\n );\n });\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 new Promise((resolve, reject) => {\n enqueueAction(\n this,\n (_channel, state) => state?.handler === handlers.channelOpen,\n (channel) => {\n send(channel, {\n jsonrpc: '2.0',\n method: 'channels.update.new_contract',\n params: {\n code,\n call_data: callData,\n deposit,\n vm_version: vmVersion,\n abi_version: abiVersion,\n },\n });\n return {\n handler: handlers.awaitingNewContractTx,\n state: {\n sign,\n resolve,\n reject,\n },\n };\n },\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 new Promise((resolve, reject) => {\n enqueueAction(\n this,\n (_channel, state) => state?.handler === handlers.channelOpen,\n (channel) => {\n send(channel, {\n jsonrpc: '2.0',\n method: 'channels.update.call_contract',\n params: {\n amount,\n call_data: callData,\n contract_id: contract,\n abi_version: abiVersion,\n },\n });\n return {\n handler: handlers.awaitingCallContractUpdateTx,\n state: { resolve, reject, sign },\n };\n },\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 new Promise((resolve, reject) => {\n enqueueAction(\n this,\n (_channel, state) => state?.handler === handlers.channelOpen,\n (channel) => {\n send(channel, {\n jsonrpc: '2.0',\n method: 'channels.force_progress',\n params: {\n amount,\n call_data: callData,\n contract_id: contract,\n abi_version: abiVersion,\n gas_price: gasPrice,\n gas: gasLimit,\n },\n });\n return {\n handler: handlers.awaitingCallContractForceProgressUpdate,\n state: {\n resolve, reject, sign, onOnChainTx,\n },\n };\n },\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<{\n returnType: ContractCallReturnType;\n returnValue: string;\n gasPrice: number | BigNumber;\n gasUsed: number | BigNumber;\n height: number;\n log: string;\n }> {\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 new Promise((resolve, reject) => {\n enqueueAction(\n this,\n (_channel, state) => state?.handler === handlers.channelOpen,\n (channel) => {\n send(channel, {\n jsonrpc: '2.0',\n method: 'channels.clean_contract_calls',\n params: {},\n });\n return {\n handler: handlers.awaitingCallsPruned,\n state: { resolve, reject },\n };\n },\n );\n });\n }\n\n /**\n * Send generic message\n *\n * If message is an object it will be serialized into JSON string\n * before sending.\n *\n * If there is ongoing update that has not yet been finished the message\n * will be sent after that update is finalized.\n *\n * @param message - Message\n * @param recipient - Address of the recipient\n * @example\n * ```js\n * channel.sendMessage(\n * 'hello world',\n * 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH'\n * )\n * ```\n */\n async sendMessage(\n message: string | object,\n recipient: Encoded.AccountAddress,\n ): Promise<void> {\n const info = typeof message === 'object' ? JSON.stringify(message) : message;\n if (this.status() === 'connecting') {\n await new Promise<void>((resolve) => {\n const onStatusChanged = (status: string): void => {\n if (status === 'connecting') return;\n resolve();\n this.off('statusChanged', onStatusChanged);\n };\n this.on('statusChanged', onStatusChanged);\n });\n // For some reason we can't immediately send a message when connection is\n // established. Thus we wait 500ms which seems to work.\n await pause(500);\n }\n send(this, {\n jsonrpc: '2.0',\n method: 'channels.message',\n params: { info, to: recipient },\n });\n }\n\n static async reconnect(options: ChannelOptions, txParams: any): Promise<Channel> {\n const { sign } = options;\n\n return Channel.initialize({\n ...options,\n reconnectTx: await sign('reconnect', buildTx(txParams, Tag.ChannelClientReconnectTx).tx),\n });\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;SAESA,a;SACAC,O,EAASC,Q;SACTC,a,EAAeC,G;OACjB,KAAKC,Q;SAEVC,a,EACAC,MAAM,IAAIC,a,EACVC,KAAK,IAAIC,Y,EACTC,U,EACAC,a,EACAC,I,EACAC,S,EACAC,I,EACAC,UAAU,IAAIC,iB,EACdC,KAAK,IAAIC,Y;SAKFC,wB,EAA0BC,Y;SAG1BC,K;;AAET,SAASC,oBAAT,CAAoCC,GAApC,EAAuD;EACrD,OAAOC,MAAM,CAACC,OAAP,CAAeF,GAAf,EAAoBG,MAApB,CAA2B,CAACC,MAAD;IAAA,IAAS,CAACC,GAAD,EAAMC,GAAN,CAAT;IAAA,OAAyB,EACzD,GAAGF,MADsD;MAEzD,CAAC5B,aAAa,CAAC6B,GAAD,CAAd,GAAsBC;IAFmC,CAAzB;EAAA,CAA3B,EAGH,EAHG,CAAP;AAID;;AA4BD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,OAAN,CAAc;EAC3B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACyB,aAAVpB,UAAU,CAACqB,OAAD,EAA4C;IACjE,MAAMC,OAAO,GAAG,IAAIF,OAAJ,EAAhB;IACA,MAAMpB,UAAU,CACdsB,OADc,EAEdD,OAAO,CAACE,aAAR,IAAyB,IAAzB,GAAgC7B,QAAQ,CAAC8B,oBAAzC,GAAgE9B,QAAQ,CAAC+B,kBAF3D,EAGd/B,QAAQ,CAACgC,WAHK,EAIdL,OAJc,CAAhB;IAMA,OAAOC,OAAP;EACD;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE;;;EACAK,EAAE,CAACC,SAAD,EAAoBC,QAApB,EAAmD;IACnD,MAAMC,YAAY,GAAGnC,aAAa,CAACoC,GAAd,CAAkB,IAAlB,CAArB;IACA,IAAID,YAAY,IAAI,IAApB,EAA0B,MAAM,IAAIrB,wBAAJ,EAAN;IAC1BqB,YAAY,CAACH,EAAb,CAAgBC,SAAhB,EAA2BC,QAA3B;EACD;EAED;AACF;AACA;AACA;AACA;;;EACEG,GAAG,CAACJ,SAAD,EAAoBC,QAApB,EAAmD;IACpD,MAAMC,YAAY,GAAGnC,aAAa,CAACoC,GAAd,CAAkB,IAAlB,CAArB;IACA,IAAID,YAAY,IAAI,IAApB,EAA0B,MAAM,IAAIrB,wBAAJ,EAAN;IAC1BqB,YAAY,CAACG,cAAb,CAA4BL,SAA5B,EAAuCC,QAAvC;EACD;EAED;AACF;AACA;;;EACExB,UAAU,GAAS;I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AkB,YAAtB,EAAoC;MAClC,MAAM,IAAIsD,OAAJ,CAAmBC,OAAD,IAAa;QACnC,MAAMgE,eAAe,GAAIvH,MAAD,IAA0B;UAChD,IAAIA,MAAM,KAAK,YAAf,EAA6B;UAC7BuD,OAAO;UACP,KAAKnB,GAAL,CAAS,eAAT,EAA0BmF,eAA1B;QACD,CAJD;;QAKA,KAAKxF,EAAL,CAAQ,eAAR,EAAyBwF,eAAzB;MACD,CAPK,CAAN,CADkC,CASlC;MACA;;MACA,MAAMxG,KAAK,CAAC,GAAD,CAAX;IACD;;IACDT,IAAI,CAAC,IAAD,EAAO;MACTqD,OAAO,EAAE,KADA;MAETC,MAAM,EAAE,kBAFC;MAGTC,MAAM,EAAE;QAAEuD,IAAF;QAAQlE,EAAE,EAAEiE;MAAZ;IAHC,CAAP,CAAJ;EAKD;;EAEqB,aAATK,SAAS,CAAC/F,OAAD,EAA0BgG,QAA1B,EAA2D;IAC/E,MAAM;MAAErE;IAAF,IAAW3B,OAAjB;IAEA,OAAOD,OAAO,CAACpB,UAAR,CAAmB,EACxB,GAAGqB,OADqB;MAExBiG,WAAW,EAAE,MAAMtE,IAAI,CAAC,WAAD,EAAc1D,OAAO,CAAC+H,QAAD,EAAW5H,GAAG,CAAC8H,wBAAf,CAAP,CAAgDnF,EAA9D;IAFC,CAAnB,CAAP;EAID;;AAh6B0B"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import BigNumber from 'bignumber.js';
|
|
4
|
+
import type Channel from '.';
|
|
5
|
+
import { Encoded } from '../utils/encoder';
|
|
6
|
+
import { BaseError } from '../utils/errors';
|
|
7
|
+
interface ChannelAction {
|
|
8
|
+
guard: (channel: Channel, state?: ChannelFsm) => boolean;
|
|
9
|
+
action: (channel: Channel, state?: ChannelFsm) => ChannelFsm;
|
|
10
|
+
}
|
|
11
|
+
export declare type SignTxWithTag = (tag: string, tx: Encoded.Transaction, options?: object) => (Promise<Encoded.Transaction>);
|
|
12
|
+
export declare type SignTx = (tx: Encoded.Transaction, options?: object) => (Promise<Encoded.Transaction | number | null>);
|
|
13
|
+
export interface ChannelOptions {
|
|
14
|
+
existingFsmId?: string;
|
|
15
|
+
url: string;
|
|
16
|
+
role: 'initiator' | 'responder';
|
|
17
|
+
initiatorId: Encoded.AccountAddress;
|
|
18
|
+
responderId: Encoded.AccountAddress;
|
|
19
|
+
pushAmount: number;
|
|
20
|
+
initiatorAmount: BigNumber;
|
|
21
|
+
responderAmount: BigNumber;
|
|
22
|
+
channelReserve?: BigNumber | number;
|
|
23
|
+
signedTx?: string;
|
|
24
|
+
ttl?: number;
|
|
25
|
+
host: string;
|
|
26
|
+
port: number;
|
|
27
|
+
lockPeriod: number;
|
|
28
|
+
existingChannelId?: string;
|
|
29
|
+
offChainTx?: string;
|
|
30
|
+
reconnectTx?: string;
|
|
31
|
+
timeoutIdle?: number;
|
|
32
|
+
timeoutFundingCreate?: number;
|
|
33
|
+
timeoutFundingSign?: number;
|
|
34
|
+
timeoutFundingLock?: number;
|
|
35
|
+
timeoutSign?: number;
|
|
36
|
+
timeoutAccept?: number;
|
|
37
|
+
timeoutInitialized?: number;
|
|
38
|
+
timeoutAwaitingOpen?: number;
|
|
39
|
+
statePassword?: string;
|
|
40
|
+
debug: boolean;
|
|
41
|
+
sign: SignTxWithTag;
|
|
42
|
+
offchainTx?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface ChannelHandler extends Function {
|
|
45
|
+
enter?: Function;
|
|
46
|
+
}
|
|
47
|
+
export interface ChannelState {
|
|
48
|
+
signedTx: any;
|
|
49
|
+
resolve: (r?: any) => void;
|
|
50
|
+
reject: (e: BaseError) => void;
|
|
51
|
+
sign: SignTx;
|
|
52
|
+
handler?: ChannelHandler;
|
|
53
|
+
onOnChainTx?: (tx: Encoded.Transaction) => void;
|
|
54
|
+
onOwnWithdrawLocked?: () => void;
|
|
55
|
+
onWithdrawLocked?: () => void;
|
|
56
|
+
onOwnDepositLocked?: () => void;
|
|
57
|
+
onDepositLocked?: () => void;
|
|
58
|
+
closeTx?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface ChannelFsm {
|
|
61
|
+
handler: ChannelHandler;
|
|
62
|
+
state?: ChannelState | {
|
|
63
|
+
resolve: Function;
|
|
64
|
+
reject: Function;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export interface ChannelMessage {
|
|
68
|
+
id?: number;
|
|
69
|
+
jsonrpc: string;
|
|
70
|
+
method: string;
|
|
71
|
+
params: any;
|
|
72
|
+
payload?: any;
|
|
73
|
+
data?: any;
|
|
74
|
+
error?: ChannelMessageError;
|
|
75
|
+
}
|
|
76
|
+
interface ChannelMessageError {
|
|
77
|
+
code: number;
|
|
78
|
+
message: string;
|
|
79
|
+
data: [
|
|
80
|
+
{
|
|
81
|
+
message: string;
|
|
82
|
+
code: number;
|
|
83
|
+
}
|
|
84
|
+
];
|
|
85
|
+
request: ChannelMessage;
|
|
86
|
+
}
|
|
87
|
+
export declare const options: WeakMap<Channel, ChannelOptions>;
|
|
88
|
+
export declare const status: WeakMap<Channel, string>;
|
|
89
|
+
export declare const state: WeakMap<Channel, `tx_${string}`>;
|
|
90
|
+
export declare const eventEmitters: WeakMap<Channel, EventEmitter>;
|
|
91
|
+
export declare const channelId: WeakMap<Channel, string>;
|
|
92
|
+
export declare const fsmId: WeakMap<Channel, string>;
|
|
93
|
+
export declare function emit(channel: Channel, ...args: any[]): void;
|
|
94
|
+
export declare function changeStatus(channel: Channel, newStatus: string): void;
|
|
95
|
+
export declare function changeState(channel: Channel, newState: Encoded.Transaction): void;
|
|
96
|
+
export declare function send(channel: Channel, message: ChannelMessage): void;
|
|
97
|
+
export declare function enqueueAction(channel: Channel, guard: ChannelAction['guard'], action: ChannelAction['action']): void;
|
|
98
|
+
export declare function disconnect(channel: Channel): void;
|
|
99
|
+
export declare function call(channel: Channel, method: string, params: any): Promise<any>;
|
|
100
|
+
export declare function initialize(channel: Channel, connectionHandler: Function, openHandler: Function, { url, ...channelOptions }: ChannelOptions): Promise<void>;
|
|
101
|
+
export {};
|