Explorer: Refactor token instruction name utility function (#28391)
This commit is contained in:
parent
36e5f33e67
commit
d40875fbec
|
@ -102,41 +102,27 @@ export function getTokenInstructionName(
|
||||||
|
|
||||||
if ("parsed" in ix) {
|
if ("parsed" in ix) {
|
||||||
if (ix.program === "spl-token") {
|
if (ix.program === "spl-token") {
|
||||||
name = getTokenProgramInstructionName(ix, signatureInfo);
|
return getTokenProgramInstructionName(ix, signatureInfo);
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
} else if (
|
}
|
||||||
transactionInstruction &&
|
|
||||||
isSerumInstruction(transactionInstruction)
|
if (transactionInstruction) {
|
||||||
) {
|
|
||||||
try {
|
try {
|
||||||
name = parseSerumInstructionTitle(transactionInstruction);
|
if (isSerumInstruction(transactionInstruction)) {
|
||||||
|
return parseSerumInstructionTitle(transactionInstruction);
|
||||||
|
} else if (isTokenSwapInstruction(transactionInstruction)) {
|
||||||
|
return parseTokenSwapInstructionTitle(transactionInstruction);
|
||||||
|
} else if (isTokenLendingInstruction(transactionInstruction)) {
|
||||||
|
return parseTokenLendingInstructionTitle(transactionInstruction);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reportError(error, { signature: signatureInfo.signature });
|
reportError(error, { signature: signatureInfo.signature });
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
} else if (
|
|
||||||
transactionInstruction &&
|
|
||||||
isTokenSwapInstruction(transactionInstruction)
|
|
||||||
) {
|
|
||||||
try {
|
|
||||||
name = parseTokenSwapInstructionTitle(transactionInstruction);
|
|
||||||
} catch (error) {
|
|
||||||
reportError(error, { signature: signatureInfo.signature });
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
} else if (
|
|
||||||
transactionInstruction &&
|
|
||||||
isTokenLendingInstruction(transactionInstruction)
|
|
||||||
) {
|
|
||||||
try {
|
|
||||||
name = parseTokenLendingInstructionTitle(transactionInstruction);
|
|
||||||
} catch (error) {
|
|
||||||
reportError(error, { signature: signatureInfo.signature });
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (
|
if (
|
||||||
ix.accounts.findIndex((account) => account.equals(TOKEN_PROGRAM_ID)) >= 0
|
ix.accounts.findIndex((account) => account.equals(TOKEN_PROGRAM_ID)) >= 0
|
||||||
) {
|
) {
|
||||||
|
@ -144,7 +130,6 @@ export function getTokenInstructionName(
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue