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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,67 @@
|
|
|
1
1
|
# viem
|
|
2
2
|
|
|
3
|
+
## 2.57.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#5310](https://github.com/wevm/viem/pull/5310) [`7e015cb1d72e6b54e4468d7dd60aa59a51fe8d9b`](https://github.com/wevm/viem/commit/7e015cb1d72e6b54e4468d7dd60aa59a51fe8d9b) Thanks [@BaronOdon](https://github.com/BaronOdon)! - Added Molibra chain.
|
|
8
|
+
|
|
9
|
+
- [#5314](https://github.com/wevm/viem/pull/5314) [`c0d52cdcb262744a64e742e4cf891cbbde9ccdc9`](https://github.com/wevm/viem/commit/c0d52cdcb262744a64e742e4cf891cbbde9ccdc9) Thanks [@jxom](https://github.com/jxom)! - `viem/tempo`: Keyed `Relay.accounts` stored configs by chain ID so `account_getConfig` no longer serves a config stored for another chain (configs stored under the previous key are no longer read), added a `resolveConfig` option that resolves and stores configs the store does not hold, and reduced round trips by reading the commitment without a prior block number request and writing each config once.
|
|
10
|
+
|
|
11
|
+
- [#5332](https://github.com/wevm/viem/pull/5332) [`de39e106022f313a16c3b7367d8330753748c516`](https://github.com/wevm/viem/commit/de39e106022f313a16c3b7367d8330753748c516) Thanks [@jxom](https://github.com/jxom)! - `viem/tempo`: Added `signMessage` and `signTypedData` support to `Account.fromConfig` configurable accounts, which sign the EIP-191 or EIP-712 digest with the same configurable signature envelope as `sign`.
|
|
12
|
+
|
|
13
|
+
- [#5325](https://github.com/wevm/viem/pull/5325) [`2220ab8f52cf7fcf5420502d30272175b49065ca`](https://github.com/wevm/viem/commit/2220ab8f52cf7fcf5420502d30272175b49065ca) Thanks [@Slokh](https://github.com/Slokh)! - `viem/tempo`: Fixed formatting of Tempo transactions whose nonce exceeds `Number.MAX_SAFE_INTEGER` (such as TIP-1106 expiring-nonce discriminators), which made `getTransaction`, `getBlock` with `includeTransactions` and `waitForTransactionReceipt` replacement checks throw `IntegerOutOfRangeError`. Formatted Tempo transactions now carry `nonce` as an exact `bigint`, matching ox.
|
|
14
|
+
|
|
15
|
+
- [#5337](https://github.com/wevm/viem/pull/5337) [`609f2bf5a127774904cbc9d97f0e9be7b45c3a7d`](https://github.com/wevm/viem/commit/609f2bf5a127774904cbc9d97f0e9be7b45c3a7d) Thanks [@jxom](https://github.com/jxom)! - `viem/tempo`: Fixed `Relay.feePayer` not reporting base-fee floor rejections when the Tempo node returns `fee cap less than base fee`.
|
|
16
|
+
|
|
17
|
+
- [#5336](https://github.com/wevm/viem/pull/5336) [`35e551ed4189d28749f0d12e67177a10e574f4f0`](https://github.com/wevm/viem/commit/35e551ed4189d28749f0d12e67177a10e574f4f0) Thanks [@jxom](https://github.com/jxom)! - `viem/tempo`: Fixed `fillTransaction` returning a `number` `nonce` on Tempo transactions when a `nonce` was passed and no fee payer signed the filled transaction.
|
|
18
|
+
|
|
19
|
+
- [#5330](https://github.com/wevm/viem/pull/5330) [`1f9c2f00e6b18b194aa510ee09f4ae684af2e976`](https://github.com/wevm/viem/commit/1f9c2f00e6b18b194aa510ee09f4ae684af2e976) Thanks [@jxom](https://github.com/jxom)! - Fixed `watchEvent` and `watchContractEvent` in the `eth_getLogs` fallback stalling for good when the blocks since the last poll exceeded the RPC Provider's block range, log count, or response size limit, repeating logs when an RPC node reported a lower block number, emitting logs from before a `fromBlock` past the latest block, ignoring `fromBlock: 1n`, and missing logs from the first polling interval without `fromBlock`.
|
|
20
|
+
|
|
21
|
+
## 2.57.12
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#5281](https://github.com/wevm/viem/pull/5281) [`744f749bcd56fa0bc93efd0fcdc05125e0252c21`](https://github.com/wevm/viem/commit/744f749bcd56fa0bc93efd0fcdc05125e0252c21) Thanks [@jxom](https://github.com/jxom)! - Fixed `getAbiItem` overload resolution for arrays with a `0` in the element size (e.g. `uint160[]`) or the wrong fixed length, tuple objects with reordered keys, and ambiguous `address[]` overloads.
|
|
26
|
+
|
|
27
|
+
- [#5304](https://github.com/wevm/viem/pull/5304) [`918955e81ef333af521e3e3e1b3fe03cb5231bdf`](https://github.com/wevm/viem/commit/918955e81ef333af521e3e3e1b3fe03cb5231bdf) Thanks [@jxom](https://github.com/jxom)! - Fixed `serializeAuthorizationList` and `serializeTransaction` to encode an EIP-7702 authorization `yParity` above 1 as is instead of normalizing it to 1, which changed the transaction hash.
|
|
28
|
+
|
|
29
|
+
- [#5279](https://github.com/wevm/viem/pull/5279) [`10ef1295f73362ea4f3c36b6655fef1cb04b397e`](https://github.com/wevm/viem/commit/10ef1295f73362ea4f3c36b6655fef1cb04b397e) Thanks [@jxom](https://github.com/jxom)! - Fixed `signatureToCompactSignature` and `compactSignatureToSignature` for values shorter than 32 bytes and a legacy `v` with a chain id, and added errors for invalid `v` and high `s`.
|
|
30
|
+
|
|
31
|
+
- [#5298](https://github.com/wevm/viem/pull/5298) [`a69e96c8e89cc0398a6b918c392e24e3b615bee0`](https://github.com/wevm/viem/commit/a69e96c8e89cc0398a6b918c392e24e3b615bee0) Thanks [@jxom](https://github.com/jxom)! - Fixed `getTimeToFinalize` and `waitToFinalize` to also wait for the proof's dispute game to resolve and pass its finality delay, instead of only the proof maturity delay.
|
|
32
|
+
|
|
33
|
+
- [#5282](https://github.com/wevm/viem/pull/5282) [`52140fef00389781737477de205f82f71553b3c3`](https://github.com/wevm/viem/commit/52140fef00389781737477de205f82f71553b3c3) Thanks [@jxom](https://github.com/jxom)! - Fixed `http` transport batches and `getHttpRpcClient` array requests mishandling a server that rejected the whole batch with a single error or returned fewer responses than requests.
|
|
34
|
+
|
|
35
|
+
- [#5286](https://github.com/wevm/viem/pull/5286) [`8e058ca71bf09c85d2a4669af5e98aeb5bc87e71`](https://github.com/wevm/viem/commit/8e058ca71bf09c85d2a4669af5e98aeb5bc87e71) Thanks [@jxom](https://github.com/jxom)! - Fixed the `http` transport to retry JSON-RPC errors from non-2xx responses by their HTTP status and `Retry-After` header, and exposed `status` and `headers` on `RpcRequestError`.
|
|
36
|
+
|
|
37
|
+
- [#5300](https://github.com/wevm/viem/pull/5300) [`485a9d922ffe00a3d2bc4bbfc6ef0262a85e9f45`](https://github.com/wevm/viem/commit/485a9d922ffe00a3d2bc4bbfc6ef0262a85e9f45) Thanks [@jxom](https://github.com/jxom)! - Fixed `toFunctionSelector` and `toSignatureHash` keeping the `error` keyword in string signatures like `error Foo(uint256)`, which produced the wrong selector.
|
|
38
|
+
|
|
39
|
+
- [#5283](https://github.com/wevm/viem/pull/5283) [`b2b7a3b82fd52ad74f80075d5a25cd99750f754a`](https://github.com/wevm/viem/commit/b2b7a3b82fd52ad74f80075d5a25cd99750f754a) Thanks [@jxom](https://github.com/jxom)! - Added an `even` option to `isHex` that rejects hex values with an odd number of hex characters.
|
|
40
|
+
|
|
41
|
+
- [#5303](https://github.com/wevm/viem/pull/5303) [`d10dc3c203c63ec42abc2cd392fb7de4562cb591`](https://github.com/wevm/viem/commit/d10dc3c203c63ec42abc2cd392fb7de4562cb591) Thanks [@jxom](https://github.com/jxom)! - Fixed `InsufficientFundsError` not being raised for reth's `EVM error: OutOfFunds` node message.
|
|
42
|
+
|
|
43
|
+
- [#5280](https://github.com/wevm/viem/pull/5280) [`e7e0122fab41b6c43d1d03ffe395044d1445bcc0`](https://github.com/wevm/viem/commit/e7e0122fab41b6c43d1d03ffe395044d1445bcc0) Thanks [@jxom](https://github.com/jxom)! - Fixed `parseEventLogs` `args` filters dropping logs whose `string` or `bytes` values were decoded from data or differed in hex case, and matching every partially decoded log.
|
|
44
|
+
|
|
45
|
+
- [#5284](https://github.com/wevm/viem/pull/5284) [`b3e39473523d7be57ec5f35f51cb416f16b6cbd2`](https://github.com/wevm/viem/commit/b3e39473523d7be57ec5f35f51cb416f16b6cbd2) Thanks [@jxom](https://github.com/jxom)! - Added a `replacement` parameter to `waitForTransactionReceipt` that detects a replacement of a Transaction the node dropped before the wait first read it, and fixed `onReplaced` not being called for a replacement when `confirmations` is greater than 1.
|
|
46
|
+
|
|
47
|
+
- [#5288](https://github.com/wevm/viem/pull/5288) [`75ffe81d29d85bee3b895a5d7ae612675b625ee8`](https://github.com/wevm/viem/commit/75ffe81d29d85bee3b895a5d7ae612675b625ee8) Thanks [@jxom](https://github.com/jxom)! - Fixed request retries firing immediately for `Retry-After` headers in HTTP-date form or for delays longer than the 24.8-day timer limit.
|
|
48
|
+
|
|
49
|
+
- [#5301](https://github.com/wevm/viem/pull/5301) [`efda1c43147b85fdde5a9d5b88c4ffd5a9262073`](https://github.com/wevm/viem/commit/efda1c43147b85fdde5a9d5b88c4ffd5a9262073) Thanks [@jxom](https://github.com/jxom)! - Fixed `sendCalls` dropping a call's `dataSuffix` when the call has no `data`.
|
|
50
|
+
|
|
51
|
+
- [#5306](https://github.com/wevm/viem/pull/5306) [`30833eca2ef352e2af34f577964b633823acc999`](https://github.com/wevm/viem/commit/30833eca2ef352e2af34f577964b633823acc999) Thanks [@jxom](https://github.com/jxom)! - Fixed importing `viem`, `viem/actions`, `viem/chains`, and other entrypoints under SES `lockdown()`, which threw `Cannot assign to read only property 'call'`.
|
|
52
|
+
|
|
53
|
+
- [#5299](https://github.com/wevm/viem/pull/5299) [`6c2278d129eb21b2928999fd2f5b28c233132f7d`](https://github.com/wevm/viem/commit/6c2278d129eb21b2928999fd2f5b28c233132f7d) Thanks [@jxom](https://github.com/jxom)! - Fixed `createSiweMessage` rejecting domains with a punycode (internationalized) top-level domain, such as `example.xn--p1ai`, and accepting top-level domain labels longer than 63 characters.
|
|
54
|
+
|
|
55
|
+
- [#5302](https://github.com/wevm/viem/pull/5302) [`c42c189ee8fe1b0183b6abf1b00a58f134ea2b57`](https://github.com/wevm/viem/commit/c42c189ee8fe1b0183b6abf1b00a58f134ea2b57) Thanks [@jxom](https://github.com/jxom)! - Fixed `getWithdrawalStatus`, `getTimeToProve` and `waitToProve` matching super-root dispute games against the withdrawal's L2 block number when `l2Timestamp` was not passed: they now use the `blockTimestamp` of the receipt's logs, or throw `L2TimestampRequiredError` when it is missing.
|
|
56
|
+
|
|
57
|
+
- [#5311](https://github.com/wevm/viem/pull/5311) [`e3247c5513912695313dba030111e7f6a1e1aacd`](https://github.com/wevm/viem/commit/e3247c5513912695313dba030111e7f6a1e1aacd) Thanks [@jxom](https://github.com/jxom)! - `viem/tempo`: Derived configurable account addresses from the initial config hash instead of a recovery factory (tempoxyz/tempo#8595), so `Account.fromConfig` no longer takes a `factory` option and `Addresses.configurableAccountRecoveryFactory` was removed.
|
|
58
|
+
|
|
59
|
+
- [#5308](https://github.com/wevm/viem/pull/5308) [`71636a342b859fa9f15296d2f15377430db4629e`](https://github.com/wevm/viem/commit/71636a342b859fa9f15296d2f15377430db4629e) Thanks [@jxom](https://github.com/jxom)! - Fixed `validateTypedData` and `hashTypedData` to accept struct names that start with a Solidity type name (such as `intent`), to reject struct names that shadow a Solidity type (such as `uint256[]` or `uint7`), and to include struct names that contain `$` in the encoded type.
|
|
60
|
+
|
|
61
|
+
- [#5271](https://github.com/wevm/viem/pull/5271) [`2867b2a88458044af6aa84fc5494539eab05e143`](https://github.com/wevm/viem/commit/2867b2a88458044af6aa84fc5494539eab05e143) Thanks [@loveyuanfandj-glitch](https://github.com/loveyuanfandj-glitch)! - Added ValueChain mainnet and testnet chains.
|
|
62
|
+
|
|
63
|
+
- [#5309](https://github.com/wevm/viem/pull/5309) [`5068c9ffc5cdb8b7240aa18158db6c62ad455944`](https://github.com/wevm/viem/commit/5068c9ffc5cdb8b7240aa18158db6c62ad455944) Thanks [@mmv08](https://github.com/mmv08)! - Fixed `watchEvent` to pass `strict` to its `getLogs` fallback, so a `strict: true` watcher on an RPC Provider without filters no longer gets logs that do not match the event.
|
|
64
|
+
|
|
3
65
|
## 2.57.11
|
|
4
66
|
|
|
5
67
|
### Patch Changes
|
|
@@ -71,7 +71,7 @@ async function fillTransaction(client, parameters) {
|
|
|
71
71
|
transaction.feePayerSignature !== null;
|
|
72
72
|
if (hasFeePayerSignature &&
|
|
73
73
|
typeof nonce !== 'undefined' &&
|
|
74
|
-
transaction.nonce !== nonce)
|
|
74
|
+
BigInt(transaction.nonce) !== BigInt(nonce))
|
|
75
75
|
throw new transaction_js_1.FeePayerNonceMismatchError({
|
|
76
76
|
filledNonce: transaction.nonce,
|
|
77
77
|
requestedNonce: nonce,
|
|
@@ -90,8 +90,11 @@ async function fillTransaction(client, parameters) {
|
|
|
90
90
|
if (transaction.maxPriorityFeePerGas)
|
|
91
91
|
transaction.maxPriorityFeePerGas =
|
|
92
92
|
parameters.maxPriorityFeePerGas ?? transaction.maxPriorityFeePerGas;
|
|
93
|
-
if (typeof transaction.nonce !== 'undefined'
|
|
94
|
-
|
|
93
|
+
if (typeof transaction.nonce !== 'undefined' &&
|
|
94
|
+
typeof parameters.nonce !== 'undefined')
|
|
95
|
+
transaction.nonce = (typeof transaction.nonce === 'bigint'
|
|
96
|
+
? BigInt(parameters.nonce)
|
|
97
|
+
: parameters.nonce);
|
|
95
98
|
const feeMultiplier = await (async () => {
|
|
96
99
|
if (typeof chain?.fees?.baseFeeMultiplier === 'function') {
|
|
97
100
|
const block = await (0, getAction_js_1.getAction)(client, getBlock_js_1.getBlock, 'getBlock')({});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fillTransaction.js","sourceRoot":"","sources":["../../../actions/public/fillTransaction.ts"],"names":[],"mappings":";;AAkGA,
|
|
1
|
+
{"version":3,"file":"fillTransaction.js","sourceRoot":"","sources":["../../../actions/public/fillTransaction.ts"],"names":[],"mappings":";;AAkGA,0CA0LC;AA3RD,0EAAmE;AAInE,gDAAwD;AACxD,gEAAwE;AAaxE,sFAGkD;AAClD,kEAA2D;AAC3D,0EAG8C;AAC9C,wFAGqD;AACrD,2DAAoD;AAEpD,+EAAwE;AACxE,+CAAwC;AACxC,mDAA2D;AA8DpD,KAAK,UAAU,eAAe,CAMnC,MAAyC,EACzC,UAKC;IAED,MAAM,EACJ,OAAO,GAAG,MAAM,CAAC,OAAO,EACxB,UAAU,EACV,iBAAiB,EACjB,KAAK,GAAG,MAAM,CAAC,KAAK,EACpB,mBAAmB,EACnB,KAAK,EACL,IAAI,EACJ,GAAG,EACH,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,oBAA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require("../../errors/block.js");
|
|
5
|
+
const rpc_js_1 = require("../../errors/rpc.js");
|
|
5
6
|
const transaction_js_1 = require("../../errors/transaction.js");
|
|
6
7
|
const isAddressEqual_js_1 = require("../../utils/address/isAddressEqual.js");
|
|
7
8
|
const getAction_js_1 = require("../../utils/getAction.js");
|
|
@@ -16,6 +17,9 @@ const watchBlockNumber_js_1 = require("./watchBlockNumber.js");
|
|
|
16
17
|
async function waitForTransactionReceipt(client, parameters) {
|
|
17
18
|
const { checkReplacement = client.chain?.supportsTransactionReplacementDetection ??
|
|
18
19
|
true, confirmations = 1, hash, onReplaced, retryCount = 6, retryDelay = ({ count }) => ~~(1 << count) * 200, timeout = 180_000, } = parameters;
|
|
20
|
+
const replacement = client.chain?.transactionReplacement?.getKey
|
|
21
|
+
? undefined
|
|
22
|
+
: parameters.replacement;
|
|
19
23
|
const getReplacementKey = (transaction) => client.chain?.transactionReplacement?.getKey?.(transaction) ??
|
|
20
24
|
String(transaction.nonce);
|
|
21
25
|
const pollingInterval = (() => {
|
|
@@ -33,13 +37,14 @@ async function waitForTransactionReceipt(client, parameters) {
|
|
|
33
37
|
checkReplacement,
|
|
34
38
|
confirmations,
|
|
35
39
|
pollingInterval,
|
|
40
|
+
replacement,
|
|
36
41
|
retryCount,
|
|
37
42
|
timeout,
|
|
38
43
|
},
|
|
39
44
|
]);
|
|
40
45
|
let transaction;
|
|
41
|
-
let replacedTransaction;
|
|
42
46
|
let receipt;
|
|
47
|
+
let replacementResponse;
|
|
43
48
|
let retrying = false;
|
|
44
49
|
let _unobserve;
|
|
45
50
|
let _unwatch;
|
|
@@ -80,7 +85,11 @@ async function waitForTransactionReceipt(client, parameters) {
|
|
|
80
85
|
(!receipt.blockNumber ||
|
|
81
86
|
blockNumber - receipt.blockNumber + 1n < confirmations))
|
|
82
87
|
return;
|
|
83
|
-
done(() =>
|
|
88
|
+
done(() => {
|
|
89
|
+
if (replacementResponse)
|
|
90
|
+
emit.onReplaced?.(replacementResponse);
|
|
91
|
+
emit.resolve(receipt);
|
|
92
|
+
});
|
|
84
93
|
return;
|
|
85
94
|
}
|
|
86
95
|
if (checkReplacement && !transaction) {
|
|
@@ -92,6 +101,7 @@ async function waitForTransactionReceipt(client, parameters) {
|
|
|
92
101
|
}, {
|
|
93
102
|
delay: retryDelay,
|
|
94
103
|
retryCount,
|
|
104
|
+
shouldRetry: ({ error }) => !(replacement && error instanceof transaction_js_1.TransactionNotFoundError),
|
|
95
105
|
});
|
|
96
106
|
retrying = false;
|
|
97
107
|
}
|
|
@@ -105,16 +115,66 @@ async function waitForTransactionReceipt(client, parameters) {
|
|
|
105
115
|
catch (err) {
|
|
106
116
|
if (err instanceof transaction_js_1.TransactionNotFoundError ||
|
|
107
117
|
err instanceof transaction_js_1.TransactionReceiptNotFoundError) {
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
retrying = false;
|
|
119
|
+
const replaced = transaction ??
|
|
120
|
+
(checkReplacement && replacement
|
|
121
|
+
? {
|
|
122
|
+
...replacement,
|
|
123
|
+
hash: hash.toLowerCase(),
|
|
124
|
+
}
|
|
125
|
+
: undefined);
|
|
126
|
+
if (!replaced)
|
|
110
127
|
return;
|
|
111
|
-
|
|
112
|
-
if (transaction.blockNumber) {
|
|
113
|
-
retrying = false;
|
|
128
|
+
if (replaced.blockNumber)
|
|
114
129
|
return;
|
|
115
|
-
}
|
|
116
130
|
try {
|
|
117
|
-
|
|
131
|
+
if (!transaction) {
|
|
132
|
+
retrying = true;
|
|
133
|
+
const found = (await (0, getAction_js_1.getAction)(client, getTransaction_js_1.getTransaction, 'getTransaction')({
|
|
134
|
+
nonce: replaced.nonce,
|
|
135
|
+
sender: replaced.from,
|
|
136
|
+
}).catch((error) => {
|
|
137
|
+
if (error instanceof rpc_js_1.MethodNotFoundRpcError ||
|
|
138
|
+
error instanceof rpc_js_1.MethodNotSupportedRpcError)
|
|
139
|
+
transaction = replaced;
|
|
140
|
+
return undefined;
|
|
141
|
+
}));
|
|
142
|
+
retrying = false;
|
|
143
|
+
if (found?.hash.toLowerCase() ===
|
|
144
|
+
replaced.hash) {
|
|
145
|
+
transaction = found;
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (found) {
|
|
149
|
+
const replacementReceipt = await (0, getAction_js_1.getAction)(client, getTransactionReceipt_js_1.getTransactionReceipt, 'getTransactionReceipt')({ hash: found.hash }).catch((error) => {
|
|
150
|
+
if (error instanceof transaction_js_1.TransactionReceiptNotFoundError)
|
|
151
|
+
return undefined;
|
|
152
|
+
throw error;
|
|
153
|
+
});
|
|
154
|
+
if (!replacementReceipt)
|
|
155
|
+
return;
|
|
156
|
+
receipt = replacementReceipt;
|
|
157
|
+
replacementResponse = {
|
|
158
|
+
reason: client.chain?.transactionReplacement?.getReason?.({
|
|
159
|
+
replaced,
|
|
160
|
+
replacement: found,
|
|
161
|
+
}) ??
|
|
162
|
+
getReplacementReason(replaced, found),
|
|
163
|
+
replacedTransaction: replaced,
|
|
164
|
+
transaction: found,
|
|
165
|
+
transactionReceipt: receipt,
|
|
166
|
+
};
|
|
167
|
+
if (confirmations > 1 &&
|
|
168
|
+
(!receipt.blockNumber ||
|
|
169
|
+
blockNumber - receipt.blockNumber + 1n < confirmations))
|
|
170
|
+
return;
|
|
171
|
+
done(() => {
|
|
172
|
+
emit.onReplaced?.(replacementResponse);
|
|
173
|
+
emit.resolve(receipt);
|
|
174
|
+
});
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
118
178
|
retrying = true;
|
|
119
179
|
const block = await (0, withRetry_js_1.withRetry)(() => (0, getAction_js_1.getAction)(client, getBlock_js_1.getBlock, 'getBlock')({
|
|
120
180
|
blockNumber,
|
|
@@ -125,31 +185,31 @@ async function waitForTransactionReceipt(client, parameters) {
|
|
|
125
185
|
shouldRetry: ({ error }) => error instanceof block_js_1.BlockNotFoundError,
|
|
126
186
|
});
|
|
127
187
|
retrying = false;
|
|
128
|
-
const replacedKey = getReplacementKey(
|
|
129
|
-
const replacementTransaction = block.transactions.find((candidate) => (0, isAddressEqual_js_1.isAddressEqual)(candidate.from,
|
|
130
|
-
candidate.hash !==
|
|
188
|
+
const replacedKey = getReplacementKey(replaced);
|
|
189
|
+
const replacementTransaction = block.transactions.find((candidate) => (0, isAddressEqual_js_1.isAddressEqual)(candidate.from, replaced.from) &&
|
|
190
|
+
candidate.hash !== replaced.hash &&
|
|
131
191
|
getReplacementKey(candidate) === replacedKey);
|
|
132
192
|
if (!replacementTransaction)
|
|
133
193
|
return;
|
|
134
194
|
receipt = await (0, getAction_js_1.getAction)(client, getTransactionReceipt_js_1.getTransactionReceipt, 'getTransactionReceipt')({
|
|
135
195
|
hash: replacementTransaction.hash,
|
|
136
196
|
});
|
|
197
|
+
replacementResponse = {
|
|
198
|
+
reason: client.chain?.transactionReplacement?.getReason?.({
|
|
199
|
+
replaced,
|
|
200
|
+
replacement: replacementTransaction,
|
|
201
|
+
}) ??
|
|
202
|
+
getReplacementReason(replaced, replacementTransaction),
|
|
203
|
+
replacedTransaction: replaced,
|
|
204
|
+
transaction: replacementTransaction,
|
|
205
|
+
transactionReceipt: receipt,
|
|
206
|
+
};
|
|
137
207
|
if (confirmations > 1 &&
|
|
138
208
|
(!receipt.blockNumber ||
|
|
139
209
|
blockNumber - receipt.blockNumber + 1n < confirmations))
|
|
140
210
|
return;
|
|
141
|
-
const reason = client.chain?.transactionReplacement?.getReason?.({
|
|
142
|
-
replaced: replacedTransaction,
|
|
143
|
-
replacement: replacementTransaction,
|
|
144
|
-
}) ??
|
|
145
|
-
getReplacementReason(replacedTransaction, replacementTransaction);
|
|
146
211
|
done(() => {
|
|
147
|
-
emit.onReplaced?.(
|
|
148
|
-
reason,
|
|
149
|
-
replacedTransaction: replacedTransaction,
|
|
150
|
-
transaction: replacementTransaction,
|
|
151
|
-
transactionReceipt: receipt,
|
|
152
|
-
});
|
|
212
|
+
emit.onReplaced?.(replacementResponse);
|
|
153
213
|
emit.resolve(receipt);
|
|
154
214
|
});
|
|
155
215
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForTransactionReceipt.js","sourceRoot":"","sources":["../../../actions/public/waitForTransactionReceipt.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"waitForTransactionReceipt.js","sourceRoot":"","sources":["../../../actions/public/waitForTransactionReceipt.ts"],"names":[],"mappings":";;AAgLA,8DAiXC;AA7hBD,oDAA0D;AAC1D,gDAG4B;AAC5B,gEAKoC;AAKpC,6EAAsE;AACtE,2DAAoD;AACpD,uDAAuE;AACvE,2EAAoE;AACpE,mEAGyC;AACzC,2DAAoD;AAEpD,+CAAgE;AAChE,2DAI4B;AAC5B,yEAImC;AACnC,+DAG8B;AAqIvB,KAAK,UAAU,yBAAyB,CAG7C,MAAgC,EAChC,UAAsD;IAEtD,MAAM,EACJ,gBAAgB,GAAG,MAAM,CAAC,KAAK,EAAE,uCAAuC;QACtE,IAAI,EACN,aAAa,GAAG,CAAC,EACjB,IAAI,EACJ,UAAU,EACV,UAAU,GAAG,CAAC,EACd,UAAU,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,GAAG,EAChD,OAAO,GAAG,OAAO,GAClB,GAAG,UAAU,CAAA;IAId,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,EAAE,sBAAsB,EAAE,MAAM;QAC9D,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,UAAU,CAAC,WAAW,CAAA;IAE1B,MAAM,iBAAiB,GAAG,CAAC,WAAwB,EAAE,EAAE,CACrD,MAAM,CAAC,KAAK,EAAE,sBAAsB,EAAE,MAAM,EAAE,CAAC,WAAW,CAAC;QAC3D,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;IAE3B,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE;QAC5B,IAAI,UAAU,CAAC,eAAe;YAAE,OAAO,UAAU,CAAC,eAAe,CAAA;QACjE,IAA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AC,CAAC,IAAA,kCAAc,EAAC,WAAW,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC7C,CAAC,CAAC,WAAW,CAAC,EAAE,KAAK,QAAQ,CAAC,EAAE,CAAC;QACnC,WAAW,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK;QACpC,WAAW,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK;QAEpC,OAAO,UAAU,CAAA;IACnB,IAAI,WAAW,CAAC,IAAI,KAAK,WAAW,CAAC,EAAE,IAAI,WAAW,CAAC,KAAK,KAAK,EAAE;QACjE,OAAO,WAAW,CAAA;IACpB,OAAO,UAAU,CAAA;AACnB,CAAC"}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.watchContractEvent = watchContractEvent;
|
|
4
4
|
const abi_js_1 = require("../../errors/abi.js");
|
|
5
|
+
const base_js_1 = require("../../errors/base.js");
|
|
6
|
+
const request_js_1 = require("../../errors/request.js");
|
|
5
7
|
const rpc_js_1 = require("../../errors/rpc.js");
|
|
6
8
|
const decodeEventLog_js_1 = require("../../utils/abi/decodeEventLog.js");
|
|
7
9
|
const encodeEventTopics_js_1 = require("../../utils/abi/encodeEventTopics.js");
|
|
@@ -45,11 +47,28 @@ function watchContractEvent(client, parameters) {
|
|
|
45
47
|
fromBlock,
|
|
46
48
|
]);
|
|
47
49
|
return (0, observe_js_1.observe)(observerId, { onLogs, onError }, (emit) => {
|
|
48
|
-
let
|
|
49
|
-
|
|
50
|
-
previousBlockNumber = fromBlock - 1n;
|
|
50
|
+
let active = true;
|
|
51
|
+
let previousBlockNumber = fromBlock === undefined ? undefined : fromBlock - 1n;
|
|
51
52
|
let filter;
|
|
52
53
|
let initialized = false;
|
|
54
|
+
const emitLogs = (logs) => {
|
|
55
|
+
if (logs.length === 0)
|
|
56
|
+
return;
|
|
57
|
+
if (batch)
|
|
58
|
+
emit.onLogs(logs);
|
|
59
|
+
else
|
|
60
|
+
for (const log of logs)
|
|
61
|
+
emit.onLogs([log]);
|
|
62
|
+
};
|
|
63
|
+
const getLogsInRange = (from, to) => (0, getAction_js_1.getAction)(client, getContractEvents_js_1.getContractEvents, 'getContractEvents')({
|
|
64
|
+
abi,
|
|
65
|
+
address,
|
|
66
|
+
args,
|
|
67
|
+
eventName,
|
|
68
|
+
fromBlock: from,
|
|
69
|
+
toBlock: to,
|
|
70
|
+
strict,
|
|
71
|
+
});
|
|
53
72
|
const unwatch = (0, poll_js_1.poll)(async () => {
|
|
54
73
|
if (!initialized) {
|
|
55
74
|
try {
|
|
@@ -64,38 +83,35 @@ function watchContractEvent(client, parameters) {
|
|
|
64
83
|
}
|
|
65
84
|
catch { }
|
|
66
85
|
initialized = true;
|
|
67
|
-
|
|
86
|
+
if (filter)
|
|
87
|
+
return;
|
|
68
88
|
}
|
|
69
89
|
try {
|
|
70
|
-
let logs;
|
|
71
90
|
if (filter) {
|
|
72
|
-
logs = await (0, getAction_js_1.getAction)(client, getFilterChanges_js_1.getFilterChanges, 'getFilterChanges')({ filter });
|
|
91
|
+
const logs = await (0, getAction_js_1.getAction)(client, getFilterChanges_js_1.getFilterChanges, 'getFilterChanges')({ filter });
|
|
92
|
+
emitLogs(logs);
|
|
93
|
+
return;
|
|
73
94
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
95
|
+
const blockNumber = await (0, getAction_js_1.getAction)(client, getBlockNumber_js_1.getBlockNumber, 'getBlockNumber')({});
|
|
96
|
+
previousBlockNumber ??= blockNumber;
|
|
97
|
+
let size = blockNumber - previousBlockNumber;
|
|
98
|
+
while (previousBlockNumber < blockNumber) {
|
|
99
|
+
const from = previousBlockNumber + 1n;
|
|
100
|
+
const end = previousBlockNumber + size;
|
|
101
|
+
const to = end < blockNumber ? end : blockNumber;
|
|
102
|
+
const logs = await getLogsInRange(from, to).catch((error) => {
|
|
103
|
+
if (from === to || !isRangeError(error))
|
|
104
|
+
throw error;
|
|
105
|
+
});
|
|
106
|
+
if (!active)
|
|
107
|
+
return;
|
|
108
|
+
if (!logs) {
|
|
109
|
+
size = (to - from + 1n) / 2n;
|
|
110
|
+
continue;
|
|
86
111
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
previousBlockNumber = blockNumber;
|
|
112
|
+
previousBlockNumber = to;
|
|
113
|
+
emitLogs(logs);
|
|
91
114
|
}
|
|
92
|
-
if (logs.length === 0)
|
|
93
|
-
return;
|
|
94
|
-
if (batch)
|
|
95
|
-
emit.onLogs(logs);
|
|
96
|
-
else
|
|
97
|
-
for (const log of logs)
|
|
98
|
-
emit.onLogs([log]);
|
|
99
115
|
}
|
|
100
116
|
catch (err) {
|
|
101
117
|
if (filter && err instanceof rpc_js_1.InvalidInputRpcError)
|
|
@@ -107,6 +123,7 @@ function watchContractEvent(client, parameters) {
|
|
|
107
123
|
interval: pollingInterval,
|
|
108
124
|
});
|
|
109
125
|
return async () => {
|
|
126
|
+
active = false;
|
|
110
127
|
if (filter)
|
|
111
128
|
await (0, getAction_js_1.getAction)(client, uninstallFilter_js_1.uninstallFilter, 'uninstallFilter')({ filter });
|
|
112
129
|
unwatch();
|
|
@@ -201,4 +218,16 @@ function watchContractEvent(client, parameters) {
|
|
|
201
218
|
};
|
|
202
219
|
return enablePolling ? pollContractEvent() : subscribeContractEvent();
|
|
203
220
|
}
|
|
221
|
+
function isRangeError(error) {
|
|
222
|
+
if (!(error instanceof base_js_1.BaseError))
|
|
223
|
+
return true;
|
|
224
|
+
const cause = error.walk((err) => err instanceof request_js_1.HttpRequestError || err instanceof request_js_1.RpcRequestError);
|
|
225
|
+
if (!cause)
|
|
226
|
+
return true;
|
|
227
|
+
if (cause instanceof request_js_1.RpcRequestError && cause.code === 429)
|
|
228
|
+
return false;
|
|
229
|
+
if (cause instanceof request_js_1.HttpRequestError && cause.status === undefined)
|
|
230
|
+
return false;
|
|
231
|
+
return cause.status !== 401 && cause.status !== 403 && cause.status !== 429;
|
|
232
|
+
}
|
|
204
233
|
//# sourceMappingURL=watchContractEvent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watchContractEvent.js","sourceRoot":"","sources":["../../../actions/public/watchContractEvent.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"watchContractEvent.js","sourceRoot":"","sources":["../../../actions/public/watchContractEvent.ts"],"names":[],"mappings":";;AAqIA,gDAgRC;AAjZD,gDAG4B;AAC5B,kDAAgD;AAChD,wDAA2E;AAC3E,gDAA0D;AAY1D,yEAAkE;AAClE,+EAG6C;AAC7C,0DAAyD;AACzD,2DAAoD;AACpD,uDAAuE;AACvE,iDAA0C;AAC1C,2DAA6E;AAC7E,iFAA0E;AAC1E,2DAAoD;AACpD,iEAG+B;AAC/B,+DAAwD;AACxD,6DAAsD;AA8FtD,SAAgB,kBAAkB,CAOhC,MAAgC,EAChC,UAA2E;IAE3E,MAAM,EACJ,GAAG,EACH,OAAO,EACP,IAAI,EACJ,KAAK,GAAG,IAAI,EACZ,SAAS,EACT,SAAS,EACT,OAAO,EACP,MAAM,EACN,IAAI,EAAE,KAAK,EACX,eAAe,GAAG,MAAM,CAAC,eAAe,EACxC,MAAM,EAAE,OAAO,GAChB,GAAG,UAAU,CAAA;IAEd,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE;QAC1B,IAAI,OAAO,KAAK,KAAK,WAAW;YAAE,OAAO,KAAK,CAAA;QAC9C,IAAI,OAAO,SAAS,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAA;QAC9C,IACE,MAAM,CAAC,SAAS,CAAC,IAAI,KAAK,WAAW;YACrC,MAAM,CAAC,SAAS,CAAC,IAAI,KAAK,KAAK;YAE/B,OAAO,KAAK,CAAA;QACd,IACE,MAAM,CAAC,SAAS,CAAC,IAAI,KAAK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ent;
|
|
4
4
|
const abi_js_1 = require("../../errors/abi.js");
|
|
5
|
+
const base_js_1 = require("../../errors/base.js");
|
|
6
|
+
const request_js_1 = require("../../errors/request.js");
|
|
5
7
|
const rpc_js_1 = require("../../errors/rpc.js");
|
|
6
8
|
const decodeEventLog_js_1 = require("../../utils/abi/decodeEventLog.js");
|
|
7
9
|
const encodeEventTopics_js_1 = require("../../utils/abi/encodeEventTopics.js");
|
|
@@ -45,11 +47,28 @@ function watchEvent(client, { address, args, batch = true, event, events, fromBl
|
|
|
45
47
|
fromBlock,
|
|
46
48
|
]);
|
|
47
49
|
return (0, observe_js_1.observe)(observerId, { onLogs, onError }, (emit) => {
|
|
48
|
-
let
|
|
49
|
-
|
|
50
|
-
previousBlockNumber = fromBlock - 1n;
|
|
50
|
+
let active = true;
|
|
51
|
+
let previousBlockNumber = fromBlock === undefined ? undefined : fromBlock - 1n;
|
|
51
52
|
let filter;
|
|
52
53
|
let initialized = false;
|
|
54
|
+
const emitLogs = (logs) => {
|
|
55
|
+
if (logs.length === 0)
|
|
56
|
+
return;
|
|
57
|
+
if (batch)
|
|
58
|
+
emit.onLogs(logs);
|
|
59
|
+
else
|
|
60
|
+
for (const log of logs)
|
|
61
|
+
emit.onLogs([log]);
|
|
62
|
+
};
|
|
63
|
+
const getLogsInRange = (from, to) => (0, getAction_js_1.getAction)(client, getLogs_js_1.getLogs, 'getLogs')({
|
|
64
|
+
address,
|
|
65
|
+
args,
|
|
66
|
+
event: event,
|
|
67
|
+
events,
|
|
68
|
+
fromBlock: from,
|
|
69
|
+
strict,
|
|
70
|
+
toBlock: to,
|
|
71
|
+
});
|
|
53
72
|
const unwatch = (0, poll_js_1.poll)(async () => {
|
|
54
73
|
if (!initialized) {
|
|
55
74
|
try {
|
|
@@ -64,37 +83,35 @@ function watchEvent(client, { address, args, batch = true, event, events, fromBl
|
|
|
64
83
|
}
|
|
65
84
|
catch { }
|
|
66
85
|
initialized = true;
|
|
67
|
-
|
|
86
|
+
if (filter)
|
|
87
|
+
return;
|
|
68
88
|
}
|
|
69
89
|
try {
|
|
70
|
-
let logs;
|
|
71
90
|
if (filter) {
|
|
72
|
-
logs = await (0, getAction_js_1.getAction)(client, getFilterChanges_js_1.getFilterChanges, 'getFilterChanges')({ filter });
|
|
91
|
+
const logs = await (0, getAction_js_1.getAction)(client, getFilterChanges_js_1.getFilterChanges, 'getFilterChanges')({ filter });
|
|
92
|
+
emitLogs(logs);
|
|
93
|
+
return;
|
|
73
94
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
const blockNumber = await (0, getAction_js_1.getAction)(client, getBlockNumber_js_1.getBlockNumber, 'getBlockNumber')({});
|
|
96
|
+
previousBlockNumber ??= blockNumber;
|
|
97
|
+
let size = blockNumber - previousBlockNumber;
|
|
98
|
+
while (previousBlockNumber < blockNumber) {
|
|
99
|
+
const from = previousBlockNumber + 1n;
|
|
100
|
+
const end = previousBlockNumber + size;
|
|
101
|
+
const to = end < blockNumber ? end : blockNumber;
|
|
102
|
+
const logs = await getLogsInRange(from, to).catch((error) => {
|
|
103
|
+
if (from === to || !isRangeError(error))
|
|
104
|
+
throw error;
|
|
105
|
+
});
|
|
106
|
+
if (!active)
|
|
107
|
+
return;
|
|
108
|
+
if (!logs) {
|
|
109
|
+
size = (to - from + 1n) / 2n;
|
|
110
|
+
continue;
|
|
88
111
|
}
|
|
89
|
-
previousBlockNumber =
|
|
112
|
+
previousBlockNumber = to;
|
|
113
|
+
emitLogs(logs);
|
|
90
114
|
}
|
|
91
|
-
if (logs.length === 0)
|
|
92
|
-
return;
|
|
93
|
-
if (batch)
|
|
94
|
-
emit.onLogs(logs);
|
|
95
|
-
else
|
|
96
|
-
for (const log of logs)
|
|
97
|
-
emit.onLogs([log]);
|
|
98
115
|
}
|
|
99
116
|
catch (err) {
|
|
100
117
|
if (filter && err instanceof rpc_js_1.InvalidInputRpcError)
|
|
@@ -106,6 +123,7 @@ function watchEvent(client, { address, args, batch = true, event, events, fromBl
|
|
|
106
123
|
interval: pollingInterval,
|
|
107
124
|
});
|
|
108
125
|
return async () => {
|
|
126
|
+
active = false;
|
|
109
127
|
if (filter)
|
|
110
128
|
await (0, getAction_js_1.getAction)(client, uninstallFilter_js_1.uninstallFilter, 'uninstallFilter')({ filter });
|
|
111
129
|
unwatch();
|
|
@@ -188,4 +206,16 @@ function watchEvent(client, { address, args, batch = true, event, events, fromBl
|
|
|
188
206
|
};
|
|
189
207
|
return enablePolling ? pollEvent() : subscribeEvent();
|
|
190
208
|
}
|
|
209
|
+
function isRangeError(error) {
|
|
210
|
+
if (!(error instanceof base_js_1.BaseError))
|
|
211
|
+
return true;
|
|
212
|
+
const cause = error.walk((err) => err instanceof request_js_1.HttpRequestError || err instanceof request_js_1.RpcRequestError);
|
|
213
|
+
if (!cause)
|
|
214
|
+
return true;
|
|
215
|
+
if (cause instanceof request_js_1.RpcRequestError && cause.code === 429)
|
|
216
|
+
return false;
|
|
217
|
+
if (cause instanceof request_js_1.HttpRequestError && cause.status === undefined)
|
|
218
|
+
return false;
|
|
219
|
+
return cause.status !== 401 && cause.status !== 403 && cause.status !== 429;
|
|
220
|
+
}
|
|
191
221
|
//# sourceMappingURL=watchEvent.js.map
|