Class: Solace::SquadsSmartAccounts::Proposal

Inherits:
Data
  • Object
show all
Defined in:
lib/solace/squads_smart_accounts/types/proposal.rb

Overview

Immutable value object for a deserialized Proposal account — the vote tracker created alongside a Transaction. A proposal collects approvals and rejections; once approved (and past the settings time lock) the associated Transaction may be executed.

Layout (state/proposal.rs, matches the IDL):

settings(32), transaction_index(u64), rent_collector(32),
status(ProposalStatus: u8 variant + i64 timestamp — except the unit-only
Executing variant, which carries no timestamp), bump(u8),
approved(Vec<Pubkey>), rejected(Vec<Pubkey>), cancelled(Vec<Pubkey>).

Examples:

proposal = program.get_proposal(proposal_address: proposal_address)
proposal.status   # => :approved
proposal.approved # => ["9xQ...", ...]

Constant Summary collapse

STATUSES =

ProposalStatus enum variants, in Borsh variant-index order. Every variant wraps an i64 timestamp except the unit-only :executing (index 4).

%i[draft active rejected approved executing executed cancelled].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#approvedObject (readonly)

Returns the value of attribute approved

Returns:

  • (Object)

    the current value of approved



20
21
22
# File 'lib/solace/squads_smart_accounts/types/proposal.rb', line 20

def approved
  @approved
end

#bumpObject (readonly)

Returns the value of attribute bump

Returns:

  • (Object)

    the current value of bump



20
21
22
# File 'lib/solace/squads_smart_accounts/types/proposal.rb', line 20

def bump
  @bump
end

#cancelledObject (readonly)

Returns the value of attribute cancelled

Returns:

  • (Object)

    the current value of cancelled



20
21
22
# File 'lib/solace/squads_smart_accounts/types/proposal.rb', line 20

def cancelled
  @cancelled
end

#rejectedObject (readonly)

Returns the value of attribute rejected

Returns:

  • (Object)

    the current value of rejected



20
21
22
# File 'lib/solace/squads_smart_accounts/types/proposal.rb', line 20

def rejected
  @rejected
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/squads_smart_accounts/types/proposal.rb', line 20

def rent_collector
  @rent_collector
end

#settingsObject (readonly)

Returns the value of attribute settings

Returns:

  • (Object)

    the current value of settings



20
21
22
# File 'lib/solace/squads_smart_accounts/types/proposal.rb', line 20

def settings
  @settings
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



20
21
22
# File 'lib/solace/squads_smart_accounts/types/proposal.rb', line 20

def status
  @status
end

#status_timestampObject (readonly)

Returns the value of attribute status_timestamp

Returns:

  • (Object)

    the current value of status_timestamp



20
21
22
# File 'lib/solace/squads_smart_accounts/types/proposal.rb', line 20

def status_timestamp
  @status_timestamp
end

#transaction_indexObject (readonly)

Returns the value of attribute transaction_index

Returns:

  • (Object)

    the current value of transaction_index



20
21
22
# File 'lib/solace/squads_smart_accounts/types/proposal.rb', line 20

def transaction_index
  @transaction_index
end

Class Method Details

.deserialize(io) ⇒ Proposal

Deserializes a Proposal account from a stream of Borsh-encoded account data.

Parameters:

  • io (IO, StringIO)

    Stream positioned at the start of the account data.

Returns:

  • (Proposal)

    The deserialized, frozen value.

Raises:

  • (RuntimeError)

    If the status variant is unknown.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/solace/squads_smart_accounts/types/proposal.rb', line 41

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

  settings                 = Solace::Utils::Codecs.decode_pubkey(io)
  transaction_index        = Solace::Utils::Codecs.decode_le_u64(io)
  rent_collector           = Solace::Utils::Codecs.decode_pubkey(io)
  status, status_timestamp = decode_status(io)
  bump                     = Solace::Utils::Codecs.decode_u8(io)
  approved                 = Solace::Utils::Codecs.decode_vec_pubkeys(io)
  rejected                 = Solace::Utils::Codecs.decode_vec_pubkeys(io)
  cancelled                = Solace::Utils::Codecs.decode_vec_pubkeys(io)

  new(
    settings:,
    transaction_index:,
    rent_collector:,
    status:,
    status_timestamp:,
    bump:,
    approved:,
    rejected:,
    cancelled:
  )
end