@snowbridge/registry 0.3.3 → 0.4.1-beta.1
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.
- package/.turbo/turbo-build.log +1 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -2
- package/dist/local_e2e_bridge_info.g.d.ts +141 -0
- package/dist/local_e2e_bridge_info.g.d.ts.map +1 -0
- package/dist/local_e2e_bridge_info.g.js +142 -0
- package/dist/paseo_sepolia_bridge_info.g.d.ts +331 -0
- package/dist/paseo_sepolia_bridge_info.g.d.ts.map +1 -0
- package/dist/paseo_sepolia_bridge_info.g.js +351 -0
- package/dist/polkadot_mainnet_bridge_info.g.d.ts +2137 -0
- package/dist/polkadot_mainnet_bridge_info.g.d.ts.map +1 -0
- package/dist/polkadot_mainnet_bridge_info.g.js +2454 -0
- package/dist/transfers.d.ts +3 -8
- package/dist/transfers.d.ts.map +1 -1
- package/dist/transfers.js +73 -215
- package/dist/westend_sepolia_bridge_info.g.d.ts +432 -0
- package/dist/westend_sepolia_bridge_info.g.d.ts.map +1 -0
- package/dist/westend_sepolia_bridge_info.g.js +487 -0
- package/package.json +7 -7
- package/scripts/buildRegistry.ts +609 -37
- package/src/index.ts +27 -2
- package/src/local_e2e_bridge_info.g.ts +140 -0
- package/src/paseo_sepolia_bridge_info.g.ts +350 -0
- package/src/polkadot_mainnet_bridge_info.g.ts +2477 -0
- package/src/transfers.ts +72 -265
- package/src/westend_sepolia_bridge_info.g.ts +495 -0
- package/dist/environment.d.ts +0 -3
- package/dist/environment.d.ts.map +0 -1
- package/dist/environment.js +0 -181
- package/dist/local_e2e.registry.json +0 -391
- package/dist/paseo_sepolia.registry.json +0 -231
- package/dist/polkadot_mainnet.registry.json +0 -1805
- package/dist/registry.d.ts +0 -3
- package/dist/registry.d.ts.map +0 -1
- package/dist/registry.js +0 -61
- package/dist/westend_sepolia.registry.json +0 -283
- package/src/environment.ts +0 -185
- package/src/local_e2e.registry.json +0 -391
- package/src/paseo_sepolia.registry.json +0 -231
- package/src/polkadot_mainnet.registry.json +0 -1805
- package/src/registry.ts +0 -63
- package/src/westend_sepolia.registry.json +0 -283
package/dist/transfers.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import { AssetRegistry,
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function getSubstrateTransferLocation(parachain: Parachain): TransferLocation;
|
|
5
|
-
export declare function getTransferLocation(registry: AssetRegistry, sourceType: string, sourceKey: string): TransferLocation;
|
|
6
|
-
export declare function getTransferLocationKusama(registry: AssetRegistry, network: string, parachainId: string): TransferLocation;
|
|
7
|
-
export declare function getTransferLocations(registry: AssetRegistry, filter?: (path: Path) => boolean): Source[];
|
|
8
|
-
export declare function defaultPathFilter(envName: string): (_: Path) => boolean;
|
|
1
|
+
import { AssetRegistry, TransferLocation, Source, ChainId, TransferRoute } from "@snowbridge/base-types";
|
|
2
|
+
export declare function getTransferLocation(registry: AssetRegistry, chain: ChainId): TransferLocation;
|
|
3
|
+
export declare function getTransferLocations(routes: readonly TransferRoute[]): Source[];
|
|
9
4
|
//# sourceMappingURL=transfers.d.ts.map
|
package/dist/transfers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfers.d.ts","sourceRoot":"","sources":["../src/transfers.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,
|
|
1
|
+
{"version":3,"file":"transfers.d.ts","sourceRoot":"","sources":["../src/transfers.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EACb,gBAAgB,EAChB,MAAM,EAGN,OAAO,EACP,aAAa,EAChB,MAAM,wBAAwB,CAAA;AAE/B,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,GAAG,gBAAgB,CA6D7F;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,MAAM,EAAE,CAuB/E"}
|
package/dist/transfers.js
CHANGED
|
@@ -1,238 +1,96 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transferSourcesFor = transferSourcesFor;
|
|
4
|
-
exports.getEthereumTransferLocation = getEthereumTransferLocation;
|
|
5
|
-
exports.getSubstrateTransferLocation = getSubstrateTransferLocation;
|
|
6
3
|
exports.getTransferLocation = getTransferLocation;
|
|
7
|
-
exports.getTransferLocationKusama = getTransferLocationKusama;
|
|
8
4
|
exports.getTransferLocations = getTransferLocations;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
type: "ethereum",
|
|
24
|
-
key: ethChain.chainId.toString(),
|
|
25
|
-
ethChain,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
const evmChain = registry.parachains[ethChain.evmParachainId];
|
|
30
|
-
return {
|
|
31
|
-
id: ethChain.id,
|
|
32
|
-
name: `${evmChain.info.name} (EVM)`,
|
|
33
|
-
key: ethChain.chainId.toString(),
|
|
34
|
-
type: "ethereum",
|
|
35
|
-
ethChain,
|
|
36
|
-
parachain: evmChain,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function getSubstrateTransferLocation(parachain) {
|
|
41
|
-
return {
|
|
42
|
-
id: parachain.info.specName,
|
|
43
|
-
name: parachain.info.name,
|
|
44
|
-
key: parachain.parachainId.toString(),
|
|
45
|
-
type: "substrate",
|
|
46
|
-
parachain,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function getTransferLocation(registry, sourceType, sourceKey) {
|
|
50
|
-
if (sourceType === "ethereum") {
|
|
51
|
-
return getEthereumTransferLocation(registry, registry.ethereumChains[sourceKey]);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
return getSubstrateTransferLocation(registry.parachains[sourceKey]);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function getTransferLocationKusama(registry, network, parachainId) {
|
|
58
|
-
if (network === "kusama" && registry.kusama) {
|
|
59
|
-
return getSubstrateTransferLocation(registry.kusama?.parachains[parachainId]);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
return getSubstrateTransferLocation(registry.parachains[parachainId]);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function getTransferLocations(registry, filter) {
|
|
66
|
-
const ethChain = registry.ethereumChains[registry.ethChainId];
|
|
67
|
-
const parachains = Object.keys(registry.parachains)
|
|
68
|
-
.filter((p) => p !== registry.bridgeHubParaId.toString())
|
|
69
|
-
.map((p) => registry.parachains[p]);
|
|
70
|
-
const pathFilter = filter ?? defaultPathFilter(registry.environment);
|
|
71
|
-
const locations = [];
|
|
72
|
-
const ethAssets = Object.keys(ethChain.assets);
|
|
73
|
-
// Bridged paths
|
|
74
|
-
for (const parachain of parachains) {
|
|
75
|
-
const destinationAssets = Object.keys(parachain.assets);
|
|
76
|
-
const commonAssets = new Set(ethAssets.filter((sa) => destinationAssets.find((da) => da === sa)));
|
|
77
|
-
for (const asset of commonAssets) {
|
|
78
|
-
const p1 = {
|
|
79
|
-
type: "ethereum",
|
|
80
|
-
id: "ethereum",
|
|
81
|
-
source: ethChain.chainId,
|
|
82
|
-
destinationType: "substrate",
|
|
83
|
-
destination: parachain.parachainId,
|
|
84
|
-
asset,
|
|
5
|
+
function getTransferLocation(registry, chain) {
|
|
6
|
+
switch (chain.kind) {
|
|
7
|
+
case "kusama": {
|
|
8
|
+
if (!registry.kusama)
|
|
9
|
+
throw Error(`Kusama not configured.`);
|
|
10
|
+
const key = `${chain.kind}_${chain.id}`;
|
|
11
|
+
const parachain = registry.kusama.parachains[key];
|
|
12
|
+
if (!parachain)
|
|
13
|
+
throw Error(`Cannot find chain ${key}`);
|
|
14
|
+
return {
|
|
15
|
+
id: parachain.id,
|
|
16
|
+
kind: parachain.kind,
|
|
17
|
+
key: parachain.key,
|
|
18
|
+
parachain,
|
|
85
19
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
20
|
+
}
|
|
21
|
+
case "polkadot": {
|
|
22
|
+
const key = `${chain.kind}_${chain.id}`;
|
|
23
|
+
const parachain = registry.parachains[key];
|
|
24
|
+
if (!parachain)
|
|
25
|
+
throw Error(`Cannot find chain ${key}`);
|
|
26
|
+
return {
|
|
27
|
+
id: parachain.id,
|
|
28
|
+
kind: parachain.kind,
|
|
29
|
+
key: parachain.key,
|
|
30
|
+
parachain,
|
|
96
31
|
};
|
|
97
|
-
|
|
98
|
-
|
|
32
|
+
}
|
|
33
|
+
case "ethereum": {
|
|
34
|
+
const key = `${chain.kind}_${chain.id}`;
|
|
35
|
+
const ethChain = registry.ethereumChains[key];
|
|
36
|
+
if (!ethChain)
|
|
37
|
+
throw Error(`Cannot find chain ${key}`);
|
|
38
|
+
if (!ethChain.evmParachainId) {
|
|
39
|
+
return {
|
|
40
|
+
kind: ethChain.kind,
|
|
41
|
+
id: ethChain.id,
|
|
42
|
+
key: ethChain.key,
|
|
43
|
+
ethChain,
|
|
44
|
+
};
|
|
99
45
|
}
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
46
|
+
else {
|
|
47
|
+
const evmChain = registry.parachains[`polkadot_${ethChain.evmParachainId}`];
|
|
48
|
+
return {
|
|
49
|
+
kind: ethChain.kind,
|
|
50
|
+
id: ethChain.id,
|
|
51
|
+
key: ethChain.key,
|
|
52
|
+
ethChain,
|
|
53
|
+
parachain: evmChain,
|
|
108
54
|
};
|
|
109
|
-
if (pathFilter(p3)) {
|
|
110
|
-
locations.push(p3);
|
|
111
|
-
}
|
|
112
55
|
}
|
|
113
56
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
destinationAssets.find((da) => da === sa)));
|
|
125
|
-
for (const asset of commonAssets) {
|
|
126
|
-
const p1 = {
|
|
127
|
-
type: "substrate",
|
|
128
|
-
id: assetHub.info.specName,
|
|
129
|
-
source: assetHub.parachainId,
|
|
130
|
-
destinationType: "substrate",
|
|
131
|
-
destination: parachain.parachainId,
|
|
132
|
-
asset,
|
|
57
|
+
case "ethereum_l2": {
|
|
58
|
+
const key = `${chain.kind}_${chain.id}`;
|
|
59
|
+
const ethChain = registry.ethereumChains[key];
|
|
60
|
+
if (!ethChain)
|
|
61
|
+
throw Error(`Cannot find chain ${key}`);
|
|
62
|
+
return {
|
|
63
|
+
kind: ethChain.kind,
|
|
64
|
+
id: ethChain.id,
|
|
65
|
+
key: ethChain.key,
|
|
66
|
+
ethChain,
|
|
133
67
|
};
|
|
134
|
-
if (pathFilter(p1)) {
|
|
135
|
-
locations.push(p1);
|
|
136
|
-
}
|
|
137
|
-
const p2 = {
|
|
138
|
-
type: "substrate",
|
|
139
|
-
id: parachain.info.specName,
|
|
140
|
-
source: parachain.parachainId,
|
|
141
|
-
destinationType: "substrate",
|
|
142
|
-
destination: assetHub.parachainId,
|
|
143
|
-
asset,
|
|
144
|
-
};
|
|
145
|
-
if (pathFilter(p2)) {
|
|
146
|
-
locations.push(p2);
|
|
147
|
-
}
|
|
148
68
|
}
|
|
69
|
+
default:
|
|
70
|
+
throw Error(`Unknown ${chain.kind} chain ${chain.id}.`);
|
|
149
71
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
72
|
+
}
|
|
73
|
+
function getTransferLocations(routes) {
|
|
74
|
+
let sources = [];
|
|
75
|
+
for (const route of routes) {
|
|
76
|
+
let source = sources.find((s) => s.id === route.from.id && s.kind === route.from.kind);
|
|
155
77
|
if (!source) {
|
|
156
78
|
source = {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
key: location.source.toString(),
|
|
79
|
+
key: `${route.from.kind}_${route.from.id}`,
|
|
80
|
+
...route.from,
|
|
160
81
|
destinations: {},
|
|
161
82
|
};
|
|
162
|
-
|
|
83
|
+
sources.push(source);
|
|
163
84
|
}
|
|
164
|
-
|
|
85
|
+
const destId = `${route.to.kind}_${route.to.id}`;
|
|
86
|
+
let destination = source.destinations[destId];
|
|
165
87
|
if (!destination) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
return results;
|
|
172
|
-
}
|
|
173
|
-
function defaultPathFilter(envName) {
|
|
174
|
-
switch (envName) {
|
|
175
|
-
case "westend_sepolia": {
|
|
176
|
-
return (path) => {
|
|
177
|
-
// Frequency
|
|
178
|
-
if (path.asset === "0x72c610e05eaafcdf1fa7a2da15374ee90edb1620") {
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
|
-
// Disable para to para transfers
|
|
182
|
-
if (path.type === "substrate" && path.destinationType === "substrate") {
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
return true;
|
|
88
|
+
source.destinations[destId] = {
|
|
89
|
+
key: destId,
|
|
90
|
+
...route.to,
|
|
91
|
+
assets: [...route.assets],
|
|
186
92
|
};
|
|
187
93
|
}
|
|
188
|
-
case "paseo_sepolia":
|
|
189
|
-
return (path) => {
|
|
190
|
-
// Disallow MUSE to any location but 3369
|
|
191
|
-
if (path.asset === "0xb34a6924a02100ba6ef12af1c798285e8f7a16ee" &&
|
|
192
|
-
((path.destination !== 3369 && path.type === "ethereum") ||
|
|
193
|
-
(path.source !== 3369 && path.type === "substrate"))) {
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
// Disable para to para transfers
|
|
197
|
-
if (path.type === "substrate" && path.destinationType === "substrate") {
|
|
198
|
-
return false;
|
|
199
|
-
}
|
|
200
|
-
return true;
|
|
201
|
-
};
|
|
202
|
-
case "polkadot_mainnet":
|
|
203
|
-
return (path) => {
|
|
204
|
-
// Disallow MYTH to any location but 3369
|
|
205
|
-
if (path.asset === "0xba41ddf06b7ffd89d1267b5a93bfef2424eb2003" &&
|
|
206
|
-
((path.destination !== 3369 && path.type === "ethereum") ||
|
|
207
|
-
(path.source !== 3369 && path.type === "substrate"))) {
|
|
208
|
-
return false;
|
|
209
|
-
}
|
|
210
|
-
// Allow TRAC to go to Hydration (2034) and Neuroweb (2043) only
|
|
211
|
-
if (path.asset === "0xaa7a9ca87d3694b5755f213b5d04094b8d0f0a6f" &&
|
|
212
|
-
((path.destination !== 2034 &&
|
|
213
|
-
path.destination !== 2043 &&
|
|
214
|
-
path.type === "ethereum") ||
|
|
215
|
-
(path.source !== 2034 && path.source !== 2043 && path.type === "substrate"))) {
|
|
216
|
-
return false;
|
|
217
|
-
}
|
|
218
|
-
// Disable stable coins in the UI from Ethereum to Polkadot
|
|
219
|
-
if ((path.asset === "0x9d39a5de30e57443bff2a8307a4256c8797a3497" || // Staked USDe
|
|
220
|
-
path.asset === "0xa3931d71877c0e7a3148cb7eb4463524fec27fbd" || // Savings USD
|
|
221
|
-
path.asset === "0x6b175474e89094c44da98b954eedeac495271d0f") && // DAI
|
|
222
|
-
path.destination === 2034 // Hydration
|
|
223
|
-
) {
|
|
224
|
-
return false;
|
|
225
|
-
}
|
|
226
|
-
// Disable para to para transfers except for hydration
|
|
227
|
-
if (path.type === "substrate" &&
|
|
228
|
-
path.destinationType === "substrate" &&
|
|
229
|
-
!((path.source === 2034 && path.destination == 1000) ||
|
|
230
|
-
(path.source === 1000 && path.destination === 2034))) {
|
|
231
|
-
return false;
|
|
232
|
-
}
|
|
233
|
-
return true;
|
|
234
|
-
};
|
|
235
|
-
default:
|
|
236
|
-
return (_) => true;
|
|
237
94
|
}
|
|
95
|
+
return sources;
|
|
238
96
|
}
|