add explorer support for pyth batch update price ix (#26240)

This commit is contained in:
Daniel Chew 2022-06-28 03:08:13 +09:00 committed by GitHub
parent 67936aaa74
commit 72dc813ada
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 1 deletions

View File

@ -87,6 +87,14 @@ export function PythDetailsCard(props: {
{...props}
/>
);
case "UpdatePriceNoFailOnError":
return (
<UpdatePriceDetailsCard
info={PythInstruction.decodeUpdatePriceNoFailOnError(ix)}
{...props}
/>
);
case "AggregatePrice":
return (
<AggregatePriceDetailsCard

View File

@ -22,7 +22,8 @@ export type PythInstructionType =
| "InitPrice"
| "InitTest"
| "UpdateTest"
| "SetMinPublishers";
| "SetMinPublishers"
| "UpdatePriceNoFailOnError";
export function headerLayout(property: string = "header") {
return BufferLayout.struct(
@ -187,6 +188,17 @@ export const PYTH_INSTRUCTION_LAYOUTS: {
BufferLayout.blob(3, "unused1"),
]),
},
UpdatePriceNoFailOnError: {
index: 13,
layout: BufferLayout.struct([
headerLayout(),
BufferLayout.u32("status"),
BufferLayout.u32("unused1"),
BufferLayout.ns64("price"),
BufferLayout.nu64("conf"),
BufferLayout.nu64("publishSlot"),
]),
},
});
export enum PriceType {
@ -433,6 +445,27 @@ export class PythInstruction {
};
}
/**
* Decode an "update price no fail error" instruction and retrieve the instruction params.
*/
static decodeUpdatePriceNoFailOnError(
instruction: TransactionInstruction
): UpdatePriceParams {
const { status, price, conf, publishSlot } = decodeData(
PYTH_INSTRUCTION_LAYOUTS.UpdatePriceNoFailOnError,
instruction.data
);
return {
publisherPubkey: instruction.keys[0].pubkey,
pricePubkey: instruction.keys[1].pubkey,
status,
price,
conf,
publishSlot,
};
}
/**
* Decode an "aggregate price" instruction and retrieve the instruction params.
*/