ever_sdk_client 1.36.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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +72 -0
- data/LICENSE +201 -0
- data/README.md +194 -0
- data/lib/ever_sdk_client/abi.rb +1070 -0
- data/lib/ever_sdk_client/boc.rb +416 -0
- data/lib/ever_sdk_client/client.rb +180 -0
- data/lib/ever_sdk_client/client_context.rb +55 -0
- data/lib/ever_sdk_client/config.rb +77 -0
- data/lib/ever_sdk_client/crypto.rb +1047 -0
- data/lib/ever_sdk_client/debot.rb +367 -0
- data/lib/ever_sdk_client/helper.rb +20 -0
- data/lib/ever_sdk_client/interop.rb +230 -0
- data/lib/ever_sdk_client/kw_struct.rb +7 -0
- data/lib/ever_sdk_client/net.rb +551 -0
- data/lib/ever_sdk_client/processing.rb +268 -0
- data/lib/ever_sdk_client/proofs.rb +61 -0
- data/lib/ever_sdk_client/tvm.rb +251 -0
- data/lib/ever_sdk_client/types.rb +45 -0
- data/lib/ever_sdk_client/utils.rb +122 -0
- data/lib/ever_sdk_client/version.rb +4 -0
- data/lib/ever_sdk_client.rb +6 -0
- metadata +136 -0
@@ -0,0 +1,551 @@
|
|
1
|
+
module EverSdk
|
2
|
+
module Net
|
3
|
+
|
4
|
+
#
|
5
|
+
# types
|
6
|
+
#
|
7
|
+
|
8
|
+
module ErrorCode
|
9
|
+
QUERY_FAILED = 601
|
10
|
+
SUBSCRIBE_FAILED = 602
|
11
|
+
WAIT_FOR_FAILED = 603
|
12
|
+
GET_SUBSCRIPTION_FAILED = 604
|
13
|
+
INVALID_SERVER_RESPONSE = 605
|
14
|
+
CLOCK_OUT_OF_SYNC = 606
|
15
|
+
WAIT_FOR_TIMEOUT = 607
|
16
|
+
GRAPHQL_ERROR = 608
|
17
|
+
NETWORK_MODULE_SUSPENDED = 609
|
18
|
+
WEBSOCKET_DISCONNECTED = 610
|
19
|
+
NOT_SUPPORTED = 611
|
20
|
+
NO_ENDPOINTS_PROVIDED = 612
|
21
|
+
GRAPHQL_WEBSOCKET_INIT_ERROR = 613
|
22
|
+
NETWORK_MODULE_RESUMED = 614
|
23
|
+
end
|
24
|
+
|
25
|
+
class OrderBy
|
26
|
+
SORT_DIRECTION_VALUES = [:asc, :desc]
|
27
|
+
|
28
|
+
attr_reader :path, :direction
|
29
|
+
|
30
|
+
def initialize(path:, direction:)
|
31
|
+
@path = path
|
32
|
+
unless SORT_DIRECTION_VALUES.include?(direction)
|
33
|
+
raise ArgumentError.new("direction #{direction} doesn't exist; existing values: #{SORT_DIRECTION_VALUES}")
|
34
|
+
end
|
35
|
+
|
36
|
+
@direction = direction
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
ParamsOfQueryCollection = KwStruct.new(:collection, :filter, :result, :order, :limit) do
|
41
|
+
def initialize(collection: , filter: nil, result: , order: [], limit: nil)
|
42
|
+
super
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_h
|
46
|
+
h = super
|
47
|
+
ord_h_s = if !self.order.nil?
|
48
|
+
self.order.map do |x|
|
49
|
+
{
|
50
|
+
path: x.path,
|
51
|
+
direction: x.direction.to_s.upcase
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
h[:order] = ord_h_s
|
57
|
+
h
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
ResultOfQueryCollection = KwStruct.new(:result)
|
62
|
+
ResultOfWaitForCollection = KwStruct.new(:result)
|
63
|
+
ResultOfQuery = KwStruct.new(:result)
|
64
|
+
ResultOfBatchQuery = KwStruct.new(:results)
|
65
|
+
ParamsOfWaitForCollection = KwStruct.new(:collection, :filter, :result, :timeout) do
|
66
|
+
def initialize(collection:, filter: nil, result:, timeout: nil)
|
67
|
+
super
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
ParamsOfSubscribeCollection = KwStruct.new(:collection, :filter, :result) do
|
72
|
+
def initialize(collection:, filter: nil, result:)
|
73
|
+
super
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
ParamsOfSubscribe = KwStruct.new(:subscription, :variables)
|
78
|
+
|
79
|
+
ResultOfSubscribeCollection = KwStruct.new(:handle)
|
80
|
+
|
81
|
+
ParamsOfQuery = KwStruct.new(:query, :variables) do
|
82
|
+
def initialize(query:, variables: nil)
|
83
|
+
super
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
ParamsOfFindLastShardBlock = KwStruct.new(:address)
|
88
|
+
ResultOfFindLastShardBlock = KwStruct.new(:block_id)
|
89
|
+
EndpointsSet = KwStruct.new(:endpoints)
|
90
|
+
|
91
|
+
class ParamsOfQueryOperation
|
92
|
+
private_class_method :new
|
93
|
+
|
94
|
+
attr_reader :type_, :params
|
95
|
+
|
96
|
+
def self.new_with_type_query_collection(params)
|
97
|
+
@type_ = :query_collection
|
98
|
+
@params = params
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.new_with_type_wait_for_collection(params)
|
102
|
+
@type_ = :wait_for_collection
|
103
|
+
@params = params
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.new_with_type_aggregate_collection(params)
|
107
|
+
@type_ = :aggregate_collection
|
108
|
+
@params = params
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.new_with_type_query_counterparties(params)
|
112
|
+
@type_ = :query_counterparties
|
113
|
+
@params = params
|
114
|
+
end
|
115
|
+
|
116
|
+
def to_h
|
117
|
+
tp = {
|
118
|
+
type: Helper.sym_to_capitalized_case_str(@type_)
|
119
|
+
}
|
120
|
+
|
121
|
+
param_keys = @params.to_h
|
122
|
+
tp.merge(param_keys)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
ParamsOfBatchQuery = KwStruct.new(:operations) do
|
127
|
+
def to_h
|
128
|
+
{
|
129
|
+
operations: self.operations.compact.map(&:to_h)
|
130
|
+
}
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
ParamsOfAggregateCollection = KwStruct.new(:collection, :filter, :fields) do
|
135
|
+
def initialize(collection:, filter: nil, fields: [])
|
136
|
+
super
|
137
|
+
end
|
138
|
+
|
139
|
+
def to_h
|
140
|
+
h = super
|
141
|
+
h[:fields] = fields.map(&:to_h)
|
142
|
+
h
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
class FieldAggregation
|
147
|
+
AGGREGATION_FN_VALUES = [
|
148
|
+
:count,
|
149
|
+
:min,
|
150
|
+
:max,
|
151
|
+
:sum,
|
152
|
+
:average
|
153
|
+
]
|
154
|
+
|
155
|
+
attr_reader :field, :fn
|
156
|
+
|
157
|
+
def initialize(field:, fn:)
|
158
|
+
unless AGGREGATION_FN_VALUES.include?(fn)
|
159
|
+
raise ArgumentError.new("aggregate function #{fn} doesn't exist; existing values: #{AGGREGATION_FN_VALUES}")
|
160
|
+
end
|
161
|
+
@field = field
|
162
|
+
@fn = fn
|
163
|
+
end
|
164
|
+
|
165
|
+
def to_h
|
166
|
+
{
|
167
|
+
field: @field,
|
168
|
+
fn: @fn.to_s.upcase
|
169
|
+
}
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
ResultOfAggregateCollection = KwStruct.new(:values)
|
174
|
+
|
175
|
+
ParamsOfQueryCounterparties = KwStruct.new(:account, :result, :first, :after) do
|
176
|
+
def initialize(account:, result:, first: nil, after: nil)
|
177
|
+
super
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
ResultOfGetEndpoints = KwStruct.new(:query, :endpoints)
|
182
|
+
|
183
|
+
TransactionNode = KwStruct.new(
|
184
|
+
:id_,
|
185
|
+
:in_msg,
|
186
|
+
:out_msgs,
|
187
|
+
:account_addr,
|
188
|
+
:total_fees,
|
189
|
+
:aborted,
|
190
|
+
:exit_code
|
191
|
+
) do
|
192
|
+
def initialize(id_:, in_msg:, out_msgs:, account_addr:, total_fees:, aborted:, exit_code: nil)
|
193
|
+
super
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
MessageNode = KwStruct.new(
|
198
|
+
:id_,
|
199
|
+
:src_transaction_id,
|
200
|
+
:dst_transaction_id,
|
201
|
+
:src,
|
202
|
+
:dst,
|
203
|
+
:value,
|
204
|
+
:bounce,
|
205
|
+
:decoded_body
|
206
|
+
) do
|
207
|
+
def initialize(
|
208
|
+
id_:,
|
209
|
+
src_transaction_id: nil,
|
210
|
+
dst_transaction_id: nil,
|
211
|
+
src: nil,
|
212
|
+
dst: nil,
|
213
|
+
value: nil,
|
214
|
+
bounce:,
|
215
|
+
decoded_body: nil
|
216
|
+
)
|
217
|
+
super
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
ParamsOfQueryTransactionTree = KwStruct.new(:in_msg, :abi_registry, :timeout) do
|
222
|
+
def initialize(in_msg:, abi_registry: [], timeout: nil)
|
223
|
+
super
|
224
|
+
end
|
225
|
+
|
226
|
+
def to_h
|
227
|
+
h = super
|
228
|
+
h[:abi_registry] = abi_registry&.map(&:to_h)
|
229
|
+
h
|
230
|
+
end
|
231
|
+
end
|
232
|
+
ResultOfQueryTransactionTree = KwStruct.new(:messages, :transactions)
|
233
|
+
|
234
|
+
ParamsOfCreateBlockIterator = KwStruct.new(:start_time, :end_time, :shard_filter, :result)
|
235
|
+
RegisteredIterator = KwStruct.new(:handle)
|
236
|
+
ParamsOfResumeBlockIterator = KwStruct.new(:resume_state)
|
237
|
+
ParamsOfCreateTransactionIterator = KwStruct.new(:start_time, :end_time, :shard_filter, :accounts_filter, :result, :include_transfers)
|
238
|
+
ParamsOfResumeTransactionIterator = KwStruct.new(:resume_state, :accounts_filter) do
|
239
|
+
def initialize(resume_state:, accounts_filter: nil)
|
240
|
+
super
|
241
|
+
end
|
242
|
+
end
|
243
|
+
ParamsOfIteratorNext = KwStruct.new(:iterator, :limit, :return_resume_state) do
|
244
|
+
def initialize(iterator:, limit: nil, return_resume_state: nil)
|
245
|
+
super
|
246
|
+
end
|
247
|
+
end
|
248
|
+
ResultOfIteratorNext = KwStruct.new(:items, :has_more, :resume_state) do
|
249
|
+
def initialize(items: [], has_more:, resume_state: nil)
|
250
|
+
super
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
|
255
|
+
#
|
256
|
+
# functions
|
257
|
+
#
|
258
|
+
|
259
|
+
def self.query_collection(ctx, params)
|
260
|
+
Interop::request_to_native_lib(
|
261
|
+
ctx,
|
262
|
+
"net.query_collection",
|
263
|
+
params,
|
264
|
+
is_single_thread_only: false
|
265
|
+
) do |resp|
|
266
|
+
if resp.success?
|
267
|
+
yield NativeLibResponseResult.new(
|
268
|
+
result: ResultOfQueryCollection.new(result: resp.result["result"])
|
269
|
+
)
|
270
|
+
else
|
271
|
+
yield resp
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
def self.wait_for_collection(ctx, params)
|
277
|
+
Interop::request_to_native_lib(
|
278
|
+
ctx,
|
279
|
+
"net.wait_for_collection",
|
280
|
+
params,
|
281
|
+
is_single_thread_only: false
|
282
|
+
) do |resp|
|
283
|
+
if resp.success?
|
284
|
+
yield NativeLibResponseResult.new(
|
285
|
+
result: ResultOfWaitForCollection.new(result: resp.result["result"])
|
286
|
+
)
|
287
|
+
else
|
288
|
+
yield resp
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
def self.unsubscribe(ctx, params)
|
294
|
+
Interop::request_to_native_lib(ctx, "net.unsubscribe", params) do |resp|
|
295
|
+
if resp.success?
|
296
|
+
yield NativeLibResponseResult.new(
|
297
|
+
result: ""
|
298
|
+
)
|
299
|
+
else
|
300
|
+
yield resp
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
def self.subscribe_collection(ctx, params, client_callback: nil)
|
306
|
+
Interop::request_to_native_lib(
|
307
|
+
ctx,
|
308
|
+
"net.subscribe_collection",
|
309
|
+
params,
|
310
|
+
client_callback: client_callback,
|
311
|
+
is_single_thread_only: false
|
312
|
+
) do |resp|
|
313
|
+
if resp.success?
|
314
|
+
yield NativeLibResponseResult.new(
|
315
|
+
result: ResultOfSubscribeCollection.new(handle: resp.result["handle"])
|
316
|
+
)
|
317
|
+
else
|
318
|
+
yield resp
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
def self.subscribe(ctx, params, client_callback: nil)
|
324
|
+
Interop::request_to_native_lib(
|
325
|
+
ctx,
|
326
|
+
"net.subscribe",
|
327
|
+
params,
|
328
|
+
client_callback: client_callback,
|
329
|
+
is_single_thread_only: false
|
330
|
+
) do |resp|
|
331
|
+
if resp.success?
|
332
|
+
yield NativeLibResponseResult.new(
|
333
|
+
result: ResultOfSubscribeCollection.new(handle: resp.result["handle"])
|
334
|
+
)
|
335
|
+
else
|
336
|
+
yield resp
|
337
|
+
end
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
def self.query(ctx, params)
|
342
|
+
Interop::request_to_native_lib(ctx, "net.query", params) do |resp|
|
343
|
+
if resp.success?
|
344
|
+
yield NativeLibResponseResult.new(
|
345
|
+
result: ResultOfQuery.new(result: resp.result["result"])
|
346
|
+
)
|
347
|
+
else
|
348
|
+
yield resp
|
349
|
+
end
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
def self.suspend(ctx)
|
354
|
+
Interop::request_to_native_lib(ctx, "net.suspend") do |resp|
|
355
|
+
if resp.success?
|
356
|
+
yield NativeLibResponseResult.new(result: "")
|
357
|
+
else
|
358
|
+
yield resp
|
359
|
+
end
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
def self.resume(ctx)
|
364
|
+
Interop::request_to_native_lib(ctx, "net.resume") do |resp|
|
365
|
+
if resp.success?
|
366
|
+
yield NativeLibResponseResult.new(result: "")
|
367
|
+
else
|
368
|
+
yield resp
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
def self.find_last_shard_block(ctx, params)
|
374
|
+
Interop::request_to_native_lib(ctx, "net.find_last_shard_block", params) do |resp|
|
375
|
+
if resp.success?
|
376
|
+
yield NativeLibResponseResult.new(
|
377
|
+
result: ResultOfFindLastShardBlock.new(block_id: resp.result["block_id"])
|
378
|
+
)
|
379
|
+
else
|
380
|
+
yield resp
|
381
|
+
end
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
def self.fetch_endpoints(ctx)
|
386
|
+
Interop::request_to_native_lib(ctx, "net.fetch_endpoints") do |resp|
|
387
|
+
if resp.success?
|
388
|
+
yield NativeLibResponseResult.new(
|
389
|
+
result: EndpointsSet.new(endpoints: resp.result["endpoints"])
|
390
|
+
)
|
391
|
+
else
|
392
|
+
yield resp
|
393
|
+
end
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
def self.set_endpoints(ctx, params)
|
398
|
+
Interop::request_to_native_lib(ctx, "net.set_endpoints", params) do |resp|
|
399
|
+
if resp.success?
|
400
|
+
yield NativeLibResponseResult.new(
|
401
|
+
result: nil
|
402
|
+
)
|
403
|
+
else
|
404
|
+
yield resp
|
405
|
+
end
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
def self.batch_query(ctx, params)
|
410
|
+
Interop::request_to_native_lib(ctx, "net.batch_query", params) do |resp|
|
411
|
+
if resp.success?
|
412
|
+
yield NativeLibResponseResult.new(
|
413
|
+
result: ResultOfBatchQuery.new(results: resp.result["results"])
|
414
|
+
)
|
415
|
+
else
|
416
|
+
yield resp
|
417
|
+
end
|
418
|
+
end
|
419
|
+
end
|
420
|
+
|
421
|
+
def self.aggregate_collection(ctx, params)
|
422
|
+
Interop::request_to_native_lib(ctx, "net.aggregate_collection", params) do |resp|
|
423
|
+
if resp.success?
|
424
|
+
yield NativeLibResponseResult.new(
|
425
|
+
result: ResultOfAggregateCollection.new(values: resp.result["values"])
|
426
|
+
)
|
427
|
+
else
|
428
|
+
yield resp
|
429
|
+
end
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
def self.get_endpoints(ctx)
|
434
|
+
Interop::request_to_native_lib(ctx, "net.get_endpoints") do |resp|
|
435
|
+
if resp.success?
|
436
|
+
yield NativeLibResponseResult.new(
|
437
|
+
result: ResultOfGetEndpoints.new(
|
438
|
+
query: resp.result["query"],
|
439
|
+
endpoints: resp.result["endpoints"],
|
440
|
+
)
|
441
|
+
)
|
442
|
+
else
|
443
|
+
yield resp
|
444
|
+
end
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
448
|
+
def self.query_counterparties(ctx, params)
|
449
|
+
Interop::request_to_native_lib(ctx, "net.query_counterparties", params) do |resp|
|
450
|
+
if resp.success?
|
451
|
+
yield NativeLibResponseResult.new(
|
452
|
+
result: ResultOfQueryCollection.new(result: resp.result["result"])
|
453
|
+
)
|
454
|
+
else
|
455
|
+
yield resp
|
456
|
+
end
|
457
|
+
end
|
458
|
+
end
|
459
|
+
|
460
|
+
def self.query_transaction_tree(ctx, params)
|
461
|
+
Interop::request_to_native_lib(ctx, "net.query_transaction_tree", params) do |resp|
|
462
|
+
if resp.success?
|
463
|
+
yield NativeLibResponseResult.new(
|
464
|
+
result: ResultOfQueryTransactionTree.new(
|
465
|
+
messages: resp.result["messages"],
|
466
|
+
transactions: resp.result["transactions"],
|
467
|
+
)
|
468
|
+
)
|
469
|
+
else
|
470
|
+
yield resp
|
471
|
+
end
|
472
|
+
end
|
473
|
+
end
|
474
|
+
|
475
|
+
def self.create_block_iterator(ctx, params)
|
476
|
+
Interop::request_to_native_lib(ctx, "net.create_block_iterator", params) do |resp|
|
477
|
+
if resp.success?
|
478
|
+
yield NativeLibResponseResult.new(
|
479
|
+
result: RegisteredIterator.new(handle: resp.result["handle"])
|
480
|
+
)
|
481
|
+
else
|
482
|
+
yield resp
|
483
|
+
end
|
484
|
+
end
|
485
|
+
end
|
486
|
+
|
487
|
+
def self.resume_block_iterator(ctx, params)
|
488
|
+
Interop::request_to_native_lib(ctx, "net.resume_block_iterator", params) do |resp|
|
489
|
+
if resp.success?
|
490
|
+
yield NativeLibResponseResult.new(
|
491
|
+
result: RegisteredIterator.new(handle: resp.result["handle"])
|
492
|
+
)
|
493
|
+
else
|
494
|
+
yield resp
|
495
|
+
end
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
499
|
+
def self.create_transaction_iterator(ctx, params)
|
500
|
+
Interop::request_to_native_lib(ctx, "net.create_transaction_iterator", params) do |resp|
|
501
|
+
if resp.success?
|
502
|
+
yield NativeLibResponseResult.new(
|
503
|
+
result: RegisteredIterator.new(handle: resp.result["handle"])
|
504
|
+
)
|
505
|
+
else
|
506
|
+
yield resp
|
507
|
+
end
|
508
|
+
end
|
509
|
+
end
|
510
|
+
|
511
|
+
def self.resume_transaction_iterator(ctx, params)
|
512
|
+
Interop::request_to_native_lib(ctx, "net.resume_transaction_iterator", params) do |resp|
|
513
|
+
if resp.success?
|
514
|
+
yield NativeLibResponseResult.new(
|
515
|
+
result: RegisteredIterator.new(handle: resp.result["handle"])
|
516
|
+
)
|
517
|
+
else
|
518
|
+
yield resp
|
519
|
+
end
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
523
|
+
def self.iterator_next(ctx, params)
|
524
|
+
Interop::request_to_native_lib(ctx, "net.iterator_next", params) do |resp|
|
525
|
+
if resp.success?
|
526
|
+
yield NativeLibResponseResult.new(
|
527
|
+
result: ResultOfIteratorNext.new(
|
528
|
+
items: resp.result["items"],
|
529
|
+
has_more: resp.result["has_more"],
|
530
|
+
resume_state: resp.result["resume_state"]
|
531
|
+
)
|
532
|
+
)
|
533
|
+
else
|
534
|
+
yield resp
|
535
|
+
end
|
536
|
+
end
|
537
|
+
end
|
538
|
+
|
539
|
+
def self.remove_iterator(ctx, params)
|
540
|
+
Interop::request_to_native_lib(ctx, "net.remove_iterator", params) do |resp|
|
541
|
+
if resp.success?
|
542
|
+
yield NativeLibResponseResult.new(
|
543
|
+
result: nil
|
544
|
+
)
|
545
|
+
else
|
546
|
+
yield resp
|
547
|
+
end
|
548
|
+
end
|
549
|
+
end
|
550
|
+
end
|
551
|
+
end
|