This repository has been archived by the owner on Oct 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathjoin-network.ts
49 lines (42 loc) · 1.64 KB
/
join-network.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
import { ArweaveSigner, IOToken, JoinNetworkParams } from '@ar.io/sdk';
import { JWKInterface } from 'arweave/node/lib/wallet';
import inquirer from 'inquirer';
import { arweave, initialize, loadWallet, networkContract } from '../utilities';
import questions from './questions';
(async () => {
// simple setup script
initialize();
// Get the key file used for the distribution
const wallet: JWKInterface = loadWallet();
const walletAddress = await arweave.wallets.jwkToAddress(wallet);
const signer = new ArweaveSigner(wallet);
const gatewayDetails = await inquirer.prompt(
questions.gatewaySettings(walletAddress),
);
const confirm = await inquirer.prompt({
name: 'confirm',
type: 'confirm',
message: `CONFIRM GATEWAY DETAILS? ${JSON.stringify(gatewayDetails)} >`,
});
if (confirm.confirm) {
const payload: JoinNetworkParams = {
observerWallet: gatewayDetails.observerWallet,
autoStake: gatewayDetails.autoStake,
allowDelegatedStaking: gatewayDetails.allowDelegatedStaking,
delegateRewardShareRatio: gatewayDetails.delegateRewardShareRatio,
minDelegatedStake: new IOToken(gatewayDetails.minDelegatedStake).toMIO(),
note: gatewayDetails.note,
properties: gatewayDetails.properties,
protocol: gatewayDetails.protocol,
port: gatewayDetails.port,
fqdn: gatewayDetails.fqdn,
label: gatewayDetails.label,
qty: new IOToken(gatewayDetails.qty).toMIO(),
};
const { id } = await networkContract(signer).joinNetwork(payload);
// eslint-disable-next-line
console.log(
`Successfully submitted request to join the network. TxId: ${id}`,
);
}
})();