-
Notifications
You must be signed in to change notification settings - Fork 5
/
calculateMBRT3100_MRLFix.ts
91 lines (77 loc) · 2.21 KB
/
calculateMBRT3100_MRLFix.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { ApiPromise, WsProvider } from '@polkadot/api';
import { decodeAddress } from '@polkadot/util-crypto';
import MBFixData from './misc/Hydration_asset_transfer_fail.json';
// Create Provider
const wsProvider = 'wss://wss.api.moonbeam.network';
const hydraDX = '0x7369626cf2070000000000000000000000000000';
const main = async () => {
// Load Provider
const api = await ApiPromise.create({
provider: new WsProvider(wsProvider),
noInitWarn: true,
});
await api.isReady;
const tx = await getMBFixData(api);
// Wrap around dispatch as
const dispatchTx = await api.tx.utility.dispatchAs({ system: { Signed: hydraDX } }, tx);
console.log(`XCM to Fix Everything Batched: ${dispatchTx.method.toHex()}`);
// Wrap around whitelist dispatch
const whitelistTx = await api.tx.whitelist.dispatchWhitelistedCallWithPreimage(dispatchTx);
console.log(`\nWhitelist Call: ${whitelistTx.method.toHex()}`);
await api.disconnect();
};
const getMBFixData = async (api) => {
let batch = [];
for (let i = 0; i < MBFixData.length; i++) {
batch.push(
await api.tx.xTokens.transferMultiasset(
{
V4: {
id: {
parents: 0,
interior: {
X2: [
{
PalletInstance: 110,
},
{
AccountKey20: {
network: null,
key: MBFixData[i].asset,
},
},
],
},
},
fun: { Fungible: BigInt(MBFixData[i].amount) },
},
},
{
V4: {
parents: 1,
interior: {
X2: [
{
Parachain: 2034,
},
{
AccountId32: {
network: null,
id: decodeAddress(MBFixData[i].sender),
},
},
],
},
},
},
'Unlimited'
)
);
}
// Batch Subcalls
const dispatchTx = await api.tx.utility.batchAll(batch);
return dispatchTx;
};
main()
.catch(console.error)
.finally(() => process.exit());