From f4d844efd20704752c3523026c21555156cbb604 Mon Sep 17 00:00:00 2001 From: Gerardo Nardelli Date: Tue, 28 Apr 2020 15:10:34 -0300 Subject: [PATCH] Add STAKE token example for testing and mainnet --- Dockerfile | 9 ++- README.md | 28 ++++++--- docker-compose.yml | 8 +++ lerna.json | 1 + my-plugin/src/assets/Stake.ts | 8 +++ my-plugin/src/assets/ksPOA.ts | 8 --- my-plugin/src/assets/sPOA.ts | 5 -- my-plugin/src/assets/xStake.ts | 8 +++ my-plugin/src/index.ts | 6 +- my-plugin/src/pairs/KSPOABridge.ts | 13 ----- my-plugin/src/pairs/StakeBridge.ts | 13 +++++ package.json | 6 +- test-wallet/.env.example | 2 + test-wallet/package.json | 44 ++++++++++++++ test-wallet/public/favicon.ico | Bin 0 -> 3870 bytes test-wallet/public/index.html | 38 ++++++++++++ test-wallet/public/manifest.json | 15 +++++ test-wallet/src/index.tsx | 44 ++++++++++++++ test-wallet/src/react-app-env.d.ts | 1 + test-wallet/tsconfig.json | 25 ++++++++ wallet/README.md | 7 --- wallet/scripts/erc20bytecode.txt | 1 - wallet/scripts/run-local-lib.js | 14 ----- wallet/scripts/run-local.js | 89 ----------------------------- wallet/src/index.tsx | 11 ++-- 25 files changed, 248 insertions(+), 156 deletions(-) create mode 100644 my-plugin/src/assets/Stake.ts delete mode 100644 my-plugin/src/assets/ksPOA.ts delete mode 100644 my-plugin/src/assets/sPOA.ts create mode 100644 my-plugin/src/assets/xStake.ts delete mode 100644 my-plugin/src/pairs/KSPOABridge.ts create mode 100644 my-plugin/src/pairs/StakeBridge.ts create mode 100644 test-wallet/.env.example create mode 100644 test-wallet/package.json create mode 100644 test-wallet/public/favicon.ico create mode 100644 test-wallet/public/index.html create mode 100644 test-wallet/public/manifest.json create mode 100644 test-wallet/src/index.tsx create mode 100644 test-wallet/src/react-app-env.d.ts create mode 100644 test-wallet/tsconfig.json delete mode 100644 wallet/README.md delete mode 100644 wallet/scripts/erc20bytecode.txt delete mode 100644 wallet/scripts/run-local-lib.js delete mode 100644 wallet/scripts/run-local.js diff --git a/Dockerfile b/Dockerfile index a5adf30..fda4792 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:12 +FROM node:12 as plugin-base WORKDIR /plugin @@ -8,10 +8,17 @@ COPY yarn.lock . COPY tsconfig.json . COPY my-plugin/package.json ./my-plugin/ COPY wallet/package.json ./wallet/ +COPY test-wallet/package.json ./test-wallet/ RUN yarn install COPY ./my-plugin ./my-plugin RUN yarn build +FROM plugin-base as test-wallet +COPY ./test-wallet ./test-wallet +CMD ["yarn", "start-wallet"] + + +FROM plugin-base as wallet COPY ./wallet ./wallet CMD ["yarn", "start-wallet"] diff --git a/README.md b/README.md index d2e2789..8d27a86 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,14 @@ Clone the sample repo to create a plugin project that uses the TokenBridge plugi #### Project structure There are two main folders in the project: -- `wallet` - is a burner wallet instance ready to test your plugin +- `wallet` - is a burner wallet instance ready to use your plugin +- `test-wallet` - is a burner wallet instance ready to test your plugin and resources in testnets - `my-plugin` - is the folder where the plugin code is located. To change the name of the plugin it is necessary to update the folder name `my-plugin` and all mentions to `my-plugin` to the new name of your plugin. -Inside `my-plugin` you can find the files that defines the resources to be exposed by the plugin to be used by the burner wallet in order to interact with the Native to ERC677 bridge extension: -- `sPOA` - uses `sPOA` defined in `tokenbridge-plugin` and adds the mediator address to the correct track of the transactions. -- `ksPOA` - extends from `ERC677Asset` defined in `tokenbridge-plugin` -- `KSPOABridge` - extends from `Mediator` defined in `tokenbridge-plugin` +Inside `my-plugin` you can find the files that defines the resources to be exposed by the plugin to be used by the burner wallet in order to interact with the ERC677 to ERC677 bridge extension: +- `Stake` - extends from `ERC677Asset` defined in `tokenbridge-plugin` +- `xStake` - extends from `ERC677Asset` defined in `tokenbridge-plugin` +- `StakeBridge` - extends from `Mediator` defined in `tokenbridge-plugin` You can extend or replace these resources based on your use case. @@ -27,8 +28,21 @@ To build the plugin package, from the root folder of project, you need to run th yarn build ``` -### Test -The project includes a burner wallet instance where you can test the implementation of the plugin. For that, you have to make sure that the build step was performed and that the plugin resources you modified are correctly imported and used in the `src/index.tsx` file of the `wallet` folder. +### Test plugin and resources in testnets +The project includes a burner wallet instance where you can test the implementation of the plugin in testnet. For that, you have to make sure that the build step was performed and that the plugin resources you modified are correctly imported and used in the `src/index.tsx` file of the `test-wallet` folder. + +1. Create `.env` file in `test-wallet` folder and set: +``` +REACT_APP_INFURA_KEY= +``` + +2. To start the burner wallet instance run: +``` +yarn start-test-wallet +``` + +### Run plugin in Mainnet +The project includes a burner wallet instance where you can use the implementation of the plugin. For that, you have to make sure that the build step was performed and that the plugin resources you modified are correctly imported and used in the `src/index.tsx` file of the `wallet` folder. 1. Create `.env` file in `wallet` folder and set: ``` diff --git a/docker-compose.yml b/docker-compose.yml index c6f0d8c..ed97363 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,5 +5,13 @@ services: build: context: . dockerfile: Dockerfile + target: wallet + environment: + - NODE_ENV=production + test-wallet: + build: + context: . + dockerfile: Dockerfile + target: test-wallet environment: - NODE_ENV=production diff --git a/lerna.json b/lerna.json index 291397e..28c4453 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,6 @@ { "packages": [ + "test-wallet", "wallet", "my-plugin" ], diff --git a/my-plugin/src/assets/Stake.ts b/my-plugin/src/assets/Stake.ts new file mode 100644 index 0000000..032d701 --- /dev/null +++ b/my-plugin/src/assets/Stake.ts @@ -0,0 +1,8 @@ +import { ERC677Asset } from '@poanet/tokenbridge-bw-exchange' + +export default new ERC677Asset({ + id: 'stake', + name: 'STAKE', + network: '1', + address: '0x0Ae055097C6d159879521C384F1D2123D1f195e6' +}) diff --git a/my-plugin/src/assets/ksPOA.ts b/my-plugin/src/assets/ksPOA.ts deleted file mode 100644 index 95bcb6d..0000000 --- a/my-plugin/src/assets/ksPOA.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ERC677Asset } from '@poanet/tokenbridge-bw-exchange' - -export default new ERC677Asset({ - id: 'xspoa', - name: 'ksPOA', - network: '42', - address: '0xff94183659f549D6273349696d73686Ee1d2AC83' -}) diff --git a/my-plugin/src/assets/sPOA.ts b/my-plugin/src/assets/sPOA.ts deleted file mode 100644 index d141627..0000000 --- a/my-plugin/src/assets/sPOA.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { sPOA } from '@poanet/tokenbridge-bw-exchange' - -sPOA.setMediatorAddress('0x867949C3F2f66D827Ed40847FaA7B3a369370e13') - -export default sPOA diff --git a/my-plugin/src/assets/xStake.ts b/my-plugin/src/assets/xStake.ts new file mode 100644 index 0000000..2824b1f --- /dev/null +++ b/my-plugin/src/assets/xStake.ts @@ -0,0 +1,8 @@ +import { ERC677Asset } from '@poanet/tokenbridge-bw-exchange' + +export default new ERC677Asset({ + id: 'xstake', + name: 'xSTAKE', + network: '100', + address: '0x' // TODO set address +}) diff --git a/my-plugin/src/index.ts b/my-plugin/src/index.ts index 5b7914f..9f9df87 100644 --- a/my-plugin/src/index.ts +++ b/my-plugin/src/index.ts @@ -1,3 +1,3 @@ -export { default as ksPOA } from './assets/ksPOA' -export { default as sPOA } from './assets/sPOA' -export { default as KSPOABridge } from './pairs/KSPOABridge' +export { default as Stake } from './assets/Stake' +export { default as xStake } from './assets/xStake' +export { default as StakeBridge } from './pairs/StakeBridge' diff --git a/my-plugin/src/pairs/KSPOABridge.ts b/my-plugin/src/pairs/KSPOABridge.ts deleted file mode 100644 index e107001..0000000 --- a/my-plugin/src/pairs/KSPOABridge.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Mediator } from '@poanet/tokenbridge-bw-exchange' -import { sPOA, ksPOA } from '../index' - -export default class KSPOABridge extends Mediator { - constructor() { - super({ - assetA: sPOA.id, - assetABridge: '0x867949C3F2f66D827Ed40847FaA7B3a369370e13', - assetB: ksPOA.id, - assetBBridge: '0x99FB1a25caeB9c3a5Bf132686E2fe5e27BC0e2dd' - }) - } -} diff --git a/my-plugin/src/pairs/StakeBridge.ts b/my-plugin/src/pairs/StakeBridge.ts new file mode 100644 index 0000000..c2a75b0 --- /dev/null +++ b/my-plugin/src/pairs/StakeBridge.ts @@ -0,0 +1,13 @@ +import { Mediator } from '@poanet/tokenbridge-bw-exchange' +import { Stake, xStake } from '../index' + +export default class StakeBridge extends Mediator { + constructor() { + super({ + assetA: xStake.id, + assetABridge: '0x', // TODO set address + assetB: Stake.id, + assetBBridge: '0x' // TODO set address + }) + } +} diff --git a/package.json b/package.json index badfa01..aedc83a 100644 --- a/package.json +++ b/package.json @@ -6,12 +6,14 @@ "private": true, "scripts": { "install": "lerna bootstrap", - "build": "lerna run --ignore wallet build", + "build": "lerna run --ignore wallet --ignore test-wallet build", "lint": "eslint '*/**/*.{js,ts,tsx}'", - "start-wallet": "lerna run --parallel start-wallet" + "start-wallet": "lerna run --parallel start-wallet", + "start-test-wallet": "lerna run --parallel start-test-wallet" }, "workspaces": [ "wallet", + "test-wallet", "my-plugin" ], "devDependencies": { diff --git a/test-wallet/.env.example b/test-wallet/.env.example new file mode 100644 index 0000000..521f04c --- /dev/null +++ b/test-wallet/.env.example @@ -0,0 +1,2 @@ +REACT_APP_INFURA_KEY= +REACT_APP_PK=0x diff --git a/test-wallet/package.json b/test-wallet/package.json new file mode 100644 index 0000000..f7c556b --- /dev/null +++ b/test-wallet/package.json @@ -0,0 +1,44 @@ +{ + "name": "test-wallet", + "version": "0.1.0", + "private": true, + "dependencies": { + "@burner-wallet/assets": "^1.1.10", + "@burner-wallet/core": "^1.1.9", + "@burner-wallet/exchange": "^1.1.3", + "@burner-wallet/metamask-plugin": "^1.0.1", + "@burner-wallet/modern-ui": "^1.0.7", + "@poanet/tokenbridge-bw-exchange": "^0.0.2", + "@types/node": "12.0.4", + "@types/react": "16.8.19", + "@types/react-dom": "16.8.4", + "@types/react-router-dom": "^4.3.3", + "my-plugin": "^1.0.0", + "react": "^16.8.6", + "react-dom": "^16.8.6", + "react-scripts": "^3.2.0", + "typescript": "3.5.1", + "web3": "1.0.0-beta.55" + }, + "scripts": { + "start-test-wallet": "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" + } +} diff --git a/test-wallet/public/favicon.ico b/test-wallet/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..a11777cc471a4344702741ab1c8a588998b1311a GIT binary patch literal 3870 zcma);c{J4h9>;%nil|2-o+rCuEF-(I%-F}ijC~o(k~HKAkr0)!FCj~d>`RtpD?8b; zXOC1OD!V*IsqUwzbMF1)-gEDD=A573Z-&G7^LoAC9|WO7Xc0Cx1g^Zu0u_SjAPB3vGa^W|sj)80f#V0@M_CAZTIO(t--xg= z!sii`1giyH7EKL_+Wi0ab<)&E_0KD!3Rp2^HNB*K2@PHCs4PWSA32*-^7d{9nH2_E zmC{C*N*)(vEF1_aMamw2A{ZH5aIDqiabnFdJ|y0%aS|64E$`s2ccV~3lR!u<){eS` z#^Mx6o(iP1Ix%4dv`t@!&Za-K@mTm#vadc{0aWDV*_%EiGK7qMC_(`exc>-$Gb9~W!w_^{*pYRm~G zBN{nA;cm^w$VWg1O^^<6vY`1XCD|s_zv*g*5&V#wv&s#h$xlUilPe4U@I&UXZbL z0)%9Uj&@yd03n;!7do+bfixH^FeZ-Ema}s;DQX2gY+7g0s(9;`8GyvPY1*vxiF&|w z>!vA~GA<~JUqH}d;DfBSi^IT*#lrzXl$fNpq0_T1tA+`A$1?(gLb?e#0>UELvljtQ zK+*74m0jn&)5yk8mLBv;=@}c{t0ztT<v;Avck$S6D`Z)^c0(jiwKhQsn|LDRY&w(Fmi91I7H6S;b0XM{e zXp0~(T@k_r-!jkLwd1_Vre^v$G4|kh4}=Gi?$AaJ)3I+^m|Zyj#*?Kp@w(lQdJZf4 z#|IJW5z+S^e9@(6hW6N~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!+%`wYOI<23q|&js`&o4xvjP7D_xv@ z5hEwpsp{HezI9!~6O{~)lLR@oF7?J7i>1|5a~UuoN=q&6N}EJPV_GD`&M*v8Y`^2j zKII*d_@Fi$+i*YEW+Hbzn{iQk~yP z>7N{S4)r*!NwQ`(qcN#8SRQsNK6>{)X12nbF`*7#ecO7I)Q$uZsV+xS4E7aUn+U(K baj7?x%VD!5Cxk2YbYLNVeiXvvpMCWYo=by@ literal 0 HcmV?d00001 diff --git a/test-wallet/public/index.html b/test-wallet/public/index.html new file mode 100644 index 0000000..dd1ccfd --- /dev/null +++ b/test-wallet/public/index.html @@ -0,0 +1,38 @@ + + + + + + + + + + + React App + + + +
+ + + diff --git a/test-wallet/public/manifest.json b/test-wallet/public/manifest.json new file mode 100644 index 0000000..348bc62 --- /dev/null +++ b/test-wallet/public/manifest.json @@ -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" +} diff --git a/test-wallet/src/index.tsx b/test-wallet/src/index.tsx new file mode 100644 index 0000000..f8c38d6 --- /dev/null +++ b/test-wallet/src/index.tsx @@ -0,0 +1,44 @@ +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 ModernUI from '@burner-wallet/modern-ui' +import Exchange from '@burner-wallet/exchange' +import MetamaskPlugin from '@burner-wallet/metamask-plugin' +import { ERC677Asset, Mediator, TokenBridgeGateway } from '@poanet/tokenbridge-bw-exchange' + +const sStake = new ERC677Asset({ + id: 'sstake', + name: 'sStake', + network: '77', + address: '0x' // TODO set address +}) + +const kStake = new ERC677Asset({ + id: 'kstake', + name: 'kStake', + network: '42', + address: '0x' // TODO set address +}) + +const StakeBridgePair = new Mediator({ + assetA: sStake.id, + assetABridge: '0x', // TODO set address + assetB: kStake.id, + assetBBridge: '0x' // TODO set address +}) + +const core = new BurnerCore({ + signers: [new InjectedSigner(), new LocalSigner({ privateKey: process.env.REACT_APP_PK, saveKey: false })], + gateways: [new InjectedGateway(), new TokenBridgeGateway(), new InfuraGateway(process.env.REACT_APP_INFURA_KEY)], + assets: [sStake, kStake] +}) + +const exchange = new Exchange({ + pairs: [StakeBridgePair] +}) + +const BurnerWallet = () => + +ReactDOM.render(, document.getElementById('root')) diff --git a/test-wallet/src/react-app-env.d.ts b/test-wallet/src/react-app-env.d.ts new file mode 100644 index 0000000..6431bc5 --- /dev/null +++ b/test-wallet/src/react-app-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/test-wallet/tsconfig.json b/test-wallet/tsconfig.json new file mode 100644 index 0000000..0980b23 --- /dev/null +++ b/test-wallet/tsconfig.json @@ -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" + ] +} diff --git a/wallet/README.md b/wallet/README.md deleted file mode 100644 index c4c437f..0000000 --- a/wallet/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## Scripts - -`yarn start`: Run the local script, then start the wallet. The local script will transfer ETH into the wallet address if it has a balance of 0. - -`yarn start-wallet`: Start the wallet without the local script. - -`yarn install-all`: Runs `yarn install` in this package, and all local dependencies. diff --git a/wallet/scripts/erc20bytecode.txt b/wallet/scripts/erc20bytecode.txt deleted file mode 100644 index 439d6fe..0000000 --- a/wallet/scripts/erc20bytecode.txt +++ /dev/null @@ -1 +0,0 @@ -0x608060405234801561001057600080fd5b506100333368056bc75e2d63100000610038640100000000026401000000009004565b6101b3565b60008273ffffffffffffffffffffffffffffffffffffffff161415151561005e57600080fd5b6100808160355461019264010000000002610e22179091906401000000009004565b6035819055506100e581603360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461019264010000000002610e22179091906401000000009004565b603360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b60008082840190508381101515156101a957600080fd5b8091505092915050565b610e6f806101c26000396000f30060806040526004361061008e576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063095ea7b31461009357806318160ddd146100f857806323b872dd1461012357806339509351146101a857806370a082311461020d578063a457c2d714610264578063a9059cbb146102c9578063dd62ed3e1461032e575b600080fd5b34801561009f57600080fd5b506100de600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506103a5565b604051808215151515815260200191505060405180910390f35b34801561010457600080fd5b5061010d6104d2565b6040518082815260200191505060405180910390f35b34801561012f57600080fd5b5061018e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104dc565b604051808215151515815260200191505060405180910390f35b3480156101b457600080fd5b506101f3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061068e565b604051808215151515815260200191505060405180910390f35b34801561021957600080fd5b5061024e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108c5565b6040518082815260200191505060405180910390f35b34801561027057600080fd5b506102af600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061090e565b604051808215151515815260200191505060405180910390f35b3480156102d557600080fd5b50610314600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b45565b604051808215151515815260200191505060405180910390f35b34801561033a57600080fd5b5061038f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b5c565b6040518082815260200191505060405180910390f35b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156103e257600080fd5b81603460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000603554905090565b6000603460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561056957600080fd5b6105f882603460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610be390919063ffffffff16565b603460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610683848484610c04565b600190509392505050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156106cb57600080fd5b61075a82603460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e2290919063ffffffff16565b603460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925603460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000603360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561094b57600080fd5b6109da82603460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610be390919063ffffffff16565b603460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925603460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000610b52338484610c04565b6001905092915050565b6000603460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600080838311151515610bf557600080fd5b82840390508091505092915050565b603360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548111151515610c5257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515610c8e57600080fd5b610ce081603360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610be390919063ffffffff16565b603360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d7581603360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e2290919063ffffffff16565b603360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000808284019050838110151515610e3957600080fd5b80915050929150505600a165627a7a723058202d673eee0ee7328de6b7c0d643a84a7b6dd97daa777f1dc05618732f8d5bebc40029 \ No newline at end of file diff --git a/wallet/scripts/run-local-lib.js b/wallet/scripts/run-local-lib.js deleted file mode 100644 index 8c49779..0000000 --- a/wallet/scripts/run-local-lib.js +++ /dev/null @@ -1,14 +0,0 @@ -const axios = require('axios') - -let id = 0 -const rpc = (url, method, ...params) => - axios.post(url, { jsonrpc: '2.0', id: id++, method, params }).then(response => response.result) - -module.exports.testRPC = url => async () => { - try { - const response = await rpc(url, 'eth_blockNumber') - return !!response - } catch (e) { - return false - } -} diff --git a/wallet/scripts/run-local.js b/wallet/scripts/run-local.js deleted file mode 100644 index 2185047..0000000 --- a/wallet/scripts/run-local.js +++ /dev/null @@ -1,89 +0,0 @@ -const { spawn } = require('child_process') -const fs = require('fs') -const Web3 = require('web3') -const { testRPC } = require('./run-local-lib') -const utils = require('ethereumjs-util') - -process.on('unhandledRejection', e => console.error(e)) - -const RPC = 'http://localhost:8545' -const PK_USER = '0xecb2222da7cbca080201acf6a7bbda53a3b2bcb22e3004b83ab8c69a884becb9' - -const DEPLOYER_PK = '0x13179885a8731284475aa2317a35a292131772bb5aa33734a1290b8b13944409' -const DEPLOYER_ADDRESS = utils.bufferToHex(utils.privateToAddress(DEPLOYER_PK)) - -const ERC20_ADDRESS = utils.bufferToHex(utils.generateAddress(DEPLOYER_ADDRESS, '0')) - -const getAccount = async web3 => { - const [defaultAccount] = await web3.eth.getAccounts() - if (!defaultAccount) { - throw new Error('Can not find an unlocked account') - } - return defaultAccount -} - -;(async function() { - if (!(await testRPC(RPC))) { - throw new Error('Ganache not found on port 8545') - } - - const web3 = new Web3(new Web3.providers.HttpProvider(RPC), null, { - transactionConfirmationBlocks: 1 - }) - - const user = web3.eth.accounts.privateKeyToAccount(PK_USER) - const deployer = web3.eth.accounts.privateKeyToAccount(DEPLOYER_PK) - - const balance = await web3.eth.getBalance(user.address) - console.log(balance, 'bal') - if (balance === '0') { - const defaultAccount = await getAccount(web3) - - console.log(`Sending 1 ETH from ${defaultAccount} to ${user.address}`) - await web3.eth.sendTransaction({ - from: defaultAccount, - to: user.address, - value: web3.utils.toWei('1', 'ether') - }) - } - - const collectableCode = await web3.eth.getCode(ERC20_ADDRESS) - if (collectableCode === '0x') { - console.log('ERC20 contract not found, deploying') - const defaultAccount = await getAccount(web3) - - await web3.eth.sendTransaction({ - from: defaultAccount, - to: deployer.address, - value: web3.utils.toWei('.2', 'ether') - }) - - // Deploy ERC20 - const erc20Bytecode = fs.readFileSync(`${__dirname}/erc20bytecode.txt`, 'utf8') - const { rawTransaction: deployTx } = await deployer.signTransaction({ - gas: '5000000', - data: erc20Bytecode - }) - await web3.eth.sendSignedTransaction(deployTx) - - // Transfer tokens to user - console.log('Transfering tokens') - const { rawTransaction: transferTx } = await deployer.signTransaction({ - to: ERC20_ADDRESS, - gas: '5000000', - data: `0xa9059cbb000000000000000000000000${user.address.substr( - 2 - )}0000000000000000000000000000000000000000000000056bc75e2d63100000` - }) - await web3.eth.sendSignedTransaction(transferTx) - } - - spawn('yarn', ['start-wallet'], { - env: { - ...process.env, - REACT_APP_PK: PK_USER, - REACT_APP_ERC20_ADDRESS: ERC20_ADDRESS - }, - stdio: 'inherit' - }) -})() diff --git a/wallet/src/index.tsx b/wallet/src/index.tsx index 40c98a6..a44aba5 100644 --- a/wallet/src/index.tsx +++ b/wallet/src/index.tsx @@ -2,22 +2,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 { InfuraGateway, InjectedGateway, XDaiGateway } from '@burner-wallet/core/gateways' import ModernUI from '@burner-wallet/modern-ui' import Exchange from '@burner-wallet/exchange' import MetamaskPlugin from '@burner-wallet/metamask-plugin' -import { TokenBridgeGateway } from '@poanet/tokenbridge-bw-exchange' // Import resources from our plugin -import { sPOA, ksPOA, KSPOABridge } from 'my-plugin' +import { Stake, xStake, StakeBridge } from 'my-plugin' const core = new BurnerCore({ signers: [new InjectedSigner(), new LocalSigner({ privateKey: process.env.REACT_APP_PK, saveKey: false })], - gateways: [new InjectedGateway(), new TokenBridgeGateway(), new InfuraGateway(process.env.REACT_APP_INFURA_KEY)], - assets: [sPOA, ksPOA] + gateways: [new InjectedGateway(), new XDaiGateway(), new InfuraGateway(process.env.REACT_APP_INFURA_KEY)], + assets: [Stake, xStake] }) const exchange = new Exchange({ - pairs: [new KSPOABridge()] + pairs: [new StakeBridge()] }) const BurnerWallet = () =>