Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,15 @@ class ReverseDataTool {

analyzeAccountInfo(accountInfo, pubkey) {
const owner = accountInfo.owner;
const dataSize = accountInfo.data ? accountInfo.data.length : 0;
let dataBytes = [];
if (accountInfo.data) {
if (Array.isArray(accountInfo.data)) {
dataBytes = this.decodeBase64ToBytes(accountInfo.data[0]);
} else if (typeof accountInfo.data === 'string') {
dataBytes = this.decodeBase64ToBytes(accountInfo.data);
}
}
const dataSize = dataBytes.length;
const programName = this.knownPrograms[owner] || 'Unknown Program';

let accountType = 'Unknown Account';
Expand All @@ -1460,10 +1468,10 @@ class ReverseDataTool {
else if (owner === 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA') {
if (dataSize === this.TOKEN_ACCOUNT_SIZE) {
accountType = 'SPL Token Account';
details = this.parseTokenAccount(accountInfo.data);
details = this.parseTokenAccount(dataBytes);
} else if (dataSize === this.TOKEN_MINT_SIZE) {
accountType = 'SPL Token Mint';
details = this.parseTokenMint(accountInfo.data);
details = this.parseTokenMint(dataBytes);
} else {
accountType = 'SPL Token Program Account';
}
Expand All @@ -1473,10 +1481,10 @@ class ReverseDataTool {
else if (owner === 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb') {
if (dataSize >= this.TOKEN_ACCOUNT_SIZE) {
accountType = 'Token-2022 Account';
details = this.parseTokenAccount(accountInfo.data);
details = this.parseTokenAccount(dataBytes);
} else if (dataSize >= this.TOKEN_MINT_SIZE) {
accountType = 'Token-2022 Mint';
details = this.parseTokenMint(accountInfo.data);
details = this.parseTokenMint(dataBytes);
} else {
accountType = 'Token-2022 Program Account';
}
Expand Down Expand Up @@ -1557,6 +1565,15 @@ class ReverseDataTool {
}
return this.base58Encode(bytes);
}

decodeBase64ToBytes(base64) {
const binaryString = atob(base64);
const bytes = new Uint8Array(binaryString.length);
for (let i = 0; i < binaryString.length; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
return bytes;
}

base58Encode(bytes) {
const alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
Expand Down