ton-sdk-ruby 0.0.14 → 0.0.16

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: f81c745cb33593fbc91dc0071409dca6aa63fcb24390abd4725c9a6eeac9b594
4
- data.tar.gz: 3a71eb78459f544bebd24eac61ea96149633438aa0edbf30ae6aa114bd681f05
3
+ metadata.gz: de803bfcd40712f354ccc4b57aa28724cdfe3ed825421ef822fc2ab968ed6fc9
4
+ data.tar.gz: 3810954a881091554b46643e2eda2015bc375eebd2713889e99969e86baf365c
5
5
  SHA512:
6
- metadata.gz: '0518bafa41f14473cffce29a722ab7ac38c1d01e94ade6c60be9336c2dc34ae9456a26822ba5a5758d687771b832b3de89eb5c9e32fb0e4c55f480d539335d0b'
7
- data.tar.gz: e7b8ffd7860e9988db37eff6c3ac4ba4c67a044741b2645fd323e2d9954ba88c82f4a2b0d8a528fdd71c3bc14ee0634f2d3fdd5aca9a21851d7519eecd5a7639
6
+ metadata.gz: e65a914d895a53418f9170536ae32cc9619acba38347c7c848ee64740d1022e9f0f0f87c7d9650b46d59ed52b8c748533f6afd3e87917052596055924c1592c0
7
+ data.tar.gz: 13db3d454771d597f33c1b576cba6f5a029f595eda42e991f2a30e50310ccddd14ab9cb789fa09867b5a3357d74a15a100bc83697702b5538f4c45483d2148a4
@@ -325,7 +325,7 @@ module TonSdkRuby
325
325
  serialize
326
326
  end
327
327
 
328
- def self.parse(key_size, slice, options = nil)
328
+ def self.parse(key_size, slice, options = {})
329
329
  deserialize(key_size, slice, options)
330
330
  end
331
331
 
@@ -349,7 +349,7 @@ module TonSdkRuby
349
349
  end
350
350
 
351
351
  class HashmapE < Hashmap
352
- def initialize(key_size, options = nil)
352
+ def initialize(key_size, options = {})
353
353
  super(key_size, options)
354
354
  end
355
355
 
@@ -366,7 +366,7 @@ module TonSdkRuby
366
366
  end
367
367
  end
368
368
 
369
- def self.deserialize(key_size, slice, options = nil)
369
+ def self.deserialize(key_size, slice, options = {})
370
370
  if slice.bits.length != 1
371
371
  raise 'HashmapE: bad hashmap size flag.'
372
372
  end
@@ -386,7 +386,7 @@ module TonSdkRuby
386
386
  end
387
387
  end
388
388
 
389
- def self.parse(key_size, slice, options = nil)
389
+ def self.parse(key_size, slice, options = {})
390
390
  deserialize(key_size, slice, options)
391
391
  end
392
392
  end
@@ -277,31 +277,40 @@ module TonSdkRuby
277
277
  end
278
278
 
279
279
  def breadth_first_sort(root)
280
- stack = Array.new(root)
280
+ stack = root.dup
281
281
  cells = root.map { |el| { cell: el, hash: el.hash } }
282
282
  hash_indexes = cells.map.with_index { |el, i| [el[:hash], i] }.to_h
283
283
 
284
- while !stack.empty?
285
- length = stack.length
284
+ while stack.size > 0 do
285
+ length = stack.size
286
286
 
287
287
  stack.each do |node|
288
288
  node.refs.each do |ref|
289
289
  hash = ref.hash
290
290
  index = hash_indexes[hash]
291
- length = index.nil? ? cells.push(cell: ref, hash: hash).size : cells.push(cells.delete_at(index)).size
291
+ if index != nil
292
+ val = cells[index]
293
+ cells[index] = nil
294
+ cells << val
295
+ else
296
+ cells << {cell: ref, hash: hash}
297
+ end
298
+ len = cells.size
292
299
 
293
300
  stack.push(ref)
294
- hash_indexes[hash] = length - 1
301
+ hash_indexes[hash] = len - 1
295
302
  end
296
303
  end
297
304
 
298
305
  stack.shift(length)
299
306
  end
300
307
 
308
+ idx = 0
301
309
  result = cells.each_with_index.reduce({ cells: [], hashmap: {} }) do |acc, (el, i)|
302
310
  unless el.nil?
303
311
  acc[:cells].push(el[:cell])
304
- acc[:hashmap][el[:hash]] = i
312
+ acc[:hashmap][el[:hash]] = idx
313
+ idx += 1
305
314
  end
306
315
 
307
316
  acc
@@ -43,12 +43,14 @@ module TonSdkRuby
43
43
 
44
44
  loop do
45
45
  res = SecureRandom.random_bytes(bytes_needed)
46
- power = (bytes_needed - 1) * 8
47
46
  number_value = 0
47
+
48
+ power = (bytes_needed - 1) * 8
48
49
  res.each_byte do |byte|
49
50
  number_value += byte.ord * (2 ** power)
50
51
  power -= 8
51
52
  end
53
+
52
54
  number_value = number_value & mask # Truncate
53
55
  return min + number_value if number_value < range
54
56
  end
@@ -20,10 +20,21 @@ module TonSdkRuby
20
20
  read_post_json_from_link(url, body, headers)
21
21
  end
22
22
 
23
+ def send_boc(boc)
24
+ send_request('sendBoc', {boc: boc})
25
+ end
26
+
23
27
  def get_address_information(address)
24
28
  send_request('getAddressInformation', {address: address})
25
29
  end
26
30
 
31
+ def get_transactions(address, archival, limit, lt, hash, to_lt)
32
+ params = {
33
+ address: address, archival: archival, limit: limit, lt: lt, hash: hash, to_lt: to_lt
34
+ }
35
+ send_request('getTransactions', params)
36
+ end
37
+
27
38
  def get_extended_address_information(address)
28
39
  send_request('getExtendedAddressInformation', {address: address})
29
40
  end
@@ -40,13 +51,6 @@ module TonSdkRuby
40
51
  send_request('getTokenData', {address: address})
41
52
  end
42
53
 
43
- def get_transactions(address, archival, limit, lt, hash, to_lt)
44
- params = {
45
- address: address, archival: archival, limit: limit, lt: lt, hash: hash, to_lt: to_lt
46
- }
47
- send_request('getTransactions', params)
48
- end
49
-
50
54
  def run_get_method(address, method, stack = [])
51
55
  params = {
52
56
  address: address, method: method, stack: stack
@@ -54,10 +58,6 @@ module TonSdkRuby
54
58
  send_request('runGetMethod', params)
55
59
  end
56
60
 
57
- def send_boc(boc)
58
- send_request('sendBoc', {boc: boc})
59
- end
60
-
61
61
  def estimate_fee(address, body, init_code, init_data, ignore_chksig = false)
62
62
  params = {
63
63
  address: address, body: body, init_code: init_code, init_data: init_data, ignore_chksig: ignore_chksig
@@ -188,7 +188,7 @@ module TonSdkRuby
188
188
  def int_msg_info(data)
189
189
  b = Builder.new
190
190
  .store_bits([0]) # int_msg_info$0
191
- .store_bit(data.ihr_disabled || false) # ihr_disabled:Bool
191
+ .store_bit(data.ihr_disabled || true) # ihr_disabled:Bool
192
192
  .store_bit(data.bounce) # bounce:Bool
193
193
  .store_bit(data.bounced || false) # bounced:Bool
194
194
  .store_address(data.src || Address::NONE) # src:MsgAddressInt
@@ -1,4 +1,4 @@
1
1
  module TonSdkRuby
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.16"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ton-sdk-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - nerzh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-07 00:00:00.000000000 Z
11
+ date: 2024-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ed25519
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  requirements: []
132
- rubygems_version: 3.4.19
132
+ rubygems_version: 3.4.10
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: This is gem ton-sdk-ruby