ton_sdk_client 1.22.0 → 1.27.0

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.
@@ -5,66 +5,134 @@ module TonSdk
5
5
  # types
6
6
  #
7
7
 
8
- ParamsOfParse = Struct.new(:boc)
9
- ResultOfParse = Struct.new(:parsed)
10
- ParamsOfParseShardstate = Struct.new(:boc, :id_, :workchain_id, keyword_init: true)
11
- ParamsOfGetBlockchainConfig = Struct.new(:block_boc)
12
- ResultOfGetBlockchainConfig = Struct.new(:config_boc)
8
+ ParamsOfParse = KwStruct.new(:boc)
9
+ ResultOfParse = KwStruct.new(:parsed)
10
+ ParamsOfParseShardstate = KwStruct.new(:boc, :id, :workchain_id)
11
+ ParamsOfGetBlockchainConfig = KwStruct.new(:block_boc)
12
+ ResultOfGetBlockchainConfig = KwStruct.new(:config_boc)
13
13
 
14
- ParamsOfGetBocHash = Struct.new(:boc)
15
- ResultOfGetBocHash = Struct.new(:hash)
16
- ParamsOfGetCodeFromTvc = Struct.new(:hash)
17
- ResultOfGetCodeFromTvc = Struct.new(:code)
18
- ParamsOfBocCacheGet = Struct.new(:boc_ref)
14
+ ParamsOfGetBocHash = KwStruct.new(:boc)
15
+ ResultOfGetBocHash = KwStruct.new(:hash)
19
16
 
20
- ResultOfBocCacheGet = Struct.new(:boc)
17
+ ParamsOfGetBocDepth = KwStruct.new(:boc)
18
+ ResultOfGetBocDepth = KwStruct.new(:depth)
19
+
20
+ ParamsOfGetCodeFromTvc = KwStruct.new(:tvc)
21
+ ResultOfGetCodeFromTvc = KwStruct.new(:code)
22
+ ParamsOfBocCacheGet = KwStruct.new(:boc_ref)
23
+
24
+ ResultOfBocCacheGet = KwStruct.new(:boc)
21
25
 
22
26
  class BocCacheType
23
- private_class_method :new
27
+ TYPES = [
28
+ :pinned,
29
+ :unpinned
30
+ ]
24
31
 
25
- attr_reader :type_, :pin
32
+ attr_reader :type, :pin
26
33
 
27
- def self.new_with_type_pinned(pin)
28
- @type_ = :pinned
34
+ def initialize(type:, pin: nil)
35
+ unless TYPES.include?(type)
36
+ raise ArgumentError.new("type #{type} is unknown; known types: #{TYPES}")
37
+ end
38
+ @type = type
29
39
  @pin = pin
30
40
  end
31
41
 
32
- def self.new_with_type_unpinned
33
- @type_ = :unpinned
42
+ def to_h
43
+ hash = {type: Helper.sym_to_capitalized_case_str(type)}
44
+ hash[:pin] = pin if type == :pinned
45
+ hash
34
46
  end
47
+ end
35
48
 
49
+ ParamsOfBocCacheSet = KwStruct.new(:boc, :cache_type) do
36
50
  def to_h
37
- h1 = {
38
- type: Helper.sym_to_capitalized_case_str(@type_)
51
+ {
52
+ boc: boc,
53
+ cache_type: cache_type.to_h
39
54
  }
55
+ end
56
+ end
40
57
 
41
- h2 = if @type_ == :pinned
42
- {
43
- pin: @pin
44
- }
45
- else
46
- { }
47
- end
58
+ ResultOfBocCacheSet = KwStruct.new(:boc_ref)
59
+ ParamsOfBocCacheUnpin = KwStruct.new(:pin, :boc_ref)
60
+ ParamsOfEncodeBoc = KwStruct.new(:builder, :boc_cache)
61
+ ResultOfEncodeBoc = KwStruct.new(:boc)
62
+
63
+ ParamsOfGetCodeSalt = KwStruct.new(:code, :boc_cache) do
64
+ def to_h
65
+ {
66
+ code: code,
67
+ boc_cache: boc_cache&.to_h
68
+ }
69
+ end
70
+ end
71
+
72
+ ResultOfGetCodeSalt = KwStruct.new(:salt)
73
+
74
+ ParamsOfSetCodeSalt = KwStruct.new(:code, :salt, :boc_cache) do
75
+ def to_h
76
+ {
77
+ code: code,
78
+ salt: salt,
79
+ boc_cache: boc_cache&.to_h
80
+ }
81
+ end
82
+ end
83
+
84
+ ResultOfSetCodeSalt = KwStruct.new(:code)
48
85
 
49
- h1.merge(h2)
86
+ ParamsOfDecodeTvc = KwStruct.new(:tvc, :boc_cache) do
87
+ def to_h
88
+ {
89
+ tvc: tvc,
90
+ boc_cache: boc_cache&.to_h
91
+ }
50
92
  end
51
93
  end
52
94
 
53
- ParamsOfBocCacheSet = Struct.new(:boc, :cache_type) do
95
+ ResultOfDecodeTvc = KwStruct.new(
96
+ :code,
97
+ :code_hash,
98
+ :code_depth,
99
+ :data,
100
+ :data_hash,
101
+ :data_depth,
102
+ :library,
103
+ :tick,
104
+ :tock,
105
+ :split_depth,
106
+ :compiler_version
107
+ )
108
+
109
+ ParamsOfEncodeTvc = KwStruct.new(
110
+ :code,
111
+ :data,
112
+ :library,
113
+ :tick,
114
+ :tock,
115
+ :split_depth,
116
+ :boc_cache
117
+ ) do
54
118
  def to_h
55
119
  {
56
- boc: @boc,
57
- cache_type: @cache_type.to_h
120
+ code: code,
121
+ data: data,
122
+ library: library,
123
+ tick: tick,
124
+ tock: tock,
125
+ split_depth: split_depth,
126
+ boc_cache: boc_cache&.to_h
58
127
  }
59
128
  end
60
129
  end
61
130
 
62
- ResultOfBocCacheSet = Struct.new(:boc_ref)
63
- ParamsOfBocCacheUnpin = Struct.new(:boc, :boc_ref)
64
- ParamsOfEncodeBoc = Struct.new(:builder, :boc_cache)
65
- ResultOfEncodeBoc = Struct.new(:boc)
131
+ ResultOfEncodeTvc = KwStruct.new(:tvc)
66
132
 
133
+ ParamsOfGetCompilerVersion = KwStruct.new(:code)
67
134
 
135
+ ResultOfGetCompilerVersion = KwStruct.new(:version)
68
136
 
69
137
  #
70
138
  # functions
@@ -73,8 +141,8 @@ module TonSdk
73
141
  def self.parse_message(ctx, params)
74
142
  Interop::request_to_native_lib(ctx, "boc.parse_message", params) do |resp|
75
143
  if resp.success?
76
- yield NativeLibResponsetResult.new(
77
- result: ResultOfParse.new(resp.result["parsed"])
144
+ yield NativeLibResponseResult.new(
145
+ result: ResultOfParse.new(parsed: resp.result["parsed"])
78
146
  )
79
147
  else
80
148
  yield resp
@@ -85,8 +153,8 @@ module TonSdk
85
153
  def self.parse_transaction(ctx, params)
86
154
  Interop::request_to_native_lib(ctx, "boc.parse_transaction", params) do |resp|
87
155
  if resp.success?
88
- yield NativeLibResponsetResult.new(
89
- result: ResultOfParse.new(resp.result["parsed"])
156
+ yield NativeLibResponseResult.new(
157
+ result: ResultOfParse.new(parsed: resp.result["parsed"])
90
158
  )
91
159
  else
92
160
  yield resp
@@ -97,8 +165,8 @@ module TonSdk
97
165
  def self.parse_account(ctx, params)
98
166
  Interop::request_to_native_lib(ctx, "boc.parse_account", params) do |resp|
99
167
  if resp.success?
100
- yield NativeLibResponsetResult.new(
101
- result: ResultOfParse.new(resp.result["parsed"])
168
+ yield NativeLibResponseResult.new(
169
+ result: ResultOfParse.new(parsed: resp.result["parsed"])
102
170
  )
103
171
  else
104
172
  yield resp
@@ -109,8 +177,8 @@ module TonSdk
109
177
  def self.parse_block(ctx, params)
110
178
  Interop::request_to_native_lib(ctx, "boc.parse_block", params) do |resp|
111
179
  if resp.success?
112
- yield NativeLibResponsetResult.new(
113
- result: ResultOfParse.new(resp.result["parsed"])
180
+ yield NativeLibResponseResult.new(
181
+ result: ResultOfParse.new(parsed: resp.result["parsed"])
114
182
  )
115
183
  else
116
184
  yield resp
@@ -121,8 +189,20 @@ module TonSdk
121
189
  def self.parse_shardstate(ctx, params)
122
190
  Interop::request_to_native_lib(ctx, "boc.parse_shardstate", params) do |resp|
123
191
  if resp.success?
124
- yield NativeLibResponsetResult.new(
125
- result: ResultOfParse.new(resp.result["parsed"])
192
+ yield NativeLibResponseResult.new(
193
+ result: ResultOfParse.new(parsed: resp.result["parsed"])
194
+ )
195
+ else
196
+ yield resp
197
+ end
198
+ end
199
+ end
200
+
201
+ def self.get_boc_hash(ctx, params)
202
+ Interop::request_to_native_lib(ctx, "boc.get_boc_hash", params) do |resp|
203
+ if resp.success?
204
+ yield NativeLibResponseResult.new(
205
+ result: ResultOfGetBocHash.new(hash: resp.result["hash"])
126
206
  )
127
207
  else
128
208
  yield resp
@@ -133,8 +213,10 @@ module TonSdk
133
213
  def self.get_blockchain_config(ctx, params)
134
214
  Interop::request_to_native_lib(ctx, "boc.get_blockchain_config", params) do |resp|
135
215
  if resp.success?
136
- yield NativeLibResponsetResult.new(
137
- result: ResultOfGetBlockchainConfig.new(resp.result["config_boc"])
216
+ yield NativeLibResponseResult.new(
217
+ result: ResultOfGetBlockchainConfig.new(
218
+ config_boc: resp.result["config_boc"]
219
+ )
138
220
  )
139
221
  else
140
222
  yield resp
@@ -142,11 +224,13 @@ module TonSdk
142
224
  end
143
225
  end
144
226
 
145
- def self.get_boc_hash(ctx, params)
146
- Interop::request_to_native_lib(ctx, "boc.get_boc_hash", params) do |resp|
227
+ def self.get_boc_depth(ctx, params)
228
+ Interop::request_to_native_lib(ctx, "boc.get_boc_depth", params) do |resp|
147
229
  if resp.success?
148
- yield NativeLibResponsetResult.new(
149
- result: ResultOfGetBocHash.new(resp.result["hash"])
230
+ yield NativeLibResponseResult.new(
231
+ result: ResultOfGetBocDepth.new(
232
+ depth: resp.result["depth"]
233
+ )
150
234
  )
151
235
  else
152
236
  yield resp
@@ -157,8 +241,8 @@ module TonSdk
157
241
  def self.get_code_from_tvc(ctx, params)
158
242
  Interop::request_to_native_lib(ctx, "boc.get_code_from_tvc", params) do |resp|
159
243
  if resp.success?
160
- yield NativeLibResponsetResult.new(
161
- result: ResultOfGetCodeFromTvc.new(resp.result["code"])
244
+ yield NativeLibResponseResult.new(
245
+ result: ResultOfGetCodeFromTvc.new(code: resp.result["code"])
162
246
  )
163
247
  else
164
248
  yield resp
@@ -169,7 +253,7 @@ module TonSdk
169
253
  def self.cache_get(ctx, params)
170
254
  Interop::request_to_native_lib(ctx, "boc.cache_get", params) do |resp|
171
255
  if resp.success?
172
- yield NativeLibResponsetResult.new(
256
+ yield NativeLibResponseResult.new(
173
257
  result: ResultOfBocCacheGet.new(
174
258
  boc: resp.result["boc"]
175
259
  )
@@ -183,7 +267,7 @@ module TonSdk
183
267
  def self.cache_set(ctx, params)
184
268
  Interop::request_to_native_lib(ctx, "boc.cache_set", params) do |resp|
185
269
  if resp.success?
186
- yield NativeLibResponsetResult.new(
270
+ yield NativeLibResponseResult.new(
187
271
  result: ResultOfBocCacheSet.new(
188
272
  boc_ref: resp.result["boc_ref"]
189
273
  )
@@ -197,7 +281,7 @@ module TonSdk
197
281
  def self.cache_unpin(ctx, params)
198
282
  Interop::request_to_native_lib(ctx, "boc.cache_unpin", params) do |resp|
199
283
  if resp.success?
200
- yield NativeLibResponsetResult.new(
284
+ yield NativeLibResponseResult.new(
201
285
  result: nil
202
286
  )
203
287
  else
@@ -209,9 +293,9 @@ module TonSdk
209
293
  def self.encode_boc(ctx, params)
210
294
  Interop::request_to_native_lib(ctx, "boc.encode_boc", params) do |resp|
211
295
  if resp.success?
212
- yield NativeLibResponsetResult.new(
296
+ yield NativeLibResponseResult.new(
213
297
  result: ResultOfEncodeBoc.new(
214
- resp.result["boc"]
298
+ boc: resp.result["boc"]
215
299
  )
216
300
  )
217
301
  else
@@ -220,12 +304,78 @@ module TonSdk
220
304
  end
221
305
  end
222
306
 
223
- def self.get_blockchain_config(ctx, params)
224
- Interop::request_to_native_lib(ctx, "boc.get_blockchain_config", params) do |resp|
307
+ def self.get_code_salt(ctx, params)
308
+ Interop::request_to_native_lib(ctx, "boc.get_code_salt", params) do |resp|
225
309
  if resp.success?
226
- yield NativeLibResponsetResult.new(
227
- result: ResultOfGetBlockchainConfig.new(
228
- resp.result["config_boc"]
310
+ yield NativeLibResponseResult.new(
311
+ result: ResultOfGetCodeSalt.new(
312
+ salt: resp.result["salt"]
313
+ )
314
+ )
315
+ else
316
+ yield resp
317
+ end
318
+ end
319
+ end
320
+
321
+ def self.set_code_salt(ctx, params)
322
+ Interop::request_to_native_lib(ctx, "boc.set_code_salt", params) do |resp|
323
+ if resp.success?
324
+ yield NativeLibResponseResult.new(
325
+ result: ResultOfSetCodeSalt.new(
326
+ code: resp.result["code"]
327
+ )
328
+ )
329
+ else
330
+ yield resp
331
+ end
332
+ end
333
+ end
334
+
335
+ def self.decode_tvc(ctx, params)
336
+ Interop::request_to_native_lib(ctx, "boc.decode_tvc", params) do |resp|
337
+ if resp.success?
338
+ yield NativeLibResponseResult.new(
339
+ result: ResultOfDecodeTvc.new(
340
+ code: resp.result["code"],
341
+ code_depth: resp.result["code_depth"],
342
+ code_hash: resp.result["code_hash"],
343
+ data: resp.result["data"],
344
+ data_depth: resp.result["data_depth"],
345
+ data_hash: resp.result["data_hash"],
346
+ library: resp.result["library"],
347
+ tick: resp.result["tick"],
348
+ tock: resp.result["tock"],
349
+ split_depth: resp.result["split_depth"],
350
+ compiler_version: resp.result["compiler_version"]
351
+ )
352
+ )
353
+ else
354
+ yield resp
355
+ end
356
+ end
357
+ end
358
+
359
+ def self.encode_tvc(ctx, params)
360
+ Interop::request_to_native_lib(ctx, "boc.encode_tvc", params) do |resp|
361
+ if resp.success?
362
+ yield NativeLibResponseResult.new(
363
+ result: ResultOfEncodeTvc.new(
364
+ tvc: resp.result["tvc"]
365
+ )
366
+ )
367
+ else
368
+ yield resp
369
+ end
370
+ end
371
+ end
372
+
373
+ def self.get_compiler_version(ctx, params)
374
+ Interop::request_to_native_lib(ctx, "boc.get_compiler_version", params) do |resp|
375
+ if resp.success?
376
+ yield NativeLibResponseResult.new(
377
+ result: ResultOfGetCompilerVersion.new(
378
+ version: resp.result["version"]
229
379
  )
230
380
  )
231
381
  else
@@ -234,4 +384,4 @@ module TonSdk
234
384
  end
235
385
  end
236
386
  end
237
- end
387
+ end
@@ -43,24 +43,22 @@ module TonSdk
43
43
  CANNOT_PARSE_NUMBER = 32
44
44
  INTERNAL_ERROR = 33
45
45
  INVALID_HANDLE = 34
46
+ LOCAL_STORAGE_ERROR = 35
46
47
  end
47
48
 
48
- ResultOfVersion = Struct.new(:version)
49
- ResultOfGetApiReference = Struct.new(:api)
49
+ ResultOfVersion = KwStruct.new(:version)
50
+ ResultOfGetApiReference = KwStruct.new(:api)
50
51
 
51
- BuildInfoDependency = Struct.new(:name, :git_commit, keyword_init: true) do
52
+ BuildInfoDependency = KwStruct.new(:name, :git_commit) do
52
53
  def self.from_json(j)
53
54
  return nil if j.nil?
54
55
 
55
- self.new(
56
- j["name"],
57
- j["git_commit"]
58
- )
56
+ self.new(name: j["name"], git_commit: j["git_commit"])
59
57
  end
60
58
  end
61
59
 
62
- ResultOfBuildInfo = Struct.new(:build_number, :dependencies, keyword_init: true)
63
- ParamsOfAppRequest = Struct.new(:app_request_id, :request_data, keyword_init: true)
60
+ ResultOfBuildInfo = KwStruct.new(:build_number, :dependencies)
61
+ ParamsOfAppRequest = KwStruct.new(:app_request_id, :request_data)
64
62
 
65
63
  class AppRequestResult
66
64
  TYPES = [:ok, :error]
@@ -94,11 +92,11 @@ module TonSdk
94
92
  end
95
93
  end
96
94
 
97
- ParamsOfResolveAppRequest = Struct.new(:app_request_id, :result, keyword_init: true) do
95
+ ParamsOfResolveAppRequest = KwStruct.new(:app_request_id, :result) do
98
96
  def to_h
99
97
  {
100
- app_request_id: @app_request_id,
101
- result: @result.to_h
98
+ app_request_id: app_request_id,
99
+ result: result.to_h
102
100
  }
103
101
  end
104
102
  end
@@ -115,8 +113,8 @@ module TonSdk
115
113
  def self.version(ctx)
116
114
  Interop::request_to_native_lib(ctx, "client.version") do |resp|
117
115
  if resp.success?
118
- yield NativeLibResponsetResult.new(
119
- result: ResultOfVersion.new(resp.result["version"])
116
+ yield NativeLibResponseResult.new(
117
+ result: ResultOfVersion.new(version: resp.result["version"])
120
118
  )
121
119
  else
122
120
  yield resp
@@ -127,8 +125,8 @@ module TonSdk
127
125
  def self.get_api_reference(ctx)
128
126
  Interop::request_to_native_lib(ctx, "client.get_api_reference") do |resp|
129
127
  if resp.success?
130
- yield NativeLibResponsetResult.new(
131
- result: ResultOfGetApiReference.new(resp.result["api"])
128
+ yield NativeLibResponseResult.new(
129
+ result: ResultOfGetApiReference.new(api: resp.result["api"])
132
130
  )
133
131
  else
134
132
  yield resp
@@ -140,7 +138,7 @@ module TonSdk
140
138
  Interop::request_to_native_lib(ctx, "client.build_info") do |resp|
141
139
  if resp.success?
142
140
  dp_s = resp.result["dependencies"].map { |x| BuildInfoDependency.from_json(x) }
143
- yield NativeLibResponsetResult.new(
141
+ yield NativeLibResponseResult.new(
144
142
  result: ResultOfBuildInfo.new(
145
143
  build_number: resp.result["build_number"],
146
144
  dependencies: dp_s
@@ -155,7 +153,7 @@ module TonSdk
155
153
  def self.resolve_app_request(ctx, params)
156
154
  Interop::request_to_native_lib(ctx, "client.resolve_app_request", params) do |resp|
157
155
  if resp.success?
158
- yield NativeLibResponsetResult.new(
156
+ yield NativeLibResponseResult.new(
159
157
  result: ""
160
158
  )
161
159
  else
@@ -164,4 +162,4 @@ module TonSdk
164
162
  end
165
163
  end
166
164
  end
167
- end
165
+ end
@@ -1,5 +1,6 @@
1
1
  require 'json'
2
2
 
3
+ require_relative './kw_struct.rb'
3
4
  require_relative './interop.rb'
4
5
  require_relative './types.rb'
5
6
  require_relative './helper.rb'
@@ -12,6 +13,7 @@ require_relative './abi.rb'
12
13
  require_relative './boc.rb'
13
14
  require_relative './net.rb'
14
15
  require_relative './tvm.rb'
16
+ require_relative './proofs.rb'
15
17
  require_relative './processing.rb'
16
18
  require_relative './debot.rb'
17
19
 
@@ -38,7 +40,7 @@ module TonSdk
38
40
 
39
41
  Interop::tc_destroy_string(ptr)
40
42
  else
41
- raise SdkError.new("unable to create context")
43
+ raise SdkError.new(message: "unable to create context")
42
44
  end
43
45
  end
44
46
 
@@ -1,7 +1,7 @@
1
1
  module TonSdk
2
- CryptoConfig = Struct.new(:mnemonic_dictionary, :mnemonic_word_count, :hdkey_derivation_path, keyword_init: true)
3
- BocConfig = Struct.new(:cache_max_size)
4
- NetworkConfig = Struct.new(
2
+ CryptoConfig = KwStruct.new(:mnemonic_dictionary, :mnemonic_word_count, :hdkey_derivation_path)
3
+ BocConfig = KwStruct.new(:cache_max_size)
4
+ NetworkConfig = KwStruct.new(
5
5
  :server_address,
6
6
  :endpoints,
7
7
  :network_retries_count,
@@ -15,8 +15,7 @@ module TonSdk
15
15
  :latency_detection_interval,
16
16
  :max_latency,
17
17
  :query_timeout,
18
- :access_key,
19
- keyword_init: true
18
+ :access_key
20
19
  ) do
21
20
  def initialize(
22
21
  server_address: "",
@@ -38,11 +37,10 @@ module TonSdk
38
37
  end
39
38
  end
40
39
 
41
- AbiConfig = Struct.new(
40
+ AbiConfig = KwStruct.new(
42
41
  :workchain,
43
42
  :message_expiration_timeout,
44
- :message_expiration_timeout_grow_factor,
45
- keyword_init: true
43
+ :message_expiration_timeout_grow_factor
46
44
  ) do
47
45
  def initialize(
48
46
  workchain: nil,
@@ -53,7 +51,7 @@ module TonSdk
53
51
  end
54
52
  end
55
53
 
56
- ClientConfig = Struct.new(:network, :crypto, :abi, :boc, keyword_init: true) do
54
+ ClientConfig = KwStruct.new(:network, :crypto, :abi, :boc) do
57
55
  def to_h
58
56
  res = super.to_h
59
57