ton_sdk_client 1.9.0 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -132,12 +132,12 @@ module TonSdk
132
132
  def self.request_to_native_lib(
133
133
  ctx,
134
134
  function_name,
135
- function_params_json = nil,
135
+ function_params = nil,
136
136
  client_callback: nil,
137
- is_single_thread_only: trfue
137
+ is_single_thread_only: true
138
138
  )
139
139
  function_name_tc_str = TcStringData.from_string(function_name)
140
- function_params_json_str = function_params_json || ""
140
+ function_params_json_str = function_params&.to_h.to_json || ""
141
141
  function_params_json_tc_str = TcStringData.from_string(function_params_json_str)
142
142
 
143
143
  @sm = Concurrent::Semaphore.new(1)
@@ -18,7 +18,7 @@ module TonSdk
18
18
  WEBSOCKET_DISCONNECTED = 610
19
19
  NOT_SUPPORTED = 611
20
20
  NO_ENDPOINTS_PROVIDED = 612
21
- GRAPHQL_WEBSOCKET_INIT_ERROR = 613,
21
+ GRAPHQL_WEBSOCKET_INIT_ERROR = 613
22
22
  NETWORK_MODULE_RESUMED = 614
23
23
  end
24
24
 
@@ -37,20 +37,15 @@ module TonSdk
37
37
  end
38
38
  end
39
39
 
40
- class ParamsOfQueryCollection
41
- attr_reader :collection, :filter, :result, :order, :limit
42
-
40
+ ParamsOfQueryCollection = Struct.new(:collection, :filter, :result, :order, :limit, keyword_init: true) do
43
41
  def initialize(collection: , filter: nil, result: , order: [], limit: nil)
44
- @collection = collection
45
- @filter = filter
46
- @result = result
47
- @order = order
48
- @limit = limit
42
+ super
49
43
  end
50
44
 
51
45
  def to_h
52
- ord_h_s = if !@order.nil?
53
- @order.map do |x|
46
+ h = super
47
+ ord_h_s = if !self.order.nil?
48
+ self.order.map do |x|
54
49
  {
55
50
  path: x.path,
56
51
  direction: x.direction.to_s.upcase
@@ -58,146 +53,54 @@ module TonSdk
58
53
  end
59
54
  end
60
55
 
61
- {
62
- collection: @collection,
63
- filter: @filter,
64
- result: @result,
65
- order: ord_h_s,
66
- limit: @limit
67
- }
56
+ h[:order] = ord_h_s
57
+ h
68
58
  end
69
59
  end
70
60
 
71
- class ResultOfQueryCollection
72
- attr_reader :result
73
-
74
- def initialize(a)
75
- @result = a
76
- end
77
- end
78
-
79
- class ParamsOfWaitForCollection
80
- attr_reader :collection, :filter, :result, :timeout
81
-
61
+ ResultOfQueryCollection = Struct.new(:result)
62
+ ResultOfWaitForCollection = Struct.new(:result)
63
+ ResultOfQuery = Struct.new(:result)
64
+ ResultOfBatchQuery = Struct.new(:results)
65
+ ParamsOfWaitForCollection = Struct.new(:collection, :filter, :result, :timeout) do
82
66
  def initialize(collection:, filter: nil, result:, timeout: nil)
83
- @collection = collection
84
- @filter = filter
85
- @result = result
86
- @timeout = timeout
87
- end
88
-
89
- def to_h
90
- {
91
- collection: @collection,
92
- filter: @filter,
93
- result: @result,
94
- timeout: @timeout
95
- }
96
- end
97
- end
98
-
99
- class ResultOfWaitForCollection
100
- attr_reader :result
101
-
102
- def initialize(a)
103
- @result = a
67
+ super
104
68
  end
105
69
  end
106
70
 
107
- class ParamsOfSubscribeCollection
108
- attr_reader :collection, :filter, :result
109
-
71
+ ParamsOfSubscribeCollection = Struct.new(:collection, :filter, :result) do
110
72
  def initialize(collection:, filter: nil, result:)
111
- @collection = collection
112
- @filter = filter
113
- @result = result
73
+ super
114
74
  end
115
-
116
- def to_h
117
- {
118
- collection: @collection,
119
- filter: @filter,
120
- result: @result
121
- }
122
- end
123
- end
124
-
125
- class ResultOfSubscribeCollection
126
- attr_reader :handle
127
-
128
- def initialize(a)
129
- @handle = a
130
- end
131
-
132
- def to_h = { handle: @handle }
133
75
  end
134
76
 
135
- class ParamsOfQuery
136
- attr_reader :query, :variables
137
-
77
+ ResultOfSubscribeCollection = Struct.new(:handle)
78
+ ParamsOfQuery = Struct.new(:query, :variables) do
138
79
  def initialize(query:, variables: nil)
139
- @query = query
140
- @variables = variables
80
+ super
141
81
  end
142
-
143
- def to_h
144
- {
145
- query: @query,
146
- variables: @variables
147
- }
148
- end
149
- end
150
-
151
- class ResultOfQuery
152
- attr_reader :result
153
-
154
- def initialize(a)
155
- @result = a
156
- end
157
- end
158
-
159
- class ParamsOfFindLastShardBlock
160
- attr_reader :address
161
-
162
- def initialize(a)
163
- @address = a
164
- end
165
-
166
- def to_h = { address: @address }
167
82
  end
168
83
 
169
- class ResultOfFindLastShardBlock
170
- attr_reader :block_id
171
-
172
- def initialize(a)
173
- @block_id = a
174
- end
175
- end
176
-
177
- class EndpointsSet
178
- attr_reader :endpoints
179
-
180
- def initialize(a)
181
- @endpoints = a
182
- end
183
-
184
- def to_h = { endpoints: @endpoints }
185
- end
84
+ ParamsOfFindLastShardBlock = Struct.new(:address)
85
+ ResultOfFindLastShardBlock = Struct.new(:block_id)
86
+ EndpointsSet = Struct.new(:endpoints)
186
87
 
187
88
  class ParamsOfQueryOperation
89
+ private_class_method :new
90
+
188
91
  attr_reader :type_, :params
189
92
 
190
- def new_with_type_query_collection(params)
93
+ def self.new_with_type_query_collection(params)
191
94
  @type_ = :query_collection
192
95
  @params = params
193
96
  end
194
97
 
195
- def new_with_type_wait_for_collection(params)
98
+ def self.new_with_type_wait_for_collection(params)
196
99
  @type_ = :wait_for_collection
197
100
  @params = params
198
101
  end
199
102
 
200
- def new_with_type_aggregate_collection(params)
103
+ def self.new_with_type_aggregate_collection(params)
201
104
  @type_ = :aggregate_collection
202
105
  @params = params
203
106
  end
@@ -212,41 +115,23 @@ module TonSdk
212
115
  end
213
116
  end
214
117
 
215
- class ParamsOfBatchQuery
216
- attr_reader :operations
217
-
218
- def initialize(a)
219
- @operations = a
220
- end
221
-
222
- def to_h = { operations: @operations.compact.map(&:to_h) }
223
- end
224
-
225
- class ResultOfBatchQuery
226
- attr_reader :results
227
-
228
- def initialize(a)
229
- @results = a
118
+ ParamsOfBatchQuery = Struct.new(:operations) do
119
+ def to_h
120
+ {
121
+ operations: self.operations.compact.map(&:to_h)
122
+ }
230
123
  end
231
-
232
- def to_h = { results: @results }
233
124
  end
234
125
 
235
- class ParamsOfAggregateCollection
236
- attr_reader :collection, :filter, :fields
237
-
126
+ ParamsOfAggregateCollection = Struct.new(:collection, :filter, :fields) do
238
127
  def initialize(collection:, filter: nil, fields: [])
239
- @collection = collection
240
- @filter = filter
241
- @fields = fields
128
+ super
242
129
  end
243
130
 
244
131
  def to_h
245
- {
246
- collection: @collection,
247
- filter: @filter,
248
- fields: @fields.map(&:to_h)
249
- }
132
+ h = super
133
+ h[:fields] = self.fields.map(&:to_h)
134
+ h
250
135
  end
251
136
  end
252
137
 
@@ -277,16 +162,15 @@ module TonSdk
277
162
  end
278
163
  end
279
164
 
280
- class ResultOfAggregateCollection
281
- attr_reader :values
165
+ ResultOfAggregateCollection = Struct.new(:values)
282
166
 
283
- def initialize(a)
284
- @values = a
167
+ ParamsOfQueryCounterparties = Struct.new(:account, :result, :first, :after, keyword_init: true) do
168
+ def initialize(account:, result:, first: nil, after: nil)
169
+ super
285
170
  end
286
-
287
- def to_h = { values: @values }
288
171
  end
289
172
 
173
+ ResultOfGetEndpoints = Struct.new(:query, :endpoints, keyword_init: true)
290
174
 
291
175
 
292
176
  #
@@ -297,7 +181,7 @@ module TonSdk
297
181
  Interop::request_to_native_lib(
298
182
  ctx,
299
183
  "net.query_collection",
300
- params.to_h.to_json,
184
+ params,
301
185
  is_single_thread_only: false
302
186
  ) do |resp|
303
187
  if resp.success?
@@ -314,7 +198,7 @@ module TonSdk
314
198
  Interop::request_to_native_lib(
315
199
  ctx,
316
200
  "net.wait_for_collection",
317
- params.to_h.to_json,
201
+ params,
318
202
  is_single_thread_only: false
319
203
  ) do |resp|
320
204
  if resp.success?
@@ -328,7 +212,7 @@ module TonSdk
328
212
  end
329
213
 
330
214
  def self.unsubscribe(ctx, params)
331
- Interop::request_to_native_lib(ctx, "net.unsubscribe", params.to_h.to_json) do |resp|
215
+ Interop::request_to_native_lib(ctx, "net.unsubscribe", params) do |resp|
332
216
  if resp.success?
333
217
  yield NativeLibResponsetResult.new(
334
218
  result: ""
@@ -343,7 +227,7 @@ module TonSdk
343
227
  Interop::request_to_native_lib(
344
228
  ctx,
345
229
  "net.subscribe_collection",
346
- params.to_h.to_json,
230
+ params,
347
231
  client_callback: client_callback,
348
232
  is_single_thread_only: false
349
233
  ) do |resp|
@@ -358,7 +242,7 @@ module TonSdk
358
242
  end
359
243
 
360
244
  def self.query(ctx, params)
361
- Interop::request_to_native_lib(ctx, "net.query", params.to_h.to_json) do |resp|
245
+ Interop::request_to_native_lib(ctx, "net.query", params) do |resp|
362
246
  if resp.success?
363
247
  yield NativeLibResponsetResult.new(
364
248
  result: ResultOfQuery.new(resp.result["result"])
@@ -370,7 +254,7 @@ module TonSdk
370
254
  end
371
255
 
372
256
  def self.suspend(ctx)
373
- Interop::request_to_native_lib(ctx, "net.suspend", "") do |resp|
257
+ Interop::request_to_native_lib(ctx, "net.suspend") do |resp|
374
258
  if resp.success?
375
259
  yield NativeLibResponsetResult.new(result: "")
376
260
  else
@@ -380,7 +264,7 @@ module TonSdk
380
264
  end
381
265
 
382
266
  def self.resume(ctx)
383
- Interop::request_to_native_lib(ctx, "net.resume", "") do |resp|
267
+ Interop::request_to_native_lib(ctx, "net.resume") do |resp|
384
268
  if resp.success?
385
269
  yield NativeLibResponsetResult.new(result: "")
386
270
  else
@@ -390,7 +274,7 @@ module TonSdk
390
274
  end
391
275
 
392
276
  def self.find_last_shard_block(ctx, params)
393
- Interop::request_to_native_lib(ctx, "net.find_last_shard_block", params.to_h.to_json) do |resp|
277
+ Interop::request_to_native_lib(ctx, "net.find_last_shard_block", params) do |resp|
394
278
  if resp.success?
395
279
  yield NativeLibResponsetResult.new(
396
280
  result: ResultOfFindLastShardBlock.new(resp.result["block_id"])
@@ -402,7 +286,7 @@ module TonSdk
402
286
  end
403
287
 
404
288
  def self.fetch_endpoints(ctx)
405
- Interop::request_to_native_lib(ctx, "net.fetch_endpoints", nil) do |resp|
289
+ Interop::request_to_native_lib(ctx, "net.fetch_endpoints") do |resp|
406
290
  if resp.success?
407
291
  yield NativeLibResponsetResult.new(
408
292
  result: EndpointsSet.new(resp.result["endpoints"])
@@ -414,7 +298,7 @@ module TonSdk
414
298
  end
415
299
 
416
300
  def self.set_endpoints(ctx, params)
417
- Interop::request_to_native_lib(ctx, "net.set_endpoints", params.to_h.to_json) do |resp|
301
+ Interop::request_to_native_lib(ctx, "net.set_endpoints", params) do |resp|
418
302
  if resp.success?
419
303
  yield NativeLibResponsetResult.new(
420
304
  result: nil
@@ -427,7 +311,7 @@ module TonSdk
427
311
  end
428
312
 
429
313
  def self.batch_query(ctx, params)
430
- Interop::request_to_native_lib(ctx, "net.batch_query", params.to_h.to_json) do |resp|
314
+ Interop::request_to_native_lib(ctx, "net.batch_query", params) do |resp|
431
315
  if resp.success?
432
316
  yield NativeLibResponsetResult.new(
433
317
  result: ResultOfBatchQuery.new(resp.result["results"])
@@ -439,7 +323,7 @@ module TonSdk
439
323
  end
440
324
 
441
325
  def self.aggregate_collection(ctx, params)
442
- Interop::request_to_native_lib(ctx, "net.aggregate_collection", params.to_h.to_json) do |resp|
326
+ Interop::request_to_native_lib(ctx, "net.aggregate_collection", params) do |resp|
443
327
  if resp.success?
444
328
  yield NativeLibResponsetResult.new(
445
329
  result: ResultOfAggregateCollection.new(resp.result["values"])
@@ -449,4 +333,31 @@ module TonSdk
449
333
  end
450
334
  end
451
335
  end
336
+
337
+ def self.query_counterparties(ctx, params)
338
+ Interop::request_to_native_lib(ctx, "net.query_counterparties", params) do |resp|
339
+ if resp.success?
340
+ yield NativeLibResponsetResult.new(
341
+ result: ResultOfQueryCollection.new(resp.result["result"])
342
+ )
343
+ else
344
+ yield resp
345
+ end
346
+ end
347
+ end
348
+
349
+ def self.get_endpoints(ctx, params)
350
+ Interop::request_to_native_lib(ctx, "net.get_endpoints", params) do |resp|
351
+ if resp.success?
352
+ yield NativeLibResponsetResult.new(
353
+ result: ResultOfGetEndpoints.new(
354
+ query: resp.result["query"],
355
+ endpoints: resp.result["endpoints"],
356
+ )
357
+ )
358
+ else
359
+ yield resp
360
+ end
361
+ end
362
+ end
452
363
  end
@@ -23,19 +23,7 @@ module TonSdk
23
23
  end
24
24
  end
25
25
 
26
- class ResultOfSendMessage
27
- attr_reader :shard_block_id
28
-
29
- def initialize(a)
30
- @shard_block_id = a
31
- end
32
-
33
- def to_h
34
- {
35
- shard_block_id: @shard_block_id
36
- }
37
- end
38
- end
26
+ ResultOfSendMessage = Struct.new(:shard_block_id)
39
27
 
40
28
  class ParamsOfWaitForTransaction
41
29
  attr_reader :abi, :message, :shard_block_id, :send_events
@@ -141,30 +129,13 @@ module TonSdk
141
129
  end
142
130
  end
143
131
 
144
- class DecodedOutput
145
- attr_reader :out_messages, :output
146
-
132
+ DecodedOutput = Struct.new(:out_messages, :output) do
147
133
  def initialize(out_messages:, output: nil)
148
- @out_messages = out_messages
149
- @output = output
150
- end
151
-
152
- def to_h
153
- {
154
- out_messages: @out_messages,
155
- output: @output
156
- }
134
+ super
157
135
  end
158
136
  end
159
137
 
160
- class ParamsOfProcessMessage
161
- attr_reader :message_encode_params, :send_events
162
-
163
- def initialize(message_encode_params:, send_events:)
164
- @message_encode_params = message_encode_params
165
- @send_events = send_events
166
- end
167
-
138
+ ParamsOfProcessMessage = Struct.new(:message_encode_params, :send_events) do
168
139
  def to_h
169
140
  {
170
141
  message_encode_params: @message_encode_params.to_h,
@@ -186,7 +157,7 @@ module TonSdk
186
157
  Interop::request_to_native_lib(
187
158
  ctx,
188
159
  "processing.send_message",
189
- params.to_h.to_json,
160
+ params,
190
161
  client_callback: client_callback,
191
162
  is_single_thread_only: false
192
163
  ) do |resp|
@@ -208,7 +179,7 @@ module TonSdk
208
179
  Interop::request_to_native_lib(
209
180
  ctx,
210
181
  "processing.wait_for_transaction",
211
- params.to_h.to_json,
182
+ params,
212
183
  client_callback: client_callback,
213
184
  is_single_thread_only: false
214
185
  ) do |resp|
@@ -235,7 +206,7 @@ module TonSdk
235
206
  Interop::request_to_native_lib(
236
207
  ctx,
237
208
  "processing.process_message",
238
- params.to_h.to_json,
209
+ params,
239
210
  client_callback: client_callback,
240
211
  is_single_thread_only: false
241
212
  ) do |resp|