viem 2.57.17 → 2.57.19
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 +100 -0
- package/_cjs/account-abstraction/actions/paymaster/getPaymasterData.js +4 -2
- package/_cjs/account-abstraction/actions/paymaster/getPaymasterData.js.map +1 -1
- package/_cjs/account-abstraction/actions/paymaster/getPaymasterStubData.js +6 -2
- package/_cjs/account-abstraction/actions/paymaster/getPaymasterStubData.js.map +1 -1
- package/_cjs/actions/ens/getEnsAddress.js +11 -1
- package/_cjs/actions/ens/getEnsAddress.js.map +1 -1
- package/_cjs/actions/ens/getEnsText.js.map +1 -1
- package/_cjs/actions/index.js +5 -3
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/public/call.js +13 -2
- package/_cjs/actions/public/call.js.map +1 -1
- package/_cjs/actions/public/getDelegation.js +2 -1
- package/_cjs/actions/public/getDelegation.js.map +1 -1
- package/_cjs/actions/public/getFeeHistory.js.map +1 -1
- package/_cjs/actions/public/getLogs.js +18 -1
- package/_cjs/actions/public/getLogs.js.map +1 -1
- package/_cjs/actions/public/internal/isRangeError.js +18 -0
- package/_cjs/actions/public/internal/isRangeError.js.map +1 -0
- package/_cjs/actions/public/internal/watchTransport.js +24 -0
- package/_cjs/actions/public/internal/watchTransport.js.map +1 -0
- package/_cjs/actions/public/iterateLogs.js +48 -0
- package/_cjs/actions/public/iterateLogs.js.map +1 -0
- package/_cjs/actions/public/simulateContract.js +4 -4
- package/_cjs/actions/public/simulateContract.js.map +1 -1
- package/_cjs/actions/public/verifyHash.js +72 -39
- package/_cjs/actions/public/verifyHash.js.map +1 -1
- package/_cjs/actions/public/waitForTransactionReceipt.js +18 -1
- package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_cjs/actions/public/watchBlockHeaders.js +2 -10
- package/_cjs/actions/public/watchBlockHeaders.js.map +1 -1
- package/_cjs/actions/public/watchBlockNumber.js +3 -18
- package/_cjs/actions/public/watchBlockNumber.js.map +1 -1
- package/_cjs/actions/public/watchBlocks.js +3 -18
- package/_cjs/actions/public/watchBlocks.js.map +1 -1
- package/_cjs/actions/public/watchContractEvent.js +5 -33
- package/_cjs/actions/public/watchContractEvent.js.map +1 -1
- package/_cjs/actions/public/watchEvent.js +5 -33
- package/_cjs/actions/public/watchEvent.js.map +1 -1
- package/_cjs/actions/token/internal.js +2 -10
- package/_cjs/actions/token/internal.js.map +1 -1
- package/_cjs/actions/wallet/deployContract.js +2 -1
- package/_cjs/actions/wallet/deployContract.js.map +1 -1
- package/_cjs/actions/wallet/prepareTransactionRequest.js +16 -3
- package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_cjs/actions/wallet/sendCalls.js +2 -1
- package/_cjs/actions/wallet/sendCalls.js.map +1 -1
- package/_cjs/actions/wallet/signAuthorization.js +2 -1
- package/_cjs/actions/wallet/signAuthorization.js.map +1 -1
- package/_cjs/celo/serializers.js +1 -1
- package/_cjs/celo/serializers.js.map +1 -1
- package/_cjs/chains/definitions/kinetiqElysium.js +30 -0
- package/_cjs/chains/definitions/kinetiqElysium.js.map +1 -0
- package/_cjs/chains/definitions/kinetiqElysiumTestnet.js +31 -0
- package/_cjs/chains/definitions/kinetiqElysiumTestnet.js.map +1 -0
- package/_cjs/chains/index.js +14 -9
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/clients/decorators/public.js +2 -0
- package/_cjs/clients/decorators/public.js.map +1 -1
- package/_cjs/constants/contracts.js +1 -1
- package/_cjs/constants/contracts.js.map +1 -1
- package/_cjs/errors/chain.js +2 -2
- package/_cjs/errors/chain.js.map +1 -1
- package/_cjs/errors/typedData.js +2 -0
- package/_cjs/errors/typedData.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js +5 -4
- package/_cjs/index.js.map +1 -1
- package/_cjs/op-stack/actions/buildProveWithdrawal.js +5 -5
- package/_cjs/op-stack/actions/buildProveWithdrawal.js.map +1 -1
- package/_cjs/op-stack/actions/getL2Output.js +13 -9
- package/_cjs/op-stack/actions/getL2Output.js.map +1 -1
- package/_cjs/op-stack/actions/waitToProve.js +1 -0
- package/_cjs/op-stack/actions/waitToProve.js.map +1 -1
- package/_cjs/tempo/Account.js +30 -0
- package/_cjs/tempo/Account.js.map +1 -1
- package/_cjs/tempo/actions/accessKey.js +1 -1
- package/_cjs/tempo/actions/accessKey.js.map +1 -1
- package/_cjs/tempo/actions/accounts.js +19 -9
- package/_cjs/tempo/actions/accounts.js.map +1 -1
- package/_cjs/tempo/actions/earn/deployment.js +1 -1
- package/_cjs/tempo/actions/earn/deployment.js.map +1 -1
- package/_cjs/tempo/actions/earn.js +3 -3
- package/_cjs/tempo/actions/earn.js.map +1 -1
- package/_cjs/tempo/actions/propAmm.js +1 -1
- package/_cjs/tempo/actions/propAmm.js.map +1 -1
- package/_cjs/tempo/actions/token.js +10 -2
- package/_cjs/tempo/actions/token.js.map +1 -1
- package/_cjs/tempo/chainConfig.js +37 -1
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_cjs/tempo/internal/preAuthorized.js +214 -0
- package/_cjs/tempo/internal/preAuthorized.js.map +1 -0
- package/_cjs/tempo/internal/relay/feePayer.js +25 -7
- package/_cjs/tempo/internal/relay/feePayer.js.map +1 -1
- package/_cjs/tempo/internal/relay.js +2 -2
- package/_cjs/tempo/internal/relay.js.map +1 -1
- package/_cjs/tempo/internal/utils.js +2 -10
- package/_cjs/tempo/internal/utils.js.map +1 -1
- package/_cjs/tokens/defineToken.js +1 -1
- package/_cjs/tokens/defineToken.js.map +1 -1
- package/_cjs/tokens/definitions/ousd.js +1 -0
- package/_cjs/tokens/definitions/ousd.js.map +1 -1
- package/_cjs/utils/abi/decodeAbiParameters.js +33 -9
- package/_cjs/utils/abi/decodeAbiParameters.js.map +1 -1
- package/_cjs/utils/abi/encodeAbiParameters.js +5 -4
- package/_cjs/utils/abi/encodeAbiParameters.js.map +1 -1
- package/_cjs/utils/abi/encodePacked.js +4 -2
- package/_cjs/utils/abi/encodePacked.js.map +1 -1
- package/_cjs/utils/ccip.js +5 -1
- package/_cjs/utils/ccip.js.map +1 -1
- package/_cjs/utils/chain/getChainContractAddress.js +2 -2
- package/_cjs/utils/chain/getChainContractAddress.js.map +1 -1
- package/_cjs/utils/encoding/toBytes.js +5 -6
- package/_cjs/utils/encoding/toBytes.js.map +1 -1
- package/_cjs/utils/ens/avatar/utils.js +25 -5
- package/_cjs/utils/ens/avatar/utils.js.map +1 -1
- package/_cjs/utils/ens/localBatchGatewayRequest.js +13 -1
- package/_cjs/utils/ens/localBatchGatewayRequest.js.map +1 -1
- package/_cjs/utils/promise/createBatchScheduler.js +1 -1
- package/_cjs/utils/promise/createBatchScheduler.js.map +1 -1
- package/_cjs/utils/siwe/validateSiweMessage.js +5 -0
- package/_cjs/utils/siwe/validateSiweMessage.js.map +1 -1
- package/_cjs/zksync/actions/estimateFee.js +1 -1
- package/_cjs/zksync/actions/estimateFee.js.map +1 -1
- package/_cjs/zksync/actions/estimateGasL1ToL2.js +1 -1
- package/_cjs/zksync/actions/estimateGasL1ToL2.js.map +1 -1
- package/_cjs/zksync/actions/finalizeWithdrawal.js +3 -3
- package/_cjs/zksync/actions/finalizeWithdrawal.js.map +1 -1
- package/_cjs/zksync/actions/sendEip712Transaction.js +10 -2
- package/_cjs/zksync/actions/sendEip712Transaction.js.map +1 -1
- package/_cjs/zksync/actions/signEip712Transaction.js +2 -2
- package/_cjs/zksync/actions/signEip712Transaction.js.map +1 -1
- package/_esm/account-abstraction/actions/paymaster/getPaymasterData.js +4 -2
- package/_esm/account-abstraction/actions/paymaster/getPaymasterData.js.map +1 -1
- package/_esm/account-abstraction/actions/paymaster/getPaymasterStubData.js +6 -2
- package/_esm/account-abstraction/actions/paymaster/getPaymasterStubData.js.map +1 -1
- package/_esm/actions/ens/getEnsAddress.js +12 -1
- package/_esm/actions/ens/getEnsAddress.js.map +1 -1
- package/_esm/actions/ens/getEnsText.js.map +1 -1
- package/_esm/actions/index.js +1 -0
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/public/call.js +13 -2
- package/_esm/actions/public/call.js.map +1 -1
- package/_esm/actions/public/getDelegation.js +2 -1
- package/_esm/actions/public/getDelegation.js.map +1 -1
- package/_esm/actions/public/getFeeHistory.js.map +1 -1
- package/_esm/actions/public/getLogs.js +18 -1
- package/_esm/actions/public/getLogs.js.map +1 -1
- package/_esm/actions/public/internal/isRangeError.js +19 -0
- package/_esm/actions/public/internal/isRangeError.js.map +1 -0
- package/_esm/actions/public/internal/watchTransport.js +22 -0
- package/_esm/actions/public/internal/watchTransport.js.map +1 -0
- package/_esm/actions/public/iterateLogs.js +84 -0
- package/_esm/actions/public/iterateLogs.js.map +1 -0
- package/_esm/actions/public/simulateContract.js +5 -4
- package/_esm/actions/public/simulateContract.js.map +1 -1
- package/_esm/actions/public/verifyHash.js +77 -40
- package/_esm/actions/public/verifyHash.js.map +1 -1
- package/_esm/actions/public/waitForTransactionReceipt.js +20 -1
- package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_esm/actions/public/watchBlockHeaders.js +2 -10
- package/_esm/actions/public/watchBlockHeaders.js.map +1 -1
- package/_esm/actions/public/watchBlockNumber.js +3 -18
- package/_esm/actions/public/watchBlockNumber.js.map +1 -1
- package/_esm/actions/public/watchBlocks.js +3 -18
- package/_esm/actions/public/watchBlocks.js.map +1 -1
- package/_esm/actions/public/watchContractEvent.js +4 -36
- package/_esm/actions/public/watchContractEvent.js.map +1 -1
- package/_esm/actions/public/watchEvent.js +4 -36
- package/_esm/actions/public/watchEvent.js.map +1 -1
- package/_esm/actions/token/internal.js +2 -10
- package/_esm/actions/token/internal.js.map +1 -1
- package/_esm/actions/wallet/deployContract.js +2 -1
- package/_esm/actions/wallet/deployContract.js.map +1 -1
- package/_esm/actions/wallet/prepareTransactionRequest.js +17 -3
- package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_esm/actions/wallet/sendCalls.js +2 -1
- package/_esm/actions/wallet/sendCalls.js.map +1 -1
- package/_esm/actions/wallet/signAuthorization.js +2 -1
- package/_esm/actions/wallet/signAuthorization.js.map +1 -1
- package/_esm/celo/serializers.js +1 -1
- package/_esm/celo/serializers.js.map +1 -1
- package/_esm/chains/definitions/kinetiqElysium.js +27 -0
- package/_esm/chains/definitions/kinetiqElysium.js.map +1 -0
- package/_esm/chains/definitions/kinetiqElysiumTestnet.js +28 -0
- package/_esm/chains/definitions/kinetiqElysiumTestnet.js.map +1 -0
- package/_esm/chains/index.js +2 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/clients/decorators/public.js +2 -0
- package/_esm/clients/decorators/public.js.map +1 -1
- package/_esm/constants/contracts.js +1 -1
- package/_esm/constants/contracts.js.map +1 -1
- package/_esm/errors/chain.js +2 -2
- package/_esm/errors/chain.js.map +1 -1
- package/_esm/errors/typedData.js +2 -0
- package/_esm/errors/typedData.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/op-stack/actions/buildProveWithdrawal.js +5 -5
- package/_esm/op-stack/actions/buildProveWithdrawal.js.map +1 -1
- package/_esm/op-stack/actions/getL2Output.js +14 -9
- package/_esm/op-stack/actions/getL2Output.js.map +1 -1
- package/_esm/op-stack/actions/waitToProve.js +1 -0
- package/_esm/op-stack/actions/waitToProve.js.map +1 -1
- package/_esm/tempo/Account.js +33 -1
- package/_esm/tempo/Account.js.map +1 -1
- package/_esm/tempo/actions/accessKey.js +1 -1
- package/_esm/tempo/actions/accessKey.js.map +1 -1
- package/_esm/tempo/actions/accounts.js +24 -10
- package/_esm/tempo/actions/accounts.js.map +1 -1
- package/_esm/tempo/actions/earn/deployment.js +1 -1
- package/_esm/tempo/actions/earn/deployment.js.map +1 -1
- package/_esm/tempo/actions/earn.js +3 -3
- package/_esm/tempo/actions/earn.js.map +1 -1
- package/_esm/tempo/actions/propAmm.js +1 -1
- package/_esm/tempo/actions/propAmm.js.map +1 -1
- package/_esm/tempo/actions/token.js +10 -2
- package/_esm/tempo/actions/token.js.map +1 -1
- package/_esm/tempo/chainConfig.js +41 -1
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_esm/tempo/internal/preAuthorized.js +244 -0
- package/_esm/tempo/internal/preAuthorized.js.map +1 -0
- package/_esm/tempo/internal/relay/feePayer.js +26 -7
- package/_esm/tempo/internal/relay/feePayer.js.map +1 -1
- package/_esm/tempo/internal/relay.js +8 -3
- package/_esm/tempo/internal/relay.js.map +1 -1
- package/_esm/tempo/internal/utils.js +2 -10
- package/_esm/tempo/internal/utils.js.map +1 -1
- package/_esm/tokens/defineToken.js +2 -1
- package/_esm/tokens/defineToken.js.map +1 -1
- package/_esm/tokens/definitions/ousd.js +2 -1
- package/_esm/tokens/definitions/ousd.js.map +1 -1
- package/_esm/utils/abi/decodeAbiParameters.js +37 -9
- package/_esm/utils/abi/decodeAbiParameters.js.map +1 -1
- package/_esm/utils/abi/encodeAbiParameters.js +6 -4
- package/_esm/utils/abi/encodeAbiParameters.js.map +1 -1
- package/_esm/utils/abi/encodePacked.js +5 -2
- package/_esm/utils/abi/encodePacked.js.map +1 -1
- package/_esm/utils/ccip.js +8 -3
- package/_esm/utils/ccip.js.map +1 -1
- package/_esm/utils/chain/getChainContractAddress.js +2 -2
- package/_esm/utils/chain/getChainContractAddress.js.map +1 -1
- package/_esm/utils/encoding/toBytes.js +5 -6
- package/_esm/utils/encoding/toBytes.js.map +1 -1
- package/_esm/utils/ens/avatar/utils.js +26 -5
- package/_esm/utils/ens/avatar/utils.js.map +1 -1
- package/_esm/utils/ens/localBatchGatewayRequest.js +17 -1
- package/_esm/utils/ens/localBatchGatewayRequest.js.map +1 -1
- package/_esm/utils/promise/createBatchScheduler.js +2 -1
- package/_esm/utils/promise/createBatchScheduler.js.map +1 -1
- package/_esm/utils/siwe/validateSiweMessage.js +6 -0
- package/_esm/utils/siwe/validateSiweMessage.js.map +1 -1
- package/_esm/zksync/actions/estimateFee.js +1 -1
- package/_esm/zksync/actions/estimateFee.js.map +1 -1
- package/_esm/zksync/actions/estimateGasL1ToL2.js +1 -1
- package/_esm/zksync/actions/estimateGasL1ToL2.js.map +1 -1
- package/_esm/zksync/actions/finalizeWithdrawal.js +3 -3
- package/_esm/zksync/actions/finalizeWithdrawal.js.map +1 -1
- package/_esm/zksync/actions/sendEip712Transaction.js +12 -2
- package/_esm/zksync/actions/sendEip712Transaction.js.map +1 -1
- package/_esm/zksync/actions/signEip712Transaction.js +2 -2
- package/_esm/zksync/actions/signEip712Transaction.js.map +1 -1
- package/_types/account-abstraction/actions/paymaster/getPaymasterData.d.ts.map +1 -1
- package/_types/account-abstraction/actions/paymaster/getPaymasterStubData.d.ts.map +1 -1
- package/_types/actions/ens/getEnsAddress.d.ts +2 -1
- package/_types/actions/ens/getEnsAddress.d.ts.map +1 -1
- package/_types/actions/ens/getEnsText.d.ts +2 -1
- package/_types/actions/ens/getEnsText.d.ts.map +1 -1
- package/_types/actions/index.d.ts +1 -0
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/public/call.d.ts.map +1 -1
- package/_types/actions/public/getDelegation.d.ts.map +1 -1
- package/_types/actions/public/getFeeHistory.d.ts +2 -1
- package/_types/actions/public/getFeeHistory.d.ts.map +1 -1
- package/_types/actions/public/getLogs.d.ts +20 -2
- package/_types/actions/public/getLogs.d.ts.map +1 -1
- package/_types/actions/public/internal/isRangeError.d.ts +3 -0
- package/_types/actions/public/internal/isRangeError.d.ts.map +1 -0
- package/_types/actions/public/internal/watchTransport.d.ts +6 -0
- package/_types/actions/public/internal/watchTransport.d.ts.map +1 -0
- package/_types/actions/public/iterateLogs.d.ts +94 -0
- package/_types/actions/public/iterateLogs.d.ts.map +1 -0
- package/_types/actions/public/simulateContract.d.ts.map +1 -1
- package/_types/actions/public/verifyHash.d.ts +2 -1
- package/_types/actions/public/verifyHash.d.ts.map +1 -1
- package/_types/actions/public/waitForTransactionReceipt.d.ts +7 -2
- package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
- package/_types/actions/public/watchBlockHeaders.d.ts.map +1 -1
- package/_types/actions/public/watchBlockNumber.d.ts.map +1 -1
- package/_types/actions/public/watchBlocks.d.ts.map +1 -1
- package/_types/actions/public/watchContractEvent.d.ts.map +1 -1
- package/_types/actions/public/watchEvent.d.ts.map +1 -1
- package/_types/actions/token/internal.d.ts.map +1 -1
- package/_types/actions/wallet/deployContract.d.ts.map +1 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts +3 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
- package/_types/actions/wallet/sendCalls.d.ts.map +1 -1
- package/_types/actions/wallet/signAuthorization.d.ts.map +1 -1
- package/_types/celo/serializers.d.ts.map +1 -1
- package/_types/chains/definitions/kinetiqElysium.d.ts +52 -0
- package/_types/chains/definitions/kinetiqElysium.d.ts.map +1 -0
- package/_types/chains/definitions/kinetiqElysiumTestnet.d.ts +52 -0
- package/_types/chains/definitions/kinetiqElysiumTestnet.d.ts.map +1 -0
- package/_types/chains/index.d.ts +2 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/clients/decorators/public.d.ts +33 -0
- package/_types/clients/decorators/public.d.ts.map +1 -1
- package/_types/constants/contracts.d.ts +1 -1
- package/_types/constants/contracts.d.ts.map +1 -1
- package/_types/errors/typedData.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +2 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/op-stack/actions/getL2Output.d.ts +6 -0
- package/_types/op-stack/actions/getL2Output.d.ts.map +1 -1
- package/_types/op-stack/actions/waitToProve.d.ts.map +1 -1
- package/_types/tempo/Account.d.ts +5 -1
- package/_types/tempo/Account.d.ts.map +1 -1
- package/_types/tempo/actions/accounts.d.ts +4 -1
- package/_types/tempo/actions/accounts.d.ts.map +1 -1
- package/_types/tempo/actions/earn/deployment.d.ts.map +1 -1
- package/_types/tempo/actions/propAmm.d.ts.map +1 -1
- package/_types/tempo/actions/token.d.ts.map +1 -1
- package/_types/tempo/chainConfig.d.ts.map +1 -1
- package/_types/tempo/internal/preAuthorized.d.ts +41 -0
- package/_types/tempo/internal/preAuthorized.d.ts.map +1 -0
- package/_types/tempo/internal/relay/feePayer.d.ts.map +1 -1
- package/_types/tempo/internal/utils.d.ts.map +1 -1
- package/_types/tokens/defineToken.d.ts +5 -1
- package/_types/tokens/defineToken.d.ts.map +1 -1
- package/_types/tokens/definitions/ousd.d.ts +2 -1
- package/_types/tokens/definitions/ousd.d.ts.map +1 -1
- package/_types/tokens/sets.d.ts +3 -0
- package/_types/tokens/sets.d.ts.map +1 -1
- package/_types/utils/abi/decodeAbiParameters.d.ts +15 -1
- package/_types/utils/abi/decodeAbiParameters.d.ts.map +1 -1
- package/_types/utils/abi/encodeAbiParameters.d.ts.map +1 -1
- package/_types/utils/ccip.d.ts +4 -3
- package/_types/utils/ccip.d.ts.map +1 -1
- package/_types/utils/encoding/toBytes.d.ts +1 -1
- package/_types/utils/encoding/toBytes.d.ts.map +1 -1
- package/_types/utils/ens/avatar/utils.d.ts +6 -2
- package/_types/utils/ens/avatar/utils.d.ts.map +1 -1
- package/_types/utils/ens/localBatchGatewayRequest.d.ts +6 -1
- package/_types/utils/ens/localBatchGatewayRequest.d.ts.map +1 -1
- package/_types/utils/promise/createBatchScheduler.d.ts.map +1 -1
- package/_types/utils/siwe/validateSiweMessage.d.ts.map +1 -1
- package/_types/zksync/actions/estimateFee.d.ts.map +1 -1
- package/_types/zksync/actions/estimateGasL1ToL2.d.ts.map +1 -1
- package/_types/zksync/actions/finalizeWithdrawal.d.ts.map +1 -1
- package/_types/zksync/actions/sendEip712Transaction.d.ts +1 -1
- package/_types/zksync/actions/sendEip712Transaction.d.ts.map +1 -1
- package/_types/zksync/errors/bridge.d.ts +1 -1
- package/_types/zksync/errors/bridge.d.ts.map +1 -1
- package/account-abstraction/actions/paymaster/getPaymasterData.ts +23 -16
- package/account-abstraction/actions/paymaster/getPaymasterStubData.ts +27 -16
- package/actions/ens/getEnsAddress.ts +15 -1
- package/actions/ens/getEnsText.ts +2 -0
- package/actions/index.ts +6 -0
- package/actions/public/call.ts +15 -2
- package/actions/public/getDelegation.ts +6 -1
- package/actions/public/getFeeHistory.ts +2 -0
- package/actions/public/getLogs.ts +44 -0
- package/actions/public/internal/isRangeError.ts +18 -0
- package/actions/public/internal/watchTransport.ts +29 -0
- package/actions/public/iterateLogs.ts +209 -0
- package/actions/public/simulateContract.ts +6 -4
- package/actions/public/verifyHash.ts +87 -60
- package/actions/public/waitForTransactionReceipt.ts +31 -1
- package/actions/public/watchBlockHeaders.ts +2 -12
- package/actions/public/watchBlockNumber.ts +6 -24
- package/actions/public/watchBlocks.ts +6 -24
- package/actions/public/watchContractEvent.ts +7 -42
- package/actions/public/watchEvent.ts +7 -42
- package/actions/token/internal.ts +2 -10
- package/actions/wallet/deployContract.ts +6 -1
- package/actions/wallet/prepareTransactionRequest.ts +25 -3
- package/actions/wallet/sendCalls.ts +6 -1
- package/actions/wallet/signAuthorization.ts +6 -1
- package/celo/serializers.ts +5 -2
- package/chains/definitions/kinetiqElysium.ts +27 -0
- package/chains/definitions/kinetiqElysiumTestnet.ts +28 -0
- package/chains/index.ts +2 -0
- package/clients/decorators/public.ts +47 -0
- package/constants/contracts.ts +1 -1
- package/errors/chain.ts +2 -2
- package/errors/typedData.ts +2 -0
- package/errors/version.ts +1 -1
- package/index.ts +7 -0
- package/op-stack/actions/buildProveWithdrawal.ts +5 -5
- package/op-stack/actions/getL2Output.ts +24 -11
- package/op-stack/actions/waitToProve.ts +1 -0
- package/package.json +2 -2
- package/tempo/Account.ts +38 -1
- package/tempo/actions/accessKey.ts +1 -1
- package/tempo/actions/accounts.ts +29 -11
- package/tempo/actions/earn/deployment.ts +2 -1
- package/tempo/actions/earn.ts +2 -2
- package/tempo/actions/propAmm.ts +2 -1
- package/tempo/actions/token.ts +10 -2
- package/tempo/chainConfig.ts +53 -5
- package/tempo/internal/preAuthorized.ts +309 -0
- package/tempo/internal/relay/feePayer.ts +33 -11
- package/tempo/internal/relay.ts +8 -3
- package/tempo/internal/utils.ts +2 -10
- package/tokens/defineToken.ts +6 -2
- package/tokens/definitions/ousd.ts +2 -1
- package/utils/abi/decodeAbiParameters.ts +60 -9
- package/utils/abi/encodeAbiParameters.ts +6 -4
- package/utils/abi/encodePacked.ts +5 -1
- package/utils/ccip.ts +17 -3
- package/utils/chain/getChainContractAddress.ts +2 -2
- package/utils/encoding/toBytes.ts +4 -6
- package/utils/ens/avatar/utils.ts +38 -4
- package/utils/ens/localBatchGatewayRequest.ts +21 -2
- package/utils/promise/createBatchScheduler.ts +2 -1
- package/utils/siwe/validateSiweMessage.ts +7 -0
- package/zksync/actions/estimateFee.ts +2 -1
- package/zksync/actions/estimateGasL1ToL2.ts +2 -1
- package/zksync/actions/finalizeWithdrawal.ts +4 -3
- package/zksync/actions/sendEip712Transaction.ts +21 -8
- package/zksync/actions/signEip712Transaction.ts +3 -3
- package/zksync/errors/bridge.ts +1 -1
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import type { Address } from 'abitype'
|
|
2
|
+
import * as Hex from 'ox/Hex'
|
|
3
|
+
import {
|
|
4
|
+
KeyAuthorization,
|
|
5
|
+
SignatureEnvelope,
|
|
6
|
+
SignaturePreAuthorized,
|
|
7
|
+
} from 'ox/tempo'
|
|
8
|
+
import { getBlock } from '../../actions/public/getBlock.js'
|
|
9
|
+
import { getChainId } from '../../actions/public/getChainId.js'
|
|
10
|
+
import { readContract } from '../../actions/public/readContract.js'
|
|
11
|
+
import type { Client } from '../../clients/createClient.js'
|
|
12
|
+
import { zeroAddress } from '../../constants/address.js'
|
|
13
|
+
import { BaseError } from '../../errors/base.js'
|
|
14
|
+
import { ContractFunctionRevertedError } from '../../errors/contract.js'
|
|
15
|
+
import type { BlockTag } from '../../types/block.js'
|
|
16
|
+
import { isAddressEqual } from '../../utils/address/isAddressEqual.js'
|
|
17
|
+
import { getAction } from '../../utils/getAction.js'
|
|
18
|
+
import { keccak256 } from '../../utils/hash/keccak256.js'
|
|
19
|
+
import * as Abis from '../Abis.js'
|
|
20
|
+
import * as Addresses from '../Addresses.js'
|
|
21
|
+
import {
|
|
22
|
+
getMetadata,
|
|
23
|
+
isWitnessBurned,
|
|
24
|
+
verifyHash as verifyAccessKey,
|
|
25
|
+
} from '../actions/accessKey.js'
|
|
26
|
+
import { verifyHash as verifyConfigurableAccount } from '../actions/accounts.js'
|
|
27
|
+
import { isTip20 } from './utils.js'
|
|
28
|
+
|
|
29
|
+
/** Most spending limits the transaction pool accepts in a key authorization. */
|
|
30
|
+
const maxLimits = 256
|
|
31
|
+
/** Most call scope targets, selector rules per target, and recipients per rule the transaction pool accepts. */
|
|
32
|
+
const maxScopes = 64
|
|
33
|
+
/** Transaction gas limit cap (from T1A). */
|
|
34
|
+
const maxTransactionGas = 30_000_000n
|
|
35
|
+
/** Base gas of every transaction. */
|
|
36
|
+
const baseTransactionGas = 21_000n
|
|
37
|
+
/** Gas to create the access key's storage slot. */
|
|
38
|
+
const keySlotGas = 20_000n
|
|
39
|
+
/** Largest spending limit `authorizeKey` accepts. */
|
|
40
|
+
const maxLimit = 2n ** 128n - 1n
|
|
41
|
+
/** TIP-20 selectors a recipient-constrained selector rule may name: `transfer`, `approve`, and `transferWithMemo`. */
|
|
42
|
+
const constrainedSelectors = ['0xa9059cbb', '0x095ea7b3', '0x95777d59']
|
|
43
|
+
|
|
44
|
+
/** Whether a signature ends with the TIP-1165 pre-authorized signature magic suffix. */
|
|
45
|
+
export function isPreAuthorized(signature: Hex.Hex): boolean {
|
|
46
|
+
const size = Hex.size(SignaturePreAuthorized.magicBytes)
|
|
47
|
+
return (
|
|
48
|
+
Hex.size(signature) > size &&
|
|
49
|
+
Hex.slice(signature, -size).toLowerCase() ===
|
|
50
|
+
SignaturePreAuthorized.magicBytes
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Verifies a TIP-1165 pre-authorized signature at a reference block: the access key is
|
|
56
|
+
* registered and passes `verifyKeychain`, or the bundled key authorization would still
|
|
57
|
+
* register it. Every failure, including a decode failure or a reverted read, returns `false`.
|
|
58
|
+
*/
|
|
59
|
+
export async function verify(
|
|
60
|
+
client: Client,
|
|
61
|
+
options: verify.Options,
|
|
62
|
+
): Promise<boolean> {
|
|
63
|
+
const { account, chainId: chainId_, hash, signature, ...block } = options
|
|
64
|
+
|
|
65
|
+
const unwrapped = (() => {
|
|
66
|
+
try {
|
|
67
|
+
return SignaturePreAuthorized.unwrap(signature)
|
|
68
|
+
} catch {
|
|
69
|
+
return undefined
|
|
70
|
+
}
|
|
71
|
+
})()
|
|
72
|
+
if (!unwrapped) return false
|
|
73
|
+
// Only an exact encoding verifies, so no other bytes can carry the same signature.
|
|
74
|
+
if (
|
|
75
|
+
SignaturePreAuthorized.wrap(unwrapped).toLowerCase() !==
|
|
76
|
+
signature.toLowerCase()
|
|
77
|
+
)
|
|
78
|
+
return false
|
|
79
|
+
const { keyAuthorization } = unwrapped
|
|
80
|
+
const keychain = unwrapped.signature
|
|
81
|
+
if (!isAddressEqual(keychain.userAddress, account)) return false
|
|
82
|
+
|
|
83
|
+
// Registered path: an active registered access key verifies without the authorization.
|
|
84
|
+
const registered = await (
|
|
85
|
+
readContract(client, {
|
|
86
|
+
...block,
|
|
87
|
+
...verifyAccessKey.call({
|
|
88
|
+
account,
|
|
89
|
+
admin: false,
|
|
90
|
+
hash,
|
|
91
|
+
signature: SignatureEnvelope.serialize(keychain),
|
|
92
|
+
}),
|
|
93
|
+
} as never) as Promise<boolean>
|
|
94
|
+
).catch(catchRevert)
|
|
95
|
+
if (registered) return true
|
|
96
|
+
|
|
97
|
+
// Access key signature: the inner signature is the authorized key's, over the keychain digest.
|
|
98
|
+
const { inner } = keychain
|
|
99
|
+
const keyId = keyAuthorization.address
|
|
100
|
+
if (inner.type !== keyAuthorization.type) return false
|
|
101
|
+
const signed = (() => {
|
|
102
|
+
try {
|
|
103
|
+
return SignatureEnvelope.verify(inner, {
|
|
104
|
+
address: keyId,
|
|
105
|
+
payload: keccak256(Hex.concat('0x04', hash, account)),
|
|
106
|
+
})
|
|
107
|
+
} catch {
|
|
108
|
+
return false
|
|
109
|
+
}
|
|
110
|
+
})()
|
|
111
|
+
if (!signed) return false
|
|
112
|
+
|
|
113
|
+
if (!isRegistrable(keyAuthorization, account)) return false
|
|
114
|
+
|
|
115
|
+
const root = keyAuthorization.signature
|
|
116
|
+
const digest = KeyAuthorization.getSignPayload(keyAuthorization)
|
|
117
|
+
const read = (call: object) =>
|
|
118
|
+
(
|
|
119
|
+
readContract(client, { ...block, ...call } as never) as Promise<unknown>
|
|
120
|
+
).catch(catchRevert)
|
|
121
|
+
const [chainId, reference, rootValid, rootActive, keyIdActive, key, burned] =
|
|
122
|
+
await Promise.all([
|
|
123
|
+
chainId_ ?? getAction(client, getChainId, 'getChainId')({}),
|
|
124
|
+
getAction(client, getBlock, 'getBlock')(getBlockParameters(block)),
|
|
125
|
+
root.type === 'configurable'
|
|
126
|
+
? read(
|
|
127
|
+
verifyConfigurableAccount.call({
|
|
128
|
+
account,
|
|
129
|
+
hash: digest,
|
|
130
|
+
signature: SignatureEnvelope.serialize(root),
|
|
131
|
+
}),
|
|
132
|
+
)
|
|
133
|
+
: read({
|
|
134
|
+
address: Addresses.signatureVerifier,
|
|
135
|
+
abi: Abis.signatureVerifier,
|
|
136
|
+
functionName: 'verify',
|
|
137
|
+
args: [account, digest, SignatureEnvelope.serialize(root)],
|
|
138
|
+
}),
|
|
139
|
+
// A configuration commitment retires the account's root key.
|
|
140
|
+
root.type === 'configurable'
|
|
141
|
+
? true
|
|
142
|
+
: read({
|
|
143
|
+
address: Addresses.accountKeychain,
|
|
144
|
+
abi: Abis.accountKeychain,
|
|
145
|
+
functionName: 'isAdminKey',
|
|
146
|
+
args: [account, account],
|
|
147
|
+
}),
|
|
148
|
+
// `authorizeKey` refuses a retired root key as an access key.
|
|
149
|
+
read({
|
|
150
|
+
address: Addresses.accountKeychain,
|
|
151
|
+
abi: Abis.accountKeychain,
|
|
152
|
+
functionName: 'isAdminKey',
|
|
153
|
+
args: [keyId, keyId],
|
|
154
|
+
}),
|
|
155
|
+
read(getMetadata.call({ account, accessKey: keyId })) as Promise<
|
|
156
|
+
{ keyId: Address; isRevoked: boolean } | false
|
|
157
|
+
>,
|
|
158
|
+
keyAuthorization.witness
|
|
159
|
+
? read(
|
|
160
|
+
isWitnessBurned.call({
|
|
161
|
+
account,
|
|
162
|
+
witness: keyAuthorization.witness,
|
|
163
|
+
}),
|
|
164
|
+
)
|
|
165
|
+
: false,
|
|
166
|
+
])
|
|
167
|
+
|
|
168
|
+
if (BigInt(chainId) !== keyAuthorization.chainId) return false
|
|
169
|
+
if (
|
|
170
|
+
keyAuthorization.expiry != null &&
|
|
171
|
+
BigInt(keyAuthorization.expiry) <= reference.timestamp
|
|
172
|
+
)
|
|
173
|
+
return false
|
|
174
|
+
if (rootValid !== true || rootActive !== true || keyIdActive !== true)
|
|
175
|
+
return false
|
|
176
|
+
// The access key was never registered and never revoked.
|
|
177
|
+
if (!key || !isAddressEqual(key.keyId, zeroAddress) || key.isRevoked)
|
|
178
|
+
return false
|
|
179
|
+
return burned === false
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export declare namespace verify {
|
|
183
|
+
type Options = {
|
|
184
|
+
/** Account the signature claims to sign for. */
|
|
185
|
+
account: Address
|
|
186
|
+
/** Hash of the reference block. */
|
|
187
|
+
blockHash?: Hex.Hex | undefined
|
|
188
|
+
/** Number of the reference block. */
|
|
189
|
+
blockNumber?: bigint | undefined
|
|
190
|
+
/** Tag of the reference block. */
|
|
191
|
+
blockTag?: BlockTag | undefined
|
|
192
|
+
/** Chain ID the key authorization must name. Read from the node when omitted. */
|
|
193
|
+
chainId?: number | undefined
|
|
194
|
+
/** Signed hash. */
|
|
195
|
+
hash: Hex.Hex
|
|
196
|
+
/** Whether the reference block hash must be canonical. */
|
|
197
|
+
requireCanonical?: boolean | undefined
|
|
198
|
+
/** Pre-authorized signature. */
|
|
199
|
+
signature: Hex.Hex
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Whether a key authorization passes the checks of `authorizeKey` and the transaction pool
|
|
205
|
+
* that need no chain state.
|
|
206
|
+
*
|
|
207
|
+
* @internal
|
|
208
|
+
*/
|
|
209
|
+
export function isRegistrable(
|
|
210
|
+
keyAuthorization: KeyAuthorization.Signed,
|
|
211
|
+
account: Address,
|
|
212
|
+
): boolean {
|
|
213
|
+
const { address, isAdmin, limits, scopes } = keyAuthorization
|
|
214
|
+
if (isAddressEqual(address, zeroAddress)) return false
|
|
215
|
+
if (
|
|
216
|
+
keyAuthorization.account &&
|
|
217
|
+
!isAddressEqual(keyAuthorization.account, account)
|
|
218
|
+
)
|
|
219
|
+
return false
|
|
220
|
+
if (isAdmin) return false
|
|
221
|
+
|
|
222
|
+
if (limits) {
|
|
223
|
+
if (limits.length > maxLimits) return false
|
|
224
|
+
const tokens = new Set(limits.map(({ token }) => token.toLowerCase()))
|
|
225
|
+
if (tokens.size !== limits.length) return false
|
|
226
|
+
if (limits.some(({ limit }) => limit > maxLimit)) return false
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// Strict decoding rejects a repeated target, which would not encode back to the same bytes,
|
|
230
|
+
// so grouping the flat scopes by target restores the wire order.
|
|
231
|
+
const targets = new Map<
|
|
232
|
+
string,
|
|
233
|
+
{ selector: Hex.Hex; recipients: readonly Address[] }[]
|
|
234
|
+
>()
|
|
235
|
+
for (const scope of scopes ?? []) {
|
|
236
|
+
const rules = targets.get(scope.address.toLowerCase()) ?? []
|
|
237
|
+
targets.set(scope.address.toLowerCase(), rules)
|
|
238
|
+
if (scope.selector)
|
|
239
|
+
rules.push({
|
|
240
|
+
selector: scope.selector as Hex.Hex,
|
|
241
|
+
recipients: scope.recipients ?? [],
|
|
242
|
+
})
|
|
243
|
+
}
|
|
244
|
+
if (targets.size > maxScopes) return false
|
|
245
|
+
let selectorCount = 0n
|
|
246
|
+
let recipientCount = 0n
|
|
247
|
+
for (const [target, rules] of targets) {
|
|
248
|
+
if (isAddressEqual(target as Address, zeroAddress)) return false
|
|
249
|
+
if (rules.length > maxScopes) return false
|
|
250
|
+
const selectors = new Set(
|
|
251
|
+
rules.map(({ selector }) => selector.toLowerCase()),
|
|
252
|
+
)
|
|
253
|
+
if (selectors.size !== rules.length) return false
|
|
254
|
+
for (const { selector, recipients } of rules) {
|
|
255
|
+
if (Hex.size(selector) !== 4) return false
|
|
256
|
+
if (recipients.length === 0) continue
|
|
257
|
+
if (recipients.length > maxScopes) return false
|
|
258
|
+
if (!isTip20(target)) return false
|
|
259
|
+
if (!constrainedSelectors.includes(selector.toLowerCase())) return false
|
|
260
|
+
if (
|
|
261
|
+
recipients.some((recipient) => isAddressEqual(recipient, zeroAddress))
|
|
262
|
+
)
|
|
263
|
+
return false
|
|
264
|
+
const unique = new Set(
|
|
265
|
+
recipients.map((recipient) => recipient.toLowerCase()),
|
|
266
|
+
)
|
|
267
|
+
if (unique.size !== recipients.length) return false
|
|
268
|
+
}
|
|
269
|
+
selectorCount += BigInt(rules.length)
|
|
270
|
+
recipientCount += BigInt(
|
|
271
|
+
rules.reduce((count, { recipients }) => count + recipients.length, 0),
|
|
272
|
+
)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// The call scope surcharge alone can exceed the transaction gas limit cap, so no transaction
|
|
276
|
+
// could carry the authorization.
|
|
277
|
+
// Any carrying transaction also pays the base transaction gas and writes the key's slot, so
|
|
278
|
+
// count those as a lower bound on the rest of its intrinsic gas. Account-dependent costs
|
|
279
|
+
// (signature verification, nonce, configurable account) are not counted.
|
|
280
|
+
const surcharge =
|
|
281
|
+
5_000n +
|
|
282
|
+
7_000n * BigInt(targets.size) +
|
|
283
|
+
7_000n * selectorCount +
|
|
284
|
+
5_000n * recipientCount
|
|
285
|
+
return baseTransactionGas + keySlotGas + surcharge <= maxTransactionGas
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** Returns the `getBlock` parameters for a reference block. */
|
|
289
|
+
function getBlockParameters(block: {
|
|
290
|
+
blockHash?: Hex.Hex | undefined
|
|
291
|
+
blockNumber?: bigint | undefined
|
|
292
|
+
blockTag?: BlockTag | undefined
|
|
293
|
+
}) {
|
|
294
|
+
if (block.blockHash) return { blockHash: block.blockHash }
|
|
295
|
+
if (typeof block.blockNumber === 'bigint')
|
|
296
|
+
return { blockNumber: block.blockNumber }
|
|
297
|
+
// An omitted tag keeps the client's default, as the state reads do.
|
|
298
|
+
return block.blockTag ? { blockTag: block.blockTag } : {}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** Returns `false` for a reverted read, and rethrows other errors. */
|
|
302
|
+
function catchRevert(error: unknown): false {
|
|
303
|
+
if (
|
|
304
|
+
error instanceof BaseError &&
|
|
305
|
+
error.walk((cause) => cause instanceof ContractFunctionRevertedError)
|
|
306
|
+
)
|
|
307
|
+
return false
|
|
308
|
+
throw error
|
|
309
|
+
}
|
|
@@ -29,7 +29,10 @@ import * as Utils from './utils.js'
|
|
|
29
29
|
|
|
30
30
|
export function create(options: Relay.feePayer.Options): Relay.Plugin {
|
|
31
31
|
// Bind signing permission to the middleware invocation and its validated payload.
|
|
32
|
-
const authorized = new WeakMap<
|
|
32
|
+
const authorized = new WeakMap<
|
|
33
|
+
Relay.Plugin.Context,
|
|
34
|
+
{ payload: Hex.Hex; sender: Address }
|
|
35
|
+
>()
|
|
33
36
|
const allowedFeePayers = new Set(
|
|
34
37
|
options.allowedFeePayers?.map((url) =>
|
|
35
38
|
ExternalFeePayerUrl.normalize(url, {
|
|
@@ -189,11 +192,30 @@ export function create(options: Relay.feePayer.Options): Relay.Plugin {
|
|
|
189
192
|
validity,
|
|
190
193
|
})
|
|
191
194
|
|
|
195
|
+
// One sender is validated, bound, and signed for, so the request, any key authorization account, and the fill must agree.
|
|
196
|
+
const sender = (() => {
|
|
197
|
+
if (external) return undefined
|
|
198
|
+
const senders = [
|
|
199
|
+
parameters.from,
|
|
200
|
+
filled.keyAuthorization?.account,
|
|
201
|
+
filled.from,
|
|
202
|
+
].filter((value): value is Address => typeof value === 'string')
|
|
203
|
+
const [first] = senders
|
|
204
|
+
if (
|
|
205
|
+
first &&
|
|
206
|
+
senders.some((value) => !core_Address.isEqual(value, first))
|
|
207
|
+
)
|
|
208
|
+
throw new RpcResponse.InvalidParamsError({
|
|
209
|
+
message: 'Transaction sender does not match the request.',
|
|
210
|
+
})
|
|
211
|
+
return first
|
|
212
|
+
})()
|
|
213
|
+
|
|
192
214
|
const sponsored =
|
|
193
215
|
external ||
|
|
194
216
|
!options.validate ||
|
|
195
217
|
(await shouldSponsor({
|
|
196
|
-
sender
|
|
218
|
+
sender,
|
|
197
219
|
transaction: filled,
|
|
198
220
|
validate: options.validate,
|
|
199
221
|
}))
|
|
@@ -210,14 +232,14 @@ export function create(options: Relay.feePayer.Options): Relay.Plugin {
|
|
|
210
232
|
|
|
211
233
|
if (options.account && !external && !defer) {
|
|
212
234
|
delete filled.signature
|
|
213
|
-
|
|
214
|
-
authorized.set(
|
|
215
|
-
|
|
216
|
-
TxEnvelopeTempo.getFeePayerSignPayload(
|
|
235
|
+
filled.from = sender!
|
|
236
|
+
authorized.set(context, {
|
|
237
|
+
payload: TxEnvelopeTempo.getFeePayerSignPayload(
|
|
217
238
|
TxEnvelopeTempo.from(filled as never),
|
|
218
239
|
{ sender: filled.from },
|
|
219
240
|
),
|
|
220
|
-
|
|
241
|
+
sender: filled.from,
|
|
242
|
+
})
|
|
221
243
|
}
|
|
222
244
|
return {
|
|
223
245
|
...result,
|
|
@@ -253,16 +275,16 @@ export function create(options: Relay.feePayer.Options): Relay.Plugin {
|
|
|
253
275
|
const transaction = Utils.normalizeTempoTransaction(result.tx)
|
|
254
276
|
const payload = TxEnvelopeTempo.getFeePayerSignPayload(
|
|
255
277
|
TxEnvelopeTempo.from(transaction as never),
|
|
256
|
-
{ sender:
|
|
278
|
+
{ sender: transaction.from ?? approved.sender },
|
|
257
279
|
)
|
|
258
|
-
if (payload !== approved)
|
|
280
|
+
if (payload !== approved.payload)
|
|
259
281
|
throw new RpcResponse.InvalidParamsError({
|
|
260
282
|
message: 'Sponsored transaction changed after validation.',
|
|
261
283
|
})
|
|
262
284
|
const signed = await sign({
|
|
263
285
|
account: options.account,
|
|
264
286
|
onSponsored: options.onSponsored,
|
|
265
|
-
sender:
|
|
287
|
+
sender: approved.sender,
|
|
266
288
|
transaction,
|
|
267
289
|
signal: context.options.signal,
|
|
268
290
|
validity,
|
|
@@ -355,7 +377,7 @@ async function shouldSponsor(options: shouldSponsor.Options) {
|
|
|
355
377
|
|
|
356
378
|
declare namespace shouldSponsor {
|
|
357
379
|
type Options = {
|
|
358
|
-
/** Sender
|
|
380
|
+
/** Sender the request and filled transaction agree on. */
|
|
359
381
|
sender?: Address | undefined
|
|
360
382
|
/** Filled transaction to validate. */
|
|
361
383
|
transaction: Record<string, unknown>
|
package/tempo/internal/relay.ts
CHANGED
|
@@ -174,10 +174,15 @@ export async function fetch(
|
|
|
174
174
|
: Response.json(response)
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
/**
|
|
177
|
+
/**
|
|
178
|
+
* Reads a request body, returning `undefined` once its declared or streamed size exceeds {@link maxBodySize}.
|
|
179
|
+
*
|
|
180
|
+
* The cancel of an oversized body is not awaited: a cloned request's body settles its cancel only once
|
|
181
|
+
* the clone's body ends too.
|
|
182
|
+
*/
|
|
178
183
|
async function readBody(request: Request) {
|
|
179
184
|
if (Number(request.headers.get('content-length')) > maxBodySize) {
|
|
180
|
-
|
|
185
|
+
void request.body?.cancel().catch(() => {})
|
|
181
186
|
return undefined
|
|
182
187
|
}
|
|
183
188
|
const chunks: Uint8Array<ArrayBuffer>[] = []
|
|
@@ -189,7 +194,7 @@ async function readBody(request: Request) {
|
|
|
189
194
|
if (done) return chunks
|
|
190
195
|
size += value.byteLength
|
|
191
196
|
if (size > maxBodySize) {
|
|
192
|
-
|
|
197
|
+
void reader.cancel().catch(() => {})
|
|
193
198
|
return undefined
|
|
194
199
|
}
|
|
195
200
|
chunks.push(value)
|
package/tempo/internal/utils.ts
CHANGED
|
@@ -126,16 +126,8 @@ function resolveTokenForChain(
|
|
|
126
126
|
token: Token,
|
|
127
127
|
chainId: number,
|
|
128
128
|
): ResolvedToken | undefined {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return {
|
|
132
|
-
address,
|
|
133
|
-
currency: token.currency,
|
|
134
|
-
decimals: token.decimals,
|
|
135
|
-
name: token.name,
|
|
136
|
-
popular: token.popular,
|
|
137
|
-
symbol: token.symbol,
|
|
138
|
-
}
|
|
129
|
+
if (!(token.addresses as Record<number, Address>)[chainId]) return undefined
|
|
130
|
+
return token(chainId as never)
|
|
139
131
|
}
|
|
140
132
|
|
|
141
133
|
/**
|
package/tokens/defineToken.ts
CHANGED
|
@@ -17,6 +17,8 @@ export type Tokens = readonly Token[]
|
|
|
17
17
|
export type ResolvedToken = {
|
|
18
18
|
/** Token contract address. */
|
|
19
19
|
address: Address
|
|
20
|
+
/** Chain id the token was resolved for. */
|
|
21
|
+
chainId: number
|
|
20
22
|
/** Token currency denomination. */
|
|
21
23
|
currency?: string | undefined
|
|
22
24
|
/** Token decimals, used to parse human-readable `amount` strings. */
|
|
@@ -57,6 +59,7 @@ export type ResolvedToken = {
|
|
|
57
59
|
* usdc(1)
|
|
58
60
|
* // {
|
|
59
61
|
* // address: '0xA0b8…48',
|
|
62
|
+
* // chainId: 1,
|
|
60
63
|
* // currency: 'USD',
|
|
61
64
|
* // decimals: 6,
|
|
62
65
|
* // name: 'USD Coin',
|
|
@@ -76,7 +79,7 @@ export function defineToken<const token extends defineToken.Parameters>(
|
|
|
76
79
|
const address = (addresses as Record<number, Address>)[chainId]
|
|
77
80
|
if (!address)
|
|
78
81
|
throw new Error(`Token has no address for chain id "${chainId}".`)
|
|
79
|
-
return { address, currency, decimals, name, popular, symbol }
|
|
82
|
+
return { address, chainId, currency, decimals, name, popular, symbol }
|
|
80
83
|
}
|
|
81
84
|
return Object.defineProperties(fn, {
|
|
82
85
|
addresses: { enumerable: true, value: addresses },
|
|
@@ -113,13 +116,14 @@ export namespace defineToken {
|
|
|
113
116
|
|
|
114
117
|
export type ReturnType<token extends Parameters = Parameters> = {
|
|
115
118
|
/**
|
|
116
|
-
* Resolves the token config (`address`, `currency`, `decimals`, `name`,
|
|
119
|
+
* Resolves the token config (`address`, `chainId`, `currency`, `decimals`, `name`,
|
|
117
120
|
* `popular`, `symbol`) for a chain id.
|
|
118
121
|
*/
|
|
119
122
|
<chainId extends keyof token['addresses']>(
|
|
120
123
|
chainId: chainId,
|
|
121
124
|
): {
|
|
122
125
|
address: token['addresses'][chainId]
|
|
126
|
+
chainId: chainId
|
|
123
127
|
currency: ParameterValue<token, 'currency'>
|
|
124
128
|
decimals: token['decimals']
|
|
125
129
|
name: ParameterValue<token, 'name'>
|
|
@@ -2,7 +2,7 @@ import { defineToken } from '../defineToken.js'
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* [Open USD](https://joinopenstandard.com/) token, with canonical contract
|
|
5
|
-
* addresses on Ethereum, Tempo, and Base.
|
|
5
|
+
* addresses on Ethereum, Tempo, Tempo Moderato, and Base.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
@@ -17,6 +17,7 @@ export const ousd = /*#__PURE__*/ defineToken({
|
|
|
17
17
|
1: '0x9f6F3991D525015a6F8CaF062C83b62fD3AC4436', // mainnet
|
|
18
18
|
4217: '0x20c0000000000000000000006a37DA5C996874BE', // tempo
|
|
19
19
|
8453: '0xB2000000000000000000002fEb517dFeC7415344', // base
|
|
20
|
+
42431: '0x20c0000000000000000000006a37DA5C996874BE', // tempoModerato
|
|
20
21
|
},
|
|
21
22
|
currency: 'USD',
|
|
22
23
|
decimals: 6,
|