@aeternity/aepp-sdk 10.0.0 → 12.0.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/README.md +15 -14
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.LICENSE.txt +13 -40
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +1 -1
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +1 -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 +69 -0
- package/es/AeSdkAepp.mjs +175 -0
- package/es/AeSdkAepp.mjs.map +1 -0
- package/es/AeSdkBase.d.ts +212 -0
- package/es/AeSdkBase.mjs +310 -0
- package/es/AeSdkBase.mjs.map +1 -0
- package/es/AeSdkWallet.d.ts +103 -0
- package/es/AeSdkWallet.mjs +322 -0
- package/es/AeSdkWallet.mjs.map +1 -0
- package/es/Node.d.ts +44 -0
- package/es/Node.mjs +141 -0
- package/es/Node.mjs.map +1 -0
- package/es/account/Base.d.ts +65 -0
- package/es/account/Base.mjs +123 -0
- package/es/account/Base.mjs.map +1 -0
- package/es/account/Memory.d.ts +25 -0
- package/es/account/Memory.mjs +81 -0
- package/es/account/Memory.mjs.map +1 -0
- package/es/account/Rpc.d.ts +27 -0
- package/es/account/Rpc.mjs +79 -0
- package/es/account/Rpc.mjs.map +1 -0
- package/es/aens.d.ts +209 -0
- package/es/aens.mjs +332 -0
- package/es/aens.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection/Browser.d.ts +32 -0
- package/es/aepp-wallet-communication/connection/Browser.mjs +70 -0
- package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +17 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +57 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +35 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +142 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection-proxy.d.ts +10 -0
- package/{src/utils/crypto-ts.ts → es/aepp-wallet-communication/connection-proxy.mjs} +15 -11
- package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -0
- package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +33 -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 +118 -0
- package/es/aepp-wallet-communication/schema.mjs +214 -0
- package/es/aepp-wallet-communication/schema.mjs.map +1 -0
- package/es/aepp-wallet-communication/wallet-detector.d.ts +24 -0
- package/es/aepp-wallet-communication/wallet-detector.mjs +63 -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 +1061 -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 +4164 -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 +220 -0
- package/es/chain.mjs +524 -0
- package/es/chain.mjs.map +1 -0
- package/es/channel/handlers.d.ts +34 -0
- package/es/channel/{handlers.js → handlers.mjs} +163 -130
- package/es/channel/handlers.mjs.map +1 -0
- package/es/channel/index.d.ts +634 -0
- package/es/channel/index.mjs +978 -0
- package/es/channel/index.mjs.map +1 -0
- package/es/channel/internal.d.ts +100 -0
- package/es/channel/internal.mjs +328 -0
- package/es/channel/internal.mjs.map +1 -0
- package/es/contract/Compiler.d.ts +17 -0
- package/es/contract/Compiler.mjs +67 -0
- package/es/contract/Compiler.mjs.map +1 -0
- package/es/contract/aci.d.ts +125 -0
- package/es/contract/aci.mjs +496 -0
- package/es/contract/aci.mjs.map +1 -0
- package/es/contract/ga.d.ts +68 -0
- package/es/contract/ga.mjs +190 -0
- package/es/contract/ga.mjs.map +1 -0
- package/es/contract/methods.d.ts +68 -0
- package/es/contract/methods.mjs +101 -0
- package/es/contract/methods.mjs.map +1 -0
- package/es/index.d.ts +32 -0
- package/es/index.mjs +49 -0
- package/es/index.mjs.map +1 -0
- package/es/oracle.d.ts +154 -0
- package/es/oracle.mjs +288 -0
- package/es/oracle.mjs.map +1 -0
- package/es/spend.d.ts +61 -0
- package/es/spend.mjs +122 -0
- package/es/spend.mjs.map +1 -0
- package/es/tx/builder/constants.d.ts +41 -0
- package/es/tx/builder/constants.mjs +100 -0
- package/es/tx/builder/constants.mjs.map +1 -0
- package/es/tx/builder/field-types.d.ts +62 -0
- package/es/tx/builder/field-types.mjs +126 -0
- package/es/tx/builder/field-types.mjs.map +1 -0
- package/es/tx/builder/helpers.d.ts +131 -0
- package/es/tx/builder/helpers.mjs +223 -0
- package/es/tx/builder/helpers.mjs.map +1 -0
- package/es/tx/builder/index.d.ts +75 -0
- package/es/tx/builder/index.mjs +424 -0
- package/es/tx/builder/index.mjs.map +1 -0
- package/es/tx/builder/schema.d.ts +350 -0
- package/es/tx/builder/schema.mjs +320 -0
- package/es/tx/builder/schema.mjs.map +1 -0
- package/es/tx/index.d.ts +63 -0
- package/es/tx/index.mjs +209 -0
- package/es/tx/index.mjs.map +1 -0
- package/es/tx/min-fee.d.ts +20 -0
- package/es/tx/min-fee.mjs +148 -0
- package/es/tx/min-fee.mjs.map +1 -0
- package/es/tx/validator.d.ts +19 -0
- package/es/tx/validator.mjs +240 -0
- package/es/tx/validator.mjs.map +1 -0
- 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 +2 -0
- package/es/typings/blakejs/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.js → amount-formatter.mjs} +38 -44
- package/es/utils/amount-formatter.mjs.map +1 -0
- 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 +23 -0
- package/es/utils/bignumber.mjs.map +1 -0
- package/es/{bytes.d.ts → utils/bytes.d.ts} +10 -13
- package/es/utils/{bytes.js → bytes.mjs} +26 -22
- package/es/utils/bytes.mjs.map +1 -0
- package/es/utils/crypto.d.ts +103 -0
- package/es/utils/crypto.mjs +221 -0
- package/es/utils/crypto.mjs.map +1 -0
- package/es/utils/encoder.d.ts +26 -0
- package/es/utils/encoder.mjs +102 -0
- package/es/utils/encoder.mjs.map +1 -0
- package/es/utils/errors.d.ts +481 -0
- package/es/utils/errors.mjs +882 -0
- package/es/utils/errors.mjs.map +1 -0
- package/es/utils/hd-wallet.d.ts +34 -0
- package/es/utils/hd-wallet.mjs +122 -0
- package/es/utils/hd-wallet.mjs.map +1 -0
- package/es/utils/json-big.d.ts +5 -0
- package/es/utils/json-big.mjs +41 -0
- package/es/utils/json-big.mjs.map +1 -0
- package/es/utils/keystore.d.ts +51 -0
- package/es/utils/keystore.mjs +145 -0
- package/es/utils/keystore.mjs.map +1 -0
- package/es/{mptree.d.ts → utils/mptree.d.ts} +5 -8
- package/es/utils/{mptree.js → mptree.mjs} +33 -25
- package/es/utils/mptree.mjs.map +1 -0
- package/es/utils/other.d.ts +14 -0
- package/es/utils/other.mjs +28 -0
- package/es/utils/other.mjs.map +1 -0
- package/es/{semver-satisfies.d.ts → utils/semver-satisfies.d.ts} +0 -0
- package/es/utils/{semver-satisfies.js → semver-satisfies.mjs} +1 -1
- package/es/utils/semver-satisfies.mjs.map +1 -0
- package/es/utils/string.d.ts +24 -0
- package/es/utils/{string.js → string.mjs} +9 -11
- package/es/utils/string.mjs.map +1 -0
- package/package.json +67 -64
- package/src/AeSdk.ts +65 -0
- package/src/AeSdkAepp.ts +167 -0
- package/src/AeSdkBase.ts +320 -0
- package/src/AeSdkWallet.ts +332 -0
- package/src/Node.ts +167 -0
- package/src/account/Base.ts +114 -0
- package/src/account/Memory.ts +83 -0
- package/src/account/Rpc.ts +67 -0
- package/src/aens.ts +391 -0
- package/src/aepp-wallet-communication/connection/Browser.ts +68 -0
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +58 -0
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +111 -0
- package/{es/utils/crypto-ts.js → src/aepp-wallet-communication/connection-proxy.ts} +16 -9
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +137 -0
- package/src/aepp-wallet-communication/rpc/types.ts +66 -0
- package/src/aepp-wallet-communication/schema.ts +181 -0
- package/src/aepp-wallet-communication/wallet-detector.ts +71 -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 +10046 -0
- package/src/apis/node/index.ts +2 -0
- package/src/apis/node/models/index.ts +1253 -0
- package/src/apis/node/models/mappers.ts +4278 -0
- package/src/apis/node/models/parameters.ts +188 -0
- package/src/apis/node/node.ts +1299 -0
- package/src/chain.ts +444 -0
- package/src/channel/{handlers.js → handlers.ts} +238 -143
- package/src/channel/index.ts +991 -0
- package/src/channel/internal.ts +345 -0
- package/src/contract/Compiler.ts +66 -0
- package/src/contract/aci.ts +529 -0
- package/src/contract/ga.ts +178 -0
- package/src/contract/methods.ts +118 -0
- package/src/index.ts +51 -0
- package/src/oracle.ts +342 -0
- package/src/spend.ts +152 -0
- package/src/tx/builder/constants.ts +96 -0
- package/src/tx/builder/field-types.ts +111 -0
- package/src/tx/builder/helpers.ts +253 -0
- package/src/tx/builder/index.ts +394 -0
- package/src/tx/builder/schema.ts +771 -0
- package/src/tx/index.ts +199 -0
- package/src/tx/min-fee.ts +136 -0
- package/src/tx/validator.ts +226 -0
- package/src/typings/@aeternity__argon2-browser/index.d.ts +3 -0
- package/src/typings/@aeternity__uuid/index.d.ts +3 -0
- package/src/typings/bip32-path/index.d.ts +33 -0
- package/src/typings/tweetnacl-auth/index.d.ts +14 -0
- package/src/utils/amount-formatter.ts +29 -41
- package/src/utils/autorest.ts +90 -0
- package/src/utils/bignumber.ts +9 -19
- package/src/utils/bytes.ts +15 -16
- package/src/utils/crypto.ts +217 -0
- package/src/utils/encoder.ts +98 -0
- package/src/utils/errors.ts +817 -0
- package/src/utils/hd-wallet.ts +134 -0
- package/src/utils/json-big.ts +26 -0
- package/src/utils/keystore.ts +179 -0
- package/src/utils/mptree.ts +26 -20
- package/src/utils/other.ts +28 -43
- package/src/utils/string.ts +8 -10
- package/CHANGELOG.md +0 -1603
- package/es/account/base.js +0 -169
- package/es/account/base.js.map +0 -1
- package/es/account/memory.js +0 -84
- package/es/account/memory.js.map +0 -1
- package/es/account/multiple.js +0 -178
- package/es/account/multiple.js.map +0 -1
- package/es/ae/aens.js +0 -408
- package/es/ae/aens.js.map +0 -1
- package/es/ae/aepp.js +0 -45
- package/es/ae/aepp.js.map +0 -1
- package/es/ae/contract.js +0 -312
- package/es/ae/contract.js.map +0 -1
- package/es/ae/index.js +0 -206
- package/es/ae/index.js.map +0 -1
- package/es/ae/oracle.js +0 -322
- package/es/ae/oracle.js.map +0 -1
- package/es/ae/universal.js +0 -45
- package/es/ae/universal.js.map +0 -1
- package/es/ae/wallet.js +0 -50
- package/es/ae/wallet.js.map +0 -1
- package/es/amount-formatter.d.ts +0 -58
- package/es/bignumber.d.ts +0 -24
- package/es/chain/index.js +0 -256
- package/es/chain/index.js.map +0 -1
- package/es/chain/node.js +0 -394
- package/es/chain/node.js.map +0 -1
- package/es/channel/handlers.js.map +0 -1
- package/es/channel/index.js +0 -980
- package/es/channel/index.js.map +0 -1
- package/es/channel/internal.js +0 -266
- package/es/channel/internal.js.map +0 -1
- package/es/contract/aci/helpers.js +0 -298
- package/es/contract/aci/helpers.js.map +0 -1
- package/es/contract/aci/index.js +0 -361
- package/es/contract/aci/index.js.map +0 -1
- package/es/contract/aci/transformation.js +0 -66
- package/es/contract/aci/transformation.js.map +0 -1
- package/es/contract/compiler.js +0 -244
- package/es/contract/compiler.js.map +0 -1
- package/es/contract/ga/helpers.js +0 -22
- package/es/contract/ga/helpers.js.map +0 -1
- package/es/contract/ga/index.js +0 -170
- package/es/contract/ga/index.js.map +0 -1
- package/es/contract/index.js +0 -162
- package/es/contract/index.js.map +0 -1
- package/es/crypto-ts.d.ts +0 -9
- package/es/index.js +0 -57
- package/es/index.js.map +0 -1
- package/es/node-pool/index.js +0 -187
- package/es/node-pool/index.js.map +0 -1
- package/es/node.js +0 -132
- package/es/node.js.map +0 -1
- package/es/other.d.ts +0 -31
- package/es/string.d.ts +0 -26
- package/es/tx/builder/helpers.js +0 -305
- package/es/tx/builder/helpers.js.map +0 -1
- package/es/tx/builder/index.js +0 -595
- package/es/tx/builder/index.js.map +0 -1
- package/es/tx/builder/schema.js +0 -814
- package/es/tx/builder/schema.js.map +0 -1
- package/es/tx/index.js +0 -300
- package/es/tx/index.js.map +0 -1
- package/es/tx/tx-object.js +0 -276
- package/es/tx/tx-object.js.map +0 -1
- package/es/tx/tx.js +0 -937
- package/es/tx/tx.js.map +0 -1
- package/es/tx/validator.js +0 -208
- package/es/tx/validator.js.map +0 -1
- package/es/typings/blakejs/index.d.js +0 -2
- package/es/typings/blakejs/index.d.js.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -131
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -184
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/index.js +0 -84
- package/es/utils/aepp-wallet-communication/connection/index.js.map +0 -1
- package/es/utils/aepp-wallet-communication/content-script-bridge.js +0 -97
- package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +0 -1
- package/es/utils/aepp-wallet-communication/helpers.js +0 -103
- package/es/utils/aepp-wallet-communication/helpers.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -329
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -270
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -533
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +0 -1
- package/es/utils/aepp-wallet-communication/schema.js +0 -107
- package/es/utils/aepp-wallet-communication/schema.js.map +0 -1
- package/es/utils/aepp-wallet-communication/wallet-detector.js +0 -109
- package/es/utils/aepp-wallet-communication/wallet-detector.js.map +0 -1
- package/es/utils/amount-formatter.js.map +0 -1
- package/es/utils/async-init.js +0 -67
- package/es/utils/async-init.js.map +0 -1
- package/es/utils/bignumber.js +0 -28
- package/es/utils/bignumber.js.map +0 -1
- package/es/utils/bytes.js.map +0 -1
- package/es/utils/crypto-ts.js.map +0 -1
- package/es/utils/crypto.js +0 -304
- package/es/utils/crypto.js.map +0 -1
- package/es/utils/hd-wallet.js +0 -112
- package/es/utils/hd-wallet.js.map +0 -1
- package/es/utils/json-big.js +0 -45
- package/es/utils/json-big.js.map +0 -1
- package/es/utils/keystore.js +0 -228
- package/es/utils/keystore.js.map +0 -1
- package/es/utils/mptree.js.map +0 -1
- package/es/utils/other.js +0 -43
- package/es/utils/other.js.map +0 -1
- package/es/utils/semver-satisfies.js.map +0 -1
- package/es/utils/string.js.map +0 -1
- package/es/utils/swagger.js +0 -132
- package/es/utils/swagger.js.map +0 -1
- package/src/account/base.js +0 -153
- package/src/account/memory.js +0 -78
- package/src/account/multiple.js +0 -154
- package/src/ae/aens.js +0 -366
- package/src/ae/aepp.js +0 -45
- package/src/ae/contract.js +0 -285
- package/src/ae/index.js +0 -167
- package/src/ae/oracle.js +0 -296
- package/src/ae/universal.js +0 -47
- package/src/ae/wallet.js +0 -50
- package/src/chain/index.js +0 -250
- package/src/chain/node.js +0 -293
- package/src/channel/index.js +0 -898
- package/src/channel/internal.js +0 -231
- package/src/contract/aci/index.js +0 -317
- package/src/contract/aci/transformation.js +0 -72
- package/src/contract/compiler.js +0 -195
- package/src/contract/ga/helpers.js +0 -17
- package/src/contract/ga/index.js +0 -147
- package/src/contract/index.js +0 -163
- package/src/index.js +0 -90
- package/src/node-pool/index.js +0 -171
- package/src/node.js +0 -118
- package/src/tx/builder/helpers.js +0 -325
- package/src/tx/builder/index.js +0 -460
- package/src/tx/builder/schema.js +0 -1211
- package/src/tx/index.js +0 -301
- package/src/tx/tx-object.js +0 -186
- package/src/tx/tx.js +0 -622
- package/src/tx/validator.js +0 -161
- package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -114
- package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -161
- package/src/utils/aepp-wallet-communication/connection/index.js +0 -85
- package/src/utils/aepp-wallet-communication/content-script-bridge.js +0 -85
- package/src/utils/aepp-wallet-communication/helpers.js +0 -70
- package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -268
- package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -223
- package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -390
- package/src/utils/aepp-wallet-communication/schema.js +0 -108
- package/src/utils/aepp-wallet-communication/wallet-detector.js +0 -91
- package/src/utils/async-init.js +0 -41
- package/src/utils/crypto.js +0 -312
- package/src/utils/hd-wallet.js +0 -115
- package/src/utils/json-big.js +0 -26
- package/src/utils/keystore.js +0 -223
- package/src/utils/swagger.js +0 -133
package/es/string.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert string from snake_case to PascalCase
|
|
3
|
-
* @rtype (s: String) => String
|
|
4
|
-
* @param {String} s - String to convert
|
|
5
|
-
* @return {String} Converted string
|
|
6
|
-
*/
|
|
7
|
-
export declare function snakeToPascal(s: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Convert string from PascalCase to snake_case
|
|
10
|
-
* @rtype (s: String) => String
|
|
11
|
-
* @param {String} s - String to convert
|
|
12
|
-
* @return {String} Converted string
|
|
13
|
-
*/
|
|
14
|
-
export declare function pascalToSnake(s: string): string;
|
|
15
|
-
/**
|
|
16
|
-
* Check whether a string is valid hex.
|
|
17
|
-
* @param {string} str String to validate.
|
|
18
|
-
* @return {boolean} True if the string is valid hex, false otherwise.
|
|
19
|
-
*/
|
|
20
|
-
export declare function isHex(str: string): boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Check whether a string is valid base-64.
|
|
23
|
-
* @param {string} str String to validate.
|
|
24
|
-
* @return {boolean} True if the string is valid base-64, false otherwise.
|
|
25
|
-
*/
|
|
26
|
-
export declare function isBase64(str: string): boolean;
|
package/es/tx/builder/helpers.js
DELETED
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
import _T from "ramda/src/T";
|
|
2
|
-
import _lte from "ramda/src/lte";
|
|
3
|
-
import _always from "ramda/src/always";
|
|
4
|
-
import _lt from "ramda/src/lt";
|
|
5
|
-
import _cond from "ramda/src/cond";
|
|
6
|
-
import BigNumber from 'bignumber.js';
|
|
7
|
-
import { decodeBase58Check, decodeBase64Check, encodeBase58Check, encodeBase64Check, hash, salt } from '../../utils/crypto';
|
|
8
|
-
import { toBytes } from '../../utils/bytes';
|
|
9
|
-
import { ID_TAG_PREFIX, PREFIX_ID_TAG, NAME_BID_RANGES, NAME_BID_MAX_LENGTH, NAME_FEE, NAME_FEE_BID_INCREMENT, NAME_BID_TIMEOUTS, NAME_MAX_LENGTH_FEE, POINTER_KEY_BY_PREFIX } from './schema';
|
|
10
|
-
import { ceil } from '../../utils/bignumber';
|
|
11
|
-
/**
|
|
12
|
-
* JavaScript-based Transaction builder helper function's
|
|
13
|
-
* @module @aeternity/aepp-sdk/es/tx/builder/helpers
|
|
14
|
-
* @export TxBuilderHelper
|
|
15
|
-
* @example import { TxBuilderHelper } from '@aeternity/aepp-sdk'
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
export const createSalt = salt;
|
|
19
|
-
const base64Types = ['tx', 'st', 'ss', 'pi', 'ov', 'or', 'cb', 'cs', 'ba'];
|
|
20
|
-
/**
|
|
21
|
-
* Build a contract public key
|
|
22
|
-
* @function
|
|
23
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
24
|
-
* @param {string} ownerId The public key of the owner account
|
|
25
|
-
* @param {number} nonce the nonce of the transaction
|
|
26
|
-
* @return {string} Contract public key
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
export function buildContractId(ownerId, nonce) {
|
|
30
|
-
const ownerIdAndNonce = Buffer.from([...decode(ownerId, 'ak'), ...toBytes(nonce)]);
|
|
31
|
-
const b2bHash = hash(ownerIdAndNonce);
|
|
32
|
-
return encode(b2bHash, 'ct');
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Build a oracle query id
|
|
36
|
-
* @function
|
|
37
|
-
* @function* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
38
|
-
* @param {String} senderId The public key of the sender account
|
|
39
|
-
* @param {Number} nonce the nonce of the transaction
|
|
40
|
-
* @param {Number} oracleId The oracle public key
|
|
41
|
-
* @return {string} Contract public key
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
export function oracleQueryId(senderId, nonce, oracleId) {
|
|
45
|
-
function _int32(val) {
|
|
46
|
-
const nonceBE = toBytes(val, true);
|
|
47
|
-
return Buffer.concat([Buffer.alloc(32 - nonceBE.length), nonceBE]);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const b2bHash = hash(Buffer.from([...decode(senderId, 'ak'), ..._int32(nonce), ...decode(oracleId, 'ok')]));
|
|
51
|
-
return encode(b2bHash, 'oq');
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Format the salt into a 64-byte hex string
|
|
55
|
-
* @function
|
|
56
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
57
|
-
* @param {number} salt
|
|
58
|
-
* @return {string} Zero-padded hex string of salt
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
export function formatSalt(salt) {
|
|
62
|
-
return Buffer.from(salt.toString(16).padStart(64, '0'), 'hex');
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Encode a domain name
|
|
66
|
-
* @function
|
|
67
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
68
|
-
* @param {String} name Name to encode
|
|
69
|
-
* @return {String} `nm_` prefixed encoded domain name
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
export function produceNameId(name) {
|
|
73
|
-
ensureNameValid(name);
|
|
74
|
-
return encode(hash(name.toLowerCase()), 'nm');
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Generate the commitment hash by hashing the formatted salt and
|
|
78
|
-
* name, base 58 encoding the result and prepending 'cm_'
|
|
79
|
-
*
|
|
80
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
81
|
-
* @function commitmentHash
|
|
82
|
-
* @category async
|
|
83
|
-
* @rtype (name: String, salt?: String) => hash: Promise[String]
|
|
84
|
-
* @param {String} name - Name to be registered
|
|
85
|
-
* @param {Number} salt Random salt
|
|
86
|
-
* @return {String} Commitment hash
|
|
87
|
-
*/
|
|
88
|
-
|
|
89
|
-
export function commitmentHash(name) {
|
|
90
|
-
let salt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createSalt();
|
|
91
|
-
ensureNameValid(name);
|
|
92
|
-
return `cm_${encodeBase58Check(hash(Buffer.concat([Buffer.from(name.toLowerCase()), formatSalt(salt)])))}`;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Decode data using the default encoding/decoding algorithm
|
|
96
|
-
* @function
|
|
97
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
98
|
-
* @param {string} data An Base58/64check encoded and prefixed string (ex tx_..., sg_..., ak_....)
|
|
99
|
-
* @param {string} [requiredPrefix] Ensure that data have this prefix
|
|
100
|
-
* @return {Buffer} Decoded data
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
export function decode(data, requiredPrefix) {
|
|
104
|
-
const [prefix, payload, extra] = data.split('_');
|
|
105
|
-
if (!payload) throw new Error(`Encoded string missing payload: ${data}`);
|
|
106
|
-
if (extra) throw new Error(`Encoded string have extra parts: ${data}`);
|
|
107
|
-
|
|
108
|
-
if (requiredPrefix && requiredPrefix !== prefix) {
|
|
109
|
-
throw new Error(`Encoded string have a wrong type: ${prefix} (expected: ${requiredPrefix})`);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return (base64Types.includes(prefix) ? decodeBase64Check : decodeBase58Check)(payload);
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Encode data using the default encoding/decoding algorithm
|
|
116
|
-
* @function
|
|
117
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
118
|
-
* @param {Buffer|String} data An decoded data
|
|
119
|
-
* @param {string} type Prefix of Transaction
|
|
120
|
-
* @return {String} Encoded string Base58check or Base64check data
|
|
121
|
-
*/
|
|
122
|
-
|
|
123
|
-
export function encode(data, type) {
|
|
124
|
-
return `${type}_${base64Types.includes(type) ? encodeBase64Check(data) : encodeBase58Check(data)}`;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Utility function to create and _id type
|
|
128
|
-
* @function
|
|
129
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
130
|
-
* @param {string} hashId Encoded hash
|
|
131
|
-
* @return {Buffer} Buffer Buffer with ID tag and decoded HASh
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
|
-
export function writeId(hashId) {
|
|
135
|
-
if (typeof hashId !== 'string') {
|
|
136
|
-
throw new Error(`Address should be a string, got ${hashId} instead`);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const prefix = hashId.slice(0, 2);
|
|
140
|
-
const idTag = PREFIX_ID_TAG[prefix];
|
|
141
|
-
if (!idTag) throw new Error(`Id tag for prefix ${prefix} not found.`);
|
|
142
|
-
return Buffer.from([...toBytes(idTag), ...decode(hashId, prefix)]);
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Utility function to read and _id type
|
|
146
|
-
* @function
|
|
147
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
148
|
-
* @param {Buffer} buf Data
|
|
149
|
-
* @return {String} Encoided hash string with prefix
|
|
150
|
-
*/
|
|
151
|
-
|
|
152
|
-
export function readId(buf) {
|
|
153
|
-
const tag = buf.readUIntBE(0, 1);
|
|
154
|
-
const prefix = ID_TAG_PREFIX[tag];
|
|
155
|
-
if (!prefix) throw new Error(`Prefix for id-tag ${tag} not found.`);
|
|
156
|
-
return encode(buf.slice(1, buf.length), prefix);
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Utility function to convert int to bytes
|
|
160
|
-
* @function
|
|
161
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
162
|
-
* @param {Number|String|BigNumber} val Value
|
|
163
|
-
* @return {Buffer} Buffer Buffer from number(BigEndian)
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
export function writeInt(val) {
|
|
167
|
-
return toBytes(val, true);
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Utility function to convert bytes to int
|
|
171
|
-
* @function
|
|
172
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
173
|
-
* @param {Buffer} buf Value
|
|
174
|
-
* @return {String} Buffer Buffer from number(BigEndian)
|
|
175
|
-
*/
|
|
176
|
-
|
|
177
|
-
export function readInt() {
|
|
178
|
-
let buf = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Buffer.from([]);
|
|
179
|
-
return BigNumber(buf.toString('hex'), 16).toString(10);
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Helper function to build pointers for name update TX
|
|
183
|
-
* @function
|
|
184
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
185
|
-
* @param {Array} pointers - Array of pointers
|
|
186
|
-
* ([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])
|
|
187
|
-
* @return {Array} Serialized pointers array
|
|
188
|
-
*/
|
|
189
|
-
|
|
190
|
-
export function buildPointers(pointers) {
|
|
191
|
-
return pointers.map(p => [toBytes(p.key), writeId(p.id)]);
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Helper function to read pointers from name update TX
|
|
195
|
-
* @function
|
|
196
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
197
|
-
* @param {Array} pointers - Array of pointers
|
|
198
|
-
* ([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])
|
|
199
|
-
* @return {Array} Deserialize pointer array
|
|
200
|
-
*/
|
|
201
|
-
|
|
202
|
-
export function readPointers(pointers) {
|
|
203
|
-
return pointers.map(_ref => {
|
|
204
|
-
let [key, id] = _ref;
|
|
205
|
-
return Object.assign({
|
|
206
|
-
key: key.toString(),
|
|
207
|
-
id: readId(id)
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Ensure that name is valid
|
|
213
|
-
* @function
|
|
214
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
215
|
-
* @param {string} name
|
|
216
|
-
* @return void
|
|
217
|
-
* @throws Error
|
|
218
|
-
*/
|
|
219
|
-
|
|
220
|
-
export function ensureNameValid(name) {
|
|
221
|
-
if (!name || typeof name !== 'string') throw new Error('Name must be a string');
|
|
222
|
-
if (!name.endsWith('.chain')) throw new Error(`Name should end with .chain: ${name}`);
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Is name valid
|
|
226
|
-
* @function
|
|
227
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
228
|
-
* @param {string} name
|
|
229
|
-
* @return Boolean
|
|
230
|
-
*/
|
|
231
|
-
|
|
232
|
-
export function isNameValid(name) {
|
|
233
|
-
try {
|
|
234
|
-
ensureNameValid(name);
|
|
235
|
-
return true;
|
|
236
|
-
} catch (error) {
|
|
237
|
-
return false;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* @param identifier - account/oracle/contract address, or channel
|
|
242
|
-
* @returns {String} default AENS pointer key
|
|
243
|
-
* @throws exception when default key not defined
|
|
244
|
-
*/
|
|
245
|
-
|
|
246
|
-
export function getDefaultPointerKey(identifier) {
|
|
247
|
-
decode(identifier);
|
|
248
|
-
const prefix = identifier.substr(0, 2);
|
|
249
|
-
return POINTER_KEY_BY_PREFIX[prefix] || (() => {
|
|
250
|
-
throw new Error(`Default AENS pointer key is not defined for ${prefix} prefix`);
|
|
251
|
-
})();
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Get the minimum name fee for a domain
|
|
255
|
-
* @function
|
|
256
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
257
|
-
* @param {String} domain the domain name to get the fee for
|
|
258
|
-
* @return {String} the minimum fee for the domain auction
|
|
259
|
-
*/
|
|
260
|
-
|
|
261
|
-
export function getMinimumNameFee(domain) {
|
|
262
|
-
const nameLength = domain.replace('.chain', '').length;
|
|
263
|
-
return NAME_BID_RANGES[nameLength >= NAME_MAX_LENGTH_FEE ? NAME_MAX_LENGTH_FEE : nameLength];
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Compute bid fee for AENS auction
|
|
267
|
-
* @function
|
|
268
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
269
|
-
* @param {String} domain the domain name to get the fee for
|
|
270
|
-
* @param {Number|String} startFee Auction start fee
|
|
271
|
-
* @param {Number} [increment=0.5] Bid multiplier(In percentage, must be between 0 and 1)
|
|
272
|
-
* @return {String} Bid fee
|
|
273
|
-
*/
|
|
274
|
-
|
|
275
|
-
export function computeBidFee(domain) {
|
|
276
|
-
let startFee = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NAME_FEE;
|
|
277
|
-
let increment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : NAME_FEE_BID_INCREMENT;
|
|
278
|
-
if (!(Number(increment) === increment && increment % 1 !== 0)) throw new Error(`Increment must be float. Current increment ${increment}`);
|
|
279
|
-
if (increment < NAME_FEE_BID_INCREMENT) throw new Error(`minimum increment percentage is ${NAME_FEE_BID_INCREMENT}`);
|
|
280
|
-
return ceil(BigNumber(BigNumber(startFee).eq(NAME_FEE) ? getMinimumNameFee(domain) : startFee).times(BigNumber(NAME_FEE_BID_INCREMENT).plus(1)));
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Compute auction end height
|
|
284
|
-
* @function
|
|
285
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
286
|
-
* @param {String} domain the domain name to get the fee for
|
|
287
|
-
* @param {Number|String} claimHeight Auction starting height
|
|
288
|
-
* @return {String} Auction end height
|
|
289
|
-
*/
|
|
290
|
-
|
|
291
|
-
export function computeAuctionEndBlock(domain, claimHeight) {
|
|
292
|
-
return _cond([[_lt(5), _always(NAME_BID_TIMEOUTS[4].plus(claimHeight))], [_lt(9), _always(NAME_BID_TIMEOUTS[8].plus(claimHeight))], [_lte(NAME_BID_MAX_LENGTH), _always(NAME_BID_TIMEOUTS[12].plus(claimHeight))], [_T, _always(BigNumber(claimHeight))]])(domain.replace('.chain', '').length).toString(10);
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Is name accept going to auction
|
|
296
|
-
* @function
|
|
297
|
-
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
298
|
-
* @param {String} name Transaction abiVersion
|
|
299
|
-
* @return {Boolean}
|
|
300
|
-
*/
|
|
301
|
-
|
|
302
|
-
export function isAuctionName(name) {
|
|
303
|
-
return name.replace('.chain', '').length < 13;
|
|
304
|
-
}
|
|
305
|
-
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/tx/builder/helpers.js"],"names":["BigNumber","decodeBase58Check","decodeBase64Check","encodeBase58Check","encodeBase64Check","hash","salt","toBytes","ID_TAG_PREFIX","PREFIX_ID_TAG","NAME_BID_RANGES","NAME_BID_MAX_LENGTH","NAME_FEE","NAME_FEE_BID_INCREMENT","NAME_BID_TIMEOUTS","NAME_MAX_LENGTH_FEE","POINTER_KEY_BY_PREFIX","ceil","createSalt","base64Types","buildContractId","ownerId","nonce","ownerIdAndNonce","Buffer","from","decode","b2bHash","encode","oracleQueryId","senderId","oracleId","_int32","val","nonceBE","concat","alloc","length","formatSalt","toString","padStart","produceNameId","name","ensureNameValid","toLowerCase","commitmentHash","data","requiredPrefix","prefix","payload","extra","split","Error","includes","type","writeId","hashId","slice","idTag","readId","buf","tag","readUIntBE","writeInt","readInt","buildPointers","pointers","map","p","key","id","readPointers","Object","assign","endsWith","isNameValid","error","getDefaultPointerKey","identifier","substr","getMinimumNameFee","domain","nameLength","replace","computeBidFee","startFee","increment","Number","eq","times","plus","computeAuctionEndBlock","claimHeight","isAuctionName"],"mappings":";;;;;AACA,OAAOA,SAAP,MAAsB,cAAtB;AAEA,SACEC,iBADF,EAEEC,iBAFF,EAGEC,iBAHF,EAGqBC,iBAHrB,EAIEC,IAJF,EAKEC,IALF,QAMO,oBANP;AAOA,SAASC,OAAT,QAAwB,mBAAxB;AACA,SACEC,aADF,EAEEC,aAFF,EAGEC,eAHF,EAIEC,mBAJF,EAKEC,QALF,EAMEC,sBANF,EAOEC,iBAPF,EAQEC,mBARF,EASEC,qBATF,QAUO,UAVP;AAWA,SAASC,IAAT,QAAqB,uBAArB;AAEA;AACA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L1C,CAAP;AAMD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASsD,aAAT,CAAwBnD,IAAxB,EAA8B;AACnC,SAAOA,IAAI,CAACyC,OAAL,CAAa,QAAb,EAAuB,EAAvB,EAA2B9C,MAA3B,GAAoC,EAA3C;AACD","sourcesContent":["import * as R from 'ramda'\nimport BigNumber from 'bignumber.js'\n\nimport {\n decodeBase58Check,\n decodeBase64Check,\n encodeBase58Check, encodeBase64Check,\n hash,\n salt\n} from '../../utils/crypto'\nimport { toBytes } from '../../utils/bytes'\nimport {\n ID_TAG_PREFIX,\n PREFIX_ID_TAG,\n NAME_BID_RANGES,\n NAME_BID_MAX_LENGTH,\n NAME_FEE,\n NAME_FEE_BID_INCREMENT,\n NAME_BID_TIMEOUTS,\n NAME_MAX_LENGTH_FEE,\n POINTER_KEY_BY_PREFIX\n} from './schema'\nimport { ceil } from '../../utils/bignumber'\n\n/**\n * JavaScript-based Transaction builder helper function's\n * @module @aeternity/aepp-sdk/es/tx/builder/helpers\n * @export TxBuilderHelper\n * @example import { TxBuilderHelper } from '@aeternity/aepp-sdk'\n */\n\nexport const createSalt = salt\n\nconst base64Types = ['tx', 'st', 'ss', 'pi', 'ov', 'or', 'cb', 'cs', 'ba']\n\n/**\n * Build a contract public key\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {string} ownerId The public key of the owner account\n * @param {number} nonce the nonce of the transaction\n * @return {string} Contract public key\n */\nexport function buildContractId (ownerId, nonce) {\n const ownerIdAndNonce = Buffer.from([...decode(ownerId, 'ak'), ...toBytes(nonce)])\n const b2bHash = hash(ownerIdAndNonce)\n return encode(b2bHash, 'ct')\n}\n\n/**\n * Build a oracle query id\n * @function\n * @function* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {String} senderId The public key of the sender account\n * @param {Number} nonce the nonce of the transaction\n * @param {Number} oracleId The oracle public key\n * @return {string} Contract public key\n */\nexport function oracleQueryId (senderId, nonce, oracleId) {\n function _int32 (val) {\n const nonceBE = toBytes(val, true)\n return Buffer.concat([Buffer.alloc(32 - nonceBE.length), nonceBE])\n }\n\n const b2bHash = hash(Buffer.from([...decode(senderId, 'ak'), ..._int32(nonce), ...decode(oracleId, 'ok')]))\n return encode(b2bHash, 'oq')\n}\n\n/**\n * Format the salt into a 64-byte hex string\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {number} salt\n * @return {string} Zero-padded hex string of salt\n */\nexport function formatSalt (salt) {\n return Buffer.from(salt.toString(16).padStart(64, '0'), 'hex')\n}\n\n/**\n * Encode a domain name\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {String} name Name to encode\n * @return {String} `nm_` prefixed encoded domain name\n */\nexport function produceNameId (name) {\n ensureNameValid(name)\n return encode(hash(name.toLowerCase()), 'nm')\n}\n\n/**\n * Generate the commitment hash by hashing the formatted salt and\n * name, base 58 encoding the result and prepending 'cm_'\n *\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @function commitmentHash\n * @category async\n * @rtype (name: String, salt?: String) => hash: Promise[String]\n * @param {String} name - Name to be registered\n * @param {Number} salt Random salt\n * @return {String} Commitment hash\n */\nexport function commitmentHash (name, salt = createSalt()) {\n ensureNameValid(name)\n return `cm_${encodeBase58Check(hash(Buffer.concat([Buffer.from(name.toLowerCase()), formatSalt(salt)])))}`\n}\n\n/**\n * Decode data using the default encoding/decoding algorithm\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {string} data An Base58/64check encoded and prefixed string (ex tx_..., sg_..., ak_....)\n * @param {string} [requiredPrefix] Ensure that data have this prefix\n * @return {Buffer} Decoded data\n */\nexport function decode (data, requiredPrefix) {\n const [prefix, payload, extra] = data.split('_')\n if (!payload) throw new Error(`Encoded string missing payload: ${data}`)\n if (extra) throw new Error(`Encoded string have extra parts: ${data}`)\n if (requiredPrefix && requiredPrefix !== prefix) {\n throw new Error(`Encoded string have a wrong type: ${prefix} (expected: ${requiredPrefix})`)\n }\n return (base64Types.includes(prefix) ? decodeBase64Check : decodeBase58Check)(payload)\n}\n\n/**\n * Encode data using the default encoding/decoding algorithm\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {Buffer|String} data An decoded data\n * @param {string} type Prefix of Transaction\n * @return {String} Encoded string Base58check or Base64check data\n */\nexport function encode (data, type) {\n return `${type}_${base64Types.includes(type)\n ? encodeBase64Check(data)\n : encodeBase58Check(data)}`\n}\n\n/**\n * Utility function to create and _id type\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {string} hashId Encoded hash\n * @return {Buffer} Buffer Buffer with ID tag and decoded HASh\n */\nexport function writeId (hashId) {\n if (typeof hashId !== 'string') {\n throw new Error(`Address should be a string, got ${hashId} instead`)\n }\n const prefix = hashId.slice(0, 2)\n const idTag = PREFIX_ID_TAG[prefix]\n if (!idTag) throw new Error(`Id tag for prefix ${prefix} not found.`)\n return Buffer.from([...toBytes(idTag), ...decode(hashId, prefix)])\n}\n\n/**\n * Utility function to read and _id type\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {Buffer} buf Data\n * @return {String} Encoided hash string with prefix\n */\nexport function readId (buf) {\n const tag = buf.readUIntBE(0, 1)\n const prefix = ID_TAG_PREFIX[tag]\n if (!prefix) throw new Error(`Prefix for id-tag ${tag} not found.`)\n return encode(buf.slice(1, buf.length), prefix)\n}\n\n/**\n * Utility function to convert int to bytes\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {Number|String|BigNumber} val Value\n * @return {Buffer} Buffer Buffer from number(BigEndian)\n */\nexport function writeInt (val) {\n return toBytes(val, true)\n}\n\n/**\n * Utility function to convert bytes to int\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {Buffer} buf Value\n * @return {String} Buffer Buffer from number(BigEndian)\n */\nexport function readInt (buf = Buffer.from([])) {\n return BigNumber(buf.toString('hex'), 16).toString(10)\n}\n\n/**\n * Helper function to build pointers for name update TX\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {Array} pointers - Array of pointers\n * ([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])\n * @return {Array} Serialized pointers array\n */\nexport function buildPointers (pointers) {\n return pointers.map(\n p => [\n toBytes(p.key),\n writeId(p.id)\n ]\n )\n}\n\n/**\n * Helper function to read pointers from name update TX\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {Array} pointers - Array of pointers\n * ([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])\n * @return {Array} Deserialize pointer array\n */\nexport function readPointers (pointers) {\n return pointers.map(\n ([key, id]) => Object.assign({\n key: key.toString(),\n id: readId(id)\n })\n )\n}\n\n/**\n * Ensure that name is valid\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {string} name\n * @return void\n * @throws Error\n */\nexport function ensureNameValid (name) {\n if (!name || typeof name !== 'string') throw new Error('Name must be a string')\n if (!name.endsWith('.chain')) throw new Error(`Name should end with .chain: ${name}`)\n}\n\n/**\n * Is name valid\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {string} name\n * @return Boolean\n */\nexport function isNameValid (name) {\n try {\n ensureNameValid(name)\n return true\n } catch (error) {\n return false\n }\n}\n\n/**\n * @param identifier - account/oracle/contract address, or channel\n * @returns {String} default AENS pointer key\n * @throws exception when default key not defined\n */\nexport function getDefaultPointerKey (identifier) {\n decode(identifier)\n const prefix = identifier.substr(0, 2)\n return POINTER_KEY_BY_PREFIX[prefix] ||\n (() => { throw new Error(`Default AENS pointer key is not defined for ${prefix} prefix`) })()\n}\n\n/**\n * Get the minimum name fee for a domain\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {String} domain the domain name to get the fee for\n * @return {String} the minimum fee for the domain auction\n */\nexport function getMinimumNameFee (domain) {\n const nameLength = domain.replace('.chain', '').length\n return NAME_BID_RANGES[nameLength >= NAME_MAX_LENGTH_FEE ? NAME_MAX_LENGTH_FEE : nameLength]\n}\n\n/**\n * Compute bid fee for AENS auction\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {String} domain the domain name to get the fee for\n * @param {Number|String} startFee Auction start fee\n * @param {Number} [increment=0.5] Bid multiplier(In percentage, must be between 0 and 1)\n * @return {String} Bid fee\n */\nexport function computeBidFee (domain, startFee = NAME_FEE, increment = NAME_FEE_BID_INCREMENT) {\n if (!(Number(increment) === increment && increment % 1 !== 0)) throw new Error(`Increment must be float. Current increment ${increment}`)\n if (increment < NAME_FEE_BID_INCREMENT) throw new Error(`minimum increment percentage is ${NAME_FEE_BID_INCREMENT}`)\n return ceil(\n BigNumber(BigNumber(startFee).eq(NAME_FEE) ? getMinimumNameFee(domain) : startFee)\n .times(BigNumber(NAME_FEE_BID_INCREMENT).plus(1))\n )\n}\n\n/**\n * Compute auction end height\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {String} domain the domain name to get the fee for\n * @param {Number|String} claimHeight Auction starting height\n * @return {String} Auction end height\n */\nexport function computeAuctionEndBlock (domain, claimHeight) {\n return R.cond([\n [R.lt(5), R.always(NAME_BID_TIMEOUTS[4].plus(claimHeight))],\n [R.lt(9), R.always(NAME_BID_TIMEOUTS[8].plus(claimHeight))],\n [R.lte(NAME_BID_MAX_LENGTH), R.always(NAME_BID_TIMEOUTS[12].plus(claimHeight))],\n [R.T, R.always(BigNumber(claimHeight))]\n ])(domain.replace('.chain', '').length).toString(10)\n}\n\n/**\n * Is name accept going to auction\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {String} name Transaction abiVersion\n * @return {Boolean}\n */\nexport function isAuctionName (name) {\n return name.replace('.chain', '').length < 13\n}\n"],"file":"helpers.js"}
|