@moonbeam-network/xcm-config 1.0.0-dev.24 → 1.0.0-dev.240

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +14 -8
  3. package/build/assets.d.ts +91 -0
  4. package/build/assets.mjs +179 -0
  5. package/build/assets.mjs.map +1 -0
  6. package/build/chains.d.ts +52 -0
  7. package/build/chains.mjs +102 -0
  8. package/build/chains.mjs.map +1 -0
  9. package/build/chunk-23FA33VA.mjs +127 -0
  10. package/build/chunk-23FA33VA.mjs.map +1 -0
  11. package/build/chunk-4KU7G625.mjs +59 -0
  12. package/build/chunk-4KU7G625.mjs.map +1 -0
  13. package/build/chunk-AACHRWYT.mjs +32 -0
  14. package/build/chunk-AACHRWYT.mjs.map +1 -0
  15. package/build/chunk-B3S2H2Z4.mjs +2329 -0
  16. package/build/chunk-B3S2H2Z4.mjs.map +1 -0
  17. package/build/chunk-BE5TS2QQ.mjs +25 -0
  18. package/build/chunk-BE5TS2QQ.mjs.map +1 -0
  19. package/build/chunk-EPEG6T7K.mjs +523 -0
  20. package/build/chunk-EPEG6T7K.mjs.map +1 -0
  21. package/build/chunk-IHY6QF2X.mjs +5759 -0
  22. package/build/chunk-IHY6QF2X.mjs.map +1 -0
  23. package/build/chunk-JBQOYNQY.mjs +31 -0
  24. package/build/chunk-JBQOYNQY.mjs.map +1 -0
  25. package/build/chunk-WZ3E3RZB.mjs +1378 -0
  26. package/build/chunk-WZ3E3RZB.mjs.map +1 -0
  27. package/build/chunk-Y5YMRWCV.mjs +38 -0
  28. package/build/chunk-Y5YMRWCV.mjs.map +1 -0
  29. package/build/chunk-ZKK445MT.mjs +210 -0
  30. package/build/chunk-ZKK445MT.mjs.map +1 -0
  31. package/build/config-service.d.ts +65 -0
  32. package/build/config-service.mjs +10 -0
  33. package/build/config-service.mjs.map +1 -0
  34. package/build/config-utils.d.ts +6 -0
  35. package/build/config-utils.mjs +11 -0
  36. package/build/config-utils.mjs.map +1 -0
  37. package/build/cross-ecosystem-configs.d.ts +9 -0
  38. package/build/cross-ecosystem-configs.mjs +14 -0
  39. package/build/cross-ecosystem-configs.mjs.map +1 -0
  40. package/build/index.d.ts +13 -359
  41. package/build/index.mjs +320 -1
  42. package/build/index.mjs.map +1 -1
  43. package/build/mrl-configs.d.ts +11 -0
  44. package/build/mrl-configs.mjs +16 -0
  45. package/build/mrl-configs.mjs.map +1 -0
  46. package/build/types/asset-route.d.ts +43 -0
  47. package/build/types/asset-route.mjs +7 -0
  48. package/build/types/asset-route.mjs.map +1 -0
  49. package/build/types/chain-routes.d.ts +23 -0
  50. package/build/types/chain-routes.mjs +11 -0
  51. package/build/types/chain-routes.mjs.map +1 -0
  52. package/build/types/mrl-asset-route.d.ts +36 -0
  53. package/build/types/mrl-asset-route.mjs +8 -0
  54. package/build/types/mrl-asset-route.mjs.map +1 -0
  55. package/build/types/mrl-chain-routes.d.ts +20 -0
  56. package/build/types/mrl-chain-routes.mjs +13 -0
  57. package/build/types/mrl-chain-routes.mjs.map +1 -0
  58. package/build/xcm-configs.d.ts +9 -0
  59. package/build/xcm-configs.mjs +14 -0
  60. package/build/xcm-configs.mjs.map +1 -0
  61. package/package.json +36 -32
  62. package/build/index.cjs +0 -2
  63. package/build/index.cjs.map +0 -1
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2022 PureStake
1
+ Copyright 2024 Moonbeam Foundation
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
package/README.md CHANGED
@@ -1,14 +1,20 @@
1
- ![Moonbeam](https://docs.moonbeam.network/images/builders/interoperability/xcm/sdk/xcm-sdk-banner.png)
1
+ The Config package contains the chains and assets configuration for the Moonbeam XCM SDK and MRL SDK.
2
2
 
3
- The Moonbeam XCM SDK enables developers to easily deposit and withdraw assets to Moonbeam/Moonriver from the relay chain and other parachains in 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 send XCM transfers. To deposit or withdraw assets, you simply define the asset and origin chain you want to deposit from or withdraw back to, along with the sending account's signer, and the amount to send.
3
+ # Documentation for the Moonbeam XCM SDK
4
4
 
5
- # Documentation
5
+ ## v3 (current)
6
6
 
7
- ## v1 (current)
7
+ ### Usage
8
8
 
9
- - TODO: (coming soon)
9
+ - [XCM SDK](https://moonbeam-foundation.github.io/xcm-sdk/latest/example-usage/xcm)
10
+ - [MRL SDK](https://moonbeam-foundation.github.io/xcm-sdk/latest/example-usage/mrl)
10
11
 
11
- ## v0 (previous)
12
+ ### References
12
13
 
13
- - [usage](https://docs.moonbeam.network/builders/xcm/xcm-sdk/xcm-sdk/)
14
- - [references](https://docs.moonbeam.network/builders/xcm/xcm-sdk/reference/)
14
+ - [XCM SDK](https://moonbeam-foundation.github.io/xcm-sdk/latest/reference/xcm)
15
+ - [MRL SDK](https://moonbeam-foundation.github.io/xcm-sdk/latest/reference/mrl)
16
+
17
+ ## v2 (previous)
18
+
19
+ - [usage](https://moonbeam-foundation.github.io/xcm-sdk/v2/example-usage)
20
+ - [references](https://moonbeam-foundation.github.io/xcm-sdk/v2/reference/interfaces)
@@ -0,0 +1,91 @@
1
+ import { Asset } from '@moonbeam-network/xcm-types';
2
+
3
+ declare const aca: Asset;
4
+ declare const agng: Asset;
5
+ declare const alan: Asset;
6
+ declare const ampe: Asset;
7
+ declare const apillon: Asset;
8
+ declare const aseed: Asset;
9
+ declare const astr: Asset;
10
+ declare const auq: Asset;
11
+ declare const axlusdc: Asset;
12
+ declare const bnc: Asset;
13
+ declare const cfg: Asset;
14
+ declare const crab: Asset;
15
+ declare const csm: Asset;
16
+ declare const dai: Asset;
17
+ declare const ded: Asset;
18
+ declare const dev: Asset;
19
+ declare const devBeta: Asset;
20
+ declare const devStage: Asset;
21
+ declare const dot: Asset;
22
+ declare const eq: Asset;
23
+ declare const eqd: Asset;
24
+ declare const eth: Asset;
25
+ declare const eurc: Asset;
26
+ declare const fil: Asset;
27
+ declare const ftm: Asset;
28
+ declare const ftmwh: Asset;
29
+ declare const glmr: Asset;
30
+ declare const hdx: Asset;
31
+ declare const ibtc: Asset;
32
+ declare const intr: Asset;
33
+ declare const kar: Asset;
34
+ declare const kbtc: Asset;
35
+ declare const kint: Asset;
36
+ declare const ksm: Asset;
37
+ declare const lama: Asset;
38
+ declare const laos: Asset;
39
+ declare const ldot: Asset;
40
+ declare const lit: Asset;
41
+ declare const manta: Asset;
42
+ declare const maos: Asset;
43
+ declare const movr: Asset;
44
+ declare const movrsama: Asset;
45
+ declare const neuro: Asset;
46
+ declare const nodl: Asset;
47
+ declare const otp: Asset;
48
+ declare const para: Asset;
49
+ declare const paring: Asset;
50
+ declare const peaq: Asset;
51
+ declare const pen: Asset;
52
+ declare const pha: Asset;
53
+ declare const pica: Asset;
54
+ declare const pink: Asset;
55
+ declare const pizza: Asset;
56
+ declare const ring: Asset;
57
+ declare const rmrk: Asset;
58
+ declare const sdn: Asset;
59
+ declare const soon: Asset;
60
+ declare const stink: Asset;
61
+ declare const sub: Asset;
62
+ declare const teer: Asset;
63
+ declare const tnkr: Asset;
64
+ declare const tt1: Asset;
65
+ declare const tur: Asset;
66
+ declare const unit: Asset;
67
+ declare const usdc: Asset;
68
+ declare const usdcwh: Asset;
69
+ declare const usdt: Asset;
70
+ declare const usdtwh: Asset;
71
+ declare const vastr: Asset;
72
+ declare const vbnc: Asset;
73
+ declare const vdot: Asset;
74
+ declare const vfil: Asset;
75
+ declare const vglmr: Asset;
76
+ declare const vksm: Asset;
77
+ declare const vmanta: Asset;
78
+ declare const vmovr: Asset;
79
+ declare const wbtc: Asset;
80
+ declare const weth: Asset;
81
+ declare const wftm: Asset;
82
+ declare const wifd: Asset;
83
+ declare const xrt: Asset;
84
+ declare const ztg: Asset;
85
+ declare const wbtce: Asset;
86
+ declare const wstethe: Asset;
87
+ declare const wethe: Asset;
88
+ declare const assetsList: Asset[];
89
+ declare const assetsMap: Map<string, Asset>;
90
+
91
+ export { aca, agng, alan, ampe, apillon, aseed, assetsList, assetsMap, astr, auq, axlusdc, bnc, cfg, crab, csm, dai, ded, dev, devBeta, devStage, dot, eq, eqd, eth, eurc, fil, ftm, ftmwh, glmr, hdx, ibtc, intr, kar, kbtc, kint, ksm, lama, laos, ldot, lit, manta, maos, movr, movrsama, neuro, nodl, otp, para, paring, peaq, pen, pha, pica, pink, pizza, ring, rmrk, sdn, soon, stink, sub, teer, tnkr, tt1, tur, unit, usdc, usdcwh, usdt, usdtwh, vastr, vbnc, vdot, vfil, vglmr, vksm, vmanta, vmovr, wbtc, wbtce, weth, wethe, wftm, wifd, wstethe, xrt, ztg };
@@ -0,0 +1,179 @@
1
+ import {
2
+ aca,
3
+ agng,
4
+ alan,
5
+ ampe,
6
+ apillon,
7
+ aseed,
8
+ assetsList,
9
+ assetsMap,
10
+ astr,
11
+ auq,
12
+ axlusdc,
13
+ bnc,
14
+ cfg,
15
+ crab,
16
+ csm,
17
+ dai,
18
+ ded,
19
+ dev,
20
+ devBeta,
21
+ devStage,
22
+ dot,
23
+ eq,
24
+ eqd,
25
+ eth,
26
+ eurc,
27
+ fil,
28
+ ftm,
29
+ ftmwh,
30
+ glmr,
31
+ hdx,
32
+ ibtc,
33
+ intr,
34
+ kar,
35
+ kbtc,
36
+ kint,
37
+ ksm,
38
+ lama,
39
+ laos,
40
+ ldot,
41
+ lit,
42
+ manta,
43
+ maos,
44
+ movr,
45
+ movrsama,
46
+ neuro,
47
+ nodl,
48
+ otp,
49
+ para,
50
+ paring,
51
+ peaq,
52
+ pen,
53
+ pha,
54
+ pica,
55
+ pink,
56
+ pizza,
57
+ ring,
58
+ rmrk,
59
+ sdn,
60
+ soon,
61
+ stink,
62
+ sub,
63
+ teer,
64
+ tnkr,
65
+ tt1,
66
+ tur,
67
+ unit,
68
+ usdc,
69
+ usdcwh,
70
+ usdt,
71
+ usdtwh,
72
+ vastr,
73
+ vbnc,
74
+ vdot,
75
+ vfil,
76
+ vglmr,
77
+ vksm,
78
+ vmanta,
79
+ vmovr,
80
+ wbtc,
81
+ wbtce,
82
+ weth,
83
+ wethe,
84
+ wftm,
85
+ wifd,
86
+ wstethe,
87
+ xrt,
88
+ ztg
89
+ } from "./chunk-EPEG6T7K.mjs";
90
+ export {
91
+ aca,
92
+ agng,
93
+ alan,
94
+ ampe,
95
+ apillon,
96
+ aseed,
97
+ assetsList,
98
+ assetsMap,
99
+ astr,
100
+ auq,
101
+ axlusdc,
102
+ bnc,
103
+ cfg,
104
+ crab,
105
+ csm,
106
+ dai,
107
+ ded,
108
+ dev,
109
+ devBeta,
110
+ devStage,
111
+ dot,
112
+ eq,
113
+ eqd,
114
+ eth,
115
+ eurc,
116
+ fil,
117
+ ftm,
118
+ ftmwh,
119
+ glmr,
120
+ hdx,
121
+ ibtc,
122
+ intr,
123
+ kar,
124
+ kbtc,
125
+ kint,
126
+ ksm,
127
+ lama,
128
+ laos,
129
+ ldot,
130
+ lit,
131
+ manta,
132
+ maos,
133
+ movr,
134
+ movrsama,
135
+ neuro,
136
+ nodl,
137
+ otp,
138
+ para,
139
+ paring,
140
+ peaq,
141
+ pen,
142
+ pha,
143
+ pica,
144
+ pink,
145
+ pizza,
146
+ ring,
147
+ rmrk,
148
+ sdn,
149
+ soon,
150
+ stink,
151
+ sub,
152
+ teer,
153
+ tnkr,
154
+ tt1,
155
+ tur,
156
+ unit,
157
+ usdc,
158
+ usdcwh,
159
+ usdt,
160
+ usdtwh,
161
+ vastr,
162
+ vbnc,
163
+ vdot,
164
+ vfil,
165
+ vglmr,
166
+ vksm,
167
+ vmanta,
168
+ vmovr,
169
+ wbtc,
170
+ wbtce,
171
+ weth,
172
+ wethe,
173
+ wftm,
174
+ wifd,
175
+ wstethe,
176
+ xrt,
177
+ ztg
178
+ };
179
+ //# sourceMappingURL=assets.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,52 @@
1
+ import { Parachain, EvmParachain, EvmChain, AnyChain } from '@moonbeam-network/xcm-types';
2
+
3
+ declare const acala: Parachain;
4
+ declare const alphanetAssetHub: Parachain;
5
+ declare const alphanetRelay: Parachain;
6
+ declare const astar: Parachain;
7
+ declare const bifrostKusama: Parachain;
8
+ declare const bifrostPolkadot: Parachain;
9
+ declare const centrifuge: Parachain;
10
+ declare const crustShadow: Parachain;
11
+ declare const darwinia: EvmParachain;
12
+ declare const darwiniaCrab: EvmParachain;
13
+ declare const ethereum: EvmChain;
14
+ declare const fantomTestnet: EvmChain;
15
+ declare const hydration: Parachain;
16
+ declare const hydrationAlphanet: Parachain;
17
+ declare const integritee: Parachain;
18
+ declare const interlay: Parachain;
19
+ declare const karura: Parachain;
20
+ declare const kintsugi: Parachain;
21
+ declare const kusama: Parachain;
22
+ declare const kusamaAssetHub: Parachain;
23
+ declare const mantaParachain: Parachain;
24
+ declare const laosAlphanet: EvmParachain;
25
+ declare const laosMainnet: EvmParachain;
26
+ declare const moonbaseAlpha: EvmParachain;
27
+ declare const moonbaseBeta: EvmParachain;
28
+ declare const moonbaseStage: EvmParachain;
29
+ declare const moonlama: EvmParachain;
30
+ declare const moonsama: EvmParachain;
31
+ declare const moonbeam: EvmParachain;
32
+ declare const moonriver: EvmParachain;
33
+ declare const neuroweb: Parachain;
34
+ declare const originTrailAlphanet: Parachain;
35
+ declare const peaqAlphanet: Parachain;
36
+ declare const peaqChain: Parachain;
37
+ declare const peaqEvm: EvmParachain;
38
+ declare const peaqEvmAlphanet: EvmParachain;
39
+ declare const pendulum: Parachain;
40
+ declare const pendulumAlphanet: Parachain;
41
+ declare const phala: Parachain;
42
+ declare const polkadot: Parachain;
43
+ declare const polkadotAssetHub: Parachain;
44
+ declare const robonomics: Parachain;
45
+ declare const shiden: Parachain;
46
+ declare const turingAlphanet: Parachain;
47
+ declare const uniqueAlpha: Parachain;
48
+ declare const zeitgeist: Parachain;
49
+ declare const chainsList: AnyChain[];
50
+ declare const chainsMap: Map<string, AnyChain>;
51
+
52
+ export { acala, alphanetAssetHub, alphanetRelay, astar, bifrostKusama, bifrostPolkadot, centrifuge, chainsList, chainsMap, crustShadow, darwinia, darwiniaCrab, ethereum, fantomTestnet, hydration, hydrationAlphanet, integritee, interlay, karura, kintsugi, kusama, kusamaAssetHub, laosAlphanet, laosMainnet, mantaParachain, moonbaseAlpha, moonbaseBeta, moonbaseStage, moonbeam, moonlama, moonriver, moonsama, neuroweb, originTrailAlphanet, peaqAlphanet, peaqChain, peaqEvm, peaqEvmAlphanet, pendulum, pendulumAlphanet, phala, polkadot, polkadotAssetHub, robonomics, shiden, turingAlphanet, uniqueAlpha, zeitgeist };
@@ -0,0 +1,102 @@
1
+ import {
2
+ acala,
3
+ alphanetAssetHub,
4
+ alphanetRelay,
5
+ astar,
6
+ bifrostKusama,
7
+ bifrostPolkadot,
8
+ centrifuge,
9
+ chainsList,
10
+ chainsMap,
11
+ crustShadow,
12
+ darwinia,
13
+ darwiniaCrab,
14
+ ethereum,
15
+ fantomTestnet,
16
+ hydration,
17
+ hydrationAlphanet,
18
+ integritee,
19
+ interlay,
20
+ karura,
21
+ kintsugi,
22
+ kusama,
23
+ kusamaAssetHub,
24
+ laosAlphanet,
25
+ laosMainnet,
26
+ mantaParachain,
27
+ moonbaseAlpha,
28
+ moonbaseBeta,
29
+ moonbaseStage,
30
+ moonbeam,
31
+ moonlama,
32
+ moonriver,
33
+ moonsama,
34
+ neuroweb,
35
+ originTrailAlphanet,
36
+ peaqAlphanet,
37
+ peaqChain,
38
+ peaqEvm,
39
+ peaqEvmAlphanet,
40
+ pendulum,
41
+ pendulumAlphanet,
42
+ phala,
43
+ polkadot,
44
+ polkadotAssetHub,
45
+ robonomics,
46
+ shiden,
47
+ turingAlphanet,
48
+ uniqueAlpha,
49
+ zeitgeist
50
+ } from "./chunk-B3S2H2Z4.mjs";
51
+ import "./chunk-EPEG6T7K.mjs";
52
+ export {
53
+ acala,
54
+ alphanetAssetHub,
55
+ alphanetRelay,
56
+ astar,
57
+ bifrostKusama,
58
+ bifrostPolkadot,
59
+ centrifuge,
60
+ chainsList,
61
+ chainsMap,
62
+ crustShadow,
63
+ darwinia,
64
+ darwiniaCrab,
65
+ ethereum,
66
+ fantomTestnet,
67
+ hydration,
68
+ hydrationAlphanet,
69
+ integritee,
70
+ interlay,
71
+ karura,
72
+ kintsugi,
73
+ kusama,
74
+ kusamaAssetHub,
75
+ laosAlphanet,
76
+ laosMainnet,
77
+ mantaParachain,
78
+ moonbaseAlpha,
79
+ moonbaseBeta,
80
+ moonbaseStage,
81
+ moonbeam,
82
+ moonlama,
83
+ moonriver,
84
+ moonsama,
85
+ neuroweb,
86
+ originTrailAlphanet,
87
+ peaqAlphanet,
88
+ peaqChain,
89
+ peaqEvm,
90
+ peaqEvmAlphanet,
91
+ pendulum,
92
+ pendulumAlphanet,
93
+ phala,
94
+ polkadot,
95
+ polkadotAssetHub,
96
+ robonomics,
97
+ shiden,
98
+ turingAlphanet,
99
+ uniqueAlpha,
100
+ zeitgeist
101
+ };
102
+ //# sourceMappingURL=chains.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,127 @@
1
+ import {
2
+ getKey
3
+ } from "./chunk-AACHRWYT.mjs";
4
+ import {
5
+ chainsMap
6
+ } from "./chunk-B3S2H2Z4.mjs";
7
+ import {
8
+ assetsMap
9
+ } from "./chunk-EPEG6T7K.mjs";
10
+
11
+ // src/ConfigService/ConfigService.ts
12
+ var ConfigService = class {
13
+ assets;
14
+ chains;
15
+ routes;
16
+ constructor(options) {
17
+ this.assets = options.assets ?? assetsMap;
18
+ this.chains = options.chains ?? chainsMap;
19
+ this.routes = options.routes;
20
+ }
21
+ getAsset(keyOrAsset) {
22
+ const key = getKey(keyOrAsset);
23
+ const asset = this.assets.get(key);
24
+ if (!asset) {
25
+ throw new Error(`Asset ${key} not found`);
26
+ }
27
+ return asset;
28
+ }
29
+ getEcosystemAssets(ecosystem) {
30
+ if (!ecosystem) {
31
+ return Array.from(this.assets.values());
32
+ }
33
+ return Array.from(
34
+ new Set(
35
+ Array.from(this.routes.values()).filter((routes) => routes.chain.ecosystem === ecosystem).map((routes) => routes.getRoutes()).flat(2).map((route) => route.source.asset)
36
+ )
37
+ ).sort((a, b) => a.key.localeCompare(b.key));
38
+ }
39
+ getChain(keyOrChain) {
40
+ const key = getKey(keyOrChain);
41
+ const chain = this.chains.get(key);
42
+ if (!chain) {
43
+ throw new Error(`Chain ${key} not found`);
44
+ }
45
+ return chain;
46
+ }
47
+ getChainRoutes(keyOrChain) {
48
+ const key = getKey(keyOrChain);
49
+ const route = this.routes.get(key);
50
+ if (!route) {
51
+ throw new Error(`ChainRoute for ${key} not found`);
52
+ }
53
+ return route;
54
+ }
55
+ getSourceChains({
56
+ asset,
57
+ ecosystem
58
+ }) {
59
+ const routes = Array.from(this.routes.values()).filter(
60
+ (chainRoutes) => !ecosystem || chainRoutes.chain.ecosystem === ecosystem
61
+ );
62
+ if (!asset) {
63
+ return routes.map((route) => route.chain);
64
+ }
65
+ return routes.filter((route) => route.getAssetRoutes(asset).length).map((route) => route.chain);
66
+ }
67
+ getDestinationChains({
68
+ asset,
69
+ source
70
+ }) {
71
+ const chainRoutes = this.getChainRoutes(source);
72
+ if (asset) {
73
+ return chainRoutes.getAssetDestinations(asset);
74
+ }
75
+ return Array.from(
76
+ new Set(
77
+ chainRoutes.getRoutes().map((routes) => routes.destination.chain)
78
+ )
79
+ );
80
+ }
81
+ getAssetRoute({
82
+ asset,
83
+ source,
84
+ destination
85
+ }) {
86
+ const routes = this.getChainRoutes(source);
87
+ return routes.getAssetRoute(asset, destination);
88
+ }
89
+ getRouteAssets({
90
+ source,
91
+ destination
92
+ }) {
93
+ const routes = this.getChainRoutes(source);
94
+ return routes.getDestinationAssets(destination);
95
+ }
96
+ updateAsset(asset) {
97
+ this.assets.set(asset.key, asset);
98
+ }
99
+ updateChain(chain) {
100
+ this.chains.set(chain.key, chain);
101
+ }
102
+ updateChainRoute(route) {
103
+ this.routes.set(route.chain.key, route);
104
+ }
105
+ updateEndpoints(endpoints) {
106
+ for (const [chainKey, endpoint] of Object.entries(endpoints)) {
107
+ let chain = this.chains.get(chainKey);
108
+ if (!chain) continue;
109
+ if ("ws" in chain && endpoint.ws.length && endpoint.ws.at(0)) {
110
+ chain = chain.copyWith({
111
+ ws: endpoint.ws
112
+ });
113
+ }
114
+ if ("rpc" in chain && endpoint.rpc) {
115
+ chain = chain.copyWith({
116
+ rpc: endpoint.rpc
117
+ });
118
+ }
119
+ this.chains.set(chainKey, chain);
120
+ }
121
+ }
122
+ };
123
+
124
+ export {
125
+ ConfigService
126
+ };
127
+ //# sourceMappingURL=chunk-23FA33VA.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ConfigService/ConfigService.ts"],"sourcesContent":["import type {\n AnyAsset,\n AnyChain,\n Asset,\n Ecosystem,\n} from '@moonbeam-network/xcm-types';\nimport { assetsMap } from '../assets';\nimport { chainsMap } from '../chains';\nimport { getKey } from '../config.utils';\nimport type { AssetRoute } from '../types/AssetRoute';\nimport type { ChainRoutes } from '../types/ChainRoutes';\nimport type { MrlAssetRoute } from '../types/MrlAssetRoute';\nimport type { MrlChainRoutes } from '../types/MrlChainRoutes';\n\n/**\n * Configuration options for initializing the ConfigService.\n * This interface defines the structure for configuring assets, chains, routes, and endpoints.\n */\nexport interface ConfigServiceOptions {\n /**\n * Optional map of assets where the key is the asset identifier and the value is the Asset object.\n * If not provided, defaults to the predefined assetsMap.\n */\n assets?: Map<string, Asset>;\n\n /**\n * Optional map of chains where the key is the chain identifier and the value is the Chain object.\n * If not provided, defaults to the predefined chainsMap.\n */\n chains?: Map<string, AnyChain>;\n\n /**\n * Routes configuration.\n */\n routes: Map<string, ChainRoutes | MrlChainRoutes>;\n}\nexport class ConfigService {\n protected assets: Map<string, Asset>;\n\n protected chains: Map<string, AnyChain>;\n\n protected routes: Map<string, ChainRoutes | MrlChainRoutes>;\n\n constructor(options: ConfigServiceOptions) {\n this.assets = options.assets ?? assetsMap;\n this.chains = options.chains ?? chainsMap;\n this.routes = options.routes;\n }\n\n getAsset(keyOrAsset: string | Asset): Asset {\n const key = getKey(keyOrAsset);\n const asset = this.assets.get(key);\n\n if (!asset) {\n throw new Error(`Asset ${key} not found`);\n }\n\n return asset;\n }\n\n getEcosystemAssets(ecosystem?: Ecosystem): Asset[] {\n if (!ecosystem) {\n return Array.from(this.assets.values());\n }\n\n return Array.from(\n new Set(\n Array.from(this.routes.values())\n .filter((routes) => routes.chain.ecosystem === ecosystem)\n .map((routes) => routes.getRoutes())\n .flat(2)\n .map((route) => route.source.asset),\n ),\n ).sort((a, b) => a.key.localeCompare(b.key));\n }\n\n getChain(keyOrChain: string | AnyChain): AnyChain {\n const key = getKey(keyOrChain);\n const chain = this.chains.get(key);\n\n if (!chain) {\n throw new Error(`Chain ${key} not found`);\n }\n\n return chain;\n }\n\n getChainRoutes(keyOrChain: string | AnyChain): ChainRoutes | MrlChainRoutes {\n const key = getKey(keyOrChain);\n const route = this.routes.get(key);\n\n if (!route) {\n throw new Error(`ChainRoute for ${key} not found`);\n }\n\n return route;\n }\n\n getSourceChains({\n asset,\n ecosystem,\n }: {\n asset?: string | Asset;\n ecosystem?: Ecosystem;\n }): AnyChain[] {\n const routes = Array.from(this.routes.values()).filter(\n (chainRoutes) => !ecosystem || chainRoutes.chain.ecosystem === ecosystem,\n );\n\n if (!asset) {\n return routes.map((route) => route.chain);\n }\n\n return routes\n .filter((route) => route.getAssetRoutes(asset).length)\n .map((route) => route.chain);\n }\n\n getDestinationChains({\n asset,\n source,\n }: {\n asset?: string | AnyAsset;\n source: string | AnyChain;\n }): AnyChain[] {\n const chainRoutes = this.getChainRoutes(source);\n\n if (asset) {\n return chainRoutes.getAssetDestinations(asset);\n }\n\n return Array.from(\n new Set(\n chainRoutes.getRoutes().map((routes) => routes.destination.chain),\n ),\n );\n }\n\n getAssetRoute({\n asset,\n source,\n destination,\n }: {\n asset: string | AnyAsset;\n source: string | AnyChain;\n destination: string | AnyChain;\n }): AssetRoute | MrlAssetRoute {\n const routes = this.getChainRoutes(source);\n\n return routes.getAssetRoute(asset, destination);\n }\n\n getRouteAssets({\n source,\n destination,\n }: {\n source: string | AnyChain;\n destination: string | AnyChain;\n }): Asset[] {\n const routes = this.getChainRoutes(source);\n\n return routes.getDestinationAssets(destination);\n }\n\n updateAsset(asset: Asset): void {\n this.assets.set(asset.key, asset);\n }\n\n updateChain(chain: AnyChain): void {\n this.chains.set(chain.key, chain);\n }\n\n updateChainRoute(route: ChainRoutes): void {\n this.routes.set(route.chain.key, route);\n }\n\n updateEndpoints(endpoints: {\n [key: string]: {\n rpc: string;\n ws: string[];\n };\n }): void {\n for (const [chainKey, endpoint] of Object.entries(endpoints)) {\n let chain = this.chains.get(chainKey);\n if (!chain) continue;\n\n if ('ws' in chain && endpoint.ws.length && endpoint.ws.at(0)) {\n chain = chain.copyWith({\n ws: endpoint.ws,\n });\n }\n\n if ('rpc' in chain && endpoint.rpc) {\n chain = chain.copyWith({\n rpc: endpoint.rpc,\n });\n }\n\n this.chains.set(chainKey, chain);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAoCO,IAAM,gBAAN,MAAoB;AAAA,EACf;AAAA,EAEA;AAAA,EAEA;AAAA,EAEV,YAAY,SAA+B;AACzC,SAAK,SAAS,QAAQ,UAAU;AAChC,SAAK,SAAS,QAAQ,UAAU;AAChC,SAAK,SAAS,QAAQ;AAAA,EACxB;AAAA,EAEA,SAAS,YAAmC;AAC1C,UAAM,MAAM,OAAO,UAAU;AAC7B,UAAM,QAAQ,KAAK,OAAO,IAAI,GAAG;AAEjC,QAAI,CAAC,OAAO;AACV,YAAM,IAAI,MAAM,SAAS,GAAG,YAAY;AAAA,IAC1C;AAEA,W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AAA,UACrB,KAAK,SAAS;AAAA,QAChB,CAAC;AAAA,MACH;AAEA,WAAK,OAAO,IAAI,UAAU,KAAK;AAAA,IACjC;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,59 @@
1
+ import {
2
+ getKey
3
+ } from "./chunk-AACHRWYT.mjs";
4
+ import {
5
+ AssetRoute
6
+ } from "./chunk-JBQOYNQY.mjs";
7
+
8
+ // src/types/ChainRoutes.ts
9
+ var ChainRoutes = class {
10
+ chain;
11
+ routes;
12
+ constructor({ chain, routes }) {
13
+ this.chain = chain;
14
+ this.routes = new Map(
15
+ routes.map(({ source, destination, contract, extrinsic, monitoring }) => [
16
+ `${source.asset.key}-${destination.chain.key}`,
17
+ new AssetRoute({
18
+ source: { ...source, chain },
19
+ destination,
20
+ contract,
21
+ extrinsic,
22
+ monitoring
23
+ })
24
+ ])
25
+ );
26
+ }
27
+ getRoutes() {
28
+ return Array.from(this.routes.values());
29
+ }
30
+ getAssetRoutes(keyOrAsset) {
31
+ const key = getKey(keyOrAsset);
32
+ return this.getRoutes().filter((route) => route.source.asset.key === key);
33
+ }
34
+ getAssetDestinations(keyOrAsset) {
35
+ return this.getAssetRoutes(keyOrAsset).map(
36
+ (assetConfig) => assetConfig.destination.chain
37
+ );
38
+ }
39
+ getDestinationAssets(keyOrChain) {
40
+ const key = getKey(keyOrChain);
41
+ return this.getRoutes().filter((route) => route.destination.chain.key === key).map((route) => route.source.asset);
42
+ }
43
+ getAssetRoute(asset, destination) {
44
+ const assetKey = getKey(asset);
45
+ const destKey = getKey(destination);
46
+ const route = this.routes.get(`${assetKey}-${destKey}`);
47
+ if (!route) {
48
+ throw new Error(
49
+ `AssetRoute for asset ${assetKey} and destination ${destKey} not found`
50
+ );
51
+ }
52
+ return route;
53
+ }
54
+ };
55
+
56
+ export {
57
+ ChainRoutes
58
+ };
59
+ //# sourceMappingURL=chunk-4KU7G625.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/ChainRoutes.ts"],"sourcesContent":["import type { AnyAsset, AnyChain, Asset } from '@moonbeam-network/xcm-types';\nimport { getKey } from '../config.utils';\nimport {\n AssetRoute,\n type AssetRouteConstructorParams,\n type SourceConfig,\n} from './AssetRoute';\n\nexport interface ChainRoutesConstructorParams {\n chain: AnyChain;\n routes: RoutesParam[];\n}\n\ninterface RoutesParam extends Omit<AssetRouteConstructorParams, 'source'> {\n source: Omit<SourceConfig, 'chain'>;\n}\n\nexport class ChainRoutes {\n readonly chain: AnyChain;\n\n protected routes: Map<string, AssetRoute>;\n\n constructor({ chain, routes }: ChainRoutesConstructorParams) {\n this.chain = chain;\n this.routes = new Map(\n routes.map(({ source, destination, contract, extrinsic, monitoring }) => [\n `${source.asset.key}-${destination.chain.key}`,\n new AssetRoute({\n source: { ...source, chain },\n destination,\n contract,\n extrinsic,\n monitoring,\n }),\n ]),\n );\n }\n\n getRoutes(): AssetRoute[] {\n return Array.from(this.routes.values());\n }\n\n getAssetRoutes(keyOrAsset: string | AnyAsset): AssetRoute[] {\n const key = getKey(keyOrAsset);\n\n return this.getRoutes().filter((route) => route.source.asset.key === key);\n }\n\n getAssetDestinations(keyOrAsset: string | AnyAsset): AnyChain[] {\n return this.getAssetRoutes(keyOrAsset).map(\n (assetConfig) => assetConfig.destination.chain,\n );\n }\n\n getDestinationAssets(keyOrChain: string | AnyChain): Asset[] {\n const key = getKey(keyOrChain);\n\n return this.getRoutes()\n .filter((route) => route.destination.chain.key === key)\n .map((route) => route.source.asset);\n }\n\n getAssetRoute(\n asset: string | AnyAsset,\n destination: string | AnyChain,\n ): AssetRoute {\n const assetKey = getKey(asset);\n const destKey = getKey(destination);\n const route = this.routes.get(`${assetKey}-${destKey}`);\n\n if (!route) {\n throw new Error(\n `AssetRoute for asset ${assetKey} and destination ${destKey} not found`,\n );\n }\n\n return route;\n }\n}\n"],"mappings":";;;;;;;;AAiBO,IAAM,cAAN,MAAkB;AAAA,EACd;AAAA,EAEC;AAAA,EAEV,YAAY,EAAE,OAAO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