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 LabelValue from './LabelValue';
|
||||||
import { useWallet } from '../../utils/wallet';
|
import { useWallet } from '../../utils/wallet';
|
||||||
|
|
||||||
export default function Neworder({ instruction, onOpenAddress }) {
|
export default function Neworder({ instruction, onOpenAddress, v3=false }) {
|
||||||
const wallet = useWallet();
|
const wallet = useWallet();
|
||||||
const { data, market, marketInfo } = instruction;
|
const { data, market, marketInfo } = instruction;
|
||||||
const { side, limitPrice, maxQuantity, orderType, ownerPubkey } = data;
|
|
||||||
|
|
||||||
const marketLabel =
|
const marketLabel =
|
||||||
(marketInfo &&
|
(marketInfo &&
|
||||||
marketInfo?.name + (marketInfo?.deprecated ? ' (deprecated)' : '')) ||
|
marketInfo?.name + (marketInfo?.deprecated ? ' (deprecated)' : '')) ||
|
||||||
|
@ -19,6 +17,8 @@ export default function Neworder({ instruction, onOpenAddress }) {
|
||||||
return isOwner ? 'This wallet' : address?.toBase58() || 'Unknown';
|
return isOwner ? 'This wallet' : address?.toBase58() || 'Unknown';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const { side, limitPrice, orderType, ownerPubkey } = data;
|
||||||
|
const maxQuantity = v3 ? data.maxBaseQuantity : data.maxQuantity;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Typography
|
<Typography
|
||||||
|
|
|
@ -465,6 +465,7 @@ function ApproveSignatureForm({
|
||||||
const getContent = (instruction) => {
|
const getContent = (instruction) => {
|
||||||
switch (instruction?.type) {
|
switch (instruction?.type) {
|
||||||
case 'cancelOrder':
|
case 'cancelOrder':
|
||||||
|
case 'cancelOrderV2':
|
||||||
case 'matchOrders':
|
case 'matchOrders':
|
||||||
case 'settleFunds':
|
case 'settleFunds':
|
||||||
return (
|
return (
|
||||||
|
@ -496,6 +497,10 @@ function ApproveSignatureForm({
|
||||||
return (
|
return (
|
||||||
<NewOrder instruction={instruction} onOpenAddress={onOpenAddress} />
|
<NewOrder instruction={instruction} onOpenAddress={onOpenAddress} />
|
||||||
);
|
);
|
||||||
|
case 'newOrderV3':
|
||||||
|
return (
|
||||||
|
<NewOrder instruction={instruction} onOpenAddress={onOpenAddress} v3={true} />
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
return <UnknownInstruction instruction={instruction} />;
|
return <UnknownInstruction instruction={instruction} />;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import {
|
||||||
SYSVAR_RENT_PUBKEY,
|
SYSVAR_RENT_PUBKEY,
|
||||||
TransactionInstruction,
|
TransactionInstruction,
|
||||||
} from '@solana/web3.js';
|
} from '@solana/web3.js';
|
||||||
import { publicKeyLayout } from '@project-serum/serum/lib/layout';
|
|
||||||
|
|
||||||
export const TOKEN_PROGRAM_ID = new PublicKey(
|
export const TOKEN_PROGRAM_ID = new PublicKey(
|
||||||
'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA',
|
'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(
|
export const OWNER_VALIDATION_PROGRAM_ID = new PublicKey(
|
||||||
'4MNPdKu9wFMvEeZBMt3Eipfs5ovVWTJb31pEXDJAAxX5',
|
'4MNPdKu9wFMvEeZBMt3Eipfs5ovVWTJb31pEXDJAAxX5',
|
||||||
);
|
);
|
||||||
|
|
|
@ -10,6 +10,8 @@ import {
|
||||||
SETTLE_FUNDS_QUOTE_WALLET_INDEX,
|
SETTLE_FUNDS_QUOTE_WALLET_INDEX,
|
||||||
NEW_ORDER_OPEN_ORDERS_INDEX,
|
NEW_ORDER_OPEN_ORDERS_INDEX,
|
||||||
NEW_ORDER_OWNER_INDEX,
|
NEW_ORDER_OWNER_INDEX,
|
||||||
|
NEW_ORDER_V3_OPEN_ORDERS_INDEX,
|
||||||
|
NEW_ORDER_V3_OWNER_INDEX,
|
||||||
} from '@project-serum/serum';
|
} from '@project-serum/serum';
|
||||||
import { PublicKey } from '@solana/web3.js';
|
import { PublicKey } from '@solana/web3.js';
|
||||||
import { TOKEN_PROGRAM_ID } from './tokens/instructions';
|
import { TOKEN_PROGRAM_ID } from './tokens/instructions';
|
||||||
|
@ -233,6 +235,9 @@ const handleDexInstruction = async (
|
||||||
} else if (type === 'newOrder') {
|
} else if (type === 'newOrder') {
|
||||||
const newOrderData = getNewOrderData(accounts, accountKeys);
|
const newOrderData = getNewOrderData(accounts, accountKeys);
|
||||||
data = { ...data, ...newOrderData };
|
data = { ...data, ...newOrderData };
|
||||||
|
} else if (type === 'newOrderV3') {
|
||||||
|
const newOrderData = getNewOrderV3Data(accounts, accountKeys);
|
||||||
|
data = { ...data, ...newOrderData };
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
type,
|
type,
|
||||||
|
@ -379,6 +384,20 @@ const getNewOrderData = (accounts, accountKeys) => {
|
||||||
return { openOrdersPubkey, ownerPubkey };
|
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 getSettleFundsData = (accounts, accountKeys) => {
|
||||||
const basePubkey = getAccountByIndex(
|
const basePubkey = getAccountByIndex(
|
||||||
accounts,
|
accounts,
|
||||||
|
|
Loading…
Reference in New Issue