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
|
@@ -11,12 +11,15 @@ import { sendTransaction } from '../../actions/wallet/sendTransaction.js';
|
|
|
11
11
|
import { sendTransactionSync, } from '../../actions/wallet/sendTransactionSync.js';
|
|
12
12
|
import { writeContract } from '../../actions/wallet/writeContract.js';
|
|
13
13
|
import { writeContractSync } from '../../actions/wallet/writeContractSync.js';
|
|
14
|
+
import { zeroAddress } from '../../constants/address.js';
|
|
14
15
|
import { AccountNotFoundError } from '../../errors/account.js';
|
|
15
16
|
import { encodeFunctionData } from '../../utils/abi/encodeFunctionData.js';
|
|
16
17
|
import { parseEventLogs } from '../../utils/abi/parseEventLogs.js';
|
|
17
18
|
import { formatUnits } from '../../utils/unit/formatUnits.js';
|
|
18
19
|
import * as Abis from '../Abis.js';
|
|
19
20
|
import * as Addresses from '../Addresses.js';
|
|
21
|
+
import { TempoExecutionError } from '../errors.js';
|
|
22
|
+
import { formatAmount, isTip20, withExecutionError, } from '../internal/errors.js';
|
|
20
23
|
import { defineCall, findDeclaredToken, pickWriteParameters, resolveCallParameters, resolveToken, resolveTokenWithDecimals, } from '../internal/utils.js';
|
|
21
24
|
/**
|
|
22
25
|
* Approves a spender to transfer TIP20 tokens on behalf of the caller.
|
|
@@ -50,7 +53,7 @@ export async function approve(client, parameters) {
|
|
|
50
53
|
(function (approve) {
|
|
51
54
|
/** @internal */
|
|
52
55
|
async function inner(action, client, parameters) {
|
|
53
|
-
return (await action(client, {
|
|
56
|
+
return (await withExecutionError(action)(client, {
|
|
54
57
|
...parameters,
|
|
55
58
|
...approve.call(client, parameters),
|
|
56
59
|
}));
|
|
@@ -208,7 +211,7 @@ export async function burnBlocked(client, parameters) {
|
|
|
208
211
|
async function inner(action, client, parameters) {
|
|
209
212
|
const { amount, from, token, ...rest } = parameters;
|
|
210
213
|
const call = burnBlocked.call(client, { amount, from, token });
|
|
211
|
-
return (await action(client, {
|
|
214
|
+
return (await withExecutionError(action)(client, {
|
|
212
215
|
...rest,
|
|
213
216
|
...call,
|
|
214
217
|
}));
|
|
@@ -354,7 +357,7 @@ export async function burn(client, parameters) {
|
|
|
354
357
|
async function inner(action, client, parameters) {
|
|
355
358
|
const { amount, from, memo, token, ...rest } = parameters;
|
|
356
359
|
const call = burn.call(client, { amount, from, memo, token });
|
|
357
|
-
return (await action(client, {
|
|
360
|
+
return (await withExecutionError(action)(client, {
|
|
358
361
|
...rest,
|
|
359
362
|
...call,
|
|
360
363
|
}));
|
|
@@ -514,7 +517,7 @@ export async function changeTransferPolicy(client, parameters) {
|
|
|
514
517
|
async function inner(action, client, parameters) {
|
|
515
518
|
const { policyId, token, ...rest } = parameters;
|
|
516
519
|
const call = changeTransferPolicy.call(client, { policyId, token });
|
|
517
|
-
return (await action(client, {
|
|
520
|
+
return (await withExecutionError(action)(client, {
|
|
518
521
|
...rest,
|
|
519
522
|
...call,
|
|
520
523
|
}));
|
|
@@ -660,7 +663,7 @@ export async function create(client, parameters) {
|
|
|
660
663
|
if (!admin)
|
|
661
664
|
throw new Error('admin is required.');
|
|
662
665
|
const call = create.call(client, { ...rest, admin: admin.address });
|
|
663
|
-
return (await action(client, {
|
|
666
|
+
return (await withExecutionError(action)(client, {
|
|
664
667
|
...parameters,
|
|
665
668
|
account,
|
|
666
669
|
chain,
|
|
@@ -824,7 +827,7 @@ export async function createSync(client, parameters) {
|
|
|
824
827
|
export async function getAllowance(client, parameters) {
|
|
825
828
|
const { account, decimals, spender, token, ...rest } = parameters;
|
|
826
829
|
const [amount, { decimals: resolved }] = await Promise.all([
|
|
827
|
-
readContract(client, {
|
|
830
|
+
withExecutionError(readContract)(client, {
|
|
828
831
|
...rest,
|
|
829
832
|
...getAllowance.call(client, { account, spender, token }),
|
|
830
833
|
}),
|
|
@@ -889,7 +892,7 @@ export async function getBalance(client, parameters) {
|
|
|
889
892
|
throw new AccountNotFoundError();
|
|
890
893
|
const account = parseAccount(account_).address;
|
|
891
894
|
const [amount, { decimals: resolved }] = await Promise.all([
|
|
892
|
-
readContract(client, {
|
|
895
|
+
withExecutionError(readContract)(client, {
|
|
893
896
|
...rest,
|
|
894
897
|
...getBalance.call(client, { account, token }),
|
|
895
898
|
}),
|
|
@@ -1082,7 +1085,7 @@ async function readMetadataContracts(client, parameters) {
|
|
|
1082
1085
|
deployless: true,
|
|
1083
1086
|
});
|
|
1084
1087
|
const { contracts, ...rest } = parameters;
|
|
1085
|
-
const results = await Promise.allSettled(contracts.map((contract) => readContract(client, {
|
|
1088
|
+
const results = await Promise.allSettled(contracts.map((contract) => withExecutionError(readContract)(client, {
|
|
1086
1089
|
...rest,
|
|
1087
1090
|
...contract,
|
|
1088
1091
|
})));
|
|
@@ -1124,7 +1127,7 @@ function unwrapMulticallResult(response, ...fallback) {
|
|
|
1124
1127
|
export async function getTotalSupply(client, parameters) {
|
|
1125
1128
|
const { decimals, token, ...rest } = parameters;
|
|
1126
1129
|
const [amount, { decimals: resolved }] = await Promise.all([
|
|
1127
|
-
readContract(client, {
|
|
1130
|
+
withExecutionError(readContract)(client, {
|
|
1128
1131
|
...rest,
|
|
1129
1132
|
...getTotalSupply.call(client, { token }),
|
|
1130
1133
|
}),
|
|
@@ -1182,7 +1185,7 @@ export async function getTotalSupply(client, parameters) {
|
|
|
1182
1185
|
* @returns The admin role hash.
|
|
1183
1186
|
*/
|
|
1184
1187
|
export async function getRoleAdmin(client, parameters) {
|
|
1185
|
-
return readContract(client, {
|
|
1188
|
+
return withExecutionError(readContract)(client, {
|
|
1186
1189
|
...parameters,
|
|
1187
1190
|
...getRoleAdmin.call(client, parameters),
|
|
1188
1191
|
});
|
|
@@ -1236,7 +1239,7 @@ export async function hasRole(client, parameters) {
|
|
|
1236
1239
|
const address = account ? parseAccount(account).address : undefined;
|
|
1237
1240
|
if (!address)
|
|
1238
1241
|
throw new Error('account is required.');
|
|
1239
|
-
return readContract(client, {
|
|
1242
|
+
return withExecutionError(readContract)(client, {
|
|
1240
1243
|
...parameters,
|
|
1241
1244
|
...hasRole.call(client, { ...parameters, account: address }),
|
|
1242
1245
|
});
|
|
@@ -1293,7 +1296,7 @@ export async function grantRoles(client, parameters) {
|
|
|
1293
1296
|
(function (grantRoles) {
|
|
1294
1297
|
/** @internal */
|
|
1295
1298
|
async function inner(action, client, parameters) {
|
|
1296
|
-
return (await action(client, {
|
|
1299
|
+
return (await withExecutionError(action)(client, {
|
|
1297
1300
|
...parameters,
|
|
1298
1301
|
calls: parameters.roles.map((role) => {
|
|
1299
1302
|
const call = grantRoles.call(client, { ...parameters, role });
|
|
@@ -1445,7 +1448,13 @@ export async function mint(client, parameters) {
|
|
|
1445
1448
|
async function inner(action, client, parameters) {
|
|
1446
1449
|
const { amount, memo, to, token, ...rest } = parameters;
|
|
1447
1450
|
const call = mint.call(client, { amount, memo, to, token });
|
|
1448
|
-
return (await action
|
|
1451
|
+
return (await withExecutionError(action, {
|
|
1452
|
+
hints: {
|
|
1453
|
+
Unauthorized: [
|
|
1454
|
+
'Minting requires the issuer role. Grant it to this account first.',
|
|
1455
|
+
],
|
|
1456
|
+
},
|
|
1457
|
+
})(client, {
|
|
1449
1458
|
...rest,
|
|
1450
1459
|
...call,
|
|
1451
1460
|
}));
|
|
@@ -1599,7 +1608,7 @@ export async function pause(client, parameters) {
|
|
|
1599
1608
|
async function inner(action, client, parameters) {
|
|
1600
1609
|
const { token, ...rest } = parameters;
|
|
1601
1610
|
const call = pause.call(client, { token });
|
|
1602
|
-
return (await action(client, {
|
|
1611
|
+
return (await withExecutionError(action)(client, {
|
|
1603
1612
|
...rest,
|
|
1604
1613
|
...call,
|
|
1605
1614
|
}));
|
|
@@ -1736,7 +1745,7 @@ export async function renounceRoles(client, parameters) {
|
|
|
1736
1745
|
(function (renounceRoles) {
|
|
1737
1746
|
/** @internal */
|
|
1738
1747
|
async function inner(action, client, parameters) {
|
|
1739
|
-
return (await action(client, {
|
|
1748
|
+
return (await withExecutionError(action)(client, {
|
|
1740
1749
|
...parameters,
|
|
1741
1750
|
calls: parameters.roles.map((role) => {
|
|
1742
1751
|
const call = renounceRoles.call(client, { ...parameters, role });
|
|
@@ -1885,7 +1894,7 @@ export async function revokeRoles(client, parameters) {
|
|
|
1885
1894
|
/** @internal */
|
|
1886
1895
|
async function inner(action, client, parameters) {
|
|
1887
1896
|
const { from: _, ...rest } = parameters;
|
|
1888
|
-
return (await action(client, {
|
|
1897
|
+
return (await withExecutionError(action)(client, {
|
|
1889
1898
|
...rest,
|
|
1890
1899
|
calls: parameters.roles.map((role) => {
|
|
1891
1900
|
const call = revokeRoles.call(client, { ...parameters, role });
|
|
@@ -2036,7 +2045,7 @@ export async function setSupplyCap(client, parameters) {
|
|
|
2036
2045
|
async function inner(action, client, parameters) {
|
|
2037
2046
|
const { supplyCap, token, ...rest } = parameters;
|
|
2038
2047
|
const call = setSupplyCap.call(client, { supplyCap, token });
|
|
2039
|
-
return (await action(client, {
|
|
2048
|
+
return (await withExecutionError(action)(client, {
|
|
2040
2049
|
...rest,
|
|
2041
2050
|
...call,
|
|
2042
2051
|
}));
|
|
@@ -2178,7 +2187,7 @@ export async function setRoleAdmin(client, parameters) {
|
|
|
2178
2187
|
async function inner(action, client, parameters) {
|
|
2179
2188
|
const { adminRole, role, token, ...rest } = parameters;
|
|
2180
2189
|
const call = setRoleAdmin.call(client, { adminRole, role, token });
|
|
2181
|
-
return (await action(client, {
|
|
2190
|
+
return (await withExecutionError(action)(client, {
|
|
2182
2191
|
...rest,
|
|
2183
2192
|
...call,
|
|
2184
2193
|
}));
|
|
@@ -2321,7 +2330,7 @@ export async function transfer(client, parameters) {
|
|
|
2321
2330
|
(function (transfer) {
|
|
2322
2331
|
/** @internal */
|
|
2323
2332
|
async function inner(action, client, parameters) {
|
|
2324
|
-
return (await action(client, {
|
|
2333
|
+
return (await withExecutionError(action)(client, {
|
|
2325
2334
|
...parameters,
|
|
2326
2335
|
...transfer.call(client, parameters),
|
|
2327
2336
|
}));
|
|
@@ -2499,7 +2508,7 @@ export async function unpause(client, parameters) {
|
|
|
2499
2508
|
async function inner(action, client, parameters) {
|
|
2500
2509
|
const { token, ...rest } = parameters;
|
|
2501
2510
|
const call = unpause.call(client, { token });
|
|
2502
|
-
return (await action(client, {
|
|
2511
|
+
return (await withExecutionError(action)(client, {
|
|
2503
2512
|
...rest,
|
|
2504
2513
|
...call,
|
|
2505
2514
|
}));
|
|
@@ -2638,7 +2647,7 @@ export async function prepareUpdateQuoteToken(client, parameters) {
|
|
|
2638
2647
|
async function inner(action, client, parameters) {
|
|
2639
2648
|
const { quoteToken, token, ...rest } = parameters;
|
|
2640
2649
|
const call = prepareUpdateQuoteToken.call(client, { quoteToken, token });
|
|
2641
|
-
return (await action(client, {
|
|
2650
|
+
return (await withExecutionError(action)(client, {
|
|
2642
2651
|
...rest,
|
|
2643
2652
|
...call,
|
|
2644
2653
|
}));
|
|
@@ -2774,7 +2783,7 @@ export async function updateQuoteToken(client, parameters) {
|
|
|
2774
2783
|
async function inner(action, client, parameters) {
|
|
2775
2784
|
const { token, ...rest } = parameters;
|
|
2776
2785
|
const call = updateQuoteToken.call(client, { token });
|
|
2777
|
-
return (await action(client, {
|
|
2786
|
+
return (await withExecutionError(action)(client, {
|
|
2778
2787
|
...rest,
|
|
2779
2788
|
...call,
|
|
2780
2789
|
}));
|
|
@@ -3200,4 +3209,434 @@ export function watchUpdateQuoteToken(client, parameters) {
|
|
|
3200
3209
|
strict: true,
|
|
3201
3210
|
});
|
|
3202
3211
|
}
|
|
3212
|
+
/** Thrown when an account's TIP-20 balance is lower than the amount a call needs. */
|
|
3213
|
+
export class TokenInsufficientBalanceError extends TempoExecutionError {
|
|
3214
|
+
constructor(parameters) {
|
|
3215
|
+
const { decimals } = parameters;
|
|
3216
|
+
const [available, required, token] = parameters.error.args;
|
|
3217
|
+
super(parameters, {
|
|
3218
|
+
details: {
|
|
3219
|
+
token,
|
|
3220
|
+
available: formatAmount(available, decimals),
|
|
3221
|
+
required: formatAmount(required, decimals),
|
|
3222
|
+
shortfall: formatAmount(required - available, decimals),
|
|
3223
|
+
},
|
|
3224
|
+
name: 'TokenInsufficientBalanceError',
|
|
3225
|
+
shortMessage: `Insufficient balance of token "${token}".`,
|
|
3226
|
+
});
|
|
3227
|
+
/** Balance available. */
|
|
3228
|
+
Object.defineProperty(this, "available", {
|
|
3229
|
+
enumerable: true,
|
|
3230
|
+
configurable: true,
|
|
3231
|
+
writable: true,
|
|
3232
|
+
value: void 0
|
|
3233
|
+
});
|
|
3234
|
+
/** Token decimals, when known. */
|
|
3235
|
+
Object.defineProperty(this, "decimals", {
|
|
3236
|
+
enumerable: true,
|
|
3237
|
+
configurable: true,
|
|
3238
|
+
writable: true,
|
|
3239
|
+
value: void 0
|
|
3240
|
+
});
|
|
3241
|
+
/** Amount required. */
|
|
3242
|
+
Object.defineProperty(this, "required", {
|
|
3243
|
+
enumerable: true,
|
|
3244
|
+
configurable: true,
|
|
3245
|
+
writable: true,
|
|
3246
|
+
value: void 0
|
|
3247
|
+
});
|
|
3248
|
+
/** Token address. */
|
|
3249
|
+
Object.defineProperty(this, "token", {
|
|
3250
|
+
enumerable: true,
|
|
3251
|
+
configurable: true,
|
|
3252
|
+
writable: true,
|
|
3253
|
+
value: void 0
|
|
3254
|
+
});
|
|
3255
|
+
this.available = available;
|
|
3256
|
+
this.decimals = decimals;
|
|
3257
|
+
this.required = required;
|
|
3258
|
+
this.token = token;
|
|
3259
|
+
}
|
|
3260
|
+
}
|
|
3261
|
+
/** Thrown when a spender's TIP-20 allowance is lower than the amount it tries to transfer. */
|
|
3262
|
+
export class TokenInsufficientAllowanceError extends TempoExecutionError {
|
|
3263
|
+
constructor(parameters) {
|
|
3264
|
+
const { allowance, amount, decimals, owner, spender, token } = parameters;
|
|
3265
|
+
super(parameters, {
|
|
3266
|
+
details: {
|
|
3267
|
+
token,
|
|
3268
|
+
owner,
|
|
3269
|
+
spender,
|
|
3270
|
+
allowance: formatAmount(allowance, decimals),
|
|
3271
|
+
amount: formatAmount(amount, decimals),
|
|
3272
|
+
},
|
|
3273
|
+
name: 'TokenInsufficientAllowanceError',
|
|
3274
|
+
shortMessage: `Spender "${spender}" has an insufficient allowance from "${owner}" for token "${token}".`,
|
|
3275
|
+
});
|
|
3276
|
+
/** Current allowance, when known. */
|
|
3277
|
+
Object.defineProperty(this, "allowance", {
|
|
3278
|
+
enumerable: true,
|
|
3279
|
+
configurable: true,
|
|
3280
|
+
writable: true,
|
|
3281
|
+
value: void 0
|
|
3282
|
+
});
|
|
3283
|
+
/** Amount the spender tried to transfer. */
|
|
3284
|
+
Object.defineProperty(this, "amount", {
|
|
3285
|
+
enumerable: true,
|
|
3286
|
+
configurable: true,
|
|
3287
|
+
writable: true,
|
|
3288
|
+
value: void 0
|
|
3289
|
+
});
|
|
3290
|
+
/** Token decimals, when known. */
|
|
3291
|
+
Object.defineProperty(this, "decimals", {
|
|
3292
|
+
enumerable: true,
|
|
3293
|
+
configurable: true,
|
|
3294
|
+
writable: true,
|
|
3295
|
+
value: void 0
|
|
3296
|
+
});
|
|
3297
|
+
/** Token owner. */
|
|
3298
|
+
Object.defineProperty(this, "owner", {
|
|
3299
|
+
enumerable: true,
|
|
3300
|
+
configurable: true,
|
|
3301
|
+
writable: true,
|
|
3302
|
+
value: void 0
|
|
3303
|
+
});
|
|
3304
|
+
/** Spender. */
|
|
3305
|
+
Object.defineProperty(this, "spender", {
|
|
3306
|
+
enumerable: true,
|
|
3307
|
+
configurable: true,
|
|
3308
|
+
writable: true,
|
|
3309
|
+
value: void 0
|
|
3310
|
+
});
|
|
3311
|
+
/** Token address. */
|
|
3312
|
+
Object.defineProperty(this, "token", {
|
|
3313
|
+
enumerable: true,
|
|
3314
|
+
configurable: true,
|
|
3315
|
+
writable: true,
|
|
3316
|
+
value: void 0
|
|
3317
|
+
});
|
|
3318
|
+
this.allowance = allowance;
|
|
3319
|
+
this.amount = amount;
|
|
3320
|
+
this.decimals = decimals;
|
|
3321
|
+
this.owner = owner;
|
|
3322
|
+
this.spender = spender;
|
|
3323
|
+
this.token = token;
|
|
3324
|
+
}
|
|
3325
|
+
}
|
|
3326
|
+
/** Thrown when minting would exceed a TIP-20 token's supply cap. */
|
|
3327
|
+
export class TokenSupplyCapExceededError extends TempoExecutionError {
|
|
3328
|
+
constructor(parameters) {
|
|
3329
|
+
const { amount, decimals, supplyCap, token, totalSupply } = parameters;
|
|
3330
|
+
super(parameters, {
|
|
3331
|
+
details: {
|
|
3332
|
+
token,
|
|
3333
|
+
amount: formatAmount(amount, decimals),
|
|
3334
|
+
'total supply': formatAmount(totalSupply, decimals),
|
|
3335
|
+
'supply cap': formatAmount(supplyCap, decimals),
|
|
3336
|
+
'mintable amount': supplyCap !== undefined && totalSupply !== undefined
|
|
3337
|
+
? formatAmount(supplyCap - totalSupply, decimals)
|
|
3338
|
+
: undefined,
|
|
3339
|
+
},
|
|
3340
|
+
name: 'TokenSupplyCapExceededError',
|
|
3341
|
+
shortMessage: `Minting exceeds the supply cap of token "${token}".`,
|
|
3342
|
+
});
|
|
3343
|
+
/** Amount to mint. */
|
|
3344
|
+
Object.defineProperty(this, "amount", {
|
|
3345
|
+
enumerable: true,
|
|
3346
|
+
configurable: true,
|
|
3347
|
+
writable: true,
|
|
3348
|
+
value: void 0
|
|
3349
|
+
});
|
|
3350
|
+
/** Token decimals, when known. */
|
|
3351
|
+
Object.defineProperty(this, "decimals", {
|
|
3352
|
+
enumerable: true,
|
|
3353
|
+
configurable: true,
|
|
3354
|
+
writable: true,
|
|
3355
|
+
value: void 0
|
|
3356
|
+
});
|
|
3357
|
+
/** Supply cap, when known. */
|
|
3358
|
+
Object.defineProperty(this, "supplyCap", {
|
|
3359
|
+
enumerable: true,
|
|
3360
|
+
configurable: true,
|
|
3361
|
+
writable: true,
|
|
3362
|
+
value: void 0
|
|
3363
|
+
});
|
|
3364
|
+
/** Token address. */
|
|
3365
|
+
Object.defineProperty(this, "token", {
|
|
3366
|
+
enumerable: true,
|
|
3367
|
+
configurable: true,
|
|
3368
|
+
writable: true,
|
|
3369
|
+
value: void 0
|
|
3370
|
+
});
|
|
3371
|
+
/** Current total supply, when known. */
|
|
3372
|
+
Object.defineProperty(this, "totalSupply", {
|
|
3373
|
+
enumerable: true,
|
|
3374
|
+
configurable: true,
|
|
3375
|
+
writable: true,
|
|
3376
|
+
value: void 0
|
|
3377
|
+
});
|
|
3378
|
+
this.amount = amount;
|
|
3379
|
+
this.decimals = decimals;
|
|
3380
|
+
this.supplyCap = supplyCap;
|
|
3381
|
+
this.token = token;
|
|
3382
|
+
this.totalSupply = totalSupply;
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
/** Thrown when a TIP-20 token's transfer policy forbids the sender or recipient. */
|
|
3386
|
+
export class TokenPolicyForbidsError extends TempoExecutionError {
|
|
3387
|
+
constructor(parameters) {
|
|
3388
|
+
const { from, policyId, recipientAuthorized, senderAuthorized, to, token } = parameters;
|
|
3389
|
+
const party = senderAuthorized === false
|
|
3390
|
+
? `sender "${from}"`
|
|
3391
|
+
: recipientAuthorized === false
|
|
3392
|
+
? `recipient "${to}"`
|
|
3393
|
+
: 'this transfer';
|
|
3394
|
+
super(parameters, {
|
|
3395
|
+
details: {
|
|
3396
|
+
token,
|
|
3397
|
+
policy: policyId,
|
|
3398
|
+
from,
|
|
3399
|
+
to,
|
|
3400
|
+
'sender authorized': senderAuthorized?.toString(),
|
|
3401
|
+
'recipient authorized': recipientAuthorized?.toString(),
|
|
3402
|
+
},
|
|
3403
|
+
name: 'TokenPolicyForbidsError',
|
|
3404
|
+
shortMessage: `The transfer policy of token "${token}" forbids ${party}.`,
|
|
3405
|
+
});
|
|
3406
|
+
/** Sender, when known. */
|
|
3407
|
+
Object.defineProperty(this, "from", {
|
|
3408
|
+
enumerable: true,
|
|
3409
|
+
configurable: true,
|
|
3410
|
+
writable: true,
|
|
3411
|
+
value: void 0
|
|
3412
|
+
});
|
|
3413
|
+
/** Transfer policy ID, when known. */
|
|
3414
|
+
Object.defineProperty(this, "policyId", {
|
|
3415
|
+
enumerable: true,
|
|
3416
|
+
configurable: true,
|
|
3417
|
+
writable: true,
|
|
3418
|
+
value: void 0
|
|
3419
|
+
});
|
|
3420
|
+
/** Whether the policy authorizes the recipient, when known. */
|
|
3421
|
+
Object.defineProperty(this, "recipientAuthorized", {
|
|
3422
|
+
enumerable: true,
|
|
3423
|
+
configurable: true,
|
|
3424
|
+
writable: true,
|
|
3425
|
+
value: void 0
|
|
3426
|
+
});
|
|
3427
|
+
/** Whether the policy authorizes the sender, when known. */
|
|
3428
|
+
Object.defineProperty(this, "senderAuthorized", {
|
|
3429
|
+
enumerable: true,
|
|
3430
|
+
configurable: true,
|
|
3431
|
+
writable: true,
|
|
3432
|
+
value: void 0
|
|
3433
|
+
});
|
|
3434
|
+
/** Recipient, when known. */
|
|
3435
|
+
Object.defineProperty(this, "to", {
|
|
3436
|
+
enumerable: true,
|
|
3437
|
+
configurable: true,
|
|
3438
|
+
writable: true,
|
|
3439
|
+
value: void 0
|
|
3440
|
+
});
|
|
3441
|
+
/** Token address. */
|
|
3442
|
+
Object.defineProperty(this, "token", {
|
|
3443
|
+
enumerable: true,
|
|
3444
|
+
configurable: true,
|
|
3445
|
+
writable: true,
|
|
3446
|
+
value: void 0
|
|
3447
|
+
});
|
|
3448
|
+
this.from = from;
|
|
3449
|
+
this.policyId = policyId;
|
|
3450
|
+
this.recipientAuthorized = recipientAuthorized;
|
|
3451
|
+
this.senderAuthorized = senderAuthorized;
|
|
3452
|
+
this.to = to;
|
|
3453
|
+
this.token = token;
|
|
3454
|
+
}
|
|
3455
|
+
}
|
|
3456
|
+
/** Thrown when calling a paused TIP-20 token. */
|
|
3457
|
+
export class TokenPausedError extends TempoExecutionError {
|
|
3458
|
+
constructor(parameters) {
|
|
3459
|
+
super(parameters, {
|
|
3460
|
+
name: 'TokenPausedError',
|
|
3461
|
+
shortMessage: `Token "${parameters.token}" is paused.`,
|
|
3462
|
+
});
|
|
3463
|
+
/** Token address. */
|
|
3464
|
+
Object.defineProperty(this, "token", {
|
|
3465
|
+
enumerable: true,
|
|
3466
|
+
configurable: true,
|
|
3467
|
+
writable: true,
|
|
3468
|
+
value: void 0
|
|
3469
|
+
});
|
|
3470
|
+
this.token = parameters.token;
|
|
3471
|
+
}
|
|
3472
|
+
}
|
|
3473
|
+
/** Thrown when an account lacks the TIP-20 role a call requires. */
|
|
3474
|
+
export class TokenUnauthorizedError extends TempoExecutionError {
|
|
3475
|
+
constructor(parameters) {
|
|
3476
|
+
const { account, role, token } = parameters;
|
|
3477
|
+
super(parameters, {
|
|
3478
|
+
details: { token, account, role },
|
|
3479
|
+
name: 'TokenUnauthorizedError',
|
|
3480
|
+
shortMessage: `Account "${account}" does not have the "${role}" role on token "${token}".`,
|
|
3481
|
+
});
|
|
3482
|
+
/** Account that made the call. */
|
|
3483
|
+
Object.defineProperty(this, "account", {
|
|
3484
|
+
enumerable: true,
|
|
3485
|
+
configurable: true,
|
|
3486
|
+
writable: true,
|
|
3487
|
+
value: void 0
|
|
3488
|
+
});
|
|
3489
|
+
/** Role the call requires. */
|
|
3490
|
+
Object.defineProperty(this, "role", {
|
|
3491
|
+
enumerable: true,
|
|
3492
|
+
configurable: true,
|
|
3493
|
+
writable: true,
|
|
3494
|
+
value: void 0
|
|
3495
|
+
});
|
|
3496
|
+
/** Token address. */
|
|
3497
|
+
Object.defineProperty(this, "token", {
|
|
3498
|
+
enumerable: true,
|
|
3499
|
+
configurable: true,
|
|
3500
|
+
writable: true,
|
|
3501
|
+
value: void 0
|
|
3502
|
+
});
|
|
3503
|
+
this.account = account;
|
|
3504
|
+
this.role = role;
|
|
3505
|
+
this.token = token;
|
|
3506
|
+
}
|
|
3507
|
+
}
|
|
3508
|
+
/** Roles required by TIP-20 functions. */
|
|
3509
|
+
const requiredRoles = {
|
|
3510
|
+
burn: 'issuer',
|
|
3511
|
+
burnAt: 'burnAt',
|
|
3512
|
+
burnBlocked: 'burnBlocked',
|
|
3513
|
+
burnWithMemo: 'issuer',
|
|
3514
|
+
changeTransferPolicyId: 'defaultAdmin',
|
|
3515
|
+
completeQuoteTokenUpdate: 'defaultAdmin',
|
|
3516
|
+
mint: 'issuer',
|
|
3517
|
+
mintWithMemo: 'issuer',
|
|
3518
|
+
pause: 'pause',
|
|
3519
|
+
setLogoURI: 'defaultAdmin',
|
|
3520
|
+
setNextQuoteToken: 'defaultAdmin',
|
|
3521
|
+
setSupplyCap: 'defaultAdmin',
|
|
3522
|
+
unpause: 'unpause',
|
|
3523
|
+
};
|
|
3524
|
+
/** @internal */
|
|
3525
|
+
export const errorResolvers = {
|
|
3526
|
+
'ContractPaused()': ({ base, call }) => isTip20(call?.address)
|
|
3527
|
+
? new TokenPausedError({ ...base, token: call.address })
|
|
3528
|
+
: undefined,
|
|
3529
|
+
'InsufficientAllowance()': async (context) => {
|
|
3530
|
+
const { base, call, signer } = context;
|
|
3531
|
+
const owner = call?.arg('from');
|
|
3532
|
+
if (!isTip20(call?.address) || !owner || !signer)
|
|
3533
|
+
return undefined;
|
|
3534
|
+
const token = call.address;
|
|
3535
|
+
const [allowance, decimals] = await context.read([
|
|
3536
|
+
{
|
|
3537
|
+
address: token,
|
|
3538
|
+
abi: Abis.tip20,
|
|
3539
|
+
functionName: 'allowance',
|
|
3540
|
+
args: [owner, signer.address],
|
|
3541
|
+
},
|
|
3542
|
+
{ address: token, abi: Abis.tip20, functionName: 'decimals' },
|
|
3543
|
+
]);
|
|
3544
|
+
return new TokenInsufficientAllowanceError({
|
|
3545
|
+
...base,
|
|
3546
|
+
allowance: allowance?.result,
|
|
3547
|
+
amount: call.arg('amount'),
|
|
3548
|
+
decimals: decimals?.result,
|
|
3549
|
+
owner,
|
|
3550
|
+
spender: signer.address,
|
|
3551
|
+
token,
|
|
3552
|
+
});
|
|
3553
|
+
},
|
|
3554
|
+
'InsufficientBalance(uint256,uint256,address)': async (context) => {
|
|
3555
|
+
// Selector-only revert data carries no arguments.
|
|
3556
|
+
const token = context.base.error.args?.[2];
|
|
3557
|
+
if (!token)
|
|
3558
|
+
return undefined;
|
|
3559
|
+
const [decimals] = await context.read([
|
|
3560
|
+
{ address: token, abi: Abis.tip20, functionName: 'decimals' },
|
|
3561
|
+
]);
|
|
3562
|
+
return new TokenInsufficientBalanceError({
|
|
3563
|
+
...context.base,
|
|
3564
|
+
decimals: decimals?.result,
|
|
3565
|
+
});
|
|
3566
|
+
},
|
|
3567
|
+
'PolicyForbids()': async (context) => {
|
|
3568
|
+
const { base, call, signer } = context;
|
|
3569
|
+
if (!isTip20(call?.address))
|
|
3570
|
+
return undefined;
|
|
3571
|
+
const token = call.address;
|
|
3572
|
+
// Mints only check the recipient.
|
|
3573
|
+
const mint = call.functionName.startsWith('mint');
|
|
3574
|
+
const from = mint
|
|
3575
|
+
? undefined
|
|
3576
|
+
: (call.arg('from') ?? signer?.address);
|
|
3577
|
+
const to = call.arg('to');
|
|
3578
|
+
const [policyId] = await context.read([
|
|
3579
|
+
{ address: token, abi: Abis.tip20, functionName: 'transferPolicyId' },
|
|
3580
|
+
]);
|
|
3581
|
+
const registry = {
|
|
3582
|
+
address: Addresses.tip403Registry,
|
|
3583
|
+
abi: Abis.tip403Registry,
|
|
3584
|
+
};
|
|
3585
|
+
const [sender, recipient] = policyId?.result === undefined
|
|
3586
|
+
? []
|
|
3587
|
+
: await context.read([
|
|
3588
|
+
{
|
|
3589
|
+
...registry,
|
|
3590
|
+
functionName: 'isAuthorizedSender',
|
|
3591
|
+
args: [policyId.result, from ?? zeroAddress],
|
|
3592
|
+
},
|
|
3593
|
+
{
|
|
3594
|
+
...registry,
|
|
3595
|
+
functionName: mint
|
|
3596
|
+
? 'isAuthorizedMintRecipient'
|
|
3597
|
+
: 'isAuthorizedRecipient',
|
|
3598
|
+
args: [policyId.result, to ?? zeroAddress],
|
|
3599
|
+
},
|
|
3600
|
+
]);
|
|
3601
|
+
return new TokenPolicyForbidsError({
|
|
3602
|
+
...base,
|
|
3603
|
+
from,
|
|
3604
|
+
policyId: policyId?.result,
|
|
3605
|
+
recipientAuthorized: to ? recipient?.result : undefined,
|
|
3606
|
+
senderAuthorized: from ? sender?.result : undefined,
|
|
3607
|
+
to,
|
|
3608
|
+
token,
|
|
3609
|
+
});
|
|
3610
|
+
},
|
|
3611
|
+
'SupplyCapExceeded()': async (context) => {
|
|
3612
|
+
const { base, call } = context;
|
|
3613
|
+
if (!isTip20(call?.address))
|
|
3614
|
+
return undefined;
|
|
3615
|
+
const token = call.address;
|
|
3616
|
+
const [supplyCap, totalSupply, decimals] = await context.read([
|
|
3617
|
+
{ address: token, abi: Abis.tip20, functionName: 'supplyCap' },
|
|
3618
|
+
{ address: token, abi: Abis.tip20, functionName: 'totalSupply' },
|
|
3619
|
+
{ address: token, abi: Abis.tip20, functionName: 'decimals' },
|
|
3620
|
+
]);
|
|
3621
|
+
return new TokenSupplyCapExceededError({
|
|
3622
|
+
...base,
|
|
3623
|
+
amount: call.arg('amount'),
|
|
3624
|
+
decimals: decimals?.result,
|
|
3625
|
+
supplyCap: supplyCap?.result,
|
|
3626
|
+
token,
|
|
3627
|
+
totalSupply: totalSupply?.result,
|
|
3628
|
+
});
|
|
3629
|
+
},
|
|
3630
|
+
'Unauthorized()': ({ base, call, signer }) => {
|
|
3631
|
+
const role = call && requiredRoles[call.functionName];
|
|
3632
|
+
if (!isTip20(call?.address) || !role || !signer)
|
|
3633
|
+
return undefined;
|
|
3634
|
+
return new TokenUnauthorizedError({
|
|
3635
|
+
...base,
|
|
3636
|
+
account: signer.address,
|
|
3637
|
+
role,
|
|
3638
|
+
token: call.address,
|
|
3639
|
+
});
|
|
3640
|
+
},
|
|
3641
|
+
};
|
|
3203
3642
|
//# sourceMappingURL=token.js.map
|