Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix swift localValidator test #1422

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion sdk/src/swift/swiftOrderSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ export class SwiftOrderSubscriber {
swiftOrderParamsMessage: SwiftOrderParamsMessage,
makerOrderParams: OptionalOrderParams
): Promise<TransactionInstruction[]> {
const swiftOrderParamsBuf = Buffer.from(
orderMessageRaw['order_message'],
'hex'
);
const takerAuthority = new PublicKey(orderMessageRaw['taker_authority']);
const takerUserPubkey = await getUserAccountPublicKey(
this.driftClient.program.programId,
Expand All @@ -164,7 +168,7 @@ export class SwiftOrderSubscriber {
).getUserAccount();
const ixs = await this.driftClient.getPlaceAndMakeSwiftPerpOrderIxs(
{
orderParams: orderMessageRaw['order_message'],
orderParams: swiftOrderParamsBuf,
signature: Buffer.from(orderMessageRaw['order_signature'], 'base64'),
},
decodeUTF8(orderMessageRaw['uuid']),
Expand Down
14 changes: 11 additions & 3 deletions tests/placeAndMakeSwiftPerp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,11 @@ describe('place and make swift order', () => {
immediateOrCancel: true,
});

const signedOrderParams = takerDriftClient.signSwiftOrderParamsMessage(
takerOrderParamsMessage
const takerOrderParamsMessageEncoded =
takerDriftClient.encodeSwiftOrderParamsMessage(takerOrderParamsMessage);
const takerOrderParamsSig = takerDriftClient.signMessage(
Buffer.from(takerOrderParamsMessageEncoded.toString('hex')),
makerDriftClient.wallet.payer
);

const ixs = [
Expand All @@ -376,7 +379,12 @@ describe('place and make swift order', () => {
];
ixs.push(
...(await makerDriftClient.getPlaceAndMakeSwiftPerpOrderIxs(
signedOrderParams,
{
orderParams: Buffer.from(
takerOrderParamsMessageEncoded.toString('hex')
),
signature: takerOrderParamsSig,
},
uuid,
{
taker: await takerDriftClient.getUserAccountPublicKey(),
Expand Down
Loading