@snowbridge/registry 0.2.20 → 0.3.0-pre

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.
@@ -1,5 +1,5 @@
1
1
   WARN  Issue while reading "/home/runner/work/snowbridge/snowbridge/web/.npmrc". Failed to replace env in config: ${NPM_AUTH_TOKEN}
2
2
 
3
- > @snowbridge/registry@0.2.0 build /home/runner/work/snowbridge/snowbridge/web/packages/registry
4
- > tsc --build --force
3
+ > @snowbridge/registry@0.3.0 build /home/runner/work/snowbridge/snowbridge/web/packages/registry
4
+ > tsc --build --force && tsc -p tsconfig.scripts.json
5
5
 
package/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
 
2
2
  # Updating the asset list
3
3
 
4
- Set the api key and run the `build.ts` script.
5
-
6
4
  ```shell
7
- ETHEREUM_API_KEY=.... npx ts-node build.ts
5
+ ETHEREUM_API_KEY=.... npx ts-node scripts/buildRegistry.ts
8
6
  ```
@@ -0,0 +1,3 @@
1
+ import { Environment } from "@snowbridge/base-types";
2
+ export declare function environmentFor(env: "polkadot_mainnet" | "westend_sepolia" | "paseo_sepolia" | (string & {})): Environment;
3
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpD,wBAAgB,cAAc,CAC1B,GAAG,EAAE,kBAAkB,GAAG,iBAAiB,GAAG,eAAe,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,GAC9E,WAAW,CAGb"}
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.environmentFor = environmentFor;
4
+ function environmentFor(env) {
5
+ if (!(env in SNOWBRIDGE_ENV))
6
+ throw Error(`Unknown env '${env}'`);
7
+ return SNOWBRIDGE_ENV[env];
8
+ }
9
+ const SNOWBRIDGE_ENV = {
10
+ local_e2e: {
11
+ name: "local_e2e",
12
+ ethChainId: 11155111,
13
+ beaconApiUrl: "http://127.0.0.1:9596",
14
+ ethereumChains: {
15
+ "11155111": "ws://127.0.0.1:8546",
16
+ },
17
+ relaychainUrl: "ws://127.0.0.1:9944",
18
+ parachains: {
19
+ "1000": "ws://127.0.0.1:12144",
20
+ "1002": "ws://127.0.0.1:11144",
21
+ "2000": "ws://127.0.0.1:13144",
22
+ },
23
+ gatewayContract: "0xb1185ede04202fe62d38f5db72f71e38ff3e8305",
24
+ beefyContract: "0x83428c7db9815f482a39a1715684dcf755021997",
25
+ assetHubParaId: 1000,
26
+ bridgeHubParaId: 1002,
27
+ indexerGraphQlUrl: "http://127.0.0.1/does/not/exist",
28
+ },
29
+ paseo_sepolia: {
30
+ name: "paseo_sepolia",
31
+ ethChainId: 11155111,
32
+ beaconApiUrl: "https://lodestar-sepolia.chainsafe.io",
33
+ ethereumChains: {
34
+ "11155111": "https://ethereum-sepolia-rpc.publicnode.com",
35
+ },
36
+ relaychainUrl: "wss://paseo-rpc.dwellir.com",
37
+ parachains: {
38
+ "1000": "wss://asset-hub-paseo-rpc.dwellir.com",
39
+ "1002": "wss://bridge-hub-paseo.dotters.network",
40
+ "3369": "wss://paseo-muse-rpc.polkadot.io",
41
+ "2043": `wss://parachain-testnet-rpc.origin-trail.network`,
42
+ },
43
+ gatewayContract: "0x1607C1368bc943130258318c91bBd8cFf3D063E6",
44
+ beefyContract: "0x2c780945beb1241fE9c645800110cb9C4bBbb639",
45
+ assetHubParaId: 1000,
46
+ bridgeHubParaId: 1002,
47
+ indexerGraphQlUrl: "https://snowbridge.squids.live/snowbridge-subsquid-paseo@v1/api/graphql",
48
+ metadataOverrides: {
49
+ // Change the name of TRAC
50
+ "0xef32abea56beff54f61da319a7311098d6fbcea9": {
51
+ name: "OriginTrail TRAC",
52
+ symbol: "TRAC",
53
+ },
54
+ },
55
+ },
56
+ polkadot_mainnet: {
57
+ name: "polkadot_mainnet",
58
+ ethChainId: 1,
59
+ beaconApiUrl: "https://lodestar-mainnet.chainsafe.io",
60
+ ethereumChains: {
61
+ "1": "https://ethereum-rpc.publicnode.com",
62
+ "1284": "https://rpc.api.moonbeam.network",
63
+ },
64
+ relaychainUrl: "https://polkadot-rpc.n.dwellir.com",
65
+ parachains: {
66
+ "1000": "wss://asset-hub-polkadot-rpc.n.dwellir.com",
67
+ "1002": "https://bridge-hub-polkadot-rpc.n.dwellir.com",
68
+ "3369": "wss://polkadot-mythos-rpc.polkadot.io",
69
+ "2034": "wss://hydration-rpc.n.dwellir.com",
70
+ "2030": "wss://bifrost-polkadot.ibp.network",
71
+ "2004": "wss://moonbeam.ibp.network",
72
+ "2000": "wss://acala-rpc-0.aca-api.network",
73
+ "2043": "wss://parachain-rpc.origin-trail.network",
74
+ // TODO: Add back in jampton once we have an indexer in place.
75
+ //"3397": "wss://rpc.jamton.network",
76
+ },
77
+ gatewayContract: "0x27ca963c279c93801941e1eb8799c23f407d68e7",
78
+ beefyContract: "0x1817874feAb3ce053d0F40AbC23870DB35C2AFfc",
79
+ assetHubParaId: 1000,
80
+ bridgeHubParaId: 1002,
81
+ indexerGraphQlUrl: "https://snowbridge.squids.live/snowbridge-subsquid-polkadot:production/api/graphql",
82
+ kusama: {
83
+ assetHubParaId: 1000,
84
+ bridgeHubParaId: 1002,
85
+ parachains: {
86
+ "1000": "wss://asset-hub-kusama-rpc.n.dwellir.com",
87
+ "1002": "https://bridge-hub-kusama-rpc.n.dwellir.com",
88
+ },
89
+ },
90
+ precompiles: {
91
+ // Add override for mythos token and add precompile for moonbeam
92
+ "2004": "0x000000000000000000000000000000000000081a",
93
+ },
94
+ metadataOverrides: {
95
+ // Change the name of TRAC
96
+ "0xaa7a9ca87d3694b5755f213b5d04094b8d0f0a6f": {
97
+ name: "OriginTrail TRAC",
98
+ },
99
+ },
100
+ },
101
+ westend_sepolia: {
102
+ name: "westend_sepolia",
103
+ ethChainId: 11155111,
104
+ beaconApiUrl: "https://lodestar-sepolia.chainsafe.io",
105
+ ethereumChains: {
106
+ "11155111": "https://ethereum-sepolia-rpc.publicnode.com",
107
+ },
108
+ relaychainUrl: "wss://westend-rpc.n.dwellir.com",
109
+ parachains: {
110
+ "1000": "wss://asset-hub-westend-rpc.n.dwellir.com",
111
+ "1002": "wss://bridge-hub-westend-rpc.n.dwellir.com",
112
+ },
113
+ gatewayContract: "0x9ed8b47bc3417e3bd0507adc06e56e2fa360a4e9",
114
+ beefyContract: "0x6DFaD3D73A28c48E4F4c616ECda80885b415283a",
115
+ assetHubParaId: 1000,
116
+ bridgeHubParaId: 1002,
117
+ indexerGraphQlUrl: "https://snowbridge.squids.live/snowbridge-subsquid-westend@v1/api/graphql",
118
+ },
119
+ };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- import { AssetRegistry } from "@snowbridge/base-types";
2
- export declare function assetRegistryFor(env: "polkadot_mainnet" | "westend_sepolia" | "paseo_sepolia" | (string & {})): AssetRegistry;
1
+ export * from "./environment";
2
+ export * from "./registry";
3
+ export * from "./transfers";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAqCtD,wBAAgB,gBAAgB,CAC5B,GAAG,EAAE,kBAAkB,GAAG,iBAAiB,GAAG,eAAe,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,GAC9E,aAAa,CAuBf"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA"}
package/dist/index.js CHANGED
@@ -1,61 +1,19 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
4
15
  };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.assetRegistryFor = assetRegistryFor;
7
- const polkadot_mainnet_registry_json_1 = __importDefault(require("./polkadot_mainnet.registry.json"));
8
- const westend_sepolia_registry_json_1 = __importDefault(require("./westend_sepolia.registry.json"));
9
- const paseo_sepolia_registry_json_1 = __importDefault(require("./paseo_sepolia.registry.json"));
10
- const local_e2e_registry_json_1 = __importDefault(require("./local_e2e.registry.json"));
11
- function transformBigInt(obj) {
12
- // Regex to match strings like "bigint:123"
13
- const bigintPattern = /^bigint:(\d+)$/;
14
- // Handle null or non-object/non-array values
15
- if (obj === null || typeof obj !== "object") {
16
- if (typeof obj === "string") {
17
- const match = obj.match(bigintPattern);
18
- if (match) {
19
- return Object.freeze(BigInt(match[1]));
20
- }
21
- }
22
- return Object.freeze(obj);
23
- }
24
- // Handle arrays
25
- if (Array.isArray(obj)) {
26
- return Object.freeze(obj.map((item) => transformBigInt(item)));
27
- }
28
- // Handle objects
29
- const result = {};
30
- for (const key in obj) {
31
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
32
- result[key] = transformBigInt(obj[key]);
33
- }
34
- }
35
- return Object.freeze(result);
36
- }
37
- const cache = {};
38
- function assetRegistryFor(env) {
39
- if (env in cache) {
40
- return cache[env];
41
- }
42
- let json;
43
- switch (env) {
44
- case "polkadot_mainnet":
45
- json = polkadot_mainnet_registry_json_1.default;
46
- break;
47
- case "westend_sepolia":
48
- json = westend_sepolia_registry_json_1.default;
49
- break;
50
- case "paseo_sepolia":
51
- json = paseo_sepolia_registry_json_1.default;
52
- break;
53
- case "local_e2e":
54
- json = local_e2e_registry_json_1.default;
55
- break;
56
- default:
57
- throw Error(`Unknown env '${env}'`);
58
- }
59
- cache[env] = transformBigInt(json);
60
- return cache[env];
61
- }
17
+ __exportStar(require("./environment"), exports);
18
+ __exportStar(require("./registry"), exports);
19
+ __exportStar(require("./transfers"), exports);
@@ -1,5 +1,5 @@
1
1
  {
2
- "timestamp": "2025-11-24T11:57:28.867Z",
2
+ "timestamp": "2025-12-19T00:24:34.223Z",
3
3
  "environment": "polkadot_mainnet",
4
4
  "ethChainId": 1,
5
5
  "gatewayAddress": "0x27ca963c279c93801941e1eb8799c23f407d68e7",
@@ -23,7 +23,7 @@
23
23
  "accountType": "AccountId32",
24
24
  "name": "Polkadot BridgeHub",
25
25
  "specName": "bridge-hub-polkadot",
26
- "specVersion": 2000000
26
+ "specVersion": 2000003
27
27
  },
28
28
  "ethereumChains": {
29
29
  "1": {
@@ -387,7 +387,7 @@
387
387
  "accountType": "AccountId32",
388
388
  "name": "Polkadot Asset Hub",
389
389
  "specName": "statemint",
390
- "specVersion": 2000002
390
+ "specVersion": 2000003
391
391
  },
392
392
  "assets": {
393
393
  "0x9d39a5de30e57443bff2a8307a4256c8797a3497": {
@@ -1001,7 +1001,7 @@
1001
1001
  "accountType": "AccountId32",
1002
1002
  "name": "Acala",
1003
1003
  "specName": "acala",
1004
- "specVersion": 2320
1004
+ "specVersion": 2330
1005
1005
  },
1006
1006
  "assets": {
1007
1007
  "0x0000000000000000000000000000000000000000": {
@@ -1038,7 +1038,7 @@
1038
1038
  "evmChainId": 1284,
1039
1039
  "name": "Moonbeam",
1040
1040
  "specName": "moonbeam",
1041
- "specVersion": 3901
1041
+ "specVersion": 4001
1042
1042
  },
1043
1043
  "xcDOT": "0xffffffff1fcacbd218edc0eba20fc2308c778080",
1044
1044
  "assets": {
@@ -1106,7 +1106,7 @@
1106
1106
  "xc20": "0xffffffff7bc304425217b49e9598415c514ae81b"
1107
1107
  }
1108
1108
  },
1109
- "estimatedExecutionFeeDOT": "bigint:104787198",
1109
+ "estimatedExecutionFeeDOT": "bigint:105696134",
1110
1110
  "estimatedDeliveryFeeDOT": "bigint:306500000"
1111
1111
  },
1112
1112
  "2030": {
@@ -1151,7 +1151,7 @@
1151
1151
  "isSufficient": false
1152
1152
  }
1153
1153
  },
1154
- "estimatedExecutionFeeDOT": "bigint:91177752",
1154
+ "estimatedExecutionFeeDOT": "bigint:125952027",
1155
1155
  "estimatedDeliveryFeeDOT": "bigint:307100000"
1156
1156
  },
1157
1157
  "2034": {
@@ -1332,7 +1332,7 @@
1332
1332
  "isSufficient": true
1333
1333
  }
1334
1334
  },
1335
- "estimatedExecutionFeeDOT": "bigint:1740820",
1335
+ "estimatedExecutionFeeDOT": "bigint:1934280",
1336
1336
  "estimatedDeliveryFeeDOT": "bigint:307100000"
1337
1337
  },
1338
1338
  "2043": {
@@ -1356,7 +1356,7 @@
1356
1356
  "accountType": "AccountId32",
1357
1357
  "name": "NeuroWeb",
1358
1358
  "specName": "origintrail-parachain",
1359
- "specVersion": 149
1359
+ "specVersion": 151
1360
1360
  },
1361
1361
  "assets": {
1362
1362
  "0xaa7a9ca87d3694b5755f213b5d04094b8d0f0a6f": {
@@ -1431,7 +1431,7 @@
1431
1431
  "accountType": "AccountId32",
1432
1432
  "name": "Kusama Asset Hub",
1433
1433
  "specName": "statemine",
1434
- "specVersion": 2000002
1434
+ "specVersion": 2000003
1435
1435
  },
1436
1436
  "assets": {
1437
1437
  "0x9d39a5de30e57443bff2a8307a4256c8797a3497": {
@@ -0,0 +1,3 @@
1
+ import { AssetRegistry } from "@snowbridge/base-types";
2
+ export declare function assetRegistryFor(env: "polkadot_mainnet" | "westend_sepolia" | "paseo_sepolia" | (string & {})): AssetRegistry;
3
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAqCtD,wBAAgB,gBAAgB,CAC5B,GAAG,EAAE,kBAAkB,GAAG,iBAAiB,GAAG,eAAe,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,GAC9E,aAAa,CAuBf"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.assetRegistryFor = assetRegistryFor;
7
+ const polkadot_mainnet_registry_json_1 = __importDefault(require("./polkadot_mainnet.registry.json"));
8
+ const westend_sepolia_registry_json_1 = __importDefault(require("./westend_sepolia.registry.json"));
9
+ const paseo_sepolia_registry_json_1 = __importDefault(require("./paseo_sepolia.registry.json"));
10
+ const local_e2e_registry_json_1 = __importDefault(require("./local_e2e.registry.json"));
11
+ function transformBigInt(obj) {
12
+ // Regex to match strings like "bigint:123"
13
+ const bigintPattern = /^bigint:(\d+)$/;
14
+ // Handle null or non-object/non-array values
15
+ if (obj === null || typeof obj !== "object") {
16
+ if (typeof obj === "string") {
17
+ const match = obj.match(bigintPattern);
18
+ if (match) {
19
+ return Object.freeze(BigInt(match[1]));
20
+ }
21
+ }
22
+ return Object.freeze(obj);
23
+ }
24
+ // Handle arrays
25
+ if (Array.isArray(obj)) {
26
+ return Object.freeze(obj.map((item) => transformBigInt(item)));
27
+ }
28
+ // Handle objects
29
+ const result = {};
30
+ for (const key in obj) {
31
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
32
+ result[key] = transformBigInt(obj[key]);
33
+ }
34
+ }
35
+ return Object.freeze(result);
36
+ }
37
+ const cache = {};
38
+ function assetRegistryFor(env) {
39
+ if (env in cache) {
40
+ return cache[env];
41
+ }
42
+ let json;
43
+ switch (env) {
44
+ case "polkadot_mainnet":
45
+ json = polkadot_mainnet_registry_json_1.default;
46
+ break;
47
+ case "westend_sepolia":
48
+ json = westend_sepolia_registry_json_1.default;
49
+ break;
50
+ case "paseo_sepolia":
51
+ json = paseo_sepolia_registry_json_1.default;
52
+ break;
53
+ case "local_e2e":
54
+ json = local_e2e_registry_json_1.default;
55
+ break;
56
+ default:
57
+ throw Error(`Unknown env '${env}'`);
58
+ }
59
+ cache[env] = transformBigInt(json);
60
+ return cache[env];
61
+ }
@@ -0,0 +1,9 @@
1
+ import { AssetRegistry, EthereumChain, Parachain, Path, Source, TransferLocation } from "@snowbridge/base-types";
2
+ export declare function transferSourcesFor(env: "polkadot_mainnet" | "westend_sepolia" | "paseo_sepolia" | (string & {})): Source[];
3
+ export declare function getEthereumTransferLocation(registry: AssetRegistry, ethChain: EthereumChain): TransferLocation;
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;
9
+ //# sourceMappingURL=transfers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transfers.d.ts","sourceRoot":"","sources":["../src/transfers.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EAEb,aAAa,EACb,SAAS,EACT,IAAI,EACJ,MAAM,EAEN,gBAAgB,EACnB,MAAM,wBAAwB,CAAA;AAK/B,wBAAgB,kBAAkB,CAC9B,GAAG,EAAE,kBAAkB,GAAG,iBAAiB,GAAG,eAAe,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,GAC9E,MAAM,EAAE,CAKV;AAED,wBAAgB,2BAA2B,CACvC,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,aAAa,GACxB,gBAAgB,CAoBlB;AAED,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,SAAS,GAAG,gBAAgB,CAQnF;AAED,wBAAgB,mBAAmB,CAC/B,QAAQ,EAAE,aAAa,EACvB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAClB,gBAAgB,CAMlB;AAED,wBAAgB,yBAAyB,CACrC,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GACpB,gBAAgB,CAMlB;AAED,wBAAgB,oBAAoB,CAChC,QAAQ,EAAE,aAAa,EACvB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,GACjC,MAAM,EAAE,CA2HV;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,IAAI,KAAK,OAAO,CA+EvE"}
@@ -0,0 +1,238 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transferSourcesFor = transferSourcesFor;
4
+ exports.getEthereumTransferLocation = getEthereumTransferLocation;
5
+ exports.getSubstrateTransferLocation = getSubstrateTransferLocation;
6
+ exports.getTransferLocation = getTransferLocation;
7
+ exports.getTransferLocationKusama = getTransferLocationKusama;
8
+ exports.getTransferLocations = getTransferLocations;
9
+ exports.defaultPathFilter = defaultPathFilter;
10
+ const registry_1 = require("./registry");
11
+ const cache = {};
12
+ function transferSourcesFor(env) {
13
+ if (env in cache) {
14
+ return cache[env];
15
+ }
16
+ return getTransferLocations((0, registry_1.assetRegistryFor)(env));
17
+ }
18
+ function getEthereumTransferLocation(registry, ethChain) {
19
+ if (!ethChain.evmParachainId) {
20
+ return {
21
+ id: "ethereum",
22
+ name: "Ethereum",
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,
85
+ };
86
+ if (pathFilter(p1)) {
87
+ locations.push(p1);
88
+ }
89
+ const p2 = {
90
+ type: "substrate",
91
+ id: parachain.info.specName,
92
+ source: parachain.parachainId,
93
+ destinationType: "ethereum",
94
+ destination: ethChain.chainId,
95
+ asset,
96
+ };
97
+ if (pathFilter(p2)) {
98
+ locations.push(p2);
99
+ }
100
+ if (parachain.info.evmChainId && registry.ethereumChains[parachain.info.evmChainId]) {
101
+ const p3 = {
102
+ type: "ethereum",
103
+ id: `${parachain.info.specName}_evm`,
104
+ source: parachain.info.evmChainId,
105
+ destinationType: "ethereum",
106
+ destination: ethChain.chainId,
107
+ asset,
108
+ };
109
+ if (pathFilter(p3)) {
110
+ locations.push(p3);
111
+ }
112
+ }
113
+ }
114
+ }
115
+ // Local paths
116
+ const assetHub = registry.parachains[registry.assetHubParaId];
117
+ for (const parachain of parachains) {
118
+ if (parachain.parachainId === assetHub.parachainId)
119
+ continue;
120
+ const assetHubAssets = Object.keys(assetHub.assets);
121
+ const destinationAssets = Object.keys(parachain.assets);
122
+ // The asset exists on ethereum, parachain and asset hub
123
+ const commonAssets = new Set(ethAssets.filter((sa) => assetHubAssets.find((da) => da === sa) &&
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,
133
+ };
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
+ }
149
+ }
150
+ const results = [];
151
+ for (const location of locations) {
152
+ let source = results.find((s) => s.type === location.type &&
153
+ s.id === location.id &&
154
+ s.key === location.source.toString());
155
+ if (!source) {
156
+ source = {
157
+ type: location.type,
158
+ id: location.id,
159
+ key: location.source.toString(),
160
+ destinations: {},
161
+ };
162
+ results.push(source);
163
+ }
164
+ let destination = source.destinations[location.destination];
165
+ if (!destination) {
166
+ destination = { type: location.destinationType, assets: [] };
167
+ source.destinations[location.destination] = destination;
168
+ }
169
+ destination.assets.push(location.asset);
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;
186
+ };
187
+ }
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
+ }
238
+ }