Skip to content
Merged
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
14 changes: 9 additions & 5 deletions governance/pyth_staking_sdk/src/pyth-staking-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
createAssociatedTokenAccountInstruction,
createTransferInstruction,
getAccount,
getAssociatedTokenAddress,
getAssociatedTokenAddressSync,
getMint,
type Mint,
} from "@solana/spl-token";
Expand Down Expand Up @@ -210,9 +210,10 @@ export class PythStakingClient {
const globalConfig = await this.getGlobalConfig();
return getAccount(
this.connection,
await getAssociatedTokenAddress(
getAssociatedTokenAddressSync(
globalConfig.pythTokenMint,
this.wallet.publicKey,
true,
),
);
}
Expand Down Expand Up @@ -446,9 +447,10 @@ export class PythStakingClient {
public async createStakeAccountAndDeposit(amount: bigint) {
const globalConfig = await this.getGlobalConfig();

const senderTokenAccount = await getAssociatedTokenAddress(
const senderTokenAccount = getAssociatedTokenAddressSync(
globalConfig.pythTokenMint,
this.wallet.publicKey,
true,
);

const nonce = crypto.randomBytes(16).toString("hex");
Expand Down Expand Up @@ -528,9 +530,10 @@ export class PythStakingClient {
const globalConfig = await this.getGlobalConfig();
const mint = globalConfig.pythTokenMint;

const senderTokenAccount = await getAssociatedTokenAddress(
const senderTokenAccount = getAssociatedTokenAddressSync(
mint,
this.wallet.publicKey,
true,
);

const instruction = createTransferInstruction(
Expand All @@ -551,9 +554,10 @@ export class PythStakingClient {
const mint = globalConfig.pythTokenMint;
const instructions = [];

const receiverTokenAccount = await getAssociatedTokenAddress(
const receiverTokenAccount = getAssociatedTokenAddressSync(
mint,
this.wallet.publicKey,
true,
);

// Edge case: if the user doesn't have an ATA, create one
Expand Down
Loading