-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (30 loc) · 1.21 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
var express = require('express');
var bodyParser = require('body-parser');
var path = require('path');
const { Receipt } = require('rt-sale-lib');
var app = express();
var router = express.Router();
router.use(bodyParser.urlencoded({ extended: true }));
router.use(bodyParser.json());
app.use('/', router);
var port = process.env.PORT || 3000;
var server = app.listen(port, ()=> {
console.log('Express server listening on port ' + port);
});
router.get('/', (req, res) => {
res.sendFile(path.join(__dirname+'/index.html'));
});
router.post('/getReceipt', async(req, res) => {
var crowdsaleAddress = req.body.crowdsaleAddress;
var dealIndex = req.body.dealIndex;
var affiliateAddress = req.body.affiliateAddress;
var purchaserAddress = req.body.purchaserAddress;
var investorAddress = req.body.investorAddress;
var orderId = req.body.orderId;
var signerPrivateKey = req.body.signerPrivateKey;
var referenceHash = req.body.referenceHash;
var timestamp = req.body.timestamp;
const investReceipt = await new Receipt(crowdsaleAddress).investment(investorAddress, referenceHash, 0, orderId, timestamp).sign(signerPrivateKey);
const receiptParams = await Receipt.parseToParams(investReceipt);
res.json(receiptParams);
});