@moonbeam-network/xcm-builder 3.3.9 → 4.0.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/build/index.d.ts +50 -1
- package/build/index.mjs +455 -100
- package/build/index.mjs.map +1 -1
- package/package.json +3 -3
package/build/index.mjs
CHANGED
|
@@ -1480,7 +1480,7 @@ function eqBalances() {
|
|
|
1480
1480
|
|
|
1481
1481
|
// src/extrinsic/pallets/polkadotXcm/polkadotXcm.util.ts
|
|
1482
1482
|
function getPolkadotXcmExtrinsicArgs({
|
|
1483
|
-
|
|
1483
|
+
assets: assets3,
|
|
1484
1484
|
destinationAddress,
|
|
1485
1485
|
destination,
|
|
1486
1486
|
func,
|
|
@@ -1511,7 +1511,53 @@ function getPolkadotXcmExtrinsicArgs({
|
|
|
1511
1511
|
},
|
|
1512
1512
|
// assets
|
|
1513
1513
|
{
|
|
1514
|
-
[version]:
|
|
1514
|
+
[version]: assets3
|
|
1515
|
+
},
|
|
1516
|
+
// feeAssetItem
|
|
1517
|
+
feeIndex,
|
|
1518
|
+
// weightLimit
|
|
1519
|
+
"Unlimited"
|
|
1520
|
+
];
|
|
1521
|
+
}
|
|
1522
|
+
function getEcosystemTransferExtrinsicArgs({
|
|
1523
|
+
assets: assets3,
|
|
1524
|
+
destinationAddress,
|
|
1525
|
+
destination,
|
|
1526
|
+
func,
|
|
1527
|
+
feeIndex = 0
|
|
1528
|
+
}) {
|
|
1529
|
+
const version = getExtrinsicArgumentVersion(func);
|
|
1530
|
+
return [
|
|
1531
|
+
// dest
|
|
1532
|
+
{
|
|
1533
|
+
[version]: normalizeX1(version, {
|
|
1534
|
+
parents: 2,
|
|
1535
|
+
interior: {
|
|
1536
|
+
X2: [
|
|
1537
|
+
{
|
|
1538
|
+
GlobalConsensus: {
|
|
1539
|
+
ByGenesis: destination.relayGenesisHash
|
|
1540
|
+
}
|
|
1541
|
+
},
|
|
1542
|
+
{
|
|
1543
|
+
Parachain: destination.parachainId
|
|
1544
|
+
}
|
|
1545
|
+
]
|
|
1546
|
+
}
|
|
1547
|
+
})
|
|
1548
|
+
},
|
|
1549
|
+
// beneficiary
|
|
1550
|
+
{
|
|
1551
|
+
[version]: normalizeX1(version, {
|
|
1552
|
+
parents: 0,
|
|
1553
|
+
interior: {
|
|
1554
|
+
X1: getExtrinsicAccount(destinationAddress)
|
|
1555
|
+
}
|
|
1556
|
+
})
|
|
1557
|
+
},
|
|
1558
|
+
// assets
|
|
1559
|
+
{
|
|
1560
|
+
[version]: assets3
|
|
1515
1561
|
},
|
|
1516
1562
|
// feeAssetItem
|
|
1517
1563
|
feeIndex,
|
|
@@ -1547,7 +1593,7 @@ function polkadotXcm() {
|
|
|
1547
1593
|
return getPolkadotXcmExtrinsicArgs({
|
|
1548
1594
|
...params,
|
|
1549
1595
|
func: extrinsicFunction,
|
|
1550
|
-
|
|
1596
|
+
assets: [
|
|
1551
1597
|
{
|
|
1552
1598
|
id: normalizeConcrete(version, {
|
|
1553
1599
|
parents: 0,
|
|
@@ -1571,7 +1617,7 @@ function polkadotXcm() {
|
|
|
1571
1617
|
return getPolkadotXcmExtrinsicArgs({
|
|
1572
1618
|
...params,
|
|
1573
1619
|
func: extrinsicFunction,
|
|
1574
|
-
|
|
1620
|
+
assets: [
|
|
1575
1621
|
{
|
|
1576
1622
|
id: normalizeConcrete(
|
|
1577
1623
|
version,
|
|
@@ -1649,7 +1695,7 @@ function polkadotXcm() {
|
|
|
1649
1695
|
return getPolkadotXcmExtrinsicArgs({
|
|
1650
1696
|
...params,
|
|
1651
1697
|
func: extrinsicFunction,
|
|
1652
|
-
|
|
1698
|
+
assets: assets3,
|
|
1653
1699
|
feeIndex: isAssetDifferent && !shouldFeeAssetPrecede ? 1 : 0
|
|
1654
1700
|
});
|
|
1655
1701
|
}
|
|
@@ -1667,7 +1713,7 @@ function polkadotXcm() {
|
|
|
1667
1713
|
return getPolkadotXcmExtrinsicArgs({
|
|
1668
1714
|
...params,
|
|
1669
1715
|
func: extrinsicFunction,
|
|
1670
|
-
|
|
1716
|
+
assets: [
|
|
1671
1717
|
{
|
|
1672
1718
|
id: normalizeConcrete(version, {
|
|
1673
1719
|
parents: 1,
|
|
@@ -1705,7 +1751,7 @@ function polkadotXcm() {
|
|
|
1705
1751
|
return getPolkadotXcmExtrinsicArgs({
|
|
1706
1752
|
...params,
|
|
1707
1753
|
func: extrinsicFunction,
|
|
1708
|
-
|
|
1754
|
+
assets: [
|
|
1709
1755
|
{
|
|
1710
1756
|
id: normalizeConcrete(version, {
|
|
1711
1757
|
parents: 1,
|
|
@@ -1743,7 +1789,7 @@ function polkadotXcm() {
|
|
|
1743
1789
|
return getPolkadotXcmExtrinsicArgs({
|
|
1744
1790
|
...params,
|
|
1745
1791
|
func: extrinsicFunction,
|
|
1746
|
-
|
|
1792
|
+
assets: [
|
|
1747
1793
|
{
|
|
1748
1794
|
id: normalizeConcrete(version, {
|
|
1749
1795
|
parents,
|
|
@@ -1767,7 +1813,7 @@ function polkadotXcm() {
|
|
|
1767
1813
|
return getPolkadotXcmExtrinsicArgs({
|
|
1768
1814
|
...params,
|
|
1769
1815
|
func: extrinsicFunction,
|
|
1770
|
-
|
|
1816
|
+
assets: [
|
|
1771
1817
|
{
|
|
1772
1818
|
id: normalizeConcrete(version, {
|
|
1773
1819
|
parents: 0,
|
|
@@ -1835,7 +1881,7 @@ function polkadotXcm() {
|
|
|
1835
1881
|
return getPolkadotXcmExtrinsicArgs({
|
|
1836
1882
|
...params,
|
|
1837
1883
|
func: extrinsicFunction,
|
|
1838
|
-
|
|
1884
|
+
assets: assets3
|
|
1839
1885
|
});
|
|
1840
1886
|
}
|
|
1841
1887
|
})
|
|
@@ -1852,7 +1898,7 @@ function polkadotXcm() {
|
|
|
1852
1898
|
return getPolkadotXcmExtrinsicArgs({
|
|
1853
1899
|
...params,
|
|
1854
1900
|
func: extrinsicFunction,
|
|
1855
|
-
|
|
1901
|
+
assets: [
|
|
1856
1902
|
{
|
|
1857
1903
|
id: normalizeConcrete(version, {
|
|
1858
1904
|
parents: 1,
|
|
@@ -1891,7 +1937,7 @@ function polkadotXcm() {
|
|
|
1891
1937
|
return getPolkadotXcmExtrinsicArgs({
|
|
1892
1938
|
...params,
|
|
1893
1939
|
func: extrinsicFunction,
|
|
1894
|
-
|
|
1940
|
+
assets: [
|
|
1895
1941
|
{
|
|
1896
1942
|
id: normalizeConcrete(version, {
|
|
1897
1943
|
parents: 1,
|
|
@@ -1947,7 +1993,7 @@ function polkadotXcm() {
|
|
|
1947
1993
|
return getPolkadotXcmExtrinsicArgs({
|
|
1948
1994
|
...params,
|
|
1949
1995
|
func: extrinsicFunction,
|
|
1950
|
-
|
|
1996
|
+
assets: [
|
|
1951
1997
|
{
|
|
1952
1998
|
id: normalizeConcrete(version, {
|
|
1953
1999
|
parents: 0,
|
|
@@ -2141,60 +2187,67 @@ function polkadotXcm() {
|
|
|
2141
2187
|
func,
|
|
2142
2188
|
getArgs: (extrinsicFunction) => {
|
|
2143
2189
|
const version = getExtrinsicArgumentVersion(extrinsicFunction);
|
|
2144
|
-
|
|
2145
|
-
// dest
|
|
2190
|
+
const assets3 = [
|
|
2146
2191
|
{
|
|
2147
|
-
|
|
2148
|
-
|
|
2192
|
+
id: normalizeConcrete(
|
|
2193
|
+
version,
|
|
2194
|
+
normalizeX1(version, {
|
|
2195
|
+
parents: 0,
|
|
2196
|
+
interior: {
|
|
2197
|
+
X1: {
|
|
2198
|
+
PalletInstance: params.asset.getAssetPalletInstance()
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
})
|
|
2202
|
+
),
|
|
2203
|
+
fun: {
|
|
2204
|
+
Fungible: params.asset.amount
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
];
|
|
2208
|
+
return getEcosystemTransferExtrinsicArgs({
|
|
2209
|
+
...params,
|
|
2210
|
+
func: extrinsicFunction,
|
|
2211
|
+
assets: assets3
|
|
2212
|
+
});
|
|
2213
|
+
}
|
|
2214
|
+
});
|
|
2215
|
+
}
|
|
2216
|
+
}),
|
|
2217
|
+
X2: () => ({
|
|
2218
|
+
build: (params) => {
|
|
2219
|
+
return new ExtrinsicConfig({
|
|
2220
|
+
module: pallet2,
|
|
2221
|
+
func,
|
|
2222
|
+
getArgs: (extrinsicFunction) => {
|
|
2223
|
+
const version = getExtrinsicArgumentVersion(extrinsicFunction);
|
|
2224
|
+
const assets3 = [
|
|
2225
|
+
{
|
|
2226
|
+
id: normalizeConcrete(version, {
|
|
2227
|
+
parents: 0,
|
|
2149
2228
|
interior: {
|
|
2150
2229
|
X2: [
|
|
2151
2230
|
{
|
|
2152
|
-
|
|
2153
|
-
ByGenesis: params.destination.relayGenesisHash
|
|
2154
|
-
}
|
|
2231
|
+
PalletInstance: params.asset.getAssetPalletInstance()
|
|
2155
2232
|
},
|
|
2156
2233
|
{
|
|
2157
|
-
|
|
2234
|
+
AccountKey20: {
|
|
2235
|
+
key: params.asset.address
|
|
2236
|
+
}
|
|
2158
2237
|
}
|
|
2159
2238
|
]
|
|
2160
2239
|
}
|
|
2161
|
-
})
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
parents: 0,
|
|
2167
|
-
interior: {
|
|
2168
|
-
X1: getExtrinsicAccount(params.destinationAddress)
|
|
2169
|
-
}
|
|
2170
|
-
})
|
|
2171
|
-
},
|
|
2172
|
-
// assets
|
|
2173
|
-
{
|
|
2174
|
-
[version]: [
|
|
2175
|
-
{
|
|
2176
|
-
id: normalizeConcrete(
|
|
2177
|
-
version,
|
|
2178
|
-
normalizeX1(version, {
|
|
2179
|
-
parents: 0,
|
|
2180
|
-
interior: {
|
|
2181
|
-
X1: {
|
|
2182
|
-
PalletInstance: params.asset.getAssetPalletInstance()
|
|
2183
|
-
}
|
|
2184
|
-
}
|
|
2185
|
-
})
|
|
2186
|
-
),
|
|
2187
|
-
fun: {
|
|
2188
|
-
Fungible: params.asset.amount
|
|
2189
|
-
}
|
|
2190
|
-
}
|
|
2191
|
-
]
|
|
2192
|
-
},
|
|
2193
|
-
// feeAssetItem
|
|
2194
|
-
0,
|
|
2195
|
-
// weightLimit
|
|
2196
|
-
"Unlimited"
|
|
2240
|
+
}),
|
|
2241
|
+
fun: {
|
|
2242
|
+
Fungible: params.asset.amount
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2197
2245
|
];
|
|
2246
|
+
return getEcosystemTransferExtrinsicArgs({
|
|
2247
|
+
...params,
|
|
2248
|
+
func: extrinsicFunction,
|
|
2249
|
+
assets: assets3
|
|
2250
|
+
});
|
|
2198
2251
|
}
|
|
2199
2252
|
});
|
|
2200
2253
|
}
|
|
@@ -2209,13 +2262,12 @@ function polkadotXcm() {
|
|
|
2209
2262
|
func,
|
|
2210
2263
|
getArgs: (extrinsicFunction) => {
|
|
2211
2264
|
const version = getExtrinsicArgumentVersion(extrinsicFunction);
|
|
2212
|
-
|
|
2213
|
-
// dest
|
|
2265
|
+
const assets3 = [
|
|
2214
2266
|
{
|
|
2215
|
-
|
|
2267
|
+
id: normalizeConcrete(version, {
|
|
2216
2268
|
parents: 2,
|
|
2217
2269
|
interior: {
|
|
2218
|
-
|
|
2270
|
+
X3: [
|
|
2219
2271
|
{
|
|
2220
2272
|
GlobalConsensus: {
|
|
2221
2273
|
ByGenesis: params.destination.relayGenesisHash
|
|
@@ -2223,53 +2275,98 @@ function polkadotXcm() {
|
|
|
2223
2275
|
},
|
|
2224
2276
|
{
|
|
2225
2277
|
Parachain: params.destination.parachainId
|
|
2278
|
+
},
|
|
2279
|
+
{
|
|
2280
|
+
PalletInstance: assetInDestination.getAssetPalletInstance()
|
|
2226
2281
|
}
|
|
2227
2282
|
]
|
|
2228
2283
|
}
|
|
2229
|
-
})
|
|
2230
|
-
|
|
2231
|
-
|
|
2284
|
+
}),
|
|
2285
|
+
fun: {
|
|
2286
|
+
Fungible: params.asset.amount
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
];
|
|
2290
|
+
return getEcosystemTransferExtrinsicArgs({
|
|
2291
|
+
...params,
|
|
2292
|
+
func: extrinsicFunction,
|
|
2293
|
+
assets: assets3
|
|
2294
|
+
});
|
|
2295
|
+
}
|
|
2296
|
+
});
|
|
2297
|
+
}
|
|
2298
|
+
}),
|
|
2299
|
+
X4: () => ({
|
|
2300
|
+
build: (params) => {
|
|
2301
|
+
return new ExtrinsicConfig({
|
|
2302
|
+
module: pallet2,
|
|
2303
|
+
func,
|
|
2304
|
+
getArgs: (extrinsicFunction) => {
|
|
2305
|
+
const version = getExtrinsicArgumentVersion(extrinsicFunction);
|
|
2306
|
+
const feeAssetInDestination = params.destination.getChainAsset(
|
|
2307
|
+
params.fee
|
|
2308
|
+
);
|
|
2309
|
+
const assetInDestination = params.destination.getChainAsset(
|
|
2310
|
+
params.asset
|
|
2311
|
+
);
|
|
2312
|
+
const assets3 = [
|
|
2232
2313
|
{
|
|
2233
|
-
|
|
2234
|
-
parents:
|
|
2314
|
+
id: normalizeConcrete(version, {
|
|
2315
|
+
parents: 2,
|
|
2235
2316
|
interior: {
|
|
2236
|
-
|
|
2317
|
+
X3: [
|
|
2318
|
+
{
|
|
2319
|
+
GlobalConsensus: {
|
|
2320
|
+
ByGenesis: params.destination.relayGenesisHash
|
|
2321
|
+
}
|
|
2322
|
+
},
|
|
2323
|
+
{
|
|
2324
|
+
Parachain: params.destination.parachainId
|
|
2325
|
+
},
|
|
2326
|
+
{
|
|
2327
|
+
PalletInstance: feeAssetInDestination.getAssetPalletInstance()
|
|
2328
|
+
}
|
|
2329
|
+
]
|
|
2237
2330
|
}
|
|
2238
|
-
})
|
|
2331
|
+
}),
|
|
2332
|
+
fun: {
|
|
2333
|
+
Fungible: params.fee.amount
|
|
2334
|
+
}
|
|
2239
2335
|
},
|
|
2240
|
-
// assets
|
|
2241
2336
|
{
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2337
|
+
id: normalizeConcrete(version, {
|
|
2338
|
+
parents: 2,
|
|
2339
|
+
interior: {
|
|
2340
|
+
X4: [
|
|
2341
|
+
{
|
|
2342
|
+
GlobalConsensus: {
|
|
2343
|
+
ByGenesis: params.destination.relayGenesisHash
|
|
2344
|
+
}
|
|
2345
|
+
},
|
|
2346
|
+
{
|
|
2347
|
+
Parachain: params.destination.parachainId
|
|
2348
|
+
},
|
|
2349
|
+
{
|
|
2350
|
+
PalletInstance: assetInDestination.getAssetPalletInstance()
|
|
2351
|
+
},
|
|
2352
|
+
{
|
|
2353
|
+
AccountKey20: {
|
|
2354
|
+
key: assetInDestination.address
|
|
2355
|
+
}
|
|
2260
2356
|
}
|
|
2261
|
-
|
|
2262
|
-
fun: {
|
|
2263
|
-
Fungible: params.asset.amount
|
|
2264
|
-
}
|
|
2357
|
+
]
|
|
2265
2358
|
}
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
"Unlimited"
|
|
2359
|
+
}),
|
|
2360
|
+
fun: {
|
|
2361
|
+
Fungible: params.asset.amount
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2272
2364
|
];
|
|
2365
|
+
return getEcosystemTransferExtrinsicArgs({
|
|
2366
|
+
...params,
|
|
2367
|
+
func: extrinsicFunction,
|
|
2368
|
+
assets: assets3
|
|
2369
|
+
});
|
|
2273
2370
|
}
|
|
2274
2371
|
});
|
|
2275
2372
|
}
|
|
@@ -2296,7 +2393,7 @@ function xcmPallet() {
|
|
|
2296
2393
|
...params,
|
|
2297
2394
|
parents,
|
|
2298
2395
|
func: extrinsicFunction,
|
|
2299
|
-
|
|
2396
|
+
assets: [
|
|
2300
2397
|
{
|
|
2301
2398
|
id: normalizeConcrete(version, {
|
|
2302
2399
|
parents: 0,
|
|
@@ -3054,6 +3151,263 @@ function FeeBuilder() {
|
|
|
3054
3151
|
};
|
|
3055
3152
|
}
|
|
3056
3153
|
|
|
3154
|
+
// src/monitoring/eventMonitoring/eventMonitoring.ts
|
|
3155
|
+
import { u8aToHex as u8aToHex7 } from "@polkadot/util";
|
|
3156
|
+
import { decodeAddress as decodeAddress7 } from "@polkadot/util-crypto";
|
|
3157
|
+
|
|
3158
|
+
// src/monitoring/eventMonitoring/eventMonitoring.utils.ts
|
|
3159
|
+
import { u8aToHex as u8aToHex6 } from "@polkadot/util";
|
|
3160
|
+
import { decodeAddress as decodeAddress6 } from "@polkadot/util-crypto";
|
|
3161
|
+
var createSourceChecker = (section, method, addressExtractor, messageIdExtractor) => (events, sourceAddress) => {
|
|
3162
|
+
const decodedSourceAddress = u8aToHex6(decodeAddress6(sourceAddress));
|
|
3163
|
+
const methods = Array.isArray(method) ? method : [method];
|
|
3164
|
+
const event = events.find((event2) => {
|
|
3165
|
+
if (event2.event.section !== section || !methods.includes(event2.event.method)) {
|
|
3166
|
+
return false;
|
|
3167
|
+
}
|
|
3168
|
+
try {
|
|
3169
|
+
const address = addressExtractor(event2);
|
|
3170
|
+
return address === decodedSourceAddress;
|
|
3171
|
+
} catch {
|
|
3172
|
+
return false;
|
|
3173
|
+
}
|
|
3174
|
+
});
|
|
3175
|
+
if (!event) {
|
|
3176
|
+
return { matched: false };
|
|
3177
|
+
}
|
|
3178
|
+
try {
|
|
3179
|
+
const messageId = messageIdExtractor(event, events);
|
|
3180
|
+
return { matched: true, messageId, event };
|
|
3181
|
+
} catch {
|
|
3182
|
+
return { matched: true, event };
|
|
3183
|
+
}
|
|
3184
|
+
};
|
|
3185
|
+
var createDestinationChecker = (section, method, matchMessageId, getIsSuccess) => (events, messageId) => {
|
|
3186
|
+
const methods = Array.isArray(method) ? method : [method];
|
|
3187
|
+
const event = events.find((event2) => {
|
|
3188
|
+
if (event2.event.section !== section || !methods.includes(event2.event.method)) {
|
|
3189
|
+
return false;
|
|
3190
|
+
}
|
|
3191
|
+
return matchMessageId(event2, messageId);
|
|
3192
|
+
});
|
|
3193
|
+
if (!event) {
|
|
3194
|
+
return { matched: false, success: false };
|
|
3195
|
+
}
|
|
3196
|
+
const success = getIsSuccess(event);
|
|
3197
|
+
return { matched: true, success, event };
|
|
3198
|
+
};
|
|
3199
|
+
|
|
3200
|
+
// src/monitoring/eventMonitoring/eventMonitoring.ts
|
|
3201
|
+
function GetAddress() {
|
|
3202
|
+
return {
|
|
3203
|
+
fromXcmEvent: () => (event) => {
|
|
3204
|
+
const eventData = event.event.data;
|
|
3205
|
+
const interior = eventData.origin.interior.asX1[0];
|
|
3206
|
+
if (interior.isAccountId32) {
|
|
3207
|
+
return interior.asAccountId32.id.toHex();
|
|
3208
|
+
} else if (interior.isAccountKey20) {
|
|
3209
|
+
return interior.asAccountKey20.key.toString();
|
|
3210
|
+
} else {
|
|
3211
|
+
throw new Error("Unsupported address type");
|
|
3212
|
+
}
|
|
3213
|
+
},
|
|
3214
|
+
fromXTokensEvent: () => (event) => {
|
|
3215
|
+
const eventData = event.event.data;
|
|
3216
|
+
return u8aToHex7(decodeAddress7(eventData.sender.toString()));
|
|
3217
|
+
}
|
|
3218
|
+
};
|
|
3219
|
+
}
|
|
3220
|
+
function GetMessageId() {
|
|
3221
|
+
return {
|
|
3222
|
+
fromXcmEvent: () => (event) => {
|
|
3223
|
+
const eventData = event.event.data;
|
|
3224
|
+
return eventData.messageId.toHex();
|
|
3225
|
+
},
|
|
3226
|
+
fromXcmpQueue: () => (_event, events) => {
|
|
3227
|
+
const xcmpEvent = events?.find(
|
|
3228
|
+
(event) => event.event.section === "xcmpQueue" && event.event.method === "XcmpMessageSent"
|
|
3229
|
+
);
|
|
3230
|
+
if (!xcmpEvent) {
|
|
3231
|
+
throw new Error("XcmpMessageSent event not found");
|
|
3232
|
+
}
|
|
3233
|
+
const eventData = xcmpEvent.event.data;
|
|
3234
|
+
return eventData.messageHash.toHex();
|
|
3235
|
+
}
|
|
3236
|
+
};
|
|
3237
|
+
}
|
|
3238
|
+
function MatchMessageId() {
|
|
3239
|
+
return {
|
|
3240
|
+
fromMessageQueueId: () => (event, messageId) => {
|
|
3241
|
+
if (!messageId) return true;
|
|
3242
|
+
try {
|
|
3243
|
+
const eventData = event.event.data;
|
|
3244
|
+
return eventData.id.toString() === messageId;
|
|
3245
|
+
} catch {
|
|
3246
|
+
return false;
|
|
3247
|
+
}
|
|
3248
|
+
},
|
|
3249
|
+
fromXcmpQueueHash: () => (event, messageId) => {
|
|
3250
|
+
if (!messageId) return true;
|
|
3251
|
+
try {
|
|
3252
|
+
const eventData = event.event.data;
|
|
3253
|
+
return eventData.messageHash.toString() === messageId;
|
|
3254
|
+
} catch {
|
|
3255
|
+
return false;
|
|
3256
|
+
}
|
|
3257
|
+
},
|
|
3258
|
+
fromEthereumXcmEvent: () => (event) => {
|
|
3259
|
+
const eventData = event.event.data;
|
|
3260
|
+
return eventData.xcmMsgHash.toHex();
|
|
3261
|
+
},
|
|
3262
|
+
never: () => () => true
|
|
3263
|
+
// Always match for cases where messageId is not used
|
|
3264
|
+
};
|
|
3265
|
+
}
|
|
3266
|
+
function GetIsSuccess() {
|
|
3267
|
+
return {
|
|
3268
|
+
fromMessageQueueProcessed: () => (event) => {
|
|
3269
|
+
try {
|
|
3270
|
+
const eventData = event.event.data;
|
|
3271
|
+
return eventData.success.isTrue;
|
|
3272
|
+
} catch {
|
|
3273
|
+
return false;
|
|
3274
|
+
}
|
|
3275
|
+
},
|
|
3276
|
+
fromXcmpQueueEvent: () => (event) => {
|
|
3277
|
+
return event.event.method === "Success";
|
|
3278
|
+
},
|
|
3279
|
+
alwaysTrue: () => () => true
|
|
3280
|
+
// Always successful for simple cases
|
|
3281
|
+
};
|
|
3282
|
+
}
|
|
3283
|
+
function CheckSource() {
|
|
3284
|
+
return {
|
|
3285
|
+
xcmPallet: () => createSourceChecker(
|
|
3286
|
+
"xcmPallet",
|
|
3287
|
+
"Sent",
|
|
3288
|
+
GetAddress().fromXcmEvent(),
|
|
3289
|
+
GetMessageId().fromXcmEvent()
|
|
3290
|
+
),
|
|
3291
|
+
polkadotXcm: () => createSourceChecker(
|
|
3292
|
+
"polkadotXcm",
|
|
3293
|
+
"Sent",
|
|
3294
|
+
GetAddress().fromXcmEvent(),
|
|
3295
|
+
GetMessageId().fromXcmEvent()
|
|
3296
|
+
),
|
|
3297
|
+
polkadotXcmAndXcmpQueue: () => createSourceChecker(
|
|
3298
|
+
"polkadotXcm",
|
|
3299
|
+
"Sent",
|
|
3300
|
+
GetAddress().fromXcmEvent(),
|
|
3301
|
+
GetMessageId().fromXcmpQueue()
|
|
3302
|
+
),
|
|
3303
|
+
xTokens: () => createSourceChecker(
|
|
3304
|
+
"xTokens",
|
|
3305
|
+
["TransferredMultiAssets", "TransferredAssets"],
|
|
3306
|
+
GetAddress().fromXTokensEvent(),
|
|
3307
|
+
GetMessageId().fromXcmpQueue()
|
|
3308
|
+
),
|
|
3309
|
+
bridgeMessages: () => (events) => {
|
|
3310
|
+
const event = events.find(
|
|
3311
|
+
(event2) => event2.event.section === "bridgeMessages" && event2.event.method === "MessageAccepted"
|
|
3312
|
+
);
|
|
3313
|
+
return event ? { matched: true, event } : { matched: false };
|
|
3314
|
+
}
|
|
3315
|
+
};
|
|
3316
|
+
}
|
|
3317
|
+
function CheckDestination() {
|
|
3318
|
+
return {
|
|
3319
|
+
messageQueue: () => createDestinationChecker(
|
|
3320
|
+
"messageQueue",
|
|
3321
|
+
"Processed",
|
|
3322
|
+
MatchMessageId().fromMessageQueueId(),
|
|
3323
|
+
GetIsSuccess().fromMessageQueueProcessed()
|
|
3324
|
+
),
|
|
3325
|
+
xcmpQueue: () => (events, messageId) => {
|
|
3326
|
+
const messageIdMatcher = MatchMessageId().fromXcmpQueueHash();
|
|
3327
|
+
const successEvent = events.find((event) => {
|
|
3328
|
+
if (event.event.section !== "xcmpQueue" || event.event.method !== "Success") {
|
|
3329
|
+
return false;
|
|
3330
|
+
}
|
|
3331
|
+
return messageIdMatcher(event, messageId);
|
|
3332
|
+
});
|
|
3333
|
+
const failEvent = events.find((event) => {
|
|
3334
|
+
if (event.event.section !== "xcmpQueue" || event.event.method !== "Fail") {
|
|
3335
|
+
return false;
|
|
3336
|
+
}
|
|
3337
|
+
return messageIdMatcher(event, messageId);
|
|
3338
|
+
});
|
|
3339
|
+
if (!successEvent && !failEvent) {
|
|
3340
|
+
return { matched: false, success: false };
|
|
3341
|
+
}
|
|
3342
|
+
return {
|
|
3343
|
+
matched: true,
|
|
3344
|
+
success: !!successEvent,
|
|
3345
|
+
event: successEvent || failEvent
|
|
3346
|
+
};
|
|
3347
|
+
},
|
|
3348
|
+
bridgeMessages: () => createDestinationChecker(
|
|
3349
|
+
"bridgeMessages",
|
|
3350
|
+
"MessagesReceived",
|
|
3351
|
+
// TODO implement message matching
|
|
3352
|
+
MatchMessageId().never(),
|
|
3353
|
+
GetIsSuccess().alwaysTrue()
|
|
3354
|
+
),
|
|
3355
|
+
ethereumXcm: () => createDestinationChecker(
|
|
3356
|
+
"ethereumXcm",
|
|
3357
|
+
"ExecutedFromXcm",
|
|
3358
|
+
MatchMessageId().never(),
|
|
3359
|
+
GetIsSuccess().alwaysTrue()
|
|
3360
|
+
)
|
|
3361
|
+
};
|
|
3362
|
+
}
|
|
3363
|
+
function monitorEvent() {
|
|
3364
|
+
return {
|
|
3365
|
+
xcmPallet: () => ({
|
|
3366
|
+
messageQueue: () => ({
|
|
3367
|
+
checkSource: CheckSource().xcmPallet(),
|
|
3368
|
+
checkDestination: CheckDestination().messageQueue()
|
|
3369
|
+
})
|
|
3370
|
+
}),
|
|
3371
|
+
polkadotXcm: () => ({
|
|
3372
|
+
messageQueue: () => ({
|
|
3373
|
+
checkSource: CheckSource().polkadotXcm(),
|
|
3374
|
+
checkDestination: CheckDestination().messageQueue()
|
|
3375
|
+
}),
|
|
3376
|
+
mixedQueue: () => ({
|
|
3377
|
+
checkSource: CheckSource().polkadotXcmAndXcmpQueue(),
|
|
3378
|
+
checkDestination: CheckDestination().messageQueue()
|
|
3379
|
+
}),
|
|
3380
|
+
xcmpQueue: () => ({
|
|
3381
|
+
checkSource: CheckSource().polkadotXcmAndXcmpQueue(),
|
|
3382
|
+
checkDestination: CheckDestination().xcmpQueue()
|
|
3383
|
+
})
|
|
3384
|
+
}),
|
|
3385
|
+
xTokens: () => ({
|
|
3386
|
+
messageQueue: () => ({
|
|
3387
|
+
checkSource: CheckSource().xTokens(),
|
|
3388
|
+
checkDestination: CheckDestination().messageQueue()
|
|
3389
|
+
}),
|
|
3390
|
+
ethereumXcm: () => ({
|
|
3391
|
+
checkSource: CheckSource().xTokens(),
|
|
3392
|
+
checkDestination: CheckDestination().ethereumXcm()
|
|
3393
|
+
})
|
|
3394
|
+
}),
|
|
3395
|
+
bridgeMessages: () => ({
|
|
3396
|
+
bridgeMessages: () => ({
|
|
3397
|
+
checkSource: CheckSource().bridgeMessages(),
|
|
3398
|
+
checkDestination: CheckDestination().bridgeMessages()
|
|
3399
|
+
})
|
|
3400
|
+
})
|
|
3401
|
+
};
|
|
3402
|
+
}
|
|
3403
|
+
|
|
3404
|
+
// src/monitoring/MonitoringBuilder.ts
|
|
3405
|
+
function MonitoringBuilder() {
|
|
3406
|
+
return {
|
|
3407
|
+
monitorEvent
|
|
3408
|
+
};
|
|
3409
|
+
}
|
|
3410
|
+
|
|
3057
3411
|
// src/mrl/providers/wormhole/contract/Batch/Batch.ts
|
|
3058
3412
|
import {
|
|
3059
3413
|
EvmParachain as EvmParachain2
|
|
@@ -3956,7 +4310,7 @@ function getCurrencies({ source, moonAsset, asset }) {
|
|
|
3956
4310
|
}
|
|
3957
4311
|
|
|
3958
4312
|
// src/mrl/providers/wormhole/contract/Gmp/Gmp.ts
|
|
3959
|
-
import { u8aToHex as
|
|
4313
|
+
import { u8aToHex as u8aToHex8 } from "@polkadot/util";
|
|
3960
4314
|
|
|
3961
4315
|
// src/mrl/providers/wormhole/contract/Gmp/GmpAbi.ts
|
|
3962
4316
|
var GMP_ABI = [
|
|
@@ -3982,7 +4336,7 @@ function Gmp() {
|
|
|
3982
4336
|
return {
|
|
3983
4337
|
wormholeTransferERC20: () => ({
|
|
3984
4338
|
build: ({ bytes }) => {
|
|
3985
|
-
const hex =
|
|
4339
|
+
const hex = u8aToHex8(bytes);
|
|
3986
4340
|
return new ContractConfig({
|
|
3987
4341
|
address: GMP_CONTRACT_ADDRESS,
|
|
3988
4342
|
abi: GMP_ABI,
|
|
@@ -5735,6 +6089,7 @@ export {
|
|
|
5735
6089
|
ExtrinsicBuilder,
|
|
5736
6090
|
ExtrinsicConfig,
|
|
5737
6091
|
FeeBuilder,
|
|
6092
|
+
MonitoringBuilder,
|
|
5738
6093
|
MrlBuilder,
|
|
5739
6094
|
Protocols,
|
|
5740
6095
|
SubstrateCallConfig,
|