-
Notifications
You must be signed in to change notification settings - Fork 3
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
12 changed files
with
352 additions
and
30 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const fs = require("fs"); | ||
var Configure = require("./configure/readconfig.js"); | ||
var Create2 = require("./api/create2.js"); | ||
|
||
const privateKey = process.env.PRIKEY | ||
|
||
function wallet(url) { | ||
const provider = new ethers.providers.JsonRpcProvider(url); | ||
const wallet = new ethers.Wallet(privateKey, provider); | ||
return wallet; | ||
} | ||
|
||
async function deployCreate2Deployer(networkUrl, version) { | ||
const w = wallet(networkUrl); | ||
const salt = ethers.utils.hexZeroPad(ethers.utils.hexlify(ethers.utils.toUtf8Bytes(version)), 32); | ||
const create2Contract = await ethers.getContractFactory("Create2Deployer", w); | ||
const bytecode = Create2.getDeployedBytecode(create2Contract, [], []); | ||
const unsignedTransaction = { | ||
from: w.address, | ||
to: "0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7", | ||
data: `${salt}${bytecode.slice(2)}`, | ||
gasLimit: 2000000, | ||
//gasPrice: 2100000000, | ||
//nonce: 0, | ||
}; | ||
const tx = await w.sendTransaction(unsignedTransaction); | ||
console.log(`deploy create2 tx: ${tx.hash}, salt: ${salt}`); | ||
return; | ||
} | ||
|
||
// 2. deploy mapping token factory | ||
async function main() { | ||
const chainInfo = Configure.chain('product'); | ||
const network = chainInfo['astar']; | ||
|
||
await deployCreate2Deployer(network.url, 'v1.0.0'); | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
var Create2 = require("./api/create2.js"); | ||
var Configure = require("./configure/readconfig.js"); | ||
var GuardV3Bytecode = require("./bytecode/GuardV3.js"); | ||
|
||
const privateKey = process.env.PRIKEY | ||
|
||
function wallet(network) { | ||
const provider = new ethers.providers.JsonRpcProvider(network.url); | ||
const wallet = new ethers.Wallet(privateKey, provider); | ||
return wallet; | ||
} | ||
|
||
async function deployGuardV3(wallet, deployerAddress, salt) { | ||
const guardContract = await ethers.getContractFactory("GuardV3", wallet); | ||
//const bytecode = Create2.getDeployedBytecode( | ||
//guardContract, | ||
//['address[]','address','uint256','uint256'], | ||
//[['0x3B9E571AdeCB0c277486036D6097E9C2CCcfa9d9'],wallet.address,1,259200]); | ||
const bytecode = GuardV3Bytecode; | ||
const address = await Create2.deploy(deployerAddress, wallet, bytecode, salt, 8000000); | ||
console.log("finish to deploy guard contract, address: ", address); | ||
return address; | ||
} | ||
|
||
// 2. deploy mapping token factory | ||
async function main() { | ||
const chainInfo = Configure.chain('product'); | ||
const network = chainInfo['crab-dvm']; | ||
const w = wallet(network); | ||
|
||
await deployGuardV3(w, network.deployer, "guardv3-v1.0.0"); | ||
} | ||
|
||
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
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
Oops, something went wrong.