viem 2.57.11 → 2.57.12
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 +44 -0
- package/_cjs/actions/public/waitForTransactionReceipt.js +83 -23
- package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_cjs/actions/public/watchEvent.js +1 -0
- 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/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 +6 -2
- 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 +2 -5
- 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/accounts/Config.js +1 -4
- 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/internal/relay/accounts.js +1 -3
- package/_cjs/tempo/internal/relay/accounts.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/waitForTransactionReceipt.js +101 -23
- package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_esm/actions/public/watchEvent.js +1 -0
- 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/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 +4 -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 +2 -5
- 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/accounts/Config.js +1 -4
- 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/internal/relay/accounts.js +1 -3
- package/_esm/tempo/internal/relay/accounts.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/public/waitForTransactionReceipt.d.ts +31 -1
- package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
- package/_types/actions/public/watchEvent.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 +4 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/clients/decorators/public.d.ts +3 -0
- 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 +0 -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/accounts/Config.d.ts.map +1 -1
- package/_types/tempo/actions/accounts.d.ts +2 -2
- package/_types/tempo/internal/relay/accounts.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/public/waitForTransactionReceipt.ts +164 -33
- package/actions/public/watchEvent.ts +1 -0
- package/actions/wallet/sendCalls.ts +1 -1
- package/chains/definitions/valuechain.ts +20 -0
- package/chains/definitions/valuechainTestnet.ts +21 -0
- package/chains/index.ts +4 -0
- package/clients/decorators/public.ts +3 -0
- 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 +2 -14
- package/tempo/Addresses.ts +0 -3
- package/tempo/accounts/Config.ts +1 -9
- package/tempo/actions/accounts.ts +2 -2
- package/tempo/internal/relay/accounts.ts +1 -3
- 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
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
|
2
|
+
|
|
3
|
+
/** ValueChain testnet. */
|
|
4
|
+
export const valuechainTestnet = /*#__PURE__*/ defineChain({
|
|
5
|
+
id: 138_565,
|
|
6
|
+
name: 'ValueChain Testnet',
|
|
7
|
+
blockTime: 2_000,
|
|
8
|
+
nativeCurrency: { name: 'SOSO', symbol: 'SOSO', decimals: 18 },
|
|
9
|
+
rpcUrls: {
|
|
10
|
+
default: {
|
|
11
|
+
http: ['https://testnet.valuechain.xyz'],
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
blockExplorers: {
|
|
15
|
+
default: {
|
|
16
|
+
name: 'ValueChain Testnet Explorer',
|
|
17
|
+
url: 'https://test-scan.valuechain.xyz',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
testnet: true,
|
|
21
|
+
})
|
package/chains/index.ts
CHANGED
|
@@ -699,6 +699,10 @@ export { unique } from './definitions/unique.js'
|
|
|
699
699
|
export { uniqueOpal } from './definitions/uniqueOpal.js'
|
|
700
700
|
export { uniqueQuartz } from './definitions/uniqueQuartz.js'
|
|
701
701
|
export { unreal } from './definitions/unreal.js'
|
|
702
|
+
/** ValueChain mainnet. */
|
|
703
|
+
export { valuechain } from './definitions/valuechain.js'
|
|
704
|
+
/** ValueChain testnet. */
|
|
705
|
+
export { valuechainTestnet } from './definitions/valuechainTestnet.js'
|
|
702
706
|
export { valygoNft } from './definitions/valygoNft.js'
|
|
703
707
|
export { valygoSmartchain } from './definitions/valygoSmartchain.js'
|
|
704
708
|
export { vana } from './definitions/vana.js'
|
|
@@ -1954,6 +1954,9 @@ export type PublicActions<
|
|
|
1954
1954
|
* - Calls [`eth_getBlockByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbynumber) and extracts the transactions
|
|
1955
1955
|
* - Checks if one of the Transactions is a replacement
|
|
1956
1956
|
* - If so, calls [`eth_getTransactionReceipt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionReceipt).
|
|
1957
|
+
* - If the Transaction is not found and `replacement` is provided:
|
|
1958
|
+
* - Calls `eth_getTransactionBySenderAndNonce` to find the Transaction in its nonce slot
|
|
1959
|
+
* - If it is a replacement, calls [`eth_getTransactionReceipt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionReceipt).
|
|
1957
1960
|
*
|
|
1958
1961
|
* @remarks
|
|
1959
1962
|
* The `waitForTransactionReceipt` action additionally supports Replacement detection (e.g. sped up Transactions).
|
|
@@ -170,7 +170,12 @@ export function http<
|
|
|
170
170
|
}),
|
|
171
171
|
]
|
|
172
172
|
|
|
173
|
-
const [{ error, result }] = await fn(body)
|
|
173
|
+
const [{ error, result }] = await fn(body).catch((err) => {
|
|
174
|
+
// Raw transports also return JSON-RPC errors from non-2xx responses.
|
|
175
|
+
if (raw && err instanceof RpcRequestError)
|
|
176
|
+
return [{ error: err.cause, result: undefined }]
|
|
177
|
+
throw err
|
|
178
|
+
})
|
|
174
179
|
|
|
175
180
|
if (raw) return { error, result }
|
|
176
181
|
if (error)
|
package/errors/node.ts
CHANGED
|
@@ -151,7 +151,7 @@ export type InsufficientFundsErrorType = InsufficientFundsError & {
|
|
|
151
151
|
}
|
|
152
152
|
export class InsufficientFundsError extends BaseError {
|
|
153
153
|
static nodeMessage =
|
|
154
|
-
/insufficient funds|exceeds transaction sender account balance/
|
|
154
|
+
/insufficient funds|exceeds transaction sender account balance|outoffunds/
|
|
155
155
|
constructor({ cause }: { cause?: BaseError | undefined } = {}) {
|
|
156
156
|
super(
|
|
157
157
|
[
|
package/errors/request.ts
CHANGED
|
@@ -96,24 +96,38 @@ export type RpcRequestErrorType = RpcRequestError & {
|
|
|
96
96
|
export class RpcRequestError extends BaseError {
|
|
97
97
|
code: number
|
|
98
98
|
data?: unknown
|
|
99
|
+
/** Response headers, when the error came from a non-2xx HTTP response. */
|
|
100
|
+
headers?: Headers | undefined
|
|
101
|
+
/** Response status, when the error came from a non-2xx HTTP response. */
|
|
102
|
+
status?: number | undefined
|
|
99
103
|
url: string
|
|
100
104
|
constructor({
|
|
101
105
|
body,
|
|
102
106
|
error,
|
|
107
|
+
headers,
|
|
108
|
+
status,
|
|
103
109
|
url,
|
|
104
110
|
}: {
|
|
105
111
|
body: { [x: string]: unknown } | { [y: string]: unknown }[]
|
|
106
112
|
error: { code: number; data?: unknown; message: string }
|
|
113
|
+
headers?: Headers | undefined
|
|
114
|
+
status?: number | undefined
|
|
107
115
|
url: string
|
|
108
116
|
}) {
|
|
109
117
|
super('RPC Request failed.', {
|
|
110
118
|
cause: error as any,
|
|
111
119
|
details: error.message,
|
|
112
|
-
metaMessages: [
|
|
120
|
+
metaMessages: [
|
|
121
|
+
status && `Status: ${status}`,
|
|
122
|
+
`URL: ${getUrl(url)}`,
|
|
123
|
+
`Request body: ${stringify(body)}`,
|
|
124
|
+
].filter(Boolean) as string[],
|
|
113
125
|
name: 'RpcRequestError',
|
|
114
126
|
})
|
|
115
127
|
this.code = error.code
|
|
116
128
|
this.data = error.data
|
|
129
|
+
this.headers = headers
|
|
130
|
+
this.status = status
|
|
117
131
|
this.url = url
|
|
118
132
|
}
|
|
119
133
|
}
|
package/errors/typedData.ts
CHANGED
|
@@ -38,7 +38,9 @@ export type InvalidStructTypeErrorType = InvalidStructTypeError & {
|
|
|
38
38
|
export class InvalidStructTypeError extends BaseError {
|
|
39
39
|
constructor({ type }: { type: string }) {
|
|
40
40
|
super(`Struct type "${type}" is invalid.`, {
|
|
41
|
-
metaMessages: [
|
|
41
|
+
metaMessages: [
|
|
42
|
+
'Struct type must contain only letters, digits, "_" and "$", and must not be a Solidity type.',
|
|
43
|
+
],
|
|
42
44
|
name: 'InvalidStructTypeError',
|
|
43
45
|
})
|
|
44
46
|
}
|
package/errors/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.57.
|
|
1
|
+
export const version = '2.57.12'
|
package/op-stack/abis.ts
CHANGED
|
@@ -479,6 +479,58 @@ export const l2ToL1MessagePasserAbi = [
|
|
|
479
479
|
] as const
|
|
480
480
|
|
|
481
481
|
export const disputeGameAbi = [
|
|
482
|
+
{
|
|
483
|
+
type: 'function',
|
|
484
|
+
name: 'createdAt',
|
|
485
|
+
inputs: [],
|
|
486
|
+
outputs: [
|
|
487
|
+
{
|
|
488
|
+
name: '',
|
|
489
|
+
type: 'uint64',
|
|
490
|
+
internalType: 'uint64',
|
|
491
|
+
},
|
|
492
|
+
],
|
|
493
|
+
stateMutability: 'view',
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
type: 'function',
|
|
497
|
+
name: 'expectedResolution',
|
|
498
|
+
inputs: [],
|
|
499
|
+
outputs: [
|
|
500
|
+
{
|
|
501
|
+
name: '',
|
|
502
|
+
type: 'uint64',
|
|
503
|
+
internalType: 'uint64',
|
|
504
|
+
},
|
|
505
|
+
],
|
|
506
|
+
stateMutability: 'view',
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
type: 'function',
|
|
510
|
+
name: 'maxClockDuration',
|
|
511
|
+
inputs: [],
|
|
512
|
+
outputs: [
|
|
513
|
+
{
|
|
514
|
+
name: 'maxClockDuration_',
|
|
515
|
+
type: 'uint64',
|
|
516
|
+
internalType: 'uint64',
|
|
517
|
+
},
|
|
518
|
+
],
|
|
519
|
+
stateMutability: 'view',
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
type: 'function',
|
|
523
|
+
name: 'resolvedAt',
|
|
524
|
+
inputs: [],
|
|
525
|
+
outputs: [
|
|
526
|
+
{
|
|
527
|
+
name: '',
|
|
528
|
+
type: 'uint64',
|
|
529
|
+
internalType: 'uint64',
|
|
530
|
+
},
|
|
531
|
+
],
|
|
532
|
+
stateMutability: 'view',
|
|
533
|
+
},
|
|
482
534
|
{
|
|
483
535
|
type: 'function',
|
|
484
536
|
name: 'l2SequenceNumber',
|
|
@@ -2,10 +2,14 @@ import {
|
|
|
2
2
|
type MulticallErrorType,
|
|
3
3
|
multicall,
|
|
4
4
|
} from '../../actions/public/multicall.js'
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
type ReadContractErrorType,
|
|
7
|
+
readContract,
|
|
8
|
+
} from '../../actions/public/readContract.js'
|
|
6
9
|
import type { Client } from '../../clients/createClient.js'
|
|
7
10
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
|
8
11
|
import { BaseError } from '../../errors/base.js'
|
|
12
|
+
import { ContractFunctionRevertedError } from '../../errors/contract.js'
|
|
9
13
|
import type { ErrorType } from '../../errors/utils.js'
|
|
10
14
|
import type { Account } from '../../types/account.js'
|
|
11
15
|
import type {
|
|
@@ -14,7 +18,12 @@ import type {
|
|
|
14
18
|
GetChainParameter,
|
|
15
19
|
} from '../../types/chain.js'
|
|
16
20
|
import type { Hash } from '../../types/misc.js'
|
|
17
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
disputeGameAbi,
|
|
23
|
+
l2OutputOracleAbi,
|
|
24
|
+
portal2Abi,
|
|
25
|
+
portalAbi,
|
|
26
|
+
} from '../abis.js'
|
|
18
27
|
import type { GetContractAddressParameter } from '../types/contract.js'
|
|
19
28
|
import { getPortalVersion } from './getPortalVersion.js'
|
|
20
29
|
|
|
@@ -27,14 +36,17 @@ export type GetTimeToFinalizeParameters<
|
|
|
27
36
|
withdrawalHash: Hash
|
|
28
37
|
}
|
|
29
38
|
export type GetTimeToFinalizeReturnType = {
|
|
30
|
-
/** The
|
|
39
|
+
/** The proof maturity delay (in seconds). */
|
|
31
40
|
period: number
|
|
32
41
|
/** Seconds until the withdrawal can be finalized. */
|
|
33
42
|
seconds: number
|
|
34
43
|
/** Timestamp of when the withdrawal can be finalized. */
|
|
35
44
|
timestamp: number
|
|
36
45
|
}
|
|
37
|
-
export type GetTimeToFinalizeErrorType =
|
|
46
|
+
export type GetTimeToFinalizeErrorType =
|
|
47
|
+
| MulticallErrorType
|
|
48
|
+
| ReadContractErrorType
|
|
49
|
+
| ErrorType
|
|
38
50
|
|
|
39
51
|
const buffer = 10
|
|
40
52
|
|
|
@@ -142,7 +154,7 @@ export async function getTimeToFinalize<
|
|
|
142
154
|
args: [withdrawalHash, numProofSubmitters - 1n],
|
|
143
155
|
}).catch(() => undefined)
|
|
144
156
|
|
|
145
|
-
const [[
|
|
157
|
+
const [[disputeGameProxy, proveTimestamp], proofMaturityDelaySeconds] =
|
|
146
158
|
await Promise.all([
|
|
147
159
|
proofSubmitter
|
|
148
160
|
? readContract(client, {
|
|
@@ -151,7 +163,7 @@ export async function getTimeToFinalize<
|
|
|
151
163
|
functionName: 'provenWithdrawals',
|
|
152
164
|
args: [withdrawalHash, proofSubmitter],
|
|
153
165
|
})
|
|
154
|
-
: Promise.resolve(['0x', 0n]),
|
|
166
|
+
: Promise.resolve(['0x', 0n] as const),
|
|
155
167
|
readContract(client, {
|
|
156
168
|
abi: portal2Abi,
|
|
157
169
|
address: portalAddress,
|
|
@@ -162,14 +174,81 @@ export async function getTimeToFinalize<
|
|
|
162
174
|
if (proveTimestamp === 0n)
|
|
163
175
|
throw new BaseError('Withdrawal has not been proven on L1.')
|
|
164
176
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
177
|
+
// The withdrawal can only be finalized once the proof's dispute game is
|
|
178
|
+
// resolved and its finality delay has passed, so also read the game.
|
|
179
|
+
const [
|
|
180
|
+
resolvedAt,
|
|
181
|
+
createdAt,
|
|
182
|
+
expectedResolution,
|
|
183
|
+
maxClockDuration,
|
|
184
|
+
disputeGameFinalityDelaySeconds,
|
|
185
|
+
] = await Promise.all([
|
|
186
|
+
readContract(client, {
|
|
187
|
+
abi: disputeGameAbi,
|
|
188
|
+
address: disputeGameProxy,
|
|
189
|
+
functionName: 'resolvedAt',
|
|
190
|
+
}),
|
|
191
|
+
readContract(client, {
|
|
192
|
+
abi: disputeGameAbi,
|
|
193
|
+
address: disputeGameProxy,
|
|
194
|
+
functionName: 'createdAt',
|
|
195
|
+
}),
|
|
196
|
+
// Only some game types implement `expectedResolution` (e.g. `AggregateVerifier`).
|
|
197
|
+
readContract(client, {
|
|
198
|
+
abi: disputeGameAbi,
|
|
199
|
+
address: disputeGameProxy,
|
|
200
|
+
functionName: 'expectedResolution',
|
|
201
|
+
}).catch(unsupported),
|
|
202
|
+
// Only some game types implement `maxClockDuration` (e.g. `FaultDisputeGame`).
|
|
203
|
+
readContract(client, {
|
|
204
|
+
abi: disputeGameAbi,
|
|
205
|
+
address: disputeGameProxy,
|
|
206
|
+
functionName: 'maxClockDuration',
|
|
207
|
+
}).catch(unsupported),
|
|
208
|
+
readContract(client, {
|
|
209
|
+
abi: portal2Abi,
|
|
210
|
+
address: portalAddress,
|
|
211
|
+
functionName: 'disputeGameFinalityDelaySeconds',
|
|
212
|
+
}),
|
|
213
|
+
])
|
|
214
|
+
|
|
215
|
+
const now = Date.now() / 1000
|
|
216
|
+
|
|
217
|
+
// When the game is not resolved yet, estimate when it will be: the expected
|
|
218
|
+
// resolution reported by the game, or the end of an unchallenged root claim's clock.
|
|
219
|
+
// An unresolved game cannot have resolved in the past, so the estimate is at least `now`.
|
|
220
|
+
const gameResolvedAt = (() => {
|
|
221
|
+
if (resolvedAt > 0n) return Number(resolvedAt)
|
|
222
|
+
const estimate = (() => {
|
|
223
|
+
if (typeof expectedResolution === 'bigint') return expectedResolution
|
|
224
|
+
if (typeof maxClockDuration === 'bigint')
|
|
225
|
+
return createdAt + maxClockDuration
|
|
226
|
+
return undefined
|
|
227
|
+
})()
|
|
228
|
+
// Without an estimate, only the proof maturity delay applies.
|
|
229
|
+
if (estimate === undefined) return 0
|
|
230
|
+
return Math.max(Number(estimate), now)
|
|
231
|
+
})()
|
|
232
|
+
|
|
233
|
+
const secondsToProofMaturity =
|
|
234
|
+
Number(proofMaturityDelaySeconds) - (now - Number(proveTimestamp))
|
|
235
|
+
const secondsToGameFinality =
|
|
236
|
+
gameResolvedAt + Number(disputeGameFinalityDelaySeconds) - now
|
|
237
|
+
const secondsToFinalize = Math.max(
|
|
238
|
+
secondsToProofMaturity,
|
|
239
|
+
secondsToGameFinality,
|
|
240
|
+
)
|
|
168
241
|
|
|
169
242
|
const seconds = Math.floor(
|
|
170
|
-
secondsToFinalize <
|
|
243
|
+
secondsToFinalize < 0 ? 0 : secondsToFinalize + buffer,
|
|
171
244
|
)
|
|
172
245
|
const timestamp = Date.now() + seconds * 1000
|
|
173
246
|
|
|
174
247
|
return { period: Number(proofMaturityDelaySeconds), seconds, timestamp }
|
|
175
248
|
}
|
|
249
|
+
|
|
250
|
+
/** Returns `undefined` when the game does not implement the getter, and rethrows other errors. */
|
|
251
|
+
function unsupported(error: ReadContractErrorType) {
|
|
252
|
+
if (error.cause instanceof ContractFunctionRevertedError) return undefined
|
|
253
|
+
throw error
|
|
254
|
+
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ReadContractErrorType,
|
|
3
|
+
readContract,
|
|
4
|
+
} from '../../actions/public/readContract.js'
|
|
1
5
|
import type { Client } from '../../clients/createClient.js'
|
|
2
6
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
|
3
7
|
import type { ErrorType } from '../../errors/utils.js'
|
|
@@ -9,6 +13,13 @@ import type {
|
|
|
9
13
|
} from '../../types/chain.js'
|
|
10
14
|
import type { TransactionReceipt } from '../../types/transaction.js'
|
|
11
15
|
import type { OneOf } from '../../types/utils.js'
|
|
16
|
+
import { portal2Abi } from '../abis.js'
|
|
17
|
+
import {
|
|
18
|
+
L2TimestampRequiredError,
|
|
19
|
+
type L2TimestampRequiredErrorType,
|
|
20
|
+
} from '../errors/withdrawal.js'
|
|
21
|
+
import { isSuperGameType } from '../gameTypes.js'
|
|
22
|
+
import type { TargetChain } from '../types/chain.js'
|
|
12
23
|
import type { GetContractAddressParameter } from '../types/contract.js'
|
|
13
24
|
import {
|
|
14
25
|
type GetPortalVersionErrorType,
|
|
@@ -62,6 +73,8 @@ export type GetTimeToProveErrorType =
|
|
|
62
73
|
| GetPortalVersionErrorType
|
|
63
74
|
| GetTimeToNextGameErrorType
|
|
64
75
|
| GetTimeToNextL2OutputErrorType
|
|
76
|
+
| L2TimestampRequiredErrorType
|
|
77
|
+
| ReadContractErrorType
|
|
65
78
|
| ErrorType
|
|
66
79
|
|
|
67
80
|
/**
|
|
@@ -102,7 +115,14 @@ export async function getTimeToProve<
|
|
|
102
115
|
client: Client<Transport, chain, account>,
|
|
103
116
|
parameters: GetTimeToProveParameters<chain, chainOverride>,
|
|
104
117
|
): Promise<GetTimeToProveReturnType> {
|
|
105
|
-
const {
|
|
118
|
+
const {
|
|
119
|
+
chain = client.chain,
|
|
120
|
+
l2Timestamp,
|
|
121
|
+
receipt,
|
|
122
|
+
targetChain: targetChain_,
|
|
123
|
+
} = parameters
|
|
124
|
+
|
|
125
|
+
const targetChain = targetChain_ as unknown as TargetChain
|
|
106
126
|
|
|
107
127
|
const portalVersion = await getPortalVersion(
|
|
108
128
|
client,
|
|
@@ -116,8 +136,29 @@ export async function getTimeToProve<
|
|
|
116
136
|
l2BlockNumber: l2Timestamp ?? receipt.blockNumber,
|
|
117
137
|
} as GetTimeToNextL2OutputParameters)
|
|
118
138
|
|
|
139
|
+
const portalAddress = (() => {
|
|
140
|
+
if (parameters.portalAddress) return parameters.portalAddress
|
|
141
|
+
if (chain) return targetChain.contracts.portal[chain.id].address
|
|
142
|
+
return Object.values(targetChain.contracts.portal)[0].address
|
|
143
|
+
})()
|
|
144
|
+
|
|
145
|
+
// Super-root games anchor on L2 timestamps instead of L2 block numbers.
|
|
146
|
+
const l2BlockNumber = await (async () => {
|
|
147
|
+
if (typeof l2Timestamp === 'bigint') return l2Timestamp
|
|
148
|
+
const gameType = await readContract(client, {
|
|
149
|
+
abi: portal2Abi,
|
|
150
|
+
address: portalAddress,
|
|
151
|
+
functionName: 'respectedGameType',
|
|
152
|
+
})
|
|
153
|
+
if (!isSuperGameType(gameType)) return receipt.blockNumber
|
|
154
|
+
const timestamp = receipt.logs[0]?.blockTimestamp
|
|
155
|
+
if (typeof timestamp !== 'bigint')
|
|
156
|
+
throw new L2TimestampRequiredError({ gameType })
|
|
157
|
+
return timestamp
|
|
158
|
+
})()
|
|
159
|
+
|
|
119
160
|
return getTimeToNextGame(client, {
|
|
120
161
|
...parameters,
|
|
121
|
-
l2BlockNumber
|
|
162
|
+
l2BlockNumber,
|
|
122
163
|
} as GetTimeToNextGameParameters)
|
|
123
164
|
}
|
|
@@ -18,9 +18,12 @@ import type { TransactionReceipt } from '../../types/transaction.js'
|
|
|
18
18
|
import type { OneOf } from '../../types/utils.js'
|
|
19
19
|
import { anchorStateRegistryAbi, portal2Abi, portalAbi } from '../abis.js'
|
|
20
20
|
import {
|
|
21
|
+
L2TimestampRequiredError,
|
|
22
|
+
type L2TimestampRequiredErrorType,
|
|
21
23
|
ReceiptContainsNoWithdrawalsError,
|
|
22
24
|
type ReceiptContainsNoWithdrawalsErrorType,
|
|
23
25
|
} from '../errors/withdrawal.js'
|
|
26
|
+
import { isSuperGameType } from '../gameTypes.js'
|
|
24
27
|
import type { TargetChain } from '../types/chain.js'
|
|
25
28
|
import type { GetContractAddressParameter } from '../types/contract.js'
|
|
26
29
|
import {
|
|
@@ -106,6 +109,7 @@ export type GetWithdrawalStatusErrorType =
|
|
|
106
109
|
| GetL2OutputErrorType
|
|
107
110
|
| GetTimeToFinalizeErrorType
|
|
108
111
|
| GetWithdrawalsErrorType
|
|
112
|
+
| L2TimestampRequiredErrorType
|
|
109
113
|
| ReadContractErrorType
|
|
110
114
|
| ReceiptContainsNoWithdrawalsErrorType
|
|
111
115
|
| ErrorType
|
|
@@ -152,6 +156,7 @@ export async function getWithdrawalStatus<
|
|
|
152
156
|
chain = client.chain,
|
|
153
157
|
gameLimit = 100,
|
|
154
158
|
receipt,
|
|
159
|
+
l2Timestamp,
|
|
155
160
|
targetChain: targetChain_,
|
|
156
161
|
logIndex = 0,
|
|
157
162
|
} = parameters
|
|
@@ -165,7 +170,7 @@ export async function getWithdrawalStatus<
|
|
|
165
170
|
})()
|
|
166
171
|
|
|
167
172
|
const l2BlockNumber =
|
|
168
|
-
|
|
173
|
+
l2Timestamp ?? receipt?.blockNumber ?? parameters.l2BlockNumber
|
|
169
174
|
|
|
170
175
|
const withdrawal = (() => {
|
|
171
176
|
if (receipt) {
|
|
@@ -254,17 +259,36 @@ export async function getWithdrawalStatus<
|
|
|
254
259
|
args: [withdrawal.withdrawalHash, numProofSubmitters - 1n],
|
|
255
260
|
}).catch(() => withdrawal.sender)
|
|
256
261
|
|
|
262
|
+
// Super-root games anchor on L2 timestamps instead of L2 block numbers.
|
|
263
|
+
// Not awaited, so a missing L2 timestamp only fails the game lookup and a
|
|
264
|
+
// finalized withdrawal still resolves.
|
|
265
|
+
const gameL2BlockNumber = (async () => {
|
|
266
|
+
if (typeof l2Timestamp === 'bigint') return l2Timestamp
|
|
267
|
+
const gameType = await readContract(client, {
|
|
268
|
+
abi: portal2Abi,
|
|
269
|
+
address: portalAddress,
|
|
270
|
+
functionName: 'respectedGameType',
|
|
271
|
+
})
|
|
272
|
+
if (!isSuperGameType(gameType)) return l2BlockNumber
|
|
273
|
+
const timestamp = receipt?.logs[0]?.blockTimestamp
|
|
274
|
+
if (typeof timestamp !== 'bigint')
|
|
275
|
+
throw new L2TimestampRequiredError({ gameType })
|
|
276
|
+
return timestamp
|
|
277
|
+
})()
|
|
278
|
+
|
|
257
279
|
const [
|
|
258
280
|
disputeGameResult,
|
|
259
281
|
provenWithdrawalsResult,
|
|
260
282
|
checkWithdrawalResult,
|
|
261
283
|
finalizedResult,
|
|
262
284
|
] = await Promise.allSettled([
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
285
|
+
gameL2BlockNumber.then((l2BlockNumber) =>
|
|
286
|
+
getGame(client, {
|
|
287
|
+
...parameters,
|
|
288
|
+
l2BlockNumber,
|
|
289
|
+
limit: gameLimit,
|
|
290
|
+
} as GetGameParameters),
|
|
291
|
+
),
|
|
268
292
|
readContract(client, {
|
|
269
293
|
abi: portal2Abi,
|
|
270
294
|
address: portalAddress,
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ReadContractErrorType,
|
|
3
|
+
readContract,
|
|
4
|
+
} from '../../actions/public/readContract.js'
|
|
1
5
|
import type { Client } from '../../clients/createClient.js'
|
|
2
6
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
|
3
7
|
import type { ErrorType } from '../../errors/utils.js'
|
|
@@ -9,7 +13,14 @@ import type {
|
|
|
9
13
|
} from '../../types/chain.js'
|
|
10
14
|
import type { TransactionReceipt } from '../../types/transaction.js'
|
|
11
15
|
import type { OneOf } from '../../types/utils.js'
|
|
12
|
-
import {
|
|
16
|
+
import { portal2Abi } from '../abis.js'
|
|
17
|
+
import {
|
|
18
|
+
L2TimestampRequiredError,
|
|
19
|
+
type L2TimestampRequiredErrorType,
|
|
20
|
+
ReceiptContainsNoWithdrawalsError,
|
|
21
|
+
} from '../errors/withdrawal.js'
|
|
22
|
+
import { isSuperGameType } from '../gameTypes.js'
|
|
23
|
+
import type { TargetChain } from '../types/chain.js'
|
|
13
24
|
import type { GetContractAddressParameter } from '../types/contract.js'
|
|
14
25
|
import type { Withdrawal } from '../types/withdrawal.js'
|
|
15
26
|
import {
|
|
@@ -68,6 +79,8 @@ export type WaitToProveReturnType = {
|
|
|
68
79
|
|
|
69
80
|
export type WaitToProveErrorType =
|
|
70
81
|
| GetWithdrawalsErrorType
|
|
82
|
+
| L2TimestampRequiredErrorType
|
|
83
|
+
| ReadContractErrorType
|
|
71
84
|
| WaitForNextL2OutputErrorType
|
|
72
85
|
| ErrorType
|
|
73
86
|
|
|
@@ -109,7 +122,15 @@ export async function waitToProve<
|
|
|
109
122
|
client: Client<Transport, chain, account>,
|
|
110
123
|
parameters: WaitToProveParameters<chain, chainOverride>,
|
|
111
124
|
): Promise<WaitToProveReturnType> {
|
|
112
|
-
const {
|
|
125
|
+
const {
|
|
126
|
+
chain = client.chain,
|
|
127
|
+
gameLimit,
|
|
128
|
+
l2Timestamp,
|
|
129
|
+
receipt,
|
|
130
|
+
targetChain: targetChain_,
|
|
131
|
+
} = parameters
|
|
132
|
+
|
|
133
|
+
const targetChain = targetChain_ as unknown as TargetChain
|
|
113
134
|
|
|
114
135
|
const [withdrawal] = getWithdrawals(receipt)
|
|
115
136
|
|
|
@@ -144,10 +165,31 @@ export async function waitToProve<
|
|
|
144
165
|
}
|
|
145
166
|
}
|
|
146
167
|
|
|
168
|
+
const portalAddress = (() => {
|
|
169
|
+
if (parameters.portalAddress) return parameters.portalAddress
|
|
170
|
+
if (chain) return targetChain.contracts.portal[chain.id].address
|
|
171
|
+
return Object.values(targetChain.contracts.portal)[0].address
|
|
172
|
+
})()
|
|
173
|
+
|
|
174
|
+
// Super-root games anchor on L2 timestamps instead of L2 block numbers.
|
|
175
|
+
const l2BlockNumber = await (async () => {
|
|
176
|
+
if (typeof l2Timestamp === 'bigint') return l2Timestamp
|
|
177
|
+
const gameType = await readContract(client, {
|
|
178
|
+
abi: portal2Abi,
|
|
179
|
+
address: portalAddress,
|
|
180
|
+
functionName: 'respectedGameType',
|
|
181
|
+
})
|
|
182
|
+
if (!isSuperGameType(gameType)) return receipt.blockNumber
|
|
183
|
+
const timestamp = receipt.logs[0]?.blockTimestamp
|
|
184
|
+
if (typeof timestamp !== 'bigint')
|
|
185
|
+
throw new L2TimestampRequiredError({ gameType })
|
|
186
|
+
return timestamp
|
|
187
|
+
})()
|
|
188
|
+
|
|
147
189
|
const game = await waitForNextGame(client, {
|
|
148
190
|
...parameters,
|
|
149
191
|
limit: gameLimit,
|
|
150
|
-
l2BlockNumber
|
|
192
|
+
l2BlockNumber,
|
|
151
193
|
} as WaitForNextGameParameters)
|
|
152
194
|
return {
|
|
153
195
|
game,
|
|
@@ -22,3 +22,20 @@ export class ReceiptContainsNoWithdrawalsError extends BaseError {
|
|
|
22
22
|
)
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
export type L2TimestampRequiredErrorType = L2TimestampRequiredError & {
|
|
27
|
+
name: 'L2TimestampRequiredError'
|
|
28
|
+
}
|
|
29
|
+
export class L2TimestampRequiredError extends BaseError {
|
|
30
|
+
constructor({ gameType }: { gameType: number }) {
|
|
31
|
+
super(
|
|
32
|
+
`Dispute game type ${gameType} anchors on L2 timestamps, so the L2 timestamp of the withdrawal is required.`,
|
|
33
|
+
{
|
|
34
|
+
metaMessages: [
|
|
35
|
+
'Pass `l2Timestamp`, or a receipt whose logs include `blockTimestamp`.',
|
|
36
|
+
],
|
|
37
|
+
name: 'L2TimestampRequiredError',
|
|
38
|
+
},
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "viem",
|
|
3
3
|
"description": "TypeScript Interface for Ethereum",
|
|
4
|
-
"version": "2.57.
|
|
4
|
+
"version": "2.57.12",
|
|
5
5
|
"main": "./_cjs/index.js",
|
|
6
6
|
"module": "./_esm/index.js",
|
|
7
7
|
"types": "./_types/index.d.ts",
|
|
@@ -229,7 +229,7 @@
|
|
|
229
229
|
"@scure/bip39": "1.6.0",
|
|
230
230
|
"abitype": "1.2.3",
|
|
231
231
|
"isows": "1.0.7",
|
|
232
|
-
"ox": "0.14.
|
|
232
|
+
"ox": "0.14.59",
|
|
233
233
|
"ws": "8.21.0"
|
|
234
234
|
},
|
|
235
235
|
"license": "MIT",
|
package/tempo/Account.ts
CHANGED
|
@@ -24,7 +24,6 @@ import { keccak256 } from '../utils/hash/keccak256.js'
|
|
|
24
24
|
import { hashMessage } from '../utils/signature/hashMessage.js'
|
|
25
25
|
import { hashTypedData } from '../utils/signature/hashTypedData.js'
|
|
26
26
|
import type { SerializeTransactionFn } from '../utils/transaction/serializeTransaction.js'
|
|
27
|
-
import { configurableAccountRecoveryFactory } from './Addresses.js'
|
|
28
27
|
import { parseApproval } from './accounts/Signature.js'
|
|
29
28
|
import type { KeyAuthorizationManager } from './KeyAuthorizationManager.js'
|
|
30
29
|
import * as Transaction from './Transaction.js'
|
|
@@ -331,11 +330,7 @@ export function fromConfig(value: fromConfig.Parameters): ConfigurableAccount {
|
|
|
331
330
|
const configInput = (() => {
|
|
332
331
|
if (typeof value === 'string') return undefined
|
|
333
332
|
if ('upgrade' in value) return value.upgrade
|
|
334
|
-
const {
|
|
335
|
-
address: _,
|
|
336
|
-
factory: __,
|
|
337
|
-
...config
|
|
338
|
-
} = value as fromConfig.InitialConfig
|
|
333
|
+
const { address: _, ...config } = value as fromConfig.InitialConfig
|
|
339
334
|
return config
|
|
340
335
|
})()
|
|
341
336
|
const config = (() => {
|
|
@@ -371,9 +366,7 @@ export function fromConfig(value: fromConfig.Parameters): ConfigurableAccount {
|
|
|
371
366
|
(() => {
|
|
372
367
|
if (typeof value === 'string') return value
|
|
373
368
|
if (value.address === undefined || value.address === 'infer')
|
|
374
|
-
return AccountConfig.getAddress(config
|
|
375
|
-
factory: value.factory ?? configurableAccountRecoveryFactory,
|
|
376
|
-
})
|
|
369
|
+
return AccountConfig.getAddress(config!)
|
|
377
370
|
return value.address
|
|
378
371
|
})(),
|
|
379
372
|
)
|
|
@@ -494,11 +487,6 @@ export declare namespace fromConfig {
|
|
|
494
487
|
export type InitialConfig = {
|
|
495
488
|
/** Derives the stable account address from this initial config. */
|
|
496
489
|
address?: 'infer' | undefined
|
|
497
|
-
/**
|
|
498
|
-
* Recovery factory used to derive the address.
|
|
499
|
-
* @default `Addresses.configurableAccountRecoveryFactory`
|
|
500
|
-
*/
|
|
501
|
-
factory?: Address.Address | undefined
|
|
502
490
|
/** Weighted owners. */
|
|
503
491
|
owners: readonly Owner[]
|
|
504
492
|
/** Caller-chosen 32-byte salt. */
|
package/tempo/Addresses.ts
CHANGED
|
@@ -13,9 +13,6 @@ export const accountKeychain = '0xaAAAaaAA00000000000000000000000000000000'
|
|
|
13
13
|
export const accountRegistrar = '0x7702ac0000000000000000000000000000000000'
|
|
14
14
|
export const addressRegistry = '0xfdc0000000000000000000000000000000000000'
|
|
15
15
|
export const configurableAccount = '0xAACC000000000000000000000000000000000000'
|
|
16
|
-
/** Default configurable account recovery factory. Temporary until the production address is finalized. */
|
|
17
|
-
export const configurableAccountRecoveryFactory =
|
|
18
|
-
'0x7171717171717171717171717171717171717171'
|
|
19
16
|
/** Current consensus committee precompile address, used with `Abis.currentCommittee` to read committee members. */
|
|
20
17
|
export const currentCommittee = '0xC077e00000000000000000000000000000000000'
|
|
21
18
|
export const feeManager = '0xfeec000000000000000000000000000000000000'
|