forked from ar-io/testnet-contract
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-gateway-settings.ts
75 lines (60 loc) · 2.24 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
68
69
70
71
72
73
74
75
import { JWKInterface } from 'arweave/node/lib/wallet';
import * as fs from 'fs';
import { keyfile } from './constants';
import { arweave, getContractManifest, initialize, warp } from './utilities';
/* eslint-disable no-console */
// This script will update the settings for a gateway that is already joined to the network
// Only the gateway's wallet owner is authorized to adjust these settings
(async () => {
initialize();
// the friendly label for this gateway
const label = 'Test Gateway';
// the fully qualified domain name for this gateway eg. arweave.net
const fqdn = 'permanence-testing.org';
// uncomment the below settings and update as needed
// the port used for this gateway eg. 443
// const port = 443
// the application layer protocol used by this gateway eg http or https
// const protocol = 'https'
// an optional gateway properties file located at this Arweave transaction id eg.
// const properties = 'FH1aVetOoulPGqgYukj0VE0wIhDy90WiQoV3U2PeY44'
// an optional, short note to further describe this gateway and its status
// const note = 'Give me feedback about this gateway at my Xwitter @testgatewayguy'
// Get the key file used for the distribution
const wallet: JWKInterface = JSON.parse(
process.env.JWK ? process.env.JWK : fs.readFileSync(keyfile).toString(),
);
// gate the contract txId
const arnsContractTxId =
process.env.ARNS_CONTRACT_TX_ID ??
'bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U';
// wallet address
const walletAddress = await arweave.wallets.getAddress(wallet);
// get contract manifest
const { evaluationOptions = {} } = await getContractManifest({
contractTxId: arnsContractTxId,
});
// Read the ANT Registry Contract
const contract = warp
.pst(arnsContractTxId)
.connect(wallet)
.setEvaluationOptions(evaluationOptions);
// Include any settings as needed below
const writeInteraction = await contract.writeInteraction(
{
function: 'updateGatewaySettings',
label,
fqdn,
// port,
// protocol,
// properties,
// note
},
{
disableBundling: true,
},
);
console.log(
`${walletAddress} successfully updated gateway settings with TX id: ${writeInteraction?.originalTxId}`,
);
})();