@snowbridge/registry 0.2.19 → 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.
- package/.turbo/turbo-build.log +2 -2
- package/README.md +1 -3
- package/dist/environment.d.ts +3 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/environment.js +119 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -58
- package/dist/polkadot_mainnet.registry.json +10 -10
- package/dist/registry.d.ts +3 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +61 -0
- package/dist/transfers.d.ts +9 -0
- package/dist/transfers.d.ts.map +1 -0
- package/dist/transfers.js +238 -0
- package/package.json +10 -6
- package/scripts/buildRegistry.ts +637 -0
- package/src/environment.ts +123 -0
- package/src/index.ts +3 -63
- package/src/polkadot_mainnet.registry.json +10 -10
- package/src/registry.ts +63 -0
- package/src/transfers.ts +290 -0
- package/tsconfig.json +1 -1
- package/tsconfig.scripts.json +23 -0
- package/build.ts +0 -28
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Environment } from "@snowbridge/base-types"
|
|
2
|
+
|
|
3
|
+
export function environmentFor(
|
|
4
|
+
env: "polkadot_mainnet" | "westend_sepolia" | "paseo_sepolia" | (string & {}),
|
|
5
|
+
): Environment {
|
|
6
|
+
if (!(env in SNOWBRIDGE_ENV)) throw Error(`Unknown env '${env}'`)
|
|
7
|
+
return SNOWBRIDGE_ENV[env]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const SNOWBRIDGE_ENV: { [env: string]: Environment } = {
|
|
11
|
+
local_e2e: {
|
|
12
|
+
name: "local_e2e",
|
|
13
|
+
ethChainId: 11155111,
|
|
14
|
+
beaconApiUrl: "http://127.0.0.1:9596",
|
|
15
|
+
ethereumChains: {
|
|
16
|
+
"11155111": "ws://127.0.0.1:8546",
|
|
17
|
+
},
|
|
18
|
+
relaychainUrl: "ws://127.0.0.1:9944",
|
|
19
|
+
parachains: {
|
|
20
|
+
"1000": "ws://127.0.0.1:12144",
|
|
21
|
+
"1002": "ws://127.0.0.1:11144",
|
|
22
|
+
"2000": "ws://127.0.0.1:13144",
|
|
23
|
+
},
|
|
24
|
+
gatewayContract: "0xb1185ede04202fe62d38f5db72f71e38ff3e8305",
|
|
25
|
+
beefyContract: "0x83428c7db9815f482a39a1715684dcf755021997",
|
|
26
|
+
assetHubParaId: 1000,
|
|
27
|
+
bridgeHubParaId: 1002,
|
|
28
|
+
indexerGraphQlUrl: "http://127.0.0.1/does/not/exist",
|
|
29
|
+
},
|
|
30
|
+
paseo_sepolia: {
|
|
31
|
+
name: "paseo_sepolia",
|
|
32
|
+
ethChainId: 11155111,
|
|
33
|
+
beaconApiUrl: "https://lodestar-sepolia.chainsafe.io",
|
|
34
|
+
ethereumChains: {
|
|
35
|
+
"11155111": "https://ethereum-sepolia-rpc.publicnode.com",
|
|
36
|
+
},
|
|
37
|
+
relaychainUrl: "wss://paseo-rpc.dwellir.com",
|
|
38
|
+
parachains: {
|
|
39
|
+
"1000": "wss://asset-hub-paseo-rpc.dwellir.com",
|
|
40
|
+
"1002": "wss://bridge-hub-paseo.dotters.network",
|
|
41
|
+
"3369": "wss://paseo-muse-rpc.polkadot.io",
|
|
42
|
+
"2043": `wss://parachain-testnet-rpc.origin-trail.network`,
|
|
43
|
+
},
|
|
44
|
+
gatewayContract: "0x1607C1368bc943130258318c91bBd8cFf3D063E6",
|
|
45
|
+
beefyContract: "0x2c780945beb1241fE9c645800110cb9C4bBbb639",
|
|
46
|
+
assetHubParaId: 1000,
|
|
47
|
+
bridgeHubParaId: 1002,
|
|
48
|
+
indexerGraphQlUrl:
|
|
49
|
+
"https://snowbridge.squids.live/snowbridge-subsquid-paseo@v1/api/graphql",
|
|
50
|
+
metadataOverrides: {
|
|
51
|
+
// Change the name of TRAC
|
|
52
|
+
"0xef32abea56beff54f61da319a7311098d6fbcea9": {
|
|
53
|
+
name: "OriginTrail TRAC",
|
|
54
|
+
symbol: "TRAC",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
polkadot_mainnet: {
|
|
59
|
+
name: "polkadot_mainnet",
|
|
60
|
+
ethChainId: 1,
|
|
61
|
+
beaconApiUrl: "https://lodestar-mainnet.chainsafe.io",
|
|
62
|
+
ethereumChains: {
|
|
63
|
+
"1": "https://ethereum-rpc.publicnode.com",
|
|
64
|
+
"1284": "https://rpc.api.moonbeam.network",
|
|
65
|
+
},
|
|
66
|
+
relaychainUrl: "https://polkadot-rpc.n.dwellir.com",
|
|
67
|
+
parachains: {
|
|
68
|
+
"1000": "wss://asset-hub-polkadot-rpc.n.dwellir.com",
|
|
69
|
+
"1002": "https://bridge-hub-polkadot-rpc.n.dwellir.com",
|
|
70
|
+
"3369": "wss://polkadot-mythos-rpc.polkadot.io",
|
|
71
|
+
"2034": "wss://hydration-rpc.n.dwellir.com",
|
|
72
|
+
"2030": "wss://bifrost-polkadot.ibp.network",
|
|
73
|
+
"2004": "wss://moonbeam.ibp.network",
|
|
74
|
+
"2000": "wss://acala-rpc-0.aca-api.network",
|
|
75
|
+
"2043": "wss://parachain-rpc.origin-trail.network",
|
|
76
|
+
// TODO: Add back in jampton once we have an indexer in place.
|
|
77
|
+
//"3397": "wss://rpc.jamton.network",
|
|
78
|
+
},
|
|
79
|
+
gatewayContract: "0x27ca963c279c93801941e1eb8799c23f407d68e7",
|
|
80
|
+
beefyContract: "0x1817874feAb3ce053d0F40AbC23870DB35C2AFfc",
|
|
81
|
+
assetHubParaId: 1000,
|
|
82
|
+
bridgeHubParaId: 1002,
|
|
83
|
+
indexerGraphQlUrl:
|
|
84
|
+
"https://snowbridge.squids.live/snowbridge-subsquid-polkadot:production/api/graphql",
|
|
85
|
+
kusama: {
|
|
86
|
+
assetHubParaId: 1000,
|
|
87
|
+
bridgeHubParaId: 1002,
|
|
88
|
+
parachains: {
|
|
89
|
+
"1000": "wss://asset-hub-kusama-rpc.n.dwellir.com",
|
|
90
|
+
"1002": "https://bridge-hub-kusama-rpc.n.dwellir.com",
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
precompiles: {
|
|
94
|
+
// Add override for mythos token and add precompile for moonbeam
|
|
95
|
+
"2004": "0x000000000000000000000000000000000000081a",
|
|
96
|
+
},
|
|
97
|
+
metadataOverrides: {
|
|
98
|
+
// Change the name of TRAC
|
|
99
|
+
"0xaa7a9ca87d3694b5755f213b5d04094b8d0f0a6f": {
|
|
100
|
+
name: "OriginTrail TRAC",
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
westend_sepolia: {
|
|
105
|
+
name: "westend_sepolia",
|
|
106
|
+
ethChainId: 11155111,
|
|
107
|
+
beaconApiUrl: "https://lodestar-sepolia.chainsafe.io",
|
|
108
|
+
ethereumChains: {
|
|
109
|
+
"11155111": "https://ethereum-sepolia-rpc.publicnode.com",
|
|
110
|
+
},
|
|
111
|
+
relaychainUrl: "wss://westend-rpc.n.dwellir.com",
|
|
112
|
+
parachains: {
|
|
113
|
+
"1000": "wss://asset-hub-westend-rpc.n.dwellir.com",
|
|
114
|
+
"1002": "wss://bridge-hub-westend-rpc.n.dwellir.com",
|
|
115
|
+
},
|
|
116
|
+
gatewayContract: "0x9ed8b47bc3417e3bd0507adc06e56e2fa360a4e9",
|
|
117
|
+
beefyContract: "0x6DFaD3D73A28c48E4F4c616ECda80885b415283a",
|
|
118
|
+
assetHubParaId: 1000,
|
|
119
|
+
bridgeHubParaId: 1002,
|
|
120
|
+
indexerGraphQlUrl:
|
|
121
|
+
"https://snowbridge.squids.live/snowbridge-subsquid-westend@v1/api/graphql",
|
|
122
|
+
},
|
|
123
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,63 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import paseo_sepolia from "./paseo_sepolia.registry.json"
|
|
5
|
-
import local_e2e from "./local_e2e.registry.json"
|
|
6
|
-
|
|
7
|
-
function transformBigInt(obj: any): any {
|
|
8
|
-
// Regex to match strings like "bigint:123"
|
|
9
|
-
const bigintPattern = /^bigint:(\d+)$/
|
|
10
|
-
|
|
11
|
-
// Handle null or non-object/non-array values
|
|
12
|
-
if (obj === null || typeof obj !== "object") {
|
|
13
|
-
if (typeof obj === "string") {
|
|
14
|
-
const match = obj.match(bigintPattern)
|
|
15
|
-
if (match) {
|
|
16
|
-
return Object.freeze(BigInt(match[1]))
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return Object.freeze(obj)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Handle arrays
|
|
23
|
-
if (Array.isArray(obj)) {
|
|
24
|
-
return Object.freeze(obj.map((item) => transformBigInt(item)))
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Handle objects
|
|
28
|
-
const result: { [key: string]: any } = {}
|
|
29
|
-
for (const key in obj) {
|
|
30
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
31
|
-
result[key] = transformBigInt(obj[key])
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return Object.freeze(result)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const cache: { [env: string]: AssetRegistry } = {}
|
|
38
|
-
export function assetRegistryFor(
|
|
39
|
-
env: "polkadot_mainnet" | "westend_sepolia" | "paseo_sepolia" | (string & {}),
|
|
40
|
-
): AssetRegistry {
|
|
41
|
-
if (env in cache) {
|
|
42
|
-
return cache[env]
|
|
43
|
-
}
|
|
44
|
-
let json
|
|
45
|
-
switch (env) {
|
|
46
|
-
case "polkadot_mainnet":
|
|
47
|
-
json = polkadot_mainnet
|
|
48
|
-
break
|
|
49
|
-
case "westend_sepolia":
|
|
50
|
-
json = westend_sepolia
|
|
51
|
-
break
|
|
52
|
-
case "paseo_sepolia":
|
|
53
|
-
json = paseo_sepolia
|
|
54
|
-
break
|
|
55
|
-
case "local_e2e":
|
|
56
|
-
json = local_e2e
|
|
57
|
-
break
|
|
58
|
-
default:
|
|
59
|
-
throw Error(`Unknown env '${env}'`)
|
|
60
|
-
}
|
|
61
|
-
cache[env] = transformBigInt(json)
|
|
62
|
-
return cache[env]
|
|
63
|
-
}
|
|
1
|
+
export * from "./environment"
|
|
2
|
+
export * from "./registry"
|
|
3
|
+
export * from "./transfers"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"timestamp": "2025-
|
|
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":
|
|
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":
|
|
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":
|
|
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":
|
|
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:
|
|
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:
|
|
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:
|
|
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":
|
|
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":
|
|
1434
|
+
"specVersion": 2000003
|
|
1435
1435
|
},
|
|
1436
1436
|
"assets": {
|
|
1437
1437
|
"0x9d39a5de30e57443bff2a8307a4256c8797a3497": {
|
package/src/registry.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { AssetRegistry } from "@snowbridge/base-types"
|
|
2
|
+
import polkadot_mainnet from "./polkadot_mainnet.registry.json"
|
|
3
|
+
import westend_sepolia from "./westend_sepolia.registry.json"
|
|
4
|
+
import paseo_sepolia from "./paseo_sepolia.registry.json"
|
|
5
|
+
import local_e2e from "./local_e2e.registry.json"
|
|
6
|
+
|
|
7
|
+
function transformBigInt(obj: any): any {
|
|
8
|
+
// Regex to match strings like "bigint:123"
|
|
9
|
+
const bigintPattern = /^bigint:(\d+)$/
|
|
10
|
+
|
|
11
|
+
// Handle null or non-object/non-array values
|
|
12
|
+
if (obj === null || typeof obj !== "object") {
|
|
13
|
+
if (typeof obj === "string") {
|
|
14
|
+
const match = obj.match(bigintPattern)
|
|
15
|
+
if (match) {
|
|
16
|
+
return Object.freeze(BigInt(match[1]))
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return Object.freeze(obj)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Handle arrays
|
|
23
|
+
if (Array.isArray(obj)) {
|
|
24
|
+
return Object.freeze(obj.map((item) => transformBigInt(item)))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Handle objects
|
|
28
|
+
const result: { [key: string]: any } = {}
|
|
29
|
+
for (const key in obj) {
|
|
30
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
31
|
+
result[key] = transformBigInt(obj[key])
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return Object.freeze(result)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const cache: { [env: string]: AssetRegistry } = {}
|
|
38
|
+
export function assetRegistryFor(
|
|
39
|
+
env: "polkadot_mainnet" | "westend_sepolia" | "paseo_sepolia" | (string & {}),
|
|
40
|
+
): AssetRegistry {
|
|
41
|
+
if (env in cache) {
|
|
42
|
+
return cache[env]
|
|
43
|
+
}
|
|
44
|
+
let json
|
|
45
|
+
switch (env) {
|
|
46
|
+
case "polkadot_mainnet":
|
|
47
|
+
json = polkadot_mainnet
|
|
48
|
+
break
|
|
49
|
+
case "westend_sepolia":
|
|
50
|
+
json = westend_sepolia
|
|
51
|
+
break
|
|
52
|
+
case "paseo_sepolia":
|
|
53
|
+
json = paseo_sepolia
|
|
54
|
+
break
|
|
55
|
+
case "local_e2e":
|
|
56
|
+
json = local_e2e
|
|
57
|
+
break
|
|
58
|
+
default:
|
|
59
|
+
throw Error(`Unknown env '${env}'`)
|
|
60
|
+
}
|
|
61
|
+
cache[env] = transformBigInt(json)
|
|
62
|
+
return cache[env]
|
|
63
|
+
}
|
package/src/transfers.ts
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AssetRegistry,
|
|
3
|
+
Environment,
|
|
4
|
+
EthereumChain,
|
|
5
|
+
Parachain,
|
|
6
|
+
Path,
|
|
7
|
+
Source,
|
|
8
|
+
SourceType,
|
|
9
|
+
TransferLocation,
|
|
10
|
+
} from "@snowbridge/base-types"
|
|
11
|
+
import { environmentFor } from "./environment"
|
|
12
|
+
import { assetRegistryFor } from "./registry"
|
|
13
|
+
|
|
14
|
+
const cache: { [env: string]: Source[] } = {}
|
|
15
|
+
export function transferSourcesFor(
|
|
16
|
+
env: "polkadot_mainnet" | "westend_sepolia" | "paseo_sepolia" | (string & {}),
|
|
17
|
+
): Source[] {
|
|
18
|
+
if (env in cache) {
|
|
19
|
+
return cache[env]
|
|
20
|
+
}
|
|
21
|
+
return getTransferLocations(assetRegistryFor(env))
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function getEthereumTransferLocation(
|
|
25
|
+
registry: AssetRegistry,
|
|
26
|
+
ethChain: EthereumChain,
|
|
27
|
+
): TransferLocation {
|
|
28
|
+
if (!ethChain.evmParachainId) {
|
|
29
|
+
return {
|
|
30
|
+
id: "ethereum",
|
|
31
|
+
name: "Ethereum",
|
|
32
|
+
type: "ethereum",
|
|
33
|
+
key: ethChain.chainId.toString(),
|
|
34
|
+
ethChain,
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
const evmChain = registry.parachains[ethChain.evmParachainId]
|
|
38
|
+
return {
|
|
39
|
+
id: ethChain.id,
|
|
40
|
+
name: `${evmChain.info.name} (EVM)`,
|
|
41
|
+
key: ethChain.chainId.toString(),
|
|
42
|
+
type: "ethereum",
|
|
43
|
+
ethChain,
|
|
44
|
+
parachain: evmChain,
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function getSubstrateTransferLocation(parachain: Parachain): TransferLocation {
|
|
50
|
+
return {
|
|
51
|
+
id: parachain.info.specName,
|
|
52
|
+
name: parachain.info.name,
|
|
53
|
+
key: parachain.parachainId.toString(),
|
|
54
|
+
type: "substrate",
|
|
55
|
+
parachain,
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function getTransferLocation(
|
|
60
|
+
registry: AssetRegistry,
|
|
61
|
+
sourceType: string,
|
|
62
|
+
sourceKey: string,
|
|
63
|
+
): TransferLocation {
|
|
64
|
+
if (sourceType === "ethereum") {
|
|
65
|
+
return getEthereumTransferLocation(registry, registry.ethereumChains[sourceKey])
|
|
66
|
+
} else {
|
|
67
|
+
return getSubstrateTransferLocation(registry.parachains[sourceKey])
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function getTransferLocationKusama(
|
|
72
|
+
registry: AssetRegistry,
|
|
73
|
+
network: string,
|
|
74
|
+
parachainId: string,
|
|
75
|
+
): TransferLocation {
|
|
76
|
+
if (network === "kusama" && registry.kusama) {
|
|
77
|
+
return getSubstrateTransferLocation(registry.kusama?.parachains[parachainId])
|
|
78
|
+
} else {
|
|
79
|
+
return getSubstrateTransferLocation(registry.parachains[parachainId])
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function getTransferLocations(
|
|
84
|
+
registry: AssetRegistry,
|
|
85
|
+
filter?: (path: Path) => boolean,
|
|
86
|
+
): Source[] {
|
|
87
|
+
const ethChain = registry.ethereumChains[registry.ethChainId]
|
|
88
|
+
const parachains = Object.keys(registry.parachains)
|
|
89
|
+
.filter((p) => p !== registry.bridgeHubParaId.toString())
|
|
90
|
+
.map((p) => registry.parachains[p])
|
|
91
|
+
|
|
92
|
+
const pathFilter = filter ?? defaultPathFilter(registry.environment)
|
|
93
|
+
|
|
94
|
+
const locations: Path[] = []
|
|
95
|
+
|
|
96
|
+
const ethAssets = Object.keys(ethChain.assets)
|
|
97
|
+
// Bridged paths
|
|
98
|
+
for (const parachain of parachains) {
|
|
99
|
+
const destinationAssets = Object.keys(parachain.assets)
|
|
100
|
+
const commonAssets = new Set(
|
|
101
|
+
ethAssets.filter((sa) => destinationAssets.find((da) => da === sa)),
|
|
102
|
+
)
|
|
103
|
+
for (const asset of commonAssets) {
|
|
104
|
+
const p1: Path = {
|
|
105
|
+
type: "ethereum",
|
|
106
|
+
id: "ethereum",
|
|
107
|
+
source: ethChain.chainId,
|
|
108
|
+
destinationType: "substrate",
|
|
109
|
+
destination: parachain.parachainId,
|
|
110
|
+
asset,
|
|
111
|
+
}
|
|
112
|
+
if (pathFilter(p1)) {
|
|
113
|
+
locations.push(p1)
|
|
114
|
+
}
|
|
115
|
+
const p2: Path = {
|
|
116
|
+
type: "substrate",
|
|
117
|
+
id: parachain.info.specName,
|
|
118
|
+
source: parachain.parachainId,
|
|
119
|
+
destinationType: "ethereum",
|
|
120
|
+
destination: ethChain.chainId,
|
|
121
|
+
asset,
|
|
122
|
+
}
|
|
123
|
+
if (pathFilter(p2)) {
|
|
124
|
+
locations.push(p2)
|
|
125
|
+
}
|
|
126
|
+
if (parachain.info.evmChainId && registry.ethereumChains[parachain.info.evmChainId]) {
|
|
127
|
+
const p3: Path = {
|
|
128
|
+
type: "ethereum",
|
|
129
|
+
id: `${parachain.info.specName}_evm`,
|
|
130
|
+
source: parachain.info.evmChainId,
|
|
131
|
+
destinationType: "ethereum",
|
|
132
|
+
destination: ethChain.chainId,
|
|
133
|
+
asset,
|
|
134
|
+
}
|
|
135
|
+
if (pathFilter(p3)) {
|
|
136
|
+
locations.push(p3)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Local paths
|
|
143
|
+
const assetHub = registry.parachains[registry.assetHubParaId]
|
|
144
|
+
for (const parachain of parachains) {
|
|
145
|
+
if (parachain.parachainId === assetHub.parachainId) continue
|
|
146
|
+
const assetHubAssets = Object.keys(assetHub.assets)
|
|
147
|
+
const destinationAssets = Object.keys(parachain.assets)
|
|
148
|
+
|
|
149
|
+
// The asset exists on ethereum, parachain and asset hub
|
|
150
|
+
const commonAssets = new Set(
|
|
151
|
+
ethAssets.filter(
|
|
152
|
+
(sa) =>
|
|
153
|
+
assetHubAssets.find((da) => da === sa) &&
|
|
154
|
+
destinationAssets.find((da) => da === sa),
|
|
155
|
+
),
|
|
156
|
+
)
|
|
157
|
+
for (const asset of commonAssets) {
|
|
158
|
+
const p1: Path = {
|
|
159
|
+
type: "substrate",
|
|
160
|
+
id: assetHub.info.specName,
|
|
161
|
+
source: assetHub.parachainId,
|
|
162
|
+
destinationType: "substrate",
|
|
163
|
+
destination: parachain.parachainId,
|
|
164
|
+
asset,
|
|
165
|
+
}
|
|
166
|
+
if (pathFilter(p1)) {
|
|
167
|
+
locations.push(p1)
|
|
168
|
+
}
|
|
169
|
+
const p2: Path = {
|
|
170
|
+
type: "substrate",
|
|
171
|
+
id: parachain.info.specName,
|
|
172
|
+
source: parachain.parachainId,
|
|
173
|
+
destinationType: "substrate",
|
|
174
|
+
destination: assetHub.parachainId,
|
|
175
|
+
asset,
|
|
176
|
+
}
|
|
177
|
+
if (pathFilter(p2)) {
|
|
178
|
+
locations.push(p2)
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const results: Source[] = []
|
|
184
|
+
for (const location of locations) {
|
|
185
|
+
let source = results.find(
|
|
186
|
+
(s) =>
|
|
187
|
+
s.type === location.type &&
|
|
188
|
+
s.id === location.id &&
|
|
189
|
+
s.key === location.source.toString(),
|
|
190
|
+
)
|
|
191
|
+
if (!source) {
|
|
192
|
+
source = {
|
|
193
|
+
type: location.type,
|
|
194
|
+
id: location.id,
|
|
195
|
+
key: location.source.toString(),
|
|
196
|
+
destinations: {},
|
|
197
|
+
}
|
|
198
|
+
results.push(source)
|
|
199
|
+
}
|
|
200
|
+
let destination: { type: SourceType; assets: string[] } =
|
|
201
|
+
source.destinations[location.destination]
|
|
202
|
+
if (!destination) {
|
|
203
|
+
destination = { type: location.destinationType, assets: [] }
|
|
204
|
+
source.destinations[location.destination] = destination
|
|
205
|
+
}
|
|
206
|
+
destination.assets.push(location.asset)
|
|
207
|
+
}
|
|
208
|
+
return results
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function defaultPathFilter(envName: string): (_: Path) => boolean {
|
|
212
|
+
switch (envName) {
|
|
213
|
+
case "westend_sepolia": {
|
|
214
|
+
return (path: Path) => {
|
|
215
|
+
// Frequency
|
|
216
|
+
if (path.asset === "0x72c610e05eaafcdf1fa7a2da15374ee90edb1620") {
|
|
217
|
+
return false
|
|
218
|
+
}
|
|
219
|
+
// Disable para to para transfers
|
|
220
|
+
if (path.type === "substrate" && path.destinationType === "substrate") {
|
|
221
|
+
return false
|
|
222
|
+
}
|
|
223
|
+
return true
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
case "paseo_sepolia":
|
|
227
|
+
return (path: Path) => {
|
|
228
|
+
// Disallow MUSE to any location but 3369
|
|
229
|
+
if (
|
|
230
|
+
path.asset === "0xb34a6924a02100ba6ef12af1c798285e8f7a16ee" &&
|
|
231
|
+
((path.destination !== 3369 && path.type === "ethereum") ||
|
|
232
|
+
(path.source !== 3369 && path.type === "substrate"))
|
|
233
|
+
) {
|
|
234
|
+
return false
|
|
235
|
+
}
|
|
236
|
+
// Disable para to para transfers
|
|
237
|
+
if (path.type === "substrate" && path.destinationType === "substrate") {
|
|
238
|
+
return false
|
|
239
|
+
}
|
|
240
|
+
return true
|
|
241
|
+
}
|
|
242
|
+
case "polkadot_mainnet":
|
|
243
|
+
return (path: Path) => {
|
|
244
|
+
// Disallow MYTH to any location but 3369
|
|
245
|
+
if (
|
|
246
|
+
path.asset === "0xba41ddf06b7ffd89d1267b5a93bfef2424eb2003" &&
|
|
247
|
+
((path.destination !== 3369 && path.type === "ethereum") ||
|
|
248
|
+
(path.source !== 3369 && path.type === "substrate"))
|
|
249
|
+
) {
|
|
250
|
+
return false
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Allow TRAC to go to Hydration (2034) and Neuroweb (2043) only
|
|
254
|
+
if (
|
|
255
|
+
path.asset === "0xaa7a9ca87d3694b5755f213b5d04094b8d0f0a6f" &&
|
|
256
|
+
((path.destination !== 2034 &&
|
|
257
|
+
path.destination !== 2043 &&
|
|
258
|
+
path.type === "ethereum") ||
|
|
259
|
+
(path.source !== 2034 && path.source !== 2043 && path.type === "substrate"))
|
|
260
|
+
) {
|
|
261
|
+
return false
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Disable stable coins in the UI from Ethereum to Polkadot
|
|
265
|
+
if (
|
|
266
|
+
(path.asset === "0x9d39a5de30e57443bff2a8307a4256c8797a3497" || // Staked USDe
|
|
267
|
+
path.asset === "0xa3931d71877c0e7a3148cb7eb4463524fec27fbd" || // Savings USD
|
|
268
|
+
path.asset === "0x6b175474e89094c44da98b954eedeac495271d0f") && // DAI
|
|
269
|
+
path.destination === 2034 // Hydration
|
|
270
|
+
) {
|
|
271
|
+
return false
|
|
272
|
+
}
|
|
273
|
+
// Disable para to para transfers except for hydration
|
|
274
|
+
if (
|
|
275
|
+
path.type === "substrate" &&
|
|
276
|
+
path.destinationType === "substrate" &&
|
|
277
|
+
!(
|
|
278
|
+
(path.source === 2034 && path.destination == 1000) ||
|
|
279
|
+
(path.source === 1000 && path.destination === 2034)
|
|
280
|
+
)
|
|
281
|
+
) {
|
|
282
|
+
return false
|
|
283
|
+
}
|
|
284
|
+
return true
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
default:
|
|
288
|
+
return (_: Path) => true
|
|
289
|
+
}
|
|
290
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"strict": true,
|
|
4
|
+
"noEmit": true,
|
|
5
|
+
"resolveJsonModule": true,
|
|
6
|
+
"allowSyntheticDefaultImports": true,
|
|
7
|
+
"target": "ES2022",
|
|
8
|
+
"moduleResolution": "node",
|
|
9
|
+
"composite": true,
|
|
10
|
+
"module": "commonjs",
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
"noEmitOnError": true,
|
|
16
|
+
"skipLibCheck": true,
|
|
17
|
+
"allowJs": true,
|
|
18
|
+
},
|
|
19
|
+
"exclude": [
|
|
20
|
+
"node_modules",
|
|
21
|
+
"dist",
|
|
22
|
+
],
|
|
23
|
+
}
|
package/build.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { assetsV2, environment } from "@snowbridge/api"
|
|
2
|
-
import { writeFile } from "fs/promises"
|
|
3
|
-
|
|
4
|
-
async function buildRegistry(env: string, options: assetsV2.RegistryOptions) {
|
|
5
|
-
const registry = await assetsV2.buildRegistry(options)
|
|
6
|
-
const json = JSON.stringify(
|
|
7
|
-
registry,
|
|
8
|
-
(key, value) => {
|
|
9
|
-
if (typeof value === "bigint") {
|
|
10
|
-
return `bigint:${value.toString()}`
|
|
11
|
-
}
|
|
12
|
-
return value
|
|
13
|
-
},
|
|
14
|
-
2
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
const filepath = `src/${env}.registry.json`
|
|
18
|
-
await writeFile(filepath, json)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
;(async () => {
|
|
22
|
-
let env = "local_e2e"
|
|
23
|
-
if (process.env.NODE_ENV !== undefined) {
|
|
24
|
-
env = process.env.NODE_ENV
|
|
25
|
-
}
|
|
26
|
-
const options = assetsV2.fromEnvironment(environment.SNOWBRIDGE_ENV[env])
|
|
27
|
-
await buildRegistry(env, options)
|
|
28
|
-
})()
|