ton_sdk_client 1.11.0 → 1.12.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 +13 -0
- data/README.md +1 -1
- data/lib/ton_sdk_client/client.rb +8 -49
- data/lib/ton_sdk_client/crypto.rb +13 -90
- data/lib/ton_sdk_client/debot.rb +40 -208
- data/lib/ton_sdk_client/utils.rb +41 -27
- data/lib/ton_sdk_client/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1488455ed50f5b20f5001060b447ac3dbe1192fa0a132aada97709581f114a05
|
4
|
+
data.tar.gz: fc3a1e81c03c190d37dfe5972343c7428a51cc455ef3a20ed10b6951d6de7e55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17dbfc68077a1c6370e31ce43eff87e5448a9bb94ddef5ff2441c2eb8b07c5e7797a5e2d01fcb73a03000e83761ccc28b7df629f5aba023082379756e6465954
|
7
|
+
data.tar.gz: ea2a1c538a3d039bfccb1a3ddc249988eb136e2ba6d3e16dda333f3b1763789c2dc7d6e58a44c8ddfabb01848f612bb263edce009278f61dfd10d030aa4f6428
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
1.12.x
|
4
|
+
-----
|
5
|
+
* TON SDK version: 1.12.0
|
6
|
+
* internal refactoring
|
7
|
+
* the changes are according the ones of TON SDK
|
8
|
+
|
9
|
+
|
10
|
+
1.11.x
|
11
|
+
-----
|
12
|
+
* TON SDK version: 1.11.0
|
13
|
+
* the changes are according the ones of TON SDK
|
14
|
+
|
15
|
+
|
3
16
|
1.10.x
|
4
17
|
-----
|
5
18
|
* TON SDK version: 1.10.0
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# TON SDK client in Ruby and for Ruby
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/ton_sdk_client.png)](https://badge.fury.io/rb/ton_sdk_client)
|
4
|
-
[![TON SDK version](https://img.shields.io/badge/TON%20SDK%20version-1.
|
4
|
+
[![TON SDK version](https://img.shields.io/badge/TON%20SDK%20version-1.12.0-green)](https://github.com/tonlabs/TON-SDK/tree/1.12.0)
|
5
5
|
|
6
6
|
Ruby gem-client bindings for [TON SDK](https://github.com/tonlabs/TON-SDK) which allows one to communicate with [FreeTON](https://freeton.org) blockchain in Ruby.
|
7
7
|
|
@@ -44,57 +44,23 @@ module TonSdk
|
|
44
44
|
INTERNAL_ERROR = 33
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
attr_reader :version
|
47
|
+
ResultOfVersion = Struct.new(:version)
|
49
48
|
|
50
|
-
|
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
|
49
|
+
ResultOfGetApiReference = Struct.new(:api)
|
70
50
|
|
51
|
+
BuildInfoDependency = Struct.new(:name, :git_commit, keyword_init: true) do
|
71
52
|
def self.from_json(j)
|
72
53
|
return nil if j.nil?
|
73
54
|
|
74
55
|
self.new(
|
75
|
-
|
76
|
-
|
56
|
+
j["name"],
|
57
|
+
j["git_commit"]
|
77
58
|
)
|
78
59
|
end
|
79
60
|
end
|
80
61
|
|
81
|
-
|
82
|
-
|
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
|
62
|
+
ResultOfBuildInfo = Struct.new(:build_number, :dependencies, keyword_init: true)
|
63
|
+
ParamsOfAppRequest = Struct.new(:app_request_id, :request_data, keyword_init: true)
|
98
64
|
|
99
65
|
class AppRequestResult
|
100
66
|
TYPES = [:ok, :error]
|
@@ -128,14 +94,7 @@ module TonSdk
|
|
128
94
|
end
|
129
95
|
end
|
130
96
|
|
131
|
-
|
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
|
-
|
97
|
+
ParamsOfResolveAppRequest = Struct.new(:app_request_id, :result, keyword_init: true) do
|
139
98
|
def to_h
|
140
99
|
{
|
141
100
|
app_request_id: @app_request_id,
|
@@ -37,13 +37,7 @@ module TonSdk
|
|
37
37
|
def to_h = { composite: @composite }
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
attr_reader :factors
|
42
|
-
|
43
|
-
def initialize(a)
|
44
|
-
@factors = a
|
45
|
-
end
|
46
|
-
end
|
40
|
+
ResultOfFactorize = Struct.new(:factors)
|
47
41
|
|
48
42
|
class ParamsOfModularPower
|
49
43
|
attr_reader :base, :exponent, :modulus
|
@@ -63,84 +57,27 @@ module TonSdk
|
|
63
57
|
end
|
64
58
|
end
|
65
59
|
|
66
|
-
|
67
|
-
attr_reader :modular_power
|
68
|
-
|
69
|
-
def initialize(a)
|
70
|
-
@modular_power = a
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
class ParamsOfTonCrc16
|
75
|
-
attr_reader :data
|
76
|
-
|
77
|
-
def initialize(a)
|
78
|
-
@data = a
|
79
|
-
end
|
60
|
+
ResultOfModularPower = Struct.new(:modular_power)
|
80
61
|
|
62
|
+
ParamsOfTonCrc16 = Struct.new(:data) do
|
81
63
|
def to_h = { data: @data }
|
82
64
|
end
|
83
65
|
|
84
|
-
|
85
|
-
attr_reader :crc
|
66
|
+
ResultOfTonCrc16 = Struct.new(:crc)
|
86
67
|
|
87
|
-
|
88
|
-
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
class ParamsOfGenerateRandomBytes
|
93
|
-
attr_reader :length
|
94
|
-
|
95
|
-
def initialize(a)
|
96
|
-
@length = a
|
97
|
-
end
|
98
|
-
|
99
|
-
def to_h
|
100
|
-
{
|
101
|
-
length: @length
|
102
|
-
}
|
103
|
-
end
|
68
|
+
ParamsOfGenerateRandomBytes = Struct.new(:length) do
|
69
|
+
def to_h = { length: @length }
|
104
70
|
end
|
105
71
|
|
106
|
-
|
107
|
-
attr_reader :bytes
|
72
|
+
ResultOfGenerateRandomBytes = Struct.new(:bytes)
|
108
73
|
|
109
|
-
|
110
|
-
|
111
|
-
end
|
74
|
+
ParamsOfConvertPublicKeyToTonSafeFormat = Struct.new(:public_key) do
|
75
|
+
def to_h = { public_key: @public_key }
|
112
76
|
end
|
113
77
|
|
114
|
-
|
115
|
-
attr_reader :public_key
|
116
|
-
|
117
|
-
def initialize(a)
|
118
|
-
@public_key = a
|
119
|
-
end
|
120
|
-
|
121
|
-
def to_h
|
122
|
-
{
|
123
|
-
public_key: @public_key
|
124
|
-
}
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
class ResultOfConvertPublicKeyToTonSafeFormat
|
129
|
-
attr_reader :ton_public_key
|
130
|
-
|
131
|
-
def initialize(a)
|
132
|
-
@ton_public_key = a
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
class KeyPair
|
137
|
-
attr_reader :public_, :secret
|
138
|
-
|
139
|
-
def initialize(public_: , secret:)
|
140
|
-
@public_ = public_
|
141
|
-
@secret = secret
|
142
|
-
end
|
78
|
+
ResultOfConvertPublicKeyToTonSafeFormat = Struct.new(:ton_public_key)
|
143
79
|
|
80
|
+
KeyPair = Struct.new(:public_, :secret) do
|
144
81
|
def to_h
|
145
82
|
{
|
146
83
|
public: @public_,
|
@@ -149,14 +86,7 @@ module TonSdk
|
|
149
86
|
end
|
150
87
|
end
|
151
88
|
|
152
|
-
|
153
|
-
attr_reader :unsigned, :keys
|
154
|
-
|
155
|
-
def initialize(unsigned:, keys:)
|
156
|
-
@unsigned = unsigned
|
157
|
-
@keys = keys
|
158
|
-
end
|
159
|
-
|
89
|
+
ParamsOfSign = Struct.new(:unsigned, :keys) do
|
160
90
|
def to_h
|
161
91
|
{
|
162
92
|
unsigned: @unsigned,
|
@@ -165,14 +95,7 @@ module TonSdk
|
|
165
95
|
end
|
166
96
|
end
|
167
97
|
|
168
|
-
|
169
|
-
attr_reader :signed, :signature
|
170
|
-
|
171
|
-
def initialize(signed:, signature:)
|
172
|
-
@signed = signed
|
173
|
-
@signature = signature
|
174
|
-
end
|
175
|
-
end
|
98
|
+
ResultOfSign = Struct.new(:signed, :signature)
|
176
99
|
|
177
100
|
class ParamsOfVerifySignature
|
178
101
|
attr_reader :signed, :public_
|
data/lib/ton_sdk_client/debot.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module TonSdk
|
2
2
|
|
3
3
|
# NOTE
|
4
|
-
# as of
|
4
|
+
# as of 28 apr 2021, in the main repository this module is still unstable
|
5
5
|
module Debot
|
6
6
|
|
7
7
|
#
|
@@ -23,18 +23,7 @@ module TonSdk
|
|
23
23
|
OPERATION_REJECTED = 812
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
attr_reader :description, :name, :action_type, :to, :attributes, :misc
|
28
|
-
|
29
|
-
def initialize(description:, name:, action_type:, to:, attributes:, misc:)
|
30
|
-
@description = description
|
31
|
-
@name = name
|
32
|
-
@action_type = action_type
|
33
|
-
@to = to
|
34
|
-
@attributes = attributes
|
35
|
-
@misc = misc
|
36
|
-
end
|
37
|
-
|
26
|
+
DebotAction = Struct.new(:description, :name, :action_type, :to, :attributes, :misc) do
|
38
27
|
def to_h
|
39
28
|
{
|
40
29
|
description: @description,
|
@@ -60,23 +49,11 @@ module TonSdk
|
|
60
49
|
end
|
61
50
|
end
|
62
51
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
def initialize(a)
|
67
|
-
@address = a
|
68
|
-
end
|
69
|
-
|
70
|
-
def to_h = { address: @address }
|
52
|
+
ParamsOfStart = Struct.new(:debot_handle) do
|
53
|
+
def to_h = { debot_handle: @debot_handle }
|
71
54
|
end
|
72
55
|
|
73
|
-
|
74
|
-
attr_reader :debot_handle
|
75
|
-
|
76
|
-
def initialize(a)
|
77
|
-
@debot_handle = a
|
78
|
-
end
|
79
|
-
|
56
|
+
RegisteredDebot = Struct.new(:debot_handle) do
|
80
57
|
def to_h = { debot_handle: @debot_handle }
|
81
58
|
end
|
82
59
|
|
@@ -195,24 +172,11 @@ module TonSdk
|
|
195
172
|
end
|
196
173
|
end
|
197
174
|
|
198
|
-
|
199
|
-
attr_reader :address
|
200
|
-
|
201
|
-
def initialize(a)
|
202
|
-
@address = a
|
203
|
-
end
|
204
|
-
|
175
|
+
ParamsOfFetch = Struct.new(:address) do
|
205
176
|
def to_h = { address: @address }
|
206
177
|
end
|
207
178
|
|
208
|
-
|
209
|
-
attr_reader :debot_handle, :action
|
210
|
-
|
211
|
-
def initialize(debot_handle:, action:)
|
212
|
-
@debot_handle = debot_handle
|
213
|
-
@action = action
|
214
|
-
end
|
215
|
-
|
179
|
+
ParamsOfExecute = Struct.new(:debot_handle, :action) do
|
216
180
|
def to_h
|
217
181
|
{
|
218
182
|
debot_handle: @debot_handle,
|
@@ -221,14 +185,7 @@ module TonSdk
|
|
221
185
|
end
|
222
186
|
end
|
223
187
|
|
224
|
-
|
225
|
-
attr_reader :debot_handle, :message
|
226
|
-
|
227
|
-
def initialize(debot_handle:, message:)
|
228
|
-
@debot_handle = debot_handle
|
229
|
-
@message = message
|
230
|
-
end
|
231
|
-
|
188
|
+
ParamsOfSend = Struct.new(:debot_handle, :message) do
|
232
189
|
def to_h
|
233
190
|
{
|
234
191
|
debot_handle: @debot_handle,
|
@@ -237,99 +194,52 @@ module TonSdk
|
|
237
194
|
end
|
238
195
|
end
|
239
196
|
|
197
|
+
ParamsOfInit = Struct.new(:address)
|
198
|
+
|
199
|
+
DebotInfo = Struct.new(
|
200
|
+
:name,
|
201
|
+
:version,
|
202
|
+
:publisher,
|
203
|
+
:key,
|
204
|
+
:author,
|
205
|
+
:support,
|
206
|
+
:hello,
|
207
|
+
:language,
|
208
|
+
:dabi,
|
209
|
+
:icon,
|
210
|
+
:interfaces,
|
211
|
+
keyword_init: true
|
212
|
+
)
|
213
|
+
|
214
|
+
ResultOfFetch = Struct.new(:info)
|
215
|
+
|
216
|
+
|
240
217
|
#
|
241
218
|
# functions
|
242
219
|
#
|
243
220
|
|
244
|
-
def self.
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
# 2) this all can be replaced with 'app_browser_obj.request(...)' and
|
250
|
-
# 'app_browser_obj.notify(...)' calls, possibly
|
251
|
-
|
252
|
-
app_resp_handler = Proc.new do |data|
|
253
|
-
req_data = data["request_data"]
|
254
|
-
case data["type"]
|
255
|
-
when "Log"
|
256
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
257
|
-
app_browser_obj.log(new_obj.msg)
|
258
|
-
|
259
|
-
when "Switch"
|
260
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
261
|
-
app_browser_obj.switch_to(new_obj.context_id)
|
262
|
-
|
263
|
-
when "SwitchCompleted"
|
264
|
-
app_browser_obj.switch_completed()
|
265
|
-
|
266
|
-
when "ShowAction"
|
267
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
268
|
-
app_browser_obj.show_action(new_obj.action)
|
269
|
-
|
270
|
-
when "Input"
|
271
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
272
|
-
# TODO possibly in a new thread or fiber
|
273
|
-
app_req_res = begin
|
274
|
-
res = app_browser_obj.input(new_obj.prompt)
|
275
|
-
Client::AppRequestResult(type_: :ok, result: ResultOfAppDebotBrowser.new(type_: :input, value: res))
|
276
|
-
rescue Exception => e
|
277
|
-
Client::AppRequestResult(type_: :error, text: e.message)
|
278
|
-
end
|
279
|
-
|
280
|
-
params = Client::ParamsOfResolveAppRequest.new(
|
281
|
-
app_request_id: data["app_request_id"],
|
282
|
-
result: app_req_res
|
283
|
-
)
|
284
|
-
TonSdk::Client.resolve_app_request(c_ctx, params)
|
285
|
-
|
286
|
-
when "GetSigningBox"
|
287
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
288
|
-
# TODO possibly in a new thread or fiber
|
289
|
-
app_req_res = begin
|
290
|
-
res = app_browser_obj.get_signing_box()
|
291
|
-
Client::AppRequestResult(type_: :ok, result: ResultOfAppDebotBrowser.new(type_: :get_signing_box, signing_box: res))
|
292
|
-
rescue Exception => e
|
293
|
-
Client::AppRequestResult(type_: :error, text: e.message)
|
294
|
-
end
|
295
|
-
|
296
|
-
params = Client::ParamsOfResolveAppRequest.new(
|
297
|
-
app_request_id: data["app_request_id"],
|
298
|
-
result: app_req_res
|
299
|
-
)
|
300
|
-
TonSdk::Client.resolve_app_request(c_ctx, params)
|
301
|
-
|
302
|
-
when "InvokeDebot"
|
303
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
304
|
-
# TODO possibly in a new thread or fiber
|
305
|
-
app_req_res = begin
|
306
|
-
res = app_browser_obj.invoke_debot(new_obj.debot_addr, new_obj.action)
|
307
|
-
Client::AppRequestResult(type_: :ok, result: ResultOfAppDebotBrowser.new(type_: :invoke_debot))
|
308
|
-
rescue Exception => e
|
309
|
-
Client::AppRequestResult(type_: :error, text: e.message)
|
310
|
-
end
|
311
|
-
|
312
|
-
params = Client::ParamsOfResolveAppRequest.new(
|
313
|
-
app_request_id: data["app_request_id"],
|
314
|
-
result: app_req_res
|
221
|
+
def self.init(ctx, params, app_browser_obj)
|
222
|
+
Interop::request_to_native_lib(ctx, "debot.init", params.to_h.to_json) do |resp|
|
223
|
+
if resp.success?
|
224
|
+
yield NativeLibResponsetResult.new(
|
225
|
+
result: nil
|
315
226
|
)
|
316
|
-
TonSdk::Client.resolve_app_request(c_ctx, params)
|
317
|
-
|
318
227
|
else
|
319
|
-
|
228
|
+
yield resp
|
320
229
|
end
|
321
230
|
end
|
231
|
+
end
|
322
232
|
|
233
|
+
def self.start(ctx, params)
|
323
234
|
Interop::request_to_native_lib(
|
324
235
|
ctx,
|
325
236
|
"debot.start",
|
326
237
|
params.to_h.to_json,
|
327
|
-
debot_app_response_handler: app_resp_handler,
|
328
238
|
is_single_thread_only: false
|
329
239
|
) do |resp|
|
330
240
|
if resp.success?
|
331
241
|
yield NativeLibResponsetResult.new(
|
332
|
-
result:
|
242
|
+
result: nil
|
333
243
|
)
|
334
244
|
else
|
335
245
|
yield resp
|
@@ -337,95 +247,17 @@ module TonSdk
|
|
337
247
|
end
|
338
248
|
end
|
339
249
|
|
340
|
-
def self.fetch(ctx, params
|
341
|
-
# TODO
|
342
|
-
# 1) the handlers in 'start' and 'fetch' are identical
|
343
|
-
# verify that it works and get rid of repetition
|
344
|
-
|
345
|
-
# 2) this all can be replaced with 'app_browser_obj.request(...)' and
|
346
|
-
# 'app_browser_obj.notify(...)' calls, possibly
|
347
|
-
|
348
|
-
app_resp_handler = Proc.new do |data|
|
349
|
-
req_data = data["request_data"]
|
350
|
-
case data["type"]
|
351
|
-
when "Log"
|
352
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
353
|
-
app_browser_obj.log(new_obj.msg)
|
354
|
-
|
355
|
-
when "Switch"
|
356
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
357
|
-
app_browser_obj.switch_to(new_obj.context_id)
|
358
|
-
|
359
|
-
when "SwitchCompleted"
|
360
|
-
app_browser_obj.switch_completed()
|
361
|
-
|
362
|
-
when "ShowAction"
|
363
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
364
|
-
app_browser_obj.show_action(new_obj.action)
|
365
|
-
|
366
|
-
when "Input"
|
367
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
368
|
-
# TODO possibly in a new thread or fiber
|
369
|
-
app_req_res = begin
|
370
|
-
res = app_browser_obj.input(new_obj.prompt)
|
371
|
-
Client::AppRequestResult(type_: :ok, result: ResultOfAppDebotBrowser.new(type_: :input, value: res))
|
372
|
-
rescue Exception => e
|
373
|
-
Client::AppRequestResult(type_: :error, text: e.message)
|
374
|
-
end
|
375
|
-
|
376
|
-
params = Client::ParamsOfResolveAppRequest.new(
|
377
|
-
app_request_id: data["app_request_id"],
|
378
|
-
result: app_req_res
|
379
|
-
)
|
380
|
-
TonSdk::Client.resolve_app_request(c_ctx, params)
|
381
|
-
|
382
|
-
when "GetSigningBox"
|
383
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
384
|
-
# TODO possibly in a new thread or fiber
|
385
|
-
app_req_res = begin
|
386
|
-
res = app_browser_obj.get_signing_box()
|
387
|
-
Client::AppRequestResult(type_: :ok, result: ResultOfAppDebotBrowser.new(type_: :get_signing_box, signing_box: res))
|
388
|
-
rescue Exception => e
|
389
|
-
Client::AppRequestResult(type_: :error, text: e.message)
|
390
|
-
end
|
391
|
-
|
392
|
-
params = Client::ParamsOfResolveAppRequest.new(
|
393
|
-
app_request_id: data["app_request_id"],
|
394
|
-
result: app_req_res
|
395
|
-
)
|
396
|
-
TonSdk::Client.resolve_app_request(c_ctx, params)
|
397
|
-
|
398
|
-
when "InvokeDebot"
|
399
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
400
|
-
# TODO possibly in a new thread or fiber
|
401
|
-
app_req_res = begin
|
402
|
-
res = app_browser_obj.invoke_debot(new_obj.debot_addr, new_obj.action)
|
403
|
-
Client::AppRequestResult(type_: :ok, result: ResultOfAppDebotBrowser.new(type_: :invoke_debot))
|
404
|
-
rescue Exception => e
|
405
|
-
Client::AppRequestResult(type_: :error, text: e.message)
|
406
|
-
end
|
407
|
-
|
408
|
-
params = Client::ParamsOfResolveAppRequest.new(
|
409
|
-
app_request_id: data["app_request_id"],
|
410
|
-
result: app_req_res
|
411
|
-
)
|
412
|
-
TonSdk::Client.resolve_app_request(c_ctx, params)
|
413
|
-
|
414
|
-
else
|
415
|
-
# TODO log 'unknown option'
|
416
|
-
end
|
417
|
-
end
|
418
|
-
|
250
|
+
def self.fetch(ctx, params)
|
419
251
|
Interop::request_to_native_lib(
|
420
252
|
ctx,
|
421
253
|
"debot.fetch",
|
422
254
|
params.to_h.to_json,
|
423
|
-
debot_app_response_handler: app_resp_handler,
|
424
255
|
is_single_thread_only: false
|
425
256
|
) do |resp|
|
426
257
|
if resp.success?
|
427
258
|
yield NativeLibResponsetResult.new(
|
428
|
-
|
259
|
+
# TODO: parse DebotInfo
|
260
|
+
result: ResultOfFetch.new(resp.result["info"])
|
429
261
|
)
|
430
262
|
else
|
431
263
|
yield resp
|
data/lib/ton_sdk_client/utils.rb
CHANGED
@@ -32,14 +32,7 @@ module TonSdk
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
attr_reader :address, :output_format
|
37
|
-
|
38
|
-
def initialize(address:, output_format:)
|
39
|
-
@address = address
|
40
|
-
@output_format = output_format
|
41
|
-
end
|
42
|
-
|
35
|
+
ParamsOfConvertAddress = Struct.new(:address, :output_format) do
|
43
36
|
def to_h
|
44
37
|
{
|
45
38
|
address: @address,
|
@@ -48,38 +41,36 @@ module TonSdk
|
|
48
41
|
end
|
49
42
|
end
|
50
43
|
|
51
|
-
|
52
|
-
attr_reader :address
|
44
|
+
ResultOfConvertAddress = Struct.new(:address)
|
53
45
|
|
54
|
-
|
55
|
-
|
46
|
+
ParamsOfCalcStorageFee = Struct.new(:account, :period) do
|
47
|
+
def to_h
|
48
|
+
{
|
49
|
+
account: @account,
|
50
|
+
period: @period
|
51
|
+
}
|
56
52
|
end
|
57
53
|
end
|
58
54
|
|
59
|
-
|
60
|
-
attr_reader :account, :period
|
61
|
-
|
62
|
-
def initialize(account:, period:)
|
63
|
-
@account = account
|
64
|
-
@period = period
|
65
|
-
end
|
55
|
+
ResultOfCalcStorageFee = Struct.new(:fee)
|
66
56
|
|
57
|
+
ParamsOfCompressZstd = Struct.new(:uncompressed, :level) do
|
67
58
|
def to_h
|
68
59
|
{
|
69
|
-
|
70
|
-
|
60
|
+
uncompressed: @uncompressed,
|
61
|
+
level: @level
|
71
62
|
}
|
72
63
|
end
|
73
64
|
end
|
74
65
|
|
75
|
-
|
76
|
-
attr_reader :fee
|
66
|
+
ResultOfCompressZstd = Struct.new(:compressed)
|
77
67
|
|
78
|
-
|
79
|
-
|
80
|
-
end
|
68
|
+
ParamsOfDecompressZstd = Struct.new(:compressed) do
|
69
|
+
def to_h = { compressed: @compressed }
|
81
70
|
end
|
82
71
|
|
72
|
+
ResultOfDecompressZstd = Struct.new(:decompressed)
|
73
|
+
|
83
74
|
|
84
75
|
#
|
85
76
|
# functions
|
@@ -97,7 +88,6 @@ module TonSdk
|
|
97
88
|
end
|
98
89
|
end
|
99
90
|
|
100
|
-
|
101
91
|
def self.calc_storage_fee(ctx, prm)
|
102
92
|
Interop::request_to_native_lib(ctx, "utils.calc_storage_fee", prm.to_h.to_json) do |resp|
|
103
93
|
if resp.success?
|
@@ -109,5 +99,29 @@ module TonSdk
|
|
109
99
|
end
|
110
100
|
end
|
111
101
|
end
|
102
|
+
|
103
|
+
def self.compress_zstd(ctx, prm)
|
104
|
+
Interop::request_to_native_lib(ctx, "utils.compress_zstd", prm.to_h.to_json) do |resp|
|
105
|
+
if resp.success?
|
106
|
+
yield NativeLibResponsetResult.new(
|
107
|
+
result: Utils::ResultOfCompressZstd.new(resp.result["compressed"])
|
108
|
+
)
|
109
|
+
else
|
110
|
+
yield resp
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def self.decompress_zstd(ctx, prm)
|
116
|
+
Interop::request_to_native_lib(ctx, "utils.decompress_zstd", prm.to_h.to_json) do |resp|
|
117
|
+
if resp.success?
|
118
|
+
yield NativeLibResponsetResult.new(
|
119
|
+
result: Utils::ParamsOfDecompressZstd.new(resp.result["decompressed"])
|
120
|
+
)
|
121
|
+
else
|
122
|
+
yield resp
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
112
126
|
end
|
113
127
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ton_sdk_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Maslakov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|