Skip to content
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

Blockchain adder and switcher #1

Open
jondubois opened this issue Mar 12, 2021 · 0 comments
Open

Blockchain adder and switcher #1

jondubois opened this issue Mar 12, 2021 · 0 comments

Comments

@jondubois
Copy link
Contributor

jondubois commented Mar 12, 2021

The ldpos-wallet application should support adding and switching between different blockchain networks.

The ldpos-client library already supports this feature as part of the createClient function. For example:

  let client = createClient({
    hostname: blockchainNodeIp,
    port: blockchainNodePort,
    networkSymbol: 'clsk',
    chainModuleName: 'capitalisk_chain'
  });

There are 3 parts to this feature:

1. A config.json file for default blockchains

The config.json file should be an object with a top-level blockchains property which is a list of config objects for different blockchains which are supported by ldpos-wallet by default (out of the box). There should be 2 different config.json files; one for mainnet and one for testnet.

Each config object in this array should be in the format (example for testnet of capitalisk blockchain):

{
  "hostname": "34.227.22.98",
  "port": "7001",
  "networkSymbol": "clsk",
  "chainModuleName": "capitalisk_chain"
}

When it starts up, ldpos-wallet should load all the available blockchains from this config.json file. The first entry in the list should be treated as the default blockchain to connect to (Capitalisk by default).

2. A mechanism for adding new blockchains to the config.json

In order to add support for a new blockchain on their ldpos-wallet app, a non-technical user needs a mechanism to add a new entry to the config.json file without actually having to actually physically modify the config.json file or having to restart the app.

A simple modal which prompts for hostname, port, networkSymbol and chainModuleName with a save button should suffice.
For hostname and port, the user just needs to point to any node within the target blockchain network.

Once the user clicks on the save button, it should update the config.json file with the new entry (be sure to not mix up testnet versus mainnet config files).

3. A mechanism for switching to one of the available blockchains

The user should be able to make the ldpos-wallet app point to any blockchain which it knows about.
This includes blockchain config objects which were inside config.json during launch as well as new blockchain config objects which were added using the modal as described in part 2.

It can be a simple dropdown. When the user selects the blockchain to switch to, it should create a new LDPoSClient instance by providing the config values for that target blockchain to the createClient function:

  let client = createClient({
    hostname: blockchainNodeIp,
    port: blockchainNodePort,
    networkSymbol: 'clsk',
    chainModuleName: 'capitalisk_chain'
  });

Make sure that you client.disconnect() and discard the reference to the old client before creating a new client.

If the user was already logged in when they switch to the different blockchain, client.connect(...) should be called and the existing (last used) passphrase should be provided. The same passphrase can work with any LDPoS-based blockchain; the client.walletAddress will be different.

The fact that the same passphrase can be used for multiple networks will be the basis for the 'quick convert' feature which we will implement later. The switching mechanism needs to be as seamless as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant