Class: Solace::Composers::ZarTrustlessEscrowClaimComposer
- Inherits:
-
Base
- Object
- Base
- Solace::Composers::ZarTrustlessEscrowClaimComposer
- Defined in:
- lib/solace/zar_trustless_escrow/composers/claim_composer.rb
Overview
Composes a ‘claim` instruction for the ZAR Trustless Escrow program.
The claim authority releases an EscrowDeposit to the claimant and closes the deposit account (rent returns to the fee payer).
Required params:
:mint [#to_s] Mint of the escrowed tokens.
:claim_authority [#to_s, Keypair] Claim authority (readonly signer).
:claimant [#to_s] Recipient of the released tokens.
:claimant_token_account [#to_s] Claimant's destination token account (ATA).
:escrow_deposit [#to_s] EscrowDeposit PDA.
:program_token_account [#to_s] Per-mint program vault PDA.
:fee_payer [#to_s, Keypair] Fee payer (writable signer).
Optional params:
:program_id [#to_s] Escrow program id (default: PROGRAM_ID, mainnet).
:token_program_id [#to_s] Token program (default: legacy SPL Token).
Instance Method Summary collapse
-
#associated_token_program ⇒ String
Returns the Associated Token Account Program id.
-
#build_instruction(context) ⇒ Solace::Instruction
Builds the instruction with resolved account indices.
-
#claim_authority ⇒ String
Extracts the claim authority from the params.
-
#claimant ⇒ String
Extracts the claimant address from the params.
-
#claimant_token_account ⇒ String
Extracts the claimant’s destination token account from the params.
-
#escrow_deposit ⇒ String
Extracts the EscrowDeposit PDA address from the params.
-
#fee_payer ⇒ String
Extracts the fee payer address from the params.
-
#mint ⇒ String
Extracts the mint address from the params.
-
#program_id ⇒ String
Returns the escrow program id (defaults to the mainnet PROGRAM_ID).
-
#program_token_account ⇒ String
Extracts the per-mint program vault address from the params.
-
#setup_accounts ⇒ Object
Declares all accounts required by this instruction.
-
#system_program ⇒ String
Returns the System Program id.
-
#token_program_id ⇒ String
Returns the token program id (defaults to the legacy SPL Token program).
Instance Method Details
#associated_token_program ⇒ String
Returns the Associated Token Account Program id
96 97 98 |
# File 'lib/solace/zar_trustless_escrow/composers/claim_composer.rb', line 96 def associated_token_program Solace::Constants::ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID end |
#build_instruction(context) ⇒ Solace::Instruction
Builds the instruction with resolved account indices.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/solace/zar_trustless_escrow/composers/claim_composer.rb', line 119 def build_instruction(context) Solace::ZarTrustlessEscrow::Instructions::ClaimInstruction.build( mint_index: context.index_of(mint), claim_authority_index: context.index_of(), claimant_index: context.index_of(claimant), claimant_token_account_index: context.index_of(claimant_token_account), escrow_deposit_index: context.index_of(escrow_deposit), program_token_account_index: context.index_of(program_token_account), fee_payer_index: context.index_of(fee_payer), system_program_index: context.index_of(system_program), token_program_index: context.index_of(token_program_id), associated_token_program_index: context.index_of(associated_token_program), program_index: context.index_of(program_id) ) end |
#claim_authority ⇒ String
Extracts the claim authority from the params
33 34 35 |
# File 'lib/solace/zar_trustless_escrow/composers/claim_composer.rb', line 33 def params[:claim_authority].to_s end |
#claimant ⇒ String
Extracts the claimant address from the params
40 41 42 |
# File 'lib/solace/zar_trustless_escrow/composers/claim_composer.rb', line 40 def claimant params[:claimant].to_s end |
#claimant_token_account ⇒ String
Extracts the claimant’s destination token account from the params
47 48 49 |
# File 'lib/solace/zar_trustless_escrow/composers/claim_composer.rb', line 47 def claimant_token_account params[:claimant_token_account].to_s end |
#escrow_deposit ⇒ String
Extracts the EscrowDeposit PDA address from the params
54 55 56 |
# File 'lib/solace/zar_trustless_escrow/composers/claim_composer.rb', line 54 def escrow_deposit params[:escrow_deposit].to_s end |
#fee_payer ⇒ String
Extracts the fee payer address from the params
68 69 70 |
# File 'lib/solace/zar_trustless_escrow/composers/claim_composer.rb', line 68 def fee_payer params[:fee_payer].to_s end |
#mint ⇒ String
Extracts the mint address from the params
26 27 28 |
# File 'lib/solace/zar_trustless_escrow/composers/claim_composer.rb', line 26 def mint params[:mint].to_s end |
#program_id ⇒ String
Returns the escrow program id (defaults to the mainnet PROGRAM_ID)
75 76 77 |
# File 'lib/solace/zar_trustless_escrow/composers/claim_composer.rb', line 75 def program_id (params[:program_id] || Solace::ZarTrustlessEscrow::PROGRAM_ID).to_s end |
#program_token_account ⇒ String
Extracts the per-mint program vault address from the params
61 62 63 |
# File 'lib/solace/zar_trustless_escrow/composers/claim_composer.rb', line 61 def program_token_account params[:program_token_account].to_s end |
#setup_accounts ⇒ Object
Declares all accounts required by this instruction.
101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/solace/zar_trustless_escrow/composers/claim_composer.rb', line 101 def setup_accounts account_context.add_readonly_nonsigner(mint) account_context.add_readonly_signer() account_context.add_readonly_nonsigner(claimant) account_context.add_writable_nonsigner(claimant_token_account) account_context.add_writable_nonsigner(escrow_deposit) account_context.add_writable_nonsigner(program_token_account) account_context.add_writable_signer(fee_payer) account_context.add_readonly_nonsigner(system_program) account_context.add_readonly_nonsigner(token_program_id) account_context.add_readonly_nonsigner(associated_token_program) account_context.add_readonly_nonsigner(program_id) end |
#system_program ⇒ String
Returns the System Program id
89 90 91 |
# File 'lib/solace/zar_trustless_escrow/composers/claim_composer.rb', line 89 def system_program Solace::Constants::SYSTEM_PROGRAM_ID end |
#token_program_id ⇒ String
Returns the token program id (defaults to the legacy SPL Token program)
82 83 84 |
# File 'lib/solace/zar_trustless_escrow/composers/claim_composer.rb', line 82 def token_program_id (params[:token_program_id] || Solace::Constants::TOKEN_PROGRAM_ID).to_s end |