This repository has been archived by the owner on Nov 4, 2020. It is now read-only.
forked from social-dist0rtion-protocol/paper-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
batch-stickers-cannes.js
81 lines (75 loc) · 2.54 KB
/
batch-stickers-cannes.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
const { generateWallet, generateStickersHTML } = require('./helpers');
const util = require('util');
const asyncStickers = util.promisify(generateStickersHTML);
var merge = require('easy-pdf-merge');
var fs = require('fs');
const URL = "https://cannes.motion.ooo";
const HOWMANY = 100;
const PATH = 'wallets';
const BATCH = '0';
const workDir = process.cwd();
const positions = {
x:[50, 200, 350], //absolute X and Y positions for sticker elemnts on page
y:[0 ,170, 450, 620],
sizes: {
priv: {
font: 10,
height: 136,
width: 136
},
addr: {
font: 9,
height: 95,
width: 95
}
}
}
async function generate() {
let accounts = [];
let sources_priv = [];
let sources_pub = [];
const perPage = positions.x.length * positions.y.length;
const pages = Math.ceil(HOWMANY / perPage);
for (let i = 0; i < HOWMANY; i++) {
accounts.push(generateWallet(URL, `./${PATH}`,BATCH));
}
let pageAccounts;
let name;
console.log('--------------');
console.log(accounts);
for (let i = 0; i < pages; i++) {
pageAccounts = accounts.slice(i * perPage, (i + 1) * perPage);
console.log('--------------');
console.log(pageAccounts);
name = `Batch-${BATCH}_${pageAccounts[0].substring(0,8)}`;
await asyncStickers(pageAccounts, workDir + '/' + PATH, name, positions);
console.log("Generated: " + name);
sources_priv[i] = (""+PATH+"/"+name+"-priv.pdf");
sources_pub[i] = (""+PATH+"/"+name+"-pub.pdf");
}
if (pages > 1) {
console.log('Merging private key QR codes');
merge(sources_priv,PATH + "/wallets-" + BATCH + "-priv.pdf",function(err){
if(err)
return console.log(err);
console.log('Success');
var i = sources_priv.length;
sources_priv.forEach(function(filepath){
console.log("Cleaning up "+filepath)
fs.unlinkSync(filepath);
});
});
console.log('Merging address QR codes');
merge(sources_pub,PATH + "/wallets-" + BATCH + "-addr.pdf",function(err){
if(err)
return console.log(err);
console.log('Success');
var i = sources_pub.length;
sources_pub.forEach(function(filepath){
console.log("Cleaning up "+filepath)
fs.unlinkSync(filepath);
});
});
}
}
generate();