-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcancelOrder.js
executable file
·42 lines (38 loc) · 1.08 KB
/
cancelOrder.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
#!/usr/bin/node
const RippleAPI = require('ripple-lib').RippleAPI;
const Tx = require('./tx.js');
const fs = require('fs');
const api = new RippleAPI({
server: 'wss://s1.ripple.com', // Public rippled server hosted by Ripple, Inc.
maxFeeXRP: '0.00001'
});
const argv = require('yargs')
.option('sequence', {
alias: 's',
describe: 'The price of the new order to be placed'
})
.option('secret_file', {
describe: 'The path of secrt file',
type: 'string',
default: '.secret.json'
})
.demandOption(['sequence'])
.help()
.strict()
.argv
var secrets = JSON.parse(fs.readFileSync(argv.secret_file, 'utf8'));
var account = secrets.account;
var secret = secrets.secret;
api.connect().then(() => {
console.log('connected');
return api.prepareOrderCancellation(account, {
'orderSequence': Number(argv.sequence),
}).then(prepared => {
return Tx.submit(api, prepared, secret, Tx.reportSequence, console.log, console.log);
});
}).then(() => {
api.disconnect().then(() => {
console.log('api disconnected');
process.exit();
});
}).catch(console.error);