dhiway / cord.js

Cord JS API
Apache License 2.0
34 stars 46 forks source link

Feature to support multi chains for CORD.js SDK #225

Closed vatsa287 closed 2 weeks ago

vatsa287 commented 1 month ago

Updated all modules with method docs to support object based network connection & destruction.

For demo below working scripts are updated to demonstrate the same.

Example Usage:


  let network = "api-1";
  await Cord.connect(networkAddress, network);
  const api = Cord.ConfigService.get(network);

  const space = await Cord.ChainSpace.dispatchToChain(
    spaceProperties,
    issuerDid.uri,
    networkAuthorityIdentity,
    async ({ data }) => ({
      signature: issuerKeys.authentication.sign(data),
      keyType: issuerKeys.authentication.type,
    }),
    network
  )

Similarly the disconnect should be made using api-1 itself. Usage of api-2 for ex. when chain is connected to api-1 object would result in error.

Where network is a optional parameter.

One more minor feature left as TODO is having ability to use dynamic variable names for the api without the use of ApiPromise type definition externally to avoid type missing warnings at some places. Ex:

const api_1: ApiPromise = Cord.ConfigService.get(network);

The target branch for this PR is base:multichain