Refactor instruction details components
This commit is contained in:
committed by
Michael Vines
parent
285ae1481f
commit
13af01dcc4
@@ -4,10 +4,6 @@ import {
|
||||
StakeProgram,
|
||||
VOTE_PROGRAM_ID,
|
||||
BpfLoader,
|
||||
TransferParams,
|
||||
SystemInstruction,
|
||||
CreateAccountParams,
|
||||
TransactionInstruction,
|
||||
SYSVAR_CLOCK_PUBKEY,
|
||||
SYSVAR_RENT_PUBKEY,
|
||||
SYSVAR_REWARDS_PUBKEY,
|
||||
@@ -53,31 +49,3 @@ export function displayAddress(pubkey: PublicKey): string {
|
||||
address
|
||||
);
|
||||
}
|
||||
|
||||
export function decodeTransfer(
|
||||
ix: TransactionInstruction
|
||||
): TransferParams | null {
|
||||
if (!ix.programId.equals(SystemProgram.programId)) return null;
|
||||
|
||||
try {
|
||||
if (SystemInstruction.decodeInstructionType(ix) !== "Transfer") return null;
|
||||
return SystemInstruction.decodeTransfer(ix);
|
||||
} catch (err) {
|
||||
console.error(ix, err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function decodeCreate(
|
||||
ix: TransactionInstruction
|
||||
): CreateAccountParams | null {
|
||||
if (!ix.programId.equals(SystemProgram.programId)) return null;
|
||||
|
||||
try {
|
||||
if (SystemInstruction.decodeInstructionType(ix) !== "Create") return null;
|
||||
return SystemInstruction.decodeCreateAccount(ix);
|
||||
} catch (err) {
|
||||
console.error(ix, err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user