-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathaccountIdAlias.js
50 lines (39 loc) · 1.11 KB
/
accountIdAlias.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
const {
AccountId,
} = require('@hashgraph/sdk');
const exit = require('node:process');
function getArg(arg) {
const customIndex = process.argv.indexOf(`-${arg}`);
let customValue;
if (customIndex > -1) {
// Retrieve the value after --custom
customValue = process.argv[customIndex + 1];
}
return customValue;
}
function getArgFlag(arg) {
const customIndex = process.argv.indexOf(`-${arg}`);
if (customIndex > -1) {
return true;
}
return false;
}
async function main() {
const help = getArgFlag('h');
if (help) {
console.log('Usage: node accountIdAlias.js [-string | -solidity] XXXXX');
console.log(' -string used if the address is in shard/realm/account format -> 0.0.XXXX');
console.log(' -solidity used if the address is in solidity EVM format');
exit(0);
}
let accountId;
if (getArgFlag('string')) {
accountId = AccountId.fromString(getArg('string'));
}
else if (getArgFlag('solidity')) {
accountId = AccountId.fromSolidityAddress(getArg('solidity'));
}
console.log('Account: ' + accountId.toString() +
'\nSolidity Address: ' + accountId.toSolidityAddress());
}
main();