Skip to content

Commit

Permalink
Since base58 is a subset of base64, we need to check if it's base58 e…
Browse files Browse the repository at this point in the history
…ncoded first
  • Loading branch information
fabioberger committed Dec 15, 2023
1 parent 2454b7e commit 38d407f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/explorerkit-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ app.post("/decode/transactions", async (req: Request, res: Response) => {
let decodedAccounts: DecodedTransactions[] = [];
for (var encodedTx of transactions) {
let txBuffer = null;
if (isValidBase64(encodedTx)) {
txBuffer = Buffer.from(encodedTx, "base64");
} else if (isValidBase58(encodedTx)) {
if (isValidBase58(encodedTx)) {
txBuffer = Buffer.from(bs58.decode(encodedTx));
} else if (isValidBase64(encodedTx)) {
txBuffer = Buffer.from(encodedTx, "base64");
} else {
decodedAccounts.push({ error: "'transaction' is not a valid base64 string.", decodedInstructions: null });
continue;
Expand Down

0 comments on commit 38d407f

Please sign in to comment.