ton_sdk_client 1.11.0 → 1.16.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/README.md +1 -1
- data/lib/ton_sdk_client/abi.rb +114 -294
- data/lib/ton_sdk_client/boc.rb +32 -212
- data/lib/ton_sdk_client/client.rb +9 -51
- data/lib/ton_sdk_client/client_context.rb +2 -0
- data/lib/ton_sdk_client/config.rb +49 -90
- data/lib/ton_sdk_client/crypto.rb +116 -675
- data/lib/ton_sdk_client/debot.rb +142 -247
- data/lib/ton_sdk_client/interop.rb +2 -2
- data/lib/ton_sdk_client/net.rb +154 -169
- data/lib/ton_sdk_client/processing.rb +7 -36
- data/lib/ton_sdk_client/tvm.rb +58 -94
- data/lib/ton_sdk_client/utils.rb +36 -42
- data/lib/ton_sdk_client/version.rb +2 -2
- metadata +2 -2
@@ -132,12 +132,12 @@ module TonSdk
|
|
132
132
|
def self.request_to_native_lib(
|
133
133
|
ctx,
|
134
134
|
function_name,
|
135
|
-
|
135
|
+
function_params = nil,
|
136
136
|
client_callback: nil,
|
137
137
|
is_single_thread_only: true
|
138
138
|
)
|
139
139
|
function_name_tc_str = TcStringData.from_string(function_name)
|
140
|
-
function_params_json_str =
|
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)
|
data/lib/ton_sdk_client/net.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
53
|
-
|
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,150 +53,63 @@ module TonSdk
|
|
58
53
|
end
|
59
54
|
end
|
60
55
|
|
61
|
-
|
62
|
-
|
63
|
-
filter: @filter,
|
64
|
-
result: @result,
|
65
|
-
order: ord_h_s,
|
66
|
-
limit: @limit
|
67
|
-
}
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
class ResultOfQueryCollection
|
72
|
-
attr_reader :result
|
73
|
-
|
74
|
-
def initialize(a)
|
75
|
-
@result = a
|
56
|
+
h[:order] = ord_h_s
|
57
|
+
h
|
76
58
|
end
|
77
59
|
end
|
78
60
|
|
79
|
-
|
80
|
-
|
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, keyword_init: true) do
|
82
66
|
def initialize(collection:, filter: nil, result:, timeout: nil)
|
83
|
-
|
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
|
-
}
|
67
|
+
super
|
96
68
|
end
|
97
69
|
end
|
98
70
|
|
99
|
-
|
100
|
-
attr_reader :result
|
101
|
-
|
102
|
-
def initialize(a)
|
103
|
-
@result = a
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
class ParamsOfSubscribeCollection
|
108
|
-
attr_reader :collection, :filter, :result
|
109
|
-
|
71
|
+
ParamsOfSubscribeCollection = Struct.new(:collection, :filter, :result, keyword_init: true) do
|
110
72
|
def initialize(collection:, filter: nil, result:)
|
111
|
-
|
112
|
-
@filter = filter
|
113
|
-
@result = result
|
114
|
-
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
|
73
|
+
super
|
130
74
|
end
|
131
|
-
|
132
|
-
def to_h = { handle: @handle }
|
133
75
|
end
|
134
76
|
|
135
|
-
|
136
|
-
|
137
|
-
|
77
|
+
ResultOfSubscribeCollection = Struct.new(:handle)
|
78
|
+
ParamsOfQuery = Struct.new(:query, :variables, keyword_init: true) do
|
138
79
|
def initialize(query:, variables: nil)
|
139
|
-
|
140
|
-
@variables = variables
|
141
|
-
end
|
142
|
-
|
143
|
-
def to_h
|
144
|
-
{
|
145
|
-
query: @query,
|
146
|
-
variables: @variables
|
147
|
-
}
|
80
|
+
super
|
148
81
|
end
|
149
82
|
end
|
150
83
|
|
151
|
-
|
152
|
-
|
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
|
-
end
|
168
|
-
|
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
|
204
107
|
|
108
|
+
def self.new_with_type_query_counterparties(params)
|
109
|
+
@type_ = :query_counterparties
|
110
|
+
@params = params
|
111
|
+
end
|
112
|
+
|
205
113
|
def to_h
|
206
114
|
tp = {
|
207
115
|
type: Helper.sym_to_capitalized_case_str(@type_)
|
@@ -212,41 +120,23 @@ module TonSdk
|
|
212
120
|
end
|
213
121
|
end
|
214
122
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
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
|
123
|
+
ParamsOfBatchQuery = Struct.new(:operations) do
|
124
|
+
def to_h
|
125
|
+
{
|
126
|
+
operations: self.operations.compact.map(&:to_h)
|
127
|
+
}
|
230
128
|
end
|
231
|
-
|
232
|
-
def to_h = { results: @results }
|
233
129
|
end
|
234
130
|
|
235
|
-
|
236
|
-
attr_reader :collection, :filter, :fields
|
237
|
-
|
131
|
+
ParamsOfAggregateCollection = Struct.new(:collection, :filter, :fields) do
|
238
132
|
def initialize(collection:, filter: nil, fields: [])
|
239
|
-
|
240
|
-
@filter = filter
|
241
|
-
@fields = fields
|
133
|
+
super
|
242
134
|
end
|
243
135
|
|
244
136
|
def to_h
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
fields: @fields.map(&:to_h)
|
249
|
-
}
|
137
|
+
h = super
|
138
|
+
h[:fields] = self.fields.map(&:to_h)
|
139
|
+
h
|
250
140
|
end
|
251
141
|
end
|
252
142
|
|
@@ -277,16 +167,69 @@ module TonSdk
|
|
277
167
|
end
|
278
168
|
end
|
279
169
|
|
280
|
-
|
281
|
-
attr_reader :values
|
170
|
+
ResultOfAggregateCollection = Struct.new(:values)
|
282
171
|
|
283
|
-
|
284
|
-
|
172
|
+
ParamsOfQueryCounterparties = Struct.new(:account, :result, :first, :after, keyword_init: true) do
|
173
|
+
def initialize(account:, result:, first: nil, after: nil)
|
174
|
+
super
|
285
175
|
end
|
176
|
+
end
|
286
177
|
|
287
|
-
|
178
|
+
ResultOfGetEndpoints = Struct.new(:query, :endpoints, keyword_init: true)
|
179
|
+
|
180
|
+
TransactionNode = Struct.new(
|
181
|
+
:id_,
|
182
|
+
:in_msg,
|
183
|
+
:out_msgs,
|
184
|
+
:account_addr,
|
185
|
+
:total_fees,
|
186
|
+
:aborted,
|
187
|
+
:exit_code,
|
188
|
+
keyword_init: true
|
189
|
+
) do
|
190
|
+
def initialize(id_:, in_msg:, out_msgs:, account_addr:, total_fees:, aborted:, exit_code: nil)
|
191
|
+
super
|
192
|
+
end
|
288
193
|
end
|
289
194
|
|
195
|
+
MessageNode = Struct.new(
|
196
|
+
:id_,
|
197
|
+
:src_transaction_id,
|
198
|
+
:dst_transaction_id,
|
199
|
+
:src,
|
200
|
+
:dst,
|
201
|
+
:value,
|
202
|
+
:bounce,
|
203
|
+
:decoded_body,
|
204
|
+
keyword_init: true
|
205
|
+
) do
|
206
|
+
def initialize(
|
207
|
+
id_:,
|
208
|
+
src_transaction_id: nil,
|
209
|
+
dst_transaction_id: nil,
|
210
|
+
src: nil,
|
211
|
+
dst: nil,
|
212
|
+
value: nil,
|
213
|
+
bounce:,
|
214
|
+
decoded_body: nil
|
215
|
+
)
|
216
|
+
super
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
ParamsOfQueryTransactionTree = Struct.new(:in_msg, :abi_registry, :timeout, keyword_init: true) do
|
221
|
+
def initialize(in_msg:, abi_registry: [], timeout: nil)
|
222
|
+
super
|
223
|
+
end
|
224
|
+
|
225
|
+
def to_h
|
226
|
+
h = super
|
227
|
+
h[:abi_registry] = self.abi_registry&.map(&:to_h)
|
228
|
+
h
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
ResultOfQueryTransactionTree = Struct.new(:messages, :transactions, keyword_init: true)
|
290
233
|
|
291
234
|
|
292
235
|
#
|
@@ -297,7 +240,7 @@ module TonSdk
|
|
297
240
|
Interop::request_to_native_lib(
|
298
241
|
ctx,
|
299
242
|
"net.query_collection",
|
300
|
-
params
|
243
|
+
params,
|
301
244
|
is_single_thread_only: false
|
302
245
|
) do |resp|
|
303
246
|
if resp.success?
|
@@ -314,7 +257,7 @@ module TonSdk
|
|
314
257
|
Interop::request_to_native_lib(
|
315
258
|
ctx,
|
316
259
|
"net.wait_for_collection",
|
317
|
-
params
|
260
|
+
params,
|
318
261
|
is_single_thread_only: false
|
319
262
|
) do |resp|
|
320
263
|
if resp.success?
|
@@ -328,7 +271,7 @@ module TonSdk
|
|
328
271
|
end
|
329
272
|
|
330
273
|
def self.unsubscribe(ctx, params)
|
331
|
-
Interop::request_to_native_lib(ctx, "net.unsubscribe", params
|
274
|
+
Interop::request_to_native_lib(ctx, "net.unsubscribe", params) do |resp|
|
332
275
|
if resp.success?
|
333
276
|
yield NativeLibResponsetResult.new(
|
334
277
|
result: ""
|
@@ -343,7 +286,7 @@ module TonSdk
|
|
343
286
|
Interop::request_to_native_lib(
|
344
287
|
ctx,
|
345
288
|
"net.subscribe_collection",
|
346
|
-
params
|
289
|
+
params,
|
347
290
|
client_callback: client_callback,
|
348
291
|
is_single_thread_only: false
|
349
292
|
) do |resp|
|
@@ -358,7 +301,7 @@ module TonSdk
|
|
358
301
|
end
|
359
302
|
|
360
303
|
def self.query(ctx, params)
|
361
|
-
Interop::request_to_native_lib(ctx, "net.query", params
|
304
|
+
Interop::request_to_native_lib(ctx, "net.query", params) do |resp|
|
362
305
|
if resp.success?
|
363
306
|
yield NativeLibResponsetResult.new(
|
364
307
|
result: ResultOfQuery.new(resp.result["result"])
|
@@ -370,7 +313,7 @@ module TonSdk
|
|
370
313
|
end
|
371
314
|
|
372
315
|
def self.suspend(ctx)
|
373
|
-
Interop::request_to_native_lib(ctx, "net.suspend"
|
316
|
+
Interop::request_to_native_lib(ctx, "net.suspend") do |resp|
|
374
317
|
if resp.success?
|
375
318
|
yield NativeLibResponsetResult.new(result: "")
|
376
319
|
else
|
@@ -380,7 +323,7 @@ module TonSdk
|
|
380
323
|
end
|
381
324
|
|
382
325
|
def self.resume(ctx)
|
383
|
-
Interop::request_to_native_lib(ctx, "net.resume"
|
326
|
+
Interop::request_to_native_lib(ctx, "net.resume") do |resp|
|
384
327
|
if resp.success?
|
385
328
|
yield NativeLibResponsetResult.new(result: "")
|
386
329
|
else
|
@@ -390,7 +333,7 @@ module TonSdk
|
|
390
333
|
end
|
391
334
|
|
392
335
|
def self.find_last_shard_block(ctx, params)
|
393
|
-
Interop::request_to_native_lib(ctx, "net.find_last_shard_block", params
|
336
|
+
Interop::request_to_native_lib(ctx, "net.find_last_shard_block", params) do |resp|
|
394
337
|
if resp.success?
|
395
338
|
yield NativeLibResponsetResult.new(
|
396
339
|
result: ResultOfFindLastShardBlock.new(resp.result["block_id"])
|
@@ -402,7 +345,7 @@ module TonSdk
|
|
402
345
|
end
|
403
346
|
|
404
347
|
def self.fetch_endpoints(ctx)
|
405
|
-
Interop::request_to_native_lib(ctx, "net.fetch_endpoints"
|
348
|
+
Interop::request_to_native_lib(ctx, "net.fetch_endpoints") do |resp|
|
406
349
|
if resp.success?
|
407
350
|
yield NativeLibResponsetResult.new(
|
408
351
|
result: EndpointsSet.new(resp.result["endpoints"])
|
@@ -414,7 +357,7 @@ module TonSdk
|
|
414
357
|
end
|
415
358
|
|
416
359
|
def self.set_endpoints(ctx, params)
|
417
|
-
Interop::request_to_native_lib(ctx, "net.set_endpoints", params
|
360
|
+
Interop::request_to_native_lib(ctx, "net.set_endpoints", params) do |resp|
|
418
361
|
if resp.success?
|
419
362
|
yield NativeLibResponsetResult.new(
|
420
363
|
result: nil
|
@@ -427,7 +370,7 @@ module TonSdk
|
|
427
370
|
end
|
428
371
|
|
429
372
|
def self.batch_query(ctx, params)
|
430
|
-
Interop::request_to_native_lib(ctx, "net.batch_query", params
|
373
|
+
Interop::request_to_native_lib(ctx, "net.batch_query", params) do |resp|
|
431
374
|
if resp.success?
|
432
375
|
yield NativeLibResponsetResult.new(
|
433
376
|
result: ResultOfBatchQuery.new(resp.result["results"])
|
@@ -439,7 +382,7 @@ module TonSdk
|
|
439
382
|
end
|
440
383
|
|
441
384
|
def self.aggregate_collection(ctx, params)
|
442
|
-
Interop::request_to_native_lib(ctx, "net.aggregate_collection", params
|
385
|
+
Interop::request_to_native_lib(ctx, "net.aggregate_collection", params) do |resp|
|
443
386
|
if resp.success?
|
444
387
|
yield NativeLibResponsetResult.new(
|
445
388
|
result: ResultOfAggregateCollection.new(resp.result["values"])
|
@@ -449,4 +392,46 @@ module TonSdk
|
|
449
392
|
end
|
450
393
|
end
|
451
394
|
end
|
395
|
+
|
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"],
|
403
|
+
)
|
404
|
+
)
|
405
|
+
else
|
406
|
+
yield resp
|
407
|
+
end
|
408
|
+
end
|
409
|
+
end
|
410
|
+
|
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
|
419
|
+
end
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
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"],
|
430
|
+
)
|
431
|
+
)
|
432
|
+
else
|
433
|
+
yield resp
|
434
|
+
end
|
435
|
+
end
|
436
|
+
end
|
452
437
|
end
|