@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/src/channel/handlers.js
DELETED
|
@@ -1,673 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* ISC License (ISC)
|
|
3
|
-
* Copyright (c) 2018 aeternity developers
|
|
4
|
-
*
|
|
5
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
* purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
* copyright notice and this permission notice appear in all copies.
|
|
8
|
-
*
|
|
9
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
-
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
-
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
-
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
-
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
-
* PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import { generateKeyPair, encodeContractAddress } from '../utils/crypto'
|
|
19
|
-
import {
|
|
20
|
-
options,
|
|
21
|
-
changeStatus,
|
|
22
|
-
changeState,
|
|
23
|
-
call,
|
|
24
|
-
send,
|
|
25
|
-
emit,
|
|
26
|
-
channelId,
|
|
27
|
-
disconnect,
|
|
28
|
-
fsmId
|
|
29
|
-
} from './internal'
|
|
30
|
-
import { unpackTx, buildTx } from '../tx/builder'
|
|
31
|
-
import { encode } from '../tx/builder/helpers'
|
|
32
|
-
import {
|
|
33
|
-
IllegalArgumentError,
|
|
34
|
-
InsufficientBalanceError,
|
|
35
|
-
ChannelConnectionError,
|
|
36
|
-
UnexpectedChannelMessageError
|
|
37
|
-
} from '../utils/errors'
|
|
38
|
-
|
|
39
|
-
async function appendSignature (tx, signFn) {
|
|
40
|
-
const { signatures, encodedTx } = unpackTx(tx).tx
|
|
41
|
-
const result = await signFn(encode(encodedTx.rlpEncoded, 'tx'))
|
|
42
|
-
if (typeof result === 'string') {
|
|
43
|
-
const { tx: signedTx, txType } = unpackTx(result)
|
|
44
|
-
return buildTx({
|
|
45
|
-
signatures: signatures.concat(signedTx.signatures),
|
|
46
|
-
encodedTx: signedTx.encodedTx.rlpEncoded
|
|
47
|
-
}, txType).tx
|
|
48
|
-
}
|
|
49
|
-
return result
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function handleUnexpectedMessage (channel, message, state) {
|
|
53
|
-
if (state && state.reject) {
|
|
54
|
-
state.reject(Object.assign(
|
|
55
|
-
new UnexpectedChannelMessageError(`Unexpected message received:\n\n${JSON.stringify(message)}`),
|
|
56
|
-
{ wsMessage: message }
|
|
57
|
-
))
|
|
58
|
-
}
|
|
59
|
-
return { handler: channelOpen }
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function awaitingConnection (channel, message, state) {
|
|
63
|
-
if (message.method === 'channels.info') {
|
|
64
|
-
if (['channel_accept', 'funding_created'].includes(message.params.data.event)) {
|
|
65
|
-
changeStatus(channel, {
|
|
66
|
-
channel_accept: 'accepted',
|
|
67
|
-
funding_created: 'halfSigned'
|
|
68
|
-
}[message.params.data.event])
|
|
69
|
-
return { handler: awaitingChannelCreateTx }
|
|
70
|
-
}
|
|
71
|
-
if (message.params.data.event === 'channel_reestablished') {
|
|
72
|
-
return { handler: awaitingOpenConfirmation }
|
|
73
|
-
}
|
|
74
|
-
if (message.params.data.event === 'fsm_up') {
|
|
75
|
-
fsmId.set(channel, message.params.data.fsm_id)
|
|
76
|
-
return { handler: awaitingConnection }
|
|
77
|
-
}
|
|
78
|
-
return { handler: awaitingConnection }
|
|
79
|
-
}
|
|
80
|
-
if (message.method === 'channels.error') {
|
|
81
|
-
emit(channel, 'error', new ChannelConnectionError(message.payload.message))
|
|
82
|
-
return { handler: channelClosed }
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export async function awaitingReconnection (channel, message, state) {
|
|
87
|
-
if (message.method === 'channels.info') {
|
|
88
|
-
if (message.params.data.event === 'fsm_up') {
|
|
89
|
-
fsmId.set(channel, message.params.data.fsm_id)
|
|
90
|
-
changeState(channel, (await call(channel, 'channels.get.offchain_state', {})).signed_tx)
|
|
91
|
-
return { handler: channelOpen }
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return handleUnexpectedMessage(channel, message, state)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export async function awaitingChannelCreateTx (channel, message, state) {
|
|
98
|
-
const tag = {
|
|
99
|
-
initiator: 'initiator_sign',
|
|
100
|
-
responder: 'responder_sign'
|
|
101
|
-
}[options.get(channel).role]
|
|
102
|
-
if (message.method === `channels.sign.${tag}`) {
|
|
103
|
-
if (message.params.data.tx) {
|
|
104
|
-
const signedTx = await options.get(channel).sign(tag, message.params.data.tx)
|
|
105
|
-
send(channel, { jsonrpc: '2.0', method: `channels.${tag}`, params: { tx: signedTx } })
|
|
106
|
-
return { handler: awaitingOnChainTx }
|
|
107
|
-
}
|
|
108
|
-
const signedTx = await appendSignature(
|
|
109
|
-
message.params.data.signed_tx, tx => options.get(channel).sign(tag, tx)
|
|
110
|
-
)
|
|
111
|
-
send(channel, { jsonrpc: '2.0', method: `channels.${tag}`, params: { signed_tx: signedTx } })
|
|
112
|
-
return { handler: awaitingOnChainTx }
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export function awaitingOnChainTx (channel, message, state) {
|
|
117
|
-
if (message.method === 'channels.on_chain_tx') {
|
|
118
|
-
if (
|
|
119
|
-
message.params.data.info === 'funding_signed' &&
|
|
120
|
-
options.get(channel).role === 'initiator'
|
|
121
|
-
) {
|
|
122
|
-
return { handler: awaitingBlockInclusion }
|
|
123
|
-
}
|
|
124
|
-
if (
|
|
125
|
-
message.params.data.info === 'funding_created' &&
|
|
126
|
-
options.get(channel).role === 'responder'
|
|
127
|
-
) {
|
|
128
|
-
return { handler: awaitingBlockInclusion }
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (
|
|
132
|
-
message.method === 'channels.info' &&
|
|
133
|
-
message.params.data.event === 'funding_signed' &&
|
|
134
|
-
options.get(channel).role === 'initiator'
|
|
135
|
-
) {
|
|
136
|
-
channelId.set(channel, message.params.channel_id)
|
|
137
|
-
changeStatus(channel, 'signed')
|
|
138
|
-
return { handler: awaitingOnChainTx }
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export function awaitingBlockInclusion (channel, message, state) {
|
|
143
|
-
if (message.method === 'channels.info') {
|
|
144
|
-
const handler = {
|
|
145
|
-
funding_created: awaitingBlockInclusion,
|
|
146
|
-
own_funding_locked: awaitingBlockInclusion,
|
|
147
|
-
funding_locked: awaitingOpenConfirmation
|
|
148
|
-
}[message.params.data.event]
|
|
149
|
-
if (handler) {
|
|
150
|
-
return { handler }
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
if (message.method === 'channels.on_chain_tx') {
|
|
154
|
-
emit(channel, 'onChainTx', message.params.data.tx, {
|
|
155
|
-
info: message.params.data.info,
|
|
156
|
-
type: message.params.data.type
|
|
157
|
-
})
|
|
158
|
-
return { handler: awaitingBlockInclusion }
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export function awaitingOpenConfirmation (channel, message, state) {
|
|
163
|
-
if (message.method === 'channels.info' && message.params.data.event === 'open') {
|
|
164
|
-
channelId.set(channel, message.params.channel_id)
|
|
165
|
-
return { handler: awaitingInitialState }
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export function awaitingInitialState (channel, message, state) {
|
|
170
|
-
if (message.method === 'channels.update') {
|
|
171
|
-
changeState(channel, message.params.data.state)
|
|
172
|
-
return { handler: channelOpen }
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export async function channelOpen (channel, message, state) {
|
|
177
|
-
switch (message.method) {
|
|
178
|
-
case 'channels.info':
|
|
179
|
-
switch (message.params.data.event) {
|
|
180
|
-
case 'update':
|
|
181
|
-
case 'withdraw_created':
|
|
182
|
-
case 'deposit_created':
|
|
183
|
-
return { handler: awaitingTxSignRequest }
|
|
184
|
-
case 'own_withdraw_locked':
|
|
185
|
-
case 'withdraw_locked':
|
|
186
|
-
case 'own_deposit_locked':
|
|
187
|
-
case 'deposit_locked':
|
|
188
|
-
case 'peer_disconnected':
|
|
189
|
-
case 'channel_reestablished':
|
|
190
|
-
case 'open':
|
|
191
|
-
// TODO: Better handling of peer_disconnected event.
|
|
192
|
-
//
|
|
193
|
-
// We should enter intermediate state where offchain transactions
|
|
194
|
-
// are blocked until channel is reestablished.
|
|
195
|
-
emit(channel, message.params.data.event)
|
|
196
|
-
return { handler: channelOpen }
|
|
197
|
-
case 'fsm_up':
|
|
198
|
-
fsmId.set(channel, message.params.data.fsm_id)
|
|
199
|
-
return { handler: channelOpen }
|
|
200
|
-
case 'timeout':
|
|
201
|
-
case 'close_mutual':
|
|
202
|
-
return { handler: channelOpen }
|
|
203
|
-
case 'closing':
|
|
204
|
-
changeStatus(channel, 'closing')
|
|
205
|
-
return { handler: channelOpen }
|
|
206
|
-
case 'closed_confirmed':
|
|
207
|
-
changeStatus(channel, 'closed')
|
|
208
|
-
return { handler: channelClosed }
|
|
209
|
-
case 'died':
|
|
210
|
-
changeStatus(channel, 'died')
|
|
211
|
-
return { handler: channelClosed }
|
|
212
|
-
case 'shutdown':
|
|
213
|
-
return { handler: channelOpen }
|
|
214
|
-
}
|
|
215
|
-
break
|
|
216
|
-
case 'channels.on_chain_tx':
|
|
217
|
-
emit(channel, 'onChainTx', message.params.data.tx, {
|
|
218
|
-
info: message.params.data.info,
|
|
219
|
-
type: message.params.data.type
|
|
220
|
-
})
|
|
221
|
-
return { handler: channelOpen }
|
|
222
|
-
case 'channels.leave':
|
|
223
|
-
// TODO: emit event
|
|
224
|
-
return { handler: channelOpen }
|
|
225
|
-
case 'channels.update':
|
|
226
|
-
changeState(channel, message.params.data.state)
|
|
227
|
-
return { handler: channelOpen }
|
|
228
|
-
case 'channels.sign.shutdown_sign_ack':
|
|
229
|
-
return awaitingTxSignRequest(channel, message, state)
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
channelOpen.enter = (channel) => {
|
|
233
|
-
changeStatus(channel, 'open')
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export async function awaitingOffChainTx (channel, message, state) {
|
|
237
|
-
if (message.method === 'channels.sign.update') {
|
|
238
|
-
const { sign } = state
|
|
239
|
-
if (message.params.data.tx) {
|
|
240
|
-
const signedTx = await sign(message.params.data.tx, { updates: message.params.data.updates })
|
|
241
|
-
send(channel, { jsonrpc: '2.0', method: 'channels.update', params: { tx: signedTx } })
|
|
242
|
-
return { handler: awaitingOffChainUpdate, state }
|
|
243
|
-
}
|
|
244
|
-
const signedTx = await appendSignature(message.params.data.signed_tx, tx =>
|
|
245
|
-
sign(tx, { updates: message.params.data.updates })
|
|
246
|
-
)
|
|
247
|
-
if (typeof signedTx === 'string') {
|
|
248
|
-
send(channel, { jsonrpc: '2.0', method: 'channels.update', params: { signed_tx: signedTx } })
|
|
249
|
-
return { handler: awaitingOffChainUpdate, state }
|
|
250
|
-
}
|
|
251
|
-
if (typeof signedTx === 'number') {
|
|
252
|
-
send(channel, { jsonrpc: '2.0', method: 'channels.update', params: { error: signedTx } })
|
|
253
|
-
return { handler: awaitingOffChainTx, state }
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
if (message.method === 'channels.error') {
|
|
257
|
-
state.reject(new ChannelConnectionError(message.data.message))
|
|
258
|
-
return { handler: channelOpen }
|
|
259
|
-
}
|
|
260
|
-
if (message.error) {
|
|
261
|
-
const { data = [] } = message.error
|
|
262
|
-
if (data.find(i => i.code === 1001)) {
|
|
263
|
-
state.reject(new InsufficientBalanceError('Insufficient balance'))
|
|
264
|
-
} else if (data.find(i => i.code === 1002)) {
|
|
265
|
-
state.reject(new IllegalArgumentError('Amount cannot be negative'))
|
|
266
|
-
} else {
|
|
267
|
-
state.reject(new ChannelConnectionError(message.error.message))
|
|
268
|
-
}
|
|
269
|
-
return { handler: channelOpen }
|
|
270
|
-
}
|
|
271
|
-
if (message.method === 'channels.conflict') {
|
|
272
|
-
state.resolve({
|
|
273
|
-
accepted: false,
|
|
274
|
-
errorCode: message.params.data.error_code,
|
|
275
|
-
errorMessage: message.params.data.error_msg
|
|
276
|
-
})
|
|
277
|
-
return { handler: channelOpen }
|
|
278
|
-
}
|
|
279
|
-
if (message.method === 'channels.info') {
|
|
280
|
-
if (message.params.data.event === 'aborted_update') {
|
|
281
|
-
state.resolve({ accepted: false })
|
|
282
|
-
return { handler: channelOpen }
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
return handleUnexpectedMessage(channel, message, state)
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
export function awaitingOffChainUpdate (channel, message, state) {
|
|
289
|
-
if (message.method === 'channels.update') {
|
|
290
|
-
changeState(channel, message.params.data.state)
|
|
291
|
-
state.resolve({ accepted: true, signedTx: message.params.data.state })
|
|
292
|
-
return { handler: channelOpen }
|
|
293
|
-
}
|
|
294
|
-
if (message.method === 'channels.conflict') {
|
|
295
|
-
state.resolve({
|
|
296
|
-
accepted: false,
|
|
297
|
-
errorCode: message.params.data.error_code,
|
|
298
|
-
errorMessage: message.params.data.error_msg
|
|
299
|
-
})
|
|
300
|
-
return { handler: channelOpen }
|
|
301
|
-
}
|
|
302
|
-
if (message.method === 'channels.info') {
|
|
303
|
-
if (message.params.data.event === 'aborted_update') {
|
|
304
|
-
state.resolve({ accepted: false })
|
|
305
|
-
return { handler: channelOpen }
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
if (message.error) {
|
|
309
|
-
state.reject(new ChannelConnectionError(message.error.message))
|
|
310
|
-
return { handler: channelOpen }
|
|
311
|
-
}
|
|
312
|
-
return handleUnexpectedMessage(channel, message, state)
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
export async function awaitingTxSignRequest (channel, message, state) {
|
|
316
|
-
const [, tag] = message.method.match(/^channels\.sign\.([^.]+)$/) || []
|
|
317
|
-
if (tag) {
|
|
318
|
-
if (message.params.data.tx) {
|
|
319
|
-
const signedTx = await options.get(channel).sign(tag, message.params.data.tx, {
|
|
320
|
-
updates: message.params.data.updates
|
|
321
|
-
})
|
|
322
|
-
if (signedTx) {
|
|
323
|
-
send(channel, { jsonrpc: '2.0', method: `channels.${tag}`, params: { tx: signedTx } })
|
|
324
|
-
return { handler: channelOpen }
|
|
325
|
-
}
|
|
326
|
-
} else {
|
|
327
|
-
const signedTx = await appendSignature(message.params.data.signed_tx, tx =>
|
|
328
|
-
options.get(channel).sign(tag, tx, { updates: message.params.data.updates })
|
|
329
|
-
)
|
|
330
|
-
if (typeof signedTx === 'string') {
|
|
331
|
-
send(channel, { jsonrpc: '2.0', method: `channels.${tag}`, params: { signed_tx: signedTx } })
|
|
332
|
-
return { handler: channelOpen }
|
|
333
|
-
}
|
|
334
|
-
if (typeof signedTx === 'number') {
|
|
335
|
-
send(channel, { jsonrpc: '2.0', method: `channels.${tag}`, params: { error: signedTx } })
|
|
336
|
-
return { handler: awaitingUpdateConflict, state }
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
// soft-reject via competing update
|
|
340
|
-
send(channel, {
|
|
341
|
-
jsonrpc: '2.0',
|
|
342
|
-
method: 'channels.update.new',
|
|
343
|
-
params: {
|
|
344
|
-
from: generateKeyPair().publicKey,
|
|
345
|
-
to: generateKeyPair().publicKey,
|
|
346
|
-
amount: 1
|
|
347
|
-
}
|
|
348
|
-
})
|
|
349
|
-
return { handler: awaitingUpdateConflict, state }
|
|
350
|
-
}
|
|
351
|
-
return handleUnexpectedMessage(channel, message, state)
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
export function awaitingUpdateConflict (channel, message, state) {
|
|
355
|
-
if (message.error) {
|
|
356
|
-
return { handler: awaitingUpdateConflict, state }
|
|
357
|
-
}
|
|
358
|
-
if (message.method === 'channels.conflict') {
|
|
359
|
-
return { handler: channelOpen }
|
|
360
|
-
}
|
|
361
|
-
return handleUnexpectedMessage(channel, message, state)
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
export async function awaitingShutdownTx (channel, message, state) {
|
|
365
|
-
if (message.method === 'channels.sign.shutdown_sign') {
|
|
366
|
-
if (message.params.data.tx) {
|
|
367
|
-
const signedTx = await state.sign(message.params.data.tx)
|
|
368
|
-
send(channel, { jsonrpc: '2.0', method: 'channels.shutdown_sign', params: { tx: signedTx } })
|
|
369
|
-
return { handler: awaitingShutdownOnChainTx, state }
|
|
370
|
-
}
|
|
371
|
-
const signedTx = await appendSignature(message.params.data.signed_tx, tx => state.sign(tx))
|
|
372
|
-
send(channel, { jsonrpc: '2.0', method: 'channels.shutdown_sign', params: { signed_tx: signedTx } })
|
|
373
|
-
return { handler: awaitingShutdownOnChainTx, state }
|
|
374
|
-
}
|
|
375
|
-
return handleUnexpectedMessage(channel, message, state)
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
export function awaitingShutdownOnChainTx (channel, message, state) {
|
|
379
|
-
if (message.method === 'channels.on_chain_tx') {
|
|
380
|
-
// state.resolve(message.params.data.tx)
|
|
381
|
-
return { handler: channelClosed, state }
|
|
382
|
-
}
|
|
383
|
-
return handleUnexpectedMessage(channel, message, state)
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
export function awaitingLeave (channel, message, state) {
|
|
387
|
-
if (message.method === 'channels.leave') {
|
|
388
|
-
state.resolve({ channelId: message.params.channel_id, signedTx: message.params.data.state })
|
|
389
|
-
disconnect(channel)
|
|
390
|
-
return { handler: channelClosed }
|
|
391
|
-
}
|
|
392
|
-
if (message.method === 'channels.error') {
|
|
393
|
-
state.reject(new ChannelConnectionError(message.data.message))
|
|
394
|
-
return { handler: channelOpen }
|
|
395
|
-
}
|
|
396
|
-
return handleUnexpectedMessage(channel, message, state)
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
export async function awaitingWithdrawTx (channel, message, state) {
|
|
400
|
-
if (message.method === 'channels.sign.withdraw_tx') {
|
|
401
|
-
const { sign } = state
|
|
402
|
-
if (message.params.data.tx) {
|
|
403
|
-
const signedTx = await sign(message.params.data.tx, { updates: message.params.data.updates })
|
|
404
|
-
send(channel, { jsonrpc: '2.0', method: 'channels.withdraw_tx', params: { tx: signedTx } })
|
|
405
|
-
return { handler: awaitingWithdrawCompletion, state }
|
|
406
|
-
}
|
|
407
|
-
const signedTx = await appendSignature(message.params.data.signed_tx, tx =>
|
|
408
|
-
sign(tx, { updates: message.params.data.updates })
|
|
409
|
-
)
|
|
410
|
-
if (typeof signedTx === 'string') {
|
|
411
|
-
send(channel, { jsonrpc: '2.0', method: 'channels.withdraw_tx', params: { signed_tx: signedTx } })
|
|
412
|
-
return { handler: awaitingWithdrawCompletion, state }
|
|
413
|
-
}
|
|
414
|
-
if (typeof signedTx === 'number') {
|
|
415
|
-
send(channel, { jsonrpc: '2.0', method: 'channels.withdraw_tx', params: { error: signedTx } })
|
|
416
|
-
return { handler: awaitingWithdrawCompletion, state }
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
return handleUnexpectedMessage(channel, message, state)
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
export function awaitingWithdrawCompletion (channel, message, state) {
|
|
423
|
-
if (message.method === 'channels.on_chain_tx') {
|
|
424
|
-
if (state.onOnChainTx) {
|
|
425
|
-
state.onOnChainTx(message.params.data.tx)
|
|
426
|
-
}
|
|
427
|
-
return { handler: awaitingWithdrawCompletion, state }
|
|
428
|
-
}
|
|
429
|
-
if (message.method === 'channels.info') {
|
|
430
|
-
if (['own_withdraw_locked', 'withdraw_locked'].includes(message.params.data.event)) {
|
|
431
|
-
const callback = {
|
|
432
|
-
own_withdraw_locked: state.onOwnWithdrawLocked,
|
|
433
|
-
withdraw_locked: state.onWithdrawLocked
|
|
434
|
-
}[message.params.data.event]
|
|
435
|
-
if (callback) {
|
|
436
|
-
callback()
|
|
437
|
-
}
|
|
438
|
-
return { handler: awaitingWithdrawCompletion, state }
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
if (message.method === 'channels.update') {
|
|
442
|
-
changeState(channel, message.params.data.state)
|
|
443
|
-
state.resolve({ accepted: true, signedTx: message.params.data.state })
|
|
444
|
-
return { handler: channelOpen }
|
|
445
|
-
}
|
|
446
|
-
if (message.method === 'channels.conflict') {
|
|
447
|
-
state.resolve({
|
|
448
|
-
accepted: false,
|
|
449
|
-
errorCode: message.params.data.error_code,
|
|
450
|
-
errorMessage: message.params.data.error_msg
|
|
451
|
-
})
|
|
452
|
-
return { handler: channelOpen }
|
|
453
|
-
}
|
|
454
|
-
if (message.method === 'channels.info') {
|
|
455
|
-
if (message.params.data.event === 'aborted_update') {
|
|
456
|
-
state.resolve({ accepted: false })
|
|
457
|
-
return { handler: channelOpen }
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
return handleUnexpectedMessage(channel, message, state)
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
export async function awaitingDepositTx (channel, message, state) {
|
|
464
|
-
if (message.method === 'channels.sign.deposit_tx') {
|
|
465
|
-
const { sign } = state
|
|
466
|
-
if (message.params.data.tx) {
|
|
467
|
-
const signedTx = await sign(message.params.data.tx, { updates: message.params.data.updates })
|
|
468
|
-
send(channel, { jsonrpc: '2.0', method: 'channels.deposit_tx', params: { tx: signedTx } })
|
|
469
|
-
return { handler: awaitingDepositCompletion, state }
|
|
470
|
-
}
|
|
471
|
-
const signedTx = await appendSignature(message.params.data.signed_tx, tx =>
|
|
472
|
-
sign(tx, { updates: message.params.data.updates })
|
|
473
|
-
)
|
|
474
|
-
if (typeof signedTx === 'string') {
|
|
475
|
-
send(channel, { jsonrpc: '2.0', method: 'channels.deposit_tx', params: { signed_tx: signedTx } })
|
|
476
|
-
return { handler: awaitingDepositCompletion, state }
|
|
477
|
-
}
|
|
478
|
-
if (typeof signedTx === 'number') {
|
|
479
|
-
send(channel, { jsonrpc: '2.0', method: 'channels.deposit_tx', params: { error: signedTx } })
|
|
480
|
-
return { handler: awaitingDepositCompletion, state }
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
return handleUnexpectedMessage(channel, message, state)
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
export function awaitingDepositCompletion (channel, message, state) {
|
|
487
|
-
if (message.method === 'channels.on_chain_tx') {
|
|
488
|
-
if (state.onOnChainTx) {
|
|
489
|
-
state.onOnChainTx(message.params.data.tx)
|
|
490
|
-
}
|
|
491
|
-
return { handler: awaitingDepositCompletion, state }
|
|
492
|
-
}
|
|
493
|
-
if (message.method === 'channels.info') {
|
|
494
|
-
if (['own_deposit_locked', 'deposit_locked'].includes(message.params.data.event)) {
|
|
495
|
-
const callback = {
|
|
496
|
-
own_deposit_locked: state.onOwnDepositLocked,
|
|
497
|
-
deposit_locked: state.onDepositLocked
|
|
498
|
-
}[message.params.data.event]
|
|
499
|
-
if (callback) {
|
|
500
|
-
callback()
|
|
501
|
-
}
|
|
502
|
-
return { handler: awaitingDepositCompletion, state }
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
if (message.method === 'channels.update') {
|
|
506
|
-
changeState(channel, message.params.data.state)
|
|
507
|
-
state.resolve({ accepted: true, signedTx: message.params.data.state })
|
|
508
|
-
return { handler: channelOpen }
|
|
509
|
-
}
|
|
510
|
-
if (message.method === 'channels.conflict') {
|
|
511
|
-
state.resolve({
|
|
512
|
-
accepted: false,
|
|
513
|
-
errorCode: message.params.data.error_code,
|
|
514
|
-
errorMessage: message.params.data.error_msg
|
|
515
|
-
})
|
|
516
|
-
return { handler: channelOpen }
|
|
517
|
-
}
|
|
518
|
-
if (message.method === 'channels.info') {
|
|
519
|
-
if (message.params.data.event === 'aborted_update') {
|
|
520
|
-
state.resolve({ accepted: false })
|
|
521
|
-
return { handler: channelOpen }
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
return handleUnexpectedMessage(channel, message, state)
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
export async function awaitingNewContractTx (channel, message, state) {
|
|
528
|
-
if (message.method === 'channels.sign.update') {
|
|
529
|
-
if (message.params.data.tx) {
|
|
530
|
-
const signedTx = await state.sign(message.params.data.tx)
|
|
531
|
-
send(channel, { jsonrpc: '2.0', method: 'channels.update', params: { tx: signedTx } })
|
|
532
|
-
return { handler: awaitingNewContractCompletion, state }
|
|
533
|
-
}
|
|
534
|
-
const signedTx = await appendSignature(message.params.data.signed_tx, tx => state.sign(tx))
|
|
535
|
-
if (typeof signedTx === 'string') {
|
|
536
|
-
send(channel, { jsonrpc: '2.0', method: 'channels.update', params: { signed_tx: signedTx } })
|
|
537
|
-
return { handler: awaitingNewContractCompletion, state }
|
|
538
|
-
}
|
|
539
|
-
if (typeof signedTx === 'number') {
|
|
540
|
-
send(channel, { jsonrpc: '2.0', method: 'channels.update', params: { error: signedTx } })
|
|
541
|
-
return { handler: awaitingNewContractCompletion, state }
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
return handleUnexpectedMessage(channel, message, state)
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
export function awaitingNewContractCompletion (channel, message, state) {
|
|
548
|
-
if (message.method === 'channels.update') {
|
|
549
|
-
const { round } = unpackTx(message.params.data.state).tx.encodedTx.tx
|
|
550
|
-
const owner = options.get(channel)[{
|
|
551
|
-
initiator: 'initiatorId',
|
|
552
|
-
responder: 'responderId'
|
|
553
|
-
}[options.get(channel).role]]
|
|
554
|
-
changeState(channel, message.params.data.state)
|
|
555
|
-
state.resolve({
|
|
556
|
-
accepted: true,
|
|
557
|
-
address: encodeContractAddress(owner, round),
|
|
558
|
-
signedTx: message.params.data.state
|
|
559
|
-
})
|
|
560
|
-
return { handler: channelOpen }
|
|
561
|
-
}
|
|
562
|
-
if (message.method === 'channels.conflict') {
|
|
563
|
-
state.resolve({
|
|
564
|
-
accepted: false,
|
|
565
|
-
errorCode: message.params.data.error_code,
|
|
566
|
-
errorMessage: message.params.data.error_msg
|
|
567
|
-
})
|
|
568
|
-
return { handler: channelOpen }
|
|
569
|
-
}
|
|
570
|
-
if (message.method === 'channels.info') {
|
|
571
|
-
if (message.params.data.event === 'aborted_update') {
|
|
572
|
-
state.resolve({ accepted: false })
|
|
573
|
-
return { handler: channelOpen }
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
return handleUnexpectedMessage(channel, message, state)
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
export async function awaitingCallContractUpdateTx (channel, message, state) {
|
|
580
|
-
if (message.method === 'channels.sign.update') {
|
|
581
|
-
if (message.params.data.tx) {
|
|
582
|
-
const signedTx = await state.sign(
|
|
583
|
-
message.params.data.tx, { updates: message.params.data.updates }
|
|
584
|
-
)
|
|
585
|
-
send(channel, { jsonrpc: '2.0', method: 'channels.update', params: { tx: signedTx } })
|
|
586
|
-
return { handler: awaitingCallContractCompletion, state }
|
|
587
|
-
}
|
|
588
|
-
const signedTx = await appendSignature(
|
|
589
|
-
message.params.data.signed_tx,
|
|
590
|
-
tx => state.sign(tx, { updates: message.params.data.updates })
|
|
591
|
-
)
|
|
592
|
-
if (typeof signedTx === 'string') {
|
|
593
|
-
send(channel, { jsonrpc: '2.0', method: 'channels.update', params: { signed_tx: signedTx } })
|
|
594
|
-
return { handler: awaitingCallContractCompletion, state }
|
|
595
|
-
}
|
|
596
|
-
if (typeof signedTx === 'number') {
|
|
597
|
-
send(channel, { jsonrpc: '2.0', method: 'channels.update', params: { error: signedTx } })
|
|
598
|
-
return { handler: awaitingCallContractCompletion, state }
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
return handleUnexpectedMessage(channel, message, state)
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
export async function awaitingCallContractForceProgressUpdate (channel, message, state) {
|
|
605
|
-
if (message.method === 'channels.sign.force_progress_tx') {
|
|
606
|
-
const signedTx = await appendSignature(message.params.data.signed_tx, tx =>
|
|
607
|
-
state.sign(tx, { updates: message.params.data.updates })
|
|
608
|
-
)
|
|
609
|
-
send(channel, { jsonrpc: '2.0', method: 'channels.force_progress_sign', params: { signed_tx: signedTx } })
|
|
610
|
-
return { handler: awaitingForceProgressCompletion, state }
|
|
611
|
-
}
|
|
612
|
-
return handleUnexpectedMessage(channel, message, state)
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
export function awaitingForceProgressCompletion (channel, message, state) {
|
|
616
|
-
if (message.method === 'channels.on_chain_tx') {
|
|
617
|
-
if (state.onOnChainTx) {
|
|
618
|
-
state.onOnChainTx(message.params.data)
|
|
619
|
-
}
|
|
620
|
-
emit(channel, 'onChainTx', message.params.data.tx, {
|
|
621
|
-
info: message.params.data.info,
|
|
622
|
-
type: message.params.data.type
|
|
623
|
-
})
|
|
624
|
-
state.resolve({ accepted: true, tx: message.params.data.tx })
|
|
625
|
-
}
|
|
626
|
-
return handleUnexpectedMessage(channel, message, state)
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
export function awaitingCallContractCompletion (channel, message, state) {
|
|
630
|
-
if (message.method === 'channels.update') {
|
|
631
|
-
changeState(channel, message.params.data.state)
|
|
632
|
-
state.resolve({ accepted: true, signedTx: message.params.data.state })
|
|
633
|
-
return { handler: channelOpen }
|
|
634
|
-
}
|
|
635
|
-
if (message.method === 'channels.conflict') {
|
|
636
|
-
state.resolve({
|
|
637
|
-
accepted: false,
|
|
638
|
-
errorCode: message.params.data.error_code,
|
|
639
|
-
errorMessage: message.params.data.error_msg
|
|
640
|
-
})
|
|
641
|
-
return { handler: channelOpen }
|
|
642
|
-
}
|
|
643
|
-
if (message.method === 'channels.info') {
|
|
644
|
-
if (message.params.data.event === 'aborted_update') {
|
|
645
|
-
state.resolve({ accepted: false })
|
|
646
|
-
return { handler: channelOpen }
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
return handleUnexpectedMessage(channel, message, state)
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
export function awaitingCallsPruned (channels, message, state) {
|
|
653
|
-
if (message.method === 'channels.calls_pruned.reply') {
|
|
654
|
-
state.resolve()
|
|
655
|
-
return { handler: channelOpen }
|
|
656
|
-
}
|
|
657
|
-
state.reject(new UnexpectedChannelMessageError('Unexpected message received'))
|
|
658
|
-
return { handler: channelClosed }
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
export function channelClosed (channel, message, state) {
|
|
662
|
-
if (!state) return { handler: channelClosed }
|
|
663
|
-
if (message.params.data.event === 'closing') return { handler: channelClosed, state }
|
|
664
|
-
if (message.params.data.info === 'channel_closed') {
|
|
665
|
-
state.closeTx = message.params.data.tx
|
|
666
|
-
return { handler: channelClosed, state }
|
|
667
|
-
}
|
|
668
|
-
if (message.params.data.event === 'closed_confirmed') {
|
|
669
|
-
state.resolve(state.closeTx)
|
|
670
|
-
return { handler: channelClosed }
|
|
671
|
-
}
|
|
672
|
-
return { handler: channelClosed, state }
|
|
673
|
-
}
|