@aeternity/aepp-sdk 13.0.0-alpha.1 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- 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 +1833 -1543
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdk.mjs.map +1 -1
- package/es/AeSdkAepp.d.ts +5 -4
- package/es/AeSdkAepp.mjs +13 -17
- 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 +12 -25
- 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 +20 -23
- 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 +197 -215
- package/es/contract/Contract.mjs.map +1 -1
- package/es/contract/compiler/Base.d.ts +10 -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 +5 -4
- package/es/index-browser.mjs +7 -21
- 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 +3 -33
- 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/AeSdkAepp.ts +16 -14
- 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 +9 -24
- 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 +7 -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 +29 -28
- 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 +161 -170
- package/src/contract/compiler/Base.ts +10 -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 +15 -21
- 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 +16 -45
- package/src/utils/string.ts +0 -17
- package/types-legacy/ts4.2/AeSdkAepp.d.ts +5 -4
- 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 +10 -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 +5 -4
- 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/AeSdkAepp.d.ts +5 -4
- 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 +10 -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 +5 -4
- 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
package/es/AeSdk.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AeSdk.mjs","names":["AeSdkBase","decode","UnavailableAccountError","AeSdk","constructor","accounts","options","forEach","account","idx","addAccount","select","_resolveAccount","selectedAddress","address","addresses","Object","keys","selectAccount","removeAccount"],"sources":["../src/AeSdk.ts"],"sourcesContent":["import AeSdkBase from './AeSdkBase';\nimport { OnAccount } from './AeSdkMethods';\nimport AccountBase from './account/Base';\nimport { decode, Encoded } from './utils/encoder';\nimport { UnavailableAccountError } from './utils/errors';\n\nexport default class AeSdk extends AeSdkBase {\n accounts: { [key: Encoded.AccountAddress]: AccountBase } = {};\n\n selectedAddress?: Encoded.AccountAddress;\n\n constructor(\n { accounts, ...options }: { accounts?: AccountBase[] }\n & ConstructorParameters<typeof AeSdkBase>[0] = {},\n ) {\n super(options);\n accounts?.forEach((account, idx) => this.addAccount(account, { select: idx === 0 }));\n }\n\n override _resolveAccount(account: OnAccount = this.selectedAddress): AccountBase {\n if (typeof account === 'string') {\n const address = account as Encoded.AccountAddress;\n decode(address);\n if (this.accounts[address] == null) throw new UnavailableAccountError(account);\n account = this.accounts[address];\n }\n return super._resolveAccount(account);\n }\n\n /**\n * Get accounts addresses\n * @example addresses()\n */\n override addresses(): Encoded.AccountAddress[] {\n return Object.keys(this.accounts) as Encoded.AccountAddress[];\n }\n\n /**\n * Add specific account\n * @param account - Account instance\n * @param options - Options\n * @param options.select - Select account\n * @example addAccount(account)\n */\n addAccount(account: AccountBase, { select }: { select?: boolean } = {}): void {\n const { address } = account;\n this.accounts[address] = account;\n if (select === true) this.selectAccount(address);\n }\n\n /**\n * Remove specific account\n * @param address - Address of account to remove\n * @example removeAccount(address)\n */\n removeAccount(address: Encoded.AccountAddress): void {\n if (this.accounts[address] == null) throw new UnavailableAccountError(address);\n delete this.accounts[address]; // eslint-disable-line @typescript-eslint/no-dynamic-delete\n if (this.selectedAddress === address) delete this.selectedAddress;\n }\n\n /**\n * Select specific account\n * @param address - Address of account to select\n * @example selectAccount('ak_xxxxxxxx')\n */\n selectAccount(address: Encoded.AccountAddress): void {\n decode(address);\n if (this.accounts[address] == null) throw new UnavailableAccountError(address);\n this.selectedAddress = address;\n }\n}\n"],"mappings":";OAAOA,SAAS;AAAA,SAGPC,MAAM;AAAA,SACNC,uBAAuB;AAEhC,eAAe,MAAMC,KAAK,SAASH,SAAS,CAAC;EAK3CI,
|
|
1
|
+
{"version":3,"file":"AeSdk.mjs","names":["AeSdkBase","decode","UnavailableAccountError","AeSdk","constructor","accounts","options","arguments","length","undefined","_defineProperty","forEach","account","idx","addAccount","select","_resolveAccount","selectedAddress","address","addresses","Object","keys","selectAccount","removeAccount"],"sources":["../src/AeSdk.ts"],"sourcesContent":["import AeSdkBase from './AeSdkBase';\nimport { OnAccount } from './AeSdkMethods';\nimport AccountBase from './account/Base';\nimport { decode, Encoded } from './utils/encoder';\nimport { UnavailableAccountError } from './utils/errors';\n\nexport default class AeSdk extends AeSdkBase {\n accounts: { [key: Encoded.AccountAddress]: AccountBase } = {};\n\n selectedAddress?: Encoded.AccountAddress;\n\n constructor(\n { accounts, ...options }: { accounts?: AccountBase[] }\n & ConstructorParameters<typeof AeSdkBase>[0] = {},\n ) {\n super(options);\n accounts?.forEach((account, idx) => this.addAccount(account, { select: idx === 0 }));\n }\n\n override _resolveAccount(account: OnAccount = this.selectedAddress): AccountBase {\n if (typeof account === 'string') {\n const address = account as Encoded.AccountAddress;\n decode(address);\n if (this.accounts[address] == null) throw new UnavailableAccountError(account);\n account = this.accounts[address];\n }\n return super._resolveAccount(account);\n }\n\n /**\n * Get accounts addresses\n * @example addresses()\n */\n override addresses(): Encoded.AccountAddress[] {\n return Object.keys(this.accounts) as Encoded.AccountAddress[];\n }\n\n /**\n * Add specific account\n * @param account - Account instance\n * @param options - Options\n * @param options.select - Select account\n * @example addAccount(account)\n */\n addAccount(account: AccountBase, { select }: { select?: boolean } = {}): void {\n const { address } = account;\n this.accounts[address] = account;\n if (select === true) this.selectAccount(address);\n }\n\n /**\n * Remove specific account\n * @param address - Address of account to remove\n * @example removeAccount(address)\n */\n removeAccount(address: Encoded.AccountAddress): void {\n if (this.accounts[address] == null) throw new UnavailableAccountError(address);\n delete this.accounts[address]; // eslint-disable-line @typescript-eslint/no-dynamic-delete\n if (this.selectedAddress === address) delete this.selectedAddress;\n }\n\n /**\n * Select specific account\n * @param address - Address of account to select\n * @example selectAccount('ak_xxxxxxxx')\n */\n selectAccount(address: Encoded.AccountAddress): void {\n decode(address);\n if (this.accounts[address] == null) throw new UnavailableAccountError(address);\n this.selectedAddress = address;\n }\n}\n"],"mappings":";OAAOA,SAAS;AAAA,SAGPC,MAAM;AAAA,SACNC,uBAAuB;AAEhC,eAAe,MAAMC,KAAK,SAASH,SAAS,CAAC;EAK3CI,WAAWA,CAAA,EAGT;IAAA,IAFA;MAAEC,QAAQ;MAAE,GAAGC;IAC4B,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAEjD,KAAK,CAACD,OAAO,CAAC;IAACI,eAAA,mBAR0C,CAAC,CAAC;IAS3DL,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEM,OAAO,CAAC,CAACC,OAAO,EAAEC,GAAG,KAAK,IAAI,CAACC,UAAU,CAACF,OAAO,EAAE;MAAEG,MAAM,EAAEF,GAAG,KAAK;IAAE,CAAC,CAAC,CAAC;EACtF;EAESG,eAAeA,CAAA,EAAyD;IAAA,IAAxDJ,OAAkB,GAAAL,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI,CAACU,eAAe;IAChE,IAAI,OAAOL,OAAO,KAAK,QAAQ,EAAE;MAC/B,MAAMM,OAAO,GAAGN,OAAiC;MACjDX,MAAM,CAACiB,OAAO,CAAC;MACf,IAAI,IAAI,CAACb,QAAQ,CAACa,OAAO,CAAC,IAAI,IAAI,EAAE,MAAM,IAAIhB,uBAAuB,CAACU,OAAO,CAAC;MAC9EA,OAAO,GAAG,IAAI,CAACP,QAAQ,CAACa,OAAO,CAAC;IAClC;IACA,OAAO,KAAK,CAACF,eAAe,CAACJ,OAAO,CAAC;EACvC;;EAEA;AACF;AACA;AACA;EACWO,SAASA,CAAA,EAA6B;IAC7C,OAAOC,MAAM,CAACC,IAAI,CAAC,IAAI,CAAChB,QAAQ,CAAC;EACnC;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACES,UAAUA,CAACF,OAAoB,EAA+C;IAAA,IAA7C;MAAEG;IAA6B,CAAC,GAAAR,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IACpE,MAAM;MAAEW;IAAQ,CAAC,GAAGN,OAAO;IAC3B,IAAI,CAACP,QAAQ,CAACa,OAAO,CAAC,GAAGN,OAAO;IAChC,IAAIG,MAAM,KAAK,IAAI,EAAE,IAAI,CAACO,aAAa,CAACJ,OAAO,CAAC;EAClD;;EAEA;AACF;AACA;AACA;AACA;EACEK,aAAaA,CAACL,OAA+B,EAAQ;IACnD,IAAI,IAAI,CAACb,QAAQ,CAACa,OAAO,CAAC,IAAI,IAAI,EAAE,MAAM,IAAIhB,uBAAuB,CAACgB,OAAO,CAAC;IAC9E,OAAO,IAAI,CAACb,QAAQ,CAACa,OAAO,CAAC,CAAC,CAAC;IAC/B,IAAI,IAAI,CAACD,eAAe,KAAKC,OAAO,EAAE,OAAO,IAAI,CAACD,eAAe;EACnE;;EAEA;AACF;AACA;AACA;AACA;EACEK,aAAaA,CAACJ,OAA+B,EAAQ;IACnDjB,MAAM,CAACiB,OAAO,CAAC;IACf,IAAI,IAAI,CAACb,QAAQ,CAACa,OAAO,CAAC,IAAI,IAAI,EAAE,MAAM,IAAIhB,uBAAuB,CAACgB,OAAO,CAAC;IAC9E,IAAI,CAACD,eAAe,GAAGC,OAAO;EAChC;AACF"}
|
package/es/AeSdkAepp.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import AeSdkBase from './AeSdkBase';
|
|
|
2
2
|
import { OnAccount } from './AeSdkMethods';
|
|
3
3
|
import AccountBase from './account/Base';
|
|
4
4
|
import { Encoded } from './utils/encoder';
|
|
5
|
-
import { Accounts, WalletInfo, Network, WalletApi, AeppApi } from './aepp-wallet-communication/rpc/types';
|
|
5
|
+
import { Accounts, WalletInfo, Network, WalletApi, AeppApi, Node as NodeRpc } from './aepp-wallet-communication/rpc/types';
|
|
6
6
|
import RpcClient from './aepp-wallet-communication/rpc/RpcClient';
|
|
7
7
|
import { METHODS, SUBSCRIPTION_TYPES } from './aepp-wallet-communication/schema';
|
|
8
8
|
import BrowserConnection from './aepp-wallet-communication/connection/Browser';
|
|
@@ -41,11 +41,12 @@ export default class AeSdkAepp extends AeSdkBase {
|
|
|
41
41
|
* @param options.name - Node name
|
|
42
42
|
* @param options.select - Select this node as current
|
|
43
43
|
*/
|
|
44
|
-
connectToWallet(connection: BrowserConnection, { connectNode, name
|
|
44
|
+
connectToWallet(connection: BrowserConnection, { connectNode, name }?: {
|
|
45
45
|
connectNode?: boolean;
|
|
46
46
|
name?: string;
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
}): Promise<WalletInfo & {
|
|
48
|
+
node?: NodeRpc;
|
|
49
|
+
}>;
|
|
49
50
|
/**
|
|
50
51
|
* Disconnect from wallet
|
|
51
52
|
*/
|
package/es/AeSdkAepp.mjs
CHANGED
|
@@ -62,11 +62,19 @@ export default class AeSdkAepp extends AeSdkBase {
|
|
|
62
62
|
async connectToWallet(connection) {
|
|
63
63
|
let {
|
|
64
64
|
connectNode = false,
|
|
65
|
-
name = 'wallet-node'
|
|
66
|
-
select = false
|
|
65
|
+
name = 'wallet-node'
|
|
67
66
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
68
67
|
if (this.rpcClient != null) throw new AlreadyConnectedError('You are already connected to wallet');
|
|
69
68
|
let disconnectParams;
|
|
69
|
+
const updateNetwork = params => {
|
|
70
|
+
if (connectNode) {
|
|
71
|
+
var _params$node;
|
|
72
|
+
if (((_params$node = params.node) === null || _params$node === void 0 ? void 0 : _params$node.url) == null) throw new RpcConnectionError('Missing URLs of the Node');
|
|
73
|
+
this.pool.delete(name);
|
|
74
|
+
this.addNode(name, new Node(params.node.url), true);
|
|
75
|
+
}
|
|
76
|
+
this.onNetworkChange(params);
|
|
77
|
+
};
|
|
70
78
|
const client = new RpcClient(connection, () => {
|
|
71
79
|
delete this.rpcClient;
|
|
72
80
|
delete this._accounts;
|
|
@@ -76,31 +84,19 @@ export default class AeSdkAepp extends AeSdkBase {
|
|
|
76
84
|
this._accounts = params;
|
|
77
85
|
this.onAddressChange(params);
|
|
78
86
|
},
|
|
79
|
-
[METHODS.updateNetwork]:
|
|
80
|
-
const {
|
|
81
|
-
node
|
|
82
|
-
} = params;
|
|
83
|
-
if (node != null) this.addNode(node.name, new Node(node.url), true);
|
|
84
|
-
this.onNetworkChange(params);
|
|
85
|
-
},
|
|
87
|
+
[METHODS.updateNetwork]: updateNetwork,
|
|
86
88
|
[METHODS.closeConnection]: params => {
|
|
87
89
|
disconnectParams = params;
|
|
88
90
|
client.connection.disconnect();
|
|
89
91
|
},
|
|
90
92
|
[METHODS.readyToConnect]: () => {}
|
|
91
93
|
});
|
|
92
|
-
const {
|
|
93
|
-
node,
|
|
94
|
-
...walletInfo
|
|
95
|
-
} = await client.request(METHODS.connect, {
|
|
94
|
+
const walletInfo = await client.request(METHODS.connect, {
|
|
96
95
|
name: this.name,
|
|
97
96
|
version: RPC_VERSION,
|
|
98
97
|
connectNode
|
|
99
98
|
});
|
|
100
|
-
|
|
101
|
-
if (node == null) throw new RpcConnectionError('Missing URLs of the Node');
|
|
102
|
-
this.addNode(name, new Node(node.url), select);
|
|
103
|
-
}
|
|
99
|
+
updateNetwork(walletInfo);
|
|
104
100
|
this.rpcClient = client;
|
|
105
101
|
return walletInfo;
|
|
106
102
|
}
|
package/es/AeSdkAepp.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AeSdkAepp.mjs","names":["AeSdkBase","AccountRpc","decode","RPC_VERSION","RpcClient","METHODS","AlreadyConnectedError","NoWalletConnectedError","UnsubscribedAccountError","UnAuthorizedAccountError","RpcConnectionError","Node","AeSdkAepp","constructor","name","onAddressChange","onDisconnect","onNetworkChange","other","_resolveAccount","account","addresses","address","includes","_ensureConnected","rpcClient","_ensureAccountAccess","_accounts","current","Object","keys","connected","connectToWallet","connection","connectNode","select","disconnectParams","client","updateAddress","params","updateNetwork","node","addNode","url","closeConnection","disconnect","readyToConnect","walletInfo","request","connect","version","disconnectWallet","notify","reason","askAddresses","undefined","subscribeAddress","type","value","result","length"],"sources":["../src/AeSdkAepp.ts"],"sourcesContent":["import AeSdkBase from './AeSdkBase';\nimport { OnAccount } from './AeSdkMethods';\nimport AccountBase from './account/Base';\nimport AccountRpc from './account/Rpc';\nimport { decode, Encoded } from './utils/encoder';\nimport {\n Accounts, RPC_VERSION, WalletInfo, Network, WalletApi, AeppApi,\n} from './aepp-wallet-communication/rpc/types';\nimport RpcClient from './aepp-wallet-communication/rpc/RpcClient';\nimport { METHODS, SUBSCRIPTION_TYPES } from './aepp-wallet-communication/schema';\nimport {\n AlreadyConnectedError,\n NoWalletConnectedError,\n UnsubscribedAccountError,\n UnAuthorizedAccountError,\n RpcConnectionError,\n} from './utils/errors';\nimport Node from './Node';\nimport BrowserConnection from './aepp-wallet-communication/connection/Browser';\n\n/**\n * RPC handler for AEPP side\n * Contain functionality for wallet interaction and connect it to sdk\n * @category aepp wallet communication\n */\nexport default class AeSdkAepp extends AeSdkBase {\n name: string;\n\n onAddressChange: (a: Accounts) => void;\n\n onDisconnect: (p: any) => void;\n\n onNetworkChange: (a: Network) => void;\n\n rpcClient?: RpcClient<WalletApi, AeppApi>;\n\n _accounts?: Accounts;\n\n /**\n * @param options - Options\n * @param options.name - Aepp name\n * @param options.onAddressChange - Call-back function for update address event\n * @param options.onDisconnect - Call-back function for disconnect event\n * @param options.onNetworkChange - Call-back function for update network event\n */\n constructor({\n name,\n onAddressChange = () => {},\n onDisconnect = () => {},\n onNetworkChange = () => {},\n ...other\n }: {\n name: string;\n onAddressChange?: (a: Accounts) => void;\n onDisconnect?: (p: any) => void;\n onNetworkChange?: (a: Network) => void;\n } & ConstructorParameters<typeof AeSdkBase>[0]) {\n super(other);\n this.onAddressChange = onAddressChange;\n this.onDisconnect = onDisconnect;\n this.onNetworkChange = onNetworkChange;\n this.name = name;\n }\n\n override _resolveAccount(account: OnAccount = this.addresses()[0]): AccountBase {\n if (typeof account === 'string') {\n const address = account as Encoded.AccountAddress;\n decode(address);\n if (!this.addresses().includes(address)) throw new UnAuthorizedAccountError(address);\n this._ensureConnected();\n account = new AccountRpc(this.rpcClient, address);\n }\n if (account == null) this._ensureAccountAccess();\n return super._resolveAccount(account);\n }\n\n override addresses(): Encoded.AccountAddress[] {\n if (this._accounts == null) return [];\n const current = Object.keys(this._accounts.current)[0];\n return [\n ...current != null ? [current] : [], ...Object.keys(this._accounts.connected),\n ] as Encoded.AccountAddress[];\n }\n\n /**\n * Connect to wallet\n * @param connection - Wallet connection object\n * @param options - Options\n * @param options.connectNode - Request wallet to bind node\n * @param options.name - Node name\n * @param options.select - Select this node as current\n */\n async connectToWallet(\n connection: BrowserConnection,\n { connectNode = false, name = 'wallet-node', select = false }:\n { connectNode?: boolean; name?: string; select?: boolean } = {},\n ): Promise<WalletInfo> {\n if (this.rpcClient != null) throw new AlreadyConnectedError('You are already connected to wallet');\n let disconnectParams: any;\n const client = new RpcClient<WalletApi, AeppApi>(\n connection,\n () => {\n delete this.rpcClient;\n delete this._accounts;\n this.onDisconnect(disconnectParams);\n },\n {\n [METHODS.updateAddress]: (params) => {\n this._accounts = params;\n this.onAddressChange(params);\n },\n [METHODS.updateNetwork]: (params) => {\n const { node } = params;\n if (node != null) this.addNode(node.name, new Node(node.url), true);\n this.onNetworkChange(params);\n },\n [METHODS.closeConnection]: (params) => {\n disconnectParams = params;\n client.connection.disconnect();\n },\n [METHODS.readyToConnect]: () => {},\n },\n );\n const { node, ...walletInfo } = await client\n .request(METHODS.connect, { name: this.name, version: RPC_VERSION, connectNode });\n if (connectNode) {\n if (node == null) throw new RpcConnectionError('Missing URLs of the Node');\n this.addNode(name, new Node(node.url), select);\n }\n this.rpcClient = client;\n return walletInfo;\n }\n\n /**\n * Disconnect from wallet\n */\n disconnectWallet(): void {\n this._ensureConnected();\n this.rpcClient.notify(METHODS.closeConnection, { reason: 'bye' });\n this.rpcClient.connection.disconnect();\n }\n\n /**\n * Ask addresses from wallet\n * @returns Addresses from wallet\n */\n async askAddresses(): Promise<Encoded.AccountAddress[]> {\n this._ensureAccountAccess();\n return this.rpcClient.request(METHODS.address, undefined);\n }\n\n /**\n * Subscribe for addresses from wallet\n * @param type - Subscription type\n * @param value - Should be one of 'current' (the selected account), 'connected' (all)\n * @returns Accounts from wallet\n */\n async subscribeAddress(\n type: SUBSCRIPTION_TYPES,\n value: 'current' | 'connected',\n ): Promise<ReturnType<WalletApi[METHODS.subscribeAddress]>> {\n this._ensureConnected();\n const result = await this.rpcClient.request(METHODS.subscribeAddress, { type, value });\n this._accounts = result.address;\n return result;\n }\n\n _ensureConnected(): asserts this is AeSdkAepp & { rpcClient: NonNullable<AeSdkAepp['rpcClient']> } {\n if (this.rpcClient != null) return;\n throw new NoWalletConnectedError('You are not connected to Wallet');\n }\n\n _ensureAccountAccess(): asserts this is AeSdkAepp & { rpcClient: NonNullable<AeSdkAepp['rpcClient']> } {\n this._ensureConnected();\n if (this.addresses().length !== 0) return;\n throw new UnsubscribedAccountError();\n }\n}\n"],"mappings":"OAAOA,SAAS;AAAA,OAGTC,UAAU;AAAA,SACRC,MAAM;AAAA,SAEHC,WAAW;AAAA,OAEhBC,SAAS;AAAA,SACPC,OAAO;AAAA,SAEdC,qBAAqB,EACrBC,sBAAsB,EACtBC,wBAAwB,EACxBC,wBAAwB,EACxBC,kBAAkB;AAAA,OAEbC,IAAI;AAGX;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,SAAS,SAASZ,SAAS,CAAC;EAa/C;AACF;AACA;AACA;AACA;AACA;AACA;EACEa,WAAW,OAWqC;IAAA,IAXpC;MACVC,IAAI;MACJC,eAAe,GAAG,MAAM,CAAC,CAAC;MAC1BC,YAAY,GAAG,MAAM,CAAC,CAAC;MACvBC,eAAe,GAAG,MAAM,CAAC,CAAC;MAC1B,GAAGC;IA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AAE;IACvB,IAAI,IAAI,CAACH,SAAS,EAAE,CAACuC,MAAM,KAAK,CAAC,EAAE;IACnC,MAAM,IAAIpD,wBAAwB,EAAE;EACtC;AACF"}
|
|
1
|
+
{"version":3,"file":"AeSdkAepp.mjs","names":["AeSdkBase","AccountRpc","decode","RPC_VERSION","RpcClient","METHODS","AlreadyConnectedError","NoWalletConnectedError","UnsubscribedAccountError","UnAuthorizedAccountError","RpcConnectionError","Node","AeSdkAepp","constructor","_ref","name","onAddressChange","onDisconnect","onNetworkChange","other","_resolveAccount","account","arguments","length","undefined","addresses","address","includes","_ensureConnected","rpcClient","_ensureAccountAccess","_accounts","current","Object","keys","connected","connectToWallet","connection","connectNode","disconnectParams","updateNetwork","params","_params$node","node","url","pool","delete","addNode","client","updateAddress","closeConnection","disconnect","readyToConnect","walletInfo","request","connect","version","disconnectWallet","notify","reason","askAddresses","subscribeAddress","type","value","result"],"sources":["../src/AeSdkAepp.ts"],"sourcesContent":["import AeSdkBase from './AeSdkBase';\nimport { OnAccount } from './AeSdkMethods';\nimport AccountBase from './account/Base';\nimport AccountRpc from './account/Rpc';\nimport { decode, Encoded } from './utils/encoder';\nimport {\n Accounts, RPC_VERSION, WalletInfo, Network, WalletApi, AeppApi, Node as NodeRpc,\n} from './aepp-wallet-communication/rpc/types';\nimport RpcClient from './aepp-wallet-communication/rpc/RpcClient';\nimport { METHODS, SUBSCRIPTION_TYPES } from './aepp-wallet-communication/schema';\nimport {\n AlreadyConnectedError,\n NoWalletConnectedError,\n UnsubscribedAccountError,\n UnAuthorizedAccountError,\n RpcConnectionError,\n} from './utils/errors';\nimport Node from './Node';\nimport BrowserConnection from './aepp-wallet-communication/connection/Browser';\n\n/**\n * RPC handler for AEPP side\n * Contain functionality for wallet interaction and connect it to sdk\n * @category aepp wallet communication\n */\nexport default class AeSdkAepp extends AeSdkBase {\n name: string;\n\n onAddressChange: (a: Accounts) => void;\n\n onDisconnect: (p: any) => void;\n\n onNetworkChange: (a: Network) => void;\n\n rpcClient?: RpcClient<WalletApi, AeppApi>;\n\n _accounts?: Accounts;\n\n /**\n * @param options - Options\n * @param options.name - Aepp name\n * @param options.onAddressChange - Call-back function for update address event\n * @param options.onDisconnect - Call-back function for disconnect event\n * @param options.onNetworkChange - Call-back function for update network event\n */\n constructor({\n name,\n onAddressChange = () => {},\n onDisconnect = () => {},\n onNetworkChange = () => {},\n ...other\n }: {\n name: string;\n onAddressChange?: (a: Accounts) => void;\n onDisconnect?: (p: any) => void;\n onNetworkChange?: (a: Network) => void;\n } & ConstructorParameters<typeof AeSdkBase>[0]) {\n super(other);\n this.onAddressChange = onAddressChange;\n this.onDisconnect = onDisconnect;\n this.onNetworkChange = onNetworkChange;\n this.name = name;\n }\n\n override _resolveAccount(account: OnAccount = this.addresses()[0]): AccountBase {\n if (typeof account === 'string') {\n const address = account as Encoded.AccountAddress;\n decode(address);\n if (!this.addresses().includes(address)) throw new UnAuthorizedAccountError(address);\n this._ensureConnected();\n account = new AccountRpc(this.rpcClient, address);\n }\n if (account == null) this._ensureAccountAccess();\n return super._resolveAccount(account);\n }\n\n override addresses(): Encoded.AccountAddress[] {\n if (this._accounts == null) return [];\n const current = Object.keys(this._accounts.current)[0];\n return [\n ...current != null ? [current] : [], ...Object.keys(this._accounts.connected),\n ] as Encoded.AccountAddress[];\n }\n\n /**\n * Connect to wallet\n * @param connection - Wallet connection object\n * @param options - Options\n * @param options.connectNode - Request wallet to bind node\n * @param options.name - Node name\n * @param options.select - Select this node as current\n */\n async connectToWallet(\n connection: BrowserConnection,\n { connectNode = false, name = 'wallet-node' }: { connectNode?: boolean; name?: string } = {},\n ): Promise<WalletInfo & { node?: NodeRpc }> {\n if (this.rpcClient != null) throw new AlreadyConnectedError('You are already connected to wallet');\n let disconnectParams: any;\n\n const updateNetwork = (params: Network): void => {\n if (connectNode) {\n if (params.node?.url == null) throw new RpcConnectionError('Missing URLs of the Node');\n this.pool.delete(name);\n this.addNode(name, new Node(params.node.url), true);\n }\n this.onNetworkChange(params);\n };\n\n const client = new RpcClient<WalletApi, AeppApi>(\n connection,\n () => {\n delete this.rpcClient;\n delete this._accounts;\n this.onDisconnect(disconnectParams);\n },\n {\n [METHODS.updateAddress]: (params) => {\n this._accounts = params;\n this.onAddressChange(params);\n },\n [METHODS.updateNetwork]: updateNetwork,\n [METHODS.closeConnection]: (params) => {\n disconnectParams = params;\n client.connection.disconnect();\n },\n [METHODS.readyToConnect]: () => {},\n },\n );\n const walletInfo = await client\n .request(METHODS.connect, { name: this.name, version: RPC_VERSION, connectNode });\n updateNetwork(walletInfo);\n this.rpcClient = client;\n return walletInfo;\n }\n\n /**\n * Disconnect from wallet\n */\n disconnectWallet(): void {\n this._ensureConnected();\n this.rpcClient.notify(METHODS.closeConnection, { reason: 'bye' });\n this.rpcClient.connection.disconnect();\n }\n\n /**\n * Ask addresses from wallet\n * @returns Addresses from wallet\n */\n async askAddresses(): Promise<Encoded.AccountAddress[]> {\n this._ensureAccountAccess();\n return this.rpcClient.request(METHODS.address, undefined);\n }\n\n /**\n * Subscribe for addresses from wallet\n * @param type - Subscription type\n * @param value - Should be one of 'current' (the selected account), 'connected' (all)\n * @returns Accounts from wallet\n */\n async subscribeAddress(\n type: SUBSCRIPTION_TYPES,\n value: 'current' | 'connected',\n ): Promise<ReturnType<WalletApi[METHODS.subscribeAddress]>> {\n this._ensureConnected();\n const result = await this.rpcClient.request(METHODS.subscribeAddress, { type, value });\n this._accounts = result.address;\n return result;\n }\n\n _ensureConnected(): asserts this is AeSdkAepp & { rpcClient: NonNullable<AeSdkAepp['rpcClient']> } {\n if (this.rpcClient != null) return;\n throw new NoWalletConnectedError('You are not connected to Wallet');\n }\n\n _ensureAccountAccess(): asserts this is AeSdkAepp & { rpcClient: NonNullable<AeSdkAepp['rpcClient']> } {\n this._ensureConnected();\n if (this.addresses().length !== 0) return;\n throw new UnsubscribedAccountError();\n }\n}\n"],"mappings":"OAAOA,SAAS;AAAA,OAGTC,UAAU;AAAA,SACRC,MAAM;AAAA,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IAC3B,OAAO,IAAI,CAACD,SAAS,CAACyB,OAAO,CAACjD,OAAO,CAACqB,OAAO,EAAEF,SAAS,CAAC;EAC3D;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,MAAMqC,gBAAgBA,CACpBC,IAAwB,EACxBC,KAA8B,EAC4B;IAC1D,IAAI,CAACnC,gBAAgB,EAAE;IACvB,MAAMoC,MAAM,GAAG,MAAM,IAAI,CAACnC,SAAS,CAACyB,OAAO,CAACjD,OAAO,CAACwD,gBAAgB,EAAE;MAAEC,IAAI;MAAEC;IAAM,CAAC,CAAC;IACtF,IAAI,CAAChC,SAAS,GAAGiC,MAAM,CAACtC,OAAO;IAC/B,OAAOsC,MAAM;EACf;EAEApC,gBAAgBA,CAAA,EAAmF;IACjG,IAAI,IAAI,CAACC,SAAS,IAAI,IAAI,EAAE;IAC5B,MAAM,IAAItB,sBAAsB,CAAC,iCAAiC,CAAC;EACrE;EAEAuB,oBAAoBA,CAAA,EAAmF;IACrG,IAAI,CAACF,gBAAgB,EAAE;IACvB,IAAI,IAAI,CAACH,SAAS,EAAE,CAACF,MAAM,KAAK,CAAC,EAAE;IACnC,MAAM,IAAIf,wBAAwB,EAAE;EACtC;AACF"}
|
package/es/AeSdkBase.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AeSdkBase.mjs","names":["CompilerError","DuplicateNodeError","NodeNotFoundError","AeSdkMethods","getValueOrErrorProxy","AeSdkBase","constructor","nodes","options","Map","forEach","i","name","instance","addNode","compilerApi","_options","onCompiler","api","ensureNodeConnected","pool","get","selectedNodeName","node","select","has","set","selectNode","isNodeConnected","getNodeInfo","getNodesInPool","Promise","all","Array","from","entries","map","addresses","address","_resolveAccount","sign","data","onAccount","signTransaction","tx","networkId","getNetworkId","
|
|
1
|
+
{"version":3,"file":"AeSdkBase.mjs","names":["CompilerError","DuplicateNodeError","NodeNotFoundError","AeSdkMethods","getValueOrErrorProxy","AeSdkBase","constructor","nodes","options","arguments","length","undefined","_defineProperty","Map","forEach","_ref","i","name","instance","addNode","compilerApi","_options","onCompiler","api","ensureNodeConnected","pool","get","selectedNodeName","node","select","has","set","selectNode","isNodeConnected","getNodeInfo","getNodesInPool","Promise","all","Array","from","entries","map","_ref2","addresses","address","_resolveAccount","sign","data","onAccount","signTransaction","tx","networkId","getNetworkId","signMessage","message","_getOptions","onNode"],"sources":["../src/AeSdkBase.ts"],"sourcesContent":["import Node from './Node';\nimport AccountBase from './account/Base';\nimport { CompilerError, DuplicateNodeError, NodeNotFoundError } from './utils/errors';\nimport { Encoded } from './utils/encoder';\nimport CompilerBase from './contract/compiler/Base';\nimport AeSdkMethods, { OnAccount, getValueOrErrorProxy } from './AeSdkMethods';\n\ntype NodeInfo = Awaited<ReturnType<Node['getNodeInfo']>> & { name: string };\n\n/**\n * Basic AeSdk class implements:\n * - node selector,\n * - integrated compiler support,\n * - wrappers of account methods mapped to the current account.\n */\nexport default class AeSdkBase extends AeSdkMethods {\n pool: Map<string, Node> = new Map();\n\n selectedNodeName?: string;\n\n /**\n * @param options - Options\n * @param options.nodes - Array of nodes\n */\n constructor(\n { nodes = [], ...options }: ConstructorParameters<typeof AeSdkMethods>[0] & {\n nodes?: Array<{ name: string; instance: Node }>;\n } = {},\n ) {\n super(options);\n\n nodes.forEach(({ name, instance }, i) => this.addNode(name, instance, i === 0));\n }\n\n // TODO: consider dropping this getter, because:\n // compiler is not intended to be used separately any more (functionality limited to sdk needs)\n // and user creates its instance by himself\n get compilerApi(): CompilerBase {\n if (this._options.onCompiler == null) {\n throw new CompilerError('You can\\'t use Compiler API. Compiler is not ready!');\n }\n return this._options.onCompiler;\n }\n\n get api(): Node {\n this.ensureNodeConnected();\n return this.pool.get(this.selectedNodeName) as Node;\n }\n\n /**\n * Add Node\n * @param name - Node name\n * @param node - Node instance\n * @param select - Select this node as current\n * @example\n * ```js\n * // add and select new node with name 'testNode'\n * aeSdkBase.addNode('testNode', new Node({ url }), true)\n * ```\n */\n addNode(name: string, node: Node, select = false): void {\n if (this.pool.has(name)) throw new DuplicateNodeError(name);\n\n this.pool.set(name, node);\n if (select || this.selectedNodeName == null) {\n this.selectNode(name);\n }\n }\n\n /**\n * Select Node\n * @param name - Node name\n * @example\n * nodePool.selectNode('testNode')\n */\n selectNode(name: string): void {\n if (!this.pool.has(name)) throw new NodeNotFoundError(`Node with name ${name} not in pool`);\n this.selectedNodeName = name;\n }\n\n /**\n * Check if you have selected node\n * @example\n * nodePool.isNodeConnected()\n */\n isNodeConnected(): this is AeSdkBase & { selectedNodeName: string } {\n return this.selectedNodeName != null;\n }\n\n protected ensureNodeConnected(): asserts this is AeSdkBase & { selectedNodeName: string } {\n if (!this.isNodeConnected()) {\n throw new NodeNotFoundError('You can\\'t use Node API. Node is not connected or not defined!');\n }\n }\n\n /**\n * Get information about node\n * @example\n * ```js\n * nodePool.getNodeInfo() // { name, version, networkId, protocol, ... }\n * ```\n */\n async getNodeInfo(): Promise<NodeInfo> {\n this.ensureNodeConnected();\n return {\n name: this.selectedNodeName,\n ...await this.api.getNodeInfo(),\n };\n }\n\n /**\n * Get array of available nodes\n * @example\n * nodePool.getNodesInPool()\n */\n async getNodesInPool(): Promise<NodeInfo[]> {\n return Promise.all(\n Array.from(this.pool.entries()).map(async ([name, node]) => ({\n name,\n ...await node.getNodeInfo(),\n })),\n );\n }\n\n // eslint-disable-next-line class-methods-use-this\n addresses(): Encoded.AccountAddress[] {\n return [];\n }\n\n get address(): Encoded.AccountAddress {\n return this._resolveAccount().address;\n }\n\n async sign(\n data: string | Uint8Array,\n { onAccount, ...options }: { onAccount?: OnAccount } = {},\n ): Promise<Uint8Array> {\n return this._resolveAccount(onAccount).sign(data, options);\n }\n\n async signTransaction(\n tx: Encoded.Transaction,\n { onAccount, ...options }: { onAccount?: OnAccount } & Parameters<AccountBase['signTransaction']>[1] = {},\n ): Promise<Encoded.Transaction> {\n const networkId = this.selectedNodeName !== null ? await this.api.getNetworkId() : undefined;\n return this._resolveAccount(onAccount).signTransaction(tx, { networkId, ...options });\n }\n\n async signMessage(\n message: string,\n { onAccount, ...options }: { onAccount?: OnAccount } & Parameters<AccountBase['signMessage']>[1] = {},\n ): Promise<Uint8Array> {\n return this._resolveAccount(onAccount).signMessage(message, options);\n }\n\n override _getOptions(): {\n onNode: Node;\n onAccount: AccountBase;\n onCompiler: CompilerBase;\n } {\n return {\n ...super._getOptions(),\n onNode: getValueOrErrorProxy(() => this.api),\n onCompiler: getValueOrErrorProxy(() => this.compilerApi),\n };\n }\n}\n"],"mappings":";SAESA,aAAa,EAAEC,kBAAkB,EAAEC,iBAAiB;AAAA,OAGtDC,YAAY,IAAeC,oBAAoB;AAItD;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,SAAS,SAASF,YAAY,CAAC;EAKlD;AACF;AACA;AACA;EACEG,WAAWA,CAAA,EAIT;IAAA,IAHA;MAAEC,KAAK,GAAG,EAAE;MAAE,GAAGC;IAEjB,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAEN,KAAK,CAACD,OAAO,CAAC;IAACI,eAAA,eAbS,IAAIC,GAAG,EAAE;IAejCN,KAAK,CAACO,OAAO,CAAC,CAAAC,IAAA,EAAqBC,CAAC;MAAA,IAArB;QAAEC,IAAI;QAAEC;MAAS,CAAC,GAAAH,IAAA;MAAA,OAAQ,IAAI,CAACI,OAAO,CAACF,IAAI,EAAEC,QAAQ,EAAEF,CAAC,KAAK,CAAC,CAAC;IAAA,EAAC;EACjF;;EAEA;EACA;EACA;EACA,IAAII,WAAWA,CAAA,EAAiB;IAC9B,IAAI,IAAI,CAACC,QAAQ,CAACC,UAAU,IAAI,IAAI,EAAE;MACpC,MAAM,IAAItB,aAAa,CAAC,qDAAqD,CAAC;IAChF;IACA,OAAO,IAAI,CAACqB,QAAQ,CAACC,UAAU;EACjC;EAEA,IAAIC,GAAGA,CAAA,EAAS;IACd,IAAI,CAACC,mBAA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CAACC,EAAE,EAAE;MAAEC,SAAS;MAAE,GAAG3C;IAAQ,CAAC,CAAC;EACvF;EAEA,MAAM6C,WAAWA,CACfC,OAAe,EAEM;IAAA,IADrB;MAAEN,SAAS;MAAE,GAAGxC;IAA+E,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAErG,OAAO,IAAI,CAACoC,eAAe,CAACG,SAAS,CAAC,CAACK,WAAW,CAACC,OAAO,EAAE9C,OAAO,CAAC;EACtE;EAES+C,WAAWA,CAAA,EAIlB;IACA,OAAO;MACL,GAAG,KAAK,CAACA,WAAW,EAAE;MACtBC,MAAM,EAAEpD,oBAAoB,CAAC,MAAM,IAAI,CAACmB,GAAG,CAAC;MAC5CD,UAAU,EAAElB,oBAAoB,CAAC,MAAM,IAAI,CAACgB,WAAW;IACzD,CAAC;EACH;AACF"}
|
package/es/AeSdkMethods.d.ts
CHANGED
|
@@ -3,19 +3,20 @@ import * as aensMethods from './aens';
|
|
|
3
3
|
import * as spendMethods from './spend';
|
|
4
4
|
import * as oracleMethods from './oracle';
|
|
5
5
|
import Contract, { ContractMethodsBase } from './contract/Contract';
|
|
6
|
+
import createDelegationSignature from './contract/delegation-signature';
|
|
6
7
|
import * as contractGaMethods from './contract/ga';
|
|
7
|
-
import { _buildTx } from './tx';
|
|
8
8
|
import { UnionToIntersection } from './utils/other';
|
|
9
9
|
import Node from './Node';
|
|
10
|
-
import {
|
|
10
|
+
import { TxParamsAsync } from './tx/builder/schema.generated';
|
|
11
11
|
import AccountBase from './account/Base';
|
|
12
12
|
import { Encoded } from './utils/encoder';
|
|
13
|
-
import CompilerBase from './contract/compiler/Base';
|
|
14
13
|
export type OnAccount = Encoded.AccountAddress | AccountBase | undefined;
|
|
15
14
|
export declare function getValueOrErrorProxy<Value extends object>(valueCb: () => Value): Value;
|
|
16
15
|
declare const methods: {
|
|
17
16
|
readonly createGeneralizedAccount: typeof contractGaMethods.createGeneralizedAccount;
|
|
18
17
|
readonly buildAuthTxHash: typeof contractGaMethods.buildAuthTxHash;
|
|
18
|
+
readonly buildAuthTxHashByGaMetaTx: typeof contractGaMethods.buildAuthTxHashByGaMetaTx;
|
|
19
|
+
readonly createDelegationSignature: typeof createDelegationSignature;
|
|
19
20
|
readonly pollForQueries: typeof oracleMethods.pollForQueries;
|
|
20
21
|
readonly pollForQueryResponse: typeof oracleMethods.pollForQueryResponse;
|
|
21
22
|
readonly getQueryObject: typeof oracleMethods.getQueryObject;
|
|
@@ -24,7 +25,6 @@ declare const methods: {
|
|
|
24
25
|
readonly respondToQuery: typeof oracleMethods.respondToQuery;
|
|
25
26
|
readonly getOracleObject: typeof oracleMethods.getOracleObject;
|
|
26
27
|
readonly registerOracle: typeof oracleMethods.registerOracle;
|
|
27
|
-
readonly send: typeof spendMethods.send;
|
|
28
28
|
readonly spend: typeof spendMethods.spend;
|
|
29
29
|
readonly transferFunds: typeof spendMethods.transferFunds;
|
|
30
30
|
readonly payForTransaction: typeof spendMethods.payForTransaction;
|
|
@@ -94,9 +94,7 @@ declare class AeSdkMethods {
|
|
|
94
94
|
_getOptions(): AeSdkMethodsOptions & {
|
|
95
95
|
onAccount: AccountBase;
|
|
96
96
|
};
|
|
97
|
-
buildTx
|
|
98
|
-
onNode?: Node;
|
|
99
|
-
}): Promise<Encoded.Transaction>;
|
|
97
|
+
buildTx(options: TxParamsAsync): Promise<Encoded.Transaction>;
|
|
100
98
|
initializeContract<Methods extends ContractMethodsBase>(options?: Omit<Parameters<typeof Contract.initialize>[0], 'onNode'> & {
|
|
101
99
|
onNode?: Node;
|
|
102
100
|
}): Promise<Contract<Methods>>;
|
|
@@ -105,12 +103,13 @@ type RequiredKeys<T> = {
|
|
|
105
103
|
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
|
|
106
104
|
}[keyof T];
|
|
107
105
|
type OptionalIfNotRequired<T extends [any]> = RequiredKeys<T[0]> extends never ? T | [] : T;
|
|
106
|
+
type ReplaceOnAccount<Options> = Options extends {
|
|
107
|
+
onAccount: any;
|
|
108
|
+
} ? Omit<Options, 'onAccount'> & {
|
|
109
|
+
onAccount: OnAccount;
|
|
110
|
+
} : Options;
|
|
108
111
|
type MakeOptional<Options> = OptionalIfNotRequired<[
|
|
109
|
-
Omit<Options, 'onNode' | 'onCompiler' | 'onAccount'> &
|
|
110
|
-
onNode?: Node;
|
|
111
|
-
onCompiler?: CompilerBase;
|
|
112
|
-
onAccount?: OnAccount;
|
|
113
|
-
}
|
|
112
|
+
Omit<Options, 'onNode' | 'onCompiler' | 'onAccount'> & Partial<ReplaceOnAccount<Options>>
|
|
114
113
|
]>;
|
|
115
114
|
type TransformMethods<Methods extends {
|
|
116
115
|
[key: string]: Function;
|
package/es/AeSdkMethods.mjs
CHANGED
|
@@ -4,10 +4,10 @@ import * as aensMethods from "./aens.mjs";
|
|
|
4
4
|
import * as spendMethods from "./spend.mjs";
|
|
5
5
|
import * as oracleMethods from "./oracle.mjs";
|
|
6
6
|
import Contract from "./contract/Contract.mjs";
|
|
7
|
+
import createDelegationSignature from "./contract/delegation-signature.mjs";
|
|
7
8
|
import * as contractGaMethods from "./contract/ga.mjs";
|
|
8
|
-
import {
|
|
9
|
+
import { buildTxAsync } from "./tx/builder/index.mjs";
|
|
9
10
|
import { mapObject } from "./utils/other.mjs";
|
|
10
|
-
import { AE_AMOUNT_FORMATS } from "./utils/amount-formatter.mjs";
|
|
11
11
|
import { ArgumentError, NotImplementedError, TypeError } from "./utils/errors.mjs";
|
|
12
12
|
export function getValueOrErrorProxy(valueCb) {
|
|
13
13
|
return new Proxy({}, {
|
|
@@ -33,6 +33,7 @@ const methods = {
|
|
|
33
33
|
...aensMethods,
|
|
34
34
|
...spendMethods,
|
|
35
35
|
...oracleMethods,
|
|
36
|
+
createDelegationSignature,
|
|
36
37
|
...contractGaMethods
|
|
37
38
|
};
|
|
38
39
|
/**
|
|
@@ -54,9 +55,7 @@ class AeSdkMethods {
|
|
|
54
55
|
*/
|
|
55
56
|
constructor() {
|
|
56
57
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
57
|
-
_defineProperty(this, "_options", {
|
|
58
|
-
denomination: AE_AMOUNT_FORMATS.AETTOS
|
|
59
|
-
});
|
|
58
|
+
_defineProperty(this, "_options", {});
|
|
60
59
|
Object.assign(this._options, options);
|
|
61
60
|
}
|
|
62
61
|
|
|
@@ -76,9 +75,8 @@ class AeSdkMethods {
|
|
|
76
75
|
onAccount: getValueOrErrorProxy(() => this._resolveAccount())
|
|
77
76
|
};
|
|
78
77
|
}
|
|
79
|
-
async buildTx(
|
|
80
|
-
|
|
81
|
-
return _buildTx(txType, {
|
|
78
|
+
async buildTx(options) {
|
|
79
|
+
return buildTxAsync({
|
|
82
80
|
...this._getOptions(),
|
|
83
81
|
...options
|
|
84
82
|
});
|
package/es/AeSdkMethods.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AeSdkMethods.mjs","names":["chainMethods","aensMethods","spendMethods","oracleMethods","Contract","
|
|
1
|
+
{"version":3,"file":"AeSdkMethods.mjs","names":["chainMethods","aensMethods","spendMethods","oracleMethods","Contract","createDelegationSignature","contractGaMethods","buildTxAsync","mapObject","ArgumentError","NotImplementedError","TypeError","getValueOrErrorProxy","valueCb","Proxy","Object","fromEntries","map","name","get","t","property","receiver","target","value","Reflect","bind","has","InvalidTxError","_2","chainMethodsOther","methods","AeSdkMethods","constructor","options","arguments","length","undefined","_defineProperty","assign","_options","_resolveAccount","account","String","_getOptions","onAccount","buildTx","initializeContract","onNode","onCompiler","otherOptions","initialize","prototype","_ref","handler","methodWrapper","_len","args","Array","_key"],"sources":["../src/AeSdkMethods.ts"],"sourcesContent":["import * as chainMethods from './chain';\nimport * as aensMethods from './aens';\nimport * as spendMethods from './spend';\nimport * as oracleMethods from './oracle';\nimport Contract, { ContractMethodsBase } from './contract/Contract';\nimport createDelegationSignature from './contract/delegation-signature';\nimport * as contractGaMethods from './contract/ga';\nimport { buildTxAsync } from './tx/builder';\nimport { mapObject, UnionToIntersection } from './utils/other';\nimport Node from './Node';\nimport { TxParamsAsync } from './tx/builder/schema.generated';\nimport AccountBase from './account/Base';\nimport { Encoded } from './utils/encoder';\nimport { ArgumentError, NotImplementedError, TypeError } from './utils/errors';\n\nexport type OnAccount = Encoded.AccountAddress | AccountBase | undefined;\n\nexport function getValueOrErrorProxy<Value extends object>(valueCb: () => Value): Value {\n return new Proxy({}, {\n ...Object.fromEntries([\n 'apply', 'construct', 'defineProperty', 'deleteProperty', 'getOwnPropertyDescriptor',\n 'getPrototypeOf', 'isExtensible', 'ownKeys', 'preventExtensions', 'set', 'setPrototypeOf',\n ].map((name) => [name, () => { throw new NotImplementedError(`${name} proxy request`); }])),\n get(t: {}, property: string | symbol, receiver: any) {\n const target = valueCb();\n const value = Reflect.get(target, property, receiver);\n return typeof value === 'function' ? value.bind(target) : value;\n },\n has(t: {}, property: string | symbol) {\n return Reflect.has(valueCb(), property);\n },\n }) as Value;\n}\n\nconst { InvalidTxError: _2, ...chainMethodsOther } = chainMethods;\n\nconst methods = {\n ...chainMethodsOther,\n ...aensMethods,\n ...spendMethods,\n ...oracleMethods,\n createDelegationSignature,\n ...contractGaMethods,\n} as const;\n\ntype Decrement<Number extends number> = [-1, 0, 1, 2, 3, 4, 5][Number];\ntype GetMethodsOptions <Methods extends { [key: string]: Function }> =\n {\n [Name in keyof Methods]:\n Methods[Name] extends (...args: infer Args) => any\n ? Args[Decrement<Args['length']>] : never\n };\ntype MethodsOptions = GetMethodsOptions<typeof methods>;\ninterface AeSdkMethodsOptions\n extends Partial<UnionToIntersection<MethodsOptions[keyof MethodsOptions]>> {\n nodes?: Array<{ name: string; instance: Node }>;\n}\n\n/**\n * AeSdkMethods is the composition of:\n * - chain methods\n * - tx methods\n * - aens methods\n * - spend methods\n * - oracle methods\n * - contract methods\n * - contract ga methods\n *\n * While these methods can be used separately, this class provides a handy way to store\n * their context (current account, network, and compiler to use).\n */\nclass AeSdkMethods {\n _options: AeSdkMethodsOptions = {};\n\n /**\n * @param options - Options\n */\n constructor(options: AeSdkMethodsOptions = {}) {\n Object.assign(this._options, options);\n }\n\n /**\n * Resolves an account\n * @param account - ak-address, instance of AccountBase, or keypair\n */\n // eslint-disable-next-line class-methods-use-this\n _resolveAccount(account?: OnAccount): AccountBase {\n if (typeof account === 'string') throw new NotImplementedError('Address in AccountResolver');\n if (typeof account === 'object') return account;\n throw new TypeError(\n 'Account should be an address (ak-prefixed string), '\n + `or instance of AccountBase, got ${String(account)} instead`,\n );\n }\n\n _getOptions(): AeSdkMethodsOptions & { onAccount: AccountBase } {\n return {\n ...this._options,\n onAccount: getValueOrErrorProxy(() => this._resolveAccount()),\n };\n }\n\n async buildTx(options: TxParamsAsync): Promise<Encoded.Transaction> {\n return buildTxAsync({ ...this._getOptions(), ...options });\n }\n\n async initializeContract<Methods extends ContractMethodsBase>(\n options?: Omit<Parameters<typeof Contract.initialize>[0], 'onNode'> & { onNode?: Node },\n ): Promise<Contract<Methods>> {\n const { onNode, onCompiler, ...otherOptions } = this._getOptions();\n if (onCompiler == null || onNode == null) {\n throw new ArgumentError('onCompiler, onNode', 'provided', null);\n }\n return Contract.initialize<Methods>({\n ...otherOptions,\n onNode,\n onCompiler,\n ...options,\n });\n }\n}\n\ntype RequiredKeys<T> = {\n [K in keyof T]-?: {} extends Pick<T, K> ? never : K\n}[keyof T];\n\ntype OptionalIfNotRequired<T extends [any]> = RequiredKeys<T[0]> extends never ? T | [] : T;\n\ntype ReplaceOnAccount<Options> = Options extends { onAccount: any }\n ? Omit<Options, 'onAccount'> & { onAccount: OnAccount } : Options;\n\ntype MakeOptional<Options> = OptionalIfNotRequired<[\n Omit<Options, 'onNode' | 'onCompiler' | 'onAccount'> & Partial<ReplaceOnAccount<Options>>,\n]>;\n\ntype TransformMethods <Methods extends { [key: string]: Function }> =\n {\n [Name in keyof Methods]:\n Methods[Name] extends (...args: [...infer Args, infer Options]) => infer Ret\n ? (...args: [...Args, ...MakeOptional<Options>]) => Ret\n : never\n };\n\ninterface AeSdkMethodsTransformed extends TransformMethods<typeof methods> {}\n\nObject.assign(AeSdkMethods.prototype, mapObject<Function, Function>(\n methods,\n ([name, handler]) => [\n name,\n function methodWrapper(...args: any[]) {\n args.length = handler.length;\n const options = args[args.length - 1];\n args[args.length - 1] = {\n ...this._getOptions(),\n ...options,\n ...options?.onAccount != null && { onAccount: this._resolveAccount(options.onAccount) },\n };\n return handler(...args);\n },\n ],\n));\n\nexport default AeSdkMethods as new (options?: ConstructorParameters<typeof AeSdkMethods>[0]) =>\nAeSdkMethods & AeSdkMethodsTransformed;\n"],"mappings":";OAAO,KAAKA,YAAY;AAAA,OACjB,KAAKC,WAAW;AAAA,OAChB,KAAKC,YAAY;AAAA,OACjB,KAAKC,aAAa;AAAA,OAClBC,QAAQ;AAAA,OACRC,yBAAyB;AAAA,OACzB,KAAKC,iBAAiB;AAAA,SACpBC,YAAY;AAAA,SACZC,SAAS;AAAA,SAKTC,aAAa,EAAEC,mBAAmB,EAAEC,SAAS;AAItD,OAAO,SAASC,oBAAoBA,CAAuBC,OAAoB,EAAS;EACtF,OAAO,IAAIC,KAAK,CAAC,CAAC,CAAC,EAAE;IACnB,GAAGC,MAAM,CAACC,WAAW,CAAC,CACpB,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,0BAA0B,EACpF,gBAAgB,EAAE,cAAc,EAAE,SAAS,EAAE,mBAAmB,EAAE,KAAK,EAAE,gBAAgB,CAC1F,CAACC,GAAG,CAAEC,IAAI,IAAK,CAACA,IAAI,EAAE,MAAM;MAAE,MAAM,IAAIR,mBAAmB,CAAE,GAAEQ,IAAK,gBAAe,CAAC;IAAE,CAAC,CAAC,CAAC,CAAC;IAC3FC,GAAGA,CAACC,CAAK,EAAEC,QAAyB,EAAEC,QAAa,EAAE;MACnD,MAAMC,MAAM,GAAGV,OAAO,EAAE;MACxB,MAAMW,KAAK,GAAGC,O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I,CAACA,IAAI,CAACrB,MAAM,GAAG,CAAC,CAAC,GAAG;MACtB,GAAG,IAAI,CAACQ,WAAW,EAAE;MACrB,GAAGV,OAAO;MACV,IAAG,CAAAA,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEW,SAAS,KAAI,IAAI,IAAI;QAAEA,SAAS,EAAE,IAAI,CAACJ,eAAe,CAACP,OAAO,CAACW,SAAS;MAAE,CAAC;IACzF,CAAC;IACD,OAAOS,OAAO,CAAC,GAAGG,IAAI,CAAC;EACzB,CAAC,CACF;AAAA,EACF,CAAC;AAEF,eAAezB,YAAY"}
|
package/es/AeSdkWallet.mjs
CHANGED
package/es/AeSdkWallet.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AeSdkWallet.mjs","names":["v4","uuid","AeSdk","verifyTransaction","RpcClient","METHODS","RPC_STATUS","SUBSCRIPTION_TYPES","RpcBroadcastError","RpcInvalidTransactionError","RpcNotAuthorizeError","RpcPermissionDenyError","RpcUnsupportedProtocolError","InternalError","UnknownRpcClientError","RPC_VERSION","jsonBig","AeSdkWallet","constructor","name","id","type","onConnection","onSubscription","onDisconnect","onAskAccounts","options","Map","_type","_pushAccountsToApps","_clients","Array","from","keys","filter","clientId","_isRpcClientSubscribed","map","_getClient","rpc","forEach","client","notify","updateAddress","getAccounts","selectAccount","address","addAccount","account","_getNode","ensureNodeConnected","node","url","api","$host","selectedNodeName","selectNode","networkId","getNetworkId","_isRpcClientConnected","updateNetwork","connectNode","get","addressSubscription","size","CONNECTED","status","connection","isConnected","_disconnectRpcClient","disconnect","DISCONNECTED","Set","removeRpcClient","delete","addRpcClient","clientConnection","disconnectParams","WAITING_FOR_CONNECTION_REQUEST","closeConnection","params","connect","origin","version","icons","getWalletInfo","subscribeAddress","value","subscribe","add","unsubscribe","subscription","addresses","sign","tx","onAccount","returnSigned","includes","parameters","aeppOrigin","aeppRpcClientId","signedTransaction","signTransaction","parse","stringify","transactionHash","send","verify","error","validation","length","message","signMessage","signature","toString","set","shareWalletInfo","readyToConnect","window","location","current","selectedAddress","connected","a","reduce","acc"],"sources":["../src/AeSdkWallet.ts"],"sourcesContent":["import { v4 as uuid } from '@aeternity/uuid';\nimport AeSdk from './AeSdk';\nimport verifyTransaction from './tx/validator';\nimport RpcClient from './aepp-wallet-communication/rpc/RpcClient';\nimport {\n METHODS, RPC_STATUS, SUBSCRIPTION_TYPES, WALLET_TYPE,\n RpcBroadcastError, RpcInvalidTransactionError,\n RpcNotAuthorizeError, RpcPermissionDenyError, RpcUnsupportedProtocolError,\n} from './aepp-wallet-communication/schema';\nimport { InternalError, UnknownRpcClientError } from './utils/errors';\nimport AccountBase from './account/Base';\nimport BrowserConnection from './aepp-wallet-communication/connection/Browser';\nimport {\n Accounts,\n AeppApi,\n Network,\n RPC_VERSION,\n WalletApi,\n WalletInfo,\n} from './aepp-wallet-communication/rpc/types';\nimport { Encoded } from './utils/encoder';\nimport jsonBig from './utils/json-big';\n\ntype RpcClientWallet = RpcClient<AeppApi, WalletApi>;\n\ntype OnConnection = (\n clientId: string, params: Omit<Parameters<WalletApi[METHODS.connect]>[0], 'version'>, origin: string\n) => void;\n\ntype OnSubscription = (\n clientId: string, params: Parameters<WalletApi[METHODS.subscribeAddress]>[0], origin: string\n) => void;\n\ntype OnDisconnect = (\n clientId: string, params: Parameters<WalletApi[METHODS.closeConnection]>[0]\n) => void;\n\ntype OnAskAccounts = (\n clientId: string, params: undefined, origin: string\n) => void;\n\ninterface RpcClientsInfo {\n id: string;\n status: RPC_STATUS;\n connectNode: boolean;\n addressSubscription: Set<'connected' | 'current'>;\n rpc: RpcClientWallet;\n}\n\n/**\n * Contain functionality for aepp interaction and managing multiple aepps\n * @category aepp wallet communication\n */\nexport default class AeSdkWallet extends AeSdk {\n id: string;\n\n _type: WALLET_TYPE;\n\n name: string;\n\n _clients = new Map<string, RpcClientsInfo>();\n\n onConnection: OnConnection;\n\n onSubscription: OnSubscription;\n\n onDisconnect: OnDisconnect;\n\n onAskAccounts: OnAskAccounts;\n\n /**\n * @param options - Options\n * @param options.name - Wallet name\n * @param options.id - Wallet id\n * @param options.type - Wallet type\n * @param options.onConnection - Call-back function for incoming AEPP connection\n * @param options.onSubscription - Call-back function for incoming AEPP account subscription\n * @param options.onAskAccounts - Call-back function for incoming AEPP get address request\n * @param options.onDisconnect - Call-back function for disconnect event\n */\n constructor({\n name,\n id,\n type,\n onConnection,\n onSubscription,\n onDisconnect,\n onAskAccounts,\n ...options\n }: {\n id: string;\n type: WALLET_TYPE;\n name: string;\n onConnection: OnConnection;\n onSubscription: OnSubscription;\n onDisconnect: OnDisconnect;\n onAskAccounts: OnAskAccounts;\n } & ConstructorParameters<typeof AeSdk>[0]) {\n super(options);\n this.onConnection = onConnection;\n this.onSubscription = onSubscription;\n this.onDisconnect = onDisconnect;\n this.onAskAccounts = onAskAccounts;\n this.name = name;\n this.id = id;\n this._type = type;\n }\n\n _pushAccountsToApps(): void {\n if (this._clients == null) return;\n Array.from(this._clients.keys())\n .filter((clientId) => this._isRpcClientSubscribed(clientId))\n .map((clientId) => this._getClient(clientId).rpc)\n .forEach((client) => client.notify(METHODS.updateAddress, this.getAccounts()));\n }\n\n override selectAccount(address: Encoded.AccountAddress): void {\n super.selectAccount(address);\n this._pushAccountsToApps();\n }\n\n override addAccount(account: AccountBase, options?: Parameters<AeSdk['addAccount']>[1]): void {\n super.addAccount(account, options);\n this._pushAccountsToApps();\n }\n\n _getNode(): { node: Network['node'] } {\n this.ensureNodeConnected();\n return { node: { url: this.api.$host, name: this.selectedNodeName } };\n }\n\n override async selectNode(name: string): Promise<void> {\n super.selectNode(name);\n const networkId = await this.api.getNetworkId();\n Array.from(this._clients.keys())\n .filter((clientId) => this._isRpcClientConnected(clientId))\n .map((clientId) => this._getClient(clientId))\n .forEach((client) => {\n client.rpc.notify(METHODS.updateNetwork, {\n networkId,\n ...client.connectNode && this._getNode(),\n });\n });\n }\n\n _getClient(clientId: string): RpcClientsInfo {\n const client = this._clients.get(clientId);\n if (client == null) throw new UnknownRpcClientError(clientId);\n return client;\n }\n\n _isRpcClientSubscribed(clientId: string): boolean {\n return this._isRpcClientConnected(clientId)\n && this._getClient(clientId).addressSubscription.size !== 0;\n }\n\n _isRpcClientConnected(clientId: string): boolean {\n return RPC_STATUS.CONNECTED === this._getClient(clientId).status\n && this._getClient(clientId).rpc.connection.isConnected();\n }\n\n _disconnectRpcClient(clientId: string): void {\n const client = this._getClient(clientId);\n client.rpc.connection.disconnect();\n client.status = RPC_STATUS.DISCONNECTED;\n client.addressSubscription = new Set();\n }\n\n /**\n * Remove specific RpcClient by ID\n * @param id - Client ID\n */\n removeRpcClient(id: string): void {\n this._disconnectRpcClient(id);\n this._clients.delete(id);\n }\n\n /**\n * Add new client by AEPP connection\n * @param clientConnection - AEPP connection object\n * @returns Client ID\n */\n addRpcClient(clientConnection: BrowserConnection): string {\n // @TODO detect if aepp has some history based on origin????\n // if yes use this instance for connection\n const id = uuid();\n let disconnectParams: any;\n const client: RpcClientsInfo = {\n id,\n status: RPC_STATUS.WAITING_FOR_CONNECTION_REQUEST,\n addressSubscription: new Set(),\n connectNode: false,\n rpc: new RpcClient<AeppApi, WalletApi>(\n clientConnection,\n () => {\n this._clients.delete(id);\n this.onDisconnect(id, disconnectParams); // also related info\n },\n {\n [METHODS.closeConnection]: (params) => {\n disconnectParams = params;\n this._disconnectRpcClient(id);\n },\n // Store client info and prepare two fn for each client `connect` and `denyConnection`\n // which automatically prepare and send response for that client\n [METHODS.connect]: async ({\n name, version, icons, connectNode,\n }, origin) => {\n if (version !== RPC_VERSION) throw new RpcUnsupportedProtocolError();\n\n await this.onConnection(id, { name, icons, connectNode }, origin);\n client.status = RPC_STATUS.CONNECTED;\n client.connectNode = connectNode;\n return {\n ...await this.getWalletInfo(),\n ...connectNode && this._getNode(),\n };\n },\n [METHODS.subscribeAddress]: async ({ type, value }, origin) => {\n if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();\n\n await this.onSubscription(id, { type, value }, origin);\n\n switch (type) {\n case SUBSCRIPTION_TYPES.subscribe:\n client.addressSubscription.add(value);\n break;\n case SUBSCRIPTION_TYPES.unsubscribe:\n client.addressSubscription.delete(value);\n break;\n default:\n throw new InternalError(`Unknown subscription type: ${type}`);\n }\n\n return {\n subscription: Array.from(client.addressSubscription),\n address: this.getAccounts(),\n };\n },\n [METHODS.address]: async (params, origin) => {\n if (!this._isRpcClientSubscribed(id)) throw new RpcNotAuthorizeError();\n await this.onAskAccounts(id, params, origin);\n return this.addresses();\n },\n [METHODS.sign]: async ({ tx, onAccount = this.address, returnSigned }, origin) => {\n if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();\n if (!this.addresses().includes(onAccount)) {\n throw new RpcPermissionDenyError(onAccount);\n }\n\n const parameters = { onAccount, aeppOrigin: origin, aeppRpcClientId: id };\n if (returnSigned) {\n return { signedTransaction: await this.signTransaction(tx, parameters) };\n }\n try {\n return jsonBig.parse(jsonBig.stringify({\n transactionHash: await this.send(tx, { ...parameters, verify: false }),\n }));\n } catch (error) {\n const validation = await verifyTransaction(tx, this.api);\n if (validation.length > 0) throw new RpcInvalidTransactionError(validation);\n throw new RpcBroadcastError(error.message);\n }\n },\n [METHODS.signMessage]: async ({ message, onAccount = this.address }, origin) => {\n if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();\n if (!this.addresses().includes(onAccount)) {\n throw new RpcPermissionDenyError(onAccount);\n }\n\n const parameters = { onAccount, aeppOrigin: origin, aeppRpcClientId: id };\n return {\n signature: Buffer.from(await this.signMessage(message, parameters)).toString('hex'),\n };\n },\n },\n ),\n };\n this._clients.set(id, client);\n return id;\n }\n\n /**\n * Send shareWalletInfo message to notify AEPP about wallet\n * @param clientId - ID of RPC client send message to\n */\n async shareWalletInfo(clientId: string): Promise<void> {\n this._getClient(clientId).rpc.notify(METHODS.readyToConnect, await this.getWalletInfo());\n }\n\n /**\n * Get Wallet info object\n * @returns Object with wallet information\n */\n async getWalletInfo(): Promise<WalletInfo> {\n return {\n id: this.id,\n name: this.name,\n networkId: await this.api.getNetworkId(),\n origin: window.location.origin,\n type: this._type,\n };\n }\n\n /**\n * Get Wallet accounts\n * @returns Object with accounts information (\\{ connected: Object, current: Object \\})\n */\n getAccounts(): Accounts {\n return {\n current: this.selectedAddress != null ? { [this.selectedAddress]: {} } : {},\n connected: this.addresses()\n .filter((a) => a !== this.selectedAddress)\n .reduce((acc, a) => ({ ...acc, [a]: {} }), {}),\n };\n }\n}\n"],"mappings":";;;;;AAAA,SAASA,EAAE,IAAIC,IAAI,QAAQ,iBAAiB;AAAC,OACtCC,KAAK;AAAA,OACLC,iBAAiB;AAAA,OACjBC,SAAS;AAAA,SAEdC,OAAO,EAAEC,UAAU,EAAEC,kBAAkB,EACvCC,iBAAiB,EAAEC,0BAA0B,EAC7CC,oBAAoB,EAAEC,sBAAsB,EAAEC,2BAA2B;AAAA,SAElEC,aAAa,EAAEC,qBAAqB;AAAA,SAO3CC,WAAW;AAAA,OAKNC,OAAO;AA4Bd;AACA;AACA;AACA;AACA,eAAe,MAAMC,WAAW,SAASf,KAAK,CAAC;EAiB7C;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEgB,WAAW,OAiBiC;IAAA,IAjBhC;MACVC,IAAI;MACJC,EAAE;MACFC,IAAI;MACJC,YAAY;MACZC,cAAc;MACdC,YAAY;MACZC,aAAa;MACb,GAAGC;IASoC,CAAC;IACxC,KAAK,CAACA,OAAO,CAAC;IAAC,kCAtCN,IAAIC,GAAG,EAA0B;IAuC1C,IAAI,CAACL,YAAY,GAAGA,YAAY;IAChC,IAAI,CAACC,cAAc,GAAGA,cAAc;IACpC,IAAI,CAACC,YAAY,GAAGA,YAAY;IAChC,IAAI,CAACC,aAAa,GAAGA,aAAa;IAClC,IAAI,CAACN,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,EAAE,GAAGA,EAAE;IACZ,IAAI,CAACQ,KAAK,GAAGP,IAAI;EACnB;EAEAQ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EAAE,IAAI,CAAC9B,SAAS,EAAE,CACxB1D,MAAM,CAAEyF,CAAC,IAAKA,CAAC,KAAK,IAAI,CAACF,eAAe,CAAC,CACzCG,MAAM,CAAC,CAACC,GAAG,EAAEF,CAAC,MAAM;QAAE,GAAGE,GAAG;QAAE,CAACF,CAAC,GAAG,CAAC;MAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACjD,CAAC;EACH;AACF"}
|
|
1
|
+
{"version":3,"file":"AeSdkWallet.mjs","names":["v4","uuid","AeSdk","verifyTransaction","RpcClient","METHODS","RPC_STATUS","SUBSCRIPTION_TYPES","RpcBroadcastError","RpcInvalidTransactionError","RpcNotAuthorizeError","RpcPermissionDenyError","RpcUnsupportedProtocolError","InternalError","UnknownRpcClientError","RPC_VERSION","jsonBig","AeSdkWallet","constructor","_ref","name","id","type","onConnection","onSubscription","onDisconnect","onAskAccounts","options","_defineProperty","Map","_type","_pushAccountsToApps","_clients","Array","from","keys","filter","clientId","_isRpcClientSubscribed","map","_getClient","rpc","forEach","client","notify","updateAddress","getAccounts","selectAccount","address","addAccount","account","_getNode","ensureNodeConnected","node","url","api","$host","selectedNodeName","selectNode","networkId","getNetworkId","_isRpcClientConnected","updateNetwork","connectNode","get","addressSubscription","size","CONNECTED","status","connection","isConnected","_disconnectRpcClient","disconnect","DISCONNECTED","Set","removeRpcClient","delete","addRpcClient","clientConnection","disconnectParams","WAITING_FOR_CONNECTION_REQUEST","closeConnection","params","connect","_ref2","origin","version","icons","getWalletInfo","subscribeAddress","_ref3","value","subscribe","add","unsubscribe","subscription","addresses","sign","_ref4","tx","onAccount","returnSigned","includes","parameters","aeppOrigin","aeppRpcClientId","signedTransaction","signTransaction","parse","stringify","transactionHash","sendTransaction","verify","error","validation","length","message","signMessage","_ref5","signature","_Buffer","toString","set","shareWalletInfo","readyToConnect","window","location","current","selectedAddress","connected","a","reduce","acc"],"sources":["../src/AeSdkWallet.ts"],"sourcesContent":["import { v4 as uuid } from '@aeternity/uuid';\nimport AeSdk from './AeSdk';\nimport verifyTransaction from './tx/validator';\nimport RpcClient from './aepp-wallet-communication/rpc/RpcClient';\nimport {\n METHODS, RPC_STATUS, SUBSCRIPTION_TYPES, WALLET_TYPE,\n RpcBroadcastError, RpcInvalidTransactionError,\n RpcNotAuthorizeError, RpcPermissionDenyError, RpcUnsupportedProtocolError,\n} from './aepp-wallet-communication/schema';\nimport { InternalError, UnknownRpcClientError } from './utils/errors';\nimport AccountBase from './account/Base';\nimport BrowserConnection from './aepp-wallet-communication/connection/Browser';\nimport {\n Accounts,\n AeppApi,\n Network,\n RPC_VERSION,\n WalletApi,\n WalletInfo,\n} from './aepp-wallet-communication/rpc/types';\nimport { Encoded } from './utils/encoder';\nimport jsonBig from './utils/json-big';\n\ntype RpcClientWallet = RpcClient<AeppApi, WalletApi>;\n\ntype OnConnection = (\n clientId: string, params: Omit<Parameters<WalletApi[METHODS.connect]>[0], 'version'>, origin: string\n) => void;\n\ntype OnSubscription = (\n clientId: string, params: Parameters<WalletApi[METHODS.subscribeAddress]>[0], origin: string\n) => void;\n\ntype OnDisconnect = (\n clientId: string, params: Parameters<WalletApi[METHODS.closeConnection]>[0]\n) => void;\n\ntype OnAskAccounts = (\n clientId: string, params: undefined, origin: string\n) => void;\n\ninterface RpcClientsInfo {\n id: string;\n status: RPC_STATUS;\n connectNode: boolean;\n addressSubscription: Set<'connected' | 'current'>;\n rpc: RpcClientWallet;\n}\n\n/**\n * Contain functionality for aepp interaction and managing multiple aepps\n * @category aepp wallet communication\n */\nexport default class AeSdkWallet extends AeSdk {\n id: string;\n\n _type: WALLET_TYPE;\n\n name: string;\n\n _clients = new Map<string, RpcClientsInfo>();\n\n onConnection: OnConnection;\n\n onSubscription: OnSubscription;\n\n onDisconnect: OnDisconnect;\n\n onAskAccounts: OnAskAccounts;\n\n /**\n * @param options - Options\n * @param options.name - Wallet name\n * @param options.id - Wallet id\n * @param options.type - Wallet type\n * @param options.onConnection - Call-back function for incoming AEPP connection\n * @param options.onSubscription - Call-back function for incoming AEPP account subscription\n * @param options.onAskAccounts - Call-back function for incoming AEPP get address request\n * @param options.onDisconnect - Call-back function for disconnect event\n */\n constructor({\n name,\n id,\n type,\n onConnection,\n onSubscription,\n onDisconnect,\n onAskAccounts,\n ...options\n }: {\n id: string;\n type: WALLET_TYPE;\n name: string;\n onConnection: OnConnection;\n onSubscription: OnSubscription;\n onDisconnect: OnDisconnect;\n onAskAccounts: OnAskAccounts;\n } & ConstructorParameters<typeof AeSdk>[0]) {\n super(options);\n this.onConnection = onConnection;\n this.onSubscription = onSubscription;\n this.onDisconnect = onDisconnect;\n this.onAskAccounts = onAskAccounts;\n this.name = name;\n this.id = id;\n this._type = type;\n }\n\n _pushAccountsToApps(): void {\n if (this._clients == null) return;\n Array.from(this._clients.keys())\n .filter((clientId) => this._isRpcClientSubscribed(clientId))\n .map((clientId) => this._getClient(clientId).rpc)\n .forEach((client) => client.notify(METHODS.updateAddress, this.getAccounts()));\n }\n\n override selectAccount(address: Encoded.AccountAddress): void {\n super.selectAccount(address);\n this._pushAccountsToApps();\n }\n\n override addAccount(account: AccountBase, options?: Parameters<AeSdk['addAccount']>[1]): void {\n super.addAccount(account, options);\n this._pushAccountsToApps();\n }\n\n _getNode(): { node: Network['node'] } {\n this.ensureNodeConnected();\n return { node: { url: this.api.$host, name: this.selectedNodeName } };\n }\n\n override async selectNode(name: string): Promise<void> {\n super.selectNode(name);\n const networkId = await this.api.getNetworkId();\n Array.from(this._clients.keys())\n .filter((clientId) => this._isRpcClientConnected(clientId))\n .map((clientId) => this._getClient(clientId))\n .forEach((client) => {\n client.rpc.notify(METHODS.updateNetwork, {\n networkId,\n ...client.connectNode && this._getNode(),\n });\n });\n }\n\n _getClient(clientId: string): RpcClientsInfo {\n const client = this._clients.get(clientId);\n if (client == null) throw new UnknownRpcClientError(clientId);\n return client;\n }\n\n _isRpcClientSubscribed(clientId: string): boolean {\n return this._isRpcClientConnected(clientId)\n && this._getClient(clientId).addressSubscription.size !== 0;\n }\n\n _isRpcClientConnected(clientId: string): boolean {\n return RPC_STATUS.CONNECTED === this._getClient(clientId).status\n && this._getClient(clientId).rpc.connection.isConnected();\n }\n\n _disconnectRpcClient(clientId: string): void {\n const client = this._getClient(clientId);\n client.rpc.connection.disconnect();\n client.status = RPC_STATUS.DISCONNECTED;\n client.addressSubscription = new Set();\n }\n\n /**\n * Remove specific RpcClient by ID\n * @param id - Client ID\n */\n removeRpcClient(id: string): void {\n this._disconnectRpcClient(id);\n this._clients.delete(id);\n }\n\n /**\n * Add new client by AEPP connection\n * @param clientConnection - AEPP connection object\n * @returns Client ID\n */\n addRpcClient(clientConnection: BrowserConnection): string {\n // @TODO detect if aepp has some history based on origin????\n // if yes use this instance for connection\n const id = uuid();\n let disconnectParams: any;\n const client: RpcClientsInfo = {\n id,\n status: RPC_STATUS.WAITING_FOR_CONNECTION_REQUEST,\n addressSubscription: new Set(),\n connectNode: false,\n rpc: new RpcClient<AeppApi, WalletApi>(\n clientConnection,\n () => {\n this._clients.delete(id);\n this.onDisconnect(id, disconnectParams); // also related info\n },\n {\n [METHODS.closeConnection]: (params) => {\n disconnectParams = params;\n this._disconnectRpcClient(id);\n },\n // Store client info and prepare two fn for each client `connect` and `denyConnection`\n // which automatically prepare and send response for that client\n [METHODS.connect]: async ({\n name, version, icons, connectNode,\n }, origin) => {\n if (version !== RPC_VERSION) throw new RpcUnsupportedProtocolError();\n\n await this.onConnection(id, { name, icons, connectNode }, origin);\n client.status = RPC_STATUS.CONNECTED;\n client.connectNode = connectNode;\n return {\n ...await this.getWalletInfo(),\n ...connectNode && this._getNode(),\n };\n },\n [METHODS.subscribeAddress]: async ({ type, value }, origin) => {\n if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();\n\n await this.onSubscription(id, { type, value }, origin);\n\n switch (type) {\n case SUBSCRIPTION_TYPES.subscribe:\n client.addressSubscription.add(value);\n break;\n case SUBSCRIPTION_TYPES.unsubscribe:\n client.addressSubscription.delete(value);\n break;\n default:\n throw new InternalError(`Unknown subscription type: ${type}`);\n }\n\n return {\n subscription: Array.from(client.addressSubscription),\n address: this.getAccounts(),\n };\n },\n [METHODS.address]: async (params, origin) => {\n if (!this._isRpcClientSubscribed(id)) throw new RpcNotAuthorizeError();\n await this.onAskAccounts(id, params, origin);\n return this.addresses();\n },\n [METHODS.sign]: async ({ tx, onAccount = this.address, returnSigned }, origin) => {\n if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();\n if (!this.addresses().includes(onAccount)) {\n throw new RpcPermissionDenyError(onAccount);\n }\n\n const parameters = { onAccount, aeppOrigin: origin, aeppRpcClientId: id };\n if (returnSigned) {\n return { signedTransaction: await this.signTransaction(tx, parameters) };\n }\n try {\n return jsonBig.parse(jsonBig.stringify({\n transactionHash: await this.sendTransaction(tx, { ...parameters, verify: false }),\n }));\n } catch (error) {\n const validation = await verifyTransaction(tx, this.api);\n if (validation.length > 0) throw new RpcInvalidTransactionError(validation);\n throw new RpcBroadcastError(error.message);\n }\n },\n [METHODS.signMessage]: async ({ message, onAccount = this.address }, origin) => {\n if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();\n if (!this.addresses().includes(onAccount)) {\n throw new RpcPermissionDenyError(onAccount);\n }\n\n const parameters = { onAccount, aeppOrigin: origin, aeppRpcClientId: id };\n return {\n signature: Buffer.from(await this.signMessage(message, parameters)).toString('hex'),\n };\n },\n },\n ),\n };\n this._clients.set(id, client);\n return id;\n }\n\n /**\n * Send shareWalletInfo message to notify AEPP about wallet\n * @param clientId - ID of RPC client send message to\n */\n async shareWalletInfo(clientId: string): Promise<void> {\n this._getClient(clientId).rpc.notify(METHODS.readyToConnect, await this.getWalletInfo());\n }\n\n /**\n * Get Wallet info object\n * @returns Object with wallet information\n */\n async getWalletInfo(): Promise<WalletInfo> {\n return {\n id: this.id,\n name: this.name,\n networkId: await this.api.getNetworkId(),\n origin: window.location.origin,\n type: this._type,\n };\n }\n\n /**\n * Get Wallet accounts\n * @returns Object with accounts information (\\{ connected: Object, current: Object \\})\n */\n getAccounts(): Accounts {\n return {\n current: this.selectedAddress != null ? { [this.selectedAddress]: {} } : {},\n connected: this.addresses()\n .filter((a) => a !== this.selectedAddress)\n .reduce((acc, a) => ({ ...acc, [a]: {} }), {}),\n };\n }\n}\n"],"mappings":";;;;;AAAA,SAASA,EAAE,IAAIC,IAAI,QAAQ,iBAAiB;AAAC,OACtCC,KAAK;AAAA,OACLC,iBAAiB;AAAA,OACjBC,SAAS;AAAA,SAEdC,OAAO,EAAEC,UAAU,EAAEC,kBAAkB,EACvCC,iBAAiB,EAAEC,0BAA0B,EAC7CC,oBAAoB,EAAEC,sBAAsB,EAAEC,2BAA2B;AAAA,SAElEC,aAAa,EAAEC,qBAAqB;AAAA,SAO3CC,WAAW;AAAA,OAKNC,OAAO;AA4Bd;AACA;AACA;AACA;AACA,eAAe,MAAMC,WAAW,SAASf,KAAK,CAAC;EAiB7C;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEgB,WAAWA,CAAAC,IAAA,EAiBiC;IAAA,IAjBhC;MACVC,IAAI;MACJC,EAAE;MACFC,IAAI;MACJC,YAAY;MACZC,cAAc;MACdC,YAAY;MACZC,aAAa;MACb,GAAGC;IASoC,CAAC,GAAAR,IAAA;IACxC,KAAK,CAACQ,OAAO,CAAC;IAACC,eAAA,mBAtCN,IAAIC,GAAG,EAA0B;IAuC1C,IAAI,CAACN,YAAY,GAAGA,YAAY;IAChC,IAAI,CAACC,cAAc,GAAGA,cAAc;IACpC,IAAI,CAACC,YAAY,GAAGA,YAAY;IAChC,IAAI,CAACC,aAAa,GAAGA,aAAa;IAClC,IAAI,CAACN,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,EAAE,GAAGA,EAAE;IACZ,IAAI,CAACS,KAAK,GAAGR,IAAI;EACnB;EAEAS,mBAAmBA,CAAA,EAAS;IAC1B,IAAI,IAAI,CAACC,QAAQ,IAAI,IAAI,EAAE;IAC3BC,KAAK,CAACC,IAAI,C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AAe,GAAG,CAAC;MAAE,CAAC,GAAG,CAAC,CAAC;MAC3EC,SAAS,EAAE,IAAI,CAACjC,SAAS,EAAE,CACxB5D,MAAM,CAAE8F,CAAC,IAAKA,CAAC,KAAK,IAAI,CAACF,eAAe,CAAC,CACzCG,MAAM,CAAC,CAACC,GAAG,EAAEF,CAAC,MAAM;QAAE,GAAGE,GAAG;QAAE,CAACF,CAAC,GAAG,CAAC;MAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACjD,CAAC;EACH;AACF"}
|
package/es/Node.d.ts
CHANGED
|
@@ -27,9 +27,13 @@ export default class Node extends Node_base {
|
|
|
27
27
|
* @param url - Url for node API
|
|
28
28
|
* @param options - Options
|
|
29
29
|
* @param options.ignoreVersion - Don't check node version
|
|
30
|
+
* @param options.retryCount - Amount of extra requests to do in case of failure
|
|
31
|
+
* @param options.retryOverallDelay - Time in ms to wait between all retries
|
|
30
32
|
*/
|
|
31
|
-
constructor(url: string, { ignoreVersion, ...options }?: NodeOptionalParams & {
|
|
33
|
+
constructor(url: string, { ignoreVersion, retryCount, retryOverallDelay, ...options }?: NodeOptionalParams & {
|
|
32
34
|
ignoreVersion?: boolean;
|
|
35
|
+
retryCount?: number;
|
|
36
|
+
retryOverallDelay?: number;
|
|
33
37
|
});
|
|
34
38
|
getNetworkId(): Promise<string>;
|
|
35
39
|
getNodeInfo(): Promise<NodeInfo>;
|
package/es/Node.mjs
CHANGED
|
@@ -6,7 +6,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
|
|
|
6
6
|
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
7
7
|
// eslint-disable-next-line max-classes-per-file
|
|
8
8
|
import BigNumber from 'bignumber.js';
|
|
9
|
-
import { genRequestQueuesPolicy, genCombineGetRequestsPolicy, genErrorFormatterPolicy, genVersionCheckPolicy } from "./utils/autorest.mjs";
|
|
9
|
+
import { genRequestQueuesPolicy, genCombineGetRequestsPolicy, genErrorFormatterPolicy, genVersionCheckPolicy, genRetryOnFailurePolicy } from "./utils/autorest.mjs";
|
|
10
10
|
import { Node as NodeApi } from "./apis/node/index.mjs";
|
|
11
11
|
import { mapObject } from "./utils/other.mjs";
|
|
12
12
|
const bigIntPropertyNames = ['balance', 'queryFee', 'fee', 'amount', 'nameFee', 'channelAmount', 'initiatorAmount', 'responderAmount', 'channelReserve', 'initiatorAmountFinal', 'responderAmountFinal', 'gasPrice', 'deposit'];
|
|
@@ -63,16 +63,20 @@ export default class Node extends NodeTransformed {
|
|
|
63
63
|
* @param url - Url for node API
|
|
64
64
|
* @param options - Options
|
|
65
65
|
* @param options.ignoreVersion - Don't check node version
|
|
66
|
+
* @param options.retryCount - Amount of extra requests to do in case of failure
|
|
67
|
+
* @param options.retryOverallDelay - Time in ms to wait between all retries
|
|
66
68
|
*/
|
|
67
69
|
constructor(url) {
|
|
68
70
|
let {
|
|
69
71
|
ignoreVersion = false,
|
|
72
|
+
retryCount = 3,
|
|
73
|
+
retryOverallDelay = 800,
|
|
70
74
|
...options
|
|
71
75
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
72
76
|
// eslint-disable-next-line constructor-super
|
|
73
77
|
super(url, {
|
|
74
78
|
allowInsecureConnection: true,
|
|
75
|
-
additionalPolicies: [genRequestQueuesPolicy(), genCombineGetRequestsPolicy(), genErrorFormatterPolicy(body => ` ${body.reason}`)],
|
|
79
|
+
additionalPolicies: [genRequestQueuesPolicy(), genCombineGetRequestsPolicy(), genRetryOnFailurePolicy(retryCount, retryOverallDelay), genErrorFormatterPolicy(body => ` ${body.reason}`)],
|
|
76
80
|
...options
|
|
77
81
|
});
|
|
78
82
|
_classPrivateFieldInitSpec(this, _networkIdPromise, {
|
|
@@ -86,13 +90,13 @@ export default class Node extends NodeTransformed {
|
|
|
86
90
|
nodeVersion
|
|
87
91
|
} = _ref2;
|
|
88
92
|
return nodeVersion;
|
|
89
|
-
});
|
|
93
|
+
}, error => error);
|
|
90
94
|
_classPrivateFieldSet(this, _networkIdPromise, statusPromise.then(_ref3 => {
|
|
91
95
|
let {
|
|
92
96
|
networkId
|
|
93
97
|
} = _ref3;
|
|
94
98
|
return networkId;
|
|
95
|
-
}));
|
|
99
|
+
}, error => error));
|
|
96
100
|
this.pipeline.addPolicy(genVersionCheckPolicy('node', '/v3/status', versionPromise, '6.2.0', '7.0.0'));
|
|
97
101
|
}
|
|
98
102
|
this.intAsString = true;
|
|
@@ -105,7 +109,9 @@ export default class Node extends NodeTransformed {
|
|
|
105
109
|
} = _ref4;
|
|
106
110
|
return networkId;
|
|
107
111
|
}));
|
|
108
|
-
|
|
112
|
+
const networkId = await _classPrivateFieldGet(this, _networkIdPromise);
|
|
113
|
+
if (networkId instanceof Error) throw networkId;
|
|
114
|
+
return networkId;
|
|
109
115
|
}
|
|
110
116
|
async getNodeInfo() {
|
|
111
117
|
const {
|