forked from ar-io/testnet-contract
-
Notifications
You must be signed in to change notification settings - Fork 0
/
decrease-operator-stake.ts
57 lines (48 loc) · 1.49 KB
/
decrease-operator-stake.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
import { JWKInterface } from 'arweave/node/lib/wallet';
import { IOState } from '../src/types';
import {
arnsContractTxId,
arweave,
getContractManifest,
initialize,
loadWallet,
warp,
} from './utilities';
/* eslint-disable no-console */
// This script will initiate decreasing a gateway operator's stake
// The staked tokens will be returned after the withdrawal period has elapsed
// Only the gateway's wallet owner is authorized to adjust these settings
(async () => {
// simple setup script
initialize();
// the qty of the staked vault that is to be unlocked and decreased
const qty = 1;
// Get the key file used for the distribution
const wallet: JWKInterface = loadWallet();
// 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 = await warp
.contract<IOState>(arnsContractTxId)
.connect(wallet)
.setEvaluationOptions(evaluationOptions)
.syncState(`https://api.arns.app/v1/contract/${arnsContractTxId}`, {
validity: true,
});
const txId = await contract.writeInteraction(
{
function: 'decreaseOperatorStake',
qty,
},
{
disableBundling: true,
},
);
console.log(
`${walletAddress} successfully submitted request to initiate decreasing gateway stake with TX id: ${txId?.originalTxId}`,
);
})();