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,11 +1,7 @@
|
|
|
1
1
|
import type { Address } from 'abitype'
|
|
2
2
|
import type * as Hex from 'ox/Hex'
|
|
3
3
|
import type * as RpcSchema from 'ox/RpcSchema'
|
|
4
|
-
import {
|
|
5
|
-
MultisigConfig,
|
|
6
|
-
MultisigOperation,
|
|
7
|
-
type RpcSchemaTempo,
|
|
8
|
-
} from 'ox/tempo'
|
|
4
|
+
import { AccountConfig, AccountOperation, type RpcSchemaTempo } from 'ox/tempo'
|
|
9
5
|
import type { Account } from '../../accounts/types.js'
|
|
10
6
|
import type { ReadContractReturnType } from '../../actions/public/readContract.js'
|
|
11
7
|
import { readContract } from '../../actions/public/readContract.js'
|
|
@@ -20,14 +16,16 @@ import type { Log } from '../../types/log.js'
|
|
|
20
16
|
import type { Compute } from '../../types/utils.js'
|
|
21
17
|
import { parseEventLogs } from '../../utils/abi/parseEventLogs.js'
|
|
22
18
|
import * as Abis from '../Abis.js'
|
|
23
|
-
import {
|
|
19
|
+
import { type ConfigurableAccount, fromConfig } from '../Account.js'
|
|
24
20
|
import * as Addresses from '../Addresses.js'
|
|
21
|
+
import type * as Errors from '../errors.js'
|
|
22
|
+
import { withExecutionError } from '../internal/errors.js'
|
|
25
23
|
import type { ReadParameters, WriteParameters } from '../internal/types.js'
|
|
26
24
|
import { defineCall } from '../internal/utils.js'
|
|
27
25
|
import type * as Transaction from '../Transaction.js'
|
|
28
26
|
|
|
29
27
|
/**
|
|
30
|
-
* Gets the current cached config for a
|
|
28
|
+
* Gets the current cached config for a configurable account.
|
|
31
29
|
*
|
|
32
30
|
* The coordinator reads the account's current onchain commitment and returns
|
|
33
31
|
* the matching config from its store. It returns `null` when the config is not
|
|
@@ -35,7 +33,7 @@ import type * as Transaction from '../Transaction.js'
|
|
|
35
33
|
*
|
|
36
34
|
* @example
|
|
37
35
|
* ```ts
|
|
38
|
-
* const config = await client.
|
|
36
|
+
* const config = await client.accounts.getConfig({
|
|
39
37
|
* address: '0x...',
|
|
40
38
|
* })
|
|
41
39
|
* ```
|
|
@@ -49,32 +47,32 @@ export async function getConfig(
|
|
|
49
47
|
parameters: getConfig.Parameters,
|
|
50
48
|
): Promise<getConfig.ReturnValue> {
|
|
51
49
|
const config = await client.request<{
|
|
52
|
-
Method: '
|
|
50
|
+
Method: 'account_getConfig'
|
|
53
51
|
Parameters: [{ address: Address }]
|
|
54
|
-
ReturnType:
|
|
52
|
+
ReturnType: AccountConfig.Rpc | null
|
|
55
53
|
}>({
|
|
56
|
-
method: '
|
|
54
|
+
method: 'account_getConfig',
|
|
57
55
|
params: [{ address: parameters.address }],
|
|
58
56
|
})
|
|
59
|
-
return config ?
|
|
57
|
+
return config ? AccountConfig.fromRpc(config) : null
|
|
60
58
|
}
|
|
61
59
|
|
|
62
60
|
export declare namespace getConfig {
|
|
63
61
|
/** Parameters for {@link getConfig}. */
|
|
64
62
|
export type Parameters = {
|
|
65
|
-
/**
|
|
63
|
+
/** Configurable account address. */
|
|
66
64
|
address: Address
|
|
67
65
|
}
|
|
68
66
|
|
|
69
67
|
/** Return value for {@link getConfig}. */
|
|
70
|
-
export type ReturnValue =
|
|
68
|
+
export type ReturnValue = AccountConfig.Config | null
|
|
71
69
|
|
|
72
70
|
/** Error type for {@link getConfig}. */
|
|
73
71
|
export type ErrorType = BaseErrorType
|
|
74
72
|
}
|
|
75
73
|
|
|
76
74
|
/**
|
|
77
|
-
* Gets the current configuration commitment for a
|
|
75
|
+
* Gets the current configuration commitment for a configurable account.
|
|
78
76
|
*
|
|
79
77
|
* @example
|
|
80
78
|
* ```ts
|
|
@@ -87,7 +85,7 @@ export declare namespace getConfig {
|
|
|
87
85
|
* transport: http(),
|
|
88
86
|
* })
|
|
89
87
|
*
|
|
90
|
-
* const commitment = await Actions.
|
|
88
|
+
* const commitment = await Actions.accounts.getConfigCommitment(client, {
|
|
91
89
|
* account: '0x...',
|
|
92
90
|
* })
|
|
93
91
|
* ```
|
|
@@ -105,7 +103,7 @@ export async function getConfigCommitment<
|
|
|
105
103
|
parameters: getConfigCommitment.Parameters,
|
|
106
104
|
): Promise<getConfigCommitment.ReturnValue> {
|
|
107
105
|
const { account, ...rest } = parameters
|
|
108
|
-
return readContract(client, {
|
|
106
|
+
return withExecutionError(readContract)(client, {
|
|
109
107
|
...rest,
|
|
110
108
|
...getConfigCommitment.call({ account }),
|
|
111
109
|
})
|
|
@@ -115,7 +113,7 @@ export namespace getConfigCommitment {
|
|
|
115
113
|
export type Parameters = ReadParameters & Args
|
|
116
114
|
|
|
117
115
|
export type Args = {
|
|
118
|
-
/** Initialized
|
|
116
|
+
/** Initialized configurable account address. */
|
|
119
117
|
account: Address
|
|
120
118
|
}
|
|
121
119
|
|
|
@@ -141,10 +139,12 @@ export namespace getConfigCommitment {
|
|
|
141
139
|
functionName: 'getConfigCommitment',
|
|
142
140
|
})
|
|
143
141
|
}
|
|
142
|
+
|
|
143
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
/**
|
|
147
|
-
* Gets a coordinated
|
|
147
|
+
* Gets a coordinated account operation by its hash.
|
|
148
148
|
*
|
|
149
149
|
* @param client - Client.
|
|
150
150
|
* @param parameters - Parameters.
|
|
@@ -154,33 +154,33 @@ export async function getOperation(
|
|
|
154
154
|
client: Client,
|
|
155
155
|
parameters: getOperation.Parameters,
|
|
156
156
|
): Promise<getOperation.ReturnValue> {
|
|
157
|
-
type
|
|
158
|
-
RpcSchema.ToViem<RpcSchemaTempo.
|
|
159
|
-
{ Method: '
|
|
157
|
+
type account_getOperation = Extract<
|
|
158
|
+
RpcSchema.ToViem<RpcSchemaTempo.Account>[number],
|
|
159
|
+
{ Method: 'account_getOperation' }
|
|
160
160
|
>
|
|
161
|
-
const operation = await client.request<
|
|
162
|
-
method: '
|
|
161
|
+
const operation = await client.request<account_getOperation>({
|
|
162
|
+
method: 'account_getOperation',
|
|
163
163
|
params: [parameters.hash],
|
|
164
164
|
})
|
|
165
|
-
return operation ?
|
|
165
|
+
return operation ? AccountOperation.fromRpc(operation) : null
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
export declare namespace getOperation {
|
|
169
169
|
/** Parameters for {@link getOperation}. */
|
|
170
170
|
export type Parameters = {
|
|
171
|
-
/**
|
|
171
|
+
/** Account operation hash. */
|
|
172
172
|
hash: Hex.Hex
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
/** Return value for {@link getOperation}. */
|
|
176
|
-
export type ReturnValue =
|
|
176
|
+
export type ReturnValue = AccountOperation.Operation | null
|
|
177
177
|
|
|
178
178
|
/** Error type for {@link getOperation}. */
|
|
179
179
|
export type ErrorType = BaseErrorType
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
/**
|
|
183
|
-
* Replaces the current configuration for a
|
|
183
|
+
* Replaces the current configuration for a configurable account.
|
|
184
184
|
*
|
|
185
185
|
* The transaction must be authorized directly by the account's current owner
|
|
186
186
|
* quorum. Local owner-signing flows can include {@link updateConfig.call} in a
|
|
@@ -196,7 +196,7 @@ export declare namespace getOperation {
|
|
|
196
196
|
* const owner = Account.fromSecp256k1(
|
|
197
197
|
* '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
|
|
198
198
|
* )
|
|
199
|
-
* const account = Account.
|
|
199
|
+
* const account = Account.fromConfig({
|
|
200
200
|
* address: 'infer',
|
|
201
201
|
* owners: [owner],
|
|
202
202
|
* })
|
|
@@ -210,7 +210,7 @@ export declare namespace getOperation {
|
|
|
210
210
|
* to: account.address,
|
|
211
211
|
* })
|
|
212
212
|
*
|
|
213
|
-
* const hash = await Actions.
|
|
213
|
+
* const hash = await Actions.accounts.updateConfig(client, {
|
|
214
214
|
* account,
|
|
215
215
|
* nextConfig: {
|
|
216
216
|
* owners: [{ owner: owner.address, weight: 1 }],
|
|
@@ -239,22 +239,22 @@ export namespace updateConfig {
|
|
|
239
239
|
account extends Account | undefined = Account | undefined,
|
|
240
240
|
> = WriteParameters<chain, account> & {
|
|
241
241
|
/** Complete current config. Inferred from the account or coordinator when omitted. */
|
|
242
|
-
currentConfig?:
|
|
242
|
+
currentConfig?: AccountConfig.Config | undefined
|
|
243
243
|
/** Replacement owners and threshold. */
|
|
244
|
-
nextConfig: Pick<
|
|
244
|
+
nextConfig: Pick<AccountConfig.Config, 'owners' | 'threshold'>
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
export type Args = {
|
|
248
248
|
/** Complete current config. */
|
|
249
|
-
currentConfig:
|
|
249
|
+
currentConfig: AccountConfig.Config
|
|
250
250
|
/** Replacement owners and threshold. */
|
|
251
|
-
nextConfig: Pick<
|
|
251
|
+
nextConfig: Pick<AccountConfig.Config, 'owners' | 'threshold'>
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
export type ReturnValue = WriteContractReturnType
|
|
255
255
|
|
|
256
256
|
// TODO: exhaustive error type
|
|
257
|
-
export type ErrorType = BaseErrorType
|
|
257
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
258
258
|
|
|
259
259
|
/** @internal */
|
|
260
260
|
export async function inner<
|
|
@@ -276,9 +276,9 @@ export namespace updateConfig {
|
|
|
276
276
|
const account = (() => {
|
|
277
277
|
if (
|
|
278
278
|
typeof accountValue === 'object' &&
|
|
279
|
-
accountValue.source === '
|
|
279
|
+
accountValue.source === 'configurable'
|
|
280
280
|
)
|
|
281
|
-
return accountValue as
|
|
281
|
+
return accountValue as ConfigurableAccount
|
|
282
282
|
return undefined
|
|
283
283
|
})()
|
|
284
284
|
const config = (() => {
|
|
@@ -293,25 +293,25 @@ export namespace updateConfig {
|
|
|
293
293
|
return undefined
|
|
294
294
|
})()
|
|
295
295
|
const currentConfig = await (async () => {
|
|
296
|
-
if (config) return
|
|
296
|
+
if (config) return AccountConfig.from(config)
|
|
297
297
|
if (!address)
|
|
298
298
|
throw new Error(
|
|
299
|
-
'A
|
|
299
|
+
'A configurable account address or current config is required.',
|
|
300
300
|
)
|
|
301
301
|
const cachedConfig = await getConfig(client, { address })
|
|
302
302
|
if (!cachedConfig)
|
|
303
303
|
throw new Error(
|
|
304
|
-
`No current
|
|
304
|
+
`No current account config is cached for account ${address}. Provide the current config.`,
|
|
305
305
|
)
|
|
306
306
|
return cachedConfig
|
|
307
307
|
})()
|
|
308
308
|
const resolvedAccount = (() => {
|
|
309
309
|
if (account) return { ...account, config: currentConfig }
|
|
310
310
|
if (typeof accountValue === 'object') return accountValue
|
|
311
|
-
if (address) return
|
|
311
|
+
if (address) return fromConfig({ address, ...currentConfig })
|
|
312
312
|
return undefined
|
|
313
313
|
})()
|
|
314
|
-
return (await action(client, {
|
|
314
|
+
return (await withExecutionError(action)(client, {
|
|
315
315
|
...rest,
|
|
316
316
|
...(resolvedAccount ? { account: resolvedAccount } : {}),
|
|
317
317
|
...updateConfig.call({ currentConfig, nextConfig }),
|
|
@@ -328,11 +328,11 @@ export namespace updateConfig {
|
|
|
328
328
|
*
|
|
329
329
|
* @example
|
|
330
330
|
* ```ts
|
|
331
|
-
* import { Actions, type
|
|
331
|
+
* import { Actions, type AccountConfig } from 'viem/tempo'
|
|
332
332
|
*
|
|
333
|
-
* declare const currentConfig:
|
|
333
|
+
* declare const currentConfig: AccountConfig.Config
|
|
334
334
|
*
|
|
335
|
-
* const call = Actions.
|
|
335
|
+
* const call = Actions.accounts.updateConfig.call({
|
|
336
336
|
* currentConfig,
|
|
337
337
|
* nextConfig: {
|
|
338
338
|
* owners: [{ owner: '0x...', weight: 1 }],
|
|
@@ -341,17 +341,12 @@ export namespace updateConfig {
|
|
|
341
341
|
* })
|
|
342
342
|
* ```
|
|
343
343
|
*
|
|
344
|
-
* @param args - Current and replacement
|
|
344
|
+
* @param args - Current and replacement account configurations.
|
|
345
345
|
* @returns The call.
|
|
346
346
|
*/
|
|
347
347
|
export function call(args: Args) {
|
|
348
|
-
const currentConfig =
|
|
349
|
-
const nextConfig =
|
|
350
|
-
owners: args.nextConfig.owners,
|
|
351
|
-
salt: currentConfig.salt,
|
|
352
|
-
threshold: args.nextConfig.threshold,
|
|
353
|
-
version: currentConfig.version + 1n,
|
|
354
|
-
})
|
|
348
|
+
const currentConfig = AccountConfig.from(args.currentConfig)
|
|
349
|
+
const nextConfig = AccountConfig.update(currentConfig, args.nextConfig)
|
|
355
350
|
return defineCall({
|
|
356
351
|
address: Addresses.nativeMultisig,
|
|
357
352
|
abi: Abis.nativeMultisig,
|
|
@@ -379,16 +374,16 @@ export namespace updateConfig {
|
|
|
379
374
|
}
|
|
380
375
|
|
|
381
376
|
/**
|
|
382
|
-
* Replaces a
|
|
377
|
+
* Replaces a configurable account configuration and waits for confirmation.
|
|
383
378
|
*
|
|
384
379
|
* @example
|
|
385
380
|
* ```ts
|
|
386
381
|
* import { createWalletClient, custom, type EIP1193Provider } from 'viem'
|
|
387
382
|
* import { tempo } from 'viem/chains'
|
|
388
|
-
* import { Actions, type
|
|
383
|
+
* import { Actions, type AccountConfig } from 'viem/tempo'
|
|
389
384
|
*
|
|
390
385
|
* declare const provider: EIP1193Provider
|
|
391
|
-
* declare const currentConfig:
|
|
386
|
+
* declare const currentConfig: AccountConfig.Config
|
|
392
387
|
*
|
|
393
388
|
* const client = createWalletClient({
|
|
394
389
|
* account: '0x...',
|
|
@@ -396,7 +391,7 @@ export namespace updateConfig {
|
|
|
396
391
|
* transport: custom(provider),
|
|
397
392
|
* })
|
|
398
393
|
*
|
|
399
|
-
* const { receipt } = await Actions.
|
|
394
|
+
* const { receipt } = await Actions.accounts.updateConfigSync(client, {
|
|
400
395
|
* currentConfig,
|
|
401
396
|
* nextConfig: {
|
|
402
397
|
* owners: [{ owner: '0x...', weight: 1 }],
|
|
@@ -426,7 +421,7 @@ export async function updateConfigSync<
|
|
|
426
421
|
const { args } = updateConfig.extractEvent(receipt.logs)
|
|
427
422
|
return {
|
|
428
423
|
account: args.account,
|
|
429
|
-
config:
|
|
424
|
+
config: AccountConfig.from({
|
|
430
425
|
owners: args.owners,
|
|
431
426
|
salt: args.salt,
|
|
432
427
|
threshold: args.threshold,
|
|
@@ -446,7 +441,7 @@ export namespace updateConfigSync {
|
|
|
446
441
|
|
|
447
442
|
export type ReturnValue = Compute<{
|
|
448
443
|
account: Address
|
|
449
|
-
config:
|
|
444
|
+
config: AccountConfig.Config
|
|
450
445
|
receipt: Transaction.TransactionReceipt
|
|
451
446
|
}>
|
|
452
447
|
|
package/tempo/actions/amm.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { writeContract } from '../../actions/wallet/writeContract.js'
|
|
|
12
12
|
import { writeContractSync } from '../../actions/wallet/writeContractSync.js'
|
|
13
13
|
import type { Client } from '../../clients/createClient.js'
|
|
14
14
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
|
15
|
+
import type { BaseErrorType } from '../../errors/base.js'
|
|
15
16
|
import type { Chain } from '../../types/chain.js'
|
|
16
17
|
import type { ExtractAbiItem, GetEventArgs } from '../../types/contract.js'
|
|
17
18
|
import type { Log, Log as viem_Log } from '../../types/log.js'
|
|
@@ -19,8 +20,16 @@ import type { Hex } from '../../types/misc.js'
|
|
|
19
20
|
import type { TransactionReceipt } from '../../types/transaction.js'
|
|
20
21
|
import type { Compute, OneOf, UnionOmit } from '../../types/utils.js'
|
|
21
22
|
import { parseEventLogs } from '../../utils/abi/parseEventLogs.js'
|
|
23
|
+
import { isAddressEqual } from '../../utils/address/isAddressEqual.js'
|
|
22
24
|
import * as Abis from '../Abis.js'
|
|
23
25
|
import * as Addresses from '../Addresses.js'
|
|
26
|
+
import type * as Errors from '../errors.js'
|
|
27
|
+
import { TempoExecutionError } from '../errors.js'
|
|
28
|
+
import {
|
|
29
|
+
type Context,
|
|
30
|
+
type Resolvers,
|
|
31
|
+
withExecutionError,
|
|
32
|
+
} from '../internal/errors.js'
|
|
24
33
|
import type { ReadParameters, WriteParameters } from '../internal/types.js'
|
|
25
34
|
import { defineCall } from '../internal/utils.js'
|
|
26
35
|
import type { TransactionReceipt as TempoTransactionReceipt } from '../Transaction.js'
|
|
@@ -149,7 +158,7 @@ export async function getLiquidityBalance<chain extends Chain | undefined>(
|
|
|
149
158
|
parameters: getLiquidityBalance.Parameters,
|
|
150
159
|
): Promise<getLiquidityBalance.ReturnValue> {
|
|
151
160
|
const { address, poolId, userToken, validatorToken, ...rest } = parameters
|
|
152
|
-
return readContract(client, {
|
|
161
|
+
return withExecutionError(readContract)(client, {
|
|
153
162
|
...rest,
|
|
154
163
|
...getLiquidityBalance.call({
|
|
155
164
|
address,
|
|
@@ -211,6 +220,8 @@ export namespace getLiquidityBalance {
|
|
|
211
220
|
functionName: 'liquidityBalances',
|
|
212
221
|
})
|
|
213
222
|
}
|
|
223
|
+
|
|
224
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
214
225
|
}
|
|
215
226
|
|
|
216
227
|
/**
|
|
@@ -287,7 +298,7 @@ export namespace rebalanceSwap {
|
|
|
287
298
|
amountOut,
|
|
288
299
|
to,
|
|
289
300
|
})
|
|
290
|
-
return (await action(client, {
|
|
301
|
+
return (await withExecutionError(action)(client, {
|
|
291
302
|
...rest,
|
|
292
303
|
...call,
|
|
293
304
|
} as never)) as never
|
|
@@ -364,6 +375,9 @@ export namespace rebalanceSwap {
|
|
|
364
375
|
if (!log) throw new Error('`RebalanceSwap` event not found.')
|
|
365
376
|
return log
|
|
366
377
|
}
|
|
378
|
+
|
|
379
|
+
// TODO: exhaustive error type
|
|
380
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
367
381
|
}
|
|
368
382
|
|
|
369
383
|
/**
|
|
@@ -433,6 +447,8 @@ export namespace rebalanceSwapSync {
|
|
|
433
447
|
receipt: TransactionReceipt
|
|
434
448
|
}
|
|
435
449
|
>
|
|
450
|
+
|
|
451
|
+
export type ErrorType = rebalanceSwap.ErrorType
|
|
436
452
|
}
|
|
437
453
|
|
|
438
454
|
/**
|
|
@@ -515,7 +531,7 @@ export namespace mint {
|
|
|
515
531
|
validatorTokenAddress,
|
|
516
532
|
validatorTokenAmount,
|
|
517
533
|
})
|
|
518
|
-
return (await action(client, {
|
|
534
|
+
return (await withExecutionError(action)(client, {
|
|
519
535
|
...rest,
|
|
520
536
|
...call,
|
|
521
537
|
} as never)) as never
|
|
@@ -597,6 +613,9 @@ export namespace mint {
|
|
|
597
613
|
if (!log) throw new Error('`Mint` event not found.')
|
|
598
614
|
return log
|
|
599
615
|
}
|
|
616
|
+
|
|
617
|
+
// TODO: exhaustive error type
|
|
618
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
600
619
|
}
|
|
601
620
|
|
|
602
621
|
/**
|
|
@@ -666,6 +685,8 @@ export namespace mintSync {
|
|
|
666
685
|
receipt: TransactionReceipt
|
|
667
686
|
}
|
|
668
687
|
>
|
|
688
|
+
|
|
689
|
+
export type ErrorType = mint.ErrorType
|
|
669
690
|
}
|
|
670
691
|
|
|
671
692
|
/**
|
|
@@ -737,7 +758,7 @@ export namespace burn {
|
|
|
737
758
|
): Promise<ReturnType<action>> {
|
|
738
759
|
const { liquidity, to, userToken, validatorToken, ...rest } = parameters
|
|
739
760
|
const call = burn.call({ liquidity, to, userToken, validatorToken })
|
|
740
|
-
return (await action(client, {
|
|
761
|
+
return (await withExecutionError(action)(client, {
|
|
741
762
|
...rest,
|
|
742
763
|
...call,
|
|
743
764
|
} as never)) as never
|
|
@@ -814,6 +835,9 @@ export namespace burn {
|
|
|
814
835
|
if (!log) throw new Error('`Burn` event not found.')
|
|
815
836
|
return log
|
|
816
837
|
}
|
|
838
|
+
|
|
839
|
+
// TODO: exhaustive error type
|
|
840
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
817
841
|
}
|
|
818
842
|
|
|
819
843
|
/**
|
|
@@ -883,6 +907,8 @@ export namespace burnSync {
|
|
|
883
907
|
receipt: TransactionReceipt
|
|
884
908
|
}
|
|
885
909
|
>
|
|
910
|
+
|
|
911
|
+
export type ErrorType = burn.ErrorType
|
|
886
912
|
}
|
|
887
913
|
|
|
888
914
|
/**
|
|
@@ -1124,3 +1150,99 @@ export declare namespace watchBurn {
|
|
|
1124
1150
|
validatorToken?: TokenId.TokenIdOrAddress | undefined
|
|
1125
1151
|
}
|
|
1126
1152
|
}
|
|
1153
|
+
|
|
1154
|
+
// Errors
|
|
1155
|
+
|
|
1156
|
+
/** Errors this module throws for decoded Tempo errors. Narrow with `error.name`. */
|
|
1157
|
+
export type ExecutionErrorType = AmmInsufficientLiquidityErrorType
|
|
1158
|
+
|
|
1159
|
+
/** `AmmInsufficientLiquidityError` with a literal `name`, for narrowing. */
|
|
1160
|
+
export type AmmInsufficientLiquidityErrorType =
|
|
1161
|
+
AmmInsufficientLiquidityError & {
|
|
1162
|
+
name: 'AmmInsufficientLiquidityError'
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
/** Thrown when a fee AMM pool cannot cover a swap, deposit, or withdrawal. */
|
|
1166
|
+
export class AmmInsufficientLiquidityError extends TempoExecutionError<
|
|
1167
|
+
Errors.TempoExecutionError.Decoded<
|
|
1168
|
+
'InsufficientLiquidity' | 'InsufficientReserves'
|
|
1169
|
+
>
|
|
1170
|
+
> {
|
|
1171
|
+
/** Amount of the call (`amountOut`, `amountValidatorToken`, or `liquidity`). */
|
|
1172
|
+
amount: bigint | undefined
|
|
1173
|
+
/** Pool reserve of `userToken`, when known. */
|
|
1174
|
+
reserveUserToken: bigint | undefined
|
|
1175
|
+
/** Pool reserve of `validatorToken`, when known. */
|
|
1176
|
+
reserveValidatorToken: bigint | undefined
|
|
1177
|
+
/** User token of the pool. */
|
|
1178
|
+
userToken: Address | undefined
|
|
1179
|
+
/** Validator token of the pool. */
|
|
1180
|
+
validatorToken: Address | undefined
|
|
1181
|
+
|
|
1182
|
+
constructor(
|
|
1183
|
+
parameters: Errors.TempoExecutionError.Parameters & {
|
|
1184
|
+
amount?: bigint | undefined
|
|
1185
|
+
reserveUserToken?: bigint | undefined
|
|
1186
|
+
reserveValidatorToken?: bigint | undefined
|
|
1187
|
+
userToken?: Address | undefined
|
|
1188
|
+
validatorToken?: Address | undefined
|
|
1189
|
+
},
|
|
1190
|
+
) {
|
|
1191
|
+
const {
|
|
1192
|
+
amount,
|
|
1193
|
+
reserveUserToken,
|
|
1194
|
+
reserveValidatorToken,
|
|
1195
|
+
userToken,
|
|
1196
|
+
validatorToken,
|
|
1197
|
+
} = parameters
|
|
1198
|
+
super(parameters, {
|
|
1199
|
+
details: {
|
|
1200
|
+
'user token': userToken,
|
|
1201
|
+
'validator token': validatorToken,
|
|
1202
|
+
amount,
|
|
1203
|
+
'user token reserve': reserveUserToken,
|
|
1204
|
+
'validator token reserve': reserveValidatorToken,
|
|
1205
|
+
},
|
|
1206
|
+
name: 'AmmInsufficientLiquidityError',
|
|
1207
|
+
})
|
|
1208
|
+
this.amount = amount
|
|
1209
|
+
this.reserveUserToken = reserveUserToken
|
|
1210
|
+
this.reserveValidatorToken = reserveValidatorToken
|
|
1211
|
+
this.userToken = userToken
|
|
1212
|
+
this.validatorToken = validatorToken
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
async function resolvePool(context: Context) {
|
|
1217
|
+
const { call } = context
|
|
1218
|
+
if (!call || !isAddressEqual(call.address, Addresses.feeManager))
|
|
1219
|
+
return undefined
|
|
1220
|
+
const userToken = call.arg<Address>('userToken')
|
|
1221
|
+
const validatorToken = call.arg<Address>('validatorToken')
|
|
1222
|
+
if (!userToken || !validatorToken) return undefined
|
|
1223
|
+
const [pool] = await context.read([
|
|
1224
|
+
{
|
|
1225
|
+
address: Addresses.feeManager,
|
|
1226
|
+
abi: Abis.feeAmm,
|
|
1227
|
+
functionName: 'getPool',
|
|
1228
|
+
args: [userToken, validatorToken],
|
|
1229
|
+
},
|
|
1230
|
+
])
|
|
1231
|
+
return new AmmInsufficientLiquidityError({
|
|
1232
|
+
...context.base,
|
|
1233
|
+
amount:
|
|
1234
|
+
call.arg<bigint>('amountOut') ??
|
|
1235
|
+
call.arg<bigint>('amountValidatorToken') ??
|
|
1236
|
+
call.arg<bigint>('liquidity'),
|
|
1237
|
+
reserveUserToken: pool?.result?.reserveUserToken,
|
|
1238
|
+
reserveValidatorToken: pool?.result?.reserveValidatorToken,
|
|
1239
|
+
userToken,
|
|
1240
|
+
validatorToken,
|
|
1241
|
+
})
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
/** @internal */
|
|
1245
|
+
export const errorResolvers: Resolvers = {
|
|
1246
|
+
'InsufficientLiquidity()': resolvePool,
|
|
1247
|
+
'InsufficientReserves()': resolvePool,
|
|
1248
|
+
}
|