Skip to content

Commit 6f02bbb

Browse files
authored
feat: enable pda wallets (#2002)
* go * go
1 parent 12536a5 commit 6f02bbb

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

governance/pyth_staking_sdk/src/pyth-staking-client.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
createAssociatedTokenAccountInstruction,
1212
createTransferInstruction,
1313
getAccount,
14-
getAssociatedTokenAddress,
14+
getAssociatedTokenAddressSync,
1515
getMint,
1616
type Mint,
1717
} from "@solana/spl-token";
@@ -210,9 +210,10 @@ export class PythStakingClient {
210210
const globalConfig = await this.getGlobalConfig();
211211
return getAccount(
212212
this.connection,
213-
await getAssociatedTokenAddress(
213+
getAssociatedTokenAddressSync(
214214
globalConfig.pythTokenMint,
215215
this.wallet.publicKey,
216+
true,
216217
),
217218
);
218219
}
@@ -446,9 +447,10 @@ export class PythStakingClient {
446447
public async createStakeAccountAndDeposit(amount: bigint) {
447448
const globalConfig = await this.getGlobalConfig();
448449

449-
const senderTokenAccount = await getAssociatedTokenAddress(
450+
const senderTokenAccount = getAssociatedTokenAddressSync(
450451
globalConfig.pythTokenMint,
451452
this.wallet.publicKey,
453+
true,
452454
);
453455

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

531-
const senderTokenAccount = await getAssociatedTokenAddress(
533+
const senderTokenAccount = getAssociatedTokenAddressSync(
532534
mint,
533535
this.wallet.publicKey,
536+
true,
534537
);
535538

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

554-
const receiverTokenAccount = await getAssociatedTokenAddress(
557+
const receiverTokenAccount = getAssociatedTokenAddressSync(
555558
mint,
556559
this.wallet.publicKey,
560+
true,
557561
);
558562

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

0 commit comments

Comments
 (0)