ton_sdk_client 1.22.0 → 1.24.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 +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 +142 -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 +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7aa3942dcf8295136874ebced4c8e69b0bd5d5bf15537aa401a3fd362bc84adc
|
4
|
+
data.tar.gz: 592b046b0cb812b15573fcec3e63eb12c2006611a7a094e4194e3cb0290c5841
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '023446187045b70c7d1afb984c58bf12ec550a631c1b1fa2ec44d2ad10661fce5e8aaa20bfb0d4d04a3b910d075663a543e98b680dbca65f921ed4b25263dff5'
|
7
|
+
data.tar.gz: 2debab81288b9ebbf77af113c7483420f6420ca4de721d317ce486b3b2e439f73008a918c5b89a8119904312fe3778f62f6f6f97e47e995ab271d894b6050237
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
all the changes are always according to the ones of the main TON SDK library; and on top on that, there may be additional ones
|
4
4
|
|
5
|
+
1.24.0
|
6
|
+
-----
|
7
|
+
* Binaries updated to `1.24.0`;
|
8
|
+
* Changes `1.24.0` (https://github.com/tonlabs/TON-SDK/blob/master/CHANGELOG.md#1240--2021-10-18);
|
9
|
+
* **BREAKING CHANGE** All Params now require keyword arguments
|
10
|
+
|
5
11
|
1.20.x
|
6
12
|
-----
|
7
13
|
* NetworkConfig and AbiContract have been changed (not mentioned explicitly in Changelog of TON SDK )
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# TON SDK client in Ruby and for Ruby
|
2
2
|
|
3
|
-
[](https://rubygems.org/gems/ton_sdk_client)
|
4
|
+
[](https://github.com/tonlabs/TON-SDK/tree/1.24.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
|
|
data/lib/ton_sdk_client/abi.rb
CHANGED
@@ -39,15 +39,23 @@ module TonSdk
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
FunctionHeader =
|
42
|
+
FunctionHeader = KwStruct.new(:expire, :time, :pubkey)
|
43
43
|
|
44
|
-
CallSet =
|
44
|
+
CallSet = KwStruct.new(:function_name, :header, :input) do
|
45
45
|
def initialize(function_name:, header: nil, input: nil)
|
46
46
|
super
|
47
47
|
end
|
48
|
+
|
49
|
+
def to_h
|
50
|
+
{
|
51
|
+
function_name: function_name,
|
52
|
+
header: header.to_h,
|
53
|
+
input: input
|
54
|
+
}
|
55
|
+
end
|
48
56
|
end
|
49
57
|
|
50
|
-
DeploySet =
|
58
|
+
DeploySet = KwStruct.new(:tvc, :workchain_id, :initial_data, :initial_pubkey) do
|
51
59
|
def initialize(tvc:, workchain_id: nil, initial_data: nil, initial_pubkey: nil)
|
52
60
|
super
|
53
61
|
end
|
@@ -95,19 +103,19 @@ module TonSdk
|
|
95
103
|
end
|
96
104
|
|
97
105
|
STATIC_INIT_SOURCE_TYPES = [:message, :state_init, :tvc]
|
98
|
-
|
99
|
-
|
106
|
+
# TODO: Refactor with subclasses?
|
107
|
+
StateInitSource = KwStruct.new(
|
108
|
+
:type,
|
100
109
|
:source,
|
101
110
|
:code,
|
102
111
|
:data,
|
103
112
|
:library,
|
104
113
|
:tvc,
|
105
114
|
:public_key,
|
106
|
-
:init_params
|
107
|
-
keyword_init: true
|
115
|
+
:init_params
|
108
116
|
) do
|
109
117
|
def initialize(
|
110
|
-
|
118
|
+
type:,
|
111
119
|
source: nil,
|
112
120
|
code: nil,
|
113
121
|
data: nil,
|
@@ -116,42 +124,42 @@ module TonSdk
|
|
116
124
|
public_key: nil,
|
117
125
|
init_params: nil
|
118
126
|
)
|
119
|
-
unless STATIC_INIT_SOURCE_TYPES.include?(
|
120
|
-
raise ArgumentError.new("unknown type: #{
|
127
|
+
unless STATIC_INIT_SOURCE_TYPES.include?(type)
|
128
|
+
raise ArgumentError.new("unknown type: #{type}; known types: #{STATIC_INIT_SOURCE_TYPES}")
|
121
129
|
end
|
122
130
|
super
|
123
131
|
end
|
124
132
|
|
125
133
|
def to_h
|
126
134
|
h1 = {
|
127
|
-
type: Helper.sym_to_capitalized_case_str(
|
135
|
+
type: Helper.sym_to_capitalized_case_str(type)
|
128
136
|
}
|
129
137
|
|
130
|
-
h2 = case
|
138
|
+
h2 = case type
|
131
139
|
when :message
|
132
140
|
{
|
133
|
-
source:
|
141
|
+
source: source.to_h
|
134
142
|
}
|
135
143
|
when :state_init
|
136
144
|
{
|
137
|
-
code:
|
138
|
-
data:
|
139
|
-
library:
|
145
|
+
code: code,
|
146
|
+
data: data,
|
147
|
+
library: library
|
140
148
|
}
|
141
149
|
when :tvc
|
142
150
|
{
|
143
|
-
public_key:
|
144
|
-
init_params:
|
151
|
+
public_key: public_key,
|
152
|
+
init_params: init_params.to_h
|
145
153
|
}
|
146
154
|
else
|
147
|
-
raise ArgumentError.new("unknown type: #{
|
155
|
+
raise ArgumentError.new("unknown type: #{type}; known types: #{STATIC_INIT_SOURCE_TYPES}")
|
148
156
|
end
|
149
157
|
|
150
158
|
h1.merge(h2)
|
151
159
|
end
|
152
160
|
end
|
153
161
|
|
154
|
-
StateInitParams =
|
162
|
+
StateInitParams = KwStruct.new(:abi, :value) do
|
155
163
|
def initialize(abi:, value:)
|
156
164
|
super
|
157
165
|
end
|
@@ -159,19 +167,18 @@ module TonSdk
|
|
159
167
|
|
160
168
|
|
161
169
|
MESSAGE_SOURCE_TYPES = [:encoded, :encoding_params]
|
162
|
-
MessageSource =
|
163
|
-
:
|
170
|
+
MessageSource = KwStruct.new(
|
171
|
+
:type,
|
164
172
|
:message,
|
165
173
|
:abi,
|
166
174
|
:address,
|
167
175
|
:deploy_set,
|
168
176
|
:call_set,
|
169
177
|
:signer,
|
170
|
-
:processing_try_index
|
171
|
-
keyword_init: true
|
178
|
+
:processing_try_index
|
172
179
|
) do
|
173
180
|
def initialize(
|
174
|
-
|
181
|
+
type:,
|
175
182
|
message: nil,
|
176
183
|
abi: nil,
|
177
184
|
address: nil,
|
@@ -180,8 +187,8 @@ module TonSdk
|
|
180
187
|
signer: nil,
|
181
188
|
processing_try_index: 0
|
182
189
|
)
|
183
|
-
unless MESSAGE_SOURCE_TYPES.include?(
|
184
|
-
raise ArgumentError.new("unknown type: #{
|
190
|
+
unless MESSAGE_SOURCE_TYPES.include?(type)
|
191
|
+
raise ArgumentError.new("unknown type: #{type}; known types: #{MESSAGE_SOURCE_TYPES}")
|
185
192
|
end
|
186
193
|
|
187
194
|
super
|
@@ -189,23 +196,23 @@ module TonSdk
|
|
189
196
|
|
190
197
|
def to_h
|
191
198
|
h1 = {
|
192
|
-
type: Helper.sym_to_capitalized_case_str(
|
199
|
+
type: Helper.sym_to_capitalized_case_str(type)
|
193
200
|
}
|
194
201
|
|
195
|
-
h2 = case
|
202
|
+
h2 = case type
|
196
203
|
when :encoded
|
197
204
|
{
|
198
|
-
message:
|
199
|
-
abi:
|
205
|
+
message: message,
|
206
|
+
abi: abi&.to_h
|
200
207
|
}
|
201
208
|
when :encoding_params
|
202
209
|
{
|
203
|
-
abi:
|
204
|
-
address:
|
205
|
-
deploy_set:
|
206
|
-
call_set:
|
207
|
-
signer:
|
208
|
-
processing_try_index:
|
210
|
+
abi: abi.to_h,
|
211
|
+
address: address,
|
212
|
+
deploy_set: deploy_set&.to_h,
|
213
|
+
call_set: call_set&.to_h,
|
214
|
+
signer: signer&.to_h,
|
215
|
+
processing_try_index: processing_try_index
|
209
216
|
}
|
210
217
|
end
|
211
218
|
|
@@ -213,34 +220,50 @@ module TonSdk
|
|
213
220
|
end
|
214
221
|
end
|
215
222
|
|
216
|
-
ParamsOfEncodeMessageBody =
|
217
|
-
|
218
|
-
|
223
|
+
ParamsOfEncodeMessageBody = KwStruct.new(
|
224
|
+
:abi,
|
225
|
+
:call_set,
|
226
|
+
:is_internal,
|
227
|
+
:signer,
|
228
|
+
:processing_try_index
|
229
|
+
) do
|
230
|
+
def to_h
|
231
|
+
{
|
232
|
+
abi: abi.to_h,
|
233
|
+
call_set: call_set.to_h,
|
234
|
+
is_internal: is_internal,
|
235
|
+
signer: signer.to_h,
|
236
|
+
processing_try_index: processing_try_index
|
237
|
+
}
|
219
238
|
end
|
220
239
|
end
|
221
240
|
|
222
|
-
ResultOfEncodeMessageBody =
|
241
|
+
ResultOfEncodeMessageBody = KwStruct.new(:body, :data_to_sign) do
|
223
242
|
def initialize(body:, data_to_sign: nil)
|
224
243
|
super
|
225
244
|
end
|
226
245
|
end
|
227
246
|
|
228
|
-
ParamsOfAttachSignatureToMessageBody =
|
229
|
-
def
|
230
|
-
|
247
|
+
ParamsOfAttachSignatureToMessageBody = KwStruct.new(:abi, :public_key, :message, :signature) do
|
248
|
+
def to_h
|
249
|
+
{
|
250
|
+
abi: abi.to_h,
|
251
|
+
public_key: public_key,
|
252
|
+
message: message,
|
253
|
+
signature: signature
|
254
|
+
}
|
231
255
|
end
|
232
256
|
end
|
233
257
|
|
234
|
-
ResultOfAttachSignatureToMessageBody =
|
258
|
+
ResultOfAttachSignatureToMessageBody = KwStruct.new(:body)
|
235
259
|
|
236
|
-
ParamsOfEncodeMessage =
|
260
|
+
ParamsOfEncodeMessage = KwStruct.new(
|
237
261
|
:abi,
|
238
262
|
:address,
|
239
263
|
:deploy_set,
|
240
264
|
:call_set,
|
241
265
|
:signer,
|
242
|
-
:processing_try_index
|
243
|
-
keyword_init: true
|
266
|
+
:processing_try_index
|
244
267
|
) do
|
245
268
|
def initialize(
|
246
269
|
abi:,
|
@@ -252,30 +275,57 @@ module TonSdk
|
|
252
275
|
)
|
253
276
|
super
|
254
277
|
end
|
278
|
+
|
279
|
+
def to_h
|
280
|
+
{
|
281
|
+
abi: abi.to_h,
|
282
|
+
address: address,
|
283
|
+
deploy_set: deploy_set&.to_h,
|
284
|
+
call_set: call_set&.to_h,
|
285
|
+
signer: signer.to_h,
|
286
|
+
processing_try_index: processing_try_index
|
287
|
+
}
|
288
|
+
end
|
255
289
|
end
|
256
290
|
|
257
|
-
ResultOfEncodeMessage =
|
291
|
+
ResultOfEncodeMessage = KwStruct.new(:message, :data_to_sign, :address, :message_id) do
|
258
292
|
def initialize(message:, data_to_sign: nil, address:, message_id:)
|
259
293
|
super
|
260
294
|
end
|
261
295
|
end
|
262
296
|
|
263
|
-
ParamsOfAttachSignature =
|
297
|
+
ParamsOfAttachSignature = KwStruct.new(:abi, :public_key, :message, :signature) do
|
264
298
|
def initialize(abi:, public_key:, message:, signature:)
|
265
299
|
super
|
266
300
|
end
|
301
|
+
|
302
|
+
def to_h
|
303
|
+
{
|
304
|
+
abi: abi&.to_h,
|
305
|
+
public_key: public_key,
|
306
|
+
message: message,
|
307
|
+
signature: signature
|
308
|
+
}
|
309
|
+
end
|
267
310
|
end
|
268
311
|
|
269
|
-
ResultOfAttachSignature =
|
312
|
+
ResultOfAttachSignature = KwStruct.new(:message, :message_id) do
|
270
313
|
def initialize(message:, message_id:)
|
271
314
|
super
|
272
315
|
end
|
273
316
|
end
|
274
317
|
|
275
|
-
ParamsOfDecodeMessage =
|
318
|
+
ParamsOfDecodeMessage = KwStruct.new(:abi, :message) do
|
276
319
|
def initialize(abi:, message:)
|
277
320
|
super
|
278
321
|
end
|
322
|
+
|
323
|
+
def to_h
|
324
|
+
{
|
325
|
+
abi: abi&.to_h,
|
326
|
+
message: message
|
327
|
+
}
|
328
|
+
end
|
279
329
|
end
|
280
330
|
|
281
331
|
class DecodedMessageBody
|
@@ -341,19 +391,39 @@ module TonSdk
|
|
341
391
|
end
|
342
392
|
end
|
343
393
|
|
344
|
-
ParamsOfDecodeMessageBody =
|
394
|
+
ParamsOfDecodeMessageBody = KwStruct.new(:abi, :body, :is_internal) do
|
345
395
|
def initialize(abi:, body:, is_internal:)
|
346
396
|
super
|
347
397
|
end
|
398
|
+
|
399
|
+
def to_h
|
400
|
+
{
|
401
|
+
abi: abi&.to_h,
|
402
|
+
body: body,
|
403
|
+
is_internal: is_internal
|
404
|
+
}
|
405
|
+
end
|
348
406
|
end
|
349
407
|
|
350
|
-
ParamsOfEncodeAccount =
|
351
|
-
|
352
|
-
|
408
|
+
ParamsOfEncodeAccount = KwStruct.new(
|
409
|
+
:state_init,
|
410
|
+
:balance,
|
411
|
+
:last_trans_lt,
|
412
|
+
:last_paid,
|
413
|
+
:boc_cache
|
414
|
+
) do
|
415
|
+
def to_h
|
416
|
+
{
|
417
|
+
state_init: state_init.to_h,
|
418
|
+
balance: balance,
|
419
|
+
last_trans_lt: last_trans_lt,
|
420
|
+
last_paid: last_paid,
|
421
|
+
boc_cache: boc_cache&.to_h
|
422
|
+
}
|
353
423
|
end
|
354
424
|
end
|
355
425
|
|
356
|
-
ResultOfEncodeAccount =
|
426
|
+
ResultOfEncodeAccount = KwStruct.new(:account, :id_) do
|
357
427
|
def initialize(account:, id_:)
|
358
428
|
super
|
359
429
|
end
|
@@ -621,7 +691,7 @@ module TonSdk
|
|
621
691
|
end
|
622
692
|
end
|
623
693
|
|
624
|
-
ParamsOfEncodeInternalMessage =
|
694
|
+
ParamsOfEncodeInternalMessage = KwStruct.new(
|
625
695
|
:abi,
|
626
696
|
:address,
|
627
697
|
:src_address,
|
@@ -629,8 +699,7 @@ module TonSdk
|
|
629
699
|
:call_set,
|
630
700
|
:value,
|
631
701
|
:bounce,
|
632
|
-
:enable_ihr
|
633
|
-
keyword_init: true
|
702
|
+
:enable_ihr
|
634
703
|
) do
|
635
704
|
def initialize(
|
636
705
|
abi: nil,
|
@@ -646,20 +715,57 @@ module TonSdk
|
|
646
715
|
end
|
647
716
|
end
|
648
717
|
|
649
|
-
ResultOfEncodeInternalMessage =
|
718
|
+
ResultOfEncodeInternalMessage = KwStruct.new(
|
650
719
|
:message,
|
651
720
|
:address,
|
652
|
-
:message_id
|
653
|
-
keyword_init: true
|
721
|
+
:message_id
|
654
722
|
) do
|
655
723
|
def initialize(message:, address:, message_id:)
|
656
724
|
super
|
657
725
|
end
|
658
726
|
end
|
659
727
|
|
660
|
-
ParamsOfDecodeAccountData =
|
661
|
-
|
728
|
+
ParamsOfDecodeAccountData = KwStruct.new(:abi, :data) do
|
729
|
+
def to_h
|
730
|
+
{
|
731
|
+
abi: abi&.to_h,
|
732
|
+
data: data
|
733
|
+
}
|
734
|
+
end
|
735
|
+
end
|
736
|
+
|
737
|
+
ResultOfDecodeData = KwStruct.new(:data)
|
738
|
+
|
739
|
+
ParamsOfUpdateInitialData = KwStruct.new(
|
740
|
+
:data,
|
741
|
+
:abi,
|
742
|
+
:initial_data,
|
743
|
+
:initial_pubkey,
|
744
|
+
:boc_cache
|
745
|
+
) do
|
746
|
+
def to_h
|
747
|
+
{
|
748
|
+
data: data,
|
749
|
+
abi: abi&.to_h,
|
750
|
+
initial_data: initial_data,
|
751
|
+
initial_pubkey: initial_pubkey,
|
752
|
+
boc_cache: boc_cache&.to_h
|
753
|
+
}
|
754
|
+
end
|
755
|
+
end
|
756
|
+
|
757
|
+
ResultOfUpdateInitialData = KwStruct.new(:data)
|
758
|
+
|
759
|
+
ParamsOfDecodeInitialData = KwStruct.new(:data, :abi) do
|
760
|
+
def to_h
|
761
|
+
{
|
762
|
+
data: data,
|
763
|
+
abi: abi&.to_h
|
764
|
+
}
|
765
|
+
end
|
766
|
+
end
|
662
767
|
|
768
|
+
ResultOfDecodeInitialData = KwStruct.new(:initial_pubkey, :initial_data)
|
663
769
|
|
664
770
|
#
|
665
771
|
# functions
|
@@ -683,7 +789,7 @@ module TonSdk
|
|
683
789
|
Interop::request_to_native_lib(ctx, "abi.attach_signature_to_message_body", params) do |resp|
|
684
790
|
if resp.success?
|
685
791
|
yield NativeLibResponsetResult.new(
|
686
|
-
result: ResultOfAttachSignatureToMessageBody.new(resp.result["body"])
|
792
|
+
result: ResultOfAttachSignatureToMessageBody.new(body: resp.result["body"])
|
687
793
|
)
|
688
794
|
else
|
689
795
|
yield resp
|
@@ -782,7 +888,7 @@ module TonSdk
|
|
782
888
|
if resp.success?
|
783
889
|
yield NativeLibResponsetResult.new(
|
784
890
|
result: ResultOfDecodeData.new(
|
785
|
-
resp.result["data"]
|
891
|
+
data: resp.result["data"]
|
786
892
|
)
|
787
893
|
)
|
788
894
|
else
|
@@ -791,7 +897,33 @@ module TonSdk
|
|
791
897
|
end
|
792
898
|
end
|
793
899
|
|
900
|
+
def self.update_initial_data(ctx, params)
|
901
|
+
Interop::request_to_native_lib(ctx, "abi.update_initial_data", params) do |resp|
|
902
|
+
if resp.success?
|
903
|
+
yield NativeLibResponsetResult.new(
|
904
|
+
result: ResultOfUpdateInitialData.new(
|
905
|
+
data: resp.result["data"]
|
906
|
+
)
|
907
|
+
)
|
908
|
+
else
|
909
|
+
yield resp
|
910
|
+
end
|
911
|
+
end
|
912
|
+
end
|
794
913
|
|
795
|
-
|
914
|
+
def self.decode_initial_data(ctx, params)
|
915
|
+
Interop::request_to_native_lib(ctx, "abi.decode_initial_data", params) do |resp|
|
916
|
+
if resp.success?
|
917
|
+
yield NativeLibResponsetResult.new(
|
918
|
+
result: ResultOfDecodeInitialData.new(
|
919
|
+
initial_pubkey: resp.result["initial_pubkey"],
|
920
|
+
initial_data: resp.result["initial_data"]
|
921
|
+
)
|
922
|
+
)
|
923
|
+
else
|
924
|
+
yield resp
|
925
|
+
end
|
926
|
+
end
|
927
|
+
end
|
796
928
|
end
|
797
|
-
end
|
929
|
+
end
|