ton_sdk_client 1.16.0 → 1.19.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c809c22fee5e69dca9653a3f3ef7541e43491152f954c97dea5e4438e9981d7
4
- data.tar.gz: 56ea8b10cbae34389691afeedb1f72f21dcf8f8568258aeb9d250ee1b7ef3231
3
+ metadata.gz: c6868c6fe12ffd4126d1eeb38b3030a3ed5d7f035dae0fec74b9d84db10114c4
4
+ data.tar.gz: e54ded382e777172f4c55f900900b8bb05c8eb92e446a7a14da9940183cf84a6
5
5
  SHA512:
6
- metadata.gz: 4602857970a2c0c5d1f7ee3917e7df637516b684b7dd69d39975d8ec866bae0556e4053e0d54ede9a831a4815027f9522f239337ba3ae8f62bac288d6f67e6be
7
- data.tar.gz: 97857fb5c4bb08844bd973e71a8c54873f963516f398457bdf19bc7af5c33e0e47745311c66a0cb5a490242cfa5280a9dc3aaa3c0682ebbb9f25b33497c96689
6
+ metadata.gz: 7d72968fce6441bc33b7c39eb1901acbeeea916aeb44975775bbe2bd95d0bd45d5cba2b80a175a5b259f00c171e5b1868fb22cdaa947a9c2786a62aad42548f5
7
+ data.tar.gz: 2677cd3d469893a7404b23df694fd756650ca90775d80d990556fa39d2fd3c36e19539be190031b17d291d466c7f14b74c32255f7a4fac1787c1b6109ddb5442
data/CHANGELOG.md CHANGED
@@ -1,88 +1,33 @@
1
1
  # Changelog
2
2
 
3
- 1.16.x
4
- -----
5
- * TON SDK version: 1.16.0
6
- * the changes are according the ones of TON SDK
3
+ all the changes are always according to the ones of the main TON SDK library; and on top on that, there may be additional ones
4
+
7
5
 
8
6
  1.15.x
9
7
  -----
10
- * TON SDK version: 1.15.0
11
8
  * internal refactoring
12
- * the changes are according the ones of TON SDK
9
+
13
10
 
14
11
  1.13.x
15
12
  -----
16
- * TON SDK version: 1.13.0
17
13
  * internal refactoring
18
- * the changes are according the ones of TON SDK
14
+
19
15
 
20
16
  1.12.x
21
17
  -----
22
- * TON SDK version: 1.12.0
23
18
  * internal refactoring
24
- * the changes are according the ones of TON SDK
25
-
26
- 1.11.x
27
- -----
28
- * TON SDK version: 1.11.0
29
- * the changes are according the ones of TON SDK
30
-
31
-
32
- 1.10.x
33
- -----
34
- * TON SDK version: 1.10.0
35
- * the changes are according the ones of TON SDK
36
19
 
37
20
 
38
21
  1.9.x
39
22
  -----
40
- * TON SDK version: 1.9.0
41
23
  * remove TonSdk::NATIVE_LIB_VERSION, rename TonSdk::SDK_VERSION to TonSdk::NATIVE_SDK_VERSION
42
- * the changes are according the ones of TON SDK
43
24
 
44
25
 
45
- 1.7.x
46
- -----
47
- * TON SDK version: 1.7.0
48
- * the changes are according the ones of TON SDK
49
-
50
- 1.3.x
51
- -----
52
- * TON SDK version: 1.6.0
53
- * the changes are according the ones of TON SDK
54
-
55
26
  1.2.x
56
27
  -----
57
- * TON SDK version: 1.5.2
58
28
  * min Ruby version: 3.0
59
29
 
60
30
 
61
- 1.1.x
62
- -----
63
- * new `Client` `.resolve_app_request()`
64
- * new `Net` `.query()`, `.suspend()`, `.resume()`
65
- * new `Debot`
66
- * new `Boc` `.get_boc_hash()`
67
- * new `Crypto` `.register_signing_box()`, `.get_signing_box()`, `.signing_box_get_public_key()`,
68
- `.signing_box_sign()`, `remove_signing_box()`
69
- * new paramentes in `NetworkConfig`; particularly
70
-
71
- ```
72
- server_address: "example.com"
73
- ```
74
-
75
- becomes
76
-
77
- ```
78
- endpoints: ["example.com"]
79
- ```
80
-
81
- check out the main repository for the details
82
-
83
- * new data types/classes in several modules
84
-
85
-
86
31
  1.0.0
87
32
  -----
88
- * The first version has been released.
33
+ * the first version has been released.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # TON SDK client in Ruby and for Ruby
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/ton_sdk_client.png)](https://badge.fury.io/rb/ton_sdk_client)
4
- [![TON SDK version](https://img.shields.io/badge/TON%20SDK%20version-1.16.0-green)](https://github.com/tonlabs/TON-SDK/tree/1.16.0)
4
+ [![TON SDK version](https://img.shields.io/badge/TON%20SDK%20version-1.19.0-green)](https://github.com/tonlabs/TON-SDK/tree/1.19.0)
5
5
 
6
6
  Ruby gem-client bindings for [TON SDK](https://github.com/tonlabs/TON-SDK) which allows one to communicate with [FreeTON](https://freeton.org) blockchain in Ruby.
7
7
 
@@ -9,7 +9,7 @@ Note that there're 2 types of versions:
9
9
  * `TonSdk::VERSION` - the version of the gem
10
10
  * `TonSdk::NATIVE_SDK_VERSION` - the version of the original SDK
11
11
 
12
- and they don't necessarily have to match each other.
12
+ and they may not always match each other.
13
13
 
14
14
 
15
15
 
@@ -549,43 +549,33 @@ module TonSdk
549
549
  end
550
550
 
551
551
  class AbiContract
552
- attr_reader :abi_version, :header, :functions, :events, :data
552
+ attr_reader :abi_version, :header, :functions, :events, :data, :fields
553
553
 
554
- def initialize(abi_version: nil, header: [], functions: [], events: [], data: [])
554
+ def initialize(
555
+ abi_version: nil,
556
+ header: [],
557
+ functions: [],
558
+ events: [],
559
+ data: [],
560
+ fields: []
561
+ )
555
562
  @abi_version = abi_version
556
-
557
- # in case if an argument has been passed as nil,
558
- # a default value should be used instead
559
-
560
- @header = header || []
561
- @functions = functions || []
562
- @events = events || []
563
- @data = data || []
563
+ @header = header
564
+ @functions = functions
565
+ @events = events
566
+ @data = data
567
+ @fields = fields
564
568
  end
565
569
 
566
570
  def to_h
567
- @header.compact! if !@header.nil?
568
-
569
- fn_h_s = if !@functions.nil?
570
- @functions.compact.map(&:to_h)
571
- end
572
-
573
- ev_h_s = if !@events.nil?
574
- @events.compact.map(&:to_h)
575
- end
576
-
577
- dt_h_s = if !@data.nil?
578
- @data.compact.map(&:to_h)
579
- end
580
-
581
571
  {
582
572
  abi_version: @abi_version,
583
573
  :"ABI version" => @abi_version, #TODO
584
-
585
574
  header: @header,
586
- functions: fn_h_s,
587
- events: ev_h_s,
588
- data: dt_h_s,
575
+ functions: @functions&.map(&:to_h),
576
+ events: @events&.map(&:to_h),
577
+ data: @data&.map(&:to_h),
578
+ fields: @fields
589
579
  }
590
580
  end
591
581
 
@@ -610,12 +600,19 @@ module TonSdk
610
600
  j["data"].compact.map {|x| AbiData.from_json(x) }
611
601
  end
612
602
 
603
+ fl_s = if j["fields"].nil?
604
+ []
605
+ else
606
+ j["fields"].compact.map {|x| AbiParam.from_json(x) }
607
+ end
608
+
613
609
  self.new(
614
610
  abi_version: j["ABI version"],
615
611
  header: j["header"],
616
612
  functions: fn_s,
617
613
  events: ev_s,
618
- data: dt_s
614
+ data: dt_s,
615
+ fields: fl_s
619
616
  )
620
617
  end
621
618
  end
@@ -656,6 +653,9 @@ module TonSdk
656
653
  end
657
654
  end
658
655
 
656
+ ParamsOfDecodeAccountData = Struct.new(:abi, :data, keyword_init: true)
657
+ ResultOfDecodeData = Struct.new(:data)
658
+
659
659
 
660
660
  #
661
661
  # functions
@@ -772,5 +772,22 @@ module TonSdk
772
772
  end
773
773
  end
774
774
  end
775
+
776
+ def self.decode_account_data(ctx, params)
777
+ Interop::request_to_native_lib(ctx, "abi.decode_account_data", params) do |resp|
778
+ if resp.success?
779
+ yield NativeLibResponsetResult.new(
780
+ result: ResultOfDecodeData.new(
781
+ resp.result["data"]
782
+ )
783
+ )
784
+ else
785
+ yield resp
786
+ end
787
+ end
788
+ end
789
+
790
+
791
+
775
792
  end
776
793
  end
@@ -42,6 +42,7 @@ module TonSdk
42
42
  UNEXPECTED_CALLBACK_RESPONSE = 31
43
43
  CANNOT_PARSE_NUMBER = 32
44
44
  INTERNAL_ERROR = 33
45
+ INVALID_HANDLE = 34
45
46
  end
46
47
 
47
48
  ResultOfVersion = Struct.new(:version)
@@ -265,6 +265,11 @@ module TonSdk
265
265
  end
266
266
  end
267
267
 
268
+ EncryptionBoxInfo = Struct.new(:hdpath, :algorithm, :options, :public, keyword_init: true)
269
+ ParamsOfEncryptionBoxGetInfo = Struct.new(:encryption_box)
270
+ ResultOfEncryptionBoxGetInfo = Struct.new(:info)
271
+ RegisteredEncryptionBox = Struct.new(:handle)
272
+
268
273
 
269
274
  #
270
275
  # functions
@@ -762,5 +767,57 @@ module TonSdk
762
767
  end
763
768
  end
764
769
  end
770
+
771
+ def self.register_encryption_box(ctx, app_obj:)
772
+ client_callback = Proc.new do |type_, x|
773
+ app_res = app_obj.request(x["request_data"])
774
+ app_req_result = case app_res
775
+ in [:success, result]
776
+ TonSdk::Client::AppRequestResult.new(
777
+ type_: :ok,
778
+ result: result
779
+ )
780
+ in [:error, text]
781
+ TonSdk::Client::AppRequestResult.new(
782
+ type_: :error,
783
+ text: text
784
+ )
785
+ end
786
+
787
+ params = TonSdk::Client::ParamsOfResolveAppRequest.new(
788
+ app_request_id: x["app_request_id"],
789
+ result: app_req_result
790
+ )
791
+ TonSdk::Client.resolve_app_request(ctx, params)
792
+ end
793
+
794
+ Interop::request_to_native_lib(
795
+ ctx,
796
+ "crypto.register_encryption_box",
797
+ nil,
798
+ client_callback: client_callback,
799
+ is_single_thread_only: false
800
+ ) do |resp|
801
+ if resp.success?
802
+ yield NativeLibResponsetResult.new(
803
+ result: RegisteredEncryptionBox.new(resp.result["handle"])
804
+ )
805
+ else
806
+ yield resp
807
+ end
808
+ end
809
+ end
810
+
811
+ def self.encryption_box_get_info(ctx, params)
812
+ Interop::request_to_native_lib(ctx, "crypto.encryption_box_get_info", params) do |resp|
813
+ if resp.success?
814
+ yield NativeLibResponsetResult.new(
815
+ result: ResultOfEncryptionBoxGetInfo.new(resp.result["info"])
816
+ )
817
+ else
818
+ yield resp
819
+ end
820
+ end
821
+ end
765
822
  end
766
823
  end
@@ -217,8 +217,8 @@ module TonSdk
217
217
  end
218
218
  end
219
219
 
220
- ParamsOfQueryTransactionTree = Struct.new(:in_msg, :abi_registry, keyword_init: true) do
221
- def initialize(in_msg:, abi_registry: [])
220
+ ParamsOfQueryTransactionTree = Struct.new(:in_msg, :abi_registry, :timeout, keyword_init: true) do
221
+ def initialize(in_msg:, abi_registry: [], timeout: nil)
222
222
  super
223
223
  end
224
224
 
@@ -228,9 +228,28 @@ module TonSdk
228
228
  h
229
229
  end
230
230
  end
231
-
232
231
  ResultOfQueryTransactionTree = Struct.new(:messages, :transactions, keyword_init: true)
233
232
 
233
+ ParamsOfCreateBlockIterator = Struct.new(:start_time, :end_time, :shard_filter, :result, keyword_init: true)
234
+ RegisteredIterator = Struct.new(:handle)
235
+ ParamsOfResumeBlockIterator = Struct.new(:resume_state)
236
+ ParamsOfCreateTransactionIterator = Struct.new(:start_time, :end_time, :shard_filter, :accounts_filter, :result, :include_transfers, keyword_init: true)
237
+ ParamsOfResumeTransactionIterator = Struct.new(:resume_state, :accounts_filter, keyword_init: true) do
238
+ def initialize(resume_state:, accounts_filter: nil)
239
+ super
240
+ end
241
+ end
242
+ ParamsOfIteratorNext = Struct.new(:iterator, :limit, :return_resume_state, keyword_init: true) do
243
+ def initialize(iterator:, limit: nil, return_resume_state: nil)
244
+ super
245
+ end
246
+ end
247
+ ResultOfIteratorNext = Struct.new(:items, :has_more, :resume_state, keyword_init: true) do
248
+ def initialize(items: [], has_more:, resume_state: nil)
249
+ super
250
+ end
251
+ end
252
+
234
253
 
235
254
  #
236
255
  # functions
@@ -367,71 +386,148 @@ module TonSdk
367
386
  end
368
387
  end
369
388
  end
370
- end
371
389
 
372
- def self.batch_query(ctx, params)
373
- Interop::request_to_native_lib(ctx, "net.batch_query", params) do |resp|
374
- if resp.success?
375
- yield NativeLibResponsetResult.new(
376
- result: ResultOfBatchQuery.new(resp.result["results"])
377
- )
378
- else
379
- yield resp
390
+ def self.batch_query(ctx, params)
391
+ Interop::request_to_native_lib(ctx, "net.batch_query", params) do |resp|
392
+ if resp.success?
393
+ yield NativeLibResponsetResult.new(
394
+ result: ResultOfBatchQuery.new(resp.result["results"])
395
+ )
396
+ else
397
+ yield resp
398
+ end
380
399
  end
381
400
  end
382
- end
383
401
 
384
- def self.aggregate_collection(ctx, params)
385
- Interop::request_to_native_lib(ctx, "net.aggregate_collection", params) do |resp|
386
- if resp.success?
387
- yield NativeLibResponsetResult.new(
388
- result: ResultOfAggregateCollection.new(resp.result["values"])
389
- )
390
- else
391
- yield resp
402
+ def self.aggregate_collection(ctx, params)
403
+ Interop::request_to_native_lib(ctx, "net.aggregate_collection", params) do |resp|
404
+ if resp.success?
405
+ yield NativeLibResponsetResult.new(
406
+ result: ResultOfAggregateCollection.new(resp.result["values"])
407
+ )
408
+ else
409
+ yield resp
410
+ end
392
411
  end
393
412
  end
394
- end
395
413
 
396
- def self.get_endpoints(ctx, params)
397
- Interop::request_to_native_lib(ctx, "net.get_endpoints", params) do |resp|
398
- if resp.success?
399
- yield NativeLibResponsetResult.new(
400
- result: ResultOfGetEndpoints.new(
401
- query: resp.result["query"],
402
- endpoints: resp.result["endpoints"],
414
+ def self.get_endpoints(ctx, params)
415
+ Interop::request_to_native_lib(ctx, "net.get_endpoints", params) do |resp|
416
+ if resp.success?
417
+ yield NativeLibResponsetResult.new(
418
+ result: ResultOfGetEndpoints.new(
419
+ query: resp.result["query"],
420
+ endpoints: resp.result["endpoints"],
421
+ )
403
422
  )
404
- )
405
- else
406
- yield resp
423
+ else
424
+ yield resp
425
+ end
407
426
  end
408
427
  end
409
- end
410
428
 
411
- def self.query_counterparties(ctx, params)
412
- Interop::request_to_native_lib(ctx, "net.query_counterparties", params) do |resp|
413
- if resp.success?
414
- yield NativeLibResponsetResult.new(
415
- result: ResultOfQueryCollection.new(resp.result["result"])
416
- )
417
- else
418
- yield resp
429
+ def self.query_counterparties(ctx, params)
430
+ Interop::request_to_native_lib(ctx, "net.query_counterparties", params) do |resp|
431
+ if resp.success?
432
+ yield NativeLibResponsetResult.new(
433
+ result: ResultOfQueryCollection.new(resp.result["result"])
434
+ )
435
+ else
436
+ yield resp
437
+ end
419
438
  end
420
439
  end
421
- end
422
440
 
423
- def self.query_transaction_tree(ctx, params)
424
- Interop::request_to_native_lib(ctx, "net.query_transaction_tree", params) do |resp|
425
- if resp.success?
426
- yield NativeLibResponsetResult.new(
427
- result: ResultOfQueryTransactionTree.new(
428
- messages: resp.result["messages"],
429
- transactions: resp.result["transactions"],
441
+ def self.query_transaction_tree(ctx, params)
442
+ Interop::request_to_native_lib(ctx, "net.query_transaction_tree", params) do |resp|
443
+ if resp.success?
444
+ yield NativeLibResponsetResult.new(
445
+ result: ResultOfQueryTransactionTree.new(
446
+ messages: resp.result["messages"],
447
+ transactions: resp.result["transactions"],
448
+ )
430
449
  )
431
- )
432
- else
433
- yield resp
450
+ else
451
+ yield resp
452
+ end
434
453
  end
435
454
  end
455
+
456
+ def self.create_block_iterator(ctx, params)
457
+ Interop::request_to_native_lib(ctx, "net.create_block_iterator", params) do |resp|
458
+ if resp.success?
459
+ yield NativeLibResponsetResult.new(
460
+ result: RegisteredIterator.new(resp.result["handle"])
461
+ )
462
+ else
463
+ yield resp
464
+ end
465
+ end
466
+ end
467
+
468
+ def self.resume_block_iterator(ctx, params)
469
+ Interop::request_to_native_lib(ctx, "net.resume_block_iterator", params) do |resp|
470
+ if resp.success?
471
+ yield NativeLibResponsetResult.new(
472
+ result: RegisteredIterator.new(resp.result["handle"])
473
+ )
474
+ else
475
+ yield resp
476
+ end
477
+ end
478
+ end
479
+
480
+ def self.create_transaction_iterator(ctx, params)
481
+ Interop::request_to_native_lib(ctx, "net.create_transaction_iterator", params) do |resp|
482
+ if resp.success?
483
+ yield NativeLibResponsetResult.new(
484
+ result: RegisteredIterator.new(resp.result["handle"])
485
+ )
486
+ else
487
+ yield resp
488
+ end
489
+ end
490
+ end
491
+
492
+ def self.resume_transaction_iterator(ctx, params)
493
+ Interop::request_to_native_lib(ctx, "net.resume_transaction_iterator", params) do |resp|
494
+ if resp.success?
495
+ yield NativeLibResponsetResult.new(
496
+ result: RegisteredIterator.new(resp.result["handle"])
497
+ )
498
+ else
499
+ yield resp
500
+ end
501
+ end
502
+ end
503
+
504
+ def self.iterator_next(ctx, params)
505
+ Interop::request_to_native_lib(ctx, "net.iterator_next", params) do |resp|
506
+ if resp.success?
507
+ yield NativeLibResponsetResult.new(
508
+ result: ResultOfIteratorNext.new(
509
+ items: resp.result["items"],
510
+ has_more: resp.result["has_more"],
511
+ resume_state: resp.result["resume_state"]
512
+ )
513
+ )
514
+ else
515
+ yield resp
516
+ end
517
+ end
518
+ end
519
+
520
+ def self.remove_iterator(ctx, params)
521
+ Interop::request_to_native_lib(ctx, "net.remove_iterator", params) do |resp|
522
+ if resp.success?
523
+ yield NativeLibResponsetResult.new(
524
+ result: nil
525
+ )
526
+ else
527
+ yield resp
528
+ end
529
+ end
530
+ end
531
+
436
532
  end
437
533
  end
@@ -51,6 +51,9 @@ module TonSdk
51
51
  ParamsOfDecompressZstd = Struct.new(:compressed)
52
52
  ResultOfDecompressZstd = Struct.new(:decompressed)
53
53
 
54
+ ParamsOfGetAddressType = Struct.new(:address)
55
+ ResultOfGetAddressType = Struct.new(:address_type)
56
+
54
57
 
55
58
  #
56
59
  # functions
@@ -60,7 +63,7 @@ module TonSdk
60
63
  Interop::request_to_native_lib(ctx, "utils.convert_address", params) do |resp|
61
64
  if resp.success?
62
65
  yield NativeLibResponsetResult.new(
63
- result: Utils::ResultOfConvertAddress.new(resp.result["address"])
66
+ result: ResultOfConvertAddress.new(resp.result["address"])
64
67
  )
65
68
  else
66
69
  yield resp
@@ -72,7 +75,7 @@ module TonSdk
72
75
  Interop::request_to_native_lib(ctx, "utils.calc_storage_fee", params) do |resp|
73
76
  if resp.success?
74
77
  yield NativeLibResponsetResult.new(
75
- result: Utils::ResultOfCalcStorageFee.new(resp.result["fee"])
78
+ result: ResultOfCalcStorageFee.new(resp.result["fee"])
76
79
  )
77
80
  else
78
81
  yield resp
@@ -84,7 +87,7 @@ module TonSdk
84
87
  Interop::request_to_native_lib(ctx, "utils.compress_zstd", params) do |resp|
85
88
  if resp.success?
86
89
  yield NativeLibResponsetResult.new(
87
- result: Utils::ResultOfCompressZstd.new(resp.result["compressed"])
90
+ result: ResultOfCompressZstd.new(resp.result["compressed"])
88
91
  )
89
92
  else
90
93
  yield resp
@@ -96,7 +99,19 @@ module TonSdk
96
99
  Interop::request_to_native_lib(ctx, "utils.decompress_zstd", params) do |resp|
97
100
  if resp.success?
98
101
  yield NativeLibResponsetResult.new(
99
- result: Utils::ParamsOfDecompressZstd.new(resp.result["decompressed"])
102
+ result: ParamsOfDecompressZstd.new(resp.result["decompressed"])
103
+ )
104
+ else
105
+ yield resp
106
+ end
107
+ end
108
+ end
109
+
110
+ def self.get_address_type(ctx, params)
111
+ Interop::request_to_native_lib(ctx, "utils.get_address_type", params) do |resp|
112
+ if resp.success?
113
+ yield NativeLibResponsetResult.new(
114
+ result: ResultOfGetAddressType.new(resp.result["address_type"])
100
115
  )
101
116
  else
102
117
  yield resp
@@ -1,4 +1,4 @@
1
1
  module TonSdk
2
- VERSION = "1.16.0"
3
- NATIVE_SDK_VERSION = "1.16.0"
2
+ VERSION = "1.19.0"
3
+ NATIVE_SDK_VERSION = "1.19.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ton_sdk_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.0
4
+ version: 1.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Maslakov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-29 00:00:00.000000000 Z
11
+ date: 2021-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi