forked from matter-labs/zksync
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
a459c3e
commit 0617794
Showing
28 changed files
with
162 additions
and
253 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
/build | ||
# /contracts/keys | ||
/contracts/KeysWithPlonkVerifier.sol | ||
/contracts/TokenInit.sol | ||
/artifacts | ||
/cache | ||
/contracts/dev-contracts/generated | ||
/typechain |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
|
||
pragma solidity ^0.7.0; | ||
|
||
contract TokenDeployInit { | ||
function getTokens() internal pure returns (address[] memory) { | ||
address[] memory tokens = new address[](0); | ||
return tokens; | ||
} | ||
} |
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,38 @@ | ||
import '@nomiclabs/hardhat-waffle'; | ||
import '@nomiclabs/hardhat-solpp'; | ||
import '@nomiclabs/hardhat-etherscan'; | ||
import 'hardhat-contract-sizer'; | ||
import { loadDefs } from './hardhat.utils'; | ||
|
||
export default { | ||
defaultNetwork: 'env', | ||
solidity: { | ||
version: '0.7.3', | ||
settings: { | ||
optimizer: { | ||
enabled: true, | ||
runs: 200 | ||
} | ||
} | ||
}, | ||
contractSizer: { | ||
runOnCompile: false | ||
}, | ||
paths: { | ||
sources: './contracts', | ||
cache: './cache/test-contracts', | ||
artifacts: './artifacts/test-contracts' | ||
}, | ||
solpp: { | ||
defs: loadDefs('test') | ||
}, | ||
networks: { | ||
env: { | ||
url: `${process.env.WEB3_URL}`, | ||
allowUnlimitedContractSize: true | ||
} | ||
}, | ||
etherscan: { | ||
apiKey: process.env.ETHERSCAN_API_KEY | ||
} | ||
}; |
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,15 @@ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
|
||
export type Network = 'localhost' | 'mainnet' | 'ropsten' | 'rinkeby' | 'test'; | ||
|
||
export function loadDefs(network: Network) { | ||
try { | ||
const configPath = path.join(process.env.ZKSYNC_HOME, `etc/contracts`); | ||
|
||
return JSON.parse(fs.readFileSync(`${configPath}/${network}.json`, { encoding: 'utf-8' })); | ||
} catch (err) { | ||
console.warn('Invalid Configuration file'); | ||
return; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,39 +1,54 @@ | ||
import { ArgumentParser } from 'argparse'; | ||
import { Command } from 'commander'; | ||
import { BigNumber, Wallet, ethers } from 'ethers'; | ||
import { Deployer } from '../src.ts/deploy'; | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
|
||
const provider = new ethers.providers.JsonRpcProvider(process.env.WEB3_URL); | ||
const testConfigPath = path.join(process.env.ZKSYNC_HOME as string, `etc/test_config/constant`); | ||
const ethTestConfig = JSON.parse(fs.readFileSync(`${testConfigPath}/eth.json`, { encoding: 'utf-8' })); | ||
const deployer = new Deployer({ deployWallet: ethers.Wallet.createRandom() }); | ||
const provider = new ethers.providers.JsonRpcProvider(process.env.WEB3_URL); | ||
const governorWallet = Wallet.fromMnemonic(ethTestConfig.mnemonic, "m/44'/60'/0'/0/1").connect(provider); | ||
|
||
async function main() { | ||
const parser = new ArgumentParser({ | ||
version: '0.1.0', | ||
addHelp: true, | ||
description: 'Add erc20 token to the governance' | ||
}); | ||
|
||
parser.addArgument('--tokenAddress', { required: true, help: 'Address erc20 token' }); | ||
parser.addArgument('--deployerPrivateKey', { required: false, help: 'Wallet used to deploy contracts' }); | ||
|
||
const args = parser.parseArgs(process.argv.slice(2)); | ||
|
||
const deployer = new Deployer({ deployWallet: ethers.Wallet.createRandom() }); | ||
|
||
const governorWallet = args.deployerPrivateKey | ||
? new Wallet(args.deployerPrivateKey, provider) | ||
: Wallet.fromMnemonic(ethTestConfig.MNEMONIC, "m/44'/60'/0'/0/1").connect(provider); | ||
|
||
console.log('Adding new ERC20 token to network: ', args.tokenAddress); | ||
async function governanceAddToken(address: string) { | ||
console.log('Adding new ERC20 token to network: ', address); | ||
|
||
const tx = await deployer | ||
.governanceContract(governorWallet) | ||
.addToken(args.tokenAddress, { gasLimit: BigNumber.from('1000000') }); | ||
.addToken(address, { gasLimit: BigNumber.from('1000000') }); | ||
console.log('tx hash: ', tx.hash); | ||
const receipt = await tx.wait(); | ||
console.log('status: ', receipt.status); | ||
|
||
if (receipt.status) { | ||
console.log('tx success'); | ||
} else { | ||
throw new Error(`failed add token to the governance`); | ||
} | ||
} | ||
|
||
async function main() { | ||
const program = new Command(); | ||
|
||
program.version('0.1.0').name('governance-add-erc20').description('add testnet erc20 token to the governance'); | ||
|
||
program | ||
.command('add') | ||
.option('-a, --address <address>') | ||
.description('Adds a new token with a given address') | ||
.action(async (address: string) => { | ||
await governanceAddToken(address); | ||
}); | ||
|
||
program | ||
.command('add-multi <tokens_json>') | ||
.description('Adds a multiple tokens given in JSON format') | ||
.action(async (tokens_json: string) => { | ||
const tokens: Array<string> = JSON.parse(tokens_json); | ||
|
||
for (const token of tokens) { | ||
await governanceAddToken(token); | ||
} | ||
}); | ||
} | ||
|
||
main(); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.