diff --git a/README.md b/README.md
index ccccd23..297abcb 100644
--- a/README.md
+++ b/README.md
@@ -79,6 +79,18 @@ npx hardhat run scripts/tron/updateProtocolFee.ts
|
+
+ Polygon Amoy |
+ Gateway Proxy |
+ 0xCAD53Ff499155Cc2fAA2082A85716322906886c2 |
+
+
+ Gateway Implementation |
+ 0xd2d97002ec87ba57fcf3f6b510f20d5a80a6c33a |
+
+
+ |
+
Arbitrum Sepolia |
Gateway Proxy |
@@ -86,7 +98,7 @@ npx hardhat run scripts/tron/updateProtocolFee.ts
Gateway Implementation |
- 0xD01abCEEeacfC91d2eCE31422DFe531004A7D2e6 |
+ 0xd2d97002Ec87ba57FCf3f6b510f20d5A80A6C33a |
|
@@ -98,7 +110,7 @@ npx hardhat run scripts/tron/updateProtocolFee.ts
Gateway Implementation |
- 0xfB411Cc6385Af50A562aFCb441864E9d541CDA67 |
+ 0xd2d97002Ec87ba57FCf3f6b510f20d5A80A6C33a |
|
@@ -185,7 +197,7 @@ npx hardhat run scripts/tron/updateProtocolFee.ts
Gateway Implementation |
- 0x647daC4807Eb82E67CE3bca930D6202190831B4a |
+ 0x8fd1f78d88dd008e557273b5cd517487c2a9a7de |
|
@@ -197,7 +209,7 @@ npx hardhat run scripts/tron/updateProtocolFee.ts
Gateway Implementation |
- 0x847dfdAa218F9137229CF8424378871A1DA8f625 |
+ 0xd2d97002Ec87ba57FCf3f6b510f20d5A80A6C33a |
Gateway Admin |
@@ -213,7 +225,7 @@ npx hardhat run scripts/tron/updateProtocolFee.ts
Gateway Implementation |
- 0x5E7eC39915F6CD48829d06648F6682765846602a |
+ 0xd2d97002ec87ba57fcf3f6b510f20d5a80a6c33a |
Gateway Admin |
diff --git a/scripts/config.ts b/scripts/config.ts
index 6c84bbe..b24cc96 100644
--- a/scripts/config.ts
+++ b/scripts/config.ts
@@ -48,7 +48,6 @@ const NETWORKS = {
},
TREASURY_FEE_PERCENT: 100, // in BPS i.e 0.1%
GATEWAY_CONTRACT: "0x1FA0EE7F9410F6fa49B7AD5Da72Cf01647090028",
- IMPERSONATE_ACCOUNT: "",
},
/**
@@ -154,10 +153,11 @@ const NETWORKS = {
* @dev Base Sepolia
*/
84532: {
+ GATEWAY_IMPLEMENTATION: "0xff0E00E0110C1FBb5315D276243497b66D3a4d8a",
RPC_URL: `https://rpc.shield3.com/v3/0x14a34/${SHIELD3_API_KEY}/rpc`,
SUPPORTED_TOKENS: {
USDC: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
- DAI: "0x7683022d84f726a96c4a6611cd31dbf5409c0ac9",
+ DAI: "0x7683022d84f726a96c4a6611cd31dbf5409c0ac9",
},
TREASURY_FEE_PERCENT: 100, // in BPS i.e 0.1%
GATEWAY_CONTRACT: "0x847dfdAa218F9137229CF8424378871A1DA8f625",
@@ -171,7 +171,7 @@ const NETWORKS = {
RPC_URL: `https://rpc.shield3.com/v3/0xaa36a7/${SHIELD3_API_KEY}/rpc`,
SUPPORTED_TOKENS: {
"6TEST": "0x3870419Ba2BBf0127060bCB37f69A1b1C090992B",
- DAI: "0x77Ab54631BfBAE40383c62044dC30B229c7df9f5",
+ DAI: "0x77Ab54631BfBAE40383c62044dC30B229c7df9f5",
},
TREASURY_FEE_PERCENT: 100, // in BPS i.e 0.1%
GATEWAY_CONTRACT: "0xCAD53Ff499155Cc2fAA2082A85716322906886c2",
diff --git a/scripts/deploy.ts b/scripts/deploy.ts
index 00f316d..93021b2 100644
--- a/scripts/deploy.ts
+++ b/scripts/deploy.ts
@@ -1,5 +1,5 @@
import { ethers, upgrades, network } from "hardhat";
-import { confirmContinue, assertEnvironment } from "./utils";
+import { confirmContinue, assertEnvironment, waitForInput, updateConfigFile } from "./utils";
import hre from "hardhat";
assertEnvironment();
@@ -19,10 +19,10 @@ async function deployGatewayProxy(): Promise {
console.log("✅ Deployed Gateway: ", tx.transactionHash);
- // const implementationAddress = await contract.implementation();
-
+ if (network.config.chainId !== undefined) {
+ await updateConfigFile(network.config.chainId, contract.address);
+ }
console.log(`Proxy Contract Address: ${contract.address}`);
- // console.log("Implementation Contract Address:", implementationAddress);
return tx;
}
@@ -46,16 +46,24 @@ async function deployGateway(): Promise {
address: contract.address,
});
+ if (network.config.chainId !== undefined) {
+ await updateConfigFile(network.config.chainId, contract.address);
+ }
+
console.log(`Proxy Contract Address: ${contract.address}`);
- // console.log("Implementation Contract Address:", implementationAddress);
return tx;
}
async function main() {
- // Deploy Gateway
- await deployGateway();
+ const response = await waitForInput("\nDo you want to deploy a new Gateway proxy? y\n");
+ const responseStr = response as string; // Cast response to string
+ if (responseStr.toLowerCase() !== "y") {
+ await deployGateway();
+ } else {
+ await deployGatewayProxy();
+ }
}
main().catch((error) => {
diff --git a/scripts/upgrade.ts b/scripts/upgrade.ts
index 46c004c..a057739 100644
--- a/scripts/upgrade.ts
+++ b/scripts/upgrade.ts
@@ -1,11 +1,11 @@
import { ethers, upgrades, network } from "hardhat";
import { NETWORKS } from "./config";
import hre from "hardhat";
-import { confirmContinue } from "./utils";
+import { confirmContinue, waitForInput } from "./utils";
const networkConfig = NETWORKS[network.config.chainId as keyof typeof NETWORKS];
-async function main() {
+async function upgradeProxy() {
await confirmContinue({
contract: "Gateway",
network: network.name,
@@ -40,6 +40,65 @@ async function main() {
}
}
+async function manualUpgrade() {
+ await confirmContinue({
+ contract: "Gateway",
+ network: network.name,
+ chainId: network.config.chainId,
+ });
+
+ try {
+
+ const [signer] = await ethers.getSigners(); // Get the signer (the account performing the upgrade)
+ const balance = await signer.getBalance(); // Get the balance of the signer's address
+
+ if (balance.eq(0)) {
+ throw new Error(`Can't upgrade ${network.config.chainId} with 0 balance`);
+ }
+ const proxyContractAddress = networkConfig.GATEWAY_CONTRACT;
+ const proxy = await ethers.getContractAt("TransparentUpgradeableProxy", proxyContractAddress);
+ // Get the proxy admin address
+ const proxyAdminAddress = await proxy.admin();
+ console.log(`Proxy Admin Address: ${proxyAdminAddress}`);
+
+ // Get the Proxy Admin contract
+ const proxyAdmin = await ethers.getContractAt("ProxyAdmin", proxyAdminAddress);
+
+ // Check if IMPLEMENTATION exists in networkConfig
+ if (!('IMPLEMENTATION' in networkConfig)) {
+ throw new Error(`No implementation address found for chainId: ${network.config.chainId}`);
+ }
+ // Fetch the new implementation address from deployment.json
+ const newImplementationAddress = networkConfig.IMPLEMENTATION;
+
+ if (!newImplementationAddress) {
+ throw new Error(`No implementation address found for chainId: ${network.config.chainId}`);
+ }
+
+ console.log(`Upgrading proxy to new implementation: ${newImplementationAddress}`);
+
+ // Call the upgrade function on the Proxy Admin contract
+ await proxyAdmin.upgrade(proxyContractAddress, newImplementationAddress);
+
+ console.log(`✅ Successfully upgraded proxy at ${proxyContractAddress} to new implementation at ${newImplementationAddress}`);
+ } catch (error) {
+ if (error instanceof Error) {
+ console.error("❌ Upgrade failed: ", error.message);
+ } else {
+ console.error("❌ Upgrade failed: Unknown error occurred");
+ }
+ }
+
+}
+
+async function main() {
+ const response = await waitForInput("\nDo you want to deploy and upgrade? y/N\n");
+ if (response !== "y") {
+ await manualUpgrade();
+ } else {
+ await upgradeProxy();
+ }
+}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
diff --git a/scripts/utils.ts b/scripts/utils.ts
index 67147b7..9b72ac4 100644
--- a/scripts/utils.ts
+++ b/scripts/utils.ts
@@ -2,6 +2,8 @@ import readline from "readline";
import dotenv from "dotenv";
import { artifacts, ethers, network } from "hardhat";
import { NETWORKS } from "./config";
+import { promises as fs } from 'fs';
+import * as path from 'path';
const TronWeb = require("tronweb");
dotenv.config();
@@ -86,6 +88,47 @@ export async function confirmContinue(params: any) {
}
+export async function updateConfigFile(chainId: number, implementationAddress: string): Promise {
+ try {
+ const configFilePath = path.join(__dirname, 'config.ts');
+ // Read the existing config file
+ let configContent = await fs.readFile(configFilePath, 'utf-8');
+
+ // Create a regex to match the network object for the specific chainId
+ const networkRegex = new RegExp(`(${chainId}:\\s*{[\\s\\S]*?)(},?)`, 'g');
+
+ if (networkRegex.test(configContent)) {
+ configContent = configContent.replace(networkRegex, (match) => {
+ const lines = match.split('\n');
+ const updatedLines = lines.map(line => {
+ if (line.trim().startsWith('GATEWAY_IMPLEMENTATION:')) {
+ return line.replace(/IMPLEMENTATION:.*/, `GATEWAY_IMPLEMENTATION: "${implementationAddress}",`);
+ }
+ return line;
+ });
+
+ if (!updatedLines.some(line => line.trim().startsWith('GATEWAY_IMPLEMENTATION:'))) {
+ // If IMPLEMENTATION doesn't exist, add it before the closing brace
+ updatedLines.splice(-1, 0, `\t\GATEWAY_IMPLEMENTATION: "${implementationAddress}",`);
+ }
+
+ return updatedLines.join('\n');
+ });
+ } else {
+ console.error(`Network configuration for chainId ${chainId} not found in config file.`);
+ return;
+ }
+
+ // Write the updated content back to the file
+ await fs.writeFile(configFilePath, configContent, 'utf-8');
+
+ console.log(`Updated config.ts with chainId: ${chainId} and implementation address: ${implementationAddress}`);
+ } catch (error) {
+ console.error('Error updating config file:', error);
+ }
+}
+
+
/**
* Retrieves the wallet and contract instances.
*