Class: Solace::ZarTrustlessEscrow::Instructions::MediatedReclaimInstruction

Inherits:
Object
  • Object
show all
Defined in:
lib/solace/zar_trustless_escrow/instructions/mediated_reclaim_instruction.rb

Overview

Encoder for the ‘mediated_reclaim` instruction: after expiry, the original depositor reclaims a MediatedEscrowDeposit and closes the deposit account.

Constant Summary collapse

DISCRIMINATOR =

8-byte Anchor discriminator: SHA256(“global:mediated_reclaim”).

[192, 255, 211, 122, 12, 11, 191, 146].freeze

Class Method Summary collapse

Class Method Details

.build(id:, mint_index:, depositor_index:, depositor_token_account_index:, mediated_escrow_deposit_index:, program_token_account_index:, fee_payer_index:, system_program_index:, token_program_index:, associated_token_program_index:, program_index:) ⇒ Solace::Instruction

Builds a Solace::Instruction for ‘mediated_reclaim`.

Account indices are in the on-chain order:

mint, depositor, depositor_token_account, mediated_escrow_deposit,
program_token_account, fee_payer, system_program, token_program,
associated_token_program.

Returns:

  • (Solace::Instruction)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/solace/zar_trustless_escrow/instructions/mediated_reclaim_instruction.rb', line 20

def self.build(
  id:,
  mint_index:,
  depositor_index:,
  depositor_token_account_index:,
  mediated_escrow_deposit_index:,
  program_token_account_index:,
  fee_payer_index:,
  system_program_index:,
  token_program_index:,
  associated_token_program_index:,
  program_index:
)
  Solace::Instruction.new.tap do |ix|
    ix.program_index = program_index
    ix.accounts      = [
      mint_index,
      depositor_index,
      ,
      mediated_escrow_deposit_index,
      ,
      fee_payer_index,
      system_program_index,
      token_program_index,
      associated_token_program_index
    ]
    ix.data = data(id:)
  end
end

.data(id:) ⇒ Array<Integer>

Encodes the MediatedReclaimCreateArgs struct in Borsh format.

Parameters:

  • id (#to_s)

    base58 unique id used to derive the mediated escrow PDA.

Returns:

  • (Array<Integer>)


54
55
56
# File 'lib/solace/zar_trustless_escrow/instructions/mediated_reclaim_instruction.rb', line 54

def self.data(id:)
  DISCRIMINATOR + Solace::Utils::Codecs.encode_pubkey(id)
end