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.
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:, 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_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.
-
#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.
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”].
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()].
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()].
44 45 46 47 48 49 |
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 44 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.
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)].
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`.
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.
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 ( 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.
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 ( 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.
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.
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.
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 ( 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.
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.
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.
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.
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 ( 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.
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 ( 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.
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.
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.
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 ( 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.
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.
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.
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.
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.
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 compose_create_smart_account( 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:) create_smart_account_ix = 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(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.
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.
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.
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.
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:) 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.
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.
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.
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 ( 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.
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 ( 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.
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 ( 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.
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 ( 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).
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.
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.
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.
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 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).
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.
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.
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.
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.
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_config ⇒ SquadsSmartAccounts::ProgramConfig
Fetches and deserializes the global ProgramConfig account from the chain.
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 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.
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:) 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
145 146 147 |
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 145 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.
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:) 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
113 114 115 |
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 113 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.
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:) 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
121 122 123 |
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 121 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.
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:) 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
129 130 131 |
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 129 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.
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:) 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
137 138 139 |
# File 'lib/solace/squads_smart_accounts/programs/squads_smart_account.rb', line 137 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.
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 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 |
#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.
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.
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 ( 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.
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 ( 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.
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 ( 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.
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 ( 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.
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 |