Fix dex3 transaction parsing
This commit is contained in:
parent
8e6a76539d
commit
8a96ab4ee7
|
@ -3,11 +3,9 @@ import Typography from '@material-ui/core/Typography';
|
|||
import LabelValue from './LabelValue';
|
||||
import { useWallet } from '../../utils/wallet';
|
||||
|
||||
export default function Neworder({ instruction, onOpenAddress }) {
|
||||
export default function Neworder({ instruction, onOpenAddress, v3=false }) {
|
||||
const wallet = useWallet();
|
||||
const { data, market, marketInfo } = instruction;
|
||||
const { side, limitPrice, maxQuantity, orderType, ownerPubkey } = data;
|
||||
|
||||
const marketLabel =
|
||||
(marketInfo &&
|
||||
marketInfo?.name + (marketInfo?.deprecated ? ' (deprecated)' : '')) ||
|
||||
|
@ -19,6 +17,8 @@ export default function Neworder({ instruction, onOpenAddress }) {
|
|||
return isOwner ? 'This wallet' : address?.toBase58() || 'Unknown';
|
||||
};
|
||||
|
||||
const { side, limitPrice, orderType, ownerPubkey } = data;
|
||||
const maxQuantity = v3 ? data.maxBaseQuantity : data.maxQuantity;
|
||||
return (
|
||||
<>
|
||||
<Typography
|
||||
|
|
|
@ -465,6 +465,7 @@ function ApproveSignatureForm({
|
|||
const getContent = (instruction) => {
|
||||
switch (instruction?.type) {
|
||||
case 'cancelOrder':
|
||||
case 'cancelOrderV2':
|
||||
case 'matchOrders':
|
||||
case 'settleFunds':
|
||||
return (
|
||||
|
@ -496,6 +497,10 @@ function ApproveSignatureForm({
|
|||
return (
|
||||
<NewOrder instruction={instruction} onOpenAddress={onOpenAddress} />
|
||||
);
|
||||
case 'newOrderV3':
|
||||
return (
|
||||
<NewOrder instruction={instruction} onOpenAddress={onOpenAddress} v3={true} />
|
||||
);
|
||||
default:
|
||||
return <UnknownInstruction instruction={instruction} />;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import {
|
|||
SYSVAR_RENT_PUBKEY,
|
||||
TransactionInstruction,
|
||||
} from '@solana/web3.js';
|
||||
import { publicKeyLayout } from '@project-serum/serum/lib/layout';
|
||||
|
||||
export const TOKEN_PROGRAM_ID = new PublicKey(
|
||||
'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA',
|
||||
|
@ -152,6 +151,25 @@ export function memoInstruction(memo) {
|
|||
});
|
||||
}
|
||||
|
||||
class PublicKeyLayout extends BufferLayout.Blob {
|
||||
constructor(property) {
|
||||
super(32, property);
|
||||
}
|
||||
|
||||
decode(b, offset) {
|
||||
return new PublicKey(super.decode(b, offset));
|
||||
}
|
||||
|
||||
encode(src, b, offset) {
|
||||
return super.encode(src.toBuffer(), b, offset);
|
||||
}
|
||||
}
|
||||
|
||||
function publicKeyLayout(property) {
|
||||
return new PublicKeyLayout(property);
|
||||
}
|
||||
|
||||
|
||||
export const OWNER_VALIDATION_PROGRAM_ID = new PublicKey(
|
||||
'4MNPdKu9wFMvEeZBMt3Eipfs5ovVWTJb31pEXDJAAxX5',
|
||||
);
|
||||
|
|
|
@ -10,6 +10,8 @@ import {
|
|||
SETTLE_FUNDS_QUOTE_WALLET_INDEX,
|
||||
NEW_ORDER_OPEN_ORDERS_INDEX,
|
||||
NEW_ORDER_OWNER_INDEX,
|
||||
NEW_ORDER_V3_OPEN_ORDERS_INDEX,
|
||||
NEW_ORDER_V3_OWNER_INDEX,
|
||||
} from '@project-serum/serum';
|
||||
import { PublicKey } from '@solana/web3.js';
|
||||
import { TOKEN_PROGRAM_ID } from './tokens/instructions';
|
||||
|
@ -233,6 +235,9 @@ const handleDexInstruction = async (
|
|||
} else if (type === 'newOrder') {
|
||||
const newOrderData = getNewOrderData(accounts, accountKeys);
|
||||
data = { ...data, ...newOrderData };
|
||||
} else if (type === 'newOrderV3') {
|
||||
const newOrderData = getNewOrderV3Data(accounts, accountKeys);
|
||||
data = { ...data, ...newOrderData };
|
||||
}
|
||||
return {
|
||||
type,
|
||||
|
@ -379,6 +384,20 @@ const getNewOrderData = (accounts, accountKeys) => {
|
|||
return { openOrdersPubkey, ownerPubkey };
|
||||
};
|
||||
|
||||
const getNewOrderV3Data = (accounts, accountKeys) => {
|
||||
const openOrdersPubkey = getAccountByIndex(
|
||||
accounts,
|
||||
accountKeys,
|
||||
NEW_ORDER_V3_OPEN_ORDERS_INDEX,
|
||||
);
|
||||
const ownerPubkey = getAccountByIndex(
|
||||
accounts,
|
||||
accountKeys,
|
||||
NEW_ORDER_V3_OWNER_INDEX,
|
||||
);
|
||||
return { openOrdersPubkey, ownerPubkey };
|
||||
}
|
||||
|
||||
const getSettleFundsData = (accounts, accountKeys) => {
|
||||
const basePubkey = getAccountByIndex(
|
||||
accounts,
|
||||
|
|
Loading…
Reference in New Issue