88#[ repr( u8 ) ]
99#[ derive( Clone , Copy , Debug , PartialEq , Eq , SchemaRead , SchemaWrite ) ]
1010#[ wincode( tag_encoding = "u8" ) ]
11- pub enum ProgrammaticSignerInstruction {
12- /// Initializes a programmatic signer account for an authority.
11+ pub enum Instruction {
12+ /// Initializes a signer context account for an authority.
1313 ///
1414 /// The caller must first create and fund the account. Recommended to include
1515 /// `solana_system_interface::instruction::create_account` and `Initialize` in the same
@@ -18,74 +18,74 @@ pub enum ProgrammaticSignerInstruction {
1818 /// On success, the program:
1919 /// 1. Verifies the account is uninitialized, rent-exempt, and owned by this program.
2020 /// 2. Derives the initial `nonce` as
21- /// `sha256("spl-ed25519-programmatic-signer::init-v1" ‖ programmatic_signer_account_address ‖ slot_hashes[0])`.
22- /// 3. Writes `ProgrammaticSignerAccount { nonce, authority }` into the account data.
21+ /// `sha256("spl-ed25519-programmatic-signer::init-v1" ‖ signer_context_address ‖ slot_hashes[0])`.
22+ /// 3. Writes `SignerContext { nonce, authority }` into the account data.
2323 ///
2424 /// Instruction data: instruction discriminator only
2525 ///
2626 /// Accounts required:
27- /// - `[writable]` Programmatic signer account
28- /// - `[]` Authority to store in the programmatic signer account
27+ /// - `[writable]` Signer context account
28+ /// - `[]` Authority to store in the signer context account
2929 /// - `[]` `SlotHashes` sysvar
3030 Initialize ,
3131
3232 /// Authorizes and executes a wrapped Solana transaction whose required signers are
33- /// `ProgrammaticSignerPda ` accounts.
33+ /// `ProgrammaticSigner ` accounts.
3434 ///
3535 /// Instruction data: instruction discriminator followed by a serialized
3636 /// `solana_transaction::versioned::VersionedTransaction`.
3737 /// All message variants supported by `VersionedTransaction` are accepted.
3838 ///
3939 /// Wrapped required signers are paired by index:
40- /// - `message.account_keys[i]`: `ProgrammaticSignerPda ` promoted during CPI.
40+ /// - `message.account_keys[i]`: `ProgrammaticSigner ` promoted during CPI.
4141 /// - `tx.signatures[i]`: wrapped-message signature from the matching authority address.
4242 ///
4343 /// On success, the program:
4444 /// 1. Deserializes the transaction and sanitizes the wrapped message.
45- /// 2. Reads the authority stored in the programmatic signer account.
46- /// 3. Checks the passed programmatic signer account's authority signed the wrapped message.
45+ /// 2. Reads the authority stored in the signer context account.
46+ /// 3. Checks the passed signer context account's authority signed the wrapped message.
4747 /// 4. Checks the wrapped message's lifetime / recent blockhash field equals the account's
4848 /// `nonce`.
4949 /// 5. Verifies the outer transaction's only top-level instruction is `Submit`.
5050 /// 6. Iterates over the outer authority accounts in order. For each `authority_i`, requires
51- /// `ProgrammaticSignerPda (authority_i) == message.account_keys[i]` and verifies
51+ /// `ProgrammaticSigner (authority_i) == message.account_keys[i]` and verifies
5252 /// `tx.signatures[i]` over the wrapped message with `authority_i`.
5353 /// 7. Executes each `message.instructions` entry by CPI, using `invoke_signed` to promote
54- /// each authorized signer's corresponding `ProgrammaticSignerPda `.
54+ /// each authorized signer's corresponding `ProgrammaticSigner `.
5555 /// 8. Derives and stores the next nonce as
56- /// `sha256("spl-ed25519-programmatic-signer::v1" ‖ programmatic_signer_account ‖ old_nonce ‖ slot_hashes[0] ‖ sha256(signed_message_bytes))`
56+ /// `sha256("spl-ed25519-programmatic-signer::v1" ‖ signer_context ‖ old_nonce ‖ slot_hashes[0] ‖ sha256(signed_message_bytes))`
5757 ///
5858 /// Accounts required:
59- /// - `[writable]` Programmatic signer account whose nonce is consumed and advanced
59+ /// - `[writable]` Signer context account whose nonce is consumed and advanced
6060 /// - `[]` `SlotHashes` sysvar
6161 /// - `[]` `Instructions` sysvar
6262 /// - Authority addresses, ordered to match the wrapped message's required signers.
6363 /// - Remaining accounts referenced by the wrapped message, in order. Writable flags
6464 /// must match the wrapped message.
6565 Submit ,
6666
67- /// Closes a programmatic signer account and refunds its lamports.
67+ /// Closes a signer context account and refunds its lamports.
6868 ///
6969 /// Instruction data: instruction discriminator followed by [`CloseData`].
7070 ///
7171 /// Runs only as an inner instruction of a wrapped transaction submitted through `Submit`
72- /// because nothing outside this program can sign for `ProgrammaticSignerPda `.
72+ /// because nothing outside this program can sign for `ProgrammaticSigner `.
7373 ///
7474 /// Accounts required:
75- /// - `[signer]` `ProgrammaticSignerPda `
76- /// - `[writable]` Programmatic signer account
75+ /// - `[signer]` `ProgrammaticSigner `
76+ /// - `[writable]` Signer context account
7777 /// - `[writable]` Lamport recipient
7878 Close ,
7979}
8080
81- /// Data for [`ProgrammaticSignerInstruction ::Close`].
81+ /// Data for [`Instruction ::Close`].
8282#[ derive( Clone , Debug , PartialEq , Eq , SchemaRead , SchemaWrite ) ]
8383pub struct CloseData {
84- /// Address that receives all lamports from the closed programmatic signer account.
84+ /// Address that receives all lamports from the closed signer context account.
8585 pub recipient : Address ,
8686}
8787
88- impl ProgrammaticSignerInstruction {
88+ impl Instruction {
8989 #[ inline( always) ]
9090 pub fn try_from_bytes ( instruction_data : & [ u8 ] ) -> Result < Self , ProgramError > {
9191 wincode:: deserialize_exact ( instruction_data)
@@ -95,30 +95,24 @@ impl ProgrammaticSignerInstruction {
9595
9696#[ cfg( test) ]
9797mod tests {
98- use super :: ProgrammaticSignerInstruction ;
98+ use super :: Instruction ;
9999
100- fn instruction_bytes ( instruction : ProgrammaticSignerInstruction ) -> [ u8 ; 1 ] {
100+ fn instruction_bytes ( instruction : Instruction ) -> [ u8 ; 1 ] {
101101 let mut bytes = [ 0 ] ;
102102 wincode:: serialize_into ( bytes. as_mut_slice ( ) , & instruction) . unwrap ( ) ;
103103 bytes
104104 }
105105
106106 #[ test]
107107 fn instruction_tags_match_wire_format ( ) {
108- assert_eq ! (
109- instruction_bytes( ProgrammaticSignerInstruction :: Initialize ) ,
110- [ 0 ]
111- ) ;
112- assert_eq ! (
113- instruction_bytes( ProgrammaticSignerInstruction :: Submit ) ,
114- [ 1 ]
115- ) ;
116- assert_eq ! ( instruction_bytes( ProgrammaticSignerInstruction :: Close ) , [ 2 ] ) ;
108+ assert_eq ! ( instruction_bytes( Instruction :: Initialize ) , [ 0 ] ) ;
109+ assert_eq ! ( instruction_bytes( Instruction :: Submit ) , [ 1 ] ) ;
110+ assert_eq ! ( instruction_bytes( Instruction :: Close ) , [ 2 ] ) ;
117111 }
118112
119113 #[ test]
120114 fn try_from_bytes_rejects_unknown ( ) {
121- assert ! ( ProgrammaticSignerInstruction :: try_from_bytes( & [ 4 ] ) . is_err( ) ) ;
122- assert ! ( ProgrammaticSignerInstruction :: try_from_bytes( & [ 255 ] ) . is_err( ) ) ;
115+ assert ! ( Instruction :: try_from_bytes( & [ 4 ] ) . is_err( ) ) ;
116+ assert ! ( Instruction :: try_from_bytes( & [ 255 ] ) . is_err( ) ) ;
123117 }
124118}
0 commit comments