Skip to content
Open
Show file tree
Hide file tree
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
30 changes: 28 additions & 2 deletions packages/controller/src/utils/solana/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export class Transaction {
// Build transaction using micro-sol-signer
if (this._transaction) {
// If we have a decoded transaction, re-serialize it
console.log("[Transaction.serialize] Re-encoding existing transaction");
return Buffer.from(sol.Transaction.encode(this._transaction));
}

Expand All @@ -98,13 +99,38 @@ export class Transaction {
throw new Error("Transaction requires feePayer and recentBlockhash");
}

const txHex = sol.createTxComplex(
console.log(
"[Transaction.serialize] Building new transaction with",
this._instructions.length,
"instructions",
);
console.log("[Transaction.serialize] feePayer:", this.feePayer.toString());
console.log(
"[Transaction.serialize] recentBlockhash:",
this.recentBlockhash,
);

// Use createTxComplex which returns a base64-encoded transaction with empty signatures
const txBase64 = sol.createTxComplex(
this.feePayer.toString(),
this._instructions,
this.recentBlockhash,
);

return Buffer.from(txHex, "hex");
console.log(
"[Transaction.serialize] createTxComplex returned base64 length:",
txBase64.length,
);

// Decode the base64 string to get the transaction bytes
const buffer = Buffer.from(txBase64, "base64");
console.log("[Transaction.serialize] Final buffer length:", buffer.length);
console.log(
"[Transaction.serialize] First 32 bytes:",
Array.from(buffer.slice(0, 32)),
);

return buffer;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Base64 vs Hex Handling Mismatch

The serialize() method now decodes sol.createTxComplex() output as base64, but serializeMessage() still treats it as hex. This inconsistency means serializeMessage() will produce incorrect transaction data. Additionally, several debugging console.log statements were left in the serialize() method.

Fix in Cursor Fix in Web

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Unintended Debug Logs in Production Code

Multiple debugging console.log statements were accidentally committed. These logs will clutter production output and may expose sensitive transaction details or internal state.

Additional Locations (2)

Fix in Cursor Fix in Web

}

serializeMessage(): Buffer {
Expand Down
18 changes: 18 additions & 0 deletions packages/controller/src/wallets/phantom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,25 @@ export class PhantomWallet implements WalletAdapter {
}

try {
console.log(
"[PhantomWallet.sendTransaction] Received serialized_txn length:",
serailized_txn.length,
);
console.log(
"[PhantomWallet.sendTransaction] First 32 bytes:",
Array.from(serailized_txn.slice(0, 32)),
);
console.log(
"[PhantomWallet.sendTransaction] Deserializing with Transaction.from...",
);

const txn = Transaction.from(serailized_txn);

console.log("[PhantomWallet.sendTransaction] Successfully deserialized");
console.log(
"[PhantomWallet.sendTransaction] Sending to Phantom provider...",
);

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Debug Logs in Production Code

The sendTransaction method contains multiple console.log debugging statements. These temporary logs, which include detailed serialized transaction data and raw byte arrays, were accidentally committed and will clutter production console output.

Fix in Cursor Fix in Web

const provider = this.getProvider();
const result = await provider.signAndSendTransaction(txn);
return {
Expand Down
35 changes: 31 additions & 4 deletions packages/keychain/src/utils/solana/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,42 @@ export class Transaction {
throw new Error("Transaction requires feePayer and recentBlockhash");
}

// Create the transaction with micro-sol-signer
const txHex = sol.createTxComplex(
console.log(
"[keychain/Transaction.serialize] Building transaction with",
this.instructions.length,
"instructions",
);
console.log(
"[keychain/Transaction.serialize] feePayer:",
this.feePayer.toString(),
);
console.log(
"[keychain/Transaction.serialize] recentBlockhash:",
this.recentBlockhash,
);

// createTxComplex returns a base64-encoded string, not hex!
const txBase64 = sol.createTxComplex(
this.feePayer.toString(),
this.instructions,
this.recentBlockhash,
);

// Convert hex string to Uint8Array
return new Uint8Array(Buffer.from(txHex, "hex"));
console.log(
"[keychain/Transaction.serialize] createTxComplex returned base64 length:",
txBase64.length,
);

// Decode the base64 string to get the transaction bytes
const buffer = new Uint8Array(Buffer.from(txBase64, "base64"));

console.log("[keychain/Transaction.serialize] Final buffer length:", buffer.length);
console.log(
"[keychain/Transaction.serialize] First 32 bytes:",
Array.from(buffer.slice(0, 32)),
);

return buffer;
}
}

Expand Down
Loading