Fix instruction validation for parsed memo instructions (#16591)
This commit is contained in:
parent
59268b8629
commit
013875e787
|
@ -185,11 +185,15 @@ function isRelevantInstruction(
|
||||||
account.equals(pubkey) ||
|
account.equals(pubkey) ||
|
||||||
mintMap.get(account.toBase58())?.mint === address
|
mintMap.get(account.toBase58())?.mint === address
|
||||||
);
|
);
|
||||||
} else {
|
} else if (
|
||||||
|
typeof instruction.parsed === "object" &&
|
||||||
|
"info" in instruction.parsed
|
||||||
|
) {
|
||||||
return Object.entries(instruction.parsed.info).some(
|
return Object.entries(instruction.parsed.info).some(
|
||||||
([key, value]) =>
|
([key, value]) =>
|
||||||
value === address ||
|
value === address ||
|
||||||
(typeof value === "string" && mintMap.get(value)?.mint === address)
|
(typeof value === "string" && mintMap.get(value)?.mint === address)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,11 @@ export class InstructionContainer {
|
||||||
this.instructions = parsedTransaction.transaction.message.instructions.map(
|
this.instructions = parsedTransaction.transaction.message.instructions.map(
|
||||||
(instruction) => {
|
(instruction) => {
|
||||||
if ("parsed" in instruction) {
|
if ("parsed" in instruction) {
|
||||||
instruction.parsed = create(instruction.parsed, ParsedInfo);
|
if (typeof instruction.parsed === "object") {
|
||||||
|
instruction.parsed = create(instruction.parsed, ParsedInfo);
|
||||||
|
} else if (typeof instruction.parsed !== "string") {
|
||||||
|
throw new Error("Unexpected parsed response");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue