Class: Solace::Programs::SquadsSmartAccount
- Inherits:
-
Base
- Object
- Base
- Solace::Programs::SquadsSmartAccount
- 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.
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
-
.get_proposal_address(settings_address:, transaction_index:) ⇒ Array<String, Integer>
Gets the address of a Proposal PDA.
-
.get_settings_address(settings_seed:) ⇒ Array<String, Integer>
Gets the address of the settings PDA for a given settings seed.
-
.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.
-
.get_spending_limit_address(settings_address:, seed:) ⇒ Array<String, Integer>
Gets the address of a SpendingLimit PDA.
-
.get_transaction_address(settings_address:, transaction_index:) ⇒ Array<String, Integer>
Gets the address of a Transaction PDA.
Instance Method Summary collapse
-
#activate_proposal(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction
Activates a draft proposal (Draft → Active), signs it, and (optionally) sends it.
-
#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.
-
#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.
-
#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.
-
#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.
-
#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.
-
#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.
-
#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.
-
#compose_activate_proposal(settings:, signer:, transaction_index:) ⇒ TransactionComposer
Prepares an activate-proposal transaction.
-
#compose_add_signer_as_authority(settings:, settings_authority:, rent_payer:, new_signer:, memo: nil) ⇒ TransactionComposer
Prepares an add-signer-as-authority transaction.
-
#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.
-
#compose_approve_proposal(settings:, signer:, transaction_index:, memo: nil) ⇒ TransactionComposer
Prepares an approve-proposal transaction.
-
#compose_cancel_proposal(settings:, signer:, transaction_index:, memo: nil) ⇒ TransactionComposer
Prepares a cancel-proposal transaction.
-
#compose_change_threshold_as_authority(settings:, settings_authority:, rent_payer:, new_threshold:, memo: nil) ⇒ TransactionComposer
Prepares a change-threshold-as-authority transaction.
-
#compose_close_settings_transaction(settings:, transaction_index:, proposal_rent_collector: nil, transaction_rent_collector: nil) ⇒ TransactionComposer
Prepares a close-settings-transaction transaction.
-
#compose_close_transaction(settings:, transaction_index:, proposal_rent_collector: nil, transaction_rent_collector: nil) ⇒ TransactionComposer
Prepares a close-transaction transaction.
-
#compose_create_proposal(settings:, creator:, rent_payer:, transaction_index:, draft: false) ⇒ TransactionComposer
Prepares a create-proposal transaction.
-
#compose_create_settings_transaction(settings:, creator:, rent_payer:, actions:, memo: nil) ⇒ TransactionComposer
Prepares a create-settings-transaction transaction.
-
#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.
-
#compose_create_transaction(settings:, creator:, rent_payer:, instructions:, account_index: 0, memo: nil) ⇒ TransactionComposer
Prepares a create-transaction transaction.
-
#compose_execute_settings_transaction(settings:, signer:, transaction_index:, rent_payer:, spending_limit_accounts: []) ⇒ TransactionComposer
Prepares an execute-settings-transaction transaction.
-
#compose_execute_settings_transaction_sync(settings:, signers:, actions:, rent_payer:, spending_limit_accounts: [], memo: nil) ⇒ TransactionComposer
Prepares a synchronous settings transaction.
-
#compose_execute_transaction(settings:, signer:, transaction_index:) ⇒ TransactionComposer
Prepares an execute-transaction transaction.
-
#compose_execute_transaction_sync(settings:, smart_account:, signers:, instructions:, account_index: 0) ⇒ TransactionComposer
Prepares a synchronous transaction execution.
-
#compose_reject_proposal(settings:, signer:, transaction_index:, memo: nil) ⇒ TransactionComposer
Prepares a reject-proposal transaction.
-
#compose_remove_signer_as_authority(settings:, settings_authority:, rent_payer:, old_signer:, memo: nil) ⇒ TransactionComposer
Prepares a remove-signer-as-authority transaction.
-
#compose_remove_spending_limit_as_authority(settings:, settings_authority:, spending_limit:, rent_collector:, memo: nil) ⇒ TransactionComposer
Prepares a remove-spending-limit-as-authority transaction.
-
#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.
-
#compose_set_time_lock_as_authority(settings:, settings_authority:, rent_payer:, time_lock:, memo: nil) ⇒ TransactionComposer
Prepares a set-time-lock-as-authority transaction.
-
#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.
-
#create_proposal(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction
Creates a proposal for a stored transaction, signs it, and (optionally) sends it.
-
#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.
-
#create_smart_account(payer:, sign: true, execute: true, **composer_opts) {|composer| ... } ⇒ Transaction
Creates a new smart account, signs it, and (optionally) sends it.
-
#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.
-
#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.
-
#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.
-
#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.
-
#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.
-
#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.
-
#get_program_config ⇒ SquadsSmartAccounts::ProgramConfig
Fetches and deserializes the global ProgramConfig account from the chain.
-
#get_proposal(proposal_address:) ⇒ SquadsSmartAccounts::Proposal
Fetches and deserializes a Proposal account from the chain.
-
#get_proposal_address(**options) ⇒ Array<String, Integer>
Alias method for get_proposal_address.
-
#get_settings(settings_address:) ⇒ SquadsSmartAccounts::Settings
Fetches and deserializes a Settings account from the chain.
-
#get_settings_address(**options) ⇒ Array<String, Integer>
Alias method for get_settings_address.
-
#get_settings_transaction(transaction_address:) ⇒ SquadsSmartAccounts::SettingsTransaction
Fetches and deserializes a SettingsTransaction account from the chain.
-
#get_smart_account_address(**options) ⇒ Array<String, Integer>
Alias method for get_smart_account_address.
-
#get_spending_limit(spending_limit_address:) ⇒ SquadsSmartAccounts::SpendingLimit
Fetches and deserializes a SpendingLimit account from the chain.
-
#get_spending_limit_address(**options) ⇒ Array<String, Integer>
Alias method for get_spending_limit_address.
-
#get_transaction(transaction_address:) ⇒ SquadsSmartAccounts::Transaction
Fetches and deserializes a Transaction account from the chain.
-
#get_transaction_address(**options) ⇒ Array<String, Integer>
Alias method for get_transaction_address.
-
#initialize(connection:) ⇒ SquadsSmartAccount
constructor
Initializes a new Squads Smart Account client.
-
#next_smart_account ⇒ SquadsSmartAccounts::SmartAccountIdentity
Gets the full deterministic identity of the next smart account to be created: the settings seed, settings address, and default vault address.
-
#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`).
-
#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.
-
#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.
-
#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.
-
#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.
-
#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.
-
#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.
Constructor Details
#initialize(connection:) ⇒ SquadsSmartAccount
Initializes a new Squads Smart Account client.
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”].
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()].
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()].
51 52 53 54 55 56 |
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 51 def get_smart_account_address(settings_address:, account_index: 0) Solace::Utils::PDA.find_program_address( ['smart_account', settings_address.to_s, 'smart_account', [account_index]], 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.
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)].
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`.
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.
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 ( 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[: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.
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 ( 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[: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.
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.
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.
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 ( 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[: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.
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.
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.
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.
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 ( 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.
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 ( 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.
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.
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.
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 ( 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.
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.
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.
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.
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.
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 compose_create_smart_account( 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 create_smart_account_ix = Composers::SquadsSmartAccountsCreateSmartAccountComposer.new( creator:, treasury: program_config.treasury, settings:, threshold:, signers:, time_lock:, settings_authority:, rent_collector:, memo: ) TransactionComposer .new(connection:) .add_instruction(create_smart_account_ix) 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.
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.
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.
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.
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:) smart_account, = get_smart_account_address( settings_address: settings.to_s, account_index: transaction.account_index ) 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.
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.
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.
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 ( 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.
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 ( 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.
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 ( settings:, settings_authority:, rent_payer:, new_settings_authority:, memo: nil ) = Composers::SquadsSmartAccountsSetNewSettingsAuthorityAsAuthorityComposer.new( settings:, settings_authority:, rent_payer:, new_settings_authority:, memo: ) TransactionComposer .new(connection:) .add_instruction() 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.
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 ( 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).
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.
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.
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.
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 create_smart_account( payer:, sign: true, execute: true, **composer_opts ) composer = compose_create_smart_account(**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).
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.
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.
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.
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.
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.
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 get_created_smart_account_event(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_config ⇒ SquadsSmartAccounts::ProgramConfig
Fetches and deserializes the global ProgramConfig account from the chain.
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 account = connection.get_account_info(Solace::SquadsSmartAccounts::PROGRAM_CONFIG_ADDRESS) raise 'ProgramConfig account not found — has the validator been bootstrapped?' unless account Solace::SquadsSmartAccounts::ProgramConfig.deserialize( Solace::Utils::Codecs.base64_to_bytestream(account['data'][0]) ) end |
#get_proposal(proposal_address:) ⇒ SquadsSmartAccounts::Proposal
Fetches and deserializes a Proposal account from the chain.
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:) account = connection.get_account_info(proposal_address.to_s) raise "Proposal account not found at #{proposal_address}" unless account Solace::SquadsSmartAccounts::Proposal.deserialize( Solace::Utils::Codecs.base64_to_bytestream(account['data'][0]) ) end |
#get_proposal_address(**options) ⇒ Array<String, Integer>
Alias method for get_proposal_address
152 153 154 |
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 152 def get_proposal_address(**) self.class.get_proposal_address(**) end |
#get_settings(settings_address:) ⇒ SquadsSmartAccounts::Settings
Fetches and deserializes a Settings account from the chain.
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:) account = connection.get_account_info(settings_address) raise "Settings account not found at #{settings_address}" unless account Solace::SquadsSmartAccounts::Settings.deserialize( Solace::Utils::Codecs.base64_to_bytestream(account['data'][0]) ) end |
#get_settings_address(**options) ⇒ Array<String, Integer>
Alias method for get_settings_address
120 121 122 |
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 120 def get_settings_address(**) self.class.get_settings_address(**) end |
#get_settings_transaction(transaction_address:) ⇒ SquadsSmartAccounts::SettingsTransaction
Fetches and deserializes a SettingsTransaction account from the chain.
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:) account = connection.get_account_info(transaction_address.to_s) raise "SettingsTransaction account not found at #{transaction_address}" unless account Solace::SquadsSmartAccounts::SettingsTransaction.deserialize( Solace::Utils::Codecs.base64_to_bytestream(account['data'][0]) ) end |
#get_smart_account_address(**options) ⇒ Array<String, Integer>
Alias method for get_smart_account_address
128 129 130 |
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 128 def get_smart_account_address(**) self.class.get_smart_account_address(**) end |
#get_spending_limit(spending_limit_address:) ⇒ SquadsSmartAccounts::SpendingLimit
Fetches and deserializes a SpendingLimit account from the chain.
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:) account = connection.get_account_info(spending_limit_address.to_s) raise "SpendingLimit account not found at #{spending_limit_address}" unless account Solace::SquadsSmartAccounts::SpendingLimit.deserialize( Solace::Utils::Codecs.base64_to_bytestream(account['data'][0]) ) end |
#get_spending_limit_address(**options) ⇒ Array<String, Integer>
Alias method for get_spending_limit_address
136 137 138 |
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 136 def get_spending_limit_address(**) self.class.get_spending_limit_address(**) end |
#get_transaction(transaction_address:) ⇒ SquadsSmartAccounts::Transaction
Fetches and deserializes a Transaction account from the chain.
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:) account = connection.get_account_info(transaction_address.to_s) raise "Transaction account not found at #{transaction_address}" unless account Solace::SquadsSmartAccounts::Transaction.deserialize( Solace::Utils::Codecs.base64_to_bytestream(account['data'][0]) ) end |
#get_transaction_address(**options) ⇒ Array<String, Integer>
Alias method for get_transaction_address
144 145 146 |
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 144 def get_transaction_address(**) self.class.get_transaction_address(**) end |
#next_smart_account ⇒ SquadsSmartAccounts::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.
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 next_smart_account settings_seed = get_program_config.smart_account_index + 1 settings_address, = get_settings_address(settings_seed:) smart_account_address, = get_smart_account_address(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.
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 next_smart_account_candidates(count: DEFAULT_CREATION_WINDOW) start_seed = get_program_config.smart_account_index + 1 Array.new(count) do |offset| settings_seed = start_seed + offset settings_address, = get_settings_address(settings_seed:) smart_account_address, = get_smart_account_address(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.
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.
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 ( 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[: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.
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 ( 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[: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.
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 ( 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[: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.
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 ( 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[: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.
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 |