This repository was archived by the owner on Mar 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrevokeEphemeralKey.js
More file actions
71 lines (62 loc) · 2.08 KB
/
revokeEphemeralKey.js
File metadata and controls
71 lines (62 loc) · 2.08 KB
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
'use strict';
/**
* @fileoverview Nodejs Program to Revoke Ephemeral Key in a given TokenHolder Contract.
* See perform method for sample code.
*
* Contract: https://github.com/OpenSTFoundation/openst-contracts/blob/v0.9.4/contracts/TokenHolder.sol
* @author kedar@ost.com (Kedar Chandrayan)
*/
const PerformerBase = require('./PerformerBase');
class Performer extends PerformerBase {
constructor(program) {
super(program);
this.tokenHolderAddress = program.tokenHolder;
this.ephemeralKeyAddress = program.ephemeralKey;
this.wallet = program.wallet;
//Validate the inputs.
this.validate();
}
perform() {
let openST = this.openST;
let config = this.getSetupConfig();
let tokenHolder = new openST.contracts.TokenHolder(this.tokenHolderAddress);
// Authorize an ephemeral public key
tokenHolder
.revokeSession(this.ephemeralKeyAddress)
.send({
from: this.wallet,
gasPrice: config.gasPrice,
gas: config.gas
})
.then((receipt) => {
if (receipt.status) {
this.exitWithoutError('Transaction Succeeded');
} else {
this.exitWithError('Failed to Confirm Transaction. See receipt for details.');
}
})
.catch((reason) => {
this.logError(reason);
this.exitWithError('Failed to Confirm Transaction. See error for details.');
});
}
validate() {}
}
const program = PerformerBase.getProgram();
program
.option('--token-holder [tokenHolder]', 'TokenHolder contract address')
.option('--wallet [wallet]', 'Wallet address')
.option('--ephemeral-key [ephemeralKey]', 'Ephemeral key address');
program.on('--help', () => {
console.log('');
console.log(' Example:');
console.log('');
console.log(
' node revokeEphemeralKey.js --token-holder 0xf8c9018DEA785A7cc8A59fE1F8A64B6f64f060cD --wallet 0xbba2c47be3add4fd302d9a8122442ca9d65ad9a3 --ephemeral-key 0xee339904c3a947f0e5eac4e7e4d0da835321f7a0'
);
console.log('');
console.log('');
});
program.parse(process.argv);
let performer = new Performer(program);
performer.perform();