@@ -10,7 +10,15 @@ import {
10
10
translateError ,
11
11
} from "@coral-xyz/anchor" ;
12
12
import { TOKEN_PROGRAM_ID , getAssociatedTokenAddressSync } from "@solana/spl-token" ;
13
- import { Commitment , Connection , ConnectionConfig , PublicKey , TransactionInstruction } from "@solana/web3.js" ;
13
+ import {
14
+ Commitment ,
15
+ Connection ,
16
+ ConnectionConfig ,
17
+ PublicKey ,
18
+ TransactionInstruction ,
19
+ SystemProgram ,
20
+ SYSVAR_RENT_PUBKEY ,
21
+ } from "@solana/web3.js" ;
14
22
import { ContractError , ICluster , ITransactionResult , invariant } from "@streamflow/common" ;
15
23
import {
16
24
buildSendThrottler ,
@@ -89,6 +97,8 @@ interface IInitOptions {
89
97
export class SolanaStakingClient {
90
98
connection : Connection ;
91
99
100
+ private readonly cluster : ICluster ;
101
+
92
102
private readonly commitment : Commitment | ConnectionConfig ;
93
103
94
104
private readonly sendThrottler : PQueue ;
@@ -103,6 +113,7 @@ export class SolanaStakingClient {
103
113
sendRate = 1 ,
104
114
sendThrottler,
105
115
} : IInitOptions ) {
116
+ this . cluster = cluster ;
106
117
this . commitment = commitment ;
107
118
this . connection = new Connection ( clusterUrl , this . commitment ) ;
108
119
this . sendThrottler = sendThrottler ?? buildSendThrottler ( sendRate ) ;
@@ -272,6 +283,20 @@ export class SolanaStakingClient {
272
283
payer : staker ,
273
284
} )
274
285
. instruction ( ) ;
286
+ if ( this . cluster == ICluster . Mainnet ) {
287
+ // TODO: remove when staking on mainnet is upgraded
288
+ instruction . keys . pop ( ) ;
289
+ instruction . keys . push ( {
290
+ pubkey : SYSVAR_RENT_PUBKEY ,
291
+ isSigner : false ,
292
+ isWritable : false ,
293
+ } ) ;
294
+ instruction . keys . push ( {
295
+ pubkey : SystemProgram . programId ,
296
+ isSigner : false ,
297
+ isWritable : false ,
298
+ } ) ;
299
+ }
275
300
276
301
return { ixs : [ instruction ] } ;
277
302
}
0 commit comments