-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsendingGifts.js
156 lines (112 loc) · 4.09 KB
/
sendingGifts.js
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import {DirectSecp256k1HdWallet} from "@cosmjs/proto-signing";
import {getEligibilityInfo, getGiftsInfo, revealNFT, sendPostRequest, sendPostRequestToMint} from "./httpFunctions.js";
export const sendingGifts = async (newMnemonics) => {
for (let i = 0; i < newMnemonics.length; i++) {
try {
const wallet1 = await DirectSecp256k1HdWallet.fromMnemonic(
newMnemonics[i],
{prefix: 'sei'}
);
const wallet2 = await DirectSecp256k1HdWallet.fromMnemonic(
newMnemonics[i + 1],
{prefix: 'sei'}
);
const [firstAccountWallet1] = await wallet1.getAccounts();
const [firstAccountWallet2] = await wallet2.getAccounts();
await sendPostRequest(firstAccountWallet1.address, firstAccountWallet2.address);
} catch (err) {
console.log(err);
}
}
}
export const claimingGifts = async (newMnemonics) => {
for (let i = 0; i < newMnemonics.length; i++) {
try {
const wallet1 = await DirectSecp256k1HdWallet.fromMnemonic(
newMnemonics[i],
{prefix: 'sei'}
);
const [firstAccountWallet1] = await wallet1.getAccounts();
await sendPostRequestToMint(firstAccountWallet1.address);
} catch (err) {
console.log(err);
}
}
}
export const checkGiftsInfo = async (newMnemonics) => {
let counter = 0;
for (let i = 0; i < newMnemonics.length; i++) {
try {
const wallet1 = await DirectSecp256k1HdWallet.fromMnemonic(
newMnemonics[i],
{prefix: 'sei'}
);
const [firstAccountWallet1] = await wallet1.getAccounts();
const mintedCount = await getGiftsInfo(firstAccountWallet1.address);
await new Promise(resolve => setTimeout(resolve, 2000));
counter+=mintedCount;
} catch (err) {
console.log(err);
}
}
console.log(`Total minted gifts: ${counter}`);
}
export const checkEligibilityInfo = async (newMnemonics) => {
const eligibilityInfo = [];
for (let i = 0; i < newMnemonics.length; i++) {
try {
const wallet1 = await DirectSecp256k1HdWallet.fromMnemonic(
newMnemonics[i],
{prefix: 'sei'}
);
const [firstAccountWallet1] = await wallet1.getAccounts();
const info = await getEligibilityInfo(firstAccountWallet1.address);
if (info) eligibilityInfo.push(info);
} catch (err) {
console.log(err.message);
}
}
return eligibilityInfo;
}
export const revealGifts = async (mnemonics) => {
const rarityResult = {
common: 0,
uncommon: 0,
rare: 0,
mythic: 0,
}
let pointsTotal = 0;
let {rare, common, mythic, uncommon} = rarityResult;
for (let i = 0; i < mnemonics.length; i++) {
try {
const wallet1 = await DirectSecp256k1HdWallet.fromMnemonic(
mnemonics[i],
{prefix: 'sei'}
);
const [firstAccountWallet1] = await wallet1.getAccounts();
const result = await revealNFT(firstAccountWallet1.address);
await new Promise(resolve => setTimeout(resolve, 2000));
if (result?.ponits) {
pointsTotal = result.points + pointsTotal;
}
switch (result?.rarity) {
case 'common':
common = common + 1
break;
case 'uncommon':
uncommon = uncommon + 1
break;
case 'rare':
rare = rare + 1
break;
case 'mythic':
mythic = mythic + 1
break;
}
} catch (err) {
console.log(err);
}
}
console.log(`Gifts results: Common: ${common} Uncommon: ${uncommon} Rare: ${rare} Mythic: ${mythic}`);
console.log(`Total points: ${pointsTotal}`)
}