@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/src/ae/aens.js
DELETED
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* ISC License (ISC)
|
|
3
|
-
* Copyright (c) 2018 aeternity developers
|
|
4
|
-
*
|
|
5
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
* purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
* copyright notice and this permission notice appear in all copies.
|
|
8
|
-
*
|
|
9
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
-
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
-
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
-
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
-
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
-
* PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Aens module - routines to interact with the æternity naming system
|
|
20
|
-
*
|
|
21
|
-
* The high-level description of the naming system is
|
|
22
|
-
* https://github.com/aeternity/protocol/blob/master/AENS.md in the protocol
|
|
23
|
-
* repository.
|
|
24
|
-
* @module @aeternity/aepp-sdk/es/ae/aens
|
|
25
|
-
* @export Aens
|
|
26
|
-
* @example import { Aens } from '@aeternity/aepp-sdk'
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
import { salt } from '../utils/crypto'
|
|
30
|
-
import {
|
|
31
|
-
commitmentHash, ensureNameValid, getMinimumNameFee, isAuctionName, encode, produceNameId
|
|
32
|
-
} from '../tx/builder/helpers'
|
|
33
|
-
import Ae from './'
|
|
34
|
-
import { CLIENT_TTL, NAME_FEE, NAME_TTL } from '../tx/builder/schema'
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Revoke a name
|
|
38
|
-
* @instance
|
|
39
|
-
* @function
|
|
40
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/aens
|
|
41
|
-
* @category async
|
|
42
|
-
* @param {String} name Name hash
|
|
43
|
-
* @param {Object} [options={}] options
|
|
44
|
-
* @param {String|Object} [options.onAccount] Make operation on specific account from sdk (you pass
|
|
45
|
-
* publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
|
|
46
|
-
* @param {Number|String|BigNumber} [options.fee] fee
|
|
47
|
-
* @param {Number|String|BigNumber} [options.ttl] ttl
|
|
48
|
-
* @param {Number|String|BigNumber} [options.nonce] nonce
|
|
49
|
-
* @return {Promise<Object>} Transaction result
|
|
50
|
-
* @example
|
|
51
|
-
* const name = 'test.chain'
|
|
52
|
-
* const nameObject = await sdkInstance.aensQuery(name)
|
|
53
|
-
*
|
|
54
|
-
* await sdkInstance.aensRevoke(name, { fee, ttl , nonce })
|
|
55
|
-
* // or
|
|
56
|
-
* await nameObject.revoke({ fee, ttl, nonce })
|
|
57
|
-
*/
|
|
58
|
-
async function revoke (name, options = {}) {
|
|
59
|
-
ensureNameValid(name)
|
|
60
|
-
const opt = { ...this.Ae.defaults, ...options }
|
|
61
|
-
|
|
62
|
-
const nameRevokeTx = await this.nameRevokeTx({
|
|
63
|
-
...opt,
|
|
64
|
-
nameId: produceNameId(name),
|
|
65
|
-
accountId: await this.address(opt)
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
return this.send(nameRevokeTx, opt)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Update a name
|
|
73
|
-
* @instance
|
|
74
|
-
* @function
|
|
75
|
-
* @category async
|
|
76
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/aens
|
|
77
|
-
* @param {String} name AENS name
|
|
78
|
-
* @param {Object.<string, string>} pointers Map of pointer keys to corresponding addresses
|
|
79
|
-
* @param {Object} [options={}]
|
|
80
|
-
* @param {Boolean} [options.extendPointers] Get the pointers from the node and merge with provided
|
|
81
|
-
* ones. Pointers with the same type will be overwritten
|
|
82
|
-
* @param {String|Object} [options.onAccount] Make operation on specific account from sdk (you
|
|
83
|
-
* pass publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
|
|
84
|
-
* @param {Number|String|BigNumber} [options.fee] fee
|
|
85
|
-
* @param {Number|String|BigNumber} [options.ttl] ttl
|
|
86
|
-
* @param {Number|String|BigNumber} [options.nonce] nonce
|
|
87
|
-
* @param {Number|String|BigNumber} [options.nameTtl=50000] Name ttl represented in number of
|
|
88
|
-
* blocks (Max value is 50000 blocks)
|
|
89
|
-
* @param {Number|String|BigNumber} [options.clientTtl=84600] a suggestion as to how long any
|
|
90
|
-
* clients should cache this information
|
|
91
|
-
* @return {Promise<Object>}
|
|
92
|
-
* @throws Invalid pointer array error
|
|
93
|
-
* @example
|
|
94
|
-
* const name = 'test.chain'
|
|
95
|
-
* const pointersArray = ['ak_asd23dasdas...,' 'ct_asdf34fasdasd...']
|
|
96
|
-
* const nameObject = await sdkInstance.aensQuery(name)
|
|
97
|
-
*
|
|
98
|
-
* await sdkInstance.aensUpdate(name, pointersArray, { nameTtl, ttl, fee, nonce, clientTtl })
|
|
99
|
-
* // or
|
|
100
|
-
* await nameObject.update(pointers, { nameTtl, ttl, fee, nonce, clientTtl })
|
|
101
|
-
*/
|
|
102
|
-
async function update (name, pointers = {}, options = {}) {
|
|
103
|
-
ensureNameValid(name)
|
|
104
|
-
const opt = { ...this.Ae.defaults, ...options }
|
|
105
|
-
const allPointers = {
|
|
106
|
-
...options.extendPointers && Object.fromEntries(
|
|
107
|
-
(await this.getName(name)).pointers.map(({ key, id }) => [key, id])
|
|
108
|
-
),
|
|
109
|
-
...pointers
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const nameUpdateTx = await this.nameUpdateTx({
|
|
113
|
-
...opt,
|
|
114
|
-
nameId: produceNameId(name),
|
|
115
|
-
accountId: await this.address(opt),
|
|
116
|
-
pointers: Object.entries(allPointers).map(([key, id]) => ({ key, id }))
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
return this.send(nameUpdateTx, opt)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Transfer a domain to another account
|
|
124
|
-
* @instance
|
|
125
|
-
* @function
|
|
126
|
-
* @category async
|
|
127
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/aens
|
|
128
|
-
* @param {String} name AENS name
|
|
129
|
-
* @param {String} account Recipient account publick key
|
|
130
|
-
* @param {Object} [options={}]
|
|
131
|
-
* @param {String|Object} [options.onAccount] Make operation on specific account from sdk (you pass
|
|
132
|
-
* publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
|
|
133
|
-
* @param {Number|String|BigNumber} [options.fee] fee
|
|
134
|
-
* @param {Number|String|BigNumber} [options.ttl] ttl
|
|
135
|
-
* @param {Number|String|BigNumber} [options.nonce] nonce
|
|
136
|
-
* @return {Promise<Object>} Transaction result
|
|
137
|
-
* @example
|
|
138
|
-
* const name = 'test.chain'
|
|
139
|
-
* const recipientPub = 'ak_asd23dasdas...'
|
|
140
|
-
* const nameObject = await sdkInstance.aensQuery(name)
|
|
141
|
-
*
|
|
142
|
-
* await sdkInstance.aensTransfer(name, recipientPub, { ttl, fee, nonce })
|
|
143
|
-
* // or
|
|
144
|
-
* await nameObject.transfer(recipientPub, { ttl, fee, nonce })
|
|
145
|
-
*/
|
|
146
|
-
async function transfer (name, account, options = {}) {
|
|
147
|
-
ensureNameValid(name)
|
|
148
|
-
const opt = { ...this.Ae.defaults, ...options }
|
|
149
|
-
|
|
150
|
-
const nameTransferTx = await this.nameTransferTx({
|
|
151
|
-
...opt,
|
|
152
|
-
nameId: produceNameId(name),
|
|
153
|
-
accountId: await this.address(opt),
|
|
154
|
-
recipientId: account
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
return this.send(nameTransferTx, opt)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Query the AENS name info from the node
|
|
162
|
-
* and return the object with info and predefined functions for manipulating name
|
|
163
|
-
* @instance
|
|
164
|
-
* @function
|
|
165
|
-
* @category async
|
|
166
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/aens
|
|
167
|
-
* @param {String} name
|
|
168
|
-
* @param {Object} opt Options
|
|
169
|
-
* @return {Promise<Object>}
|
|
170
|
-
* @example
|
|
171
|
-
* const nameObject = sdkInstance.aensQuery('test.chain')
|
|
172
|
-
* console.log(nameObject)
|
|
173
|
-
* {
|
|
174
|
-
* id, // name hash
|
|
175
|
-
* pointers, // array of pointers
|
|
176
|
-
* update, // Update name function
|
|
177
|
-
* extendTtl, // Extend Ttl name function
|
|
178
|
-
* transfer, // Transfer name function
|
|
179
|
-
* revoke // Revoke name function
|
|
180
|
-
* }
|
|
181
|
-
*/
|
|
182
|
-
async function query (name, opt = {}) {
|
|
183
|
-
ensureNameValid(name)
|
|
184
|
-
const o = await this.getName(name)
|
|
185
|
-
|
|
186
|
-
return Object.freeze(Object.assign(o, {
|
|
187
|
-
pointers: o.pointers || [],
|
|
188
|
-
update: async (pointers, options = {}) => {
|
|
189
|
-
return {
|
|
190
|
-
...(await this.aensUpdate(name, pointers, { ...opt, ...options })),
|
|
191
|
-
...(await this.aensQuery(name))
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
transfer: async (account, options = {}) => {
|
|
195
|
-
return {
|
|
196
|
-
...(await this.aensTransfer(name, account, { ...opt, ...options })),
|
|
197
|
-
...(await this.aensQuery(name))
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
revoke: async (options = {}) => this.aensRevoke(name, { ...opt, ...options }),
|
|
201
|
-
extendTtl: async (nameTtl = NAME_TTL, options = {}) => {
|
|
202
|
-
if (!nameTtl || typeof nameTtl !== 'number' || nameTtl > NAME_TTL) throw new Error('Ttl must be an number and less then 180000 blocks')
|
|
203
|
-
|
|
204
|
-
return {
|
|
205
|
-
...await this.aensUpdate(name, {}, { ...opt, ...options, nameTtl, extendPointers: true }),
|
|
206
|
-
...await this.aensQuery(name)
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}))
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Claim a previously preclaimed registration. This can only be done after the
|
|
214
|
-
* preclaim step
|
|
215
|
-
* @instance
|
|
216
|
-
* @function
|
|
217
|
-
* @category async
|
|
218
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/aens
|
|
219
|
-
* @param {String} name
|
|
220
|
-
* @param {Number} salt Salt from pre-claim, or 0 if it's a bid
|
|
221
|
-
* @param {Object} [options] options
|
|
222
|
-
* @param {String|Object} [options.onAccount] Make operation on specific account from sdk (you pass
|
|
223
|
-
* publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
|
|
224
|
-
* @param {Number|String|BigNumber} [options.fee] fee
|
|
225
|
-
* @param {Number|String|BigNumber} [options.ttl] ttl
|
|
226
|
-
* @param {Number|String|BigNumber} [options.nonce] nonce
|
|
227
|
-
* @param {Number|String} [options.nameFee] Name Fee (By default calculated by sdk)
|
|
228
|
-
* @return {Promise<Object>} the result of the claim
|
|
229
|
-
* @example
|
|
230
|
-
* const name = 'test.chain'
|
|
231
|
-
* const salt = preclaimResult.salt // salt from pre-claim transaction
|
|
232
|
-
*
|
|
233
|
-
* await sdkInstance.aensClaim(name, salt, { ttl, fee, nonce, nameFee })
|
|
234
|
-
*/
|
|
235
|
-
async function claim (name, salt, options) {
|
|
236
|
-
ensureNameValid(name)
|
|
237
|
-
const opt = { ...this.Ae.defaults, ...options }
|
|
238
|
-
|
|
239
|
-
const minNameFee = getMinimumNameFee(name)
|
|
240
|
-
if (opt.nameFee !== this.Ae.defaults.nameFee && minNameFee.gt(opt.nameFee)) {
|
|
241
|
-
throw new Error(`the provided fee ${opt.nameFee} is not enough to execute the claim, required: ${minNameFee}`)
|
|
242
|
-
}
|
|
243
|
-
opt.nameFee = opt.nameFee !== this.Ae.defaults.nameFee ? opt.nameFee : minNameFee
|
|
244
|
-
const claimTx = await this.nameClaimTx({
|
|
245
|
-
...opt,
|
|
246
|
-
accountId: await this.address(opt),
|
|
247
|
-
nameSalt: salt,
|
|
248
|
-
name: encode(name, 'nm')
|
|
249
|
-
})
|
|
250
|
-
|
|
251
|
-
const result = await this.send(claimTx, opt)
|
|
252
|
-
if (!isAuctionName(name)) {
|
|
253
|
-
const nameInter = opt.waitMined ? await this.aensQuery(name, opt) : {}
|
|
254
|
-
return Object.assign(result, nameInter)
|
|
255
|
-
}
|
|
256
|
-
return { ...result, nameFee: opt.nameFee }
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Preclaim a name. Sends a hash of the name and a random salt to the node
|
|
261
|
-
* @instance
|
|
262
|
-
* @function
|
|
263
|
-
* @category async
|
|
264
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/aens
|
|
265
|
-
* @param {String} name
|
|
266
|
-
* @param {Object} [options={}]
|
|
267
|
-
* @param {String|Object} [options.onAccount] Make operation on specific account from sdk (you pass
|
|
268
|
-
* publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
|
|
269
|
-
* @param {Number|String|BigNumber} [options.fee] fee
|
|
270
|
-
* @param {Number|String|BigNumber} [options.ttl] ttl
|
|
271
|
-
* @param {Number|String|BigNumber} [options.nonce] nonce
|
|
272
|
-
* @return {Promise<Object>}
|
|
273
|
-
* @example
|
|
274
|
-
* const name = 'test.chain'
|
|
275
|
-
* const salt = preclaimResult.salt // salt from pre-claim transaction
|
|
276
|
-
*
|
|
277
|
-
* await sdkInstance.aensPreclaim(name, { ttl, fee, nonce })
|
|
278
|
-
* {
|
|
279
|
-
* ...transactionResult,
|
|
280
|
-
* claim, // Claim function (options={}) => claimTransactionResult
|
|
281
|
-
* salt,
|
|
282
|
-
* commitmentId
|
|
283
|
-
* }
|
|
284
|
-
*/
|
|
285
|
-
async function preclaim (name, options = {}) {
|
|
286
|
-
ensureNameValid(name)
|
|
287
|
-
const opt = { ...this.Ae.defaults, ...options }
|
|
288
|
-
const _salt = salt()
|
|
289
|
-
const height = await this.height()
|
|
290
|
-
const commitmentId = commitmentHash(name, _salt)
|
|
291
|
-
|
|
292
|
-
const preclaimTx = await this.namePreclaimTx({
|
|
293
|
-
...opt,
|
|
294
|
-
accountId: await this.address(opt),
|
|
295
|
-
commitmentId
|
|
296
|
-
})
|
|
297
|
-
|
|
298
|
-
const result = await this.send(preclaimTx, opt)
|
|
299
|
-
|
|
300
|
-
return Object.freeze({
|
|
301
|
-
...result,
|
|
302
|
-
height,
|
|
303
|
-
claim: options => this.aensClaim(name, _salt, { ...options, onAccount: opt.onAccount }),
|
|
304
|
-
salt: _salt,
|
|
305
|
-
commitmentId
|
|
306
|
-
})
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Bid to name auction
|
|
311
|
-
* @instance
|
|
312
|
-
* @function
|
|
313
|
-
* @category async
|
|
314
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/aens
|
|
315
|
-
* @param {String} name Domain name
|
|
316
|
-
* @param {String|Number} nameFee Name fee (bid fee)
|
|
317
|
-
* @param {Object} [options={}]
|
|
318
|
-
* @param {String|Object} [options.onAccount] Make operation on specific account from sdk (you pass
|
|
319
|
-
* publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
|
|
320
|
-
* @param {Number|String|BigNumber} [options.fee] fee
|
|
321
|
-
* @param {Number|String|BigNumber} [options.ttl] ttl
|
|
322
|
-
* @param {Number|String|BigNumber} [options.nonce] nonce
|
|
323
|
-
* @return {Promise<Object>} Transaction result
|
|
324
|
-
* @example
|
|
325
|
-
* const name = 'test.chain'
|
|
326
|
-
* const bidFee = computeBidFee(name, startFee, incrementPercentage)
|
|
327
|
-
*
|
|
328
|
-
* await sdkInstance.aensBid(name, 213109412839123, { ttl, fee, nonce })
|
|
329
|
-
*/
|
|
330
|
-
async function bid (name, nameFee = NAME_FEE, options = {}) {
|
|
331
|
-
return this.aensClaim(name, 0, { ...options, nameFee, vsn: 2 })
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* Aens Stamp
|
|
336
|
-
*
|
|
337
|
-
* Aens provides name-system related methods atop
|
|
338
|
-
* {@link module:@aeternity/aepp-sdk/es/ae--Ae} clients.
|
|
339
|
-
* @function
|
|
340
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/aens
|
|
341
|
-
* @rtype Stamp
|
|
342
|
-
* @param {Object} [options={}] - Initializer object
|
|
343
|
-
* @return {Object} Aens instance
|
|
344
|
-
*/
|
|
345
|
-
const Aens = Ae.compose({
|
|
346
|
-
methods: {
|
|
347
|
-
aensQuery: query,
|
|
348
|
-
aensPreclaim: preclaim,
|
|
349
|
-
aensClaim: claim,
|
|
350
|
-
aensUpdate: update,
|
|
351
|
-
aensTransfer: transfer,
|
|
352
|
-
aensRevoke: revoke,
|
|
353
|
-
aensBid: bid
|
|
354
|
-
},
|
|
355
|
-
deepProps: {
|
|
356
|
-
Ae: {
|
|
357
|
-
defaults: {
|
|
358
|
-
clientTtl: CLIENT_TTL,
|
|
359
|
-
nameTtl: NAME_TTL, // aec_governance:name_claim_max_expiration() => 50000
|
|
360
|
-
nameFee: NAME_FEE
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
})
|
|
365
|
-
|
|
366
|
-
export default Aens
|
package/src/ae/aepp.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* ISC License (ISC)
|
|
3
|
-
* Copyright (c) 2018 aeternity developers
|
|
4
|
-
*
|
|
5
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
* purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
* copyright notice and this permission notice appear in all copies.
|
|
8
|
-
*
|
|
9
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
-
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
-
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
-
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
-
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
-
* PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Aepp module
|
|
20
|
-
* @module @aeternity/aepp-sdk/es/ae/aepp
|
|
21
|
-
* @export Aepp
|
|
22
|
-
* @example import { RpcAepp } from '@aeternity/aepp-sdk'
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import Ae from './'
|
|
26
|
-
import Aens from './aens'
|
|
27
|
-
import { ContractWithCompiler as Contract } from './contract'
|
|
28
|
-
import AeppRpc from '../utils/aepp-wallet-communication/rpc/aepp-rpc'
|
|
29
|
-
import Chain from '../chain/node'
|
|
30
|
-
import Tx from '../tx/tx'
|
|
31
|
-
import Oracle from './oracle'
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Aepp Stamp
|
|
35
|
-
*
|
|
36
|
-
* Aepp provides base functionality.
|
|
37
|
-
* Expected to use this stamp with a Wallet.
|
|
38
|
-
* {@link module:@aeternity/aepp-sdk/es/ae--Ae} clients.
|
|
39
|
-
* @function
|
|
40
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/aepp
|
|
41
|
-
* @rtype Stamp
|
|
42
|
-
* @param {Object} [options={}] - Initializer object
|
|
43
|
-
* @return {Object} Aepp instance
|
|
44
|
-
*/
|
|
45
|
-
export default Ae.compose(Tx, Oracle, Contract, Aens, Chain, AeppRpc)
|
package/src/ae/contract.js
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* ISC License (ISC)
|
|
3
|
-
* Copyright (c) 2018 aeternity developers
|
|
4
|
-
*
|
|
5
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
* purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
* copyright notice and this permission notice appear in all copies.
|
|
8
|
-
*
|
|
9
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
-
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
-
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
-
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
-
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
-
* PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Contract module - routines to interact with the æternity contract
|
|
20
|
-
*
|
|
21
|
-
* High level documentation of the contracts are available at
|
|
22
|
-
* https://github.com/aeternity/protocol/tree/master/contracts and
|
|
23
|
-
*
|
|
24
|
-
* @module @aeternity/aepp-sdk/es/ae/contract
|
|
25
|
-
* @export Contract
|
|
26
|
-
* @example import { Contract } from '@aeternity/aepp-sdk'
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
import Ae from './'
|
|
30
|
-
import ContractCompilerAPI from '../contract/compiler'
|
|
31
|
-
import ContractBase from '../contract'
|
|
32
|
-
import getContractInstance from '../contract/aci'
|
|
33
|
-
import NodePool from '../node-pool'
|
|
34
|
-
import { AMOUNT, DEPOSIT, GAS, MIN_GAS_PRICE } from '../tx/builder/schema'
|
|
35
|
-
import { decode, produceNameId } from '../tx/builder/helpers'
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Static contract call(using dry-run)
|
|
39
|
-
* @function
|
|
40
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/contract
|
|
41
|
-
* @category async
|
|
42
|
-
* @deprecated
|
|
43
|
-
* @param {String} source Contract source code
|
|
44
|
-
* @param {String} contractAddress Contract address
|
|
45
|
-
* @param {String} name Name of function to call
|
|
46
|
-
* @param {Array} args Arguments array for call/deploy transaction
|
|
47
|
-
* @param {Object} [options]
|
|
48
|
-
* @param {Number|String} [options.top] Block height or hash on which you want to call contract
|
|
49
|
-
* @param {String} [options.bytecode] Block hash on which you want to call contract
|
|
50
|
-
* @param {Object} [options.filesystem] Contract external namespaces map
|
|
51
|
-
* @return {Promise<Object>} Result object
|
|
52
|
-
* @example
|
|
53
|
-
* const callResult = await client.contractCallStatic(source, address, fnName, args)
|
|
54
|
-
* {
|
|
55
|
-
* result: TX_DATA,
|
|
56
|
-
* decode: (type) => Decode call result
|
|
57
|
-
* }
|
|
58
|
-
*/
|
|
59
|
-
async function contractCallStatic (source, contractAddress, name, args = [], options) {
|
|
60
|
-
const contract = await this.getContractInstance({ ...options, source, contractAddress })
|
|
61
|
-
return contract.call(name, args, { ...options, callStatic: true })
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Call contract function
|
|
66
|
-
* @function
|
|
67
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/contract
|
|
68
|
-
* @category async
|
|
69
|
-
* @deprecated
|
|
70
|
-
* @param {String} source Contract source code
|
|
71
|
-
* @param {String} contractAddress Contract address or AENS name
|
|
72
|
-
* @param {String} name Name of function to call
|
|
73
|
-
* @param {Array} args Arguments array for call/deploy transaction
|
|
74
|
-
* @param {Object} [options] Transaction options (fee, ttl, gas, amount, deposit)
|
|
75
|
-
* @param {Object} [options.filesystem] Contract external namespaces map
|
|
76
|
-
* @return {Promise<Object>} Result object
|
|
77
|
-
* @example
|
|
78
|
-
* const callResult = await client.contractCall(source, address, fnName, args = [], options)
|
|
79
|
-
* {
|
|
80
|
-
* hash: TX_HASH,
|
|
81
|
-
* result: TX_DATA,
|
|
82
|
-
* decode: (type) => Decode call result
|
|
83
|
-
* }
|
|
84
|
-
*/
|
|
85
|
-
async function contractCall (source, contractAddress, name, args, options) {
|
|
86
|
-
const contract = await this.getContractInstance({ ...options, source, contractAddress })
|
|
87
|
-
return contract.call(name, args, options)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Deploy contract to the node
|
|
92
|
-
* @function
|
|
93
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/contract
|
|
94
|
-
* @category async
|
|
95
|
-
* @deprecated
|
|
96
|
-
* @param {String} code Compiled contract
|
|
97
|
-
* @param {String} source Contract source code
|
|
98
|
-
* @param {Array} params Arguments of contract constructor(init) function. Can be array of
|
|
99
|
-
* arguments or callData string
|
|
100
|
-
* @param {Object} [options] Transaction options (fee, ttl, gas, amount, deposit)
|
|
101
|
-
* @param {Object} [options.filesystem={}] Contract external namespaces map*
|
|
102
|
-
* @return {Promise<Object>} Result object
|
|
103
|
-
* @example
|
|
104
|
-
* const deployed = await client.contractDeploy(bytecode, source, init = [], options)
|
|
105
|
-
* {
|
|
106
|
-
* owner: OWNER_PUB_KEY,
|
|
107
|
-
* transaction: TX_HASH,
|
|
108
|
-
* address: CONTRACT_ADDRESS,
|
|
109
|
-
* createdAt: Date,
|
|
110
|
-
* result: DEPLOY_TX_DATA,
|
|
111
|
-
* call: (fnName, args = [], options) => Call contract function,
|
|
112
|
-
* callStatic: (fnName, args = [], options) => Static all contract function
|
|
113
|
-
* }
|
|
114
|
-
*/
|
|
115
|
-
async function contractDeploy (code, source, params, options) {
|
|
116
|
-
const contract = await this.getContractInstance({ ...options, source })
|
|
117
|
-
contract.bytecode = code
|
|
118
|
-
return contract.deploy(params, options)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Compile contract source code
|
|
123
|
-
* @function
|
|
124
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/contract
|
|
125
|
-
* @category async
|
|
126
|
-
* @param {String} source Contract sourece code
|
|
127
|
-
* @param {Object} [options={}] Transaction options (fee, ttl, gas, amount, deposit)
|
|
128
|
-
* @param {Object} [options.filesystem={}] Contract external namespaces map*
|
|
129
|
-
* @return {Promise<Object>} Result object
|
|
130
|
-
* @example
|
|
131
|
-
* const compiled = await client.contractCompile(SOURCE_CODE)
|
|
132
|
-
* {
|
|
133
|
-
* bytecode: CONTRACT_BYTE_CODE,
|
|
134
|
-
* deploy: (init = [], options = {}) => Deploy Contract,
|
|
135
|
-
* encodeCall: (fnName, args = []) => Prepare callData
|
|
136
|
-
* }
|
|
137
|
-
*/
|
|
138
|
-
async function contractCompile (source, options = {}) {
|
|
139
|
-
const opt = { ...this.Ae.defaults, ...options }
|
|
140
|
-
const bytecode = await this.compileContractAPI(source, options)
|
|
141
|
-
return Object.freeze({
|
|
142
|
-
encodeCall: (name, args) => this.contractEncodeCallDataAPI(source, name, args, opt),
|
|
143
|
-
deploy: (init, options) => this.contractDeploy(bytecode, source, init, { ...opt, ...options }),
|
|
144
|
-
deployStatic: (init, options) => this.contractCallStatic(source, null, 'init', init, {
|
|
145
|
-
...opt,
|
|
146
|
-
...options,
|
|
147
|
-
bytecode
|
|
148
|
-
}),
|
|
149
|
-
bytecode
|
|
150
|
-
})
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Utility method to create a delegate signature for a contract
|
|
155
|
-
* @function
|
|
156
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/contract
|
|
157
|
-
* @category async
|
|
158
|
-
* @param {String[]} ids The list of id's to prepend
|
|
159
|
-
* @param {Object} [opt={}] options
|
|
160
|
-
* @param {{ onAccount: String | Object }} [opt={}] opt Options
|
|
161
|
-
* @return {Promise<String>} Signature in hex representation
|
|
162
|
-
*/
|
|
163
|
-
async function delegateSignatureCommon (ids = [], opt = {}) {
|
|
164
|
-
const signature = await this.sign(
|
|
165
|
-
Buffer.concat([
|
|
166
|
-
Buffer.from(this.getNetworkId(opt)),
|
|
167
|
-
...(Object.prototype.hasOwnProperty.call(opt, 'onAccount') ? [decode(await this.address(opt))] : []),
|
|
168
|
-
...ids.map(e => decode(e))
|
|
169
|
-
]),
|
|
170
|
-
opt
|
|
171
|
-
)
|
|
172
|
-
return Buffer.from(signature).toString('hex')
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Helper to generate a signature to delegate pre-claim/claim/transfer/revoke of a name to
|
|
177
|
-
* a contract.
|
|
178
|
-
* @function
|
|
179
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/contract
|
|
180
|
-
* @category async
|
|
181
|
-
* @param {String} contractId Contract Id
|
|
182
|
-
* @param {String} [name] The name
|
|
183
|
-
* @param {{ onAccount: String | Object }} [opt={}] opt Options
|
|
184
|
-
* @return {Promise<String>} Signature for delegation
|
|
185
|
-
* @example
|
|
186
|
-
* const client = await Universal({ ... })
|
|
187
|
-
* const contractId = 'ct_asd2ks...' // contract address
|
|
188
|
-
* const name = 'example.chain' // AENS name
|
|
189
|
-
* const onAccount = await client.address() // Sign with a specific account
|
|
190
|
-
* // Preclaim signature
|
|
191
|
-
* const params = { contractId }
|
|
192
|
-
* const preclaimSig = await client.createAensDelegationSignature(params, { onAccount: current })
|
|
193
|
-
* // Claim, transfer and revoke signature
|
|
194
|
-
* const params = { contractId, name }
|
|
195
|
-
* const aensDelegationSig = await contract.createAensDelegationSignature(
|
|
196
|
-
* params, name, { onAccount: current }
|
|
197
|
-
* )
|
|
198
|
-
*/
|
|
199
|
-
async function createAensDelegationSignature ({ contractId, name }, opt = {}) {
|
|
200
|
-
return this.delegateSignatureCommon([...name ? [produceNameId(name)] : [], contractId], opt)
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Helper to generate a signature to delegate register/extend/respond of a Oracle to a contract.
|
|
205
|
-
* @function
|
|
206
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/contract
|
|
207
|
-
* @category async
|
|
208
|
-
* @param {String} contractId Contract Id
|
|
209
|
-
* @param {String} [queryId] Oracle Query Id
|
|
210
|
-
* @param {{ onAccount: String | Object }} [opt={}] opt Options
|
|
211
|
-
* @return {Promise<String>} Signature for delegation
|
|
212
|
-
* @example
|
|
213
|
-
* const client = await Universal({ ... })
|
|
214
|
-
* const contractId = 'ct_asd2ks...' // contract address
|
|
215
|
-
* const queryId = 'oq_...' // Oracle Query Id
|
|
216
|
-
* const onAccount = await client.address() // Sign with a specific account
|
|
217
|
-
* // Oracle register and extend signature
|
|
218
|
-
* const params = { contractId }
|
|
219
|
-
* const oracleDelegationSig = await contract.createOracleDelegationSignature(params, { onAccount })
|
|
220
|
-
* // Oracle respond signature
|
|
221
|
-
* const params = { contractId, queryId }
|
|
222
|
-
* const respondSig = await contract.createOracleDelegationSignature(params, queryId)
|
|
223
|
-
*/
|
|
224
|
-
async function createOracleDelegationSignature ({ contractId, queryId }, opt = {}) {
|
|
225
|
-
return this.delegateSignatureCommon([...queryId ? [queryId] : [], contractId], opt)
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Contract Stamp
|
|
230
|
-
*
|
|
231
|
-
* Provide contract implementation
|
|
232
|
-
* {@link module:@aeternity/aepp-sdk/es/ae--Ae} clients.
|
|
233
|
-
* @function
|
|
234
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/contract
|
|
235
|
-
* @rtype Stamp
|
|
236
|
-
* @param {Object} [options={}] - Initializer object
|
|
237
|
-
* @return {Object} Contract instance
|
|
238
|
-
* @example
|
|
239
|
-
* import Transaction from '@aeternity/aepp-sdk/es/tx/tx
|
|
240
|
-
* import MemoryAccount from '@aeternity/aepp-sdk/es/account/memory
|
|
241
|
-
* import ChainNode from '@aeternity/aepp-sdk/es/chain/node
|
|
242
|
-
* import ContractCompilerAPI from '@aeternity/aepp-sdk/es/contract/compiler
|
|
243
|
-
* // or using bundle
|
|
244
|
-
* import {
|
|
245
|
-
* Transaction,
|
|
246
|
-
* MemoryAccount,
|
|
247
|
-
* ChainNode,
|
|
248
|
-
* ContractCompilerAPI
|
|
249
|
-
* } from '@aeternity/aepp-sdk
|
|
250
|
-
*
|
|
251
|
-
* const ContractWithAE = await Contract
|
|
252
|
-
* .compose(Transaction, MemoryAccount, ChainNode) // AE implementation
|
|
253
|
-
* .compose(ContractCompilerAPI) // ContractBase implementation
|
|
254
|
-
* const client = await ContractWithAe({ url, internalUrl, compilerUrl, keypair, ... })
|
|
255
|
-
*
|
|
256
|
-
*/
|
|
257
|
-
export const ContractAPI = Ae.compose(ContractBase, {
|
|
258
|
-
methods: {
|
|
259
|
-
getContractInstance,
|
|
260
|
-
contractCompile,
|
|
261
|
-
contractCallStatic,
|
|
262
|
-
contractDeploy,
|
|
263
|
-
contractCall,
|
|
264
|
-
// Delegation for contract
|
|
265
|
-
delegateSignatureCommon,
|
|
266
|
-
// AENS
|
|
267
|
-
createAensDelegationSignature,
|
|
268
|
-
// Oracle
|
|
269
|
-
createOracleDelegationSignature
|
|
270
|
-
},
|
|
271
|
-
deepProps: {
|
|
272
|
-
Ae: {
|
|
273
|
-
defaults: {
|
|
274
|
-
deposit: DEPOSIT,
|
|
275
|
-
gasPrice: MIN_GAS_PRICE,
|
|
276
|
-
amount: AMOUNT,
|
|
277
|
-
gas: GAS
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
})
|
|
282
|
-
|
|
283
|
-
export const Contract = ContractAPI.compose(NodePool)
|
|
284
|
-
export const ContractWithCompiler = Contract.compose(ContractCompilerAPI)
|
|
285
|
-
export default ContractWithCompiler
|