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
package/tempo/chainConfig.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Address } from 'abitype'
|
|
2
2
|
import * as Hex from 'ox/Hex'
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type
|
|
4
|
+
AccountConfig,
|
|
5
|
+
AccountOperation,
|
|
6
|
+
type AccountSimulation,
|
|
7
7
|
SignatureEnvelope,
|
|
8
8
|
type TokenId,
|
|
9
9
|
} from 'ox/tempo'
|
|
@@ -20,9 +20,9 @@ import { defineTransactionRequest } from '../utils/formatters/transactionRequest
|
|
|
20
20
|
import { getAction } from '../utils/getAction.js'
|
|
21
21
|
import { keccak256 } from '../utils/hash/keccak256.js'
|
|
22
22
|
import type { SerializeTransactionFn } from '../utils/transaction/serializeTransaction.js'
|
|
23
|
-
import type { Account,
|
|
23
|
+
import type { Account, ConfigurableAccount } from './Account.js'
|
|
24
24
|
import { getMetadata } from './actions/accessKey.js'
|
|
25
|
-
import { getConfig } from './actions/
|
|
25
|
+
import { getConfig } from './actions/accounts.js'
|
|
26
26
|
import * as Formatters from './Formatters.js'
|
|
27
27
|
import type { Hardfork } from './Hardfork.js'
|
|
28
28
|
import * as Concurrent from './internal/concurrent.js'
|
|
@@ -55,7 +55,7 @@ export const chainConfig = {
|
|
|
55
55
|
prepareTransactionRequest: [
|
|
56
56
|
async (r, { client, phase }) => {
|
|
57
57
|
const request = r as Transaction.TransactionRequest & {
|
|
58
|
-
account?: Account |
|
|
58
|
+
account?: Account | ConfigurableAccount | undefined
|
|
59
59
|
chainId?: number | undefined
|
|
60
60
|
chain?:
|
|
61
61
|
| (Chain & {
|
|
@@ -67,8 +67,8 @@ export const chainConfig = {
|
|
|
67
67
|
hash?: Hex.Hex | undefined
|
|
68
68
|
keyData?: Hex.Hex | undefined
|
|
69
69
|
keyType?: 'p256' | 'secp256k1' | 'webAuthn' | undefined
|
|
70
|
-
|
|
71
|
-
owner?: Account |
|
|
70
|
+
accountSimulation?: AccountSimulation.Spec | undefined
|
|
71
|
+
owner?: Account | ConfigurableAccount | Address | undefined
|
|
72
72
|
signatures?: readonly unknown[] | undefined
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -76,18 +76,18 @@ export const chainConfig = {
|
|
|
76
76
|
if (
|
|
77
77
|
!request.account ||
|
|
78
78
|
typeof request.account === 'string' ||
|
|
79
|
-
request.account.source !== '
|
|
79
|
+
request.account.source !== 'configurable'
|
|
80
80
|
)
|
|
81
81
|
throw new Error(
|
|
82
|
-
'A local
|
|
82
|
+
'A local configurable account is required to approve a stored configurable account transaction.',
|
|
83
83
|
)
|
|
84
84
|
if (!request.owner || typeof request.owner === 'string')
|
|
85
85
|
throw new Error(
|
|
86
|
-
'A local owner account is required to approve a stored
|
|
86
|
+
'A local owner account is required to approve a stored configurable account transaction.',
|
|
87
87
|
)
|
|
88
88
|
if (request.owner.source !== 'root')
|
|
89
89
|
throw new Error(
|
|
90
|
-
'A Tempo owner account is required to approve a stored
|
|
90
|
+
'A Tempo owner account is required to approve a stored configurable account transaction.',
|
|
91
91
|
)
|
|
92
92
|
const transaction = await getAction(
|
|
93
93
|
client,
|
|
@@ -95,28 +95,28 @@ export const chainConfig = {
|
|
|
95
95
|
'getTransaction',
|
|
96
96
|
)({ hash: request.hash })
|
|
97
97
|
const operation =
|
|
98
|
-
'
|
|
99
|
-
? (transaction.
|
|
100
|
-
|
|
|
98
|
+
'operation' in transaction
|
|
99
|
+
? (transaction.operation as
|
|
100
|
+
| AccountOperation.TransactionOperation
|
|
101
101
|
| undefined)
|
|
102
102
|
: undefined
|
|
103
103
|
if (!operation)
|
|
104
|
-
throw new Error('Expected
|
|
104
|
+
throw new Error('Expected an account operation transaction.')
|
|
105
105
|
if (!isAddressEqual(operation.account, request.account.address))
|
|
106
106
|
throw new Error(
|
|
107
|
-
'
|
|
107
|
+
'Account operation account does not match the requested account.',
|
|
108
108
|
)
|
|
109
109
|
const storedTransaction = Transaction.deserialize(
|
|
110
110
|
operation.transaction as Transaction.TransactionSerializedTempo,
|
|
111
111
|
)
|
|
112
|
-
const hash =
|
|
112
|
+
const hash = AccountOperation.getHash({
|
|
113
113
|
account: operation.account,
|
|
114
114
|
config: operation.config,
|
|
115
115
|
transaction: operation.transaction,
|
|
116
116
|
type: 'transaction',
|
|
117
117
|
})
|
|
118
118
|
if (hash.toLowerCase() !== request.hash.toLowerCase())
|
|
119
|
-
throw new Error('
|
|
119
|
+
throw new Error('Account operation hash does not match transaction.')
|
|
120
120
|
return {
|
|
121
121
|
...storedTransaction,
|
|
122
122
|
// Serialized zero values must not trigger a new fill of an approved transaction.
|
|
@@ -125,7 +125,7 @@ export const chainConfig = {
|
|
|
125
125
|
maxPriorityFeePerGas: storedTransaction.maxPriorityFeePerGas ?? 0n,
|
|
126
126
|
account: request.account,
|
|
127
127
|
from: operation.account,
|
|
128
|
-
|
|
128
|
+
accountSimulation: getAccountSimulation({
|
|
129
129
|
config: operation.config,
|
|
130
130
|
local: request.account,
|
|
131
131
|
}),
|
|
@@ -151,40 +151,40 @@ export const chainConfig = {
|
|
|
151
151
|
return request as unknown as typeof r
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
const
|
|
155
|
-
if (request.account?.source === '
|
|
154
|
+
const configurableIdentity = (() => {
|
|
155
|
+
if (request.account?.source === 'configurable')
|
|
156
156
|
return {
|
|
157
157
|
account: request.account.address,
|
|
158
|
-
config: (request.account as
|
|
159
|
-
local: request.account as
|
|
158
|
+
config: (request.account as ConfigurableAccount).config,
|
|
159
|
+
local: request.account as ConfigurableAccount,
|
|
160
160
|
}
|
|
161
161
|
return undefined
|
|
162
162
|
})()
|
|
163
|
-
if (request.owner && !
|
|
163
|
+
if (request.owner && !configurableIdentity)
|
|
164
164
|
throw new Error(
|
|
165
|
-
'A
|
|
165
|
+
'A configurable account is required when an owner is provided.',
|
|
166
166
|
)
|
|
167
167
|
if (request.owner && typeof request.owner === 'string')
|
|
168
168
|
throw new Error(
|
|
169
|
-
'A local owner account is required to approve a
|
|
169
|
+
'A local owner account is required to approve a configurable account transaction.',
|
|
170
170
|
)
|
|
171
171
|
if (request.owner && request.owner.source !== 'root')
|
|
172
172
|
throw new Error(
|
|
173
|
-
'A Tempo owner account is required to approve a
|
|
173
|
+
'A Tempo owner account is required to approve a configurable account transaction.',
|
|
174
174
|
)
|
|
175
|
-
const
|
|
176
|
-
!!
|
|
175
|
+
const coordinated =
|
|
176
|
+
!!configurableIdentity &&
|
|
177
177
|
!!request.owner &&
|
|
178
|
-
(client.transport as {
|
|
179
|
-
if (
|
|
180
|
-
const { account, local } =
|
|
178
|
+
(client.transport as { accounts?: boolean }).accounts === true
|
|
179
|
+
if (configurableIdentity) {
|
|
180
|
+
const { account, local } = configurableIdentity
|
|
181
181
|
if (!account)
|
|
182
182
|
throw new Error(
|
|
183
|
-
'A
|
|
183
|
+
'A configurable account address is required with a current config.',
|
|
184
184
|
)
|
|
185
185
|
const config = await (async () => {
|
|
186
|
-
if (
|
|
187
|
-
if (!
|
|
186
|
+
if (configurableIdentity.config) return configurableIdentity.config
|
|
187
|
+
if (!coordinated) return undefined
|
|
188
188
|
const cachedConfig = await getAction(
|
|
189
189
|
client,
|
|
190
190
|
getConfig,
|
|
@@ -192,16 +192,16 @@ export const chainConfig = {
|
|
|
192
192
|
)({ address: account })
|
|
193
193
|
if (!cachedConfig)
|
|
194
194
|
throw new Error(
|
|
195
|
-
`No current
|
|
195
|
+
`No current account config is cached for account ${account}. Provide the current config.`,
|
|
196
196
|
)
|
|
197
197
|
return cachedConfig
|
|
198
198
|
})()
|
|
199
199
|
if (!config)
|
|
200
200
|
throw new Error(
|
|
201
|
-
'
|
|
201
|
+
'An account config is required to prepare a transaction.',
|
|
202
202
|
)
|
|
203
203
|
request.from = account
|
|
204
|
-
request.
|
|
204
|
+
request.accountSimulation = getAccountSimulation({
|
|
205
205
|
config,
|
|
206
206
|
local,
|
|
207
207
|
})
|
|
@@ -213,12 +213,12 @@ export const chainConfig = {
|
|
|
213
213
|
if (request.nonceKey === 'expiring' || request.nonceKey === maxUint256)
|
|
214
214
|
return true
|
|
215
215
|
if (typeof request.nonceKey !== 'undefined') return false
|
|
216
|
-
if (
|
|
216
|
+
if (configurableIdentity) return false
|
|
217
217
|
if (request.feePayer && typeof request.nonceKey === 'undefined')
|
|
218
218
|
return true
|
|
219
219
|
const account = request.account as
|
|
220
220
|
| Account
|
|
221
|
-
|
|
|
221
|
+
| ConfigurableAccount
|
|
222
222
|
| Address
|
|
223
223
|
| undefined
|
|
224
224
|
const address = typeof account === 'string' ? account : account?.address
|
|
@@ -227,7 +227,7 @@ export const chainConfig = {
|
|
|
227
227
|
return false
|
|
228
228
|
})()
|
|
229
229
|
|
|
230
|
-
if (
|
|
230
|
+
if (coordinated && typeof request.nonceKey === 'undefined') {
|
|
231
231
|
// A random nonce lane lets a stored approval ceremony remain valid
|
|
232
232
|
// indefinitely without blocking other pending operations.
|
|
233
233
|
request.nonceKey = Hex.toBigInt(Hex.random(31)) + 1n
|
|
@@ -294,17 +294,17 @@ export const chainConfig = {
|
|
|
294
294
|
transaction: serializeTransaction,
|
|
295
295
|
async transactionEnvelope({ serializedTransaction, transaction }) {
|
|
296
296
|
const request = transaction as Transaction.TransactionSerializableTempo
|
|
297
|
-
if (!request.
|
|
297
|
+
if (!request.accountSimulation) return serializedTransaction
|
|
298
298
|
try {
|
|
299
299
|
SignatureEnvelope.deserialize(serializedTransaction)
|
|
300
300
|
} catch {
|
|
301
301
|
const transaction = Transaction.deserialize(
|
|
302
302
|
serializedTransaction as Transaction.TransactionSerializedTempo,
|
|
303
303
|
)
|
|
304
|
-
if (transaction.signature?.type === '
|
|
304
|
+
if (transaction.signature?.type === 'configurable')
|
|
305
305
|
return serializedTransaction
|
|
306
306
|
throw new Error(
|
|
307
|
-
'A Tempo owner account is required to approve a
|
|
307
|
+
'A Tempo owner account is required to approve a configurable account transaction.',
|
|
308
308
|
)
|
|
309
309
|
}
|
|
310
310
|
return await serializeTransaction({
|
|
@@ -402,11 +402,11 @@ export const chainConfig = {
|
|
|
402
402
|
|
|
403
403
|
export type ChainConfig = typeof chainConfig
|
|
404
404
|
|
|
405
|
-
/** Builds a bounded
|
|
406
|
-
function
|
|
407
|
-
config:
|
|
408
|
-
local?:
|
|
409
|
-
}):
|
|
405
|
+
/** Builds a bounded account spec for gas simulation. */
|
|
406
|
+
function getAccountSimulation(options: {
|
|
407
|
+
config: AccountConfig.Config
|
|
408
|
+
local?: ConfigurableAccount | undefined
|
|
409
|
+
}): AccountSimulation.Spec {
|
|
410
410
|
const { config, local } = options
|
|
411
411
|
return {
|
|
412
412
|
approvals: selectOwners(config).map((owner) => {
|
|
@@ -453,7 +453,7 @@ function randomValidAfter(): number {
|
|
|
453
453
|
}
|
|
454
454
|
|
|
455
455
|
/** Selects a deterministic minimum-cardinality owner quorum. */
|
|
456
|
-
function selectOwners(config:
|
|
456
|
+
function selectOwners(config: AccountConfig.Config) {
|
|
457
457
|
const owners = [...config.owners].sort(
|
|
458
458
|
(a, b) =>
|
|
459
459
|
Number(b.weight) - Number(a.weight) ||
|
|
@@ -461,7 +461,7 @@ function selectOwners(config: MultisigConfig.Config) {
|
|
|
461
461
|
)
|
|
462
462
|
const selected: typeof owners = []
|
|
463
463
|
let weight = 0
|
|
464
|
-
for (const owner of owners.slice(0,
|
|
464
|
+
for (const owner of owners.slice(0, AccountConfig.maxSignatures)) {
|
|
465
465
|
if (weight >= Number(config.threshold)) break
|
|
466
466
|
selected.push(owner)
|
|
467
467
|
weight += Number(owner.weight)
|
package/tempo/errors.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import type { Address } from 'abitype'
|
|
1
|
+
import type { AbiError, Address } from 'abitype'
|
|
2
2
|
import type { Hex } from 'ox'
|
|
3
3
|
import { BaseError } from '../errors/base.js'
|
|
4
|
+
import { prettyPrint } from '../errors/transaction.js'
|
|
5
|
+
import type * as accessKey from './actions/accessKey.js'
|
|
6
|
+
import type * as amm from './actions/amm.js'
|
|
7
|
+
import type * as channel from './actions/channel.js'
|
|
8
|
+
import type * as dex from './actions/dex.js'
|
|
9
|
+
import type * as fee from './actions/fee.js'
|
|
10
|
+
import type * as nonce from './actions/nonce.js'
|
|
11
|
+
import type * as policy from './actions/policy.js'
|
|
12
|
+
import type * as token from './actions/token.js'
|
|
13
|
+
import type * as ExecutionError from './ExecutionError.js'
|
|
4
14
|
|
|
5
15
|
export type GetVaultEngineChangedErrorType = GetVaultEngineChangedError & {
|
|
6
16
|
name: 'GetVaultEngineChangedError'
|
|
@@ -138,3 +148,106 @@ export class FeeTokenPausedError extends BaseError {
|
|
|
138
148
|
})
|
|
139
149
|
}
|
|
140
150
|
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Errors thrown by Tempo actions for decoded Tempo precompile errors. Narrow with `error.name`,
|
|
154
|
+
* then `error.errorName` for the base `TempoExecutionError`.
|
|
155
|
+
*/
|
|
156
|
+
export type ExecutionErrorType =
|
|
157
|
+
| TempoExecutionErrorType
|
|
158
|
+
| accessKey.ExecutionErrorType
|
|
159
|
+
| amm.ExecutionErrorType
|
|
160
|
+
| channel.ExecutionErrorType
|
|
161
|
+
| dex.ExecutionErrorType
|
|
162
|
+
| fee.ExecutionErrorType
|
|
163
|
+
| nonce.ExecutionErrorType
|
|
164
|
+
| policy.ExecutionErrorType
|
|
165
|
+
| token.ExecutionErrorType
|
|
166
|
+
|
|
167
|
+
/** Union of `TempoExecutionError` per decoded error, so `errorName` narrows `args`. */
|
|
168
|
+
export type TempoExecutionErrorType<
|
|
169
|
+
decoded extends TempoExecutionError.Decoded = TempoExecutionError.Decoded,
|
|
170
|
+
> = decoded extends TempoExecutionError.Decoded
|
|
171
|
+
? TempoExecutionError<decoded> & { name: 'TempoExecutionError' }
|
|
172
|
+
: never
|
|
173
|
+
|
|
174
|
+
/** Thrown when a Tempo action fails with a decoded Tempo precompile error. */
|
|
175
|
+
export class TempoExecutionError<
|
|
176
|
+
decoded extends TempoExecutionError.Decoded = TempoExecutionError.Decoded,
|
|
177
|
+
> extends BaseError {
|
|
178
|
+
/** ABI item of the error. */
|
|
179
|
+
abiItem: AbiError
|
|
180
|
+
/** Decoded error arguments, when the revert data carried them. */
|
|
181
|
+
args: decoded['args']
|
|
182
|
+
/** Revert data, or the error selector when only the name is known. */
|
|
183
|
+
data: Hex.Hex
|
|
184
|
+
/** Error name from `Abis.coreErrors`. */
|
|
185
|
+
errorName: decoded['errorName']
|
|
186
|
+
/** Steps to resolve the error. */
|
|
187
|
+
hints: readonly string[]
|
|
188
|
+
|
|
189
|
+
constructor(
|
|
190
|
+
{ cause, error, hints }: TempoExecutionError.Parameters,
|
|
191
|
+
{
|
|
192
|
+
details,
|
|
193
|
+
docsPath,
|
|
194
|
+
name = 'TempoExecutionError',
|
|
195
|
+
shortMessage = error.message,
|
|
196
|
+
}: TempoExecutionError.Options = {},
|
|
197
|
+
) {
|
|
198
|
+
// Keep the call or request summary from the original error.
|
|
199
|
+
const summary = cause.metaMessages?.findIndex((message) =>
|
|
200
|
+
/^(Contract Call|Request Arguments):/.test(message),
|
|
201
|
+
)
|
|
202
|
+
super(shortMessage, {
|
|
203
|
+
cause,
|
|
204
|
+
docsPath,
|
|
205
|
+
metaMessages: [
|
|
206
|
+
...(details ? [prettyPrint(details), ' '] : []),
|
|
207
|
+
...(hints.length
|
|
208
|
+
? ['How to fix:', ...hints.map((hint) => `- ${hint}`), ' ']
|
|
209
|
+
: []),
|
|
210
|
+
...(summary !== undefined && summary >= 0
|
|
211
|
+
? cause.metaMessages!.slice(summary)
|
|
212
|
+
: []),
|
|
213
|
+
],
|
|
214
|
+
name,
|
|
215
|
+
})
|
|
216
|
+
this.abiItem = error.abiItem as AbiError
|
|
217
|
+
// Subclasses narrow `decoded` to the error they are built for.
|
|
218
|
+
this.args = error.args as decoded['args']
|
|
219
|
+
this.data = error.data
|
|
220
|
+
this.errorName = error.errorName as decoded['errorName']
|
|
221
|
+
this.hints = hints
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export declare namespace TempoExecutionError {
|
|
226
|
+
/** Decoded Tempo error, optionally narrowed to `name`. */
|
|
227
|
+
type Decoded<name extends string = string> = Extract<
|
|
228
|
+
Exclude<ExecutionError.ExecutionError, { errorName: 'unknown' }>,
|
|
229
|
+
{ errorName: name }
|
|
230
|
+
>
|
|
231
|
+
/** Name of any decoded Tempo error. */
|
|
232
|
+
type ErrorName = Decoded['errorName']
|
|
233
|
+
/** Message options for subclasses. */
|
|
234
|
+
type Options = {
|
|
235
|
+
/** Rows printed below the short message. Empty values are omitted. */
|
|
236
|
+
details?: Record<string, unknown> | undefined
|
|
237
|
+
/** Documentation path. */
|
|
238
|
+
docsPath?: string | undefined
|
|
239
|
+
/** Error name. Defaults to `TempoExecutionError`. */
|
|
240
|
+
name?: string | undefined
|
|
241
|
+
/** Short message. Defaults to the decoded error message. */
|
|
242
|
+
shortMessage?: string | undefined
|
|
243
|
+
}
|
|
244
|
+
/** Constructor parameters. */
|
|
245
|
+
type Parameters = {
|
|
246
|
+
/** Original error. */
|
|
247
|
+
cause: BaseError
|
|
248
|
+
/** Decoded Tempo error. */
|
|
249
|
+
error: Decoded
|
|
250
|
+
/** Steps to resolve the error. */
|
|
251
|
+
hints: readonly string[]
|
|
252
|
+
}
|
|
253
|
+
}
|
package/tempo/index.ts
CHANGED
|
@@ -12,10 +12,10 @@ export type {
|
|
|
12
12
|
TxEnvelopeTempo as z_TxEnvelopeTempo,
|
|
13
13
|
} from 'ox/tempo'
|
|
14
14
|
export {
|
|
15
|
+
AccountConfig,
|
|
16
|
+
AccountOperation,
|
|
15
17
|
Channel,
|
|
16
18
|
EarnShares,
|
|
17
|
-
MultisigConfig,
|
|
18
|
-
MultisigOperation,
|
|
19
19
|
Period,
|
|
20
20
|
ReceivePolicyReceipt,
|
|
21
21
|
TempoAddress,
|
|
@@ -26,8 +26,8 @@ export {
|
|
|
26
26
|
} from 'ox/tempo'
|
|
27
27
|
export type {
|
|
28
28
|
/** @deprecated */
|
|
29
|
-
Owner as
|
|
30
|
-
} from 'ox/tempo/
|
|
29
|
+
Owner as z_AccountConfigOwner,
|
|
30
|
+
} from 'ox/tempo/AccountConfig'
|
|
31
31
|
export {
|
|
32
32
|
type CustomTransport,
|
|
33
33
|
type CustomTransportConfig,
|
|
@@ -73,6 +73,7 @@ export * as Expiry from './Expiry.js'
|
|
|
73
73
|
export * from './errors.js'
|
|
74
74
|
export * as Formatters from './Formatters.js'
|
|
75
75
|
export * as Hardfork from './Hardfork.js'
|
|
76
|
+
/** Client-side storage for pending key authorizations, backed by a `Store`. */
|
|
76
77
|
export * as KeyAuthorizationManager from './KeyAuthorizationManager.js'
|
|
77
78
|
export * as P256 from './P256.js'
|
|
78
79
|
/**
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { Address } from 'abitype'
|
|
2
|
+
import { TokenId } from 'ox/tempo'
|
|
3
|
+
import type {
|
|
4
|
+
MulticallParameters,
|
|
5
|
+
MulticallReturnType,
|
|
6
|
+
} from '../../actions/public/multicall.js'
|
|
7
|
+
import type { Client } from '../../clients/createClient.js'
|
|
8
|
+
import { formatUnits } from '../../utils/unit/formatUnits.js'
|
|
9
|
+
import type * as ExecutionError from '../ExecutionError.js'
|
|
10
|
+
import type { TempoExecutionError } from '../errors.js'
|
|
11
|
+
|
|
12
|
+
/** Action-specific steps to resolve errors, keyed by error name. Listed before the default steps. */
|
|
13
|
+
export type Hints = {
|
|
14
|
+
[name in TempoExecutionError.ErrorName]?: readonly string[]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Builds a specific error for a decoded Tempo error, or returns `undefined` when it does not apply. */
|
|
18
|
+
type Resolver = (
|
|
19
|
+
context: Context,
|
|
20
|
+
) => Promise<TempoExecutionError | undefined> | TempoExecutionError | undefined
|
|
21
|
+
|
|
22
|
+
/** Resolvers keyed by error signature. */
|
|
23
|
+
export type Resolvers = {
|
|
24
|
+
[signature in keyof typeof ExecutionError.messages]?: Resolver
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type Context = {
|
|
28
|
+
/** Parameters for the base `TempoExecutionError`. */
|
|
29
|
+
base: TempoExecutionError.Parameters
|
|
30
|
+
client: Client
|
|
31
|
+
/** Signer, with its access key when signing with one. */
|
|
32
|
+
signer: { address: Address; accessKey: Address | undefined } | undefined
|
|
33
|
+
/** Contract call that failed, when the action made one. */
|
|
34
|
+
call:
|
|
35
|
+
| {
|
|
36
|
+
address: Address
|
|
37
|
+
args: readonly unknown[]
|
|
38
|
+
functionName: string
|
|
39
|
+
/** Reads an argument by its ABI input name. */
|
|
40
|
+
arg: <type = unknown>(name: string) => type | undefined
|
|
41
|
+
}
|
|
42
|
+
| undefined
|
|
43
|
+
/** Whether the error came from transaction validation or fee payment rather than a revert. */
|
|
44
|
+
validation: boolean
|
|
45
|
+
/** Raw node message. */
|
|
46
|
+
details: string
|
|
47
|
+
parameters: Record<string, any>
|
|
48
|
+
/** Multicall with `allowFailure: true`. Resolves an empty array when the request fails. */
|
|
49
|
+
read: <const contracts extends readonly unknown[]>(
|
|
50
|
+
contracts: MulticallParameters<contracts>['contracts'],
|
|
51
|
+
) => Promise<Partial<MulticallReturnType<contracts, true>>>
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Wraps an action so failures with a decoded Tempo error throw a {@link TempoExecutionError}.
|
|
56
|
+
* Other errors are rethrown unchanged.
|
|
57
|
+
*
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
export function withExecutionError<
|
|
61
|
+
action extends (client: any, parameters: any) => Promise<any>,
|
|
62
|
+
>(action: action, options: { hints?: Hints | undefined } = {}): action {
|
|
63
|
+
return (async (client: Client, parameters: Record<string, any>) => {
|
|
64
|
+
try {
|
|
65
|
+
return await action(client, parameters)
|
|
66
|
+
} catch (error) {
|
|
67
|
+
// Loaded on failure only, so resolvers and error tables stay out of the success path.
|
|
68
|
+
const { toExecutionError } = await import('./resolveError.js')
|
|
69
|
+
throw await toExecutionError(error, { ...options, client, parameters })
|
|
70
|
+
}
|
|
71
|
+
}) as action
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Fee token from the action parameters or chain, when set. */
|
|
75
|
+
export function getFeeToken(context: Context) {
|
|
76
|
+
const feeToken =
|
|
77
|
+
context.parameters.feeToken ??
|
|
78
|
+
(
|
|
79
|
+
context.client.chain as
|
|
80
|
+
| { feeToken?: TokenId.TokenIdOrAddress }
|
|
81
|
+
| undefined
|
|
82
|
+
)?.feeToken
|
|
83
|
+
return feeToken === undefined || feeToken === null
|
|
84
|
+
? undefined
|
|
85
|
+
: TokenId.toAddress(feeToken)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Whether `address` is a TIP-20 token. */
|
|
89
|
+
export function isTip20(address: Address | undefined): address is Address {
|
|
90
|
+
return !!address?.toLowerCase().startsWith('0x20c0')
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Formats an amount as `formatted (raw)` when decimals are known. */
|
|
94
|
+
export function formatAmount(
|
|
95
|
+
value: bigint | undefined,
|
|
96
|
+
decimals: number | undefined,
|
|
97
|
+
) {
|
|
98
|
+
if (value === undefined) return undefined
|
|
99
|
+
if (decimals === undefined) return value.toString()
|
|
100
|
+
return `${formatUnits(value, decimals)} (${value})`
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Formats Unix seconds as an ISO 8601 string. */
|
|
104
|
+
export function formatTime(seconds: bigint | number | undefined) {
|
|
105
|
+
if (!seconds) return undefined
|
|
106
|
+
const milliseconds = Number(seconds) * 1000
|
|
107
|
+
// `Date` cannot represent times past ±8.64e15 milliseconds.
|
|
108
|
+
if (!(Math.abs(milliseconds) <= 8.64e15)) return seconds.toString()
|
|
109
|
+
return new Date(milliseconds).toISOString()
|
|
110
|
+
}
|