Skip to content
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

Add Burner Wallet Plugin for WETC Bridge #306

Merged
merged 53 commits into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
8a41767
Add burner wallet plugin
patitonar Apr 3, 2020
c184b87
fix local wallet params
patitonar Apr 3, 2020
9be79e7
don't run test on burner-plugin
patitonar Apr 3, 2020
5e3bee0
burner-plugin cleanup
patitonar Apr 3, 2020
cd15a7c
Use ERC677 abi from commons package
patitonar Apr 3, 2020
4c98a61
Update docker files for burner-wallet-plugin
patitonar Apr 3, 2020
eee814b
Update yarn.lock
patitonar Apr 6, 2020
f86b241
Update burner-wallet dependencies to 1.1.0
patitonar Apr 6, 2020
7164131
update plugin docs and scripts
patitonar Apr 6, 2020
5fc66cc
Add script command in burner plugin Dockerfile
patitonar Apr 6, 2020
d0b7560
Add new pair erc677toErc677 in local BW
patitonar Apr 7, 2020
b64c310
Add generic TokenBridgeGateway
patitonar Apr 8, 2020
11fc1e6
Add sPOA asset
patitonar Apr 8, 2020
fb9cf1f
Refactor directories
patitonar Apr 8, 2020
9990f8d
Fix variable name in BW plugin Bridge pair
patitonar Apr 8, 2020
f405986
Rename basic-wallet and local-wallet
patitonar Apr 8, 2020
039ffb3
Fix BW wallets headers
patitonar Apr 8, 2020
53d4491
Update BW plugin Dockerfile and docker-compose
patitonar Apr 8, 2020
9f20532
Fix BW plugin lerna scripts
patitonar Apr 8, 2020
83023ff
Add env vars for BW testing
patitonar Apr 9, 2020
0cd9e67
Fix ERC677Asset event watching
patitonar Apr 9, 2020
3593009
Include BW plugin unit tests in root test script
patitonar Apr 9, 2020
e547835
Update BW exchange and asset dependencies
patitonar Apr 15, 2020
7bbb24e
Listen to mediators events
patitonar Apr 17, 2020
679b55c
Calculate fees when estimating exchange operation
patitonar Apr 20, 2020
5498476
Fix mediator fee calculation
patitonar Apr 20, 2020
115cd58
Fix transaction details displayed for ERC677Asset when mediator has fees
patitonar Apr 20, 2020
e0464c7
Update plugin package.json
patitonar Apr 22, 2020
709207c
Fix Mediator pair getFeeAmount
patitonar Apr 22, 2020
c9c5973
Add instructions to publish bw plugin to npm
patitonar Apr 23, 2020
7d39b5b
Add other provided resources by the plugin in README
patitonar Apr 23, 2020
44891be
Update instruction to publish npm package
patitonar Apr 24, 2020
62c8e52
Add repository info to bw plugin package.json
patitonar Apr 24, 2020
9725377
Update bw plugin name
patitonar Apr 24, 2020
1a51606
Update bw plugin docs
patitonar Apr 24, 2020
ada93ab
Update bw dependencies
patitonar Apr 27, 2020
1a9ccdc
Add fee message on exchange estimate
patitonar Apr 27, 2020
5d9a353
Include abis in bw plugin utils
patitonar Apr 27, 2020
8789d3e
Add install plugin package instruction
patitonar Apr 27, 2020
ef27817
Display fee percentage in estimation
patitonar Apr 27, 2020
36b20d1
Bump @poanet/tokenbridge-bw-exchange version to 0.0.2
patitonar Apr 27, 2020
cee5f93
Fix plugin dependencies
patitonar Apr 27, 2020
56d7b54
Update burner-wallet-plugin yarn.lock
patitonar Apr 28, 2020
170767e
Update bw plugin Dockerfile
patitonar Apr 28, 2020
318c306
Update @burner-wallet/exchange version
patitonar Apr 29, 2020
a3fd30a
Remove not needed dependency
patitonar Apr 29, 2020
8fcab33
Bump @poanet/tokenbridge-bw-exchange version to 0.0.3
patitonar Apr 29, 2020
8c5faee
Update plugin npm parameters and README
patitonar May 4, 2020
cce9e03
Reduce plugin abis to only needed methods
patitonar May 4, 2020
9cc9d96
Update burner-wallet-plugin/testing/.env.example
patitonar May 4, 2020
fb02baf
Merge branch 'burner-wallet-plugin' of github.com:poanetwork/tokenbri…
patitonar May 4, 2020
28e8570
Remove contracts from plugin Dockerfile
patitonar May 4, 2020
02a2be8
Bump @poanet/tokenbridge-bw-exchange version to 1.0.0
patitonar May 4, 2020
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
submodules
coverage
lib
dist
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ coverage

# production
build
dist

# misc
.DS_Store
Expand Down Expand Up @@ -48,4 +49,4 @@ __pycache__

#monitor
monitor/responses/*
!monitor/.gitkeep
!monitor/.gitkeep
31 changes: 31 additions & 0 deletions burner-wallet-plugin/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
extends: [
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from @typescript-eslint/eslint-plugin
"../.eslintrc"
],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: "module", // Allows for the use of imports
ecmaFeatures: {
jsx: true // Allows for the parsing of JSX
}
},
rules: {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off", // Reduce the use of 'any'
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-var-requires": "off",
"react/prop-types": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/member-delimiter-style": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/explicit-member-accessibility": "off"
},
settings: {
react: {
version: "detect",
}
}
};
30 changes: 30 additions & 0 deletions burner-wallet-plugin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM node:12 as plugin-base

WORKDIR /mono
COPY package.json .
RUN mkdir -p contracts/node_modules

COPY burner-wallet-plugin/package.json ./burner-wallet-plugin/
COPY burner-wallet-plugin/lerna.json ./burner-wallet-plugin/
COPY burner-wallet-plugin/yarn.lock ./burner-wallet-plugin/
COPY burner-wallet-plugin/tsconfig.json ./burner-wallet-plugin/
COPY burner-wallet-plugin/tokenbridge-bw-exchange/package.json ./burner-wallet-plugin/tokenbridge-bw-exchange/
COPY burner-wallet-plugin/staging/package.json ./burner-wallet-plugin/staging/
COPY burner-wallet-plugin/testing/package.json ./burner-wallet-plugin/testing/
COPY yarn.lock .
RUN yarn install --production --frozen-lockfile

COPY ./burner-wallet-plugin/tokenbridge-bw-exchange ./burner-wallet-plugin/tokenbridge-bw-exchange
RUN yarn build:plugin


FROM plugin-base as testing
COPY ./burner-wallet-plugin/testing ./burner-wallet-plugin/testing
WORKDIR /mono/burner-wallet-plugin
CMD ["yarn", "start-testing"]


FROM plugin-base as staging
COPY ./burner-wallet-plugin/staging ./burner-wallet-plugin/staging
WORKDIR /mono/burner-wallet-plugin
CMD ["yarn", "start-staging"]
41 changes: 41 additions & 0 deletions burner-wallet-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# TokenBridge Burner Wallet 2 Plugin

Please refer to the [Plugin README](./tokenrbdige-bw-exchange/README.md) for resources provided, instructions to install and use the plugin.

### Setup
akolotov marked this conversation as resolved.
Show resolved Hide resolved
1. [Initialize](../README.md#initializing-the-monorepository) the monorepository.
2. Run `yarn build` or from the monorepository root `yarn build:plugin`

### Run Burner Wallet with the plugin in Mainnet & Classic
1. Create `.env` file in `staging` folder and set `REACT_APP_INFURA_KEY=<your key from infura.com>`
2. Run `yarn start-staging` to start the wallet connected to Mainnet & Classic and interact with the ETH - WETC Bridge.

### Run Burner Wallet with the plugin in Sokol & Kovan
1. Create `.env` file in `testing` folder and set `REACT_APP_INFURA_KEY=<your key from infura.com>`.
Also, a private key can be set to start the wallet with the specified account `REACT_APP_PK=0x...`
2. Run `yarn start-testing` to start the wallet connected to Sokol & Kovan and interact with a test bridge
that works on top of the AMB bridge.

### Docker Setup
Docker can be used to build the services and run the testing and staging wallets.

First you may want to create the `.env` files for testing and staging as mentioned before. This is optional before building the containers, variables can be passes later using `--env-file` or `--env` parameters in `docker run`.

Build the services with docker-compose:
```bash
docker-compose build
```

### Run Burner Wallet with the plugin in Mainnet & Classic using Docker
```bash
docker run -ti -p 8080:8080 -e PORT=8080 --rm burner-wallet-plugin_staging
```

### Run Burner Wallet with the plugin in Sokol & Kovan using Docker
```bash
docker run -ti -p 8080:8080 -e PORT=8080 --rm burner-wallet-plugin_testing
```
### Publish to npm
In order to make this plugin accessible, it should be available as a npm package. Follow the [instructions](publish.md) to publish
the package to npm registry.

17 changes: 17 additions & 0 deletions burner-wallet-plugin/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
version: '2.4'
services:
staging:
build:
context: ..
dockerfile: burner-wallet-plugin/Dockerfile
target: staging
environment:
- NODE_ENV=production
testing:
build:
context: ..
dockerfile: burner-wallet-plugin/Dockerfile
target: testing
environment:
- NODE_ENV=production
10 changes: 10 additions & 0 deletions burner-wallet-plugin/lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"packages": [
"basic-wallet",
"local-wallet",
"tokenbridge-bw-exchange"
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "independent"
}
28 changes: 28 additions & 0 deletions burner-wallet-plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "burner-wallet-plugin",
"description": "Burner Wallet 2 plugin",
"version": "1.0.0",
"license": "GPL-3.0-only",
"private": true,
"scripts": {
"install": "lerna bootstrap",
"build": "lerna run --ignore testing --ignore staging build --stream",
"lint": "eslint '*/**/*.{js,ts,tsx}' --ignore-path ../.eslintignore",
"start-staging": "lerna run --scope staging start --stream",
"start-testing": "lerna run --scope testing start --stream",
"test": "lerna run --ignore testing --ignore staging test --stream"
},
"workspaces": [
"staging",
"testing",
"tokenbridge-bw-exchange"
],
"dependencies": {
"@types/color": "3.0.0",
"@typescript-eslint/eslint-plugin": "1.13.0",
"@typescript-eslint/parser": "1.13.0",
"eslint-plugin-react": "7.19.0",
"lerna": "3.16.4",
"typescript": "3.5.3"
}
}
36 changes: 36 additions & 0 deletions burner-wallet-plugin/publish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Plugin Package Information

The package to be published gets its configuration from `tokenbridge/burner-wallet-plugin/tokenbridge-bw-exchange/package.json`

```json
{
"name": "tokenbridge-bw-exchange",
"version": "1.0.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"/dist"
]
}
```

- `name` is the name of how package will be available in npm.
- `main` is entry point for the package
- `types` is the entry point for typescript types
- `files` is the list of files included when publishing the package. So we have to run `yarn build` first to
generate the `dist` folder.

## Steps to publish to npm

1. Create account in https://www.npmjs.com/

2. Go to `tokenbridge/burner-wallet-plugin/tokenbridge-bw-exchange/`

3. Run `yarn build`. Make sure it generates the `dist` folder

4. Update `version` in `tokenbridge/burner-wallet-plugin/tokenbridge-bw-exchange/package.json`
5. Run `yarn login` and fill login information if required.
6. Run `yarn publish --access public`.
The prompt will ask for the new version, complete it with the version from `package.json`

More information in https://classic.yarnpkg.com/en/docs/publishing-a-package/
1 change: 1 addition & 0 deletions burner-wallet-plugin/staging/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_INFURA_KEY=
40 changes: 40 additions & 0 deletions burner-wallet-plugin/staging/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "staging",
"version": "0.1.0",
"private": true,
"dependencies": {
"@burner-wallet/assets": "^1.1.10",
"@burner-wallet/core": "^1.1.0",
"@burner-wallet/exchange": "^1.1.4",
"@burner-wallet/metamask-plugin": "^1.0.0",
"@burner-wallet/modern-ui": "^1.0.7",
"@poanet/tokenbridge-bw-exchange": "^1.0.0",
"@types/node": "12.0.4",
"@types/react": "*",
"@types/react-dom": "16.8.4",
"@types/react-router-dom": "^4.3.3",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "3.0.1",
"typescript": "3.5.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {}
}
Binary file added burner-wallet-plugin/staging/public/favicon.ico
Binary file not shown.
38 changes: 38 additions & 0 deletions burner-wallet-plugin/staging/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.

To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
15 changes: 15 additions & 0 deletions burner-wallet-plugin/staging/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
21 changes: 21 additions & 0 deletions burner-wallet-plugin/staging/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'
import ReactDOM from 'react-dom'
import BurnerCore from '@burner-wallet/core'
import { InjectedSigner, LocalSigner } from '@burner-wallet/core/signers'
import { InfuraGateway, InjectedGateway } from '@burner-wallet/core/gateways'
import Exchange from '@burner-wallet/exchange'
import ModernUI from '@burner-wallet/modern-ui'
import { Etc, Wetc, TokenBridgeGateway, WETCBridge } from '@poanet/tokenbridge-bw-exchange'
akolotov marked this conversation as resolved.
Show resolved Hide resolved
import MetamaskPlugin from '@burner-wallet/metamask-plugin'

const core = new BurnerCore({
signers: [new InjectedSigner(), new LocalSigner()],
gateways: [new InjectedGateway(), new InfuraGateway(process.env.REACT_APP_INFURA_KEY), new TokenBridgeGateway()],
assets: [Wetc, Etc]
})

const exchange = new Exchange([new WETCBridge()])

const BurnerWallet = () => <ModernUI title="Staging Wallet" core={core} plugins={[exchange, new MetamaskPlugin()]} />

ReactDOM.render(<BurnerWallet />, document.getElementById('root'))
1 change: 1 addition & 0 deletions burner-wallet-plugin/staging/src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
25 changes: 25 additions & 0 deletions burner-wallet-plugin/staging/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve"
},
"include": [
"src"
]
}
14 changes: 14 additions & 0 deletions burner-wallet-plugin/testing/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
REACT_APP_INFURA_KEY=
#REACT_APP_PK=0x

REACT_APP_MODE=AMB_NATIVE_TO_ERC677

REACT_APP_HOME_TOKEN_NAME=sPOA
REACT_APP_HOME_NETWORK=77
REACT_APP_HOME_MEDIATOR_ADDRESS=0x867949C3F2f66D827Ed40847FaA7B3a369370e13
REACT_APP_HOME_TOKEN_ADDRESS=

REACT_APP_FOREIGN_TOKEN_NAME=ksPOA
REACT_APP_FOREIGN_NETWORK=42
REACT_APP_FOREIGN_MEDIATOR_ADDRESS=0x99FB1a25caeB9c3a5Bf132686E2fe5e27BC0e2dd
REACT_APP_FOREIGN_TOKEN_ADDRESS=0xff94183659f549D6273349696d73686Ee1d2AC83
Loading