solace 0.1.5 → 0.1.6

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/lib/solace/composers/associated_token_account_program_create_account_composer.rb +6 -6
  3. data/lib/solace/composers/associated_token_account_program_create_idempotent_account_composer.rb +2 -1
  4. data/lib/solace/composers/base.rb +1 -1
  5. data/lib/solace/composers/spl_token_program_close_account_composer.rb +3 -3
  6. data/lib/solace/composers/spl_token_program_initialize_mint_composer.rb +5 -5
  7. data/lib/solace/composers/spl_token_program_mint_to_composer.rb +4 -4
  8. data/lib/solace/composers/spl_token_program_transfer_checked_composer.rb +6 -6
  9. data/lib/solace/composers/spl_token_program_transfer_composer.rb +4 -4
  10. data/lib/solace/composers/system_program_create_account_composer.rb +5 -5
  11. data/lib/solace/composers/system_program_transfer_composer.rb +3 -3
  12. data/lib/solace/composers/token_2022_program_close_account_composer.rb +3 -3
  13. data/lib/solace/composers/token_2022_program_initialize_mint_composer.rb +5 -5
  14. data/lib/solace/composers/token_2022_program_mint_to_composer.rb +4 -4
  15. data/lib/solace/composers/token_2022_program_transfer_checked_composer.rb +6 -6
  16. data/lib/solace/composers/token_2022_program_transfer_composer.rb +4 -4
  17. data/lib/solace/connection.rb +5 -5
  18. data/lib/solace/errors/confirmation_timeout.rb +4 -4
  19. data/lib/solace/errors/rpc_error.rb +4 -4
  20. data/lib/solace/instructions/associated_token_account/create_account_instruction.rb +2 -1
  21. data/lib/solace/instructions/spl_token/close_account_instruction.rb +2 -2
  22. data/lib/solace/instructions/spl_token/initialize_account_instruction.rb +2 -2
  23. data/lib/solace/instructions/spl_token/initialize_mint_instruction.rb +2 -2
  24. data/lib/solace/instructions/spl_token/mint_to_instruction.rb +2 -2
  25. data/lib/solace/instructions/spl_token/transfer_checked_instruction.rb +2 -2
  26. data/lib/solace/instructions/spl_token/transfer_instruction.rb +2 -2
  27. data/lib/solace/instructions/system_program/create_account_instruction.rb +2 -2
  28. data/lib/solace/instructions/system_program/transfer_instruction.rb +2 -2
  29. data/lib/solace/instructions/token_2022/close_account_instruction.rb +2 -2
  30. data/lib/solace/instructions/token_2022/initialize_account_instruction.rb +2 -2
  31. data/lib/solace/instructions/token_2022/initialize_mint_instruction.rb +2 -2
  32. data/lib/solace/instructions/token_2022/mint_to_instruction.rb +2 -2
  33. data/lib/solace/instructions/token_2022/transfer_checked_instruction.rb +2 -2
  34. data/lib/solace/instructions/token_2022/transfer_instruction.rb +2 -2
  35. data/lib/solace/message.rb +5 -5
  36. data/lib/solace/programs/associated_token_account.rb +10 -9
  37. data/lib/solace/programs/token_program_interface.rb +18 -18
  38. data/lib/solace/serializers/address_lookup_table_deserializer.rb +2 -2
  39. data/lib/solace/serializers/base_deserializer.rb +1 -1
  40. data/lib/solace/serializers/instruction_deserializer.rb +2 -2
  41. data/lib/solace/serializers/message_deserializer.rb +3 -3
  42. data/lib/solace/serializers/transaction_deserializer.rb +1 -1
  43. data/lib/solace/tokens/token.rb +1 -1
  44. data/lib/solace/tokens.rb +2 -2
  45. data/lib/solace/transaction.rb +1 -1
  46. data/lib/solace/transaction_composer.rb +5 -5
  47. data/lib/solace/utils/account_context.rb +9 -9
  48. data/lib/solace/utils/codecs.rb +309 -49
  49. data/lib/solace/utils/rpc_client.rb +9 -9
  50. data/lib/solace/version.rb +1 -1
  51. metadata +111 -9
  52. data/CHANGELOG +0 -243
  53. data/LICENSE +0 -21
  54. data/README.md +0 -578
@@ -84,18 +84,18 @@ module Solace
84
84
 
85
85
  # Build the account for the mint
86
86
  create_account_ix = Composers::SystemProgramCreateAccountComposer.new(
87
- from: funder,
87
+ from: funder,
88
88
  new_account: mint_account,
89
- owner: program_id,
90
- lamports: rent_lamports,
91
- space: 82
89
+ owner: program_id,
90
+ lamports: rent_lamports,
91
+ space: 82
92
92
  )
93
93
 
94
94
  # Build the initialize mint composer (per-program class supplied by includer)
95
95
  initialize_mint_ix = initialize_mint_composer_class.new(
96
- decimals: decimals,
97
- mint_account: mint_account,
98
- mint_authority: mint_authority,
96
+ decimals: decimals,
97
+ mint_account: mint_account,
98
+ mint_authority: mint_authority,
99
99
  freeze_authority: freeze_authority
100
100
  )
101
101
 
@@ -153,9 +153,9 @@ module Solace
153
153
  mint_authority:
154
154
  )
155
155
  ix = mint_to_composer_class.new(
156
- amount: amount,
157
- mint: mint,
158
- destination: destination,
156
+ amount: amount,
157
+ mint: mint,
158
+ destination: destination,
159
159
  mint_authority: mint_authority
160
160
  )
161
161
 
@@ -210,9 +210,9 @@ module Solace
210
210
  owner:
211
211
  )
212
212
  ix = transfer_composer_class.new(
213
- amount: amount,
214
- owner: owner,
215
- source: source,
213
+ amount: amount,
214
+ owner: owner,
215
+ source: source,
216
216
  destination: destination
217
217
  )
218
218
 
@@ -272,12 +272,12 @@ module Solace
272
272
  decimals:
273
273
  )
274
274
  ix = transfer_checked_composer_class.new(
275
- to: to,
276
- from: from,
277
- mint: mint,
275
+ to: to,
276
+ from: from,
277
+ mint: mint,
278
278
  authority: authority,
279
- amount: amount,
280
- decimals: decimals
279
+ amount: amount,
280
+ decimals: decimals
281
281
  )
282
282
 
283
283
  TransactionComposer
@@ -40,7 +40,7 @@ module Solace
40
40
  #
41
41
  # @return [Array<Integer>] The writable indexes
42
42
  def next_extract_writable_indexes
43
- length, = Codecs.decode_compact_u16(io)
43
+ length, = Codecs.decode_compact_u16(io)
44
44
  record.writable_indexes = io.read(length).unpack('C*')
45
45
  end
46
46
 
@@ -52,7 +52,7 @@ module Solace
52
52
  #
53
53
  # @return [Array<Integer>] The readonly indexes
54
54
  def next_extract_readonly_indexes
55
- length, = Codecs.decode_compact_u16(io)
55
+ length, = Codecs.decode_compact_u16(io)
56
56
  record.readonly_indexes = io.read(length).unpack('C*')
57
57
  end
58
58
  end
@@ -36,7 +36,7 @@ module Solace
36
36
  # @return [BaseDeserializer] The new deserializer object
37
37
  def initialize(io)
38
38
  super()
39
- @io = io
39
+ @io = io
40
40
  @record = self.class.record_class.new
41
41
  end
42
42
 
@@ -40,7 +40,7 @@ module Solace
40
40
  #
41
41
  # @return [Array] The accounts
42
42
  def next_extract_accounts
43
- length, = Codecs.decode_compact_u16(io)
43
+ length, = Codecs.decode_compact_u16(io)
44
44
  record.accounts = io.read(length).unpack('C*')
45
45
  end
46
46
 
@@ -52,7 +52,7 @@ module Solace
52
52
  #
53
53
  # @return [Array] The instruction data
54
54
  def next_extract_data
55
- length, = Codecs.decode_compact_u16(io)
55
+ length, = Codecs.decode_compact_u16(io)
56
56
  record.data = io.read(length).unpack('C*')
57
57
  end
58
58
  end
@@ -64,7 +64,7 @@ module Solace
64
64
  #
65
65
  # @return [Array<String>] The account keys of the message
66
66
  def next_extract_accounts
67
- count, = Codecs.decode_compact_u16(io)
67
+ count, = Codecs.decode_compact_u16(io)
68
68
  record.accounts = count.times.map do
69
69
  Codecs.bytes_to_base58 io.read(32).bytes
70
70
  end
@@ -88,7 +88,7 @@ module Solace
88
88
  #
89
89
  # @return [Array<Solace::Instruction>] The instructions of the message
90
90
  def next_extract_instructions
91
- count, = Codecs.decode_compact_u16(io)
91
+ count, = Codecs.decode_compact_u16(io)
92
92
  record.instructions = count.times.map do
93
93
  Solace::Instruction.deserialize(io)
94
94
  end
@@ -104,7 +104,7 @@ module Solace
104
104
  def next_extract_address_lookup_table
105
105
  return unless record.versioned?
106
106
 
107
- count, = Codecs.decode_compact_u16(io)
107
+ count, = Codecs.decode_compact_u16(io)
108
108
  record.address_lookup_tables = count.times.map do
109
109
  Solace::AddressLookupTable.deserialize(io)
110
110
  end
@@ -29,7 +29,7 @@ module Solace
29
29
  #
30
30
  # @return [Array] Array of base58 encoded signatures
31
31
  def next_extract_signatures
32
- count, = Codecs.decode_compact_u16(io)
32
+ count, = Codecs.decode_compact_u16(io)
33
33
  record.signatures = count.times.map { io.read(64) }
34
34
  end
35
35
 
@@ -18,7 +18,7 @@ module Solace
18
18
  # @param metadata [Hash] A hash containing the token's metadata attributes
19
19
  # @return [self] The initialized Token object
20
20
  def initialize(symbol, metadata)
21
- @symbol = symbol
21
+ @symbol = symbol
22
22
  @metadata = metadata.transform_keys(&:to_sym)
23
23
  end
24
24
 
data/lib/solace/tokens.rb CHANGED
@@ -29,7 +29,7 @@ module Solace
29
29
  # @param network [String, Symbol] Network name (e.g., 'mainnet', 'testnet')
30
30
  # @return [void]
31
31
  def self.load(path:, network:)
32
- data = YAML.load_file(path)
32
+ data = YAML.load_file(path)
33
33
  tokens = data.fetch(network.to_s) do
34
34
  raise ArgumentError, "Network '#{network}' not found in config"
35
35
  end
@@ -40,7 +40,7 @@ module Solace
40
40
  @registry = {}
41
41
 
42
42
  tokens.each do |symbol, attrs|
43
- token = Solace::Tokens::Token.new(symbol, attrs)
43
+ token = Solace::Tokens::Token.new(symbol, attrs)
44
44
  const_set(symbol, token)
45
45
  @registry[symbol.to_s] = token
46
46
  end
@@ -66,7 +66,7 @@ module Solace
66
66
  )
67
67
  super()
68
68
  @signatures = signatures
69
- @message = message
69
+ @message = message
70
70
  end
71
71
 
72
72
  # Returns the first signature of the transaction (signature of the transaction fee payer)
@@ -77,9 +77,9 @@ module Solace
77
77
  #
78
78
  # @param connection [Solace::Connection] The connection to the Solana cluster
79
79
  def initialize(connection:)
80
- @connection = connection
80
+ @connection = connection
81
81
  @instruction_composers = []
82
- @context = Utils::AccountContext.new
82
+ @context = Utils::AccountContext.new
83
83
  end
84
84
 
85
85
  # Add an instruction composer to the transaction
@@ -161,9 +161,9 @@ module Solace
161
161
  context.compile
162
162
 
163
163
  message = Solace::Message.new(
164
- header: context.header,
165
- accounts: context.accounts,
166
- instructions: build_instructions,
164
+ header: context.header,
165
+ accounts: context.accounts,
166
+ instructions: build_instructions,
167
167
  recent_blockhash: connection.get_latest_blockhash[0]
168
168
  )
169
169
 
@@ -35,8 +35,8 @@ module Solace
35
35
  #
36
36
  # @return [Hash] The default account data with lowest level of permissions
37
37
  DEFAULT_ACCOUNT = {
38
- signer: false,
39
- writable: false,
38
+ signer: false,
39
+ writable: false,
40
40
  fee_payer: false
41
41
  }.freeze
42
42
 
@@ -60,8 +60,8 @@ module Solace
60
60
 
61
61
  # Initialize the account context
62
62
  def initialize
63
- @header = []
64
- @accounts = []
63
+ @header = []
64
+ @accounts = []
65
65
  @pubkey_account_map = {}
66
66
  end
67
67
 
@@ -175,7 +175,7 @@ module Solace
175
175
  #
176
176
  # @return [Hash] The compiled accounts and header
177
177
  def compile
178
- self.header = calculate_header
178
+ self.header = calculate_header
179
179
  self.accounts = order_accounts
180
180
  self
181
181
  end
@@ -206,9 +206,9 @@ module Solace
206
206
  def merge_account(pubkey, signer:, writable:, fee_payer: false)
207
207
  pubkey_str = pubkey.is_a?(String) ? pubkey : pubkey.address
208
208
 
209
- @pubkey_account_map[pubkey_str] ||= DEFAULT_ACCOUNT.dup
210
- @pubkey_account_map[pubkey_str][:signer] ||= signer
211
- @pubkey_account_map[pubkey_str][:writable] ||= writable
209
+ @pubkey_account_map[pubkey_str] ||= DEFAULT_ACCOUNT.dup
210
+ @pubkey_account_map[pubkey_str][:signer] ||= signer
211
+ @pubkey_account_map[pubkey_str][:writable] ||= writable
212
212
  @pubkey_account_map[pubkey_str][:fee_payer] ||= fee_payer
213
213
 
214
214
  self
@@ -242,7 +242,7 @@ module Solace
242
242
  @pubkey_account_map.keys.each_with_object([0, 0, 0]) do |pubkey, acc|
243
243
  acc[0] += 1 if signer?(pubkey)
244
244
 
245
- if readonly_signer?(pubkey) then acc[1] += 1
245
+ if readonly_signer?(pubkey) then acc[1] += 1
246
246
  elsif readonly_nonsigner?(pubkey) then acc[2] += 1
247
247
  end
248
248
  end