viem 2.57.4 → 2.57.6
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/CHANGELOG.md +34 -0
- package/_cjs/actions/public/waitForTransactionReceipt.js +5 -2
- package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_cjs/actions/wallet/waitForCallsStatus.js +25 -2
- package/_cjs/actions/wallet/waitForCallsStatus.js.map +1 -1
- package/_cjs/chains/definitions/arcTestnet.js +11 -8
- package/_cjs/chains/definitions/arcTestnet.js.map +1 -1
- package/_cjs/chains/definitions/qmsTestnet.js +30 -0
- package/_cjs/chains/definitions/qmsTestnet.js.map +1 -0
- package/_cjs/chains/definitions/tempo.js +1 -1
- package/_cjs/chains/definitions/tempoModerato.js +2 -2
- package/_cjs/chains/index.js +7 -5
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/clients/transports/ipc.js +19 -10
- package/_cjs/clients/transports/ipc.js.map +1 -1
- package/_cjs/clients/transports/webSocket.js +19 -10
- package/_cjs/clients/transports/webSocket.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/tempo/Abis.js +297 -1
- package/_cjs/tempo/Abis.js.map +1 -1
- package/_cjs/tempo/Account.js +40 -40
- package/_cjs/tempo/Account.js.map +1 -1
- package/_cjs/tempo/Addresses.js +2 -1
- package/_cjs/tempo/Addresses.js.map +1 -1
- package/_cjs/tempo/Decorator.js +9 -8
- package/_cjs/tempo/Decorator.js.map +1 -1
- package/_cjs/tempo/ExecutionError.js +95 -4
- package/_cjs/tempo/ExecutionError.js.map +1 -1
- package/_cjs/tempo/Formatters.js +8 -7
- package/_cjs/tempo/Formatters.js.map +1 -1
- package/_cjs/tempo/KeyAuthorizationManager.js +25 -16
- package/_cjs/tempo/KeyAuthorizationManager.js.map +1 -1
- package/_cjs/tempo/Relay.js +9 -4
- package/_cjs/tempo/Relay.js.map +1 -1
- package/_cjs/tempo/Transaction.js +9 -9
- package/_cjs/tempo/Transaction.js.map +1 -1
- package/_cjs/tempo/Transport.js +21 -11
- package/_cjs/tempo/Transport.js.map +1 -1
- package/_cjs/tempo/{multisig → accounts}/Config.js +8 -8
- package/_cjs/tempo/{multisig → accounts}/Config.js.map +1 -1
- package/_cjs/tempo/{multisig → accounts}/Operation.js +10 -10
- package/_cjs/tempo/{multisig → accounts}/Operation.js.map +1 -1
- package/_cjs/tempo/{multisig → accounts}/Signature.js +2 -2
- package/_cjs/tempo/accounts/Signature.js.map +1 -0
- package/_cjs/tempo/actions/accessKey.js +442 -47
- package/_cjs/tempo/actions/accessKey.js.map +1 -1
- package/_cjs/tempo/actions/{multisig.js → accounts.js} +16 -20
- package/_cjs/tempo/actions/accounts.js.map +1 -0
- package/_cjs/tempo/actions/amm.js +90 -4
- package/_cjs/tempo/actions/amm.js.map +1 -1
- package/_cjs/tempo/actions/channel.js +183 -7
- package/_cjs/tempo/actions/channel.js.map +1 -1
- package/_cjs/tempo/actions/dex.js +507 -14
- package/_cjs/tempo/actions/dex.js.map +1 -1
- package/_cjs/tempo/actions/earn/deployment.js +4 -3
- package/_cjs/tempo/actions/earn/deployment.js.map +1 -1
- package/_cjs/tempo/actions/earn.js +22 -21
- package/_cjs/tempo/actions/earn.js.map +1 -1
- package/_cjs/tempo/actions/fee.js +85 -5
- package/_cjs/tempo/actions/fee.js.map +1 -1
- package/_cjs/tempo/actions/index.js +2 -2
- package/_cjs/tempo/actions/index.js.map +1 -1
- package/_cjs/tempo/actions/nonce.js +54 -1
- package/_cjs/tempo/actions/nonce.js.map +1 -1
- package/_cjs/tempo/actions/policy.js +35 -6
- package/_cjs/tempo/actions/policy.js.map +1 -1
- package/_cjs/tempo/actions/propAmm.js +18 -8
- package/_cjs/tempo/actions/propAmm.js.map +1 -1
- package/_cjs/tempo/actions/receivePolicy.js +7 -6
- package/_cjs/tempo/actions/receivePolicy.js.map +1 -1
- package/_cjs/tempo/actions/reward.js +7 -6
- package/_cjs/tempo/actions/reward.js.map +1 -1
- package/_cjs/tempo/actions/token.js +433 -22
- package/_cjs/tempo/actions/token.js.map +1 -1
- package/_cjs/tempo/actions/validator.js +12 -11
- package/_cjs/tempo/actions/validator.js.map +1 -1
- package/_cjs/tempo/actions/virtualAddress.js +3 -2
- package/_cjs/tempo/actions/virtualAddress.js.map +1 -1
- package/_cjs/tempo/actions/zone.js +12 -11
- package/_cjs/tempo/actions/zone.js.map +1 -1
- package/_cjs/tempo/chainConfig.js +37 -37
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_cjs/tempo/errors.js +57 -1
- package/_cjs/tempo/errors.js.map +1 -1
- package/_cjs/tempo/index.js +3 -3
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/tempo/internal/errors.js +46 -0
- package/_cjs/tempo/internal/errors.js.map +1 -0
- package/_cjs/tempo/internal/relay/{multisig.js → accounts.js} +90 -93
- package/_cjs/tempo/internal/relay/accounts.js.map +1 -0
- package/_cjs/tempo/internal/relay/keyAuthorization.js +296 -0
- package/_cjs/tempo/internal/relay/keyAuthorization.js.map +1 -0
- package/_cjs/tempo/internal/relay/plugin.js +17 -7
- package/_cjs/tempo/internal/relay/plugin.js.map +1 -1
- package/_cjs/tempo/internal/resolveError.js +128 -0
- package/_cjs/tempo/internal/resolveError.js.map +1 -0
- package/_cjs/tempo/internal/utils.js +1 -0
- package/_cjs/tempo/internal/utils.js.map +1 -1
- package/_cjs/utils/hash/normalizeSignature.js +1 -1
- package/_cjs/utils/hash/normalizeSignature.js.map +1 -1
- package/_cjs/utils/rpc/http.js +66 -31
- package/_cjs/utils/rpc/http.js.map +1 -1
- package/_cjs/utils/rpc/socket.js +1 -1
- package/_cjs/utils/rpc/socket.js.map +1 -1
- package/_esm/actions/public/waitForTransactionReceipt.js +5 -2
- package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_esm/actions/wallet/waitForCallsStatus.js +39 -2
- package/_esm/actions/wallet/waitForCallsStatus.js.map +1 -1
- package/_esm/chains/definitions/arcTestnet.js +11 -8
- package/_esm/chains/definitions/arcTestnet.js.map +1 -1
- package/_esm/chains/definitions/qmsTestnet.js +27 -0
- package/_esm/chains/definitions/qmsTestnet.js.map +1 -0
- package/_esm/chains/definitions/tempo.js +1 -1
- package/_esm/chains/definitions/tempoModerato.js +2 -2
- package/_esm/chains/index.js +1 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/clients/transports/ipc.js +21 -10
- package/_esm/clients/transports/ipc.js.map +1 -1
- package/_esm/clients/transports/webSocket.js +21 -10
- package/_esm/clients/transports/webSocket.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/tempo/Abis.js +297 -0
- package/_esm/tempo/Abis.js.map +1 -1
- package/_esm/tempo/Account.js +42 -42
- package/_esm/tempo/Account.js.map +1 -1
- package/_esm/tempo/Addresses.js +1 -0
- package/_esm/tempo/Addresses.js.map +1 -1
- package/_esm/tempo/Client.js +3 -3
- package/_esm/tempo/Decorator.js +9 -8
- package/_esm/tempo/Decorator.js.map +1 -1
- package/_esm/tempo/ExecutionError.js +96 -3
- package/_esm/tempo/ExecutionError.js.map +1 -1
- package/_esm/tempo/Formatters.js +11 -10
- package/_esm/tempo/Formatters.js.map +1 -1
- package/_esm/tempo/KeyAuthorizationManager.js +58 -16
- package/_esm/tempo/KeyAuthorizationManager.js.map +1 -1
- package/_esm/tempo/Relay.js +49 -8
- package/_esm/tempo/Relay.js.map +1 -1
- package/_esm/tempo/Transaction.js +11 -11
- package/_esm/tempo/Transaction.js.map +1 -1
- package/_esm/tempo/Transport.js +22 -12
- package/_esm/tempo/Transport.js.map +1 -1
- package/_esm/tempo/{multisig → accounts}/Config.js +14 -14
- package/_esm/tempo/{multisig → accounts}/Config.js.map +1 -1
- package/_esm/tempo/{multisig → accounts}/Operation.js +17 -17
- package/_esm/tempo/{multisig → accounts}/Operation.js.map +1 -1
- package/_esm/tempo/accounts/Signature.js +9 -0
- package/_esm/tempo/accounts/Signature.js.map +1 -0
- package/_esm/tempo/actions/accessKey.js +499 -48
- package/_esm/tempo/actions/accessKey.js.map +1 -1
- package/_esm/tempo/actions/{multisig.js → accounts.js} +34 -38
- package/_esm/tempo/actions/accounts.js.map +1 -0
- package/_esm/tempo/actions/amm.js +95 -4
- package/_esm/tempo/actions/amm.js.map +1 -1
- package/_esm/tempo/actions/channel.js +191 -7
- package/_esm/tempo/actions/channel.js.map +1 -1
- package/_esm/tempo/actions/dex.js +537 -14
- package/_esm/tempo/actions/dex.js.map +1 -1
- package/_esm/tempo/actions/earn/deployment.js +4 -3
- package/_esm/tempo/actions/earn/deployment.js.map +1 -1
- package/_esm/tempo/actions/earn.js +22 -21
- package/_esm/tempo/actions/earn.js.map +1 -1
- package/_esm/tempo/actions/fee.js +90 -6
- package/_esm/tempo/actions/fee.js.map +1 -1
- package/_esm/tempo/actions/index.js +1 -1
- package/_esm/tempo/actions/index.js.map +1 -1
- package/_esm/tempo/actions/nonce.js +57 -1
- package/_esm/tempo/actions/nonce.js.map +1 -1
- package/_esm/tempo/actions/policy.js +36 -6
- package/_esm/tempo/actions/policy.js.map +1 -1
- package/_esm/tempo/actions/propAmm.js +18 -8
- package/_esm/tempo/actions/propAmm.js.map +1 -1
- package/_esm/tempo/actions/receivePolicy.js +7 -6
- package/_esm/tempo/actions/receivePolicy.js.map +1 -1
- package/_esm/tempo/actions/reward.js +7 -6
- package/_esm/tempo/actions/reward.js.map +1 -1
- package/_esm/tempo/actions/token.js +461 -22
- package/_esm/tempo/actions/token.js.map +1 -1
- package/_esm/tempo/actions/validator.js +12 -11
- package/_esm/tempo/actions/validator.js.map +1 -1
- package/_esm/tempo/actions/virtualAddress.js +3 -2
- package/_esm/tempo/actions/virtualAddress.js.map +1 -1
- package/_esm/tempo/actions/zone.js +12 -11
- package/_esm/tempo/actions/zone.js.map +1 -1
- package/_esm/tempo/chainConfig.js +38 -38
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_esm/tempo/errors.js +63 -0
- package/_esm/tempo/errors.js.map +1 -1
- package/_esm/tempo/index.js +2 -1
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/tempo/internal/errors.js +51 -0
- package/_esm/tempo/internal/errors.js.map +1 -0
- package/_esm/tempo/internal/relay/{multisig.js → accounts.js} +93 -98
- package/_esm/tempo/internal/relay/accounts.js.map +1 -0
- package/_esm/tempo/internal/relay/feePayer.js +1 -1
- package/_esm/tempo/internal/relay/feePayer.js.map +1 -1
- package/_esm/tempo/internal/relay/keyAuthorization.js +334 -0
- package/_esm/tempo/internal/relay/keyAuthorization.js.map +1 -0
- package/_esm/tempo/internal/relay/plugin.js +15 -6
- package/_esm/tempo/internal/relay/plugin.js.map +1 -1
- package/_esm/tempo/internal/resolveError.js +130 -0
- package/_esm/tempo/internal/resolveError.js.map +1 -0
- package/_esm/tempo/internal/utils.js +2 -0
- package/_esm/tempo/internal/utils.js.map +1 -1
- package/_esm/utils/hash/normalizeSignature.js +3 -2
- package/_esm/utils/hash/normalizeSignature.js.map +1 -1
- package/_esm/utils/rpc/http.js +74 -31
- package/_esm/utils/rpc/http.js.map +1 -1
- package/_esm/utils/rpc/socket.js +3 -1
- package/_esm/utils/rpc/socket.js.map +1 -1
- package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
- package/_types/actions/wallet/waitForCallsStatus.d.ts.map +1 -1
- package/_types/chains/definitions/arcTestnet.d.ts +5 -5
- package/_types/chains/definitions/arcTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/qmsTestnet.d.ts +50 -0
- package/_types/chains/definitions/qmsTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/tempo.d.ts +2 -2
- package/_types/chains/definitions/tempoModerato.d.ts +4 -4
- package/_types/chains/index.d.ts +1 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/clients/transports/ipc.d.ts.map +1 -1
- package/_types/clients/transports/webSocket.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/tempo/Abis.d.ts +807 -0
- package/_types/tempo/Abis.d.ts.map +1 -1
- package/_types/tempo/Account.d.ts +28 -28
- package/_types/tempo/Account.d.ts.map +1 -1
- package/_types/tempo/Addresses.d.ts +1 -0
- package/_types/tempo/Addresses.d.ts.map +1 -1
- package/_types/tempo/Client.d.ts +3 -3
- package/_types/tempo/Decorator.d.ts +64 -38
- package/_types/tempo/Decorator.d.ts.map +1 -1
- package/_types/tempo/ExecutionError.d.ts +3 -1
- package/_types/tempo/ExecutionError.d.ts.map +1 -1
- package/_types/tempo/Formatters.d.ts.map +1 -1
- package/_types/tempo/KeyAuthorizationManager.d.ts +45 -2
- package/_types/tempo/KeyAuthorizationManager.d.ts.map +1 -1
- package/_types/tempo/Relay.d.ts +62 -12
- package/_types/tempo/Relay.d.ts.map +1 -1
- package/_types/tempo/Transaction.d.ts +14 -11
- package/_types/tempo/Transaction.d.ts.map +1 -1
- package/_types/tempo/Transport.d.ts +20 -7
- package/_types/tempo/Transport.d.ts.map +1 -1
- package/_types/tempo/{multisig → accounts}/Config.d.ts +7 -7
- package/_types/tempo/accounts/Config.d.ts.map +1 -0
- package/_types/tempo/{multisig → accounts}/Operation.d.ts +7 -7
- package/_types/tempo/accounts/Operation.d.ts.map +1 -0
- package/_types/tempo/{multisig → accounts}/Signature.d.ts +1 -1
- package/_types/tempo/accounts/Signature.d.ts.map +1 -0
- package/_types/tempo/actions/accessKey.d.ts +214 -25
- package/_types/tempo/actions/accessKey.d.ts.map +1 -1
- package/_types/tempo/actions/{multisig.d.ts → accounts.d.ts} +31 -29
- package/_types/tempo/actions/accounts.d.ts.map +1 -0
- package/_types/tempo/actions/amm.d.ts +39 -0
- package/_types/tempo/actions/amm.d.ts.map +1 -1
- package/_types/tempo/actions/channel.d.ts +77 -7
- package/_types/tempo/actions/channel.d.ts.map +1 -1
- package/_types/tempo/actions/dex.d.ts +222 -16
- package/_types/tempo/actions/dex.d.ts.map +1 -1
- package/_types/tempo/actions/earn/deployment.d.ts +7 -6
- package/_types/tempo/actions/earn/deployment.d.ts.map +1 -1
- package/_types/tempo/actions/earn.d.ts +15 -14
- package/_types/tempo/actions/earn.d.ts.map +1 -1
- package/_types/tempo/actions/fee.d.ts +32 -6
- package/_types/tempo/actions/fee.d.ts.map +1 -1
- package/_types/tempo/actions/index.d.ts +1 -1
- package/_types/tempo/actions/index.d.ts.map +1 -1
- package/_types/tempo/actions/nonce.d.ts +35 -0
- package/_types/tempo/actions/nonce.d.ts.map +1 -1
- package/_types/tempo/actions/policy.d.ts +29 -8
- package/_types/tempo/actions/policy.d.ts.map +1 -1
- package/_types/tempo/actions/propAmm.d.ts +9 -1
- package/_types/tempo/actions/propAmm.d.ts.map +1 -1
- package/_types/tempo/actions/receivePolicy.d.ts +10 -6
- package/_types/tempo/actions/receivePolicy.d.ts.map +1 -1
- package/_types/tempo/actions/reward.d.ts +7 -3
- package/_types/tempo/actions/reward.d.ts.map +1 -1
- package/_types/tempo/actions/token.d.ts +200 -32
- package/_types/tempo/actions/token.d.ts.map +1 -1
- package/_types/tempo/actions/validator.d.ts +17 -5
- package/_types/tempo/actions/validator.d.ts.map +1 -1
- package/_types/tempo/actions/virtualAddress.d.ts +4 -3
- package/_types/tempo/actions/virtualAddress.d.ts.map +1 -1
- package/_types/tempo/actions/zone.d.ts +10 -9
- package/_types/tempo/actions/zone.d.ts.map +1 -1
- package/_types/tempo/errors.d.ts +63 -1
- package/_types/tempo/errors.d.ts.map +1 -1
- package/_types/tempo/index.d.ts +3 -2
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/tempo/internal/errors.d.ts +59 -0
- package/_types/tempo/internal/errors.d.ts.map +1 -0
- package/_types/tempo/internal/relay/accounts.d.ts +15 -0
- package/_types/tempo/internal/relay/accounts.d.ts.map +1 -0
- package/_types/tempo/internal/relay/keyAuthorization.d.ts +25 -0
- package/_types/tempo/internal/relay/keyAuthorization.d.ts.map +1 -0
- package/_types/tempo/internal/relay/plugin.d.ts +6 -3
- package/_types/tempo/internal/relay/plugin.d.ts.map +1 -1
- package/_types/tempo/internal/resolveError.d.ts +8 -0
- package/_types/tempo/internal/resolveError.d.ts.map +1 -0
- package/_types/tempo/internal/utils.d.ts.map +1 -1
- package/_types/utils/hash/normalizeSignature.d.ts.map +1 -1
- package/_types/utils/rpc/http.d.ts.map +1 -1
- package/_types/utils/rpc/socket.d.ts.map +1 -1
- package/actions/public/waitForTransactionReceipt.ts +8 -2
- package/actions/wallet/waitForCallsStatus.ts +41 -2
- package/chains/definitions/arcTestnet.ts +11 -8
- package/chains/definitions/qmsTestnet.ts +27 -0
- package/chains/definitions/tempo.ts +1 -1
- package/chains/definitions/tempoModerato.ts +2 -2
- package/chains/index.ts +1 -0
- package/clients/transports/ipc.ts +38 -29
- package/clients/transports/webSocket.ts +42 -33
- package/errors/version.ts +1 -1
- package/package.json +2 -2
- package/tempo/Abis.ts +298 -0
- package/tempo/Account.ts +95 -84
- package/tempo/Addresses.ts +1 -0
- package/tempo/Client.ts +3 -3
- package/tempo/Decorator.ts +91 -60
- package/tempo/ExecutionError.ts +102 -4
- package/tempo/Formatters.ts +14 -13
- package/tempo/KeyAuthorizationManager.ts +71 -19
- package/tempo/Relay.ts +70 -14
- package/tempo/Transaction.ts +31 -23
- package/tempo/Transport.ts +49 -21
- package/tempo/{multisig → accounts}/Config.ts +21 -21
- package/tempo/{multisig → accounts}/Operation.ts +26 -26
- package/tempo/{multisig → accounts}/Signature.ts +5 -3
- package/tempo/actions/accessKey.ts +675 -104
- package/tempo/actions/{multisig.ts → accounts.ts} +54 -59
- package/tempo/actions/amm.ts +126 -4
- package/tempo/actions/channel.ts +248 -14
- package/tempo/actions/dex.ts +599 -33
- package/tempo/actions/earn/deployment.ts +11 -9
- package/tempo/actions/earn.ts +40 -35
- package/tempo/actions/fee.ts +111 -9
- package/tempo/actions/index.ts +1 -1
- package/tempo/actions/nonce.ts +86 -1
- package/tempo/actions/policy.ts +66 -14
- package/tempo/actions/propAmm.ts +36 -9
- package/tempo/actions/receivePolicy.ts +26 -15
- package/tempo/actions/reward.ts +17 -9
- package/tempo/actions/token.ts +519 -54
- package/tempo/actions/validator.ts +40 -16
- package/tempo/actions/virtualAddress.ts +7 -5
- package/tempo/actions/zone.ts +25 -20
- package/tempo/chainConfig.ts +52 -52
- package/tempo/errors.ts +114 -1
- package/tempo/index.ts +5 -4
- package/tempo/internal/errors.ts +110 -0
- package/tempo/internal/relay/{multisig.ts → accounts.ts} +118 -118
- package/tempo/internal/relay/feePayer.ts +1 -1
- package/tempo/internal/relay/keyAuthorization.ts +415 -0
- package/tempo/internal/relay/plugin.ts +20 -7
- package/tempo/internal/resolveError.ts +169 -0
- package/tempo/internal/utils.ts +2 -0
- package/utils/hash/normalizeSignature.ts +3 -2
- package/utils/rpc/http.ts +76 -30
- package/utils/rpc/socket.ts +3 -1
- package/_cjs/tempo/actions/multisig.js.map +0 -1
- package/_cjs/tempo/internal/relay/multisig.js.map +0 -1
- package/_cjs/tempo/multisig/Signature.js.map +0 -1
- package/_esm/tempo/actions/multisig.js.map +0 -1
- package/_esm/tempo/internal/relay/multisig.js.map +0 -1
- package/_esm/tempo/multisig/Signature.js +0 -9
- package/_esm/tempo/multisig/Signature.js.map +0 -1
- package/_types/tempo/actions/multisig.d.ts.map +0 -1
- package/_types/tempo/internal/relay/multisig.d.ts +0 -4
- package/_types/tempo/internal/relay/multisig.d.ts.map +0 -1
- package/_types/tempo/multisig/Config.d.ts.map +0 -1
- package/_types/tempo/multisig/Operation.d.ts.map +0 -1
- package/_types/tempo/multisig/Signature.d.ts.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.errorResolvers = exports.AccessKeyExpiryInPastError = exports.AccessKeySignatureTypeMismatchError = exports.AccessKeyAlreadyExistsError = exports.AccessKeyCallNotAllowedError = exports.AccessKeyExpiredError = exports.AccessKeySpendingLimitExceededError = exports.AccessKeyError = void 0;
|
|
3
4
|
exports.authorize = authorize;
|
|
4
5
|
exports.authorizeSync = authorizeSync;
|
|
5
6
|
exports.burnWitness = burnWitness;
|
|
@@ -11,6 +12,7 @@ exports.isWitnessBurned = isWitnessBurned;
|
|
|
11
12
|
exports.revoke = revoke;
|
|
12
13
|
exports.revokeSync = revokeSync;
|
|
13
14
|
exports.prepareAuthorization = prepareAuthorization;
|
|
15
|
+
exports.saveAuthorization = saveAuthorization;
|
|
14
16
|
exports.signAuthorization = signAuthorization;
|
|
15
17
|
exports.updateLimit = updateLimit;
|
|
16
18
|
exports.updateLimitSync = updateLimitSync;
|
|
@@ -26,15 +28,19 @@ const sendTransaction_js_1 = require("../../actions/wallet/sendTransaction.js");
|
|
|
26
28
|
const sendTransactionSync_js_1 = require("../../actions/wallet/sendTransactionSync.js");
|
|
27
29
|
const writeContract_js_1 = require("../../actions/wallet/writeContract.js");
|
|
28
30
|
const writeContractSync_js_1 = require("../../actions/wallet/writeContractSync.js");
|
|
31
|
+
const rpc_js_1 = require("../../errors/rpc.js");
|
|
32
|
+
const formatAbiItem_js_1 = require("../../utils/abi/formatAbiItem.js");
|
|
29
33
|
const parseEventLogs_js_1 = require("../../utils/abi/parseEventLogs.js");
|
|
30
34
|
const isAddressEqual_js_1 = require("../../utils/address/isAddressEqual.js");
|
|
31
35
|
const Abis = require("../Abis.js");
|
|
32
36
|
const Account_js_1 = require("../Account.js");
|
|
33
37
|
const Addresses = require("../Addresses.js");
|
|
38
|
+
const Signature_js_1 = require("../accounts/Signature.js");
|
|
39
|
+
const errors_js_1 = require("../errors.js");
|
|
34
40
|
const Hardfork = require("../Hardfork.js");
|
|
41
|
+
const errors_js_2 = require("../internal/errors.js");
|
|
35
42
|
const utils_js_1 = require("../internal/utils.js");
|
|
36
|
-
const
|
|
37
|
-
const multisig_js_1 = require("./multisig.js");
|
|
43
|
+
const accounts_js_1 = require("./accounts.js");
|
|
38
44
|
const signatureTypes = {
|
|
39
45
|
0: 'secp256k1',
|
|
40
46
|
1: 'p256',
|
|
@@ -55,7 +61,7 @@ async function authorize(client, parameters) {
|
|
|
55
61
|
throw new Error('account is required.');
|
|
56
62
|
if (!chainId)
|
|
57
63
|
throw new Error('chainId is required.');
|
|
58
|
-
const keyAuthorization = await
|
|
64
|
+
const keyAuthorization = await signLocal(client, {
|
|
59
65
|
account: account_,
|
|
60
66
|
accessKey,
|
|
61
67
|
chainId,
|
|
@@ -65,7 +71,13 @@ async function authorize(client, parameters) {
|
|
|
65
71
|
scopes,
|
|
66
72
|
witness,
|
|
67
73
|
});
|
|
68
|
-
return (await
|
|
74
|
+
return (await (0, errors_js_2.withExecutionError)(action, {
|
|
75
|
+
hints: {
|
|
76
|
+
KeyAlreadyExists: [
|
|
77
|
+
'This access key is already authorized. Update its spending limits instead.',
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
})(client, {
|
|
69
81
|
...rest,
|
|
70
82
|
keyAuthorization,
|
|
71
83
|
}));
|
|
@@ -105,7 +117,7 @@ async function burnWitness(client, parameters) {
|
|
|
105
117
|
async function inner(action, client, parameters) {
|
|
106
118
|
const { witness, ...rest } = parameters;
|
|
107
119
|
const call = burnWitness.call({ witness });
|
|
108
|
-
return (await action(client, {
|
|
120
|
+
return (await (0, errors_js_2.withExecutionError)(action)(client, {
|
|
109
121
|
...rest,
|
|
110
122
|
...call,
|
|
111
123
|
}));
|
|
@@ -153,7 +165,7 @@ async function getMetadata(client, parameters) {
|
|
|
153
165
|
if (!account_)
|
|
154
166
|
throw new Error('account is required.');
|
|
155
167
|
const account = (0, parseAccount_js_1.parseAccount)(account_);
|
|
156
|
-
const result = await (0, readContract_js_1.readContract)(client, {
|
|
168
|
+
const result = await (0, errors_js_2.withExecutionError)(readContract_js_1.readContract)(client, {
|
|
157
169
|
...rest,
|
|
158
170
|
account: null,
|
|
159
171
|
...getMetadata.call({ account: account.address, accessKey }),
|
|
@@ -186,13 +198,13 @@ async function getRemainingLimit(client, parameters) {
|
|
|
186
198
|
const account = (0, parseAccount_js_1.parseAccount)(account_);
|
|
187
199
|
const hardfork = client.chain?.hardfork;
|
|
188
200
|
if (hardfork && Hardfork.lt(hardfork, 't3')) {
|
|
189
|
-
const remaining = await (0, readContract_js_1.readContract)(client, {
|
|
201
|
+
const remaining = await (0, errors_js_2.withExecutionError)(readContract_js_1.readContract)(client, {
|
|
190
202
|
...rest,
|
|
191
203
|
...getRemainingLimit.call({ account: account.address, accessKey, token }),
|
|
192
204
|
});
|
|
193
205
|
return { remaining, periodEnd: undefined };
|
|
194
206
|
}
|
|
195
|
-
const [remaining, periodEnd] = await (0, readContract_js_1.readContract)(client, {
|
|
207
|
+
const [remaining, periodEnd] = await (0, errors_js_2.withExecutionError)(readContract_js_1.readContract)(client, {
|
|
196
208
|
...rest,
|
|
197
209
|
...getRemainingLimit.callWithPeriod({
|
|
198
210
|
account: account.address,
|
|
@@ -229,7 +241,7 @@ async function isAdmin(client, parameters) {
|
|
|
229
241
|
if (!account_)
|
|
230
242
|
throw new Error('account is required.');
|
|
231
243
|
const account = (0, parseAccount_js_1.parseAccount)(account_);
|
|
232
|
-
return (0, readContract_js_1.readContract)(client, {
|
|
244
|
+
return (0, errors_js_2.withExecutionError)(readContract_js_1.readContract)(client, {
|
|
233
245
|
...rest,
|
|
234
246
|
account: null,
|
|
235
247
|
...isAdmin.call({ account: account.address, accessKey }),
|
|
@@ -252,7 +264,7 @@ async function isWitnessBurned(client, parameters) {
|
|
|
252
264
|
if (!account_)
|
|
253
265
|
throw new Error('account is required.');
|
|
254
266
|
const account = (0, parseAccount_js_1.parseAccount)(account_);
|
|
255
|
-
return (0, readContract_js_1.readContract)(client, {
|
|
267
|
+
return (0, errors_js_2.withExecutionError)(readContract_js_1.readContract)(client, {
|
|
256
268
|
...rest,
|
|
257
269
|
account: null,
|
|
258
270
|
...isWitnessBurned.call({ account: account.address, witness }),
|
|
@@ -277,7 +289,7 @@ async function revoke(client, parameters) {
|
|
|
277
289
|
async function inner(action, client, parameters) {
|
|
278
290
|
const { accessKey, ...rest } = parameters;
|
|
279
291
|
const call = revoke.call({ accessKey });
|
|
280
|
-
return (await action(client, {
|
|
292
|
+
return (await (0, errors_js_2.withExecutionError)(action)(client, {
|
|
281
293
|
...rest,
|
|
282
294
|
...call,
|
|
283
295
|
}));
|
|
@@ -328,14 +340,14 @@ async function prepareAuthorization(client, parameters) {
|
|
|
328
340
|
if (!chainId)
|
|
329
341
|
throw new Error('chainId is required.');
|
|
330
342
|
const parsed = (0, parseAccount_js_1.parseAccount)(account_);
|
|
331
|
-
const
|
|
332
|
-
if ('
|
|
333
|
-
return parameters.
|
|
334
|
-
if (parsed.source !== '
|
|
343
|
+
const configurableState = await (async () => {
|
|
344
|
+
if ('configurable' in parameters)
|
|
345
|
+
return parameters.configurable;
|
|
346
|
+
if (parsed.source !== 'configurable')
|
|
335
347
|
return undefined;
|
|
336
348
|
const account = parsed;
|
|
337
349
|
if (!account.config)
|
|
338
|
-
throw new Error('
|
|
350
|
+
throw new Error('An account config is required to prepare a key authorization.');
|
|
339
351
|
return { config: account.config };
|
|
340
352
|
})();
|
|
341
353
|
const authorizationSignPayload = (0, Account_js_1.getKeyAuthorizationSignPayload)(parsed, {
|
|
@@ -343,10 +355,10 @@ async function prepareAuthorization(client, parameters) {
|
|
|
343
355
|
chainId: BigInt(chainId),
|
|
344
356
|
key: parameters.accessKey,
|
|
345
357
|
});
|
|
346
|
-
const signPayload = parsed.source === '
|
|
347
|
-
? tempo_1.
|
|
358
|
+
const signPayload = parsed.source === 'configurable' && configurableState
|
|
359
|
+
? tempo_1.AccountConfig.getSignPayload({
|
|
348
360
|
account: parsed.address,
|
|
349
|
-
config:
|
|
361
|
+
config: configurableState.config,
|
|
350
362
|
payload: authorizationSignPayload,
|
|
351
363
|
})
|
|
352
364
|
: authorizationSignPayload;
|
|
@@ -354,10 +366,17 @@ async function prepareAuthorization(client, parameters) {
|
|
|
354
366
|
...parameters,
|
|
355
367
|
account: parsed,
|
|
356
368
|
chainId,
|
|
357
|
-
|
|
369
|
+
configurable: configurableState,
|
|
358
370
|
signPayload,
|
|
359
371
|
};
|
|
360
372
|
}
|
|
373
|
+
async function saveAuthorization(client, parameters) {
|
|
374
|
+
const { keyAuthorization } = parameters;
|
|
375
|
+
await client.request({
|
|
376
|
+
method: 'relay_saveKeyAuthorization',
|
|
377
|
+
params: [tempo_1.KeyAuthorization.toRpc(keyAuthorization)],
|
|
378
|
+
});
|
|
379
|
+
}
|
|
361
380
|
async function signAuthorization(client, parameters) {
|
|
362
381
|
const coordinated = ('hash' in parameters && parameters.hash) ||
|
|
363
382
|
('owner' in parameters && parameters.owner);
|
|
@@ -365,11 +384,11 @@ async function signAuthorization(client, parameters) {
|
|
|
365
384
|
const parameters_ = parameters;
|
|
366
385
|
const owner_ = parameters_.owner;
|
|
367
386
|
if (!owner_ || typeof owner_ === 'string')
|
|
368
|
-
throw new Error('A local owner account is required to approve a
|
|
387
|
+
throw new Error('A local owner account is required to approve a configurable account key authorization.');
|
|
369
388
|
const owner = (0, parseAccount_js_1.parseAccount)(owner_);
|
|
370
389
|
const sign = owner.sign;
|
|
371
390
|
if (!sign)
|
|
372
|
-
throw new Error('A local owner account is required to approve a
|
|
391
|
+
throw new Error('A local owner account is required to approve a configurable account key authorization.');
|
|
373
392
|
const request = await (async () => {
|
|
374
393
|
if ('hash' in parameters_ && parameters_.hash) {
|
|
375
394
|
const signature = tempo_1.SignatureEnvelope.serialize(tempo_1.SignatureEnvelope.from(await sign({ hash: parameters_.hash })));
|
|
@@ -380,19 +399,19 @@ async function signAuthorization(client, parameters) {
|
|
|
380
399
|
const config = await (async () => {
|
|
381
400
|
if (typeof account_ !== 'string' && account_.config)
|
|
382
401
|
return account_.config;
|
|
383
|
-
const config = await (0,
|
|
402
|
+
const config = await (0, accounts_js_1.getConfig)(client, { address });
|
|
384
403
|
if (config)
|
|
385
404
|
return config;
|
|
386
|
-
throw new Error(`No current
|
|
405
|
+
throw new Error(`No current account config is cached for account ${address}. Provide the current config.`);
|
|
387
406
|
})();
|
|
388
407
|
const account = (() => {
|
|
389
408
|
if (config.version !== 0n)
|
|
390
|
-
return (0, Account_js_1.
|
|
409
|
+
return (0, Account_js_1.fromConfig)({ address, ...config });
|
|
391
410
|
const { version: _, ...initialConfig } = config;
|
|
392
|
-
return (0, Account_js_1.
|
|
411
|
+
return (0, Account_js_1.fromConfig)({ address: 'infer', ...initialConfig });
|
|
393
412
|
})();
|
|
394
413
|
if (!(0, isAddressEqual_js_1.isAddressEqual)(account.address, address))
|
|
395
|
-
throw new Error('Initial
|
|
414
|
+
throw new Error('Initial account config does not match the account.');
|
|
396
415
|
const prepared = await prepareAuthorization(client, {
|
|
397
416
|
...authorization,
|
|
398
417
|
account,
|
|
@@ -416,44 +435,58 @@ async function signAuthorization(client, parameters) {
|
|
|
416
435
|
return { keyAuthorization: tempo_1.KeyAuthorization.toRpc(keyAuthorization) };
|
|
417
436
|
})();
|
|
418
437
|
const operation = await client.request({
|
|
419
|
-
method: '
|
|
438
|
+
method: 'account_approveKeyAuthorization',
|
|
420
439
|
params: [request],
|
|
421
440
|
});
|
|
422
|
-
const
|
|
441
|
+
const operation_ = tempo_1.AccountOperation.fromRpc(operation);
|
|
423
442
|
const keyAuthorization = tempo_1.KeyAuthorization.deserialize(await (async () => {
|
|
424
|
-
if (
|
|
425
|
-
return
|
|
426
|
-
const approvals = await tempo_1.
|
|
427
|
-
account:
|
|
428
|
-
approvals:
|
|
429
|
-
config:
|
|
430
|
-
hash:
|
|
443
|
+
if (operation_.status === 'success')
|
|
444
|
+
return operation_.keyAuthorization;
|
|
445
|
+
const approvals = await tempo_1.AccountOperation.selectApprovals({
|
|
446
|
+
account: operation_.account,
|
|
447
|
+
approvals: operation_.approvals,
|
|
448
|
+
config: operation_.config,
|
|
449
|
+
hash: operation_.hash,
|
|
431
450
|
});
|
|
432
|
-
return tempo_1.
|
|
433
|
-
account:
|
|
451
|
+
return tempo_1.AccountOperation.serializeKeyAuthorization(operation_.keyAuthorization, {
|
|
452
|
+
account: operation_.account,
|
|
434
453
|
approvals: approvals.selectedApprovals.length > 0
|
|
435
454
|
? approvals.selectedApprovals
|
|
436
455
|
: approvals.approvals.slice(0, 1),
|
|
437
|
-
config:
|
|
456
|
+
config: operation_.config,
|
|
438
457
|
});
|
|
439
458
|
})());
|
|
440
459
|
if (!keyAuthorization.signature)
|
|
441
|
-
throw new Error('Expected a signed
|
|
460
|
+
throw new Error('Expected a signed configurable account key authorization.');
|
|
442
461
|
return {
|
|
443
462
|
...keyAuthorization,
|
|
444
|
-
hash:
|
|
445
|
-
|
|
446
|
-
status:
|
|
463
|
+
hash: operation_.hash,
|
|
464
|
+
operation: operation_,
|
|
465
|
+
status: operation_.status,
|
|
447
466
|
};
|
|
448
467
|
}
|
|
468
|
+
const keyAuthorization = await signLocal(client, parameters);
|
|
469
|
+
const signer = parameters.account ?? client.account;
|
|
470
|
+
if (client.transport.keyAuthorization &&
|
|
471
|
+
signer &&
|
|
472
|
+
(0, parseAccount_js_1.parseAccount)(signer).source !== 'accessKey')
|
|
473
|
+
await saveAuthorization(client, { keyAuthorization }).catch((error) => {
|
|
474
|
+
if (error instanceof rpc_js_1.MethodNotFoundRpcError ||
|
|
475
|
+
error instanceof rpc_js_1.MethodNotSupportedRpcError)
|
|
476
|
+
return;
|
|
477
|
+
throw error;
|
|
478
|
+
});
|
|
479
|
+
return keyAuthorization;
|
|
480
|
+
}
|
|
481
|
+
async function signLocal(client, parameters) {
|
|
449
482
|
const prepared = ('signPayload' in parameters
|
|
450
483
|
? parameters
|
|
451
484
|
: await prepareAuthorization(client, parameters));
|
|
452
|
-
const { accessKey, account: account_, chainId,
|
|
485
|
+
const { accessKey, account: account_, chainId, configurable: configurableState, signPayload: _, ...rest } = prepared;
|
|
453
486
|
return (0, Account_js_1.signKeyAuthorization)(account_, {
|
|
454
487
|
chainId: BigInt(chainId),
|
|
455
488
|
key: accessKey,
|
|
456
|
-
|
|
489
|
+
configurable: configurableState,
|
|
457
490
|
...rest,
|
|
458
491
|
});
|
|
459
492
|
}
|
|
@@ -464,7 +497,7 @@ async function updateLimit(client, parameters) {
|
|
|
464
497
|
async function inner(action, client, parameters) {
|
|
465
498
|
const { accessKey, token, limit, ...rest } = parameters;
|
|
466
499
|
const call = updateLimit.call({ accessKey, token, limit });
|
|
467
|
-
return (await action(client, {
|
|
500
|
+
return (await (0, errors_js_2.withExecutionError)(action)(client, {
|
|
468
501
|
...rest,
|
|
469
502
|
...call,
|
|
470
503
|
}));
|
|
@@ -554,7 +587,7 @@ function watchWitnessBurned(client, parameters) {
|
|
|
554
587
|
}
|
|
555
588
|
async function verifyHash(client, parameters) {
|
|
556
589
|
const { account, admin, hash, signature, ...rest } = parameters;
|
|
557
|
-
return (0, readContract_js_1.readContract)(client, {
|
|
590
|
+
return (0, errors_js_2.withExecutionError)(readContract_js_1.readContract)(client, {
|
|
558
591
|
...rest,
|
|
559
592
|
...verifyHash.call({ account, admin, hash, signature }),
|
|
560
593
|
});
|
|
@@ -576,4 +609,366 @@ function resolveAccessKeyAddress(accessKey) {
|
|
|
576
609
|
return accessKey;
|
|
577
610
|
return accessKey.accessKeyAddress;
|
|
578
611
|
}
|
|
612
|
+
class AccessKeyError extends errors_js_1.TempoExecutionError {
|
|
613
|
+
constructor(parameters, options = {}) {
|
|
614
|
+
const { account, accessKey } = parameters;
|
|
615
|
+
super(parameters, {
|
|
616
|
+
shortMessage: `Access key "${accessKey}" failed: ${parameters.error.message}`,
|
|
617
|
+
...options,
|
|
618
|
+
details: { account, 'access key': accessKey, ...options.details },
|
|
619
|
+
docsPath: '/tempo/guides/access-keys/manage',
|
|
620
|
+
name: options.name ?? 'AccessKeyError',
|
|
621
|
+
});
|
|
622
|
+
Object.defineProperty(this, "account", {
|
|
623
|
+
enumerable: true,
|
|
624
|
+
configurable: true,
|
|
625
|
+
writable: true,
|
|
626
|
+
value: void 0
|
|
627
|
+
});
|
|
628
|
+
Object.defineProperty(this, "accessKey", {
|
|
629
|
+
enumerable: true,
|
|
630
|
+
configurable: true,
|
|
631
|
+
writable: true,
|
|
632
|
+
value: void 0
|
|
633
|
+
});
|
|
634
|
+
this.account = account;
|
|
635
|
+
this.accessKey = accessKey;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
exports.AccessKeyError = AccessKeyError;
|
|
639
|
+
class AccessKeySpendingLimitExceededError extends AccessKeyError {
|
|
640
|
+
constructor(parameters) {
|
|
641
|
+
const { amount, decimals, fee, periodEnd, remaining, token } = parameters;
|
|
642
|
+
super(parameters, {
|
|
643
|
+
details: {
|
|
644
|
+
token,
|
|
645
|
+
amount: (0, errors_js_2.formatAmount)(amount, decimals),
|
|
646
|
+
remaining: (0, errors_js_2.formatAmount)(remaining, decimals),
|
|
647
|
+
'exceeded by': amount !== undefined && remaining !== undefined
|
|
648
|
+
? (0, errors_js_2.formatAmount)(amount - remaining, decimals)
|
|
649
|
+
: undefined,
|
|
650
|
+
'resets at': (0, errors_js_2.formatTime)(periodEnd),
|
|
651
|
+
},
|
|
652
|
+
name: 'AccessKeySpendingLimitExceededError',
|
|
653
|
+
shortMessage: `Access key "${parameters.accessKey}" exceeded its spending limit${token ? ` for token "${token}"` : ''}${fee ? ' while paying fees' : ''}.`,
|
|
654
|
+
});
|
|
655
|
+
Object.defineProperty(this, "amount", {
|
|
656
|
+
enumerable: true,
|
|
657
|
+
configurable: true,
|
|
658
|
+
writable: true,
|
|
659
|
+
value: void 0
|
|
660
|
+
});
|
|
661
|
+
Object.defineProperty(this, "decimals", {
|
|
662
|
+
enumerable: true,
|
|
663
|
+
configurable: true,
|
|
664
|
+
writable: true,
|
|
665
|
+
value: void 0
|
|
666
|
+
});
|
|
667
|
+
Object.defineProperty(this, "fee", {
|
|
668
|
+
enumerable: true,
|
|
669
|
+
configurable: true,
|
|
670
|
+
writable: true,
|
|
671
|
+
value: void 0
|
|
672
|
+
});
|
|
673
|
+
Object.defineProperty(this, "periodEnd", {
|
|
674
|
+
enumerable: true,
|
|
675
|
+
configurable: true,
|
|
676
|
+
writable: true,
|
|
677
|
+
value: void 0
|
|
678
|
+
});
|
|
679
|
+
Object.defineProperty(this, "remaining", {
|
|
680
|
+
enumerable: true,
|
|
681
|
+
configurable: true,
|
|
682
|
+
writable: true,
|
|
683
|
+
value: void 0
|
|
684
|
+
});
|
|
685
|
+
Object.defineProperty(this, "token", {
|
|
686
|
+
enumerable: true,
|
|
687
|
+
configurable: true,
|
|
688
|
+
writable: true,
|
|
689
|
+
value: void 0
|
|
690
|
+
});
|
|
691
|
+
this.amount = amount;
|
|
692
|
+
this.decimals = decimals;
|
|
693
|
+
this.fee = fee;
|
|
694
|
+
this.periodEnd = periodEnd;
|
|
695
|
+
this.remaining = remaining;
|
|
696
|
+
this.token = token;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
exports.AccessKeySpendingLimitExceededError = AccessKeySpendingLimitExceededError;
|
|
700
|
+
class AccessKeyExpiredError extends AccessKeyError {
|
|
701
|
+
constructor(parameters) {
|
|
702
|
+
super(parameters, {
|
|
703
|
+
details: { 'expired at': (0, errors_js_2.formatTime)(parameters.expiry) },
|
|
704
|
+
name: 'AccessKeyExpiredError',
|
|
705
|
+
shortMessage: `Access key "${parameters.accessKey}" has expired.`,
|
|
706
|
+
});
|
|
707
|
+
Object.defineProperty(this, "expiry", {
|
|
708
|
+
enumerable: true,
|
|
709
|
+
configurable: true,
|
|
710
|
+
writable: true,
|
|
711
|
+
value: void 0
|
|
712
|
+
});
|
|
713
|
+
this.expiry = parameters.expiry;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
exports.AccessKeyExpiredError = AccessKeyExpiredError;
|
|
717
|
+
class AccessKeyCallNotAllowedError extends AccessKeyError {
|
|
718
|
+
constructor(parameters) {
|
|
719
|
+
const { selector, target } = parameters;
|
|
720
|
+
super(parameters, {
|
|
721
|
+
details: { target, selector },
|
|
722
|
+
name: 'AccessKeyCallNotAllowedError',
|
|
723
|
+
shortMessage: `Access key "${parameters.accessKey}" is not allowed to make this call.`,
|
|
724
|
+
});
|
|
725
|
+
Object.defineProperty(this, "selector", {
|
|
726
|
+
enumerable: true,
|
|
727
|
+
configurable: true,
|
|
728
|
+
writable: true,
|
|
729
|
+
value: void 0
|
|
730
|
+
});
|
|
731
|
+
Object.defineProperty(this, "target", {
|
|
732
|
+
enumerable: true,
|
|
733
|
+
configurable: true,
|
|
734
|
+
writable: true,
|
|
735
|
+
value: void 0
|
|
736
|
+
});
|
|
737
|
+
this.selector = selector;
|
|
738
|
+
this.target = target;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
exports.AccessKeyCallNotAllowedError = AccessKeyCallNotAllowedError;
|
|
742
|
+
class AccessKeyAlreadyExistsError extends AccessKeyError {
|
|
743
|
+
constructor(parameters) {
|
|
744
|
+
const { expiry, limited } = parameters;
|
|
745
|
+
super(parameters, {
|
|
746
|
+
details: {
|
|
747
|
+
expires: (0, errors_js_2.formatTime)(expiry),
|
|
748
|
+
'spending limits': limited === undefined ? undefined : limited ? 'enforced' : 'none',
|
|
749
|
+
},
|
|
750
|
+
name: 'AccessKeyAlreadyExistsError',
|
|
751
|
+
shortMessage: `Access key "${parameters.accessKey}" is already authorized on account "${parameters.account}".`,
|
|
752
|
+
});
|
|
753
|
+
Object.defineProperty(this, "expiry", {
|
|
754
|
+
enumerable: true,
|
|
755
|
+
configurable: true,
|
|
756
|
+
writable: true,
|
|
757
|
+
value: void 0
|
|
758
|
+
});
|
|
759
|
+
Object.defineProperty(this, "limited", {
|
|
760
|
+
enumerable: true,
|
|
761
|
+
configurable: true,
|
|
762
|
+
writable: true,
|
|
763
|
+
value: void 0
|
|
764
|
+
});
|
|
765
|
+
this.expiry = expiry;
|
|
766
|
+
this.limited = limited;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
exports.AccessKeyAlreadyExistsError = AccessKeyAlreadyExistsError;
|
|
770
|
+
class AccessKeySignatureTypeMismatchError extends AccessKeyError {
|
|
771
|
+
constructor(parameters) {
|
|
772
|
+
const [expected, actual] = (parameters.error.args ?? []).map((type) => signatureTypes[Number(type)]);
|
|
773
|
+
super(parameters, {
|
|
774
|
+
details: { expected, actual },
|
|
775
|
+
name: 'AccessKeySignatureTypeMismatchError',
|
|
776
|
+
shortMessage: `Access key "${parameters.accessKey}" signed with a ${actual ?? 'different'} key, but was authorized as a ${expected ?? 'different'} key.`,
|
|
777
|
+
});
|
|
778
|
+
Object.defineProperty(this, "expected", {
|
|
779
|
+
enumerable: true,
|
|
780
|
+
configurable: true,
|
|
781
|
+
writable: true,
|
|
782
|
+
value: void 0
|
|
783
|
+
});
|
|
784
|
+
Object.defineProperty(this, "actual", {
|
|
785
|
+
enumerable: true,
|
|
786
|
+
configurable: true,
|
|
787
|
+
writable: true,
|
|
788
|
+
value: void 0
|
|
789
|
+
});
|
|
790
|
+
this.expected = expected;
|
|
791
|
+
this.actual = actual;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
exports.AccessKeySignatureTypeMismatchError = AccessKeySignatureTypeMismatchError;
|
|
795
|
+
class AccessKeyExpiryInPastError extends AccessKeyError {
|
|
796
|
+
constructor(parameters) {
|
|
797
|
+
const { expiry, minimum } = parameters;
|
|
798
|
+
super(parameters, {
|
|
799
|
+
details: { expiry: (0, errors_js_2.formatTime)(expiry), minimum: (0, errors_js_2.formatTime)(minimum) },
|
|
800
|
+
name: 'AccessKeyExpiryInPastError',
|
|
801
|
+
shortMessage: `Access key "${parameters.accessKey}" expiry must be later${minimum ? ` than ${(0, errors_js_2.formatTime)(minimum)}` : ''}.`,
|
|
802
|
+
});
|
|
803
|
+
Object.defineProperty(this, "expiry", {
|
|
804
|
+
enumerable: true,
|
|
805
|
+
configurable: true,
|
|
806
|
+
writable: true,
|
|
807
|
+
value: void 0
|
|
808
|
+
});
|
|
809
|
+
Object.defineProperty(this, "minimum", {
|
|
810
|
+
enumerable: true,
|
|
811
|
+
configurable: true,
|
|
812
|
+
writable: true,
|
|
813
|
+
value: void 0
|
|
814
|
+
});
|
|
815
|
+
this.expiry = expiry;
|
|
816
|
+
this.minimum = minimum;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
exports.AccessKeyExpiryInPastError = AccessKeyExpiryInPastError;
|
|
820
|
+
const keychain = {
|
|
821
|
+
address: Addresses.accountKeychain,
|
|
822
|
+
abi: Abis.accountKeychain,
|
|
823
|
+
};
|
|
824
|
+
function getSigner(context) {
|
|
825
|
+
const { call, parameters, signer } = context;
|
|
826
|
+
if (!signer?.accessKey)
|
|
827
|
+
return undefined;
|
|
828
|
+
if (call && (0, isAddressEqual_js_1.isAddressEqual)(call.address, Addresses.accountKeychain))
|
|
829
|
+
return undefined;
|
|
830
|
+
const authorized = parameters.keyAuthorization?.address;
|
|
831
|
+
if (authorized && !(0, isAddressEqual_js_1.isAddressEqual)(authorized, signer.accessKey))
|
|
832
|
+
return undefined;
|
|
833
|
+
return {
|
|
834
|
+
...context.base,
|
|
835
|
+
account: signer.address,
|
|
836
|
+
accessKey: signer.accessKey,
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
function getFeePayer(context) {
|
|
840
|
+
const { feePayer } = context.parameters;
|
|
841
|
+
if (typeof feePayer !== 'object')
|
|
842
|
+
return undefined;
|
|
843
|
+
const account = (0, parseAccount_js_1.parseAccount)(feePayer);
|
|
844
|
+
if (account.source !== 'accessKey' || !('accessKeyAddress' in account))
|
|
845
|
+
return undefined;
|
|
846
|
+
return {
|
|
847
|
+
...context.base,
|
|
848
|
+
account: account.address,
|
|
849
|
+
accessKey: account.accessKeyAddress,
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
function getAuthorization(context) {
|
|
853
|
+
const { call, parameters, signer } = context;
|
|
854
|
+
const accessKey = parameters.keyAuthorization?.address ??
|
|
855
|
+
call?.arg('keyId');
|
|
856
|
+
if (!signer || !accessKey)
|
|
857
|
+
return undefined;
|
|
858
|
+
return { ...context.base, account: signer.address, accessKey };
|
|
859
|
+
}
|
|
860
|
+
exports.errorResolvers = {
|
|
861
|
+
...Object.fromEntries(Abis.accountKeychain.flatMap((item) => item.type === 'error'
|
|
862
|
+
? [
|
|
863
|
+
[
|
|
864
|
+
(0, formatAbiItem_js_1.formatAbiItem)(item),
|
|
865
|
+
(context) => {
|
|
866
|
+
const parameters = getSigner(context);
|
|
867
|
+
return parameters && new AccessKeyError(parameters);
|
|
868
|
+
},
|
|
869
|
+
],
|
|
870
|
+
]
|
|
871
|
+
: [])),
|
|
872
|
+
'CallNotAllowed()': (context) => {
|
|
873
|
+
const parameters = getSigner(context);
|
|
874
|
+
if (!parameters)
|
|
875
|
+
return undefined;
|
|
876
|
+
return new AccessKeyCallNotAllowedError({
|
|
877
|
+
...parameters,
|
|
878
|
+
selector: context.parameters.data?.slice(0, 10),
|
|
879
|
+
target: context.call?.address ?? context.parameters.to,
|
|
880
|
+
});
|
|
881
|
+
},
|
|
882
|
+
'ExpiryInPast()': (context) => {
|
|
883
|
+
const parameters = getAuthorization(context);
|
|
884
|
+
if (!parameters)
|
|
885
|
+
return undefined;
|
|
886
|
+
const [, expiry, minimum] = /expiry (\d+) <= min allowed (\d+)/.exec(context.details) ?? [];
|
|
887
|
+
const requested = context.parameters.keyAuthorization?.expiry ??
|
|
888
|
+
context.call?.arg('expiry') ??
|
|
889
|
+
context.call?.arg('config')?.expiry;
|
|
890
|
+
return new AccessKeyExpiryInPastError({
|
|
891
|
+
...parameters,
|
|
892
|
+
expiry: expiry
|
|
893
|
+
? BigInt(expiry)
|
|
894
|
+
: requested === undefined || requested === null
|
|
895
|
+
? undefined
|
|
896
|
+
: BigInt(requested),
|
|
897
|
+
minimum: minimum ? BigInt(minimum) : undefined,
|
|
898
|
+
});
|
|
899
|
+
},
|
|
900
|
+
'KeyAlreadyExists()': async (context) => {
|
|
901
|
+
const parameters = getAuthorization(context);
|
|
902
|
+
if (!parameters)
|
|
903
|
+
return undefined;
|
|
904
|
+
const [key] = await context.read([
|
|
905
|
+
{
|
|
906
|
+
...keychain,
|
|
907
|
+
functionName: 'getKey',
|
|
908
|
+
args: [parameters.account, parameters.accessKey],
|
|
909
|
+
},
|
|
910
|
+
]);
|
|
911
|
+
return new AccessKeyAlreadyExistsError({
|
|
912
|
+
...parameters,
|
|
913
|
+
expiry: key?.result?.expiry,
|
|
914
|
+
limited: key?.result?.enforceLimits,
|
|
915
|
+
});
|
|
916
|
+
},
|
|
917
|
+
'KeyExpired()': async (context) => {
|
|
918
|
+
const parameters = getSigner(context);
|
|
919
|
+
if (!parameters)
|
|
920
|
+
return undefined;
|
|
921
|
+
const [key] = await context.read([
|
|
922
|
+
{
|
|
923
|
+
...keychain,
|
|
924
|
+
functionName: 'getKey',
|
|
925
|
+
args: [parameters.account, parameters.accessKey],
|
|
926
|
+
},
|
|
927
|
+
]);
|
|
928
|
+
return new AccessKeyExpiredError({
|
|
929
|
+
...parameters,
|
|
930
|
+
expiry: key?.result?.expiry,
|
|
931
|
+
});
|
|
932
|
+
},
|
|
933
|
+
'SignatureTypeMismatch(uint8,uint8)': (context) => {
|
|
934
|
+
const parameters = getSigner(context) ?? getAuthorization(context);
|
|
935
|
+
return parameters && new AccessKeySignatureTypeMismatchError(parameters);
|
|
936
|
+
},
|
|
937
|
+
'SpendingLimitExceeded()': async (context) => {
|
|
938
|
+
const fee = context.validation;
|
|
939
|
+
const parameters = fee && context.parameters.feePayer
|
|
940
|
+
? getFeePayer(context)
|
|
941
|
+
: getSigner(context);
|
|
942
|
+
if (!parameters)
|
|
943
|
+
return undefined;
|
|
944
|
+
const token = fee
|
|
945
|
+
? (0, errors_js_2.getFeeToken)(context)
|
|
946
|
+
: (0, errors_js_2.isTip20)(context.call?.address)
|
|
947
|
+
? context.call.address
|
|
948
|
+
: undefined;
|
|
949
|
+
if (!token)
|
|
950
|
+
return new AccessKeySpendingLimitExceededError({
|
|
951
|
+
...parameters,
|
|
952
|
+
fee,
|
|
953
|
+
hints: fee
|
|
954
|
+
? [...parameters.hints, 'Pay fees with another token.']
|
|
955
|
+
: parameters.hints,
|
|
956
|
+
});
|
|
957
|
+
const args = [parameters.account, parameters.accessKey, token];
|
|
958
|
+
const [withPeriod, legacy, decimals] = await context.read([
|
|
959
|
+
{ ...keychain, functionName: 'getRemainingLimitWithPeriod', args },
|
|
960
|
+
{ ...keychain, functionName: 'getRemainingLimit', args },
|
|
961
|
+
{ address: token, abi: Abis.tip20, functionName: 'decimals' },
|
|
962
|
+
]);
|
|
963
|
+
return new AccessKeySpendingLimitExceededError({
|
|
964
|
+
...parameters,
|
|
965
|
+
amount: fee ? undefined : context.call?.arg('amount'),
|
|
966
|
+
decimals: decimals?.result,
|
|
967
|
+
fee,
|
|
968
|
+
periodEnd: withPeriod?.result?.[1] || undefined,
|
|
969
|
+
remaining: withPeriod?.result?.[0] ?? legacy?.result,
|
|
970
|
+
token,
|
|
971
|
+
});
|
|
972
|
+
},
|
|
973
|
+
};
|
|
579
974
|
//# sourceMappingURL=accessKey.js.map
|