viem 2.57.11 → 2.57.13
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 +62 -0
- package/_cjs/actions/public/fillTransaction.js +6 -3
- package/_cjs/actions/public/fillTransaction.js.map +1 -1
- package/_cjs/actions/public/waitForTransactionReceipt.js +83 -23
- package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_cjs/actions/public/watchContractEvent.js +58 -29
- package/_cjs/actions/public/watchContractEvent.js.map +1 -1
- package/_cjs/actions/public/watchEvent.js +58 -28
- package/_cjs/actions/public/watchEvent.js.map +1 -1
- package/_cjs/actions/token/approve.js +1 -1
- package/_cjs/actions/token/approve.js.map +1 -1
- package/_cjs/actions/token/getAllowance.js +1 -1
- package/_cjs/actions/token/getAllowance.js.map +1 -1
- package/_cjs/actions/token/getBalance.js +1 -1
- package/_cjs/actions/token/getBalance.js.map +1 -1
- package/_cjs/actions/token/getTotalSupply.js +1 -1
- package/_cjs/actions/token/getTotalSupply.js.map +1 -1
- package/_cjs/actions/token/transfer.js +1 -1
- package/_cjs/actions/token/transfer.js.map +1 -1
- package/_cjs/actions/wallet/sendCalls.js +1 -1
- package/_cjs/actions/wallet/sendCalls.js.map +1 -1
- package/_cjs/chains/definitions/molibra.js +21 -0
- package/_cjs/chains/definitions/molibra.js.map +1 -0
- package/_cjs/chains/definitions/valuechain.js +22 -0
- package/_cjs/chains/definitions/valuechain.js.map +1 -0
- package/_cjs/chains/definitions/valuechainTestnet.js +23 -0
- package/_cjs/chains/definitions/valuechainTestnet.js.map +1 -0
- package/_cjs/chains/index.js +13 -7
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/clients/decorators/public.js.map +1 -1
- package/_cjs/clients/transports/http.js +5 -1
- package/_cjs/clients/transports/http.js.map +1 -1
- package/_cjs/errors/node.js +1 -1
- package/_cjs/errors/node.js.map +1 -1
- package/_cjs/errors/request.js +20 -2
- package/_cjs/errors/request.js.map +1 -1
- package/_cjs/errors/typedData.js +3 -1
- package/_cjs/errors/typedData.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/op-stack/abis.js +52 -0
- package/_cjs/op-stack/abis.js.map +1 -1
- package/_cjs/op-stack/actions/getTimeToFinalize.js +53 -4
- package/_cjs/op-stack/actions/getTimeToFinalize.js.map +1 -1
- package/_cjs/op-stack/actions/getTimeToProve.js +29 -2
- package/_cjs/op-stack/actions/getTimeToProve.js.map +1 -1
- package/_cjs/op-stack/actions/getWithdrawalStatus.js +20 -4
- package/_cjs/op-stack/actions/getWithdrawalStatus.js.map +1 -1
- package/_cjs/op-stack/actions/waitToProve.js +28 -2
- package/_cjs/op-stack/actions/waitToProve.js.map +1 -1
- package/_cjs/op-stack/errors/withdrawal.js +12 -1
- package/_cjs/op-stack/errors/withdrawal.js.map +1 -1
- package/_cjs/tempo/Account.js +6 -9
- package/_cjs/tempo/Account.js.map +1 -1
- package/_cjs/tempo/Addresses.js +1 -2
- package/_cjs/tempo/Addresses.js.map +1 -1
- package/_cjs/tempo/Formatters.js +13 -2
- package/_cjs/tempo/Formatters.js.map +1 -1
- package/_cjs/tempo/Relay.js.map +1 -1
- package/_cjs/tempo/Transaction.js.map +1 -1
- package/_cjs/tempo/accounts/Config.js +22 -12
- package/_cjs/tempo/accounts/Config.js.map +1 -1
- package/_cjs/tempo/actions/accessKey.js +8 -8
- package/_cjs/tempo/actions/accessKey.js.map +1 -1
- package/_cjs/tempo/actions/accounts.js +5 -5
- package/_cjs/tempo/actions/accounts.js.map +1 -1
- package/_cjs/tempo/actions/amm.js +4 -4
- package/_cjs/tempo/actions/amm.js.map +1 -1
- package/_cjs/tempo/actions/channel.js +7 -7
- package/_cjs/tempo/actions/channel.js.map +1 -1
- package/_cjs/tempo/actions/dex.js +14 -14
- package/_cjs/tempo/actions/dex.js.map +1 -1
- package/_cjs/tempo/actions/earn/deployment.js +3 -3
- package/_cjs/tempo/actions/earn/deployment.js.map +1 -1
- package/_cjs/tempo/actions/earn.js +6 -6
- package/_cjs/tempo/actions/earn.js.map +1 -1
- package/_cjs/tempo/actions/fee.js +4 -4
- package/_cjs/tempo/actions/fee.js.map +1 -1
- package/_cjs/tempo/actions/nonce.js +1 -1
- package/_cjs/tempo/actions/nonce.js.map +1 -1
- package/_cjs/tempo/actions/policy.js +6 -6
- package/_cjs/tempo/actions/policy.js.map +1 -1
- package/_cjs/tempo/actions/propAmm.js +10 -10
- package/_cjs/tempo/actions/propAmm.js.map +1 -1
- package/_cjs/tempo/actions/receivePolicy.js +6 -6
- package/_cjs/tempo/actions/receivePolicy.js.map +1 -1
- package/_cjs/tempo/actions/reward.js +6 -6
- package/_cjs/tempo/actions/reward.js.map +1 -1
- package/_cjs/tempo/actions/token.js +21 -21
- package/_cjs/tempo/actions/token.js.map +1 -1
- package/_cjs/tempo/actions/validator.js +11 -11
- package/_cjs/tempo/actions/validator.js.map +1 -1
- package/_cjs/tempo/actions/virtualAddress.js +2 -2
- package/_cjs/tempo/actions/virtualAddress.js.map +1 -1
- package/_cjs/tempo/chainConfig.js +11 -4
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_cjs/tempo/internal/relay/accounts.js +42 -7
- package/_cjs/tempo/internal/relay/accounts.js.map +1 -1
- package/_cjs/tempo/internal/relay/feePayer.js +4 -1
- package/_cjs/tempo/internal/relay/feePayer.js.map +1 -1
- package/_cjs/utils/abi/getAbiItem.js +33 -12
- package/_cjs/utils/abi/getAbiItem.js.map +1 -1
- package/_cjs/utils/abi/parseEventLogs.js +18 -10
- package/_cjs/utils/abi/parseEventLogs.js.map +1 -1
- package/_cjs/utils/authorization/serializeAuthorizationList.js +4 -1
- package/_cjs/utils/authorization/serializeAuthorizationList.js.map +1 -1
- package/_cjs/utils/buildRequest.js +25 -14
- package/_cjs/utils/buildRequest.js.map +1 -1
- package/_cjs/utils/data/isHex.js +3 -1
- package/_cjs/utils/data/isHex.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 +24 -4
- package/_cjs/utils/rpc/http.js.map +1 -1
- package/_cjs/utils/signature/compactSignatureToSignature.js +3 -2
- package/_cjs/utils/signature/compactSignatureToSignature.js.map +1 -1
- package/_cjs/utils/signature/hashTypedData.js +1 -2
- package/_cjs/utils/signature/hashTypedData.js.map +1 -1
- package/_cjs/utils/signature/signatureToCompactSignature.js +15 -7
- package/_cjs/utils/signature/signatureToCompactSignature.js.map +1 -1
- package/_cjs/utils/siwe/createSiweMessage.js +1 -1
- package/_cjs/utils/siwe/createSiweMessage.js.map +1 -1
- package/_cjs/utils/typedData.js +6 -7
- package/_cjs/utils/typedData.js.map +1 -1
- package/_cjs/utils/wait.js +1 -1
- package/_cjs/utils/wait.js.map +1 -1
- package/_esm/actions/public/fillTransaction.js +8 -3
- package/_esm/actions/public/fillTransaction.js.map +1 -1
- package/_esm/actions/public/waitForTransactionReceipt.js +101 -23
- package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_esm/actions/public/watchContractEvent.js +73 -36
- package/_esm/actions/public/watchContractEvent.js.map +1 -1
- package/_esm/actions/public/watchEvent.js +73 -35
- package/_esm/actions/public/watchEvent.js.map +1 -1
- package/_esm/actions/token/approve.js +1 -1
- package/_esm/actions/token/approve.js.map +1 -1
- package/_esm/actions/token/getAllowance.js +1 -1
- package/_esm/actions/token/getAllowance.js.map +1 -1
- package/_esm/actions/token/getBalance.js +1 -1
- package/_esm/actions/token/getBalance.js.map +1 -1
- package/_esm/actions/token/getTotalSupply.js +1 -1
- package/_esm/actions/token/getTotalSupply.js.map +1 -1
- package/_esm/actions/token/transfer.js +1 -1
- package/_esm/actions/token/transfer.js.map +1 -1
- package/_esm/actions/wallet/sendCalls.js +1 -1
- package/_esm/actions/wallet/sendCalls.js.map +1 -1
- package/_esm/chains/definitions/molibra.js +18 -0
- package/_esm/chains/definitions/molibra.js.map +1 -0
- package/_esm/chains/definitions/valuechain.js +20 -0
- package/_esm/chains/definitions/valuechain.js.map +1 -0
- package/_esm/chains/definitions/valuechainTestnet.js +21 -0
- package/_esm/chains/definitions/valuechainTestnet.js.map +1 -0
- package/_esm/chains/index.js +5 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/clients/decorators/public.js.map +1 -1
- package/_esm/clients/transports/http.js +6 -1
- package/_esm/clients/transports/http.js.map +1 -1
- package/_esm/errors/node.js +1 -1
- package/_esm/errors/node.js.map +1 -1
- package/_esm/errors/request.js +22 -2
- package/_esm/errors/request.js.map +1 -1
- package/_esm/errors/typedData.js +3 -1
- package/_esm/errors/typedData.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/op-stack/abis.js +52 -0
- package/_esm/op-stack/abis.js.map +1 -1
- package/_esm/op-stack/actions/getTimeToFinalize.js +64 -6
- package/_esm/op-stack/actions/getTimeToFinalize.js.map +1 -1
- package/_esm/op-stack/actions/getTimeToProve.js +30 -2
- package/_esm/op-stack/actions/getTimeToProve.js.map +1 -1
- package/_esm/op-stack/actions/getWithdrawalStatus.js +24 -5
- package/_esm/op-stack/actions/getWithdrawalStatus.js.map +1 -1
- package/_esm/op-stack/actions/waitToProve.js +30 -3
- package/_esm/op-stack/actions/waitToProve.js.map +1 -1
- package/_esm/op-stack/errors/withdrawal.js +10 -0
- package/_esm/op-stack/errors/withdrawal.js.map +1 -1
- package/_esm/tempo/Account.js +6 -9
- package/_esm/tempo/Account.js.map +1 -1
- package/_esm/tempo/Addresses.js +0 -2
- package/_esm/tempo/Addresses.js.map +1 -1
- package/_esm/tempo/Formatters.js +12 -2
- package/_esm/tempo/Formatters.js.map +1 -1
- package/_esm/tempo/Relay.js.map +1 -1
- package/_esm/tempo/Transaction.js.map +1 -1
- package/_esm/tempo/accounts/Config.js +28 -16
- package/_esm/tempo/accounts/Config.js.map +1 -1
- package/_esm/tempo/actions/accessKey.js +8 -8
- package/_esm/tempo/actions/accessKey.js.map +1 -1
- package/_esm/tempo/actions/accounts.js +7 -7
- package/_esm/tempo/actions/accounts.js.map +1 -1
- package/_esm/tempo/actions/amm.js +4 -4
- package/_esm/tempo/actions/amm.js.map +1 -1
- package/_esm/tempo/actions/channel.js +7 -7
- package/_esm/tempo/actions/channel.js.map +1 -1
- package/_esm/tempo/actions/dex.js +14 -14
- package/_esm/tempo/actions/dex.js.map +1 -1
- package/_esm/tempo/actions/earn/deployment.js +3 -3
- package/_esm/tempo/actions/earn/deployment.js.map +1 -1
- package/_esm/tempo/actions/earn.js +6 -6
- package/_esm/tempo/actions/earn.js.map +1 -1
- package/_esm/tempo/actions/fee.js +4 -4
- package/_esm/tempo/actions/fee.js.map +1 -1
- package/_esm/tempo/actions/nonce.js +1 -1
- package/_esm/tempo/actions/nonce.js.map +1 -1
- package/_esm/tempo/actions/policy.js +6 -6
- package/_esm/tempo/actions/policy.js.map +1 -1
- package/_esm/tempo/actions/propAmm.js +10 -10
- package/_esm/tempo/actions/propAmm.js.map +1 -1
- package/_esm/tempo/actions/receivePolicy.js +6 -6
- package/_esm/tempo/actions/receivePolicy.js.map +1 -1
- package/_esm/tempo/actions/reward.js +6 -6
- package/_esm/tempo/actions/reward.js.map +1 -1
- package/_esm/tempo/actions/token.js +21 -21
- package/_esm/tempo/actions/token.js.map +1 -1
- package/_esm/tempo/actions/validator.js +11 -11
- package/_esm/tempo/actions/validator.js.map +1 -1
- package/_esm/tempo/actions/virtualAddress.js +2 -2
- package/_esm/tempo/actions/virtualAddress.js.map +1 -1
- package/_esm/tempo/chainConfig.js +13 -4
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_esm/tempo/internal/relay/accounts.js +44 -7
- package/_esm/tempo/internal/relay/accounts.js.map +1 -1
- package/_esm/tempo/internal/relay/feePayer.js +4 -1
- package/_esm/tempo/internal/relay/feePayer.js.map +1 -1
- package/_esm/utils/abi/getAbiItem.js +36 -14
- package/_esm/utils/abi/getAbiItem.js.map +1 -1
- package/_esm/utils/abi/parseEventLogs.js +25 -11
- package/_esm/utils/abi/parseEventLogs.js.map +1 -1
- package/_esm/utils/authorization/serializeAuthorizationList.js +7 -1
- package/_esm/utils/authorization/serializeAuthorizationList.js.map +1 -1
- package/_esm/utils/buildRequest.js +29 -15
- package/_esm/utils/buildRequest.js.map +1 -1
- package/_esm/utils/data/isHex.js +3 -1
- package/_esm/utils/data/isHex.js.map +1 -1
- package/_esm/utils/hash/normalizeSignature.js +1 -1
- package/_esm/utils/hash/normalizeSignature.js.map +1 -1
- package/_esm/utils/hash/toSignature.js +1 -1
- package/_esm/utils/hash/toSignatureHash.js +1 -1
- package/_esm/utils/rpc/http.js +29 -7
- package/_esm/utils/rpc/http.js.map +1 -1
- package/_esm/utils/signature/compactSignatureToSignature.js +3 -2
- package/_esm/utils/signature/compactSignatureToSignature.js.map +1 -1
- package/_esm/utils/signature/hashTypedData.js +1 -2
- package/_esm/utils/signature/hashTypedData.js.map +1 -1
- package/_esm/utils/signature/signatureToCompactSignature.js +16 -7
- package/_esm/utils/signature/signatureToCompactSignature.js.map +1 -1
- package/_esm/utils/siwe/createSiweMessage.js +1 -1
- package/_esm/utils/siwe/createSiweMessage.js.map +1 -1
- package/_esm/utils/typedData.js +12 -8
- package/_esm/utils/typedData.js.map +1 -1
- package/_esm/utils/wait.js +2 -1
- package/_esm/utils/wait.js.map +1 -1
- package/_types/actions/getContract.d.ts +1 -1
- package/_types/actions/public/fillTransaction.d.ts.map +1 -1
- package/_types/actions/public/waitForTransactionReceipt.d.ts +31 -1
- package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
- package/_types/actions/public/watchContractEvent.d.ts +1 -1
- package/_types/actions/public/watchContractEvent.d.ts.map +1 -1
- package/_types/actions/public/watchEvent.d.ts +1 -1
- package/_types/actions/public/watchEvent.d.ts.map +1 -1
- package/_types/chains/definitions/molibra.d.ts +52 -0
- package/_types/chains/definitions/molibra.d.ts.map +1 -0
- package/_types/chains/definitions/tempo.d.ts +14 -6
- package/_types/chains/definitions/tempo.d.ts.map +1 -1
- package/_types/chains/definitions/tempoDevnet.d.ts +14 -6
- package/_types/chains/definitions/tempoDevnet.d.ts.map +1 -1
- package/_types/chains/definitions/tempoLocalnet.d.ts +14 -6
- package/_types/chains/definitions/tempoLocalnet.d.ts.map +1 -1
- package/_types/chains/definitions/tempoModerato.d.ts +14 -6
- package/_types/chains/definitions/tempoModerato.d.ts.map +1 -1
- package/_types/chains/definitions/valuechain.d.ts +53 -0
- package/_types/chains/definitions/valuechain.d.ts.map +1 -0
- package/_types/chains/definitions/valuechainTestnet.d.ts +53 -0
- package/_types/chains/definitions/valuechainTestnet.d.ts.map +1 -0
- package/_types/chains/index.d.ts +5 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/clients/decorators/public.d.ts +5 -2
- package/_types/clients/decorators/public.d.ts.map +1 -1
- package/_types/clients/transports/http.d.ts.map +1 -1
- package/_types/errors/node.d.ts.map +1 -1
- package/_types/errors/request.d.ts +7 -1
- package/_types/errors/request.d.ts.map +1 -1
- package/_types/errors/typedData.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/op-stack/abis.d.ts +40 -0
- package/_types/op-stack/abis.d.ts.map +1 -1
- package/_types/op-stack/actions/getTimeToFinalize.d.ts +3 -2
- package/_types/op-stack/actions/getTimeToFinalize.d.ts.map +1 -1
- package/_types/op-stack/actions/getTimeToProve.d.ts +3 -1
- package/_types/op-stack/actions/getTimeToProve.d.ts.map +1 -1
- package/_types/op-stack/actions/getWithdrawalStatus.d.ts +2 -2
- package/_types/op-stack/actions/getWithdrawalStatus.d.ts.map +1 -1
- package/_types/op-stack/actions/waitToProve.d.ts +3 -1
- package/_types/op-stack/actions/waitToProve.d.ts.map +1 -1
- package/_types/op-stack/errors/withdrawal.d.ts +8 -0
- package/_types/op-stack/errors/withdrawal.d.ts.map +1 -1
- package/_types/tempo/Account.d.ts +14 -5
- package/_types/tempo/Account.d.ts.map +1 -1
- package/_types/tempo/Addresses.d.ts +0 -2
- package/_types/tempo/Addresses.d.ts.map +1 -1
- package/_types/tempo/Formatters.d.ts +3 -0
- package/_types/tempo/Formatters.d.ts.map +1 -1
- package/_types/tempo/Relay.d.ts +20 -0
- package/_types/tempo/Relay.d.ts.map +1 -1
- package/_types/tempo/Transaction.d.ts +7 -2
- package/_types/tempo/Transaction.d.ts.map +1 -1
- package/_types/tempo/accounts/Config.d.ts +24 -2
- package/_types/tempo/accounts/Config.d.ts.map +1 -1
- package/_types/tempo/actions/accounts.d.ts +2 -2
- package/_types/tempo/chainConfig.d.ts +8 -3
- package/_types/tempo/chainConfig.d.ts.map +1 -1
- package/_types/tempo/internal/relay/accounts.d.ts.map +1 -1
- package/_types/tempo/internal/relay/feePayer.d.ts.map +1 -1
- package/_types/utils/abi/getAbiItem.d.ts.map +1 -1
- package/_types/utils/abi/parseEventLogs.d.ts.map +1 -1
- package/_types/utils/authorization/serializeAuthorizationList.d.ts.map +1 -1
- package/_types/utils/buildRequest.d.ts.map +1 -1
- package/_types/utils/data/isHex.d.ts +12 -1
- package/_types/utils/data/isHex.d.ts.map +1 -1
- package/_types/utils/hash/toSignature.d.ts +1 -1
- package/_types/utils/hash/toSignatureHash.d.ts +1 -1
- package/_types/utils/rpc/http.d.ts +2 -2
- package/_types/utils/rpc/http.d.ts.map +1 -1
- package/_types/utils/signature/compactSignatureToSignature.d.ts +2 -1
- package/_types/utils/signature/compactSignatureToSignature.d.ts.map +1 -1
- package/_types/utils/signature/hashTypedData.d.ts.map +1 -1
- package/_types/utils/signature/signatureToCompactSignature.d.ts +2 -1
- package/_types/utils/signature/signatureToCompactSignature.d.ts.map +1 -1
- package/_types/utils/typedData.d.ts.map +1 -1
- package/_types/utils/wait.d.ts.map +1 -1
- package/actions/getContract.ts +1 -1
- package/actions/public/fillTransaction.ts +12 -3
- package/actions/public/waitForTransactionReceipt.ts +164 -33
- package/actions/public/watchContractEvent.ts +82 -39
- package/actions/public/watchEvent.ts +82 -38
- package/actions/wallet/sendCalls.ts +1 -1
- package/chains/definitions/molibra.ts +18 -0
- package/chains/definitions/valuechain.ts +20 -0
- package/chains/definitions/valuechainTestnet.ts +21 -0
- package/chains/index.ts +5 -0
- package/clients/decorators/public.ts +5 -2
- package/clients/transports/http.ts +6 -1
- package/errors/node.ts +1 -1
- package/errors/request.ts +15 -1
- package/errors/typedData.ts +3 -1
- package/errors/version.ts +1 -1
- package/op-stack/abis.ts +52 -0
- package/op-stack/actions/getTimeToFinalize.ts +89 -10
- package/op-stack/actions/getTimeToProve.ts +43 -2
- package/op-stack/actions/getWithdrawalStatus.ts +30 -6
- package/op-stack/actions/waitToProve.ts +45 -3
- package/op-stack/errors/withdrawal.ts +17 -0
- package/package.json +2 -2
- package/tempo/Account.ts +20 -22
- package/tempo/Addresses.ts +0 -3
- package/tempo/Formatters.ts +19 -7
- package/tempo/Relay.ts +26 -0
- package/tempo/Transaction.ts +10 -2
- package/tempo/accounts/Config.ts +40 -25
- package/tempo/actions/accounts.ts +2 -2
- package/tempo/chainConfig.ts +15 -4
- package/tempo/internal/relay/accounts.ts +45 -9
- package/tempo/internal/relay/feePayer.ts +6 -1
- package/utils/abi/getAbiItem.ts +49 -17
- package/utils/abi/parseEventLogs.ts +32 -11
- package/utils/authorization/serializeAuthorizationList.ts +7 -1
- package/utils/buildRequest.ts +29 -14
- package/utils/data/isHex.ts +18 -1
- package/utils/hash/normalizeSignature.ts +1 -1
- package/utils/hash/toSignature.ts +1 -1
- package/utils/hash/toSignatureHash.ts +1 -1
- package/utils/rpc/http.ts +33 -8
- package/utils/signature/compactSignatureToSignature.ts +4 -2
- package/utils/signature/hashTypedData.ts +1 -2
- package/utils/signature/signatureToCompactSignature.ts +13 -8
- package/utils/siwe/createSiweMessage.ts +1 -1
- package/utils/typedData.ts +11 -8
- package/utils/wait.ts +8 -4
|
@@ -25,6 +25,7 @@ import type * as Relay from '../../Relay.js'
|
|
|
25
25
|
import type * as Store from '../../Store.js'
|
|
26
26
|
import * as Transaction from '../../Transaction.js'
|
|
27
27
|
import * as Plugin from './plugin.js'
|
|
28
|
+
import * as Utils from './utils.js'
|
|
28
29
|
|
|
29
30
|
const submissionTtl = 30_000
|
|
30
31
|
const pollingInterval = 100
|
|
@@ -76,17 +77,42 @@ export function create(
|
|
|
76
77
|
throw new RpcResponse.InvalidParamsError({
|
|
77
78
|
message: 'Expected a configurable account address.',
|
|
78
79
|
})
|
|
79
|
-
const
|
|
80
|
+
const chainId = requestOptions?.chainId
|
|
81
|
+
if (chainId === undefined)
|
|
82
|
+
throw new RpcResponse.InvalidParamsError({
|
|
83
|
+
message: 'A chain ID is required to resolve the downstream client.',
|
|
84
|
+
})
|
|
85
|
+
// Surface a downstream failure as its RPC error, not as a reverted read.
|
|
80
86
|
const commitment = await getConfigCommitment(client, {
|
|
81
87
|
account: address,
|
|
82
|
-
|
|
88
|
+
}).catch((error) => {
|
|
89
|
+
throw Utils.toRpcError(error)
|
|
83
90
|
})
|
|
84
91
|
const config = await ConfigStore.read(options.store, {
|
|
85
92
|
address,
|
|
93
|
+
chainId,
|
|
86
94
|
commitment,
|
|
87
95
|
})
|
|
88
|
-
if (
|
|
89
|
-
|
|
96
|
+
if (config) return AccountConfig.toRpc(config)
|
|
97
|
+
const resolved = await options.resolveConfig?.({
|
|
98
|
+
address,
|
|
99
|
+
chainId,
|
|
100
|
+
commitment,
|
|
101
|
+
})
|
|
102
|
+
if (!resolved) return null
|
|
103
|
+
try {
|
|
104
|
+
await ConfigStore.write(options.store, {
|
|
105
|
+
address,
|
|
106
|
+
chainId,
|
|
107
|
+
commitment,
|
|
108
|
+
config: resolved,
|
|
109
|
+
})
|
|
110
|
+
} catch (error) {
|
|
111
|
+
// A resolved config that does not match the account and commitment is not served.
|
|
112
|
+
if (error instanceof ConfigStore.InvalidStoreValueError) return null
|
|
113
|
+
throw error
|
|
114
|
+
}
|
|
115
|
+
return AccountConfig.toRpc(AccountConfig.from(resolved))
|
|
90
116
|
}
|
|
91
117
|
|
|
92
118
|
if (request.method === 'account_getOperation') {
|
|
@@ -101,6 +127,7 @@ export function create(
|
|
|
101
127
|
|
|
102
128
|
if (request.method === 'account_approveKeyAuthorization')
|
|
103
129
|
return await approveKeyAuthorization({
|
|
130
|
+
chainId: requestOptions?.chainId,
|
|
104
131
|
client,
|
|
105
132
|
request,
|
|
106
133
|
store: options.store,
|
|
@@ -325,6 +352,7 @@ async function submit(options: submit.Options) {
|
|
|
325
352
|
|
|
326
353
|
await ConfigStore.write(options.store, {
|
|
327
354
|
address: signature.account,
|
|
355
|
+
chainId: transaction.chainId,
|
|
328
356
|
commitment: configCommitment,
|
|
329
357
|
config,
|
|
330
358
|
})
|
|
@@ -643,6 +671,11 @@ async function approveKeyAuthorization(
|
|
|
643
671
|
message: 'A owner approval envelope must include a signature.',
|
|
644
672
|
})
|
|
645
673
|
|
|
674
|
+
const { chainId } = options
|
|
675
|
+
if (chainId === undefined)
|
|
676
|
+
throw new RpcResponse.InvalidParamsError({
|
|
677
|
+
message: 'A chain ID is required to resolve the downstream client.',
|
|
678
|
+
})
|
|
646
679
|
const blockNumber = await getBlockNumber(options.client, { cacheTime: 0 })
|
|
647
680
|
const commitment = await validateConfig({
|
|
648
681
|
account: approval.account,
|
|
@@ -723,6 +756,7 @@ async function approveKeyAuthorization(
|
|
|
723
756
|
)
|
|
724
757
|
await ConfigStore.write(options.store, {
|
|
725
758
|
address: approval.account,
|
|
759
|
+
chainId,
|
|
726
760
|
commitment,
|
|
727
761
|
config: approval.config,
|
|
728
762
|
})
|
|
@@ -734,6 +768,8 @@ async function approveKeyAuthorization(
|
|
|
734
768
|
declare namespace approveKeyAuthorization {
|
|
735
769
|
/** Options for {@link approveKeyAuthorization}. */
|
|
736
770
|
export type Options = {
|
|
771
|
+
/** Chain of `client`, whose commitment validates the config. */
|
|
772
|
+
chainId?: number | undefined
|
|
737
773
|
/** Client used to validate configs. */
|
|
738
774
|
client: ReturnType<typeof createClient>
|
|
739
775
|
/** Original RPC request. */
|
|
@@ -765,9 +801,7 @@ function assertConfig(options: {
|
|
|
765
801
|
const { account, commitment, config } = options
|
|
766
802
|
if (
|
|
767
803
|
config.version === 0n &&
|
|
768
|
-
AccountConfig.getAddress(config
|
|
769
|
-
factory: Addresses.configurableAccountRecoveryFactory,
|
|
770
|
-
}).toLowerCase() !== account.toLowerCase()
|
|
804
|
+
AccountConfig.getAddress(config).toLowerCase() !== account.toLowerCase()
|
|
771
805
|
)
|
|
772
806
|
throw new RpcResponse.InvalidParamsError({
|
|
773
807
|
message:
|
|
@@ -845,6 +879,7 @@ async function cacheNextConfigs(options: cacheNextConfigs.Options) {
|
|
|
845
879
|
if (!config) continue
|
|
846
880
|
await ConfigStore.write(options.store, {
|
|
847
881
|
address: options.account,
|
|
882
|
+
chainId: options.transaction.chainId,
|
|
848
883
|
commitment: AccountConfig.getCommitment(config),
|
|
849
884
|
config,
|
|
850
885
|
})
|
|
@@ -860,7 +895,7 @@ declare namespace cacheNextConfigs {
|
|
|
860
895
|
/** Root config used to authorize the transaction. */
|
|
861
896
|
config: AccountConfig.Config
|
|
862
897
|
/** Shared account store. */
|
|
863
|
-
store: Store.
|
|
898
|
+
store: Store.Atomic
|
|
864
899
|
/** Submitted transaction containing potential config updates. */
|
|
865
900
|
transaction: Transaction.TransactionSerializableTempo
|
|
866
901
|
}
|
|
@@ -897,6 +932,7 @@ async function cacheUpgradeConfig(options: cacheUpgradeConfig.Options) {
|
|
|
897
932
|
if (!config) return
|
|
898
933
|
await ConfigStore.write(options.store, {
|
|
899
934
|
address: from,
|
|
935
|
+
chainId: options.transaction.chainId,
|
|
900
936
|
commitment: AccountConfig.getCommitment(config),
|
|
901
937
|
config,
|
|
902
938
|
})
|
|
@@ -906,7 +942,7 @@ declare namespace cacheUpgradeConfig {
|
|
|
906
942
|
/** Parameters for {@link cacheUpgradeConfig}. */
|
|
907
943
|
export type Options = {
|
|
908
944
|
/** Shared account store. */
|
|
909
|
-
store: Store.
|
|
945
|
+
store: Store.Atomic
|
|
910
946
|
/** Submitted transaction containing a potential account upgrade. */
|
|
911
947
|
transaction: Transaction.TransactionSerializableTempo
|
|
912
948
|
}
|
|
@@ -817,7 +817,12 @@ function isBaseFeeRejection(error: unknown) {
|
|
|
817
817
|
const { cause, code, message } = current as Record<string, unknown>
|
|
818
818
|
// Reth reports pool admission failures as invalid input (-32000). `transaction underpriced`
|
|
819
819
|
// reflects a node-configurable floor, so another node could still admit the envelope.
|
|
820
|
-
if (
|
|
820
|
+
if (
|
|
821
|
+
code === -32000 &&
|
|
822
|
+
typeof message === 'string' &&
|
|
823
|
+
(message === 'gas price is less than basefee' ||
|
|
824
|
+
message.startsWith('fee cap less than base fee'))
|
|
825
|
+
)
|
|
821
826
|
return true
|
|
822
827
|
current = cause
|
|
823
828
|
}
|
package/utils/abi/getAbiItem.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
type ToFunctionSelectorErrorType,
|
|
22
22
|
toFunctionSelector,
|
|
23
23
|
} from '../hash/toFunctionSelector.js'
|
|
24
|
+
import { getArrayComponents } from './encodeAbiParameters.js'
|
|
24
25
|
|
|
25
26
|
export type GetAbiItemParameters<
|
|
26
27
|
abi extends Abi | readonly unknown[] = Abi,
|
|
@@ -174,9 +175,7 @@ export function isArgOfType(arg: unknown, abiParameter: AbiParameter): boolean {
|
|
|
174
175
|
return (
|
|
175
176
|
argType === 'object' &&
|
|
176
177
|
isArgOfType(
|
|
177
|
-
|
|
178
|
-
index
|
|
179
|
-
],
|
|
178
|
+
getComponentValue(arg, component, index),
|
|
180
179
|
component as AbiParameter,
|
|
181
180
|
)
|
|
182
181
|
)
|
|
@@ -198,16 +197,14 @@ export function isArgOfType(arg: unknown, abiParameter: AbiParameter): boolean {
|
|
|
198
197
|
return argType === 'string' || arg instanceof Uint8Array
|
|
199
198
|
|
|
200
199
|
// fixed-length (`<type>[M]`) and dynamic (`<type>[]`) arrays
|
|
201
|
-
|
|
202
|
-
if (
|
|
200
|
+
const arrayComponents = getArrayComponents(abiParameterType)
|
|
201
|
+
if (arrayComponents) {
|
|
202
|
+
const [length, type] = arrayComponents
|
|
203
203
|
return (
|
|
204
204
|
Array.isArray(arg) &&
|
|
205
|
+
(length === null || arg.length === length) &&
|
|
205
206
|
arg.every((x: unknown) =>
|
|
206
|
-
isArgOfType(x, {
|
|
207
|
-
...abiParameter,
|
|
208
|
-
// Pop off `[]` or `[M]` from end of type
|
|
209
|
-
type: abiParameterType.replace(/(\[[0-9]{0,}\])$/, ''),
|
|
210
|
-
} as AbiParameter),
|
|
207
|
+
isArgOfType(x, { ...abiParameter, type } as AbiParameter),
|
|
211
208
|
)
|
|
212
209
|
)
|
|
213
210
|
}
|
|
@@ -226,27 +223,52 @@ export function getAmbiguousTypes(
|
|
|
226
223
|
for (const parameterIndex in sourceParameters) {
|
|
227
224
|
const sourceParameter = sourceParameters[parameterIndex]
|
|
228
225
|
const targetParameter = targetParameters[parameterIndex]
|
|
226
|
+
if (!targetParameter) continue
|
|
229
227
|
|
|
230
228
|
if (
|
|
231
229
|
sourceParameter.type === 'tuple' &&
|
|
232
230
|
targetParameter.type === 'tuple' &&
|
|
233
231
|
'components' in sourceParameter &&
|
|
234
232
|
'components' in targetParameter
|
|
235
|
-
)
|
|
236
|
-
|
|
233
|
+
) {
|
|
234
|
+
const value = args[parameterIndex]
|
|
235
|
+
const types = getAmbiguousTypes(
|
|
237
236
|
sourceParameter.components,
|
|
238
237
|
targetParameter.components,
|
|
239
|
-
(
|
|
238
|
+
sourceParameter.components.map((component, index) =>
|
|
239
|
+
getComponentValue(value, component, index),
|
|
240
|
+
),
|
|
240
241
|
)
|
|
242
|
+
if (types) return types
|
|
243
|
+
continue
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const sourceArray = getArrayComponents(sourceParameter.type)
|
|
247
|
+
const targetArray = getArrayComponents(targetParameter.type)
|
|
248
|
+
if (sourceArray && targetArray) {
|
|
249
|
+
// Every item matches both element types, so the first item (or `undefined` for an empty array) decides.
|
|
250
|
+
const types = getAmbiguousTypes(
|
|
251
|
+
[{ ...sourceParameter, type: sourceArray[1] } as AbiParameter],
|
|
252
|
+
[{ ...targetParameter, type: targetArray[1] } as AbiParameter],
|
|
253
|
+
[(args[parameterIndex] as readonly unknown[] | undefined)?.[0]],
|
|
254
|
+
)
|
|
255
|
+
if (types) return types
|
|
256
|
+
continue
|
|
257
|
+
}
|
|
241
258
|
|
|
242
259
|
const types = [sourceParameter.type, targetParameter.type]
|
|
260
|
+
const value = args[parameterIndex]
|
|
243
261
|
|
|
244
262
|
const ambiguous = (() => {
|
|
245
263
|
if (types.includes('address') && types.includes('bytes20')) return true
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
264
|
+
// An `undefined` value comes from an empty array, which matches both types.
|
|
265
|
+
if (
|
|
266
|
+
types.includes('address') &&
|
|
267
|
+
(types.includes('string') || types.includes('bytes'))
|
|
268
|
+
)
|
|
269
|
+
return (
|
|
270
|
+
value === undefined || isAddress(value as Address, { strict: false })
|
|
271
|
+
)
|
|
250
272
|
return false
|
|
251
273
|
})()
|
|
252
274
|
|
|
@@ -255,3 +277,13 @@ export function getAmbiguousTypes(
|
|
|
255
277
|
|
|
256
278
|
return
|
|
257
279
|
}
|
|
280
|
+
|
|
281
|
+
/** Reads a tuple component's value by index from arrays and by name from objects, like `encodeAbiParameters`. */
|
|
282
|
+
function getComponentValue(
|
|
283
|
+
arg: unknown,
|
|
284
|
+
component: AbiParameter,
|
|
285
|
+
index: number,
|
|
286
|
+
): unknown {
|
|
287
|
+
if (Array.isArray(arg)) return arg[index]
|
|
288
|
+
return (arg as Record<string, unknown> | undefined)?.[component.name!]
|
|
289
|
+
}
|
|
@@ -10,6 +10,7 @@ import { stringToBytes, toBytes } from '../encoding/toBytes.js'
|
|
|
10
10
|
import { formatLog } from '../formatters/log.js'
|
|
11
11
|
import { keccak256 } from '../hash/keccak256.js'
|
|
12
12
|
import { toEventSelector } from '../hash/toEventSelector.js'
|
|
13
|
+
import { bytesRegex } from '../regex.js'
|
|
13
14
|
import {
|
|
14
15
|
type DecodeEventLogErrorType,
|
|
15
16
|
decodeEventLog,
|
|
@@ -162,15 +163,11 @@ export function parseEventLogs<
|
|
|
162
163
|
strict: false,
|
|
163
164
|
})
|
|
164
165
|
} catch {
|
|
165
|
-
// If decoding still fails,
|
|
166
|
+
// If decoding still fails, use a partial log in non-strict mode.
|
|
166
167
|
const isUnnamed = abiItem.abi.inputs?.some(
|
|
167
168
|
(x) => !('name' in x && x.name),
|
|
168
169
|
)
|
|
169
|
-
|
|
170
|
-
...formattedLog,
|
|
171
|
-
args: isUnnamed ? [] : {},
|
|
172
|
-
eventName: abiItem.abi.name,
|
|
173
|
-
}
|
|
170
|
+
event = { eventName: abiItem.abi.name, args: isUnnamed ? [] : {} }
|
|
174
171
|
}
|
|
175
172
|
}
|
|
176
173
|
|
|
@@ -186,6 +183,7 @@ export function parseEventLogs<
|
|
|
186
183
|
args: event.args,
|
|
187
184
|
inputs: abiItem.abi.inputs,
|
|
188
185
|
matchArgs: args,
|
|
186
|
+
topics: formattedLog.topics,
|
|
189
187
|
})
|
|
190
188
|
)
|
|
191
189
|
return null
|
|
@@ -203,20 +201,43 @@ function includesArgs(parameters: {
|
|
|
203
201
|
args: unknown
|
|
204
202
|
inputs: AbiEvent['inputs']
|
|
205
203
|
matchArgs: unknown
|
|
204
|
+
topics: Log['topics']
|
|
206
205
|
}) {
|
|
207
|
-
const { args, inputs, matchArgs } = parameters
|
|
206
|
+
const { args, inputs, matchArgs, topics } = parameters
|
|
208
207
|
|
|
209
208
|
if (!matchArgs) return true
|
|
210
209
|
if (!args) return false
|
|
211
210
|
|
|
211
|
+
// Topics hold the signature, then indexed inputs in order. Non-strict
|
|
212
|
+
// decoding reads indexed inputs without a topic from data.
|
|
213
|
+
const topicInputs = inputs
|
|
214
|
+
.filter((input) => input.indexed)
|
|
215
|
+
.slice(0, topics.length - 1)
|
|
216
|
+
|
|
212
217
|
function isEqual(input: AbiEventParameter, value: unknown, arg: unknown) {
|
|
213
218
|
try {
|
|
214
219
|
if (input.type === 'address')
|
|
215
220
|
return isAddressEqual(value as Address, arg as Address)
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (
|
|
219
|
-
|
|
221
|
+
// `string` and `bytes` topics hold the keccak256 of their contents.
|
|
222
|
+
// Other values are ABI-decoded.
|
|
223
|
+
if (
|
|
224
|
+
topicInputs.includes(input) &&
|
|
225
|
+
(input.type === 'string' || input.type === 'bytes')
|
|
226
|
+
) {
|
|
227
|
+
const bytes =
|
|
228
|
+
input.type === 'string'
|
|
229
|
+
? stringToBytes(value as string)
|
|
230
|
+
: toBytes(value as string)
|
|
231
|
+
return keccak256(bytes) === arg
|
|
232
|
+
}
|
|
233
|
+
// Decoded `bytes` and `bytesN` are lowercase hex. Match either case,
|
|
234
|
+
// same as the indexed `bytes` hash path.
|
|
235
|
+
if (
|
|
236
|
+
typeof value === 'string' &&
|
|
237
|
+
typeof arg === 'string' &&
|
|
238
|
+
bytesRegex.test(input.type)
|
|
239
|
+
)
|
|
240
|
+
return value.toLowerCase() === arg.toLowerCase()
|
|
220
241
|
return value === arg
|
|
221
242
|
} catch {
|
|
222
243
|
return false
|
|
@@ -22,11 +22,17 @@ export function serializeAuthorizationList(
|
|
|
22
22
|
for (const authorization of authorizationList) {
|
|
23
23
|
const { chainId, nonce, ...signature } = authorization
|
|
24
24
|
const contractAddress = authorization.address
|
|
25
|
+
const signatureArray = toYParitySignatureArray({}, signature)
|
|
26
|
+
// EIP-7702 permits any `y_parity` below 2**8 in an authorization tuple, and a
|
|
27
|
+
// tuple that fails recovery does not invalidate the transaction. Encode a
|
|
28
|
+
// numeric `yParity` as is, so that serialization preserves the transaction hash.
|
|
29
|
+
if (signatureArray.length > 0 && signature.yParity)
|
|
30
|
+
signatureArray[0] = toHex(signature.yParity)
|
|
25
31
|
serializedAuthorizationList.push([
|
|
26
32
|
chainId ? toHex(chainId) : '0x',
|
|
27
33
|
contractAddress,
|
|
28
34
|
nonce ? toHex(nonce) : '0x',
|
|
29
|
-
...
|
|
35
|
+
...signatureArray,
|
|
30
36
|
])
|
|
31
37
|
}
|
|
32
38
|
|
package/utils/buildRequest.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { BaseError } from '../errors/base.js'
|
|
|
2
2
|
import {
|
|
3
3
|
HttpRequestError,
|
|
4
4
|
type HttpRequestErrorType,
|
|
5
|
+
RpcRequestError,
|
|
5
6
|
type RpcRequestErrorType,
|
|
6
7
|
type TimeoutErrorType,
|
|
7
8
|
type WebSocketRequestErrorType,
|
|
@@ -268,10 +269,14 @@ export function buildRequest<
|
|
|
268
269
|
{
|
|
269
270
|
delay: ({ count, error }) => {
|
|
270
271
|
// If we find a Retry-After header, let's retry after the given time.
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
272
|
+
const retryAfter =
|
|
273
|
+
getHttpError(error)?.headers?.get('Retry-After')
|
|
274
|
+
if (retryAfter) {
|
|
275
|
+
const seconds = Number.parseInt(retryAfter, 10)
|
|
276
|
+
if (!Number.isNaN(seconds)) return seconds * 1000
|
|
277
|
+
// HTTP-date form. A past or invalid date falls back to backoff.
|
|
278
|
+
const delay = Date.parse(retryAfter) - Date.now()
|
|
279
|
+
if (delay > 0) return delay
|
|
275
280
|
}
|
|
276
281
|
|
|
277
282
|
// Otherwise, let's retry with an exponential backoff.
|
|
@@ -290,6 +295,7 @@ export function buildRequest<
|
|
|
290
295
|
/** @internal */
|
|
291
296
|
export function shouldRetry(error: Error) {
|
|
292
297
|
if (isAbortError(error)) return false
|
|
298
|
+
const status = getHttpError(error)?.status
|
|
293
299
|
if ('code' in error && typeof error.code === 'number') {
|
|
294
300
|
if (error.code === -1) return true // Unknown error
|
|
295
301
|
if (error.code === LimitExceededRpcError.code) return true
|
|
@@ -304,30 +310,39 @@ export function shouldRetry(error: Error) {
|
|
|
304
310
|
// reached - reduce calls per second or upgrade your account at
|
|
305
311
|
// quicknode.com" }`.
|
|
306
312
|
if (error.code === -32007) return true
|
|
307
|
-
|
|
313
|
+
// A JSON-RPC error from a non-2xx response also retries by its HTTP status.
|
|
314
|
+
if (!status) return false
|
|
308
315
|
}
|
|
309
|
-
if (
|
|
316
|
+
if (status) {
|
|
310
317
|
// Forbidden
|
|
311
|
-
if (
|
|
318
|
+
if (status === 403) return true
|
|
312
319
|
// Request Timeout
|
|
313
|
-
if (
|
|
320
|
+
if (status === 408) return true
|
|
314
321
|
// Request Entity Too Large
|
|
315
|
-
if (
|
|
322
|
+
if (status === 413) return true
|
|
316
323
|
// Too Many Requests
|
|
317
|
-
if (
|
|
324
|
+
if (status === 429) return true
|
|
318
325
|
// Internal Server Error
|
|
319
|
-
if (
|
|
326
|
+
if (status === 500) return true
|
|
320
327
|
// Bad Gateway
|
|
321
|
-
if (
|
|
328
|
+
if (status === 502) return true
|
|
322
329
|
// Service Unavailable
|
|
323
|
-
if (
|
|
330
|
+
if (status === 503) return true
|
|
324
331
|
// Gateway Timeout
|
|
325
|
-
if (
|
|
332
|
+
if (status === 504) return true
|
|
326
333
|
return false
|
|
327
334
|
}
|
|
328
335
|
return true
|
|
329
336
|
}
|
|
330
337
|
|
|
338
|
+
/** Returns the error in the cause chain that carries the HTTP response. */
|
|
339
|
+
function getHttpError(error: Error | undefined) {
|
|
340
|
+
if (!(error instanceof BaseError)) return undefined
|
|
341
|
+
return error.walk(
|
|
342
|
+
(err) => err instanceof HttpRequestError || err instanceof RpcRequestError,
|
|
343
|
+
) as HttpRequestError | RpcRequestError | null
|
|
344
|
+
}
|
|
345
|
+
|
|
331
346
|
/** @internal cyrb53 – fast, non-cryptographic 53-bit string hash */
|
|
332
347
|
function hashString(str: string, seed = 0): string {
|
|
333
348
|
let h1 = 0xdeadbeef ^ seed
|
package/utils/data/isHex.ts
CHANGED
|
@@ -5,9 +5,26 @@ export type IsHexErrorType = ErrorType
|
|
|
5
5
|
|
|
6
6
|
export function isHex(
|
|
7
7
|
value: unknown,
|
|
8
|
-
{
|
|
8
|
+
{
|
|
9
|
+
even = false,
|
|
10
|
+
strict = true,
|
|
11
|
+
}: {
|
|
12
|
+
/**
|
|
13
|
+
* Whether or not to require an even number of hex characters (whole bytes).
|
|
14
|
+
*
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
even?: boolean | undefined
|
|
18
|
+
/**
|
|
19
|
+
* Whether or not to require only hex characters after the `0x` prefix.
|
|
20
|
+
*
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
23
|
+
strict?: boolean | undefined
|
|
24
|
+
} = {},
|
|
9
25
|
): value is Hex {
|
|
10
26
|
if (!value) return false
|
|
11
27
|
if (typeof value !== 'string') return false
|
|
28
|
+
if (even && value.length % 2 !== 0) return false
|
|
12
29
|
return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith('0x')
|
|
13
30
|
}
|
|
@@ -29,7 +29,7 @@ export function normalizeSignature(
|
|
|
29
29
|
|
|
30
30
|
// If level === 0, we are at the definition level.
|
|
31
31
|
if (level === 0) {
|
|
32
|
-
if (char === ' ' && ['event', 'function', ''].includes(result))
|
|
32
|
+
if (char === ' ' && ['event', 'function', 'error', ''].includes(result))
|
|
33
33
|
result = ''
|
|
34
34
|
else {
|
|
35
35
|
result += char
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
export type ToSignatureErrorType = NormalizeSignatureErrorType | ErrorType
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Returns the signature for a given function or
|
|
12
|
+
* Returns the signature for a given function, event, or error definition.
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* const signature = toSignature('function ownerOf(uint256 tokenId)')
|
|
@@ -10,7 +10,7 @@ export type ToSignatureHashErrorType =
|
|
|
10
10
|
| ErrorType
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Returns the hash (of the function/event signature) for a given event or
|
|
13
|
+
* Returns the hash (of the function/event/error signature) for a given function, event, or error definition.
|
|
14
14
|
*/
|
|
15
15
|
export function toSignatureHash(fn: string | AbiFunction | AbiEvent) {
|
|
16
16
|
return hashSignature(toSignature(fn))
|
package/utils/rpc/http.ts
CHANGED
|
@@ -3,6 +3,8 @@ import {
|
|
|
3
3
|
type HttpRequestErrorType as HttpRequestErrorType_,
|
|
4
4
|
ResponseBodyTooLargeError,
|
|
5
5
|
type ResponseBodyTooLargeErrorType,
|
|
6
|
+
RpcRequestError,
|
|
7
|
+
type RpcRequestErrorType,
|
|
6
8
|
TimeoutError,
|
|
7
9
|
type TimeoutErrorType,
|
|
8
10
|
} from '../../errors/request.js'
|
|
@@ -77,6 +79,7 @@ export type HttpRequestReturnType<
|
|
|
77
79
|
export type HttpRequestErrorType =
|
|
78
80
|
| HttpRequestErrorType_
|
|
79
81
|
| ResponseBodyTooLargeErrorType
|
|
82
|
+
| RpcRequestErrorType
|
|
80
83
|
| TimeoutErrorType
|
|
81
84
|
| WithTimeoutErrorType
|
|
82
85
|
| ErrorType
|
|
@@ -188,14 +191,24 @@ export function getHttpRpcClient(
|
|
|
188
191
|
}
|
|
189
192
|
}
|
|
190
193
|
|
|
194
|
+
// A server that rejects a whole batch replies with a single error, bare
|
|
195
|
+
// or in a one-element array (geth).
|
|
196
|
+
const error =
|
|
197
|
+
Array.isArray(body) && Array.isArray(data) && data.length === 1
|
|
198
|
+
? data[0]
|
|
199
|
+
: data
|
|
200
|
+
|
|
191
201
|
if (!response.ok) {
|
|
192
|
-
//
|
|
193
|
-
//
|
|
194
|
-
if (
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
202
|
+
// A valid JSON-RPC error body keeps its RPC error class and the
|
|
203
|
+
// response status and headers for retries.
|
|
204
|
+
if (isRpcError(error))
|
|
205
|
+
throw new RpcRequestError({
|
|
206
|
+
body,
|
|
207
|
+
error: error.error,
|
|
208
|
+
headers: response.headers,
|
|
209
|
+
status: response.status,
|
|
210
|
+
url,
|
|
211
|
+
})
|
|
199
212
|
|
|
200
213
|
throw new HttpRequestError({
|
|
201
214
|
body,
|
|
@@ -206,12 +219,17 @@ export function getHttpRpcClient(
|
|
|
206
219
|
})
|
|
207
220
|
}
|
|
208
221
|
|
|
209
|
-
return data
|
|
222
|
+
if (!Array.isArray(body) || !body.length) return data
|
|
223
|
+
if (Array.isArray(data) && data.length >= body.length) return data
|
|
224
|
+
if (!isRpcError(error))
|
|
225
|
+
throw new Error(`Expected ${body.length} responses to batch request.`)
|
|
226
|
+
return body.map(() => error)
|
|
210
227
|
} catch (err) {
|
|
211
228
|
if (signal_?.aborted) throw getAbortError(signal_)
|
|
212
229
|
if (isAbortError(err)) throw err
|
|
213
230
|
if (err instanceof HttpRequestError) throw err
|
|
214
231
|
if (err instanceof ResponseBodyTooLargeError) throw err
|
|
232
|
+
if (err instanceof RpcRequestError) throw err
|
|
215
233
|
if (err instanceof TimeoutError) throw err
|
|
216
234
|
throw new HttpRequestError({
|
|
217
235
|
body,
|
|
@@ -306,6 +324,13 @@ async function readResponseBody(
|
|
|
306
324
|
}
|
|
307
325
|
}
|
|
308
326
|
|
|
327
|
+
function isRpcError(data: any) {
|
|
328
|
+
return (
|
|
329
|
+
typeof data?.error?.code === 'number' &&
|
|
330
|
+
typeof data?.error?.message === 'string'
|
|
331
|
+
)
|
|
332
|
+
}
|
|
333
|
+
|
|
309
334
|
/** @internal */
|
|
310
335
|
export function parseUrl(url_: string) {
|
|
311
336
|
try {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { ErrorType } from '../../errors/utils.js'
|
|
2
2
|
import type { CompactSignature, Signature } from '../../types/misc.js'
|
|
3
|
+
import { type PadErrorType, pad } from '../data/pad.js'
|
|
3
4
|
import { type HexToBytesErrorType, hexToBytes } from '../encoding/toBytes.js'
|
|
4
5
|
import { type BytesToHexErrorType, bytesToHex } from '../encoding/toHex.js'
|
|
5
6
|
|
|
6
7
|
export type CompactSignatureToSignatureErrorType =
|
|
7
8
|
| BytesToHexErrorType
|
|
8
9
|
| HexToBytesErrorType
|
|
10
|
+
| PadErrorType
|
|
9
11
|
| ErrorType
|
|
10
12
|
|
|
11
13
|
/**
|
|
@@ -29,9 +31,9 @@ export function compactSignatureToSignature({
|
|
|
29
31
|
r,
|
|
30
32
|
yParityAndS,
|
|
31
33
|
}: CompactSignature): Signature {
|
|
32
|
-
const yParityAndS_bytes = hexToBytes(yParityAndS)
|
|
34
|
+
const yParityAndS_bytes = hexToBytes(pad(yParityAndS))
|
|
33
35
|
const yParity = yParityAndS_bytes[0] & 0x80 ? 1 : 0
|
|
34
36
|
const s = yParityAndS_bytes
|
|
35
37
|
if (yParity === 1) s[0] &= 0x7f
|
|
36
|
-
return { r, s: bytesToHex(s), yParity }
|
|
38
|
+
return { r: pad(r), s: bytesToHex(s), yParity }
|
|
37
39
|
}
|
|
@@ -209,8 +209,7 @@ function findTypeDependencies(
|
|
|
209
209
|
},
|
|
210
210
|
results: Set<string> = new Set(),
|
|
211
211
|
): Set<string> {
|
|
212
|
-
const
|
|
213
|
-
const primaryType = match?.[0]!
|
|
212
|
+
const primaryType = primaryType_.replace(/(\[[0-9]*\])+$/, '')
|
|
214
213
|
if (results.has(primaryType) || types[primaryType] === undefined) {
|
|
215
214
|
return results
|
|
216
215
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { ErrorType } from '../../errors/utils.js'
|
|
2
2
|
import type { CompactSignature, Signature } from '../../types/misc.js'
|
|
3
|
+
import { type PadErrorType, pad } from '../data/pad.js'
|
|
3
4
|
import { type HexToBytesErrorType, hexToBytes } from '../encoding/toBytes.js'
|
|
4
5
|
import { type BytesToHexErrorType, bytesToHex } from '../encoding/toHex.js'
|
|
5
6
|
|
|
6
7
|
export type SignatureToCompactSignatureErrorType =
|
|
7
8
|
| HexToBytesErrorType
|
|
8
9
|
| BytesToHexErrorType
|
|
10
|
+
| PadErrorType
|
|
9
11
|
| ErrorType
|
|
10
12
|
|
|
11
13
|
/**
|
|
@@ -29,12 +31,15 @@ export function signatureToCompactSignature(
|
|
|
29
31
|
signature: Signature,
|
|
30
32
|
): CompactSignature {
|
|
31
33
|
const { r, s, v, yParity } = signature
|
|
32
|
-
const yParity_ =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
const yParity_ = (() => {
|
|
35
|
+
if (yParity === 0 || yParity === 1) return yParity
|
|
36
|
+
if (v === 0n || v === 1n) return Number(v)
|
|
37
|
+
if (v && (v === 27n || v === 28n || v >= 35n)) return v % 2n === 0n ? 1 : 0
|
|
38
|
+
throw new Error('Invalid `v` or `yParity` value')
|
|
39
|
+
})()
|
|
40
|
+
const bytes = hexToBytes(pad(s))
|
|
41
|
+
// EIP-2098 stores yParity in the top bit, which is always clear for a low `s`.
|
|
42
|
+
if (bytes[0] & 0x80) throw new Error('Invalid `s` value')
|
|
43
|
+
if (yParity_ === 1) bytes[0] |= 0x80
|
|
44
|
+
return { r: pad(r), yParityAndS: bytesToHex(bytes) }
|
|
40
45
|
}
|