-
Notifications
You must be signed in to change notification settings - Fork 5
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
Dev mode for zkopru client package #40
Open
sifnoc
wants to merge
8
commits into
zkopru-network:develop
Choose a base branch
from
sifnoc:feat/setup-localdev
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b67feca
feat: add script and package files for @zkopru/client in local
sifnoc d920bf4
fix: reinstall for applying local zkopru
sifnoc 1f03a65
fix: install command and remove shx package no longer need
sifnoc a70cbfd
feat: add environment variable using dotenv-webpack
sifnoc c5a8320
chore: updating docs and remove comments
sifnoc 08663af
feat: add more explanation for development
sifnoc 2b24b7d
chore: small fix typo
sifnoc c1ca899
fix: missing submodule part
sifnoc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
WEBSOCKET=ws://127.0.0.1:8545 | ||
ZKOPRU_ADDRESS=0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE | ||
CHAINID=31337 |
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 |
---|---|---|
|
@@ -13,3 +13,6 @@ wrangler.toml | |
workers-site | ||
|
||
.vercel | ||
|
||
# dev module | ||
zkopru |
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,67 @@ | ||
{ | ||
"name": "zkopru-webapp", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "NODE_ENV=development node server.js", | ||
"dev": "webpack-dev-server", | ||
"buildnum": "node scripts/buildversion", | ||
"build": "webpack --config webpack.prod.js --progress", | ||
"clean": "rm -rf build", | ||
"server": "node server", | ||
"ipfs": "npm run clean && npm run build && node scripts/ipfsify.js", | ||
"stats": " webpack --profile --json > stats.json", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "Chance Hudson", | ||
"license": "MIT", | ||
"dependencies": { | ||
"axios": "^0.20.0", | ||
"compression": "^1.7.4", | ||
"dayjs": "^1.10.6", | ||
"especial": "0.0.4", | ||
"eth-ens-namehash": "^2.0.8", | ||
"express": "^4.17.1", | ||
"js-sha512": "^0.8.0", | ||
"lottie-web": "^5.8.1", | ||
"route-cache": "^0.4.5", | ||
"vue": "^2.6.12", | ||
"vue-class-component": "^7.2.5", | ||
"vue-meta": "^2.4.0", | ||
"vue-router": "^3.4.9", | ||
"vuex": "^3.5.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.11.6", | ||
"@babel/plugin-proposal-class-properties": "^7.10.4", | ||
"@babel/plugin-proposal-decorators": "^7.10.5", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5", | ||
"@babel/plugin-proposal-optional-chaining": "^7.14.5", | ||
"@babel/plugin-syntax-dynamic-import": "^7.8.3", | ||
"@zkopru/client": "file:./zkopru/packages/client", | ||
"babel-loader": "^8.1.0", | ||
"chokidar": "^3.4.2", | ||
"cidbadge": "^0.0.7", | ||
"css-loader": "^3.2.0", | ||
"dotenv-webpack": "^8.0.1", | ||
"file-loader": "^6.1.0", | ||
"has-tostringtag": "^1.0.0", | ||
"html-webpack-inline-source-plugin": "0.0.10", | ||
"html-webpack-plugin": "^4.4.1", | ||
"husky": "^6.0.0", | ||
"ipfs-unixfs-importer": "^9.0.6", | ||
"memory-fs": "^0.5.0", | ||
"svgo-loader": "^3.0.0", | ||
"vue-loader": "^15.9.3", | ||
"vue-server-renderer": "^2.6.12", | ||
"vue-style-loader": "^4.1.2", | ||
"vue-template-compiler": "^2.6.12", | ||
"webpack": "^4.44.1", | ||
"webpack-cli": "^3.3.12", | ||
"webpack-dev-server": "^3.11.0", | ||
"webpack-hot-middleware": "^2.25.0", | ||
"webpack-merge": "^5.1.4", | ||
"webpack-node-externals": "^2.5.2" | ||
} | ||
} |
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,69 @@ | ||
{ | ||
"name": "zkopru-webapp", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"install-dev": "npm install --no-package-lock --no-save shelljs && node scripts/setupLocaldev.js && npm install", | ||
"start": "NODE_ENV=development node server.js", | ||
"dev": "webpack-dev-server", | ||
"buildnum": "node scripts/buildversion", | ||
"build": "webpack --config webpack.prod.js --progress", | ||
"build:dev": "webpack --progress", | ||
"clean": "rm -rf build", | ||
"server": "node server", | ||
"ipfs": "npm run clean && npm run build && node scripts/ipfsify.js", | ||
"stats": " webpack --profile --json > stats.json", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "Chance Hudson", | ||
"license": "MIT", | ||
"dependencies": { | ||
"axios": "^0.20.0", | ||
"compression": "^1.7.4", | ||
"dayjs": "^1.10.6", | ||
"especial": "0.0.4", | ||
"eth-ens-namehash": "^2.0.8", | ||
"express": "^4.17.1", | ||
"js-sha512": "^0.8.0", | ||
"lottie-web": "^5.8.1", | ||
"route-cache": "^0.4.5", | ||
"vue": "^2.6.12", | ||
"vue-class-component": "^7.2.5", | ||
"vue-meta": "^2.4.0", | ||
"vue-router": "^3.4.9", | ||
"vuex": "^3.5.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.11.6", | ||
"@babel/plugin-proposal-class-properties": "^7.10.4", | ||
"@babel/plugin-proposal-decorators": "^7.10.5", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5", | ||
"@babel/plugin-proposal-optional-chaining": "^7.14.5", | ||
"@babel/plugin-syntax-dynamic-import": "^7.8.3", | ||
"@zkopru/client": "^2.0.0-beta.5", | ||
"babel-loader": "^8.1.0", | ||
"chokidar": "^3.4.2", | ||
"cidbadge": "^0.0.7", | ||
"css-loader": "^3.2.0", | ||
"dotenv-webpack": "^8.0.1", | ||
"file-loader": "^6.1.0", | ||
"has-tostringtag": "^1.0.0", | ||
"html-webpack-inline-source-plugin": "0.0.10", | ||
"html-webpack-plugin": "^4.4.1", | ||
"husky": "^6.0.0", | ||
"ipfs-unixfs-importer": "^9.0.6", | ||
"memory-fs": "^0.5.0", | ||
"svgo-loader": "^3.0.0", | ||
"vue-loader": "^15.9.3", | ||
"vue-server-renderer": "^2.6.12", | ||
"vue-style-loader": "^4.1.2", | ||
"vue-template-compiler": "^2.6.12", | ||
"webpack": "^4.44.1", | ||
"webpack-cli": "^3.3.12", | ||
"webpack-dev-server": "^3.11.0", | ||
"webpack-hot-middleware": "^2.25.0", | ||
"webpack-merge": "^5.1.4", | ||
"webpack-node-externals": "^2.5.2" | ||
} | ||
} |
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,18 @@ | ||
// import shell from 'shelljs'; | ||
var shell = require('shelljs'); | ||
|
||
if (!shell.which('git')) { | ||
shell.echo('Sorry, this script requires git'); | ||
shell.exit(1); | ||
} | ||
|
||
// clone zkopru repo for `@zkopru/client` package | ||
shell.echo(`Clone and build zkopru`) | ||
shell.exec(`git submodule update --init`); | ||
shell.cd(`zkopru`); | ||
shell.exec(`yarn && yarn build:ts:serial`); | ||
shell.cd(`..`); | ||
|
||
// copy package file which is replaced local path | ||
shell.echo(`Override package.json for using client package in local`); | ||
shell.cp(`-f`, `package-dev.json`, `package.json`); |
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,5 +1,4 @@ | ||
import { fromWei } from '../utils/wei' | ||
import dayjs from 'dayjs' | ||
import BN from 'bn.js' | ||
|
||
const DEFAULT_NETWORKS = { | ||
|
@@ -21,22 +20,26 @@ const DEFAULT_NETWORKS = { | |
blockExplorerUrls: ['https://goerli.etherscan.io'] | ||
} | ||
}, | ||
'69': { | ||
NAME: 'Optimism testnet', | ||
WEBSOCKET: 'wss://optimism-kovan.zkopru.network', | ||
} | ||
|
||
if (process.env.NODE_ENV == "development") { | ||
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 not keep the config for testnet? If we changed to this, we can only support local dev env only. |
||
let chainId = '0x7A69' // 31337 | ||
if (process.env.CHAINID) chainId = `0x${parseInt(process.env.CHAINID).toString(16)}` | ||
|
||
DEFAULT_NETWORKS[process.env.CHAINID ?? '31337'] = { | ||
NAME: 'hardhat node', | ||
WEBSOCKET: process.env.WEBSOCKET ?? 'ws://localhost:8546', | ||
ZKOPRU_ADDRESSES: [ | ||
'0x31f3E51Fc7BE2BD24F258af92B0E371fa0A48762' // minimum stake amount 1 ETH | ||
process.env.ZKOPRU_ADDRESS ?? '0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE' // | ||
], | ||
METAMASK_PARAMS: { | ||
chainId: '0x45', | ||
chainName: 'Optimism-kovan', | ||
chainId, | ||
chainName: 'testnet', | ||
nativeCurrency: { | ||
name: 'Optimism ETH', | ||
name: 'hardhat ETH', | ||
symbol: 'ETH', | ||
decimals: 18 | ||
}, | ||
rpcUrls: ['https://kovan.optimism.io'], | ||
blockExplorerUrls: ['https://kovan-optimistic.etherscan.io'] | ||
} | ||
} | ||
} | ||
|
@@ -134,9 +137,9 @@ export default { | |
// Error code 4902 - no added network in metamask | ||
if (error.code == 4902 || error.code) { | ||
try { | ||
await window.ethereum.request({ | ||
method: 'wallet_addEthereumChain', | ||
params: [DEFAULT_NETWORKS[chainId].METAMASK_PARAMS] | ||
await window.ethereum.request({ | ||
method: 'wallet_addEthereumChain', | ||
params: [DEFAULT_NETWORKS[chainId].METAMASK_PARAMS] | ||
}) | ||
rootState.chainId = chainId | ||
} catch (error) { | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
question about this, it works well by using
yarn link @zkopru/client
as mentioned above Line16. Why do we need to have another commandnpm run install-dev
forzkopru/client
integration?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.
In my environment,
yarn link
requires permission to create a folder in the global node module.I think it is okay setup and forgets in this way. If you use
yarn link
, have to unlink at some point, even though not worry about the permission.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.
May need some more explanation in this section about using the script or
yarn link
:)