@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/ae/contract.js
DELETED
|
@@ -1,312 +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
|
-
import Ae from './';
|
|
29
|
-
import ContractCompilerAPI from '../contract/compiler';
|
|
30
|
-
import ContractBase from '../contract';
|
|
31
|
-
import getContractInstance from '../contract/aci';
|
|
32
|
-
import NodePool from '../node-pool';
|
|
33
|
-
import { AMOUNT, DEPOSIT, GAS, MIN_GAS_PRICE } from '../tx/builder/schema';
|
|
34
|
-
import { decode, produceNameId } from '../tx/builder/helpers';
|
|
35
|
-
/**
|
|
36
|
-
* Static contract call(using dry-run)
|
|
37
|
-
* @function
|
|
38
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/contract
|
|
39
|
-
* @category async
|
|
40
|
-
* @deprecated
|
|
41
|
-
* @param {String} source Contract source code
|
|
42
|
-
* @param {String} contractAddress Contract address
|
|
43
|
-
* @param {String} name Name of function to call
|
|
44
|
-
* @param {Array} args Arguments array for call/deploy transaction
|
|
45
|
-
* @param {Object} [options]
|
|
46
|
-
* @param {Number|String} [options.top] Block height or hash on which you want to call contract
|
|
47
|
-
* @param {String} [options.bytecode] Block hash on which you want to call contract
|
|
48
|
-
* @param {Object} [options.filesystem] Contract external namespaces map
|
|
49
|
-
* @return {Promise<Object>} Result object
|
|
50
|
-
* @example
|
|
51
|
-
* const callResult = await client.contractCallStatic(source, address, fnName, args)
|
|
52
|
-
* {
|
|
53
|
-
* result: TX_DATA,
|
|
54
|
-
* decode: (type) => Decode call result
|
|
55
|
-
* }
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
async function contractCallStatic(source, contractAddress, name) {
|
|
59
|
-
let args = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
60
|
-
let options = arguments.length > 4 ? arguments[4] : undefined;
|
|
61
|
-
const contract = await this.getContractInstance({ ...options,
|
|
62
|
-
source,
|
|
63
|
-
contractAddress
|
|
64
|
-
});
|
|
65
|
-
return contract.call(name, args, { ...options,
|
|
66
|
-
callStatic: true
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Call contract function
|
|
71
|
-
* @function
|
|
72
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/contract
|
|
73
|
-
* @category async
|
|
74
|
-
* @deprecated
|
|
75
|
-
* @param {String} source Contract source code
|
|
76
|
-
* @param {String} contractAddress Contract address or AENS name
|
|
77
|
-
* @param {String} name Name of function to call
|
|
78
|
-
* @param {Array} args Arguments array for call/deploy transaction
|
|
79
|
-
* @param {Object} [options] Transaction options (fee, ttl, gas, amount, deposit)
|
|
80
|
-
* @param {Object} [options.filesystem] Contract external namespaces map
|
|
81
|
-
* @return {Promise<Object>} Result object
|
|
82
|
-
* @example
|
|
83
|
-
* const callResult = await client.contractCall(source, address, fnName, args = [], options)
|
|
84
|
-
* {
|
|
85
|
-
* hash: TX_HASH,
|
|
86
|
-
* result: TX_DATA,
|
|
87
|
-
* decode: (type) => Decode call result
|
|
88
|
-
* }
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
async function contractCall(source, contractAddress, name, args, options) {
|
|
93
|
-
const contract = await this.getContractInstance({ ...options,
|
|
94
|
-
source,
|
|
95
|
-
contractAddress
|
|
96
|
-
});
|
|
97
|
-
return contract.call(name, args, options);
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Deploy contract to the node
|
|
101
|
-
* @function
|
|
102
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/contract
|
|
103
|
-
* @category async
|
|
104
|
-
* @deprecated
|
|
105
|
-
* @param {String} code Compiled contract
|
|
106
|
-
* @param {String} source Contract source code
|
|
107
|
-
* @param {Array} params Arguments of contract constructor(init) function. Can be array of
|
|
108
|
-
* arguments or callData string
|
|
109
|
-
* @param {Object} [options] Transaction options (fee, ttl, gas, amount, deposit)
|
|
110
|
-
* @param {Object} [options.filesystem={}] Contract external namespaces map*
|
|
111
|
-
* @return {Promise<Object>} Result object
|
|
112
|
-
* @example
|
|
113
|
-
* const deployed = await client.contractDeploy(bytecode, source, init = [], options)
|
|
114
|
-
* {
|
|
115
|
-
* owner: OWNER_PUB_KEY,
|
|
116
|
-
* transaction: TX_HASH,
|
|
117
|
-
* address: CONTRACT_ADDRESS,
|
|
118
|
-
* createdAt: Date,
|
|
119
|
-
* result: DEPLOY_TX_DATA,
|
|
120
|
-
* call: (fnName, args = [], options) => Call contract function,
|
|
121
|
-
* callStatic: (fnName, args = [], options) => Static all contract function
|
|
122
|
-
* }
|
|
123
|
-
*/
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
async function contractDeploy(code, source, params, options) {
|
|
127
|
-
const contract = await this.getContractInstance({ ...options,
|
|
128
|
-
source
|
|
129
|
-
});
|
|
130
|
-
contract.bytecode = code;
|
|
131
|
-
return contract.deploy(params, options);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Compile contract source code
|
|
135
|
-
* @function
|
|
136
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/contract
|
|
137
|
-
* @category async
|
|
138
|
-
* @param {String} source Contract sourece code
|
|
139
|
-
* @param {Object} [options={}] Transaction options (fee, ttl, gas, amount, deposit)
|
|
140
|
-
* @param {Object} [options.filesystem={}] Contract external namespaces map*
|
|
141
|
-
* @return {Promise<Object>} Result object
|
|
142
|
-
* @example
|
|
143
|
-
* const compiled = await client.contractCompile(SOURCE_CODE)
|
|
144
|
-
* {
|
|
145
|
-
* bytecode: CONTRACT_BYTE_CODE,
|
|
146
|
-
* deploy: (init = [], options = {}) => Deploy Contract,
|
|
147
|
-
* encodeCall: (fnName, args = []) => Prepare callData
|
|
148
|
-
* }
|
|
149
|
-
*/
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
async function contractCompile(source) {
|
|
153
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
154
|
-
const opt = { ...this.Ae.defaults,
|
|
155
|
-
...options
|
|
156
|
-
};
|
|
157
|
-
const bytecode = await this.compileContractAPI(source, options);
|
|
158
|
-
return Object.freeze({
|
|
159
|
-
encodeCall: (name, args) => this.contractEncodeCallDataAPI(source, name, args, opt),
|
|
160
|
-
deploy: (init, options) => this.contractDeploy(bytecode, source, init, { ...opt,
|
|
161
|
-
...options
|
|
162
|
-
}),
|
|
163
|
-
deployStatic: (init, options) => this.contractCallStatic(source, null, 'init', init, { ...opt,
|
|
164
|
-
...options,
|
|
165
|
-
bytecode
|
|
166
|
-
}),
|
|
167
|
-
bytecode
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Utility method to create a delegate signature for a contract
|
|
172
|
-
* @function
|
|
173
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/contract
|
|
174
|
-
* @category async
|
|
175
|
-
* @param {String[]} ids The list of id's to prepend
|
|
176
|
-
* @param {Object} [opt={}] options
|
|
177
|
-
* @param {{ onAccount: String | Object }} [opt={}] opt Options
|
|
178
|
-
* @return {Promise<String>} Signature in hex representation
|
|
179
|
-
*/
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
async function delegateSignatureCommon() {
|
|
183
|
-
let ids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
184
|
-
let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
185
|
-
const signature = await this.sign(Buffer.concat([Buffer.from(this.getNetworkId(opt)), ...(Object.prototype.hasOwnProperty.call(opt, 'onAccount') ? [decode(await this.address(opt))] : []), ...ids.map(e => decode(e))]), opt);
|
|
186
|
-
return Buffer.from(signature).toString('hex');
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Helper to generate a signature to delegate pre-claim/claim/transfer/revoke of a name to
|
|
190
|
-
* a contract.
|
|
191
|
-
* @function
|
|
192
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/contract
|
|
193
|
-
* @category async
|
|
194
|
-
* @param {String} contractId Contract Id
|
|
195
|
-
* @param {String} [name] The name
|
|
196
|
-
* @param {{ onAccount: String | Object }} [opt={}] opt Options
|
|
197
|
-
* @return {Promise<String>} Signature for delegation
|
|
198
|
-
* @example
|
|
199
|
-
* const client = await Universal({ ... })
|
|
200
|
-
* const contractId = 'ct_asd2ks...' // contract address
|
|
201
|
-
* const name = 'example.chain' // AENS name
|
|
202
|
-
* const onAccount = await client.address() // Sign with a specific account
|
|
203
|
-
* // Preclaim signature
|
|
204
|
-
* const params = { contractId }
|
|
205
|
-
* const preclaimSig = await client.createAensDelegationSignature(params, { onAccount: current })
|
|
206
|
-
* // Claim, transfer and revoke signature
|
|
207
|
-
* const params = { contractId, name }
|
|
208
|
-
* const aensDelegationSig = await contract.createAensDelegationSignature(
|
|
209
|
-
* params, name, { onAccount: current }
|
|
210
|
-
* )
|
|
211
|
-
*/
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
async function createAensDelegationSignature(_ref) {
|
|
215
|
-
let {
|
|
216
|
-
contractId,
|
|
217
|
-
name
|
|
218
|
-
} = _ref;
|
|
219
|
-
let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
220
|
-
return this.delegateSignatureCommon([...(name ? [produceNameId(name)] : []), contractId], opt);
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Helper to generate a signature to delegate register/extend/respond of a Oracle to a contract.
|
|
224
|
-
* @function
|
|
225
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/contract
|
|
226
|
-
* @category async
|
|
227
|
-
* @param {String} contractId Contract Id
|
|
228
|
-
* @param {String} [queryId] Oracle Query Id
|
|
229
|
-
* @param {{ onAccount: String | Object }} [opt={}] opt Options
|
|
230
|
-
* @return {Promise<String>} Signature for delegation
|
|
231
|
-
* @example
|
|
232
|
-
* const client = await Universal({ ... })
|
|
233
|
-
* const contractId = 'ct_asd2ks...' // contract address
|
|
234
|
-
* const queryId = 'oq_...' // Oracle Query Id
|
|
235
|
-
* const onAccount = await client.address() // Sign with a specific account
|
|
236
|
-
* // Oracle register and extend signature
|
|
237
|
-
* const params = { contractId }
|
|
238
|
-
* const oracleDelegationSig = await contract.createOracleDelegationSignature(params, { onAccount })
|
|
239
|
-
* // Oracle respond signature
|
|
240
|
-
* const params = { contractId, queryId }
|
|
241
|
-
* const respondSig = await contract.createOracleDelegationSignature(params, queryId)
|
|
242
|
-
*/
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
async function createOracleDelegationSignature(_ref2) {
|
|
246
|
-
let {
|
|
247
|
-
contractId,
|
|
248
|
-
queryId
|
|
249
|
-
} = _ref2;
|
|
250
|
-
let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
251
|
-
return this.delegateSignatureCommon([...(queryId ? [queryId] : []), contractId], opt);
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Contract Stamp
|
|
255
|
-
*
|
|
256
|
-
* Provide contract implementation
|
|
257
|
-
* {@link module:@aeternity/aepp-sdk/es/ae--Ae} clients.
|
|
258
|
-
* @function
|
|
259
|
-
* @alias module:@aeternity/aepp-sdk/es/ae/contract
|
|
260
|
-
* @rtype Stamp
|
|
261
|
-
* @param {Object} [options={}] - Initializer object
|
|
262
|
-
* @return {Object} Contract instance
|
|
263
|
-
* @example
|
|
264
|
-
* import Transaction from '@aeternity/aepp-sdk/es/tx/tx
|
|
265
|
-
* import MemoryAccount from '@aeternity/aepp-sdk/es/account/memory
|
|
266
|
-
* import ChainNode from '@aeternity/aepp-sdk/es/chain/node
|
|
267
|
-
* import ContractCompilerAPI from '@aeternity/aepp-sdk/es/contract/compiler
|
|
268
|
-
* // or using bundle
|
|
269
|
-
* import {
|
|
270
|
-
* Transaction,
|
|
271
|
-
* MemoryAccount,
|
|
272
|
-
* ChainNode,
|
|
273
|
-
* ContractCompilerAPI
|
|
274
|
-
* } from '@aeternity/aepp-sdk
|
|
275
|
-
*
|
|
276
|
-
* const ContractWithAE = await Contract
|
|
277
|
-
* .compose(Transaction, MemoryAccount, ChainNode) // AE implementation
|
|
278
|
-
* .compose(ContractCompilerAPI) // ContractBase implementation
|
|
279
|
-
* const client = await ContractWithAe({ url, internalUrl, compilerUrl, keypair, ... })
|
|
280
|
-
*
|
|
281
|
-
*/
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
export const ContractAPI = Ae.compose(ContractBase, {
|
|
285
|
-
methods: {
|
|
286
|
-
getContractInstance,
|
|
287
|
-
contractCompile,
|
|
288
|
-
contractCallStatic,
|
|
289
|
-
contractDeploy,
|
|
290
|
-
contractCall,
|
|
291
|
-
// Delegation for contract
|
|
292
|
-
delegateSignatureCommon,
|
|
293
|
-
// AENS
|
|
294
|
-
createAensDelegationSignature,
|
|
295
|
-
// Oracle
|
|
296
|
-
createOracleDelegationSignature
|
|
297
|
-
},
|
|
298
|
-
deepProps: {
|
|
299
|
-
Ae: {
|
|
300
|
-
defaults: {
|
|
301
|
-
deposit: DEPOSIT,
|
|
302
|
-
gasPrice: MIN_GAS_PRICE,
|
|
303
|
-
amount: AMOUNT,
|
|
304
|
-
gas: GAS
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
export const Contract = ContractAPI.compose(NodePool);
|
|
310
|
-
export const ContractWithCompiler = Contract.compose(ContractCompilerAPI);
|
|
311
|
-
export default ContractWithCompiler;
|
|
312
|
-
//# sourceMappingURL=contract.js.map
|
package/es/ae/contract.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ae/contract.js"],"names":["Ae","ContractCompilerAPI","ContractBase","getContractInstance","NodePool","AMOUNT","DEPOSIT","GAS","MIN_GAS_PRICE","decode","produceNameId","contractCallStatic","source","contractAddress","name","args","options","contract","call","callStatic","contractCall","contractDeploy","code","params","bytecode","deploy","contractCompile","opt","defaults","compileContractAPI","Object","freeze","encodeCall","contractEncodeCallDataAPI","init","deployStatic","delegateSignatureCommon","ids","signature","sign","Buffer","concat","from","getNetworkId","prototype","hasOwnProperty","address","map","e","toString","createAensDelegationSignature","contractId","createOracleDelegationSignature","queryId","ContractAPI","compose","methods","deepProps","deposit","gasPrice","amount","gas","Contract","ContractWithCompiler"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,EAAP,MAAe,IAAf;AACA,OAAOC,mBAAP,MAAgC,sBAAhC;AACA,OAAOC,YAAP,MAAyB,aAAzB;AACA,OAAOC,mBAAP,MAAgC,iBAAhC;AACA,OAAOC,QAAP,MAAqB,cAArB;AACA,SAASC,MAAT,EAAi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AAED,IAAAA,UAAF;AAAcE,IAAAA;AAAd,GAAmC;AAAA,MAAV1B,GAAU,uEAAJ,EAAI;AACjF,SAAO,KAAKS,uBAAL,CAA6B,CAAC,IAAGiB,OAAO,GAAG,CAACA,OAAD,CAAH,GAAe,EAAzB,CAAD,EAA8BF,UAA9B,CAA7B,EAAwExB,GAAxE,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAM2B,WAAW,GAAGtD,EAAE,CAACuD,OAAH,CAAWrD,YAAX,EAAyB;AAClDsD,EAAAA,OAAO,EAAE;AACPrD,IAAAA,mBADO;AAEPuB,IAAAA,eAFO;AAGPf,IAAAA,kBAHO;AAIPU,IAAAA,cAJO;AAKPD,IAAAA,YALO;AAMP;AACAgB,IAAAA,uBAPO;AAQP;AACAc,IAAAA,6BATO;AAUP;AACAE,IAAAA;AAXO,GADyC;AAclDK,EAAAA,SAAS,EAAE;AACTzD,IAAAA,EAAE,EAAE;AACF4B,MAAAA,QAAQ,EAAE;AACR8B,QAAAA,OAAO,EAAEpD,OADD;AAERqD,QAAAA,QAAQ,EAAEnD,aAFF;AAGRoD,QAAAA,MAAM,EAAEvD,MAHA;AAIRwD,QAAAA,GAAG,EAAEtD;AAJG;AADR;AADK;AAduC,CAAzB,CAApB;AA0BP,OAAO,MAAMuD,QAAQ,GAAGR,WAAW,CAACC,OAAZ,CAAoBnD,QAApB,CAAjB;AACP,OAAO,MAAM2D,oBAAoB,GAAGD,QAAQ,CAACP,OAAT,CAAiBtD,mBAAjB,CAA7B;AACP,eAAe8D,oBAAf","sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2018 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * Contract module - routines to interact with the æternity contract\n *\n * High level documentation of the contracts are available at\n * https://github.com/aeternity/protocol/tree/master/contracts and\n *\n * @module @aeternity/aepp-sdk/es/ae/contract\n * @export Contract\n * @example import { Contract } from '@aeternity/aepp-sdk'\n */\n\nimport Ae from './'\nimport ContractCompilerAPI from '../contract/compiler'\nimport ContractBase from '../contract'\nimport getContractInstance from '../contract/aci'\nimport NodePool from '../node-pool'\nimport { AMOUNT, DEPOSIT, GAS, MIN_GAS_PRICE } from '../tx/builder/schema'\nimport { decode, produceNameId } from '../tx/builder/helpers'\n\n/**\n * Static contract call(using dry-run)\n * @function\n * @alias module:@aeternity/aepp-sdk/es/ae/contract\n * @category async\n * @deprecated\n * @param {String} source Contract source code\n * @param {String} contractAddress Contract address\n * @param {String} name Name of function to call\n * @param {Array} args Arguments array for call/deploy transaction\n * @param {Object} [options]\n * @param {Number|String} [options.top] Block height or hash on which you want to call contract\n * @param {String} [options.bytecode] Block hash on which you want to call contract\n * @param {Object} [options.filesystem] Contract external namespaces map\n * @return {Promise<Object>} Result object\n * @example\n * const callResult = await client.contractCallStatic(source, address, fnName, args)\n * {\n * result: TX_DATA,\n * decode: (type) => Decode call result\n * }\n */\nasync function contractCallStatic (source, contractAddress, name, args = [], options) {\n const contract = await this.getContractInstance({ ...options, source, contractAddress })\n return contract.call(name, args, { ...options, callStatic: true })\n}\n\n/**\n * Call contract function\n * @function\n * @alias module:@aeternity/aepp-sdk/es/ae/contract\n * @category async\n * @deprecated\n * @param {String} source Contract source code\n * @param {String} contractAddress Contract address or AENS name\n * @param {String} name Name of function to call\n * @param {Array} args Arguments array for call/deploy transaction\n * @param {Object} [options] Transaction options (fee, ttl, gas, amount, deposit)\n * @param {Object} [options.filesystem] Contract external namespaces map\n * @return {Promise<Object>} Result object\n * @example\n * const callResult = await client.contractCall(source, address, fnName, args = [], options)\n * {\n * hash: TX_HASH,\n * result: TX_DATA,\n * decode: (type) => Decode call result\n * }\n */\nasync function contractCall (source, contractAddress, name, args, options) {\n const contract = await this.getContractInstance({ ...options, source, contractAddress })\n return contract.call(name, args, options)\n}\n\n/**\n * Deploy contract to the node\n * @function\n * @alias module:@aeternity/aepp-sdk/es/ae/contract\n * @category async\n * @deprecated\n * @param {String} code Compiled contract\n * @param {String} source Contract source code\n * @param {Array} params Arguments of contract constructor(init) function. Can be array of\n * arguments or callData string\n * @param {Object} [options] Transaction options (fee, ttl, gas, amount, deposit)\n * @param {Object} [options.filesystem={}] Contract external namespaces map*\n * @return {Promise<Object>} Result object\n * @example\n * const deployed = await client.contractDeploy(bytecode, source, init = [], options)\n * {\n * owner: OWNER_PUB_KEY,\n * transaction: TX_HASH,\n * address: CONTRACT_ADDRESS,\n * createdAt: Date,\n * result: DEPLOY_TX_DATA,\n * call: (fnName, args = [], options) => Call contract function,\n * callStatic: (fnName, args = [], options) => Static all contract function\n * }\n */\nasync function contractDeploy (code, source, params, options) {\n const contract = await this.getContractInstance({ ...options, source })\n contract.bytecode = code\n return contract.deploy(params, options)\n}\n\n/**\n * Compile contract source code\n * @function\n * @alias module:@aeternity/aepp-sdk/es/ae/contract\n * @category async\n * @param {String} source Contract sourece code\n * @param {Object} [options={}] Transaction options (fee, ttl, gas, amount, deposit)\n * @param {Object} [options.filesystem={}] Contract external namespaces map*\n * @return {Promise<Object>} Result object\n * @example\n * const compiled = await client.contractCompile(SOURCE_CODE)\n * {\n * bytecode: CONTRACT_BYTE_CODE,\n * deploy: (init = [], options = {}) => Deploy Contract,\n * encodeCall: (fnName, args = []) => Prepare callData\n * }\n */\nasync function contractCompile (source, options = {}) {\n const opt = { ...this.Ae.defaults, ...options }\n const bytecode = await this.compileContractAPI(source, options)\n return Object.freeze({\n encodeCall: (name, args) => this.contractEncodeCallDataAPI(source, name, args, opt),\n deploy: (init, options) => this.contractDeploy(bytecode, source, init, { ...opt, ...options }),\n deployStatic: (init, options) => this.contractCallStatic(source, null, 'init', init, {\n ...opt,\n ...options,\n bytecode\n }),\n bytecode\n })\n}\n\n/**\n * Utility method to create a delegate signature for a contract\n * @function\n * @alias module:@aeternity/aepp-sdk/es/ae/contract\n * @category async\n * @param {String[]} ids The list of id's to prepend\n * @param {Object} [opt={}] options\n * @param {{ onAccount: String | Object }} [opt={}] opt Options\n * @return {Promise<String>} Signature in hex representation\n */\nasync function delegateSignatureCommon (ids = [], opt = {}) {\n const signature = await this.sign(\n Buffer.concat([\n Buffer.from(this.getNetworkId(opt)),\n ...(Object.prototype.hasOwnProperty.call(opt, 'onAccount') ? [decode(await this.address(opt))] : []),\n ...ids.map(e => decode(e))\n ]),\n opt\n )\n return Buffer.from(signature).toString('hex')\n}\n\n/**\n * Helper to generate a signature to delegate pre-claim/claim/transfer/revoke of a name to\n * a contract.\n * @function\n * @alias module:@aeternity/aepp-sdk/es/ae/contract\n * @category async\n * @param {String} contractId Contract Id\n * @param {String} [name] The name\n * @param {{ onAccount: String | Object }} [opt={}] opt Options\n * @return {Promise<String>} Signature for delegation\n * @example\n * const client = await Universal({ ... })\n * const contractId = 'ct_asd2ks...' // contract address\n * const name = 'example.chain' // AENS name\n * const onAccount = await client.address() // Sign with a specific account\n * // Preclaim signature\n * const params = { contractId }\n * const preclaimSig = await client.createAensDelegationSignature(params, { onAccount: current })\n * // Claim, transfer and revoke signature\n * const params = { contractId, name }\n * const aensDelegationSig = await contract.createAensDelegationSignature(\n * params, name, { onAccount: current }\n * )\n */\nasync function createAensDelegationSignature ({ contractId, name }, opt = {}) {\n return this.delegateSignatureCommon([...name ? [produceNameId(name)] : [], contractId], opt)\n}\n\n/**\n * Helper to generate a signature to delegate register/extend/respond of a Oracle to a contract.\n * @function\n * @alias module:@aeternity/aepp-sdk/es/ae/contract\n * @category async\n * @param {String} contractId Contract Id\n * @param {String} [queryId] Oracle Query Id\n * @param {{ onAccount: String | Object }} [opt={}] opt Options\n * @return {Promise<String>} Signature for delegation\n * @example\n * const client = await Universal({ ... })\n * const contractId = 'ct_asd2ks...' // contract address\n * const queryId = 'oq_...' // Oracle Query Id\n * const onAccount = await client.address() // Sign with a specific account\n * // Oracle register and extend signature\n * const params = { contractId }\n * const oracleDelegationSig = await contract.createOracleDelegationSignature(params, { onAccount })\n * // Oracle respond signature\n * const params = { contractId, queryId }\n * const respondSig = await contract.createOracleDelegationSignature(params, queryId)\n */\nasync function createOracleDelegationSignature ({ contractId, queryId }, opt = {}) {\n return this.delegateSignatureCommon([...queryId ? [queryId] : [], contractId], opt)\n}\n\n/**\n * Contract Stamp\n *\n * Provide contract implementation\n * {@link module:@aeternity/aepp-sdk/es/ae--Ae} clients.\n * @function\n * @alias module:@aeternity/aepp-sdk/es/ae/contract\n * @rtype Stamp\n * @param {Object} [options={}] - Initializer object\n * @return {Object} Contract instance\n * @example\n * import Transaction from '@aeternity/aepp-sdk/es/tx/tx\n * import MemoryAccount from '@aeternity/aepp-sdk/es/account/memory\n * import ChainNode from '@aeternity/aepp-sdk/es/chain/node\n * import ContractCompilerAPI from '@aeternity/aepp-sdk/es/contract/compiler\n * // or using bundle\n * import {\n * Transaction,\n * MemoryAccount,\n * ChainNode,\n * ContractCompilerAPI\n * } from '@aeternity/aepp-sdk\n *\n * const ContractWithAE = await Contract\n * .compose(Transaction, MemoryAccount, ChainNode) // AE implementation\n * .compose(ContractCompilerAPI) // ContractBase implementation\n * const client = await ContractWithAe({ url, internalUrl, compilerUrl, keypair, ... })\n *\n */\nexport const ContractAPI = Ae.compose(ContractBase, {\n methods: {\n getContractInstance,\n contractCompile,\n contractCallStatic,\n contractDeploy,\n contractCall,\n // Delegation for contract\n delegateSignatureCommon,\n // AENS\n createAensDelegationSignature,\n // Oracle\n createOracleDelegationSignature\n },\n deepProps: {\n Ae: {\n defaults: {\n deposit: DEPOSIT,\n gasPrice: MIN_GAS_PRICE,\n amount: AMOUNT,\n gas: GAS\n }\n }\n }\n})\n\nexport const Contract = ContractAPI.compose(NodePool)\nexport const ContractWithCompiler = Contract.compose(ContractCompilerAPI)\nexport default ContractWithCompiler\n"],"file":"contract.js"}
|
package/es/ae/index.js
DELETED
|
@@ -1,206 +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
|
-
* Ae module
|
|
20
|
-
* @module @aeternity/aepp-sdk/es/ae
|
|
21
|
-
* @export Ae
|
|
22
|
-
* @example import { Ae } from '@aeternity/aepp-sdk'
|
|
23
|
-
*/
|
|
24
|
-
import stampit from '@stamp/it';
|
|
25
|
-
import Tx from '../tx';
|
|
26
|
-
import Chain from '../chain';
|
|
27
|
-
import AccountBase from '../account/base';
|
|
28
|
-
import TxBuilder from '../tx/builder';
|
|
29
|
-
import BigNumber from 'bignumber.js';
|
|
30
|
-
import { AE_AMOUNT_FORMATS } from '../utils/amount-formatter';
|
|
31
|
-
/**
|
|
32
|
-
* Sign and post a transaction to the chain
|
|
33
|
-
* @instance
|
|
34
|
-
* @category async
|
|
35
|
-
* @rtype (tx: String, options: Object) => Promise[String]
|
|
36
|
-
* @param {String} tx - Transaction
|
|
37
|
-
* @param {Object} [options={}] options - Options
|
|
38
|
-
* @param {Object} [options.verify=true] - Verify transaction before broadcast, throw error if not
|
|
39
|
-
* valid
|
|
40
|
-
* @return {Object} Transaction
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
async function send(tx) {
|
|
44
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
45
|
-
const opt = { ...this.Ae.defaults,
|
|
46
|
-
...options
|
|
47
|
-
};
|
|
48
|
-
const {
|
|
49
|
-
contractId,
|
|
50
|
-
authFun
|
|
51
|
-
} = options.innerTx ? {
|
|
52
|
-
contractId: false
|
|
53
|
-
} : await this.getAccount(await this.address(opt));
|
|
54
|
-
const signed = contractId ? await this.signUsingGA(tx, { ...opt,
|
|
55
|
-
authFun
|
|
56
|
-
}) : await this.signTransaction(tx, opt);
|
|
57
|
-
return opt.innerTx ? {
|
|
58
|
-
hash: TxBuilder.buildTxHash(signed),
|
|
59
|
-
rawTx: signed
|
|
60
|
-
} : this.sendTransaction(signed, opt);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async function signUsingGA(tx) {
|
|
64
|
-
let {
|
|
65
|
-
authData,
|
|
66
|
-
authFun,
|
|
67
|
-
...options
|
|
68
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
69
|
-
return this.createMetaTx(tx, authData, authFun, options);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Send tokens to another account
|
|
73
|
-
* @instance
|
|
74
|
-
* @category async
|
|
75
|
-
* @rtype (amount: Number|String, recipientIdOrName: String, options?: Object) => Promise[String]
|
|
76
|
-
* @param {Number|String} amount - Amount to spend
|
|
77
|
-
* @param {String} recipientIdOrName - Address or name of recipient account
|
|
78
|
-
* @param {Object} [options] - Options
|
|
79
|
-
* @return {Object} Transaction
|
|
80
|
-
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
async function spend(amount, recipientIdOrName, options) {
|
|
84
|
-
const opt = { ...this.Ae.defaults,
|
|
85
|
-
...options
|
|
86
|
-
};
|
|
87
|
-
return this.send(await this.spendTx({ ...opt,
|
|
88
|
-
senderId: await this.address(opt),
|
|
89
|
-
recipientId: await this.resolveName(recipientIdOrName, 'account_pubkey', opt),
|
|
90
|
-
amount
|
|
91
|
-
}), opt);
|
|
92
|
-
} // TODO: Rename to spendFraction
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Send a fraction of token balance to another account
|
|
96
|
-
* @instance
|
|
97
|
-
* @category async
|
|
98
|
-
* @rtype (fraction: Number|String, recipientIdOrName: String, options?: Object) => Promise[String]
|
|
99
|
-
* @param {Number|String} fraction - Fraction of balance to spend (between 0 and 1)
|
|
100
|
-
* @param {String} recipientIdOrName - Address or name of recipient account
|
|
101
|
-
* @param {Object} [options] - Options
|
|
102
|
-
* @return {Object} Transaction
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
async function transferFunds(fraction, recipientIdOrName, options) {
|
|
107
|
-
if (fraction < 0 || fraction > 1) {
|
|
108
|
-
throw new Error(`Fraction should be a number between 0 and 1, got ${fraction}`);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const opt = { ...this.Ae.defaults,
|
|
112
|
-
...options
|
|
113
|
-
};
|
|
114
|
-
const recipientId = await this.resolveName(recipientIdOrName, 'account_pubkey', opt);
|
|
115
|
-
const senderId = await this.address(opt);
|
|
116
|
-
const balance = new BigNumber(await this.balance(senderId));
|
|
117
|
-
const desiredAmount = balance.times(fraction).integerValue(BigNumber.ROUND_HALF_UP);
|
|
118
|
-
const {
|
|
119
|
-
tx: {
|
|
120
|
-
fee
|
|
121
|
-
}
|
|
122
|
-
} = TxBuilder.unpackTx(await this.spendTx({ ...opt,
|
|
123
|
-
senderId,
|
|
124
|
-
recipientId,
|
|
125
|
-
amount: desiredAmount
|
|
126
|
-
})); // Reducing of the amount may reduce transaction fee, so this is not completely accurate
|
|
127
|
-
|
|
128
|
-
const amount = desiredAmount.plus(fee).gt(balance) ? balance.minus(fee) : desiredAmount;
|
|
129
|
-
return this.send(await this.spendTx({ ...opt,
|
|
130
|
-
senderId,
|
|
131
|
-
recipientId,
|
|
132
|
-
amount
|
|
133
|
-
}), opt);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Submit transaction of another account paying for it (fee and gas)
|
|
137
|
-
* @instance
|
|
138
|
-
* @category async
|
|
139
|
-
* @rtype (transaction: String, options?: Object) => Promise[String]
|
|
140
|
-
* @param {String} transaction - tx_<base64>-encoded transaction
|
|
141
|
-
* @param {Object} [options]
|
|
142
|
-
* @return {Object} Transaction
|
|
143
|
-
*/
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
async function payForTransaction(transaction, options) {
|
|
147
|
-
const opt = { ...this.Ae.defaults,
|
|
148
|
-
...options
|
|
149
|
-
};
|
|
150
|
-
return this.send(await this.payingForTx({ ...opt,
|
|
151
|
-
payerId: await this.address(opt),
|
|
152
|
-
tx: transaction
|
|
153
|
-
}), opt);
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Remove all listeners for RPC
|
|
157
|
-
* @instance
|
|
158
|
-
* @return {void}
|
|
159
|
-
*/
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
function destroyInstance() {
|
|
163
|
-
const destroyMethods = ['destroyClient', 'destroyServer']; // Array with destroy function's
|
|
164
|
-
|
|
165
|
-
destroyMethods.forEach(m => this[m] && typeof this[m] === 'function' && this[m]());
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Basic Ae Stamp
|
|
169
|
-
*
|
|
170
|
-
* Attempting to create instances from the Stamp without overwriting all
|
|
171
|
-
* abstract methods using composition will result in an exception.
|
|
172
|
-
*
|
|
173
|
-
* Ae objects are the composition of three basic building blocks:
|
|
174
|
-
* * {@link module:@aeternity/aepp-sdk/es/tx--Tx}
|
|
175
|
-
* * {@link module:@aeternity/aepp-sdk/es/account--Account}
|
|
176
|
-
* * {@link module:@aeternity/aepp-sdk/es/chain--Chain}
|
|
177
|
-
* Only by providing the joint functionality of those three, most more advanced
|
|
178
|
-
* operations, i.e. the ones with actual use value on the chain, become
|
|
179
|
-
* available.
|
|
180
|
-
* @function
|
|
181
|
-
* @alias module:@aeternity/aepp-sdk/es/ae
|
|
182
|
-
* @rtype Stamp
|
|
183
|
-
* @param {Object} [options={}] - Initializer object
|
|
184
|
-
* @return {Object} Ae instance
|
|
185
|
-
*/
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const Ae = stampit(Tx, AccountBase, Chain, {
|
|
189
|
-
methods: {
|
|
190
|
-
send,
|
|
191
|
-
spend,
|
|
192
|
-
transferFunds,
|
|
193
|
-
payForTransaction,
|
|
194
|
-
destroyInstance,
|
|
195
|
-
signUsingGA
|
|
196
|
-
},
|
|
197
|
-
deepProps: {
|
|
198
|
-
Ae: {
|
|
199
|
-
defaults: {
|
|
200
|
-
denomination: AE_AMOUNT_FORMATS.AETTOS
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
export default Ae;
|
|
206
|
-
//# sourceMappingURL=index.js.map
|
package/es/ae/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ae/index.js"],"names":["stampit","Tx","Chain","AccountBase","TxBuilder","BigNumber","AE_AMOUNT_FORMATS","send","tx","options","opt","Ae","defaults","contractId","authFun","innerTx","getAccount","address","signed","signUsingGA","signTransaction","hash","buildTxHash","rawTx","sendTransaction","authData","createMetaTx","spend","amount","recipientIdOrName","spendTx","senderId","recipientId","resolveName","transferFunds","fraction","Error","balance","desiredAmount","times","integerValue","ROUND_HALF_UP","fee","unpackTx","plus","gt","minus","payForTransaction","transaction","payingForTx","payerId","destroyInstance","destroyMethods","forEach","m","methods","deepProps","denomination","AETTOS"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,OAAP,MAAoB,WAApB;AACA,OAAOC,EAAP,MAAe,OAAf;AACA,OAAOC,KAAP,MAAkB,UAAlB;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,OAAOC,SAAP,MAAsB,cAAtB;AACA,SAASC,iBAAT,QAAkC,2BAAlC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAeC,IAAf,CAAqBC,EAArB,EAAuC;AAAA,MAAdC,OAAc,uEAAJ,EAAI;AACrC,QAAMC,GAAG,GAAG,EAAE,GAAG,KAAKC,EAAL,CAAQC,QAAb;AAAuB,OAAGH;AAA1B,GAAZ;AACA,QAAM;AAAEI,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAA0BL,OAAO,CAACM,OAAR,GAC5B;AAAEF,IAAAA,UAAU,EAAE;AAAd,GAD4B,GAE5B,MAAM,KAAKG,UAAL,CAAgB,MAAM,KAAKC,OAAL,CAAaP,GAAb,CAAtB,CAFV;AAGA,QAAMQ,MAAM,GAAGL,UAAU,GACrB,MA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sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2018 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * Ae module\n * @module @aeternity/aepp-sdk/es/ae\n * @export Ae\n * @example import { Ae } from '@aeternity/aepp-sdk'\n */\n\nimport stampit from '@stamp/it'\nimport Tx from '../tx'\nimport Chain from '../chain'\nimport AccountBase from '../account/base'\nimport TxBuilder from '../tx/builder'\nimport BigNumber from 'bignumber.js'\nimport { AE_AMOUNT_FORMATS } from '../utils/amount-formatter'\n\n/**\n * Sign and post a transaction to the chain\n * @instance\n * @category async\n * @rtype (tx: String, options: Object) => Promise[String]\n * @param {String} tx - Transaction\n * @param {Object} [options={}] options - Options\n * @param {Object} [options.verify=true] - Verify transaction before broadcast, throw error if not\n * valid\n * @return {Object} Transaction\n */\nasync function send (tx, options = {}) {\n const opt = { ...this.Ae.defaults, ...options }\n const { contractId, authFun } = options.innerTx\n ? { contractId: false }\n : await this.getAccount(await this.address(opt))\n const signed = contractId\n ? await this.signUsingGA(tx, { ...opt, authFun })\n : await this.signTransaction(tx, opt)\n return opt.innerTx\n ? { hash: TxBuilder.buildTxHash(signed), rawTx: signed }\n : this.sendTransaction(signed, opt)\n}\n\nasync function signUsingGA (tx, { authData, authFun, ...options } = {}) {\n return this.createMetaTx(tx, authData, authFun, options)\n}\n\n/**\n * Send tokens to another account\n * @instance\n * @category async\n * @rtype (amount: Number|String, recipientIdOrName: String, options?: Object) => Promise[String]\n * @param {Number|String} amount - Amount to spend\n * @param {String} recipientIdOrName - Address or name of recipient account\n * @param {Object} [options] - Options\n * @return {Object} Transaction\n */\nasync function spend (amount, recipientIdOrName, options) {\n const opt = { ...this.Ae.defaults, ...options }\n return this.send(\n await this.spendTx({\n ...opt,\n senderId: await this.address(opt),\n recipientId: await this.resolveName(recipientIdOrName, 'account_pubkey', opt),\n amount\n }),\n opt\n )\n}\n\n// TODO: Rename to spendFraction\n/**\n * Send a fraction of token balance to another account\n * @instance\n * @category async\n * @rtype (fraction: Number|String, recipientIdOrName: String, options?: Object) => Promise[String]\n * @param {Number|String} fraction - Fraction of balance to spend (between 0 and 1)\n * @param {String} recipientIdOrName - Address or name of recipient account\n * @param {Object} [options] - Options\n * @return {Object} Transaction\n */\nasync function transferFunds (fraction, recipientIdOrName, options) {\n if (fraction < 0 || fraction > 1) {\n throw new Error(`Fraction should be a number between 0 and 1, got ${fraction}`)\n }\n const opt = { ...this.Ae.defaults, ...options }\n const recipientId = await this.resolveName(recipientIdOrName, 'account_pubkey', opt)\n const senderId = await this.address(opt)\n const balance = new BigNumber(await this.balance(senderId))\n const desiredAmount = balance.times(fraction).integerValue(BigNumber.ROUND_HALF_UP)\n const { tx: { fee } } = TxBuilder.unpackTx(\n await this.spendTx({ ...opt, senderId, recipientId, amount: desiredAmount })\n )\n // Reducing of the amount may reduce transaction fee, so this is not completely accurate\n const amount = desiredAmount.plus(fee).gt(balance) ? balance.minus(fee) : desiredAmount\n return this.send(await this.spendTx({ ...opt, senderId, recipientId, amount }), opt)\n}\n\n/**\n * Submit transaction of another account paying for it (fee and gas)\n * @instance\n * @category async\n * @rtype (transaction: String, options?: Object) => Promise[String]\n * @param {String} transaction - tx_<base64>-encoded transaction\n * @param {Object} [options]\n * @return {Object} Transaction\n */\nasync function payForTransaction (transaction, options) {\n const opt = { ...this.Ae.defaults, ...options }\n return this.send(\n await this.payingForTx({\n ...opt,\n payerId: await this.address(opt),\n tx: transaction\n }),\n opt\n )\n}\n\n/**\n * Remove all listeners for RPC\n * @instance\n * @return {void}\n */\nfunction destroyInstance () {\n const destroyMethods = ['destroyClient', 'destroyServer'] // Array with destroy function's\n destroyMethods.forEach(m => this[m] && typeof this[m] === 'function' && this[m]())\n}\n\n/**\n * Basic Ae Stamp\n *\n * Attempting to create instances from the Stamp without overwriting all\n * abstract methods using composition will result in an exception.\n *\n * Ae objects are the composition of three basic building blocks:\n * * {@link module:@aeternity/aepp-sdk/es/tx--Tx}\n * * {@link module:@aeternity/aepp-sdk/es/account--Account}\n * * {@link module:@aeternity/aepp-sdk/es/chain--Chain}\n * Only by providing the joint functionality of those three, most more advanced\n * operations, i.e. the ones with actual use value on the chain, become\n * available.\n * @function\n * @alias module:@aeternity/aepp-sdk/es/ae\n * @rtype Stamp\n * @param {Object} [options={}] - Initializer object\n * @return {Object} Ae instance\n */\nconst Ae = stampit(Tx, AccountBase, Chain, {\n methods: { send, spend, transferFunds, payForTransaction, destroyInstance, signUsingGA },\n deepProps: { Ae: { defaults: { denomination: AE_AMOUNT_FORMATS.AETTOS } } }\n})\n\nexport default Ae\n"],"file":"index.js"}
|