diff --git a/.changeset/old-pandas-bathe.md b/.changeset/old-pandas-bathe.md new file mode 100644 index 0000000000..27fa436022 --- /dev/null +++ b/.changeset/old-pandas-bathe.md @@ -0,0 +1,5 @@ +--- +"viem": patch +--- + +**OP Stack:** Handled case for `InvalidGameType` error on `getWithdrawalStatus` diff --git a/src/op-stack/abis.ts b/src/op-stack/abis.ts index 6d887bdcf8..9d4dc02f2c 100644 --- a/src/op-stack/abis.ts +++ b/src/op-stack/abis.ts @@ -913,101 +913,119 @@ export const portal2Abi = [ stateMutability: 'nonpayable', type: 'constructor', }, - { inputs: [], name: 'BadTarget', type: 'error' }, - { inputs: [], name: 'CallPaused', type: 'error' }, - { inputs: [], name: 'GasEstimation', type: 'error' }, - { inputs: [], name: 'LargeCalldata', type: 'error' }, - { inputs: [], name: 'OutOfGas', type: 'error' }, - { inputs: [], name: 'SmallGasLimit', type: 'error' }, - { inputs: [], name: 'Unauthorized', type: 'error' }, { - anonymous: false, - inputs: [ - { indexed: false, internalType: 'uint8', name: 'version', type: 'uint8' }, - ], - name: 'Initialized', - type: 'event', + stateMutability: 'payable', + type: 'receive', }, { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'address', name: 'from', type: 'address' }, - { indexed: true, internalType: 'address', name: 'to', type: 'address' }, + inputs: [], + name: 'balance', + outputs: [ { - indexed: true, internalType: 'uint256', - name: 'version', + name: '', type: 'uint256', }, - { - indexed: false, - internalType: 'bytes', - name: 'opaqueData', - type: 'bytes', - }, ], - name: 'TransactionDeposited', - type: 'event', + stateMutability: 'view', + type: 'function', }, { - anonymous: false, inputs: [ { - indexed: true, - internalType: 'bytes32', - name: 'withdrawalHash', - type: 'bytes32', + internalType: 'contract IDisputeGame', + name: '_disputeGame', + type: 'address', }, - { indexed: false, internalType: 'bool', name: 'success', type: 'bool' }, ], - name: 'WithdrawalFinalized', - type: 'event', + name: 'blacklistDisputeGame', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', }, { - anonymous: false, inputs: [ { - indexed: true, internalType: 'bytes32', - name: 'withdrawalHash', + name: '_withdrawalHash', type: 'bytes32', }, - { indexed: true, internalType: 'address', name: 'from', type: 'address' }, - { indexed: true, internalType: 'address', name: 'to', type: 'address' }, - ], - name: 'WithdrawalProven', - type: 'event', - }, - { - inputs: [ { - internalType: 'contract IDisputeGame', - name: '_disputeGame', + internalType: 'address', + name: '_proofSubmitter', type: 'address', }, ], - name: 'blacklistDisputeGame', + name: 'checkWithdrawal', outputs: [], - stateMutability: 'nonpayable', + stateMutability: 'view', type: 'function', }, { inputs: [ - { internalType: 'bytes32', name: '_withdrawalHash', type: 'bytes32' }, - { internalType: 'address', name: '_proofSubmitter', type: 'address' }, + { + internalType: 'address', + name: '_to', + type: 'address', + }, + { + internalType: 'uint256', + name: '_mint', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_value', + type: 'uint256', + }, + { + internalType: 'uint64', + name: '_gasLimit', + type: 'uint64', + }, + { + internalType: 'bool', + name: '_isCreation', + type: 'bool', + }, + { + internalType: 'bytes', + name: '_data', + type: 'bytes', + }, ], - name: 'checkWithdrawal', + name: 'depositERC20Transaction', outputs: [], - stateMutability: 'view', + stateMutability: 'nonpayable', type: 'function', }, { inputs: [ - { internalType: 'address', name: '_to', type: 'address' }, - { internalType: 'uint256', name: '_value', type: 'uint256' }, - { internalType: 'uint64', name: '_gasLimit', type: 'uint64' }, - { internalType: 'bool', name: '_isCreation', type: 'bool' }, - { internalType: 'bytes', name: '_data', type: 'bytes' }, + { + internalType: 'address', + name: '_to', + type: 'address', + }, + { + internalType: 'uint256', + name: '_value', + type: 'uint256', + }, + { + internalType: 'uint64', + name: '_gasLimit', + type: 'uint64', + }, + { + internalType: 'bool', + name: '_isCreation', + type: 'bool', + }, + { + internalType: 'bytes', + name: '_data', + type: 'bytes', + }, ], name: 'depositTransaction', outputs: [], @@ -1016,10 +1034,20 @@ export const portal2Abi = [ }, { inputs: [ - { internalType: 'contract IDisputeGame', name: '', type: 'address' }, + { + internalType: 'contract IDisputeGame', + name: '', + type: 'address', + }, ], name: 'disputeGameBlacklist', - outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], stateMutability: 'view', type: 'function', }, @@ -1039,7 +1067,13 @@ export const portal2Abi = [ { inputs: [], name: 'disputeGameFinalityDelaySeconds', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], stateMutability: 'view', type: 'function', }, @@ -1054,12 +1088,36 @@ export const portal2Abi = [ inputs: [ { components: [ - { internalType: 'uint256', name: 'nonce', type: 'uint256' }, - { internalType: 'address', name: 'sender', type: 'address' }, - { internalType: 'address', name: 'target', type: 'address' }, - { internalType: 'uint256', name: 'value', type: 'uint256' }, - { internalType: 'uint256', name: 'gasLimit', type: 'uint256' }, - { internalType: 'bytes', name: 'data', type: 'bytes' }, + { + internalType: 'uint256', + name: 'nonce', + type: 'uint256', + }, + { + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + internalType: 'address', + name: 'target', + type: 'address', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'gasLimit', + type: 'uint256', + }, + { + internalType: 'bytes', + name: 'data', + type: 'bytes', + }, ], internalType: 'struct Types.WithdrawalTransaction', name: '_tx', @@ -1075,18 +1133,46 @@ export const portal2Abi = [ inputs: [ { components: [ - { internalType: 'uint256', name: 'nonce', type: 'uint256' }, - { internalType: 'address', name: 'sender', type: 'address' }, - { internalType: 'address', name: 'target', type: 'address' }, - { internalType: 'uint256', name: 'value', type: 'uint256' }, - { internalType: 'uint256', name: 'gasLimit', type: 'uint256' }, - { internalType: 'bytes', name: 'data', type: 'bytes' }, + { + internalType: 'uint256', + name: 'nonce', + type: 'uint256', + }, + { + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + internalType: 'address', + name: 'target', + type: 'address', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'gasLimit', + type: 'uint256', + }, + { + internalType: 'bytes', + name: 'data', + type: 'bytes', + }, ], internalType: 'struct Types.WithdrawalTransaction', name: '_tx', type: 'tuple', }, - { internalType: 'address', name: '_proofSubmitter', type: 'address' }, + { + internalType: 'address', + name: '_proofSubmitter', + type: 'address', + }, ], name: 'finalizeWithdrawalTransactionExternalProof', outputs: [], @@ -1094,16 +1180,34 @@ export const portal2Abi = [ type: 'function', }, { - inputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + inputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], name: 'finalizedWithdrawals', - outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], stateMutability: 'view', type: 'function', }, { inputs: [], name: 'guardian', - outputs: [{ internalType: 'address', name: '', type: 'address' }], + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], stateMutability: 'view', type: 'function', }, @@ -1138,23 +1242,51 @@ export const portal2Abi = [ { inputs: [], name: 'l2Sender', - outputs: [{ internalType: 'address', name: '', type: 'address' }], + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], stateMutability: 'view', type: 'function', }, { - inputs: [{ internalType: 'uint64', name: '_byteCount', type: 'uint64' }], + inputs: [ + { + internalType: 'uint64', + name: '_byteCount', + type: 'uint64', + }, + ], name: 'minimumGasLimit', - outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }], + outputs: [ + { + internalType: 'uint64', + name: '', + type: 'uint64', + }, + ], stateMutability: 'pure', type: 'function', }, { inputs: [ - { internalType: 'bytes32', name: '_withdrawalHash', type: 'bytes32' }, + { + internalType: 'bytes32', + name: '_withdrawalHash', + type: 'bytes32', + }, ], name: 'numProofSubmitters', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], stateMutability: 'view', type: 'function', }, @@ -1162,9 +1294,21 @@ export const portal2Abi = [ inputs: [], name: 'params', outputs: [ - { internalType: 'uint128', name: 'prevBaseFee', type: 'uint128' }, - { internalType: 'uint64', name: 'prevBoughtGas', type: 'uint64' }, - { internalType: 'uint64', name: 'prevBlockNum', type: 'uint64' }, + { + internalType: 'uint128', + name: 'prevBaseFee', + type: 'uint128', + }, + { + internalType: 'uint64', + name: 'prevBoughtGas', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'prevBlockNum', + type: 'uint64', + }, ], stateMutability: 'view', type: 'function', @@ -1172,24 +1316,50 @@ export const portal2Abi = [ { inputs: [], name: 'paused', - outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], stateMutability: 'view', type: 'function', }, { inputs: [], name: 'proofMaturityDelaySeconds', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], stateMutability: 'view', type: 'function', }, { inputs: [ - { internalType: 'bytes32', name: '', type: 'bytes32' }, - { internalType: 'uint256', name: '', type: 'uint256' }, + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, ], name: 'proofSubmitters', - outputs: [{ internalType: 'address', name: '', type: 'address' }], + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], stateMutability: 'view', type: 'function', }, @@ -1197,34 +1367,78 @@ export const portal2Abi = [ inputs: [ { components: [ - { internalType: 'uint256', name: 'nonce', type: 'uint256' }, - { internalType: 'address', name: 'sender', type: 'address' }, - { internalType: 'address', name: 'target', type: 'address' }, - { internalType: 'uint256', name: 'value', type: 'uint256' }, - { internalType: 'uint256', name: 'gasLimit', type: 'uint256' }, - { internalType: 'bytes', name: 'data', type: 'bytes' }, - ], - internalType: 'struct Types.WithdrawalTransaction', - name: '_tx', - type: 'tuple', + { + internalType: 'uint256', + name: 'nonce', + type: 'uint256', + }, + { + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + internalType: 'address', + name: 'target', + type: 'address', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'gasLimit', + type: 'uint256', + }, + { + internalType: 'bytes', + name: 'data', + type: 'bytes', + }, + ], + internalType: 'struct Types.WithdrawalTransaction', + name: '_tx', + type: 'tuple', + }, + { + internalType: 'uint256', + name: '_disputeGameIndex', + type: 'uint256', }, - { internalType: 'uint256', name: '_disputeGameIndex', type: 'uint256' }, { components: [ - { internalType: 'bytes32', name: 'version', type: 'bytes32' }, - { internalType: 'bytes32', name: 'stateRoot', type: 'bytes32' }, + { + internalType: 'bytes32', + name: 'version', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'stateRoot', + type: 'bytes32', + }, { internalType: 'bytes32', name: 'messagePasserStorageRoot', type: 'bytes32', }, - { internalType: 'bytes32', name: 'latestBlockhash', type: 'bytes32' }, + { + internalType: 'bytes32', + name: 'latestBlockhash', + type: 'bytes32', + }, ], internalType: 'struct Types.OutputRootProof', name: '_outputRootProof', type: 'tuple', }, - { internalType: 'bytes[]', name: '_withdrawalProof', type: 'bytes[]' }, + { + internalType: 'bytes[]', + name: '_withdrawalProof', + type: 'bytes[]', + }, ], name: 'proveWithdrawalTransaction', outputs: [], @@ -1233,8 +1447,16 @@ export const portal2Abi = [ }, { inputs: [ - { internalType: 'bytes32', name: '', type: 'bytes32' }, - { internalType: 'address', name: '', type: 'address' }, + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + { + internalType: 'address', + name: '', + type: 'address', + }, ], name: 'provenWithdrawals', outputs: [ @@ -1243,7 +1465,11 @@ export const portal2Abi = [ name: 'disputeGameProxy', type: 'address', }, - { internalType: 'uint64', name: 'timestamp', type: 'uint64' }, + { + internalType: 'uint64', + name: 'timestamp', + type: 'uint64', + }, ], stateMutability: 'view', type: 'function', @@ -1251,19 +1477,65 @@ export const portal2Abi = [ { inputs: [], name: 'respectedGameType', - outputs: [{ internalType: 'GameType', name: '', type: 'uint32' }], + outputs: [ + { + internalType: 'GameType', + name: '', + type: 'uint32', + }, + ], stateMutability: 'view', type: 'function', }, { inputs: [], name: 'respectedGameTypeUpdatedAt', - outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }], + outputs: [ + { + internalType: 'uint64', + name: '', + type: 'uint64', + }, + ], stateMutability: 'view', type: 'function', }, { - inputs: [{ internalType: 'GameType', name: '_gameType', type: 'uint32' }], + inputs: [ + { + internalType: 'address', + name: '_token', + type: 'address', + }, + { + internalType: 'uint8', + name: '_decimals', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: '_name', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: '_symbol', + type: 'bytes32', + }, + ], + name: 'setGasPayingToken', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'GameType', + name: '_gameType', + type: 'uint32', + }, + ], name: 'setRespectedGameType', outputs: [], stateMutability: 'nonpayable', @@ -1273,7 +1545,11 @@ export const portal2Abi = [ inputs: [], name: 'superchainConfig', outputs: [ - { internalType: 'contract SuperchainConfig', name: '', type: 'address' }, + { + internalType: 'contract SuperchainConfig', + name: '', + type: 'address', + }, ], stateMutability: 'view', type: 'function', @@ -1282,7 +1558,11 @@ export const portal2Abi = [ inputs: [], name: 'systemConfig', outputs: [ - { internalType: 'contract SystemConfig', name: '', type: 'address' }, + { + internalType: 'contract SystemConfig', + name: '', + type: 'address', + }, ], stateMutability: 'view', type: 'function', @@ -1290,11 +1570,280 @@ export const portal2Abi = [ { inputs: [], name: 'version', - outputs: [{ internalType: 'string', name: '', type: 'string' }], - stateMutability: 'view', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'pure', type: 'function', }, - { stateMutability: 'payable', type: 'receive' }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'contract IDisputeGame', + name: 'disputeGame', + type: 'address', + }, + ], + name: 'DisputeGameBlacklisted', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint8', + name: 'version', + type: 'uint8', + }, + ], + name: 'Initialized', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'GameType', + name: 'newGameType', + type: 'uint32', + }, + { + indexed: true, + internalType: 'Timestamp', + name: 'updatedAt', + type: 'uint64', + }, + ], + name: 'RespectedGameTypeSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: true, + internalType: 'uint256', + name: 'version', + type: 'uint256', + }, + { + indexed: false, + internalType: 'bytes', + name: 'opaqueData', + type: 'bytes', + }, + ], + name: 'TransactionDeposited', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'withdrawalHash', + type: 'bytes32', + }, + { + indexed: false, + internalType: 'bool', + name: 'success', + type: 'bool', + }, + ], + name: 'WithdrawalFinalized', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'withdrawalHash', + type: 'bytes32', + }, + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + ], + name: 'WithdrawalProven', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'withdrawalHash', + type: 'bytes32', + }, + { + indexed: true, + internalType: 'address', + name: 'proofSubmitter', + type: 'address', + }, + ], + name: 'WithdrawalProvenExtension1', + type: 'event', + }, + { + inputs: [], + name: 'AlreadyFinalized', + type: 'error', + }, + { + inputs: [], + name: 'BadTarget', + type: 'error', + }, + { + inputs: [], + name: 'Blacklisted', + type: 'error', + }, + { + inputs: [], + name: 'CallPaused', + type: 'error', + }, + { + inputs: [], + name: 'ContentLengthMismatch', + type: 'error', + }, + { + inputs: [], + name: 'EmptyItem', + type: 'error', + }, + { + inputs: [], + name: 'GasEstimation', + type: 'error', + }, + { + inputs: [], + name: 'InvalidDataRemainder', + type: 'error', + }, + { + inputs: [], + name: 'InvalidDisputeGame', + type: 'error', + }, + { + inputs: [], + name: 'InvalidGameType', + type: 'error', + }, + { + inputs: [], + name: 'InvalidHeader', + type: 'error', + }, + { + inputs: [], + name: 'InvalidMerkleProof', + type: 'error', + }, + { + inputs: [], + name: 'InvalidProof', + type: 'error', + }, + { + inputs: [], + name: 'LargeCalldata', + type: 'error', + }, + { + inputs: [], + name: 'NoValue', + type: 'error', + }, + { + inputs: [], + name: 'NonReentrant', + type: 'error', + }, + { + inputs: [], + name: 'OnlyCustomGasToken', + type: 'error', + }, + { + inputs: [], + name: 'OutOfGas', + type: 'error', + }, + { + inputs: [], + name: 'ProposalNotValidated', + type: 'error', + }, + { + inputs: [], + name: 'SmallGasLimit', + type: 'error', + }, + { + inputs: [], + name: 'TransferFailed', + type: 'error', + }, + { + inputs: [], + name: 'Unauthorized', + type: 'error', + }, + { + inputs: [], + name: 'UnexpectedList', + type: 'error', + }, + { + inputs: [], + name: 'UnexpectedString', + type: 'error', + }, + { + inputs: [], + name: 'Unproven', + type: 'error', + }, ] as const export const portalAbi = [ diff --git a/src/op-stack/actions/getWithdrawalStatus.ts b/src/op-stack/actions/getWithdrawalStatus.ts index 5f2d62e6de..04b4746f22 100644 --- a/src/op-stack/actions/getWithdrawalStatus.ts +++ b/src/op-stack/actions/getWithdrawalStatus.ts @@ -238,6 +238,7 @@ export async function getWithdrawalStatus< if (error.cause instanceof ContractFunctionRevertedError) { const errorMessage = error.cause.data?.args?.[0] if ( + errorMessage === 'OptimismPortal: invalid game type' || errorMessage === 'OptimismPortal: withdrawal has not been proven yet' || errorMessage === 'OptimismPortal: withdrawal has not been proven by proof submitter address yet' @@ -251,6 +252,9 @@ export async function getWithdrawalStatus< errorMessage === 'OptimismPortal: output proposal in air-gap' ) return 'waiting-to-finalize' + + if (error.cause.data?.errorName === 'InvalidGameType') + return 'ready-to-prove' } throw checkWithdrawalResult.reason }