Class: Solace::Programs::SquadsSmartAccount

Inherits:
Base
  • Object
show all
Defined in:
lib/solace/squads_smart_accounts/programs/squads_smart_account.rb

Overview

Client for interacting with the Squads Smart Account program.

This client provides methods for interacting with the Squads Smart Account program, including deriving the program’s PDAs. Address derivation is the Program layer’s responsibility — composers receive resolved addresses.

Examples:

Derive the settings address for the next smart account

program_config = program.get_program_config

settings_address, = Solace::Programs::SquadsSmartAccount.get_settings_address(
  settings_seed: program_config. + 1
)

See Also:

Constant Summary collapse

DEFAULT_CREATION_WINDOW =

Default number of candidate settings PDAs offered by windowed creation. The on-chain counter must land inside this window for the transaction to succeed; ~20 absorbs heavy concurrency while staying well under the transaction account limit. Non-winning candidates are never initialized, so a larger window costs transaction size only, never rent.

20

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection:) ⇒ SquadsSmartAccount

Initializes a new Squads Smart Account client.

Parameters:

  • connection (Solace::Connection)

    The connection to the Solana cluster.



112
113
114
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 112

def initialize(connection:)
  super(connection:, program_id: Solace::SquadsSmartAccounts::PROGRAM_ID)
end

Class Method Details

.get_proposal_address(settings_address:, transaction_index:) ⇒ Array<String, Integer>

Gets the address of a Proposal PDA.

The on-chain derivation appends a trailing “proposal” marker to the transaction seeds: [“smart_account”, settings_pda, “transaction”, u64(transaction_index), “proposal”].

Parameters:

  • settings_address (#to_s)

    Base58 address of the settings account.

  • transaction_index (Integer)

    The transaction index the proposal tracks.

Returns:

  • (Array<String, Integer>)

    The proposal address and bump seed.



100
101
102
103
104
105
106
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 100

def get_proposal_address(settings_address:, transaction_index:)
  Solace::Utils::PDA.find_program_address(
    ['smart_account', settings_address.to_s, 'transaction',
     Solace::Utils::Codecs.encode_le_u64(transaction_index).bytes, 'proposal'],
    Solace::SquadsSmartAccounts::PROGRAM_ID
  )
end

.get_settings_address(settings_seed:) ⇒ Array<String, Integer>

Gets the address of the settings PDA for a given settings seed.

The seed is encoded as a 16-byte little-endian u128, matching the on-chain derivation [“smart_account”, “settings”, seed.to_le_bytes()].

Parameters:

  • settings_seed (Integer)

    ProgramConfig#smart_account_index + 1 at composition time.

Returns:

  • (Array<String, Integer>)

    The settings address and bump seed.



35
36
37
38
39
40
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 35

def get_settings_address(settings_seed:)
  Solace::Utils::PDA.find_program_address(
    ['smart_account', 'settings', Solace::Utils::Codecs.encode_le_u128(settings_seed).bytes],
    Solace::SquadsSmartAccounts::PROGRAM_ID
  )
end

.get_smart_account_address(settings_address:, account_index: 0) ⇒ Array<String, Integer>

Gets the address of a smart account (vault) PDA controlled by a settings account.

Funds live in vault PDAs; one settings account controls up to 256 vaults (index 0-255). The on-chain derivation is [“smart_account”, settings_pda, “smart_account”, account_index.to_le_bytes()].

Parameters:

  • settings_address (String)

    Base58 address of the settings account.

  • account_index (Integer) (defaults to: 0)

    Vault index in range 0..255 (default: 0).

Returns:

  • (Array<String, Integer>)

    The vault address and bump seed.



51
52
53
54
55
56
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 51

def (settings_address:, account_index: 0)
  Solace::Utils::PDA.find_program_address(
    ['smart_account', settings_address.to_s, 'smart_account', []],
    Solace::SquadsSmartAccounts::PROGRAM_ID
  )
end

.get_spending_limit_address(settings_address:, seed:) ⇒ Array<String, Integer>

Gets the address of a SpendingLimit PDA.

The on-chain derivation is

“smart_account”, settings_pda, “spending_limit”, seed_pubkey

— the

seed is an arbitrary client-generated pubkey that uniquely identifies the limit under its settings account.

Parameters:

  • settings_address (#to_s)

    Base58 address of the settings account.

  • seed (#to_s)

    The pubkey the limit is (or will be) seeded with.

Returns:

  • (Array<String, Integer>)

    The spending limit address and bump seed.



68
69
70
71
72
73
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 68

def get_spending_limit_address(settings_address:, seed:)
  Solace::Utils::PDA.find_program_address(
    ['smart_account', settings_address.to_s, 'spending_limit', seed.to_s],
    Solace::SquadsSmartAccounts::PROGRAM_ID
  )
end

.get_transaction_address(settings_address:, transaction_index:) ⇒ Array<String, Integer>

Gets the address of a Transaction PDA.

The on-chain derivation is [“smart_account”, settings_pda, “transaction”, u64(transaction_index)].

Parameters:

  • settings_address (#to_s)

    Base58 address of the settings account.

  • transaction_index (Integer)

    The transaction index (settings.transaction_index + 1 for a new one).

Returns:

  • (Array<String, Integer>)

    The transaction address and bump seed.



83
84
85
86
87
88
89
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 83

def get_transaction_address(settings_address:, transaction_index:)
  Solace::Utils::PDA.find_program_address(
    ['smart_account', settings_address.to_s, 'transaction',
     Solace::Utils::Codecs.encode_le_u64(transaction_index).bytes],
    Solace::SquadsSmartAccounts::PROGRAM_ID
  )
end

Instance Method Details

#activate_proposal(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Activates a draft proposal (Draft → Active), signs it, and (optionally) sends it. The signer must be a smart-account member with the Initiate permission. Only needed for proposals created with ‘draft: true`.

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1481

def activate_proposal(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_activate_proposal(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, composer_opts[:signer])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#add_signer_as_authority(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Adds a new signer to a controlled smart account, signs with the settings authority, and (optionally) sends it.

Examples:

Add a vote-only signer

tx = program.add_signer_as_authority(
  payer: authority,
  settings: identity.settings_address,
  settings_authority: authority,
  rent_payer: authority,
  new_signer: SmartAccountSigner.new(pubkey: new_key.address, permission: Permissions::VOTE)
)

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 512

def add_signer_as_authority(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_add_signer_as_authority(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, composer_opts[:settings_authority], composer_opts[:rent_payer])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#add_spending_limit_as_authority(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Creates a spending limit on a controlled smart account, signs with the settings authority, and (optionally) sends it.

Examples:

Grant a member a daily SOL allowance

spending_limit, = program.get_spending_limit_address(
  settings_address: identity.settings_address, seed:
)

tx = program.add_spending_limit_as_authority(
  payer: authority,
  settings: identity.settings_address,
  settings_authority: authority,
  rent_payer: authority,
  spending_limit:,
  seed:,
  amount: 500_000_000,
  period: Period::DAY,
  signers: [member.address]
)

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 906

def add_spending_limit_as_authority(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_add_spending_limit_as_authority(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, composer_opts[:settings_authority], composer_opts[:rent_payer])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#approve_proposal(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Approves a proposal on behalf of a signer, signs it, and (optionally) sends it. The signer must be a smart-account member with the Vote permission; the proposal becomes Approved once approvals reach threshold.

Examples:

Approve the proposal for transaction index 1

tx = program.approve_proposal(
  payer: creator,
  settings: identity.settings_address,
  signer: creator,
  transaction_index: 1
)

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1300

def approve_proposal(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_approve_proposal(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, composer_opts[:signer])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#cancel_proposal(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Cancels an Approved proposal on behalf of a signer, signs it, and (optionally) sends it. The signer must be a smart-account member with the Vote permission; once cancellations reach the threshold the proposal becomes Cancelled and its transaction can no longer execute.

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1421

def cancel_proposal(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_cancel_proposal(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, composer_opts[:signer])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#change_threshold_as_authority(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Changes the approval threshold of a controlled smart account, signs with the settings authority, and (optionally) sends it.

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 630

def change_threshold_as_authority(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_change_threshold_as_authority(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, composer_opts[:settings_authority], composer_opts[:rent_payer])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#close_settings_transaction(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Closes a settings transaction and its proposal, refunding their rent, signs it, and (optionally) sends it. Closeable once the proposal is terminal (Executed/Rejected/Cancelled) or stale. Only the fee payer signs.

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1830

def close_settings_transaction(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_close_settings_transaction(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer)

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#close_transaction(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Closes a vault transaction and its proposal, refunding their rent, signs it, and (optionally) sends it. Closeable once the proposal is terminal (Executed/Rejected/Cancelled) or stale and not Approved. Only the fee payer signs.

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1618

def close_transaction(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_close_transaction(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer)

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#compose_activate_proposal(settings:, signer:, transaction_index:) ⇒ TransactionComposer

Prepares an activate-proposal transaction. The Proposal PDA is derived from the settings address and transaction index here.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • signer (#to_s, Keypair)

    The activating signer (must sign).

  • transaction_index (Integer)

    Index of the transaction the proposal tracks.

Returns:

  • (TransactionComposer)

    A composer with required instructions.



1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1511

def compose_activate_proposal(
  settings:,
  signer:,
  transaction_index:
)
  proposal, = get_proposal_address(settings_address: settings.to_s, transaction_index:)

  activate_proposal_ix = Composers::SquadsSmartAccountsActivateProposalComposer.new(
    settings:,
    signer:,
    proposal:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(activate_proposal_ix)
end

#compose_add_signer_as_authority(settings:, settings_authority:, rent_payer:, new_signer:, memo: nil) ⇒ TransactionComposer

Prepares an add-signer-as-authority transaction.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • settings_authority (#to_s, Keypair)

    The account’s settings authority.

  • rent_payer (#to_s, Keypair)

    Pays for settings account reallocation.

  • new_signer (SquadsSmartAccounts::SmartAccountSigner)

    The signer to add.

  • memo (String) (defaults to: nil)

    (Optional) Indexing memo.

Returns:

  • (TransactionComposer)

    A composer with required instructions.



543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 543

def compose_add_signer_as_authority(
  settings:,
  settings_authority:,
  rent_payer:,
  new_signer:,
  memo: nil
)
  add_signer_ix = Composers::SquadsSmartAccountsAddSignerAsAuthorityComposer.new(
    settings:,
    settings_authority:,
    rent_payer:,
    new_signer:,
    memo:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(add_signer_ix)
end

#compose_add_spending_limit_as_authority(settings:, settings_authority:, spending_limit:, rent_payer:, seed:, amount:, period:, signers:, account_index: 0, mint: Solace::SquadsSmartAccounts::DEFAULT_PUBKEY, destinations: [], expiration: Solace::SquadsSmartAccounts::I64_MAX, memo: nil) ⇒ TransactionComposer

Prepares an add-spending-limit-as-authority transaction.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • settings_authority (#to_s, Keypair)

    The account’s settings authority.

  • spending_limit (#to_s)

    The SpendingLimit PDA to create.

  • rent_payer (#to_s, Keypair)

    Funds the new account’s rent.

  • seed (#to_s)

    The pubkey the spending_limit PDA was derived with.

  • amount (Integer)

    Amount spendable per period (mint decimals).

  • period (Integer)

    Period enum value (reset cadence).

  • signers (Array<#to_s>)

    Pubkeys allowed to use the limit.

  • account_index (Integer) (defaults to: 0)

    (Optional) Vault index (default: 0).

  • mint (#to_s) (defaults to: Solace::SquadsSmartAccounts::DEFAULT_PUBKEY)

    (Optional) Token mint (default: DEFAULT_PUBKEY = SOL).

  • destinations (Array<#to_s>) (defaults to: [])

    (Optional) Allowed destinations; empty = any.

  • expiration (Integer) (defaults to: Solace::SquadsSmartAccounts::I64_MAX)

    (Optional) Unix expiration (default: I64_MAX = never).

  • memo (String) (defaults to: nil)

    (Optional) Indexing memo.

Returns:

  • (TransactionComposer)

    A composer with required instructions.



945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 945

def compose_add_spending_limit_as_authority(
  settings:,
  settings_authority:,
  spending_limit:,
  rent_payer:,
  seed:,
  amount:,
  period:,
  signers:,
  account_index: 0,
  mint: Solace::SquadsSmartAccounts::DEFAULT_PUBKEY,
  destinations: [],
  expiration: Solace::SquadsSmartAccounts::I64_MAX,
  memo: nil
)
  add_spending_limit_ix = Composers::SquadsSmartAccountsAddSpendingLimitAsAuthorityComposer.new(
    settings:,
    settings_authority:,
    spending_limit:,
    rent_payer:,
    seed:,
    amount:,
    period:,
    signers:,
    account_index:,
    mint:,
    destinations:,
    expiration:,
    memo:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(add_spending_limit_ix)
end

#compose_approve_proposal(settings:, signer:, transaction_index:, memo: nil) ⇒ TransactionComposer

Prepares an approve-proposal transaction. The Proposal PDA is derived from the settings address and transaction index here.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • signer (#to_s, Keypair)

    The voting signer (must sign).

  • transaction_index (Integer)

    Index of the transaction the proposal tracks.

  • memo (String) (defaults to: nil)

    (Optional) Indexing memo.

Returns:

  • (TransactionComposer)

    A composer with required instructions.



1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1331

def compose_approve_proposal(
  settings:,
  signer:,
  transaction_index:,
  memo: nil
)
  proposal, = get_proposal_address(settings_address: settings.to_s, transaction_index:)

  approve_proposal_ix = Composers::SquadsSmartAccountsApproveProposalComposer.new(
    settings:,
    signer:,
    proposal:,
    memo:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(approve_proposal_ix)
end

#compose_cancel_proposal(settings:, signer:, transaction_index:, memo: nil) ⇒ TransactionComposer

Prepares a cancel-proposal transaction. The Proposal PDA is derived from the settings address and transaction index here.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • signer (#to_s, Keypair)

    The voting signer (must sign).

  • transaction_index (Integer)

    Index of the transaction the proposal tracks.

  • memo (String) (defaults to: nil)

    (Optional) Indexing memo.

Returns:

  • (TransactionComposer)

    A composer with required instructions.



1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1452

def compose_cancel_proposal(
  settings:,
  signer:,
  transaction_index:,
  memo: nil
)
  proposal, = get_proposal_address(settings_address: settings.to_s, transaction_index:)

  cancel_proposal_ix = Composers::SquadsSmartAccountsCancelProposalComposer.new(
    settings:,
    signer:,
    proposal:,
    memo:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(cancel_proposal_ix)
end

#compose_change_threshold_as_authority(settings:, settings_authority:, rent_payer:, new_threshold:, memo: nil) ⇒ TransactionComposer

Prepares a change-threshold-as-authority transaction.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • settings_authority (#to_s, Keypair)

    The account’s settings authority.

  • rent_payer (#to_s, Keypair)

    Pays for settings account reallocation.

  • new_threshold (Integer)

    The new approval threshold.

  • memo (String) (defaults to: nil)

    (Optional) Indexing memo.

Returns:

  • (TransactionComposer)

    A composer with required instructions.



661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 661

def compose_change_threshold_as_authority(
  settings:,
  settings_authority:,
  rent_payer:,
  new_threshold:,
  memo: nil
)
  change_threshold_ix = Composers::SquadsSmartAccountsChangeThresholdAsAuthorityComposer.new(
    settings:,
    settings_authority:,
    rent_payer:,
    new_threshold:,
    memo:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(change_threshold_ix)
end

#compose_close_settings_transaction(settings:, transaction_index:, proposal_rent_collector: nil, transaction_rent_collector: nil) ⇒ TransactionComposer

Prepares a close-settings-transaction transaction. The Proposal and SettingsTransaction PDAs are derived here; the rent collectors default to the on-chain values (the proposal’s and transaction’s stored collectors) when not supplied.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • transaction_index (Integer)

    Index of the settings transaction to close.

  • proposal_rent_collector (#to_s) (defaults to: nil)

    (Optional) Receives the proposal rent (defaults to the proposal’s stored rent collector).

  • transaction_rent_collector (#to_s) (defaults to: nil)

    (Optional) Receives the transaction rent (defaults to the transaction’s stored rent collector).

Returns:

  • (TransactionComposer)

    A composer with required instructions.



1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1865

def compose_close_settings_transaction(
  settings:,
  transaction_index:,
  proposal_rent_collector: nil,
  transaction_rent_collector: nil
)
  transaction, = get_transaction_address(settings_address: settings.to_s, transaction_index:)
  proposal,    = get_proposal_address(settings_address: settings.to_s, transaction_index:)

  proposal_rent_collector    ||= get_proposal(proposal_address: proposal).rent_collector
  transaction_rent_collector ||= get_settings_transaction(transaction_address: transaction).rent_collector

  close_settings_transaction_ix = Composers::SquadsSmartAccountsCloseSettingsTransactionComposer.new(
    settings:,
    proposal:,
    transaction:,
    proposal_rent_collector:,
    transaction_rent_collector:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(close_settings_transaction_ix)
end

#compose_close_transaction(settings:, transaction_index:, proposal_rent_collector: nil, transaction_rent_collector: nil) ⇒ TransactionComposer

Prepares a close-transaction transaction. The Proposal and vault Transaction PDAs are derived here; the rent collectors default to the on-chain stored values (the proposal’s and transaction’s collectors) when not supplied.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • transaction_index (Integer)

    Index of the vault transaction to close.

  • proposal_rent_collector (#to_s) (defaults to: nil)

    (Optional) Receives the proposal rent (defaults to the proposal’s stored rent collector).

  • transaction_rent_collector (#to_s) (defaults to: nil)

    (Optional) Receives the transaction rent (defaults to the transaction’s stored rent collector).

Returns:

  • (TransactionComposer)

    A composer with required instructions.



1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1653

def compose_close_transaction(
  settings:,
  transaction_index:,
  proposal_rent_collector: nil,
  transaction_rent_collector: nil
)
  transaction, = get_transaction_address(settings_address: settings.to_s, transaction_index:)
  proposal,    = get_proposal_address(settings_address: settings.to_s, transaction_index:)

  proposal_rent_collector    ||= get_proposal(proposal_address: proposal).rent_collector
  transaction_rent_collector ||= get_transaction(transaction_address: transaction).rent_collector

  close_transaction_ix = Composers::SquadsSmartAccountsCloseTransactionComposer.new(
    settings:,
    proposal:,
    transaction:,
    proposal_rent_collector:,
    transaction_rent_collector:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(close_transaction_ix)
end

#compose_create_proposal(settings:, creator:, rent_payer:, transaction_index:, draft: false) ⇒ TransactionComposer

Prepares a create-proposal transaction. The Proposal PDA is derived from the settings address and transaction index here.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • creator (#to_s, Keypair)

    A smart-account signer creating the proposal (must sign).

  • rent_payer (#to_s, Keypair)

    Funds the new account’s rent.

  • transaction_index (Integer)

    Index of the transaction this proposal tracks.

  • draft (Boolean) (defaults to: false)

    (Optional) Initialize as Draft instead of Active (default: false).

Returns:

  • (TransactionComposer)

    A composer with required instructions.



1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1260

def compose_create_proposal(
  settings:,
  creator:,
  rent_payer:,
  transaction_index:,
  draft: false
)
  proposal, = get_proposal_address(settings_address: settings.to_s, transaction_index:)

  create_proposal_ix = Composers::SquadsSmartAccountsCreateProposalComposer.new(
    settings:,
    proposal:,
    creator:,
    rent_payer:,
    transaction_index:,
    draft:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(create_proposal_ix)
end

#compose_create_settings_transaction(settings:, creator:, rent_payer:, actions:, memo: nil) ⇒ TransactionComposer

Prepares a create-settings-transaction transaction. The transaction index is the settings account’s current transaction_index + 1, and the SettingsTransaction PDA is derived from it here.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • creator (#to_s, Keypair)

    A signer creating the transaction (must sign).

  • rent_payer (#to_s, Keypair)

    Funds the new account’s rent.

  • actions (Array<SquadsSmartAccounts::SettingsAction>)

    Actions to store.

  • memo (String) (defaults to: nil)

    (Optional) Indexing memo.

Returns:

  • (TransactionComposer)

    A composer with required instructions.



1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1729

def compose_create_settings_transaction(
  settings:,
  creator:,
  rent_payer:,
  actions:,
  memo: nil
)
  transaction_index = get_settings(settings_address: settings.to_s).transaction_index + 1
  transaction,      = get_transaction_address(settings_address: settings.to_s, transaction_index:)

  create_settings_transaction_ix = Composers::SquadsSmartAccountsCreateSettingsTransactionComposer.new(
    settings:,
    transaction:,
    creator:,
    rent_payer:,
    actions:,
    memo:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(create_settings_transaction_ix)
end

#compose_create_smart_account(settings_seed:, creator:, threshold:, signers:, window: 1, time_lock: 0, settings_authority: nil, rent_collector: nil, memo: nil) ⇒ TransactionComposer

Prepares a new smart account transaction.

The settings PDA is derived from the given settings_seed, which the caller obtains via #next_settings_seed — keeping the seed explicit so clients can derive and persist the settings and vault addresses before sending the transaction.

With the default ‘window: 1` this offers a single settings PDA and is subject to the same races as #next_smart_account. Pass `window > 1` to offer a window of consecutive candidate PDAs (seeds `settings_seed .. settings_seed + window - 1`); the program initializes whichever matches the freshly incremented counter, so creation tolerates concurrent creations. The chosen address is then resolved via #get_created_smart_account_event.

Parameters:

  • settings_seed (Integer)

    The (starting) seed for the settings PDA (see #next_settings_seed).

  • creator (#to_s, Keypair)

    The account creating the smart account (must sign).

  • threshold (Integer)

    Number of approvals required to execute a transaction.

  • signers (Array<SquadsSmartAccounts::SmartAccountSigner>)

    Signers on the smart account.

  • window (Integer) (defaults to: 1)

    (Optional) Number of candidate PDAs to offer (default: 1).

  • time_lock (Integer) (defaults to: 0)

    (Optional) Seconds between proposal and execution (default: 0).

  • settings_authority (#to_s) (defaults to: nil)

    (Optional) Pubkey of the reconfiguration authority.

  • rent_collector (#to_s) (defaults to: nil)

    (Optional) Pubkey for reclaiming rent on closed accounts.

  • memo (String) (defaults to: nil)

    (Optional) Indexing memo.

Returns:

  • (TransactionComposer)

    A composer with required instructions.



384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 384

def (
  settings_seed:,
  creator:,
  threshold:,
  signers:,
  window: 1,
  time_lock: 0,
  settings_authority: nil,
  rent_collector: nil,
  memo: nil
)
  program_config = get_program_config

  settings = Array.new(window) do |offset|
    address, = get_settings_address(settings_seed: settings_seed + offset)
    address
  end

   = Composers::SquadsSmartAccountsCreateSmartAccountComposer.new(
    creator:,
    treasury:           program_config.treasury,
    settings:,
    threshold:,
    signers:,
    time_lock:,
    settings_authority:,
    rent_collector:,
    memo:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction()
end

#compose_create_transaction(settings:, creator:, rent_payer:, instructions:, account_index: 0, memo: nil) ⇒ TransactionComposer

Prepares a create-transaction transaction. The transaction index is the settings account’s current transaction_index + 1, and the Transaction PDA is derived from it here.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • creator (#to_s, Keypair)

    The transaction creator (must sign).

  • rent_payer (#to_s, Keypair)

    Funds the new account’s rent.

  • instructions (Array<Composers::Base>)

    Inner instruction composers.

  • account_index (Integer) (defaults to: 0)

    (Optional) Vault index (default: 0).

  • memo (String) (defaults to: nil)

    (Optional) Indexing memo.

Returns:

  • (TransactionComposer)

    A composer with required instructions.



1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1184

def compose_create_transaction(
  settings:,
  creator:,
  rent_payer:,
  instructions:,
  account_index: 0,
  memo: nil
)
  transaction_index = get_settings(settings_address: settings.to_s).transaction_index + 1
  transaction,      = get_transaction_address(settings_address: settings.to_s, transaction_index:)

  create_transaction_ix = Composers::SquadsSmartAccountsCreateTransactionComposer.new(
    settings:,
    transaction:,
    creator:,
    rent_payer:,
    instructions:,
    account_index:,
    memo:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(create_transaction_ix)
end

#compose_execute_settings_transaction(settings:, signer:, transaction_index:, rent_payer:, spending_limit_accounts: []) ⇒ TransactionComposer

Prepares an execute-settings-transaction transaction. The Proposal and SettingsTransaction PDAs are derived from the settings address and transaction index here.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • signer (#to_s, Keypair)

    The executing signer (must sign).

  • transaction_index (Integer)

    Index of the settings transaction to apply.

  • rent_payer (#to_s, Keypair)

    Pays for any settings realloc (must sign).

  • spending_limit_accounts (Array<#to_s>) (defaults to: [])

    (Optional) SpendingLimit PDAs touched by the actions, in action order.

Returns:

  • (TransactionComposer)

    A composer with required instructions.



1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1797

def compose_execute_settings_transaction(
  settings:,
  signer:,
  transaction_index:,
  rent_payer:,
  spending_limit_accounts: []
)
  transaction, = get_transaction_address(settings_address: settings.to_s, transaction_index:)
  proposal,    = get_proposal_address(settings_address: settings.to_s, transaction_index:)

  execute_settings_transaction_ix = Composers::SquadsSmartAccountsExecuteSettingsTransactionComposer.new(
    settings:,
    signer:,
    proposal:,
    transaction:,
    rent_payer:,
    spending_limit_accounts:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(execute_settings_transaction_ix)
end

#compose_execute_settings_transaction_sync(settings:, signers:, actions:, rent_payer:, spending_limit_accounts: [], memo: nil) ⇒ TransactionComposer

Prepares a synchronous settings transaction.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • signers (Array<#to_s, Keypair>)

    Co-signers proving threshold consensus.

  • actions (Array<SquadsSmartAccounts::SettingsAction>)

    Actions applied atomically.

  • rent_payer (#to_s, Keypair)

    Pays for settings reallocation.

  • spending_limit_accounts (Array<#to_s>) (defaults to: [])

    (Optional) SpendingLimit PDAs initialized or closed by spending-limit actions, in action order.

  • memo (String) (defaults to: nil)

    (Optional) Indexing memo.

Returns:

  • (TransactionComposer)

    A composer with required instructions.



859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 859

def compose_execute_settings_transaction_sync(
  settings:,
  signers:,
  actions:,
  rent_payer:,
  spending_limit_accounts: [],
  memo: nil
)
  settings_sync_ix = Composers::SquadsSmartAccountsExecuteSettingsTransactionSyncComposer.new(
    settings:,
    signers:,
    actions:,
    rent_payer:,
    spending_limit_accounts:,
    memo:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(settings_sync_ix)
end

#compose_execute_transaction(settings:, signer:, transaction_index:) ⇒ TransactionComposer

Prepares an execute-transaction transaction. Fetches the stored Transaction to derive its vault and replay its account metas as the instruction’s remaining accounts; the Transaction and Proposal PDAs are derived from the settings address and transaction index here.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • signer (#to_s, Keypair)

    The executing signer (must sign).

  • transaction_index (Integer)

    Index of the transaction to execute.

Returns:

  • (TransactionComposer)

    A composer with required instructions.



1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1579

def compose_execute_transaction(
  settings:,
  signer:,
  transaction_index:
)
  transaction_address, = get_transaction_address(settings_address: settings.to_s, transaction_index:)
  proposal_address,    = get_proposal_address(settings_address: settings.to_s, transaction_index:)

  transaction = get_transaction(transaction_address:)

  , = (
    settings_address: settings.to_s,
    account_index:    transaction.
  )

  execute_transaction_ix = Composers::SquadsSmartAccountsExecuteTransactionComposer.new(
    settings:,
    proposal:      proposal_address,
    transaction:   transaction_address,
    signer:,
    smart_account:,
    account_metas: transaction.
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(execute_transaction_ix)
end

#compose_execute_transaction_sync(settings:, smart_account:, signers:, instructions:, account_index: 0) ⇒ TransactionComposer

Prepares a synchronous transaction execution.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • smart_account (#to_s)

    Base58 address of the vault PDA the inner instructions spend from.

  • signers (Array<#to_s, Keypair>)

    Co-signers proving threshold consensus.

  • instructions (Array<Composers::Base>)

    Inner instruction composers.

  • account_index (Integer) (defaults to: 0)

    (Optional) Vault index (default: 0).

Returns:

  • (TransactionComposer)

    A composer with required instructions.



475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 475

def compose_execute_transaction_sync(
  settings:,
  smart_account:,
  signers:,
  instructions:,
  account_index: 0
)
  execute_transaction_sync_ix = Composers::SquadsSmartAccountsExecuteTransactionSyncComposer.new(
    settings:,
    smart_account:,
    signers:,
    instructions:,
    account_index:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(execute_transaction_sync_ix)
end

#compose_reject_proposal(settings:, signer:, transaction_index:, memo: nil) ⇒ TransactionComposer

Prepares a reject-proposal transaction. The Proposal PDA is derived from the settings address and transaction index here.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • signer (#to_s, Keypair)

    The voting signer (must sign).

  • transaction_index (Integer)

    Index of the transaction the proposal tracks.

  • memo (String) (defaults to: nil)

    (Optional) Indexing memo.

Returns:

  • (TransactionComposer)

    A composer with required instructions.



1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1391

def compose_reject_proposal(
  settings:,
  signer:,
  transaction_index:,
  memo: nil
)
  proposal, = get_proposal_address(settings_address: settings.to_s, transaction_index:)

  reject_proposal_ix = Composers::SquadsSmartAccountsRejectProposalComposer.new(
    settings:,
    signer:,
    proposal:,
    memo:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(reject_proposal_ix)
end

#compose_remove_signer_as_authority(settings:, settings_authority:, rent_payer:, old_signer:, memo: nil) ⇒ TransactionComposer

Prepares a remove-signer-as-authority transaction.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • settings_authority (#to_s, Keypair)

    The account’s settings authority.

  • rent_payer (#to_s, Keypair)

    Pays for settings account reallocation.

  • old_signer (#to_s)

    Base58 pubkey of the signer to remove.

  • memo (String) (defaults to: nil)

    (Optional) Indexing memo.

Returns:

  • (TransactionComposer)

    A composer with required instructions.



602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 602

def compose_remove_signer_as_authority(
  settings:,
  settings_authority:,
  rent_payer:,
  old_signer:,
  memo: nil
)
  remove_signer_ix = Composers::SquadsSmartAccountsRemoveSignerAsAuthorityComposer.new(
    settings:,
    settings_authority:,
    rent_payer:,
    old_signer:,
    memo:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(remove_signer_ix)
end

#compose_remove_spending_limit_as_authority(settings:, settings_authority:, spending_limit:, rent_collector:, memo: nil) ⇒ TransactionComposer

Prepares a remove-spending-limit-as-authority transaction.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • settings_authority (#to_s, Keypair)

    The account’s settings authority.

  • spending_limit (#to_s)

    The SpendingLimit PDA to close.

  • rent_collector (#to_s)

    Receives the closed account’s rent (does not sign).

  • memo (String) (defaults to: nil)

    (Optional) Indexing memo.

Returns:

  • (TransactionComposer)

    A composer with required instructions.



1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1108

def compose_remove_spending_limit_as_authority(
  settings:,
  settings_authority:,
  spending_limit:,
  rent_collector:,
  memo: nil
)
  remove_spending_limit_ix = Composers::SquadsSmartAccountsRemoveSpendingLimitAsAuthorityComposer.new(
    settings:,
    settings_authority:,
    spending_limit:,
    rent_collector:,
    memo:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(remove_spending_limit_ix)
end

#compose_set_new_settings_authority_as_authority(settings:, settings_authority:, rent_payer:, new_settings_authority:, memo: nil) ⇒ TransactionComposer

Prepares a set-new-settings-authority-as-authority transaction.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • settings_authority (#to_s, Keypair)

    The current settings authority.

  • rent_payer (#to_s, Keypair)

    Pays for settings account reallocation.

  • new_settings_authority (#to_s, nil)

    Base58 pubkey of the new settings authority, or nil to renounce control — stores Pubkey::default(), permanently converting the account to autonomous.

  • memo (String) (defaults to: nil)

    (Optional) Indexing memo.

Returns:

  • (TransactionComposer)

    A composer with required instructions.



781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 781

def compose_set_new_settings_authority_as_authority(
  settings:,
  settings_authority:,
  rent_payer:,
  new_settings_authority:,
  memo: nil
)
  set_new_authority_ix = Composers::SquadsSmartAccountsSetNewSettingsAuthorityAsAuthorityComposer.new(
    settings:,
    settings_authority:,
    rent_payer:,
    new_settings_authority:,
    memo:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(set_new_authority_ix)
end

#compose_set_time_lock_as_authority(settings:, settings_authority:, rent_payer:, time_lock:, memo: nil) ⇒ TransactionComposer

Prepares a set-time-lock-as-authority transaction.

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • settings_authority (#to_s, Keypair)

    The account’s settings authority.

  • rent_payer (#to_s, Keypair)

    Pays for settings account reallocation.

  • time_lock (Integer)

    Seconds between approval and execution.

  • memo (String) (defaults to: nil)

    (Optional) Indexing memo.

Returns:

  • (TransactionComposer)

    A composer with required instructions.



720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 720

def compose_set_time_lock_as_authority(
  settings:,
  settings_authority:,
  rent_payer:,
  time_lock:,
  memo: nil
)
  set_time_lock_ix = Composers::SquadsSmartAccountsSetTimeLockAsAuthorityComposer.new(
    settings:,
    settings_authority:,
    rent_payer:,
    time_lock:,
    memo:
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(set_time_lock_ix)
end

#compose_use_spending_limit(settings:, signer:, spending_limit:, smart_account:, destination:, amount:, decimals: 9, mint: nil, token_program: nil, memo: nil) ⇒ TransactionComposer

Prepares a use-spending-limit transaction.

For SOL limits, omit :mint. For SPL Token / Token-2022 limits, pass :mint and :token_program; the vault and destination ATAs are derived here from those plus :smart_account and :destination (the owners). The destination ATA must already exist on-chain — this method does not create it. Pass :decimals matching the mint (9 for SOL).

Parameters:

  • settings (#to_s)

    Base58 address of the settings account.

  • signer (#to_s, Keypair)

    An allowed signer of the spending limit.

  • spending_limit (#to_s)

    The SpendingLimit PDA to spend against.

  • smart_account (#to_s)

    The vault to transfer from.

  • destination (#to_s)

    The destination owner (receives SOL, or owns the destination ATA).

  • amount (Integer)

    Amount to transfer (mint decimals).

  • decimals (Integer) (defaults to: 9)

    (Optional) Mint decimals, 9 for SOL (default: 9).

  • mint (#to_s) (defaults to: nil)

    (Optional) Token mint; omit for SOL limits.

  • token_program (#to_s) (defaults to: nil)

    (Optional) Program owning the mint; required with :mint.

  • memo (String) (defaults to: nil)

    (Optional) Indexing memo.

Returns:

  • (TransactionComposer)

    A composer with required instructions.



1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1031

def compose_use_spending_limit(
  settings:,
  signer:,
  spending_limit:,
  smart_account:,
  destination:,
  amount:,
  decimals: 9,
  mint: nil,
  token_program: nil,
  memo: nil
)
  use_spending_limit_ix = Composers::SquadsSmartAccountsUseSpendingLimitComposer.new(
    settings:,
    signer:,
    spending_limit:,
    smart_account:,
    destination:,
    amount:,
    decimals:,
    mint:,
    token_program:,
    memo:,
    # Additional options are required when the non SOL tokens are being spent
    **(
      smart_account:,
      destination:,
      mint:,
      token_program:
    )
  )

  TransactionComposer
    .new(connection:)
    .add_instruction(use_spending_limit_ix)
end

#create_proposal(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Creates a proposal for a stored transaction, signs it, and (optionally) sends it. A proposal created with the default ‘draft: false` starts Active (ready to vote); `draft: true` starts Draft and must be activated.

Examples:

Open voting on the transaction just created

tx = program.create_proposal(
  payer: creator,
  settings: identity.settings_address,
  creator: creator,
  rent_payer: creator,
  transaction_index: 1
)

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1228

def create_proposal(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_create_proposal(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, composer_opts[:creator], composer_opts[:rent_payer])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#create_settings_transaction(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Creates a settings transaction (a stored batch of SettingsActions) on an autonomous smart account, signs it, and (optionally) sends it. The transaction is stored, not applied — it awaits a proposal and approvals.

Examples:

Store a “raise the threshold” settings change for later approval

tx = program.create_settings_transaction(
  payer: creator,
  settings: identity.settings_address,
  creator: creator,
  rent_payer: creator,
  actions: [SettingsAction.change_threshold(2)]
)

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1696

def create_settings_transaction(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_create_settings_transaction(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, composer_opts[:creator], composer_opts[:rent_payer])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#create_smart_account(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Creates a new smart account, signs it, and (optionally) sends it.

Examples:

Create a smart account, retaining the values to index

identity = program.

tx = program.(
  payer: creator,
  settings_seed: identity.settings_seed,
  creator: creator,
  threshold: 1,
  signers: [SmartAccountSigner.new(pubkey: creator.address, permission: Permissions::ALL)]
)

Parameters:

  • payer (Keypair)

    The keypair that will pay for fees, rent, and the creation fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 337

def (
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = (**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, composer_opts[:creator])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#create_transaction(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Creates a pending vault transaction from inner instructions, signs it, and (optionally) sends it. The transaction is stored, not executed — it awaits a proposal and approvals (see the proposal flow).

Examples:

Store a vault → recipient transfer for later approval

tx = program.create_transaction(
  payer: creator,
  settings: identity.settings_address,
  creator: creator,
  rent_payer: creator,
  instructions: [
    Solace::Composers::SystemProgramTransferComposer.new(
      from: identity., to: recipient, lamports: 1_000_000
    )
  ]
)

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1150

def create_transaction(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_create_transaction(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, composer_opts[:creator], composer_opts[:rent_payer])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#execute_settings_transaction(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Applies an Approved proposal’s stored settings transaction, signs it, and (optionally) sends it. The signer must be a smart-account member with the Execute permission, and the proposal must be Approved with its time lock elapsed.

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1763

def execute_settings_transaction(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_execute_settings_transaction(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, composer_opts[:signer], composer_opts[:rent_payer])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#execute_settings_transaction_sync(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Synchronously applies a batch of SettingsActions to an autonomous smart account, signs with all co-signers, and (optionally) sends it.

The transaction must carry enough co-signer signatures to reach the settings threshold, so :signers must be Keypairs when sign is true. Controlled accounts are rejected by the program — use the *AsAuthority methods instead.

Examples:

Atomically add a signer and raise the threshold (1-of-1 account)

tx = program.execute_settings_transaction_sync(
  payer: creator,
  settings: identity.settings_address,
  signers: [creator],
  rent_payer: creator,
  actions: [
    SettingsAction.add_signer(pubkey: new_key, permission: Permissions::ALL),
    SettingsAction.change_threshold(2)
  ]
)

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 826

def execute_settings_transaction_sync(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_execute_settings_transaction_sync(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, *composer_opts[:signers], composer_opts[:rent_payer])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#execute_transaction(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Executes an Approved proposal’s stored transaction, signs it, and (optionally) sends it — moving the vault funds. The signer must be a smart-account member with the Execute permission, and the proposal must be Approved with its time lock elapsed.

Examples:

Execute the approved transaction at index 1

tx = program.execute_transaction(
  payer: creator,
  settings: identity.settings_address,
  signer: creator,
  transaction_index: 1
)

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1547

def execute_transaction(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_execute_transaction(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, composer_opts[:signer])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#execute_transaction_sync(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Synchronously executes inner instructions signed by a smart account (vault) PDA, signs with all co-signers, and (optionally) sends it.

The transaction must carry enough co-signer signatures to reach the settings threshold, so :signers must be Keypairs when sign is true.

Examples:

Transfer SOL out of a vault (1-of-1 smart account)

tx = program.execute_transaction_sync(
  payer: creator,
  settings: identity.settings_address,
  smart_account: identity.,
  signers: [creator],
  instructions: [
    Solace::Composers::SystemProgramTransferComposer.new(
      from: identity., to: recipient, lamports: 1_000_000
    )
  ]
)

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 443

def execute_transaction_sync(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_execute_transaction_sync(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, *composer_opts[:signers])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#get_created_smart_account_event(signature:) ⇒ SquadsSmartAccounts::CreateSmartAccountEvent

Fetches a confirmed createSmartAccount transaction and deserializes the CreateSmartAccountEvent it emitted, revealing the settings address the program actually created.

This is how a windowed creation (see #compose_create_smart_account with ‘window > 1`) learns which candidate won: the program picks one of the offered PDAs, observable only after the transaction lands. Match the returned `new_settings_pubkey` against your #next_smart_account_candidates to recover the seed and vault.

Parameters:

  • signature (String)

    Signature of the confirmed createSmartAccount transaction.

Returns:

Raises:

  • (RuntimeError)

    If the transaction is missing or carries no logEvent.



252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 252

def (signature:)
  transaction = connection.get_transaction(
    signature,
    commitment:                     'confirmed',
    encoding:                       'json',
    maxSupportedTransactionVersion: 0
  )
  raise "Transaction not found for signature #{signature}" unless transaction

  io = log_event_stream(transaction)
  raise "No logEvent inner instruction found in transaction #{signature}" unless io

  args = Solace::SquadsSmartAccounts::LogEventArgsV2.deserialize(io)

  Solace::SquadsSmartAccounts::CreateSmartAccountEvent.deserialize(StringIO.new(args.event))
end

#get_program_configSquadsSmartAccounts::ProgramConfig

Fetches and deserializes the global ProgramConfig account from the chain.

Returns:

Raises:

  • (RuntimeError)

    If the account does not exist at the expected address.



216
217
218
219
220
221
222
223
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 216

def get_program_config
   = connection.(Solace::SquadsSmartAccounts::PROGRAM_CONFIG_ADDRESS)
  raise 'ProgramConfig account not found — has the validator been bootstrapped?' unless 

  Solace::SquadsSmartAccounts::ProgramConfig.deserialize(
    Solace::Utils::Codecs.base64_to_bytestream(['data'][0])
  )
end

#get_proposal(proposal_address:) ⇒ SquadsSmartAccounts::Proposal

Fetches and deserializes a Proposal account from the chain.

Parameters:

  • proposal_address (#to_s)

    Base58 address of the proposal account.

Returns:

Raises:

  • (RuntimeError)

    If the account does not exist at the given address.



203
204
205
206
207
208
209
210
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 203

def get_proposal(proposal_address:)
   = connection.(proposal_address.to_s)
  raise "Proposal account not found at #{proposal_address}" unless 

  Solace::SquadsSmartAccounts::Proposal.deserialize(
    Solace::Utils::Codecs.base64_to_bytestream(['data'][0])
  )
end

#get_proposal_address(**options) ⇒ Array<String, Integer>

Alias method for get_proposal_address

Parameters:

  • options (Hash)

    A hash of options for the get_proposal_address class method

Returns:

  • (Array<String, Integer>)

    The proposal address and bump seed.



152
153
154
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 152

def get_proposal_address(**options)
  self.class.get_proposal_address(**options)
end

#get_settings(settings_address:) ⇒ SquadsSmartAccounts::Settings

Fetches and deserializes a Settings account from the chain.

Parameters:

  • settings_address (String)

    Base58 address of the settings account.

Returns:

Raises:

  • (RuntimeError)

    If the account does not exist at the given address.



230
231
232
233
234
235
236
237
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 230

def get_settings(settings_address:)
   = connection.(settings_address)
  raise "Settings account not found at #{settings_address}" unless 

  Solace::SquadsSmartAccounts::Settings.deserialize(
    Solace::Utils::Codecs.base64_to_bytestream(['data'][0])
  )
end

#get_settings_address(**options) ⇒ Array<String, Integer>

Alias method for get_settings_address

Parameters:

  • options (Hash)

    A hash of options for the get_settings_address class method

Returns:

  • (Array<String, Integer>)

    The settings address and bump seed.



120
121
122
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 120

def get_settings_address(**options)
  self.class.get_settings_address(**options)
end

#get_settings_transaction(transaction_address:) ⇒ SquadsSmartAccounts::SettingsTransaction

Fetches and deserializes a SettingsTransaction account from the chain.

Parameters:

  • transaction_address (#to_s)

    Base58 address of the settings transaction account.

Returns:

Raises:

  • (RuntimeError)

    If the account does not exist at the given address.



189
190
191
192
193
194
195
196
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 189

def get_settings_transaction(transaction_address:)
   = connection.(transaction_address.to_s)
  raise "SettingsTransaction account not found at #{transaction_address}" unless 

  Solace::SquadsSmartAccounts::SettingsTransaction.deserialize(
    Solace::Utils::Codecs.base64_to_bytestream(['data'][0])
  )
end

#get_smart_account_address(**options) ⇒ Array<String, Integer>

Alias method for get_smart_account_address

Parameters:

  • options (Hash)

    A hash of options for the get_smart_account_address class method

Returns:

  • (Array<String, Integer>)

    The vault address and bump seed.



128
129
130
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 128

def (**options)
  self.class.(**options)
end

#get_spending_limit(spending_limit_address:) ⇒ SquadsSmartAccounts::SpendingLimit

Fetches and deserializes a SpendingLimit account from the chain.

Parameters:

  • spending_limit_address (#to_s)

    Base58 address of the spending limit account.

Returns:

Raises:

  • (RuntimeError)

    If the account does not exist at the given address.



161
162
163
164
165
166
167
168
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 161

def get_spending_limit(spending_limit_address:)
   = connection.(spending_limit_address.to_s)
  raise "SpendingLimit account not found at #{spending_limit_address}" unless 

  Solace::SquadsSmartAccounts::SpendingLimit.deserialize(
    Solace::Utils::Codecs.base64_to_bytestream(['data'][0])
  )
end

#get_spending_limit_address(**options) ⇒ Array<String, Integer>

Alias method for get_spending_limit_address

Parameters:

  • options (Hash)

    A hash of options for the get_spending_limit_address class method

Returns:

  • (Array<String, Integer>)

    The spending limit address and bump seed.



136
137
138
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 136

def get_spending_limit_address(**options)
  self.class.get_spending_limit_address(**options)
end

#get_transaction(transaction_address:) ⇒ SquadsSmartAccounts::Transaction

Fetches and deserializes a Transaction account from the chain.

Parameters:

  • transaction_address (#to_s)

    Base58 address of the transaction account.

Returns:

Raises:

  • (RuntimeError)

    If the account does not exist at the given address.



175
176
177
178
179
180
181
182
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 175

def get_transaction(transaction_address:)
   = connection.(transaction_address.to_s)
  raise "Transaction account not found at #{transaction_address}" unless 

  Solace::SquadsSmartAccounts::Transaction.deserialize(
    Solace::Utils::Codecs.base64_to_bytestream(['data'][0])
  )
end

#get_transaction_address(**options) ⇒ Array<String, Integer>

Alias method for get_transaction_address

Parameters:

  • options (Hash)

    A hash of options for the get_transaction_address class method

Returns:

  • (Array<String, Integer>)

    The transaction address and bump seed.



144
145
146
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 144

def get_transaction_address(**options)
  self.class.get_transaction_address(**options)
end

#next_smart_accountSquadsSmartAccounts::SmartAccountIdentity

Gets the full deterministic identity of the next smart account to be created: the settings seed, settings address, and default vault address.

This is the one-stop call for clients — persist all three values, then pass the settings_seed to #create_smart_account. Subject to races if other smart accounts are created between this call and execution — the transaction fails in that case rather than creating an account at an unexpected address.

Returns:



279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 279

def 
  settings_seed = get_program_config. + 1

  settings_address,      = get_settings_address(settings_seed:)
  , = (settings_address:)

  Solace::SquadsSmartAccounts::SmartAccountIdentity.new(
    settings_seed:,
    settings_address:,
    smart_account_address:
  )
end

#next_smart_account_candidates(count: DEFAULT_CREATION_WINDOW) ⇒ Array<SquadsSmartAccounts::SmartAccountIdentity>

Gets a window of candidate identities for race-free creation: the next ‘count` consecutive smart accounts (seeds `index+1 .. index+count`).

Pass the candidates’ settings addresses to #create_smart_account_windowed, which offers them all and lets the program pick whichever matches the freshly incremented counter — so creation succeeds even if other accounts are created concurrently, as long as the true index lands in the window.

Parameters:

  • count (Integer) (defaults to: DEFAULT_CREATION_WINDOW)

    Size of the candidate window (default: DEFAULT_CREATION_WINDOW).

Returns:



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 302

def (count: DEFAULT_CREATION_WINDOW)
  start_seed = get_program_config. + 1

  Array.new(count) do |offset|
    settings_seed = start_seed + offset

    settings_address,      = get_settings_address(settings_seed:)
    , = (settings_address:)

    Solace::SquadsSmartAccounts::SmartAccountIdentity.new(
      settings_seed:,
      settings_address:,
      smart_account_address:
    )
  end
end

#reject_proposal(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Rejects a proposal on behalf of a signer, signs it, and (optionally) sends it. The signer must be a smart-account member with the Vote permission; the proposal becomes Rejected once rejections reach the cutoff.

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1360

def reject_proposal(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_reject_proposal(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, composer_opts[:signer])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#remove_signer_as_authority(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Removes a signer from a controlled smart account, signs with the settings authority, and (optionally) sends it.

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 571

def remove_signer_as_authority(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_remove_signer_as_authority(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, composer_opts[:settings_authority], composer_opts[:rent_payer])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#remove_spending_limit_as_authority(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Removes a spending limit from a controlled smart account, signs with the settings authority, and (optionally) sends it. The closed account’s rent is refunded to the rent collector.

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1077

def remove_spending_limit_as_authority(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_remove_spending_limit_as_authority(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, composer_opts[:settings_authority])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#set_new_settings_authority_as_authority(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Hands the settings authority of a controlled smart account to a new key, signs with the current settings authority, and (optionally) sends it.

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 748

def set_new_settings_authority_as_authority(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_set_new_settings_authority_as_authority(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, composer_opts[:settings_authority], composer_opts[:rent_payer])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#set_time_lock_as_authority(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Sets the time lock of a controlled smart account, signs with the settings authority, and (optionally) sends it.

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 689

def set_time_lock_as_authority(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_set_time_lock_as_authority(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, composer_opts[:settings_authority], composer_opts[:rent_payer])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end

#use_spending_limit(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction

Transfers SOL from a vault within a pre-authorized spending limit, signs with the allowed signer, and (optionally) sends it.

Parameters:

  • payer (Keypair)

    The keypair that will pay the transaction fee.

  • sign (Boolean) (defaults to: true)

    Whether to sign the transaction.

  • execute (Boolean) (defaults to: true)

    Whether to execute the transaction.

  • composer_opts (Hash)

Yields:

  • (composer)

Returns:

  • (Transaction)

    The created or sent transaction.



989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 989

def use_spending_limit(
  payer:,
  sign: true,
  execute: true,
  **composer_opts
)
  composer = compose_use_spending_limit(**composer_opts)

  yield composer if block_given?

  tx = composer
       .set_fee_payer(payer)
       .compose_transaction

  if sign
    tx.sign(payer, composer_opts[:signer])

    connection.send_transaction(tx.serialize) if execute
  end

  tx
end