-
Notifications
You must be signed in to change notification settings - Fork 4
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
Bridge v3 #7
base: bridge-v2
Are you sure you want to change the base?
Bridge v3 #7
Changes from 7 commits
134623c
af35127
bc512ee
7b8db4a
a3de913
7fdf7b0
c1599c2
9d212bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
import DeployConfig from "./config"; | ||
|
||
const config: DeployConfig = { | ||
"xorAddress": "0x9826ecfcd937c4518e1c42b3703c7cb908b61197", | ||
"valAddress": "0x88ee18defc56d78417b0d331e794ef75799ca6d1", | ||
"sidechainAssets": [ | ||
], | ||
"erc20Addresses": [ | ||
], | ||
"peers": [ | ||
"0x981bccf6d8593dc49c22cf744a59afa5a2b23118", | ||
"0x90dca3c91c10e802093318123ad8bb8809061765", | ||
"0x457d710255184dbf63c019ab50f65743c6cb072f" | ||
] | ||
}; | ||
|
||
export default config; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ import { resolve } from "path"; | |
import "solidity-coverage" | ||
|
||
import * as gen_config from "./tasks/gen-config"; | ||
import * as send from "./tasks/send"; | ||
|
||
dotenv({ path: resolve(__dirname, ".env") }); | ||
|
||
|
@@ -57,6 +58,11 @@ const config: HardhatUserConfig = { | |
url: 'https://rpc.sepolia.org', | ||
accounts: [sepoliaPrivateKey], | ||
}, | ||
sepolia2: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? they are the same (sepolia and sepolia2) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To have deployment data for test and stage environment |
||
chainId: 11155111, | ||
url: 'https://rpc.sepolia.org', | ||
accounts: [sepoliaPrivateKey], | ||
}, | ||
mainnet: { | ||
chainId: 1, | ||
url: `https://mainnet.infura.io/v3/${infuraKey}`, | ||
|
@@ -87,7 +93,25 @@ const config: HardhatUserConfig = { | |
timeout: 60000 | ||
}, | ||
etherscan: { | ||
apiKey: etherscanKey | ||
apiKey: etherscanKey, | ||
customChains: [ | ||
{ | ||
network: "sepolia", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2 exactly the same chains |
||
chainId: 11155111, | ||
urls: { | ||
apiURL: "https://api-sepolia.etherscan.io/api", | ||
browserURL: "https://sepolia.etherscan.io" | ||
} | ||
}, | ||
{ | ||
network: "sepolia", | ||
chainId: 11155111, | ||
urls: { | ||
apiURL: "https://api-sepolia.etherscan.io/api", | ||
browserURL: "https://sepolia.etherscan.io" | ||
} | ||
} | ||
] | ||
} | ||
}; | ||
|
||
|
@@ -97,4 +121,9 @@ task("gen-config", "Generate config file for given network") | |
.addParam("peers") | ||
.addParam("output").setAction(gen_config.main); | ||
|
||
task("send", "Generate config file for given network") | ||
.addParam("to") | ||
.addParam("amount") | ||
.addParam("token", "Token address", undefined, undefined, true) | ||
.setAction(send.main); | ||
export default config; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||
import DeployConfig from "../deploy-data/config"; | ||
import { default as mainnetConfig } from "../deploy-data/mainnet" | ||
|
||
async function main() { | ||
const hh: HardhatRuntimeEnvironment = require("hardhat"); | ||
const config = mainnetConfig; | ||
const bridgeAddress = "0x6F984C337aD5b7C2084805042AE942cef462e3ff"; | ||
let tokenAddresses = config.sidechainAssets.map((val) => val.address); | ||
let assetIds = config.sidechainAssets.map((val) => val.asset_id); | ||
await hh.run("verify:verify", { | ||
address: bridgeAddress, | ||
constructorArguments: [ | ||
config.peers, | ||
tokenAddresses, assetIds, config.erc20Addresses, | ||
config.valAddress, config.xorAddress, | ||
'0x0000000000000000000000000000000000000000000000000000000000000000' | ||
], | ||
}); | ||
} | ||
|
||
main().then(() => process.exit(0)).catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||
import DeployConfig from "../deploy-data/config"; | ||
import * as sora from "@sora-substrate/util"; | ||
import abi from "../abis/BridgeOld.abi"; | ||
import { writeFile } from "fs/promises"; | ||
import "hardhat-deploy"; | ||
|
||
export async function main({ to, amount, token }) { | ||
const hh: HardhatRuntimeEnvironment = require("hardhat"); | ||
let [deployer] = await hh.getUnnamedAccounts(); | ||
let res; | ||
if (!token) { | ||
res = await hh.deployments.execute("Bridge", { from: deployer, log: true, value: amount }, "sendEthToSidechain", to); | ||
} else { | ||
res = await hh.deployments.execute("Bridge", { from: deployer, log: true }, "sendERC20ToSidechain", to, amount, token); | ||
} | ||
console.log(res); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Transition from encode to encodePacked is not that necessary but might be taken as it may only affect the order of the params for the statement we sign but not the signature itself
Just make sure that it works fine when passing params to recoverAddress, now it looks okay, but it will not be superfluous to double check it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's needed to prevent signature collision