ton_sdk_client 1.7.1 → 1.13.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 +4 -4
- data/CHANGELOG.md +31 -0
- data/README.md +5 -6
- data/lib/ton_sdk_client/abi.rb +2 -2
- data/lib/ton_sdk_client/boc.rb +52 -109
- data/lib/ton_sdk_client/client.rb +8 -49
- data/lib/ton_sdk_client/config.rb +34 -22
- data/lib/ton_sdk_client/crypto.rb +37 -241
- data/lib/ton_sdk_client/debot.rb +56 -218
- data/lib/ton_sdk_client/interop.rb +1 -1
- data/lib/ton_sdk_client/net.rb +45 -78
- data/lib/ton_sdk_client/processing.rb +2 -15
- data/lib/ton_sdk_client/tvm.rb +22 -3
- data/lib/ton_sdk_client/utils.rb +63 -12
- data/lib/ton_sdk_client/version.rb +2 -3
- metadata +2 -2
@@ -10,11 +10,11 @@ module TonSdk
|
|
10
10
|
INVALID_KEY = 102
|
11
11
|
INVALID_FACTORIZE_CHALLENGE = 106
|
12
12
|
INVALID_BIGINT = 107
|
13
|
-
SCRYPT_FAILED = 108
|
13
|
+
SCRYPT_FAILED = 108
|
14
14
|
INVALID_KEYSIZE = 109
|
15
|
-
NACL_SECRET_BOX_FAILED = 110
|
16
|
-
NACL_BOX_FAILED = 111
|
17
|
-
NACL_SIGN_FAILED = 112
|
15
|
+
NACL_SECRET_BOX_FAILED = 110
|
16
|
+
NACL_BOX_FAILED = 111
|
17
|
+
NACL_SIGN_FAILED = 112
|
18
18
|
BIP39_INVALID_ENTROPY = 113
|
19
19
|
BIP39_INVALID_PHRASE = 114
|
20
20
|
BIP32_INVALID_KEY = 115
|
@@ -27,33 +27,13 @@ module TonSdk
|
|
27
27
|
INVALID_SIGNATURE = 122
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
attr_reader :composite
|
32
|
-
|
33
|
-
def initialize(a)
|
34
|
-
@composite = a
|
35
|
-
end
|
36
|
-
|
30
|
+
ParamsOfFactorize = Struct.new(:composite) do
|
37
31
|
def to_h = { composite: @composite }
|
38
32
|
end
|
39
33
|
|
40
|
-
|
41
|
-
attr_reader :factors
|
42
|
-
|
43
|
-
def initialize(a)
|
44
|
-
@factors = a
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
class ParamsOfModularPower
|
49
|
-
attr_reader :base, :exponent, :modulus
|
50
|
-
|
51
|
-
def initialize(base:, exponent:, modulus:)
|
52
|
-
@base = base
|
53
|
-
@exponent = exponent
|
54
|
-
@modulus = modulus
|
55
|
-
end
|
34
|
+
ResultOfFactorize = Struct.new(:factors)
|
56
35
|
|
36
|
+
ParamsOfModularPower = Struct.new(:base, :exponent, :modulus) do
|
57
37
|
def to_h
|
58
38
|
{
|
59
39
|
base: @base,
|
@@ -63,84 +43,27 @@ module TonSdk
|
|
63
43
|
end
|
64
44
|
end
|
65
45
|
|
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
|
46
|
+
ResultOfModularPower = Struct.new(:modular_power)
|
80
47
|
|
48
|
+
ParamsOfTonCrc16 = Struct.new(:data) do
|
81
49
|
def to_h = { data: @data }
|
82
50
|
end
|
83
51
|
|
84
|
-
|
85
|
-
attr_reader :crc
|
86
|
-
|
87
|
-
def initialize(a)
|
88
|
-
@crc = a
|
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
|
104
|
-
end
|
105
|
-
|
106
|
-
class ResultOfGenerateRandomBytes
|
107
|
-
attr_reader :bytes
|
52
|
+
ResultOfTonCrc16 = Struct.new(:crc)
|
108
53
|
|
109
|
-
|
110
|
-
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
class ParamsOfConvertPublicKeyToTonSafeFormat
|
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
|
54
|
+
ParamsOfGenerateRandomBytes = Struct.new(:length) do
|
55
|
+
def to_h = { length: @length }
|
126
56
|
end
|
127
57
|
|
128
|
-
|
129
|
-
attr_reader :ton_public_key
|
58
|
+
ResultOfGenerateRandomBytes = Struct.new(:bytes)
|
130
59
|
|
131
|
-
|
132
|
-
|
133
|
-
end
|
60
|
+
ParamsOfConvertPublicKeyToTonSafeFormat = Struct.new(:public_key) do
|
61
|
+
def to_h = { public_key: @public_key }
|
134
62
|
end
|
135
63
|
|
136
|
-
|
137
|
-
attr_reader :public_, :secret
|
138
|
-
|
139
|
-
def initialize(public_: , secret:)
|
140
|
-
@public_ = public_
|
141
|
-
@secret = secret
|
142
|
-
end
|
64
|
+
ResultOfConvertPublicKeyToTonSafeFormat = Struct.new(:ton_public_key)
|
143
65
|
|
66
|
+
KeyPair = Struct.new(:public_, :secret) do
|
144
67
|
def to_h
|
145
68
|
{
|
146
69
|
public: @public_,
|
@@ -149,14 +72,7 @@ module TonSdk
|
|
149
72
|
end
|
150
73
|
end
|
151
74
|
|
152
|
-
|
153
|
-
attr_reader :unsigned, :keys
|
154
|
-
|
155
|
-
def initialize(unsigned:, keys:)
|
156
|
-
@unsigned = unsigned
|
157
|
-
@keys = keys
|
158
|
-
end
|
159
|
-
|
75
|
+
ParamsOfSign = Struct.new(:unsigned, :keys) do
|
160
76
|
def to_h
|
161
77
|
{
|
162
78
|
unsigned: @unsigned,
|
@@ -165,23 +81,9 @@ module TonSdk
|
|
165
81
|
end
|
166
82
|
end
|
167
83
|
|
168
|
-
|
169
|
-
attr_reader :signed, :signature
|
170
|
-
|
171
|
-
def initialize(signed:, signature:)
|
172
|
-
@signed = signed
|
173
|
-
@signature = signature
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
class ParamsOfVerifySignature
|
178
|
-
attr_reader :signed, :public_
|
179
|
-
|
180
|
-
def initialize(signed:, public_:)
|
181
|
-
@signed = signed
|
182
|
-
@public_ = public_
|
183
|
-
end
|
84
|
+
ResultOfSign = Struct.new(:signed, :signature)
|
184
85
|
|
86
|
+
ParamsOfVerifySignature = Struct.new(:signed, :public_) do
|
185
87
|
def to_h
|
186
88
|
{
|
187
89
|
signed: @signed,
|
@@ -190,48 +92,15 @@ module TonSdk
|
|
190
92
|
end
|
191
93
|
end
|
192
94
|
|
193
|
-
|
194
|
-
attr_reader :unsigned
|
195
|
-
|
196
|
-
def initialize(a)
|
197
|
-
@unsigned = a
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
class ParamsOfHash
|
202
|
-
attr_reader :data
|
203
|
-
|
204
|
-
def initialize(a)
|
205
|
-
@data = a
|
206
|
-
end
|
207
|
-
|
208
|
-
def to_h
|
209
|
-
{
|
210
|
-
data: @data
|
211
|
-
}
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
class ResultOfHash
|
216
|
-
attr_reader :hash
|
95
|
+
ResultOfVerifySignature = Struct.new(:unsigned)
|
217
96
|
|
218
|
-
|
219
|
-
|
220
|
-
end
|
97
|
+
ParamsOfHash = Struct.new(:data) do
|
98
|
+
def to_h = { data: @data }
|
221
99
|
end
|
222
100
|
|
223
|
-
|
224
|
-
attr_reader :password, :salt, :log_n, :r, :p_, :dk_len
|
225
|
-
|
226
|
-
def initialize(password:, salt:, log_n:, r:, p_:, dk_len:)
|
227
|
-
@password = password
|
228
|
-
@salt = salt
|
229
|
-
@log_n = log_n
|
230
|
-
@r = r
|
231
|
-
@p_ = p_
|
232
|
-
@dk_len = dk_len
|
233
|
-
end
|
101
|
+
ResultOfHash = Struct.new(:hash)
|
234
102
|
|
103
|
+
ParamsOfScrypt = Struct.new(:password, :salt, :log_n, :r, :p_, :dk_len) do
|
235
104
|
def to_h
|
236
105
|
{
|
237
106
|
password: @password,
|
@@ -244,32 +113,13 @@ module TonSdk
|
|
244
113
|
end
|
245
114
|
end
|
246
115
|
|
247
|
-
|
248
|
-
attr_reader :key
|
249
|
-
|
250
|
-
def initialize(a)
|
251
|
-
@key = a
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
class ParamsOfNaclSignKeyPairFromSecret
|
256
|
-
attr_reader :secret
|
257
|
-
|
258
|
-
def initialize(a)
|
259
|
-
@secret = a
|
260
|
-
end
|
116
|
+
ResultOfScrypt = Struct.new(:key)
|
261
117
|
|
118
|
+
ParamsOfNaclSignKeyPairFromSecret = Struct.new(:secret) do
|
262
119
|
def to_h = { secret: @secret }
|
263
120
|
end
|
264
121
|
|
265
|
-
|
266
|
-
attr_reader :unsigned, :secret
|
267
|
-
|
268
|
-
def initialize(unsigned:, secret:)
|
269
|
-
@unsigned = unsigned
|
270
|
-
@secret = secret
|
271
|
-
end
|
272
|
-
|
122
|
+
ParamsOfNaclSign = Struct.new(:unsigned, :secret) do
|
273
123
|
def to_h
|
274
124
|
{
|
275
125
|
unsigned: @unsigned,
|
@@ -278,13 +128,7 @@ module TonSdk
|
|
278
128
|
end
|
279
129
|
end
|
280
130
|
|
281
|
-
|
282
|
-
attr_reader :signed
|
283
|
-
|
284
|
-
def initialize(a)
|
285
|
-
@signed = a
|
286
|
-
end
|
287
|
-
end
|
131
|
+
ResultOfNaclSign = Struct.new(:signed)
|
288
132
|
|
289
133
|
class ParamsOfNaclSignOpen
|
290
134
|
attr_reader :signed, :public_
|
@@ -302,21 +146,9 @@ module TonSdk
|
|
302
146
|
end
|
303
147
|
end
|
304
148
|
|
305
|
-
|
306
|
-
attr_reader :unsigned
|
149
|
+
ResultOfNaclSignOpen = Struct.new(:unsigned)
|
307
150
|
|
308
|
-
|
309
|
-
@unsigned = a
|
310
|
-
end
|
311
|
-
end
|
312
|
-
|
313
|
-
class ResultOfNaclSignDetached
|
314
|
-
attr_reader :signature
|
315
|
-
|
316
|
-
def initialize(a)
|
317
|
-
@signature = a
|
318
|
-
end
|
319
|
-
end
|
151
|
+
ResultOfNaclSignDetached = Struct.new(:signature)
|
320
152
|
|
321
153
|
class ParamsOfNaclBoxKeyPairFromSecret
|
322
154
|
attr_reader :secret
|
@@ -352,13 +184,7 @@ module TonSdk
|
|
352
184
|
end
|
353
185
|
end
|
354
186
|
|
355
|
-
|
356
|
-
attr_reader :encrypted
|
357
|
-
|
358
|
-
def initialize(a)
|
359
|
-
@encrypted = a
|
360
|
-
end
|
361
|
-
end
|
187
|
+
ResultOfNaclBox = Struct.new(:encrypted)
|
362
188
|
|
363
189
|
class ParamsOfNaclBoxOpen
|
364
190
|
attr_reader :encrypted, :nonce, :their_public, :secret
|
@@ -380,13 +206,7 @@ module TonSdk
|
|
380
206
|
end
|
381
207
|
end
|
382
208
|
|
383
|
-
|
384
|
-
attr_reader :decrypted
|
385
|
-
|
386
|
-
def initialize(a)
|
387
|
-
@decrypted = a
|
388
|
-
end
|
389
|
-
end
|
209
|
+
ResultOfNaclBoxOpen = Struct.new(:decrypted)
|
390
210
|
|
391
211
|
class ParamsOfNaclSecretBox
|
392
212
|
attr_reader :decrypted, :nonce, :key
|
@@ -438,13 +258,7 @@ module TonSdk
|
|
438
258
|
end
|
439
259
|
end
|
440
260
|
|
441
|
-
|
442
|
-
attr_reader :words
|
443
|
-
|
444
|
-
def initialize(a)
|
445
|
-
@words = a
|
446
|
-
end
|
447
|
-
end
|
261
|
+
ResultOfMnemonicWords = Struct.new(:words)
|
448
262
|
|
449
263
|
class ParamsOfMnemonicFromRandom
|
450
264
|
attr_reader :dictionary, :word_count
|
@@ -462,13 +276,7 @@ module TonSdk
|
|
462
276
|
end
|
463
277
|
end
|
464
278
|
|
465
|
-
|
466
|
-
attr_reader :phrase
|
467
|
-
|
468
|
-
def initialize(a)
|
469
|
-
@phrase = a
|
470
|
-
end
|
471
|
-
end
|
279
|
+
ResultOfMnemonicFromRandom = Struct.new(:phrase)
|
472
280
|
|
473
281
|
class ParamsOfMnemonicFromEntropy
|
474
282
|
attr_reader :entropy, :dictionary, :word_count
|
@@ -488,13 +296,7 @@ module TonSdk
|
|
488
296
|
end
|
489
297
|
end
|
490
298
|
|
491
|
-
|
492
|
-
attr_reader :phrase
|
493
|
-
|
494
|
-
def initialize(a)
|
495
|
-
@phrase = a
|
496
|
-
end
|
497
|
-
end
|
299
|
+
ResultOfMnemonicFromEntropy = Struct.new(:phrase)
|
498
300
|
|
499
301
|
class ParamsOfMnemonicVerify
|
500
302
|
attr_reader :phrase, :dictionary, :word_count
|
@@ -514,13 +316,7 @@ module TonSdk
|
|
514
316
|
end
|
515
317
|
end
|
516
318
|
|
517
|
-
|
518
|
-
attr_reader :valid
|
519
|
-
|
520
|
-
def initialize(a)
|
521
|
-
@valid = a
|
522
|
-
end
|
523
|
-
end
|
319
|
+
ResultOfMnemonicVerify = Struct.new(:valid)
|
524
320
|
|
525
321
|
class ParamsOfMnemonicDeriveSignKeys
|
526
322
|
attr_reader :phrase, :path, :dictionary, :word_count
|
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
|
#
|
@@ -19,20 +19,11 @@ module TonSdk
|
|
19
19
|
GET_METHOD_FAILED = 808
|
20
20
|
INVALID_MSG = 809
|
21
21
|
EXTERNAL_CALL_FAILED = 810
|
22
|
+
BROWSER_CALLBACK_FAILED = 811
|
23
|
+
OPERATION_REJECTED = 812
|
22
24
|
end
|
23
25
|
|
24
|
-
|
25
|
-
attr_reader :description, :name, :action_type, :to, :attributes, :misc
|
26
|
-
|
27
|
-
def initialize(description:, name:, action_type:, to:, attributes:, misc:)
|
28
|
-
@description = description
|
29
|
-
@name = name
|
30
|
-
@action_type = action_type
|
31
|
-
@to = to
|
32
|
-
@attributes = attributes
|
33
|
-
@misc = misc
|
34
|
-
end
|
35
|
-
|
26
|
+
DebotAction = Struct.new(:description, :name, :action_type, :to, :attributes, :misc, keyword_init: true) do
|
36
27
|
def to_h
|
37
28
|
{
|
38
29
|
description: @description,
|
@@ -58,23 +49,11 @@ module TonSdk
|
|
58
49
|
end
|
59
50
|
end
|
60
51
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
def initialize(a)
|
65
|
-
@address = a
|
66
|
-
end
|
67
|
-
|
68
|
-
def to_h = { address: @address }
|
52
|
+
ParamsOfStart = Struct.new(:debot_handle) do
|
53
|
+
def to_h = { debot_handle: @debot_handle }
|
69
54
|
end
|
70
55
|
|
71
|
-
|
72
|
-
attr_reader :debot_handle
|
73
|
-
|
74
|
-
def initialize(a)
|
75
|
-
@debot_handle = a
|
76
|
-
end
|
77
|
-
|
56
|
+
RegisteredDebot = Struct.new(:debot_handle) do
|
78
57
|
def to_h = { debot_handle: @debot_handle }
|
79
58
|
end
|
80
59
|
|
@@ -171,42 +150,33 @@ module TonSdk
|
|
171
150
|
end
|
172
151
|
|
173
152
|
class ResultOfAppDebotBrowser
|
174
|
-
|
175
|
-
:input,
|
176
|
-
:get_signing_box,
|
177
|
-
:invoke_debot
|
178
|
-
]
|
153
|
+
attr_reader :type_, :value, :signing_box, :is_approved
|
179
154
|
|
180
|
-
|
155
|
+
def new_with_type_input(a)
|
156
|
+
@type_ = :input
|
157
|
+
@value = a
|
158
|
+
end
|
181
159
|
|
182
|
-
def
|
183
|
-
|
184
|
-
raise ArgumentError.new("type #{type_} is unknown; known types: #{TYPE_VALUES}")
|
185
|
-
end
|
186
|
-
@type_ = type_
|
187
|
-
@value = value
|
160
|
+
def new_with_type_get_signing_box(a)
|
161
|
+
@type_ = :get_signing_box
|
188
162
|
@signing_box = signing_box
|
189
163
|
end
|
190
|
-
end
|
191
164
|
|
192
|
-
|
193
|
-
|
165
|
+
def new_with_type_invoke_debot
|
166
|
+
@type_ = :invoke_debot
|
167
|
+
end
|
194
168
|
|
195
|
-
def
|
196
|
-
@
|
169
|
+
def new_with_type_approve(a)
|
170
|
+
@type_ = :approve
|
171
|
+
@is_approved = a
|
197
172
|
end
|
173
|
+
end
|
198
174
|
|
175
|
+
ParamsOfFetch = Struct.new(:address) do
|
199
176
|
def to_h = { address: @address }
|
200
177
|
end
|
201
178
|
|
202
|
-
|
203
|
-
attr_reader :debot_handle, :action
|
204
|
-
|
205
|
-
def initialize(debot_handle:, action:)
|
206
|
-
@debot_handle = debot_handle
|
207
|
-
@action = action
|
208
|
-
end
|
209
|
-
|
179
|
+
ParamsOfExecute = Struct.new(:debot_handle, :action) do
|
210
180
|
def to_h
|
211
181
|
{
|
212
182
|
debot_handle: @debot_handle,
|
@@ -215,14 +185,7 @@ module TonSdk
|
|
215
185
|
end
|
216
186
|
end
|
217
187
|
|
218
|
-
|
219
|
-
attr_reader :debot_handle, :message
|
220
|
-
|
221
|
-
def initialize(debot_handle:, message:)
|
222
|
-
@debot_handle = debot_handle
|
223
|
-
@message = message
|
224
|
-
end
|
225
|
-
|
188
|
+
ParamsOfSend = Struct.new(:debot_handle, :message) do
|
226
189
|
def to_h
|
227
190
|
{
|
228
191
|
debot_handle: @debot_handle,
|
@@ -231,99 +194,52 @@ module TonSdk
|
|
231
194
|
end
|
232
195
|
end
|
233
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
|
+
|
234
217
|
#
|
235
218
|
# functions
|
236
219
|
#
|
237
220
|
|
238
|
-
def self.
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
# 2) this all can be replaced with 'app_browser_obj.request(...)' and
|
244
|
-
# 'app_browser_obj.notify(...)' calls, possibly
|
245
|
-
|
246
|
-
app_resp_handler = Proc.new do |data|
|
247
|
-
req_data = data["request_data"]
|
248
|
-
case data["type"]
|
249
|
-
when "Log"
|
250
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
251
|
-
app_browser_obj.log(new_obj.msg)
|
252
|
-
|
253
|
-
when "Switch"
|
254
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
255
|
-
app_browser_obj.switch_to(new_obj.context_id)
|
256
|
-
|
257
|
-
when "SwitchCompleted"
|
258
|
-
app_browser_obj.switch_completed()
|
259
|
-
|
260
|
-
when "ShowAction"
|
261
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
262
|
-
app_browser_obj.show_action(new_obj.action)
|
263
|
-
|
264
|
-
when "Input"
|
265
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
266
|
-
# TODO possibly in a new thread or fiber
|
267
|
-
app_req_res = begin
|
268
|
-
res = app_browser_obj.input(new_obj.prompt)
|
269
|
-
Client::AppRequestResult(type_: :ok, result: ResultOfAppDebotBrowser.new(type_: :input, value: res))
|
270
|
-
rescue Exception => e
|
271
|
-
Client::AppRequestResult(type_: :error, text: e.message)
|
272
|
-
end
|
273
|
-
|
274
|
-
params = Client::ParamsOfResolveAppRequest.new(
|
275
|
-
app_request_id: data["app_request_id"],
|
276
|
-
result: app_req_res
|
277
|
-
)
|
278
|
-
TonSdk::Client.resolve_app_request(c_ctx, params)
|
279
|
-
|
280
|
-
when "GetSigningBox"
|
281
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
282
|
-
# TODO possibly in a new thread or fiber
|
283
|
-
app_req_res = begin
|
284
|
-
res = app_browser_obj.get_signing_box()
|
285
|
-
Client::AppRequestResult(type_: :ok, result: ResultOfAppDebotBrowser.new(type_: :get_signing_box, signing_box: res))
|
286
|
-
rescue Exception => e
|
287
|
-
Client::AppRequestResult(type_: :error, text: e.message)
|
288
|
-
end
|
289
|
-
|
290
|
-
params = Client::ParamsOfResolveAppRequest.new(
|
291
|
-
app_request_id: data["app_request_id"],
|
292
|
-
result: app_req_res
|
293
|
-
)
|
294
|
-
TonSdk::Client.resolve_app_request(c_ctx, params)
|
295
|
-
|
296
|
-
when "InvokeDebot"
|
297
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
298
|
-
# TODO possibly in a new thread or fiber
|
299
|
-
app_req_res = begin
|
300
|
-
res = app_browser_obj.invoke_debot(new_obj.debot_addr, new_obj.action)
|
301
|
-
Client::AppRequestResult(type_: :ok, result: ResultOfAppDebotBrowser.new(type_: :invoke_debot))
|
302
|
-
rescue Exception => e
|
303
|
-
Client::AppRequestResult(type_: :error, text: e.message)
|
304
|
-
end
|
305
|
-
|
306
|
-
params = Client::ParamsOfResolveAppRequest.new(
|
307
|
-
app_request_id: data["app_request_id"],
|
308
|
-
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
|
309
226
|
)
|
310
|
-
TonSdk::Client.resolve_app_request(c_ctx, params)
|
311
|
-
|
312
227
|
else
|
313
|
-
|
228
|
+
yield resp
|
314
229
|
end
|
315
230
|
end
|
231
|
+
end
|
316
232
|
|
233
|
+
def self.start(ctx, params)
|
317
234
|
Interop::request_to_native_lib(
|
318
235
|
ctx,
|
319
236
|
"debot.start",
|
320
237
|
params.to_h.to_json,
|
321
|
-
debot_app_response_handler: app_resp_handler,
|
322
238
|
is_single_thread_only: false
|
323
239
|
) do |resp|
|
324
240
|
if resp.success?
|
325
241
|
yield NativeLibResponsetResult.new(
|
326
|
-
result:
|
242
|
+
result: nil
|
327
243
|
)
|
328
244
|
else
|
329
245
|
yield resp
|
@@ -331,95 +247,17 @@ module TonSdk
|
|
331
247
|
end
|
332
248
|
end
|
333
249
|
|
334
|
-
def self.fetch(ctx, params
|
335
|
-
# TODO
|
336
|
-
# 1) the handlers in 'start' and 'fetch' are identical
|
337
|
-
# verify that it works and get rid of repetition
|
338
|
-
|
339
|
-
# 2) this all can be replaced with 'app_browser_obj.request(...)' and
|
340
|
-
# 'app_browser_obj.notify(...)' calls, possibly
|
341
|
-
|
342
|
-
app_resp_handler = Proc.new do |data|
|
343
|
-
req_data = data["request_data"]
|
344
|
-
case data["type"]
|
345
|
-
when "Log"
|
346
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
347
|
-
app_browser_obj.log(new_obj.msg)
|
348
|
-
|
349
|
-
when "Switch"
|
350
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
351
|
-
app_browser_obj.switch_to(new_obj.context_id)
|
352
|
-
|
353
|
-
when "SwitchCompleted"
|
354
|
-
app_browser_obj.switch_completed()
|
355
|
-
|
356
|
-
when "ShowAction"
|
357
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
358
|
-
app_browser_obj.show_action(new_obj.action)
|
359
|
-
|
360
|
-
when "Input"
|
361
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
362
|
-
# TODO possibly in a new thread or fiber
|
363
|
-
app_req_res = begin
|
364
|
-
res = app_browser_obj.input(new_obj.prompt)
|
365
|
-
Client::AppRequestResult(type_: :ok, result: ResultOfAppDebotBrowser.new(type_: :input, value: res))
|
366
|
-
rescue Exception => e
|
367
|
-
Client::AppRequestResult(type_: :error, text: e.message)
|
368
|
-
end
|
369
|
-
|
370
|
-
params = Client::ParamsOfResolveAppRequest.new(
|
371
|
-
app_request_id: data["app_request_id"],
|
372
|
-
result: app_req_res
|
373
|
-
)
|
374
|
-
TonSdk::Client.resolve_app_request(c_ctx, params)
|
375
|
-
|
376
|
-
when "GetSigningBox"
|
377
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
378
|
-
# TODO possibly in a new thread or fiber
|
379
|
-
app_req_res = begin
|
380
|
-
res = app_browser_obj.get_signing_box()
|
381
|
-
Client::AppRequestResult(type_: :ok, result: ResultOfAppDebotBrowser.new(type_: :get_signing_box, signing_box: res))
|
382
|
-
rescue Exception => e
|
383
|
-
Client::AppRequestResult(type_: :error, text: e.message)
|
384
|
-
end
|
385
|
-
|
386
|
-
params = Client::ParamsOfResolveAppRequest.new(
|
387
|
-
app_request_id: data["app_request_id"],
|
388
|
-
result: app_req_res
|
389
|
-
)
|
390
|
-
TonSdk::Client.resolve_app_request(c_ctx, params)
|
391
|
-
|
392
|
-
when "InvokeDebot"
|
393
|
-
new_obj = ParamsOfAppDebotBrowser.from_json(data)
|
394
|
-
# TODO possibly in a new thread or fiber
|
395
|
-
app_req_res = begin
|
396
|
-
res = app_browser_obj.invoke_debot(new_obj.debot_addr, new_obj.action)
|
397
|
-
Client::AppRequestResult(type_: :ok, result: ResultOfAppDebotBrowser.new(type_: :invoke_debot))
|
398
|
-
rescue Exception => e
|
399
|
-
Client::AppRequestResult(type_: :error, text: e.message)
|
400
|
-
end
|
401
|
-
|
402
|
-
params = Client::ParamsOfResolveAppRequest.new(
|
403
|
-
app_request_id: data["app_request_id"],
|
404
|
-
result: app_req_res
|
405
|
-
)
|
406
|
-
TonSdk::Client.resolve_app_request(c_ctx, params)
|
407
|
-
|
408
|
-
else
|
409
|
-
# TODO log 'unknown option'
|
410
|
-
end
|
411
|
-
end
|
412
|
-
|
250
|
+
def self.fetch(ctx, params)
|
413
251
|
Interop::request_to_native_lib(
|
414
252
|
ctx,
|
415
253
|
"debot.fetch",
|
416
254
|
params.to_h.to_json,
|
417
|
-
debot_app_response_handler: app_resp_handler,
|
418
255
|
is_single_thread_only: false
|
419
256
|
) do |resp|
|
420
257
|
if resp.success?
|
421
258
|
yield NativeLibResponsetResult.new(
|
422
|
-
|
259
|
+
# TODO: parse DebotInfo
|
260
|
+
result: ResultOfFetch.new(resp.result["info"])
|
423
261
|
)
|
424
262
|
else
|
425
263
|
yield resp
|