Class: Solace::ZarTrustlessEscrow::MediatedEscrowDeposit

Inherits:
Data
  • Object
show all
Defined in:
lib/solace/zar_trustless_escrow/types/mediated_escrow_deposit.rb

Overview

Immutable value object representing the deserialized MediatedEscrowDeposit account — the three-party escrow created by ‘mediated_deposit` and consumed by `mediated_release` / `mediated_reclaim`. Fetching from the chain is the Program layer’s responsibility — see Solace::Programs::ZarTrustlessEscrow#get_mediated_escrow_deposit.

On-chain layout (state/mediated_escrow_deposit.rs, matches the IDL):

discriminator(8), version(u8), mint(32), depositor(32), mediator(32),
beneficiary(32), amount(u64), rent_collector(Option<Pubkey>),
expires_at(Option<i64>).

Examples:

escrow = program.get_mediated_escrow_deposit(id: id)
escrow.mediator   # => "9xQ..."
escrow.expires_at # => 1_780_000_000 or nil

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount

Returns:

  • (Object)

    the current value of amount



20
21
22
# File 'lib/solace/zar_trustless_escrow/types/mediated_escrow_deposit.rb', line 20

def amount
  @amount
end

#beneficiaryObject (readonly)

Returns the value of attribute beneficiary

Returns:

  • (Object)

    the current value of beneficiary



20
21
22
# File 'lib/solace/zar_trustless_escrow/types/mediated_escrow_deposit.rb', line 20

def beneficiary
  @beneficiary
end

#depositorObject (readonly)

Returns the value of attribute depositor

Returns:

  • (Object)

    the current value of depositor



20
21
22
# File 'lib/solace/zar_trustless_escrow/types/mediated_escrow_deposit.rb', line 20

def depositor
  @depositor
end

#expires_atObject (readonly)

Returns the value of attribute expires_at

Returns:

  • (Object)

    the current value of expires_at



20
21
22
# File 'lib/solace/zar_trustless_escrow/types/mediated_escrow_deposit.rb', line 20

def expires_at
  @expires_at
end

#mediatorObject (readonly)

Returns the value of attribute mediator

Returns:

  • (Object)

    the current value of mediator



20
21
22
# File 'lib/solace/zar_trustless_escrow/types/mediated_escrow_deposit.rb', line 20

def mediator
  @mediator
end

#mintObject (readonly)

Returns the value of attribute mint

Returns:

  • (Object)

    the current value of mint



20
21
22
# File 'lib/solace/zar_trustless_escrow/types/mediated_escrow_deposit.rb', line 20

def mint
  @mint
end

#rent_collectorObject (readonly)

Returns the value of attribute rent_collector

Returns:

  • (Object)

    the current value of rent_collector



20
21
22
# File 'lib/solace/zar_trustless_escrow/types/mediated_escrow_deposit.rb', line 20

def rent_collector
  @rent_collector
end

#versionObject (readonly)

Returns the value of attribute version

Returns:

  • (Object)

    the current value of version



20
21
22
# File 'lib/solace/zar_trustless_escrow/types/mediated_escrow_deposit.rb', line 20

def version
  @version
end

Class Method Details

.deserialize(io) ⇒ MediatedEscrowDeposit

Deserializes a MediatedEscrowDeposit from a stream of Borsh-encoded data.

Parameters:

  • io (IO, StringIO)

    Stream positioned at the start of the account data.

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/solace/zar_trustless_escrow/types/mediated_escrow_deposit.rb', line 34

def self.deserialize(io)
  io.read(8) # skip the 8-byte Anchor discriminator

  new(
    version:        Solace::Utils::Codecs.decode_u8(io),
    mint:           Solace::Utils::Codecs.decode_pubkey(io),
    depositor:      Solace::Utils::Codecs.decode_pubkey(io),
    mediator:       Solace::Utils::Codecs.decode_pubkey(io),
    beneficiary:    Solace::Utils::Codecs.decode_pubkey(io),
    amount:         Solace::Utils::Codecs.decode_le_u64(io),
    rent_collector: Solace::Utils::Codecs.decode_option_pubkey(io),
    expires_at:     Solace::Utils::Codecs.decode_option_i64(io)
  )
end