@helium/helium-admin-cli 0.9.23 → 0.9.24-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.run = void 0;
39
+ const anchor = __importStar(require("@coral-xyz/anchor"));
40
+ const helium_entity_manager_sdk_1 = require("@helium/helium-entity-manager-sdk");
41
+ const helium_sub_daos_sdk_1 = require("@helium/helium-sub-daos-sdk");
42
+ const spl_utils_1 = require("@helium/spl-utils");
43
+ const mpl_bubblegum_1 = require("@metaplex-foundation/mpl-bubblegum");
44
+ const spl_account_compression_1 = require("@solana/spl-account-compression");
45
+ const web3_js_1 = require("@solana/web3.js");
46
+ const bs58_1 = __importDefault(require("bs58"));
47
+ const os_1 = __importDefault(require("os"));
48
+ const yargs_1 = __importDefault(require("yargs/yargs"));
49
+ const utils_1 = require("./utils");
50
+ function run(args = process.argv) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ const yarg = (0, yargs_1.default)(args).options({
53
+ ruggedWallet: {
54
+ describe: "Anchor wallet keypair",
55
+ required: true,
56
+ type: "string",
57
+ },
58
+ recipient: {
59
+ describe: "Recipient of the hotspots",
60
+ type: "string",
61
+ required: true,
62
+ },
63
+ wallet: {
64
+ alias: "k",
65
+ describe: "Anchor wallet keypair",
66
+ default: `${os_1.default.homedir()}/.config/solana/id.json`,
67
+ },
68
+ url: {
69
+ alias: "u",
70
+ default: "http://127.0.0.1:8899",
71
+ describe: "The solana url",
72
+ },
73
+ hntMint: {
74
+ type: "string",
75
+ describe: "HNT mint of the dao to be updated",
76
+ default: spl_utils_1.HNT_MINT.toBase58(),
77
+ },
78
+ });
79
+ const argv = yield yarg.argv;
80
+ process.env.ANCHOR_WALLET = argv.wallet;
81
+ process.env.ANCHOR_PROVIDER_URL = argv.url;
82
+ anchor.setProvider(anchor.AnchorProvider.local(argv.url));
83
+ const provider = anchor.getProvider();
84
+ const ruggedWallet = new anchor.Wallet((0, utils_1.loadKeypair)(argv.ruggedWallet));
85
+ const ruggedWalletKeypair = (0, utils_1.loadKeypair)(argv.ruggedWallet);
86
+ const myKeypair = (0, utils_1.loadKeypair)(argv.wallet);
87
+ const cNFTs = yield (0, spl_utils_1.searchAssets)(provider.connection.rpcEndpoint, {
88
+ ownerAddress: ruggedWallet.publicKey.toBase58(),
89
+ limit: 1000,
90
+ creatorVerified: true,
91
+ burnt: false,
92
+ creatorAddress: (0, helium_entity_manager_sdk_1.entityCreatorKey)((0, helium_sub_daos_sdk_1.daoKey)(spl_utils_1.HNT_MINT)[0])[0].toBase58(),
93
+ });
94
+ const drafts = [];
95
+ for (const cNFT of cNFTs) {
96
+ const draft = yield transferCompressedCollectable(provider.connection, provider.wallet.publicKey, cNFT, new web3_js_1.PublicKey(argv.recipient));
97
+ drafts.push(draft);
98
+ }
99
+ for (const draft of drafts) {
100
+ const tx = yield (0, spl_utils_1.toVersionedTx)(yield (0, spl_utils_1.populateMissingDraftInfo)(provider.connection, draft));
101
+ yield tx.sign([ruggedWalletKeypair, myKeypair]);
102
+ yield (0, spl_utils_1.bulkSendRawTransactions)(provider.connection, [Buffer.from(tx.serialize())], console.log);
103
+ }
104
+ });
105
+ }
106
+ exports.run = run;
107
+ function getBubblegumAuthorityPDA(merkleRollPubKey) {
108
+ const [bubblegumAuthorityPDAKey] = web3_js_1.PublicKey.findProgramAddressSync([merkleRollPubKey.toBuffer()], new web3_js_1.PublicKey("BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY"));
109
+ return bubblegumAuthorityPDAKey;
110
+ }
111
+ function bufferToArray(buffer) {
112
+ const nums = [];
113
+ for (let i = 0; i < buffer.length; i += 1) {
114
+ nums.push(buffer[i]);
115
+ }
116
+ return nums;
117
+ }
118
+ const mapProof = (assetProof) => {
119
+ if (!assetProof.proof || assetProof.proof.length === 0) {
120
+ throw new Error("Proof is empty");
121
+ }
122
+ return assetProof.proof.map((node) => ({
123
+ pubkey: new web3_js_1.PublicKey(node),
124
+ isSigner: false,
125
+ isWritable: false,
126
+ }));
127
+ };
128
+ const transferCompressedCollectable = (conn, payer, collectable, recipientPubKey) => __awaiter(void 0, void 0, void 0, function* () {
129
+ const instructions = [];
130
+ const assetProof = (yield (0, spl_utils_1.getAssetProof)(conn.rpcEndpoint, collectable.id));
131
+ const treeAuthority = getBubblegumAuthorityPDA(new web3_js_1.PublicKey(assetProof.treeId));
132
+ const leafDelegate = collectable.ownership.delegate
133
+ ? new web3_js_1.PublicKey(collectable.ownership.delegate)
134
+ : new web3_js_1.PublicKey(collectable.ownership.owner);
135
+ const merkleTree = new web3_js_1.PublicKey(assetProof.treeId);
136
+ const tree = yield spl_account_compression_1.ConcurrentMerkleTreeAccount.fromAccountAddress(conn, merkleTree, "confirmed");
137
+ const canopyHeight = tree.getCanopyDepth();
138
+ const proofPath = mapProof(assetProof);
139
+ const anchorRemainingAccounts = proofPath.slice(0, proofPath.length - (canopyHeight || 0));
140
+ const ix = (0, mpl_bubblegum_1.createTransferInstruction)({
141
+ treeAuthority,
142
+ leafOwner: new web3_js_1.PublicKey(collectable.ownership.owner),
143
+ leafDelegate,
144
+ newLeafOwner: recipientPubKey,
145
+ merkleTree,
146
+ logWrapper: spl_account_compression_1.SPL_NOOP_PROGRAM_ID,
147
+ compressionProgram: spl_account_compression_1.SPL_ACCOUNT_COMPRESSION_PROGRAM_ID,
148
+ anchorRemainingAccounts,
149
+ }, {
150
+ root: bufferToArray(assetProof.root.toBuffer()),
151
+ dataHash: bufferToArray(Buffer.from(bs58_1.default.decode(collectable.compression.data_hash.trim()))),
152
+ creatorHash: bufferToArray(Buffer.from(bs58_1.default.decode(collectable.compression.creator_hash.trim()))),
153
+ nonce: collectable.compression.leaf_id,
154
+ index: collectable.compression.leaf_id,
155
+ });
156
+ ix.keys[1].isSigner = true;
157
+ instructions.push(ix);
158
+ return {
159
+ instructions: yield (0, spl_utils_1.withPriorityFees)({
160
+ connection: conn,
161
+ instructions,
162
+ feePayer: payer,
163
+ }),
164
+ feePayer: payer,
165
+ };
166
+ });
167
+ //# sourceMappingURL=unrug-hotspots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unrug-hotspots.js","sourceRoot":"","s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E,aAAa,CACrB,MAAM,CAAC,IAAI,CAAC,cAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,CACnE;QACD,WAAW,EAAE,aAAa,CACxB,MAAM,CAAC,IAAI,CAAC,cAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,CACtE;QACD,KAAK,EAAE,WAAW,CAAC,WAAW,CAAC,OAAO;QACtC,KAAK,EAAE,WAAW,CAAC,WAAW,CAAC,OAAO;KACvC,CACF,CAAC;IACF,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC;IAC3B,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEtB,OAAO;QACL,YAAY,EAAE,MAAM,IAAA,4BAAgB,EAAC;YACnC,UAAU,EAAE,IAAI;YAChB,YAAY;YACZ,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,QAAQ,EAAE,KAAK;KAChB,CAAC;AACJ,CAAC,CAAA,CAAC"}
@@ -0,0 +1,126 @@
1
+ import * as anchor from "@coral-xyz/anchor";
2
+ import { entityCreatorKey } from "@helium/helium-entity-manager-sdk";
3
+ import { daoKey } from "@helium/helium-sub-daos-sdk";
4
+ import { bulkSendRawTransactions, getAssetProof, HNT_MINT, populateMissingDraftInfo, searchAssets, toVersionedTx, withPriorityFees, } from "@helium/spl-utils";
5
+ import { createTransferInstruction } from "@metaplex-foundation/mpl-bubblegum";
6
+ import { ConcurrentMerkleTreeAccount, SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, SPL_NOOP_PROGRAM_ID, } from "@solana/spl-account-compression";
7
+ import { PublicKey, } from "@solana/web3.js";
8
+ import bs58 from "bs58";
9
+ import os from "os";
10
+ import yargs from "yargs/yargs";
11
+ import { loadKeypair } from "./utils";
12
+ export async function run(args = process.argv) {
13
+ const yarg = yargs(args).options({
14
+ ruggedWallet: {
15
+ describe: "Anchor wallet keypair",
16
+ required: true,
17
+ type: "string",
18
+ },
19
+ recipient: {
20
+ describe: "Recipient of the hotspots",
21
+ type: "string",
22
+ required: true,
23
+ },
24
+ wallet: {
25
+ alias: "k",
26
+ describe: "Anchor wallet keypair",
27
+ default: `${os.homedir()}/.config/solana/id.json`,
28
+ },
29
+ url: {
30
+ alias: "u",
31
+ default: "http://127.0.0.1:8899",
32
+ describe: "The solana url",
33
+ },
34
+ hntMint: {
35
+ type: "string",
36
+ describe: "HNT mint of the dao to be updated",
37
+ default: HNT_MINT.toBase58(),
38
+ },
39
+ });
40
+ const argv = await yarg.argv;
41
+ process.env.ANCHOR_WALLET = argv.wallet;
42
+ process.env.ANCHOR_PROVIDER_URL = argv.url;
43
+ anchor.setProvider(anchor.AnchorProvider.local(argv.url));
44
+ const provider = anchor.getProvider();
45
+ const ruggedWallet = new anchor.Wallet(loadKeypair(argv.ruggedWallet));
46
+ const ruggedWalletKeypair = loadKeypair(argv.ruggedWallet);
47
+ const myKeypair = loadKeypair(argv.wallet);
48
+ const cNFTs = await searchAssets(provider.connection.rpcEndpoint, {
49
+ ownerAddress: ruggedWallet.publicKey.toBase58(),
50
+ limit: 1000,
51
+ creatorVerified: true,
52
+ burnt: false,
53
+ creatorAddress: entityCreatorKey(daoKey(HNT_MINT)[0])[0].toBase58(),
54
+ });
55
+ const drafts = [];
56
+ for (const cNFT of cNFTs) {
57
+ const draft = await transferCompressedCollectable(provider.connection, provider.wallet.publicKey, cNFT, new PublicKey(argv.recipient));
58
+ drafts.push(draft);
59
+ }
60
+ for (const draft of drafts) {
61
+ const tx = await toVersionedTx(await populateMissingDraftInfo(provider.connection, draft));
62
+ await tx.sign([ruggedWalletKeypair, myKeypair]);
63
+ await bulkSendRawTransactions(provider.connection, [Buffer.from(tx.serialize())], console.log);
64
+ }
65
+ }
66
+ function getBubblegumAuthorityPDA(merkleRollPubKey) {
67
+ const [bubblegumAuthorityPDAKey] = PublicKey.findProgramAddressSync([merkleRollPubKey.toBuffer()], new PublicKey("BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY"));
68
+ return bubblegumAuthorityPDAKey;
69
+ }
70
+ function bufferToArray(buffer) {
71
+ const nums = [];
72
+ for (let i = 0; i < buffer.length; i += 1) {
73
+ nums.push(buffer[i]);
74
+ }
75
+ return nums;
76
+ }
77
+ const mapProof = (assetProof) => {
78
+ if (!assetProof.proof || assetProof.proof.length === 0) {
79
+ throw new Error("Proof is empty");
80
+ }
81
+ return assetProof.proof.map((node) => ({
82
+ pubkey: new PublicKey(node),
83
+ isSigner: false,
84
+ isWritable: false,
85
+ }));
86
+ };
87
+ const transferCompressedCollectable = async (conn, payer, collectable, recipientPubKey) => {
88
+ const instructions = [];
89
+ const assetProof = (await getAssetProof(conn.rpcEndpoint, collectable.id));
90
+ const treeAuthority = getBubblegumAuthorityPDA(new PublicKey(assetProof.treeId));
91
+ const leafDelegate = collectable.ownership.delegate
92
+ ? new PublicKey(collectable.ownership.delegate)
93
+ : new PublicKey(collectable.ownership.owner);
94
+ const merkleTree = new PublicKey(assetProof.treeId);
95
+ const tree = await ConcurrentMerkleTreeAccount.fromAccountAddress(conn, merkleTree, "confirmed");
96
+ const canopyHeight = tree.getCanopyDepth();
97
+ const proofPath = mapProof(assetProof);
98
+ const anchorRemainingAccounts = proofPath.slice(0, proofPath.length - (canopyHeight || 0));
99
+ const ix = createTransferInstruction({
100
+ treeAuthority,
101
+ leafOwner: new PublicKey(collectable.ownership.owner),
102
+ leafDelegate,
103
+ newLeafOwner: recipientPubKey,
104
+ merkleTree,
105
+ logWrapper: SPL_NOOP_PROGRAM_ID,
106
+ compressionProgram: SPL_ACCOUNT_COMPRESSION_PROGRAM_ID,
107
+ anchorRemainingAccounts,
108
+ }, {
109
+ root: bufferToArray(assetProof.root.toBuffer()),
110
+ dataHash: bufferToArray(Buffer.from(bs58.decode(collectable.compression.data_hash.trim()))),
111
+ creatorHash: bufferToArray(Buffer.from(bs58.decode(collectable.compression.creator_hash.trim()))),
112
+ nonce: collectable.compression.leaf_id,
113
+ index: collectable.compression.leaf_id,
114
+ });
115
+ ix.keys[1].isSigner = true;
116
+ instructions.push(ix);
117
+ return {
118
+ instructions: await withPriorityFees({
119
+ connection: conn,
120
+ instructions,
121
+ feePayer: payer,
122
+ }),
123
+ feePayer: payer,
124
+ };
125
+ };
126
+ //# sourceMappingURL=unrug-hotspots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unrug-hotspots.js","sourceRoot":"","sources":["../../../src/unrug-hotspots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAEL,uBAAuB,EAEvB,aAAa,EACb,QAAQ,EACR,wBAAwB,EACxB,YAAY,EACZ,aAAa,EAEb,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EACL,2BAA2B,EAC3B,kCAAkC,EAClC,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAGL,SAAS,GAEV,MAAM,iBAAiB,CAAC;AACzB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,OAAY,OAAO,CAAC,IAAI;IAChD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;QAC/B,YAAY,EAAE;YACZ,QAAQ,EAAE,uBAAuB;YACjC,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,QAAQ;SACf;QAC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