Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero network support #153

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ typechain-types/
dist/

.vscode/
lcov.info
lcov.info

artifacts-zk/
cache_hardhat-zk/
deployments-zk/
16 changes: 16 additions & 0 deletions deployments/superbridge/surge_zero-testnet_verification.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"4457845": [
[
"0xfeD826A38A4Caa3f7946e313689d3EEB71663e31",
"Controller",
"contracts/bridge/Controller.sol",
["0x90B667E7B071a611935C038f14cf57fdF2c9B313"]
],
[
null,
"Controller",
"contracts/bridge/Controller.sol",
["0x90B667E7B071a611935C038f14cf57fdF2c9B313"]
]
]
}
15 changes: 13 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-etherscan";
// import "@nomiclabs/hardhat-etherscan";
import "@typechain/hardhat";
import "hardhat-preprocessor";
import "hardhat-deploy";
import "hardhat-abi-exporter";
import "hardhat-change-network";

import "@nomicfoundation/hardhat-foundry";

import { config as dotenvConfig } from "dotenv";
import type { HardhatUserConfig } from "hardhat/config";
import "@matterlabs/hardhat-zksync";
import type {
HardhatNetworkAccountUserConfig,
NetworkUserConfig,
Expand Down Expand Up @@ -209,6 +209,13 @@ const config: HardhatUserConfig = {
chainId: ChainSlugToId[hardhatChainNameToSlug.hardhat],
},
...hardhatNetworkDetails,
zeroTestnet: {
url: "https://rpc.zerion.io/v1/zero-sepolia",
zksync: true,
ethNetwork: "sepolia",
verifyURL:
"https://api-explorer.zero.network/contract/contract_verification",
},
},
paths: {
sources: "./contracts",
Expand All @@ -231,6 +238,10 @@ const config: HardhatUserConfig = {
},
}),
},
zksolc: {
version: "latest", // Uses latest available in https://github.com/matter-labs/zksolc-bin
settings: {},
},
solidity: {
version: "0.8.13",
settings: {
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"repository": "[email protected]:SocketDotTech/socketDL-examples.git",
"devDependencies": {
"@ethersproject/bytes": "^5.7.0",
"@matterlabs/hardhat-zksync": "^1.2.0",
"@nomicfoundation/hardhat-foundry": "^1.1.2",
"@nomiclabs/hardhat-ethers": "^2.1.1",
"@nomiclabs/hardhat-etherscan": "^3.1.0",
Expand All @@ -27,7 +28,7 @@
"@types/yargs": "^17.0.22",
"dotenv": "^16.0.3",
"ethers": "^5.6.6",
"hardhat": "^2.17.2",
"hardhat": "^2.22.7",
"hardhat-abi-exporter": "^2.10.1",
"hardhat-change-network": "^0.0.7",
"hardhat-deploy": "^0.11.20",
Expand Down Expand Up @@ -66,6 +67,7 @@
"@eth-optimism/sdk": "^3.3.2",
"@socket.tech/dl-core": "^2.28.0",
"lodash": "^4.17.21",
"prompts": "^2.4.2"
"prompts": "^2.4.2",
"zksync-ethers": "5"
}
}
23 changes: 23 additions & 0 deletions script/constants/projectConstants/superbridge/zero-testnet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {
ChainSlug,
DeploymentMode,
IntegrationTypes,
} from "@socket.tech/dl-core";
import { Hooks, ProjectConstants } from "../../../../src";
import { Tokens } from "../../../../src/enums";

// For testnet deployments, ChainSlug enum may not have some chains, therefore some keys will look like {421614:{}} instead of {[ChainSlug.ARBITRUM_SEPOLIA]:{}}. This wont affect the functionality of the project.
export const pc: ProjectConstants = {
[DeploymentMode.SURGE]: {
[Tokens.USDC]: {
vaultChains: [ChainSlug.ARBITRUM_SEPOLIA],
controllerChains: [4457845],
tokenAddresses: {
4457845: "0x90B667E7B071a611935C038f14cf57fdF2c9B313",
},
hook: {
hookType: Hooks.NO_HOOK,
},
},
},
};
57 changes: 46 additions & 11 deletions script/helpers/deployUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { Contract, ContractFactory, Wallet } from "ethers";
import { ethers, network, run } from "hardhat";
import * as hre from "hardhat";
import { Deployer } from "@matterlabs/hardhat-zksync";
import "@matterlabs/hardhat-zksync-node/dist/type-extensions";
import {
Wallet as zkWallet,
Provider,
} from "@matterlabs/hardhat-zksync/node_modules/zksync-ethers";

import { ChainSlug, IntegrationTypes } from "@socket.tech/dl-core";
import socketABI from "@socket.tech/dl-core/artifacts/abi/Socket.json";
Expand Down Expand Up @@ -150,17 +157,45 @@ export async function deployContractWithArgs(
);
} else {
try {
const Contract: ContractFactory = await ethers.getContractFactory(
contractName
);
const contract: Contract = await Contract.connect(signer).deploy(
...args,
{
...getOverrides(chainSlug),
}
);
await contract.deployed();
return contract;
if (chainSlug === (4457845 as ChainSlug)) {
console.log(process.env.ZKSYNC_RPC_URL);
const provider = new Provider(process.env.ZKSYNC_RPC_URL!);
console.log(provider, process.env.OWNER_SIGNER_KEY);
let wallet = new zkWallet(process.env.OWNER_SIGNER_KEY, provider);
const deployer = new Deployer(hre, wallet);
const artifact = await deployer
.loadArtifact(contractName)
.catch((error) => {
if (
error?.message?.includes(
`Artifact for contract "${contractName}" not found.`
)
) {
console.error(error.message);
throw `⛔️ Please make sure you have compiled your contracts or specified the correct contract name!`;
} else {
throw error;
}
});
const contract = await deployer.deploy(artifact, args);
const address = await contract.getAddress();

console.log(contract);
// contract.address = address;
return { address };
} else {
const Contract: ContractFactory = await ethers.getContractFactory(
contractName
);
const contract: Contract = await Contract.connect(signer).deploy(
...args,
{
...getOverrides(chainSlug),
}
);
await contract.deployed();
return contract;
}
} catch (error) {
throw error;
}
Expand Down
4 changes: 4 additions & 0 deletions script/helpers/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ export function getJsonRpcUrl(chain: ChainSlug): string {
export const getProviderFromChainSlug = (
chainSlug: ChainSlug
): ethers.providers.StaticJsonRpcProvider => {
if (chainSlug == (4457845 as ChainSlug))
return new ethers.providers.JsonRpcProvider(
"https://rpc.zerion.io/v1/zero-sepolia"
);
const jsonRpcUrl = getJsonRpcUrl(chainSlug);
return new ethers.providers.StaticJsonRpcProvider(jsonRpcUrl);
};
Expand Down
2 changes: 1 addition & 1 deletion socket-plugs-details.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,4 @@
"MAGIC",
"SUSDE"
]
}
}
1 change: 1 addition & 0 deletions src/enums/projectType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ export const ProjectTypeMap: Record<Project, ProjectType> = {
[Project.TESTING_TESTNET]: ProjectType.SUPERTOKEN,
[Project.MAGIC_MAINNET]: ProjectType.SUPERTOKEN,
[Project.POLTER_TESTNET]: ProjectType.SUPERBRIDGE,
[Project.ZERO_TESTNET]: ProjectType.SUPERBRIDGE,
};
1 change: 1 addition & 0 deletions src/enums/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export enum Project {
TESTING_TESTNET = "testing_testnet",
MAGIC_MAINNET = "magic_mainnet",
POLTER_TESTNET = "polter_testnet",
ZERO_TESTNET = "zero-testnet",
}
Loading