-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-tree-status.mjs
More file actions
69 lines (56 loc) · 2.31 KB
/
test-tree-status.mjs
File metadata and controls
69 lines (56 loc) · 2.31 KB
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
import { Connection, Keypair, PublicKey, Transaction, TransactionInstruction } from '@solana/web3.js';
import fs from 'fs';
const connection = new Connection('https://api.devnet.solana.com');
// Load keypairs
const payerKeypair = Keypair.fromSecretKey(
new Uint8Array(JSON.parse(fs.readFileSync('/Users/krewdev/.config/solana/id.json')))
);
const merkleTreeKeypair = Keypair.fromSecretKey(
new Uint8Array(JSON.parse(fs.readFileSync('merkle-tree-keypair.json')))
);
// Test if the tree can be used for minting
console.log('Testing tree account for Bubblegum compatibility...');
console.log('Tree:', merkleTreeKeypair.publicKey.toString());
try {
// Get the account data
const accountInfo = await connection.getAccountInfo(merkleTreeKeypair.publicKey);
if (!accountInfo) {
console.log('❌ Account does not exist');
process.exit(1);
}
console.log('✅ Account exists');
console.log('Owner:', accountInfo.owner.toString());
console.log('Data length:', accountInfo.data.length);
console.log('Space:', accountInfo.space);
// Check if it's owned by Bubblegum
const BUBBLEGUM_PROGRAM_ID = 'BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY';
if (accountInfo.owner.toString() === BUBBLEGUM_PROGRAM_ID) {
console.log('✅ Owned by Bubblegum program');
// Check if it's initialized (non-zero data)
const isZero = accountInfo.data.every(byte => byte === 0);
if (isZero) {
console.log('❌ Account is not initialized (all zeros)');
console.log('This tree needs to be initialized with a create_tree instruction');
} else {
console.log('✅ Account appears to be initialized');
console.log('First 32 bytes:', accountInfo.data.slice(0, 32));
}
} else {
console.log('❌ Not owned by Bubblegum program');
}
// Find the tree authority PDA
const [treeAuthority] = PublicKey.findProgramAddressSync(
[merkleTreeKeypair.publicKey.toBuffer()],
new PublicKey(BUBBLEGUM_PROGRAM_ID)
);
console.log('Tree Authority PDA:', treeAuthority.toString());
// Check if tree authority exists
const treeAuthorityInfo = await connection.getAccountInfo(treeAuthority);
if (treeAuthorityInfo) {
console.log('✅ Tree Authority PDA exists');
} else {
console.log('❌ Tree Authority PDA does not exist');
}
} catch (error) {
console.error('Error:', error);
}