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
/
update-gateway-settings.ts
67 lines (57 loc) · 1.94 KB
/
update-gateway-settings.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import {
ArweaveSigner,
Gateway,
IOToken,
UpdateGatewaySettingsParams,
} 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 existingGatewayDetails: Gateway | undefined = await networkContract(
signer,
).getGateway({
address: walletAddress,
});
if (!existingGatewayDetails) {
console.error('Gateway not found with address:', walletAddress);
return;
}
const gatewayDetails = await inquirer.prompt(
questions.gatewaySettings(walletAddress, existingGatewayDetails),
);
const confirm = await inquirer.prompt({
name: 'confirm',
type: 'confirm',
message: `CONFIRM UPDATED GATEWAY DETAILS? ${JSON.stringify(
gatewayDetails,
)} >`,
});
if (confirm.confirm) {
const payload: UpdateGatewaySettingsParams = {
observerWallet: gatewayDetails.observerWallet,
allowDelegatedStaking: gatewayDetails.allowDelegatedStaking,
delegateRewardShareRatio: gatewayDetails.delegateRewardShareRatio,
autoStake: gatewayDetails.autoStake,
minDelegatedStake: new IOToken(gatewayDetails.minDelegatedStake).toMIO(),
note: gatewayDetails.note,
properties: gatewayDetails.properties,
protocol: gatewayDetails.protocol,
port: gatewayDetails.port,
fqdn: gatewayDetails.fqdn,
label: gatewayDetails.label,
};
const { id } = await networkContract(signer).updateGatewaySettings(payload);
// eslint-disable-next-line
console.log(
`Successfully submitted request to update gateway. TxId: ${id}`,
);
}
})();