rename plugin
This commit is contained in:
parent
f083e7c252
commit
3bad6c60cc
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"name": "my-plugin",
|
||||
"name": "amb-mediator",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"main": "dist/MyPlugin.js",
|
||||
"types": "dist/MyPlugin.d.ts",
|
||||
"main": "dist/AmbMediator.js",
|
||||
"types": "dist/AmbMediator.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"start-basic": "tsc -w",
|
|
@ -0,0 +1,9 @@
|
|||
import { BurnerPluginContext, Plugin } from '@burner-wallet/types'
|
||||
|
||||
export default class AmbMediator implements Plugin {
|
||||
private pluginContext?: BurnerPluginContext
|
||||
|
||||
initializePlugin(pluginContext: BurnerPluginContext) {
|
||||
this.pluginContext = pluginContext
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
"@types/react": "*",
|
||||
"@types/react-dom": "16.8.4",
|
||||
"@types/react-router-dom": "^4.3.3",
|
||||
"my-plugin": "^1.0.0",
|
||||
"amb-mediator": "^1.0.0",
|
||||
"react": "^16.8.6",
|
||||
"react-dom": "^16.8.6",
|
||||
"react-scripts": "^3.2.0",
|
||||
|
|
|
@ -6,7 +6,7 @@ import { InjectedSigner, LocalSigner } from '@burner-wallet/core/signers'
|
|||
import { InfuraGateway, InjectedGateway, XDaiGateway } from '@burner-wallet/core/gateways'
|
||||
import Exchange, { Uniswap, XDaiBridge } from '@burner-wallet/exchange'
|
||||
import ModernUI from '@burner-wallet/modern-ui'
|
||||
// import MyPlugin from 'my-plugin';
|
||||
// import MyPlugin from 'amb-mediator';
|
||||
|
||||
const core = new BurnerCore({
|
||||
signers: [new InjectedSigner(), new LocalSigner()],
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"packages": [
|
||||
"basic-wallet",
|
||||
"local-wallet",
|
||||
"my-plugin"
|
||||
"amb-mediator"
|
||||
],
|
||||
"npmClient": "yarn",
|
||||
"useWorkspaces": true,
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"@types/react": "16.8.19",
|
||||
"@types/react-dom": "16.8.4",
|
||||
"@types/react-router-dom": "^4.3.3",
|
||||
"my-plugin": "^1.0.0",
|
||||
"amb-mediator": "^1.0.0",
|
||||
"react": "^16.8.6",
|
||||
"react-dom": "^16.8.6",
|
||||
"react-scripts": "^3.2.0",
|
||||
|
|
|
@ -6,7 +6,7 @@ import { InjectedSigner, LocalSigner } from '@burner-wallet/core/signers'
|
|||
import { HTTPGateway } from '@burner-wallet/core/gateways'
|
||||
import ModernUI from '@burner-wallet/modern-ui'
|
||||
import Exchange, { Uniswap, XDaiBridge } from '@burner-wallet/exchange'
|
||||
// import MyPlugin from 'my-plugin';
|
||||
// import MyPlugin from 'amb-mediator';
|
||||
|
||||
const core = new BurnerCore({
|
||||
signers: [new InjectedSigner(), new LocalSigner({ privateKey: process.env.REACT_APP_PK, saveKey: false })],
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
import { BurnerPluginContext, Plugin, Actions } from '@burner-wallet/types'
|
||||
import MyPage from './ui/MyPage'
|
||||
import MyElement from './ui/MyElement'
|
||||
|
||||
interface PluginActionContext {
|
||||
actions: Actions
|
||||
}
|
||||
|
||||
export default class MyPlugin implements Plugin {
|
||||
private pluginContext?: BurnerPluginContext
|
||||
|
||||
initializePlugin(pluginContext: BurnerPluginContext) {
|
||||
this.pluginContext = pluginContext
|
||||
|
||||
pluginContext.addPage('/my-page', MyPage)
|
||||
pluginContext.addButton('apps', 'My Plugin', '/my-page', {
|
||||
description: 'Sample plugin page'
|
||||
})
|
||||
pluginContext.addElement('home-middle', MyElement)
|
||||
|
||||
onQRScanned: (scan: string, ctx: PluginActionContext) => {
|
||||
if (scan === 'My Plugin') {
|
||||
ctx.actions.navigateTo('/my-page')
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async getBlockNum() {
|
||||
const assets = this.pluginContext!.getAssets()
|
||||
const web3 = this.pluginContext!.getWeb3(assets[0].network)
|
||||
const blockNum = web3.eth.getBlockNumber()
|
||||
return blockNum
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
import React, { useEffect, useState } from 'react'
|
||||
import { PluginElementContext } from '@burner-wallet/types'
|
||||
import MyPlugin from '../MyPlugin'
|
||||
|
||||
const MyElement: React.FC<PluginElementContext> = ({ plugin }) => {
|
||||
const [block, setBlock] = useState<string | null>(null)
|
||||
const _plugin = plugin as MyPlugin
|
||||
|
||||
useEffect(() => {
|
||||
_plugin.getBlockNum().then((num: number) => setBlock(num.toString()))
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div>Injected plugin element</div>
|
||||
{block && <div>Current block number: {block}</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default MyElement
|
|
@ -1,15 +0,0 @@
|
|||
import React from 'react'
|
||||
import { PluginPageContext } from '@burner-wallet/types'
|
||||
import { Asset } from '@burner-wallet/assets'
|
||||
|
||||
const MyPage: React.FC<PluginPageContext> = ({ burnerComponents, assets, defaultAccount }) => {
|
||||
const { Page } = burnerComponents
|
||||
return (
|
||||
<Page title="My Page">
|
||||
<div>Account: {defaultAccount}</div>
|
||||
<div>Assets: {assets.map((asset: Asset) => asset.name).join(', ')}</div>
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
|
||||
export default MyPage
|
|
@ -3,6 +3,7 @@
|
|||
"description": "Arbitrary message bridge Burner Wallet 2 plugin",
|
||||
"version": "1.0.0",
|
||||
"license": "GPL-3.0-only",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"install": "lerna bootstrap",
|
||||
"build": "lerna run --ignore local-wallet --ignore basic-wallet build",
|
||||
|
@ -13,7 +14,7 @@
|
|||
"workspaces": [
|
||||
"basic-wallet",
|
||||
"local-wallet",
|
||||
"my-plugin"
|
||||
"amb-mediator"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^2.5.0",
|
||||
|
|
Loading…
Reference in New Issue