ton_sdk_client 1.20.0 → 1.24.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +2 -2
- data/lib/ton_sdk_client/abi.rb +201 -69
- data/lib/ton_sdk_client/boc.rb +200 -50
- data/lib/ton_sdk_client/client.rb +12 -15
- data/lib/ton_sdk_client/client_context.rb +2 -1
- data/lib/ton_sdk_client/config.rb +7 -9
- data/lib/ton_sdk_client/crypto.rb +174 -184
- data/lib/ton_sdk_client/debot.rb +13 -14
- data/lib/ton_sdk_client/interop.rb +2 -2
- data/lib/ton_sdk_client/kw_struct.rb +7 -0
- data/lib/ton_sdk_client/net.rb +44 -46
- data/lib/ton_sdk_client/processing.rb +7 -7
- data/lib/ton_sdk_client/tvm.rb +10 -12
- data/lib/ton_sdk_client/types.rb +2 -1
- data/lib/ton_sdk_client/utils.rb +18 -18
- data/lib/ton_sdk_client/version.rb +2 -2
- metadata +7 -6
data/lib/ton_sdk_client/boc.rb
CHANGED
@@ -5,66 +5,134 @@ module TonSdk
|
|
5
5
|
# types
|
6
6
|
#
|
7
7
|
|
8
|
-
ParamsOfParse =
|
9
|
-
ResultOfParse =
|
10
|
-
ParamsOfParseShardstate =
|
11
|
-
ParamsOfGetBlockchainConfig =
|
12
|
-
ResultOfGetBlockchainConfig =
|
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
13
|
|
14
|
-
ParamsOfGetBocHash =
|
15
|
-
ResultOfGetBocHash =
|
16
|
-
ParamsOfGetCodeFromTvc = Struct.new(:hash)
|
17
|
-
ResultOfGetCodeFromTvc = Struct.new(:code)
|
18
|
-
ParamsOfBocCacheGet = Struct.new(:boc_ref)
|
14
|
+
ParamsOfGetBocHash = KwStruct.new(:boc)
|
15
|
+
ResultOfGetBocHash = KwStruct.new(:hash)
|
19
16
|
|
20
|
-
|
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)
|
21
25
|
|
22
26
|
class BocCacheType
|
23
|
-
|
27
|
+
TYPES = [
|
28
|
+
:pinned,
|
29
|
+
:unpinned
|
30
|
+
]
|
24
31
|
|
25
|
-
attr_reader :
|
32
|
+
attr_reader :type, :pin
|
26
33
|
|
27
|
-
def
|
28
|
-
|
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
|
29
39
|
@pin = pin
|
30
40
|
end
|
31
41
|
|
32
|
-
def
|
33
|
-
|
42
|
+
def to_h
|
43
|
+
hash = {type: Helper.sym_to_capitalized_case_str(type)}
|
44
|
+
hash[:pin] = pin if type == :pinned
|
45
|
+
hash
|
34
46
|
end
|
47
|
+
end
|
35
48
|
|
49
|
+
ParamsOfBocCacheSet = KwStruct.new(:boc, :cache_type) do
|
36
50
|
def to_h
|
37
|
-
|
38
|
-
|
51
|
+
{
|
52
|
+
boc: boc,
|
53
|
+
cache_type: cache_type.to_h
|
39
54
|
}
|
55
|
+
end
|
56
|
+
end
|
40
57
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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)
|
48
85
|
|
49
|
-
|
86
|
+
ParamsOfDecodeTvc = KwStruct.new(:tvc, :boc_cache) do
|
87
|
+
def to_h
|
88
|
+
{
|
89
|
+
tvc: tvc,
|
90
|
+
boc_cache: boc_cache&.to_h
|
91
|
+
}
|
50
92
|
end
|
51
93
|
end
|
52
94
|
|
53
|
-
|
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
|
54
118
|
def to_h
|
55
119
|
{
|
56
|
-
|
57
|
-
|
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
|
58
127
|
}
|
59
128
|
end
|
60
129
|
end
|
61
130
|
|
62
|
-
|
63
|
-
ParamsOfBocCacheUnpin = Struct.new(:boc, :boc_ref)
|
64
|
-
ParamsOfEncodeBoc = Struct.new(:builder, :boc_cache)
|
65
|
-
ResultOfEncodeBoc = Struct.new(:boc)
|
131
|
+
ResultOfEncodeTvc = KwStruct.new(:tvc)
|
66
132
|
|
133
|
+
ParamsOfGetCompilerVersion = KwStruct.new(:code)
|
67
134
|
|
135
|
+
ResultOfGetCompilerVersion = KwStruct.new(:version)
|
68
136
|
|
69
137
|
#
|
70
138
|
# functions
|
@@ -74,7 +142,7 @@ module TonSdk
|
|
74
142
|
Interop::request_to_native_lib(ctx, "boc.parse_message", params) do |resp|
|
75
143
|
if resp.success?
|
76
144
|
yield NativeLibResponsetResult.new(
|
77
|
-
result: ResultOfParse.new(resp.result["parsed"])
|
145
|
+
result: ResultOfParse.new(parsed: resp.result["parsed"])
|
78
146
|
)
|
79
147
|
else
|
80
148
|
yield resp
|
@@ -86,7 +154,7 @@ module TonSdk
|
|
86
154
|
Interop::request_to_native_lib(ctx, "boc.parse_transaction", params) do |resp|
|
87
155
|
if resp.success?
|
88
156
|
yield NativeLibResponsetResult.new(
|
89
|
-
result: ResultOfParse.new(resp.result["parsed"])
|
157
|
+
result: ResultOfParse.new(parsed: resp.result["parsed"])
|
90
158
|
)
|
91
159
|
else
|
92
160
|
yield resp
|
@@ -98,7 +166,7 @@ module TonSdk
|
|
98
166
|
Interop::request_to_native_lib(ctx, "boc.parse_account", params) do |resp|
|
99
167
|
if resp.success?
|
100
168
|
yield NativeLibResponsetResult.new(
|
101
|
-
result: ResultOfParse.new(resp.result["parsed"])
|
169
|
+
result: ResultOfParse.new(parsed: resp.result["parsed"])
|
102
170
|
)
|
103
171
|
else
|
104
172
|
yield resp
|
@@ -110,7 +178,7 @@ module TonSdk
|
|
110
178
|
Interop::request_to_native_lib(ctx, "boc.parse_block", params) do |resp|
|
111
179
|
if resp.success?
|
112
180
|
yield NativeLibResponsetResult.new(
|
113
|
-
result: ResultOfParse.new(resp.result["parsed"])
|
181
|
+
result: ResultOfParse.new(parsed: resp.result["parsed"])
|
114
182
|
)
|
115
183
|
else
|
116
184
|
yield resp
|
@@ -122,7 +190,19 @@ module TonSdk
|
|
122
190
|
Interop::request_to_native_lib(ctx, "boc.parse_shardstate", params) do |resp|
|
123
191
|
if resp.success?
|
124
192
|
yield NativeLibResponsetResult.new(
|
125
|
-
result: ResultOfParse.new(resp.result["parsed"])
|
193
|
+
result: ResultOfParse.new(parsed: resp.result["parsed"])
|
194
|
+
)
|
195
|
+
else
|
196
|
+
yield resp
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def self.get_boc_hash(ctx, params)
|
202
|
+
Interop::request_to_native_lib(ctx, "boc.get_boc_hash", params) do |resp|
|
203
|
+
if resp.success?
|
204
|
+
yield NativeLibResponsetResult.new(
|
205
|
+
result: ResultOfGetBocHash.new(hash: resp.result["hash"])
|
126
206
|
)
|
127
207
|
else
|
128
208
|
yield resp
|
@@ -134,7 +214,9 @@ module TonSdk
|
|
134
214
|
Interop::request_to_native_lib(ctx, "boc.get_blockchain_config", params) do |resp|
|
135
215
|
if resp.success?
|
136
216
|
yield NativeLibResponsetResult.new(
|
137
|
-
result: ResultOfGetBlockchainConfig.new(
|
217
|
+
result: ResultOfGetBlockchainConfig.new(
|
218
|
+
config_boc: resp.result["config_boc"]
|
219
|
+
)
|
138
220
|
)
|
139
221
|
else
|
140
222
|
yield resp
|
@@ -142,11 +224,13 @@ module TonSdk
|
|
142
224
|
end
|
143
225
|
end
|
144
226
|
|
145
|
-
def self.
|
146
|
-
Interop::request_to_native_lib(ctx, "boc.
|
227
|
+
def self.get_boc_depth(ctx, params)
|
228
|
+
Interop::request_to_native_lib(ctx, "boc.get_boc_depth", params) do |resp|
|
147
229
|
if resp.success?
|
148
230
|
yield NativeLibResponsetResult.new(
|
149
|
-
result:
|
231
|
+
result: ResultOfGetBocDepth.new(
|
232
|
+
depth: resp.result["depth"]
|
233
|
+
)
|
150
234
|
)
|
151
235
|
else
|
152
236
|
yield resp
|
@@ -158,7 +242,7 @@ module TonSdk
|
|
158
242
|
Interop::request_to_native_lib(ctx, "boc.get_code_from_tvc", params) do |resp|
|
159
243
|
if resp.success?
|
160
244
|
yield NativeLibResponsetResult.new(
|
161
|
-
result: ResultOfGetCodeFromTvc.new(resp.result["code"])
|
245
|
+
result: ResultOfGetCodeFromTvc.new(code: resp.result["code"])
|
162
246
|
)
|
163
247
|
else
|
164
248
|
yield resp
|
@@ -211,7 +295,7 @@ module TonSdk
|
|
211
295
|
if resp.success?
|
212
296
|
yield NativeLibResponsetResult.new(
|
213
297
|
result: ResultOfEncodeBoc.new(
|
214
|
-
resp.result["boc"]
|
298
|
+
boc: resp.result["boc"]
|
215
299
|
)
|
216
300
|
)
|
217
301
|
else
|
@@ -220,12 +304,78 @@ module TonSdk
|
|
220
304
|
end
|
221
305
|
end
|
222
306
|
|
223
|
-
def self.
|
224
|
-
Interop::request_to_native_lib(ctx, "boc.
|
307
|
+
def self.get_code_salt(ctx, params)
|
308
|
+
Interop::request_to_native_lib(ctx, "boc.get_code_salt", params) do |resp|
|
225
309
|
if resp.success?
|
226
310
|
yield NativeLibResponsetResult.new(
|
227
|
-
result:
|
228
|
-
resp.result["
|
311
|
+
result: ResultOfGetCodeSalt.new(
|
312
|
+
salt: resp.result["salt"]
|
313
|
+
)
|
314
|
+
)
|
315
|
+
else
|
316
|
+
yield resp
|
317
|
+
end
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
def self.set_code_salt(ctx, params)
|
322
|
+
Interop::request_to_native_lib(ctx, "boc.set_code_salt", params) do |resp|
|
323
|
+
if resp.success?
|
324
|
+
yield NativeLibResponsetResult.new(
|
325
|
+
result: ResultOfSetCodeSalt.new(
|
326
|
+
code: resp.result["code"]
|
327
|
+
)
|
328
|
+
)
|
329
|
+
else
|
330
|
+
yield resp
|
331
|
+
end
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
def self.decode_tvc(ctx, params)
|
336
|
+
Interop::request_to_native_lib(ctx, "boc.decode_tvc", params) do |resp|
|
337
|
+
if resp.success?
|
338
|
+
yield NativeLibResponsetResult.new(
|
339
|
+
result: ResultOfDecodeTvc.new(
|
340
|
+
code: resp.result["code"],
|
341
|
+
code_depth: resp.result["code_depth"],
|
342
|
+
code_hash: resp.result["code_hash"],
|
343
|
+
data: resp.result["data"],
|
344
|
+
data_depth: resp.result["data_depth"],
|
345
|
+
data_hash: resp.result["data_hash"],
|
346
|
+
library: resp.result["library"],
|
347
|
+
tick: resp.result["tick"],
|
348
|
+
tock: resp.result["tock"],
|
349
|
+
split_depth: resp.result["split_depth"],
|
350
|
+
compiler_version: resp.result["compiler_version"]
|
351
|
+
)
|
352
|
+
)
|
353
|
+
else
|
354
|
+
yield resp
|
355
|
+
end
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
def self.encode_tvc(ctx, params)
|
360
|
+
Interop::request_to_native_lib(ctx, "boc.encode_tvc", params) do |resp|
|
361
|
+
if resp.success?
|
362
|
+
yield NativeLibResponsetResult.new(
|
363
|
+
result: ResultOfEncodeTvc.new(
|
364
|
+
tvc: resp.result["tvc"]
|
365
|
+
)
|
366
|
+
)
|
367
|
+
else
|
368
|
+
yield resp
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
def self.get_compiler_version(ctx, params)
|
374
|
+
Interop::request_to_native_lib(ctx, "boc.get_compiler_version", params) do |resp|
|
375
|
+
if resp.success?
|
376
|
+
yield NativeLibResponsetResult.new(
|
377
|
+
result: ResultOfGetCompilerVersion.new(
|
378
|
+
version: resp.result["version"]
|
229
379
|
)
|
230
380
|
)
|
231
381
|
else
|
@@ -234,4 +384,4 @@ module TonSdk
|
|
234
384
|
end
|
235
385
|
end
|
236
386
|
end
|
237
|
-
end
|
387
|
+
end
|
@@ -45,22 +45,19 @@ module TonSdk
|
|
45
45
|
INVALID_HANDLE = 34
|
46
46
|
end
|
47
47
|
|
48
|
-
ResultOfVersion =
|
49
|
-
ResultOfGetApiReference =
|
48
|
+
ResultOfVersion = KwStruct.new(:version)
|
49
|
+
ResultOfGetApiReference = KwStruct.new(:api)
|
50
50
|
|
51
|
-
BuildInfoDependency =
|
51
|
+
BuildInfoDependency = KwStruct.new(:name, :git_commit) do
|
52
52
|
def self.from_json(j)
|
53
53
|
return nil if j.nil?
|
54
54
|
|
55
|
-
self.new(
|
56
|
-
j["name"],
|
57
|
-
j["git_commit"]
|
58
|
-
)
|
55
|
+
self.new(name: j["name"], git_commit: j["git_commit"])
|
59
56
|
end
|
60
57
|
end
|
61
58
|
|
62
|
-
ResultOfBuildInfo =
|
63
|
-
ParamsOfAppRequest =
|
59
|
+
ResultOfBuildInfo = KwStruct.new(:build_number, :dependencies)
|
60
|
+
ParamsOfAppRequest = KwStruct.new(:app_request_id, :request_data)
|
64
61
|
|
65
62
|
class AppRequestResult
|
66
63
|
TYPES = [:ok, :error]
|
@@ -94,11 +91,11 @@ module TonSdk
|
|
94
91
|
end
|
95
92
|
end
|
96
93
|
|
97
|
-
ParamsOfResolveAppRequest =
|
94
|
+
ParamsOfResolveAppRequest = KwStruct.new(:app_request_id, :result) do
|
98
95
|
def to_h
|
99
96
|
{
|
100
|
-
app_request_id:
|
101
|
-
result:
|
97
|
+
app_request_id: app_request_id,
|
98
|
+
result: result.to_h
|
102
99
|
}
|
103
100
|
end
|
104
101
|
end
|
@@ -116,7 +113,7 @@ module TonSdk
|
|
116
113
|
Interop::request_to_native_lib(ctx, "client.version") do |resp|
|
117
114
|
if resp.success?
|
118
115
|
yield NativeLibResponsetResult.new(
|
119
|
-
result: ResultOfVersion.new(resp.result["version"])
|
116
|
+
result: ResultOfVersion.new(version: resp.result["version"])
|
120
117
|
)
|
121
118
|
else
|
122
119
|
yield resp
|
@@ -128,7 +125,7 @@ module TonSdk
|
|
128
125
|
Interop::request_to_native_lib(ctx, "client.get_api_reference") do |resp|
|
129
126
|
if resp.success?
|
130
127
|
yield NativeLibResponsetResult.new(
|
131
|
-
result: ResultOfGetApiReference.new(resp.result["api"])
|
128
|
+
result: ResultOfGetApiReference.new(api: resp.result["api"])
|
132
129
|
)
|
133
130
|
else
|
134
131
|
yield resp
|
@@ -164,4 +161,4 @@ module TonSdk
|
|
164
161
|
end
|
165
162
|
end
|
166
163
|
end
|
167
|
-
end
|
164
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'json'
|
2
2
|
|
3
|
+
require_relative './kw_struct.rb'
|
3
4
|
require_relative './interop.rb'
|
4
5
|
require_relative './types.rb'
|
5
6
|
require_relative './helper.rb'
|
@@ -38,7 +39,7 @@ module TonSdk
|
|
38
39
|
|
39
40
|
Interop::tc_destroy_string(ptr)
|
40
41
|
else
|
41
|
-
raise SdkError.new("unable to create context")
|
42
|
+
raise SdkError.new(message: "unable to create context")
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module TonSdk
|
2
|
-
CryptoConfig =
|
3
|
-
BocConfig =
|
4
|
-
NetworkConfig =
|
2
|
+
CryptoConfig = KwStruct.new(:mnemonic_dictionary, :mnemonic_word_count, :hdkey_derivation_path)
|
3
|
+
BocConfig = KwStruct.new(:cache_max_size)
|
4
|
+
NetworkConfig = KwStruct.new(
|
5
5
|
:server_address,
|
6
6
|
:endpoints,
|
7
7
|
:network_retries_count,
|
@@ -15,8 +15,7 @@ module TonSdk
|
|
15
15
|
:latency_detection_interval,
|
16
16
|
:max_latency,
|
17
17
|
:query_timeout,
|
18
|
-
:access_key
|
19
|
-
keyword_init: true
|
18
|
+
:access_key
|
20
19
|
) do
|
21
20
|
def initialize(
|
22
21
|
server_address: "",
|
@@ -38,11 +37,10 @@ module TonSdk
|
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
41
|
-
AbiConfig =
|
40
|
+
AbiConfig = KwStruct.new(
|
42
41
|
:workchain,
|
43
42
|
:message_expiration_timeout,
|
44
|
-
:message_expiration_timeout_grow_factor
|
45
|
-
keyword_init: true
|
43
|
+
:message_expiration_timeout_grow_factor
|
46
44
|
) do
|
47
45
|
def initialize(
|
48
46
|
workchain: nil,
|
@@ -53,7 +51,7 @@ module TonSdk
|
|
53
51
|
end
|
54
52
|
end
|
55
53
|
|
56
|
-
ClientConfig =
|
54
|
+
ClientConfig = KwStruct.new(:network, :crypto, :abi, :boc) do
|
57
55
|
def to_h
|
58
56
|
res = super.to_h
|
59
57
|
|