Created
January 24, 2022 23:54
-
-
Save nginnever/228da59dc79b607fc38345157094cf15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example of adding an owner to the mainnet safe via a proposal on the sidechain | |
const safeKovan = new ethers.Contract( | |
KOVAN_SAFE_ADDRESS, | |
GnosisSafeL2.abi, | |
deployer | |
) | |
const safeSokol = new ethers.Contract( | |
SOKOL_SAFE_ADDRESS, | |
GnosisSafeL2.abi, | |
deployer | |
) | |
const usulSokol = new ethers.Contract( | |
SOKOL_USUL_ADDRESS, | |
Usul.abi, | |
deployer | |
) | |
const AMBSokol = new ethers.Contract( | |
_amb_ADDRESS, | |
AMB.abi, | |
deployer | |
) | |
const bridgeKovan = new ethers.Contract( | |
KOVAN_BRIDGE, | |
AMB.abi, | |
deployer | |
) | |
// generate the call selected in the action of the proposal (one at a time for now, we | |
// need to use multisend to achieve multiple calls in one bridge | |
const addCall = buildContractCall( | |
safeKovan, | |
"addOwnerWithThreshold", | |
[NEW_ADMIN_ACCOUNT, 1], | |
0 | |
); | |
// generate the call to the mainnet bridge module that will happend after bridging, this forwards | |
// the addOwner tx to the gnosis safe on mainnet | |
const bridgeCall = buildContractCall( | |
bridgeKovan, | |
"executeTransaction", // this method on the bridge module forwards the call to the mainnet safe | |
// see the method here https://github.com/gnosis/zodiac-module-bridge/blob/main/contracts/AMBModule.sol#L118 | |
[safeKovan.address, 0, addCall.data, 0], // to address will always be the mainnet safe | |
0 | |
); | |
// store ambCall.data, this will be used to generate the proposal call data on the sidechain Usul | |
const ambCall = buildContractCall( | |
AMBSokol, | |
"requireToPassMessage", | |
[bridgeKovan.address, bridgeCall.data, 1000000], | |
0 | |
); | |
console.log(ambCall.data) | |
// Create proposal on sidechain usul | |
const txHash = await usul.getTransactionHash( | |
AMBSokol.address, // the target of the proposal call | |
0, | |
ambCall.data, // we will execute the call to the amb that wraps the call on mainnet | |
0 | |
); | |
// submit the propsal to sidechain usul as normal | |
const tx = await usul.submitProposal([txHash], linear.address, "0x", {gasPrice: 20000000000}); | |
// now vote on the propsal as usual, but on the sidechain | |
const tx = await linear.vote(proposalId, 1, {gasPrice: 20000000000}) | |
await tx.wait() | |
// waiting for voting period to end | |
await sleep(120000); | |
// finalize the strat, here get the transaction hash from tx2 object, i forget what the key is for it | |
const tx2 = await linear.finalizeStrategy(proposalId, {gasPrice: 20000000000}); | |
// prompt user to submit tx2 hash at the AMB website https://alm-test-amb.herokuapp.com/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment