Skip to content

Commit ee55148

Browse files
fix(staking): use dummy wallet that throws error (#1947)
* fix(staking): use dummy wallet that throws error * fix
1 parent aa90ce9 commit ee55148

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as crypto from "crypto";
22

3-
import { AnchorProvider, BN, Program, Wallet } from "@coral-xyz/anchor";
3+
import { AnchorProvider, BN, Program } from "@coral-xyz/anchor";
44
import {
55
getTokenOwnerRecordAddress,
66
PROGRAM_VERSION_V2,
@@ -15,7 +15,6 @@ import {
1515
import type { AnchorWallet } from "@solana/wallet-adapter-react";
1616
import {
1717
Connection,
18-
Keypair,
1918
PublicKey,
2019
SystemProgram,
2120
Transaction,
@@ -46,6 +45,7 @@ import {
4645
} from "./utils/position";
4746
import { sendTransaction } from "./utils/transaction";
4847
import { getUnlockSchedule } from "./utils/vesting";
48+
import { DummyWallet } from "./utils/wallet";
4949
import * as IntegrityPoolIdl from "../idl/integrity-pool.json";
5050
import * as PublisherCapsIdl from "../idl/publisher-caps.json";
5151
import * as StakingIdl from "../idl/staking.json";
@@ -67,8 +67,10 @@ export class PythStakingClient {
6767
publisherCapsProgram: Program<PublisherCaps>;
6868

6969
constructor(config: PythStakingClientConfig) {
70-
this.connection = config.connection;
71-
this.wallet = config.wallet ?? new Wallet(Keypair.generate());
70+
const { connection, wallet = DummyWallet } = config;
71+
72+
this.connection = connection;
73+
this.wallet = wallet;
7274

7375
this.provider = new AnchorProvider(this.connection, this.wallet, {
7476
skipPreflight: true,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { AnchorWallet } from "@solana/wallet-adapter-react";
2+
import { PublicKey } from "@solana/web3.js";
3+
4+
export const DummyWallet: AnchorWallet = {
5+
publicKey: PublicKey.default,
6+
signTransaction: () => {
7+
throw new Error("Cannot sign transaction without a wallet");
8+
},
9+
signAllTransactions: () => {
10+
throw new Error("Cannot sign transactions without a wallet");
11+
},
12+
};

0 commit comments

Comments
 (0)