powerdlz23 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Zefoy-Automation/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/Zefoy-Automation/README.md +134 -0
- package/Zefoy-Automation/captcha.png +0 -0
- package/Zefoy-Automation/donation-userlist.md +7 -0
- package/Zefoy-Automation/main.py +257 -0
- package/Zefoy-Automation/output/Zefoy Automation for Windows.exe +0 -0
- package/Zefoy-Automation/requirements.txt +5 -0
- package/Zefoy-Automation/src/captcha.png +0 -0
- package/Zefoy-Automation/src/process.py +269 -0
- package/package.json +1 -1
- package/polymer/polymer-template/.env.example +27 -0
- package/polymer/polymer-template/.gitmodules +6 -0
- package/polymer/polymer-template/.gitpod.yml +10 -0
- package/polymer/polymer-template/Justfile +97 -0
- package/polymer/polymer-template/README.md +312 -0
- package/polymer/polymer-template/config/alt-config.json +42 -0
- package/polymer/polymer-template/config.json +42 -0
- package/polymer/polymer-template/contracts/XCounter.sol +89 -0
- package/polymer/polymer-template/contracts/XCounterUC.sol +100 -0
- package/polymer/polymer-template/contracts/arguments.js +7 -0
- package/polymer/polymer-template/contracts/base/CustomChanIbcApp.sol +205 -0
- package/polymer/polymer-template/contracts/base/GeneralMiddleware.sol +200 -0
- package/polymer/polymer-template/contracts/base/UniversalChanIbcApp.sol +93 -0
- package/polymer/polymer-template/foundry.toml +6 -0
- package/polymer/polymer-template/hardhat.config.js +66 -0
- package/polymer/polymer-template/ibc.json +26 -0
- package/polymer/polymer-template/img/gh_template.png +0 -0
- package/polymer/polymer-template/package-lock.json +7672 -0
- package/polymer/polymer-template/package.json +34 -0
- package/polymer/polymer-template/remappings.txt +5 -0
- package/polymer/polymer-template/scripts/deploy.js +51 -0
- package/polymer/polymer-template/scripts/private/_create-channel-config.js +62 -0
- package/polymer/polymer-template/scripts/private/_create-channel.js +96 -0
- package/polymer/polymer-template/scripts/private/_deploy-config.js +62 -0
- package/polymer/polymer-template/scripts/private/_events.js +241 -0
- package/polymer/polymer-template/scripts/private/_helpers.js +113 -0
- package/polymer/polymer-template/scripts/private/_sanity-check-custom.js +69 -0
- package/polymer/polymer-template/scripts/private/_sanity-check-universal.js +120 -0
- package/polymer/polymer-template/scripts/private/_sanity-check.js +21 -0
- package/polymer/polymer-template/scripts/private/_send-packet-config.js +53 -0
- package/polymer/polymer-template/scripts/private/_set-contracts-config.js +50 -0
- package/polymer/polymer-template/scripts/private/_switch-clients.js +90 -0
- package/polymer/polymer-template/scripts/private/_update-vibc-address.js +52 -0
- package/polymer/polymer-template/scripts/private/_vibc-helpers.js +118 -0
- package/polymer/polymer-template/scripts/send-packet.js +38 -0
- package/polymer/polymer-template/scripts/send-universal-packet.js +44 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// We require the Hardhat Runtime Environment explicitly here. This is optional
|
|
2
|
+
// but useful for running the script in a standalone fashion through `node <script>`.
|
|
3
|
+
//
|
|
4
|
+
// You can also run a script with `npx hardhat run <script>`. If you do that, Hardhat
|
|
5
|
+
// will compile your contracts, add the Hardhat Runtime Environment's members to the
|
|
6
|
+
// global scope, and execute the script.
|
|
7
|
+
const hre = require("hardhat");
|
|
8
|
+
const { getConfigPath } = require('./_helpers');
|
|
9
|
+
const { areAddressesEqual } = require("./_helpers");
|
|
10
|
+
const { getIbcApp } = require("./_vibc-helpers");
|
|
11
|
+
|
|
12
|
+
async function main() {
|
|
13
|
+
const configPath = getConfigPath();
|
|
14
|
+
const config = require(configPath);
|
|
15
|
+
const accounts = await hre.ethers.getSigners();
|
|
16
|
+
const networkName = hre.network.name;
|
|
17
|
+
|
|
18
|
+
// Get the Dispatcher from your IBC enabled contract and compare it with the stored value in the .env file
|
|
19
|
+
|
|
20
|
+
// 1. Get the contract type from the config and get the contract
|
|
21
|
+
const ibcApp = await getIbcApp(networkName);
|
|
22
|
+
|
|
23
|
+
// 2. Query your contract for the Dispatcher address
|
|
24
|
+
let dispatcherAddr
|
|
25
|
+
try {
|
|
26
|
+
dispatcherAddr = await ibcApp.dispatcher();
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.log(`❌ Error getting dispatcher address from IBC app. Check if the configuration file has the correct isUniversal flag set...`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 3. Compare with the value expected in the .env config file
|
|
33
|
+
let sanityCheck = false;
|
|
34
|
+
let envDispatcherAddr;
|
|
35
|
+
try {
|
|
36
|
+
if (networkName === "optimism") {
|
|
37
|
+
envDispatcherAddr = config.proofsEnabled === true ? process.env.OP_DISPATCHER : process.env.OP_DISPATCHER_SIM;
|
|
38
|
+
sanityCheck = areAddressesEqual(dispatcherAddr, envDispatcherAddr);
|
|
39
|
+
} else if (networkName === "base") {
|
|
40
|
+
envDispatcherAddr = config.proofsEnabled === true ? process.env.BASE_DISPATCHER : process.env.BASE_DISPATCHER_SIM;
|
|
41
|
+
sanityCheck = areAddressesEqual(dispatcherAddr, envDispatcherAddr);
|
|
42
|
+
}
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.log(`❌ Error comparing dispatcher addresses in .env file and IBC app: ${error}`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 4. Print the result of the sanity check
|
|
49
|
+
// If true, it means all values in the contracts check out with those in the .env file and we can continue with the other scripts.
|
|
50
|
+
if (sanityCheck) {
|
|
51
|
+
console.log(`✅ Sanity check passed for network ${networkName}`);
|
|
52
|
+
} else {
|
|
53
|
+
console.log(`
|
|
54
|
+
⛔ Sanity check failed for network ${networkName},
|
|
55
|
+
check if the values provided in the .env file for the Universal Channel Mw and the dispatcher are correct.
|
|
56
|
+
--------------------------------------------------
|
|
57
|
+
🔮 Expected dispatcher (in IBC contract): ${dispatcherAddr}...
|
|
58
|
+
🗃️ Found dispatcher (in .env file): ${envDispatcherAddr}...
|
|
59
|
+
--------------------------------------------------
|
|
60
|
+
`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// We recommend this pattern to be able to use async/await everywhere
|
|
65
|
+
// and properly handle errors.
|
|
66
|
+
main().catch((error) => {
|
|
67
|
+
console.error(error);
|
|
68
|
+
process.exitCode = 1;
|
|
69
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// We require the Hardhat Runtime Environment explicitly here. This is optional
|
|
2
|
+
// but useful for running the script in a standalone fashion through `node <script>`.
|
|
3
|
+
//
|
|
4
|
+
// You can also run a script with `npx hardhat run <script>`. If you do that, Hardhat
|
|
5
|
+
// will compile your contracts, add the Hardhat Runtime Environment's members to the
|
|
6
|
+
// global scope, and execute the script.
|
|
7
|
+
const hre = require("hardhat");
|
|
8
|
+
const { getConfigPath, areAddressesEqual } = require('./_helpers.js');
|
|
9
|
+
const { getIbcApp, getUcHandler } = require("./_vibc-helpers.js");
|
|
10
|
+
|
|
11
|
+
async function main() {
|
|
12
|
+
const config = require(getConfigPath());
|
|
13
|
+
const accounts = await hre.ethers.getSigners();
|
|
14
|
+
const networkName = hre.network.name;
|
|
15
|
+
|
|
16
|
+
// Get the Universal Channel Mw from your IBC enabled contract and comare it with the values in the .env file
|
|
17
|
+
|
|
18
|
+
// 1. Get the contract type from the config and get the contract
|
|
19
|
+
const ibcApp = await getIbcApp(networkName);
|
|
20
|
+
|
|
21
|
+
// 2. Query your app for the Universal Channel Mw address stored
|
|
22
|
+
let ucHandlerAddr;
|
|
23
|
+
try {
|
|
24
|
+
ucHandlerAddr = await ibcApp.mw();
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.log(`❌ Error getting Universal Channel Mw address from IBC app. Check if the configuration file has the correct isUniversal flag set...`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 3. Compare with the value expected in the .env config file
|
|
31
|
+
let sanityCheck = false;
|
|
32
|
+
let envUcHandlerAddr;
|
|
33
|
+
try {
|
|
34
|
+
if (networkName === "optimism") {
|
|
35
|
+
envUcHandlerAddr = config.proofsEnabled === true ? process.env.OP_UC_MW : process.env.OP_UC_MW_SIM;
|
|
36
|
+
sanityCheck = areAddressesEqual(ucHandlerAddr, envUcHandlerAddr);
|
|
37
|
+
} else if (networkName === "base") {
|
|
38
|
+
envUcHandlerAddr = config.proofsEnabled === true ? process.env.BASE_UC_MW : process.env.BASE_UC_MW_SIM;
|
|
39
|
+
sanityCheck = areAddressesEqual(ucHandlerAddr, envUcHandlerAddr);
|
|
40
|
+
}
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.log(`❌ Error comparing Universal Channel Mw addresses in .env file and IBC app: ${error}`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 4. If true, we continue to check the dispatcher stored in the Universal Channel Mw
|
|
47
|
+
let envDispatcherAddr;
|
|
48
|
+
let dispatcherAddr;
|
|
49
|
+
let ucHandler;
|
|
50
|
+
|
|
51
|
+
if (sanityCheck) {
|
|
52
|
+
try {
|
|
53
|
+
ucHandler = await getUcHandler(networkName);
|
|
54
|
+
dispatcherAddr = await ucHandler.dispatcher();
|
|
55
|
+
if (networkName === "optimism") {
|
|
56
|
+
envDispatcherAddr = config.proofsEnabled === true ? process.env.OP_DISPATCHER : process.env.OP_DISPATCHER_SIM;
|
|
57
|
+
sanityCheck = areAddressesEqual(dispatcherAddr, envDispatcherAddr);
|
|
58
|
+
} else if (networkName === "base") {
|
|
59
|
+
envDispatcherAddr = config.proofsEnabled === true ? process.env.BASE_DISPATCHER : process.env.BASE_DISPATCHER_SIM;
|
|
60
|
+
sanityCheck = areAddressesEqual(dispatcherAddr, envDispatcherAddr);
|
|
61
|
+
} else {
|
|
62
|
+
sanityCheck = false;
|
|
63
|
+
}
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.log(`❌ Error getting dispatcher address from Universal Channel Mw or from config: ${error}`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
console.log(`
|
|
70
|
+
⛔ Sanity check failed for network ${networkName},
|
|
71
|
+
check if the values provided in the .env file for the Universal Channel Mw and the dispatcher are correct.
|
|
72
|
+
--------------------------------------------------
|
|
73
|
+
🔮 Expected Universal Channel Handler (in IBC contract): ${ucHandlerAddr}...
|
|
74
|
+
🗃️ Found Universal Channel Handler (in .env file): ${envUcHandlerAddr}...
|
|
75
|
+
--------------------------------------------------
|
|
76
|
+
`);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (sanityCheck) {
|
|
81
|
+
const channelBytes = await ucHandler.connectedChannels(0);
|
|
82
|
+
const channelId = hre.ethers.decodeBytes32String(channelBytes);
|
|
83
|
+
const envChannelId = config["sendUniversalPacket"][networkName]["channelId"];
|
|
84
|
+
|
|
85
|
+
if (channelId !== envChannelId) {
|
|
86
|
+
sanityCheck = false;
|
|
87
|
+
console.log(`
|
|
88
|
+
⛔ Sanity check failed for network ${networkName},
|
|
89
|
+
check if the channel id value for the Universal channel in the config is correct.
|
|
90
|
+
--------------------------------------------------
|
|
91
|
+
🔮 Expected Channel ID (in Universal Channel Handler contract): ${channelId}...
|
|
92
|
+
🗃️ Found Dispatcher (in .env file): ${envChannelId}...
|
|
93
|
+
--------------------------------------------------
|
|
94
|
+
`);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// 5. Print the result of the sanity check
|
|
100
|
+
// If true, it means all values in the contracts check out with those in the .env file and we can continue with the script.
|
|
101
|
+
if (sanityCheck) {
|
|
102
|
+
console.log(`✅ Sanity check passed for network ${networkName}`);
|
|
103
|
+
} else {
|
|
104
|
+
console.log(`
|
|
105
|
+
⛔ Sanity check failed for network ${networkName},
|
|
106
|
+
check if the values provided in the .env file for the Universal Channel Mw and the dispatcher are correct.
|
|
107
|
+
--------------------------------------------------
|
|
108
|
+
🔮 Expected Dispatcher (in Universal Channel Handler contract): ${dispatcherAddr}...
|
|
109
|
+
🗃️ Found Dispatcher (in .env file): ${envDispatcherAddr}...
|
|
110
|
+
--------------------------------------------------
|
|
111
|
+
`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// We recommend this pattern to be able to use async/await everywhere
|
|
116
|
+
// and properly handle errors.
|
|
117
|
+
main().catch((error) => {
|
|
118
|
+
console.error(error);
|
|
119
|
+
process.exitCode = 1;
|
|
120
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Example:
|
|
2
|
+
// $ node scripts/sanity-check.js
|
|
3
|
+
const { exec } = require("child_process");
|
|
4
|
+
const { getConfigPath } = require('./_helpers.js');
|
|
5
|
+
|
|
6
|
+
function runSanityCheck(network) {
|
|
7
|
+
const config = require(getConfigPath());
|
|
8
|
+
const scriptSuffix = config.isUniversal ? 'universal' : 'custom';
|
|
9
|
+
|
|
10
|
+
exec(`npx hardhat run scripts/private/_sanity-check-${scriptSuffix}.js --network ${network}`, (error, stdout, stderr) => {
|
|
11
|
+
if (error) {
|
|
12
|
+
console.error(`exec error: ${error}`);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
console.log(stdout);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// TODO: EXTEND THIS TO SUPPORT MULTIPLE NETWORKS
|
|
20
|
+
runSanityCheck('optimism');
|
|
21
|
+
runSanityCheck('base');
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const { exec } = require("child_process");
|
|
2
|
+
const {getConfigPath, getWhitelistedNetworks} = require('./_helpers.js');
|
|
3
|
+
const { setupIbcPacketEventListener } = require('./_events.js');
|
|
4
|
+
|
|
5
|
+
const source = process.argv[2];
|
|
6
|
+
if (!source) {
|
|
7
|
+
console.error('Usage: node send-packet-config.js <source_network>');
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function runSendPacket(config) {
|
|
12
|
+
// Check if the source chain from user input is whitelisted
|
|
13
|
+
const allowedNetworks = getWhitelistedNetworks();
|
|
14
|
+
if (!allowedNetworks.includes(source)) {
|
|
15
|
+
console.error("❌ Please provide a valid source chain");
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Run the send-packet or send-universal-packet script based on the config
|
|
20
|
+
if (config.isUniversal) {
|
|
21
|
+
exec(`npx hardhat run scripts/send-universal-packet.js --network ${source}`, (error, stdout, stderr) => {
|
|
22
|
+
if (error) {
|
|
23
|
+
console.error(`exec error: ${error}`);
|
|
24
|
+
return;
|
|
25
|
+
} else {
|
|
26
|
+
console.log(stdout);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
exec(`npx hardhat run scripts/send-packet.js --network ${source}`, (error, stdout, stderr) => {
|
|
31
|
+
if (error) {
|
|
32
|
+
console.error(`exec error: ${error}`);
|
|
33
|
+
return;
|
|
34
|
+
}else {
|
|
35
|
+
console.log(stdout);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function main() {
|
|
42
|
+
const configPath = getConfigPath();
|
|
43
|
+
const config = require(configPath);
|
|
44
|
+
|
|
45
|
+
await setupIbcPacketEventListener();
|
|
46
|
+
|
|
47
|
+
runSendPacket(config);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
main().catch((error) => {
|
|
51
|
+
console.error(error);
|
|
52
|
+
process.exitCode = 1;
|
|
53
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Run script to set the contract in the config.json file along with the isUniversal flag
|
|
2
|
+
// Example:
|
|
3
|
+
// $ node set-contracts-config.js optimism XCounterUC true
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const { getConfigPath } = require('./_helpers.js');
|
|
6
|
+
|
|
7
|
+
if(process.argv.length < 5) {
|
|
8
|
+
console.error('❌ Incorrect number of args. Usage: node set-contracts-config.js <chain> <contractType> <isUniversal>');
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
const chain = process.argv[2];
|
|
12
|
+
const contractType = process.argv[3];
|
|
13
|
+
const universalBoolean = process.argv[4].trim().toLowerCase()
|
|
14
|
+
|
|
15
|
+
if (chain !== "optimism" && chain !== "base") {
|
|
16
|
+
console.error('❌ Incorrect chain value. Usage: node set-contracts-config.js <chain> <contractType> <isUniversal>');
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let isUniversal;
|
|
21
|
+
if (universalBoolean === "true") {
|
|
22
|
+
isUniversal = true;
|
|
23
|
+
} else if (universalBoolean === "false") {
|
|
24
|
+
isUniversal = false;
|
|
25
|
+
} else {
|
|
26
|
+
console.error('❌ Incorrect boolean value. Usage: node set-contracts-config.js <chain> <contractType> <isUniversal>');
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const configPath = getConfigPath();
|
|
31
|
+
|
|
32
|
+
// Function to update config.json
|
|
33
|
+
function updateConfig(network, contractType) {
|
|
34
|
+
try {
|
|
35
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
36
|
+
|
|
37
|
+
// Update the config object
|
|
38
|
+
config["deploy"][`${network}`] = contractType;
|
|
39
|
+
config["isUniversal"] = isUniversal;
|
|
40
|
+
|
|
41
|
+
// Write the updated config back to the file
|
|
42
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
43
|
+
console.log(`🆗 Updated config with ${contractType} for ${network}. Set isUniversal to ${isUniversal}.`);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error(`❌ Failed to update config: ${error.message}`);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
updateConfig(chain, contractType);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const { getConfigPath } = require('./_helpers.js');
|
|
3
|
+
const ibcConfig = require('../../ibc.json');
|
|
4
|
+
|
|
5
|
+
// Function to update config.json
|
|
6
|
+
function flipConfig() {
|
|
7
|
+
try {
|
|
8
|
+
const configPath = getConfigPath();
|
|
9
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
10
|
+
// Create a temporary copy of the config object to store a backup of the current values
|
|
11
|
+
// The backup is used when switching back to between clients
|
|
12
|
+
const tempConfig = {...config};
|
|
13
|
+
const source = tempConfig["createChannel"]["srcChain"];
|
|
14
|
+
const destination = tempConfig["createChannel"]["dstChain"];
|
|
15
|
+
|
|
16
|
+
// Below, we'll update the config object
|
|
17
|
+
if (config.backup !== undefined && typeof config.backup === 'object' && Object.keys(config.backup).length > 0) {
|
|
18
|
+
// Update the createChannel object with backup values
|
|
19
|
+
config["createChannel"]["srcAddr"] = config["backup"]["sendPacket"][`${source}`]["portAddr"];
|
|
20
|
+
config["createChannel"]["dstAddr"] = config["backup"]["sendPacket"][`${destination}`]["portAddr"];
|
|
21
|
+
|
|
22
|
+
// Update the sendPacket and sendUniversalPacket object with backup values
|
|
23
|
+
config["sendPacket"] = config["backup"]["sendPacket"];
|
|
24
|
+
config["sendUniversalPacket"] = config["backup"]["sendUniversalPacket"];
|
|
25
|
+
} else {
|
|
26
|
+
// If no backup object is provided, use the default values
|
|
27
|
+
config["createChannel"] = {
|
|
28
|
+
"srcChain": source,
|
|
29
|
+
"srcAddr": "0x1234567890AbCdEf1234567890aBcDeF12345678",
|
|
30
|
+
"dstChain": destination,
|
|
31
|
+
"dstAddr": "0x1234567890AbCdEf1234567890aBcDeF12345678",
|
|
32
|
+
"version": "1.0",
|
|
33
|
+
"ordering": 0,
|
|
34
|
+
"fees": false
|
|
35
|
+
};
|
|
36
|
+
config["sendPacket"] = {
|
|
37
|
+
"optimism": {
|
|
38
|
+
"portAddr": "0x1234567890abcdef1234567890abcdef12345678",
|
|
39
|
+
"channelId": "channel-n",
|
|
40
|
+
"timeout": 36000
|
|
41
|
+
},
|
|
42
|
+
"base": {
|
|
43
|
+
"portAddr": "0x1234567890abcdef1234567890abcdef12345678",
|
|
44
|
+
"channelId": "channel-n",
|
|
45
|
+
"timeout": 36000
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
config["sendUniversalPacket"] = {
|
|
49
|
+
"optimism": {
|
|
50
|
+
"portAddr": "0x1234567890abcdef1234567890abcdef12345678",
|
|
51
|
+
"channelId": "channel-x",
|
|
52
|
+
"timeout": 36000
|
|
53
|
+
},
|
|
54
|
+
"base": {
|
|
55
|
+
"portAddr": "0x1234567890abcdef1234567890abcdef12345678",
|
|
56
|
+
"channelId": "channel-y",
|
|
57
|
+
"timeout": 36000
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Update the universal channel values for new client
|
|
63
|
+
config["sendUniversalPacket"]["optimism"]["channelId"] =
|
|
64
|
+
tempConfig.proofsEnabled ?
|
|
65
|
+
ibcConfig["optimism"]["sim-client"]["universalChannel"] :
|
|
66
|
+
ibcConfig["optimism"]["op-client"]["universalChannel"];
|
|
67
|
+
config["sendUniversalPacket"]["base"]["channelId"] =
|
|
68
|
+
tempConfig.proofsEnabled ?
|
|
69
|
+
ibcConfig["base"]["sim-client"]["universalChannel"] :
|
|
70
|
+
ibcConfig["base"]["op-client"]["universalChannel"];
|
|
71
|
+
|
|
72
|
+
// Write a new backup object to the config
|
|
73
|
+
config["backup"] = {
|
|
74
|
+
"sendPacket": tempConfig["sendPacket"],
|
|
75
|
+
"sendUniversalPacket": tempConfig["sendUniversalPacket"]
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// Flip the proofsEnabled flag
|
|
79
|
+
config["proofsEnabled"] = !config["proofsEnabled"];
|
|
80
|
+
|
|
81
|
+
// Write the updated config back to the file
|
|
82
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
83
|
+
console.log('🆗 Config updated');
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error(`❌ Failed to update config: ${error.message}`);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
flipConfig();
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// We require the Hardhat Runtime Environment explicitly here. This is optional
|
|
2
|
+
// but useful for running the script in a standalone fashion through `node <script>`.
|
|
3
|
+
//
|
|
4
|
+
// You can also run a script with `npx hardhat run <script>`. If you do that, Hardhat
|
|
5
|
+
// will compile your contracts, add the Hardhat Runtime Environment's members to the
|
|
6
|
+
// global scope, and execute the script.
|
|
7
|
+
const hre = require("hardhat");
|
|
8
|
+
const { getDispatcherAddress, getUcHandlerAddress, getIbcApp } = require("./_vibc-helpers");
|
|
9
|
+
const { getConfigPath } = require("./_helpers");
|
|
10
|
+
|
|
11
|
+
async function main() {
|
|
12
|
+
await hre.ethers.getSigners();
|
|
13
|
+
const networkName = hre.network.name;
|
|
14
|
+
const config = require(getConfigPath());
|
|
15
|
+
|
|
16
|
+
if (!config.isUniversal) {
|
|
17
|
+
// Determine the new dispatcher, based on the network.
|
|
18
|
+
const newDispatcher = getDispatcherAddress(networkName);
|
|
19
|
+
|
|
20
|
+
// Get the contract type from the config and get the contract
|
|
21
|
+
const ibcApp = await getIbcApp(networkName);
|
|
22
|
+
try {
|
|
23
|
+
await ibcApp.updateDispatcher(newDispatcher);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error(`❌ Error getting dispatcher address from IBC app. Check if the configuration file has the correct isUniversal flag set...`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
console.log(`✅ Dispatcher updated to ${newDispatcher}`);
|
|
29
|
+
} else if (config.isUniversal) {
|
|
30
|
+
// Determine the new universal channel handler, based on the network.
|
|
31
|
+
const newUcHandler = getUcHandlerAddress(networkName);
|
|
32
|
+
|
|
33
|
+
// Get the contract type from the config and get the contract
|
|
34
|
+
const ibcApp = await getIbcApp(networkName, true);
|
|
35
|
+
try {
|
|
36
|
+
await ibcApp.setDefaultMw(newUcHandler);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.log(`❌ Error updating Universal Channel Mw address from IBC app. Check if the configuration file has the correct isUniversal flag set...`);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
console.log(`✅ Universal channel handler updated to ${newUcHandler}`);
|
|
42
|
+
}else {
|
|
43
|
+
console.error('❌ Check the config file for isUniversal value. It should be a boolean.');
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// We recommend this pattern to be able to use async/await everywhere
|
|
48
|
+
// and properly handle errors.
|
|
49
|
+
main().catch((error) => {
|
|
50
|
+
console.error(error);
|
|
51
|
+
process.exitCode = 1;
|
|
52
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const {ethers} = require("hardhat");
|
|
2
|
+
const { getConfigPath, fetchABI} = require("./_helpers.js");
|
|
3
|
+
|
|
4
|
+
const explorerOpUrl = "https://optimism-sepolia.blockscout.com/";
|
|
5
|
+
const explorerBaseUrl = "https://base-sepolia.blockscout.com/";
|
|
6
|
+
|
|
7
|
+
const rpcOptimism = `https://opt-sepolia.g.alchemy.com/v2/${process.env.OP_ALCHEMY_API_KEY}`;
|
|
8
|
+
const rpcBase = `https://base-sepolia.g.alchemy.com/v2/${process.env.BASE_ALCHEMY_API_KEY}`;
|
|
9
|
+
|
|
10
|
+
async function getIbcApp (network) {
|
|
11
|
+
try {
|
|
12
|
+
const config = require(getConfigPath());
|
|
13
|
+
const ibcAppAddr = config.isUniversal ? config["sendUniversalPacket"][`${network}`]["portAddr"] : config["sendPacket"][`${network}`]["portAddr"];
|
|
14
|
+
console.log(`🗄️ Fetching IBC app on ${network} at address: ${ibcAppAddr}`)
|
|
15
|
+
const contractType = config["deploy"][`${network}`];
|
|
16
|
+
const ibcApp = await ethers.getContractAt(
|
|
17
|
+
`${contractType}`,
|
|
18
|
+
ibcAppAddr
|
|
19
|
+
);
|
|
20
|
+
return ibcApp;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.log(`❌ Error getting IBC app: ${error}`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getDispatcherAddress(network) {
|
|
28
|
+
const config = require(getConfigPath());
|
|
29
|
+
let dispatcherAddr;
|
|
30
|
+
if (network === "optimism") {
|
|
31
|
+
dispatcherAddr = config.proofsEnabled ? process.env.OP_DISPATCHER : process.env.OP_DISPATCHER_SIM;
|
|
32
|
+
} else if (network === "base") {
|
|
33
|
+
dispatcherAddr = config.proofsEnabled ? process.env.BASE_DISPATCHER : process.env.BASE_DISPATCHER_SIM;
|
|
34
|
+
} else {
|
|
35
|
+
throw new Error("❌ Invalid network");
|
|
36
|
+
}
|
|
37
|
+
return dispatcherAddr;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function getDispatcher (network) {
|
|
41
|
+
const config = require(getConfigPath());
|
|
42
|
+
const providerOptimism = new ethers.JsonRpcProvider(rpcOptimism);
|
|
43
|
+
const providerBase = new ethers.JsonRpcProvider(rpcBase);
|
|
44
|
+
|
|
45
|
+
let explorerUrl;
|
|
46
|
+
let dispatcher;
|
|
47
|
+
let dispatcherAddress;
|
|
48
|
+
try {
|
|
49
|
+
if (network === "optimism") {
|
|
50
|
+
explorerUrl = explorerOpUrl;
|
|
51
|
+
dispatcherAddress = config.proofsEnabled ? dispatcherAddress = process.env.OP_DISPATCHER : dispatcherAddress = process.env.OP_DISPATCHER_SIM;
|
|
52
|
+
|
|
53
|
+
const opDispatcherAbi = await fetchABI(explorerUrl, dispatcherAddress);
|
|
54
|
+
dispatcher = new ethers.Contract(dispatcherAddress, opDispatcherAbi, providerOptimism);
|
|
55
|
+
} else if (network === "base") {
|
|
56
|
+
explorerUrl = explorerBaseUrl;
|
|
57
|
+
dispatcherAddress = config.proofsEnabled ? dispatcherAddress = process.env.BASE_DISPATCHER : dispatcherAddress = process.env.BASE_DISPATCHER_SIM;
|
|
58
|
+
|
|
59
|
+
const baseDispatcherAbi = await fetchABI(explorerUrl, dispatcherAddress);
|
|
60
|
+
dispatcher = new ethers.Contract(dispatcherAddress, baseDispatcherAbi, providerBase);
|
|
61
|
+
} else {
|
|
62
|
+
throw new Error(`❌ Invalid network: ${network}`);
|
|
63
|
+
}
|
|
64
|
+
return dispatcher;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.log(`❌ Error getting dispatcher: ${error}`);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function getUcHandlerAddress(network) {
|
|
73
|
+
const config = require(getConfigPath());
|
|
74
|
+
let ucHandlerAddr;
|
|
75
|
+
if (network === "optimism") {
|
|
76
|
+
ucHandlerAddr = config.proofsEnabled ? process.env.OP_UC_MW : process.env.OP_UC_MW_SIM;
|
|
77
|
+
} else if (network === "base") {
|
|
78
|
+
ucHandlerAddr = config.proofsEnabled ? process.env.BASE_UC_MW : process.env.BASE_UC_MW_SIM;
|
|
79
|
+
} else {
|
|
80
|
+
throw new Error("❌ Invalid network");
|
|
81
|
+
}
|
|
82
|
+
return ucHandlerAddr;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function getUcHandler (network) {
|
|
86
|
+
const config = require(getConfigPath());
|
|
87
|
+
const providerOptimism = new ethers.JsonRpcProvider(rpcOptimism);
|
|
88
|
+
const providerBase = new ethers.JsonRpcProvider(rpcBase);
|
|
89
|
+
|
|
90
|
+
let explorerUrl;
|
|
91
|
+
let ucHandler;
|
|
92
|
+
let ucHandlerAddress;
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
if (network === "optimism") {
|
|
96
|
+
explorerUrl = explorerOpUrl;
|
|
97
|
+
ucHandlerAddress = config.proofsEnabled ? process.env.OP_UC_MW : process.env.OP_UC_MW_SIM;
|
|
98
|
+
|
|
99
|
+
const opUcHandlerAbi = await fetchABI(explorerUrl, ucHandlerAddress);
|
|
100
|
+
ucHandler = new ethers.Contract(ucHandlerAddress, opUcHandlerAbi, providerOptimism);
|
|
101
|
+
} else if (network === "base") {
|
|
102
|
+
explorerUrl = explorerBaseUrl;
|
|
103
|
+
ucHandlerAddress = config.proofsEnabled ? process.env.BASE_UC_MW : process.env.BASE_UC_MW_SIM;
|
|
104
|
+
|
|
105
|
+
const baseUcHandlerAbi = await fetchABI(explorerUrl, ucHandlerAddress);
|
|
106
|
+
ucHandler = new ethers.Contract(ucHandlerAddress, baseUcHandlerAbi, providerBase);
|
|
107
|
+
} else {
|
|
108
|
+
throw new Error(`❌ Invalid network: ${network}`);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return ucHandler;
|
|
112
|
+
} catch (error) {
|
|
113
|
+
console.log(`❌ Error getting ucHandler: ${error}`);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
module.exports = { getIbcApp, getDispatcherAddress, getDispatcher, getUcHandlerAddress, getUcHandler };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// We require the Hardhat Runtime Environment explicitly here. This is optional
|
|
2
|
+
// but useful for running the script in a standalone fashion through `node <script>`.
|
|
3
|
+
//
|
|
4
|
+
// You can also run a script with `npx hardhat run <script>`. If you do that, Hardhat
|
|
5
|
+
// will compile your contracts, add the Hardhat Runtime Environment's members to the
|
|
6
|
+
// global scope, and execute the script.
|
|
7
|
+
const hre = require('hardhat');
|
|
8
|
+
const { getConfigPath } = require('./private/_helpers');
|
|
9
|
+
const { getIbcApp } = require('./private/_vibc-helpers.js');
|
|
10
|
+
|
|
11
|
+
async function main() {
|
|
12
|
+
const accounts = await hre.ethers.getSigners();
|
|
13
|
+
const config = require(getConfigPath());
|
|
14
|
+
const sendConfig = config.sendPacket;
|
|
15
|
+
|
|
16
|
+
const networkName = hre.network.name;
|
|
17
|
+
// Get the contract type from the config and get the contract
|
|
18
|
+
const ibcApp = await getIbcApp(networkName);
|
|
19
|
+
|
|
20
|
+
// Do logic to prepare the packet
|
|
21
|
+
const channelId = sendConfig[`${networkName}`]["channelId"];
|
|
22
|
+
const channelIdBytes = hre.ethers.encodeBytes32String(channelId);
|
|
23
|
+
const timeoutSeconds = sendConfig[`${networkName}`]["timeout"];
|
|
24
|
+
|
|
25
|
+
// Send the packet
|
|
26
|
+
await ibcApp.connect(accounts[0]).sendPacket(
|
|
27
|
+
channelIdBytes,
|
|
28
|
+
timeoutSeconds,
|
|
29
|
+
// Define and pass optionalArgs appropriately or remove if not needed
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// We recommend this pattern to be able to use async/await everywhere
|
|
34
|
+
// and properly handle errors.
|
|
35
|
+
main().catch((error) => {
|
|
36
|
+
console.error(error);
|
|
37
|
+
process.exitCode = 1;
|
|
38
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// We require the Hardhat Runtime Environment explicitly here. This is optional
|
|
2
|
+
// but useful for running the script in a standalone fashion through `node <script>`.
|
|
3
|
+
//
|
|
4
|
+
// You can also run a script with `npx hardhat run <script>`. If you do that, Hardhat
|
|
5
|
+
// will compile your contracts, add the Hardhat Runtime Environment's members to the
|
|
6
|
+
// global scope, and execute the script.
|
|
7
|
+
const hre = require('hardhat');
|
|
8
|
+
const { getConfigPath } = require('./private/_helpers');
|
|
9
|
+
const { getIbcApp } = require('./private/_vibc-helpers.js');
|
|
10
|
+
|
|
11
|
+
async function main() {
|
|
12
|
+
const accounts = await hre.ethers.getSigners();
|
|
13
|
+
const config = require(getConfigPath());
|
|
14
|
+
const sendConfig = config.sendUniversalPacket;
|
|
15
|
+
|
|
16
|
+
const networkName = hre.network.name;
|
|
17
|
+
// Get the contract type from the config and get the contract
|
|
18
|
+
const ibcApp = await getIbcApp(networkName);
|
|
19
|
+
|
|
20
|
+
// Do logic to prepare the packet
|
|
21
|
+
|
|
22
|
+
// If the network we are sending on is optimism, we need to use the base port address and vice versa
|
|
23
|
+
const destPortAddr = networkName === "optimism" ?
|
|
24
|
+
config["sendUniversalPacket"]["base"]["portAddr"] :
|
|
25
|
+
config["sendUniversalPacket"]["optimism"]["portAddr"];
|
|
26
|
+
const channelId = sendConfig[`${networkName}`]["channelId"];
|
|
27
|
+
const channelIdBytes = hre.ethers.encodeBytes32String(channelId);
|
|
28
|
+
const timeoutSeconds = sendConfig[`${networkName}`]["timeout"];
|
|
29
|
+
|
|
30
|
+
// Send the packet
|
|
31
|
+
await ibcApp.connect(accounts[0]).sendUniversalPacket(
|
|
32
|
+
destPortAddr,
|
|
33
|
+
channelIdBytes,
|
|
34
|
+
timeoutSeconds,
|
|
35
|
+
// Define and pass optionalArgs appropriately or remove if not needed
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// We recommend this pattern to be able to use async/await everywhere
|
|
40
|
+
// and properly handle errors.
|
|
41
|
+
main().catch((error) => {
|
|
42
|
+
console.error(error);
|
|
43
|
+
process.exitCode = 1;
|
|
44
|
+
});
|