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/actions/channel.ts
CHANGED
|
@@ -17,8 +17,18 @@ import type { GetEventArgs } from '../../types/contract.js'
|
|
|
17
17
|
import type { Log } from '../../types/log.js'
|
|
18
18
|
import type { Compute } from '../../types/utils.js'
|
|
19
19
|
import { parseEventLogs } from '../../utils/abi/parseEventLogs.js'
|
|
20
|
+
import { isAddressEqual } from '../../utils/address/isAddressEqual.js'
|
|
20
21
|
import * as Abis from '../Abis.js'
|
|
21
22
|
import { signVoucher as signVoucher_ } from '../Account.js'
|
|
23
|
+
import * as Addresses from '../Addresses.js'
|
|
24
|
+
import type * as Errors from '../errors.js'
|
|
25
|
+
import { TempoExecutionError } from '../errors.js'
|
|
26
|
+
import {
|
|
27
|
+
type Context,
|
|
28
|
+
formatTime,
|
|
29
|
+
type Resolvers,
|
|
30
|
+
withExecutionError,
|
|
31
|
+
} from '../internal/errors.js'
|
|
22
32
|
import type {
|
|
23
33
|
GetAccountParameter,
|
|
24
34
|
ReadParameters,
|
|
@@ -76,7 +86,7 @@ export namespace close {
|
|
|
76
86
|
export type ReturnValue = WriteContractReturnType
|
|
77
87
|
|
|
78
88
|
// TODO: exhaustive error type
|
|
79
|
-
export type ErrorType = BaseErrorType
|
|
89
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
80
90
|
|
|
81
91
|
/** @internal */
|
|
82
92
|
export async function inner<
|
|
@@ -90,7 +100,7 @@ export namespace close {
|
|
|
90
100
|
): Promise<ReturnType<action>> {
|
|
91
101
|
const { captureAmount, cumulativeAmount, channel, signature, ...rest } =
|
|
92
102
|
parameters
|
|
93
|
-
return (await action(client, {
|
|
103
|
+
return (await withExecutionError(action)(client, {
|
|
94
104
|
...rest,
|
|
95
105
|
...close.call({
|
|
96
106
|
captureAmount,
|
|
@@ -195,6 +205,8 @@ export namespace closeSync {
|
|
|
195
205
|
receipt: TransactionReceipt
|
|
196
206
|
}
|
|
197
207
|
>
|
|
208
|
+
|
|
209
|
+
export type ErrorType = close.ErrorType
|
|
198
210
|
}
|
|
199
211
|
|
|
200
212
|
/**
|
|
@@ -230,7 +242,7 @@ export async function getStates<
|
|
|
230
242
|
const chainId = client.chain?.id
|
|
231
243
|
const { channel, ...rest } = parameters
|
|
232
244
|
|
|
233
|
-
return readContract(client, {
|
|
245
|
+
return withExecutionError(readContract)(client, {
|
|
234
246
|
...rest,
|
|
235
247
|
...getStates.call({ channel, chainId } as never),
|
|
236
248
|
} as never) as never
|
|
@@ -269,7 +281,7 @@ export namespace getStates {
|
|
|
269
281
|
channel extends readonly Channel[] ? readonly State[] : State
|
|
270
282
|
|
|
271
283
|
// TODO: exhaustive error type
|
|
272
|
-
export type ErrorType = BaseErrorType
|
|
284
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
273
285
|
|
|
274
286
|
/**
|
|
275
287
|
* Defines a call to the `getChannelState` or `getChannelStatesBatch` function.
|
|
@@ -398,7 +410,7 @@ export namespace open {
|
|
|
398
410
|
export type ReturnValue = WriteContractReturnType
|
|
399
411
|
|
|
400
412
|
// TODO: exhaustive error type
|
|
401
|
-
export type ErrorType = BaseErrorType
|
|
413
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
402
414
|
|
|
403
415
|
/** @internal */
|
|
404
416
|
export async function inner<
|
|
@@ -412,7 +424,7 @@ export namespace open {
|
|
|
412
424
|
): Promise<ReturnType<action>> {
|
|
413
425
|
const { authorizedSigner, deposit, operator, payee, salt, token, ...rest } =
|
|
414
426
|
parameters
|
|
415
|
-
return (await action(client, {
|
|
427
|
+
return (await withExecutionError(action)(client, {
|
|
416
428
|
...rest,
|
|
417
429
|
...open.call({
|
|
418
430
|
authorizedSigner,
|
|
@@ -537,6 +549,8 @@ export namespace openSync {
|
|
|
537
549
|
receipt: TransactionReceipt
|
|
538
550
|
}
|
|
539
551
|
>
|
|
552
|
+
|
|
553
|
+
export type ErrorType = open.ErrorType
|
|
540
554
|
}
|
|
541
555
|
|
|
542
556
|
/**
|
|
@@ -579,7 +593,7 @@ export namespace requestClose {
|
|
|
579
593
|
export type ReturnValue = WriteContractReturnType
|
|
580
594
|
|
|
581
595
|
// TODO: exhaustive error type
|
|
582
|
-
export type ErrorType = BaseErrorType
|
|
596
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
583
597
|
|
|
584
598
|
/** @internal */
|
|
585
599
|
export async function inner<
|
|
@@ -592,7 +606,7 @@ export namespace requestClose {
|
|
|
592
606
|
parameters: Parameters<chain, account>,
|
|
593
607
|
): Promise<ReturnType<action>> {
|
|
594
608
|
const { channel, ...rest } = parameters
|
|
595
|
-
return (await action(client, {
|
|
609
|
+
return (await withExecutionError(action)(client, {
|
|
596
610
|
...rest,
|
|
597
611
|
...requestClose.call({ channel }),
|
|
598
612
|
} as never)) as never
|
|
@@ -684,6 +698,8 @@ export namespace requestCloseSync {
|
|
|
684
698
|
receipt: TransactionReceipt
|
|
685
699
|
}
|
|
686
700
|
>
|
|
701
|
+
|
|
702
|
+
export type ErrorType = requestClose.ErrorType
|
|
687
703
|
}
|
|
688
704
|
|
|
689
705
|
/**
|
|
@@ -734,7 +750,7 @@ export namespace settle {
|
|
|
734
750
|
export type ReturnValue = WriteContractReturnType
|
|
735
751
|
|
|
736
752
|
// TODO: exhaustive error type
|
|
737
|
-
export type ErrorType = BaseErrorType
|
|
753
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
738
754
|
|
|
739
755
|
/** @internal */
|
|
740
756
|
export async function inner<
|
|
@@ -747,7 +763,7 @@ export namespace settle {
|
|
|
747
763
|
parameters: Parameters<chain, account>,
|
|
748
764
|
): Promise<ReturnType<action>> {
|
|
749
765
|
const { cumulativeAmount, channel, signature, ...rest } = parameters
|
|
750
|
-
return (await action(client, {
|
|
766
|
+
return (await withExecutionError(action)(client, {
|
|
751
767
|
...rest,
|
|
752
768
|
...settle.call({ cumulativeAmount, channel, signature }),
|
|
753
769
|
} as never)) as never
|
|
@@ -841,6 +857,8 @@ export namespace settleSync {
|
|
|
841
857
|
receipt: TransactionReceipt
|
|
842
858
|
}
|
|
843
859
|
>
|
|
860
|
+
|
|
861
|
+
export type ErrorType = settle.ErrorType
|
|
844
862
|
}
|
|
845
863
|
|
|
846
864
|
/**
|
|
@@ -951,7 +969,7 @@ export namespace topUp {
|
|
|
951
969
|
export type ReturnValue = WriteContractReturnType
|
|
952
970
|
|
|
953
971
|
// TODO: exhaustive error type
|
|
954
|
-
export type ErrorType = BaseErrorType
|
|
972
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
955
973
|
|
|
956
974
|
/** @internal */
|
|
957
975
|
export async function inner<
|
|
@@ -964,7 +982,7 @@ export namespace topUp {
|
|
|
964
982
|
parameters: Parameters<chain, account>,
|
|
965
983
|
): Promise<ReturnType<action>> {
|
|
966
984
|
const { additionalDeposit, channel, ...rest } = parameters
|
|
967
|
-
return (await action(client, {
|
|
985
|
+
return (await withExecutionError(action)(client, {
|
|
968
986
|
...rest,
|
|
969
987
|
...topUp.call({ additionalDeposit, channel }),
|
|
970
988
|
} as never)) as never
|
|
@@ -1058,6 +1076,8 @@ export namespace topUpSync {
|
|
|
1058
1076
|
receipt: TransactionReceipt
|
|
1059
1077
|
}
|
|
1060
1078
|
>
|
|
1079
|
+
|
|
1080
|
+
export type ErrorType = topUp.ErrorType
|
|
1061
1081
|
}
|
|
1062
1082
|
|
|
1063
1083
|
/**
|
|
@@ -1100,7 +1120,7 @@ export namespace withdraw {
|
|
|
1100
1120
|
export type ReturnValue = WriteContractReturnType
|
|
1101
1121
|
|
|
1102
1122
|
// TODO: exhaustive error type
|
|
1103
|
-
export type ErrorType = BaseErrorType
|
|
1123
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
1104
1124
|
|
|
1105
1125
|
/** @internal */
|
|
1106
1126
|
export async function inner<
|
|
@@ -1113,7 +1133,7 @@ export namespace withdraw {
|
|
|
1113
1133
|
parameters: Parameters<chain, account>,
|
|
1114
1134
|
): Promise<ReturnType<action>> {
|
|
1115
1135
|
const { channel, ...rest } = parameters
|
|
1116
|
-
return (await action(client, {
|
|
1136
|
+
return (await withExecutionError(action)(client, {
|
|
1117
1137
|
...rest,
|
|
1118
1138
|
...withdraw.call({ channel }),
|
|
1119
1139
|
} as never)) as never
|
|
@@ -1206,4 +1226,218 @@ export namespace withdrawSync {
|
|
|
1206
1226
|
receipt: TransactionReceipt
|
|
1207
1227
|
}
|
|
1208
1228
|
>
|
|
1229
|
+
|
|
1230
|
+
export type ErrorType = withdraw.ErrorType
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
// Errors
|
|
1234
|
+
|
|
1235
|
+
/** Errors this module throws for decoded Tempo errors. Narrow with `error.name`. */
|
|
1236
|
+
export type ExecutionErrorType =
|
|
1237
|
+
| ChannelAmountExceedsDepositErrorType
|
|
1238
|
+
| ChannelAmountNotIncreasingErrorType
|
|
1239
|
+
| ChannelCloseNotReadyErrorType
|
|
1240
|
+
| ChannelNotFoundErrorType
|
|
1241
|
+
|
|
1242
|
+
/** `ChannelNotFoundError` with a literal `name`, for narrowing. */
|
|
1243
|
+
export type ChannelNotFoundErrorType = ChannelNotFoundError & {
|
|
1244
|
+
name: 'ChannelNotFoundError'
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
/** Thrown when a payment channel does not exist. */
|
|
1248
|
+
export class ChannelNotFoundError extends TempoExecutionError<
|
|
1249
|
+
Errors.TempoExecutionError.Decoded<'ChannelNotFound'>
|
|
1250
|
+
> {
|
|
1251
|
+
/** Channel descriptor, when known. */
|
|
1252
|
+
descriptor: Record<string, unknown> | undefined
|
|
1253
|
+
|
|
1254
|
+
constructor(
|
|
1255
|
+
parameters: Errors.TempoExecutionError.Parameters & {
|
|
1256
|
+
descriptor?: Record<string, unknown> | undefined
|
|
1257
|
+
},
|
|
1258
|
+
) {
|
|
1259
|
+
const { descriptor } = parameters
|
|
1260
|
+
super(parameters, {
|
|
1261
|
+
details: {
|
|
1262
|
+
payer: descriptor?.payer,
|
|
1263
|
+
payee: descriptor?.payee,
|
|
1264
|
+
token: descriptor?.token,
|
|
1265
|
+
},
|
|
1266
|
+
name: 'ChannelNotFoundError',
|
|
1267
|
+
})
|
|
1268
|
+
this.descriptor = descriptor
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
/** `ChannelCloseNotReadyError` with a literal `name`, for narrowing. */
|
|
1273
|
+
export type ChannelCloseNotReadyErrorType = ChannelCloseNotReadyError & {
|
|
1274
|
+
name: 'ChannelCloseNotReadyError'
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
/** Thrown when withdrawing from a channel before its close grace period ends. */
|
|
1278
|
+
export class ChannelCloseNotReadyError extends TempoExecutionError<
|
|
1279
|
+
Errors.TempoExecutionError.Decoded<'CloseNotReady'>
|
|
1280
|
+
> {
|
|
1281
|
+
/** When the close was requested (Unix seconds), or `0` when it was not. */
|
|
1282
|
+
closeRequestedAt: number | undefined
|
|
1283
|
+
/** When the channel can be withdrawn from (Unix seconds), when known. */
|
|
1284
|
+
readyAt: bigint | undefined
|
|
1285
|
+
|
|
1286
|
+
constructor(
|
|
1287
|
+
parameters: Errors.TempoExecutionError.Parameters & {
|
|
1288
|
+
closeRequestedAt?: number | undefined
|
|
1289
|
+
readyAt?: bigint | undefined
|
|
1290
|
+
},
|
|
1291
|
+
) {
|
|
1292
|
+
const { closeRequestedAt, readyAt } = parameters
|
|
1293
|
+
super(parameters, {
|
|
1294
|
+
details: {
|
|
1295
|
+
'close requested at': formatTime(closeRequestedAt),
|
|
1296
|
+
'ready at': formatTime(readyAt),
|
|
1297
|
+
},
|
|
1298
|
+
name: 'ChannelCloseNotReadyError',
|
|
1299
|
+
shortMessage:
|
|
1300
|
+
closeRequestedAt === 0
|
|
1301
|
+
? 'Channel close has not been requested.'
|
|
1302
|
+
: readyAt
|
|
1303
|
+
? `Channel is not ready to close until ${formatTime(readyAt)}.`
|
|
1304
|
+
: undefined,
|
|
1305
|
+
})
|
|
1306
|
+
this.closeRequestedAt = closeRequestedAt
|
|
1307
|
+
this.readyAt = readyAt
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
/** `ChannelAmountExceedsDepositError` with a literal `name`, for narrowing. */
|
|
1312
|
+
export type ChannelAmountExceedsDepositErrorType =
|
|
1313
|
+
ChannelAmountExceedsDepositError & {
|
|
1314
|
+
name: 'ChannelAmountExceedsDepositError'
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
/** Thrown when a voucher amount exceeds the channel deposit. */
|
|
1318
|
+
export class ChannelAmountExceedsDepositError extends TempoExecutionError<
|
|
1319
|
+
Errors.TempoExecutionError.Decoded<'AmountExceedsDeposit'>
|
|
1320
|
+
> {
|
|
1321
|
+
/** Cumulative voucher amount. */
|
|
1322
|
+
amount: bigint | undefined
|
|
1323
|
+
/** Channel deposit, when known. */
|
|
1324
|
+
deposit: bigint | undefined
|
|
1325
|
+
|
|
1326
|
+
constructor(
|
|
1327
|
+
parameters: Errors.TempoExecutionError.Parameters & {
|
|
1328
|
+
amount?: bigint | undefined
|
|
1329
|
+
deposit?: bigint | undefined
|
|
1330
|
+
},
|
|
1331
|
+
) {
|
|
1332
|
+
const { amount, deposit } = parameters
|
|
1333
|
+
super(parameters, {
|
|
1334
|
+
details: { amount, deposit },
|
|
1335
|
+
name: 'ChannelAmountExceedsDepositError',
|
|
1336
|
+
})
|
|
1337
|
+
this.amount = amount
|
|
1338
|
+
this.deposit = deposit
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
/** `ChannelAmountNotIncreasingError` with a literal `name`, for narrowing. */
|
|
1343
|
+
export type ChannelAmountNotIncreasingErrorType =
|
|
1344
|
+
ChannelAmountNotIncreasingError & {
|
|
1345
|
+
name: 'ChannelAmountNotIncreasingError'
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
/** Thrown when a voucher amount is not above the amount already settled. */
|
|
1349
|
+
export class ChannelAmountNotIncreasingError extends TempoExecutionError<
|
|
1350
|
+
Errors.TempoExecutionError.Decoded<'AmountNotIncreasing'>
|
|
1351
|
+
> {
|
|
1352
|
+
/** Cumulative voucher amount. */
|
|
1353
|
+
amount: bigint | undefined
|
|
1354
|
+
/** Amount already settled, when known. */
|
|
1355
|
+
settled: bigint | undefined
|
|
1356
|
+
|
|
1357
|
+
constructor(
|
|
1358
|
+
parameters: Errors.TempoExecutionError.Parameters & {
|
|
1359
|
+
amount?: bigint | undefined
|
|
1360
|
+
settled?: bigint | undefined
|
|
1361
|
+
},
|
|
1362
|
+
) {
|
|
1363
|
+
const { amount, settled } = parameters
|
|
1364
|
+
super(parameters, {
|
|
1365
|
+
details: { amount, settled },
|
|
1366
|
+
name: 'ChannelAmountNotIncreasingError',
|
|
1367
|
+
})
|
|
1368
|
+
this.amount = amount
|
|
1369
|
+
this.settled = settled
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
const reserve = {
|
|
1374
|
+
address: Addresses.tip20ChannelReserve,
|
|
1375
|
+
abi: Abis.tip20ChannelReserve,
|
|
1376
|
+
} as const
|
|
1377
|
+
|
|
1378
|
+
/** Reads the channel state of the failed call, when it targets the channel reserve. */
|
|
1379
|
+
async function readChannel(context: Context) {
|
|
1380
|
+
const { call } = context
|
|
1381
|
+
if (!call || !isAddressEqual(call.address, Addresses.tip20ChannelReserve))
|
|
1382
|
+
return undefined
|
|
1383
|
+
const descriptor = call.arg<ox_Channel.Resolved>('descriptor')
|
|
1384
|
+
if (!descriptor) return { call, descriptor }
|
|
1385
|
+
const [channel, gracePeriod] = await context.read([
|
|
1386
|
+
{
|
|
1387
|
+
...reserve,
|
|
1388
|
+
functionName: 'getChannel',
|
|
1389
|
+
args: [descriptor as never],
|
|
1390
|
+
},
|
|
1391
|
+
{ ...reserve, functionName: 'CLOSE_GRACE_PERIOD' },
|
|
1392
|
+
])
|
|
1393
|
+
return {
|
|
1394
|
+
call,
|
|
1395
|
+
descriptor,
|
|
1396
|
+
gracePeriod: gracePeriod?.result,
|
|
1397
|
+
state: channel?.result?.state,
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
/** @internal */
|
|
1402
|
+
export const errorResolvers: Resolvers = {
|
|
1403
|
+
'AmountExceedsDeposit()': async (context) => {
|
|
1404
|
+
const channel = await readChannel(context)
|
|
1405
|
+
if (!channel) return undefined
|
|
1406
|
+
return new ChannelAmountExceedsDepositError({
|
|
1407
|
+
...context.base,
|
|
1408
|
+
amount: channel.call.arg<bigint>('cumulativeAmount'),
|
|
1409
|
+
deposit: channel.state?.deposit,
|
|
1410
|
+
})
|
|
1411
|
+
},
|
|
1412
|
+
'AmountNotIncreasing()': async (context) => {
|
|
1413
|
+
const channel = await readChannel(context)
|
|
1414
|
+
if (!channel) return undefined
|
|
1415
|
+
return new ChannelAmountNotIncreasingError({
|
|
1416
|
+
...context.base,
|
|
1417
|
+
amount: channel.call.arg<bigint>('cumulativeAmount'),
|
|
1418
|
+
settled: channel.state?.settled,
|
|
1419
|
+
})
|
|
1420
|
+
},
|
|
1421
|
+
'ChannelNotFound()': (context) => {
|
|
1422
|
+
const { call } = context
|
|
1423
|
+
if (!call || !isAddressEqual(call.address, Addresses.tip20ChannelReserve))
|
|
1424
|
+
return undefined
|
|
1425
|
+
return new ChannelNotFoundError({
|
|
1426
|
+
...context.base,
|
|
1427
|
+
descriptor: call.arg<Record<string, unknown>>('descriptor'),
|
|
1428
|
+
})
|
|
1429
|
+
},
|
|
1430
|
+
'CloseNotReady()': async (context) => {
|
|
1431
|
+
const channel = await readChannel(context)
|
|
1432
|
+
if (!channel) return undefined
|
|
1433
|
+
const closeRequestedAt = channel.state?.closeRequestedAt
|
|
1434
|
+
return new ChannelCloseNotReadyError({
|
|
1435
|
+
...context.base,
|
|
1436
|
+
closeRequestedAt,
|
|
1437
|
+
readyAt:
|
|
1438
|
+
closeRequestedAt && channel.gracePeriod !== undefined
|
|
1439
|
+
? BigInt(closeRequestedAt) + channel.gracePeriod
|
|
1440
|
+
: undefined,
|
|
1441
|
+
})
|
|
1442
|
+
},
|
|
1209
1443
|
}
|