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

Use multiple API Augmentations in the same DApp #5779

Open
4 of 10 tasks
peetzweg opened this issue Jan 12, 2024 · 0 comments
Open
4 of 10 tasks

Use multiple API Augmentations in the same DApp #5779

peetzweg opened this issue Jan 12, 2024 · 0 comments
Labels

Comments

@peetzweg
Copy link
Contributor

I was able to augment my API following the docs here and using the new input from this PR polkadot-js/docs#445.

However, I'm struggeling how to get it to work if I want to work with multiple chains in a single project. So I want to have apiChainA and apiChainB properly typed augmented. If I generate both into different folders and import them I get a mixture of both maybe even breaking the api?

  • Bug report
  • Feature request
  • Support request
  • Other
  • What is the current behavior and expected behavior?

Using polkadot-types-from-defs & polkadot-types-from-chain to generate type augmentations with metadata for ChainA and ChainB.

ChainA only has a Balances Pallet, ChainB only has a Identity pallet.

import "./interfaces/chainA/augment-api.ts"
import "./interfaces/chainA/augment-types.ts"

import "./interfaces/chainB/augment-api.ts"
import "./interfaces/chainB/augment-types.ts"


const apiChainA = new ApiPromise({provider:new WsProvider("wss://chainA")})
const apiChainB = new ApiPromise({provider:new WsProvider("wss://chainB")})

// apiChainA and apiChainB both would have `api.tx.balances` and `api.tx.identity`
  • Please tell us about your environment:
  • Version: 10.11.2

    • Node.js
    • Browser
    • Other (limited support for other environments)
  • Language:

    • JavaScript
    • TypeScript (include tsc --version)
    • Other
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants