Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

multiple chains x same module #499

Closed
harrysolovay opened this issue Jan 8, 2023 · 0 comments · Fixed by #641
Closed

multiple chains x same module #499

harrysolovay opened this issue Jan 8, 2023 · 0 comments · Fixed by #641

Comments

@harrysolovay
Copy link
Contributor

Let's say we're using a Capi pattern lib multisig_util.

import * as multisigUtil from "multisig_util"

Let's use an import map to specify the chain.

import_map.json

{
  "scopes": {
    "multisig_util/": {
      "#chain": "<the-compass>"
    }
  }
}

What if we want to utilize this lib twice in the same file, with two different chains? Given this approach, we cannot.

On one hand, we could design libs such that the "compass" needs to be injected into instances at runtime.

import { MultisigUtil } from "multisig_util"

const multisigUtil = new MultisigUtil(client)

But this is lackluster, as one does not get the type-checking against the target chain (not ideal).

I believe we'll need to tackle this via the codegen server (#471)

import * as multisigUtil from "http://localhost:8000/...compass.../lib/multisig_util/mod.ts"

How would this look with the import-mapped lead?

import * as multisigUtil from "#polkadot/lib/multisig_util/mod.ts"

I suppose any valid import spec could follow /lib (as well as anything defined within the import map)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant