moonbeam-foundation / xcm-sdk

The Moonbeam XCM SDK enables developers to easily transfer assets between chains, either between parachains or between a parachain and the relay chain, within the Polkadot/Kusama ecosystem. With the SDK, you don't need to worry about determining the multilocation of the origin or destination assets or which extrinsics are used on which networks to
https://moonbeam-foundation.github.io/xcm-sdk/latest/
MIT License
14 stars 9 forks source link

Multiple WsProvider support for chains #231

Closed ap211unitech closed 4 months ago

ap211unitech commented 6 months ago

In current chain configuration, We can put only one provider for a chain. but native polkadot API connector can accept an array of multiple providers. It would be great to have this functionality in SDK as well. It would be better for having a reliable connection with blockchain.

For e.g. -

export const assetHub = new Parachain({
  assetsData: [
    {
      asset: dot,
      decimals: 10,
      id: 0,
    },
    {
      asset: usdt,
      decimals: 6,
      id: 1984,
      palletInstance: 50,
    },
  ],
  ecosystem: Ecosystem.Polkadot,
  genesisHash:
    "0x68d56f15f85d3136970ec16946040bc1752654e906147f7e43e9d539d7c3de2f",
  key: "assethub",
  name: "AssetHub",
  parachainId: 1000,
  ss58Format: 42,
  ws: "wss://polkadot-asset-hub-rpc.polkadot.io",  // Only one WS provider
});

but Polkadot API connector can support it like this -


const apiUrl = ["wss://statemint.public.curie.radiumblock.co/ws", "wss://statemint-rpc.dwellir.com", "wss://statemint.api.onfinality.io/public-ws"]

export async function createApi(apiUrl: string[]): Promise<void> {
  const provider = new WsProvider(apiUrl, RECONNECT_TIME_MS);
  statics.api = new ApiPromise({
    provider,
    runtime: { ...runtime, ...apiTypes.runtime },
    types: { ...types, ...apiTypes.types },
    rpc: { ...rpc, ...apiTypes.rpc },
    signedExtensions: {
      ChargeAssetTxPayment: {
        extrinsic: {
          tip: "Compact<Balance>",
          assetId: "Option<u128>",
        },
        payload: {},
      },
    },
  });
}

Would like to know if we can have this feature.

ekenigs commented 6 months ago

@ap211unitech hey, sorry for the delayed answer. I think what you are proposing makes sense and I had this in my mind for a while but we could not implement this yet. You can wait until we have time or if you really need this you can submit a PR and we will review it.

ekenigs commented 4 months ago

Will be published in this release https://github.com/moonbeam-foundation/xcm-sdk/pull/274