ton_sdk_client 1.7.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 +7 -0
- data/CHANGELOG.md +46 -0
- data/LICENSE +201 -0
- data/README.md +235 -0
- data/lib/ton_sdk_client.rb +6 -0
- data/lib/ton_sdk_client/abi.rb +956 -0
- data/lib/ton_sdk_client/boc.rb +344 -0
- data/lib/ton_sdk_client/client.rb +208 -0
- data/lib/ton_sdk_client/client_context.rb +51 -0
- data/lib/ton_sdk_client/config.rb +108 -0
- data/lib/ton_sdk_client/crypto.rb +1325 -0
- data/lib/ton_sdk_client/debot.rb +466 -0
- data/lib/ton_sdk_client/helper.rb +20 -0
- data/lib/ton_sdk_client/interop.rb +230 -0
- data/lib/ton_sdk_client/net.rb +452 -0
- data/lib/ton_sdk_client/processing.rb +257 -0
- data/lib/ton_sdk_client/tvm.rb +264 -0
- data/lib/ton_sdk_client/types.rb +44 -0
- data/lib/ton_sdk_client/utils.rb +76 -0
- data/lib/ton_sdk_client/version.rb +5 -0
- metadata +134 -0
@@ -0,0 +1,344 @@
|
|
1
|
+
module TonSdk
|
2
|
+
module Boc
|
3
|
+
|
4
|
+
#
|
5
|
+
# types
|
6
|
+
#
|
7
|
+
|
8
|
+
class ParamsOfParse
|
9
|
+
attr_reader :boc
|
10
|
+
|
11
|
+
def initialize(a)
|
12
|
+
@boc = a
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_h = { boc: @boc }
|
16
|
+
end
|
17
|
+
|
18
|
+
class ResultOfParse
|
19
|
+
attr_reader :parsed
|
20
|
+
|
21
|
+
def initialize(a)
|
22
|
+
@parsed = a
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class ParamsOfParseShardstate
|
27
|
+
attr_reader :boc, :id, :workchain_id
|
28
|
+
|
29
|
+
def initialize(boc:, id_:, workchain_id:)
|
30
|
+
@boc = boc
|
31
|
+
@id_ = id_
|
32
|
+
@workchain_id = workchain_id
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_h
|
36
|
+
{
|
37
|
+
boc: @boc,
|
38
|
+
id: @id_,
|
39
|
+
workchain_id: @workchain_id
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class ParamsOfGetBlockchainConfig
|
45
|
+
attr_reader :block_boc
|
46
|
+
|
47
|
+
def initialize(a)
|
48
|
+
@block_boc = a
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_h
|
52
|
+
{
|
53
|
+
block_boc: @block_boc
|
54
|
+
}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class ResultOfGetBlockchainConfig
|
59
|
+
attr_reader :config_boc
|
60
|
+
|
61
|
+
def initialize(a)
|
62
|
+
@config_boc = a
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class ParamsOfGetBocHash
|
67
|
+
attr_reader :boc
|
68
|
+
|
69
|
+
def initialize(a)
|
70
|
+
@boc = a
|
71
|
+
end
|
72
|
+
|
73
|
+
def to_h
|
74
|
+
{
|
75
|
+
boc: @boc
|
76
|
+
}
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
class ResultOfGetBocHash
|
81
|
+
attr_reader :hash
|
82
|
+
|
83
|
+
def initialize(a)
|
84
|
+
@hash = a
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
class ParamsOfGetCodeFromTvc
|
89
|
+
attr_reader :tvc
|
90
|
+
|
91
|
+
def initialize(a)
|
92
|
+
@tvc = a
|
93
|
+
end
|
94
|
+
|
95
|
+
def to_h
|
96
|
+
{
|
97
|
+
tvc: @tvc
|
98
|
+
}
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
class ResultOfGetCodeFromTvc
|
103
|
+
attr_reader :code
|
104
|
+
|
105
|
+
def initialize(a)
|
106
|
+
@code = a
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
class ParamsOfBocCacheGet
|
111
|
+
attr_reader :boc_ref
|
112
|
+
|
113
|
+
def initialize(a)
|
114
|
+
@boc_ref = a
|
115
|
+
end
|
116
|
+
|
117
|
+
def to_h = { boc_ref: @boc_ref }
|
118
|
+
end
|
119
|
+
|
120
|
+
class ResultOfBocCacheGet
|
121
|
+
attr_reader :boc
|
122
|
+
|
123
|
+
def initialize(boc: nil)
|
124
|
+
@boc = boc
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
class BocCacheType
|
129
|
+
TYPES = [
|
130
|
+
:pinned,
|
131
|
+
:unpinned
|
132
|
+
]
|
133
|
+
|
134
|
+
attr_reader :type_, :pin
|
135
|
+
|
136
|
+
def new_with_type_pinned(pin)
|
137
|
+
@type_ = :pinned
|
138
|
+
@pin = pin
|
139
|
+
end
|
140
|
+
|
141
|
+
def new_with_type_unpinned
|
142
|
+
@type_ = :unpinned
|
143
|
+
end
|
144
|
+
|
145
|
+
def to_h
|
146
|
+
h1 = {
|
147
|
+
type: Helper.sym_to_capitalized_case_str(@type_)
|
148
|
+
}
|
149
|
+
|
150
|
+
h2 = if @type_ == :pinned
|
151
|
+
{
|
152
|
+
pin: @pin
|
153
|
+
}
|
154
|
+
else
|
155
|
+
{ }
|
156
|
+
end
|
157
|
+
|
158
|
+
h1.merge(h2)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
class ParamsOfBocCacheSet
|
163
|
+
attr_reader :boc, :cache_type
|
164
|
+
|
165
|
+
def initialize(boc:, cache_type:)
|
166
|
+
@boc = boc
|
167
|
+
@cache_type = cache_type
|
168
|
+
end
|
169
|
+
|
170
|
+
def to_h
|
171
|
+
{
|
172
|
+
boc: @boc,
|
173
|
+
cache_type: @cache_type.to_h
|
174
|
+
}
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
class ResultOfBocCacheGet
|
179
|
+
attr_reader :boc_ref
|
180
|
+
|
181
|
+
def initialize(a)
|
182
|
+
@boc_ref = a
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
class ParamsOfBocCacheUnpin
|
187
|
+
attr_reader :boc, :boc_ref
|
188
|
+
|
189
|
+
def initialize(boc:, boc_ref: nil)
|
190
|
+
@boc = boc
|
191
|
+
@boc_ref = boc_ref
|
192
|
+
end
|
193
|
+
|
194
|
+
def to_h
|
195
|
+
{
|
196
|
+
boc: @boc,
|
197
|
+
boc_ref: @boc_ref
|
198
|
+
}
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
#
|
205
|
+
# functions
|
206
|
+
#
|
207
|
+
|
208
|
+
def self.parse_message(ctx, params)
|
209
|
+
Interop::request_to_native_lib(ctx, "boc.parse_message", params.to_h.to_json) do |resp|
|
210
|
+
if resp.success?
|
211
|
+
yield NativeLibResponsetResult.new(
|
212
|
+
result: ResultOfParse.new(resp.result["parsed"])
|
213
|
+
)
|
214
|
+
else
|
215
|
+
yield resp
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def self.parse_transaction(ctx, params)
|
221
|
+
Interop::request_to_native_lib(ctx, "boc.parse_transaction", params.to_h.to_json) do |resp|
|
222
|
+
if resp.success?
|
223
|
+
yield NativeLibResponsetResult.new(
|
224
|
+
result: ResultOfParse.new(resp.result["parsed"])
|
225
|
+
)
|
226
|
+
else
|
227
|
+
yield resp
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
def self.parse_account(ctx, params)
|
233
|
+
Interop::request_to_native_lib(ctx, "boc.parse_account", params.to_h.to_json) do |resp|
|
234
|
+
if resp.success?
|
235
|
+
yield NativeLibResponsetResult.new(
|
236
|
+
result: ResultOfParse.new(resp.result["parsed"])
|
237
|
+
)
|
238
|
+
else
|
239
|
+
yield resp
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
def self.parse_block(ctx, params)
|
245
|
+
Interop::request_to_native_lib(ctx, "boc.parse_block", params.to_h.to_json) do |resp|
|
246
|
+
if resp.success?
|
247
|
+
yield NativeLibResponsetResult.new(
|
248
|
+
result: ResultOfParse.new(resp.result["parsed"])
|
249
|
+
)
|
250
|
+
else
|
251
|
+
yield resp
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
def self.parse_shardstate(ctx, params)
|
257
|
+
Interop::request_to_native_lib(ctx, "boc.parse_shardstate", params.to_h.to_json) do |resp|
|
258
|
+
if resp.success?
|
259
|
+
yield NativeLibResponsetResult.new(
|
260
|
+
result: ResultOfParse.new(resp.result["parsed"])
|
261
|
+
)
|
262
|
+
else
|
263
|
+
yield resp
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
def self.get_blockchain_config(ctx, params)
|
269
|
+
Interop::request_to_native_lib(ctx, "boc.get_blockchain_config", params.to_h.to_json) do |resp|
|
270
|
+
if resp.success?
|
271
|
+
yield NativeLibResponsetResult.new(
|
272
|
+
result: ResultOfGetBlockchainConfig.new(resp.result["config_boc"])
|
273
|
+
)
|
274
|
+
else
|
275
|
+
yield resp
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
def self.get_boc_hash(ctx, params)
|
281
|
+
Interop::request_to_native_lib(ctx, "boc.get_boc_hash", params.to_h.to_json) do |resp|
|
282
|
+
if resp.success?
|
283
|
+
yield NativeLibResponsetResult.new(
|
284
|
+
result: ResultOfGetBocHash.new(resp.result["hash"])
|
285
|
+
)
|
286
|
+
else
|
287
|
+
yield resp
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
def self.get_code_from_tvc(ctx, params)
|
293
|
+
Interop::request_to_native_lib(ctx, "boc.get_code_from_tvc", params.to_h.to_json) do |resp|
|
294
|
+
if resp.success?
|
295
|
+
yield NativeLibResponsetResult.new(
|
296
|
+
result: ResultOfGetCodeFromTvc.new(resp.result["code"])
|
297
|
+
)
|
298
|
+
else
|
299
|
+
yield resp
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
def self.cache_get(ctx, params)
|
305
|
+
Interop::request_to_native_lib(ctx, "boc.cache_get", params.to_h.to_json) do |resp|
|
306
|
+
if resp.success?
|
307
|
+
yield NativeLibResponsetResult.new(
|
308
|
+
result: ResultOfBocCacheGet.new(
|
309
|
+
boc: resp.result["boc"]
|
310
|
+
)
|
311
|
+
)
|
312
|
+
else
|
313
|
+
yield resp
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
def self.cache_set(ctx, params)
|
319
|
+
Interop::request_to_native_lib(ctx, "boc.cache_set", params.to_h.to_json) do |resp|
|
320
|
+
if resp.success?
|
321
|
+
yield NativeLibResponsetResult.new(
|
322
|
+
result: ResultOfBocCacheSet.new(
|
323
|
+
boc_ref: resp.result["boc_ref"]
|
324
|
+
)
|
325
|
+
)
|
326
|
+
else
|
327
|
+
yield resp
|
328
|
+
end
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
def self.cache_unpin(ctx, params)
|
333
|
+
Interop::request_to_native_lib(ctx, "boc.cache_unpin", params.to_h.to_json) do |resp|
|
334
|
+
if resp.success?
|
335
|
+
yield NativeLibResponsetResult.new(
|
336
|
+
result: nil
|
337
|
+
)
|
338
|
+
else
|
339
|
+
yield resp
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
343
|
+
end
|
344
|
+
end
|
@@ -0,0 +1,208 @@
|
|
1
|
+
require 'json'
|
2
|
+
require_relative './interop.rb'
|
3
|
+
|
4
|
+
module TonSdk
|
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
|
+
end
|
46
|
+
|
47
|
+
class ResultOfVersion
|
48
|
+
attr_reader :version
|
49
|
+
|
50
|
+
def initialize(a)
|
51
|
+
@version = a
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class ResultOfGetApiReference
|
56
|
+
attr_reader :api
|
57
|
+
|
58
|
+
def initialize(a)
|
59
|
+
@api = a
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
class BuildInfoDependency
|
64
|
+
attr_reader :name, :git_commit
|
65
|
+
|
66
|
+
def initialize(name:, git_commit:)
|
67
|
+
@name = name
|
68
|
+
@git_commit = git_commit
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.from_json(j)
|
72
|
+
return nil if j.nil?
|
73
|
+
|
74
|
+
self.new(
|
75
|
+
name: j["name"],
|
76
|
+
git_commit: j["git_commit"]
|
77
|
+
)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
class ResultOfBuildInfo
|
82
|
+
attr_reader :build_number, :dependencies
|
83
|
+
|
84
|
+
def initialize(build_number:, dependencies:)
|
85
|
+
@build_number = build_number
|
86
|
+
@dependencies = dependencies
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class ParamsOfAppRequest
|
91
|
+
attr_reader :app_request_id, :request_data
|
92
|
+
|
93
|
+
def initialize(app_request_id:, request_data:)
|
94
|
+
@app_request_id = app_request_id
|
95
|
+
@request_data = request_data
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
class AppRequestResult
|
100
|
+
TYPES = [:ok, :error]
|
101
|
+
attr_reader :type_, :text, :result
|
102
|
+
|
103
|
+
def initialize(type_:, result: nil, text: nil)
|
104
|
+
unless TYPES.include?(type_)
|
105
|
+
raise ArgumentError.new("type #{type_} is unknown; known types: #{TYPES}")
|
106
|
+
end
|
107
|
+
@type_ = type_
|
108
|
+
|
109
|
+
if !result.nil? && !text.nil?
|
110
|
+
raise ArgumentError.new("both 'result' and 'text' may not contain values at the same time")
|
111
|
+
end
|
112
|
+
|
113
|
+
if @type_ == :ok
|
114
|
+
@result = result
|
115
|
+
elsif @type_ == :error
|
116
|
+
@text = text
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def to_h
|
121
|
+
{
|
122
|
+
type: Helper.sym_to_capitalized_case_str(@type_),
|
123
|
+
|
124
|
+
# may be either one instead?
|
125
|
+
result: @result,
|
126
|
+
text: @text
|
127
|
+
}
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
class ParamsOfResolveAppRequest
|
132
|
+
attr_reader :app_request_id, :result
|
133
|
+
|
134
|
+
def initialize(app_request_id:, result:)
|
135
|
+
@app_request_id = app_request_id
|
136
|
+
@result = result
|
137
|
+
end
|
138
|
+
|
139
|
+
def to_h
|
140
|
+
{
|
141
|
+
app_request_id: @app_request_id,
|
142
|
+
result: @result.to_h
|
143
|
+
}
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
#
|
149
|
+
# functions
|
150
|
+
#
|
151
|
+
|
152
|
+
|
153
|
+
# returns a version of TON
|
154
|
+
# params:
|
155
|
+
# +ctx+:: +ClientContext+ object
|
156
|
+
def self.version(ctx)
|
157
|
+
Interop::request_to_native_lib(ctx, "client.version") do |resp|
|
158
|
+
if resp.success?
|
159
|
+
yield NativeLibResponsetResult.new(
|
160
|
+
result: ResultOfVersion.new(resp.result["version"])
|
161
|
+
)
|
162
|
+
else
|
163
|
+
yield resp
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def self.get_api_reference(ctx)
|
169
|
+
Interop::request_to_native_lib(ctx, "client.get_api_reference") do |resp|
|
170
|
+
if resp.success?
|
171
|
+
yield NativeLibResponsetResult.new(
|
172
|
+
result: ResultOfGetApiReference.new(resp.result["api"])
|
173
|
+
)
|
174
|
+
else
|
175
|
+
yield resp
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def self.build_info(ctx)
|
181
|
+
Interop::request_to_native_lib(ctx, "client.build_info") do |resp|
|
182
|
+
if resp.success?
|
183
|
+
dp_s = resp.result["dependencies"].map { |x| BuildInfoDependency.from_json(x) }
|
184
|
+
yield NativeLibResponsetResult.new(
|
185
|
+
result: ResultOfBuildInfo.new(
|
186
|
+
build_number: resp.result["build_number"],
|
187
|
+
dependencies: dp_s
|
188
|
+
)
|
189
|
+
)
|
190
|
+
else
|
191
|
+
yield resp
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def self.resolve_app_request(ctx, params)
|
197
|
+
Interop::request_to_native_lib(ctx, "client.resolve_app_request", params.to_h.to_json) do |resp|
|
198
|
+
if resp.success?
|
199
|
+
yield NativeLibResponsetResult.new(
|
200
|
+
result: ""
|
201
|
+
)
|
202
|
+
else
|
203
|
+
yield resp
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|