@aeternity/aepp-sdk 13.0.0-alpha.0 → 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 +5595 -2249
- 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.d.ts +3 -3
- package/es/AeSdkBase.mjs +4 -0
- package/es/AeSdkBase.mjs.map +1 -1
- package/es/AeSdkMethods.d.ts +12 -14
- 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 +9 -4
- package/es/Node.mjs +12 -6
- package/es/Node.mjs.map +1 -1
- package/es/account/Base.d.ts +13 -8
- package/es/account/Base.mjs +0 -17
- package/es/account/Base.mjs.map +1 -1
- package/es/account/Generalized.mjs +14 -25
- package/es/account/Generalized.mjs.map +1 -1
- package/es/account/Ledger.mjs +2 -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 +11 -22
- 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 +22 -32
- 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.d.ts +1 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +19 -20
- 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 +5 -6
- 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 +17 -9
- package/es/chain.mjs +23 -23
- package/es/chain.mjs.map +1 -1
- package/es/channel/Base.d.ts +27 -9
- package/es/channel/Base.mjs +27 -27
- package/es/channel/Base.mjs.map +1 -1
- package/es/channel/Contract.d.ts +8 -7
- package/es/channel/Contract.mjs +8 -21
- package/es/channel/Contract.mjs.map +1 -1
- package/es/channel/Spend.d.ts +5 -1
- package/es/channel/Spend.mjs +4 -18
- package/es/channel/Spend.mjs.map +1 -1
- package/es/channel/handlers.mjs +16 -26
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/internal.d.ts +19 -2
- package/es/channel/internal.mjs +22 -20
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Contract.d.ts +43 -123
- package/es/contract/Contract.mjs +230 -250
- package/es/contract/Contract.mjs.map +1 -1
- package/es/contract/compiler/Base.d.ts +74 -0
- package/es/contract/compiler/Base.mjs +5 -0
- package/es/contract/compiler/Base.mjs.map +1 -0
- package/es/contract/compiler/Cli.d.ts +23 -0
- package/es/contract/compiler/Cli.mjs +149 -0
- package/es/contract/compiler/Cli.mjs.map +1 -0
- package/es/contract/compiler/Http.d.ts +32 -0
- package/es/contract/compiler/Http.mjs +94 -0
- package/es/contract/compiler/Http.mjs.map +1 -0
- package/es/contract/compiler/HttpNode.d.ts +17 -0
- package/es/contract/compiler/HttpNode.mjs +26 -0
- package/es/contract/compiler/HttpNode.mjs.map +1 -0
- package/es/contract/compiler/getFileSystem.d.ts +6 -0
- package/es/contract/compiler/getFileSystem.mjs +40 -0
- package/es/contract/compiler/getFileSystem.mjs.map +1 -0
- 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 +27 -10
- package/es/contract/ga.mjs +63 -29
- package/es/contract/ga.mjs.map +1 -1
- package/es/index-browser.d.ts +40 -0
- package/es/index-browser.mjs +41 -0
- package/es/index-browser.mjs.map +1 -0
- package/es/index.d.ts +4 -38
- package/es/index.mjs +4 -53
- package/es/index.mjs.map +1 -1
- package/es/oracle.d.ts +12 -17
- package/es/oracle.mjs +29 -49
- package/es/oracle.mjs.map +1 -1
- package/es/spend.d.ts +19 -27
- package/es/spend.mjs +21 -46
- 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 +31 -2
- package/es/tx/builder/constants.mjs +34 -3
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types/abi-version.d.ts +19 -0
- package/es/tx/builder/field-types/abi-version.mjs +40 -0
- package/es/tx/builder/field-types/abi-version.mjs.map +1 -0
- package/es/tx/builder/field-types/address.d.ts +5 -6
- package/es/tx/builder/field-types/address.mjs +17 -8
- package/es/tx/builder/field-types/address.mjs.map +1 -1
- package/es/tx/builder/field-types/array.d.ts +7 -0
- package/es/tx/builder/field-types/array.mjs +11 -0
- package/es/tx/builder/field-types/array.mjs.map +1 -0
- package/es/tx/builder/field-types/boolean.d.ts +6 -0
- package/es/tx/builder/field-types/boolean.mjs +13 -0
- package/es/tx/builder/field-types/boolean.mjs.map +1 -0
- package/es/tx/builder/field-types/coin-amount.d.ts +4 -5
- 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 +49 -0
- package/es/tx/builder/field-types/ct-version.mjs +76 -0
- package/es/tx/builder/field-types/ct-version.mjs.map +1 -0
- package/es/tx/builder/field-types/deposit.d.ts +3 -2
- 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 +6 -0
- package/es/tx/builder/field-types/encoded.mjs +21 -0
- package/es/tx/builder/field-types/encoded.mjs.map +1 -0
- package/es/tx/builder/field-types/entry.d.ts +11 -0
- package/es/tx/builder/field-types/entry.mjs +34 -0
- package/es/tx/builder/field-types/entry.mjs.map +1 -0
- package/es/tx/builder/field-types/enumeration.d.ts +5 -3
- package/es/tx/builder/field-types/enumeration.mjs +11 -2
- package/es/tx/builder/field-types/enumeration.mjs.map +1 -1
- package/es/tx/builder/field-types/fee.d.ts +12 -7
- package/es/tx/builder/field-types/fee.mjs +28 -20
- 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 +7 -3
- package/es/tx/builder/field-types/gas-limit.mjs +13 -8
- 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 +107 -30
- package/es/tx/builder/field-types/index.mjs +38 -12
- 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 +42 -0
- package/es/tx/builder/field-types/mptree.mjs +266 -0
- package/es/tx/builder/field-types/mptree.mjs.map +1 -0
- package/es/tx/builder/field-types/name-fee.d.ts +2 -3
- 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 +2 -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 +2 -2
- package/es/tx/builder/field-types/pointers.mjs.map +1 -1
- package/es/tx/builder/field-types/raw.d.ts +6 -0
- package/es/tx/builder/field-types/raw.mjs +13 -0
- package/es/tx/builder/field-types/raw.mjs.map +1 -0
- package/es/tx/builder/field-types/short-u-int-const.d.ts +7 -0
- package/es/tx/builder/field-types/short-u-int-const.mjs +20 -0
- package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -0
- package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
- package/es/tx/builder/field-types/string.d.ts +6 -0
- package/es/tx/builder/field-types/string.mjs +10 -0
- package/es/tx/builder/field-types/string.mjs.map +1 -0
- 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.d.ts +1 -2
- 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 +18 -36
- package/es/tx/builder/index.mjs +65 -236
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +2734 -1324
- 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 -223
- 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.d.ts +3 -5
- package/es/tx/validator.mjs +91 -153
- 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 +1 -17
- 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 +16 -38
- package/es/utils/errors.mjs +3 -43
- 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.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 +52 -40
- package/src/AeSdkBase.ts +6 -3
- package/src/AeSdkMethods.ts +12 -18
- package/src/AeSdkWallet.ts +1 -1
- package/src/Node.ts +23 -9
- package/src/account/Base.ts +13 -24
- package/src/account/Generalized.ts +9 -24
- package/src/account/Ledger.ts +1 -1
- package/src/account/Memory.ts +15 -22
- package/src/aens.ts +34 -49
- package/src/aepp-wallet-communication/connection/Browser.ts +0 -17
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +18 -24
- 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/RpcClient.ts +2 -2
- 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 +33 -30
- package/src/channel/Base.ts +39 -31
- package/src/channel/Contract.ts +18 -32
- package/src/channel/Spend.ts +8 -18
- package/src/channel/handlers.ts +14 -26
- package/src/channel/internal.ts +41 -23
- package/src/contract/Contract.ts +188 -228
- package/src/contract/compiler/Base.ts +87 -0
- package/src/contract/compiler/Cli.ts +128 -0
- package/src/contract/compiler/Http.ts +105 -0
- package/src/contract/compiler/HttpNode.ts +26 -0
- package/src/contract/compiler/getFileSystem.ts +42 -0
- package/src/contract/delegation-signature.ts +56 -0
- package/src/contract/ga.ts +61 -37
- package/src/index-browser.ts +50 -0
- package/src/index.ts +4 -56
- package/src/oracle.ts +47 -57
- package/src/spend.ts +34 -68
- package/src/tx/builder/SchemaTypes.ts +79 -0
- package/src/tx/builder/constants.ts +34 -3
- package/src/tx/builder/field-types/abi-version.ts +44 -0
- package/src/tx/builder/field-types/address.ts +23 -13
- package/src/tx/builder/field-types/array.ts +19 -0
- package/src/tx/builder/field-types/boolean.ts +9 -0
- package/src/tx/builder/field-types/coin-amount.ts +8 -5
- package/src/tx/builder/field-types/ct-version.ts +83 -0
- package/src/tx/builder/field-types/deposit.ts +4 -2
- package/src/tx/builder/field-types/encoded.ts +27 -0
- package/src/tx/builder/field-types/entry.ts +36 -0
- package/src/tx/builder/field-types/enumeration.ts +15 -4
- package/src/tx/builder/field-types/fee.ts +41 -19
- package/src/tx/builder/field-types/gas-limit.ts +13 -8
- package/src/tx/builder/field-types/index.ts +60 -17
- package/src/tx/builder/field-types/map.ts +45 -0
- package/src/tx/builder/field-types/mptree.ts +243 -0
- package/src/tx/builder/field-types/name-fee.ts +3 -3
- package/src/tx/builder/field-types/name-id.ts +1 -1
- package/src/tx/builder/field-types/nonce.ts +40 -0
- package/src/tx/builder/field-types/pointers.ts +2 -2
- package/src/tx/builder/field-types/raw.ts +9 -0
- package/src/tx/builder/field-types/short-u-int-const.ts +30 -0
- package/src/tx/builder/field-types/string.ts +11 -0
- package/src/tx/builder/field-types/ttl.ts +24 -0
- package/src/tx/builder/field-types/u-int.ts +1 -3
- package/src/tx/builder/field-types/wrapped.ts +32 -0
- package/src/tx/builder/index.ts +82 -280
- package/src/tx/builder/schema.generated.ts +2013 -0
- package/src/tx/builder/schema.ts +536 -666
- package/src/tx/execution-cost.ts +146 -0
- package/src/tx/transaction-signer.ts +27 -0
- package/src/tx/validator.ts +100 -154
- package/src/utils/amount-formatter.ts +0 -16
- package/src/utils/autorest.ts +52 -11
- package/src/utils/bytes.ts +1 -17
- package/src/utils/crypto.ts +0 -16
- package/src/utils/errors.ts +18 -56
- package/src/utils/string.ts +0 -17
- package/types-legacy/ts4.2/AeSdkBase.d.ts +3 -3
- package/types-legacy/ts4.2/AeSdkMethods.d.ts +12 -14
- package/types-legacy/ts4.2/Node.d.ts +8 -4
- package/types-legacy/ts4.2/account/Base.d.ts +13 -8
- 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/connection/BrowserRuntime.d.ts +1 -0
- 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 +17 -9
- package/types-legacy/ts4.2/channel/Base.d.ts +27 -9
- package/types-legacy/ts4.2/channel/Contract.d.ts +8 -7
- package/types-legacy/ts4.2/channel/Spend.d.ts +5 -1
- package/types-legacy/ts4.2/channel/internal.d.ts +22 -2
- package/types-legacy/ts4.2/contract/Contract.d.ts +42 -122
- package/types-legacy/ts4.2/contract/compiler/Base.d.ts +74 -0
- package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +23 -0
- package/types-legacy/ts4.2/contract/compiler/Http.d.ts +32 -0
- package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +17 -0
- package/types-legacy/ts4.2/contract/compiler/getFileSystem.d.ts +6 -0
- package/types-legacy/ts4.2/contract/delegation-signature.d.ts +43 -0
- package/types-legacy/ts4.2/contract/ga.d.ts +27 -10
- package/types-legacy/ts4.2/index-browser.d.ts +40 -0
- package/types-legacy/ts4.2/index.d.ts +4 -38
- 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 +31 -2
- package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +19 -0
- package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +11 -12
- package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +7 -0
- package/types-legacy/ts4.2/tx/builder/field-types/boolean.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +4 -5
- package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +72 -0
- package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +3 -2
- package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/entry.d.ts +11 -0
- package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +5 -3
- package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +12 -7
- package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +7 -3
- 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 +113 -30
- 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 +48 -0
- package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +2 -3
- package/types-legacy/ts4.2/tx/builder/field-types/nonce.d.ts +14 -0
- package/types-legacy/ts4.2/tx/builder/field-types/raw.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +7 -0
- package/types-legacy/ts4.2/tx/builder/field-types/string.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +11 -0
- package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +1 -2
- package/types-legacy/ts4.2/tx/builder/field-types/wrapped.d.ts +14 -0
- package/types-legacy/ts4.2/tx/builder/index.d.ts +21 -36
- package/types-legacy/ts4.2/tx/builder/schema.d.ts +2971 -2926
- 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/tx/validator.d.ts +3 -5
- package/types-legacy/ts4.2/utils/autorest.d.ts +3 -2
- package/types-legacy/ts4.2/utils/errors.d.ts +16 -38
- package/types-legacy/ts4.5/AeSdkBase.d.ts +3 -3
- package/types-legacy/ts4.5/AeSdkMethods.d.ts +12 -14
- package/types-legacy/ts4.5/Node.d.ts +8 -4
- package/types-legacy/ts4.5/account/Base.d.ts +13 -8
- 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/connection/BrowserRuntime.d.ts +1 -0
- 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 +17 -9
- package/types-legacy/ts4.5/channel/Base.d.ts +27 -9
- package/types-legacy/ts4.5/channel/Contract.d.ts +8 -7
- package/types-legacy/ts4.5/channel/Spend.d.ts +5 -1
- package/types-legacy/ts4.5/channel/internal.d.ts +22 -2
- package/types-legacy/ts4.5/contract/Contract.d.ts +42 -122
- package/types-legacy/ts4.5/contract/compiler/Base.d.ts +74 -0
- package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +23 -0
- package/types-legacy/ts4.5/contract/compiler/Http.d.ts +32 -0
- package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +17 -0
- package/types-legacy/ts4.5/contract/compiler/getFileSystem.d.ts +6 -0
- package/types-legacy/ts4.5/contract/delegation-signature.d.ts +43 -0
- package/types-legacy/ts4.5/contract/ga.d.ts +27 -10
- package/types-legacy/ts4.5/index-browser.d.ts +40 -0
- package/types-legacy/ts4.5/index.d.ts +4 -38
- 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 +31 -2
- package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +19 -0
- package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +11 -12
- package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +7 -0
- package/types-legacy/ts4.5/tx/builder/field-types/boolean.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +4 -5
- package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +72 -0
- package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +3 -2
- package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/entry.d.ts +11 -0
- package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +5 -3
- package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +12 -7
- package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +7 -3
- 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 +113 -30
- 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 +48 -0
- package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +2 -3
- package/types-legacy/ts4.5/tx/builder/field-types/nonce.d.ts +14 -0
- package/types-legacy/ts4.5/tx/builder/field-types/raw.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +7 -0
- package/types-legacy/ts4.5/tx/builder/field-types/string.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +11 -0
- package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +1 -2
- package/types-legacy/ts4.5/tx/builder/field-types/wrapped.d.ts +14 -0
- package/types-legacy/ts4.5/tx/builder/index.d.ts +21 -36
- package/types-legacy/ts4.5/tx/builder/schema.d.ts +2971 -2926
- 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/tx/validator.d.ts +3 -5
- package/types-legacy/ts4.5/utils/autorest.d.ts +3 -2
- package/types-legacy/ts4.5/utils/errors.d.ts +16 -38
- package/es/contract/CompilerHttp.d.ts +0 -18
- package/es/contract/CompilerHttp.mjs +0 -63
- package/es/contract/CompilerHttp.mjs.map +0 -1
- package/es/tx/builder/field-types/addresses.d.ts +0 -6
- package/es/tx/builder/field-types/addresses.mjs +0 -13
- package/es/tx/builder/field-types/addresses.mjs.map +0 -1
- package/es/tx/index.d.ts +0 -34
- package/es/tx/index.mjs +0 -172
- package/es/tx/index.mjs.map +0 -1
- package/es/utils/mptree.d.ts +0 -26
- package/es/utils/mptree.mjs +0 -143
- package/es/utils/mptree.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/contract/CompilerHttp.ts +0 -67
- package/src/tx/builder/field-types/addresses.ts +0 -18
- package/src/tx/index.ts +0 -196
- package/src/utils/mptree.ts +0 -145
- package/types-legacy/ts4.2/contract/CompilerHttp.d.ts +0 -18
- package/types-legacy/ts4.2/tx/builder/field-types/addresses.d.ts +0 -6
- package/types-legacy/ts4.2/tx/index.d.ts +0 -34
- package/types-legacy/ts4.2/utils/mptree.d.ts +0 -32
- package/types-legacy/ts4.5/contract/CompilerHttp.d.ts +0 -18
- package/types-legacy/ts4.5/tx/builder/field-types/addresses.d.ts +0 -6
- package/types-legacy/ts4.5/tx/index.d.ts +0 -34
- package/types-legacy/ts4.5/utils/mptree.d.ts +0 -32
package/es/Node.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Node.mjs","names":["BigNumber","genRequestQueuesPolicy","genCombineGetRequestsPolicy","genErrorFormatterPolicy","genVersionCheckPolicy","Node","NodeApi","mapObject","bigIntPropertyNames","numberPropertyNames","NodeTransformed","sendOperationRequest","operationArguments","operationSpec","args","key","value","data","transform","Array","isArray","map","d","some","k","bigInt","number","toFixed","toString","BigInt","constructor","url","ignoreVersion","options","allowInsecureConnection","additionalPolicies","body","reason","statusPromise","getStatus","versionPromise","then","nodeVersion","networkId","pipeline","addPolicy","intAsString","getNetworkId","getNodeInfo","version","nodeNetworkId","protocols","topBlockHeight","consensusProtocolVersion","filter","effectiveAtHeight","reduce","acc","p","$host"],"sources":["../src/Node.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport BigNumber from 'bignumber.js';\nimport { OperationArguments, OperationSpec } from '@azure/core-client';\nimport {\n genRequestQueuesPolicy, genCombineGetRequestsPolicy, genErrorFormatterPolicy,\n genVersionCheckPolicy,\n} from './utils/autorest';\nimport { Node as NodeApi, NodeOptionalParams, ErrorModel } from './apis/node';\nimport { mapObject } from './utils/other';\nimport { Encoded } from './utils/encoder';\n\nconst bigIntPropertyNames = [\n 'balance', 'queryFee', 'fee', 'amount', 'nameFee', 'channelAmount',\n 'initiatorAmount', 'responderAmount', 'channelReserve', 'initiatorAmountFinal',\n 'responderAmountFinal', 'gasPrice', 'deposit',\n] as const;\n\nconst numberPropertyNames = [\n 'time', 'gas', 'gasUsed', 'nameSalt',\n 'nonce', 'nextNonce', 'height', 'blockHeight', 'top', 'topBlockHeight',\n 'ttl', 'nameTtl', 'clientTtl',\n 'inbound', 'outbound', 'peerCount', 'pendingTransactionsCount', 'effectiveAtHeight',\n 'version', 'solutions', 'round',\n] as const;\n\nclass NodeTransformed extends NodeApi {\n override async sendOperationRequest(\n operationArguments: OperationArguments,\n operationSpec: OperationSpec,\n ): Promise<any> {\n const args = mapObject(\n operationArguments,\n ([key, value]) => [key, this.#encodeArg(value)],\n ) as OperationArguments;\n return this.#decodeRes(await super.sendOperationRequest(args, operationSpec));\n }\n\n #mapData(data: any, transform: {\n bigInt: (v: any) => any;\n number: (v: any) => any;\n }): unknown {\n if (Array.isArray(data)) return data.map((d) => this.#mapData(d, transform));\n if (data != null && typeof data === 'object') {\n return mapObject(data, ([key, value]) => {\n if (value == null) return [key, value];\n if (bigIntPropertyNames.some((k) => k === key)) return [key, transform.bigInt(value)];\n if (numberPropertyNames.some((k) => k === key)) return [key, transform.number(value)];\n return [key, this.#mapData(value, transform)];\n });\n }\n return data;\n }\n\n #encodeArg(data: any): any {\n return this.#mapData(data, {\n bigInt: (value) => {\n if (value instanceof BigNumber) return value.toFixed();\n return value.toString();\n },\n number: (value) => value.toString(),\n });\n }\n\n #decodeRes(data: any): any {\n return this.#mapData(data, {\n bigInt: (value) => BigInt(value),\n number: (value) => +value,\n });\n }\n}\n\ntype BigIntPropertyNames = typeof bigIntPropertyNames[number];\ntype NumberPropertyNames = typeof numberPropertyNames[number];\ntype PreserveOptional<NewType, OrigType> =\n OrigType extends undefined ? NewType | undefined : NewType;\nexport type TransformNodeType<Type> =\n Type extends (...args: infer Args) => infer Ret\n ? (...args: TransformNodeType<Args>) => TransformNodeType<Ret>\n : Type extends [infer Item, ...infer Rest]\n ? [TransformNodeType<Item>, ...TransformNodeType<Rest>]\n : Type extends Array<infer Item>\n ? Array<TransformNodeType<Item>>\n : Type extends Promise<infer T>\n ? Promise<TransformNodeType<T>>\n : Type extends { [P in any]: any }\n ? {\n [Property in keyof Type]:\n Property extends BigIntPropertyNames\n ? PreserveOptional<bigint, Type[Property]>\n : Property extends NumberPropertyNames\n ? PreserveOptional<number, Type[Property]>\n : Property extends 'txHash'\n ? PreserveOptional<Encoded.TxHash, Type[Property]>\n : TransformNodeType<Type[Property]>\n }\n : Type;\ntype NodeTransformedApi = new (...args: ConstructorParameters<typeof NodeApi>) => {\n [Name in keyof InstanceType<typeof NodeApi>]:\n Name extends 'pipeline' | 'sendRequest' | 'sendOperationRequest'\n ? NodeApi[Name] : TransformNodeType<NodeApi[Name]>\n};\n\nexport interface NodeInfo {\n url: string;\n nodeNetworkId: string;\n version: string;\n consensusProtocolVersion: number;\n}\n\nexport default class Node extends (NodeTransformed as unknown as NodeTransformedApi) {\n #networkIdPromise?: Promise<string>;\n\n /**\n * @param url - Url for node API\n * @param options - Options\n * @param options.ignoreVersion - Don't check node version\n */\n constructor(\n url: string,\n { ignoreVersion = false, ...options }: NodeOptionalParams & { ignoreVersion?: boolean } = {},\n ) {\n // eslint-disable-next-line constructor-super\n super(url, {\n allowInsecureConnection: true,\n additionalPolicies: [\n genRequestQueuesPolicy(),\n genCombineGetRequestsPolicy(),\n genErrorFormatterPolicy((body: ErrorModel) => ` ${body.reason}`),\n ],\n ...options,\n });\n if (!ignoreVersion) {\n const statusPromise = this.getStatus();\n const versionPromise = statusPromise.then(({ nodeVersion }) => nodeVersion);\n this.#networkIdPromise = statusPromise.then(({ networkId }) => networkId);\n this.pipeline.addPolicy(\n genVersionCheckPolicy('node', '/v3/status', versionPromise, '6.2.0', '7.0.0'),\n );\n }\n this.intAsString = true;\n }\n\n async getNetworkId(): Promise<string> {\n this.#networkIdPromise ??= this.getStatus().then(({ networkId }) => networkId);\n return this.#networkIdPromise;\n }\n\n async getNodeInfo(): Promise<NodeInfo> {\n const {\n nodeVersion: version,\n networkId: nodeNetworkId,\n protocols,\n topBlockHeight,\n } = await this.getStatus();\n const consensusProtocolVersion = protocols\n .filter(({ effectiveAtHeight }) => topBlockHeight >= effectiveAtHeight)\n .reduce(\n (acc, p) => (p.effectiveAtHeight > acc.effectiveAtHeight ? p : acc),\n { effectiveAtHeight: -1, version: 0 },\n )\n .version;\n return {\n url: this.$host,\n nodeNetworkId,\n version,\n consensusProtocolVersion,\n };\n }\n}\n"],"mappings":";;;;;;AAAA;AACA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAGnCC,sBAAsB,EAAEC,2BAA2B,EAAEC,uBAAuB,EAC5EC,qBAAqB;AAAA,SAEdC,IAAI,IAAIC,OAAO;AAAA,SACfC,SAAS;AAGlB,MAAMC,mBAAmB,GAAG,CAC1B,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAClE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,sBAAsB,EAC9E,sBAAsB,EAAE,UAAU,EAAE,SAAS,CACrC;AAEV,MAAMC,mBAAmB,GAAG,CAC1B,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EACpC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,gBAAgB,EACtE,KAAK,EAAE,SAAS,EAAE,WAAW,EAC7B,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,0BAA0B,EAAE,mBAAmB,EACnF,SAAS,EAAE,WAAW,EAAE,OAAO,CACvB;AAAC;AAAA;AAAA;AAEX,MAAMC,eAAe,SAASJ,OAAO,CAAC;EAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EACpC,MAAeK,oBAAoB,CACjCC,kBAAsC,EACtCC,aAA4B,EACd;IACd,MAAMC,IAAI,GAAGP,SAAS,CACpBK,kBAAkB,EAClB;MAAA,I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,OAAO,EAAE,OAAO,CAAC,CAC9E;IACH;IACA,IAAI,CAACM,WAAW,GAAG,IAAI;EACzB;EAEA,MAAMC,YAAY,GAAoB;IAAA;IACpC,oDAAI,qHAAJ,IAAI,qBAAuB,IAAI,CAACR,SAAS,EAAE,CAACE,IAAI,CAAC;MAAA,IAAC;QAAEE;MAAU,CAAC;MAAA,OAAKA,SAAS;IAAA,EAAC;IAC9E,6BAAO,IAAI;EACb;EAEA,MAAMK,WAAW,GAAsB;IACrC,MAAM;MACJN,WAAW,EAAEO,OAAO;MACpBN,SAAS,EAAEO,aAAa;MACxBC,SAAS;MACTC;IACF,CAAC,GAAG,MAAM,IAAI,CAACb,SAAS,EAAE;IAC1B,MAAMc,wBAAwB,GAAGF,SAAS,CACvCG,MAAM,CAAC;MAAA,IAAC;QAAEC;MAAkB,CAAC;MAAA,OAAKH,cAAc,IAAIG,iBAAiB;IAAA,EAAC,CACtEC,MAAM,CACL,CAACC,GAAG,EAAEC,CAAC,KAAMA,CAAC,CAACH,iBAAiB,GAAGE,GAAG,CAACF,iBAAiB,GAAGG,CAAC,GAAGD,GAAI,EACnE;MAAEF,iBAAiB,EAAE,CAAC,CAAC;MAAEN,OAAO,EAAE;IAAE,CAAC,CACtC,CACAA,OAAO;IACV,OAAO;MACLlB,GAAG,EAAE,IAAI,CAAC4B,KAAK;MACfT,aAAa;MACbD,OAAO;MACPI;IACF,CAAC;EACH;AACF"}
|
|
1
|
+
{"version":3,"file":"Node.mjs","names":["BigNumber","genRequestQueuesPolicy","genCombineGetRequestsPolicy","genErrorFormatterPolicy","genVersionCheckPolicy","genRetryOnFailurePolicy","Node","NodeApi","mapObject","bigIntPropertyNames","numberPropertyNames","_mapData","WeakSet","_encodeArg","_decodeRes","NodeTransformed","constructor","arguments","_classPrivateMethodInitSpec","sendOperationRequest","operationArguments","operationSpec","args","_ref","key","value","_classPrivateMethodGet","_encodeArg2","call","_decodeRes2","_mapData2","data","transform","Array","isArray","map","d","_ref6","some","k","bigInt","number","toFixed","toString","BigInt","_networkIdPromise","WeakMap","url","ignoreVersion","retryCount","retryOverallDelay","options","length","undefined","allowInsecureConnection","additionalPolicies","body","reason","_classPrivateFieldInitSpec","writable","statusPromise","getStatus","versionPromise","then","_ref2","nodeVersion","error","_classPrivateFieldSet","_ref3","networkId","pipeline","addPolicy","intAsString","getNetworkId","_classPrivateFieldGet2","_classPrivateFieldGet","_ref4","Error","getNodeInfo","version","nodeNetworkId","protocols","topBlockHeight","consensusProtocolVersion","filter","_ref5","effectiveAtHeight","reduce","acc","p","$host"],"sources":["../src/Node.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport BigNumber from 'bignumber.js';\nimport { OperationArguments, OperationSpec } from '@azure/core-client';\nimport {\n genRequestQueuesPolicy, genCombineGetRequestsPolicy, genErrorFormatterPolicy,\n genVersionCheckPolicy, genRetryOnFailurePolicy,\n} from './utils/autorest';\nimport { Node as NodeApi, NodeOptionalParams, ErrorModel } from './apis/node';\nimport { mapObject } from './utils/other';\nimport { Encoded } from './utils/encoder';\nimport { ConsensusProtocolVersion } from './tx/builder/constants';\n\nconst bigIntPropertyNames = [\n 'balance', 'queryFee', 'fee', 'amount', 'nameFee', 'channelAmount',\n 'initiatorAmount', 'responderAmount', 'channelReserve', 'initiatorAmountFinal',\n 'responderAmountFinal', 'gasPrice', 'deposit',\n] as const;\n\nconst numberPropertyNames = [\n 'time', 'gas', 'gasUsed', 'nameSalt',\n 'nonce', 'nextNonce', 'height', 'blockHeight', 'topBlockHeight',\n 'ttl', 'nameTtl', 'clientTtl',\n 'inbound', 'outbound', 'peerCount', 'pendingTransactionsCount', 'effectiveAtHeight',\n 'version', 'solutions', 'round',\n] as const;\n\nclass NodeTransformed extends NodeApi {\n override async sendOperationRequest(\n operationArguments: OperationArguments,\n operationSpec: OperationSpec,\n ): Promise<any> {\n const args = mapObject(\n operationArguments,\n ([key, value]) => [key, this.#encodeArg(value)],\n ) as OperationArguments;\n return this.#decodeRes(await super.sendOperationRequest(args, operationSpec));\n }\n\n #mapData(data: any, transform: {\n bigInt: (v: any) => any;\n number: (v: any) => any;\n }): unknown {\n if (Array.isArray(data)) return data.map((d) => this.#mapData(d, transform));\n if (data != null && typeof data === 'object') {\n return mapObject(data, ([key, value]) => {\n if (value == null) return [key, value];\n if (bigIntPropertyNames.some((k) => k === key)) return [key, transform.bigInt(value)];\n if (numberPropertyNames.some((k) => k === key)) return [key, transform.number(value)];\n return [key, this.#mapData(value, transform)];\n });\n }\n return data;\n }\n\n #encodeArg(data: any): any {\n return this.#mapData(data, {\n bigInt: (value) => {\n if (value instanceof BigNumber) return value.toFixed();\n return value.toString();\n },\n number: (value) => value.toString(),\n });\n }\n\n #decodeRes(data: any): any {\n return this.#mapData(data, {\n bigInt: (value) => BigInt(value),\n number: (value) => +value,\n });\n }\n}\n\ntype BigIntPropertyNames = typeof bigIntPropertyNames[number];\ntype NumberPropertyNames = typeof numberPropertyNames[number];\ntype PreserveOptional<NewType, OrigType> =\n OrigType extends undefined ? NewType | undefined : NewType;\nexport type TransformNodeType<Type> =\n Type extends (...args: infer Args) => infer Ret\n ? (...args: TransformNodeType<Args>) => TransformNodeType<Ret>\n : Type extends [infer Item, ...infer Rest]\n ? [TransformNodeType<Item>, ...TransformNodeType<Rest>]\n : Type extends Array<infer Item>\n ? Array<TransformNodeType<Item>>\n : Type extends Promise<infer T>\n ? Promise<TransformNodeType<T>>\n : Type extends { [P in any]: any }\n ? {\n [Property in keyof Type]:\n Property extends BigIntPropertyNames\n ? PreserveOptional<bigint, Type[Property]>\n : Property extends NumberPropertyNames\n ? PreserveOptional<number, Type[Property]>\n : Property extends 'txHash'\n ? PreserveOptional<Encoded.TxHash, Type[Property]>\n : Property extends 'bytecode'\n ? PreserveOptional<Encoded.ContractBytearray, Type[Property]>\n : TransformNodeType<Type[Property]>\n }\n : Type;\ntype NodeTransformedApi = new (...args: ConstructorParameters<typeof NodeApi>) => {\n [Name in keyof InstanceType<typeof NodeApi>]:\n Name extends 'pipeline' | 'sendRequest' | 'sendOperationRequest'\n ? NodeApi[Name] : TransformNodeType<NodeApi[Name]>\n};\n\nexport interface NodeInfo {\n url: string;\n nodeNetworkId: string;\n version: string;\n consensusProtocolVersion: ConsensusProtocolVersion;\n}\n\nexport default class Node extends (NodeTransformed as unknown as NodeTransformedApi) {\n #networkIdPromise?: Promise<string | Error>;\n\n /**\n * @param url - Url for node API\n * @param options - Options\n * @param options.ignoreVersion - Don't check node version\n * @param options.retryCount - Amount of extra requests to do in case of failure\n * @param options.retryOverallDelay - Time in ms to wait between all retries\n */\n constructor(\n url: string,\n {\n ignoreVersion = false, retryCount = 3, retryOverallDelay = 800, ...options\n }: NodeOptionalParams & {\n ignoreVersion?: boolean;\n retryCount?: number;\n retryOverallDelay?: number;\n } = {},\n ) {\n // eslint-disable-next-line constructor-super\n super(url, {\n allowInsecureConnection: true,\n additionalPolicies: [\n genRequestQueuesPolicy(),\n genCombineGetRequestsPolicy(),\n genRetryOnFailurePolicy(retryCount, retryOverallDelay),\n genErrorFormatterPolicy((body: ErrorModel) => ` ${body.reason}`),\n ],\n ...options,\n });\n if (!ignoreVersion) {\n const statusPromise = this.getStatus();\n const versionPromise = statusPromise.then(({ nodeVersion }) => nodeVersion, (error) => error);\n this.#networkIdPromise = statusPromise.then(({ networkId }) => networkId, (error) => error);\n this.pipeline.addPolicy(\n genVersionCheckPolicy('node', '/v3/status', versionPromise, '6.2.0', '7.0.0'),\n );\n }\n this.intAsString = true;\n }\n\n async getNetworkId(): Promise<string> {\n this.#networkIdPromise ??= this.getStatus().then(({ networkId }) => networkId);\n const networkId = await this.#networkIdPromise;\n if (networkId instanceof Error) throw networkId;\n return networkId;\n }\n\n async getNodeInfo(): Promise<NodeInfo> {\n const {\n nodeVersion: version,\n networkId: nodeNetworkId,\n protocols,\n topBlockHeight,\n } = await this.getStatus();\n const consensusProtocolVersion = protocols\n .filter(({ effectiveAtHeight }) => topBlockHeight >= effectiveAtHeight)\n .reduce(\n (acc, p) => (p.effectiveAtHeight > acc.effectiveAtHeight ? p : acc),\n { effectiveAtHeight: -1, version: 0 },\n )\n .version;\n return {\n url: this.$host,\n nodeNetworkId,\n version,\n consensusProtocolVersion,\n };\n }\n}\n"],"mappings":";;;;;;AAAA;AACA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAGnCC,sBAAsB,EAAEC,2BAA2B,EAAEC,uBAAuB,EAC5EC,qBAAqB,EAAEC,uBAAuB;AAAA,SAEvCC,IAAI,IAAIC,OAAO;AAAA,SACfC,SAAS;AAIlB,MAAMC,mBAAmB,GAAG,CAC1B,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAClE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,sBAAsB,EAC9E,sBAAsB,EAAE,UAAU,EAAE,SAAS,CACrC;AAEV,MAAMC,mBAAmB,GAAG,CAC1B,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EACpC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAC/D,KAAK,EAAE,SAAS,EAAE,WAAW,EAC7B,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,0BAA0B,EAAE,mBAAmB,EACnF,SAAS,EAAE,WAAW,EAAE,OAAO,CACvB;AAAC,IAAAC,QAAA,oBAAAC,OAAA;AAAA,IAAAC,UAAA,oBAAAD,OAAA;AAAA,IAAAE,UAAA,oBAAAF,OAAA;AAEX,MAAMG,eAAe,SAASR,OAAO,CAAC;EAAAS,YAAA;IAAA,SAAAC,SAAA;IAAAC,2BAAA,OAAAJ,UAAA;IAAAI,2BAAA,OAAAL,UAAA;IAAAK,2BAAA,OAAAP,QAAA;EAAA;EACpC,MAAeQ,oBAAoBA,CACjCC,kBAAsC,EACtCC,aAA4B,EACd;IACd,MAAMC,IAAI,GAAGd,SAAS,CACpBY,kBAAkB,EAClBG,IAAA;MAAA,IAAC,CAACC,GAAG,EAAEC,KAA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,KAAK,EAAE,MAAMR,SAAS;IAC/C,OAAOA,SAAS;EAClB;EAEA,MAAMS,WAAWA,CAAA,EAAsB;IACrC,MAAM;MACJb,WAAW,EAAEc,OAAO;MACpBV,SAAS,EAAEW,aAAa;MACxBC,SAAS;MACTC;IACF,CAAC,GAAG,MAAM,IAAI,CAACrB,SAAS,EAAE;IAC1B,MAAMsB,wBAAwB,GAAGF,SAAS,CACvCG,MAAM,CAACC,KAAA;MAAA,IAAC;QAAEC;MAAkB,CAAC,GAAAD,KAAA;MAAA,OAAKH,cAAc,IAAII,iBAAiB;IAAA,EAAC,CACtEC,MAAM,CACL,CAACC,GAAG,EAAEC,CAAC,KAAMA,CAAC,CAACH,iBAAiB,GAAGE,GAAG,CAACF,iBAAiB,GAAGG,CAAC,GAAGD,GAAI,EACnE;MAAEF,iBAAiB,EAAE,CAAC,CAAC;MAAEP,OAAO,EAAE;IAAE,CAAC,CACtC,CACAA,OAAO;IACV,OAAO;MACLhC,GAAG,EAAE,IAAI,CAAC2C,KAAK;MACfV,aAAa;MACbD,OAAO;MACPI;IACF,CAAC;EACH;AACF"}
|
package/es/account/Base.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { Encoded } from '../utils/encoder';
|
|
2
2
|
import Node from '../Node';
|
|
3
|
-
import
|
|
3
|
+
import CompilerBase from '../contract/compiler/Base';
|
|
4
|
+
import { Int } from '../tx/builder/constants';
|
|
5
|
+
interface AuthData {
|
|
6
|
+
fee?: Int;
|
|
7
|
+
gasLimit?: number;
|
|
8
|
+
gasPrice?: Int;
|
|
9
|
+
callData?: Encoded.ContractBytearray;
|
|
10
|
+
sourceCode?: string;
|
|
11
|
+
args?: any[];
|
|
12
|
+
}
|
|
4
13
|
/**
|
|
5
14
|
* Account is one of the three basic building blocks of an
|
|
6
15
|
* {@link AeSdk} and provides access to a signing key pair.
|
|
@@ -17,14 +26,9 @@ export default abstract class AccountBase {
|
|
|
17
26
|
abstract signTransaction(tx: Encoded.Transaction, options: {
|
|
18
27
|
innerTx?: boolean;
|
|
19
28
|
networkId?: string;
|
|
20
|
-
authData?:
|
|
21
|
-
gasLimit?: number;
|
|
22
|
-
callData?: Encoded.ContractBytearray;
|
|
23
|
-
sourceCode?: string;
|
|
24
|
-
args?: any[];
|
|
25
|
-
};
|
|
29
|
+
authData?: AuthData | ((tx: Encoded.Transaction) => Promise<AuthData>);
|
|
26
30
|
onNode?: Node;
|
|
27
|
-
onCompiler?:
|
|
31
|
+
onCompiler?: CompilerBase;
|
|
28
32
|
aeppOrigin?: string;
|
|
29
33
|
aeppRpcClientId?: string;
|
|
30
34
|
}): Promise<Encoded.Transaction>;
|
|
@@ -50,3 +54,4 @@ export default abstract class AccountBase {
|
|
|
50
54
|
*/
|
|
51
55
|
readonly address: Encoded.AccountAddress;
|
|
52
56
|
}
|
|
57
|
+
export {};
|
package/es/account/Base.mjs
CHANGED
|
@@ -1,20 +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
|
-
|
|
18
1
|
/**
|
|
19
2
|
* Account is one of the three basic building blocks of an
|
|
20
3
|
* {@link AeSdk} and provides access to a signing key pair.
|
package/es/account/Base.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Base.mjs","names":["AccountBase"],"sources":["../../src/account/Base.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"Base.mjs","names":["AccountBase"],"sources":["../../src/account/Base.ts"],"sourcesContent":["import { Encoded } from '../utils/encoder';\nimport Node from '../Node';\nimport CompilerBase from '../contract/compiler/Base';\nimport { Int } from '../tx/builder/constants';\n\ninterface AuthData {\n fee?: Int;\n gasLimit?: number;\n gasPrice?: Int;\n callData?: Encoded.ContractBytearray;\n sourceCode?: string;\n args?: any[];\n}\n\n/**\n * Account is one of the three basic building blocks of an\n * {@link AeSdk} and provides access to a signing key pair.\n */\nexport default abstract class AccountBase {\n /**\n * Sign encoded transaction\n * @param tx - Transaction to sign\n * @param options - Options\n * @param options.innerTx - Sign as inner transaction for PayingFor\n * @param options.authData - Object with gaMeta params\n * @returns Signed transaction\n */\n abstract signTransaction(\n tx: Encoded.Transaction,\n options: {\n innerTx?: boolean;\n networkId?: string;\n authData?: AuthData | ((tx: Encoded.Transaction) => Promise<AuthData>);\n onNode?: Node;\n onCompiler?: CompilerBase;\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Encoded.Transaction>;\n\n /**\n * Sign message\n * @param message - Message to sign\n * @param options - Options\n * @returns Signature as hex string of Uint8Array\n */\n abstract signMessage(\n message: string,\n options?: {\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Uint8Array>;\n\n /**\n * Sign data blob\n * @param data - Data blob to sign\n * @param options - Options\n * @returns Signed data blob\n */\n abstract sign(data: string | Uint8Array, options?: any): Promise<Uint8Array>;\n\n /**\n * Account address\n */\n readonly address: Encoded.AccountAddress;\n}\n"],"mappings":"AAcA;AACA;AACA;AACA;AACA,eAAe,MAAeA,WAAW,CAAC"}
|
|
@@ -2,30 +2,13 @@ import _classPrivateFieldSet from "@babel/runtime-corejs3/helpers/classPrivateFi
|
|
|
2
2
|
import _classPrivateFieldGet from "@babel/runtime-corejs3/helpers/classPrivateFieldGet";
|
|
3
3
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
4
4
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
5
|
-
/*
|
|
6
|
-
* ISC License (ISC)
|
|
7
|
-
* Copyright (c) 2022 aeternity developers
|
|
8
|
-
*
|
|
9
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
-
* purpose with or without fee is hereby granted, provided that the above
|
|
11
|
-
* copyright notice and this permission notice appear in all copies.
|
|
12
|
-
*
|
|
13
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
-
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
-
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
-
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
-
* PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
-
*/
|
|
21
5
|
import AccountBase from "./Base.mjs";
|
|
22
6
|
import { ArgumentError, InternalError, InvalidAuthDataError, NotImplementedError } from "../utils/errors.mjs";
|
|
23
7
|
import { decode } from "../utils/encoder.mjs";
|
|
24
8
|
import { getAccount } from "../chain.mjs";
|
|
25
9
|
import Contract from "../contract/Contract.mjs";
|
|
26
|
-
import {
|
|
10
|
+
import { buildTxAsync, buildTx } from "../tx/builder/index.mjs";
|
|
27
11
|
import { Tag } from "../tx/builder/constants.mjs";
|
|
28
|
-
import { buildTx } from "../tx/builder/index.mjs";
|
|
29
12
|
/**
|
|
30
13
|
* Generalized account class
|
|
31
14
|
*/
|
|
@@ -66,8 +49,10 @@ export default class AccountGeneralized extends AccountBase {
|
|
|
66
49
|
callData,
|
|
67
50
|
sourceCode,
|
|
68
51
|
args,
|
|
69
|
-
|
|
70
|
-
|
|
52
|
+
fee,
|
|
53
|
+
gasLimit,
|
|
54
|
+
gasPrice
|
|
55
|
+
} = typeof authData === 'function' ? await authData(tx) : authData;
|
|
71
56
|
const authCallData = callData !== null && callData !== void 0 ? callData : await (async () => {
|
|
72
57
|
if (_classPrivateFieldGet(this, _authFun) == null) {
|
|
73
58
|
const account = await getAccount(this.address, {
|
|
@@ -91,21 +76,25 @@ export default class AccountGeneralized extends AccountBase {
|
|
|
91
76
|
});
|
|
92
77
|
return contract._calldata.encode(contract._name, _classPrivateFieldGet(this, _authFun), args);
|
|
93
78
|
})();
|
|
94
|
-
const gaMetaTx = await
|
|
95
|
-
|
|
79
|
+
const gaMetaTx = await buildTxAsync({
|
|
80
|
+
tag: Tag.GaMetaTx,
|
|
81
|
+
tx: {
|
|
82
|
+
tag: Tag.SignedTx,
|
|
96
83
|
encodedTx: decode(tx),
|
|
97
84
|
signatures: []
|
|
98
|
-
},
|
|
85
|
+
},
|
|
99
86
|
gaId: this.address,
|
|
100
87
|
authData: authCallData,
|
|
88
|
+
fee,
|
|
101
89
|
gasLimit,
|
|
102
|
-
|
|
90
|
+
gasPrice,
|
|
103
91
|
onNode
|
|
104
92
|
});
|
|
105
93
|
return buildTx({
|
|
94
|
+
tag: Tag.SignedTx,
|
|
106
95
|
encodedTx: decode(gaMetaTx),
|
|
107
96
|
signatures: []
|
|
108
|
-
}
|
|
97
|
+
});
|
|
109
98
|
}
|
|
110
99
|
}
|
|
111
100
|
//# sourceMappingURL=Generalized.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Generalized.mjs","names":["AccountBase","ArgumentError","InternalError","InvalidAuthDataError","NotImplementedError","decode","getAccount","Contract","
|
|
1
|
+
{"version":3,"file":"Generalized.mjs","names":["AccountBase","ArgumentError","InternalError","InvalidAuthDataError","NotImplementedError","decode","getAccount","Contract","buildTxAsync","buildTx","Tag","_authFun","WeakMap","AccountGeneralized","constructor","address","_classPrivateFieldInitSpec","writable","value","sign","signMessage","signTransaction","tx","_ref","authData","onCompiler","onNode","callData","sourceCode","args","fee","gasLimit","gasPrice","authCallData","_classPrivateFieldGet","account","kind","_classPrivateFieldSet","authFun","contract","initialize","_calldata","encode","_name","gaMetaTx","tag","GaMetaTx","SignedTx","encodedTx","signatures","gaId"],"sources":["../../src/account/Generalized.ts"],"sourcesContent":["import AccountBase from './Base';\nimport {\n ArgumentError,\n InternalError,\n InvalidAuthDataError,\n NotImplementedError,\n} from '../utils/errors';\nimport { decode, Encoded } from '../utils/encoder';\nimport { getAccount } from '../chain';\nimport Contract from '../contract/Contract';\nimport { buildTxAsync, buildTx } from '../tx/builder';\nimport { Tag } from '../tx/builder/constants';\n\n/**\n * Generalized account class\n */\nexport default class AccountGeneralized extends AccountBase {\n override readonly address: Encoded.AccountAddress;\n\n #authFun?: string;\n\n /**\n * @param address - Address of generalized account\n */\n constructor(address: Encoded.AccountAddress) {\n super();\n decode(address);\n this.address = address;\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async sign(): Promise<Uint8Array> {\n throw new NotImplementedError('Can\\'t sign using generalized account');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signMessage(): Promise<Uint8Array> {\n throw new NotImplementedError('Can\\'t sign using generalized account');\n }\n\n override async signTransaction(\n tx: Encoded.Transaction,\n { authData, onCompiler, onNode }: Parameters<AccountBase['signTransaction']>[1],\n ): Promise<Encoded.Transaction> {\n if (authData == null || onCompiler == null || onNode == null) {\n throw new ArgumentError('authData, onCompiler, onNode', 'provided', null);\n }\n const {\n callData, sourceCode, args, fee, gasLimit, gasPrice,\n } = typeof authData === 'function' ? await authData(tx) : authData;\n\n const authCallData = callData ?? await (async () => {\n if (this.#authFun == null) {\n const account = await getAccount(this.address, { onNode });\n if (account.kind !== 'generalized') {\n throw new ArgumentError('account kind', 'generalized', account.kind);\n }\n this.#authFun = account.authFun;\n }\n if (this.#authFun == null) {\n throw new InternalError('Account in generalised, but authFun not provided');\n }\n\n if (sourceCode == null || args == null) {\n throw new InvalidAuthDataError('Auth data must contain source code and arguments.');\n }\n const contract = await Contract.initialize({ onCompiler, onNode, sourceCode });\n return contract._calldata.encode(contract._name, this.#authFun, args);\n })();\n\n const gaMetaTx = await buildTxAsync({\n tag: Tag.GaMetaTx,\n tx: { tag: Tag.SignedTx, encodedTx: decode(tx), signatures: [] },\n gaId: this.address,\n authData: authCallData,\n fee,\n gasLimit,\n gasPrice,\n onNode,\n });\n return buildTx({ tag: Tag.SignedTx, encodedTx: decode(gaMetaTx), signatures: [] });\n }\n}\n"],"mappings":";;;;OAAOA,WAAW;AAAA,SAEhBC,aAAa,EACbC,aAAa,EACbC,oBAAoB,EACpBC,mBAAmB;AAAA,SAEZC,MAAM;AAAA,SACNC,UAAU;AAAA,OACZC,QAAQ;AAAA,SACNC,YAAY,EAAEC,OAAO;AAAA,SACrBC,GAAG;AAEZ;AACA;AACA;AAFA,IAAAC,QAAA,oBAAAC,OAAA;AAGA,eAAe,MAAMC,kBAAkB,SAASb,WAAW,CAAC;EAK1D;AACF;AACA;EACEc,WAAWA,CAACC,OAA+B,EAAE;IAC3C,KAAK,EAAE;IAACC,0BAAA,OAAAL,QAAA;MAAAM,QAAA;MAAAC,KAAA;IAAA;IACRb,MAAM,CAACU,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;QACzB,MAAM,IAAIT,aAAa,CAAC,kDAAkD,CAAC;MAC7E;MAEA,IAAI0B,UAAU,IAAI,IAAI,IAAIC,IAAI,IAAI,IAAI,EAAE;QACtC,MAAM,IAAI1B,oBAAoB,CAAC,mDAAmD,CAAC;MACrF;MACA,MAAMoC,QAAQ,GAAG,MAAMhC,QAAQ,CAACiC,UAAU,CAAC;QAAEf,UAAU;QAAEC,MAAM;QAAEE;MAAW,CAAC,CAAC;MAC9E,OAAOW,QAAQ,CAACE,SAAS,CAACC,MAAM,CAACH,QAAQ,CAACI,KAAK,EAAAT,qBAAA,CAAE,IAAI,EAAAvB,QAAA,GAAWkB,IAAI,CAAC;IACvE,CAAC,GAAG;IAEJ,MAAMe,QAAQ,GAAG,MAAMpC,YAAY,CAAC;MAClCqC,GAAG,EAAEnC,GAAG,CAACoC,QAAQ;MACjBxB,EAAE,EAAE;QAAEuB,GAAG,EAAEnC,GAAG,CAACqC,QAAQ;QAAEC,SAAS,EAAE3C,MAAM,CAACiB,EAAE,CAAC;QAAE2B,UAAU,EAAE;MAAG,CAAC;MAChEC,IAAI,EAAE,IAAI,CAACnC,OAAO;MAClBS,QAAQ,EAAES,YAAY;MACtBH,GAAG;MACHC,QAAQ;MACRC,QAAQ;MACRN;IACF,CAAC,CAAC;IACF,OAAOjB,OAAO,CAAC;MAAEoC,GAAG,EAAEnC,GAAG,CAACqC,QAAQ;MAAEC,SAAS,EAAE3C,MAAM,CAACuC,QAAQ,CAAC;MAAEK,UAAU,EAAE;IAAG,CAAC,CAAC;EACpF;AACF"}
|
package/es/account/Ledger.mjs
CHANGED
|
@@ -69,9 +69,10 @@ export default class AccountLedger extends AccountBase {
|
|
|
69
69
|
}, Promise.resolve(_Buffer.alloc(0)));
|
|
70
70
|
const signatures = [response.subarray(0, 64)];
|
|
71
71
|
return buildTx({
|
|
72
|
+
tag: Tag.SignedTx,
|
|
72
73
|
encodedTx: rawTx,
|
|
73
74
|
signatures
|
|
74
|
-
}
|
|
75
|
+
});
|
|
75
76
|
}
|
|
76
77
|
async signMessage(messageStr) {
|
|
77
78
|
let offset = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ledger.mjs","names":["AccountBase","ArgumentError","NotImplementedError","decode","buildTx","Tag","CLA","GET_ADDRESS","SIGN_TRANSACTION","GET_APP_CONFIGURATION","SIGN_PERSONAL_MESSAGE","AccountLedger","constructor","transport","index","address","scrambleKey","decorateAppAPIMethods","sign","signTransaction","tx","innerTx","networkId","rawTx","offset","headerLength","networkIdBuffer","
|
|
1
|
+
{"version":3,"file":"Ledger.mjs","names":["AccountBase","ArgumentError","NotImplementedError","decode","buildTx","Tag","CLA","GET_ADDRESS","SIGN_TRANSACTION","GET_APP_CONFIGURATION","SIGN_PERSONAL_MESSAGE","AccountLedger","constructor","transport","index","address","scrambleKey","decorateAppAPIMethods","sign","signTransaction","tx","innerTx","networkId","arguments","length","undefined","rawTx","offset","headerLength","networkIdBuffer","_Buffer","from","toSend","maxChunkSize","chunkSize","buffer","alloc","bufferOffset","writeUInt32BE","writeUInt8","copy","push","response","reduce","previous","data","i","send","Promise","resolve","signatures","subarray","tag","SignedTx","encodedTx","signMessage","messageStr","message"],"sources":["../../src/account/Ledger.ts"],"sourcesContent":["import type Transport from '@ledgerhq/hw-transport';\nimport AccountBase from './Base';\nimport { ArgumentError, NotImplementedError } from '../utils/errors';\nimport { decode, Encoded } from '../utils/encoder';\nimport { buildTx } from '../tx/builder';\nimport { Tag } from '../tx/builder/constants';\n\nexport const CLA = 0xe0;\nexport const GET_ADDRESS = 0x02;\nexport const SIGN_TRANSACTION = 0x04;\nexport const GET_APP_CONFIGURATION = 0x06;\nexport const SIGN_PERSONAL_MESSAGE = 0x08;\n\n/**\n * Ledger wallet account class\n */\nexport default class AccountLedger extends AccountBase {\n readonly transport: Transport;\n\n override readonly address: Encoded.AccountAddress;\n\n readonly index: number;\n\n /**\n * @param transport - Connection to Ledger to use\n * @param index - Index of account\n * @param address - Address of account\n */\n constructor(transport: Transport, index: number, address: Encoded.AccountAddress) {\n super();\n this.transport = transport;\n this.index = index;\n this.address = address;\n const scrambleKey = 'w0w';\n transport.decorateAppAPIMethods(this, ['signTransaction', 'signMessage'], scrambleKey);\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async sign(): Promise<Uint8Array> {\n throw new NotImplementedError('RAW signing using Ledger HW');\n }\n\n override async signTransaction(\n tx: Encoded.Transaction,\n { innerTx, networkId }: { innerTx?: boolean; networkId?: string } = {},\n ): Promise<Encoded.Transaction> {\n if (innerTx != null) throw new NotImplementedError('innerTx option in AccountLedger');\n if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);\n\n const rawTx = decode(tx);\n let offset = 0;\n const headerLength = 4 + 1 + 4;\n const networkIdBuffer = Buffer.from(networkId);\n const toSend = [];\n while (offset !== rawTx.length) {\n const maxChunkSize = offset === 0 ? 150 - headerLength - networkIdBuffer.length : 150;\n const chunkSize = offset + maxChunkSize > rawTx.length\n ? rawTx.length - offset : maxChunkSize;\n const buffer = Buffer.alloc(\n offset === 0 ? headerLength + networkIdBuffer.length + chunkSize : chunkSize,\n );\n if (offset === 0) {\n let bufferOffset = buffer.writeUInt32BE(this.index, 0);\n bufferOffset = buffer.writeUInt32BE(rawTx.length, bufferOffset);\n bufferOffset = buffer.writeUInt8(networkIdBuffer.length, bufferOffset);\n bufferOffset += networkIdBuffer.copy(\n buffer,\n bufferOffset,\n 0,\n networkIdBuffer.length,\n );\n rawTx.copy(buffer, bufferOffset, 0, 150 - bufferOffset);\n } else {\n rawTx.copy(buffer, 0, offset, offset + chunkSize);\n }\n toSend.push(buffer);\n offset += chunkSize;\n }\n const response = await toSend.reduce(\n async (previous, data, i) => {\n await previous;\n return this.transport.send(\n CLA,\n SIGN_TRANSACTION,\n i === 0 ? 0x00 : 0x80,\n 0x00,\n data,\n );\n },\n Promise.resolve(Buffer.alloc(0)),\n );\n const signatures = [response.subarray(0, 64)];\n\n return buildTx({ tag: Tag.SignedTx, encodedTx: rawTx, signatures });\n }\n\n override async signMessage(messageStr: string): Promise<Uint8Array> {\n let offset = 0;\n const message = Buffer.from(messageStr);\n const toSend = [];\n while (offset !== message.length) {\n const maxChunkSize = offset === 0 ? 150 - 4 - 4 : 150;\n const chunkSize = offset + maxChunkSize > message.length\n ? message.length - offset : maxChunkSize;\n const buffer = Buffer.alloc(offset === 0 ? 4 + 4 + chunkSize : chunkSize);\n if (offset === 0) {\n buffer.writeUInt32BE(this.index, 0);\n buffer.writeUInt32BE(message.length, 4);\n message.copy(buffer, 4 + 4, offset, offset + chunkSize);\n } else {\n message.copy(buffer, 0, offset, offset + chunkSize);\n }\n toSend.push(buffer);\n offset += chunkSize;\n }\n const response = await toSend.reduce(\n async (previous, data, i) => {\n await previous;\n return this.transport.send(\n CLA,\n SIGN_PERSONAL_MESSAGE,\n i === 0 ? 0x00 : 0x80,\n 0x00,\n data,\n );\n },\n Promise.resolve(Buffer.alloc(0)),\n );\n return response.subarray(0, 64);\n }\n}\n"],"mappings":";;;;OACOA,WAAW;AAAA,SACTC,aAAa,EAAEC,mBAAmB;AAAA,SAClCC,MAAM;AAAA,SACNC,OAAO;AAAA,SACPC,GAAG;AAEZ,OAAO,MAAMC,GAAG,GAAG,IAAI;AACvB,OAAO,MAAMC,WAAW,GAAG,IAAI;AAC/B,OAAO,MAAMC,gBAAgB,GAAG,IAAI;AACpC,OAAO,MAAMC,qBAAqB,GAAG,IAAI;AACzC,OAAO,MAAMC,qBAAqB,GAAG,IAAI;;AAEzC;AACA;AACA;AACA,eAAe,MAAMC,aAAa,SAASX,WAAW,CAAC;EAOrD;AACF;AACA;AACA;AACA;EACEY,WAAWA,CAACC,SAAoB,EAAEC,KAAa,EAAEC,OAA+B,EAAE;IAChF,KAAK,EAAE;IACP,IAAI,CAACF,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,OAAO,GAAGA,OAAO;IACtB,MAAMC,WAAW,GAAG,KA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S,CAACkC,IAAI,CACxBzC,GAAG,EACHI,qBAAqB,EACrBoC,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,IAAI,EACrB,IAAI,EACJD,IAAI,CACL;IACH,CAAC,EACDG,OAAO,CAACC,OAAO,CAACnB,OAAA,CAAOM,KAAK,CAAC,CAAC,CAAC,CAAC,CACjC;IACD,OAAOM,QAAQ,CAACS,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC;EACjC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LedgerFactory.mjs","names":["AccountLedger","CLA","GET_ADDRESS","GET_APP_CONFIGURATION","UnsupportedVersionError","semverSatisfies","AccountLedgerFactory","constructor","transport","versionCheckPromise","getAppConfiguration","then","version","args","scrambleKey","decorateAppAPIMethods","response","send","join","getAddress","accountIndex","verify","buffer","alloc","writeUInt32BE","addressLength","subarray","toString","initialize","discover","node","index","result","account","push","getAccountByPubkey","address"],"sources":["../../src/account/LedgerFactory.ts"],"sourcesContent":["import type Transport from '@ledgerhq/hw-transport';\nimport AccountLedger, { CLA, GET_ADDRESS, GET_APP_CONFIGURATION } from './Ledger';\nimport { UnsupportedVersionError } from '../utils/errors';\nimport { Encoded } from '../utils/encoder';\nimport semverSatisfies from '../utils/semver-satisfies';\nimport Node from '../Node';\n\n/**\n * A factory class that generates instances of AccountLedger based on provided transport.\n */\nexport default class AccountLedgerFactory {\n readonly transport: Transport;\n\n private readonly versionCheckPromise: Promise<void>;\n\n /**\n * @param transport - Connection to Ledger to use\n */\n constructor(transport: Transport) {\n this.transport = transport;\n this.versionCheckPromise = this.getAppConfiguration().then(({ version }) => {\n const args = [version, '0.4.4', '0.5.0'] as const;\n if (!semverSatisfies(...args)) throw new UnsupportedVersionError('app on ledger', ...args);\n });\n const scrambleKey = 'w0w';\n transport.decorateAppAPIMethods(this, ['getAddress', 'getAppConfiguration'], scrambleKey);\n }\n\n /**\n * @returns the version of app installed on Ledger wallet\n */\n async getAppConfiguration(): Promise<{ version: string }> {\n await this.versionCheckPromise;\n const response = await this.transport.send(CLA, GET_APP_CONFIGURATION, 0x00, 0x00);\n return {\n version: [response[1], response[2], response[3]].join('.'),\n };\n }\n\n /**\n * Get `ak_`-prefixed address for a given account index.\n * @param accountIndex - Index of account\n * @param verify - Ask user to confirm address by showing it on the device screen\n */\n async getAddress(accountIndex: number, verify = false): Promise<Encoded.AccountAddress> {\n await this.versionCheckPromise;\n const buffer = Buffer.alloc(4);\n buffer.writeUInt32BE(accountIndex, 0);\n const response = await this.transport.send(\n CLA,\n GET_ADDRESS,\n verify ? 0x01 : 0x00,\n 0x00,\n buffer,\n );\n const addressLength = response[0];\n return response.subarray(1, 1 + addressLength).toString('ascii') as Encoded.AccountAddress;\n }\n\n /**\n * Get an instance of AccountLedger for a given account index.\n * @param accountIndex - Index of account\n */\n async initialize(accountIndex: number): Promise<AccountLedger> {\n await this.versionCheckPromise;\n return new AccountLedger(this.transport, accountIndex, await this.getAddress(accountIndex));\n }\n\n /**\n * Discovers accounts on Ledger that already have been used (has any on-chain transactions).\n * It returns an empty array if none of accounts been used.\n * If a used account is preceded by an unused account then it would be ignored.\n * @param node - Instance of Node to get account information from\n */\n async discover(node: Node): Promise<AccountLedger[]> {\n let index = 0;\n const result = [];\n let account;\n do {\n if (account != null) result.push(account);\n account = await this.initialize(index);\n index += 1;\n } while (await node.getAccountByPubkey(account.address).then(() => true, () => false));\n return result;\n }\n}\n"],"mappings":";;;;OACOA,aAAa,IAAIC,GAAG,EAAEC,WAAW,EAAEC,qBAAqB;AAAA,SACtDC,uBAAuB;AAAA,OAEzBC,eAAe;AAGtB;AACA;AACA;AACA,eAAe,MAAMC,oBAAoB,CAAC;EAKxC;AACF;AACA;EACEC,
|
|
1
|
+
{"version":3,"file":"LedgerFactory.mjs","names":["AccountLedger","CLA","GET_ADDRESS","GET_APP_CONFIGURATION","UnsupportedVersionError","semverSatisfies","AccountLedgerFactory","constructor","transport","versionCheckPromise","getAppConfiguration","then","_ref","version","args","scrambleKey","decorateAppAPIMethods","response","send","join","getAddress","accountIndex","verify","arguments","length","undefined","buffer","_Buffer","alloc","writeUInt32BE","addressLength","subarray","toString","initialize","discover","node","index","result","account","push","getAccountByPubkey","address"],"sources":["../../src/account/LedgerFactory.ts"],"sourcesContent":["import type Transport from '@ledgerhq/hw-transport';\nimport AccountLedger, { CLA, GET_ADDRESS, GET_APP_CONFIGURATION } from './Ledger';\nimport { UnsupportedVersionError } from '../utils/errors';\nimport { Encoded } from '../utils/encoder';\nimport semverSatisfies from '../utils/semver-satisfies';\nimport Node from '../Node';\n\n/**\n * A factory class that generates instances of AccountLedger based on provided transport.\n */\nexport default class AccountLedgerFactory {\n readonly transport: Transport;\n\n private readonly versionCheckPromise: Promise<void>;\n\n /**\n * @param transport - Connection to Ledger to use\n */\n constructor(transport: Transport) {\n this.transport = transport;\n this.versionCheckPromise = this.getAppConfiguration().then(({ version }) => {\n const args = [version, '0.4.4', '0.5.0'] as const;\n if (!semverSatisfies(...args)) throw new UnsupportedVersionError('app on ledger', ...args);\n });\n const scrambleKey = 'w0w';\n transport.decorateAppAPIMethods(this, ['getAddress', 'getAppConfiguration'], scrambleKey);\n }\n\n /**\n * @returns the version of app installed on Ledger wallet\n */\n async getAppConfiguration(): Promise<{ version: string }> {\n await this.versionCheckPromise;\n const response = await this.transport.send(CLA, GET_APP_CONFIGURATION, 0x00, 0x00);\n return {\n version: [response[1], response[2], response[3]].join('.'),\n };\n }\n\n /**\n * Get `ak_`-prefixed address for a given account index.\n * @param accountIndex - Index of account\n * @param verify - Ask user to confirm address by showing it on the device screen\n */\n async getAddress(accountIndex: number, verify = false): Promise<Encoded.AccountAddress> {\n await this.versionCheckPromise;\n const buffer = Buffer.alloc(4);\n buffer.writeUInt32BE(accountIndex, 0);\n const response = await this.transport.send(\n CLA,\n GET_ADDRESS,\n verify ? 0x01 : 0x00,\n 0x00,\n buffer,\n );\n const addressLength = response[0];\n return response.subarray(1, 1 + addressLength).toString('ascii') as Encoded.AccountAddress;\n }\n\n /**\n * Get an instance of AccountLedger for a given account index.\n * @param accountIndex - Index of account\n */\n async initialize(accountIndex: number): Promise<AccountLedger> {\n await this.versionCheckPromise;\n return new AccountLedger(this.transport, accountIndex, await this.getAddress(accountIndex));\n }\n\n /**\n * Discovers accounts on Ledger that already have been used (has any on-chain transactions).\n * It returns an empty array if none of accounts been used.\n * If a used account is preceded by an unused account then it would be ignored.\n * @param node - Instance of Node to get account information from\n */\n async discover(node: Node): Promise<AccountLedger[]> {\n let index = 0;\n const result = [];\n let account;\n do {\n if (account != null) result.push(account);\n account = await this.initialize(index);\n index += 1;\n } while (await node.getAccountByPubkey(account.address).then(() => true, () => false));\n return result;\n }\n}\n"],"mappings":";;;;OACOA,aAAa,IAAIC,GAAG,EAAEC,WAAW,EAAEC,qBAAqB;AAAA,SACtDC,uBAAuB;AAAA,OAEzBC,eAAe;AAGtB;AACA;AACA;AACA,eAAe,MAAMC,oBAAoB,CAAC;EAKxC;AACF;AACA;EACEC,WAAWA,CAACC,SAAoB,EAAE;IAChC,IAAI,CAACA,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,mBAAmB,GAAG,IAAI,CAACC,mBAAmB,EAAE,CAACC,IAAI,CAACC,IAAA,IAAiB;MAAA,IAAhB;QAAEC;MAAQ,CAAC,GAAAD,IAAA;MACrE,MAAME,IAAI,GAAG,CAACD,OAAO,EAAE,OAAO,EAAE,OAAO,CAAU;MACjD,IAAI,CAACR,eAAe,CAAC,GAAGS,IAAI,CAAC,EAAE,MAAM,IAAIV,uBAAuB,CAAC,eAAe,EAAE,GAAGU,IAAI,CAAC;IAC5F,CAAC,CAAC;IACF,MAAMC,WAAW,GAAG,KAAK;IACzBP,SAAS,CAACQ,qBAAqB,CAAC,IAAI,EAAE,CAAC,YAAY,EAAE,qBAAqB,CAAC,EAAED,WAAW,CAAC;EAC3F;;EAEA;AACF;AACA;EACE,MAAML,mBAAmBA,CAAA,EAAiC;IACxD,MAAM,IAAI,CAACD,mBA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AA4B;IACnD,IAAIC,KAAK,GAAG,CAAC;IACb,MAAMC,MAAM,GAAG,EAAE;IACjB,IAAIC,OAAO;IACX,GAAG;MACD,IAAIA,OAAO,IAAI,IAAI,EAAED,MAAM,CAACE,IAAI,CAACD,OAAO,CAAC;MACzCA,OAAO,GAAG,MAAM,IAAI,CAACL,UAAU,CAACG,KAAK,CAAC;MACtCA,KAAK,IAAI,CAAC;IACZ,CAAC,QAAQ,MAAMD,IAAI,CAACK,kBAAkB,CAACF,OAAO,CAACG,OAAO,CAAC,CAAC9B,IAAI,CAAC,MAAM,IAAI,EAAE,MAAM,KAAK,CAAC;IACrF,OAAO0B,MAAM;EACf;AACF"}
|
package/es/account/Memory.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import AccountBase from './Base';
|
|
2
2
|
import { Encoded } from '../utils/encoder';
|
|
3
|
+
export declare function getBufferToSign(transaction: Encoded.Transaction, networkId: string, innerTx: boolean): Uint8Array;
|
|
3
4
|
/**
|
|
4
5
|
* In-memory account class
|
|
5
6
|
*/
|
|
@@ -14,7 +15,7 @@ export default class AccountMemory extends AccountBase {
|
|
|
14
15
|
*/
|
|
15
16
|
static generate(): AccountMemory;
|
|
16
17
|
sign(data: string | Uint8Array, options?: any): Promise<Uint8Array>;
|
|
17
|
-
signTransaction(
|
|
18
|
+
signTransaction(transaction: Encoded.Transaction, { innerTx, networkId, ...options }?: {
|
|
18
19
|
innerTx?: boolean;
|
|
19
20
|
networkId?: string;
|
|
20
21
|
}): Promise<Encoded.Transaction>;
|
package/es/account/Memory.mjs
CHANGED
|
@@ -2,22 +2,6 @@ import _buffer from "buffer";
|
|
|
2
2
|
const {
|
|
3
3
|
Buffer: _Buffer
|
|
4
4
|
} = _buffer;
|
|
5
|
-
/*
|
|
6
|
-
* ISC License (ISC)
|
|
7
|
-
* Copyright (c) 2022 aeternity developers
|
|
8
|
-
*
|
|
9
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
-
* purpose with or without fee is hereby granted, provided that the above
|
|
11
|
-
* copyright notice and this permission notice appear in all copies.
|
|
12
|
-
*
|
|
13
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
-
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
-
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
-
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
-
* PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
-
*/
|
|
21
5
|
import AccountBase from "./Base.mjs";
|
|
22
6
|
import { generateKeyPairFromSecret, sign, generateKeyPair, hash, messageToHash } from "../utils/crypto.mjs";
|
|
23
7
|
import { ArgumentError } from "../utils/errors.mjs";
|
|
@@ -26,6 +10,12 @@ import { concatBuffers } from "../utils/other.mjs";
|
|
|
26
10
|
import { buildTx } from "../tx/builder/index.mjs";
|
|
27
11
|
import { Tag } from "../tx/builder/constants.mjs";
|
|
28
12
|
const secretKeys = new WeakMap();
|
|
13
|
+
export function getBufferToSign(transaction, networkId, innerTx) {
|
|
14
|
+
const prefixes = [networkId];
|
|
15
|
+
if (innerTx) prefixes.push('inner_tx');
|
|
16
|
+
const rlpBinaryTx = decode(transaction);
|
|
17
|
+
return concatBuffers([_Buffer.from(prefixes.join('-')), hash(rlpBinaryTx)]);
|
|
18
|
+
}
|
|
29
19
|
|
|
30
20
|
/**
|
|
31
21
|
* In-memory account class
|
|
@@ -55,7 +45,7 @@ export default class AccountMemory extends AccountBase {
|
|
|
55
45
|
async sign(data, options) {
|
|
56
46
|
return sign(data, secretKeys.get(this));
|
|
57
47
|
}
|
|
58
|
-
async signTransaction(
|
|
48
|
+
async signTransaction(transaction) {
|
|
59
49
|
let {
|
|
60
50
|
innerTx,
|
|
61
51
|
networkId,
|
|
@@ -64,15 +54,14 @@ export default class AccountMemory extends AccountBase {
|
|
|
64
54
|
if (networkId == null) {
|
|
65
55
|
throw new ArgumentError('networkId', 'provided', networkId);
|
|
66
56
|
}
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
const rlpBinaryTx = decode(tx);
|
|
70
|
-
const txWithNetworkId = concatBuffers([_Buffer.from(prefixes.join('-')), hash(rlpBinaryTx)]);
|
|
57
|
+
const rlpBinaryTx = decode(transaction);
|
|
58
|
+
const txWithNetworkId = getBufferToSign(transaction, networkId, innerTx === true);
|
|
71
59
|
const signatures = [await this.sign(txWithNetworkId, options)];
|
|
72
60
|
return buildTx({
|
|
61
|
+
tag: Tag.SignedTx,
|
|
73
62
|
encodedTx: rlpBinaryTx,
|
|
74
63
|
signatures
|
|
75
|
-
}
|
|
64
|
+
});
|
|
76
65
|
}
|
|
77
66
|
async signMessage(message, options) {
|
|
78
67
|
return this.sign(messageToHash(message), options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Memory.mjs","names":["AccountBase","generateKeyPairFromSecret","sign","generateKeyPair","hash","messageToHash","ArgumentError","decode","encode","Encoding","concatBuffers","buildTx","Tag","secretKeys","WeakMap","
|
|
1
|
+
{"version":3,"file":"Memory.mjs","names":["AccountBase","generateKeyPairFromSecret","sign","generateKeyPair","hash","messageToHash","ArgumentError","decode","encode","Encoding","concatBuffers","buildTx","Tag","secretKeys","WeakMap","getBufferToSign","transaction","networkId","innerTx","prefixes","push","rlpBinaryTx","_Buffer","from","join","AccountMemory","constructor","secretKey","length","set","address","get","publicKey","AccountAddress","generate","data","options","signTransaction","arguments","undefined","txWithNetworkId","signatures","tag","SignedTx","encodedTx","signMessage","message"],"sources":["../../src/account/Memory.ts"],"sourcesContent":["import AccountBase from './Base';\nimport {\n generateKeyPairFromSecret, sign, generateKeyPair, hash, messageToHash,\n} from '../utils/crypto';\nimport { ArgumentError } from '../utils/errors';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../utils/encoder';\nimport { concatBuffers } from '../utils/other';\nimport { buildTx } from '../tx/builder';\nimport { Tag } from '../tx/builder/constants';\n\nconst secretKeys = new WeakMap();\n\nexport function getBufferToSign(\n transaction: Encoded.Transaction,\n networkId: string,\n innerTx: boolean,\n): Uint8Array {\n const prefixes = [networkId];\n if (innerTx) prefixes.push('inner_tx');\n const rlpBinaryTx = decode(transaction);\n return concatBuffers([Buffer.from(prefixes.join('-')), hash(rlpBinaryTx)]);\n}\n\n/**\n * In-memory account class\n */\nexport default class AccountMemory extends AccountBase {\n override readonly address: Encoded.AccountAddress;\n\n /**\n * @param secretKey - Secret key\n */\n constructor(secretKey: string | Uint8Array) {\n super();\n secretKey = typeof secretKey === 'string' ? Buffer.from(secretKey, 'hex') : secretKey;\n if (secretKey.length !== 64) {\n throw new ArgumentError('secretKey', '64 bytes', secretKey.length);\n }\n secretKeys.set(this, secretKey);\n this.address = encode(\n generateKeyPairFromSecret(secretKeys.get(this)).publicKey,\n Encoding.AccountAddress,\n );\n }\n\n /**\n * Generates a new AccountMemory using a random secret key\n */\n static generate(): AccountMemory {\n return new AccountMemory(generateKeyPair().secretKey);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n override async sign(data: string | Uint8Array, options?: any): Promise<Uint8Array> {\n return sign(data, secretKeys.get(this));\n }\n\n override async signTransaction(\n transaction: Encoded.Transaction,\n { innerTx, networkId, ...options }: { innerTx?: boolean; networkId?: string } = {},\n ): Promise<Encoded.Transaction> {\n if (networkId == null) {\n throw new ArgumentError('networkId', 'provided', networkId);\n }\n const rlpBinaryTx = decode(transaction);\n const txWithNetworkId = getBufferToSign(transaction, networkId, innerTx === true);\n\n const signatures = [await this.sign(txWithNetworkId, options)];\n return buildTx({ tag: Tag.SignedTx, encodedTx: rlpBinaryTx, signatures });\n }\n\n override async signMessage(message: string, options?: any): Promise<Uint8Array> {\n return this.sign(messageToHash(message), options);\n }\n}\n"],"mappings":";;;;OAAOA,WAAW;AAAA,SAEhBC,yBAAyB,EAAEC,IAAI,EAAEC,eAAe,EAAEC,IAAI,EAAEC,aAAa;AAAA,SAE9DC,aAAa;AAAA,SAEpBC,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAE1BC,aAAa;AAAA,SACbC,OAAO;AAAA,SACPC,GAAG;AAEZ,MAAMC,UAAU,GAAG,IAAIC,OAAO,EAAE;AAEhC,OAAO,SAASC,eAAeA,CAC7BC,WAAgC,EAChCC,SAAiB,EACjBC,OAAgB,EACJ;EACZ,MAAMC,QAAQ,GAAG,CAACF,SAAS,CAAC;EAC5B,IAAIC,OAAO,EAAEC,QAAQ,CAACC,IAAI,CAAC,UAAU,CAAC;EACtC,MAAMC,WAAW,GAAGd,MAAM,CAACS,WAAW,CAAC;EACvC,OAAON,aAAa,CAAC,CAACY,OAAA,CAAOC,IAAI,CAACJ,QAAQ,CAACK,IAAI,CAAC,GAAG,CAAC,CAAC,EAAEpB,IAAI,CAACiB,WAAW,CAAC,CAAC,CAAC;AAC5E;;AAEA;AACA;AACA;AACA,eAAe,MAAMI,aAAa,SAASzB,WAAW,CAAC;EAGrD;AACF;AACA;EACE0B,WAAWA,CAACC,SAA8B,EAAE;IAC1C,KAAK,EAAE;IACPA,SAAS,GAAG,OAAOA,SAAS,KAAK,QAAQ,GAAGL,OAAA,CAAOC,IAAI,CAACI,SAAS,EAAE,KAAK,CAAC,GAAGA,SAAS;IACrF,IAAIA,SAAS,CAACC,MAAM,KAAK,EAAE,EAAE;MAC3B,MAAM,IAAItB,aAAa,CAAC,WAAW,EAAE,UAAU,EAAEqB,SAAS,CAACC,MAAM,CAAC;IACpE;IACAf,UAAU,CAACgB,GAAG,CAAC,IAAI,EAAEF,SAAS,CAAC;IAC/B,IAAI,CAACG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D;AACF"}
|
package/es/account/Rpc.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rpc.mjs","names":["AccountBase","METHODS","ArgumentError","NotImplementedError","UnsupportedProtocolError","AccountRpc","constructor","rpcClient","address","_rpcClient","sign","signTransaction","tx","innerTx","networkId","res","request","onAccount","returnSigned","signedTransaction","signMessage","message","signature","from"],"sources":["../../src/account/Rpc.ts"],"sourcesContent":["import AccountBase from './Base';\nimport { METHODS } from '../aepp-wallet-communication/schema';\nimport { ArgumentError, NotImplementedError, UnsupportedProtocolError } from '../utils/errors';\nimport { Encoded } from '../utils/encoder';\nimport RpcClient from '../aepp-wallet-communication/rpc/RpcClient';\nimport { AeppApi, WalletApi } from '../aepp-wallet-communication/rpc/types';\n\n/**\n * Account provided by wallet\n * @param params - Params\n * @param params.rpcClient - RpcClient instance\n * @param params.address - RPC account address\n * @returns AccountRpc instance\n */\nexport default class AccountRpc extends AccountBase {\n _rpcClient: RpcClient<WalletApi, AeppApi>;\n\n override readonly address: Encoded.AccountAddress;\n\n constructor(rpcClient: RpcClient<WalletApi, AeppApi>, address: Encoded.AccountAddress) {\n super();\n this._rpcClient = rpcClient;\n this.address = address;\n }\n\n // eslint-disable-next-line class-methods-use-this\n async sign(): Promise<Uint8Array> {\n throw new NotImplementedError('RAW signing using wallet');\n }\n\n /**\n * @returns Signed transaction\n */\n override async signTransaction(\n tx: Encoded.Transaction,\n { innerTx, networkId }: Parameters<AccountBase['signTransaction']>[1] = {},\n ): Promise<Encoded.Transaction> {\n if (innerTx != null) throw new NotImplementedError('innerTx option in AccountRpc');\n if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);\n const res = await this._rpcClient.request(METHODS.sign, {\n onAccount: this.address,\n tx,\n returnSigned: true,\n networkId,\n });\n if (res.signedTransaction == null) {\n throw new UnsupportedProtocolError('signedTransaction is missed in wallet response');\n }\n return res.signedTransaction;\n }\n\n /**\n * @returns Signed message\n */\n override async signMessage(message: string): Promise<Uint8Array> {\n const { signature } = await this._rpcClient\n .request(METHODS.signMessage, { onAccount: this.address, message });\n return Buffer.from(signature, 'hex');\n }\n}\n"],"mappings":";;;;OAAOA,WAAW;AAAA,SACTC,OAAO;AAAA,SACPC,aAAa,EAAEC,mBAAmB,EAAEC,wBAAwB;AAKrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,UAAU,SAASL,WAAW,CAAC;EAKlDM,
|
|
1
|
+
{"version":3,"file":"Rpc.mjs","names":["AccountBase","METHODS","ArgumentError","NotImplementedError","UnsupportedProtocolError","AccountRpc","constructor","rpcClient","address","_rpcClient","sign","signTransaction","tx","innerTx","networkId","arguments","length","undefined","res","request","onAccount","returnSigned","signedTransaction","signMessage","message","signature","_Buffer","from"],"sources":["../../src/account/Rpc.ts"],"sourcesContent":["import AccountBase from './Base';\nimport { METHODS } from '../aepp-wallet-communication/schema';\nimport { ArgumentError, NotImplementedError, UnsupportedProtocolError } from '../utils/errors';\nimport { Encoded } from '../utils/encoder';\nimport RpcClient from '../aepp-wallet-communication/rpc/RpcClient';\nimport { AeppApi, WalletApi } from '../aepp-wallet-communication/rpc/types';\n\n/**\n * Account provided by wallet\n * @param params - Params\n * @param params.rpcClient - RpcClient instance\n * @param params.address - RPC account address\n * @returns AccountRpc instance\n */\nexport default class AccountRpc extends AccountBase {\n _rpcClient: RpcClient<WalletApi, AeppApi>;\n\n override readonly address: Encoded.AccountAddress;\n\n constructor(rpcClient: RpcClient<WalletApi, AeppApi>, address: Encoded.AccountAddress) {\n super();\n this._rpcClient = rpcClient;\n this.address = address;\n }\n\n // eslint-disable-next-line class-methods-use-this\n async sign(): Promise<Uint8Array> {\n throw new NotImplementedError('RAW signing using wallet');\n }\n\n /**\n * @returns Signed transaction\n */\n override async signTransaction(\n tx: Encoded.Transaction,\n { innerTx, networkId }: Parameters<AccountBase['signTransaction']>[1] = {},\n ): Promise<Encoded.Transaction> {\n if (innerTx != null) throw new NotImplementedError('innerTx option in AccountRpc');\n if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);\n const res = await this._rpcClient.request(METHODS.sign, {\n onAccount: this.address,\n tx,\n returnSigned: true,\n networkId,\n });\n if (res.signedTransaction == null) {\n throw new UnsupportedProtocolError('signedTransaction is missed in wallet response');\n }\n return res.signedTransaction;\n }\n\n /**\n * @returns Signed message\n */\n override async signMessage(message: string): Promise<Uint8Array> {\n const { signature } = await this._rpcClient\n .request(METHODS.signMessage, { onAccount: this.address, message });\n return Buffer.from(signature, 'hex');\n }\n}\n"],"mappings":";;;;OAAOA,WAAW;AAAA,SACTC,OAAO;AAAA,SACPC,aAAa,EAAEC,mBAAmB,EAAEC,wBAAwB;AAKrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,UAAU,SAASL,WAAW,CAAC;EAKlDM,WAAWA,CAACC,SAAwC,EAAEC,OAA+B,EAAE;IACrF,KAAK,EAAE;IACP,IAAI,CAACC,UAAU,GAAGF,SAAS;IAC3B,IAAI,CAACC,OAAO,GAAGA,OAAO;EACxB;;EAEA;EACA,MAAME,IAAIA,CAAA,EAAwB;IAChC,MAAM,IAAIP,mBAAmB,CAAC,0BAA0B,CAAC;EAC3D;;EAEA;AACF;AACA;EACE,MAAeQ,eAAeA,CAC5BC,EAAuB,EAEO;IAAA,IAD9B;MAAEC,OAAO;MAAEC;IAAyD,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAE1E,IAAIF,OAAO,IAAI,IAAI,EAAE,MAAM,IAAIV,mBAAmB,CAAC,8BAA8B,CAAC;IAClF,IAAIW,SAAS,IAAI,IAAI,EAAE,MAAM,IAAIZ,aAAa,CAAC,WAAW,EAAE,UAAU,EAAEY,SAAS,CAAC;IAClF,MAAMI,GAAG,GAAG,MAAM,IAAI,CAACT,UAAU,CAACU,OAAO,CAAClB,OAAO,CAACS,IAAI,EAAE;MACtDU,SAAS,EAAE,IAAI,CAACZ,OAAO;MACvBI,EAAE;MACFS,YAAY,EAAE,IAAI;MAClBP;IACF,CAAC,CAAC;IACF,IAAII,GAAG,CAACI,iBAAiB,IAAI,IAAI,EAAE;MACjC,MAAM,IAAIlB,wBAAwB,CAAC,gDAAgD,CAAC;IACtF;IACA,OAAOc,GAAG,CAACI,iBAAiB;EAC9B;;EAEA;AACF;AACA;EACE,MAAeC,WAAWA,CAACC,OAAe,EAAuB;IAC/D,MAAM;MAAEC;IAAU,CAAC,GAAG,MAAM,IAAI,CAAChB,UAAU,CACxCU,OAAO,CAAClB,OAAO,CAACsB,WAAW,EAAE;MAAEH,SAAS,EAAE,IAAI,CAACZ,OAAO;MAAEgB;IAAQ,CAAC,CAAC;IACrE,OAAOE,OAAA,CAAOC,IAAI,CAACF,SAAS,EAAE,KAAK,CAAC;EACtC;AACF"}
|
package/es/aens.d.ts
CHANGED
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
import BigNumber from 'bignumber.js';
|
|
9
9
|
import { Tag, AensName } from './tx/builder/constants';
|
|
10
10
|
import { Encoded } from './utils/encoder';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { BuildTxOptions } from './tx';
|
|
11
|
+
import { sendTransaction, SendTransactionOptions, getName } from './chain';
|
|
12
|
+
import { BuildTxOptions } from './tx/builder';
|
|
14
13
|
import { TransformNodeType } from './Node';
|
|
15
14
|
import { NameEntry, NamePointer } from './apis/node';
|
|
16
15
|
import AccountBase from './account/Base';
|
|
@@ -39,8 +38,8 @@ interface KeyPointers {
|
|
|
39
38
|
* await nameObject.revoke({ fee, ttl, nonce })
|
|
40
39
|
* ```
|
|
41
40
|
*/
|
|
42
|
-
export declare function aensRevoke(name: AensName, options: AensRevokeOptions): ReturnType<typeof
|
|
43
|
-
interface AensRevokeOptions extends BuildTxOptions<Tag.NameRevokeTx, 'nameId' | 'accountId'>,
|
|
41
|
+
export declare function aensRevoke(name: AensName, options: AensRevokeOptions): ReturnType<typeof sendTransaction>;
|
|
42
|
+
interface AensRevokeOptions extends BuildTxOptions<Tag.NameRevokeTx, 'nameId' | 'accountId' | 'onNode'>, SendTransactionOptions {
|
|
44
43
|
}
|
|
45
44
|
/**
|
|
46
45
|
* Update a name
|
|
@@ -71,8 +70,8 @@ interface AensRevokeOptions extends BuildTxOptions<Tag.NameRevokeTx, 'nameId' |
|
|
|
71
70
|
* await nameObject.update(pointers, { nameTtl, ttl, fee, nonce, clientTtl })
|
|
72
71
|
* ```
|
|
73
72
|
*/
|
|
74
|
-
export declare function aensUpdate(name: AensName, pointers: KeyPointers, { extendPointers, ...options }: AensUpdateOptions): ReturnType<typeof
|
|
75
|
-
interface AensUpdateOptions extends BuildTxOptions<Tag.NameUpdateTx, 'nameId' | 'accountId' | 'pointers' | 'clientTtl' | 'nameTtl'>,
|
|
73
|
+
export declare function aensUpdate(name: AensName, pointers: KeyPointers, { extendPointers, ...options }: AensUpdateOptions): ReturnType<typeof sendTransaction>;
|
|
74
|
+
interface AensUpdateOptions extends BuildTxOptions<Tag.NameUpdateTx, 'nameId' | 'accountId' | 'pointers' | 'clientTtl' | 'nameTtl' | 'onNode'>, SendTransactionOptions {
|
|
76
75
|
extendPointers?: boolean;
|
|
77
76
|
clientTtl?: number;
|
|
78
77
|
nameTtl?: number;
|
|
@@ -100,8 +99,8 @@ interface AensUpdateOptions extends BuildTxOptions<Tag.NameUpdateTx, 'nameId' |
|
|
|
100
99
|
* await nameObject.transfer(recipientPub, { ttl, fee, nonce })
|
|
101
100
|
* ```
|
|
102
101
|
*/
|
|
103
|
-
export declare function aensTransfer(name: AensName, account: Encoded.AccountAddress, options: AensTransferOptions): ReturnType<typeof
|
|
104
|
-
interface AensTransferOptions extends BuildTxOptions<Tag.NameTransferTx, 'nameId' | 'accountId' | 'recipientId'>,
|
|
102
|
+
export declare function aensTransfer(name: AensName, account: Encoded.AccountAddress, options: AensTransferOptions): ReturnType<typeof sendTransaction>;
|
|
103
|
+
interface AensTransferOptions extends BuildTxOptions<Tag.NameTransferTx, 'nameId' | 'accountId' | 'recipientId' | 'onNode'>, SendTransactionOptions {
|
|
105
104
|
}
|
|
106
105
|
/**
|
|
107
106
|
* Query the AENS name info from the node
|
|
@@ -161,10 +160,10 @@ export declare function aensQuery(name: AensName, opt: Parameters<typeof getName
|
|
|
161
160
|
* ```
|
|
162
161
|
*/
|
|
163
162
|
export declare function aensClaim(name: AensName, salt: number, options: AensClaimOptions): Promise<AensClaimReturnType>;
|
|
164
|
-
type AensClaimOptionsType = BuildTxOptions<Tag.NameClaimTx, 'accountId' | 'nameSalt' | 'name'> &
|
|
163
|
+
type AensClaimOptionsType = BuildTxOptions<Tag.NameClaimTx, 'accountId' | 'nameSalt' | 'name'> & SendTransactionOptions & Parameters<typeof aensQuery>[1];
|
|
165
164
|
interface AensClaimOptions extends AensClaimOptionsType {
|
|
166
165
|
}
|
|
167
|
-
interface AensClaimReturnType extends Awaited<ReturnType<typeof
|
|
166
|
+
interface AensClaimReturnType extends Awaited<ReturnType<typeof sendTransaction>>, Partial<Awaited<ReturnType<typeof aensQuery>>> {
|
|
168
167
|
}
|
|
169
168
|
/**
|
|
170
169
|
* Preclaim a name. Sends a hash of the name and a random salt to the node
|
|
@@ -190,13 +189,12 @@ interface AensClaimReturnType extends Awaited<ReturnType<typeof send>>, Partial<
|
|
|
190
189
|
* }
|
|
191
190
|
* ```
|
|
192
191
|
*/
|
|
193
|
-
export declare function aensPreclaim(name: AensName, options: AensPreclaimOptions): Promise<Readonly<Awaited<ReturnType<typeof
|
|
194
|
-
height: number;
|
|
192
|
+
export declare function aensPreclaim(name: AensName, options: AensPreclaimOptions): Promise<Readonly<Awaited<ReturnType<typeof sendTransaction>> & {
|
|
195
193
|
salt: number;
|
|
196
194
|
commitmentId: string;
|
|
197
195
|
claim: (opts?: Parameters<typeof aensClaim>[2]) => ReturnType<typeof aensClaim>;
|
|
198
196
|
}>>;
|
|
199
|
-
interface AensPreclaimOptions extends BuildTxOptions<Tag.NamePreclaimTx, 'accountId' | 'commitmentId'>,
|
|
197
|
+
interface AensPreclaimOptions extends BuildTxOptions<Tag.NamePreclaimTx, 'accountId' | 'commitmentId' | 'onNode'>, SendTransactionOptions, Omit<AensClaimOptions, 'version'> {
|
|
200
198
|
}
|
|
201
199
|
/**
|
|
202
200
|
* Bid to name auction
|