Skip to content

Fix deploy.ts #40

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

Merged
merged 1 commit into from
Nov 19, 2021
Merged
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
20 changes: 20 additions & 0 deletions accounts.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{"account_id":0,"mnemonic":"ready relief cabbage liar nation leisure genuine wolf juice logic scale bridge drill word leader leader gossip shrug enough kangaroo knock educate merry secret","priv_key":"0x46e2acccb36d276fd357b2928c95210ada30e551a0e7791302d8e9735dc4a779","eth_addr":"0x452aC94C662F4Bc2b29f3689E38D8E45884b35ee"}
{"account_id":1,"mnemonic":"olympic comfort palm large heavy verb acid lion attract vast dash memory olympic syrup announce sure body cruise flip merge fabric frame question result","priv_key":"0x977e9bb2a7c13351c149b26784081882673741d8616c79feeb472b6378fed81d","eth_addr":"0x6286d0A2FC1d4C12a4ACc274018b401c68157Fdb"}
{"account_id":2,"mnemonic":"mixture latin cage defense recipe mention rather pledge fix sea casino start fluid final place exhibit enroll clarify salad mobile recipe ask buyer assume","priv_key":"0xa2ef80f6d150a3f7e64a4f2fe3193a84fed24f932f0e59a50f990ece39679135","eth_addr":"0xf40e08F651f2f7f96f5602114E5A77F1A7BEeA5d"}
{"account_id":3,"mnemonic":"zone steel market aunt chimney galaxy imitate sibling divide sister until front tail blush source maze equal globe include weather any reason fault awful","priv_key":"0x4434f4547080599945b6b171739e754f7a5ae93855ba933b991c4e7b3ef57339","eth_addr":"0xeD94298D30812327f22fA01cA9fAABAead2440Af"}
{"account_id":4,"mnemonic":"also sausage kite amused mercy joke genius pioneer trash woman blush never afraid trim laptop maid bike museum reform spring pretty brand retreat shaft","priv_key":"0x940cdded1e7c8a2284c68fe75586564e956144dbb7cf0ee198ad120bbf997168","eth_addr":"0xc79030AFa00571BdA193846ff5B1F10bC1cf9a1E"}
{"account_id":5,"mnemonic":"space boy neck venue govern flag prefer busy convince uncle gold figure chief degree park hand dose vintage tide scare exotic distance february wash","priv_key":"0x160276a92fce4c44039c24471f4c3ca7cacab358094ecd1b4863897eb2bcdba7","eth_addr":"0xec9C8B21a9f8e5Eb22373eDf7D0860Df0b98EBa5"}
{"account_id":6,"mnemonic":"mention notable lady spin meadow fiber rare member comic drastic dwarf phone prevent dizzy lesson noise post butter pilot case virus animal entire safe","priv_key":"0xd33e3c7db96471ad4b3a34504a43cbed773dc5a6a21bd5acdcac7cba5aa06cce","eth_addr":"0x92f9a57b427Ee5D7599D12CeBae3f3F4f89C7392"}
{"account_id":7,"mnemonic":"boost route aisle brother disorder squeeze tuna bridge purchase aunt acid liberty pen topple end lunch suffer favorite wear essence donkey scatter unaware taste","priv_key":"0x81946fe3c8c92e3f8b3b15ded2ec94bd227493c81240a773d2866d46ba34d79d","eth_addr":"0xB0660beF4DBF9e28eB422D46F3844CB41cc24717"}
{"account_id":8,"mnemonic":"embark music govern stick clarify settle tent adapt dragon rubber keep few fashion casino eagle text denial mule survey fitness wonder wonder basic upset","priv_key":"0xce1489b4675348244d15e0369f7a848befb1257f6d51196d9e9d9b1209c19a7e","eth_addr":"0x94c8C37116Df235bF56A3F9C4cbdd1b6a43F3af0"}
{"account_id":9,"mnemonic":"bread regret similar crack hero exercise day then corn verify vocal refuse spy endless second split canoe horse slice trip soccer bench sausage candy","priv_key":"0xbc66c297a75dba2e94790145fbc11b8aca5506ee6189f4733f50d8435a96e4e1","eth_addr":"0x3705EE1c0BcaEBd05c1FC971A2e3931a8D1BE77A"}
{"account_id":10,"mnemonic":"artefact wood town zoo tiny isolate typical salad always choice mesh tool explain sign fence ghost peasant dragon rebel chef payment must real sadness","priv_key":"0x005c149d49d661b95c4e5ba042cdd8b8e9e5593842c3d317a2f46568b3afcf02","eth_addr":"0xe9206889b78E5b339853a1F08bE7E5295aAf9Db3"}
{"account_id":11,"mnemonic":"whisper mountain upset upper tragic elegant grace veteran increase indoor copy teach antenna glue gauge fury concert cream swear clay fetch safe van hawk","priv_key":"0x709efe9f80cb5196cb0485c52b4df52d3467e03e1b1a1efd6d0c29d38b5fad95","eth_addr":"0x550df4b307884A751a6c60947126D3EB3D36D476"}
{"account_id":12,"mnemonic":"worth program ostrich fame one track shoot eternal grunt transfer broccoli oval legal more member tenant cheap barrel idea tuna live kit detail husband","priv_key":"0x262ac634a06fe4bdf28093d9cd330efa661f0e323663923ab5464f66d127156f","eth_addr":"0xfD2F21Af21bd9901A55F95f53911F99B0f4d961D"}
{"account_id":13,"mnemonic":"degree cabin section turtle history aspect credit subway vicious erase tip meadow remove salute fine welcome drum share speed era patrol stock right vicious","priv_key":"0x6477d1fbdc97591c2d2c54541ae3a09dd1b19ad20921c91c5ddcfbc0f53c9b8d","eth_addr":"0x9ddB77695AB6F5289f71889F8A1FcfF3Bb881769"}
{"account_id":14,"mnemonic":"tiger base process wealth depend suggest horse above expose forget oak basic leave hope curious stuff engine praise moon road endless arch mesh interest","priv_key":"0x4e0c4cebc1456ef8cf20d93edc757c6d3c973cee924582b1580d698dcecc06dc","eth_addr":"0x616B71Cbcd8006F577673960700CB1811C2C4775"}
{"account_id":15,"mnemonic":"verb anchor host hand actor pull patrol wear gossip enough bamboo horn cycle festival picture unfair target vault reduce eyebrow miss lucky orange guide","priv_key":"0x7105836e5d903f273075ab50429c36c08afb0b786986c3612b522bf59bcecc20","eth_addr":"0xfD4f6976e084CbBC8Dee5956B09bF32f94786eb9"}
{"account_id":16,"mnemonic":"sound select report rug run cave provide index grief foster bar someone garage donate nominee crew once oil sausage flight tail holiday style afford","priv_key":"0xcd73077a9bb493ada626df70a3ebcd6a4df420be1870524b7ae4176596884aba","eth_addr":"0x7e99AE2709D761FBc3B3a23e0c0874Ba4aBBF229"}
{"account_id":17,"mnemonic":"extra glove demise parade space april fashion mixture section barrel prize emerge flip sight pride swift beyond fresh check never scene ring anchor hazard","priv_key":"0x4976112050d262bfa62f56a12892590eb912f78c9b6a2df5098070940c72288e","eth_addr":"0x63C8C465dC4bb57723b2EC78Cb2aD50a2C804b1a"}
{"account_id":18,"mnemonic":"camp awful sand include refuse cash reveal mystery pupil salad length plunge square admit vocal draft found side same clock hurt length say figure","priv_key":"0x8d3aa186bd7ff3a72dd7f7367b4f893dc7758c5154596a9b2a7b1c10bf8750b7","eth_addr":"0x09C4Ad711EfB0B9c4D3D9133b56c5Ab6DD1B4CD0"}
{"account_id":19,"mnemonic":"chat cabin first fit zero avoid engine screen guitar young wool later occur element enroll amount brush melody seminar believe gossip alpha pool inch","priv_key":"0x5ee6b5badcda025167c8bccb0044d0df416dbae910b8bea5726145de3e9cf3ad","eth_addr":"0xd889eec15E43E9FfD49ae05fC131a8B374D3BDEb"}
3 changes: 2 additions & 1 deletion contracts/FluiDex.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ contract FluiDexDemo is
_setRoleAdmin(DELEGATE_ROLE, DEFAULT_ADMIN_ROLE);
grantRole(TOKEN_ADMIN_ROLE, msg.sender);
grantRole(PLUGIN_ADMIN_ROLE, msg.sender);
grantRole(DELEGATE_ROLE, msg.sender);
}

/**
Expand Down Expand Up @@ -147,7 +148,7 @@ contract FluiDexDemo is
* @param ethAddr the L1 address
* @param bjjPubkey the L2 address (bjjPubkey)
*/
function registerUser(address ethAddr, bytes32 bjjPubkey) internal {
function registerUser(address ethAddr, bytes32 bjjPubkey) public {
require(userBjjPubkeyToUserId[bjjPubkey] == 0, "user existed");
userNum++;
require(userNum < USER_NUM_LIMIT, "user num limit reached");
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"chai": "^4.2.0",
"ethereum-waffle": "^3.2.1",
"ethers": "^5.0.24",
"fluidex.js": "git+https://github.com/fluidex/fluidex.js.git#b9224719013c224445fe8ec06f6a05e800b4469e",
"hardhat": "^2.0.6",
"prettier": "^2.2.1",
"prettier-plugin-solidity": "^1.0.0-beta.2",
Expand Down
6 changes: 6 additions & 0 deletions scripts/accounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let accounts = require("fs").readFileSync("./accounts.jsonl", "utf-8").split("\n").filter(Boolean).map(JSON.parse);

export function getTestAccount(id: number) {
let a = accounts[id];
return a;
}
25 changes: 21 additions & 4 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { Account } from "fluidex.js";
import { run, ethers } from "hardhat";
import * as hre from "hardhat";
import { default as tokens} from "../tokens";
import { getTestAccount } from "./accounts";

const loadAccounts = () => Array.from(botsIds).map((user_id) => Account.fromMnemonic(getTestAccount(user_id).mnemonic));
const botsIds = [1, 2, 3, 4, 5];
const accounts = loadAccounts();

async function main() {
await run('compile');
Expand All @@ -16,17 +22,28 @@ async function main() {
const fluiDex = await fluidexFactory.deploy(genesisRoot, verifier.address);
await fluiDex.deployed();
console.log("FluiDex deployed to:", fluiDex.address);
const addToken = fluiDex.functions.addToken;
for (const {name, address} of Array.from(tokens)) {
await addToken(address);
console.log(`add ${name} token at`, address);

const registerUser = fluiDex.functions.registerUser;
for(const account of accounts) {
await registerUser(account.ethAddr, account.bjjPubKey);
console.log(`register user ${account.bjjPubKey}`);
}

const fluiDexDelegateFactory = await ethers.getContractFactory("FluiDexDelegate");
const fluiDexDelegate = await fluiDexDelegateFactory.deploy(fluiDex.address);
await fluiDexDelegate.deployed();
console.log("FluiDexDelegate deployed to:", fluiDexDelegate.address);

const DELEGATE_ROLE = await fluiDex.callStatic.DELEGATE_ROLE();
await fluiDex.functions.grantRole(DELEGATE_ROLE, fluiDexDelegate.address);
console.log("grant DELEGATE_ROLE to FluiDexDelegate");

const addToken = fluiDexDelegate.functions.addToken;
for (const {name, address} of Array.from(tokens)) {
await addToken(address);
console.log(`add ${name} token at`, address);
}

// skip verify on localhost
if (hre.network.name !== "localhost") {
await run('verify', {
Expand Down
Loading