Skip to content

Commit c69ac46

Browse files
feat(chunk): flag for chunking batch call on emotes
1 parent f7988cf commit c69ac46

File tree

6 files changed

+44
-39
lines changed

6 files changed

+44
-39
lines changed

Diff for: .addresses.txt

-4
This file was deleted.

Diff for: .receiving-addresses.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FUKCwdGW4LofxJhvTMR8h3f2tP269DZEYEH51JbKCo3UChb
2+
JEVPTctJ2qXTwia23UmAFi5QEJCSTNbSJsxvqZkf5E6vGnt
3+
EVVr12NFATeJe2ghnzcRpRUMc6V2FcrA2mdV2c2rGtB4GfX
4+
EzCLWYrngKsVohqP47mTH4wqrUCqNsTP4woiBhM2JToSnPW
5+
FQBHNMbxhWUR9NbbCgTg1A2v7ux7Q3qMYd8WG5dNQTrwNJh
6+
E2vURASWn5qw4ZnDAZAiKZgzyeWoYBjoekByuRnEJrFCjzA
7+
FM8d5SWfN1359E3wJPMfUgGueveJvMFb4RUt9yhbsT5M3JV
8+
Hjg5eXctdbqE7cgE5qFkx6anE29r6rvyJNeLR2zRWQeJxUR
9+
Hc7A6bCJe1nvZEfnHkwRz4o5LudTv8LfuFv8ugKW3kj9DyD
10+
G2V13Rr6f5ggid4pSpZLVpAyx5P5ZHhXmgn9fdGEu6N7bwL
11+
DrV3LvHcAnrgg8SZZEQCqvKCm6UtDVFxKR7Af9du6XDjUNp
12+
DfPrFA7nSb7o1XgyYqzEv2V8ZzjXmoZgxKQbKdsBJ91tS1K
13+
EtDnQ1pS1THuGLjbdB9hE6me8NWC258UjbWme4Y7fp6grWx
14+
DYXpdCa6u3vGz9f3SYJgoa6rMbgdFDhMhs9yH5QNftXH2Y9
15+
DM9aCR7oBofMQ6oCy69XLWjX4V6KVpUi668pyDBo2GDhXkB

Diff for: example-commands

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Sending specific emotee
22
node index.js --id <RMRK_ID_FILE> -e wss://kusama-rpc.polkadot.io -s <SEED_FILE> --emotes
3-
node index.js --id rmrk_ids.txt -e wss://westend-rpc.polkadot.io -s keys.txt --emotes 🐣
3+
node index.js --id rmrk_ids.txt -e wss://kusama-rpc.polkadot.io -s keys.txt --emotes 🐣 --chunk
44

55
# Removing specific emotes from complete list of emotes
66
node index.js --id <RMRK_ID_FILE> -e wss://kusama-rpc.polkadot.io -s <SEED_FILE> -r
@@ -12,4 +12,4 @@ node index.js --id rmrk_ids.txt -e wss://westend-rpc.polkadot.io -s keys.txt
1212

1313
# Fund other accounts by sending an amount from a funder to receiving addresses
1414
node index.js -e wss://kusama-rpc.polkadot.io --receiving-addresses <FILE_WITH_ADDRESSES> --funding-account <FILE_WITH_SEED> --amount <AMOUNT>
15-
node index.js -e wss://westend-rpc.polkadot.io --receiving-addresses .addresses.txt --funding-account .funding-account --amount 0.2
15+
node index.js -e wss://westend-rpc.polkadot.io --receiving-addresses .receiving-addresses.txt --funding-account .funding-account --amount 0.2

Diff for: index.js

+26-18
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ const options = require('yargs')
4949
description: 'array of emojis to remove from the list, space separated',
5050
required: false,
5151
})
52+
.option('chunk', {
53+
alias: 'c',
54+
type: 'boolean',
55+
description: 'Boolean for if script should run chunked batch calls',
56+
required: false,
57+
default: false,
58+
})
5259
.argv
5360

5461
async function main() {
@@ -75,6 +82,7 @@ async function main() {
7582
const amount = options.amount;
7683
const emotes = options.emotes;
7784
const removeEmotes = options.remove;
85+
const chunk = options.chunk;
7886

7987
if (typeof fundingAccount !== 'undefined' &&
8088
typeof receivingAddresses !== 'undefined' &&
@@ -89,11 +97,11 @@ async function main() {
8997

9098
const avg_amount = (amount * ksmPrecision) / receivingAddresses.length;
9199

92-
console.log('💰 AVG_AMOUNT: ', avg_amount);
100+
console.log('💰 AVG_AMOUNT: ', avg_amount / ksmPrecision);
93101

94102
for (receiver of receivingAddresses) {
95103
fundings.push(api.tx.balances.transfer(receiver, avg_amount));
96-
console.log(`💸 Should send ${avg_amount} to ${receiver}`);
104+
console.log(`💸 Should send ${avg_amount / ksmPrecision} to ${receiver}`);
97105
}
98106

99107
const tx = api.tx.utility.batch(fundings);
@@ -158,28 +166,28 @@ async function main() {
158166

159167
});
160168

161-
let rmrksChunked = chunkArray(rmrks, 100);
169+
if (chunk) {
170+
let rmrksChunked = chunkArray(rmrks, 100);
171+
172+
console.log(`Total rmrks: ${rmrks.length}`);
173+
console.log(`Total rmrk chunks: ${rmrksChunked.length}`);
162174

163-
console.log(`Total rmrks: ${rmrks.length}`);
164-
console.log(`Total rmrk chunks: ${rmrksChunked.length}`);
175+
for (chunk of rmrksChunked) {
176+
console.log(`Chunk size: ${chunk.length}`);
165177

166-
for (chunk of rmrksChunked) {
167-
console.log(`Chunk size: ${chunk.length}`);
178+
const tx = api.tx.utility.batch(chunk);
179+
await sendAndFinalize(tx, account);
180+
}
181+
} else {
182+
const tx = api.tx.utility.batch(rmrks);
168183

169-
const tx = api.tx.utility.batch(chunk);
170-
await sendAndFinalize(tx, account);
171-
}
184+
// Sign and send the transaction using account
185+
const hash = await tx.signAndSend(account);
172186

187+
console.log('Transaction sent with hash', hash.toHex());
188+
}
173189
}
174-
175-
//const tx = api.tx.utility.batch(rmrks);
176-
177-
// Sign and send the transaction using account
178-
//const hash = await tx.signAndSend(account);
179-
180-
//console.log('Transaction sent with hash', hash.toHex());
181190
}
182-
183191
}
184192

185193
function chunkArray(array, size) {

Diff for: keys.txt

-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +0,0 @@
1-
0xb04a44851dd11c2ac6a1f7348ae44430ca55bbe81c902ef501fc67d1914e72c0
2-
0x7d469640dfbac148df4963b2b4a6c5a0e66e8efa9349dd8d94f586bcb058c911
3-
0x9218e5cdd0759fe7c44de9b908ac8d20f52e58ead0a859afb60f34af8e0532b2
4-
0xd69779b9a8a059c3ff1e2bc964eecc1289b2947ad4cd8c734b46caea7295a2dc
5-
6-
0x7f1e5273033594cf6753f7c9ac513b7f0a10506772cf538317a30834b56cea0a
7-
0x84daf627a5b88d89c44633b450b4578ebafff64db4968cafbe0c232e4cb2124f
8-
0x69f9aa4d4155a01067bfdfcde4b66cc82edba3852cf76b6e61e2beb916d2e5d1
9-
0xb5d30f6cb916779585c1cc6dee2d4eed6b6fa2079c0ae568399e45c1cb24d186

Diff for: rmrk_ids.txt

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
6802639-24d573f4dfa1d7fd33-KAN-KANL-0000000000006537
2-
6802639-24d573f4dfa1d7fd33-KAN-KANL-0000000000006538
3-
6802639-24d573f4dfa1d7fd33-KAN-KANL-0000000000006539
4-
5-
6802639-24d573f4dfa1d7fd33-KAN-KANL-0000000000006540
6-
6802639-24d573f4dfa1d7fd33-KAN-KANL-0000000000006541
1+
6802595-24d573f4dfa1d7fd33-KAN-KANL-0000000000003818

0 commit comments

Comments
 (0)