@aeternity/aepp-sdk 13.0.0-alpha.1 → 13.0.0-beta.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/bin/aesophia_cli +0 -0
- package/dist/aepp-sdk.browser-script.js +1 -1
- 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 +1792 -1525
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdk.mjs.map +1 -1
- package/es/AeSdkAepp.mjs.map +1 -1
- package/es/AeSdkBase.mjs.map +1 -1
- package/es/AeSdkMethods.d.ts +11 -12
- package/es/AeSdkMethods.mjs +6 -8
- package/es/AeSdkMethods.mjs.map +1 -1
- package/es/AeSdkWallet.mjs +1 -1
- package/es/AeSdkWallet.mjs.map +1 -1
- package/es/Node.d.ts +5 -1
- package/es/Node.mjs +11 -5
- package/es/Node.mjs.map +1 -1
- package/es/account/Base.d.ts +11 -6
- package/es/account/Base.mjs +0 -17
- package/es/account/Base.mjs.map +1 -1
- package/es/account/Generalized.mjs +11 -24
- package/es/account/Generalized.mjs.map +1 -1
- package/es/account/Ledger.mjs.map +1 -1
- package/es/account/LedgerFactory.mjs.map +1 -1
- package/es/account/Memory.d.ts +2 -1
- package/es/account/Memory.mjs +9 -21
- package/es/account/Memory.mjs.map +1 -1
- package/es/account/Rpc.mjs.map +1 -1
- package/es/aens.d.ts +12 -14
- package/es/aens.mjs +17 -31
- package/es/aens.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/Browser.mjs +0 -16
- package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +0 -16
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -16
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection-proxy.mjs +0 -17
- package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +4 -5
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/types.d.ts +6 -2
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
- package/es/aepp-wallet-communication/schema.mjs.map +1 -1
- package/es/aepp-wallet-communication/wallet-detector.mjs +0 -16
- package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
- package/es/apis/compiler/compiler.d.ts +1 -1
- package/es/apis/compiler/compiler.mjs +4 -20
- package/es/apis/compiler/compiler.mjs.map +1 -1
- package/es/apis/compiler/models/index.d.ts +3 -2
- package/es/apis/compiler/models/index.mjs.map +1 -1
- package/es/apis/compiler/models/mappers.d.ts +1 -1
- package/es/apis/compiler/models/mappers.mjs +19 -2
- package/es/apis/compiler/models/mappers.mjs.map +1 -1
- package/es/apis/node/models/index.d.ts +15 -15
- package/es/apis/node/models/index.mjs.map +1 -1
- package/es/apis/node/models/mappers.d.ts +1 -1
- package/es/apis/node/models/mappers.mjs +2 -1
- package/es/apis/node/models/mappers.mjs.map +1 -1
- package/es/apis/node/models/parameters.d.ts +2 -2
- package/es/apis/node/models/parameters.mjs +2 -2
- package/es/apis/node/models/parameters.mjs.map +1 -1
- package/es/apis/node/node.mjs +3 -19
- package/es/apis/node/node.mjs.map +1 -1
- package/es/chain.d.ts +8 -8
- package/es/chain.mjs +19 -22
- package/es/chain.mjs.map +1 -1
- package/es/channel/Base.d.ts +25 -12
- package/es/channel/Base.mjs +23 -26
- package/es/channel/Base.mjs.map +1 -1
- package/es/channel/Contract.mjs +8 -21
- package/es/channel/Contract.mjs.map +1 -1
- package/es/channel/Spend.d.ts +4 -2
- package/es/channel/Spend.mjs +0 -16
- package/es/channel/Spend.mjs.map +1 -1
- package/es/channel/handlers.mjs +6 -18
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/internal.d.ts +19 -2
- package/es/channel/internal.mjs +19 -19
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Contract.d.ts +30 -85
- package/es/contract/Contract.mjs +174 -211
- package/es/contract/Contract.mjs.map +1 -1
- package/es/contract/compiler/Base.d.ts +7 -14
- package/es/contract/compiler/Base.mjs.map +1 -1
- package/es/contract/compiler/Cli.mjs +5 -11
- package/es/contract/compiler/Cli.mjs.map +1 -1
- package/es/contract/compiler/Http.mjs +6 -30
- package/es/contract/compiler/Http.mjs.map +1 -1
- package/es/contract/compiler/HttpNode.mjs.map +1 -1
- package/es/contract/compiler/getFileSystem.mjs.map +1 -1
- package/es/contract/delegation-signature.d.ts +43 -0
- package/es/contract/delegation-signature.mjs +45 -0
- package/es/contract/delegation-signature.mjs.map +1 -0
- package/es/contract/ga.d.ts +23 -7
- package/es/contract/ga.mjs +52 -27
- package/es/contract/ga.mjs.map +1 -1
- package/es/index-browser.d.ts +4 -3
- package/es/index-browser.mjs +6 -20
- package/es/index-browser.mjs.map +1 -1
- package/es/oracle.d.ts +12 -17
- package/es/oracle.mjs +28 -48
- package/es/oracle.mjs.map +1 -1
- package/es/spend.d.ts +19 -27
- package/es/spend.mjs +20 -43
- package/es/spend.mjs.map +1 -1
- package/es/tx/builder/SchemaTypes.d.ts +37 -0
- package/es/tx/builder/SchemaTypes.mjs +2 -0
- package/es/tx/builder/SchemaTypes.mjs.map +1 -0
- package/es/tx/builder/constants.d.ts +4 -2
- package/es/tx/builder/constants.mjs +2 -0
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types/abi-version.d.ts +11 -2
- package/es/tx/builder/field-types/abi-version.mjs +24 -4
- package/es/tx/builder/field-types/abi-version.mjs.map +1 -1
- package/es/tx/builder/field-types/address.mjs.map +1 -1
- package/es/tx/builder/field-types/array.d.ts +1 -1
- package/es/tx/builder/field-types/array.mjs.map +1 -1
- package/es/tx/builder/field-types/boolean.mjs.map +1 -1
- package/es/tx/builder/field-types/coin-amount.d.ts +3 -4
- package/es/tx/builder/field-types/coin-amount.mjs +4 -5
- package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
- package/es/tx/builder/field-types/ct-version.d.ts +22 -3
- package/es/tx/builder/field-types/ct-version.mjs +32 -4
- package/es/tx/builder/field-types/ct-version.mjs.map +1 -1
- package/es/tx/builder/field-types/deposit.d.ts +2 -1
- package/es/tx/builder/field-types/deposit.mjs +3 -2
- package/es/tx/builder/field-types/deposit.mjs.map +1 -1
- package/es/tx/builder/field-types/encoded.d.ts +1 -1
- package/es/tx/builder/field-types/encoded.mjs.map +1 -1
- package/es/tx/builder/field-types/entry.mjs +3 -0
- package/es/tx/builder/field-types/entry.mjs.map +1 -1
- package/es/tx/builder/field-types/enumeration.mjs.map +1 -1
- package/es/tx/builder/field-types/fee.d.ts +3 -1
- package/es/tx/builder/field-types/fee.mjs +5 -1
- package/es/tx/builder/field-types/fee.mjs.map +1 -1
- package/es/tx/builder/field-types/field.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-limit.d.ts +3 -2
- package/es/tx/builder/field-types/gas-limit.mjs +4 -2
- package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-price.d.ts +3 -1
- package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
- package/es/tx/builder/field-types/index.d.ts +52 -13
- package/es/tx/builder/field-types/index.mjs +10 -2
- package/es/tx/builder/field-types/index.mjs.map +1 -1
- package/es/tx/builder/field-types/map.d.ts +13 -0
- package/es/tx/builder/field-types/map.mjs +49 -0
- package/es/tx/builder/field-types/map.mjs.map +1 -0
- package/es/tx/builder/field-types/mptree.d.ts +7 -2
- package/es/tx/builder/field-types/mptree.mjs +5 -7
- package/es/tx/builder/field-types/mptree.mjs.map +1 -1
- package/es/tx/builder/field-types/name-fee.d.ts +1 -1
- package/es/tx/builder/field-types/name-fee.mjs +2 -2
- package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
- package/es/tx/builder/field-types/name-id.mjs.map +1 -1
- package/es/tx/builder/field-types/name.mjs.map +1 -1
- package/es/tx/builder/field-types/nonce.d.ts +14 -0
- package/es/tx/builder/field-types/nonce.mjs +29 -0
- package/es/tx/builder/field-types/nonce.mjs.map +1 -0
- package/es/tx/builder/field-types/pointers.mjs.map +1 -1
- package/es/tx/builder/field-types/raw.mjs.map +1 -1
- package/es/tx/builder/field-types/short-u-int-const.d.ts +4 -2
- package/es/tx/builder/field-types/short-u-int-const.mjs +12 -8
- package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -1
- package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
- package/es/tx/builder/field-types/string.mjs.map +1 -1
- package/es/tx/builder/field-types/ttl.d.ts +11 -0
- package/es/tx/builder/field-types/ttl.mjs +21 -0
- package/es/tx/builder/field-types/ttl.mjs.map +1 -0
- package/es/tx/builder/field-types/u-int.mjs.map +1 -1
- package/es/tx/builder/field-types/wrapped.d.ts +14 -0
- package/es/tx/builder/field-types/wrapped.mjs +22 -0
- package/es/tx/builder/field-types/wrapped.mjs.map +1 -0
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +20 -20
- package/es/tx/builder/index.mjs +54 -64
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +2735 -2865
- package/es/tx/builder/schema.generated.d.ts +2011 -0
- package/es/tx/builder/schema.generated.mjs +2 -0
- package/es/tx/builder/schema.generated.mjs.map +1 -0
- package/es/tx/builder/schema.mjs +459 -155
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/execution-cost.d.ts +35 -0
- package/es/tx/execution-cost.mjs +123 -0
- package/es/tx/execution-cost.mjs.map +1 -0
- package/es/tx/transaction-signer.d.ts +6 -0
- package/es/tx/transaction-signer.mjs +27 -0
- package/es/tx/transaction-signer.mjs.map +1 -0
- package/es/tx/validator.mjs +60 -109
- package/es/tx/validator.mjs.map +1 -1
- package/es/utils/amount-formatter.mjs +0 -16
- package/es/utils/amount-formatter.mjs.map +1 -1
- package/es/utils/autorest.d.ts +3 -2
- package/es/utils/autorest.mjs +43 -11
- package/es/utils/autorest.mjs.map +1 -1
- package/es/utils/bytes.mjs +0 -16
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/crypto.mjs +0 -16
- package/es/utils/crypto.mjs.map +1 -1
- package/es/utils/encoder.mjs.map +1 -1
- package/es/utils/errors.d.ts +14 -31
- package/es/utils/errors.mjs +2 -32
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/hd-wallet.mjs.map +1 -1
- package/es/utils/json-big.mjs.map +1 -1
- package/es/utils/keystore.mjs.map +1 -1
- package/es/utils/other.d.ts +1 -1
- package/es/utils/other.mjs.map +1 -1
- package/es/utils/semver-satisfies.mjs.map +1 -1
- package/es/utils/string.mjs +0 -17
- package/es/utils/string.mjs.map +1 -1
- package/package.json +34 -30
- package/src/AeSdkMethods.ts +11 -16
- package/src/AeSdkWallet.ts +1 -1
- package/src/Node.ts +17 -6
- package/src/account/Base.ts +11 -22
- package/src/account/Generalized.ts +8 -23
- package/src/account/Memory.ts +14 -21
- package/src/aens.ts +31 -47
- package/src/aepp-wallet-communication/connection/Browser.ts +0 -17
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +0 -17
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +0 -17
- package/src/aepp-wallet-communication/connection-proxy.ts +0 -17
- package/src/aepp-wallet-communication/rpc/types.ts +6 -2
- package/src/aepp-wallet-communication/wallet-detector.ts +0 -17
- package/src/apis/compiler/compiler.ts +3 -27
- package/src/apis/compiler/models/index.ts +3 -2
- package/src/apis/compiler/models/mappers.ts +15 -2
- package/src/apis/node/models/index.ts +16 -15
- package/src/apis/node/models/mappers.ts +2 -1
- package/src/apis/node/models/parameters.ts +2 -2
- package/src/apis/node/node.ts +3 -27
- package/src/chain.ts +28 -27
- package/src/channel/Base.ts +33 -33
- package/src/channel/Contract.ts +8 -23
- package/src/channel/Spend.ts +2 -17
- package/src/channel/handlers.ts +5 -18
- package/src/channel/internal.ts +40 -22
- package/src/contract/Contract.ts +133 -163
- package/src/contract/compiler/Base.ts +7 -14
- package/src/contract/compiler/Cli.ts +5 -11
- package/src/contract/compiler/Http.ts +6 -25
- package/src/contract/delegation-signature.ts +56 -0
- package/src/contract/ga.ts +53 -32
- package/src/index-browser.ts +12 -20
- package/src/oracle.ts +46 -56
- package/src/spend.ts +33 -67
- package/src/tx/builder/SchemaTypes.ts +79 -0
- package/src/tx/builder/constants.ts +2 -0
- package/src/tx/builder/field-types/abi-version.ts +29 -6
- package/src/tx/builder/field-types/array.ts +1 -1
- package/src/tx/builder/field-types/coin-amount.ts +6 -4
- package/src/tx/builder/field-types/ct-version.ts +37 -4
- package/src/tx/builder/field-types/deposit.ts +3 -1
- package/src/tx/builder/field-types/encoded.ts +1 -1
- package/src/tx/builder/field-types/entry.ts +8 -3
- package/src/tx/builder/field-types/fee.ts +6 -4
- package/src/tx/builder/field-types/gas-limit.ts +2 -2
- package/src/tx/builder/field-types/index.ts +15 -1
- package/src/tx/builder/field-types/map.ts +45 -0
- package/src/tx/builder/field-types/mptree.ts +4 -3
- package/src/tx/builder/field-types/name-fee.ts +2 -1
- package/src/tx/builder/field-types/nonce.ts +40 -0
- package/src/tx/builder/field-types/short-u-int-const.ts +18 -8
- package/src/tx/builder/field-types/ttl.ts +24 -0
- package/src/tx/builder/field-types/wrapped.ts +32 -0
- package/src/tx/builder/index.ts +57 -71
- package/src/tx/builder/schema.generated.ts +2013 -0
- package/src/tx/builder/schema.ts +544 -624
- package/src/tx/execution-cost.ts +146 -0
- package/src/tx/transaction-signer.ts +27 -0
- package/src/tx/validator.ts +60 -91
- package/src/utils/amount-formatter.ts +0 -16
- package/src/utils/autorest.ts +52 -11
- package/src/utils/bytes.ts +0 -16
- package/src/utils/crypto.ts +0 -16
- package/src/utils/errors.ts +15 -44
- package/src/utils/string.ts +0 -17
- package/types-legacy/ts4.2/AeSdkMethods.d.ts +11 -12
- package/types-legacy/ts4.2/Node.d.ts +5 -1
- package/types-legacy/ts4.2/account/Base.d.ts +11 -6
- package/types-legacy/ts4.2/account/Memory.d.ts +2 -1
- package/types-legacy/ts4.2/aens.d.ts +12 -14
- package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +6 -2
- package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +1 -1
- package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +3 -2
- package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +1 -1
- package/types-legacy/ts4.2/apis/node/models/index.d.ts +15 -15
- package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +1 -1
- package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +2 -2
- package/types-legacy/ts4.2/chain.d.ts +8 -8
- package/types-legacy/ts4.2/channel/Base.d.ts +25 -12
- package/types-legacy/ts4.2/channel/Spend.d.ts +4 -2
- package/types-legacy/ts4.2/channel/internal.d.ts +22 -2
- package/types-legacy/ts4.2/contract/Contract.d.ts +29 -84
- package/types-legacy/ts4.2/contract/compiler/Base.d.ts +7 -14
- package/types-legacy/ts4.2/contract/delegation-signature.d.ts +43 -0
- package/types-legacy/ts4.2/contract/ga.d.ts +23 -7
- package/types-legacy/ts4.2/index-browser.d.ts +4 -3
- package/types-legacy/ts4.2/oracle.d.ts +12 -17
- package/types-legacy/ts4.2/spend.d.ts +19 -27
- package/types-legacy/ts4.2/tx/builder/SchemaTypes.d.ts +37 -0
- package/types-legacy/ts4.2/tx/builder/constants.d.ts +4 -2
- package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +11 -2
- package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +1 -1
- package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +3 -4
- package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +33 -3
- package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +2 -1
- package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +1 -1
- package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +3 -1
- package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +3 -2
- package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +3 -1
- package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +52 -13
- package/types-legacy/ts4.2/tx/builder/field-types/map.d.ts +13 -0
- package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +7 -2
- package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +1 -1
- package/types-legacy/ts4.2/tx/builder/field-types/nonce.d.ts +14 -0
- package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +4 -2
- package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +11 -0
- package/types-legacy/ts4.2/tx/builder/field-types/wrapped.d.ts +14 -0
- package/types-legacy/ts4.2/tx/builder/index.d.ts +23 -20
- package/types-legacy/ts4.2/tx/builder/schema.d.ts +2962 -4629
- package/types-legacy/ts4.2/tx/builder/schema.generated.d.ts +2011 -0
- package/types-legacy/ts4.2/tx/execution-cost.d.ts +35 -0
- package/types-legacy/ts4.2/tx/transaction-signer.d.ts +6 -0
- package/types-legacy/ts4.2/utils/autorest.d.ts +3 -2
- package/types-legacy/ts4.2/utils/errors.d.ts +14 -31
- package/types-legacy/ts4.2/utils/other.d.ts +1 -1
- package/types-legacy/ts4.5/AeSdkMethods.d.ts +11 -12
- package/types-legacy/ts4.5/Node.d.ts +5 -1
- package/types-legacy/ts4.5/account/Base.d.ts +11 -6
- package/types-legacy/ts4.5/account/Memory.d.ts +2 -1
- package/types-legacy/ts4.5/aens.d.ts +12 -14
- package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +6 -2
- package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +1 -1
- package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +3 -2
- package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +1 -1
- package/types-legacy/ts4.5/apis/node/models/index.d.ts +15 -15
- package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +1 -1
- package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +2 -2
- package/types-legacy/ts4.5/chain.d.ts +8 -8
- package/types-legacy/ts4.5/channel/Base.d.ts +25 -12
- package/types-legacy/ts4.5/channel/Spend.d.ts +4 -2
- package/types-legacy/ts4.5/channel/internal.d.ts +22 -2
- package/types-legacy/ts4.5/contract/Contract.d.ts +29 -84
- package/types-legacy/ts4.5/contract/compiler/Base.d.ts +7 -14
- package/types-legacy/ts4.5/contract/delegation-signature.d.ts +43 -0
- package/types-legacy/ts4.5/contract/ga.d.ts +23 -7
- package/types-legacy/ts4.5/index-browser.d.ts +4 -3
- package/types-legacy/ts4.5/oracle.d.ts +12 -17
- package/types-legacy/ts4.5/spend.d.ts +19 -27
- package/types-legacy/ts4.5/tx/builder/SchemaTypes.d.ts +37 -0
- package/types-legacy/ts4.5/tx/builder/constants.d.ts +4 -2
- package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +11 -2
- package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +1 -1
- package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +3 -4
- package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +33 -3
- package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +2 -1
- package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +1 -1
- package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +3 -1
- package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +3 -2
- package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +3 -1
- package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +52 -13
- package/types-legacy/ts4.5/tx/builder/field-types/map.d.ts +13 -0
- package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +7 -2
- package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +1 -1
- package/types-legacy/ts4.5/tx/builder/field-types/nonce.d.ts +14 -0
- package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +4 -2
- package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +11 -0
- package/types-legacy/ts4.5/tx/builder/field-types/wrapped.d.ts +14 -0
- package/types-legacy/ts4.5/tx/builder/index.d.ts +23 -20
- package/types-legacy/ts4.5/tx/builder/schema.d.ts +2962 -4629
- package/types-legacy/ts4.5/tx/builder/schema.generated.d.ts +2011 -0
- package/types-legacy/ts4.5/tx/execution-cost.d.ts +35 -0
- package/types-legacy/ts4.5/tx/transaction-signer.d.ts +6 -0
- package/types-legacy/ts4.5/utils/autorest.d.ts +3 -2
- package/types-legacy/ts4.5/utils/errors.d.ts +14 -31
- package/types-legacy/ts4.5/utils/other.d.ts +1 -1
- package/es/tx/index.d.ts +0 -19
- package/es/tx/index.mjs +0 -115
- package/es/tx/index.mjs.map +0 -1
- package/src/apis/compiler/code-model-v4.yaml +0 -2442
- package/src/apis/node/code-model-v4.yaml +0 -10080
- package/src/tx/index.ts +0 -129
- package/types-legacy/ts4.2/tx/index.d.ts +0 -19
- package/types-legacy/ts4.5/tx/index.d.ts +0 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contract.mjs","names":["DRY_RUN_ACCOUNT","Tag","buildContractIdByContractTx","unpackTx","_buildTx","send","decode","MissingContractDefError","MissingContractAddressError","InactiveContractError","BytecodeMismatchError","DuplicateContractError","MissingFunctionNameError","InvalidMethodInvocationError","NotPayableFunctionError","TypeError","NodeInvocationError","IllegalArgumentError","NoSuchContractFunctionError","MissingEventDefinitionError","AmbiguousEventDefinitionError","UnexpectedTsError","InternalError","NoWalletConnectedError","hash","calcHash","getAccount","getContract","getContractByteCode","resolveName","txDryRun","concatBuffers","isNameValid","produceNameId","Contract","$createDelegationSignature","ids","_options","options","$options","contractId","address","onAccount","sign","from","onNode","getNetworkId","omitAddress","map","e","$compile","bytecode","sourceCode","onCompiler","compileBySourceCode","fileSystem","_handleCallError","transaction","returnType","returnValue","message","_calldata","decodeFateString","toString","_sendAndProcess","tx","txData","result","rawTx","blockHeight","callInfo","getTransactionInfoByHash","Object","assign","_estimateGas","name","params","$call","callStatic","gasUsed","Math","floor","$deploy","opt","ownerId","ContractCreateTx","gasLimit","callData","encode","_name","code","other","log","decodedEvents","$decodeEvents","owner","_getFunctionACI","fn","_aci","encodedAci","contract","functions","find","f","payable","top","fnACI","amount","callerId","error","useFallbackAccount","pub","res","nonce","topKey","txOpt","ContractCallTx","callObj","dryRunOther","decodedResult","returns","_getContractNameByEvent","ctAddress","nameHash","contractAddressToName","addressToName","isEqual","a","b","JSON","stringify","matchedEvents","externalEncodedAci","filter","event","variant","events","keys","values","flat","eventName","BigInt","idx","arr","type","slice","some","el","length","omitUnknown","topics","t","contractName","decoded","decodeEvent","data","args","entries","initialize","aci","sourceCodePath","validateBytecode","otherOptions","compile","resolveByNode","active","onChanBytecode","isValid","validateBySourceCode","ContractWithMethods","constructor","Calldata","fromEntries","arguments","aciArgs","stateful","pop"],"sources":["../../src/contract/Contract.ts"],"sourcesContent":["/*\n* ISC License (ISC)\n* Copyright (c) 2022 aeternity developers\n*\n* Permission to use, copy, modify, and/or distribute this software for any\n* purpose with or without fee is hereby granted, provided that the above\n* copyright notice and this permission notice appear in all copies.\n*\n* THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n* PERFORMANCE OF THIS SOFTWARE.\n*/\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\nimport { Encoder as Calldata } from '@aeternity/aepp-calldata';\nimport { DRY_RUN_ACCOUNT } from '../tx/builder/schema';\nimport { Tag, AensName } from '../tx/builder/constants';\nimport { buildContractIdByContractTx, unpackTx } from '../tx/builder';\nimport { _buildTx, BuildTxOptions } from '../tx';\nimport { send, SendOptions } from '../spend';\nimport { decode, Encoded } from '../utils/encoder';\nimport {\n MissingContractDefError,\n MissingContractAddressError,\n InactiveContractError,\n BytecodeMismatchError,\n DuplicateContractError,\n MissingFunctionNameError,\n InvalidMethodInvocationError,\n NotPayableFunctionError,\n TypeError,\n NodeInvocationError,\n IllegalArgumentError,\n NoSuchContractFunctionError,\n MissingEventDefinitionError,\n AmbiguousEventDefinitionError,\n UnexpectedTsError,\n InternalError,\n NoWalletConnectedError,\n} from '../utils/errors';\nimport { hash as calcHash } from '../utils/crypto';\nimport {\n ContractCallObject as NodeContractCallObject, ContractCallReturnType, Event as NodeEvent,\n} from '../apis/node';\nimport CompilerBase, { Aci } from './compiler/Base';\nimport Node, { TransformNodeType } from '../Node';\nimport {\n getAccount, getContract, getContractByteCode, resolveName, txDryRun,\n} from '../chain';\nimport AccountBase from '../account/Base';\nimport { concatBuffers } from '../utils/other';\nimport { isNameValid, produceNameId } from '../tx/builder/helpers';\n\ntype FunctionAci = Aci['encodedAci']['contract']['functions'][0];\n\ninterface Event extends NodeEvent {\n address: Encoded.ContractAddress;\n data: Encoded.ContractBytearray;\n}\n\nexport interface ContractCallObject extends NodeContractCallObject {\n returnValue: Encoded.ContractBytearray;\n log: Event[];\n}\n\ninterface DecodedEvent {\n name: string;\n args: unknown[];\n contract: {\n name: string;\n address: Encoded.ContractAddress;\n };\n}\n\ntype TxData = Awaited<ReturnType<typeof send>>;\n\ninterface SendAndProcessReturnType {\n result?: TransformNodeType<ContractCallObject>;\n hash: TxData['hash'];\n tx: Awaited<ReturnType<typeof unpackTx<Tag.ContractCallTx | Tag.ContractCreateTx>>>;\n txData: TxData;\n rawTx: Encoded.Transaction;\n}\n\nexport interface ContractMethodsBase { [key: string]: (...args: any[]) => any }\n\ntype MethodsToContractApi<M extends ContractMethodsBase> = {\n [Name in keyof M]:\n M[Name] extends (...args: infer Args) => infer Ret\n ? (...args: [\n ...Args,\n ...[] | [Name extends 'init'\n ? Parameters<Contract<M>['$deploy']>[1] : Parameters<Contract<M>['$call']>[2]],\n ]) => Promise<\n Awaited<ReturnType<Contract<M>['$call']>> &\n { decodedResult?: Ret }\n >\n : never\n};\n\ntype ContractWithMethods<M extends ContractMethodsBase> = Contract<M> & MethodsToContractApi<M>;\n\ntype MethodNames<M extends ContractMethodsBase> = keyof M & string | 'init';\n\ntype MethodParameters<M extends ContractMethodsBase, Fn extends MethodNames<M>> =\n Fn extends 'init'\n ? M extends { init: any } ? Parameters<M['init']> : []\n : Parameters<M[Fn]>;\n\n/**\n * Generate contract ACI object with predefined js methods for contract usage - can be used for\n * creating a reference to already deployed contracts\n * @category contract\n * @param options - Options object\n * @returns JS Contract API\n * @example\n * ```js\n * const contractIns = await aeSdk.initializeContract({ sourceCode })\n * await contractIns.$deploy([321]) or await contractIns.init(321)\n * const callResult = await contractIns.$call('setState', [123])\n * const staticCallResult = await contractIns.$call('setState', [123], { callStatic: true })\n * ```\n * Also you can call contract like: `await contractIns.setState(123, options)`\n * Then sdk decide to make on-chain or static call(dry-run API) transaction based on function is\n * stateful or not\n */\nclass Contract<M extends ContractMethodsBase> {\n /**\n * Helper to generate a signature to delegate\n * - pre-claim/claim/transfer/revoke of a name to a contract.\n * - register/extend/respond of an Oracle to a contract.\n * @category contract\n * @param ids - The list of id's to prepend\n * @param _options - Options\n * @param _options.omitAddress - Prepend delegation signature with an account address\n * @param _options.onAccount - Account to use\n * @returns Signature\n * @example\n * ```js\n * const aeSdk = new AeSdk({ ... })\n * const contract = await aeSdk.initializeContract({ address: 'ct_asd2ks...' })\n * const aensName = 'example.chain'\n * const onAccount = new MemoryAccount(...) // Sign with a specific account\n * // Preclaim signature\n * const preclaimSig = await contract.$createDelegationSignature([], { onAccount })\n * // Claim, transfer and revoke signature\n * const aensDelegationSig = await contract\n * .$createDelegationSignature([aensName], { onAccount })\n * ```\n * @example\n * ```js\n * const aeSdk = new AeSdk({ ... })\n * const contract = await aeSdk.initializeContract({ address: 'ct_asd2ks...' })\n * const oracleQueryId = 'oq_...'\n * const onAccount = new MemoryAccount(...) // Sign with a specific account\n * // Oracle register and extend signature\n * const oracleDelegationSig = await contract.$createDelegationSignature([], { onAccount })\n * // Oracle respond signature\n * const respondSig = await contract\n * .$createDelegationSignature([oracleQueryId], { onAccount, omitAddress: true })\n * ```\n */\n async $createDelegationSignature(\n ids: Array<Encoded.Any | AensName> = [],\n _options?: { omitAddress?: boolean; onAccount?: AccountBase },\n ): Promise<Uint8Array> {\n const options = { ...this.$options, ..._options };\n const contractId = this.$options.address;\n if (options.onAccount == null) throw new IllegalArgumentError('Can\\'t create delegation signature without account');\n if (contractId == null) throw new MissingContractAddressError('Can\\'t create delegation signature without address');\n return options.onAccount.sign(\n concatBuffers([\n Buffer.from(await options.onNode.getNetworkId()),\n ...options.omitAddress === true ? [] : [decode(options.onAccount.address)],\n ...ids.map((e) => (isNameValid(e) ? produceNameId(e) : e)).map((e) => decode(e)),\n decode(contractId),\n ]),\n options,\n );\n }\n\n /**\n * Compile contract\n * @returns bytecode\n */\n async $compile(): Promise<Encoded.ContractBytearray> {\n if (this.$options.bytecode != null) return this.$options.bytecode;\n if (this.$options.sourceCode == null) throw new IllegalArgumentError('Can\\'t compile without source code');\n if (this.$options.onCompiler == null) throw new IllegalArgumentError('Can\\'t compile without compiler');\n this.$options.bytecode = (await this.$options.onCompiler\n .compileBySourceCode(this.$options.sourceCode, this.$options.fileSystem)\n ).bytecode;\n return this.$options.bytecode;\n }\n\n protected _handleCallError(\n { returnType, returnValue }: {\n returnType: ContractCallReturnType;\n returnValue: Encoded.ContractBytearray;\n },\n transaction: string,\n ): void {\n let message: string;\n switch (returnType) {\n case 'ok': return;\n case 'revert':\n message = this._calldata.decodeFateString(returnValue);\n break;\n case 'error':\n message = decode(returnValue).toString();\n break;\n default:\n throw new InternalError(`Unknown return type: ${returnType}`);\n }\n throw new NodeInvocationError(message, transaction);\n }\n\n protected async _sendAndProcess(\n tx: Encoded.Transaction,\n options: SendOptions,\n ): Promise<SendAndProcessReturnType> {\n const txData = await send(tx, { ...this.$options, ...options });\n const result = {\n hash: txData.hash,\n tx: unpackTx<Tag.ContractCallTx | Tag.ContractCreateTx>(txData.rawTx),\n txData,\n rawTx: txData.rawTx,\n };\n if (txData.blockHeight == null) return result;\n const { callInfo } = await this.$options.onNode.getTransactionInfoByHash(txData.hash);\n Object.assign(result.txData, callInfo); // TODO: don't duplicate data in result\n // @ts-expect-error TODO api should be updated to match types\n this._handleCallError(callInfo, tx);\n return { ...result, result: callInfo as TransformNodeType<ContractCallObject> };\n }\n\n async _estimateGas<Fn extends MethodNames<M>>(\n name: Fn,\n params: MethodParameters<M, Fn>,\n options: object = {},\n ): Promise<number> {\n const { result } = await this.$call(name, params, { ...options, callStatic: true });\n if (result == null) throw new UnexpectedTsError();\n const { gasUsed } = result;\n // taken from https://github.com/aeternity/aepp-sdk-js/issues/1286#issuecomment-977814771\n return Math.floor(gasUsed * 1.25);\n }\n\n /**\n * Deploy contract\n * @param params - Contract init function arguments array\n * @param options - Options\n * @returns deploy info\n */\n async $deploy(\n params: MethodParameters<M, 'init'>,\n options?: Parameters<Contract<M>['$call']>[2]\n & Partial<BuildTxOptions<Tag.ContractCreateTx, 'ownerId' | 'code' | 'callData'>>,\n ): Promise<Omit<SendAndProcessReturnType, 'hash'> & {\n transaction?: Encoded.TxHash;\n owner?: Encoded.AccountAddress;\n address?: Encoded.ContractAddress;\n decodedEvents?: ReturnType<Contract<M>['$decodeEvents']>;\n }> {\n const { callStatic, ...opt } = { ...this.$options, ...options };\n if (this.$options.bytecode == null) await this.$compile();\n if (callStatic === true) return this.$call('init', params, { ...opt, callStatic });\n if (this.$options.address != null) throw new DuplicateContractError();\n\n if (opt.onAccount == null) throw new IllegalArgumentError('Can\\'t deploy without account');\n const ownerId = opt.onAccount.address;\n if (this.$options.bytecode == null) throw new IllegalArgumentError('Can\\'t deploy without bytecode');\n const tx = await _buildTx(Tag.ContractCreateTx, {\n ...opt,\n gasLimit: opt.gasLimit ?? await this._estimateGas('init', params, opt),\n callData: this._calldata.encode(this._name, 'init', params),\n code: this.$options.bytecode,\n ownerId,\n });\n this.$options.address = buildContractIdByContractTx(tx);\n const { hash, ...other } = await this._sendAndProcess(tx, { ...opt, onAccount: opt.onAccount });\n return {\n ...other,\n ...other.result?.log != null && {\n decodedEvents: this.$decodeEvents(other.result.log, opt),\n },\n owner: ownerId,\n transaction: hash,\n address: this.$options.address,\n };\n }\n\n /**\n * Get function schema from contract ACI object\n * @param name - Function name\n * @returns function ACI\n */\n protected _getFunctionACI(name: string): Partial<FunctionAci> {\n const fn = this._aci.encodedAci.contract.functions.find(\n (f: { name: string }) => f.name === name,\n );\n if (fn != null) {\n return fn;\n }\n if (name === 'init') return { payable: false };\n throw new NoSuchContractFunctionError(`Function ${name} doesn't exist in contract`);\n }\n\n /**\n * Call contract function\n * @param fn - Function name\n * @param params - Array of function arguments\n * @param options - Array of function arguments\n * @returns CallResult\n */\n async $call<Fn extends MethodNames<M>>(\n fn: Fn,\n params: MethodParameters<M, Fn>,\n options: Partial<BuildTxOptions<Tag.ContractCallTx, 'callerId' | 'contractId' | 'callData'>>\n & Parameters<Contract<M>['$decodeEvents']>[1]\n & Omit<Parameters<Contract<M>['_sendAndProcess']>[1], 'onAccount' | 'onNode'>\n & Omit<Parameters<typeof txDryRun>[2], 'onNode'>\n & { onAccount?: AccountBase; onNode?: Node; callStatic?: boolean } = {},\n ): Promise<{\n decodedResult?: any;\n decodedEvents?: ReturnType<Contract<M>['$decodeEvents']>;\n } & SendAndProcessReturnType> {\n const { callStatic, top, ...opt } = { ...this.$options, ...options };\n const fnACI = this._getFunctionACI(fn);\n const contractId = this.$options.address;\n const { onNode } = opt;\n\n if (fn == null) throw new MissingFunctionNameError();\n if (fn === 'init' && callStatic !== true) throw new InvalidMethodInvocationError('\"init\" can be called only via dryRun');\n if (fn !== 'init' && opt.amount != null && opt.amount > 0 && fnACI.payable === false) {\n throw new NotPayableFunctionError(opt.amount, fn);\n }\n\n let callerId;\n try {\n if (opt.onAccount == null) throw new InternalError('Use fallback account');\n callerId = opt.onAccount.address;\n } catch (error) {\n const useFallbackAccount = callStatic === true && (\n (error instanceof TypeError && error.message === 'Account should be an address (ak-prefixed string), or instance of AccountBase, got undefined instead')\n || (error instanceof NoWalletConnectedError)\n );\n if (!useFallbackAccount) throw error;\n callerId = DRY_RUN_ACCOUNT.pub;\n }\n const callData = this._calldata.encode(this._name, fn, params);\n\n let res: any;\n if (callStatic === true) {\n if (opt.nonce == null && top != null) {\n const topKey = typeof top === 'number' ? 'height' : 'hash';\n opt.nonce = (await getAccount(callerId, { [topKey]: top, onNode })).nonce + 1;\n }\n const txOpt = { ...opt, onNode, callData };\n let tx;\n if (fn === 'init') {\n if (this.$options.bytecode == null) throw new IllegalArgumentError('Can\\'t dry-run \"init\" without bytecode');\n tx = await _buildTx(\n Tag.ContractCreateTx,\n { ...txOpt, code: this.$options.bytecode, ownerId: callerId },\n );\n } else {\n if (contractId == null) throw new MissingContractAddressError('Can\\'t dry-run contract without address');\n tx = await _buildTx(Tag.ContractCallTx, { ...txOpt, callerId, contractId });\n }\n\n const { callObj, ...dryRunOther } = await txDryRun(tx, callerId, { ...opt, top });\n if (callObj == null) throw new UnexpectedTsError();\n this._handleCallError({\n returnType: callObj.returnType as ContractCallReturnType,\n returnValue: callObj.returnValue as Encoded.ContractBytearray,\n }, tx);\n res = { ...dryRunOther, tx: unpackTx(tx), result: callObj };\n } else {\n if (top != null) throw new IllegalArgumentError('Can\\'t handle `top` option in on-chain contract call');\n if (contractId == null) throw new MissingContractAddressError('Can\\'t call contract without address');\n const tx = await _buildTx(Tag.ContractCallTx, {\n ...opt,\n gasLimit: opt.gasLimit ?? await this._estimateGas(fn, params, opt),\n callerId,\n contractId,\n callData,\n });\n if (opt.onAccount == null) throw new IllegalArgumentError('Can\\'t call contract on chain without account');\n res = await this._sendAndProcess(tx, { ...opt, onAccount: opt.onAccount });\n }\n if (callStatic === true || res.txData.blockHeight != null) {\n res.decodedResult = fnACI.returns != null && fnACI.returns !== 'unit' && fn !== 'init'\n && this._calldata.decode(this._name, fn, res.result.returnValue);\n res.decodedEvents = this.$decodeEvents(res.result.log, opt);\n }\n return res;\n }\n\n /**\n * @param ctAddress - Contract address that emitted event\n * @param nameHash - Hash of emitted event name\n * @param options - Options\n * @returns Contract name\n * @throws {@link MissingEventDefinitionError}\n * @throws {@link AmbiguousEventDefinitionError}\n */\n protected _getContractNameByEvent(\n ctAddress: Encoded.ContractAddress,\n nameHash: BigInt,\n { contractAddressToName }: {\n contractAddressToName?: { [key: Encoded.ContractAddress]: string };\n },\n ): string {\n const addressToName = { ...this.$options.contractAddressToName, ...contractAddressToName };\n if (addressToName[ctAddress] != null) return addressToName[ctAddress];\n\n // TODO: consider using a third-party library\n const isEqual = (a: any, b: any): boolean => JSON.stringify(a) === JSON.stringify(b);\n\n const matchedEvents = [this._aci.encodedAci, ...this._aci.externalEncodedAci]\n .filter(({ contract }) => contract?.event)\n .map(({ contract }) => [contract.name, contract.event.variant])\n .map(([name, events]) => events.map((event: {}) => (\n [name, Object.keys(event)[0], Object.values(event)[0]]\n )))\n .flat()\n .filter(([, eventName]) => BigInt(`0x${calcHash(eventName).toString('hex')}`) === nameHash)\n .filter(([, , type], idx, arr) => !arr.slice(0, idx).some((el) => isEqual(el[2], type)));\n switch (matchedEvents.length) {\n case 0: throw new MissingEventDefinitionError(nameHash.toString(), ctAddress);\n case 1: return matchedEvents[0][0];\n default: throw new AmbiguousEventDefinitionError(ctAddress, matchedEvents);\n }\n }\n\n /**\n * Decode Events\n * @param events - Array of encoded events (callRes.result.log)\n * @param options - Options\n * @returns DecodedEvents\n */\n $decodeEvents(\n events: Event[],\n { omitUnknown, ...opt }: { omitUnknown?: boolean } &\n Parameters<Contract<M>['_getContractNameByEvent']>[2] = {},\n ): DecodedEvent[] {\n return events\n .map((event) => {\n const topics = event.topics.map((t: string | number) => BigInt(t));\n let contractName;\n try {\n contractName = this._getContractNameByEvent(event.address, topics[0], opt);\n } catch (error) {\n if ((omitUnknown ?? false) && error instanceof MissingEventDefinitionError) return null;\n throw error;\n }\n const decoded = this._calldata.decodeEvent(contractName, event.data, topics);\n const [name, args] = Object.entries(decoded)[0];\n return {\n name,\n args,\n contract: {\n name: contractName,\n address: event.address,\n },\n };\n }).filter((e: DecodedEvent | null): e is DecodedEvent => e != null);\n }\n\n static async initialize<M extends ContractMethodsBase>(\n {\n onCompiler,\n onNode,\n bytecode,\n aci,\n address,\n sourceCodePath,\n sourceCode,\n fileSystem,\n validateBytecode,\n ...otherOptions\n }: Omit<ConstructorParameters<typeof Contract>[0], 'aci' | 'address'> & {\n validateBytecode?: boolean;\n aci?: Aci;\n address?: Encoded.ContractAddress | AensName;\n },\n ): Promise<ContractWithMethods<M>> {\n if (aci == null && onCompiler != null) {\n let res;\n if (sourceCodePath != null) res = await onCompiler.compile(sourceCodePath);\n if (sourceCode != null) res = await onCompiler.compileBySourceCode(sourceCode, fileSystem);\n if (res != null) {\n aci = res.aci;\n bytecode ??= res.bytecode;\n }\n }\n if (aci == null) throw new MissingContractDefError();\n\n if (address != null) {\n address = await resolveName(\n address,\n 'contract_pubkey',\n { resolveByNode: true, onNode },\n ) as Encoded.ContractAddress;\n }\n\n if (address == null && sourceCode == null && bytecode == null) {\n throw new MissingContractAddressError('Can\\'t create instance by ACI without address');\n }\n\n if (address != null) {\n const contract = await getContract(address, { onNode });\n if (contract.active == null) throw new InactiveContractError(address);\n }\n\n if (validateBytecode === true) {\n if (address == null) throw new MissingContractAddressError('Can\\'t validate bytecode without contract address');\n const onChanBytecode = (await getContractByteCode(address, { onNode })).bytecode;\n let isValid = false;\n if (bytecode != null) isValid = bytecode === onChanBytecode;\n else if (sourceCode != null) {\n if (onCompiler == null) throw new IllegalArgumentError('Can\\'t validate bytecode without compiler');\n isValid = await onCompiler.validateBySourceCode(onChanBytecode, sourceCode, fileSystem);\n }\n if (!isValid) throw new BytecodeMismatchError(sourceCode != null ? 'source code' : 'bytecode');\n }\n\n return new ContractWithMethods<M>({\n onCompiler, onNode, sourceCode, bytecode, aci, address, fileSystem, ...otherOptions,\n });\n }\n\n _aci: Aci;\n\n _name: string;\n\n _calldata: Calldata;\n\n $options: Omit<ConstructorParameters<typeof Contract>[0], 'aci'>;\n\n constructor({ aci, ...otherOptions }: {\n onCompiler?: CompilerBase;\n onNode: Node;\n bytecode?: Encoded.ContractBytearray;\n aci: Aci;\n address?: Encoded.ContractAddress;\n sourceCodePath?: Parameters<CompilerBase['compile']>[0];\n sourceCode?: Parameters<CompilerBase['compileBySourceCode']>[0];\n fileSystem?: Parameters<CompilerBase['compileBySourceCode']>[1];\n } & Parameters<Contract<M>['$deploy']>[1]) {\n this._aci = aci;\n this._name = aci.encodedAci.contract.name;\n this._calldata = new Calldata([aci.encodedAci, ...aci.externalEncodedAci]);\n this.$options = otherOptions;\n\n /**\n * Generate proto function based on contract function using Contract ACI schema\n * All function can be called like:\n * ```js\n * await contract.testFunction()\n * ```\n * then sdk will decide to use dry-run or send tx\n * on-chain base on if function stateful or not.\n * Also, you can manually do that:\n * ```js\n * await contract.testFunction({ callStatic: true }) // use call-static (dry-run)\n * await contract.testFunction({ callStatic: false }) // send tx on-chain\n * ```\n */\n Object.assign(\n this,\n Object.fromEntries(this._aci.encodedAci.contract.functions\n .map(({ name, arguments: aciArgs, stateful }: FunctionAci) => {\n const callStatic = name !== 'init' && !stateful;\n return [\n name,\n async (...args: any) => {\n const options = args.length === aciArgs.length + 1 ? args.pop() : {};\n if (typeof options !== 'object') throw new TypeError(`Options should be an object: ${options}`);\n if (name === 'init') return this.$deploy(args, { callStatic, ...options });\n return this.$call(name, args, { callStatic, ...options });\n },\n ];\n })),\n );\n }\n}\n\ninterface ContractWithMethodsClass {\n new <M extends ContractMethodsBase>(\n options: ConstructorParameters<typeof Contract>[0],\n ): ContractWithMethods<M>;\n initialize: typeof Contract['initialize'];\n}\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nconst ContractWithMethods: ContractWithMethodsClass = Contract as any;\n\nexport default ContractWithMethods;\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,mCAAoC,0BAA0B;AAAC;EAAA;AAAA;AAAA,SACtDA,eAAe;AAAA,SACfC,GAAG;AAAA,SACHC,2BAA2B,EAAEC,QAAQ;AAAA,SACrCC,QAAQ;AAAA,SACRC,IAAI;AAAA,SACJC,MAAM;AAAA,SAEbC,uBAAuB,EACvBC,2BAA2B,EAC3BC,qBAAqB,EACrBC,qBAAqB,EACrBC,sBAAsB,EACtBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,uBAAuB,EACvBC,SAAS,EACTC,mBAAmB,EACnBC,oBAAoB,EACpBC,2BAA2B,EAC3BC,2BAA2B,EAC3BC,6BAA6B,EAC7BC,iBAAiB,EACjBC,aAAa,EACbC,sBAAsB;AAAA,SAEfC,IAAI,IAAIC,QAAQ;AAAA,SAOvBC,UAAU,EAAEC,WAAW,EAAEC,mBAAmB,EAAEC,WAAW,EAAEC,QAAQ;AAAA,SAG5DC,aAAa;AAAA,SACbC,WAAW,EAAEC,aAAa;AA0DnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAQ,CAAgC;EAC5C;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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UAAE,GAAGxC;QAAQ,CAAC,CAAC;MAC3D,CAAC,CACF;IACH,CAAC,CAAC,CAAC,CACN;EACH;AACF;AASA;AACA,MAAMmI,mBAA6C,GAAGvI,QAAe;AAErE,eAAeuI,mBAAmB"}
|
|
1
|
+
{"version":3,"file":"Contract.mjs","names":["_aeternityAeppCalldata","Encoder","Calldata","DRY_RUN_ACCOUNT","Tag","buildContractIdByContractTx","unpackTx","buildTxAsync","buildTxHash","decode","MissingContractDefError","MissingContractAddressError","InactiveContractError","BytecodeMismatchError","DuplicateContractError","MissingFunctionNameError","InvalidMethodInvocationError","NotPayableFunctionError","TypeError","NodeInvocationError","IllegalArgumentError","NoSuchContractFunctionError","MissingEventDefinitionError","AmbiguousEventDefinitionError","UnexpectedTsError","InternalError","NoWalletConnectedError","ContractError","hash","calcHash","getAccount","getContract","getContractByteCode","resolveName","txDryRun","sendTransaction","_getCallResult","WeakSet","_sendAndProcess","_getFunctionAci","_getContractNameByEvent","_aciContract","WeakMap","Contract","$compile","$options","bytecode","sourceCode","onCompiler","compileBySourceCode","fileSystem","$getCallResultByTxHash","fnName","options","callInfo","onNode","getTransactionInfoByHash","callInfoTyped","_classPrivateMethodGet","_getCallResult2","call","undefined","result","_estimateGas","name","params","arguments","length","$call","callStatic","gasUsed","Math","floor","$deploy","_opt$gasLimit","_other$result","opt","address","onAccount","ownerId","tx","tag","ContractCreateTx","gasLimit","callData","_calldata","encode","_name","code","other","_sendAndProcess2","log","decodedEvents","$decodeEvents","owner","transaction","fn","_opt$gasLimit2","top","fnAci","_getFunctionAci2","contractId","amount","payable","callerId","error","useFallbackAccount","message","pub","nonce","topKey","txOpt","ContractCallTx","callObj","dryRunOther","rawTx","txData","events","omitUnknown","map","event","topics","t","BigInt","contractName","_getContractNameByEvent2","decoded","decodeEvent","data","args","Object","entries","contract","filter","e","initialize","_ref","aci","sourceCodePath","validateBytecode","otherOptions","res","compile","_bytecode","resolveByNode","active","onChanBytecode","isValid","validateBySourceCode","ContractWithMethods","constructor","_ref2","_this","_classPrivateMethodInitSpec","_classPrivateFieldInitSpec","writable","value","_aci","aciLast","keys","_classPrivateFieldSet","_classPrivateFieldGet","assign","fromEntries","functions","_ref3","aciArgs","stateful","_len","Array","_key","pop","_ref4","returnType","returnValue","decodedResult","decodeFateString","toString","blockHeight","find","f","returns","ctAddress","nameHash","_ref5","contractAddressToName","addressToName","isEqual","a","b","JSON","stringify","contracts","_ref6","matchedEvents","variant","_ref7","values","flat","_ref8","eventName","_ref9","idx","arr","type","slice","some","el"],"sources":["../../src/contract/Contract.ts"],"sourcesContent":["/**\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\nimport { Encoder as Calldata } from '@aeternity/aepp-calldata';\nimport { DRY_RUN_ACCOUNT } from '../tx/builder/schema';\nimport { Tag, AensName } from '../tx/builder/constants';\nimport {\n buildContractIdByContractTx, unpackTx, buildTxAsync, BuildTxOptions, buildTxHash,\n} from '../tx/builder';\nimport { decode, Encoded } from '../utils/encoder';\nimport {\n MissingContractDefError,\n MissingContractAddressError,\n InactiveContractError,\n BytecodeMismatchError,\n DuplicateContractError,\n MissingFunctionNameError,\n InvalidMethodInvocationError,\n NotPayableFunctionError,\n TypeError,\n NodeInvocationError,\n IllegalArgumentError,\n NoSuchContractFunctionError,\n MissingEventDefinitionError,\n AmbiguousEventDefinitionError,\n UnexpectedTsError,\n InternalError,\n NoWalletConnectedError,\n ContractError,\n} from '../utils/errors';\nimport { hash as calcHash } from '../utils/crypto';\nimport {\n ContractCallObject as NodeContractCallObject, Event as NodeEvent,\n} from '../apis/node';\nimport CompilerBase, { Aci } from './compiler/Base';\nimport Node, { TransformNodeType } from '../Node';\nimport {\n getAccount, getContract, getContractByteCode, resolveName, txDryRun, sendTransaction,\n SendTransactionOptions,\n} from '../chain';\nimport AccountBase from '../account/Base';\nimport { TxUnpacked } from '../tx/builder/schema.generated';\n\ntype ContractAci = NonNullable<Aci[0]['contract']>;\ntype FunctionAci = ContractAci['functions'][0];\n\ninterface Event extends NodeEvent {\n address: Encoded.ContractAddress;\n data: Encoded.ContractBytearray;\n}\n\nexport interface ContractCallObject extends TransformNodeType<NodeContractCallObject> {\n returnValue: Encoded.ContractBytearray;\n log: Event[];\n}\n\ninterface DecodedEvent {\n name: string;\n args: unknown[];\n contract: {\n name: string;\n address: Encoded.ContractAddress;\n };\n}\n\ntype TxData = Awaited<ReturnType<typeof sendTransaction>>;\n\ninterface SendAndProcessReturnType {\n result?: ContractCallObject;\n hash: TxData['hash'];\n tx: TxUnpacked & { tag: Tag.ContractCallTx | Tag.ContractCreateTx };\n txData: TxData;\n rawTx: Encoded.Transaction;\n}\n\nexport interface ContractMethodsBase { [key: string]: (...args: any[]) => any }\n\ntype MethodsToContractApi<M extends ContractMethodsBase> = {\n [Name in keyof M]:\n M[Name] extends (...args: infer Args) => any\n ? (...args: [\n ...Args,\n ...[] | [Name extends 'init'\n ? Parameters<Contract<M>['$deploy']>[1] : Parameters<Contract<M>['$call']>[2]],\n ]) => ReturnType<Contract<M>['$call']>\n : never\n};\n\ntype ContractWithMethods<M extends ContractMethodsBase> = Contract<M> & MethodsToContractApi<M>;\n\ntype MethodNames<M extends ContractMethodsBase> = keyof M & string | 'init';\n\ntype MethodParameters<M extends ContractMethodsBase, Fn extends MethodNames<M>> =\n Fn extends 'init'\n ? M extends { init: any } ? Parameters<M['init']> : []\n : Parameters<M[Fn]>;\n\ninterface GetContractNameByEventOptions {\n contractAddressToName?: { [key: Encoded.ContractAddress]: string };\n}\n\ninterface GetCallResultByHashReturnType<M extends ContractMethodsBase, Fn extends MethodNames<M>> {\n decodedResult: ReturnType<M[Fn]>;\n decodedEvents?: ReturnType<Contract<M>['$decodeEvents']>;\n}\n\n/**\n * Generate contract ACI object with predefined js methods for contract usage - can be used for\n * creating a reference to already deployed contracts\n * @category contract\n * @param options - Options object\n * @returns JS Contract API\n * @example\n * ```js\n * const contractIns = await aeSdk.initializeContract({ sourceCode })\n * await contractIns.$deploy([321]) or await contractIns.init(321)\n * const callResult = await contractIns.$call('setState', [123])\n * const staticCallResult = await contractIns.$call('setState', [123], { callStatic: true })\n * ```\n * Also you can call contract like: `await contractIns.setState(123, options)`\n * Then sdk decide to make on-chain or static call(dry-run API) transaction based on function is\n * stateful or not\n */\nclass Contract<M extends ContractMethodsBase> {\n /**\n * Compile contract\n * @returns bytecode\n */\n async $compile(): Promise<Encoded.ContractBytearray> {\n if (this.$options.bytecode != null) return this.$options.bytecode;\n if (this.$options.sourceCode == null) throw new IllegalArgumentError('Can\\'t compile without source code');\n if (this.$options.onCompiler == null) throw new IllegalArgumentError('Can\\'t compile without compiler');\n this.$options.bytecode = (await this.$options.onCompiler\n .compileBySourceCode(this.$options.sourceCode, this.$options.fileSystem)\n ).bytecode;\n return this.$options.bytecode;\n }\n\n #getCallResult<Fn extends MethodNames<M>>(\n { returnType, returnValue, log }: ContractCallObject,\n fnName: Fn,\n transaction: Encoded.Transaction | undefined,\n options: Parameters<Contract<M>['$decodeEvents']>[1],\n ): GetCallResultByHashReturnType<M, Fn> {\n let message: string;\n switch (returnType) {\n case 'ok': {\n const fnAci = this.#getFunctionAci(fnName);\n return {\n decodedResult: this._calldata.decode(this._name, fnAci.name, returnValue),\n decodedEvents: this.$decodeEvents(log, options),\n };\n }\n case 'revert':\n message = this._calldata.decodeFateString(returnValue);\n break;\n case 'error':\n message = decode(returnValue).toString();\n break;\n default:\n throw new InternalError(`Unknown return type: ${returnType}`);\n }\n throw new NodeInvocationError(message, transaction);\n }\n\n async #sendAndProcess<Fn extends MethodNames<M>>(\n tx: Encoded.Transaction,\n fnName: Fn,\n options: SendTransactionOptions & Parameters<Contract<M>['$getCallResultByTxHash']>[2],\n ): Promise<SendAndProcessReturnType & Partial<GetCallResultByHashReturnType<M, Fn>>> {\n const txData = await sendTransaction(tx, { ...this.$options, ...options });\n return {\n hash: txData.hash,\n tx: unpackTx<Tag.ContractCallTx | Tag.ContractCreateTx>(txData.rawTx),\n txData,\n rawTx: txData.rawTx,\n ...txData.blockHeight != null && (\n await this.$getCallResultByTxHash(txData.hash, fnName, options)\n ),\n };\n }\n\n async $getCallResultByTxHash<Fn extends MethodNames<M>>(\n hash: Encoded.TxHash,\n fnName: Fn,\n options?: Parameters<Contract<M>['$decodeEvents']>[1],\n ): Promise<GetCallResultByHashReturnType<M, Fn> & { result: ContractCallObject }> {\n const { callInfo } = await this.$options.onNode.getTransactionInfoByHash(hash);\n if (callInfo == null) {\n throw new ContractError(`callInfo is not available for transaction ${hash}`);\n }\n const callInfoTyped = callInfo as ContractCallObject;\n return {\n ...this.#getCallResult(callInfoTyped, fnName, undefined, options),\n result: callInfoTyped,\n };\n }\n\n async _estimateGas<Fn extends MethodNames<M>>(\n name: Fn,\n params: MethodParameters<M, Fn>,\n options: Omit<Parameters<Contract<M>['$call']>[2], 'callStatic'> = {},\n ): Promise<number> {\n const { result } = await this.$call(name, params, { ...options, callStatic: true });\n if (result == null) throw new UnexpectedTsError();\n const { gasUsed } = result;\n // taken from https://github.com/aeternity/aepp-sdk-js/issues/1286#issuecomment-977814771\n return Math.floor(gasUsed * 1.25);\n }\n\n /**\n * Deploy contract\n * @param params - Contract init function arguments array\n * @param options - Options\n * @returns deploy info\n */\n async $deploy(\n params: MethodParameters<M, 'init'>,\n options?: Parameters<Contract<M>['$call']>[2]\n & Partial<BuildTxOptions<Tag.ContractCreateTx, 'ownerId' | 'code' | 'callData'>>,\n ): Promise<Omit<SendAndProcessReturnType, 'hash'> & {\n transaction?: Encoded.TxHash;\n owner?: Encoded.AccountAddress;\n address?: Encoded.ContractAddress;\n decodedEvents?: ReturnType<Contract<M>['$decodeEvents']>;\n }> {\n const { callStatic, ...opt } = { ...this.$options, ...options };\n if (this.$options.bytecode == null) await this.$compile();\n if (callStatic === true) return this.$call('init', params, { ...opt, callStatic });\n if (this.$options.address != null) throw new DuplicateContractError();\n\n if (opt.onAccount == null) throw new IllegalArgumentError('Can\\'t deploy without account');\n const ownerId = opt.onAccount.address;\n if (this.$options.bytecode == null) throw new IllegalArgumentError('Can\\'t deploy without bytecode');\n const tx = await buildTxAsync({\n ...opt,\n tag: Tag.ContractCreateTx,\n gasLimit: opt.gasLimit ?? await this._estimateGas('init', params, opt),\n callData: this._calldata.encode(this._name, 'init', params),\n code: this.$options.bytecode,\n ownerId,\n });\n this.$options.address = buildContractIdByContractTx(tx);\n const { hash, ...other } = await this.#sendAndProcess(\n tx,\n 'init',\n { ...opt, onAccount: opt.onAccount },\n );\n return {\n ...other,\n ...other.result?.log != null && {\n decodedEvents: this.$decodeEvents(other.result.log, opt),\n },\n owner: ownerId,\n transaction: hash,\n address: this.$options.address,\n };\n }\n\n /**\n * Get function schema from contract ACI object\n * @param name - Function name\n * @returns function ACI\n */\n #getFunctionAci(name: string): FunctionAci {\n const fn = this.#aciContract.functions.find(\n (f: { name: string }) => f.name === name,\n );\n if (fn != null) {\n return fn;\n }\n if (name === 'init') {\n return {\n arguments: [], name: 'init', payable: false, returns: 'unit', stateful: true,\n };\n }\n throw new NoSuchContractFunctionError(`Function ${name} doesn't exist in contract`);\n }\n\n /**\n * Call contract function\n * @param fn - Function name\n * @param params - Array of function arguments\n * @param options - Array of function arguments\n * @returns CallResult\n */\n async $call<Fn extends MethodNames<M>>(\n fn: Fn,\n params: MethodParameters<M, Fn>,\n options: Partial<BuildTxOptions<Tag.ContractCallTx, 'callerId' | 'contractId' | 'callData'>>\n & Parameters<Contract<M>['$decodeEvents']>[1]\n & Omit<SendTransactionOptions, 'onAccount' | 'onNode'>\n & Omit<Parameters<typeof txDryRun>[2], 'onNode'>\n & { onAccount?: AccountBase; onNode?: Node; callStatic?: boolean } = {},\n ): Promise<SendAndProcessReturnType & Partial<GetCallResultByHashReturnType<M, Fn>>> {\n const { callStatic, top, ...opt } = { ...this.$options, ...options };\n const fnAci = this.#getFunctionAci(fn);\n const contractId = this.$options.address;\n const { onNode } = opt;\n\n if (fn == null) throw new MissingFunctionNameError();\n if (fn === 'init' && callStatic !== true) throw new InvalidMethodInvocationError('\"init\" can be called only via dryRun');\n if (fn !== 'init' && opt.amount != null && opt.amount > 0 && !fnAci.payable) {\n throw new NotPayableFunctionError(opt.amount, fn);\n }\n\n let callerId;\n try {\n if (opt.onAccount == null) throw new InternalError('Use fallback account');\n callerId = opt.onAccount.address;\n } catch (error) {\n const useFallbackAccount = callStatic === true && (\n (error instanceof TypeError && error.message === 'Account should be an address (ak-prefixed string), or instance of AccountBase, got undefined instead')\n || (error instanceof NoWalletConnectedError)\n );\n if (!useFallbackAccount) throw error;\n callerId = DRY_RUN_ACCOUNT.pub;\n }\n const callData = this._calldata.encode(this._name, fn, params);\n\n if (callStatic === true) {\n if (opt.nonce == null && top != null) {\n const topKey = typeof top === 'number' ? 'height' : 'hash';\n opt.nonce = (await getAccount(callerId, { [topKey]: top, onNode })).nonce + 1;\n }\n const txOpt = { ...opt, onNode, callData };\n let tx;\n if (fn === 'init') {\n if (this.$options.bytecode == null) throw new IllegalArgumentError('Can\\'t dry-run \"init\" without bytecode');\n tx = await buildTxAsync({\n ...txOpt, tag: Tag.ContractCreateTx, code: this.$options.bytecode, ownerId: callerId,\n });\n } else {\n if (contractId == null) throw new MissingContractAddressError('Can\\'t dry-run contract without address');\n tx = await buildTxAsync({\n ...txOpt, tag: Tag.ContractCallTx, callerId, contractId,\n });\n }\n\n const { callObj, ...dryRunOther } = await txDryRun(tx, callerId, { ...opt, top });\n if (callObj == null) {\n throw new InternalError(`callObj is not available for transaction ${tx}`);\n }\n const callInfoTyped = callObj as ContractCallObject;\n return {\n ...dryRunOther,\n ...this.#getCallResult(callInfoTyped, fn, tx, opt),\n tx: unpackTx(tx),\n result: callInfoTyped,\n rawTx: tx,\n hash: buildTxHash(tx),\n txData: undefined as any,\n };\n }\n\n if (top != null) throw new IllegalArgumentError('Can\\'t handle `top` option in on-chain contract call');\n if (contractId == null) throw new MissingContractAddressError('Can\\'t call contract without address');\n const tx = await buildTxAsync({\n ...opt,\n tag: Tag.ContractCallTx,\n gasLimit: opt.gasLimit ?? await this._estimateGas(fn, params, opt),\n callerId,\n contractId,\n callData,\n });\n if (opt.onAccount == null) throw new IllegalArgumentError('Can\\'t call contract on chain without account');\n return this.#sendAndProcess(tx, fn, { ...opt, onAccount: opt.onAccount });\n }\n\n /**\n * @param ctAddress - Contract address that emitted event\n * @param nameHash - Hash of emitted event name\n * @param options - Options\n * @returns Contract name\n * @throws {@link MissingEventDefinitionError}\n * @throws {@link AmbiguousEventDefinitionError}\n */\n #getContractNameByEvent(\n ctAddress: Encoded.ContractAddress,\n nameHash: BigInt,\n { contractAddressToName }: GetContractNameByEventOptions,\n ): string {\n const addressToName = { ...this.$options.contractAddressToName, ...contractAddressToName };\n if (addressToName[ctAddress] != null) return addressToName[ctAddress];\n\n // TODO: consider using a third-party library\n const isEqual = (a: any, b: any): boolean => JSON.stringify(a) === JSON.stringify(b);\n\n const contracts = this._aci\n .map(({ contract }) => contract)\n .filter((contract) => contract?.event) as ContractAci[];\n const matchedEvents = contracts\n .map((contract) => [contract.name, contract.event.variant])\n .map(([name, events]) => events.map((event: {}) => (\n [name, Object.keys(event)[0], Object.values(event)[0]]\n )))\n .flat()\n .filter(([, eventName]) => BigInt(`0x${calcHash(eventName).toString('hex')}`) === nameHash)\n .filter(([, , type], idx, arr) => !arr.slice(0, idx).some((el) => isEqual(el[2], type)));\n switch (matchedEvents.length) {\n case 0: throw new MissingEventDefinitionError(nameHash.toString(), ctAddress);\n case 1: return matchedEvents[0][0];\n default: throw new AmbiguousEventDefinitionError(ctAddress, matchedEvents);\n }\n }\n\n /**\n * Decode Events\n * @param events - Array of encoded events (callRes.result.log)\n * @param options - Options\n * @returns DecodedEvents\n */\n $decodeEvents(\n events: Event[],\n { omitUnknown, ...opt }: { omitUnknown?: boolean } & GetContractNameByEventOptions = {},\n ): DecodedEvent[] {\n return events\n .map((event) => {\n const topics = event.topics.map((t: string | number) => BigInt(t));\n let contractName;\n try {\n contractName = this.#getContractNameByEvent(event.address, topics[0], opt);\n } catch (error) {\n if ((omitUnknown ?? false) && error instanceof MissingEventDefinitionError) return null;\n throw error;\n }\n const decoded = this._calldata.decodeEvent(contractName, event.data, topics);\n const [name, args] = Object.entries(decoded)[0];\n return {\n name,\n args,\n contract: {\n name: contractName,\n address: event.address,\n },\n };\n }).filter((e: DecodedEvent | null): e is DecodedEvent => e != null);\n }\n\n static async initialize<M extends ContractMethodsBase>(\n {\n onCompiler,\n onNode,\n bytecode,\n aci,\n address,\n sourceCodePath,\n sourceCode,\n fileSystem,\n validateBytecode,\n ...otherOptions\n }: Omit<ConstructorParameters<typeof Contract>[0], 'aci' | 'address'> & {\n validateBytecode?: boolean;\n aci?: Aci;\n address?: Encoded.ContractAddress | AensName;\n },\n ): Promise<ContractWithMethods<M>> {\n if (aci == null && onCompiler != null) {\n let res;\n if (sourceCodePath != null) res = await onCompiler.compile(sourceCodePath);\n if (sourceCode != null) res = await onCompiler.compileBySourceCode(sourceCode, fileSystem);\n if (res != null) {\n aci = res.aci;\n bytecode ??= res.bytecode;\n }\n }\n if (aci == null) throw new MissingContractDefError();\n\n if (address != null) {\n address = await resolveName(\n address,\n 'contract_pubkey',\n { resolveByNode: true, onNode },\n ) as Encoded.ContractAddress;\n }\n\n if (address == null && sourceCode == null && bytecode == null) {\n throw new MissingContractAddressError('Can\\'t create instance by ACI without address');\n }\n\n if (address != null) {\n const contract = await getContract(address, { onNode });\n if (contract.active == null) throw new InactiveContractError(address);\n }\n\n if (validateBytecode === true) {\n if (address == null) throw new MissingContractAddressError('Can\\'t validate bytecode without contract address');\n const onChanBytecode = (await getContractByteCode(address, { onNode })).bytecode;\n let isValid = false;\n if (bytecode != null) isValid = bytecode === onChanBytecode;\n else if (sourceCode != null) {\n if (onCompiler == null) throw new IllegalArgumentError('Can\\'t validate bytecode without compiler');\n isValid = await onCompiler.validateBySourceCode(onChanBytecode, sourceCode, fileSystem);\n }\n if (!isValid) throw new BytecodeMismatchError(sourceCode != null ? 'source code' : 'bytecode');\n }\n\n return new ContractWithMethods<M>({\n onCompiler, onNode, sourceCode, bytecode, aci, address, fileSystem, ...otherOptions,\n });\n }\n\n _aci: Aci;\n\n #aciContract: ContractAci;\n\n _name: string;\n\n _calldata: Calldata;\n\n $options: Omit<ConstructorParameters<typeof Contract>[0], 'aci'>;\n\n constructor({ aci, ...otherOptions }: {\n onCompiler?: CompilerBase;\n onNode: Node;\n bytecode?: Encoded.ContractBytearray;\n aci: Aci;\n address?: Encoded.ContractAddress;\n sourceCodePath?: Parameters<CompilerBase['compile']>[0];\n sourceCode?: Parameters<CompilerBase['compileBySourceCode']>[0];\n fileSystem?: Parameters<CompilerBase['compileBySourceCode']>[1];\n } & Parameters<Contract<M>['$deploy']>[1]) {\n this._aci = aci;\n const aciLast = aci[aci.length - 1];\n if (aciLast.contract == null) {\n throw new IllegalArgumentError(`The last 'aci' item should have 'contract' key, got ${Object.keys(aciLast)} keys instead`);\n }\n this.#aciContract = aciLast.contract;\n this._name = this.#aciContract.name;\n this._calldata = new Calldata(aci);\n this.$options = otherOptions;\n\n /**\n * Generate proto function based on contract function using Contract ACI schema\n * All function can be called like:\n * ```js\n * await contract.testFunction()\n * ```\n * then sdk will decide to use dry-run or send tx\n * on-chain base on if function stateful or not.\n * Also, you can manually do that:\n * ```js\n * await contract.testFunction({ callStatic: true }) // use call-static (dry-run)\n * await contract.testFunction({ callStatic: false }) // send tx on-chain\n * ```\n */\n Object.assign(\n this,\n Object.fromEntries(this.#aciContract.functions\n .map(({ name, arguments: aciArgs, stateful }: FunctionAci) => {\n const callStatic = name !== 'init' && !stateful;\n return [\n name,\n async (...args: any) => {\n const options = args.length === aciArgs.length + 1 ? args.pop() : {};\n if (typeof options !== 'object') throw new TypeError(`Options should be an object: ${options}`);\n if (name === 'init') return this.$deploy(args, { callStatic, ...options });\n return this.$call(name, args, { callStatic, ...options });\n },\n ];\n })),\n );\n }\n}\n\ninterface ContractWithMethodsClass {\n new <M extends ContractMethodsBase>(\n options: ConstructorParameters<typeof Contract>[0],\n ): ContractWithMethods<M>;\n initialize: typeof Contract['initialize'];\n}\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nconst ContractWithMethods: ContractWithMethodsClass = Contract as any;\n\nexport default ContractWithMethods;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAAA,sBAAA,MAAoC,0BAA0B;AAAC;EAAAC,OAAA,EAAAC;AAAA,IAAAF,sBAAA;AAAA,SACtDG,eAAe;AAAA,SACfC,GAAG;AAAA,SAEVC,2BAA2B,EAAEC,QAAQ,EAAEC,YAAY,EAAkBC,WAAW;AAAA,SAEzEC,MAAM;AAAA,SAEbC,uBAAuB,EACvBC,2BAA2B,EAC3BC,qBAAqB,EACrBC,qBAAqB,EACrBC,sBAAsB,EACtBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,uBAAuB,EACvBC,SAAS,IAATA,UAAS,EACTC,mBAAmB,EACnBC,oBAAoB,EACpBC,2BAA2B,EAC3BC,2BAA2B,EAC3BC,6BAA6B,EAC7BC,iBAAiB,EACjBC,aAAa,EACbC,sBAAsB,EACtBC,aAAa;AAAA,SAENC,IAAI,IAAIC,QAAQ;AAAA,SAOvBC,UAAU,EAAEC,WAAW,EAAEC,mBAAmB,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,eAAe;AAAA,IAAAC,cAAA,oBAAAC,OAAA;AAAA,IAAAC,eAAA,oBAAAD,OAAA;AAAA,IAAAE,eAAA,oBAAAF,OAAA;AAAA,IAAAG,uBAAA,oBAAAH,OAAA;AAAA,IAAAI,YAAA,oBAAAC,OAAA;AAqEtF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAQ,CAAgC;EAC5C;AACF;AACA;AACA;EACE,MAAMC,QAAQA,CAAA,EAAuC;IACnD,IAAI,IAAI,CAACC,QAAQ,CAACC,QAAQ,IAAI,IAAI,EAAE,OAAO,IAAI,CAACD,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CAAC,CAAC,CAAC,CAAC,CACtD,CAAC;EAAA,EAAC,CACF8E,IAAI,EAAE,CACNjE,MAAM,CAACkE,KAAA;IAAA,IAAC,GAAGC,SAAS,CAAC,GAAAD,KAAA;IAAA,OAAK5E,MAAM,CAAE,KAAI9F,QAAQ,CAAC2K,SAAS,CAAC,CAACvB,QAAQ,CAAC,KAAK,CAAE,EAAC,CAAC,KAAKM,QAAQ;EAAA,EAAC,CAC1FlD,MAAM,CAAC,CAAAoE,KAAA,EAAaC,GAAG,EAAEC,GAAG;IAAA,IAApB,IAAKC,IAAI,CAAC,GAAAH,KAAA;IAAA,OAAe,CAACE,GAAG,CAACE,KAAK,CAAC,CAAC,EAAEH,GAAG,CAAC,CAACI,IAAI,CAAEC,EAAE,IAAKpB,OAAO,CAACoB,EAAE,CAAC,CAAC,CAAC,EAAEH,IAAI,CAAC,CAAC;EAAA,EAAC;EAC1F,QAAQV,aAAa,CAAC/H,MAAM;IAC1B,KAAK,CAAC;MAAE,MAAM,IAAI7C,2BAA2B,CAACiK,QAAQ,CAACN,QAAQ,EAAE,EAAEK,SAAS,CAAC;IAC7E,KAAK,CAAC;MAAE,OAAOY,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC;MAAS,MAAM,IAAI3K,6BAA6B,CAAC+J,SAAS,EAAEY,aAAa,CAAC;EAAC;AAE/E;AAwKF;AACA,MAAM7C,mBAA6C,GAAG1G,QAAe;AAErE,eAAe0G,mBAAmB"}
|
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
import { Encoded } from '../../utils/encoder';
|
|
2
|
-
import { Aci as BaseAci } from '../../apis/compiler';
|
|
3
2
|
interface FunctionAci {
|
|
4
3
|
arguments: any[];
|
|
5
4
|
name: string;
|
|
6
5
|
payable: boolean;
|
|
7
|
-
returns:
|
|
6
|
+
returns: any;
|
|
8
7
|
stateful: boolean;
|
|
9
8
|
}
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
kind: string;
|
|
16
|
-
state: any;
|
|
17
|
-
type_defs: any[];
|
|
18
|
-
functions: FunctionAci[];
|
|
19
|
-
};
|
|
9
|
+
export type Aci = Array<{
|
|
10
|
+
contract?: {
|
|
11
|
+
name: string;
|
|
12
|
+
event?: any;
|
|
13
|
+
functions: FunctionAci[];
|
|
20
14
|
};
|
|
21
|
-
|
|
22
|
-
}
|
|
15
|
+
}>;
|
|
23
16
|
/**
|
|
24
17
|
* A base class for all compiler implementations
|
|
25
18
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Base.mjs","names":["CompilerBase"],"sources":["../../../src/contract/compiler/Base.ts"],"sourcesContent":["import { Encoded } from '../../utils/encoder';\
|
|
1
|
+
{"version":3,"file":"Base.mjs","names":["CompilerBase"],"sources":["../../../src/contract/compiler/Base.ts"],"sourcesContent":["import { Encoded } from '../../utils/encoder';\n\ninterface FunctionAci {\n arguments: any[];\n name: string;\n payable: boolean;\n returns: any;\n stateful: boolean;\n}\n\nexport type Aci = Array<{\n contract?: {\n name: string;\n event?: any;\n functions: FunctionAci[];\n };\n}>;\n\n/**\n * A base class for all compiler implementations\n */\nexport default abstract class CompilerBase {\n /**\n * Compile contract by contract's path\n * Available only in Node.js\n * @param path - Path to contract source code\n * @returns ACI and bytecode\n */\n abstract compile(path: string): Promise<{\n bytecode: Encoded.ContractBytearray;\n aci: Aci;\n }>;\n\n /**\n * Compile contract by contract's source code\n * @param sourceCode - Contract source code as string\n * @param fileSystem - A map of contract filename to the corresponding contract source code to\n * include into the main contract\n * @example\n * ```js\n * {\n * 'library.aes': 'namespace TestLib =\\n function sum(x: int, y: int) : int = x + y'\n * }\n * ```\n * @returns ACI and bytecode\n */\n abstract compileBySourceCode(\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<{\n bytecode: Encoded.ContractBytearray;\n aci: Aci;\n }>;\n\n /**\n * Verify that a contract bytecode is the result of compiling the given source code\n * Available only in Node.js\n * @param bytecode - Contract bytecode to verify\n * @param path - Path to contract source code\n * @returns ACI and bytecode\n */\n abstract validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean>;\n\n /**\n * Verify that a contract bytecode is the result of compiling the given source code\n * @param bytecode - Contract bytecode to verify\n * @param sourceCode - Contract source code as string\n * @param fileSystem - A map of contract filename to the corresponding contract source code to\n * include into the main contract\n * @example\n * ```js\n * {\n * 'library.aes': 'namespace TestLib =\\n function sum(x: int, y: int) : int = x + y'\n * }\n * ```\n */\n abstract validateBySourceCode(\n bytecode: Encoded.ContractBytearray,\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<boolean>;\n\n /**\n * @returns Compiler version\n */\n abstract version(): Promise<string>;\n}\n"],"mappings":"AAkBA;AACA;AACA;AACA,eAAe,MAAeA,YAAY,CAAC"}
|
|
@@ -73,21 +73,15 @@ export default class CompilerCli extends CompilerBase {
|
|
|
73
73
|
}
|
|
74
74
|
async compile(path) {
|
|
75
75
|
await _classPrivateFieldGet(this, _ensureCompatibleVersion);
|
|
76
|
-
let bytecode;
|
|
77
|
-
let aciCli;
|
|
78
76
|
try {
|
|
79
|
-
[bytecode,
|
|
77
|
+
const [bytecode, aci] = await Promise.all([_classPrivateMethodGet(this, _run, _run2).call(this, path), _classPrivateMethodGet(this, _run, _run2).call(this, '--create_json_aci', path).then(res => JSON.parse(res))]);
|
|
78
|
+
return {
|
|
79
|
+
bytecode: bytecode.trimEnd(),
|
|
80
|
+
aci: aci
|
|
81
|
+
};
|
|
80
82
|
} catch (error) {
|
|
81
83
|
throw new CompilerError(error.message);
|
|
82
84
|
}
|
|
83
|
-
const aci = {
|
|
84
|
-
encodedAci: aciCli[0],
|
|
85
|
-
externalEncodedAci: aciCli.slice(1)
|
|
86
|
-
};
|
|
87
|
-
return {
|
|
88
|
-
bytecode: bytecode.trimEnd(),
|
|
89
|
-
aci: aci
|
|
90
|
-
};
|
|
91
85
|
}
|
|
92
86
|
async compileBySourceCode(sourceCode, fileSystem) {
|
|
93
87
|
const tmp = await _classStaticPrivateMethodGet(CompilerCli, CompilerCli, _saveContractToTmpDir).call(CompilerCli, sourceCode, fileSystem);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cli.mjs","names":["CompilerBase","CompilerError","InternalError","UnsupportedVersionError","semverSatisfies","getPackagePath","path","dirname","fileURLToPath","import","meta","url","basename","resolve","CompilerCli","constructor","compilerPath","ignoreVersion","version","then","versions","compile","bytecode","aciCli","Promise","all","res","JSON","parse","error","message","aci","encodedAci","externalEncodedAci","slice","trimEnd","compileBySourceCode","sourceCode","fileSystem","tmp","rm","recursive","validate","includes","validateBySourceCode","verMessage","ver","match","parameters","pResolve","pReject","execFile","stdout","stderr","randomName","Math","random","toString","tmpdir","mkdir","sourceCodePath","writeFile","Object","entries","map","name","src","p"],"sources":["../../../src/contract/compiler/Cli.ts"],"sourcesContent":["import { execFile } from 'child_process';\nimport { tmpdir } from 'os';\nimport { resolve, dirname, basename } from 'path';\nimport { mkdir, writeFile, rm } from 'fs/promises';\nimport { fileURLToPath } from 'url';\nimport CompilerBase, { Aci } from './Base';\nimport { Encoded } from '../../utils/encoder';\nimport { CompilerError, InternalError, UnsupportedVersionError } from '../../utils/errors';\nimport semverSatisfies from '../../utils/semver-satisfies';\n\nconst getPackagePath = (): string => {\n const path = dirname(fileURLToPath(import.meta.url));\n if (basename(path) === 'dist') return resolve(path, '..');\n if (basename(path) === 'compiler') return resolve(path, '../../..');\n throw new InternalError('Can\\'t get package path');\n};\n\n/**\n * A wrapper around aesophia_cli, available only in Node.js\n * Assumes that `escript` is available in PATH.\n */\nexport default class CompilerCli extends CompilerBase {\n #path: string;\n\n #ensureCompatibleVersion: Promise<void>;\n\n constructor(\n compilerPath = resolve(getPackagePath(), './bin/aesophia_cli'),\n { ignoreVersion }: { ignoreVersion?: boolean } = {},\n ) {\n super();\n this.#path = compilerPath;\n if (ignoreVersion !== true) {\n this.#ensureCompatibleVersion = this.version().then((version) => {\n const versions = [version, '7.0.1', '8.0.0'] as const;\n if (!semverSatisfies(...versions)) throw new UnsupportedVersionError('compiler', ...versions);\n });\n }\n }\n\n async #run(...parameters: string[]): Promise<string> {\n return new Promise((pResolve, pReject) => {\n execFile('escript', [this.#path, ...parameters], (error, stdout, stderr) => {\n if (error != null) pReject(error);\n else if (stderr !== '') pReject(new CompilerError(stderr));\n else pResolve(stdout);\n });\n });\n }\n\n static async #saveContractToTmpDir(\n sourceCode: string,\n fileSystem: Record<string, string> = {},\n ): Promise<string> {\n const randomName = (): string => Math.random().toString(36).slice(2);\n const path = resolve(tmpdir(), `aepp-sdk-js-${randomName()}`);\n await mkdir(path);\n const sourceCodePath = resolve(path, `${randomName()}.aes`);\n await writeFile(sourceCodePath, sourceCode);\n await Promise.all(Object.entries(fileSystem)\n .map(async ([name, src]) => {\n const p = resolve(path, name);\n await mkdir(dirname(p), { recursive: true });\n return writeFile(p, src);\n }));\n return sourceCodePath;\n }\n\n async compile(path: string): Promise<{\n bytecode: Encoded.ContractBytearray;\n aci: Aci;\n }> {\n await this.#ensureCompatibleVersion;\n let bytecode;\n let aciCli;\n try {\n [bytecode, aciCli] = await Promise.all([\n this.#run(path),\n this.#run('--create_json_aci', path).then((res) => JSON.parse(res)),\n ]);\n } catch (error) {\n throw new CompilerError(error.message);\n }\n const aci = {\n encodedAci: aciCli[0],\n externalEncodedAci: aciCli.slice(1),\n };\n return {\n bytecode: bytecode.trimEnd() as Encoded.ContractBytearray,\n aci: aci as Aci,\n };\n }\n\n async compileBySourceCode(sourceCode: string, fileSystem?: Record<string, string>): Promise<{\n bytecode: Encoded.ContractBytearray;\n aci: Aci;\n }> {\n const tmp = await CompilerCli.#saveContractToTmpDir(sourceCode, fileSystem);\n try {\n return await this.compile(tmp);\n } finally {\n await rm(dirname(tmp), { recursive: true });\n }\n }\n\n async validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean> {\n await this.#ensureCompatibleVersion;\n try {\n return (await this.#run(path, '--validate', bytecode)).includes('Validation successful.');\n } catch (error) {\n return false;\n }\n }\n\n async validateBySourceCode(\n bytecode: Encoded.ContractBytearray,\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<boolean> {\n const tmp = await CompilerCli.#saveContractToTmpDir(sourceCode, fileSystem);\n try {\n return await this.validate(bytecode, tmp);\n } finally {\n await rm(dirname(tmp), { recursive: true });\n }\n }\n\n async version(): Promise<string> {\n const verMessage = await this.#run('--version');\n const ver = verMessage.match(/Sophia compiler version ([\\d.]+)\\n/)?.[1];\n if (ver == null) throw new CompilerError('Can\\'t get compiler version');\n return ver;\n }\n}\n"],"mappings":";;;;;;;;AAAA,2BAAyB,eAAe;AAAC;EAAA;AAAA;AACzC,gBAAuB,IAAI;AAAC;EAAA;AAAA;AAC5B,kBAA2C,MAAM;AAAC;EAAA;EAAA;EAAA;AAAA;AAClD,wBAAqC,aAAa;AAAC;EAAA;EAAA;EAAA;AAAA;AACnD,iBAA8B,KAAK;AAAC;EAAA;AAAA;AAAA,OAC7BA,YAAY;AAAA,SAEVC,aAAa,EAAEC,aAAa,EAAEC,uBAAuB;AAAA,OACvDC,eAAe;AAEtB,MAAMC,cAAc,GAAG,MAAc;EACnC,MAAMC,IAAI,GAAGC,OAAO,CAACC,aAAa,CAACC,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC,CAAC;EACpD,IAAIC,QAAQ,CAACN,IAAI,CAAC,KAAK,MAAM,EAAE,OAAOO,OAAO,CAACP,IAAI,EAAE,IAAI,CAAC;EACzD,IAAIM,QAAQ,CAACN,IAAI,CAAC,KAAK,UAAU,EAAE,OAAOO,OAAO,CAACP,IAAI,EAAE,UAAU,CAAC;EACnE,MAAM,IAAIJ,aAAa,CAAC,yBAAyB,CAAC;AACpD,CAAC;;AAED;AACA;AACA;AACA;AAHA;AAAA;AAAA;AAIA,eAAe,MAAMY,WAAW,SAASd,YAAY,CAAC;EAKpDe,WAAW,GAGT;IAAA,IAFAC,YAAY,uEAAGH,OAAO,CAACR,cAAc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AACP,IAAI,EAAE2D,IAAI,CAAC;IAC7B,MAAMN,KAAK,CAACpD,OAAO,CAAC4D,CAAC,CAAC,EAAE;MAAE1B,SAAS,EAAE;IAAK,CAAC,CAAC;IAC5C,OAAOoB,SAAS,CAACM,CAAC,EAAED,GAAG,CAAC;EAC1B,CAAC,CAAC,CAAC;EACL,OAAON,cAAc;AACvB"}
|
|
1
|
+
{"version":3,"file":"Cli.mjs","names":["_child_process","execFile","_os","tmpdir","_path","resolve","dirname","basename","_fsPromises","mkdir","writeFile","rm","_url","fileURLToPath","CompilerBase","CompilerError","InternalError","UnsupportedVersionError","semverSatisfies","getPackagePath","path","import","meta","url","_path2","WeakMap","_ensureCompatibleVersion","_run","WeakSet","CompilerCli","constructor","compilerPath","arguments","length","undefined","ignoreVersion","_classPrivateMethodInitSpec","_classPrivateFieldInitSpec","writable","value","_classPrivateFieldSet","version","then","versions","compile","_classPrivateFieldGet","bytecode","aci","Promise","all","_classPrivateMethodGet","_run2","call","res","JSON","parse","trimEnd","error","message","compileBySourceCode","sourceCode","fileSystem","tmp","_classStaticPrivateMethodGet","_saveContractToTmpDir","recursive","validate","includes","validateBySourceCode","_verMessage$match","verMessage","ver","match","_len","parameters","Array","_key","pResolve","pReject","stdout","stderr","randomName","Math","random","toString","slice","sourceCodePath","Object","entries","map","_ref","name","src","p"],"sources":["../../../src/contract/compiler/Cli.ts"],"sourcesContent":["import { execFile } from 'child_process';\nimport { tmpdir } from 'os';\nimport { resolve, dirname, basename } from 'path';\nimport { mkdir, writeFile, rm } from 'fs/promises';\nimport { fileURLToPath } from 'url';\nimport CompilerBase, { Aci } from './Base';\nimport { Encoded } from '../../utils/encoder';\nimport { CompilerError, InternalError, UnsupportedVersionError } from '../../utils/errors';\nimport semverSatisfies from '../../utils/semver-satisfies';\n\nconst getPackagePath = (): string => {\n const path = dirname(fileURLToPath(import.meta.url));\n if (basename(path) === 'dist') return resolve(path, '..');\n if (basename(path) === 'compiler') return resolve(path, '../../..');\n throw new InternalError('Can\\'t get package path');\n};\n\n/**\n * A wrapper around aesophia_cli, available only in Node.js\n * Assumes that `escript` is available in PATH.\n */\nexport default class CompilerCli extends CompilerBase {\n #path: string;\n\n #ensureCompatibleVersion: Promise<void>;\n\n constructor(\n compilerPath = resolve(getPackagePath(), './bin/aesophia_cli'),\n { ignoreVersion }: { ignoreVersion?: boolean } = {},\n ) {\n super();\n this.#path = compilerPath;\n if (ignoreVersion !== true) {\n this.#ensureCompatibleVersion = this.version().then((version) => {\n const versions = [version, '7.0.1', '8.0.0'] as const;\n if (!semverSatisfies(...versions)) throw new UnsupportedVersionError('compiler', ...versions);\n });\n }\n }\n\n async #run(...parameters: string[]): Promise<string> {\n return new Promise((pResolve, pReject) => {\n execFile('escript', [this.#path, ...parameters], (error, stdout, stderr) => {\n if (error != null) pReject(error);\n else if (stderr !== '') pReject(new CompilerError(stderr));\n else pResolve(stdout);\n });\n });\n }\n\n static async #saveContractToTmpDir(\n sourceCode: string,\n fileSystem: Record<string, string> = {},\n ): Promise<string> {\n const randomName = (): string => Math.random().toString(36).slice(2);\n const path = resolve(tmpdir(), `aepp-sdk-js-${randomName()}`);\n await mkdir(path);\n const sourceCodePath = resolve(path, `${randomName()}.aes`);\n await writeFile(sourceCodePath, sourceCode);\n await Promise.all(Object.entries(fileSystem)\n .map(async ([name, src]) => {\n const p = resolve(path, name);\n await mkdir(dirname(p), { recursive: true });\n return writeFile(p, src);\n }));\n return sourceCodePath;\n }\n\n async compile(path: string): Promise<{\n bytecode: Encoded.ContractBytearray;\n aci: Aci;\n }> {\n await this.#ensureCompatibleVersion;\n try {\n const [bytecode, aci] = await Promise.all([\n this.#run(path),\n this.#run('--create_json_aci', path).then((res) => JSON.parse(res)),\n ]);\n return {\n bytecode: bytecode.trimEnd() as Encoded.ContractBytearray,\n aci: aci as Aci,\n };\n } catch (error) {\n throw new CompilerError(error.message);\n }\n }\n\n async compileBySourceCode(sourceCode: string, fileSystem?: Record<string, string>): Promise<{\n bytecode: Encoded.ContractBytearray;\n aci: Aci;\n }> {\n const tmp = await CompilerCli.#saveContractToTmpDir(sourceCode, fileSystem);\n try {\n return await this.compile(tmp);\n } finally {\n await rm(dirname(tmp), { recursive: true });\n }\n }\n\n async validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean> {\n await this.#ensureCompatibleVersion;\n try {\n return (await this.#run(path, '--validate', bytecode)).includes('Validation successful.');\n } catch (error) {\n return false;\n }\n }\n\n async validateBySourceCode(\n bytecode: Encoded.ContractBytearray,\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<boolean> {\n const tmp = await CompilerCli.#saveContractToTmpDir(sourceCode, fileSystem);\n try {\n return await this.validate(bytecode, tmp);\n } finally {\n await rm(dirname(tmp), { recursive: true });\n }\n }\n\n async version(): Promise<string> {\n const verMessage = await this.#run('--version');\n const ver = verMessage.match(/Sophia compiler version ([\\d.]+)\\n/)?.[1];\n if (ver == null) throw new CompilerError('Can\\'t get compiler version');\n return ver;\n }\n}\n"],"mappings":";;;;;;;;AAAA,OAAAA,cAAA,MAAyB,eAAe;AAAC;EAAAC;AAAA,IAAAD,cAAA;AACzC,OAAAE,GAAA,MAAuB,IAAI;AAAC;EAAAC;AAAA,IAAAD,GAAA;AAC5B,OAAAE,KAAA,MAA2C,MAAM;AAAC;EAAAC,OAAA;EAAAC,OAAA;EAAAC;AAAA,IAAAH,KAAA;AAClD,OAAAI,WAAA,MAAqC,aAAa;AAAC;EAAAC,KAAA;EAAAC,SAAA;EAAAC;AAAA,IAAAH,WAAA;AACnD,OAAAI,IAAA,MAA8B,KAAK;AAAC;EAAAC;AAAA,IAAAD,IAAA;AAAA,OAC7BE,YAAY;AAAA,SAEVC,aAAa,EAAEC,aAAa,EAAEC,uBAAuB;AAAA,OACvDC,eAAe;AAEtB,MAAMC,cAAc,GAAGA,CAAA,KAAc;EACnC,MAAMC,IAAI,GAAGd,OAAO,CAACO,aAAa,CAACQ,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC,CAAC;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AAC,IAAA,IAAuB;IAAA,IAAhB,CAACC,IAAI,EAAEC,GAAG,CAAC,GAAAF,IAAA;IACrB,MAAMG,CAAC,GAAGxF,OAAO,CAACe,IAAI,EAAEuE,IAAI,CAAC;IAC7B,MAAMlF,KAAK,CAACH,OAAO,CAACuF,CAAC,CAAC,EAAE;MAAE5B,SAAS,EAAE;IAAK,CAAC,CAAC;IAC5C,OAAOvD,SAAS,CAACmF,CAAC,EAAED,GAAG,CAAC;EAC1B,CAAC,CAAC,CAAC;EACL,OAAON,cAAc;AACvB"}
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* ISC License (ISC)
|
|
3
|
-
* Copyright (c) 2022 aeternity developers
|
|
4
|
-
*
|
|
5
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
* purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
* copyright notice and this permission notice appear in all copies.
|
|
8
|
-
*
|
|
9
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
-
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
-
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
-
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
-
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
-
* PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
-
*/
|
|
17
1
|
import { RestError } from '@azure/core-rest-pipeline';
|
|
18
2
|
import { Compiler as CompilerApi } from "../../apis/compiler/index.mjs";
|
|
19
3
|
import { genErrorFormatterPolicy, genVersionCheckPolicy } from "../../utils/autorest.mjs";
|
|
@@ -47,7 +31,7 @@ export default class CompilerHttp extends CompilerBase {
|
|
|
47
31
|
}${body.info != null ? ` (${JSON.stringify(body.info)})` : ''}`;
|
|
48
32
|
}
|
|
49
33
|
if (Array.isArray(body)) {
|
|
50
|
-
message += `\n${body.map(e => `${e.type}:${e.pos.line}:${e.pos.col}: ${e.message}${e.context != null ? `(${e.context})` : ''}`).join('\n')}`;
|
|
34
|
+
message += `\n${body.map(e => `${e.type}:${e.pos.line}:${e.pos.col}: ${e.message}${e.context != null ? ` (${e.context})` : ''}`).join('\n')}`;
|
|
51
35
|
}
|
|
52
36
|
return message;
|
|
53
37
|
})]
|
|
@@ -58,28 +42,20 @@ export default class CompilerHttp extends CompilerBase {
|
|
|
58
42
|
apiVersion
|
|
59
43
|
} = _ref;
|
|
60
44
|
return apiVersion;
|
|
61
|
-
});
|
|
62
|
-
this.api.pipeline.addPolicy(genVersionCheckPolicy('compiler', '/api-version', versionPromise, '7.
|
|
45
|
+
}, error => error);
|
|
46
|
+
this.api.pipeline.addPolicy(genVersionCheckPolicy('compiler', '/api-version', versionPromise, '7.1.1', '8.0.0'));
|
|
63
47
|
}
|
|
64
48
|
}
|
|
65
49
|
async compileBySourceCode(sourceCode, fileSystem) {
|
|
66
50
|
try {
|
|
67
|
-
const
|
|
68
|
-
code: sourceCode,
|
|
69
|
-
options: {
|
|
70
|
-
fileSystem
|
|
71
|
-
}
|
|
72
|
-
}).then(res => res.bytecode), this.api.generateACI({
|
|
51
|
+
const res = await this.api.compileContract({
|
|
73
52
|
code: sourceCode,
|
|
74
53
|
options: {
|
|
75
54
|
fileSystem
|
|
76
55
|
}
|
|
77
|
-
})
|
|
56
|
+
});
|
|
78
57
|
// TODO: should be fixed when the compiledAci interface gets updated
|
|
79
|
-
return
|
|
80
|
-
bytecode,
|
|
81
|
-
aci: aci
|
|
82
|
-
};
|
|
58
|
+
return res;
|
|
83
59
|
} catch (error) {
|
|
84
60
|
if (error instanceof RestError && error.statusCode === 400) {
|
|
85
61
|
throw new CompilerError(error.message.replace(/^aci error:/, 'compile error:'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Http.mjs","names":["RestError","Compiler","CompilerApi","genErrorFormatterPolicy","genVersionCheckPolicy","CompilerBase","CompilerError","NotImplementedError","CompilerHttp","constructor","compilerUrl","ignoreVersion","api","allowInsecureConnection","additionalPolicies","body","message","reason","parameter","info","JSON","stringify","Array","isArray","map","e","type","pos","line","col","context","join","versionPromise","apiVersion","then","
|
|
1
|
+
{"version":3,"file":"Http.mjs","names":["RestError","Compiler","CompilerApi","genErrorFormatterPolicy","genVersionCheckPolicy","CompilerBase","CompilerError","NotImplementedError","CompilerHttp","constructor","compilerUrl","ignoreVersion","arguments","length","undefined","api","allowInsecureConnection","additionalPolicies","body","message","reason","parameter","info","JSON","stringify","Array","isArray","map","e","type","pos","line","col","context","join","versionPromise","apiVersion","then","_ref","error","pipeline","addPolicy","compileBySourceCode","sourceCode","fileSystem","res","compileContract","code","options","statusCode","replace","compile","path","validateBySourceCode","bytecode","validateByteCode","source","validate","version"],"sources":["../../../src/contract/compiler/Http.ts"],"sourcesContent":["import { RestError } from '@azure/core-rest-pipeline';\nimport {\n Compiler as CompilerApi,\n ErrorModel,\n CompilerError as CompilerErrorApi,\n} from '../../apis/compiler';\nimport { genErrorFormatterPolicy, genVersionCheckPolicy } from '../../utils/autorest';\nimport CompilerBase, { Aci } from './Base';\nimport { Encoded } from '../../utils/encoder';\nimport { CompilerError, NotImplementedError } from '../../utils/errors';\n\ntype GeneralCompilerError = ErrorModel & {\n info?: object;\n parameter?: string;\n};\n\n/**\n * Contract Compiler over HTTP\n *\n * This class include api call's related to contract compiler functionality.\n * @category contract\n * @example CompilerHttp('COMPILER_URL')\n */\nexport default class CompilerHttp extends CompilerBase {\n readonly api: CompilerApi;\n\n /**\n * @param compilerUrl - Url for compiler API\n * @param options - Options\n * @param options.ignoreVersion - Don't check compiler version\n */\n constructor(compilerUrl: string, { ignoreVersion }: { ignoreVersion?: boolean } = {}) {\n super();\n this.api = new CompilerApi(compilerUrl, {\n allowInsecureConnection: true,\n additionalPolicies: [\n genErrorFormatterPolicy((body: GeneralCompilerError | CompilerErrorApi[]) => {\n let message = '';\n if ('reason' in body) {\n message += ` ${body.reason\n }${body.parameter != null ? ` in ${body.parameter}` : ''\n // TODO: revising after improving documentation https://github.com/aeternity/aesophia_http/issues/78\n }${body.info != null ? ` (${JSON.stringify(body.info)})` : ''}`;\n }\n if (Array.isArray(body)) {\n message += `\\n${body\n .map((e) => `${e.type}:${e.pos.line}:${e.pos.col}: ${e.message}${e.context != null ? ` (${e.context})` : ''}`)\n .join('\\n')}`;\n }\n return message;\n }),\n ],\n });\n if (ignoreVersion !== true) {\n const versionPromise = this.api.apiVersion()\n .then(({ apiVersion }) => apiVersion, (error) => error);\n this.api.pipeline.addPolicy(\n genVersionCheckPolicy('compiler', '/api-version', versionPromise, '7.1.1', '8.0.0'),\n );\n }\n }\n\n async compileBySourceCode(\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<{ bytecode: Encoded.ContractBytearray; aci: Aci }> {\n try {\n const res = await this.api.compileContract({ code: sourceCode, options: { fileSystem } });\n // TODO: should be fixed when the compiledAci interface gets updated\n return res as { bytecode: Encoded.ContractBytearray; aci: Aci };\n } catch (error) {\n if (error instanceof RestError && error.statusCode === 400) {\n throw new CompilerError(error.message.replace(/^aci error:/, 'compile error:'));\n }\n throw error;\n }\n }\n\n // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars\n async compile(path: string): Promise<{ bytecode: Encoded.ContractBytearray; aci: Aci }> {\n throw new NotImplementedError('File system access, use CompilerHttpNode instead');\n }\n\n async validateBySourceCode(\n bytecode: Encoded.ContractBytearray,\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<boolean> {\n try {\n await this.api.validateByteCode({ bytecode, source: sourceCode, options: { fileSystem } });\n return true;\n } catch {\n return false;\n }\n }\n\n // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars\n async validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean> {\n throw new NotImplementedError('File system access, use CompilerHttpNode instead');\n }\n\n async version(): Promise<string> {\n return (await this.api.version()).version;\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,2BAA2B;AAAC,SAEpDC,QAAQ,IAAIC,WAAW;AAAA,SAIhBC,uBAAuB,EAAEC,qBAAqB;AAAA,OAChDC,YAAY;AAAA,SAEVC,aAAa,EAAEC,mBAAmB;AAO3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,YAAY,SAASH,YAAY,CAAC;EAGrD;AACF;AACA;AACA;AACA;EACEI,WAAWA,CAACC,WAAmB,EAAuD;IAAA,IAArD;MAAEC;IAA2C,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAClF,KAAK,EAAE;IACP,IAAI,CAACG,GAAG,GAAG,IAAIb,WAAW,CAACQ,WAAW,EAAE;MACtCM,uBAAuB,EAAE,IAAI;MAC7BC,kBAAkB,EAAE,CAClBd,uBAAuB,CAAEe,IAA+C,IAAK;QAC3E,IAAIC,OAAO,GAAG,EAAE;QAChB,IAAI,QAAQ,IAAID,IAAI,EAAE;UACpBC,OAAO,IAAK,IAAGD,IAAI,CAACE,MACnB,GAAEF,IAAI,CAACG,SAAS,IAAI,IAAI,GAAI,OAAMH,IAAI,CAACG,SAAU,EAAC,GAAG;UACpD;UACD,GAAEH,IAAI,CAACI,IAAI,IAAI,IAAI,GAAI,KAAIC,IAAI,CAACC,SAAS,CAACN,IAAI,CAACI,IAAI,CAAE,GAAE,GAAG,EAAG,EAAC;QACjE;QACA,IAAIG,KAAK,CAACC,OAAO,CAACR,IAAI,CAAC,EAAE;UACvBC,OAAO,IAAK,KAAID,IAAI,CACjBS,GAAG,CAAEC,CAAC,IAAM,GAAEA,CAAC,C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AA8D;IACtF,MAAM,IAAI7C,mBAAmB,CAAC,kDAAkD,CAAC;EACnF;EAEA,MAAM8C,oBAAoBA,CACxBC,QAAmC,EACnCX,UAAkB,EAClBC,UAAmC,EACjB;IAClB,IAAI;MACF,MAAM,IAAI,CAAC7B,GAAG,CAACwC,gBAAgB,CAAC;QAAED,QAAQ;QAAEE,MAAM,EAAEb,UAAU;QAAEK,OAAO,EAAE;UAAEJ;QAAW;MAAE,CAAC,CAAC;MAC1F,OAAO,IAAI;IACb,CAAC,CAAC,MAAM;MACN,OAAO,KAAK;IACd;EACF;;EAEA;EACA,MAAMa,QAAQA,CAACH,QAAmC,EAAEF,IAAY,EAAoB;IAClF,MAAM,IAAI7C,mBAAmB,CAAC,kDAAkD,CAAC;EACnF;EAEA,MAAMmD,OAAOA,CAAA,EAAoB;IAC/B,OAAO,CAAC,MAAM,IAAI,CAAC3C,GAAG,CAAC2C,OAAO,EAAE,EAAEA,OAAO;EAC3C;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpNode.mjs","names":["HttpBrowser","getFileSystem","CompilerHttpNode","compile","path","fileSystem","sourceCode","
|
|
1
|
+
{"version":3,"file":"HttpNode.mjs","names":["_fsPromises","readFile","HttpBrowser","getFileSystem","CompilerHttpNode","compile","path","fileSystem","sourceCode","compileBySourceCode","validate","bytecode","validateBySourceCode"],"sources":["../../../src/contract/compiler/HttpNode.ts"],"sourcesContent":["import { readFile } from 'fs/promises';\nimport HttpBrowser from './Http';\nimport { Aci } from './Base';\nimport { Encoded } from '../../utils/encoder';\nimport getFileSystem from './getFileSystem';\n\n/**\n * Contract Compiler over HTTP for Nodejs\n *\n * Inherits CompilerHttp and implements `compile`, `validate` methods\n * @category contract\n * @example CompilerHttpNode('COMPILER_URL')\n */\nexport default class CompilerHttpNode extends HttpBrowser {\n override async compile(path: string): Promise<{ bytecode: Encoded.ContractBytearray; aci: Aci }> {\n const fileSystem = await getFileSystem(path);\n const sourceCode = await readFile(path, 'utf8');\n return this.compileBySourceCode(sourceCode, fileSystem);\n }\n\n override async validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean> {\n const fileSystem = await getFileSystem(path);\n const sourceCode = await readFile(path, 'utf8');\n return this.validateBySourceCode(bytecode, sourceCode, fileSystem);\n }\n}\n"],"mappings":"AAAA,OAAAA,WAAA,MAAyB,aAAa;AAAC;EAAAC;AAAA,IAAAD,WAAA;AAAA,OAChCE,WAAW;AAAA,OAGXC,aAAa;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,gBAAgB,SAASF,WAAW,CAAC;EACxD,MAAeG,OAAOA,CAACC,IAAY,EAA8D;IAC/F,MAAMC,UAAU,GAAG,MAAMJ,aAAa,CAACG,IAAI,CAAC;IAC5C,MAAME,UAAU,GAAG,MAAMP,QAAQ,CAACK,IAAI,EAAE,MAAM,CAAC;IAC/C,OAAO,IAAI,CAACG,mBAAmB,CAACD,UAAU,EAAED,UAAU,CAAC;EACzD;EAEA,MAAeG,QAAQA,CAACC,QAAmC,EAAEL,IAAY,EAAoB;IAC3F,MAAMC,UAAU,GAAG,MAAMJ,aAAa,CAACG,IAAI,CAAC;IAC5C,MAAME,UAAU,GAAG,MAAMP,QAAQ,CAACK,IAAI,EAAE,MAAM,CAAC;IAC/C,OAAO,IAAI,CAACM,oBAAoB,CAACD,QAAQ,EAAEH,UAAU,EAAED,UAAU,CAAC;EACpE;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileSystem.mjs","names":["InternalError","defaultIncludes","includeRegExp","includesRegExp","RegExp","source","getFileSystemRec","root","relative","
|
|
1
|
+
{"version":3,"file":"getFileSystem.mjs","names":["_fsPromises","readFile","_path","dirname","resolve","basename","InternalError","defaultIncludes","includeRegExp","includesRegExp","RegExp","source","_flagsInstanceProperty","getFileSystemRec","root","relative","_sourceCode$match","sourceCode","filesystem","Promise","all","match","map","include","m","length","filter","includes","includePath","Object","assign","getFileSystem","path"],"sources":["../../../src/contract/compiler/getFileSystem.ts"],"sourcesContent":["import { readFile } from 'fs/promises';\nimport { dirname, resolve, basename } from 'path';\nimport { InternalError } from '../../utils/errors';\n\nconst defaultIncludes = [\n 'List.aes', 'Option.aes', 'String.aes',\n 'Func.aes', 'Pair.aes', 'Triple.aes',\n 'BLS12_381.aes', 'Frac.aes', 'Set.aes',\n 'Bitwise.aes',\n];\nconst includeRegExp = /^include\\s*\"([\\w/.-]+)\"/mi;\nconst includesRegExp = new RegExp(includeRegExp.source, `${includeRegExp.flags}g`);\n\nasync function getFileSystemRec(\n root: string,\n relative: string,\n): Promise<Record<string, string>> {\n const sourceCode = await readFile(resolve(root, relative), 'utf8');\n const filesystem: Record<string, string> = {};\n await Promise.all((sourceCode.match(includesRegExp) ?? [])\n .map((include) => {\n const m = include.match(includeRegExp);\n if (m?.length !== 2) throw new InternalError('Unexpected match length');\n return m[1];\n })\n .filter((include) => !defaultIncludes.includes(include))\n .map(async (include) => {\n const includePath = resolve(root, include);\n filesystem[include] = await readFile(includePath, 'utf8');\n Object.assign(filesystem, await getFileSystemRec(root, include));\n }));\n return filesystem;\n}\n\n/**\n * Reads all files included in the provided contract\n * Available only in Node.js\n * @param path - a path to the main contract source code\n */\nexport default async function getFileSystem(path: string): Promise<Record<string, string>> {\n return getFileSystemRec(dirname(path), basename(path));\n}\n"],"mappings":";AAAA,OAAAA,WAAA,MAAyB,aAAa;AAAC;EAAAC;AAAA,IAAAD,WAAA;AACvC,OAAAE,KAAA,MAA2C,MAAM;AAAC;EAAAC,OAAA;EAAAC,OAAA;EAAAC;AAAA,IAAAH,KAAA;AAAA,SACzCI,aAAa;AAEtB,MAAMC,eAAe,GAAG,CACtB,UAAU,EAAE,YAAY,EAAE,YAAY,EACtC,UAAU,EAAE,UAAU,EAAE,YAAY,EACpC,eAAe,EAAE,UAAU,EAAE,SAAS,EACtC,aAAa,CACd;AACD,MAAMC,aAAa,GAAG,2BAA2B;AACjD,MAAMC,cAAc,GAAG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AACV,OAAO,CAAC6B,IAAI,CAAC,EAAE3B,QAAQ,CAAC2B,IAAI,CAAC,CAAC;AACxD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Encoded } from '../utils/encoder';
|
|
2
|
+
import { AensName } from '../tx/builder/constants';
|
|
3
|
+
import AccountBase from '../account/Base';
|
|
4
|
+
import Node from '../Node';
|
|
5
|
+
/**
|
|
6
|
+
* Helper to generate a signature to delegate
|
|
7
|
+
* - pre-claim/claim/transfer/revoke of a name to a contract.
|
|
8
|
+
* - register/extend/respond of an Oracle to a contract.
|
|
9
|
+
* @category contract
|
|
10
|
+
* @param contractAddress - Address of contract to delegate access
|
|
11
|
+
* @param ids - The list of id's to prepend
|
|
12
|
+
* @param options - Options
|
|
13
|
+
* @param options.omitAddress - Prepend delegation signature with an account address
|
|
14
|
+
* @param options.onAccount - Account to use
|
|
15
|
+
* @param options.onNode - Node to use
|
|
16
|
+
* @returns Signature
|
|
17
|
+
* @example
|
|
18
|
+
* ```js
|
|
19
|
+
* const aeSdk = new AeSdk({ ... })
|
|
20
|
+
* const contractAddress = 'ct_asd2ks...'
|
|
21
|
+
* const aensName = 'example.chain'
|
|
22
|
+
* const onAccount = new MemoryAccount(...) // Sign with a specific account
|
|
23
|
+
* // Preclaim signature
|
|
24
|
+
* const preclaimSig = await aeSdk.createDelegationSignature(contractAddress, [], { onAccount })
|
|
25
|
+
* // Claim, transfer and revoke signature
|
|
26
|
+
* const aensDelegationSig = await aeSdk
|
|
27
|
+
* .createDelegationSignature(contractAddress, [aensName], { onAccount })
|
|
28
|
+
*
|
|
29
|
+
* const oracleQueryId = 'oq_...'
|
|
30
|
+
* const onAccount = new MemoryAccount(...) // Sign with a specific account
|
|
31
|
+
* // Oracle register and extend signature
|
|
32
|
+
* const oracleDelegationSig = await aeSdk
|
|
33
|
+
* .createDelegationSignature(contractAddress, [], { onAccount })
|
|
34
|
+
* // Oracle respond signature
|
|
35
|
+
* const respondSig = await aeSdk
|
|
36
|
+
* .createDelegationSignature(contractAddress, [oracleQueryId], { onAccount, omitAddress: true })
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export default function createDelegationSignature(contractAddress: Encoded.ContractAddress, ids: Array<Encoded.Any | AensName>, options: {
|
|
40
|
+
omitAddress?: boolean;
|
|
41
|
+
onAccount: AccountBase;
|
|
42
|
+
onNode: Node;
|
|
43
|
+
}): Promise<Uint8Array>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import _buffer from "buffer";
|
|
2
|
+
const {
|
|
3
|
+
Buffer: _Buffer
|
|
4
|
+
} = _buffer;
|
|
5
|
+
import { decode } from "../utils/encoder.mjs";
|
|
6
|
+
import { concatBuffers } from "../utils/other.mjs";
|
|
7
|
+
import { isNameValid, produceNameId } from "../tx/builder/helpers.mjs";
|
|
8
|
+
/**
|
|
9
|
+
* Helper to generate a signature to delegate
|
|
10
|
+
* - pre-claim/claim/transfer/revoke of a name to a contract.
|
|
11
|
+
* - register/extend/respond of an Oracle to a contract.
|
|
12
|
+
* @category contract
|
|
13
|
+
* @param contractAddress - Address of contract to delegate access
|
|
14
|
+
* @param ids - The list of id's to prepend
|
|
15
|
+
* @param options - Options
|
|
16
|
+
* @param options.omitAddress - Prepend delegation signature with an account address
|
|
17
|
+
* @param options.onAccount - Account to use
|
|
18
|
+
* @param options.onNode - Node to use
|
|
19
|
+
* @returns Signature
|
|
20
|
+
* @example
|
|
21
|
+
* ```js
|
|
22
|
+
* const aeSdk = new AeSdk({ ... })
|
|
23
|
+
* const contractAddress = 'ct_asd2ks...'
|
|
24
|
+
* const aensName = 'example.chain'
|
|
25
|
+
* const onAccount = new MemoryAccount(...) // Sign with a specific account
|
|
26
|
+
* // Preclaim signature
|
|
27
|
+
* const preclaimSig = await aeSdk.createDelegationSignature(contractAddress, [], { onAccount })
|
|
28
|
+
* // Claim, transfer and revoke signature
|
|
29
|
+
* const aensDelegationSig = await aeSdk
|
|
30
|
+
* .createDelegationSignature(contractAddress, [aensName], { onAccount })
|
|
31
|
+
*
|
|
32
|
+
* const oracleQueryId = 'oq_...'
|
|
33
|
+
* const onAccount = new MemoryAccount(...) // Sign with a specific account
|
|
34
|
+
* // Oracle register and extend signature
|
|
35
|
+
* const oracleDelegationSig = await aeSdk
|
|
36
|
+
* .createDelegationSignature(contractAddress, [], { onAccount })
|
|
37
|
+
* // Oracle respond signature
|
|
38
|
+
* const respondSig = await aeSdk
|
|
39
|
+
* .createDelegationSignature(contractAddress, [oracleQueryId], { onAccount, omitAddress: true })
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export default async function createDelegationSignature(contractAddress, ids, options) {
|
|
43
|
+
return options.onAccount.sign(concatBuffers([_Buffer.from(await options.onNode.getNetworkId()), ...(options.omitAddress === true ? [] : [decode(options.onAccount.address)]), ...ids.map(e => isNameValid(e) ? produceNameId(e) : e).map(e => decode(e)), decode(contractAddress)]), options);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=delegation-signature.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegation-signature.mjs","names":["decode","concatBuffers","isNameValid","produceNameId","createDelegationSignature","contractAddress","ids","options","onAccount","sign","_Buffer","from","onNode","getNetworkId","omitAddress","address","map","e"],"sources":["../../src/contract/delegation-signature.ts"],"sourcesContent":["import { decode, Encoded } from '../utils/encoder';\nimport { AensName } from '../tx/builder/constants';\nimport AccountBase from '../account/Base';\nimport { concatBuffers } from '../utils/other';\nimport { isNameValid, produceNameId } from '../tx/builder/helpers';\nimport Node from '../Node';\n\n/**\n * Helper to generate a signature to delegate\n * - pre-claim/claim/transfer/revoke of a name to a contract.\n * - register/extend/respond of an Oracle to a contract.\n * @category contract\n * @param contractAddress - Address of contract to delegate access\n * @param ids - The list of id's to prepend\n * @param options - Options\n * @param options.omitAddress - Prepend delegation signature with an account address\n * @param options.onAccount - Account to use\n * @param options.onNode - Node to use\n * @returns Signature\n * @example\n * ```js\n * const aeSdk = new AeSdk({ ... })\n * const contractAddress = 'ct_asd2ks...'\n * const aensName = 'example.chain'\n * const onAccount = new MemoryAccount(...) // Sign with a specific account\n * // Preclaim signature\n * const preclaimSig = await aeSdk.createDelegationSignature(contractAddress, [], { onAccount })\n * // Claim, transfer and revoke signature\n * const aensDelegationSig = await aeSdk\n * .createDelegationSignature(contractAddress, [aensName], { onAccount })\n *\n * const oracleQueryId = 'oq_...'\n * const onAccount = new MemoryAccount(...) // Sign with a specific account\n * // Oracle register and extend signature\n * const oracleDelegationSig = await aeSdk\n * .createDelegationSignature(contractAddress, [], { onAccount })\n * // Oracle respond signature\n * const respondSig = await aeSdk\n * .createDelegationSignature(contractAddress, [oracleQueryId], { onAccount, omitAddress: true })\n * ```\n */\nexport default async function createDelegationSignature(\n contractAddress: Encoded.ContractAddress,\n ids: Array<Encoded.Any | AensName>,\n options: { omitAddress?: boolean; onAccount: AccountBase; onNode: Node },\n): Promise<Uint8Array> {\n return options.onAccount.sign(\n concatBuffers([\n Buffer.from(await options.onNode.getNetworkId()),\n ...options.omitAddress === true ? [] : [decode(options.onAccount.address)],\n ...ids.map((e) => (isNameValid(e) ? produceNameId(e) : e)).map((e) => decode(e)),\n decode(contractAddress),\n ]),\n options,\n );\n}\n"],"mappings":";;;;SAASA,MAAM;AAAA,SAGNC,aAAa;AAAA,SACbC,WAAW,EAAEC,aAAa;AAGnC;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;AACA;AACA;AACA;AACA;AACA,eAAe,eAAeC,yBAAyBA,CACrDC,eAAwC,EACxCC,GAAkC,EAClCC,OAAwE,EACnD;EACrB,OAAOA,OAAO,CAACC,SAAS,CAACC,IAAI,CAC3BR,aAAa,CAAC,CACZS,OAAA,CAAOC,IAAI,CAAC,MAAMJ,OAAO,CAACK,MAAM,CAACC,YAAY,EAAE,CAAC,EAChD,IAAGN,OAAO,CAACO,WAAW,KAAK,IAAI,GAAG,EAAE,GAAG,CAACd,MAAM,CAACO,OAAO,CAACC,SAAS,CAACO,OAAO,CAAC,CAAC,GAC1E,GAAGT,GAAG,CAACU,GAAG,CAAEC,CAAC,IAAMf,WAAW,CAACe,CAAC,CAAC,GAAGd,aAAa,CAACc,CAAC,CAAC,GAAGA,CAAE,CAAC,CAACD,GAAG,CAAEC,CAAC,IAAKjB,MAAM,CAACiB,CAAC,CAAC,CAAC,EAChFjB,MAAM,CAACK,eAAe,CAAC,CACxB,CAAC,EACFE,OAAO,CACR;AACH"}
|