Add Superchain interop message passing
In Solidity's Custom tab, this PR adds a Cross-Chain Messaging option that adds an example of Superchain interop message passing when enabled. This includes a function that can be called from a different network on the Superchain.
For example, when enabled, this adds the following functions by default:
-
callMyFunctionwhich takes a chain ID argument, and sends a message tomyFunctionat a contract at the same address on the given chain ID -
myFunctionwhich receives messages from other chains. The name of this function is customizable (which affects the name of the above function as well).
Implementation checklist:
- [x] Add UI elements to emphasize that this is only compatible with chains on the Superchain and requires deterministic deployments
- [x] Add unit tests
- [x] Add snapshot tests
- [x] Update AI assistant definitions and MCP schemas
- [x] Test/fix usage with AI assistant
- [x] Add Optimism contracts for compilation tests
- [x] Add Optimism contracts to Download Hardhat and Foundry packages
- [x] Test an example contract locally using supersim, non-upgradeable (see comments below for test steps)
- [x] Test an example contract locally using supersim, upgradeable (see comments below for test steps)
- [x] Add changesets
- [x] Add soldeer.lock
Solid!, just one thing that you are probably aware of; the ai assistant seems to be generating crosschain messaging code very well, however the changes aren't getting correctly reflected on the UI, the contract code appears, but the checkboxes are kept unchecked as if nothing happened, they're not in sync with the code changes made by the ai
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
All alerts resolved. Learn more about Socket for GitHub.
This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.
Ignoring alerts on:
-
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
@humanwhocodes/[email protected] -
@manypkg/[email protected] -
@types/[email protected] -
@manypkg/[email protected] -
@changesets/[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
@types/[email protected] -
[email protected] -
@changesets/[email protected] -
@changesets/[email protected] -
@changesets/[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
@sindresorhus/[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
@isaacs/[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
@changesets/[email protected] -
[email protected] -
@types/[email protected] -
[email protected] -
@humanwhocodes/[email protected] -
[email protected] -
@babel/[email protected] -
@eslint-community/[email protected] -
@eslint-community/[email protected] -
@humanfs/[email protected] -
@humanfs/[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
@mapbox/[email protected] -
@eslint/[email protected] -
@eslint/[email protected] -
[email protected] -
[email protected] -
[email protected] -
@changesets/[email protected] -
@changesets/[email protected] -
@changesets/[email protected] -
@changesets/[email protected] -
@changesets/[email protected] -
@changesets/[email protected] -
@changesets/[email protected] -
@changesets/[email protected] -
@changesets/[email protected] -
[email protected] -
[email protected] -
@humanwhocodes/[email protected] -
[email protected] -
@changesets/[email protected] -
@eslint/[email protected] -
@eslint/[email protected] -
@eslint/[email protected] -
@eslint/[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
@eslint-community/[email protected] -
[email protected] -
[email protected] -
@babel/[email protected] -
@types/[email protected] -
[email protected] -
[email protected] -
[email protected] -
@typescript-eslint/[email protected] -
@typescript-eslint/[email protected] -
@typescript-eslint/[email protected] -
[email protected] -
@typescript-eslint/[email protected] -
@typescript-eslint/[email protected] -
@typescript-eslint/[email protected] -
@typescript-eslint/[email protected] -
@typescript-eslint/[email protected] -
@pkgr/[email protected] -
[email protected] -
@changesets/[email protected] -
@changesets/[email protected] -
@changesets/[email protected] -
@changesets/[email protected] -
@changesets/[email protected] -
[email protected] -
[email protected] -
[email protected] -
@vercel/[email protected] -
[email protected] -
[email protected] -
[email protected] -
@rollup/[email protected] -
[email protected] -
@jridgewell/[email protected] -
[email protected] -
[email protected] -
[email protected] -
[email protected] -
@types/[email protected] -
[email protected]
Also manually tested as follows. Note these are testcases only and do not represent best practices for actual deployments.
- [x] Test an example contract locally using supersim, non-upgradeable (Custom, only Cross-Chain Messaging enabled)
- Test steps:
- After generating the contract, download as Foundry project, run setup script, then update
myFunctionto emit an event e.g.emit ReceivedCrossChainMessage(messenger.crossDomainMessageSender()); - Follow these steps except using
MyContractinstead ofGreeter, and deploying to the same address on chains A and B without constructor parameters. - After calling the crosschain function, use
cast logsto look for the event defined in step 1 on chain B.
- After generating the contract, download as Foundry project, run setup script, then update
- Test steps:
- [x] Test an example contract locally using supersim, upgradeable (Custom, Cross-Chain Messaging with Ownable and UUPS)
- Test steps:
- After generating the contract, download as Hardhat project, run setup script, then update
myFunctionto emit an event, and updatedeploy.tsto set the owner address to the first address fromsupersim. - Define supersim networks in Hardhat config, for example:
- Deploy to both chains:
-
npx hardhat run scripts/deploy.ts --network OPChainA -
npx hardhat run scripts/deploy.ts --network OPChainB
-
- Create script
callcrosschain.ts:
- After generating the contract, download as Hardhat project, run setup script, then update
- Test steps:
import { ethers } from "hardhat";
import { MyContract } from "../typechain-types";
async function main() {
const ContractFactory = await ethers.getContractFactory("MyContract");
const proxy = "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"; // use address from step above
const instance = await ContractFactory.attach(proxy) as MyContract;
await instance.callMyFunction(902);
}
// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
e. Call the crosschain function using script: npx hardhat run scripts/callcrosschain.ts --network OPChainA
f. After calling the crosschain function, use cast logs to look for the event defined in step 1 on chain B.
@SocketSecurity ignore-all Not related
@CoveMB
I am wondering in the Custom contract it seem Optimism option add both emitter and receiver functions is it standar or does contract usually implement on or the other?
In this example, we include both functions. If only one function is included, the emitter and/or receiver would need to take or track other addresses, which would be a more complex example. That can be considered as an enhancement if there is a need for it.