From 246d253951a63ed356498973e09ac8eaa8e2617d Mon Sep 17 00:00:00 2001 From: Rikkard29 Date: Tue, 12 Dec 2023 17:37:32 +0100 Subject: [PATCH] =?UTF-8?q?Use=20Mangata=20SDK=20to=20create=20ApiPromise?= =?UTF-8?q?=20for=20Mangata=20=E2=9B=93=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + pnpm-lock.yaml | 235 ++++++++++++++++++++++++++++++++- src/index.ts | 10 +- src/maps/consts.ts | 2 + src/nodes/ParachainNode.ts | 7 +- src/nodes/supported/Mangata.ts | 8 ++ src/types.ts | 7 +- src/utils.ts | 12 +- 8 files changed, 275 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 55ac852e..3cf55a9c 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ } }, "dependencies": { + "@mangata-finance/sdk": "^2.1.1", "ethers": "^5.7.1" }, "peerDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 49f48b6c..6f019253 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,9 +1,12 @@ lockfileVersion: '6.0' dependencies: + '@mangata-finance/sdk': + specifier: ^2.1.1 + version: 2.1.1(@polkadot/api@10.9.1)(@polkadot/types@10.9.1) '@polkadot/api': specifier: ^10.6.1 - version: 10.11.1 + version: 10.9.1 '@polkadot/api-base': specifier: ^10.6.1 version: 10.6.1 @@ -12,7 +15,7 @@ dependencies: version: 0.133.1(@polkadot/keyring@12.6.1)(@polkadot/util-crypto@12.6.1)(react-dom@18.2.0)(react-is@18.2.0)(react@18.2.0) '@polkadot/types': specifier: ^10.6.1 - version: 10.11.1 + version: 10.9.1 '@polkadot/util': specifier: ^12.6.1 || 12 version: 12.6.1 @@ -2028,6 +2031,20 @@ packages: - utf-8-validate dev: false + /@mangata-finance/sdk@2.1.1(@polkadot/api@10.9.1)(@polkadot/types@10.9.1): + resolution: {integrity: sha512-Sbge0swlR2oFTi4QR6my2RjZ0T01SbKICYO2NOgT2ipUcva3gbpt0B+O/FJ7WfckrAYVsiTUmBmQc76euAgxxA==} + engines: {node: '>=18.0.0'} + peerDependencies: + '@polkadot/api': 10.9.1 + dependencies: + '@mangata-finance/type-definitions': 2.0.0(@polkadot/types@10.9.1) + '@polkadot/api': 10.9.1 + big.js: 6.2.1 + tslog: 4.8.2 + transitivePeerDependencies: + - '@polkadot/types' + dev: false + /@mangata-finance/type-definitions@2.0.0(@polkadot/types@10.11.1): resolution: {integrity: sha512-N8o0PgeSjTsb5MLfdsZD/DsD1BldBqrvRZ/KaanPY1ESFAAEu+B9BebSUZm/XFDm9GzQpOZqNg9KaZsghx4E5A==} engines: {node: '>=18.0.0'} @@ -2037,6 +2054,15 @@ packages: '@polkadot/types': 10.11.1 dev: false + /@mangata-finance/type-definitions@2.0.0(@polkadot/types@10.9.1): + resolution: {integrity: sha512-N8o0PgeSjTsb5MLfdsZD/DsD1BldBqrvRZ/KaanPY1ESFAAEu+B9BebSUZm/XFDm9GzQpOZqNg9KaZsghx4E5A==} + engines: {node: '>=18.0.0'} + peerDependencies: + '@polkadot/types': 10.9.1 + dependencies: + '@polkadot/types': 10.9.1 + dev: false + /@metaverse-network-sdk/type-definitions@0.0.1-16: resolution: {integrity: sha512-lo1NbA0gi+Tu23v4cTkN/oxEhQxaf3QxQ2qvUUfTxDU7a1leYp2Bw3IcoUvqHAGb/PPp8bNmYQfAKXsjqp+LZw==} dependencies: @@ -2153,6 +2179,23 @@ packages: - utf-8-validate dev: false + /@polkadot/api-augment@10.9.1: + resolution: {integrity: sha512-kRZZvCFVcN4hAH4dJ+Qzfdy27/4EEq3oLDf3ihj0LTVrAezSWcKPGE3EVFy+Mn6Lo4SUc7RVyoKvIUhSk2l4Dg==} + engines: {node: '>=16'} + dependencies: + '@polkadot/api-base': 10.9.1 + '@polkadot/rpc-augment': 10.9.1 + '@polkadot/types': 10.9.1 + '@polkadot/types-augment': 10.9.1 + '@polkadot/types-codec': 10.9.1 + '@polkadot/util': 12.6.1 + tslib: 2.6.2 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + dev: false + /@polkadot/api-augment@7.15.1: resolution: {integrity: sha512-7csQLS6zuYuGq7W1EkTBz1ZmxyRvx/Qpz7E7zPSwxmY8Whb7Yn2effU9XF0eCcRpyfSW8LodF8wMmLxGYs1OaQ==} engines: {node: '>=14.0.0'} @@ -2216,6 +2259,21 @@ packages: - utf-8-validate dev: false + /@polkadot/api-base@10.9.1: + resolution: {integrity: sha512-Q3m2KzlceMK2kX8bhnUZWk3RT6emmijeeFZZQgCePpEcrSeNjnqG4qjuTPgkveaOkUT8MAoDc5Avuzcc2jlW9g==} + engines: {node: '>=16'} + dependencies: + '@polkadot/rpc-core': 10.9.1 + '@polkadot/types': 10.9.1 + '@polkadot/util': 12.6.1 + rxjs: 7.8.1 + tslib: 2.6.2 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + dev: false + /@polkadot/api-base@7.15.1: resolution: {integrity: sha512-UlhLdljJPDwGpm5FxOjvJNFTxXMRFaMuVNx6EklbuetbBEJ/Amihhtj0EJRodxQwtZ4ZtPKYKt+g+Dn7OJJh4g==} engines: {node: '>=14.0.0'} @@ -2265,6 +2323,26 @@ packages: - utf-8-validate dev: false + /@polkadot/api-derive@10.9.1: + resolution: {integrity: sha512-mRud1UZCFIc4Z63qAoGSIHh/foyUYADfy1RQYCmPpeFKfIdCIrHpd7xFdJXTOMYOS0BwlM6u4qli/ZT4XigezQ==} + engines: {node: '>=16'} + dependencies: + '@polkadot/api': 10.9.1 + '@polkadot/api-augment': 10.9.1 + '@polkadot/api-base': 10.9.1 + '@polkadot/rpc-core': 10.9.1 + '@polkadot/types': 10.9.1 + '@polkadot/types-codec': 10.9.1 + '@polkadot/util': 12.6.1 + '@polkadot/util-crypto': 12.6.1(@polkadot/util@12.6.1) + rxjs: 7.8.1 + tslib: 2.6.2 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + dev: false + /@polkadot/api-derive@7.15.1: resolution: {integrity: sha512-CsOQppksQBaa34L1fWRzmfQQpoEBwfH0yTTQxgj3h7rFYGVPxEKGeFjo1+IgI2vXXvOO73Z8E4H/MnbxvKrs1Q==} engines: {node: '>=14.0.0'} @@ -2331,6 +2409,33 @@ packages: - utf-8-validate dev: false + /@polkadot/api@10.9.1: + resolution: {integrity: sha512-ND/2UqZBWvtt4PfV03OStTKg0mxmPk4UpMAgJKutdgsz/wP9CYJ1KbjwFgPNekL9JnzbKQsWyQNPVrcw7kQk8A==} + engines: {node: '>=16'} + dependencies: + '@polkadot/api-augment': 10.9.1 + '@polkadot/api-base': 10.9.1 + '@polkadot/api-derive': 10.9.1 + '@polkadot/keyring': 12.6.1(@polkadot/util-crypto@12.6.1)(@polkadot/util@12.6.1) + '@polkadot/rpc-augment': 10.9.1 + '@polkadot/rpc-core': 10.9.1 + '@polkadot/rpc-provider': 10.9.1 + '@polkadot/types': 10.9.1 + '@polkadot/types-augment': 10.9.1 + '@polkadot/types-codec': 10.9.1 + '@polkadot/types-create': 10.9.1 + '@polkadot/types-known': 10.9.1 + '@polkadot/util': 12.6.1 + '@polkadot/util-crypto': 12.6.1(@polkadot/util@12.6.1) + eventemitter3: 5.0.1 + rxjs: 7.8.1 + tslib: 2.6.2 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + dev: false + /@polkadot/api@7.15.1: resolution: {integrity: sha512-z0z6+k8+R9ixRMWzfsYrNDnqSV5zHKmyhTCL0I7+1I081V18MJTCFUKubrh0t1gD0/FCt3U9Ibvr4IbtukYLrQ==} engines: {node: '>=14.0.0'} @@ -2641,6 +2746,21 @@ packages: - utf-8-validate dev: false + /@polkadot/rpc-augment@10.9.1: + resolution: {integrity: sha512-MaLHkNlyqN20ZRYr6uNd1BZr1OsrnX9qLAmsl0mcrri1vPGRH6VHjfFH1RBLkikpWD82v17g0l2hLwdV1ZHMcw==} + engines: {node: '>=16'} + dependencies: + '@polkadot/rpc-core': 10.9.1 + '@polkadot/types': 10.9.1 + '@polkadot/types-codec': 10.9.1 + '@polkadot/util': 12.6.1 + tslib: 2.6.2 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + dev: false + /@polkadot/rpc-augment@7.15.1: resolution: {integrity: sha512-sK0+mphN7nGz/eNPsshVi0qd0+N0Pqxuebwc1YkUGP0f9EkDxzSGp6UjGcSwWVaAtk9WZZ1MpK1Jwb/2GrKV7Q==} engines: {node: '>=14.0.0'} @@ -2702,6 +2822,22 @@ packages: - utf-8-validate dev: false + /@polkadot/rpc-core@10.9.1: + resolution: {integrity: sha512-ZtA8B8SfXSAwVkBlCcKRHw0eSM7ec/sbiNOM5GasXPeRujUgT7lOwSH2GbUZSqe9RfRDMp6DvO9c2JoGc3LLWw==} + engines: {node: '>=16'} + dependencies: + '@polkadot/rpc-augment': 10.9.1 + '@polkadot/rpc-provider': 10.9.1 + '@polkadot/types': 10.9.1 + '@polkadot/util': 12.6.1 + rxjs: 7.8.1 + tslib: 2.6.2 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + dev: false + /@polkadot/rpc-core@7.15.1: resolution: {integrity: sha512-4Sb0e0PWmarCOizzxQAE1NQSr5z0n+hdkrq3+aPohGu9Rh4PodG+OWeIBy7Ov/3GgdhNQyBLG+RiVtliXecM3g==} engines: {node: '>=14.0.0'} @@ -2781,6 +2917,30 @@ packages: - utf-8-validate dev: false + /@polkadot/rpc-provider@10.9.1: + resolution: {integrity: sha512-4QzT2QzD+320+eT6b79sGAA85Tt3Bb8fQvse4r5Mom2iiBd2SO81vOhxSAOaIe4GUsw25VzFJmsbe7+OObItdg==} + engines: {node: '>=16'} + dependencies: + '@polkadot/keyring': 12.6.1(@polkadot/util-crypto@12.6.1)(@polkadot/util@12.6.1) + '@polkadot/types': 10.9.1 + '@polkadot/types-support': 10.9.1 + '@polkadot/util': 12.6.1 + '@polkadot/util-crypto': 12.6.1(@polkadot/util@12.6.1) + '@polkadot/x-fetch': 12.6.1 + '@polkadot/x-global': 12.6.1 + '@polkadot/x-ws': 12.6.1 + eventemitter3: 5.0.1 + mock-socket: 9.3.1 + nock: 13.4.0 + tslib: 2.6.2 + optionalDependencies: + '@substrate/connect': 0.7.26 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + dev: false + /@polkadot/rpc-provider@7.15.1: resolution: {integrity: sha512-n0RWfSaD/r90JXeJkKry1aGZwJeBUUiMpXUQ9Uvp6DYBbYEDs0fKtWLpdT3PdFrMbe5y3kwQmNLxwe6iF4+mzg==} engines: {node: '>=14.0.0'} @@ -2847,6 +3007,16 @@ packages: tslib: 2.6.2 dev: false + /@polkadot/types-augment@10.9.1: + resolution: {integrity: sha512-OY9/jTMFRFqYdkUnfcGwqMLC64A0Q25bjvCuVQCVjsPFKE3wl0Kt5rNT01eV2UmLXrR6fY0xWbR2w80bLA7CIQ==} + engines: {node: '>=16'} + dependencies: + '@polkadot/types': 10.9.1 + '@polkadot/types-codec': 10.9.1 + '@polkadot/util': 12.6.1 + tslib: 2.6.2 + dev: false + /@polkadot/types-augment@7.15.1: resolution: {integrity: sha512-aqm7xT/66TCna0I2utpIekoquKo0K5pnkA/7WDzZ6gyD8he2h0IXfe8xWjVmuyhjxrT/C/7X1aUF2Z0xlOCwzQ==} engines: {node: '>=14.0.0'} @@ -2885,6 +3055,15 @@ packages: tslib: 2.6.2 dev: false + /@polkadot/types-codec@10.9.1: + resolution: {integrity: sha512-mJ5OegKGraY1FLvEa8FopRCr3pQrhDkcn5RNOjmgJQozENVeRaxhk0NwxYz7IojFvSDnKnc6lNQfKaaSe5pLHg==} + engines: {node: '>=16'} + dependencies: + '@polkadot/util': 12.6.1 + '@polkadot/x-bigint': 12.6.1 + tslib: 2.6.2 + dev: false + /@polkadot/types-codec@7.15.1: resolution: {integrity: sha512-nI11dT7FGaeDd/fKPD8iJRFGhosOJoyjhZ0gLFFDlKCaD3AcGBRTTY8HFJpP/5QXXhZzfZsD93fVKrosnegU0Q==} engines: {node: '>=14.0.0'} @@ -2920,6 +3099,15 @@ packages: tslib: 2.6.2 dev: false + /@polkadot/types-create@10.9.1: + resolution: {integrity: sha512-OVz50MGTTuiuVnRP/zAx4CTuLioc0hsiwNwqN2lNhmIJGtnQ4Vy/7mQRsIWehiYz6g0Vzzm5B3qWkTXO1NSN5w==} + engines: {node: '>=16'} + dependencies: + '@polkadot/types-codec': 10.9.1 + '@polkadot/util': 12.6.1 + tslib: 2.6.2 + dev: false + /@polkadot/types-create@7.15.1: resolution: {integrity: sha512-+HiaHn7XOwP0kv/rVdORlVkNuMoxuvt+jd67A/CeEreJiXqRLu+S61Mdk7wi6719PTaOal1hTDFfyGrtUd8FSQ==} engines: {node: '>=14.0.0'} @@ -2950,6 +3138,18 @@ packages: tslib: 2.6.2 dev: false + /@polkadot/types-known@10.9.1: + resolution: {integrity: sha512-zCMVWc4pJtkbMFPu72bD4IhvV/gkHXPX3C5uu92WdmCfnn0vEIEsMKWlVXVVvQQZKAqvs/awpqIfrUtEViOGEA==} + engines: {node: '>=16'} + dependencies: + '@polkadot/networks': 12.6.1 + '@polkadot/types': 10.9.1 + '@polkadot/types-codec': 10.9.1 + '@polkadot/types-create': 10.9.1 + '@polkadot/util': 12.6.1 + tslib: 2.6.2 + dev: false + /@polkadot/types-known@4.17.1: resolution: {integrity: sha512-YkOwGrO+k9aVrBR8FgYHnfJKhOfpdgC5ZRYNL/xJ9oa7lBYqPts9ENAxeBmJS/5IGeDF9f32MNyrCP2umeCXWg==} engines: {node: '>=14.0.0'} @@ -3010,6 +3210,14 @@ packages: tslib: 2.6.2 dev: false + /@polkadot/types-support@10.9.1: + resolution: {integrity: sha512-XsieuLDsszvMZQlleacQBfx07i/JkwQV/UxH9q8Hz7Okmaz9pEVEW1h3ka2/cPuC7a4l32JhaORBUYshBZNdJg==} + engines: {node: '>=16'} + dependencies: + '@polkadot/util': 12.6.1 + tslib: 2.6.2 + dev: false + /@polkadot/types-support@7.15.1: resolution: {integrity: sha512-FIK251ffVo+NaUXLlaJeB5OvT7idDd3uxaoBM6IwsS87rzt2CcWMyCbu0uX89AHZUhSviVx7xaBxfkGEqMePWA==} engines: {node: '>=14.0.0'} @@ -3054,6 +3262,20 @@ packages: tslib: 2.6.2 dev: false + /@polkadot/types@10.9.1: + resolution: {integrity: sha512-AG33i2ZGGfq7u+5rkAdGrXAQHHl844/Yv+junH5ZzX69xiCoWO1bH/yzDUNBdpki2GlACWvF9nLYh3F2tVF93w==} + engines: {node: '>=16'} + dependencies: + '@polkadot/keyring': 12.6.1(@polkadot/util-crypto@12.6.1)(@polkadot/util@12.6.1) + '@polkadot/types-augment': 10.9.1 + '@polkadot/types-codec': 10.9.1 + '@polkadot/types-create': 10.9.1 + '@polkadot/util': 12.6.1 + '@polkadot/util-crypto': 12.6.1(@polkadot/util@12.6.1) + rxjs: 7.8.1 + tslib: 2.6.2 + dev: false + /@polkadot/types@4.17.1: resolution: {integrity: sha512-rjW4OFdwvFekzN3ATLibC2JPSd8AWt5YepJhmuCPdwH26r3zB8bEC6dM7YQExLVUmygVPvgXk5ffHI6RAdXBMg==} engines: {node: '>=14.0.0'} @@ -4822,6 +5044,10 @@ packages: resolution: {integrity: sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==} dev: false + /big.js@6.2.1: + resolution: {integrity: sha512-bCtHMwL9LeDIozFn+oNhhFoq+yQ3BNdnsLSASUxLciOb1vgvpHsIO1dsENiGMgbb4SkP5TrzWzRiLddn8ahVOQ==} + dev: false + /blakejs@1.2.1: resolution: {integrity: sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ==} dev: false @@ -8137,6 +8363,11 @@ packages: /tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} + /tslog@4.8.2: + resolution: {integrity: sha512-eAKIRjxfSKYLs06r1wT7oou6Uv9VN6NW9g0JPidBlqQwPBBl5+84dm7r8zSOPVq1kyfEw1P6B3/FLSpZCorAgA==} + engines: {node: '>=16'} + dev: false + /tweetnacl@1.0.3: resolution: {integrity: sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==} dev: false diff --git a/src/index.ts b/src/index.ts index 35bba174..8ba9041c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,6 +9,12 @@ export * from './pallets/assets' export * from './pallets/builder' export * from './pallets/pallets' export * from './types' -export { NODE_NAMES, SUPPORTED_PALLETS } from './maps/consts' -export { getNodeEndpointOption, getNode, getNodeProvider, getAllNodeProviders } from './utils' +export { NODE_NAMES, NODES_WITH_RELAY_CHAINS, SUPPORTED_PALLETS } from './maps/consts' +export { + getNodeEndpointOption, + getNode, + getNodeProvider, + getAllNodeProviders, + createApiInstanceForNode +} from './utils' export * from './errors' diff --git a/src/maps/consts.ts b/src/maps/consts.ts index 063ddbf2..1cda3439 100644 --- a/src/maps/consts.ts +++ b/src/maps/consts.ts @@ -106,6 +106,8 @@ export const NODE_NAMES = [ 'Zeitgeist' ] as const +export const NODES_WITH_RELAY_CHAINS = [...NODE_NAMES, 'Polkadot', 'Kusama'] as const + export const nodes: Record = { AssetHubPolkadot: new AssetHubPolkadot(), Acala: new Acala(), diff --git a/src/nodes/ParachainNode.ts b/src/nodes/ParachainNode.ts index 10eca074..4eff5e04 100644 --- a/src/nodes/ParachainNode.ts +++ b/src/nodes/ParachainNode.ts @@ -19,7 +19,8 @@ import { getFees, createHeaderPolkadotXCM, createCurrencySpecification, - getAllNodeProviders + getAllNodeProviders, + createApiInstance } from '../utils' import { constructRelayToParaParameters } from '../pallets/xcmPallet/utils' @@ -142,6 +143,10 @@ abstract class ParachainNode { getProvider(): string { return getAllNodeProviders(this.node)[0] } + + async createApiInstance(): Promise { + return await createApiInstance(this.getProvider()) + } } export default ParachainNode diff --git a/src/nodes/supported/Mangata.ts b/src/nodes/supported/Mangata.ts index b730349d..0a0a063d 100644 --- a/src/nodes/supported/Mangata.ts +++ b/src/nodes/supported/Mangata.ts @@ -1,5 +1,6 @@ // Contains detailed structure of XCM call construction for Mangata Parachain +import { type ApiPromise } from '@polkadot/api' import { type IXTokensTransfer, Version, @@ -18,6 +19,13 @@ class Mangata extends ParachainNode implements IXTokensTransfer { transferXTokens(input: XTokensTransferInput): Extrinsic | TSerializedApiCall { return XTokensTransferImpl.transferXTokens(input, input.currencyID) } + + async createApiInstance(): Promise { + const MangataSDK = await import('@mangata-finance/sdk') + const Mangata = MangataSDK.Mangata + const mangataInstance = Mangata.instance([this.getProvider()]) + return await mangataInstance.api() + } } export default Mangata diff --git a/src/types.ts b/src/types.ts index 907140c3..d563c4d3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2,7 +2,11 @@ import { type ApiPromise } from '@polkadot/api' import { type SubmittableExtrinsic } from '@polkadot/api/types' -import { type NODE_NAMES, type SUPPORTED_PALLETS } from './maps/consts' +import { + type NODES_WITH_RELAY_CHAINS, + type NODE_NAMES, + type SUPPORTED_PALLETS +} from './maps/consts' export type UpdateFunction = (name: string, index: number) => string export type Extrinsic = SubmittableExtrinsic<'promise'> @@ -10,6 +14,7 @@ export type ExtrinsicFunction = (arg: T) => Extrinsic export type TRelayChainType = 'polkadot' | 'kusama' export type TRelayChainSymbol = 'DOT' | 'KSM' export type TNode = (typeof NODE_NAMES)[number] +export type TNodeWithRelayChains = (typeof NODES_WITH_RELAY_CHAINS)[number] export interface TAssetDetails { assetId: string symbol?: string diff --git a/src/utils.ts b/src/utils.ts index c9f97c54..e5a122ef 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -9,7 +9,8 @@ import { type TScenario, type TSerializedApiCall, Version, - type Extrinsic + type Extrinsic, + type TNodeWithRelayChains } from './types' import { nodes } from './maps/consts' import type ParachainNode from './nodes/ParachainNode' @@ -307,6 +308,15 @@ export const createApiInstance = async (wsUrl: string): Promise => { return await ApiPromise.create({ provider: wsProvider }) } +export const createApiInstanceForNode = async (node: TNodeWithRelayChains): Promise => { + if (node === 'Polkadot' || node === 'Kusama') { + const endpointOption = node === 'Polkadot' ? prodRelayPolkadot : prodRelayKusama + const wsUrl = Object.values(endpointOption.providers)[0] + return await createApiInstance(wsUrl) + } + return await getNode(node).createApiInstance() +} + export const lowercaseFirstLetter = (str: string): string => str.charAt(0).toLowerCase() + str.slice(1)