-
Notifications
You must be signed in to change notification settings - Fork 211
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reviewed your approach and few ideas came to my mind how we can improve it.
-
Do you think it makes sense to introduce a generic gateway (
TokenBridgeGateway
?) similar toInfuraGateway
. This gateway will supply Web3 providers for our chains: ETC, Sokol, POA. If my understanding correct,InfuraGateway
make it happens by using chain id, so, we can do by the same manner. -
What if we introduce a new asset
sPOA
? -
All assets, the gateway and
Bridge.ts
will be placed to thetokenbridge-burnerwallet
directory. It will allow us for every new plugin (in fact, a pair) create a new directory liketokenbridge-burnerwallet-wetcbridge
which will have only two files: the bridge definition (likeWETCBridge.ts
) andindex.ts
.index.ts
will contain only one line in this case. E.g. fortokenbridge-burnerwallet-wetcbridge
it could be:export { default as WETCBridge } from './WETCBridge'
-
We could consider to rename the directories
basic-wallet
andlocal-wallet
tostaging
andtesting
correspondingly (it will also require two docker files: Dockerfile.staging and Dockerfile.testing). Instaging
, we will extend the list ofassets
andpairs
every time when an official plugin is prepared. Intesting
, the code will checkREACT_APP_MODE
to build the corresponding assets and the pair. For example, the code could look like:if ( process.env.REACT_APP_MODE === 'AMB_NATIVE_TO_ERC677' ) { const assetAtHome = new sPOA({id: 'assetAtHome'}) const assetAtForeign = new ERC677Asset({ id: 'assetAtForeign', name: process.env.REACT_APP_FOREIGN_TOKEN_NAME, network: process.env.REACT_APP_FOREIGN_NETWORK, address: process.env.REACT_APP_FOREIGN_TOKEN_ADDRESS }) } else if ( process.env.REACT_APP_MODE === 'AMB_ERC677_TO_ERC677' ) { const assetAtHome = new ERC677Asset({ id: 'assetAtHome', name: process.env.REACT_APP_HOME_TOKEN_NAME, network: process.env.REACT_APP_HOME_NETWORK, address: process.env.REACT_APP_HOME_TOKEN_ADDRESS }) const assetAtForeign = new ERC677Asset({ id: 'assetAtForeign', name: process.env.REACT_APP_FOREIGN_TOKEN_NAME, network: process.env.REACT_APP_FOREIGN_NETWORK, address: process.env.REACT_APP_FOREIGN_TOKEN_ADDRESS }) } const testBridge = new Bridge({ assetA: 'assetAtHome', assetABridge: process.env.REACT_APP_HOME_MEDIATOR_ADDRESS, assetB: 'assetAtForeign', assetBBridge: process.env.REACT_APP_FOREIGN_MEDIATOR_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: [assetAtHome, assetAtForeign] }) const exchange = new Exchange({ pairs: [testBridge] })
Such approach will allow to test the plugins without modifications significant modifications by providing only a correct
.env
file.
What do you think?
Thanks for the ideas! I think they are good improvements.
I think it makes sense, we will be able to use different chains by importing only one gateway
We will be using it in testing so I think it's a good idea |
Applied the proposed improvements, please check. Also, I found an issue that incoming transfers to an ERC677Asset were not displayed in the The fix consisted of overriding the method Another issue I found is with the incoming native transfer of NativeAssets of This is because of how the code works. It looks for the latest blocks. Then looks for each transaction in the block, and check if the transaction has the Is this something we should try to fix? I'm not sure how can we detect those kind native transfers if it is possible. I'll try to think of an approach to fix this at least for our use case. One idea for our use case to explore could be that the bridge pair of the exchange, after performing the exchange and detecting the balance was updated on the other side, if it is a native asset, add into the history event list a new entry for this receiving transfer. But I need to think how to get all the required information, if possible, and what changes will be involved in order for the Bridge Pair to have such functionality. |
For me, it means that the current version of BW does not reflect transfer of xDai tokens from the block reward contract. It looks to be OK for BW authors.
In our cases we have two different scenarios:
For both scenarios we need to watch for logs from the bridge/mediator contracts and judging from the code, the BW does not watch for the bridge logs so far at all. I have added the corresponding comment to your PR in the |
Do you think it is enough to use only the event |
Well, could you say how it will look like from the UX point of view? Will the user see the list of assets transfers the transaction that emits If the transaction is not displayed in the wallet UI to provide more details about the incoming transfer, so, yes - it is enough to use only the event |
PR burner-wallet/burner-wallet-2#24 was merged and a new version was published. I updated the dependencies and now we can display information on the exchange estimate. I added a generic message mentioning the fee in 1a9ccdc Also, added instructions on the plugin Readme to show how to install the package using yarn. 8789d3e
Regarding this issue, we were importing the abis from the We should publish a new preliminary version with these changes and check using it as part of https://github.com/poanetwork/tokenbridge-burner-wallet-plugin |
Updated the displayed message to include the fee percentage ef27817 |
Published a new version for the npm package I found 2 errors. One related to typescript types that also faced in the plugin that I thought I was able to ignore it.
I opened this PR to fix it burner-wallet/burner-wallet-2#25 The other one is related to a dependency that was not correctly specified in the package.json
I fixed it by declaring the dependency correctly for |
Given that the plugin does not use the |
Updated the plugin to use the latest version of I updated the plugin sample repo to include the new version and no error was found this time. |
burner-wallet-plugin/tokenbridge-bw-exchange/src/utils/abis/HomeBridgeNativeToErc.ts
Show resolved
Hide resolved
Co-authored-by: Alexander Kolotov <[email protected]>
…dge into burner-wallet-plugin
Addressed the comments, also updated the license and homepage attributes for the plugin 8c5faee The README was also split and now the introduction, installation and usage sections are included in the plugin package. I think it will now be displayed in the npm page. If changes look good and/or there are no other comments, we should publish a new npm version for the package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am OK with updating the package with the new content and even under the version 1.0.0.
Published the package version |
Relates to omni/tokenbridge-contracts#365
This work was originally submitted on a separate repo and now integrated into the monorepo. Also, the burner-wallet dependencies were updated to the latest version.
The plugin adds the following definitions to be used by the existing Exchange plugin:
Assets:
Gateway:
Pair:
Project structure
tokenbridge-plugin
plugin definitionlocal-wallet
Burner wallet using the plugin with a Native - ERC20 bridge deployed in Sokol - Kovan on top of AMB.basic-wallet
Burner wallet using the plugin with the existing WETC Bridge in mainnet and Classic.I tested the plugin in Sokol - Kovan and also with the WETC Bridge in mainnet and Classic and it worked correctly.
Here are some notes from my initial testing related more to the Burner Wallet user experience rather than the plugin itself:
When instead of using the PK, Metamask or Nifty Wallet is used, the popup to sign the transaction is not triggered when using different networks than the required for the exchange transaction and no feedback is provided. I guess this behavior is Ok but giving some feedback to the user that it is in an incorrect network would help. This is related to the officialAfter upgrading the exchange version, now a message is displayed when the wallet is not on the correct network.exchange
plugin.When using Nifty wallet, the popup to sign the transaction is not triggered for the exchange transaction even when it is set to the correct network. It works correctly when using Metamask. I think it is probably related to the officialThis was fixed with the latest version of Nifty wallet and now works correctly.metamask-plugin
.exchange
plugin, I guess a possible improvement to propose would be to allow Exchange Pairs to set a feedback message after the execution so the user can be informed on the delay due to the bridge operations.