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/token.ts
CHANGED
|
@@ -33,6 +33,7 @@ import { writeContract } from '../../actions/wallet/writeContract.js'
|
|
|
33
33
|
import { writeContractSync } from '../../actions/wallet/writeContractSync.js'
|
|
34
34
|
import type { Client } from '../../clients/createClient.js'
|
|
35
35
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
|
36
|
+
import { zeroAddress } from '../../constants/address.js'
|
|
36
37
|
import { AccountNotFoundError } from '../../errors/account.js'
|
|
37
38
|
import type { BaseErrorType } from '../../errors/base.js'
|
|
38
39
|
import type { Chain } from '../../types/chain.js'
|
|
@@ -44,6 +45,14 @@ import { parseEventLogs } from '../../utils/abi/parseEventLogs.js'
|
|
|
44
45
|
import { formatUnits } from '../../utils/unit/formatUnits.js'
|
|
45
46
|
import * as Abis from '../Abis.js'
|
|
46
47
|
import * as Addresses from '../Addresses.js'
|
|
48
|
+
import type * as Errors from '../errors.js'
|
|
49
|
+
import { TempoExecutionError } from '../errors.js'
|
|
50
|
+
import {
|
|
51
|
+
formatAmount,
|
|
52
|
+
isTip20,
|
|
53
|
+
type Resolvers,
|
|
54
|
+
withExecutionError,
|
|
55
|
+
} from '../internal/errors.js'
|
|
47
56
|
import type {
|
|
48
57
|
GetAccountParameter,
|
|
49
58
|
ReadParameters,
|
|
@@ -111,7 +120,7 @@ export namespace approve {
|
|
|
111
120
|
> = WriteParameters<chain, account> & Args
|
|
112
121
|
export type ReturnValue = WriteContractReturnType
|
|
113
122
|
// TODO: exhaustive error type
|
|
114
|
-
export type ErrorType = BaseErrorType
|
|
123
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
115
124
|
|
|
116
125
|
/** @internal */
|
|
117
126
|
export async function inner<
|
|
@@ -123,7 +132,7 @@ export namespace approve {
|
|
|
123
132
|
client: Client<Transport, chain, account>,
|
|
124
133
|
parameters: approve.Parameters<chain, account>,
|
|
125
134
|
): Promise<ReturnType<action>> {
|
|
126
|
-
return (await action(client, {
|
|
135
|
+
return (await withExecutionError(action)(client, {
|
|
127
136
|
...parameters,
|
|
128
137
|
...approve.call(client, parameters as never),
|
|
129
138
|
} as never)) as never
|
|
@@ -290,7 +299,7 @@ export namespace approveSync {
|
|
|
290
299
|
}
|
|
291
300
|
>
|
|
292
301
|
// TODO: exhaustive error type
|
|
293
|
-
export type ErrorType = BaseErrorType
|
|
302
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
294
303
|
}
|
|
295
304
|
|
|
296
305
|
/**
|
|
@@ -346,7 +355,7 @@ export namespace burnBlocked {
|
|
|
346
355
|
export type ReturnValue = WriteContractReturnType
|
|
347
356
|
|
|
348
357
|
// TODO: exhaustive error type
|
|
349
|
-
export type ErrorType = BaseErrorType
|
|
358
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
350
359
|
|
|
351
360
|
/** @internal */
|
|
352
361
|
export async function inner<
|
|
@@ -360,7 +369,7 @@ export namespace burnBlocked {
|
|
|
360
369
|
): Promise<ReturnType<action>> {
|
|
361
370
|
const { amount, from, token, ...rest } = parameters
|
|
362
371
|
const call = burnBlocked.call(client, { amount, from, token } as never)
|
|
363
|
-
return (await action(client, {
|
|
372
|
+
return (await withExecutionError(action)(client, {
|
|
364
373
|
...rest,
|
|
365
374
|
...call,
|
|
366
375
|
} as never)) as never
|
|
@@ -503,7 +512,7 @@ export namespace burnBlockedSync {
|
|
|
503
512
|
>
|
|
504
513
|
|
|
505
514
|
// TODO: exhaustive error type
|
|
506
|
-
export type ErrorType = BaseErrorType
|
|
515
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
507
516
|
}
|
|
508
517
|
|
|
509
518
|
/**
|
|
@@ -569,7 +578,7 @@ export namespace burn {
|
|
|
569
578
|
export type ReturnValue = WriteContractReturnType
|
|
570
579
|
|
|
571
580
|
// TODO: exhaustive error type
|
|
572
|
-
export type ErrorType = BaseErrorType
|
|
581
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
573
582
|
|
|
574
583
|
/** @internal */
|
|
575
584
|
export async function inner<
|
|
@@ -583,7 +592,7 @@ export namespace burn {
|
|
|
583
592
|
): Promise<ReturnType<action>> {
|
|
584
593
|
const { amount, from, memo, token, ...rest } = parameters
|
|
585
594
|
const call = burn.call(client, { amount, from, memo, token } as never)
|
|
586
|
-
return (await action(client, {
|
|
595
|
+
return (await withExecutionError(action)(client, {
|
|
587
596
|
...rest,
|
|
588
597
|
...call,
|
|
589
598
|
} as never)) as never
|
|
@@ -741,7 +750,7 @@ export namespace burnSync {
|
|
|
741
750
|
>
|
|
742
751
|
|
|
743
752
|
// TODO: exhaustive error type
|
|
744
|
-
export type ErrorType = BaseErrorType
|
|
753
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
745
754
|
}
|
|
746
755
|
|
|
747
756
|
/**
|
|
@@ -796,7 +805,7 @@ export namespace changeTransferPolicy {
|
|
|
796
805
|
export type ReturnValue = WriteContractReturnType
|
|
797
806
|
|
|
798
807
|
// TODO: exhaustive error type
|
|
799
|
-
export type ErrorType = BaseErrorType
|
|
808
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
800
809
|
|
|
801
810
|
/** @internal */
|
|
802
811
|
export async function inner<
|
|
@@ -810,7 +819,7 @@ export namespace changeTransferPolicy {
|
|
|
810
819
|
): Promise<ReturnType<action>> {
|
|
811
820
|
const { policyId, token, ...rest } = parameters
|
|
812
821
|
const call = changeTransferPolicy.call(client, { policyId, token })
|
|
813
|
-
return (await action(client, {
|
|
822
|
+
return (await withExecutionError(action)(client, {
|
|
814
823
|
...rest,
|
|
815
824
|
...call,
|
|
816
825
|
} as never)) as never
|
|
@@ -947,7 +956,7 @@ export namespace changeTransferPolicySync {
|
|
|
947
956
|
>
|
|
948
957
|
|
|
949
958
|
// TODO: exhaustive error type
|
|
950
|
-
export type ErrorType = BaseErrorType
|
|
959
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
951
960
|
}
|
|
952
961
|
|
|
953
962
|
/**
|
|
@@ -1018,7 +1027,7 @@ export namespace create {
|
|
|
1018
1027
|
export type ReturnValue = WriteContractReturnType
|
|
1019
1028
|
|
|
1020
1029
|
// TODO: exhaustive error type
|
|
1021
|
-
export type ErrorType = BaseErrorType
|
|
1030
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
1022
1031
|
|
|
1023
1032
|
/** @internal */
|
|
1024
1033
|
export async function inner<
|
|
@@ -1041,7 +1050,7 @@ export namespace create {
|
|
|
1041
1050
|
|
|
1042
1051
|
const call = create.call(client, { ...rest, admin: admin.address })
|
|
1043
1052
|
|
|
1044
|
-
return (await action(
|
|
1053
|
+
return (await withExecutionError(action)(
|
|
1045
1054
|
client as never,
|
|
1046
1055
|
{
|
|
1047
1056
|
...parameters,
|
|
@@ -1220,7 +1229,7 @@ export namespace createSync {
|
|
|
1220
1229
|
>
|
|
1221
1230
|
|
|
1222
1231
|
// TODO: exhaustive error type
|
|
1223
|
-
export type ErrorType = BaseErrorType
|
|
1232
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
1224
1233
|
}
|
|
1225
1234
|
|
|
1226
1235
|
/**
|
|
@@ -1256,7 +1265,7 @@ export async function getAllowance<chain extends Chain | undefined>(
|
|
|
1256
1265
|
): Promise<getAllowance.ReturnValue> {
|
|
1257
1266
|
const { account, decimals, spender, token, ...rest } = parameters
|
|
1258
1267
|
const [amount, { decimals: resolved }] = await Promise.all([
|
|
1259
|
-
readContract(client, {
|
|
1268
|
+
withExecutionError(readContract)(client, {
|
|
1260
1269
|
...rest,
|
|
1261
1270
|
...getAllowance.call(client, { account, spender, token } as never),
|
|
1262
1271
|
}),
|
|
@@ -1299,6 +1308,8 @@ export namespace getAllowance {
|
|
|
1299
1308
|
args: [args.account, args.spender],
|
|
1300
1309
|
})
|
|
1301
1310
|
}
|
|
1311
|
+
|
|
1312
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
1302
1313
|
}
|
|
1303
1314
|
|
|
1304
1315
|
/**
|
|
@@ -1343,7 +1354,7 @@ export async function getBalance<
|
|
|
1343
1354
|
if (!account_) throw new AccountNotFoundError()
|
|
1344
1355
|
const account = parseAccount(account_).address
|
|
1345
1356
|
const [amount, { decimals: resolved }] = await Promise.all([
|
|
1346
|
-
readContract(client, {
|
|
1357
|
+
withExecutionError(readContract)(client, {
|
|
1347
1358
|
...rest,
|
|
1348
1359
|
...getBalance.call(client, { account, token } as never),
|
|
1349
1360
|
}),
|
|
@@ -1393,6 +1404,8 @@ export namespace getBalance {
|
|
|
1393
1404
|
args: [account],
|
|
1394
1405
|
})
|
|
1395
1406
|
}
|
|
1407
|
+
|
|
1408
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
1396
1409
|
}
|
|
1397
1410
|
|
|
1398
1411
|
/**
|
|
@@ -1598,7 +1611,7 @@ async function readMetadataContracts<chain extends Chain | undefined>(
|
|
|
1598
1611
|
const { contracts, ...rest } = parameters
|
|
1599
1612
|
const results = await Promise.allSettled(
|
|
1600
1613
|
contracts.map((contract) =>
|
|
1601
|
-
readContract(client, {
|
|
1614
|
+
withExecutionError(readContract)(client, {
|
|
1602
1615
|
...rest,
|
|
1603
1616
|
...contract,
|
|
1604
1617
|
}),
|
|
@@ -1690,6 +1703,8 @@ export declare namespace getMetadata {
|
|
|
1690
1703
|
*/
|
|
1691
1704
|
transferPolicyId?: bigint | undefined
|
|
1692
1705
|
}>
|
|
1706
|
+
|
|
1707
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
1693
1708
|
}
|
|
1694
1709
|
|
|
1695
1710
|
/**
|
|
@@ -1721,7 +1736,7 @@ export async function getTotalSupply<chain extends Chain | undefined>(
|
|
|
1721
1736
|
): Promise<getTotalSupply.ReturnValue> {
|
|
1722
1737
|
const { decimals, token, ...rest } = parameters
|
|
1723
1738
|
const [amount, { decimals: resolved }] = await Promise.all([
|
|
1724
|
-
readContract(client, {
|
|
1739
|
+
withExecutionError(readContract)(client, {
|
|
1725
1740
|
...rest,
|
|
1726
1741
|
...getTotalSupply.call(client, { token } as never),
|
|
1727
1742
|
}),
|
|
@@ -1759,6 +1774,8 @@ export namespace getTotalSupply {
|
|
|
1759
1774
|
functionName: 'totalSupply',
|
|
1760
1775
|
})
|
|
1761
1776
|
}
|
|
1777
|
+
|
|
1778
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
1762
1779
|
}
|
|
1763
1780
|
|
|
1764
1781
|
/**
|
|
@@ -1789,7 +1806,7 @@ export async function getRoleAdmin<chain extends Chain | undefined>(
|
|
|
1789
1806
|
client: Client<Transport, chain>,
|
|
1790
1807
|
parameters: getRoleAdmin.Parameters,
|
|
1791
1808
|
): Promise<getRoleAdmin.ReturnValue> {
|
|
1792
|
-
return readContract(client, {
|
|
1809
|
+
return withExecutionError(readContract)(client, {
|
|
1793
1810
|
...parameters,
|
|
1794
1811
|
...getRoleAdmin.call(client, parameters),
|
|
1795
1812
|
})
|
|
@@ -1829,6 +1846,8 @@ export namespace getRoleAdmin {
|
|
|
1829
1846
|
args: [TokenRole.serialize(role)],
|
|
1830
1847
|
})
|
|
1831
1848
|
}
|
|
1849
|
+
|
|
1850
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
1832
1851
|
}
|
|
1833
1852
|
|
|
1834
1853
|
/**
|
|
@@ -1866,7 +1885,7 @@ export async function hasRole<
|
|
|
1866
1885
|
const { account = client.account } = parameters
|
|
1867
1886
|
const address = account ? parseAccount(account).address : undefined
|
|
1868
1887
|
if (!address) throw new Error('account is required.')
|
|
1869
|
-
return readContract(client, {
|
|
1888
|
+
return withExecutionError(readContract)(client, {
|
|
1870
1889
|
...parameters,
|
|
1871
1890
|
...hasRole.call(client, { ...parameters, account: address }),
|
|
1872
1891
|
})
|
|
@@ -1910,6 +1929,8 @@ export namespace hasRole {
|
|
|
1910
1929
|
args: [account, TokenRole.serialize(role)],
|
|
1911
1930
|
})
|
|
1912
1931
|
}
|
|
1932
|
+
|
|
1933
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
1913
1934
|
}
|
|
1914
1935
|
|
|
1915
1936
|
/**
|
|
@@ -1971,7 +1992,7 @@ export namespace grantRoles {
|
|
|
1971
1992
|
export type ReturnValue = WriteContractReturnType
|
|
1972
1993
|
|
|
1973
1994
|
// TODO: exhaustive error type
|
|
1974
|
-
export type ErrorType = BaseErrorType
|
|
1995
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
1975
1996
|
|
|
1976
1997
|
/** @internal */
|
|
1977
1998
|
export async function inner<
|
|
@@ -1983,7 +2004,7 @@ export namespace grantRoles {
|
|
|
1983
2004
|
client: Client<Transport, chain, account>,
|
|
1984
2005
|
parameters: grantRoles.Parameters<chain, account>,
|
|
1985
2006
|
): Promise<ReturnType<action>> {
|
|
1986
|
-
return (await action(client, {
|
|
2007
|
+
return (await withExecutionError(action)(client, {
|
|
1987
2008
|
...parameters,
|
|
1988
2009
|
calls: parameters.roles.map((role) => {
|
|
1989
2010
|
const call = grantRoles.call(client, { ...parameters, role })
|
|
@@ -2127,7 +2148,7 @@ export namespace grantRolesSync {
|
|
|
2127
2148
|
}
|
|
2128
2149
|
|
|
2129
2150
|
// TODO: exhaustive error type
|
|
2130
|
-
export type ErrorType = BaseErrorType
|
|
2151
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
2131
2152
|
}
|
|
2132
2153
|
|
|
2133
2154
|
/**
|
|
@@ -2185,7 +2206,7 @@ export namespace mint {
|
|
|
2185
2206
|
export type ReturnValue = WriteContractReturnType
|
|
2186
2207
|
|
|
2187
2208
|
// TODO: exhaustive error type
|
|
2188
|
-
export type ErrorType = BaseErrorType
|
|
2209
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
2189
2210
|
|
|
2190
2211
|
/** @internal */
|
|
2191
2212
|
export async function inner<
|
|
@@ -2199,7 +2220,13 @@ export namespace mint {
|
|
|
2199
2220
|
): Promise<ReturnType<action>> {
|
|
2200
2221
|
const { amount, memo, to, token, ...rest } = parameters
|
|
2201
2222
|
const call = mint.call(client, { amount, memo, to, token } as never)
|
|
2202
|
-
return (await action
|
|
2223
|
+
return (await withExecutionError(action, {
|
|
2224
|
+
hints: {
|
|
2225
|
+
Unauthorized: [
|
|
2226
|
+
'Minting requires the issuer role. Grant it to this account first.',
|
|
2227
|
+
],
|
|
2228
|
+
},
|
|
2229
|
+
})(client, {
|
|
2203
2230
|
...rest,
|
|
2204
2231
|
...call,
|
|
2205
2232
|
} as never)) as never
|
|
@@ -2350,7 +2377,7 @@ export namespace mintSync {
|
|
|
2350
2377
|
>
|
|
2351
2378
|
|
|
2352
2379
|
// TODO: exhaustive error type
|
|
2353
|
-
export type ErrorType = BaseErrorType
|
|
2380
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
2354
2381
|
}
|
|
2355
2382
|
|
|
2356
2383
|
/**
|
|
@@ -2402,7 +2429,7 @@ export namespace pause {
|
|
|
2402
2429
|
export type ReturnValue = WriteContractReturnType
|
|
2403
2430
|
|
|
2404
2431
|
// TODO: exhaustive error type
|
|
2405
|
-
export type ErrorType = BaseErrorType
|
|
2432
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
2406
2433
|
|
|
2407
2434
|
/** @internal */
|
|
2408
2435
|
export async function inner<
|
|
@@ -2416,7 +2443,7 @@ export namespace pause {
|
|
|
2416
2443
|
): Promise<ReturnType<action>> {
|
|
2417
2444
|
const { token, ...rest } = parameters
|
|
2418
2445
|
const call = pause.call(client, { token })
|
|
2419
|
-
return (await action(client, {
|
|
2446
|
+
return (await withExecutionError(action)(client, {
|
|
2420
2447
|
...rest,
|
|
2421
2448
|
...call,
|
|
2422
2449
|
} as never)) as never
|
|
@@ -2546,7 +2573,7 @@ export namespace pauseSync {
|
|
|
2546
2573
|
}
|
|
2547
2574
|
|
|
2548
2575
|
// TODO: exhaustive error type
|
|
2549
|
-
export type ErrorType = BaseErrorType
|
|
2576
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
2550
2577
|
}
|
|
2551
2578
|
|
|
2552
2579
|
/**
|
|
@@ -2605,7 +2632,7 @@ export namespace renounceRoles {
|
|
|
2605
2632
|
export type ReturnValue = WriteContractReturnType
|
|
2606
2633
|
|
|
2607
2634
|
// TODO: exhaustive error type
|
|
2608
|
-
export type ErrorType = BaseErrorType
|
|
2635
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
2609
2636
|
|
|
2610
2637
|
/** @internal */
|
|
2611
2638
|
export async function inner<
|
|
@@ -2617,7 +2644,7 @@ export namespace renounceRoles {
|
|
|
2617
2644
|
client: Client<Transport, chain, account>,
|
|
2618
2645
|
parameters: renounceRoles.Parameters<chain, account>,
|
|
2619
2646
|
): Promise<ReturnType<action>> {
|
|
2620
|
-
return (await action(client, {
|
|
2647
|
+
return (await withExecutionError(action)(client, {
|
|
2621
2648
|
...parameters,
|
|
2622
2649
|
calls: parameters.roles.map((role) => {
|
|
2623
2650
|
const call = renounceRoles.call(client, { ...parameters, role })
|
|
@@ -2759,7 +2786,7 @@ export namespace renounceRolesSync {
|
|
|
2759
2786
|
}
|
|
2760
2787
|
|
|
2761
2788
|
// TODO: exhaustive error type
|
|
2762
|
-
export type ErrorType = BaseErrorType
|
|
2789
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
2763
2790
|
}
|
|
2764
2791
|
|
|
2765
2792
|
/**
|
|
@@ -2821,7 +2848,7 @@ export namespace revokeRoles {
|
|
|
2821
2848
|
export type ReturnValue = WriteContractReturnType
|
|
2822
2849
|
|
|
2823
2850
|
// TODO: exhaustive error type
|
|
2824
|
-
export type ErrorType = BaseErrorType
|
|
2851
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
2825
2852
|
|
|
2826
2853
|
/** @internal */
|
|
2827
2854
|
export async function inner<
|
|
@@ -2834,7 +2861,7 @@ export namespace revokeRoles {
|
|
|
2834
2861
|
parameters: revokeRoles.Parameters<chain, account>,
|
|
2835
2862
|
): Promise<ReturnType<action>> {
|
|
2836
2863
|
const { from: _, ...rest } = parameters
|
|
2837
|
-
return (await action(client, {
|
|
2864
|
+
return (await withExecutionError(action)(client, {
|
|
2838
2865
|
...rest,
|
|
2839
2866
|
calls: parameters.roles.map((role) => {
|
|
2840
2867
|
const call = revokeRoles.call(client, { ...parameters, role })
|
|
@@ -2978,7 +3005,7 @@ export namespace revokeRolesSync {
|
|
|
2978
3005
|
}
|
|
2979
3006
|
|
|
2980
3007
|
// TODO: exhaustive error type
|
|
2981
|
-
export type ErrorType = BaseErrorType
|
|
3008
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
2982
3009
|
}
|
|
2983
3010
|
|
|
2984
3011
|
/**
|
|
@@ -3033,7 +3060,7 @@ export namespace setSupplyCap {
|
|
|
3033
3060
|
export type ReturnValue = WriteContractReturnType
|
|
3034
3061
|
|
|
3035
3062
|
// TODO: exhaustive error type
|
|
3036
|
-
export type ErrorType = BaseErrorType
|
|
3063
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
3037
3064
|
|
|
3038
3065
|
/** @internal */
|
|
3039
3066
|
export async function inner<
|
|
@@ -3047,7 +3074,7 @@ export namespace setSupplyCap {
|
|
|
3047
3074
|
): Promise<ReturnType<action>> {
|
|
3048
3075
|
const { supplyCap, token, ...rest } = parameters
|
|
3049
3076
|
const call = setSupplyCap.call(client, { supplyCap, token })
|
|
3050
|
-
return (await action(client, {
|
|
3077
|
+
return (await withExecutionError(action)(client, {
|
|
3051
3078
|
...rest,
|
|
3052
3079
|
...call,
|
|
3053
3080
|
} as never)) as never
|
|
@@ -3179,7 +3206,7 @@ export namespace setSupplyCapSync {
|
|
|
3179
3206
|
}
|
|
3180
3207
|
|
|
3181
3208
|
// TODO: exhaustive error type
|
|
3182
|
-
export type ErrorType = BaseErrorType
|
|
3209
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
3183
3210
|
}
|
|
3184
3211
|
|
|
3185
3212
|
/**
|
|
@@ -3237,7 +3264,7 @@ export namespace setRoleAdmin {
|
|
|
3237
3264
|
export type ReturnValue = WriteContractReturnType
|
|
3238
3265
|
|
|
3239
3266
|
// TODO: exhaustive error type
|
|
3240
|
-
export type ErrorType = BaseErrorType
|
|
3267
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
3241
3268
|
|
|
3242
3269
|
/** @internal */
|
|
3243
3270
|
export async function inner<
|
|
@@ -3251,7 +3278,7 @@ export namespace setRoleAdmin {
|
|
|
3251
3278
|
): Promise<ReturnType<action>> {
|
|
3252
3279
|
const { adminRole, role, token, ...rest } = parameters
|
|
3253
3280
|
const call = setRoleAdmin.call(client, { adminRole, role, token })
|
|
3254
|
-
return (await action(client, {
|
|
3281
|
+
return (await withExecutionError(action)(client, {
|
|
3255
3282
|
...rest,
|
|
3256
3283
|
...call,
|
|
3257
3284
|
} as never)) as never
|
|
@@ -3387,7 +3414,7 @@ export namespace setRoleAdminSync {
|
|
|
3387
3414
|
}
|
|
3388
3415
|
|
|
3389
3416
|
// TODO: exhaustive error type
|
|
3390
|
-
export type ErrorType = BaseErrorType
|
|
3417
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
3391
3418
|
}
|
|
3392
3419
|
|
|
3393
3420
|
/**
|
|
@@ -3443,7 +3470,7 @@ export namespace transfer {
|
|
|
3443
3470
|
> = WriteParameters<chain, account> & Args
|
|
3444
3471
|
export type ReturnValue = WriteContractReturnType
|
|
3445
3472
|
// TODO: exhaustive error type
|
|
3446
|
-
export type ErrorType = BaseErrorType
|
|
3473
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
3447
3474
|
|
|
3448
3475
|
/** @internal */
|
|
3449
3476
|
export async function inner<
|
|
@@ -3455,7 +3482,7 @@ export namespace transfer {
|
|
|
3455
3482
|
client: Client<Transport, chain, account>,
|
|
3456
3483
|
parameters: transfer.Parameters<chain, account>,
|
|
3457
3484
|
): Promise<ReturnType<action>> {
|
|
3458
|
-
return (await action(client, {
|
|
3485
|
+
return (await withExecutionError(action)(client, {
|
|
3459
3486
|
...parameters,
|
|
3460
3487
|
...transfer.call(client, parameters as never),
|
|
3461
3488
|
} as never)) as never
|
|
@@ -3646,7 +3673,7 @@ export namespace transferSync {
|
|
|
3646
3673
|
}
|
|
3647
3674
|
>
|
|
3648
3675
|
// TODO: exhaustive error type
|
|
3649
|
-
export type ErrorType = BaseErrorType
|
|
3676
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
3650
3677
|
}
|
|
3651
3678
|
|
|
3652
3679
|
/**
|
|
@@ -3698,7 +3725,7 @@ export namespace unpause {
|
|
|
3698
3725
|
export type ReturnValue = WriteContractReturnType
|
|
3699
3726
|
|
|
3700
3727
|
// TODO: exhaustive error type
|
|
3701
|
-
export type ErrorType = BaseErrorType
|
|
3728
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
3702
3729
|
|
|
3703
3730
|
/** @internal */
|
|
3704
3731
|
export async function inner<
|
|
@@ -3712,7 +3739,7 @@ export namespace unpause {
|
|
|
3712
3739
|
): Promise<ReturnType<action>> {
|
|
3713
3740
|
const { token, ...rest } = parameters
|
|
3714
3741
|
const call = unpause.call(client, { token })
|
|
3715
|
-
return (await action(client, {
|
|
3742
|
+
return (await withExecutionError(action)(client, {
|
|
3716
3743
|
...rest,
|
|
3717
3744
|
...call,
|
|
3718
3745
|
} as never)) as never
|
|
@@ -3842,7 +3869,7 @@ export namespace unpauseSync {
|
|
|
3842
3869
|
}
|
|
3843
3870
|
|
|
3844
3871
|
// TODO: exhaustive error type
|
|
3845
|
-
export type ErrorType = BaseErrorType
|
|
3872
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
3846
3873
|
}
|
|
3847
3874
|
|
|
3848
3875
|
/**
|
|
@@ -3897,7 +3924,7 @@ export namespace prepareUpdateQuoteToken {
|
|
|
3897
3924
|
export type ReturnValue = WriteContractReturnType
|
|
3898
3925
|
|
|
3899
3926
|
// TODO: exhaustive error type
|
|
3900
|
-
export type ErrorType = BaseErrorType
|
|
3927
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
3901
3928
|
|
|
3902
3929
|
/** @internal */
|
|
3903
3930
|
export async function inner<
|
|
@@ -3911,7 +3938,7 @@ export namespace prepareUpdateQuoteToken {
|
|
|
3911
3938
|
): Promise<ReturnType<action>> {
|
|
3912
3939
|
const { quoteToken, token, ...rest } = parameters
|
|
3913
3940
|
const call = prepareUpdateQuoteToken.call(client, { quoteToken, token })
|
|
3914
|
-
return (await action(client, {
|
|
3941
|
+
return (await withExecutionError(action)(client, {
|
|
3915
3942
|
...rest,
|
|
3916
3943
|
...call,
|
|
3917
3944
|
} as never)) as never
|
|
@@ -4048,7 +4075,7 @@ export namespace prepareUpdateQuoteTokenSync {
|
|
|
4048
4075
|
>
|
|
4049
4076
|
|
|
4050
4077
|
// TODO: exhaustive error type
|
|
4051
|
-
export type ErrorType = BaseErrorType
|
|
4078
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
4052
4079
|
}
|
|
4053
4080
|
|
|
4054
4081
|
/**
|
|
@@ -4100,7 +4127,7 @@ export namespace updateQuoteToken {
|
|
|
4100
4127
|
export type ReturnValue = WriteContractReturnType
|
|
4101
4128
|
|
|
4102
4129
|
// TODO: exhaustive error type
|
|
4103
|
-
export type ErrorType = BaseErrorType
|
|
4130
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
4104
4131
|
|
|
4105
4132
|
/** @internal */
|
|
4106
4133
|
export async function inner<
|
|
@@ -4114,7 +4141,7 @@ export namespace updateQuoteToken {
|
|
|
4114
4141
|
): Promise<ReturnType<action>> {
|
|
4115
4142
|
const { token, ...rest } = parameters
|
|
4116
4143
|
const call = updateQuoteToken.call(client, { token })
|
|
4117
|
-
return (await action(client, {
|
|
4144
|
+
return (await withExecutionError(action)(client, {
|
|
4118
4145
|
...rest,
|
|
4119
4146
|
...call,
|
|
4120
4147
|
} as never)) as never
|
|
@@ -4249,7 +4276,7 @@ export namespace updateQuoteTokenSync {
|
|
|
4249
4276
|
>
|
|
4250
4277
|
|
|
4251
4278
|
// TODO: exhaustive error type
|
|
4252
|
-
export type ErrorType = BaseErrorType
|
|
4279
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
4253
4280
|
}
|
|
4254
4281
|
|
|
4255
4282
|
/**
|
|
@@ -4858,3 +4885,441 @@ export declare namespace watchUpdateQuoteToken {
|
|
|
4858
4885
|
token: TokenId.TokenIdOrAddress
|
|
4859
4886
|
}
|
|
4860
4887
|
}
|
|
4888
|
+
|
|
4889
|
+
// Errors
|
|
4890
|
+
|
|
4891
|
+
/** Errors this module throws for decoded Tempo errors. Narrow with `error.name`. */
|
|
4892
|
+
export type ExecutionErrorType =
|
|
4893
|
+
| TokenInsufficientAllowanceErrorType
|
|
4894
|
+
| TokenInsufficientBalanceErrorType
|
|
4895
|
+
| TokenPausedErrorType
|
|
4896
|
+
| TokenPolicyForbidsErrorType
|
|
4897
|
+
| TokenSupplyCapExceededErrorType
|
|
4898
|
+
| TokenUnauthorizedErrorType
|
|
4899
|
+
|
|
4900
|
+
/** `TokenInsufficientBalanceError` with a literal `name`, for narrowing. */
|
|
4901
|
+
export type TokenInsufficientBalanceErrorType =
|
|
4902
|
+
TokenInsufficientBalanceError & { name: 'TokenInsufficientBalanceError' }
|
|
4903
|
+
|
|
4904
|
+
/** Thrown when an account's TIP-20 balance is lower than the amount a call needs. */
|
|
4905
|
+
export class TokenInsufficientBalanceError extends TempoExecutionError<
|
|
4906
|
+
Errors.TempoExecutionError.Decoded<'InsufficientBalance'>
|
|
4907
|
+
> {
|
|
4908
|
+
/** Balance available. */
|
|
4909
|
+
available: bigint
|
|
4910
|
+
/** Token decimals, when known. */
|
|
4911
|
+
decimals: number | undefined
|
|
4912
|
+
/** Amount required. */
|
|
4913
|
+
required: bigint
|
|
4914
|
+
/** Token address. */
|
|
4915
|
+
token: Address
|
|
4916
|
+
|
|
4917
|
+
constructor(
|
|
4918
|
+
parameters: Errors.TempoExecutionError.Parameters & {
|
|
4919
|
+
decimals?: number | undefined
|
|
4920
|
+
},
|
|
4921
|
+
) {
|
|
4922
|
+
const { decimals } = parameters
|
|
4923
|
+
const [available, required, token] = parameters.error.args as readonly [
|
|
4924
|
+
bigint,
|
|
4925
|
+
bigint,
|
|
4926
|
+
Address,
|
|
4927
|
+
]
|
|
4928
|
+
super(parameters, {
|
|
4929
|
+
details: {
|
|
4930
|
+
token,
|
|
4931
|
+
available: formatAmount(available, decimals),
|
|
4932
|
+
required: formatAmount(required, decimals),
|
|
4933
|
+
shortfall: formatAmount(required - available, decimals),
|
|
4934
|
+
},
|
|
4935
|
+
name: 'TokenInsufficientBalanceError',
|
|
4936
|
+
shortMessage: `Insufficient balance of token "${token}".`,
|
|
4937
|
+
})
|
|
4938
|
+
this.available = available
|
|
4939
|
+
this.decimals = decimals
|
|
4940
|
+
this.required = required
|
|
4941
|
+
this.token = token
|
|
4942
|
+
}
|
|
4943
|
+
}
|
|
4944
|
+
|
|
4945
|
+
/** `TokenInsufficientAllowanceError` with a literal `name`, for narrowing. */
|
|
4946
|
+
export type TokenInsufficientAllowanceErrorType =
|
|
4947
|
+
TokenInsufficientAllowanceError & { name: 'TokenInsufficientAllowanceError' }
|
|
4948
|
+
|
|
4949
|
+
/** Thrown when a spender's TIP-20 allowance is lower than the amount it tries to transfer. */
|
|
4950
|
+
export class TokenInsufficientAllowanceError extends TempoExecutionError<
|
|
4951
|
+
Errors.TempoExecutionError.Decoded<'InsufficientAllowance'>
|
|
4952
|
+
> {
|
|
4953
|
+
/** Current allowance, when known. */
|
|
4954
|
+
allowance: bigint | undefined
|
|
4955
|
+
/** Amount the spender tried to transfer. */
|
|
4956
|
+
amount: bigint | undefined
|
|
4957
|
+
/** Token decimals, when known. */
|
|
4958
|
+
decimals: number | undefined
|
|
4959
|
+
/** Token owner. */
|
|
4960
|
+
owner: Address
|
|
4961
|
+
/** Spender. */
|
|
4962
|
+
spender: Address
|
|
4963
|
+
/** Token address. */
|
|
4964
|
+
token: Address
|
|
4965
|
+
|
|
4966
|
+
constructor(parameters: TokenInsufficientAllowanceError.Parameters) {
|
|
4967
|
+
const { allowance, amount, decimals, owner, spender, token } = parameters
|
|
4968
|
+
super(parameters, {
|
|
4969
|
+
details: {
|
|
4970
|
+
token,
|
|
4971
|
+
owner,
|
|
4972
|
+
spender,
|
|
4973
|
+
allowance: formatAmount(allowance, decimals),
|
|
4974
|
+
amount: formatAmount(amount, decimals),
|
|
4975
|
+
},
|
|
4976
|
+
name: 'TokenInsufficientAllowanceError',
|
|
4977
|
+
shortMessage: `Spender "${spender}" has an insufficient allowance from "${owner}" for token "${token}".`,
|
|
4978
|
+
})
|
|
4979
|
+
this.allowance = allowance
|
|
4980
|
+
this.amount = amount
|
|
4981
|
+
this.decimals = decimals
|
|
4982
|
+
this.owner = owner
|
|
4983
|
+
this.spender = spender
|
|
4984
|
+
this.token = token
|
|
4985
|
+
}
|
|
4986
|
+
}
|
|
4987
|
+
|
|
4988
|
+
export declare namespace TokenInsufficientAllowanceError {
|
|
4989
|
+
/** Constructor parameters. */
|
|
4990
|
+
type Parameters = Errors.TempoExecutionError.Parameters & {
|
|
4991
|
+
/** Current allowance, when known. */
|
|
4992
|
+
allowance?: bigint | undefined
|
|
4993
|
+
/** Amount the spender tried to transfer. */
|
|
4994
|
+
amount?: bigint | undefined
|
|
4995
|
+
/** Token decimals, when known. */
|
|
4996
|
+
decimals?: number | undefined
|
|
4997
|
+
/** Token owner. */
|
|
4998
|
+
owner: Address
|
|
4999
|
+
/** Spender. */
|
|
5000
|
+
spender: Address
|
|
5001
|
+
/** Token address. */
|
|
5002
|
+
token: Address
|
|
5003
|
+
}
|
|
5004
|
+
}
|
|
5005
|
+
|
|
5006
|
+
/** `TokenSupplyCapExceededError` with a literal `name`, for narrowing. */
|
|
5007
|
+
export type TokenSupplyCapExceededErrorType = TokenSupplyCapExceededError & {
|
|
5008
|
+
name: 'TokenSupplyCapExceededError'
|
|
5009
|
+
}
|
|
5010
|
+
|
|
5011
|
+
/** Thrown when minting would exceed a TIP-20 token's supply cap. */
|
|
5012
|
+
export class TokenSupplyCapExceededError extends TempoExecutionError<
|
|
5013
|
+
Errors.TempoExecutionError.Decoded<'SupplyCapExceeded'>
|
|
5014
|
+
> {
|
|
5015
|
+
/** Amount to mint. */
|
|
5016
|
+
amount: bigint | undefined
|
|
5017
|
+
/** Token decimals, when known. */
|
|
5018
|
+
decimals: number | undefined
|
|
5019
|
+
/** Supply cap, when known. */
|
|
5020
|
+
supplyCap: bigint | undefined
|
|
5021
|
+
/** Token address. */
|
|
5022
|
+
token: Address
|
|
5023
|
+
/** Current total supply, when known. */
|
|
5024
|
+
totalSupply: bigint | undefined
|
|
5025
|
+
|
|
5026
|
+
constructor(parameters: TokenSupplyCapExceededError.Parameters) {
|
|
5027
|
+
const { amount, decimals, supplyCap, token, totalSupply } = parameters
|
|
5028
|
+
super(parameters, {
|
|
5029
|
+
details: {
|
|
5030
|
+
token,
|
|
5031
|
+
amount: formatAmount(amount, decimals),
|
|
5032
|
+
'total supply': formatAmount(totalSupply, decimals),
|
|
5033
|
+
'supply cap': formatAmount(supplyCap, decimals),
|
|
5034
|
+
'mintable amount':
|
|
5035
|
+
supplyCap !== undefined && totalSupply !== undefined
|
|
5036
|
+
? formatAmount(supplyCap - totalSupply, decimals)
|
|
5037
|
+
: undefined,
|
|
5038
|
+
},
|
|
5039
|
+
name: 'TokenSupplyCapExceededError',
|
|
5040
|
+
shortMessage: `Minting exceeds the supply cap of token "${token}".`,
|
|
5041
|
+
})
|
|
5042
|
+
this.amount = amount
|
|
5043
|
+
this.decimals = decimals
|
|
5044
|
+
this.supplyCap = supplyCap
|
|
5045
|
+
this.token = token
|
|
5046
|
+
this.totalSupply = totalSupply
|
|
5047
|
+
}
|
|
5048
|
+
}
|
|
5049
|
+
|
|
5050
|
+
export declare namespace TokenSupplyCapExceededError {
|
|
5051
|
+
/** Constructor parameters. */
|
|
5052
|
+
type Parameters = Errors.TempoExecutionError.Parameters & {
|
|
5053
|
+
/** Amount to mint. */
|
|
5054
|
+
amount?: bigint | undefined
|
|
5055
|
+
/** Token decimals, when known. */
|
|
5056
|
+
decimals?: number | undefined
|
|
5057
|
+
/** Supply cap, when known. */
|
|
5058
|
+
supplyCap?: bigint | undefined
|
|
5059
|
+
/** Token address. */
|
|
5060
|
+
token: Address
|
|
5061
|
+
/** Current total supply, when known. */
|
|
5062
|
+
totalSupply?: bigint | undefined
|
|
5063
|
+
}
|
|
5064
|
+
}
|
|
5065
|
+
|
|
5066
|
+
/** `TokenPolicyForbidsError` with a literal `name`, for narrowing. */
|
|
5067
|
+
export type TokenPolicyForbidsErrorType = TokenPolicyForbidsError & {
|
|
5068
|
+
name: 'TokenPolicyForbidsError'
|
|
5069
|
+
}
|
|
5070
|
+
|
|
5071
|
+
/** Thrown when a TIP-20 token's transfer policy forbids the sender or recipient. */
|
|
5072
|
+
export class TokenPolicyForbidsError extends TempoExecutionError<
|
|
5073
|
+
Errors.TempoExecutionError.Decoded<'PolicyForbids'>
|
|
5074
|
+
> {
|
|
5075
|
+
/** Sender, when known. */
|
|
5076
|
+
from: Address | undefined
|
|
5077
|
+
/** Transfer policy ID, when known. */
|
|
5078
|
+
policyId: bigint | undefined
|
|
5079
|
+
/** Whether the policy authorizes the recipient, when known. */
|
|
5080
|
+
recipientAuthorized: boolean | undefined
|
|
5081
|
+
/** Whether the policy authorizes the sender, when known. */
|
|
5082
|
+
senderAuthorized: boolean | undefined
|
|
5083
|
+
/** Recipient, when known. */
|
|
5084
|
+
to: Address | undefined
|
|
5085
|
+
/** Token address. */
|
|
5086
|
+
token: Address
|
|
5087
|
+
|
|
5088
|
+
constructor(parameters: TokenPolicyForbidsError.Parameters) {
|
|
5089
|
+
const { from, policyId, recipientAuthorized, senderAuthorized, to, token } =
|
|
5090
|
+
parameters
|
|
5091
|
+
const party =
|
|
5092
|
+
senderAuthorized === false
|
|
5093
|
+
? `sender "${from}"`
|
|
5094
|
+
: recipientAuthorized === false
|
|
5095
|
+
? `recipient "${to}"`
|
|
5096
|
+
: 'this transfer'
|
|
5097
|
+
super(parameters, {
|
|
5098
|
+
details: {
|
|
5099
|
+
token,
|
|
5100
|
+
policy: policyId,
|
|
5101
|
+
from,
|
|
5102
|
+
to,
|
|
5103
|
+
'sender authorized': senderAuthorized?.toString(),
|
|
5104
|
+
'recipient authorized': recipientAuthorized?.toString(),
|
|
5105
|
+
},
|
|
5106
|
+
name: 'TokenPolicyForbidsError',
|
|
5107
|
+
shortMessage: `The transfer policy of token "${token}" forbids ${party}.`,
|
|
5108
|
+
})
|
|
5109
|
+
this.from = from
|
|
5110
|
+
this.policyId = policyId
|
|
5111
|
+
this.recipientAuthorized = recipientAuthorized
|
|
5112
|
+
this.senderAuthorized = senderAuthorized
|
|
5113
|
+
this.to = to
|
|
5114
|
+
this.token = token
|
|
5115
|
+
}
|
|
5116
|
+
}
|
|
5117
|
+
|
|
5118
|
+
export declare namespace TokenPolicyForbidsError {
|
|
5119
|
+
/** Constructor parameters. */
|
|
5120
|
+
type Parameters = Errors.TempoExecutionError.Parameters & {
|
|
5121
|
+
/** Sender, when known. */
|
|
5122
|
+
from?: Address | undefined
|
|
5123
|
+
/** Transfer policy ID, when known. */
|
|
5124
|
+
policyId?: bigint | undefined
|
|
5125
|
+
/** Whether the policy authorizes the recipient, when known. */
|
|
5126
|
+
recipientAuthorized?: boolean | undefined
|
|
5127
|
+
/** Whether the policy authorizes the sender, when known. */
|
|
5128
|
+
senderAuthorized?: boolean | undefined
|
|
5129
|
+
/** Recipient, when known. */
|
|
5130
|
+
to?: Address | undefined
|
|
5131
|
+
/** Token address. */
|
|
5132
|
+
token: Address
|
|
5133
|
+
}
|
|
5134
|
+
}
|
|
5135
|
+
|
|
5136
|
+
/** `TokenPausedError` with a literal `name`, for narrowing. */
|
|
5137
|
+
export type TokenPausedErrorType = TokenPausedError & {
|
|
5138
|
+
name: 'TokenPausedError'
|
|
5139
|
+
}
|
|
5140
|
+
|
|
5141
|
+
/** Thrown when calling a paused TIP-20 token. */
|
|
5142
|
+
export class TokenPausedError extends TempoExecutionError<
|
|
5143
|
+
Errors.TempoExecutionError.Decoded<'ContractPaused'>
|
|
5144
|
+
> {
|
|
5145
|
+
/** Token address. */
|
|
5146
|
+
token: Address
|
|
5147
|
+
|
|
5148
|
+
constructor(
|
|
5149
|
+
parameters: Errors.TempoExecutionError.Parameters & { token: Address },
|
|
5150
|
+
) {
|
|
5151
|
+
super(parameters, {
|
|
5152
|
+
name: 'TokenPausedError',
|
|
5153
|
+
shortMessage: `Token "${parameters.token}" is paused.`,
|
|
5154
|
+
})
|
|
5155
|
+
this.token = parameters.token
|
|
5156
|
+
}
|
|
5157
|
+
}
|
|
5158
|
+
|
|
5159
|
+
/** `TokenUnauthorizedError` with a literal `name`, for narrowing. */
|
|
5160
|
+
export type TokenUnauthorizedErrorType = TokenUnauthorizedError & {
|
|
5161
|
+
name: 'TokenUnauthorizedError'
|
|
5162
|
+
}
|
|
5163
|
+
|
|
5164
|
+
/** Thrown when an account lacks the TIP-20 role a call requires. */
|
|
5165
|
+
export class TokenUnauthorizedError extends TempoExecutionError<
|
|
5166
|
+
Errors.TempoExecutionError.Decoded<'Unauthorized'>
|
|
5167
|
+
> {
|
|
5168
|
+
/** Account that made the call. */
|
|
5169
|
+
account: Address
|
|
5170
|
+
/** Role the call requires. */
|
|
5171
|
+
role: TokenRole.TokenRole
|
|
5172
|
+
/** Token address. */
|
|
5173
|
+
token: Address
|
|
5174
|
+
|
|
5175
|
+
constructor(
|
|
5176
|
+
parameters: Errors.TempoExecutionError.Parameters & {
|
|
5177
|
+
account: Address
|
|
5178
|
+
role: TokenRole.TokenRole
|
|
5179
|
+
token: Address
|
|
5180
|
+
},
|
|
5181
|
+
) {
|
|
5182
|
+
const { account, role, token } = parameters
|
|
5183
|
+
super(parameters, {
|
|
5184
|
+
details: { token, account, role },
|
|
5185
|
+
name: 'TokenUnauthorizedError',
|
|
5186
|
+
shortMessage: `Account "${account}" does not have the "${role}" role on token "${token}".`,
|
|
5187
|
+
})
|
|
5188
|
+
this.account = account
|
|
5189
|
+
this.role = role
|
|
5190
|
+
this.token = token
|
|
5191
|
+
}
|
|
5192
|
+
}
|
|
5193
|
+
|
|
5194
|
+
/** Roles required by TIP-20 functions. */
|
|
5195
|
+
const requiredRoles: Record<string, TokenRole.TokenRole> = {
|
|
5196
|
+
burn: 'issuer',
|
|
5197
|
+
burnAt: 'burnAt',
|
|
5198
|
+
burnBlocked: 'burnBlocked',
|
|
5199
|
+
burnWithMemo: 'issuer',
|
|
5200
|
+
changeTransferPolicyId: 'defaultAdmin',
|
|
5201
|
+
completeQuoteTokenUpdate: 'defaultAdmin',
|
|
5202
|
+
mint: 'issuer',
|
|
5203
|
+
mintWithMemo: 'issuer',
|
|
5204
|
+
pause: 'pause',
|
|
5205
|
+
setLogoURI: 'defaultAdmin',
|
|
5206
|
+
setNextQuoteToken: 'defaultAdmin',
|
|
5207
|
+
setSupplyCap: 'defaultAdmin',
|
|
5208
|
+
unpause: 'unpause',
|
|
5209
|
+
}
|
|
5210
|
+
|
|
5211
|
+
/** @internal */
|
|
5212
|
+
export const errorResolvers: Resolvers = {
|
|
5213
|
+
'ContractPaused()': ({ base, call }) =>
|
|
5214
|
+
isTip20(call?.address)
|
|
5215
|
+
? new TokenPausedError({ ...base, token: call.address })
|
|
5216
|
+
: undefined,
|
|
5217
|
+
'InsufficientAllowance()': async (context) => {
|
|
5218
|
+
const { base, call, signer } = context
|
|
5219
|
+
const owner = call?.arg<Address>('from')
|
|
5220
|
+
if (!isTip20(call?.address) || !owner || !signer) return undefined
|
|
5221
|
+
const token = call.address
|
|
5222
|
+
const [allowance, decimals] = await context.read([
|
|
5223
|
+
{
|
|
5224
|
+
address: token,
|
|
5225
|
+
abi: Abis.tip20,
|
|
5226
|
+
functionName: 'allowance',
|
|
5227
|
+
args: [owner, signer.address],
|
|
5228
|
+
},
|
|
5229
|
+
{ address: token, abi: Abis.tip20, functionName: 'decimals' },
|
|
5230
|
+
])
|
|
5231
|
+
return new TokenInsufficientAllowanceError({
|
|
5232
|
+
...base,
|
|
5233
|
+
allowance: allowance?.result,
|
|
5234
|
+
amount: call.arg<bigint>('amount'),
|
|
5235
|
+
decimals: decimals?.result,
|
|
5236
|
+
owner,
|
|
5237
|
+
spender: signer.address,
|
|
5238
|
+
token,
|
|
5239
|
+
})
|
|
5240
|
+
},
|
|
5241
|
+
'InsufficientBalance(uint256,uint256,address)': async (context) => {
|
|
5242
|
+
// Selector-only revert data carries no arguments.
|
|
5243
|
+
const token = context.base.error.args?.[2] as Address | undefined
|
|
5244
|
+
if (!token) return undefined
|
|
5245
|
+
const [decimals] = await context.read([
|
|
5246
|
+
{ address: token, abi: Abis.tip20, functionName: 'decimals' },
|
|
5247
|
+
])
|
|
5248
|
+
return new TokenInsufficientBalanceError({
|
|
5249
|
+
...context.base,
|
|
5250
|
+
decimals: decimals?.result,
|
|
5251
|
+
})
|
|
5252
|
+
},
|
|
5253
|
+
'PolicyForbids()': async (context) => {
|
|
5254
|
+
const { base, call, signer } = context
|
|
5255
|
+
if (!isTip20(call?.address)) return undefined
|
|
5256
|
+
const token = call.address
|
|
5257
|
+
// Mints only check the recipient.
|
|
5258
|
+
const mint = call.functionName.startsWith('mint')
|
|
5259
|
+
const from = mint
|
|
5260
|
+
? undefined
|
|
5261
|
+
: (call.arg<Address>('from') ?? signer?.address)
|
|
5262
|
+
const to = call.arg<Address>('to')
|
|
5263
|
+
const [policyId] = await context.read([
|
|
5264
|
+
{ address: token, abi: Abis.tip20, functionName: 'transferPolicyId' },
|
|
5265
|
+
])
|
|
5266
|
+
const registry = {
|
|
5267
|
+
address: Addresses.tip403Registry,
|
|
5268
|
+
abi: Abis.tip403Registry,
|
|
5269
|
+
} as const
|
|
5270
|
+
const [sender, recipient] =
|
|
5271
|
+
policyId?.result === undefined
|
|
5272
|
+
? []
|
|
5273
|
+
: await context.read([
|
|
5274
|
+
{
|
|
5275
|
+
...registry,
|
|
5276
|
+
functionName: 'isAuthorizedSender',
|
|
5277
|
+
args: [policyId.result, from ?? zeroAddress],
|
|
5278
|
+
},
|
|
5279
|
+
{
|
|
5280
|
+
...registry,
|
|
5281
|
+
functionName: mint
|
|
5282
|
+
? 'isAuthorizedMintRecipient'
|
|
5283
|
+
: 'isAuthorizedRecipient',
|
|
5284
|
+
args: [policyId.result, to ?? zeroAddress],
|
|
5285
|
+
},
|
|
5286
|
+
])
|
|
5287
|
+
return new TokenPolicyForbidsError({
|
|
5288
|
+
...base,
|
|
5289
|
+
from,
|
|
5290
|
+
policyId: policyId?.result,
|
|
5291
|
+
recipientAuthorized: to ? recipient?.result : undefined,
|
|
5292
|
+
senderAuthorized: from ? sender?.result : undefined,
|
|
5293
|
+
to,
|
|
5294
|
+
token,
|
|
5295
|
+
})
|
|
5296
|
+
},
|
|
5297
|
+
'SupplyCapExceeded()': async (context) => {
|
|
5298
|
+
const { base, call } = context
|
|
5299
|
+
if (!isTip20(call?.address)) return undefined
|
|
5300
|
+
const token = call.address
|
|
5301
|
+
const [supplyCap, totalSupply, decimals] = await context.read([
|
|
5302
|
+
{ address: token, abi: Abis.tip20, functionName: 'supplyCap' },
|
|
5303
|
+
{ address: token, abi: Abis.tip20, functionName: 'totalSupply' },
|
|
5304
|
+
{ address: token, abi: Abis.tip20, functionName: 'decimals' },
|
|
5305
|
+
])
|
|
5306
|
+
return new TokenSupplyCapExceededError({
|
|
5307
|
+
...base,
|
|
5308
|
+
amount: call.arg<bigint>('amount'),
|
|
5309
|
+
decimals: decimals?.result,
|
|
5310
|
+
supplyCap: supplyCap?.result,
|
|
5311
|
+
token,
|
|
5312
|
+
totalSupply: totalSupply?.result,
|
|
5313
|
+
})
|
|
5314
|
+
},
|
|
5315
|
+
'Unauthorized()': ({ base, call, signer }) => {
|
|
5316
|
+
const role = call && requiredRoles[call.functionName]
|
|
5317
|
+
if (!isTip20(call?.address) || !role || !signer) return undefined
|
|
5318
|
+
return new TokenUnauthorizedError({
|
|
5319
|
+
...base,
|
|
5320
|
+
account: signer.address,
|
|
5321
|
+
role,
|
|
5322
|
+
token: call.address,
|
|
5323
|
+
})
|
|
5324
|
+
},
|
|
5325
|
+
}
|