@@ -5,7 +5,6 @@ use anchor_lang::solana_program::hash::Hash;
55use anchor_lang:: solana_program:: instruction:: { AccountMeta , Instruction } ;
66use anchor_lang:: solana_program:: program_error:: ProgramError ;
77use anchor_lang:: solana_program:: pubkey:: Pubkey ;
8- use anchor_lang:: solana_program:: system_program;
98use anchor_lang:: { AccountDeserialize , Discriminator , InstructionData , ToAccountMetas } ;
109use regex:: Regex ;
1110use solana_account_decoder:: UiAccountEncoding ;
@@ -112,18 +111,6 @@ impl Program {
112111 self . cfg . cluster . url ( ) ,
113112 self . cfg . payer . clone ( ) ,
114113 self . cfg . options ,
115- RequestNamespace :: Global ,
116- )
117- }
118-
119- /// Returns a request builder for program state.
120- pub fn state_request ( & self ) -> RequestBuilder {
121- RequestBuilder :: from (
122- self . program_id ,
123- self . cfg . cluster . url ( ) ,
124- self . cfg . payer . clone ( ) ,
125- self . cfg . options ,
126- RequestNamespace :: State { new : false } ,
127114 )
128115 }
129116
@@ -176,10 +163,6 @@ impl Program {
176163 } )
177164 }
178165
179- pub fn state < T : AccountDeserialize > ( & self ) -> Result < T , ClientError > {
180- self . account ( anchor_lang:: __private:: state:: address ( & self . program_id ) )
181- }
182-
183166 pub fn rpc ( & self ) -> RpcClient {
184167 RpcClient :: new_with_commitment (
185168 self . cfg . cluster . url ( ) . to_string ( ) ,
@@ -400,18 +383,6 @@ pub struct RequestBuilder<'a> {
400383 // Serialized instruction data for the target RPC.
401384 instruction_data : Option < Vec < u8 > > ,
402385 signers : Vec < & ' a dyn Signer > ,
403- // True if the user is sending a state instruction.
404- namespace : RequestNamespace ,
405- }
406-
407- #[ derive( PartialEq , Eq ) ]
408- pub enum RequestNamespace {
409- Global ,
410- State {
411- // True if the request is to the state's new ctor.
412- new : bool ,
413- } ,
414- Interface ,
415386}
416387
417388impl < ' a > RequestBuilder < ' a > {
@@ -420,7 +391,6 @@ impl<'a> RequestBuilder<'a> {
420391 cluster : & str ,
421392 payer : Rc < dyn Signer > ,
422393 options : Option < CommitmentConfig > ,
423- namespace : RequestNamespace ,
424394 ) -> Self {
425395 Self {
426396 program_id,
@@ -431,7 +401,6 @@ impl<'a> RequestBuilder<'a> {
431401 instructions : Vec :: new ( ) ,
432402 instruction_data : None ,
433403 signers : Vec :: new ( ) ,
434- namespace,
435404 }
436405 }
437406
@@ -478,53 +447,19 @@ impl<'a> RequestBuilder<'a> {
478447 self
479448 }
480449
481- /// Invokes the `#[state]`'s `new` constructor.
482- #[ allow( clippy:: wrong_self_convention) ]
483- #[ must_use]
484- pub fn new ( mut self , args : impl InstructionData ) -> Self {
485- assert ! ( self . namespace == RequestNamespace :: State { new: false } ) ;
486- self . namespace = RequestNamespace :: State { new : true } ;
487- self . instruction_data = Some ( args. data ( ) ) ;
488- self
489- }
490-
491450 #[ must_use]
492451 pub fn signer ( mut self , signer : & ' a dyn Signer ) -> Self {
493452 self . signers . push ( signer) ;
494453 self
495454 }
496455
497456 pub fn instructions ( & self ) -> Result < Vec < Instruction > , ClientError > {
498- let mut accounts = match self . namespace {
499- RequestNamespace :: State { new } => match new {
500- false => vec ! [ AccountMeta :: new(
501- anchor_lang:: __private:: state:: address( & self . program_id) ,
502- false ,
503- ) ] ,
504- true => vec ! [
505- AccountMeta :: new_readonly( self . payer. pubkey( ) , true ) ,
506- AccountMeta :: new(
507- anchor_lang:: __private:: state:: address( & self . program_id) ,
508- false ,
509- ) ,
510- AccountMeta :: new_readonly(
511- Pubkey :: find_program_address( & [ ] , & self . program_id) . 0 ,
512- false ,
513- ) ,
514- AccountMeta :: new_readonly( system_program:: ID , false ) ,
515- AccountMeta :: new_readonly( self . program_id, false ) ,
516- ] ,
517- } ,
518- _ => Vec :: new ( ) ,
519- } ;
520- accounts. extend_from_slice ( & self . accounts ) ;
521-
522457 let mut instructions = self . instructions . clone ( ) ;
523458 if let Some ( ix_data) = & self . instruction_data {
524459 instructions. push ( Instruction {
525460 program_id : self . program_id ,
526461 data : ix_data. clone ( ) ,
527- accounts,
462+ accounts : self . accounts . clone ( ) ,
528463 } ) ;
529464 }
530465
0 commit comments