diff --git a/package.json b/package.json index f3cf78bca9d2..820e9311d9b9 100644 --- a/package.json +++ b/package.json @@ -70,12 +70,13 @@ "lint-staged": "15.2.0", "mocha": "^10.2.0", "nx": "18.1.2", + "nx-cloud": "latest", "nyc": "^15.1.0", "prettier": "^2.8.0", "rimraf": "^5.0.5", "ts-mocha": "^10.0.0", "typescript": "^5.3.3", - "nx-cloud": "latest" + "wait-on": "^7.2.0" }, "dependencies": { "@changesets/cli": "^2.27.1" diff --git a/packages/sdk/src/cross-chain-messenger.ts b/packages/sdk/src/cross-chain-messenger.ts index 3756ec08ede3..3b4d0ae786e3 100644 --- a/packages/sdk/src/cross-chain-messenger.ts +++ b/packages/sdk/src/cross-chain-messenger.ts @@ -1249,13 +1249,13 @@ export class CrossChainMessenger { const challengePeriod = oracleVersion === '1.0.0' ? // The ABI in the SDK does not contain FINALIZATION_PERIOD_SECONDS - // in OptimismPortal, so making an explicit call instead. - BigNumber.from( - await this.contracts.l1.OptimismPortal.provider.call({ - to: this.contracts.l1.OptimismPortal.address, - data: '0xf4daa291', // FINALIZATION_PERIOD_SECONDS - }) - ) + // in OptimismPortal, so making an explicit call instead. + BigNumber.from( + await this.contracts.l1.OptimismPortal.provider.call({ + to: this.contracts.l1.OptimismPortal.address, + data: '0xf4daa291', // FINALIZATION_PERIOD_SECONDS + }) + ) : await this.contracts.l1.L2OutputOracle.FINALIZATION_PERIOD_SECONDS() return challengePeriod.toNumber() } @@ -1496,7 +1496,7 @@ export class CrossChainMessenger { // latest games are all invalid and the SDK would be forced to make a bunch of archive calls. for (let i = matches.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)) - ;[matches[i], matches[j]] = [matches[j], matches[i]] + ;[matches[i], matches[j]] = [matches[j], matches[i]] } // Now we verify the proposals in the matches array. @@ -2328,18 +2328,18 @@ export class CrossChainMessenger { messageHashV1 ) - // if failed we need to replay the message rather than finalizing it if (isFailed === true) { - const tx = await this.contracts.l1.L1CrossDomainMessenger.populateTransaction.relayMessage( - xdmWithdrawal._nonce, - xdmWithdrawal._sender, - xdmWithdrawal._target, - xdmWithdrawal._value, - xdmWithdrawal._minGasLimit, - xdmWithdrawal._message, - opts?.overrides || {} - ) + const tx = + await this.contracts.l1.L1CrossDomainMessenger.populateTransaction.relayMessage( + xdmWithdrawal._nonce, + xdmWithdrawal._sender, + xdmWithdrawal._target, + xdmWithdrawal._value, + xdmWithdrawal._minGasLimit, + xdmWithdrawal._message, + opts?.overrides || {} + ) return tx } if ('todo remove me') { diff --git a/packages/sdk/test-next/failedMessages.spec.ts b/packages/sdk/test-next/failedMessages.spec.ts index 0c4385e13661..ac2ea9554a68 100644 --- a/packages/sdk/test-next/failedMessages.spec.ts +++ b/packages/sdk/test-next/failedMessages.spec.ts @@ -3,11 +3,11 @@ import { Address, Hex, encodePacked, keccak256, toHex } from 'viem' import { ethers } from 'ethers' import { z } from 'zod' import { hashCrossDomainMessagev1 } from '@eth-optimism/core-utils' +import { optimismSepolia } from 'viem/chains' import { CONTRACT_ADDRESSES, CrossChainMessenger } from '../src' import { sepoliaPublicClient, sepoliaTestClient } from './testUtils/viemClients' import { sepoliaProvider, opSepoliaProvider } from './testUtils/ethersProviders' -import { optimismSepolia } from 'viem/chains' /** * Generated on Mar 28 2024 using @@ -22,8 +22,9 @@ const failedMessagesStorageLayout = { type: 't_mapping(t_bytes32,t_bool)', } -const sepoliaCrossDomainMessengerAddress = - CONTRACT_ADDRESSES[optimismSepolia.id].l1.L1CrossDomainMessenger as Address +const sepoliaCrossDomainMessengerAddress = CONTRACT_ADDRESSES[ + optimismSepolia.id +].l1.L1CrossDomainMessenger as Address const setMessageAsFailed = async (tx: Hex) => { const message = await crossChainMessenger.toCrossChainMessage(tx) @@ -36,11 +37,12 @@ const setMessageAsFailed = async (tx: Hex) => { message.message ) as Hex - const keySlotHash = keccak256(encodePacked( - ['bytes32', 'uint256'], - [messageHash, failedMessagesStorageLayout.slot] - - )) + const keySlotHash = keccak256( + encodePacked( + ['bytes32', 'uint256'], + [messageHash, failedMessagesStorageLayout.slot] + ) + ) return sepoliaTestClient.setStorageAt({ address: sepoliaCrossDomainMessengerAddress, index: keySlotHash, @@ -75,7 +77,8 @@ describe('replaying failed messages', () => { // debugging ethers.js is brutal because of error message so let's instead // send the tx with viem. If it succeeds we will then test with ethers - const txData = await crossChainMessenger.populateTransaction.finalizeMessage(tx) + const txData = + await crossChainMessenger.populateTransaction.finalizeMessage(tx) await sepoliaPublicClient.call({ data: txData.data as Hex, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 147dc061bcd7..a8256020ff2d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -108,6 +108,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + wait-on: + specifier: ^7.2.0 + version: 7.2.0 endpoint-monitor: {} @@ -15323,6 +15326,12 @@ packages: resolution: {integrity: sha512-4VlvkRUuCJvr2J6Y0ImW7NvTCriMi7ErOAqWk1y69vAdoNIzCF3yPmgeNzx+RQTLEDFq5sHfscn1MwHxP9hNfA==} dev: true + /rxjs@7.8.1: + resolution: {integrity: sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==} + dependencies: + tslib: 2.6.2 + dev: true + /safe-array-concat@1.0.0: resolution: {integrity: sha512-9dVEFruWIsnie89yym+xWTAYASdpw3CJV7Li/6zBewGf9z2i1j31rP6jnY0pHEO4QZh6N0K11bFjWmdR8UGdPQ==} engines: {node: '>=0.4'} @@ -17338,6 +17347,20 @@ packages: - zod dev: true + /wait-on@7.2.0: + resolution: {integrity: sha512-wCQcHkRazgjG5XoAq9jbTMLpNIjoSlZslrJ2+N9MxDsGEv1HnFoVjOCexL0ESva7Y9cu350j+DWADdk54s4AFQ==} + engines: {node: '>=12.0.0'} + hasBin: true + dependencies: + axios: 1.6.7 + joi: 17.11.0 + lodash: 4.17.21 + minimist: 1.2.8 + rxjs: 7.8.1 + transitivePeerDependencies: + - debug + dev: true + /walker@1.0.8: resolution: {integrity: sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==} dependencies: