solace 0.1.1 → 0.1.2
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 21862a029b8b0922fa42fd3798e86d11c69900255bb92a035c806d83a8c985c1
|
|
4
|
+
data.tar.gz: 10eb8a0433c9907b7e75a7a3bb71637f1e41f0012e7cb695afcb91f2115d3f3f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 813efcb0fae947ac7a93bb88d6984ca4b4369390b807d08eb11e9ff7d49b7742c53de1e2a9d0ffd6c2fd98b07dcd3cd8161e477ec91e9b0b5574ebdb54dd5ebc
|
|
7
|
+
data.tar.gz: a7a077c4af7e7379364bec45ef965eafcab28c58cca0588f9f2c0854a99bb5e4f5bf7a4262e4f5c64d57bd02f311c03bb98146b500e0d6a6621a528fe297a782
|
data/CHANGELOG
CHANGED
|
@@ -22,6 +22,14 @@ Got it — here’s your changelog tidied up for clarity and consistency without
|
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
25
|
+
## [0.1.2] - 2025-05-11
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
1. Added support for closing SPL token accounts with:
|
|
30
|
+
- `Solace::Composers::SystemProgramCreateAccountComposer`
|
|
31
|
+
- `Solace::Instructions::SystemProgram::CreateAccountInstruction`
|
|
32
|
+
|
|
25
33
|
## [0.1.1] - 2025-05-11
|
|
26
34
|
|
|
27
35
|
### Added
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solace
|
|
4
|
+
module Composers
|
|
5
|
+
# Composer for creating a SPL Token Program CloseAccount instruction.
|
|
6
|
+
#
|
|
7
|
+
# This composer resolves and orders the required accounts for a `CloseAccount` instruction,
|
|
8
|
+
# sets up their access permissions, and delegates construction to the appropriate
|
|
9
|
+
# instruction builder.
|
|
10
|
+
#
|
|
11
|
+
# The CloseAccount instruction closes a token account and transfers remaining lamports
|
|
12
|
+
# to a destination account. The account must have a balance of zero tokens.
|
|
13
|
+
#
|
|
14
|
+
# Required accounts:
|
|
15
|
+
# - **Account**: token account to close (writable, non-signer)
|
|
16
|
+
# - **Destination**: account to receive lamports (writable, non-signer)
|
|
17
|
+
# - **Authority**: account authority (non-writable, signer)
|
|
18
|
+
#
|
|
19
|
+
# @example Compose and build a close account instruction
|
|
20
|
+
# composer = SplTokenProgramCloseAccountComposer.new(
|
|
21
|
+
# account: token_account_address,
|
|
22
|
+
# destination: destination_address,
|
|
23
|
+
# authority: authority_address
|
|
24
|
+
# )
|
|
25
|
+
#
|
|
26
|
+
# @since 0.1.2
|
|
27
|
+
class SplTokenProgramCloseAccountComposer < Base
|
|
28
|
+
# Extracts the token account address from the params
|
|
29
|
+
#
|
|
30
|
+
# @return [String] The token account address
|
|
31
|
+
def account
|
|
32
|
+
params[:account].to_s
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Extracts the destination address from the params
|
|
36
|
+
#
|
|
37
|
+
# @return [String] The destination address
|
|
38
|
+
def destination
|
|
39
|
+
params[:destination].to_s
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Extracts the authority address from the params
|
|
43
|
+
#
|
|
44
|
+
# @return [String] The authority address
|
|
45
|
+
def authority
|
|
46
|
+
params[:authority].to_s
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Returns the spl token program id
|
|
50
|
+
#
|
|
51
|
+
# @return [String] The spl token program id
|
|
52
|
+
def spl_token_program
|
|
53
|
+
Constants::TOKEN_PROGRAM_ID.to_s
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Setup accounts required for close account instruction
|
|
57
|
+
# Called automatically during initialization
|
|
58
|
+
#
|
|
59
|
+
# @return [void]
|
|
60
|
+
def setup_accounts
|
|
61
|
+
account_context.add_writable_nonsigner(account)
|
|
62
|
+
account_context.add_writable_nonsigner(destination)
|
|
63
|
+
account_context.add_readonly_signer(authority)
|
|
64
|
+
account_context.add_readonly_nonsigner(spl_token_program)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Build instruction with resolved account indices
|
|
68
|
+
#
|
|
69
|
+
# @param account_context [Utils::AccountContext] The account context
|
|
70
|
+
# @return [Solace::Instruction]
|
|
71
|
+
def build_instruction(account_context)
|
|
72
|
+
Instructions::SplToken::CloseAccountInstruction.build(
|
|
73
|
+
account_index: account_context.index_of(account),
|
|
74
|
+
authority_index: account_context.index_of(authority),
|
|
75
|
+
destination_index: account_context.index_of(destination),
|
|
76
|
+
program_index: account_context.index_of(spl_token_program)
|
|
77
|
+
)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solace
|
|
4
|
+
module Instructions
|
|
5
|
+
module SplToken
|
|
6
|
+
# Instruction builder for SPL Token Program CloseAccount.
|
|
7
|
+
#
|
|
8
|
+
# The CloseAccount instruction closes a token account and transfers all remaining
|
|
9
|
+
# lamports to a destination account. The token account must have a balance of zero.
|
|
10
|
+
#
|
|
11
|
+
# Instruction discriminator: 9
|
|
12
|
+
#
|
|
13
|
+
# Accounts:
|
|
14
|
+
# 1. [writable] Token account to close
|
|
15
|
+
# 2. [writable] Destination account to receive lamports
|
|
16
|
+
# 3. [signer] Account authority
|
|
17
|
+
#
|
|
18
|
+
# @since 0.1.2
|
|
19
|
+
class CloseAccountInstruction
|
|
20
|
+
# Instruction discriminator for CloseAccount
|
|
21
|
+
INSTRUCTION_DISCRIMINATOR = [9].freeze
|
|
22
|
+
|
|
23
|
+
# Builds a CloseAccount instruction
|
|
24
|
+
#
|
|
25
|
+
# @param account_index [Integer] Index of the token account to close
|
|
26
|
+
# @param destination_index [Integer] Index of the destination account
|
|
27
|
+
# @param authority_index [Integer] Index of the account authority
|
|
28
|
+
# @param program_index [Integer] Index of the SPL Token program
|
|
29
|
+
# @return [Solace::Instruction] The constructed instruction
|
|
30
|
+
def self.build(account_index:, destination_index:, authority_index:, program_index:)
|
|
31
|
+
Solace::Instruction.new.tap do |ix|
|
|
32
|
+
ix.program_index = program_index
|
|
33
|
+
ix.accounts = [account_index, destination_index, authority_index]
|
|
34
|
+
ix.data = data
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Builds the data for a CloseAccount instruction
|
|
39
|
+
#
|
|
40
|
+
# The BufferLayout is:
|
|
41
|
+
# - [Instruction Index (1 byte)]
|
|
42
|
+
#
|
|
43
|
+
# @return [Array] 1-byte instruction index
|
|
44
|
+
def self.data
|
|
45
|
+
INSTRUCTION_DISCRIMINATOR
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
data/lib/solace/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: solace
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sebastian Scholl
|
|
@@ -109,6 +109,7 @@ files:
|
|
|
109
109
|
- lib/solace/address_lookup_table.rb
|
|
110
110
|
- lib/solace/composers/associated_token_account_program_create_account_composer.rb
|
|
111
111
|
- lib/solace/composers/base.rb
|
|
112
|
+
- lib/solace/composers/spl_token_program_close_account_composer.rb
|
|
112
113
|
- lib/solace/composers/spl_token_program_initialize_mint_composer.rb
|
|
113
114
|
- lib/solace/composers/spl_token_program_mint_to_composer.rb
|
|
114
115
|
- lib/solace/composers/spl_token_program_transfer_checked_composer.rb
|
|
@@ -125,6 +126,7 @@ files:
|
|
|
125
126
|
- lib/solace/errors/rpc_error.rb
|
|
126
127
|
- lib/solace/instruction.rb
|
|
127
128
|
- lib/solace/instructions/associated_token_account/create_associated_token_account_instruction.rb
|
|
129
|
+
- lib/solace/instructions/spl_token/close_account_instruction.rb
|
|
128
130
|
- lib/solace/instructions/spl_token/initialize_account_instruction.rb
|
|
129
131
|
- lib/solace/instructions/spl_token/initialize_mint_instruction.rb
|
|
130
132
|
- lib/solace/instructions/spl_token/mint_to_instruction.rb
|