forked from ar-io/testnet-contract
-
Notifications
You must be signed in to change notification settings - Fork 0
/
finalize-leave-network.ts
50 lines (41 loc) · 1.4 KB
/
finalize-leave-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
50
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 finalize the leave network protocol and remove the gateway from the registry
// The gateway's wallet owner or any other user is authorized to finalize the leave network request
(async () => {
// simple setup script
initialize();
// load local wallet
const wallet: JWKInterface = JSON.parse(
process.env.JWK ? process.env.JWK : fs.readFileSync(keyfile).toString(),
);
// load state of contract
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);
const txId = await contract.writeInteraction(
{
function: 'finalizeLeave',
},
{
disableBundling: true,
},
);
console.log(
`${walletAddress} successfully submitted request to finalize leaving the network with TX id: ${txId}`,
);
})();