Refactor instruction details components

This commit is contained in:
Justin Starry
2020-05-08 23:36:41 +08:00
committed by Michael Vines
parent 285ae1481f
commit 13af01dcc4
6 changed files with 313 additions and 300 deletions

View File

@@ -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;
}
}