ton_sdk_client 1.10.0 → 1.16.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,140 +5,31 @@ module TonSdk
5
5
  # types
6
6
  #
7
7
 
8
- class ParamsOfParse
9
- attr_reader :boc
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)
10
13
 
11
- def initialize(a)
12
- @boc = a
13
- end
14
-
15
- def to_h = { boc: @boc }
16
- end
17
-
18
- class ResultOfParse
19
- attr_reader :parsed
20
-
21
- def initialize(a)
22
- @parsed = a
23
- end
24
- end
25
-
26
- class ParamsOfParseShardstate
27
- attr_reader :boc, :id, :workchain_id
28
-
29
- def initialize(boc:, id_:, workchain_id:)
30
- @boc = boc
31
- @id_ = id_
32
- @workchain_id = workchain_id
33
- end
34
-
35
- def to_h
36
- {
37
- boc: @boc,
38
- id: @id_,
39
- workchain_id: @workchain_id
40
- }
41
- end
42
- end
43
-
44
- class ParamsOfGetBlockchainConfig
45
- attr_reader :block_boc
46
-
47
- def initialize(a)
48
- @block_boc = a
49
- end
50
-
51
- def to_h
52
- {
53
- block_boc: @block_boc
54
- }
55
- end
56
- end
57
-
58
- class ResultOfGetBlockchainConfig
59
- attr_reader :config_boc
60
-
61
- def initialize(a)
62
- @config_boc = a
63
- end
64
- end
65
-
66
- class ParamsOfGetBocHash
67
- attr_reader :boc
68
-
69
- def initialize(a)
70
- @boc = a
71
- end
72
-
73
- def to_h
74
- {
75
- boc: @boc
76
- }
77
- end
78
- end
79
-
80
- class ResultOfGetBocHash
81
- attr_reader :hash
82
-
83
- def initialize(a)
84
- @hash = a
85
- end
86
- end
87
-
88
- class ParamsOfGetCodeFromTvc
89
- attr_reader :tvc
90
-
91
- def initialize(a)
92
- @tvc = a
93
- end
94
-
95
- def to_h
96
- {
97
- tvc: @tvc
98
- }
99
- end
100
- end
101
-
102
- class ResultOfGetCodeFromTvc
103
- attr_reader :code
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)
104
19
 
105
- def initialize(a)
106
- @code = a
107
- end
108
- end
109
-
110
- class ParamsOfBocCacheGet
111
- attr_reader :boc_ref
112
-
113
- def initialize(a)
114
- @boc_ref = a
115
- end
116
-
117
- def to_h = { boc_ref: @boc_ref }
118
- end
119
-
120
- class ResultOfBocCacheGet
121
- attr_reader :boc
122
-
123
- def initialize(boc: nil)
124
- @boc = boc
125
- end
126
- end
20
+ ResultOfBocCacheGet = Struct.new(:boc)
127
21
 
128
22
  class BocCacheType
129
- TYPES = [
130
- :pinned,
131
- :unpinned
132
- ]
23
+ private_class_method :new
133
24
 
134
25
  attr_reader :type_, :pin
135
26
 
136
- def new_with_type_pinned(pin)
27
+ def self.new_with_type_pinned(pin)
137
28
  @type_ = :pinned
138
29
  @pin = pin
139
30
  end
140
31
 
141
- def new_with_type_unpinned
32
+ def self.new_with_type_unpinned
142
33
  @type_ = :unpinned
143
34
  end
144
35
 
@@ -159,14 +50,7 @@ module TonSdk
159
50
  end
160
51
  end
161
52
 
162
- class ParamsOfBocCacheSet
163
- attr_reader :boc, :cache_type
164
-
165
- def initialize(boc:, cache_type:)
166
- @boc = boc
167
- @cache_type = cache_type
168
- end
169
-
53
+ ParamsOfBocCacheSet = Struct.new(:boc, :cache_type) do
170
54
  def to_h
171
55
  {
172
56
  boc: @boc,
@@ -175,75 +59,11 @@ module TonSdk
175
59
  end
176
60
  end
177
61
 
178
- class ResultOfBocCacheGet
179
- attr_reader :boc_ref
180
-
181
- def initialize(a)
182
- @boc_ref = a
183
- end
184
- end
185
-
186
- class ParamsOfBocCacheUnpin
187
- attr_reader :boc, :boc_ref
188
-
189
- def initialize(boc:, boc_ref: nil)
190
- @boc = boc
191
- @boc_ref = boc_ref
192
- end
193
-
194
- def to_h
195
- {
196
- boc: @boc,
197
- boc_ref: @boc_ref
198
- }
199
- end
200
- end
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)
201
66
 
202
- class ParamsOfEncodeBoc
203
- attr_reader :builder, :boc_cache
204
-
205
- def initialize(builder:, boc_cache: nil)
206
- @builder = builder
207
- @boc_cache = boc_cache
208
- end
209
-
210
- def to_h
211
- {
212
- boc: @boc,
213
- boc_ref: @boc_ref
214
- }
215
- end
216
- end
217
-
218
- class ResultOfEncodeBoc
219
- attr_reader :boc
220
-
221
- def initialize(a)
222
- @boc = a
223
- end
224
- end
225
-
226
- class ParamsOfGetBlockchainConfig
227
- attr_reader :block_boc
228
-
229
- def initialize(a)
230
- @block_boc = a
231
- end
232
-
233
- def to_h
234
- {
235
- block_boc: @block_boc
236
- }
237
- end
238
- end
239
-
240
- class ResultOfGetBlockchainConfig
241
- attr_reader :config_boc
242
-
243
- def initialize(a)
244
- @config_boc = a
245
- end
246
- end
247
67
 
248
68
 
249
69
  #
@@ -251,7 +71,7 @@ module TonSdk
251
71
  #
252
72
 
253
73
  def self.parse_message(ctx, params)
254
- Interop::request_to_native_lib(ctx, "boc.parse_message", params.to_h.to_json) do |resp|
74
+ Interop::request_to_native_lib(ctx, "boc.parse_message", params) do |resp|
255
75
  if resp.success?
256
76
  yield NativeLibResponsetResult.new(
257
77
  result: ResultOfParse.new(resp.result["parsed"])
@@ -263,7 +83,7 @@ module TonSdk
263
83
  end
264
84
 
265
85
  def self.parse_transaction(ctx, params)
266
- Interop::request_to_native_lib(ctx, "boc.parse_transaction", params.to_h.to_json) do |resp|
86
+ Interop::request_to_native_lib(ctx, "boc.parse_transaction", params) do |resp|
267
87
  if resp.success?
268
88
  yield NativeLibResponsetResult.new(
269
89
  result: ResultOfParse.new(resp.result["parsed"])
@@ -275,7 +95,7 @@ module TonSdk
275
95
  end
276
96
 
277
97
  def self.parse_account(ctx, params)
278
- Interop::request_to_native_lib(ctx, "boc.parse_account", params.to_h.to_json) do |resp|
98
+ Interop::request_to_native_lib(ctx, "boc.parse_account", params) do |resp|
279
99
  if resp.success?
280
100
  yield NativeLibResponsetResult.new(
281
101
  result: ResultOfParse.new(resp.result["parsed"])
@@ -287,7 +107,7 @@ module TonSdk
287
107
  end
288
108
 
289
109
  def self.parse_block(ctx, params)
290
- Interop::request_to_native_lib(ctx, "boc.parse_block", params.to_h.to_json) do |resp|
110
+ Interop::request_to_native_lib(ctx, "boc.parse_block", params) do |resp|
291
111
  if resp.success?
292
112
  yield NativeLibResponsetResult.new(
293
113
  result: ResultOfParse.new(resp.result["parsed"])
@@ -299,7 +119,7 @@ module TonSdk
299
119
  end
300
120
 
301
121
  def self.parse_shardstate(ctx, params)
302
- Interop::request_to_native_lib(ctx, "boc.parse_shardstate", params.to_h.to_json) do |resp|
122
+ Interop::request_to_native_lib(ctx, "boc.parse_shardstate", params) do |resp|
303
123
  if resp.success?
304
124
  yield NativeLibResponsetResult.new(
305
125
  result: ResultOfParse.new(resp.result["parsed"])
@@ -311,7 +131,7 @@ module TonSdk
311
131
  end
312
132
 
313
133
  def self.get_blockchain_config(ctx, params)
314
- Interop::request_to_native_lib(ctx, "boc.get_blockchain_config", params.to_h.to_json) do |resp|
134
+ Interop::request_to_native_lib(ctx, "boc.get_blockchain_config", params) do |resp|
315
135
  if resp.success?
316
136
  yield NativeLibResponsetResult.new(
317
137
  result: ResultOfGetBlockchainConfig.new(resp.result["config_boc"])
@@ -323,7 +143,7 @@ module TonSdk
323
143
  end
324
144
 
325
145
  def self.get_boc_hash(ctx, params)
326
- Interop::request_to_native_lib(ctx, "boc.get_boc_hash", params.to_h.to_json) do |resp|
146
+ Interop::request_to_native_lib(ctx, "boc.get_boc_hash", params) do |resp|
327
147
  if resp.success?
328
148
  yield NativeLibResponsetResult.new(
329
149
  result: ResultOfGetBocHash.new(resp.result["hash"])
@@ -335,7 +155,7 @@ module TonSdk
335
155
  end
336
156
 
337
157
  def self.get_code_from_tvc(ctx, params)
338
- Interop::request_to_native_lib(ctx, "boc.get_code_from_tvc", params.to_h.to_json) do |resp|
158
+ Interop::request_to_native_lib(ctx, "boc.get_code_from_tvc", params) do |resp|
339
159
  if resp.success?
340
160
  yield NativeLibResponsetResult.new(
341
161
  result: ResultOfGetCodeFromTvc.new(resp.result["code"])
@@ -347,7 +167,7 @@ module TonSdk
347
167
  end
348
168
 
349
169
  def self.cache_get(ctx, params)
350
- Interop::request_to_native_lib(ctx, "boc.cache_get", params.to_h.to_json) do |resp|
170
+ Interop::request_to_native_lib(ctx, "boc.cache_get", params) do |resp|
351
171
  if resp.success?
352
172
  yield NativeLibResponsetResult.new(
353
173
  result: ResultOfBocCacheGet.new(
@@ -361,7 +181,7 @@ module TonSdk
361
181
  end
362
182
 
363
183
  def self.cache_set(ctx, params)
364
- Interop::request_to_native_lib(ctx, "boc.cache_set", params.to_h.to_json) do |resp|
184
+ Interop::request_to_native_lib(ctx, "boc.cache_set", params) do |resp|
365
185
  if resp.success?
366
186
  yield NativeLibResponsetResult.new(
367
187
  result: ResultOfBocCacheSet.new(
@@ -375,7 +195,7 @@ module TonSdk
375
195
  end
376
196
 
377
197
  def self.cache_unpin(ctx, params)
378
- Interop::request_to_native_lib(ctx, "boc.cache_unpin", params.to_h.to_json) do |resp|
198
+ Interop::request_to_native_lib(ctx, "boc.cache_unpin", params) do |resp|
379
199
  if resp.success?
380
200
  yield NativeLibResponsetResult.new(
381
201
  result: nil
@@ -387,7 +207,7 @@ module TonSdk
387
207
  end
388
208
 
389
209
  def self.encode_boc(ctx, params)
390
- Interop::request_to_native_lib(ctx, "boc.encode_boc", params.to_h.to_json) do |resp|
210
+ Interop::request_to_native_lib(ctx, "boc.encode_boc", params) do |resp|
391
211
  if resp.success?
392
212
  yield NativeLibResponsetResult.new(
393
213
  result: ResultOfEncodeBoc.new(
@@ -401,7 +221,7 @@ module TonSdk
401
221
  end
402
222
 
403
223
  def self.get_blockchain_config(ctx, params)
404
- Interop::request_to_native_lib(ctx, "boc.get_blockchain_config", params.to_h.to_json) do |resp|
224
+ Interop::request_to_native_lib(ctx, "boc.get_blockchain_config", params) do |resp|
405
225
  if resp.success?
406
226
  yield NativeLibResponsetResult.new(
407
227
  result: ResultOfGetBlockchainConfig.new(
@@ -44,57 +44,22 @@ module TonSdk
44
44
  INTERNAL_ERROR = 33
45
45
  end
46
46
 
47
- class ResultOfVersion
48
- attr_reader :version
49
-
50
- def initialize(a)
51
- @version = a
52
- end
53
- end
54
-
55
- class ResultOfGetApiReference
56
- attr_reader :api
57
-
58
- def initialize(a)
59
- @api = a
60
- end
61
- end
62
-
63
- class BuildInfoDependency
64
- attr_reader :name, :git_commit
65
-
66
- def initialize(name:, git_commit:)
67
- @name = name
68
- @git_commit = git_commit
69
- end
47
+ ResultOfVersion = Struct.new(:version)
48
+ ResultOfGetApiReference = Struct.new(:api)
70
49
 
50
+ BuildInfoDependency = Struct.new(:name, :git_commit, keyword_init: true) do
71
51
  def self.from_json(j)
72
52
  return nil if j.nil?
73
53
 
74
54
  self.new(
75
- name: j["name"],
76
- git_commit: j["git_commit"]
55
+ j["name"],
56
+ j["git_commit"]
77
57
  )
78
58
  end
79
59
  end
80
60
 
81
- class ResultOfBuildInfo
82
- attr_reader :build_number, :dependencies
83
-
84
- def initialize(build_number:, dependencies:)
85
- @build_number = build_number
86
- @dependencies = dependencies
87
- end
88
- end
89
-
90
- class ParamsOfAppRequest
91
- attr_reader :app_request_id, :request_data
92
-
93
- def initialize(app_request_id:, request_data:)
94
- @app_request_id = app_request_id
95
- @request_data = request_data
96
- end
97
- end
61
+ ResultOfBuildInfo = Struct.new(:build_number, :dependencies, keyword_init: true)
62
+ ParamsOfAppRequest = Struct.new(:app_request_id, :request_data, keyword_init: true)
98
63
 
99
64
  class AppRequestResult
100
65
  TYPES = [:ok, :error]
@@ -128,14 +93,7 @@ module TonSdk
128
93
  end
129
94
  end
130
95
 
131
- class ParamsOfResolveAppRequest
132
- attr_reader :app_request_id, :result
133
-
134
- def initialize(app_request_id:, result:)
135
- @app_request_id = app_request_id
136
- @result = result
137
- end
138
-
96
+ ParamsOfResolveAppRequest = Struct.new(:app_request_id, :result, keyword_init: true) do
139
97
  def to_h
140
98
  {
141
99
  app_request_id: @app_request_id,
@@ -194,7 +152,7 @@ module TonSdk
194
152
  end
195
153
 
196
154
  def self.resolve_app_request(ctx, params)
197
- Interop::request_to_native_lib(ctx, "client.resolve_app_request", params.to_h.to_json) do |resp|
155
+ Interop::request_to_native_lib(ctx, "client.resolve_app_request", params) do |resp|
198
156
  if resp.success?
199
157
  yield NativeLibResponsetResult.new(
200
158
  result: ""
@@ -1,4 +1,5 @@
1
1
  require 'json'
2
+
2
3
  require_relative './interop.rb'
3
4
  require_relative './types.rb'
4
5
  require_relative './helper.rb'
@@ -14,6 +15,7 @@ require_relative './tvm.rb'
14
15
  require_relative './processing.rb'
15
16
  require_relative './debot.rb'
16
17
 
18
+
17
19
  module TonSdk
18
20
  class ClientContext
19
21
  attr_reader :context