Class: Solace::Composers::SquadsSmartAccountsRemoveSpendingLimitAsAuthorityComposer
- Inherits:
-
Base
- Object
- Base
- Solace::Composers::SquadsSmartAccountsRemoveSpendingLimitAsAuthorityComposer
- Defined in:
- lib/solace/squads_smart_accounts/composers/remove_spending_limit_as_authority_composer.rb
Overview
Composes a ‘removeSpendingLimitAsAuthority` instruction for the Squads Smart Account program.
Closes a SpendingLimit PDA, refunding its rent to the rent collector. Only the account’s settings authority may do this — single signature, no consensus.
Required params:
:settings [#to_s] Base58 address of the settings account.
:settings_authority [#to_s, Keypair] The account's settings authority (must sign).
:spending_limit [#to_s] The SpendingLimit PDA to close.
:rent_collector [#to_s] Receives the closed account's rent (does not sign).
Optional params:
:memo [String] Indexing memo (default: nil).
Instance Method Summary collapse
-
#build_instruction(context) ⇒ Solace::Instruction
Builds the instruction with resolved account indices.
-
#memo ⇒ String?
Extracts the memo from the params.
-
#program_id ⇒ String
Returns the Squads Smart Account program id from the constants.
-
#rent_collector ⇒ String
Extracts the rent collector address from the params.
-
#settings ⇒ String
Extracts the settings address from the params.
-
#settings_authority ⇒ String
Extracts the settings authority address from the params.
-
#setup_accounts ⇒ Object
Declares all accounts required by this instruction.
-
#spending_limit ⇒ String
Extracts the spending limit PDA address from the params.
Instance Method Details
#build_instruction(context) ⇒ Solace::Instruction
Builds the instruction with resolved account indices.
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/solace/squads_smart_accounts/composers/remove_spending_limit_as_authority_composer.rb', line 76 def build_instruction(context) SquadsSmartAccounts::Instructions::RemoveSpendingLimitAsAuthorityInstruction.build( memo:, settings_index: context.index_of(settings), settings_authority_index: context.index_of(), spending_limit_index: context.index_of(spending_limit), rent_collector_index: context.index_of(rent_collector), program_index: context.index_of(program_id) ) end |
#memo ⇒ String?
Extracts the memo from the params
52 53 54 |
# File 'lib/solace/squads_smart_accounts/composers/remove_spending_limit_as_authority_composer.rb', line 52 def memo params[:memo] end |
#program_id ⇒ String
Returns the Squads Smart Account program id from the constants
59 60 61 |
# File 'lib/solace/squads_smart_accounts/composers/remove_spending_limit_as_authority_composer.rb', line 59 def program_id SquadsSmartAccounts::PROGRAM_ID end |
#rent_collector ⇒ String
Extracts the rent collector address from the params
45 46 47 |
# File 'lib/solace/squads_smart_accounts/composers/remove_spending_limit_as_authority_composer.rb', line 45 def rent_collector params[:rent_collector].to_s end |
#settings ⇒ String
Extracts the settings address from the params
24 25 26 |
# File 'lib/solace/squads_smart_accounts/composers/remove_spending_limit_as_authority_composer.rb', line 24 def settings params[:settings].to_s end |
#settings_authority ⇒ String
Extracts the settings authority address from the params
31 32 33 |
# File 'lib/solace/squads_smart_accounts/composers/remove_spending_limit_as_authority_composer.rb', line 31 def params[:settings_authority].to_s end |
#setup_accounts ⇒ Object
Declares all accounts required by this instruction.
64 65 66 67 68 69 70 |
# File 'lib/solace/squads_smart_accounts/composers/remove_spending_limit_as_authority_composer.rb', line 64 def setup_accounts account_context.add_readonly_nonsigner(settings) account_context.add_readonly_signer() account_context.add_writable_nonsigner(spending_limit) account_context.add_writable_nonsigner(rent_collector) account_context.add_readonly_nonsigner(program_id) end |
#spending_limit ⇒ String
Extracts the spending limit PDA address from the params
38 39 40 |
# File 'lib/solace/squads_smart_accounts/composers/remove_spending_limit_as_authority_composer.rb', line 38 def spending_limit params[:spending_limit].to_s end |