-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathtake_down_deployment.ts
55 lines (44 loc) · 1.64 KB
/
take_down_deployment.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
import { DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing";
import { SigningStargateClient } from "@cosmjs/stargate";
import { getAkashTypeRegistry, getTypeUrl } from "@akashnetwork/akashjs/build/stargate";
import { MsgCloseDeployment } from "@akashnetwork/akash-api/akash/deployment/v1beta3";
import dotenv from "dotenv";
dotenv.config({ path: "../.env" });
async function main() {
const mnemonic = process.env.MNEMONIC || "";
if (!mnemonic) {
throw new Error("MNEMONIC environment variable is not set. Please set the environment variable in the .env file. See .env.sample for more information.");
}
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { prefix: "akash" });
// get first account
const [account] = await wallet.getAccounts();
// Use the encode method for the message to wrap the data
const message = MsgCloseDeployment.fromPartial({
id: {
dseq: "19837048",
owner: account.address
}
});
// Set the appropriate typeUrl and attach the encoded message as the value
const msgAny = {
typeUrl: getTypeUrl(MsgCloseDeployment),
value: message
};
// You can use your own RPC node, or get a list of public nodes from akashjs
const rpcEndpoint = "http://rpc.akashnet.net";
const myRegistry = new Registry(getAkashTypeRegistry());
const client = await SigningStargateClient.connectWithSigner(rpcEndpoint, wallet, {
registry: myRegistry
});
const fee = {
amount: [
{
denom: "uakt",
amount: "20000"
}
],
gas: "800000"
};
await client.signAndBroadcast(account.address, [msgAny], fee, "take down deployment");
}
main();