ton_sdk_client 1.26.0 → 1.34.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: 6089c778489c542c5be6b2f08aaa25b658b0de1bc82cea166a36fe6005e6430e
4
- data.tar.gz: 05511b5132c85588c2f2d9c9c26fc1681fa08ebecbf4445f7d4171ae997e9fc7
3
+ metadata.gz: 5a7f0b6efe10b27110b81583c88d1001e261d4a65d5b244698c7fb1f6f948e1c
4
+ data.tar.gz: c589d48fba0d43db0eaeebb1f0997414d9b27a64b84d05f0815a2a5e590f9b9b
5
5
  SHA512:
6
- metadata.gz: a5287864732773d988a8a668e6a19a99d8c199bfbf59ddd913924c334771bcaf43b64ed1ed423ceb67270c5dfe1ad2a534cfb5251d2562981b2ff15351e9cc92
7
- data.tar.gz: d058acfb7188d6e5c96a2b01294d90494138254ebfbf991f9ba97990c1b191cb10a0746a9247302bb610a6b42ce050af5b8e48cc12992c374c9ee30ab1d8b79d
6
+ metadata.gz: b596337a82d897dc1d7f5e8805525d34f4121e052f22a1ebdc8253c87d1199347c658e89f0874cac8abdd5f1d9d7f2863a882be40ba92a2f9ccef80a39ea84d8
7
+ data.tar.gz: b156904a3e7d0087c1e110f9d77dbecd52e660811f82fabad23a6b0a6fbf59e2c436e0efb07bd05cdc7a2dd74c6b2e7de5b0051be89058d19a061286708d33a5
data/CHANGELOG.md CHANGED
@@ -2,17 +2,30 @@
2
2
 
3
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
4
 
5
+ 1.34.0
6
+ -----
7
+ * Changes https://github.com/tonlabs/ever-sdk/blob/master/CHANGELOG.md
8
+
9
+ 1.28.0
10
+ -----
11
+ * Changes `1.28.0` https://github.com/tonlabs/ever-sdk/blob/master/CHANGELOG.md#1280--2021-12-24
12
+ * Implement Debot module
13
+
14
+ 1.27.0
15
+ -----
16
+ * Changes `1.27.0` https://github.com/tonlabs/ever-sdk/blob/master/CHANGELOG.md#1270--2021-12-03
17
+
5
18
  1.26.0
6
19
  -----
7
- * Changes `1.26.0` https://github.com/tonlabs/TON-SDK/blob/master/CHANGELOG.md#1260--2021-11-25
20
+ * Changes `1.26.0` https://github.com/tonlabs/ever-sdk/blob/master/CHANGELOG.md#1260--2021-11-25
8
21
 
9
22
  1.25.0
10
23
  -----
11
- * Changes `1.25.0` https://github.com/tonlabs/TON-SDK/blob/master/CHANGELOG.md#1250--2021-11-08
24
+ * Changes `1.25.0` https://github.com/tonlabs/ever-sdk/blob/master/CHANGELOG.md#1250--2021-11-08
12
25
 
13
26
  1.24.0
14
27
  -----
15
- * Changes `1.24.0` https://github.com/tonlabs/TON-SDK/blob/master/CHANGELOG.md#1240--2021-10-18
28
+ * Changes `1.24.0` https://github.com/tonlabs/ever-sdk/blob/master/CHANGELOG.md#1240--2021-10-18
16
29
  * **BREAKING CHANGE** All Params now require keyword arguments
17
30
 
18
31
  1.20.x
data/README.md CHANGED
@@ -1,44 +1,39 @@
1
- # TON SDK client in Ruby and for Ruby
1
+ # Ever SDK (formerly TON SDK) client in Ruby and for Ruby
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/ton_sdk_client.svg)](https://rubygems.org/gems/ton_sdk_client)
4
- [![TON SDK version](https://img.shields.io/badge/TON%20SDK%20version-1.26.0-green)](https://github.com/tonlabs/TON-SDK/tree/1.26.0)
4
+ [![Ever SDK version](https://img.shields.io/badge/Ever%20SDK%20version-1.34.0-green)](https://github.com/tonlabs/ever-sdk/tree/1.34.0)
5
5
 
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.
6
+ Ruby gem-client bindings for [Ever SDK](https://github.com/tonlabs/ever-sdk) which allows one to communicate with [Everscale](https://everscale.network/) blockchain in Ruby.
7
7
 
8
- Note that there're 2 types of versions:
8
+ Note that there are 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
12
  and they may not always match each other.
13
13
 
14
-
15
-
16
14
  ## Installation
17
15
 
18
16
  Add this to the `Gemfile` of a project:
19
17
 
20
18
  ```ruby
21
- gem 'ton_sdk_client'
19
+ gem "ton_sdk_client"
22
20
  ```
23
21
  and run `bundle install`
24
22
 
25
23
  Alternatively install it directly
26
24
 
27
- ```
25
+ ```shell
28
26
  gem install ton_sdk_client
29
27
  ```
30
28
 
31
-
32
29
  ## Requirements
33
30
 
34
31
  The gem requires `tonclient` native library, appropriate for one's OS; the download links are at:
35
32
 
36
- https://github.com/tonlabs/TON-SDK/#download-precompiled-binaries
33
+ https://github.com/tonlabs/ever-sdk#download-precompiled-binaries
37
34
 
38
35
  Once downloaded, unpack it into a directory of your choice and then set an environmental variable `TON_CLIENT_NATIVE_LIB_NAME` pointing to the full path of a library.
39
36
 
40
- Also, check out the file `.ruby-version` to see which version has been used to develop the gem. Some older versions of ruby may work as well.
41
-
42
37
  ## Examples
43
38
 
44
39
  The examples are located in the `examples` directory, and they cover most the modules.
@@ -46,7 +41,7 @@ The examples are located in the `examples` directory, and they cover most the mo
46
41
  And here's a simple minimalistic one:
47
42
 
48
43
  ```ruby
49
- require 'ton_sdk_client'
44
+ require "ton_sdk_client"
50
45
 
51
46
  cfg = TonSdk::ClientConfig.new(
52
47
  network: TonSdk::NetworkConfig.new(
@@ -60,7 +55,7 @@ c_ctx = TonSdk::ClientContext.new(cfg.to_h.to_json)
60
55
  # next, call a method of a module you want passing a context to it
61
56
  TonSdk::Client.version(c_ctx.context) do |res|
62
57
 
63
- # 'res' is of type TonSdk::NativeLibResponsetResult
58
+ # 'res' is of type TonSdk::NativeLibResponseResult
64
59
  # holds either 'result' or 'error'
65
60
  # to check which one it is, use boolean methods:
66
61
  # res.success? or res.failure?
@@ -75,13 +70,12 @@ end
75
70
  ```
76
71
 
77
72
  In this case, the method `version()` requires only a `context` object. But most others require an additional 2nd argument appropriate for a certain method.
78
- Note that some methods, such some of the `Processing`, `Net`, `Tvm` modules, will continue to run for some time asyncronously delivering a result to a user, for instance, `Processing.process_message(...)` will do it via a callback
73
+ Note that some methods, such some of the `Processing`, `Net`, `Tvm` modules, will continue to run for some time asynchronously delivering a result to a user, for instance, `Processing.process_message(...)` will do it via a callback
79
74
 
80
75
  ```ruby
81
-
82
76
  my_callback = Proc.new do |a|
83
77
 
84
- # will be triggered multiple times, asyncronously
78
+ # will be triggered multiple times, asynchronously
85
79
  puts "callback fired: #{a}"
86
80
  end
87
81
 
@@ -93,32 +87,17 @@ Note that some methods, such some of the `Processing`, `Net`, `Tvm` modules, wil
93
87
  TonSdk::Processing.process_message(@c_ctx.context, pr1, my_callback) do |a|
94
88
  # [.......]
95
89
  end
96
-
97
90
  ```
98
91
 
99
92
  while other methods will deliver a result relatively fast, without a callback, and terminate.
100
93
 
101
-
102
- ## Implementation coverage, by modules
103
- - ✅ abi
104
- - ✅ boc
105
- - ✅ client
106
- - ✅ crypto
107
- - ✅ net
108
- - ✅ processing
109
- - ✅ tvm
110
- - ✅ utils
111
- - ✅ debot (unstable)
112
-
113
-
114
94
  ## Documentation
115
95
 
116
96
  * https://docs.ton.dev/86757ecb2/p/7941cd-what-is-ton-os
117
- * https://github.com/tonlabs/TON-SDK/tree/master/docs
118
- * https://github.com/tonlabs/TON-SDK/blob/master/tools/api.json
119
-
120
- Mind the current version of SDK when reading documentation and examples at https://github.com/tonlabs/TON-SDK
97
+ * https://github.com/tonlabs/ever-sdk/tree/master/docs
98
+ * https://github.com/tonlabs/ever-sdk/blob/master/tools/api.json
121
99
 
100
+ Mind the current version of SDK when reading documentation and examples at https://github.com/tonlabs/ever-sdk
122
101
 
123
102
  ## Using it as a developer
124
103
 
@@ -131,8 +110,7 @@ cd ton-client-ruby
131
110
 
132
111
  ### Install the dependencies
133
112
  ```
134
- gem install ffi
135
- gem install concurrent-ruby
113
+ gem install ffi concurrent-ruby rspec
136
114
  ```
137
115
  There may be other dependencies too, check the `gemspec` file for the full list of them.
138
116
 
@@ -153,16 +131,6 @@ or run a specific set of the tests:
153
131
  rspec spec/boc_spec.rb
154
132
  ```
155
133
 
156
- ## Test coverage, by modules
157
- - ✅ abi
158
- - ✅ boc
159
- - ✅ client
160
- - ✅ crypto
161
- - ✅ net
162
- - ✅ processing
163
- - ✅ tvm
164
- - ✅ utils
165
-
166
134
 
167
135
  ### Run the examples
168
136
 
@@ -180,40 +148,31 @@ factorize
180
148
  ```
181
149
 
182
150
 
183
- ## Tested at and with
151
+ ## Tested with
184
152
 
185
153
  * MacOS Catalina 10.15.5
186
154
  * Arch Linux x86_64
187
- * TON client native library: `TonSdk::NATIVE_SDK_VERSION`
188
-
189
155
 
190
156
  ## References
191
157
  * Wiki of the gem FFI: https://github.com/ffi/ffi/wiki ; callbacks: https://github.com/ffi/ffi/wiki/Callbacks
192
-
193
158
  * https://stackoverflow.com/questions/60689128/ruby-ffi-callback-return-values
194
159
 
195
-
196
160
  ## Notes
197
161
  * Rspec validators or matchers don't work in a block of a non main thread, therefore in the tests an intermediate variable is used to save a result, a block, and then validate it outside of a block.
198
-
199
- * Testing asyncronous code in Ruby is difficult and can incur hacks. Not all asyncronous code should be tested automatically via Rspec or other libraries, some should be instead tested manually once and then left alone thereafter:
162
+ * Testing asynchronous code in Ruby is difficult and can incur hacks. Not all asynchronous code should be tested automatically via Rspec or other libraries, some should be instead tested manually once and then left alone thereafter:
200
163
  https://www.mikeperham.com/2015/12/14/how-to-test-multithreaded-code
201
-
202
- * In some of the tests of the gem a "sleep" loop with a timeout are used to wait for an asyncronous operation to deliver a result, and this approach will do, although it can be replaced with a more idiomatic one. Oweing to the side effects, at times some tests may fail. When it happens, try to increase a timeout:
164
+ * In some of the tests of the gem a "sleep" loop with a timeout are used to wait for an asynchronous operation to deliver a result, and this approach will do, although it can be replaced with a more idiomatic one. Oweing to the side effects, at times some tests may fail. When it happens, try to increase a timeout:
203
165
 
204
166
  ```ruby
205
- timeout_at = get_timeout_for_async_operation()
167
+ timeout_at = get_timeout_for_async_operation
206
168
 
207
169
  # before, 5 seconds by default
208
- sleep(0.1) until @res || get_now() >= timeout_at
170
+ sleep(0.1) until @res || get_now >= timeout_at
209
171
 
210
172
  # after, longer timeout
211
- sleep(0.1) until @res || get_now() >= (timeout_at * 2)
173
+ sleep(0.1) until @res || get_now >= (timeout_at * 2)
212
174
  ```
213
175
 
214
- * No automatic generator has been used to generate Ruby classes or bindings to the SDK. Why not? Because no appropriate, simple and functional one has been found.
215
-
216
-
217
176
  ## Credits
218
177
 
219
178
  * [Tonlabs.io](https://tonlabs.io)
@@ -230,5 +189,6 @@ See the `CHANGELOG` file
230
189
 
231
190
  ## Community
232
191
 
233
- * news about FreeTON on Telegram https://t.me/ton_crystal_news
234
- * [FreeTON](https://freeton.org)
192
+ * Everscale News on Telegram https://t.me/everscale_news
193
+ * Everscale DEV Tools & SDK Telegram chat https://t.me/ever_sdk
194
+ * [Everscale](https://everscale.network/)
@@ -315,15 +315,16 @@ module TonSdk
315
315
  end
316
316
  end
317
317
 
318
- ParamsOfDecodeMessage = KwStruct.new(:abi, :message) do
319
- def initialize(abi:, message:)
318
+ ParamsOfDecodeMessage = KwStruct.new(:abi, :message, :allow_partial) do
319
+ def initialize(abi:, message:, allow_partial: false)
320
320
  super
321
321
  end
322
322
 
323
323
  def to_h
324
324
  {
325
325
  abi: abi&.to_h,
326
- message: message
326
+ message: message,
327
+ allow_partial: allow_partial
327
328
  }
328
329
  end
329
330
  end
@@ -391,8 +392,8 @@ module TonSdk
391
392
  end
392
393
  end
393
394
 
394
- ParamsOfDecodeMessageBody = KwStruct.new(:abi, :body, :is_internal) do
395
- def initialize(abi:, body:, is_internal:)
395
+ ParamsOfDecodeMessageBody = KwStruct.new(:abi, :body, :is_internal, :allow_partial) do
396
+ def initialize(abi:, body:, is_internal:, allow_partial: false)
396
397
  super
397
398
  end
398
399
 
@@ -400,7 +401,8 @@ module TonSdk
400
401
  {
401
402
  abi: abi&.to_h,
402
403
  body: body,
403
- is_internal: is_internal
404
+ is_internal: is_internal,
405
+ allow_partial: allow_partial
404
406
  }
405
407
  end
406
408
  end
@@ -725,11 +727,16 @@ module TonSdk
725
727
  end
726
728
  end
727
729
 
728
- ParamsOfDecodeAccountData = KwStruct.new(:abi, :data) do
730
+ ParamsOfDecodeAccountData = KwStruct.new(:abi, :data, :allow_partial) do
731
+ def initialize(abi:, data:, allow_partial: false)
732
+ super
733
+ end
734
+
729
735
  def to_h
730
736
  {
731
737
  abi: abi&.to_h,
732
- data: data
738
+ data: data,
739
+ allow_partial: allow_partial
733
740
  }
734
741
  end
735
742
  end
@@ -756,11 +763,29 @@ module TonSdk
756
763
 
757
764
  ResultOfUpdateInitialData = KwStruct.new(:data)
758
765
 
759
- ParamsOfDecodeInitialData = KwStruct.new(:data, :abi) do
766
+ ParamsOfEncodeInitialData = KwStruct.new(:abi, :initial_data, :initial_pubkey, :boc_cache) do
767
+ def to_h
768
+ {
769
+ abi: abi&.to_h,
770
+ initial_data: initial_data,
771
+ initial_pubkey: initial_pubkey,
772
+ boc_cache: boc_cache&.to_h
773
+ }
774
+ end
775
+ end
776
+
777
+ ResultOfEncodeInitialData = KwStruct.new(:data)
778
+
779
+ ParamsOfDecodeInitialData = KwStruct.new(:data, :abi, :allow_partial) do
780
+ def initialize(data:, abi:, allow_partial: false)
781
+ super
782
+ end
783
+
760
784
  def to_h
761
785
  {
762
786
  data: data,
763
- abi: abi&.to_h
787
+ abi: abi&.to_h,
788
+ allow_partial: allow_partial
764
789
  }
765
790
  end
766
791
  end
@@ -779,6 +804,18 @@ module TonSdk
779
804
 
780
805
  ResultOfDecodeBoc = KwStruct.new(:data)
781
806
 
807
+ ParamsOfAbiEncodeBoc = KwStruct.new(:params, :data, :boc_cache) do
808
+ def to_h
809
+ {
810
+ params: params&.map(&:to_h),
811
+ data: data,
812
+ boc_cache: boc_cache&.to_h
813
+ }
814
+ end
815
+ end
816
+
817
+ ResultOfAbiEncodeBoc = KwStruct.new(:boc)
818
+
782
819
  #
783
820
  # functions
784
821
  #
@@ -923,6 +960,20 @@ module TonSdk
923
960
  end
924
961
  end
925
962
 
963
+ def self.encode_initial_data(ctx, params)
964
+ Interop::request_to_native_lib(ctx, "abi.encode_initial_data", params) do |resp|
965
+ if resp.success?
966
+ yield NativeLibResponseResult.new(
967
+ result: ResultOfEncodeInitialData.new(
968
+ data: resp.result["data"]
969
+ )
970
+ )
971
+ else
972
+ yield resp
973
+ end
974
+ end
975
+ end
976
+
926
977
  def self.decode_initial_data(ctx, params)
927
978
  Interop::request_to_native_lib(ctx, "abi.decode_initial_data", params) do |resp|
928
979
  if resp.success?
@@ -951,5 +1002,19 @@ module TonSdk
951
1002
  end
952
1003
  end
953
1004
  end
1005
+
1006
+ def self.encode_boc(ctx, params)
1007
+ Interop::request_to_native_lib(ctx, "abi.encode_boc", params) do |resp|
1008
+ if resp.success?
1009
+ yield NativeLibResponseResult.new(
1010
+ result: ResultOfAbiEncodeBoc.new(
1011
+ boc: resp.result["boc"]
1012
+ )
1013
+ )
1014
+ else
1015
+ yield resp
1016
+ end
1017
+ end
1018
+ end
954
1019
  end
955
1020
  end
@@ -130,6 +130,20 @@ module TonSdk
130
130
 
131
131
  ResultOfEncodeTvc = KwStruct.new(:tvc)
132
132
 
133
+ ParamsOfEncodeExternalInMessage = KwStruct.new(:src, :dst, :init, :body, :boc_cache) do
134
+ def to_h
135
+ {
136
+ src: src,
137
+ dst: dst,
138
+ init: init,
139
+ body: body,
140
+ boc_cache: boc_cache&.to_h
141
+ }
142
+ end
143
+ end
144
+
145
+ ResultOfEncodeExternalInMessage = KwStruct.new(:message, :message_id)
146
+
133
147
  ParamsOfGetCompilerVersion = KwStruct.new(:code)
134
148
 
135
149
  ResultOfGetCompilerVersion = KwStruct.new(:version)
@@ -370,6 +384,21 @@ module TonSdk
370
384
  end
371
385
  end
372
386
 
387
+ def self.encode_external_in_message(ctx, params)
388
+ Interop::request_to_native_lib(ctx, "boc.encode_external_in_message", params) do |resp|
389
+ if resp.success?
390
+ yield NativeLibResponseResult.new(
391
+ result: ResultOfEncodeExternalInMessage.new(
392
+ message: resp.result["message"],
393
+ message_id: resp.result["message_id"]
394
+ )
395
+ )
396
+ else
397
+ yield resp
398
+ end
399
+ end
400
+ end
401
+
373
402
  def self.get_compiler_version(ctx, params)
374
403
  Interop::request_to_native_lib(ctx, "boc.get_compiler_version", params) do |resp|
375
404
  if resp.success?
@@ -122,6 +122,23 @@ module TonSdk
122
122
  end
123
123
  end
124
124
 
125
+ def self.config(ctx)
126
+ Interop::request_to_native_lib(ctx, "client.config") do |resp|
127
+ if resp.success?
128
+ yield NativeLibResponseResult.new(
129
+ result: ClientConfig.new(
130
+ network: resp.result["network"],
131
+ crypto: resp.result["crypto"],
132
+ abi: resp.result["abi"],
133
+ boc: resp.result["boc"]
134
+ )
135
+ )
136
+ else
137
+ yield resp
138
+ end
139
+ end
140
+ end
141
+
125
142
  def self.get_api_reference(ctx)
126
143
  Interop::request_to_native_lib(ctx, "client.get_api_reference") do |resp|
127
144
  if resp.success?
@@ -15,6 +15,9 @@ module TonSdk
15
15
  :latency_detection_interval,
16
16
  :max_latency,
17
17
  :query_timeout,
18
+ :queries_protocol,
19
+ :first_remp_status_timeout,
20
+ :next_remp_status_timeout,
18
21
  :access_key
19
22
  ) do
20
23
  def initialize(
@@ -31,12 +34,20 @@ module TonSdk
31
34
  latency_detection_interval: 60000,
32
35
  max_latency: 60000,
33
36
  query_timeout: 60000,
37
+ queries_protocol: nil,
38
+ first_remp_status_timeout: nil,
39
+ next_remp_status_timeout: nil,
34
40
  access_key: nil
35
41
  )
36
42
  super
37
43
  end
38
44
  end
39
45
 
46
+ module NetworkQueriesProtocol
47
+ HTTP = "HTTP".freeze
48
+ WS = "WS".freeze
49
+ end
50
+
40
51
  AbiConfig = KwStruct.new(
41
52
  :workchain,
42
53
  :message_expiration_timeout,
@@ -63,5 +74,4 @@ module TonSdk
63
74
  }
64
75
  end
65
76
  end
66
-
67
77
  end