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,416 @@
|
|
|
1
|
+
module EverSdk
|
|
2
|
+
module Boc
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# types
|
|
6
|
+
#
|
|
7
|
+
|
|
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
|
+
|
|
14
|
+
ParamsOfGetBocHash = KwStruct.new(:boc)
|
|
15
|
+
ResultOfGetBocHash = KwStruct.new(:hash)
|
|
16
|
+
|
|
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)
|
|
25
|
+
|
|
26
|
+
class BocCacheType
|
|
27
|
+
TYPES = [
|
|
28
|
+
:pinned,
|
|
29
|
+
:unpinned
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
attr_reader :type, :pin
|
|
33
|
+
|
|
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
|
|
39
|
+
@pin = pin
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def to_h
|
|
43
|
+
hash = {type: Helper.sym_to_capitalized_case_str(type)}
|
|
44
|
+
hash[:pin] = pin if type == :pinned
|
|
45
|
+
hash
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
ParamsOfBocCacheSet = KwStruct.new(:boc, :cache_type) do
|
|
50
|
+
def to_h
|
|
51
|
+
{
|
|
52
|
+
boc: boc,
|
|
53
|
+
cache_type: cache_type.to_h
|
|
54
|
+
}
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
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)
|
|
85
|
+
|
|
86
|
+
ParamsOfDecodeTvc = KwStruct.new(:tvc, :boc_cache) do
|
|
87
|
+
def to_h
|
|
88
|
+
{
|
|
89
|
+
tvc: tvc,
|
|
90
|
+
boc_cache: boc_cache&.to_h
|
|
91
|
+
}
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
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
|
|
118
|
+
def to_h
|
|
119
|
+
{
|
|
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
|
|
127
|
+
}
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
ResultOfEncodeTvc = KwStruct.new(:tvc)
|
|
132
|
+
|
|
133
|
+
ParamsOfEncodeExternalInMessage = KwStruct.new(:src, :dst, :init, :body, :boc_cache) do
|
|
134
|
+
def to_h
|
|
135
|
+
{
|
|
136
|
+
src: src,
|
|
137
|
+
dst: dst,
|
|
138
|
+
init: init,
|
|
139
|
+
body: body,
|
|
140
|
+
boc_cache: boc_cache&.to_h
|
|
141
|
+
}
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
ResultOfEncodeExternalInMessage = KwStruct.new(:message, :message_id)
|
|
146
|
+
|
|
147
|
+
ParamsOfGetCompilerVersion = KwStruct.new(:code)
|
|
148
|
+
|
|
149
|
+
ResultOfGetCompilerVersion = KwStruct.new(:version)
|
|
150
|
+
|
|
151
|
+
#
|
|
152
|
+
# functions
|
|
153
|
+
#
|
|
154
|
+
|
|
155
|
+
def self.parse_message(ctx, params)
|
|
156
|
+
Interop::request_to_native_lib(ctx, "boc.parse_message", params) do |resp|
|
|
157
|
+
if resp.success?
|
|
158
|
+
yield NativeLibResponseResult.new(
|
|
159
|
+
result: ResultOfParse.new(parsed: resp.result["parsed"])
|
|
160
|
+
)
|
|
161
|
+
else
|
|
162
|
+
yield resp
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def self.parse_transaction(ctx, params)
|
|
168
|
+
Interop::request_to_native_lib(ctx, "boc.parse_transaction", params) do |resp|
|
|
169
|
+
if resp.success?
|
|
170
|
+
yield NativeLibResponseResult.new(
|
|
171
|
+
result: ResultOfParse.new(parsed: resp.result["parsed"])
|
|
172
|
+
)
|
|
173
|
+
else
|
|
174
|
+
yield resp
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def self.parse_account(ctx, params)
|
|
180
|
+
Interop::request_to_native_lib(ctx, "boc.parse_account", params) do |resp|
|
|
181
|
+
if resp.success?
|
|
182
|
+
yield NativeLibResponseResult.new(
|
|
183
|
+
result: ResultOfParse.new(parsed: resp.result["parsed"])
|
|
184
|
+
)
|
|
185
|
+
else
|
|
186
|
+
yield resp
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def self.parse_block(ctx, params)
|
|
192
|
+
Interop::request_to_native_lib(ctx, "boc.parse_block", params) do |resp|
|
|
193
|
+
if resp.success?
|
|
194
|
+
yield NativeLibResponseResult.new(
|
|
195
|
+
result: ResultOfParse.new(parsed: resp.result["parsed"])
|
|
196
|
+
)
|
|
197
|
+
else
|
|
198
|
+
yield resp
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def self.parse_shardstate(ctx, params)
|
|
204
|
+
Interop::request_to_native_lib(ctx, "boc.parse_shardstate", params) do |resp|
|
|
205
|
+
if resp.success?
|
|
206
|
+
yield NativeLibResponseResult.new(
|
|
207
|
+
result: ResultOfParse.new(parsed: resp.result["parsed"])
|
|
208
|
+
)
|
|
209
|
+
else
|
|
210
|
+
yield resp
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
def self.get_boc_hash(ctx, params)
|
|
216
|
+
Interop::request_to_native_lib(ctx, "boc.get_boc_hash", params) do |resp|
|
|
217
|
+
if resp.success?
|
|
218
|
+
yield NativeLibResponseResult.new(
|
|
219
|
+
result: ResultOfGetBocHash.new(hash: resp.result["hash"])
|
|
220
|
+
)
|
|
221
|
+
else
|
|
222
|
+
yield resp
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
def self.get_blockchain_config(ctx, params)
|
|
228
|
+
Interop::request_to_native_lib(ctx, "boc.get_blockchain_config", params) do |resp|
|
|
229
|
+
if resp.success?
|
|
230
|
+
yield NativeLibResponseResult.new(
|
|
231
|
+
result: ResultOfGetBlockchainConfig.new(
|
|
232
|
+
config_boc: resp.result["config_boc"]
|
|
233
|
+
)
|
|
234
|
+
)
|
|
235
|
+
else
|
|
236
|
+
yield resp
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
def self.get_boc_depth(ctx, params)
|
|
242
|
+
Interop::request_to_native_lib(ctx, "boc.get_boc_depth", params) do |resp|
|
|
243
|
+
if resp.success?
|
|
244
|
+
yield NativeLibResponseResult.new(
|
|
245
|
+
result: ResultOfGetBocDepth.new(
|
|
246
|
+
depth: resp.result["depth"]
|
|
247
|
+
)
|
|
248
|
+
)
|
|
249
|
+
else
|
|
250
|
+
yield resp
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
def self.get_code_from_tvc(ctx, params)
|
|
256
|
+
Interop::request_to_native_lib(ctx, "boc.get_code_from_tvc", params) do |resp|
|
|
257
|
+
if resp.success?
|
|
258
|
+
yield NativeLibResponseResult.new(
|
|
259
|
+
result: ResultOfGetCodeFromTvc.new(code: resp.result["code"])
|
|
260
|
+
)
|
|
261
|
+
else
|
|
262
|
+
yield resp
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
def self.cache_get(ctx, params)
|
|
268
|
+
Interop::request_to_native_lib(ctx, "boc.cache_get", params) do |resp|
|
|
269
|
+
if resp.success?
|
|
270
|
+
yield NativeLibResponseResult.new(
|
|
271
|
+
result: ResultOfBocCacheGet.new(
|
|
272
|
+
boc: resp.result["boc"]
|
|
273
|
+
)
|
|
274
|
+
)
|
|
275
|
+
else
|
|
276
|
+
yield resp
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
def self.cache_set(ctx, params)
|
|
282
|
+
Interop::request_to_native_lib(ctx, "boc.cache_set", params) do |resp|
|
|
283
|
+
if resp.success?
|
|
284
|
+
yield NativeLibResponseResult.new(
|
|
285
|
+
result: ResultOfBocCacheSet.new(
|
|
286
|
+
boc_ref: resp.result["boc_ref"]
|
|
287
|
+
)
|
|
288
|
+
)
|
|
289
|
+
else
|
|
290
|
+
yield resp
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
def self.cache_unpin(ctx, params)
|
|
296
|
+
Interop::request_to_native_lib(ctx, "boc.cache_unpin", params) do |resp|
|
|
297
|
+
if resp.success?
|
|
298
|
+
yield NativeLibResponseResult.new(
|
|
299
|
+
result: nil
|
|
300
|
+
)
|
|
301
|
+
else
|
|
302
|
+
yield resp
|
|
303
|
+
end
|
|
304
|
+
end
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
def self.encode_boc(ctx, params)
|
|
308
|
+
Interop::request_to_native_lib(ctx, "boc.encode_boc", params) do |resp|
|
|
309
|
+
if resp.success?
|
|
310
|
+
yield NativeLibResponseResult.new(
|
|
311
|
+
result: ResultOfEncodeBoc.new(
|
|
312
|
+
boc: resp.result["boc"]
|
|
313
|
+
)
|
|
314
|
+
)
|
|
315
|
+
else
|
|
316
|
+
yield resp
|
|
317
|
+
end
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
def self.get_code_salt(ctx, params)
|
|
322
|
+
Interop::request_to_native_lib(ctx, "boc.get_code_salt", params) do |resp|
|
|
323
|
+
if resp.success?
|
|
324
|
+
yield NativeLibResponseResult.new(
|
|
325
|
+
result: ResultOfGetCodeSalt.new(
|
|
326
|
+
salt: resp.result["salt"]
|
|
327
|
+
)
|
|
328
|
+
)
|
|
329
|
+
else
|
|
330
|
+
yield resp
|
|
331
|
+
end
|
|
332
|
+
end
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
def self.set_code_salt(ctx, params)
|
|
336
|
+
Interop::request_to_native_lib(ctx, "boc.set_code_salt", params) do |resp|
|
|
337
|
+
if resp.success?
|
|
338
|
+
yield NativeLibResponseResult.new(
|
|
339
|
+
result: ResultOfSetCodeSalt.new(
|
|
340
|
+
code: resp.result["code"]
|
|
341
|
+
)
|
|
342
|
+
)
|
|
343
|
+
else
|
|
344
|
+
yield resp
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
def self.decode_tvc(ctx, params)
|
|
350
|
+
Interop::request_to_native_lib(ctx, "boc.decode_tvc", params) do |resp|
|
|
351
|
+
if resp.success?
|
|
352
|
+
yield NativeLibResponseResult.new(
|
|
353
|
+
result: ResultOfDecodeTvc.new(
|
|
354
|
+
code: resp.result["code"],
|
|
355
|
+
code_depth: resp.result["code_depth"],
|
|
356
|
+
code_hash: resp.result["code_hash"],
|
|
357
|
+
data: resp.result["data"],
|
|
358
|
+
data_depth: resp.result["data_depth"],
|
|
359
|
+
data_hash: resp.result["data_hash"],
|
|
360
|
+
library: resp.result["library"],
|
|
361
|
+
tick: resp.result["tick"],
|
|
362
|
+
tock: resp.result["tock"],
|
|
363
|
+
split_depth: resp.result["split_depth"],
|
|
364
|
+
compiler_version: resp.result["compiler_version"]
|
|
365
|
+
)
|
|
366
|
+
)
|
|
367
|
+
else
|
|
368
|
+
yield resp
|
|
369
|
+
end
|
|
370
|
+
end
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
def self.encode_tvc(ctx, params)
|
|
374
|
+
Interop::request_to_native_lib(ctx, "boc.encode_tvc", params) do |resp|
|
|
375
|
+
if resp.success?
|
|
376
|
+
yield NativeLibResponseResult.new(
|
|
377
|
+
result: ResultOfEncodeTvc.new(
|
|
378
|
+
tvc: resp.result["tvc"]
|
|
379
|
+
)
|
|
380
|
+
)
|
|
381
|
+
else
|
|
382
|
+
yield resp
|
|
383
|
+
end
|
|
384
|
+
end
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
def self.encode_external_in_message(ctx, params)
|
|
388
|
+
Interop::request_to_native_lib(ctx, "boc.encode_external_in_message", params) do |resp|
|
|
389
|
+
if resp.success?
|
|
390
|
+
yield NativeLibResponseResult.new(
|
|
391
|
+
result: ResultOfEncodeExternalInMessage.new(
|
|
392
|
+
message: resp.result["message"],
|
|
393
|
+
message_id: resp.result["message_id"]
|
|
394
|
+
)
|
|
395
|
+
)
|
|
396
|
+
else
|
|
397
|
+
yield resp
|
|
398
|
+
end
|
|
399
|
+
end
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
def self.get_compiler_version(ctx, params)
|
|
403
|
+
Interop::request_to_native_lib(ctx, "boc.get_compiler_version", params) do |resp|
|
|
404
|
+
if resp.success?
|
|
405
|
+
yield NativeLibResponseResult.new(
|
|
406
|
+
result: ResultOfGetCompilerVersion.new(
|
|
407
|
+
version: resp.result["version"]
|
|
408
|
+
)
|
|
409
|
+
)
|
|
410
|
+
else
|
|
411
|
+
yield resp
|
|
412
|
+
end
|
|
413
|
+
end
|
|
414
|
+
end
|
|
415
|
+
end
|
|
416
|
+
end
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
require_relative './interop.rb'
|
|
3
|
+
|
|
4
|
+
module EverSdk
|
|
5
|
+
module Client
|
|
6
|
+
|
|
7
|
+
#
|
|
8
|
+
# types
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
module ErrorCode
|
|
12
|
+
NOT_IMPLEMENTED = 1
|
|
13
|
+
INVALID_HEX = 2
|
|
14
|
+
INVALID_BASE64 = 3
|
|
15
|
+
INVALID_ADDRESS = 4
|
|
16
|
+
CALLBACK_PARAMS_CANT_BE_CONVERTED_TO_JSON = 5
|
|
17
|
+
WEBSOCKET_CONNECT_ERROR = 6
|
|
18
|
+
WEBSOCKET_RECEIVE_ERROR = 7
|
|
19
|
+
WEBSOCKET_SEND_ERROR = 8
|
|
20
|
+
HTTP_CLIENT_CREATE_ERROR = 9
|
|
21
|
+
HTTP_REQUEST_CREATE_ERROR = 10
|
|
22
|
+
HTTP_REQUEST_SEND_ERROR = 11
|
|
23
|
+
HTTP_REQUEST_PARSE_ERROR = 12
|
|
24
|
+
CALLBACKNOTREGISTERED = 13
|
|
25
|
+
NET_MODULE_NOT_INIT = 14
|
|
26
|
+
INVALID_CONFIG = 15
|
|
27
|
+
CANNOT_CREATE_RUNTIME = 16
|
|
28
|
+
INVALID_CONTEXT_HANDLE = 17
|
|
29
|
+
CANNOT_SERIALIZE_RESULT = 18
|
|
30
|
+
CANNOT_SERIALIZE_ERROR = 19
|
|
31
|
+
CANNOT_CONVERT_JS_VALUE_TO_JSON = 20
|
|
32
|
+
CANNOT_RECEIVE_SPAWNED_RESULT = 21
|
|
33
|
+
SET_TIMER_ERROR = 22
|
|
34
|
+
INVALID_PARAMS = 23
|
|
35
|
+
CONTRACTS_ADDRESS_CONVERSION_FAILED = 24
|
|
36
|
+
UNKNOWN_FUNCTION = 25
|
|
37
|
+
APP_REQUEST_ERROR = 26
|
|
38
|
+
NO_SUCH_REQUEST = 27
|
|
39
|
+
CANNOT_SEND_REQUEST_RESULT = 28
|
|
40
|
+
CANNOT_RECEIVE_REQUEST_RESULT = 29
|
|
41
|
+
CANNOT_PARSE_REQUEST_RESULT = 30
|
|
42
|
+
UNEXPECTED_CALLBACK_RESPONSE = 31
|
|
43
|
+
CANNOT_PARSE_NUMBER = 32
|
|
44
|
+
INTERNAL_ERROR = 33
|
|
45
|
+
INVALID_HANDLE = 34
|
|
46
|
+
LOCAL_STORAGE_ERROR = 35
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
ResultOfVersion = KwStruct.new(:version)
|
|
50
|
+
ResultOfGetApiReference = KwStruct.new(:api)
|
|
51
|
+
|
|
52
|
+
BuildInfoDependency = KwStruct.new(:name, :git_commit) do
|
|
53
|
+
def self.from_json(j)
|
|
54
|
+
return nil if j.nil?
|
|
55
|
+
|
|
56
|
+
self.new(name: j["name"], git_commit: j["git_commit"])
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
ResultOfBuildInfo = KwStruct.new(:build_number, :dependencies)
|
|
61
|
+
ParamsOfAppRequest = KwStruct.new(:app_request_id, :request_data)
|
|
62
|
+
|
|
63
|
+
class AppRequestResult
|
|
64
|
+
TYPES = [:ok, :error]
|
|
65
|
+
attr_reader :type_, :text, :result
|
|
66
|
+
|
|
67
|
+
def initialize(type_:, result: nil, text: nil)
|
|
68
|
+
unless TYPES.include?(type_)
|
|
69
|
+
raise ArgumentError.new("type #{type_} is unknown; known types: #{TYPES}")
|
|
70
|
+
end
|
|
71
|
+
@type_ = type_
|
|
72
|
+
|
|
73
|
+
if !result.nil? && !text.nil?
|
|
74
|
+
raise ArgumentError.new("both 'result' and 'text' may not contain values at the same time")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
if @type_ == :ok
|
|
78
|
+
@result = result
|
|
79
|
+
elsif @type_ == :error
|
|
80
|
+
@text = text
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def to_h
|
|
85
|
+
{
|
|
86
|
+
type: Helper.sym_to_capitalized_case_str(@type_),
|
|
87
|
+
|
|
88
|
+
# may be either one instead?
|
|
89
|
+
result: @result,
|
|
90
|
+
text: @text
|
|
91
|
+
}
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
ParamsOfResolveAppRequest = KwStruct.new(:app_request_id, :result) do
|
|
96
|
+
def to_h
|
|
97
|
+
{
|
|
98
|
+
app_request_id: app_request_id,
|
|
99
|
+
result: result.to_h
|
|
100
|
+
}
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
#
|
|
106
|
+
# functions
|
|
107
|
+
#
|
|
108
|
+
|
|
109
|
+
# params:
|
|
110
|
+
# +ctx+:: +ClientContext+ object
|
|
111
|
+
def self.version(ctx)
|
|
112
|
+
Interop::request_to_native_lib(ctx, "client.version") do |resp|
|
|
113
|
+
if resp.success?
|
|
114
|
+
yield NativeLibResponseResult.new(
|
|
115
|
+
result: ResultOfVersion.new(version: resp.result["version"])
|
|
116
|
+
)
|
|
117
|
+
else
|
|
118
|
+
yield resp
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def self.config(ctx)
|
|
124
|
+
Interop::request_to_native_lib(ctx, "client.config") do |resp|
|
|
125
|
+
if resp.success?
|
|
126
|
+
yield NativeLibResponseResult.new(
|
|
127
|
+
result: ClientConfig.new(
|
|
128
|
+
network: resp.result["network"],
|
|
129
|
+
crypto: resp.result["crypto"],
|
|
130
|
+
abi: resp.result["abi"],
|
|
131
|
+
boc: resp.result["boc"]
|
|
132
|
+
)
|
|
133
|
+
)
|
|
134
|
+
else
|
|
135
|
+
yield resp
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def self.get_api_reference(ctx)
|
|
141
|
+
Interop::request_to_native_lib(ctx, "client.get_api_reference") do |resp|
|
|
142
|
+
if resp.success?
|
|
143
|
+
yield NativeLibResponseResult.new(
|
|
144
|
+
result: ResultOfGetApiReference.new(api: resp.result["api"])
|
|
145
|
+
)
|
|
146
|
+
else
|
|
147
|
+
yield resp
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def self.build_info(ctx)
|
|
153
|
+
Interop::request_to_native_lib(ctx, "client.build_info") do |resp|
|
|
154
|
+
if resp.success?
|
|
155
|
+
dp_s = resp.result["dependencies"].map { |x| BuildInfoDependency.from_json(x) }
|
|
156
|
+
yield NativeLibResponseResult.new(
|
|
157
|
+
result: ResultOfBuildInfo.new(
|
|
158
|
+
build_number: resp.result["build_number"],
|
|
159
|
+
dependencies: dp_s
|
|
160
|
+
)
|
|
161
|
+
)
|
|
162
|
+
else
|
|
163
|
+
yield resp
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def self.resolve_app_request(ctx, params)
|
|
169
|
+
Interop::request_to_native_lib(ctx, "client.resolve_app_request", params) do |resp|
|
|
170
|
+
if resp.success?
|
|
171
|
+
yield NativeLibResponseResult.new(
|
|
172
|
+
result: ""
|
|
173
|
+
)
|
|
174
|
+
else
|
|
175
|
+
yield resp
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
require_relative './kw_struct.rb'
|
|
4
|
+
require_relative './interop.rb'
|
|
5
|
+
require_relative './types.rb'
|
|
6
|
+
require_relative './helper.rb'
|
|
7
|
+
|
|
8
|
+
require_relative './config.rb'
|
|
9
|
+
require_relative './client.rb'
|
|
10
|
+
require_relative './utils.rb'
|
|
11
|
+
require_relative './crypto.rb'
|
|
12
|
+
require_relative './abi.rb'
|
|
13
|
+
require_relative './boc.rb'
|
|
14
|
+
require_relative './net.rb'
|
|
15
|
+
require_relative './tvm.rb'
|
|
16
|
+
require_relative './proofs.rb'
|
|
17
|
+
require_relative './processing.rb'
|
|
18
|
+
require_relative './debot.rb'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
module EverSdk
|
|
22
|
+
class ClientContext
|
|
23
|
+
attr_reader :context
|
|
24
|
+
|
|
25
|
+
def initialize(cfg_json)
|
|
26
|
+
cfg_json_tc_str = Interop::TcStringData::from_string(cfg_json)
|
|
27
|
+
ptr = Interop::tc_create_context(cfg_json_tc_str)
|
|
28
|
+
ctx_tc_str = Interop::tc_read_string(ptr)
|
|
29
|
+
if (ctx_tc_str != nil) && (ctx_tc_str[:len] > 0)
|
|
30
|
+
cont_str = ctx_tc_str[:content].read_string(ctx_tc_str[:len])
|
|
31
|
+
ctx_json = JSON.parse(cont_str)
|
|
32
|
+
ctx_val = ctx_json["result"]
|
|
33
|
+
if ctx_val != nil
|
|
34
|
+
@context = ctx_val
|
|
35
|
+
@requests = Concurrent::Hash.new()
|
|
36
|
+
ObjectSpace.define_finalizer(self, self.class.finalize(@context))
|
|
37
|
+
else
|
|
38
|
+
raise SdkError.new(message: "unable to create context: #{ctx_json}")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
Interop::tc_destroy_string(ptr)
|
|
42
|
+
else
|
|
43
|
+
raise SdkError.new(message: "unable to create context")
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.finalize(ctx)
|
|
48
|
+
Proc.new do
|
|
49
|
+
if (ctx != nil) && (ctx > 0)
|
|
50
|
+
Interop::tc_destroy_context(ctx)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|