solace-squads-smart-accounts 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/solace/squads_smart_accounts/codecs_extensions.rb +259 -0
- data/lib/solace/squads_smart_accounts/composers/activate_proposal_composer.rb +69 -0
- data/lib/solace/squads_smart_accounts/composers/add_signer_as_authority_composer.rb +94 -0
- data/lib/solace/squads_smart_accounts/composers/add_spending_limit_as_authority_composer.rb +170 -0
- data/lib/solace/squads_smart_accounts/composers/approve_proposal_composer.rb +80 -0
- data/lib/solace/squads_smart_accounts/composers/cancel_proposal_composer.rb +86 -0
- data/lib/solace/squads_smart_accounts/composers/change_threshold_as_authority_composer.rb +94 -0
- data/lib/solace/squads_smart_accounts/composers/close_settings_transaction_composer.rb +98 -0
- data/lib/solace/squads_smart_accounts/composers/close_transaction_composer.rb +97 -0
- data/lib/solace/squads_smart_accounts/composers/create_proposal_composer.rb +104 -0
- data/lib/solace/squads_smart_accounts/composers/create_settings_transaction_composer.rb +105 -0
- data/lib/solace/squads_smart_accounts/composers/create_smart_account_composer.rb +142 -0
- data/lib/solace/squads_smart_accounts/composers/create_transaction_composer.rb +154 -0
- data/lib/solace/squads_smart_accounts/composers/execute_settings_transaction_composer.rb +112 -0
- data/lib/solace/squads_smart_accounts/composers/execute_settings_transaction_sync_composer.rb +114 -0
- data/lib/solace/squads_smart_accounts/composers/execute_transaction_composer.rb +122 -0
- data/lib/solace/squads_smart_accounts/composers/execute_transaction_sync_composer.rb +157 -0
- data/lib/solace/squads_smart_accounts/composers/reject_proposal_composer.rb +80 -0
- data/lib/solace/squads_smart_accounts/composers/remove_signer_as_authority_composer.rb +94 -0
- data/lib/solace/squads_smart_accounts/composers/remove_spending_limit_as_authority_composer.rb +88 -0
- data/lib/solace/squads_smart_accounts/composers/set_new_settings_authority_as_authority_composer.rb +100 -0
- data/lib/solace/squads_smart_accounts/composers/set_time_lock_as_authority_composer.rb +94 -0
- data/lib/solace/squads_smart_accounts/composers/use_spending_limit_composer.rb +203 -0
- data/lib/solace/squads_smart_accounts/constants.rb +27 -0
- data/lib/solace/squads_smart_accounts/idl/squads_smart_account_program.json +3966 -0
- data/lib/solace/squads_smart_accounts/instructions/activate_proposal_instruction.rb +60 -0
- data/lib/solace/squads_smart_accounts/instructions/add_signer_as_authority_instruction.rb +69 -0
- data/lib/solace/squads_smart_accounts/instructions/add_spending_limit_as_authority_instruction.rb +112 -0
- data/lib/solace/squads_smart_accounts/instructions/approve_proposal_instruction.rb +66 -0
- data/lib/solace/squads_smart_accounts/instructions/cancel_proposal_instruction.rb +67 -0
- data/lib/solace/squads_smart_accounts/instructions/change_threshold_as_authority_instruction.rb +66 -0
- data/lib/solace/squads_smart_accounts/instructions/close_settings_transaction_instruction.rb +71 -0
- data/lib/solace/squads_smart_accounts/instructions/close_transaction_instruction.rb +72 -0
- data/lib/solace/squads_smart_accounts/instructions/create_proposal_instruction.rb +78 -0
- data/lib/solace/squads_smart_accounts/instructions/create_settings_transaction_instruction.rb +78 -0
- data/lib/solace/squads_smart_accounts/instructions/create_smart_account_instruction.rb +96 -0
- data/lib/solace/squads_smart_accounts/instructions/create_transaction_instruction.rb +95 -0
- data/lib/solace/squads_smart_accounts/instructions/execute_settings_transaction_instruction.rb +79 -0
- data/lib/solace/squads_smart_accounts/instructions/execute_settings_transaction_sync_instruction.rb +78 -0
- data/lib/solace/squads_smart_accounts/instructions/execute_transaction_instruction.rb +71 -0
- data/lib/solace/squads_smart_accounts/instructions/execute_transaction_sync_instruction.rb +80 -0
- data/lib/solace/squads_smart_accounts/instructions/reject_proposal_instruction.rb +66 -0
- data/lib/solace/squads_smart_accounts/instructions/remove_signer_as_authority_instruction.rb +66 -0
- data/lib/solace/squads_smart_accounts/instructions/remove_spending_limit_as_authority_instruction.rb +62 -0
- data/lib/solace/squads_smart_accounts/instructions/set_new_settings_authority_as_authority_instruction.rb +66 -0
- data/lib/solace/squads_smart_accounts/instructions/set_time_lock_as_authority_instruction.rb +66 -0
- data/lib/solace/squads_smart_accounts/instructions/use_spending_limit_instruction.rb +96 -0
- data/lib/solace/squads_smart_accounts/programs/squads_smart_account.rb +1841 -0
- data/lib/solace/squads_smart_accounts/types/period.rb +24 -0
- data/lib/solace/squads_smart_accounts/types/permissions.rb +43 -0
- data/lib/solace/squads_smart_accounts/types/program_config.rb +36 -0
- data/lib/solace/squads_smart_accounts/types/proposal.rb +91 -0
- data/lib/solace/squads_smart_accounts/types/settings.rb +50 -0
- data/lib/solace/squads_smart_accounts/types/settings_action.rb +109 -0
- data/lib/solace/squads_smart_accounts/types/settings_transaction.rb +40 -0
- data/lib/solace/squads_smart_accounts/types/smart_account_identity.rb +20 -0
- data/lib/solace/squads_smart_accounts/types/smart_account_signer.rb +26 -0
- data/lib/solace/squads_smart_accounts/types/spending_limit.rb +52 -0
- data/lib/solace/squads_smart_accounts/types/transaction.rb +115 -0
- data/lib/solace/squads_smart_accounts/types/transaction_message.rb +41 -0
- data/lib/solace/squads_smart_accounts/vault_index.rb +113 -0
- data/lib/solace/squads_smart_accounts/version.rb +7 -0
- data/lib/solace/squads_smart_accounts.rb +29 -0
- metadata +210 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solace
|
|
4
|
+
module Composers
|
|
5
|
+
# Composes a `cancelProposal` instruction for the Squads Smart Account program.
|
|
6
|
+
#
|
|
7
|
+
# Casts a cancellation vote on an Approved proposal. The signer must be a
|
|
8
|
+
# smart account member with the Vote permission. Unlike approve/reject, the
|
|
9
|
+
# System program is a required account (it funds the proposal realloc).
|
|
10
|
+
#
|
|
11
|
+
# Required params:
|
|
12
|
+
# :settings [#to_s] Base58 address of the settings account.
|
|
13
|
+
# :signer [#to_s, Keypair] The voting signer (must sign).
|
|
14
|
+
# :proposal [#to_s] The Proposal PDA to cancel (must be Approved).
|
|
15
|
+
#
|
|
16
|
+
# Optional params:
|
|
17
|
+
# :memo [String] Indexing memo (default: nil).
|
|
18
|
+
class SquadsSmartAccountsCancelProposalComposer < Base
|
|
19
|
+
# Extracts the settings address from the params
|
|
20
|
+
#
|
|
21
|
+
# @return [String] The settings address
|
|
22
|
+
def settings
|
|
23
|
+
params[:settings].to_s
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Extracts the voting signer address from the params
|
|
27
|
+
#
|
|
28
|
+
# @return [String] The signer address
|
|
29
|
+
def signer
|
|
30
|
+
params[:signer].to_s
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Extracts the proposal PDA address from the params
|
|
34
|
+
#
|
|
35
|
+
# @return [String] The proposal address
|
|
36
|
+
def proposal
|
|
37
|
+
params[:proposal].to_s
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Extracts the memo from the params
|
|
41
|
+
#
|
|
42
|
+
# @return [String, nil] The memo
|
|
43
|
+
def memo
|
|
44
|
+
params[:memo]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Returns the Squads Smart Account program id from the constants
|
|
48
|
+
#
|
|
49
|
+
# @return [String] The Squads Smart Account program id
|
|
50
|
+
def program_id
|
|
51
|
+
SquadsSmartAccounts::PROGRAM_ID
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Returns the system program id from the constants
|
|
55
|
+
#
|
|
56
|
+
# @return [String] The system program id
|
|
57
|
+
def system_program
|
|
58
|
+
Solace::Constants::SYSTEM_PROGRAM_ID
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Declares all accounts required by this instruction.
|
|
62
|
+
def setup_accounts
|
|
63
|
+
account_context.add_readonly_nonsigner(settings)
|
|
64
|
+
account_context.add_writable_signer(signer)
|
|
65
|
+
account_context.add_writable_nonsigner(proposal)
|
|
66
|
+
account_context.add_readonly_nonsigner(system_program)
|
|
67
|
+
account_context.add_readonly_nonsigner(program_id)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Builds the instruction with resolved account indices.
|
|
71
|
+
#
|
|
72
|
+
# @param context [Solace::Utils::AccountContext] Merged context from TransactionComposer.
|
|
73
|
+
# @return [Solace::Instruction]
|
|
74
|
+
def build_instruction(context)
|
|
75
|
+
SquadsSmartAccounts::Instructions::CancelProposalInstruction.build(
|
|
76
|
+
memo:,
|
|
77
|
+
settings_index: context.index_of(settings),
|
|
78
|
+
signer_index: context.index_of(signer),
|
|
79
|
+
proposal_index: context.index_of(proposal),
|
|
80
|
+
system_program_index: context.index_of(system_program),
|
|
81
|
+
program_index: context.index_of(program_id)
|
|
82
|
+
)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solace
|
|
4
|
+
module Composers
|
|
5
|
+
# Composes a `changeThresholdAsAuthority` instruction for the Squads Smart Account program.
|
|
6
|
+
#
|
|
7
|
+
# Changes the approval threshold of a controlled smart account. Only the
|
|
8
|
+
# account's settings authority may do this — single signature, no consensus.
|
|
9
|
+
#
|
|
10
|
+
# Required params:
|
|
11
|
+
# :settings [String] Base58 address of the settings account.
|
|
12
|
+
# :settings_authority [#to_s, Keypair] The account's settings authority (must sign).
|
|
13
|
+
# :rent_payer [#to_s, Keypair] Pays for settings account reallocation (must sign).
|
|
14
|
+
# :new_threshold [Integer] The new approval threshold.
|
|
15
|
+
#
|
|
16
|
+
# Optional params:
|
|
17
|
+
# :memo [String] Indexing memo (default: nil).
|
|
18
|
+
class SquadsSmartAccountsChangeThresholdAsAuthorityComposer < Base
|
|
19
|
+
# Extracts the settings address from the params
|
|
20
|
+
#
|
|
21
|
+
# @return [String] The settings address
|
|
22
|
+
def settings
|
|
23
|
+
params[:settings].to_s
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Extracts the settings authority address from the params
|
|
27
|
+
#
|
|
28
|
+
# @return [String] The settings authority address
|
|
29
|
+
def settings_authority
|
|
30
|
+
params[:settings_authority].to_s
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Extracts the rent payer address from the params
|
|
34
|
+
#
|
|
35
|
+
# @return [String] The rent payer address
|
|
36
|
+
def rent_payer
|
|
37
|
+
params[:rent_payer].to_s
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Extracts the new threshold from the params
|
|
41
|
+
#
|
|
42
|
+
# @return [Integer] The new approval threshold
|
|
43
|
+
def new_threshold
|
|
44
|
+
params[:new_threshold]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Extracts the memo from the params
|
|
48
|
+
#
|
|
49
|
+
# @return [String, nil] The memo
|
|
50
|
+
def memo
|
|
51
|
+
params[:memo]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Returns the Squads Smart Account program id from the constants
|
|
55
|
+
#
|
|
56
|
+
# @return [String] The Squads Smart Account program id
|
|
57
|
+
def program_id
|
|
58
|
+
SquadsSmartAccounts::PROGRAM_ID
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Returns the system program id from the constants
|
|
62
|
+
#
|
|
63
|
+
# @return [String] The system program id
|
|
64
|
+
def system_program
|
|
65
|
+
Solace::Constants::SYSTEM_PROGRAM_ID
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Declares all accounts required by this instruction.
|
|
69
|
+
def setup_accounts
|
|
70
|
+
account_context.add_writable_nonsigner(settings)
|
|
71
|
+
account_context.add_readonly_signer(settings_authority)
|
|
72
|
+
account_context.add_writable_signer(rent_payer)
|
|
73
|
+
account_context.add_readonly_nonsigner(system_program)
|
|
74
|
+
account_context.add_readonly_nonsigner(program_id)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Builds the instruction with resolved account indices.
|
|
78
|
+
#
|
|
79
|
+
# @param context [Solace::Utils::AccountContext] Merged context from TransactionComposer.
|
|
80
|
+
# @return [Solace::Instruction]
|
|
81
|
+
def build_instruction(context)
|
|
82
|
+
SquadsSmartAccounts::Instructions::ChangeThresholdAsAuthorityInstruction.build(
|
|
83
|
+
new_threshold:,
|
|
84
|
+
memo:,
|
|
85
|
+
settings_index: context.index_of(settings),
|
|
86
|
+
settings_authority_index: context.index_of(settings_authority),
|
|
87
|
+
rent_payer_index: context.index_of(rent_payer),
|
|
88
|
+
system_program_index: context.index_of(system_program),
|
|
89
|
+
program_index: context.index_of(program_id)
|
|
90
|
+
)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solace
|
|
4
|
+
module Composers
|
|
5
|
+
# Composes a `closeSettingsTransaction` instruction for the Squads Smart
|
|
6
|
+
# Account program.
|
|
7
|
+
#
|
|
8
|
+
# Closes a SettingsTransaction and its Proposal, refunding rent to the
|
|
9
|
+
# respective collectors. No smart-account signer is required — only the fee
|
|
10
|
+
# payer signs. The transaction is closeable once its proposal is terminal
|
|
11
|
+
# (Executed/Rejected/Cancelled) or stale.
|
|
12
|
+
#
|
|
13
|
+
# Required params:
|
|
14
|
+
# :settings [#to_s] Base58 address of the settings account.
|
|
15
|
+
# :proposal [#to_s] The Proposal PDA to close.
|
|
16
|
+
# :transaction [#to_s] The SettingsTransaction PDA to close.
|
|
17
|
+
# :proposal_rent_collector [#to_s] Receives the proposal rent.
|
|
18
|
+
# :transaction_rent_collector [#to_s] Receives the transaction rent (must equal
|
|
19
|
+
# transaction.rent_collector).
|
|
20
|
+
class SquadsSmartAccountsCloseSettingsTransactionComposer < Base
|
|
21
|
+
# Extracts the settings address from the params
|
|
22
|
+
#
|
|
23
|
+
# @return [String] The settings address
|
|
24
|
+
def settings
|
|
25
|
+
params[:settings].to_s
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Extracts the proposal PDA address from the params
|
|
29
|
+
#
|
|
30
|
+
# @return [String] The proposal address
|
|
31
|
+
def proposal
|
|
32
|
+
params[:proposal].to_s
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Extracts the settings transaction PDA address from the params
|
|
36
|
+
#
|
|
37
|
+
# @return [String] The transaction address
|
|
38
|
+
def transaction
|
|
39
|
+
params[:transaction].to_s
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Extracts the proposal rent collector address from the params
|
|
43
|
+
#
|
|
44
|
+
# @return [String] The proposal rent collector address
|
|
45
|
+
def proposal_rent_collector
|
|
46
|
+
params[:proposal_rent_collector].to_s
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Extracts the transaction rent collector address from the params
|
|
50
|
+
#
|
|
51
|
+
# @return [String] The transaction rent collector address
|
|
52
|
+
def transaction_rent_collector
|
|
53
|
+
params[:transaction_rent_collector].to_s
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Returns the Squads Smart Account program id from the constants
|
|
57
|
+
#
|
|
58
|
+
# @return [String] The Squads Smart Account program id
|
|
59
|
+
def program_id
|
|
60
|
+
SquadsSmartAccounts::PROGRAM_ID
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Returns the system program id from the constants
|
|
64
|
+
#
|
|
65
|
+
# @return [String] The system program id
|
|
66
|
+
def system_program
|
|
67
|
+
Solace::Constants::SYSTEM_PROGRAM_ID
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Declares all accounts required by this instruction.
|
|
71
|
+
def setup_accounts
|
|
72
|
+
account_context.add_readonly_nonsigner(settings)
|
|
73
|
+
account_context.add_writable_nonsigner(proposal)
|
|
74
|
+
account_context.add_writable_nonsigner(transaction)
|
|
75
|
+
account_context.add_writable_nonsigner(proposal_rent_collector)
|
|
76
|
+
account_context.add_writable_nonsigner(transaction_rent_collector)
|
|
77
|
+
account_context.add_readonly_nonsigner(system_program)
|
|
78
|
+
account_context.add_readonly_nonsigner(program_id)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Builds the instruction with resolved account indices.
|
|
82
|
+
#
|
|
83
|
+
# @param context [Solace::Utils::AccountContext] Merged context from TransactionComposer.
|
|
84
|
+
# @return [Solace::Instruction]
|
|
85
|
+
def build_instruction(context)
|
|
86
|
+
SquadsSmartAccounts::Instructions::CloseSettingsTransactionInstruction.build(
|
|
87
|
+
settings_index: context.index_of(settings),
|
|
88
|
+
proposal_index: context.index_of(proposal),
|
|
89
|
+
transaction_index: context.index_of(transaction),
|
|
90
|
+
proposal_rent_collector_index: context.index_of(proposal_rent_collector),
|
|
91
|
+
transaction_rent_collector_index: context.index_of(transaction_rent_collector),
|
|
92
|
+
system_program_index: context.index_of(system_program),
|
|
93
|
+
program_index: context.index_of(program_id)
|
|
94
|
+
)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solace
|
|
4
|
+
module Composers
|
|
5
|
+
# Composes a `closeTransaction` instruction for the Squads Smart Account program.
|
|
6
|
+
#
|
|
7
|
+
# Closes a vault Transaction and its Proposal, refunding rent to the
|
|
8
|
+
# respective collectors. No smart-account signer is required — only the fee
|
|
9
|
+
# payer signs. Closeable once the proposal is terminal
|
|
10
|
+
# (Executed/Rejected/Cancelled) or stale and not Approved.
|
|
11
|
+
#
|
|
12
|
+
# Required params:
|
|
13
|
+
# :settings [#to_s] Base58 address of the settings account.
|
|
14
|
+
# :proposal [#to_s] The Proposal PDA to close.
|
|
15
|
+
# :transaction [#to_s] The vault Transaction PDA to close.
|
|
16
|
+
# :proposal_rent_collector [#to_s] Receives the proposal rent.
|
|
17
|
+
# :transaction_rent_collector [#to_s] Receives the transaction rent (must equal
|
|
18
|
+
# transaction.rent_collector).
|
|
19
|
+
class SquadsSmartAccountsCloseTransactionComposer < Base
|
|
20
|
+
# Extracts the settings address from the params
|
|
21
|
+
#
|
|
22
|
+
# @return [String] The settings address
|
|
23
|
+
def settings
|
|
24
|
+
params[:settings].to_s
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Extracts the proposal PDA address from the params
|
|
28
|
+
#
|
|
29
|
+
# @return [String] The proposal address
|
|
30
|
+
def proposal
|
|
31
|
+
params[:proposal].to_s
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Extracts the transaction PDA address from the params
|
|
35
|
+
#
|
|
36
|
+
# @return [String] The transaction address
|
|
37
|
+
def transaction
|
|
38
|
+
params[:transaction].to_s
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Extracts the proposal rent collector address from the params
|
|
42
|
+
#
|
|
43
|
+
# @return [String] The proposal rent collector address
|
|
44
|
+
def proposal_rent_collector
|
|
45
|
+
params[:proposal_rent_collector].to_s
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Extracts the transaction rent collector address from the params
|
|
49
|
+
#
|
|
50
|
+
# @return [String] The transaction rent collector address
|
|
51
|
+
def transaction_rent_collector
|
|
52
|
+
params[:transaction_rent_collector].to_s
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Returns the Squads Smart Account program id from the constants
|
|
56
|
+
#
|
|
57
|
+
# @return [String] The Squads Smart Account program id
|
|
58
|
+
def program_id
|
|
59
|
+
SquadsSmartAccounts::PROGRAM_ID
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Returns the system program id from the constants
|
|
63
|
+
#
|
|
64
|
+
# @return [String] The system program id
|
|
65
|
+
def system_program
|
|
66
|
+
Solace::Constants::SYSTEM_PROGRAM_ID
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Declares all accounts required by this instruction.
|
|
70
|
+
def setup_accounts
|
|
71
|
+
account_context.add_readonly_nonsigner(settings)
|
|
72
|
+
account_context.add_writable_nonsigner(proposal)
|
|
73
|
+
account_context.add_writable_nonsigner(transaction)
|
|
74
|
+
account_context.add_writable_nonsigner(proposal_rent_collector)
|
|
75
|
+
account_context.add_writable_nonsigner(transaction_rent_collector)
|
|
76
|
+
account_context.add_readonly_nonsigner(system_program)
|
|
77
|
+
account_context.add_readonly_nonsigner(program_id)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Builds the instruction with resolved account indices.
|
|
81
|
+
#
|
|
82
|
+
# @param context [Solace::Utils::AccountContext] Merged context from TransactionComposer.
|
|
83
|
+
# @return [Solace::Instruction]
|
|
84
|
+
def build_instruction(context)
|
|
85
|
+
SquadsSmartAccounts::Instructions::CloseTransactionInstruction.build(
|
|
86
|
+
settings_index: context.index_of(settings),
|
|
87
|
+
proposal_index: context.index_of(proposal),
|
|
88
|
+
transaction_index: context.index_of(transaction),
|
|
89
|
+
proposal_rent_collector_index: context.index_of(proposal_rent_collector),
|
|
90
|
+
transaction_rent_collector_index: context.index_of(transaction_rent_collector),
|
|
91
|
+
system_program_index: context.index_of(system_program),
|
|
92
|
+
program_index: context.index_of(program_id)
|
|
93
|
+
)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solace
|
|
4
|
+
module Composers
|
|
5
|
+
# Composes a `createProposal` instruction for the Squads Smart Account program.
|
|
6
|
+
#
|
|
7
|
+
# Creates the Proposal account that tracks votes for a stored Transaction.
|
|
8
|
+
# The transaction must already exist (its index is referenced here).
|
|
9
|
+
#
|
|
10
|
+
# Required params:
|
|
11
|
+
# :settings [#to_s] Base58 address of the settings account.
|
|
12
|
+
# :proposal [#to_s] The Proposal PDA to create.
|
|
13
|
+
# :creator [#to_s, Keypair] A smart-account signer creating the proposal (must sign).
|
|
14
|
+
# :rent_payer [#to_s, Keypair] Funds the new account's rent (must sign).
|
|
15
|
+
# :transaction_index [Integer] Index of the transaction this proposal tracks.
|
|
16
|
+
#
|
|
17
|
+
# Optional params:
|
|
18
|
+
# :draft [Boolean] Initialize as Draft instead of Active (default: false).
|
|
19
|
+
class SquadsSmartAccountsCreateProposalComposer < Base
|
|
20
|
+
# Extracts the settings address from the params
|
|
21
|
+
#
|
|
22
|
+
# @return [String] The settings address
|
|
23
|
+
def settings
|
|
24
|
+
params[:settings].to_s
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Extracts the proposal PDA address from the params
|
|
28
|
+
#
|
|
29
|
+
# @return [String] The proposal address
|
|
30
|
+
def proposal
|
|
31
|
+
params[:proposal].to_s
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Extracts the creator address from the params
|
|
35
|
+
#
|
|
36
|
+
# @return [String] The creator address
|
|
37
|
+
def creator
|
|
38
|
+
params[:creator].to_s
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Extracts the rent payer address from the params
|
|
42
|
+
#
|
|
43
|
+
# @return [String] The rent payer address
|
|
44
|
+
def rent_payer
|
|
45
|
+
params[:rent_payer].to_s
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Extracts the transaction index from the params
|
|
49
|
+
#
|
|
50
|
+
# @return [Integer] The transaction index the proposal tracks
|
|
51
|
+
def transaction_index
|
|
52
|
+
params[:transaction_index]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Extracts the draft flag from the params
|
|
56
|
+
#
|
|
57
|
+
# @return [Boolean] Whether to initialize the proposal as Draft (defaults to false)
|
|
58
|
+
def draft
|
|
59
|
+
params[:draft] || false
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Returns the Squads Smart Account program id from the constants
|
|
63
|
+
#
|
|
64
|
+
# @return [String] The Squads Smart Account program id
|
|
65
|
+
def program_id
|
|
66
|
+
SquadsSmartAccounts::PROGRAM_ID
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Returns the system program id from the constants
|
|
70
|
+
#
|
|
71
|
+
# @return [String] The system program id
|
|
72
|
+
def system_program
|
|
73
|
+
Solace::Constants::SYSTEM_PROGRAM_ID
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Declares all accounts required by this instruction.
|
|
77
|
+
def setup_accounts
|
|
78
|
+
account_context.add_readonly_nonsigner(settings)
|
|
79
|
+
account_context.add_writable_nonsigner(proposal)
|
|
80
|
+
account_context.add_readonly_signer(creator)
|
|
81
|
+
account_context.add_writable_signer(rent_payer)
|
|
82
|
+
account_context.add_readonly_nonsigner(system_program)
|
|
83
|
+
account_context.add_readonly_nonsigner(program_id)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Builds the instruction with resolved account indices.
|
|
87
|
+
#
|
|
88
|
+
# @param context [Solace::Utils::AccountContext] Merged context from TransactionComposer.
|
|
89
|
+
# @return [Solace::Instruction]
|
|
90
|
+
def build_instruction(context)
|
|
91
|
+
SquadsSmartAccounts::Instructions::CreateProposalInstruction.build(
|
|
92
|
+
transaction_index:,
|
|
93
|
+
draft:,
|
|
94
|
+
settings_index: context.index_of(settings),
|
|
95
|
+
proposal_index: context.index_of(proposal),
|
|
96
|
+
creator_index: context.index_of(creator),
|
|
97
|
+
rent_payer_index: context.index_of(rent_payer),
|
|
98
|
+
system_program_index: context.index_of(system_program),
|
|
99
|
+
program_index: context.index_of(program_id)
|
|
100
|
+
)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solace
|
|
4
|
+
module Composers
|
|
5
|
+
# Composes a `createSettingsTransaction` instruction for the Squads Smart
|
|
6
|
+
# Account program.
|
|
7
|
+
#
|
|
8
|
+
# Stores a batch of SettingsActions as a SettingsTransaction for later
|
|
9
|
+
# approval and execution. Autonomous accounts only.
|
|
10
|
+
#
|
|
11
|
+
# Required params:
|
|
12
|
+
# :settings [#to_s] Base58 address of the settings account.
|
|
13
|
+
# :transaction [#to_s] The SettingsTransaction PDA to create.
|
|
14
|
+
# :creator [#to_s, Keypair] A signer creating the transaction (must sign).
|
|
15
|
+
# :rent_payer [#to_s, Keypair] Funds the new account's rent (must sign).
|
|
16
|
+
# :actions [Array<SquadsSmartAccounts::SettingsAction>] Actions to store.
|
|
17
|
+
#
|
|
18
|
+
# Optional params:
|
|
19
|
+
# :memo [String] Indexing memo (default: nil).
|
|
20
|
+
class SquadsSmartAccountsCreateSettingsTransactionComposer < Base
|
|
21
|
+
# Extracts the settings address from the params
|
|
22
|
+
#
|
|
23
|
+
# @return [String] The settings address
|
|
24
|
+
def settings
|
|
25
|
+
params[:settings].to_s
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Extracts the transaction PDA address from the params
|
|
29
|
+
#
|
|
30
|
+
# @return [String] The transaction address
|
|
31
|
+
def transaction
|
|
32
|
+
params[:transaction].to_s
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Extracts the creator address from the params
|
|
36
|
+
#
|
|
37
|
+
# @return [String] The creator address
|
|
38
|
+
def creator
|
|
39
|
+
params[:creator].to_s
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Extracts the rent payer address from the params
|
|
43
|
+
#
|
|
44
|
+
# @return [String] The rent payer address
|
|
45
|
+
def rent_payer
|
|
46
|
+
params[:rent_payer].to_s
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Extracts the settings actions from the params
|
|
50
|
+
#
|
|
51
|
+
# @return [Array<SquadsSmartAccounts::SettingsAction>] The actions to store
|
|
52
|
+
def actions
|
|
53
|
+
params[:actions]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Extracts the memo from the params
|
|
57
|
+
#
|
|
58
|
+
# @return [String, nil] The memo
|
|
59
|
+
def memo
|
|
60
|
+
params[:memo]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Returns the Squads Smart Account program id from the constants
|
|
64
|
+
#
|
|
65
|
+
# @return [String] The Squads Smart Account program id
|
|
66
|
+
def program_id
|
|
67
|
+
SquadsSmartAccounts::PROGRAM_ID
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Returns the system program id from the constants
|
|
71
|
+
#
|
|
72
|
+
# @return [String] The system program id
|
|
73
|
+
def system_program
|
|
74
|
+
Solace::Constants::SYSTEM_PROGRAM_ID
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Declares all accounts required by this instruction.
|
|
78
|
+
def setup_accounts
|
|
79
|
+
account_context.add_writable_nonsigner(settings)
|
|
80
|
+
account_context.add_writable_nonsigner(transaction)
|
|
81
|
+
account_context.add_readonly_signer(creator)
|
|
82
|
+
account_context.add_writable_signer(rent_payer)
|
|
83
|
+
account_context.add_readonly_nonsigner(system_program)
|
|
84
|
+
account_context.add_readonly_nonsigner(program_id)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Builds the instruction with resolved account indices.
|
|
88
|
+
#
|
|
89
|
+
# @param context [Solace::Utils::AccountContext] Merged context from TransactionComposer.
|
|
90
|
+
# @return [Solace::Instruction]
|
|
91
|
+
def build_instruction(context)
|
|
92
|
+
SquadsSmartAccounts::Instructions::CreateSettingsTransactionInstruction.build(
|
|
93
|
+
actions:,
|
|
94
|
+
memo:,
|
|
95
|
+
settings_index: context.index_of(settings),
|
|
96
|
+
transaction_index: context.index_of(transaction),
|
|
97
|
+
creator_index: context.index_of(creator),
|
|
98
|
+
rent_payer_index: context.index_of(rent_payer),
|
|
99
|
+
system_program_index: context.index_of(system_program),
|
|
100
|
+
program_index: context.index_of(program_id)
|
|
101
|
+
)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|