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:

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.



105
106
107
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 105

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.



93
94
95
96
97
98
99
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 93

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.



28
29
30
31
32
33
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 28

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.



44
45
46
47
48
49
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 44

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.



61
62
63
64
65
66
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 61

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.



76
77
78
79
80
81
82
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 76

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.



1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1405

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.



436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 436

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.



830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 830

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.



1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1224

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.



1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1345

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.



554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 554

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.



1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1754

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.



1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1542

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.



1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1435

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.



467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 467

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.



869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 869

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.



1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1255

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.



1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1376

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.



585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 585

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.



1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1789

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.



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

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.



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

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.



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

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:, 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.

Parameters:

  • settings_seed (Integer)

    The 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.

  • 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.



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 312

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

  settings_address, = get_settings_address(settings_seed:)

   = Composers::SquadsSmartAccountsCreateSmartAccountComposer.new(
    creator:,
    treasury:           program_config.treasury,
    settings:           settings_address,
    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.



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

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.



1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1721

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.



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

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.



1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1503

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.



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 399

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.



1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1315

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.



526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 526

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.



1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1032

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.



705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 705

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.



644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 644

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.



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
980
981
982
983
984
985
986
987
988
989
990
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 955

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.



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

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.



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

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.



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 273

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.



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

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.



1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1687

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.



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

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.



1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1471

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.



367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 367

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_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.



209
210
211
212
213
214
215
216
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 209

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.



196
197
198
199
200
201
202
203
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 196

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.



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

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.



223
224
225
226
227
228
229
230
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 223

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.



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

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.



182
183
184
185
186
187
188
189
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 182

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.



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

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.



154
155
156
157
158
159
160
161
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 154

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.



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

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.



168
169
170
171
172
173
174
175
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 168

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.



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

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:



242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 242

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

#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.



1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1284

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.



495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 495

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.



1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 1001

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.



672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 672

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.



613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 613

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.



913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 913

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