Go to file
Gerardo Nardelli f4d844efd2 Add STAKE token example for testing and mainnet 2020-04-28 15:10:34 -03:00
my-plugin Add STAKE token example for testing and mainnet 2020-04-28 15:10:34 -03:00
test-wallet Add STAKE token example for testing and mainnet 2020-04-28 15:10:34 -03:00
wallet Add STAKE token example for testing and mainnet 2020-04-28 15:10:34 -03:00
.editorconfig update repo information 2020-03-20 16:25:12 -03:00
.eslintignore add linter 2020-03-20 16:14:46 -03:00
.eslintrc.js add linter 2020-03-20 16:14:46 -03:00
.gitignore fix dependencies versions 2020-03-20 15:15:08 -03:00
.nvmrc add .nvmrc 2020-03-20 17:15:32 -03:00
.prettierrc add linter 2020-03-20 16:14:46 -03:00
Dockerfile Add STAKE token example for testing and mainnet 2020-04-28 15:10:34 -03:00
LICENSE update repo information 2020-03-20 16:25:12 -03:00
README.md Add STAKE token example for testing and mainnet 2020-04-28 15:10:34 -03:00
docker-compose.yml Add STAKE token example for testing and mainnet 2020-04-28 15:10:34 -03:00
lerna.json Add STAKE token example for testing and mainnet 2020-04-28 15:10:34 -03:00
package.json Add STAKE token example for testing and mainnet 2020-04-28 15:10:34 -03:00
tsconfig.json Update to 1.0 packages 2019-11-25 23:58:29 -05:00
yarn.lock Add @poanet/tokenbridge-bw-exchange 2020-04-27 16:57:32 -03:00

README.md

TokenBridge Burner Wallet 2 Plugin Sample

This sample plugin defines a mediator extension exchange pair to be used in the Exchange Plugin in the burner wallet. It uses the resources from the tokenbridge-plugin package to define new assets and exchange pairs.

Clone the sample repo

Clone the sample repo to create a plugin project that uses the TokenBridge plugin. This sample repo containes a ready to publish plugin for a ERC677 to ERC677 bridge extension, but you can later modify it to define your own resources.

Project structure

There are two main folders in the project:

  • 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 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.

Install dependencies

Run yarn install. This repo uses Lerna and Yarn Workspaces, so yarn install will install all dependencies and link modules in the repo.

Build

To build the plugin package, from the root folder of project, you need to run the following command:

yarn build

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=<your key from infura.com>
  1. 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:
REACT_APP_INFURA_KEY=<your key from infura.com>
  1. To start the burner wallet instances run:
yarn start-wallet

Publish to npm

In order to make the plugin accessible it needs to be published in the npm registry. For that, you can follow these steps:

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

  2. Go to my-plugin folder

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

  4. Update version in my-plugin/package.json

  5. Run yarn publish and fill login information if required. The prompt will ask for the new version, complete it with the version from my-plugin/package.json

More information in https://classic.yarnpkg.com/en/docs/publishing-a-package/