-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (35 loc) · 1.05 KB
/
index.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
require("dotenv").config();
const { fetchCreated, fetchCollected } = require("./src/tzkt");
const pinata = require("./src/pinata");
const local = require("./src/local");
const addresses = process.env.TEZ_ADDRESSES.split(",");
// node index.js <local|pinata> <created|collected>
const args = process.argv.slice(2);
const mode = args[0];
const type = args.length > 1 && args[1] ? args[1] : "created";
const pinWork = async () => {
let tokens = [];
if (mode === "pinata") {
console.log("Pinning to Pinata");
} else {
console.log("Pinning to Local Node");
}
if (type === "created") {
tokens = tokens.concat(await fetchCreated(addresses));
} else if (type === "collected") {
tokens = tokens.concat(await fetchCollected(addresses));
}
console.log(`${tokens.length} tokens ready for pinning`);
if (mode === "pinata") {
await pinata.pin(tokens);
} else {
await local.pin(tokens);
}
};
pinWork()
.then(() => {
console.log("\n\nFinished pinning. Have a nice day. :)\n\n");
})
.catch((err) => {
console.error(err);
});