├── .gitignore ├── basic-wallet ├── src │ ├── react-app-env.d.ts │ └── index.tsx ├── public │ ├── favicon.ico │ ├── manifest.json │ └── index.html ├── .gitignore ├── tsconfig.json └── package.json ├── local-wallet ├── src │ ├── react-app-env.d.ts │ └── index.tsx ├── public │ ├── favicon.ico │ ├── manifest.json │ └── index.html ├── README.md ├── tsconfig.json └── package.json ├── my-plugin ├── tsconfig.json ├── package.json └── src │ ├── ui │ ├── MyPage.tsx │ └── MyElement.tsx │ └── MyPlugin.ts ├── lerna.json ├── tsconfig.json ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | .env 4 | -------------------------------------------------------------------------------- /basic-wallet/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /local-wallet/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /basic-wallet/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/burner-wallet/sample-plugin/HEAD/basic-wallet/public/favicon.ico -------------------------------------------------------------------------------- /local-wallet/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/burner-wallet/sample-plugin/HEAD/local-wallet/public/favicon.ico -------------------------------------------------------------------------------- /my-plugin/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "./dist" 6 | }, 7 | "include": [ 8 | "./src" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": [ 3 | "basic-wallet", 4 | "local-wallet", 5 | "my-plugin" 6 | ], 7 | "npmClient": "yarn", 8 | "useWorkspaces": true, 9 | "version": "independent" 10 | } 11 | -------------------------------------------------------------------------------- /local-wallet/README.md: -------------------------------------------------------------------------------- 1 | ## Scripts 2 | 3 | `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. 4 | 5 | `yarn start-wallet`: Start the wallet without the local script. 6 | 7 | `yarn install-all`: Runs `yarn install` in this package, and all local dependencies. 8 | -------------------------------------------------------------------------------- /local-wallet/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "Burner Wallet", 3 | "name": "Burner Wallet", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /basic-wallet/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /basic-wallet/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /my-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-plugin", 3 | "version": "1.0.0", 4 | "license": "MIT", 5 | "main": "dist/MyPlugin.js", 6 | "types": "dist/MyPlugin.d.ts", 7 | "scripts": { 8 | "build": "tsc", 9 | "start-basic": "tsc -w", 10 | "start-local": "tsc -w" 11 | }, 12 | "dependencies": { 13 | "@burner-wallet/assets": "^1.0.0", 14 | "@burner-wallet/types": "^1.0.0", 15 | "@types/react": "*" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /my-plugin/src/ui/MyPage.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { PluginPageContext } from '@burner-wallet/types'; 3 | import { Asset } from '@burner-wallet/assets'; 4 | 5 | const MyPage: React.FC = ({ burnerComponents, assets, defaultAccount }) => { 6 | const { Page } = burnerComponents; 7 | return ( 8 | 9 |
Account: {defaultAccount}
10 |
Assets: {assets.map((asset: Asset) => asset.name).join(', ')}
11 |
12 | ); 13 | }; 14 | 15 | export default MyPage; 16 | -------------------------------------------------------------------------------- /basic-wallet/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "noEmit": true, 20 | "jsx": "preserve" 21 | }, 22 | "include": [ 23 | "src" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /local-wallet/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "noEmit": true, 20 | "jsx": "preserve" 21 | }, 22 | "include": [ 23 | "src" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "esnext", 4 | "declaration": true, 5 | "removeComments": true, 6 | "noLib": false, 7 | "emitDecoratorMetadata": true, 8 | "experimentalDecorators": true, 9 | "esModuleInterop": true, 10 | "jsx": "react", 11 | "target": "esnext", 12 | "sourceMap": true, 13 | "strict": true, 14 | "allowSyntheticDefaultImports": true, 15 | "moduleResolution": "node", 16 | "resolveJsonModule": true, 17 | "lib": [ 18 | "es6", 19 | "dom" 20 | ] 21 | }, 22 | "exclude": [ 23 | "node_modules", 24 | "**/*.spec.ts" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /my-plugin/src/ui/MyElement.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from 'react'; 2 | import { PluginElementContext } from '@burner-wallet/types'; 3 | import MyPlugin from '../MyPlugin'; 4 | 5 | const MyElement: React.FC = ({ plugin }) => { 6 | const [block, setBlock] = useState(null); 7 | const _plugin = plugin as MyPlugin; 8 | 9 | useEffect(() => { 10 | _plugin.getBlockNum().then((num: number) => setBlock(num)) 11 | }, []); 12 | 13 | return ( 14 |
15 |
Injected plugin element
16 | {block && ( 17 |
Current block number: {block}
18 | )} 19 |
20 | ); 21 | }; 22 | 23 | export default MyElement; 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sample-burner-wallet-plugin", 3 | "description": "Sample repo for building a Burner Wallet 2 plugin", 4 | "author": "David Mihal ", 5 | "license": "MIT", 6 | "private": true, 7 | "scripts": { 8 | "install": "lerna bootstrap", 9 | "build": "lerna run --ignore local-wallet --ignore basic-wallet build", 10 | "lint": "eslint '*/**/*.{js,ts,tsx}'", 11 | "start-basic": "lerna run --parallel start-basic", 12 | "start-local": "lerna run --parallel start-local" 13 | }, 14 | "workspaces": [ 15 | "basic-wallet", 16 | "local-wallet", 17 | "my-plugin" 18 | ], 19 | "devDependencies": { 20 | "@typescript-eslint/eslint-plugin": "^2.5.0", 21 | "@typescript-eslint/parser": "^2.5.0", 22 | "eslint": "^6.6.0", 23 | "eslint-plugin-react": "^7.16.0", 24 | "lerna": "^3.16.4" 25 | }, 26 | "dependencies": { 27 | "typescript": "^3.6.3" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /basic-wallet/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "basic-wallet", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@burner-wallet/assets": "^1.0.0", 7 | "@burner-wallet/core": "^1.0.0", 8 | "@burner-wallet/exchange": "^1.0.0", 9 | "@burner-wallet/modern-ui": "^1.0.0", 10 | "@types/node": "12.0.4", 11 | "@types/react": "*", 12 | "@types/react-dom": "16.8.4", 13 | "@types/react-router-dom": "^4.3.3", 14 | "my-plugin": "^1.0.0", 15 | "react": "^16.8.6", 16 | "react-dom": "^16.8.6", 17 | "react-scripts": "^3.2.0" 18 | }, 19 | "scripts": { 20 | "start": "react-scripts start", 21 | "start-basic": "react-scripts start", 22 | "build": "react-scripts build", 23 | "test": "react-scripts test", 24 | "eject": "react-scripts eject" 25 | }, 26 | "browserslist": { 27 | "production": [ 28 | ">0.2%", 29 | "not dead", 30 | "not op_mini all" 31 | ], 32 | "development": [ 33 | "last 1 chrome version", 34 | "last 1 firefox version", 35 | "last 1 safari version" 36 | ] 37 | }, 38 | "devDependencies": {} 39 | } 40 | -------------------------------------------------------------------------------- /local-wallet/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "local-wallet", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@burner-wallet/assets": "^1.0.0", 7 | "@burner-wallet/cli": "^0.1.0", 8 | "@burner-wallet/core": "^1.0.0", 9 | "@burner-wallet/modern-ui": "^1.0.0", 10 | "@types/node": "12.0.4", 11 | "@types/react": "16.8.19", 12 | "@types/react-dom": "16.8.4", 13 | "@types/react-router-dom": "^4.3.3", 14 | "my-plugin": "^1.0.0", 15 | "react": "^16.8.6", 16 | "react-dom": "^16.8.6", 17 | "react-scripts": "^3.2.0" 18 | }, 19 | "scripts": { 20 | "start": "burner start", 21 | "start-local": "burner start", 22 | "start-wallet": "react-scripts start", 23 | "build": "react-scripts build", 24 | "test": "react-scripts test", 25 | "eject": "react-scripts eject" 26 | }, 27 | "browserslist": { 28 | "production": [ 29 | ">0.2%", 30 | "not dead", 31 | "not op_mini all" 32 | ], 33 | "development": [ 34 | "last 1 chrome version", 35 | "last 1 firefox version", 36 | "last 1 safari version" 37 | ] 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /basic-wallet/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import { xdai, dai, eth } from '@burner-wallet/assets'; 4 | import BurnerCore from '@burner-wallet/core'; 5 | import { InjectedSigner, LocalSigner } from '@burner-wallet/core/signers'; 6 | import { InfuraGateway, InjectedGateway, XDaiGateway, } from '@burner-wallet/core/gateways'; 7 | import Exchange, { Uniswap, XDaiBridge } from '@burner-wallet/exchange'; 8 | import ModernUI from '@burner-wallet/modern-ui'; 9 | import MyPlugin from 'my-plugin'; 10 | 11 | const core = new BurnerCore({ 12 | signers: [new InjectedSigner(), new LocalSigner()], 13 | gateways: [ 14 | new InjectedGateway(), 15 | new InfuraGateway(process.env.REACT_APP_INFURA_KEY), 16 | new XDaiGateway(), 17 | ], 18 | assets: [xdai, dai, eth], 19 | }); 20 | 21 | const exchange = new Exchange([new XDaiBridge(), new Uniswap('dai')]); 22 | 23 | const BurnerWallet = () => 24 | 29 | 30 | 31 | ReactDOM.render(, document.getElementById('root')); 32 | -------------------------------------------------------------------------------- /my-plugin/src/MyPlugin.ts: -------------------------------------------------------------------------------- 1 | import { BurnerPluginContext, Plugin, Actions } from '@burner-wallet/types'; 2 | import MyPage from './ui/MyPage'; 3 | import MyElement from './ui/MyElement'; 4 | 5 | interface PluginActionContext { 6 | actions: Actions; 7 | } 8 | 9 | export default class MyPlugin implements Plugin { 10 | private pluginContext?: BurnerPluginContext; 11 | 12 | initializePlugin(pluginContext: BurnerPluginContext) { 13 | this.pluginContext = pluginContext; 14 | 15 | pluginContext.addPage('/my-page', MyPage); 16 | pluginContext.addButton('apps', 'My Plugin', '/my-page', { 17 | description: 'Sample plugin page', 18 | }); 19 | pluginContext.addElement('home-middle', MyElement); 20 | 21 | pluginContext.onQRScanned((scannedQR: string, ctx: PluginActionContext) => { 22 | if (scannedQR === 'My Plugin') { 23 | ctx.actions.navigateTo('/my-page'); 24 | return true; 25 | } 26 | }); 27 | } 28 | 29 | async getBlockNum() { 30 | const assets = this.pluginContext!.getAssets(); 31 | const web3 = this.pluginContext!.getWeb3(assets[0].network); 32 | const blockNum = web3.eth.getBlockNumber(); 33 | return blockNum; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /local-wallet/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import { NativeAsset, ERC20Asset } from '@burner-wallet/assets'; 4 | import BurnerCore from '@burner-wallet/core'; 5 | import { InjectedSigner, LocalSigner } from '@burner-wallet/core/signers'; 6 | import { HTTPGateway } from '@burner-wallet/core/gateways'; 7 | import ModernUI from '@burner-wallet/modern-ui'; 8 | import MyPlugin from 'my-plugin'; 9 | 10 | const core = new BurnerCore({ 11 | signers: [ 12 | new InjectedSigner(), 13 | new LocalSigner({ privateKey: process.env.REACT_APP_PK, saveKey: false }), 14 | ], 15 | gateways: [ 16 | new HTTPGateway('http://localhost:8545', '5777'), 17 | ], 18 | assets: [ 19 | new ERC20Asset({ 20 | id: 'localerc20', 21 | name: 'Local Token', 22 | network: '5777', 23 | // @ts-ignore 24 | address: process.env.REACT_APP_ERC20_ADDRESS, 25 | }), 26 | new NativeAsset({ 27 | id: 'geth', 28 | name: 'Ganache ETH', 29 | network: '5777', 30 | }), 31 | ], 32 | }); 33 | 34 | const BurnerWallet = () => 35 | 40 | 41 | 42 | ReactDOM.render(, document.getElementById('root')); 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sample Burner Wallet 2 Plugin 2 | 3 | This repo provides a boilerplate for building a new plugin for the Burner Wallet 2. 4 | 5 | ## Setup 6 | 7 | 1. Clone the repo 8 | 2. Run `yarn install`. This repo uses Lerna and Yarn Workspaces, so `yarn install` will install 9 | all dependencies and link modules in the repo 10 | 3. To connect to mainnet & most testnets, you'll need to provide an Infura key. Create a file 11 | named `.env` in the `basic-wallet` folder and set the contents to `REACT_APP_INFURA_KEY=` 12 | 4. Run `yarn start-local` to start the wallet while connected to Ganache, or run `yarn start-basic` 13 | to start the wallet connected to Mainnet & xDai 14 | 15 | ## Renaming the plugin 16 | 17 | To rename the plugin from "MyPlugin" to your own plugin name, you must update the following locations: 18 | 19 | 1. Rename the `my-plugin` directory 20 | 2. Change `my-plugin` in `lerna.json` and the root `package.json` 21 | 3. Change the name field in `package.json` in your plugin's `package.json` file 22 | 4. Rename `MyPlugin.ts` 23 | 5. Change `MyPlugin.js` and `MyPlugin.d.ts` in the plugin `package.json` file 24 | 6. Change the class name in the main plugin file 25 | 7. Change rename `my-plugin` dependency in `basic-wallet/package.json` & `local-wallet/package.json` 26 | 8. In `basic-wallet/src/index.tsx` and `local-wallet/src/index.tsx`, update the import 27 | `import MyPlugin from 'my-plugin';` as well as the `new MyPlugin()` constructor. 28 | 9. Finally, run `yarn install` in the root to re-link the packages 29 | -------------------------------------------------------------------------------- /basic-wallet/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 22 | Burner Wallet 23 | 24 | 25 | 26 |
27 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /local-wallet/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 22 | Burner Wallet 23 | 24 | 25 | 26 |
27 | 37 | 38 | 39 | --------------------------------------------------------------------------------