forked from austintgriffith/paper-wallet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
batch.js
80 lines (75 loc) · 1.92 KB
/
batch.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
const { generateWallet, generateWithTemplate } = require('./helpers');
const util = require('util');
const applyTemplate = util.promisify(generateWithTemplate);
var merge = require('easy-pdf-merge');
var fs = require('fs');
const URL = "https://cannes.motion.ooo";
const HOWMANY = 10;
const PATH = 'wallets';
const BATCH = '0';
const workDir = process.cwd();
const templates = {
addr: `${workDir}/Flyer_Test 23b-1.svg`,
priv: `${workDir}/Flyer_Test 23b-2.svg`
};
const positions = {
priv: {
x:155,
y:270,
sizes: {
font: 10,
height: 120,
width: 120
}
},
addr: {
x:155,
y:350,
sizes: {
font: 9,
height: 90,
width: 90
}
}
};
const page = {
width: '3.94in',
height: '8.27in',
};
async function generate() {
let address;
let sources = [];
for (let i = 0; i < HOWMANY; i++) {
address = generateWallet(URL, `./${PATH}`,BATCH);
await applyTemplate(
address,
'',
'.svg',
templates.addr,
workDir + '/' + PATH,
positions.addr,
page);
sources.push(""+PATH+"/"+address.substring(0,8)+".pdf");
await applyTemplate(
address,
'-priv',
'.png',
templates.priv,
workDir + '/' + PATH,
positions.priv,
page);
sources.push(""+PATH+"/"+address.substring(0,8)+"-priv.pdf");
}
console.log('Merging PDFs...');
merge(sources,PATH + "/wallets-" + BATCH + ".pdf",function(err){
if(err)
return console.log(err);
console.log('Success');
var i = sources.length;
sources.forEach(function(filepath){
console.log("Cleaning up "+filepath)
fs.unlinkSync(filepath);
});
});
}
generate();