@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/spend.mjs
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ISC License (ISC)
|
|
3
|
+
* Copyright (c) 2022 aeternity developers
|
|
4
|
+
*
|
|
5
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
* copyright notice and this permission notice appear in all copies.
|
|
8
|
+
*
|
|
9
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
* PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
*/
|
|
17
|
+
import BigNumber from 'bignumber.js';
|
|
18
|
+
import { sendTransaction, getAccount, getBalance, resolveName } from "./chain.mjs";
|
|
19
|
+
import { _buildTx } from "./tx/index.mjs";
|
|
20
|
+
import { buildTxHash, unpackTx } from "./tx/builder/index.mjs";
|
|
21
|
+
import { ArgumentError } from "./utils/errors.mjs";
|
|
22
|
+
import { Tag } from "./tx/builder/constants.mjs";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Sign and post a transaction to the chain
|
|
26
|
+
* @category chain
|
|
27
|
+
* @param tx - Transaction
|
|
28
|
+
* @param options - Options
|
|
29
|
+
* @param options.verify - Verify transaction before broadcast, throw error if not
|
|
30
|
+
* valid
|
|
31
|
+
* @returns Transaction
|
|
32
|
+
*/
|
|
33
|
+
export async function send(tx, options) {
|
|
34
|
+
// TODO: detect authFun in AccountGa
|
|
35
|
+
const authFun = options.innerTx === true ? undefined : (await getAccount(await options.onAccount.address(options), options)).authFun;
|
|
36
|
+
const signed = await options.onAccount.signTransaction(tx, { ...options,
|
|
37
|
+
authFun,
|
|
38
|
+
networkId: (await options.onNode.getStatus()).networkId
|
|
39
|
+
});
|
|
40
|
+
return options.innerTx === true ? {
|
|
41
|
+
hash: buildTxHash(signed),
|
|
42
|
+
rawTx: signed
|
|
43
|
+
} : sendTransaction(signed, options);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Send coins to another account
|
|
48
|
+
* @category chain
|
|
49
|
+
* @param amount - Amount to spend
|
|
50
|
+
* @param recipientIdOrName - Address or name of recipient account
|
|
51
|
+
* @param options - Options
|
|
52
|
+
* @returns Transaction
|
|
53
|
+
*/
|
|
54
|
+
export async function spend(amount, recipientIdOrName, options) {
|
|
55
|
+
return send(await _buildTx(Tag.SpendTx, { ...options,
|
|
56
|
+
senderId: await options.onAccount.address(options),
|
|
57
|
+
recipientId: await resolveName(recipientIdOrName, 'account_pubkey', options),
|
|
58
|
+
amount
|
|
59
|
+
}), options);
|
|
60
|
+
}
|
|
61
|
+
// TODO: Rename to spendFraction
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Send a fraction of coin balance to another account
|
|
65
|
+
* @category chain
|
|
66
|
+
* @param fraction - Fraction of balance to spend (between 0 and 1)
|
|
67
|
+
* @param recipientIdOrName - Address or name of recipient account
|
|
68
|
+
* @param options - Options
|
|
69
|
+
* @returns Transaction
|
|
70
|
+
*/
|
|
71
|
+
export async function transferFunds(fraction, recipientIdOrName, options) {
|
|
72
|
+
if (fraction < 0 || fraction > 1) {
|
|
73
|
+
throw new ArgumentError('fraction', 'a number between 0 and 1', fraction);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const recipientId = await resolveName(recipientIdOrName, 'account_pubkey', options);
|
|
77
|
+
const senderId = await options.onAccount.address(options);
|
|
78
|
+
const balance = new BigNumber(await getBalance.bind(options.onAccount)(senderId, options));
|
|
79
|
+
const desiredAmount = balance.times(fraction).integerValue(BigNumber.ROUND_HALF_UP);
|
|
80
|
+
const {
|
|
81
|
+
tx: {
|
|
82
|
+
fee
|
|
83
|
+
}
|
|
84
|
+
} = unpackTx(await _buildTx(Tag.SpendTx, { ...options,
|
|
85
|
+
senderId,
|
|
86
|
+
recipientId,
|
|
87
|
+
amount: desiredAmount
|
|
88
|
+
}), Tag.SpendTx); // Reducing of the amount may reduce transaction fee, so this is not completely accurate
|
|
89
|
+
|
|
90
|
+
const amount = desiredAmount.plus(fee).gt(balance) ? balance.minus(fee) : desiredAmount;
|
|
91
|
+
return send(await _buildTx(Tag.SpendTx, { ...options,
|
|
92
|
+
senderId,
|
|
93
|
+
recipientId,
|
|
94
|
+
amount
|
|
95
|
+
}), options);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Submit transaction of another account paying for it (fee and gas)
|
|
100
|
+
* @category chain
|
|
101
|
+
* @param transaction - tx_<base64>-encoded transaction
|
|
102
|
+
* @param options - Options
|
|
103
|
+
* @returns Object Transaction
|
|
104
|
+
*/
|
|
105
|
+
export async function payForTransaction(transaction, options) {
|
|
106
|
+
return send(await _buildTx(Tag.PayingForTx, { ...options,
|
|
107
|
+
payerId: await options.onAccount.address(options),
|
|
108
|
+
tx: transaction
|
|
109
|
+
}), options);
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=spend.mjs.map
|
package/es/spend.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spend.mjs","names":["BigNumber","sendTransaction","getAccount","getBalance","resolveName","_buildTx","buildTxHash","unpackTx","ArgumentError","Tag","send","tx","options","authFun","innerTx","undefined","onAccount","address","signed","signTransaction","networkId","onNode","getStatus","hash","rawTx","spend","amount","recipientIdOrName","SpendTx","senderId","recipientId","transferFunds","fraction","balance","bind","desiredAmount","times","integerValue","ROUND_HALF_UP","fee","plus","gt","minus","payForTransaction","transaction","PayingForTx","payerId"],"sources":["../src/spend.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2022 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\nimport BigNumber from 'bignumber.js';\nimport {\n sendTransaction, getAccount, getBalance, resolveName,\n} from './chain';\nimport { _buildTx, BuildTxOptions } from './tx';\nimport { buildTxHash, unpackTx } from './tx/builder';\nimport { ArgumentError } from './utils/errors';\nimport { Encoded, Encoding } from './utils/encoder';\nimport { Tag, AensName } from './tx/builder/constants';\nimport AccountBase from './account/Base';\n\n/**\n * Sign and post a transaction to the chain\n * @category chain\n * @param tx - Transaction\n * @param options - Options\n * @param options.verify - Verify transaction before broadcast, throw error if not\n * valid\n * @returns Transaction\n */\nexport async function send(\n tx: Encoded.Transaction,\n options: SendOptions,\n): Promise<SendReturnType> {\n // TODO: detect authFun in AccountGa\n const authFun = options.innerTx === true\n ? undefined\n : (await getAccount(await options.onAccount.address(options), options)).authFun;\n\n const signed = await options.onAccount.signTransaction(tx, {\n ...options,\n authFun,\n networkId: (await options.onNode.getStatus()).networkId,\n });\n\n return options.innerTx === true\n ? { hash: buildTxHash(signed), rawTx: signed }\n : sendTransaction(signed, options);\n}\n\ntype SendOptionsType = Parameters<AccountBase['signTransaction']>[1]\n& Parameters<typeof sendTransaction>[1] & { onAccount: AccountBase };\nexport interface SendOptions extends SendOptionsType {}\ninterface SendReturnType extends Awaited<ReturnType<typeof sendTransaction>> {}\n\n/**\n * Send coins to another account\n * @category chain\n * @param amount - Amount to spend\n * @param recipientIdOrName - Address or name of recipient account\n * @param options - Options\n * @returns Transaction\n */\nexport async function spend(\n amount: number | string,\n recipientIdOrName: Encoded.AccountAddress | AensName,\n options: SpendOptions,\n): ReturnType<typeof send> {\n return send(\n await _buildTx(Tag.SpendTx, {\n ...options,\n senderId: await options.onAccount.address(options),\n recipientId: await resolveName<Encoding.AccountAddress>(\n recipientIdOrName,\n 'account_pubkey',\n options,\n ),\n amount,\n }),\n options,\n );\n}\n\ntype SpendOptionsType = BuildTxOptions<Tag.SpendTx, 'senderId' | 'recipientId' | 'amount'>\n& Parameters<typeof resolveName>[2] & { onAccount: AccountBase } & SendOptions;\ninterface SpendOptions extends SpendOptionsType {}\n\n// TODO: Rename to spendFraction\n/**\n * Send a fraction of coin balance to another account\n * @category chain\n * @param fraction - Fraction of balance to spend (between 0 and 1)\n * @param recipientIdOrName - Address or name of recipient account\n * @param options - Options\n * @returns Transaction\n */\nexport async function transferFunds(\n fraction: number | string,\n recipientIdOrName: AensName | Encoded.AccountAddress,\n options: TransferFundsOptions,\n): ReturnType<typeof send> {\n if (fraction < 0 || fraction > 1) {\n throw new ArgumentError('fraction', 'a number between 0 and 1', fraction);\n }\n const recipientId = await resolveName<Encoding.AccountAddress>(\n recipientIdOrName,\n 'account_pubkey',\n options,\n );\n const senderId = await options.onAccount.address(options);\n const balance = new BigNumber(\n await getBalance.bind(options.onAccount)(senderId, options),\n );\n const desiredAmount = balance.times(fraction).integerValue(BigNumber.ROUND_HALF_UP);\n const { tx: { fee } } = unpackTx(\n await _buildTx(Tag.SpendTx, {\n ...options, senderId, recipientId, amount: desiredAmount,\n }),\n Tag.SpendTx,\n );\n // Reducing of the amount may reduce transaction fee, so this is not completely accurate\n const amount = desiredAmount.plus(fee).gt(balance) ? balance.minus(fee) : desiredAmount;\n return send(\n await _buildTx(Tag.SpendTx, {\n ...options, senderId, recipientId, amount,\n }),\n options,\n );\n}\n\ntype TransferFundsOptionsType = BuildTxOptions<Tag.SpendTx, 'senderId' | 'recipientId' | 'amount'>\n& Parameters<typeof resolveName>[2] & { onAccount: AccountBase } & SendOptions;\ninterface TransferFundsOptions extends TransferFundsOptionsType {}\n\n/**\n * Submit transaction of another account paying for it (fee and gas)\n * @category chain\n * @param transaction - tx_<base64>-encoded transaction\n * @param options - Options\n * @returns Object Transaction\n */\nexport async function payForTransaction(\n transaction: Encoded.Transaction,\n options: PayForTransactionOptions,\n): ReturnType<typeof send> {\n return send(\n await _buildTx(\n Tag.PayingForTx,\n { ...options, payerId: await options.onAccount.address(options), tx: transaction },\n ),\n options,\n );\n}\n\ninterface PayForTransactionOptions extends\n BuildTxOptions<Tag.PayingForTx, 'payerId' | 'tx'>, SendOptions {\n onAccount: AccountBase;\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Encoded } from '../../utils/encoder';
|
|
3
|
+
/**
|
|
4
|
+
* Map of prefix to ID tag constant
|
|
5
|
+
* @see {@link https://github.com/aeternity/protocol/blob/master/serializations.md#the-id-type}
|
|
6
|
+
* @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_id.erl#L97-L102}
|
|
7
|
+
* @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L163-L168}
|
|
8
|
+
*/
|
|
9
|
+
declare const idTagToEncoding: readonly [Encoded.Encoding.AccountAddress, Encoded.Encoding.Name, Encoded.Encoding.Commitment, Encoded.Encoding.OracleAddress, Encoded.Encoding.ContractAddress, Encoded.Encoding.Channel];
|
|
10
|
+
declare type AddressEncodings = typeof idTagToEncoding[number];
|
|
11
|
+
/**
|
|
12
|
+
* Utility function to create and _id type
|
|
13
|
+
* @category transaction builder
|
|
14
|
+
* @param hashId - Encoded hash
|
|
15
|
+
* @returns Buffer Buffer with ID tag and decoded HASh
|
|
16
|
+
*/
|
|
17
|
+
export declare function writeId(hashId: Encoded.Generic<AddressEncodings>): Buffer;
|
|
18
|
+
/**
|
|
19
|
+
* Utility function to read and _id type
|
|
20
|
+
* @category transaction builder
|
|
21
|
+
* @param buf - Data
|
|
22
|
+
* @returns Encoided hash string with prefix
|
|
23
|
+
*/
|
|
24
|
+
export declare function readId(buf: Buffer): Encoded.Generic<AddressEncodings>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import _buffer from "buffer";
|
|
2
|
+
const {
|
|
3
|
+
Buffer: _Buffer
|
|
4
|
+
} = _buffer;
|
|
5
|
+
import { ArgumentError, PrefixNotFoundError, TagNotFoundError } from "../../utils/errors.mjs";
|
|
6
|
+
import { toBytes } from "../../utils/bytes.mjs";
|
|
7
|
+
import { decode, encode, Encoding } from "../../utils/encoder.mjs";
|
|
8
|
+
import { isItemOfArray } from "../../utils/other.mjs";
|
|
9
|
+
/**
|
|
10
|
+
* Map of prefix to ID tag constant
|
|
11
|
+
* @see {@link https://github.com/aeternity/protocol/blob/master/serializations.md#the-id-type}
|
|
12
|
+
* @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_id.erl#L97-L102}
|
|
13
|
+
* @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L163-L168}
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const idTagToEncoding = [Encoding.AccountAddress, Encoding.Name, Encoding.Commitment, Encoding.OracleAddress, Encoding.ContractAddress, Encoding.Channel];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Utility function to create and _id type
|
|
20
|
+
* @category transaction builder
|
|
21
|
+
* @param hashId - Encoded hash
|
|
22
|
+
* @returns Buffer Buffer with ID tag and decoded HASh
|
|
23
|
+
*/
|
|
24
|
+
export function writeId(hashId) {
|
|
25
|
+
if (typeof hashId !== 'string') throw new ArgumentError('hashId', 'a string', hashId);
|
|
26
|
+
const encoding = hashId.slice(0, 2);
|
|
27
|
+
if (!isItemOfArray(encoding, idTagToEncoding)) throw new TagNotFoundError(encoding);
|
|
28
|
+
const idTag = idTagToEncoding.indexOf(encoding) + 1;
|
|
29
|
+
return _Buffer.from([...toBytes(idTag), ...decode(hashId)]);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Utility function to read and _id type
|
|
33
|
+
* @category transaction builder
|
|
34
|
+
* @param buf - Data
|
|
35
|
+
* @returns Encoided hash string with prefix
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
export function readId(buf) {
|
|
39
|
+
const idTag = _Buffer.from(buf).readUIntBE(0, 1);
|
|
40
|
+
|
|
41
|
+
const encoding = idTagToEncoding[idTag - 1];
|
|
42
|
+
if (encoding == null) throw new PrefixNotFoundError(idTag);
|
|
43
|
+
return encode(buf.slice(1, buf.length), encoding);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=address.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.mjs","names":["ArgumentError","PrefixNotFoundError","TagNotFoundError","toBytes","decode","encode","Encoding","isItemOfArray","idTagToEncoding","AccountAddress","Name","Commitment","OracleAddress","ContractAddress","Channel","writeId","hashId","encoding","slice","idTag","indexOf","from","readId","buf","readUIntBE","length"],"sources":["../../../src/tx/builder/address.ts"],"sourcesContent":["import { ArgumentError, PrefixNotFoundError, TagNotFoundError } from '../../utils/errors';\nimport { toBytes } from '../../utils/bytes';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../../utils/encoder';\nimport { isItemOfArray } from '../../utils/other';\n\n/**\n * Map of prefix to ID tag constant\n * @see {@link https://github.com/aeternity/protocol/blob/master/serializations.md#the-id-type}\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_id.erl#L97-L102}\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L163-L168}\n */\nconst idTagToEncoding = [\n Encoding.AccountAddress,\n Encoding.Name,\n Encoding.Commitment,\n Encoding.OracleAddress,\n Encoding.ContractAddress,\n Encoding.Channel,\n] as const;\n\ntype AddressEncodings = typeof idTagToEncoding[number];\n\n/**\n * Utility function to create and _id type\n * @category transaction builder\n * @param hashId - Encoded hash\n * @returns Buffer Buffer with ID tag and decoded HASh\n */\nexport function writeId(hashId: Encoded.Generic<AddressEncodings>): Buffer {\n if (typeof hashId !== 'string') throw new ArgumentError('hashId', 'a string', hashId);\n const encoding = hashId.slice(0, 2);\n if (!isItemOfArray(encoding, idTagToEncoding)) throw new TagNotFoundError(encoding);\n const idTag = idTagToEncoding.indexOf(encoding) + 1;\n return Buffer.from([...toBytes(idTag), ...decode(hashId)]);\n}\n\n/**\n * Utility function to read and _id type\n * @category transaction builder\n * @param buf - Data\n * @returns Encoided hash string with prefix\n */\nexport function readId(buf: Buffer): Encoded.Generic<AddressEncodings> {\n const idTag = Buffer.from(buf).readUIntBE(0, 1);\n const encoding = idTagToEncoding[idTag - 1];\n if (encoding == null) throw new PrefixNotFoundError(idTag);\n return encode(buf.slice(1, buf.length), encoding);\n}\n"],"mappings":";;;;SAASA,a,EAAeC,mB,EAAqBC,gB;SACpCC,O;SAEPC,M,EAAQC,M,EAAiBC,Q;SAElBC,a;AAET;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,eAAe,GAAG,CACtBF,QAAQ,CAACG,cADa,EAEtBH,QAAQ,CAACI,IAFa,EAGtBJ,QAAQ,CAACK,UAHa,EAItBL,QAAQ,CAACM,aAJa,EAKtBN,QAAQ,CAACO,eALa,EAMtBP,QAAQ,CAACQ,OANa,CAAxB;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,OAAT,CAAiBC,MAAjB,EAAoE;EACzE,IAAI,OAAOA,MAAP,KAAkB,QAAtB,EAAgC,MAAM,IAAIhB,aAAJ,CAAkB,QAAlB,EAA4B,UAA5B,EAAwCgB,MAAxC,CAAN;EAChC,MAAMC,QAAQ,GAAGD,MAAM,CAACE,KAAP,CAAa,CAAb,EAAgB,CAAhB,CAAjB;EACA,IAAI,CAACX,aAAa,CAACU,QAAD,EAAWT,eAAX,CAAlB,EAA+C,MAAM,IAAIN,gBAAJ,CAAqBe,QAArB,CAAN;EAC/C,MAAME,KAAK,GAAGX,eAAe,CAACY,OAAhB,CAAwBH,QAAxB,IAAoC,CAAlD;EACA,OAAO,QAAOI,IAAP,CAAY,CAAC,GAAGlB,OAAO,CAACgB,KAAD,CAAX,EAAoB,GAAGf,MAAM,CAACY,MAAD,CAA7B,CAAZ,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASM,MAAT,CAAgBC,GAAhB,EAAgE;EACrE,MAAMJ,KAAK,GAAG,QAAOE,IAAP,CAAYE,GAAZ,EAAiBC,UAAjB,CAA4B,CAA5B,EAA+B,CAA/B,CAAd;;EACA,MAAMP,QAAQ,GAAGT,eAAe,CAACW,KAAK,GAAG,CAAT,CAAhC;EACA,IAAIF,QAAQ,IAAI,IAAhB,EAAsB,MAAM,IAAIhB,mBAAJ,CAAwBkB,KAAxB,CAAN;EACtB,OAAOd,MAAM,CAACkB,GAAG,CAACL,KAAJ,CAAU,CAAV,EAAaK,GAAG,CAACE,MAAjB,CAAD,EAA2BR,QAA3B,CAAb;AACD"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
export declare type AensName = `${string}.chain`;
|
|
3
|
+
export declare const NAME_TTL = 180000;
|
|
4
|
+
export declare const NAME_MAX_TTL = 36000;
|
|
5
|
+
export declare const NAME_MAX_CLIENT_TTL = 84600;
|
|
6
|
+
export declare const CLIENT_TTL = 84600;
|
|
7
|
+
export declare const MIN_GAS_PRICE = 1000000000;
|
|
8
|
+
export declare const NAME_FEE_MULTIPLIER = 100000000000000;
|
|
9
|
+
export declare const NAME_FEE_BID_INCREMENT = 0.05;
|
|
10
|
+
export declare const NAME_BID_TIMEOUT_BLOCKS = 480;
|
|
11
|
+
export declare const NAME_MAX_LENGTH_FEE = 31;
|
|
12
|
+
export declare const NAME_BID_MAX_LENGTH = 12;
|
|
13
|
+
export declare const NAME_BID_RANGES: {
|
|
14
|
+
[k: string]: BigNumber;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Enum with tag types
|
|
18
|
+
* @category transaction builder
|
|
19
|
+
* @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/serializations.md#binary-serialization}
|
|
20
|
+
* @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_chain_objects.erl#L39-L97}
|
|
21
|
+
*/
|
|
22
|
+
export declare enum Tag {
|
|
23
|
+
Account = 10,
|
|
24
|
+
SignedTx = 11,
|
|
25
|
+
SpendTx = 12,
|
|
26
|
+
OracleRegisterTx = 22,
|
|
27
|
+
OracleQueryTx = 23,
|
|
28
|
+
OracleResponseTx = 24,
|
|
29
|
+
OracleExtendTx = 25,
|
|
30
|
+
NameClaimTx = 32,
|
|
31
|
+
NamePreclaimTx = 33,
|
|
32
|
+
NameUpdateTx = 34,
|
|
33
|
+
NameRevokeTx = 35,
|
|
34
|
+
NameTransferTx = 36,
|
|
35
|
+
Contract = 40,
|
|
36
|
+
ContractCall = 41,
|
|
37
|
+
ContractCreateTx = 42,
|
|
38
|
+
ContractCallTx = 43,
|
|
39
|
+
ChannelCreateTx = 50,
|
|
40
|
+
ChannelDepositTx = 51,
|
|
41
|
+
ChannelWithdrawTx = 52,
|
|
42
|
+
ChannelForceProgressTx = 521,
|
|
43
|
+
ChannelCloseMutualTx = 53,
|
|
44
|
+
ChannelCloseSoloTx = 54,
|
|
45
|
+
ChannelSlashTx = 55,
|
|
46
|
+
ChannelSettleTx = 56,
|
|
47
|
+
ChannelOffChainTx = 57,
|
|
48
|
+
ChannelOffChainUpdateTransfer = 570,
|
|
49
|
+
ChannelOffChainUpdateDeposit = 571,
|
|
50
|
+
ChannelOffChainUpdateWithdraw = 572,
|
|
51
|
+
ChannelOffChainUpdateCreateContract = 573,
|
|
52
|
+
ChannelOffChainUpdateCallContract = 574,
|
|
53
|
+
ChannelClientReconnectTx = 575,
|
|
54
|
+
Channel = 58,
|
|
55
|
+
ChannelSnapshotSoloTx = 59,
|
|
56
|
+
TreesPoi = 60,
|
|
57
|
+
StateTrees = 62,
|
|
58
|
+
Mtree = 63,
|
|
59
|
+
MtreeValue = 64,
|
|
60
|
+
ContractsMtree = 621,
|
|
61
|
+
CallsMtree = 622,
|
|
62
|
+
ChannelsMtree = 623,
|
|
63
|
+
NameserviceMtree = 624,
|
|
64
|
+
OraclesMtree = 625,
|
|
65
|
+
AccountsMtree = 626,
|
|
66
|
+
CompilerSophia = 70,
|
|
67
|
+
GaAttachTx = 80,
|
|
68
|
+
GaMetaTx = 81,
|
|
69
|
+
PayingForTx = 82
|
|
70
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
import { mapObject } from "../../utils/other.mjs"; // # AENS
|
|
3
|
+
|
|
4
|
+
export const NAME_TTL = 180000; // # max number of block into the future that the name is going to be available
|
|
5
|
+
// # https://github.com/aeternity/protocol/blob/epoch-v0.22.0/AENS.md#update
|
|
6
|
+
// # https://github.com/aeternity/protocol/blob/44a93d3aab957ca820183c3520b9daf6b0fedff4/AENS.md#aens-entry
|
|
7
|
+
|
|
8
|
+
export const NAME_MAX_TTL = 36000;
|
|
9
|
+
export const NAME_MAX_CLIENT_TTL = 84600;
|
|
10
|
+
export const CLIENT_TTL = NAME_MAX_CLIENT_TTL;
|
|
11
|
+
export const MIN_GAS_PRICE = 1e9; // # see https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L67
|
|
12
|
+
|
|
13
|
+
export const NAME_FEE_MULTIPLIER = 1e14; // 100000000000000
|
|
14
|
+
|
|
15
|
+
export const NAME_FEE_BID_INCREMENT = 0.05; // # the increment is in percentage
|
|
16
|
+
// # see https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L272
|
|
17
|
+
|
|
18
|
+
export const NAME_BID_TIMEOUT_BLOCKS = 480; // # ~1 day
|
|
19
|
+
// # this is the max length for a domain that requires a base fee to be paid
|
|
20
|
+
|
|
21
|
+
export const NAME_MAX_LENGTH_FEE = 31;
|
|
22
|
+
export const NAME_BID_MAX_LENGTH = 12; // # this is the max length for a domain to be part of a bid
|
|
23
|
+
// # https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L290
|
|
24
|
+
// # https://github.com/aeternity/protocol/blob/master/AENS.md#protocol-fees-and-protection-times
|
|
25
|
+
// # bid ranges:
|
|
26
|
+
|
|
27
|
+
export const NAME_BID_RANGES = mapObject({
|
|
28
|
+
31: 3,
|
|
29
|
+
30: 5,
|
|
30
|
+
29: 8,
|
|
31
|
+
28: 13,
|
|
32
|
+
27: 21,
|
|
33
|
+
26: 34,
|
|
34
|
+
25: 55,
|
|
35
|
+
24: 89,
|
|
36
|
+
23: 144,
|
|
37
|
+
22: 233,
|
|
38
|
+
21: 377,
|
|
39
|
+
20: 610,
|
|
40
|
+
19: 987,
|
|
41
|
+
18: 1597,
|
|
42
|
+
17: 2584,
|
|
43
|
+
16: 4181,
|
|
44
|
+
15: 6765,
|
|
45
|
+
14: 10946,
|
|
46
|
+
13: 17711,
|
|
47
|
+
12: 28657,
|
|
48
|
+
11: 46368,
|
|
49
|
+
10: 75025,
|
|
50
|
+
9: 121393,
|
|
51
|
+
8: 196418,
|
|
52
|
+
7: 317811,
|
|
53
|
+
6: 514229,
|
|
54
|
+
5: 832040,
|
|
55
|
+
4: 1346269,
|
|
56
|
+
3: 2178309,
|
|
57
|
+
2: 3524578,
|
|
58
|
+
1: 5702887
|
|
59
|
+
}, _ref => {
|
|
60
|
+
let [key, value] = _ref;
|
|
61
|
+
return [key, new BigNumber(value).times(NAME_FEE_MULTIPLIER)];
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Enum with tag types
|
|
65
|
+
* @category transaction builder
|
|
66
|
+
* @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/serializations.md#binary-serialization}
|
|
67
|
+
* @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_chain_objects.erl#L39-L97}
|
|
68
|
+
*/
|
|
69
|
+
// TODO: implement serialisation for commented-out tags
|
|
70
|
+
|
|
71
|
+
export let Tag;
|
|
72
|
+
|
|
73
|
+
(function (Tag) {
|
|
74
|
+
Tag[Tag["Account"] = 10] = "Account";
|
|
75
|
+
Tag[Tag["SignedTx"] = 11] = "SignedTx";
|
|
76
|
+
Tag[Tag["SpendTx"] = 12] = "SpendTx";
|
|
77
|
+
Tag[Tag["OracleRegisterTx"] = 22] = "OracleRegisterTx";
|
|
78
|
+
Tag[Tag["OracleQueryTx"] = 23] = "OracleQueryTx";
|
|
79
|
+
Tag[Tag["OracleResponseTx"] = 24] = "OracleResponseTx";
|
|
80
|
+
Tag[Tag["OracleExtendTx"] = 25] = "OracleExtendTx";
|
|
81
|
+
Tag[Tag["NameClaimTx"] = 32] = "NameClaimTx";
|
|
82
|
+
Tag[Tag["NamePreclaimTx"] = 33] = "NamePreclaimTx";
|
|
83
|
+
Tag[Tag["NameUpdateTx"] = 34] = "NameUpdateTx";
|
|
84
|
+
Tag[Tag["NameRevokeTx"] = 35] = "NameRevokeTx";
|
|
85
|
+
Tag[Tag["NameTransferTx"] = 36] = "NameTransferTx";
|
|
86
|
+
Tag[Tag["Contract"] = 40] = "Contract";
|
|
87
|
+
Tag[Tag["ContractCall"] = 41] = "ContractCall";
|
|
88
|
+
Tag[Tag["ContractCreateTx"] = 42] = "ContractCreateTx";
|
|
89
|
+
Tag[Tag["ContractCallTx"] = 43] = "ContractCallTx";
|
|
90
|
+
Tag[Tag["ChannelCreateTx"] = 50] = "ChannelCreateTx";
|
|
91
|
+
Tag[Tag["ChannelDepositTx"] = 51] = "ChannelDepositTx";
|
|
92
|
+
Tag[Tag["ChannelWithdrawTx"] = 52] = "ChannelWithdrawTx";
|
|
93
|
+
Tag[Tag["ChannelForceProgressTx"] = 521] = "ChannelForceProgressTx";
|
|
94
|
+
Tag[Tag["ChannelCloseMutualTx"] = 53] = "ChannelCloseMutualTx";
|
|
95
|
+
Tag[Tag["ChannelCloseSoloTx"] = 54] = "ChannelCloseSoloTx";
|
|
96
|
+
Tag[Tag["ChannelSlashTx"] = 55] = "ChannelSlashTx";
|
|
97
|
+
Tag[Tag["ChannelSettleTx"] = 56] = "ChannelSettleTx";
|
|
98
|
+
Tag[Tag["ChannelOffChainTx"] = 57] = "ChannelOffChainTx";
|
|
99
|
+
Tag[Tag["ChannelOffChainUpdateTransfer"] = 570] = "ChannelOffChainUpdateTransfer";
|
|
100
|
+
Tag[Tag["ChannelOffChainUpdateDeposit"] = 571] = "ChannelOffChainUpdateDeposit";
|
|
101
|
+
Tag[Tag["ChannelOffChainUpdateWithdraw"] = 572] = "ChannelOffChainUpdateWithdraw";
|
|
102
|
+
Tag[Tag["ChannelOffChainUpdateCreateContract"] = 573] = "ChannelOffChainUpdateCreateContract";
|
|
103
|
+
Tag[Tag["ChannelOffChainUpdateCallContract"] = 574] = "ChannelOffChainUpdateCallContract";
|
|
104
|
+
Tag[Tag["ChannelClientReconnectTx"] = 575] = "ChannelClientReconnectTx";
|
|
105
|
+
Tag[Tag["Channel"] = 58] = "Channel";
|
|
106
|
+
Tag[Tag["ChannelSnapshotSoloTx"] = 59] = "ChannelSnapshotSoloTx";
|
|
107
|
+
Tag[Tag["TreesPoi"] = 60] = "TreesPoi";
|
|
108
|
+
Tag[Tag["StateTrees"] = 62] = "StateTrees";
|
|
109
|
+
Tag[Tag["Mtree"] = 63] = "Mtree";
|
|
110
|
+
Tag[Tag["MtreeValue"] = 64] = "MtreeValue";
|
|
111
|
+
Tag[Tag["ContractsMtree"] = 621] = "ContractsMtree";
|
|
112
|
+
Tag[Tag["CallsMtree"] = 622] = "CallsMtree";
|
|
113
|
+
Tag[Tag["ChannelsMtree"] = 623] = "ChannelsMtree";
|
|
114
|
+
Tag[Tag["NameserviceMtree"] = 624] = "NameserviceMtree";
|
|
115
|
+
Tag[Tag["OraclesMtree"] = 625] = "OraclesMtree";
|
|
116
|
+
Tag[Tag["AccountsMtree"] = 626] = "AccountsMtree";
|
|
117
|
+
Tag[Tag["CompilerSophia"] = 70] = "CompilerSophia";
|
|
118
|
+
Tag[Tag["GaAttachTx"] = 80] = "GaAttachTx";
|
|
119
|
+
Tag[Tag["GaMetaTx"] = 81] = "GaMetaTx";
|
|
120
|
+
Tag[Tag["PayingForTx"] = 82] = "PayingForTx";
|
|
121
|
+
})(Tag || (Tag = {}));
|
|
122
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":["BigNumber","mapObject","NAME_TTL","NAME_MAX_TTL","NAME_MAX_CLIENT_TTL","CLIENT_TTL","MIN_GAS_PRICE","NAME_FEE_MULTIPLIER","NAME_FEE_BID_INCREMENT","NAME_BID_TIMEOUT_BLOCKS","NAME_MAX_LENGTH_FEE","NAME_BID_MAX_LENGTH","NAME_BID_RANGES","key","value","times","Tag"],"sources":["../../../src/tx/builder/constants.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { mapObject } from '../../utils/other';\n\n// # AENS\nexport type AensName = `${string}.chain`;\nexport const NAME_TTL = 180000;\n// # max number of block into the future that the name is going to be available\n// # https://github.com/aeternity/protocol/blob/epoch-v0.22.0/AENS.md#update\n// # https://github.com/aeternity/protocol/blob/44a93d3aab957ca820183c3520b9daf6b0fedff4/AENS.md#aens-entry\nexport const NAME_MAX_TTL = 36000;\nexport const NAME_MAX_CLIENT_TTL = 84600;\nexport const CLIENT_TTL = NAME_MAX_CLIENT_TTL;\nexport const MIN_GAS_PRICE = 1e9;\n// # see https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L67\nexport const NAME_FEE_MULTIPLIER = 1e14; // 100000000000000\nexport const NAME_FEE_BID_INCREMENT = 0.05; // # the increment is in percentage\n// # see https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L272\nexport const NAME_BID_TIMEOUT_BLOCKS = 480; // # ~1 day\n// # this is the max length for a domain that requires a base fee to be paid\nexport const NAME_MAX_LENGTH_FEE = 31;\nexport const NAME_BID_MAX_LENGTH = 12; // # this is the max length for a domain to be part of a bid\n// # https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L290\n// # https://github.com/aeternity/protocol/blob/master/AENS.md#protocol-fees-and-protection-times\n// # bid ranges:\nexport const NAME_BID_RANGES = mapObject({\n 31: 3,\n 30: 5,\n 29: 8,\n 28: 13,\n 27: 21,\n 26: 34,\n 25: 55,\n 24: 89,\n 23: 144,\n 22: 233,\n 21: 377,\n 20: 610,\n 19: 987,\n 18: 1597,\n 17: 2584,\n 16: 4181,\n 15: 6765,\n 14: 10946,\n 13: 17711,\n 12: 28657,\n 11: 46368,\n 10: 75025,\n 9: 121393,\n 8: 196418,\n 7: 317811,\n 6: 514229,\n 5: 832040,\n 4: 1346269,\n 3: 2178309,\n 2: 3524578,\n 1: 5702887,\n}, ([key, value]) => [key, new BigNumber(value).times(NAME_FEE_MULTIPLIER)]);\n\n/**\n * Enum with tag types\n * @category transaction builder\n * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/serializations.md#binary-serialization}\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_chain_objects.erl#L39-L97}\n */\n// TODO: implement serialisation for commented-out tags\nexport enum Tag {\n Account = 10,\n SignedTx = 11,\n SpendTx = 12,\n // Oracle = 20,\n // OracleQuery = 21,\n OracleRegisterTx = 22,\n OracleQueryTx = 23,\n OracleResponseTx = 24,\n OracleExtendTx = 25,\n // Name = 30,\n // NameCommitment = 31,\n NameClaimTx = 32,\n NamePreclaimTx = 33,\n NameUpdateTx = 34,\n NameRevokeTx = 35,\n NameTransferTx = 36,\n // NameAuction = 37,\n Contract = 40,\n ContractCall = 41,\n ContractCreateTx = 42,\n ContractCallTx = 43,\n ChannelCreateTx = 50,\n // ChannelSetDelegatesTx = 501,\n ChannelDepositTx = 51,\n ChannelWithdrawTx = 52,\n ChannelForceProgressTx = 521,\n ChannelCloseMutualTx = 53,\n ChannelCloseSoloTx = 54,\n ChannelSlashTx = 55,\n ChannelSettleTx = 56,\n ChannelOffChainTx = 57,\n ChannelOffChainUpdateTransfer = 570,\n ChannelOffChainUpdateDeposit = 571,\n ChannelOffChainUpdateWithdraw = 572,\n ChannelOffChainUpdateCreateContract = 573,\n ChannelOffChainUpdateCallContract = 574,\n // ChannelOffChainUpdateMeta = 576,\n ChannelClientReconnectTx = 575,\n Channel = 58,\n ChannelSnapshotSoloTx = 59,\n TreesPoi = 60,\n // TreesDb = 61,\n StateTrees = 62,\n Mtree = 63,\n MtreeValue = 64,\n ContractsMtree = 621,\n CallsMtree = 622,\n ChannelsMtree = 623,\n NameserviceMtree = 624,\n OraclesMtree = 625,\n AccountsMtree = 626,\n CompilerSophia = 70,\n GaAttachTx = 80,\n GaMetaTx = 81,\n PayingForTx = 82,\n // KeyBlock = 100,\n // MicroBlock = 101,\n // LightMicroBlock = 102,\n // Pof = 200,\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Int } from './u-int';
|
|
3
|
+
import { AE_AMOUNT_FORMATS } from '../../../utils/amount-formatter';
|
|
4
|
+
export interface Options {
|
|
5
|
+
denomination?: AE_AMOUNT_FORMATS;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: {
|
|
8
|
+
serializeAettos(value: string | undefined): string;
|
|
9
|
+
serializeOptional(value: Int | undefined, { denomination, ...options }: Options): Buffer;
|
|
10
|
+
serialize(value: Int, options: Options): Buffer;
|
|
11
|
+
deserialize(value: Buffer): string;
|
|
12
|
+
};
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import uInt from "./u-int.mjs";
|
|
2
|
+
import { formatAmount } from "../../../utils/amount-formatter.mjs";
|
|
3
|
+
import { ArgumentError } from "../../../utils/errors.mjs";
|
|
4
|
+
export default { ...uInt,
|
|
5
|
+
|
|
6
|
+
serializeAettos(value) {
|
|
7
|
+
if (value == null) throw new ArgumentError('value', 'provided', value);
|
|
8
|
+
return value;
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
serializeOptional(value, _ref) {
|
|
12
|
+
let {
|
|
13
|
+
denomination,
|
|
14
|
+
...options
|
|
15
|
+
} = _ref;
|
|
16
|
+
return uInt.serialize(this.serializeAettos(value != null ? formatAmount(value, {
|
|
17
|
+
denomination
|
|
18
|
+
}) : value, options));
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
serialize(value, options) {
|
|
22
|
+
return this.serializeOptional(value, options);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=coin-amount.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coin-amount.mjs","names":["uInt","formatAmount","ArgumentError","serializeAettos","value","serializeOptional","denomination","options","serialize"],"sources":["../../../../src/tx/builder/field-types/coin-amount.ts"],"sourcesContent":["import uInt, { Int } from './u-int';\nimport { AE_AMOUNT_FORMATS, formatAmount } from '../../../utils/amount-formatter';\nimport { ArgumentError } from '../../../utils/errors';\n\nexport interface Options { denomination?: AE_AMOUNT_FORMATS }\n\nexport default {\n ...uInt,\n\n serializeAettos(value: string | undefined): string {\n if (value == null) throw new ArgumentError('value', 'provided', value);\n return value;\n },\n\n serializeOptional(value: Int | undefined, { denomination, ...options }: Options): Buffer {\n return uInt.serialize(\n this.serializeAettos(\n value != null ? formatAmount(value, { denomination }) : value,\n options,\n ),\n );\n },\n\n serialize(value: Int, options: Options): Buffer {\n return this.serializeOptional(value, options);\n },\n};\n"],"mappings":"OAAOA,I;SACqBC,Y;SACnBC,a;AAIT,eAAe,EACb,GAAGF,IADU;;EAGbG,eAAe,CAACC,KAAD,EAAoC;IACjD,IAAIA,KAAK,IAAI,IAAb,EAAmB,MAAM,IAAIF,aAAJ,CAAkB,OAAlB,EAA2B,UAA3B,EAAuCE,KAAvC,CAAN;IACnB,OAAOA,KAAP;EACD,CANY;;EAQbC,iBAAiB,CAACD,KAAD,QAAwE;IAAA,IAA/C;MAAEE,YAAF;MAAgB,GAAGC;IAAnB,CAA+C;IACvF,OAAOP,IAAI,CAACQ,SAAL,CACL,KAAKL,eAAL,CACEC,KAAK,IAAI,IAAT,GAAgBH,YAAY,CAACG,KAAD,EAAQ;MAAEE;IAAF,CAAR,CAA5B,GAAwDF,KAD1D,EAEEG,OAFF,CADK,CAAP;EAMD,CAfY;;EAiBbC,SAAS,CAACJ,KAAD,EAAaG,OAAb,EAAuC;IAC9C,OAAO,KAAKF,iBAAL,CAAuBD,KAAvB,EAA8BG,OAA9B,CAAP;EACD;;AAnBY,CAAf"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import coinAmount from './coin-amount';
|
|
3
|
+
import { Int } from './u-int';
|
|
4
|
+
declare const _default: {
|
|
5
|
+
/**
|
|
6
|
+
* @param value - Deposit value in string format. Should be equal to '0'.
|
|
7
|
+
* @param options - Options
|
|
8
|
+
* @returns Deposit value Buffer.
|
|
9
|
+
*/
|
|
10
|
+
serialize(value: Int | undefined, options: Parameters<(typeof coinAmount)['serialize']>[1]): Buffer;
|
|
11
|
+
serializeAettos(value: string | undefined): string;
|
|
12
|
+
serializeOptional(value: Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
|
|
13
|
+
deserialize(value: Buffer): string;
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import coinAmount from "./coin-amount.mjs";
|
|
2
|
+
import { IllegalArgumentError } from "../../../utils/errors.mjs";
|
|
3
|
+
export default { ...coinAmount,
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param value - Deposit value in string format. Should be equal to '0'.
|
|
7
|
+
* @param options - Options
|
|
8
|
+
* @returns Deposit value Buffer.
|
|
9
|
+
*/
|
|
10
|
+
serialize(value, options) {
|
|
11
|
+
var _value;
|
|
12
|
+
|
|
13
|
+
(_value = value) !== null && _value !== void 0 ? _value : value = 0;
|
|
14
|
+
if (+value !== 0) throw new IllegalArgumentError(`Contract deposit is not refundable, so it should be equal 0, got ${value.toString()} instead`);
|
|
15
|
+
return coinAmount.serialize(value, options);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=deposit.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deposit.mjs","names":["coinAmount","IllegalArgumentError","serialize","value","options","toString"],"sources":["../../../../src/tx/builder/field-types/deposit.ts"],"sourcesContent":["import coinAmount from './coin-amount';\nimport { Int } from './u-int';\nimport { IllegalArgumentError } from '../../../utils/errors';\n\nexport default {\n ...coinAmount,\n\n /**\n * @param value - Deposit value in string format. Should be equal to '0'.\n * @param options - Options\n * @returns Deposit value Buffer.\n */\n serialize(\n value: Int | undefined,\n options: Parameters<typeof coinAmount['serialize']>[1],\n ): Buffer {\n value ??= 0;\n if (+value !== 0) throw new IllegalArgumentError(`Contract deposit is not refundable, so it should be equal 0, got ${value.toString()} instead`);\n return coinAmount.serialize(value, options);\n },\n};\n"],"mappings":"OAAOA,U;SAEEC,oB;AAET,eAAe,EACb,GAAGD,UADU;;EAGb;AACF;AACA;AACA;AACA;EACEE,SAAS,CACPC,KADO,EAEPC,OAFO,EAGC;IAAA;;IACR,UAAAD,KAAK,UAAL,iCAAAA,KAAK,GAAK,CAAV;IACA,IAAI,CAACA,KAAD,KAAW,CAAf,EAAkB,MAAM,IAAIF,oBAAJ,CAA0B,oEAAmEE,KAAK,CAACE,QAAN,EAAiB,UAA9G,CAAN;IAClB,OAAOL,UAAU,CAACE,SAAX,CAAqBC,KAArB,EAA4BC,OAA5B,CAAP;EACD;;AAfY,CAAf"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import BigNumber from 'bignumber.js';
|
|
3
|
+
import { Tag } from '../constants';
|
|
4
|
+
/**
|
|
5
|
+
* Calculate fee based on tx type and params
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildFee(txType: Tag, buildTx: any): BigNumber;
|
|
8
|
+
/**
|
|
9
|
+
* Calculate min fee
|
|
10
|
+
* @category transaction builder
|
|
11
|
+
* @param txType - Transaction type
|
|
12
|
+
* @param rebuildTx - Callback to get built transaction with specific fee
|
|
13
|
+
*/
|
|
14
|
+
export declare function calculateMinFee(txType: Tag, rebuildTx: (value: BigNumber) => any): BigNumber;
|
|
15
|
+
declare const _default: {
|
|
16
|
+
serializeAettos(_value: string | undefined, { txType, rebuildTx, _computingMinFee }: {
|
|
17
|
+
txType: Tag;
|
|
18
|
+
rebuildTx: (params: any) => any;
|
|
19
|
+
_computingMinFee?: string | undefined;
|
|
20
|
+
}): string;
|
|
21
|
+
serialize: (value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options) => Buffer;
|
|
22
|
+
serializeOptional(value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
|
|
23
|
+
deserialize(value: Buffer): string;
|
|
24
|
+
};
|
|
25
|
+
export default _default;
|