Module: Solace::SquadsSmartAccounts::Permissions

Defined in:
lib/solace/squads_smart_accounts/types/permissions.rb

Overview

Bitmask constants for the three signer permission bits on a smart account. Permissions are combined with bitwise OR to grant multiple roles.

Examples:

Grant all permissions

Permissions::ALL

Grant initiate and vote only

Permissions::INITIATE | Permissions::VOTE

Build a mask from permission names

Permissions.mask(:initiate, :vote)

Constant Summary collapse

INITIATE =

Permission to initiate (create) new transactions.

0b001
VOTE =

Permission to vote (approve or reject) on proposals.

0b010
EXECUTE =

Permission to execute approved transactions.

0b100
ALL =

Convenience constant granting all three permissions.

INITIATE | VOTE | EXECUTE

Class Method Summary collapse

Class Method Details

.mask(*names) ⇒ Integer

Builds a permission bitmask from named permissions.

Parameters:

  • names (Array<Symbol>)

    Any of :initiate, :vote, :execute, :all.

Returns:

  • (Integer)

    Combined permission bitmask.

Raises:

  • (ArgumentError)

    If a name doesn’t correspond to a permission.



34
35
36
37
38
39
40
# File 'lib/solace/squads_smart_accounts/types/permissions.rb', line 34

def self.mask(*names)
  names.reduce(0) do |mask, name|
    raise ArgumentError, "unknown permission: #{name.inspect}" unless const_defined?(name.to_s.upcase)

    mask | const_get(name.to_s.upcase)
  end
end