Skip to content

Commit

Permalink
Fix form txn serialization (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChewingGlass authored Apr 19, 2024
1 parent 5e0be10 commit 6348a29
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions packages/distributor-oracle/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ export async function formTransaction({
true
);

const instructions: TransactionInstruction[] = [];
let instructions: TransactionInstruction[] = [];
const recipientAcc =
await lazyDistributorProgram.account.recipientV0.fetchNullable(recipient);
if (!recipientAcc) {
Expand Down Expand Up @@ -564,14 +564,7 @@ export async function formTransaction({
.instruction();
});
const ixs = await Promise.all(ixPromises);
instructions.push(
...(await withPriorityFees({
connection: provider.connection,
computeUnits: recipientAcc ? RECIPIENT_EXISTS_CU : MISSING_RECIPIENT_CU,
instructions: ixs,
basePriorityFee,
}))
);
instructions.push(...ixs);

if (
recipientAcc &&
Expand Down Expand Up @@ -630,20 +623,28 @@ export async function formTransaction({
.instruction();
instructions.push(distributeIx);
}
const tx = toVersionedTx(
await populateMissingDraftInfo(provider.connection, {
instructions,
feePayer: payer ? payer : provider.wallet.publicKey,
})
);

const fullDraft = await populateMissingDraftInfo(provider.connection, {
instructions,
feePayer: payer ? payer : provider.wallet.publicKey,
});
instructions = await withPriorityFees({
connection: provider.connection,
basePriorityFee,
...fullDraft,
});
const tx = toVersionedTx({
...fullDraft,
instructions,
});
// @ts-ignore
const oracleUrls = lazyDistributorAcc.oracles.map((x: any) => x.url);

let serTx = tx.serialize();
if (!skipOracleSign) {
for (const oracle of oracleUrls) {
const res = await axios.post(`${oracle}`, {
transaction: serTx,
transaction: Buffer.from(serTx).toJSON(),
});
serTx = Buffer.from(res.data.transaction);
}
Expand Down

0 comments on commit 6348a29

Please sign in to comment.