-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
171 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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
90 changes: 90 additions & 0 deletions
90
scripts/proposals/proposal_10_staking_verifier_set_implementation.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/*global process*/ | ||
|
||
const { ethers } = require("ethers"); | ||
|
||
async function main() { | ||
const fs = require("fs"); | ||
// Mainnet globals file | ||
const globalsFile = "globals.json"; | ||
const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); | ||
const parsedData = JSON.parse(dataFromJSON); | ||
|
||
const ALCHEMY_API_KEY_MAINNET = process.env.ALCHEMY_API_KEY_MAINNET; | ||
const mainnetURL = "https://eth-mainnet.g.alchemy.com/v2/" + ALCHEMY_API_KEY_MAINNET; | ||
const mainnetProvider = new ethers.providers.JsonRpcProvider(mainnetURL); | ||
await mainnetProvider.getBlockNumber().then((result) => { | ||
console.log("Current block number mainnet: " + result); | ||
}); | ||
|
||
const gnosisURL = "https://rpc.gnosischain.com"; | ||
const gnosisProvider = new ethers.providers.JsonRpcProvider(gnosisURL); | ||
await gnosisProvider.getBlockNumber().then((result) => { | ||
console.log("Current block number gnosis: " + result); | ||
}); | ||
|
||
|
||
// AMBProxy address on mainnet | ||
const AMBProxyAddress = parsedData.AMBContractProxyForeignAddress; | ||
const AMBProxyJSON = "abis/bridges/gnosis/EternalStorageProxy.json"; | ||
let contractFromJSON = fs.readFileSync(AMBProxyJSON, "utf8"); | ||
const AMBProxyABI = JSON.parse(contractFromJSON); | ||
const AMBProxy = new ethers.Contract(AMBProxyAddress, AMBProxyABI, mainnetProvider); | ||
|
||
// Test deployed HomeMediator address on chiado | ||
const homeMediatorAddress = parsedData.bridgeMediatorAddress; | ||
const homeMediatorJSON = "abis/bridges/gnosis/HomeMediator.json"; | ||
contractFromJSON = fs.readFileSync(homeMediatorJSON, "utf8"); | ||
let parsedFile = JSON.parse(contractFromJSON); | ||
const homeMediatorABI = parsedFile["abi"]; | ||
const homeMediator = new ethers.Contract(homeMediatorAddress, homeMediatorABI, gnosisProvider); | ||
|
||
// StakingVerifier address on gnosis | ||
const stakingVerifierAddress = parsedData.stakingVerifierAddress; | ||
const stakingVerifierJSON = "artifacts/contracts/staking/StakingVerifier.sol/StakingVerifier.json"; | ||
contractFromJSON = fs.readFileSync(stakingVerifierJSON, "utf8"); | ||
parsedFile = JSON.parse(contractFromJSON); | ||
const stakingVerifierABI = parsedFile["abi"]; | ||
const stakingVerifier = new ethers.Contract(stakingVerifierAddress, stakingVerifierABI, gnosisProvider); | ||
|
||
// Timelock contract across the bridge must change staking limits | ||
const rawPayload = stakingVerifier.interface.encodeFunctionData("setImplementationsStatuses", | ||
[[parsedData.stakingTokenAddress], [true], true]); | ||
// Pack the second part of data | ||
const target = stakingVerifierAddress; | ||
const value = 0; | ||
const payload = ethers.utils.arrayify(rawPayload); | ||
const data = ethers.utils.solidityPack( | ||
["address", "uint96", "uint32", "bytes"], | ||
[target, value, payload.length, payload] | ||
); | ||
|
||
// Proposal preparation | ||
console.log("Proposal 10. Whitelist StakingTokenImplementation in StakingFactory on gnosis\n"); | ||
const mediatorPayload = await homeMediator.interface.encodeFunctionData("processMessageFromForeign", [data]); | ||
|
||
// AMBContractProxyHomeAddress on gnosis mainnet: 0x75Df5AF045d91108662D8080fD1FEFAd6aA0bb59 | ||
// Function to call by homeMediator: processMessageFromForeign | ||
console.log("AMBContractProxyHomeAddress to call homeMediator's processMessageFromForeign function with the data:", data); | ||
|
||
const requestGasLimit = "2000000"; | ||
const timelockPayload = await AMBProxy.interface.encodeFunctionData("requireToPassMessage", [homeMediatorAddress, | ||
mediatorPayload, requestGasLimit]); | ||
|
||
const targets = [AMBProxyAddress]; | ||
const values = [0]; | ||
const callDatas = [timelockPayload]; | ||
const description = "Whitelist StakingTokenImplementation in StakingFactory on gnosis"; | ||
|
||
// Proposal details | ||
console.log("targets:", targets); | ||
console.log("values:", values); | ||
console.log("call datas:", callDatas); | ||
console.log("description:", description); | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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