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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21862a029b8b0922fa42fd3798e86d11c69900255bb92a035c806d83a8c985c1
4
- data.tar.gz: 10eb8a0433c9907b7e75a7a3bb71637f1e41f0012e7cb695afcb91f2115d3f3f
3
+ metadata.gz: 4c4e4949dfaad369b5fbe6db182896b73fce66456fa04b480a394753bd76f3d8
4
+ data.tar.gz: e0fc2a7292a0ef3688555b419a534b7d8aa64fae214cc5f0317aebcd2af767e1
5
5
  SHA512:
6
- metadata.gz: 813efcb0fae947ac7a93bb88d6984ca4b4369390b807d08eb11e9ff7d49b7742c53de1e2a9d0ffd6c2fd98b07dcd3cd8161e477ec91e9b0b5574ebdb54dd5ebc
7
- data.tar.gz: a7a077c4af7e7379364bec45ef965eafcab28c58cca0588f9f2c0854a99bb5e4f5bf7a4262e4f5c64d57bd02f311c03bb98146b500e0d6a6621a528fe297a782
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
- Got it — here’s your changelog tidied up for clarity and consistency without changing any of the substance. I only fixed grammar/typos and tightened phrasing.
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::CreateAssociatedTokenAccountInstruction`).
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::CreateAssociatedTokenAccountInstruction
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::CreateAssociatedTokenAccountInstruction.build(
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),
@@ -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 AssociatedTokenAccount module contains instruction builders for 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 CreateAssociatedTokenAccount instruction
21
- # instruction = Solace::Instructions::AssociatedTokenAccount::CreateAssociatedTokenAccountInstruction.build(
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 CreateAssociatedTokenAccountInstruction
30
+ class CreateAccountInstruction
31
31
  # !@const INSTRUCTION_INDEX
32
- # Instruction index for CreateAssociatedTokenAccount
32
+ # Instruction index for CreateAccount
33
33
  #
34
34
  # @return [Array<Integer>]
35
35
  INSTRUCTION_INDEX = [0].freeze
36
36
 
37
- # Builds a CreateAssociatedTokenAccount instruction.
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 CreateAssociatedTokenAccount instruction
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
@@ -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::CreateAssociatedTokenAccountInstruction
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::CreateAssociatedTokenAccountInstruction
25
+ # @see Solace::Instructions::AssociatedTokenAccount::CreateAccountInstruction
26
26
  # @see Solace::Instructions::SystemProgram::CreateAccountInstruction
27
27
  # @since 0.0.2
28
28
  class InitializeAccountInstruction
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Solace
4
4
  # Latest version of the Solace gem.
5
- VERSION = '0.1.2'
5
+ VERSION = '0.1.3'
6
6
  end
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.2
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/create_associated_token_account_instruction.rb
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