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 11 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",
}
}
};
32 changes: 32 additions & 0 deletions burner-wallet-plugin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM node:12

WORKDIR /mono
COPY package.json .
COPY contracts/package.json ./contracts/
akolotov marked this conversation as resolved.
Show resolved Hide resolved
COPY commons/package.json ./commons/

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-plugin/package.json ./burner-wallet-plugin/tokenbridge-plugin/
COPY burner-wallet-plugin/basic-wallet/package.json ./burner-wallet-plugin/basic-wallet/
COPY burner-wallet-plugin/local-wallet/package.json ./burner-wallet-plugin/local-wallet/
COPY yarn.lock .
RUN yarn install --production --frozen-lockfile

COPY ./contracts ./contracts
RUN yarn run compile:contracts
RUN mv ./contracts/build ./ && rm -rf ./contracts/* ./contracts/.[!.]* && mv ./build ./contracts/

COPY ./commons ./commons

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

COPY ./burner-wallet-plugin/basic-wallet ./burner-wallet-plugin/basic-wallet
COPY ./burner-wallet-plugin/local-wallet ./burner-wallet-plugin/local-wallet

WORKDIR /mono/burner-wallet-plugin

CMD ["yarn", "start-local"]
38 changes: 38 additions & 0 deletions burner-wallet-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# TokenBridge Burner Wallet 2 Plugin

This plugin defines a Bridge trading pair to be used in the Exchange Plugin.

Bridge trading pairs supported:
* ETC - WETC Bridge

### Usage

```javascript
import { Etc, Wetc, EtcGateway, WETCBridge } from 'tokenbridge-plugin'

const core = new BurnerCore({
...
gateways: [new EtcGateway(), new InfuraGateway(process.env.REACT_APP_INFURA_KEY)],
assets: [Etc, Wetc]
})

const exchange = new Exchange({
pairs: [new WETCBridge()]
})
```

akolotov marked this conversation as resolved.
Show resolved Hide resolved

### 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 `basic-wallet` folder and set `REACT_APP_INFURA_KEY=<your key from infura.com>`
2. Run `yarn start-basic` 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 `local-wallet` 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-local` to start the wallet connected to Sokol & Kovan and interact with a test bridge sPoa - sPoa20
that works on top of the AMB bridge.

1 change: 1 addition & 0 deletions burner-wallet-plugin/basic-wallet/.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/basic-wallet/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "basic-wallet",
"version": "0.1.0",
"private": true,
"dependencies": {
"@burner-wallet/assets": "^1.1.0",
"@burner-wallet/core": "^1.1.0",
"@burner-wallet/exchange": "^1.1.0",
"@burner-wallet/metamask-plugin": "^1.0.0",
"@burner-wallet/modern-ui": "^1.0.5",
"@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",
"tokenbridge-plugin": "^1.0.0",
"typescript": "3.5.1"
},
"scripts": {
"start-basic": "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 not shown.
38 changes: 38 additions & 0 deletions burner-wallet-plugin/basic-wallet/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/basic-wallet/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"
}
23 changes: 23 additions & 0 deletions burner-wallet-plugin/basic-wallet/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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, EtcGateway, WETCBridge } from 'tokenbridge-plugin'
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 EtcGateway()],
assets: [Wetc, Etc]
})

const exchange = new Exchange({
pairs: [new WETCBridge()]
})

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

ReactDOM.render(<BurnerWallet />, document.getElementById('root'))
1 change: 1 addition & 0 deletions burner-wallet-plugin/basic-wallet/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/basic-wallet/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"
]
}
9 changes: 9 additions & 0 deletions burner-wallet-plugin/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
version: '2.4'
services:
burner-wallet-plugin:
build:
context: ..
dockerfile: burner-wallet-plugin/Dockerfile
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-plugin"
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "independent"
}
2 changes: 2 additions & 0 deletions burner-wallet-plugin/local-wallet/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_INFURA_KEY=
REACT_APP_PK=0x
43 changes: 43 additions & 0 deletions burner-wallet-plugin/local-wallet/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "local-wallet",
"version": "0.1.0",
"private": true,
"dependencies": {
"@burner-wallet/assets": "^1.1.0",
"@burner-wallet/core": "^1.1.0",
"@burner-wallet/exchange": "^1.1.0",
"@burner-wallet/metamask-plugin": "^1.0.0",
"@burner-wallet/modern-ui": "^1.0.5",
"@types/node": "12.0.4",
"@types/react": "16.8.19",
"@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",
"tokenbridge-plugin": "^1.0.0",
"typescript": "3.5.1",
"web3": "1.0.0-beta.55"
},
"scripts": {
"start-local": "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": {
"axios": "^0.19.0"
}
}
Binary file not shown.
38 changes: 38 additions & 0 deletions burner-wallet-plugin/local-wallet/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/local-wallet/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "Burner Wallet",
"name": "Burner Wallet",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
Loading