Class: Solace::SquadsSmartAccounts::SpendingLimit

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

Overview

Immutable value object representing a deserialized SpendingLimit account —a pre-authorized allowance letting designated signers move funds from a vault without consensus. Fetching from the chain is the Program layer’s responsibility — see Solace::Programs::SquadsSmartAccount#get_spending_limit.

Examples:

limit = program.get_spending_limit(spending_limit_address: address)
limit.amount           # => 500_000_000
limit.remaining_amount # => 300_000_000

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#account_indexObject (readonly)

Returns the value of attribute account_index

Returns:

  • (Object)

    the current value of account_index



14
15
16
# File 'lib/solace/squads_smart_accounts/types/spending_limit.rb', line 14

def 
  @account_index
end

#amountObject (readonly)

Returns the value of attribute amount

Returns:

  • (Object)

    the current value of amount



14
15
16
# File 'lib/solace/squads_smart_accounts/types/spending_limit.rb', line 14

def amount
  @amount
end

#bumpObject (readonly)

Returns the value of attribute bump

Returns:

  • (Object)

    the current value of bump



14
15
16
# File 'lib/solace/squads_smart_accounts/types/spending_limit.rb', line 14

def bump
  @bump
end

#destinationsObject (readonly)

Returns the value of attribute destinations

Returns:

  • (Object)

    the current value of destinations



14
15
16
# File 'lib/solace/squads_smart_accounts/types/spending_limit.rb', line 14

def destinations
  @destinations
end

#expirationObject (readonly)

Returns the value of attribute expiration

Returns:

  • (Object)

    the current value of expiration



14
15
16
# File 'lib/solace/squads_smart_accounts/types/spending_limit.rb', line 14

def expiration
  @expiration
end

#last_resetObject (readonly)

Returns the value of attribute last_reset

Returns:

  • (Object)

    the current value of last_reset



14
15
16
# File 'lib/solace/squads_smart_accounts/types/spending_limit.rb', line 14

def last_reset
  @last_reset
end

#mintObject (readonly)

Returns the value of attribute mint

Returns:

  • (Object)

    the current value of mint



14
15
16
# File 'lib/solace/squads_smart_accounts/types/spending_limit.rb', line 14

def mint
  @mint
end

#periodObject (readonly)

Returns the value of attribute period

Returns:

  • (Object)

    the current value of period



14
15
16
# File 'lib/solace/squads_smart_accounts/types/spending_limit.rb', line 14

def period
  @period
end

#remaining_amountObject (readonly)

Returns the value of attribute remaining_amount

Returns:

  • (Object)

    the current value of remaining_amount



14
15
16
# File 'lib/solace/squads_smart_accounts/types/spending_limit.rb', line 14

def remaining_amount
  @remaining_amount
end

#seedObject (readonly)

Returns the value of attribute seed

Returns:

  • (Object)

    the current value of seed



14
15
16
# File 'lib/solace/squads_smart_accounts/types/spending_limit.rb', line 14

def seed
  @seed
end

#settingsObject (readonly)

Returns the value of attribute settings

Returns:

  • (Object)

    the current value of settings



14
15
16
# File 'lib/solace/squads_smart_accounts/types/spending_limit.rb', line 14

def settings
  @settings
end

#signersObject (readonly)

Returns the value of attribute signers

Returns:

  • (Object)

    the current value of signers



14
15
16
# File 'lib/solace/squads_smart_accounts/types/spending_limit.rb', line 14

def signers
  @signers
end

Class Method Details

.deserialize(io) ⇒ SpendingLimit

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

Parameters:

  • io (IO, StringIO)

    Stream positioned at the start of the account data.

Returns:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/solace/squads_smart_accounts/types/spending_limit.rb', line 32

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

  new(
    settings:         Solace::Utils::Codecs.decode_pubkey(io),
    seed:             Solace::Utils::Codecs.decode_pubkey(io),
    account_index:    Solace::Utils::Codecs.decode_u8(io),
    mint:             Solace::Utils::Codecs.decode_pubkey(io),
    amount:           Solace::Utils::Codecs.decode_le_u64(io),
    period:           Solace::Utils::Codecs.decode_u8(io),
    remaining_amount: Solace::Utils::Codecs.decode_le_u64(io),
    last_reset:       Solace::Utils::Codecs.decode_le_i64(io),
    bump:             Solace::Utils::Codecs.decode_u8(io),
    signers:          Solace::Utils::Codecs.decode_vec_pubkeys(io),
    destinations:     Solace::Utils::Codecs.decode_vec_pubkeys(io),
    expiration:       Solace::Utils::Codecs.decode_le_i64(io)
  )
end