-
Notifications
You must be signed in to change notification settings - Fork 2
/
postCompile.ts
78 lines (58 loc) · 2.34 KB
/
postCompile.ts
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
import * as fs from 'fs';
import * as path from 'path';
/////////////////////////////////////
const filePathVaultCompleteWithdrawal = path.resolve(__dirname, './artifacts/vaultCompleteWithdrawal.json');
fs.readFile(filePathVaultCompleteWithdrawal, 'utf8', (err, data) => {
if (err) {
console.error('Error reading file:', err);
return;
}
// Replace occurrences of "OP_CODESEPARATOR OP_TRUE" with "OP_CSV OP_TRUE",
// since sCrypt compiler doesn't support CSV for now...
const result = data.replace(/ab51/g, 'b251');
fs.writeFile(filePathVaultCompleteWithdrawal, result, 'utf8', (err) => {
if (err) {
console.error('Error writing file:', err);
return;
}
console.log('Post-compile hook completed for:', filePathVaultCompleteWithdrawal.toString())
});
});
/////////////////////////////////////
const filePathTestMerklePath = path.resolve(__dirname, './artifacts/tests/testMerklePath.json');
fs.readFile(filePathTestMerklePath, 'utf8', (err, data) => {
if (err) {
console.error('Error reading file:', err);
return;
}
// Replace occurrences of "OP_2 OP_MUL" with "OP_DUP OP_ADD",
// since BTC doesn't support OP_MUL...
const result = data.replace(/5295/g, '7693');
fs.writeFile(filePathTestMerklePath, result, 'utf8', (err) => {
if (err) {
console.error('Error writing file:', err);
return;
}
console.log('Post-compile hook completed for:', filePathTestMerklePath.toString())
});
});
/////////////////////////////////////
const filePathTestLamportOracle = path.resolve(__dirname, './artifacts/tests/testLamportOracle.json');
fs.readFile(filePathTestLamportOracle, 'utf8', (err, data) => {
if (err) {
console.error('Error reading file:', err);
return;
}
// Replace occurrences of "OP_2 OP_MUL" with "OP_DUP OP_ADD",
// since BTC doesn't support OP_MUL...
let result = data.replace(/5295/g, '7693');
// Remove redundant "OP_1 OP_MUL"
result = result.replace(/5195/g, '');
fs.writeFile(filePathTestLamportOracle, result, 'utf8', (err) => {
if (err) {
console.error('Error writing file:', err);
return;
}
console.log('Post-compile hook completed for:', filePathTestLamportOracle.toString())
});
});