Skip to content

Use multiple API Augmentations in the same DApp #5779

Open
@peetzweg

Description

@peetzweg

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    SupportTracks issues or requests related to troubleshooting, answering questions, and user assistance.

    Type

    No type

    Projects

    Status

    Support

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions