solace 0.1.2 → 0.1.3
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 +4 -4
- data/CHANGELOG +12 -1
- data/lib/solace/composers/associated_token_account_program_create_account_composer.rb +3 -3
- data/lib/solace/composers/associated_token_account_program_create_idempotent_account_composer.rb +51 -0
- data/lib/solace/instructions/associated_token_account/{create_associated_token_account_instruction.rb → create_account_instruction.rb} +10 -7
- data/lib/solace/instructions/associated_token_account/create_idempotent_account_instruction.rb +52 -0
- data/lib/solace/instructions/spl_token/initialize_account_instruction.rb +2 -2
- data/lib/solace/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4c4e4949dfaad369b5fbe6db182896b73fce66456fa04b480a394753bd76f3d8
|
|
4
|
+
data.tar.gz: e0fc2a7292a0ef3688555b419a534b7d8aa64fae214cc5f0317aebcd2af767e1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a1653573d2cabf8c0253157a03b7bb5ebfadedf0eeeb6dea1eefa89c0b79aa01250637bab175f0d91e3072bcf7fd18a43b082d40851cb9b5d5bc7759971d54fe
|
|
7
|
+
data.tar.gz: 718ea842339b67b89b99f9c1a674148b510e3ed6bdd4921a9fa574cd83525452e8ff7e17d8138a97821d9885cdb54a8b09037b3826666c7db59328bdfc25f67c
|
data/CHANGELOG
CHANGED
|
@@ -18,7 +18,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|
|
18
18
|
### Fixed
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 0.1.3 - 2025-06-11
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
1. Added `Solace::Instructions::AssociatedTokenAccount::CreateIdempotentAccountInstruction`
|
|
28
|
+
2. Added `Solace::Composers::AssociatedTokenAccountCreateIdempotentAccountComposer`
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
|
|
32
|
+
1. Renamed `Solace::Instructions::AssociatedTokenAccount::CreateAssociatedTokenAccountInstruction` to `Solace::Instructions::AssociatedTokenAccount::CreateAccountInstruction` with backwards compatibility
|
|
22
33
|
|
|
23
34
|
---
|
|
24
35
|
|
|
@@ -6,7 +6,7 @@ module Solace
|
|
|
6
6
|
#
|
|
7
7
|
# This composer resolves and orders the required accounts for a `CreateAssociatedTokenAccount` instruction,
|
|
8
8
|
# sets up their access permissions, and delegates construction to the appropriate
|
|
9
|
-
# instruction builder (`Instructions::AssociatedTokenAccount::
|
|
9
|
+
# instruction builder (`Instructions::AssociatedTokenAccount::CreateAccountInstruction`).
|
|
10
10
|
#
|
|
11
11
|
# Required accounts:
|
|
12
12
|
# - **Funder**: the account that will pay for fees and rent.
|
|
@@ -25,7 +25,7 @@ module Solace
|
|
|
25
25
|
# mint: mint_address
|
|
26
26
|
# )
|
|
27
27
|
#
|
|
28
|
-
# @see Instructions::AssociatedTokenAccount::
|
|
28
|
+
# @see Instructions::AssociatedTokenAccount::CreateAccountInstruction
|
|
29
29
|
# @since 0.0.7
|
|
30
30
|
class AssociatedTokenAccountProgramCreateAccountComposer < Base
|
|
31
31
|
# Extracts the owner address from the params
|
|
@@ -96,7 +96,7 @@ module Solace
|
|
|
96
96
|
# @param account_context [Utils::AccountContext] The account context
|
|
97
97
|
# @return [Solace::Instruction] The instruction
|
|
98
98
|
def build_instruction(account_context)
|
|
99
|
-
Instructions::AssociatedTokenAccount::
|
|
99
|
+
Instructions::AssociatedTokenAccount::CreateAccountInstruction.build(
|
|
100
100
|
funder_index: account_context.index_of(funder),
|
|
101
101
|
owner_index: account_context.index_of(owner),
|
|
102
102
|
mint_index: account_context.index_of(mint),
|
data/lib/solace/composers/associated_token_account_program_create_idempotent_account_composer.rb
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solace
|
|
4
|
+
module Composers
|
|
5
|
+
# Composer for creating an associated token account program create account instruction with idempotency
|
|
6
|
+
#
|
|
7
|
+
# This composer resolves and orders the required accounts for a `CreateIdempotentAssociatedTokenAccount` instruction,
|
|
8
|
+
# sets up their access permissions, and delegates construction to the appropriate
|
|
9
|
+
# instruction builder (`Instructions::AssociatedTokenAccount::CreateIdempotentAssociatedTokenAccountInstruction`).
|
|
10
|
+
#
|
|
11
|
+
# Required accounts:
|
|
12
|
+
# - **Funder**: the account that will pay for fees and rent.
|
|
13
|
+
# - **Owner**: the account that will own the new ATA.
|
|
14
|
+
# - **ATA**: the address of the new ATA.
|
|
15
|
+
# - **Mint**: the mint address of the token.
|
|
16
|
+
# - **System Program**: the system program id.
|
|
17
|
+
# - **Token Program**: the token program id.
|
|
18
|
+
# - **Associated Token Account Program**: the associated token account program id.
|
|
19
|
+
#
|
|
20
|
+
# @example Compose and build a create account instruction
|
|
21
|
+
# composer = AssociatedTokenAccountProgramCreateAccountComposer.new(
|
|
22
|
+
# funder: funder_address,
|
|
23
|
+
# owner: owner_address,
|
|
24
|
+
# ata_address: ata_address,
|
|
25
|
+
# mint: mint_address
|
|
26
|
+
# )
|
|
27
|
+
#
|
|
28
|
+
# @see Instructions::AssociatedTokenAccount::CreateAccountInstruction
|
|
29
|
+
# @since 0.1.3
|
|
30
|
+
#
|
|
31
|
+
# rubocop:disable Layout
|
|
32
|
+
class AssociatedTokenAccountProgramCreateIdempotentAccountComposer < AssociatedTokenAccountProgramCreateAccountComposer
|
|
33
|
+
# Builds the instruction for the associated token account program create account instruction
|
|
34
|
+
#
|
|
35
|
+
# @param account_context [Utils::AccountContext] The account context
|
|
36
|
+
# @return [Solace::Instruction] The instruction
|
|
37
|
+
def build_instruction(account_context)
|
|
38
|
+
Instructions::AssociatedTokenAccount::CreateIdempotentAccountInstruction.build(
|
|
39
|
+
funder_index: account_context.index_of(funder),
|
|
40
|
+
owner_index: account_context.index_of(owner),
|
|
41
|
+
mint_index: account_context.index_of(mint),
|
|
42
|
+
associated_token_account_index: account_context.index_of(ata_address),
|
|
43
|
+
system_program_index: account_context.index_of(system_program_id),
|
|
44
|
+
token_program_index: account_context.index_of(token_program_id),
|
|
45
|
+
program_index: account_context.index_of(associated_token_account_program_id)
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
# rubocop:enable Layout
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Solace
|
|
4
4
|
module Instructions
|
|
5
|
-
# The
|
|
5
|
+
# The Account module contains instruction builders for the
|
|
6
6
|
# Associated Token Account Program.
|
|
7
7
|
#
|
|
8
8
|
# The Associated Token Account (ATA) Program provides a deterministic way to
|
|
@@ -17,8 +17,8 @@ module Solace
|
|
|
17
17
|
# This is a special "all-in-one" instruction that creates and initializes the account. It
|
|
18
18
|
# is used to create an Associated Token Account (ATA) for a given mint and owner.
|
|
19
19
|
#
|
|
20
|
-
# @example Build a
|
|
21
|
-
# instruction = Solace::Instructions::AssociatedTokenAccount::
|
|
20
|
+
# @example Build a CreateAccount instruction
|
|
21
|
+
# instruction = Solace::Instructions::AssociatedTokenAccount::CreateAccountInstruction.build(
|
|
22
22
|
# funder_index: 0,
|
|
23
23
|
# associated_token_account_index: 1,
|
|
24
24
|
# owner_index: 2,
|
|
@@ -27,14 +27,14 @@ module Solace
|
|
|
27
27
|
# token_program_index: 5,
|
|
28
28
|
# program_index: 6
|
|
29
29
|
# )
|
|
30
|
-
class
|
|
30
|
+
class CreateAccountInstruction
|
|
31
31
|
# !@const INSTRUCTION_INDEX
|
|
32
|
-
# Instruction index for
|
|
32
|
+
# Instruction index for CreateAccount
|
|
33
33
|
#
|
|
34
34
|
# @return [Array<Integer>]
|
|
35
35
|
INSTRUCTION_INDEX = [0].freeze
|
|
36
36
|
|
|
37
|
-
# Builds a
|
|
37
|
+
# Builds a CreateAccount instruction.
|
|
38
38
|
#
|
|
39
39
|
# The on-chain program requires accounts in a specific order:
|
|
40
40
|
# 1. [writable, signer] Funder: The account paying for the rent.
|
|
@@ -75,7 +75,7 @@ module Solace
|
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
# Data for a
|
|
78
|
+
# Data for a CreateAccount instruction
|
|
79
79
|
#
|
|
80
80
|
# The BufferLayout is:
|
|
81
81
|
# - [Instruction Index (1 byte)]
|
|
@@ -85,6 +85,9 @@ module Solace
|
|
|
85
85
|
INSTRUCTION_INDEX
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
|
+
|
|
89
|
+
# Alias for CreateAccountInstruction for backward compatibility
|
|
90
|
+
CreateAssociatedTokenAccountInstruction = CreateAccountInstruction
|
|
88
91
|
end
|
|
89
92
|
end
|
|
90
93
|
end
|
data/lib/solace/instructions/associated_token_account/create_idempotent_account_instruction.rb
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solace
|
|
4
|
+
module Instructions
|
|
5
|
+
# The AssociatedTokenAccount module contains instruction builders for the
|
|
6
|
+
# Associated Token Account Program.
|
|
7
|
+
#
|
|
8
|
+
# The Associated Token Account (ATA) Program provides a deterministic way to
|
|
9
|
+
# derive token account addresses for a given wallet and mint. This ensures that
|
|
10
|
+
# each wallet has a single, predictable token account for each token type.
|
|
11
|
+
#
|
|
12
|
+
# @see https://spl.solana.com/associated-token-account
|
|
13
|
+
# @since 0.1.3
|
|
14
|
+
module AssociatedTokenAccount
|
|
15
|
+
# Instruction for creating an Associated Token Account idempotently.
|
|
16
|
+
#
|
|
17
|
+
# This instruction behaves like `CreateAccountInstruction`, but will not fail
|
|
18
|
+
# if the account already exists. This is useful for scenarios where the existence of the
|
|
19
|
+
# account is uncertain, and you want to ensure it exists without causing an error.
|
|
20
|
+
#
|
|
21
|
+
# @example Build a CreateIdempotentAccount instruction
|
|
22
|
+
# instruction = Solace::Instructions::AssociatedTokenAccount::CreateIdempotentAccountInstruction.build(
|
|
23
|
+
# funder_index: 0,
|
|
24
|
+
# associated_token_account_index: 1,
|
|
25
|
+
# owner_index: 2,
|
|
26
|
+
# mint_index: 3,
|
|
27
|
+
# system_program_index: 4,
|
|
28
|
+
# token_program_index: 5,
|
|
29
|
+
# program_index: 6
|
|
30
|
+
# )
|
|
31
|
+
#
|
|
32
|
+
# @see CreateAccountInstruction
|
|
33
|
+
class CreateIdempotentAccountInstruction < CreateAccountInstruction
|
|
34
|
+
# !@const INSTRUCTION_INDEX
|
|
35
|
+
# Instruction index for CreateIdempotentAccount
|
|
36
|
+
#
|
|
37
|
+
# @return [Array<Integer>]
|
|
38
|
+
INSTRUCTION_INDEX = [1].freeze
|
|
39
|
+
|
|
40
|
+
# Data for a CreateAccount instruction
|
|
41
|
+
#
|
|
42
|
+
# The BufferLayout is:
|
|
43
|
+
# - [Instruction Index (1 byte)]
|
|
44
|
+
#
|
|
45
|
+
# @return [Array] 1-byte instruction index
|
|
46
|
+
def self.data
|
|
47
|
+
INSTRUCTION_INDEX
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -9,7 +9,7 @@ module Solace
|
|
|
9
9
|
#
|
|
10
10
|
# This instruction is used to initialize a new token account for a given mint and owner. It
|
|
11
11
|
# is used in conjunction with the CreateAccount instruction to create and initialize a new
|
|
12
|
-
# token account. Note that the AssociatedTokenAccount::
|
|
12
|
+
# token account. Note that the AssociatedTokenAccount::CreateAccountInstruction
|
|
13
13
|
# is a special "all-in-one" instruction that creates and initializes the account in a single
|
|
14
14
|
# instruction.
|
|
15
15
|
#
|
|
@@ -22,7 +22,7 @@ module Solace
|
|
|
22
22
|
# program_index: 4
|
|
23
23
|
# )
|
|
24
24
|
#
|
|
25
|
-
# @see Solace::Instructions::AssociatedTokenAccount::
|
|
25
|
+
# @see Solace::Instructions::AssociatedTokenAccount::CreateAccountInstruction
|
|
26
26
|
# @see Solace::Instructions::SystemProgram::CreateAccountInstruction
|
|
27
27
|
# @since 0.0.2
|
|
28
28
|
class InitializeAccountInstruction
|
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.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sebastian Scholl
|
|
@@ -108,6 +108,7 @@ files:
|
|
|
108
108
|
- lib/solace.rb
|
|
109
109
|
- lib/solace/address_lookup_table.rb
|
|
110
110
|
- lib/solace/composers/associated_token_account_program_create_account_composer.rb
|
|
111
|
+
- lib/solace/composers/associated_token_account_program_create_idempotent_account_composer.rb
|
|
111
112
|
- lib/solace/composers/base.rb
|
|
112
113
|
- lib/solace/composers/spl_token_program_close_account_composer.rb
|
|
113
114
|
- lib/solace/composers/spl_token_program_initialize_mint_composer.rb
|
|
@@ -125,7 +126,8 @@ files:
|
|
|
125
126
|
- lib/solace/errors/parse_error.rb
|
|
126
127
|
- lib/solace/errors/rpc_error.rb
|
|
127
128
|
- lib/solace/instruction.rb
|
|
128
|
-
- lib/solace/instructions/associated_token_account/
|
|
129
|
+
- lib/solace/instructions/associated_token_account/create_account_instruction.rb
|
|
130
|
+
- lib/solace/instructions/associated_token_account/create_idempotent_account_instruction.rb
|
|
129
131
|
- lib/solace/instructions/spl_token/close_account_instruction.rb
|
|
130
132
|
- lib/solace/instructions/spl_token/initialize_account_instruction.rb
|
|
131
133
|
- lib/solace/instructions/spl_token/initialize_mint_instruction.rb
|