ton_sdk_client 1.28.0 → 1.34.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 +9 -5
- data/README.md +24 -64
- data/lib/ton_sdk_client/abi.rb +48 -10
- data/lib/ton_sdk_client/boc.rb +29 -0
- data/lib/ton_sdk_client/client.rb +17 -0
- data/lib/ton_sdk_client/config.rb +11 -1
- data/lib/ton_sdk_client/crypto.rb +295 -61
- data/lib/ton_sdk_client/net.rb +21 -1
- data/lib/ton_sdk_client/processing.rb +70 -40
- data/lib/ton_sdk_client/tvm.rb +8 -2
- 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: 5a7f0b6efe10b27110b81583c88d1001e261d4a65d5b244698c7fb1f6f948e1c
|
4
|
+
data.tar.gz: c589d48fba0d43db0eaeebb1f0997414d9b27a64b84d05f0815a2a5e590f9b9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b596337a82d897dc1d7f5e8805525d34f4121e052f22a1ebdc8253c87d1199347c658e89f0874cac8abdd5f1d9d7f2863a882be40ba92a2f9ccef80a39ea84d8
|
7
|
+
data.tar.gz: b156904a3e7d0087c1e110f9d77dbecd52e660811f82fabad23a6b0a6fbf59e2c436e0efb07bd05cdc7a2dd74c6b2e7de5b0051be89058d19a061286708d33a5
|
data/CHANGELOG.md
CHANGED
@@ -2,26 +2,30 @@
|
|
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.34.0
|
6
|
+
-----
|
7
|
+
* Changes https://github.com/tonlabs/ever-sdk/blob/master/CHANGELOG.md
|
8
|
+
|
5
9
|
1.28.0
|
6
10
|
-----
|
7
|
-
* Changes `1.28.0` https://github.com/tonlabs/
|
11
|
+
* Changes `1.28.0` https://github.com/tonlabs/ever-sdk/blob/master/CHANGELOG.md#1280--2021-12-24
|
8
12
|
* Implement Debot module
|
9
13
|
|
10
14
|
1.27.0
|
11
15
|
-----
|
12
|
-
* Changes `1.27.0` https://github.com/tonlabs/
|
16
|
+
* Changes `1.27.0` https://github.com/tonlabs/ever-sdk/blob/master/CHANGELOG.md#1270--2021-12-03
|
13
17
|
|
14
18
|
1.26.0
|
15
19
|
-----
|
16
|
-
* Changes `1.26.0` https://github.com/tonlabs/
|
20
|
+
* Changes `1.26.0` https://github.com/tonlabs/ever-sdk/blob/master/CHANGELOG.md#1260--2021-11-25
|
17
21
|
|
18
22
|
1.25.0
|
19
23
|
-----
|
20
|
-
* Changes `1.25.0` https://github.com/tonlabs/
|
24
|
+
* Changes `1.25.0` https://github.com/tonlabs/ever-sdk/blob/master/CHANGELOG.md#1250--2021-11-08
|
21
25
|
|
22
26
|
1.24.0
|
23
27
|
-----
|
24
|
-
* Changes `1.24.0` https://github.com/tonlabs/
|
28
|
+
* Changes `1.24.0` https://github.com/tonlabs/ever-sdk/blob/master/CHANGELOG.md#1240--2021-10-18
|
25
29
|
* **BREAKING CHANGE** All Params now require keyword arguments
|
26
30
|
|
27
31
|
1.20.x
|
data/README.md
CHANGED
@@ -1,44 +1,39 @@
|
|
1
|
-
# TON SDK client in Ruby and for Ruby
|
1
|
+
# Ever SDK (formerly TON SDK) client in Ruby and for Ruby
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/ton_sdk_client.svg)](https://rubygems.org/gems/ton_sdk_client)
|
4
|
-
[![
|
4
|
+
[![Ever SDK version](https://img.shields.io/badge/Ever%20SDK%20version-1.34.0-green)](https://github.com/tonlabs/ever-sdk/tree/1.34.0)
|
5
5
|
|
6
|
-
Ruby gem-client bindings for [
|
6
|
+
Ruby gem-client bindings for [Ever SDK](https://github.com/tonlabs/ever-sdk) which allows one to communicate with [Everscale](https://everscale.network/) blockchain in Ruby.
|
7
7
|
|
8
|
-
Note that there
|
8
|
+
Note that there are 2 types of versions:
|
9
9
|
* `TonSdk::VERSION` - the version of the gem
|
10
10
|
* `TonSdk::NATIVE_SDK_VERSION` - the version of the original SDK
|
11
11
|
|
12
12
|
and they may not always match each other.
|
13
13
|
|
14
|
-
|
15
|
-
|
16
14
|
## Installation
|
17
15
|
|
18
16
|
Add this to the `Gemfile` of a project:
|
19
17
|
|
20
18
|
```ruby
|
21
|
-
gem
|
19
|
+
gem "ton_sdk_client"
|
22
20
|
```
|
23
21
|
and run `bundle install`
|
24
22
|
|
25
23
|
Alternatively install it directly
|
26
24
|
|
27
|
-
```
|
25
|
+
```shell
|
28
26
|
gem install ton_sdk_client
|
29
27
|
```
|
30
28
|
|
31
|
-
|
32
29
|
## Requirements
|
33
30
|
|
34
31
|
The gem requires `tonclient` native library, appropriate for one's OS; the download links are at:
|
35
32
|
|
36
|
-
https://github.com/tonlabs/
|
33
|
+
https://github.com/tonlabs/ever-sdk#download-precompiled-binaries
|
37
34
|
|
38
35
|
Once downloaded, unpack it into a directory of your choice and then set an environmental variable `TON_CLIENT_NATIVE_LIB_NAME` pointing to the full path of a library.
|
39
36
|
|
40
|
-
Also, check out the file `.ruby-version` to see which version has been used to develop the gem. Some older versions of ruby may work as well.
|
41
|
-
|
42
37
|
## Examples
|
43
38
|
|
44
39
|
The examples are located in the `examples` directory, and they cover most the modules.
|
@@ -46,7 +41,7 @@ The examples are located in the `examples` directory, and they cover most the mo
|
|
46
41
|
And here's a simple minimalistic one:
|
47
42
|
|
48
43
|
```ruby
|
49
|
-
require
|
44
|
+
require "ton_sdk_client"
|
50
45
|
|
51
46
|
cfg = TonSdk::ClientConfig.new(
|
52
47
|
network: TonSdk::NetworkConfig.new(
|
@@ -60,7 +55,7 @@ c_ctx = TonSdk::ClientContext.new(cfg.to_h.to_json)
|
|
60
55
|
# next, call a method of a module you want passing a context to it
|
61
56
|
TonSdk::Client.version(c_ctx.context) do |res|
|
62
57
|
|
63
|
-
# 'res' is of type TonSdk::
|
58
|
+
# 'res' is of type TonSdk::NativeLibResponseResult
|
64
59
|
# holds either 'result' or 'error'
|
65
60
|
# to check which one it is, use boolean methods:
|
66
61
|
# res.success? or res.failure?
|
@@ -75,13 +70,12 @@ end
|
|
75
70
|
```
|
76
71
|
|
77
72
|
In this case, the method `version()` requires only a `context` object. But most others require an additional 2nd argument appropriate for a certain method.
|
78
|
-
Note that some methods, such some of the `Processing`, `Net`, `Tvm` modules, will continue to run for some time
|
73
|
+
Note that some methods, such some of the `Processing`, `Net`, `Tvm` modules, will continue to run for some time asynchronously delivering a result to a user, for instance, `Processing.process_message(...)` will do it via a callback
|
79
74
|
|
80
75
|
```ruby
|
81
|
-
|
82
76
|
my_callback = Proc.new do |a|
|
83
77
|
|
84
|
-
# will be triggered multiple times,
|
78
|
+
# will be triggered multiple times, asynchronously
|
85
79
|
puts "callback fired: #{a}"
|
86
80
|
end
|
87
81
|
|
@@ -93,32 +87,17 @@ Note that some methods, such some of the `Processing`, `Net`, `Tvm` modules, wil
|
|
93
87
|
TonSdk::Processing.process_message(@c_ctx.context, pr1, my_callback) do |a|
|
94
88
|
# [.......]
|
95
89
|
end
|
96
|
-
|
97
90
|
```
|
98
91
|
|
99
92
|
while other methods will deliver a result relatively fast, without a callback, and terminate.
|
100
93
|
|
101
|
-
|
102
|
-
## Implementation coverage, by modules
|
103
|
-
- ✅ abi
|
104
|
-
- ✅ boc
|
105
|
-
- ✅ client
|
106
|
-
- ✅ crypto
|
107
|
-
- ✅ net
|
108
|
-
- ✅ processing
|
109
|
-
- ✅ tvm
|
110
|
-
- ✅ utils
|
111
|
-
- ✅ debot (unstable)
|
112
|
-
|
113
|
-
|
114
94
|
## Documentation
|
115
95
|
|
116
96
|
* https://docs.ton.dev/86757ecb2/p/7941cd-what-is-ton-os
|
117
|
-
* https://github.com/tonlabs/
|
118
|
-
* https://github.com/tonlabs/
|
119
|
-
|
120
|
-
Mind the current version of SDK when reading documentation and examples at https://github.com/tonlabs/TON-SDK
|
97
|
+
* https://github.com/tonlabs/ever-sdk/tree/master/docs
|
98
|
+
* https://github.com/tonlabs/ever-sdk/blob/master/tools/api.json
|
121
99
|
|
100
|
+
Mind the current version of SDK when reading documentation and examples at https://github.com/tonlabs/ever-sdk
|
122
101
|
|
123
102
|
## Using it as a developer
|
124
103
|
|
@@ -131,8 +110,7 @@ cd ton-client-ruby
|
|
131
110
|
|
132
111
|
### Install the dependencies
|
133
112
|
```
|
134
|
-
gem install ffi
|
135
|
-
gem install concurrent-ruby
|
113
|
+
gem install ffi concurrent-ruby rspec
|
136
114
|
```
|
137
115
|
There may be other dependencies too, check the `gemspec` file for the full list of them.
|
138
116
|
|
@@ -153,16 +131,6 @@ or run a specific set of the tests:
|
|
153
131
|
rspec spec/boc_spec.rb
|
154
132
|
```
|
155
133
|
|
156
|
-
## Test coverage, by modules
|
157
|
-
- ✅ abi
|
158
|
-
- ✅ boc
|
159
|
-
- ✅ client
|
160
|
-
- ✅ crypto
|
161
|
-
- ✅ net
|
162
|
-
- ✅ processing
|
163
|
-
- ✅ tvm
|
164
|
-
- ✅ utils
|
165
|
-
|
166
134
|
|
167
135
|
### Run the examples
|
168
136
|
|
@@ -180,40 +148,31 @@ factorize
|
|
180
148
|
```
|
181
149
|
|
182
150
|
|
183
|
-
## Tested
|
151
|
+
## Tested with
|
184
152
|
|
185
153
|
* MacOS Catalina 10.15.5
|
186
154
|
* Arch Linux x86_64
|
187
|
-
* TON client native library: `TonSdk::NATIVE_SDK_VERSION`
|
188
|
-
|
189
155
|
|
190
156
|
## References
|
191
157
|
* Wiki of the gem FFI: https://github.com/ffi/ffi/wiki ; callbacks: https://github.com/ffi/ffi/wiki/Callbacks
|
192
|
-
|
193
158
|
* https://stackoverflow.com/questions/60689128/ruby-ffi-callback-return-values
|
194
159
|
|
195
|
-
|
196
160
|
## Notes
|
197
161
|
* Rspec validators or matchers don't work in a block of a non main thread, therefore in the tests an intermediate variable is used to save a result, a block, and then validate it outside of a block.
|
198
|
-
|
199
|
-
* Testing asyncronous code in Ruby is difficult and can incur hacks. Not all asyncronous code should be tested automatically via Rspec or other libraries, some should be instead tested manually once and then left alone thereafter:
|
162
|
+
* Testing asynchronous code in Ruby is difficult and can incur hacks. Not all asynchronous code should be tested automatically via Rspec or other libraries, some should be instead tested manually once and then left alone thereafter:
|
200
163
|
https://www.mikeperham.com/2015/12/14/how-to-test-multithreaded-code
|
201
|
-
|
202
|
-
* In some of the tests of the gem a "sleep" loop with a timeout are used to wait for an asyncronous operation to deliver a result, and this approach will do, although it can be replaced with a more idiomatic one. Oweing to the side effects, at times some tests may fail. When it happens, try to increase a timeout:
|
164
|
+
* In some of the tests of the gem a "sleep" loop with a timeout are used to wait for an asynchronous operation to deliver a result, and this approach will do, although it can be replaced with a more idiomatic one. Oweing to the side effects, at times some tests may fail. When it happens, try to increase a timeout:
|
203
165
|
|
204
166
|
```ruby
|
205
|
-
timeout_at = get_timeout_for_async_operation
|
167
|
+
timeout_at = get_timeout_for_async_operation
|
206
168
|
|
207
169
|
# before, 5 seconds by default
|
208
|
-
sleep(0.1) until @res || get_now
|
170
|
+
sleep(0.1) until @res || get_now >= timeout_at
|
209
171
|
|
210
172
|
# after, longer timeout
|
211
|
-
sleep(0.1) until @res || get_now
|
173
|
+
sleep(0.1) until @res || get_now >= (timeout_at * 2)
|
212
174
|
```
|
213
175
|
|
214
|
-
* No automatic generator has been used to generate Ruby classes or bindings to the SDK. Why not? Because no appropriate, simple and functional one has been found.
|
215
|
-
|
216
|
-
|
217
176
|
## Credits
|
218
177
|
|
219
178
|
* [Tonlabs.io](https://tonlabs.io)
|
@@ -230,5 +189,6 @@ See the `CHANGELOG` file
|
|
230
189
|
|
231
190
|
## Community
|
232
191
|
|
233
|
-
*
|
234
|
-
*
|
192
|
+
* Everscale News on Telegram https://t.me/everscale_news
|
193
|
+
* Everscale DEV Tools & SDK Telegram chat https://t.me/ever_sdk
|
194
|
+
* [Everscale](https://everscale.network/)
|
data/lib/ton_sdk_client/abi.rb
CHANGED
@@ -315,15 +315,16 @@ module TonSdk
|
|
315
315
|
end
|
316
316
|
end
|
317
317
|
|
318
|
-
ParamsOfDecodeMessage = KwStruct.new(:abi, :message) do
|
319
|
-
def initialize(abi:, message:)
|
318
|
+
ParamsOfDecodeMessage = KwStruct.new(:abi, :message, :allow_partial) do
|
319
|
+
def initialize(abi:, message:, allow_partial: false)
|
320
320
|
super
|
321
321
|
end
|
322
322
|
|
323
323
|
def to_h
|
324
324
|
{
|
325
325
|
abi: abi&.to_h,
|
326
|
-
message: message
|
326
|
+
message: message,
|
327
|
+
allow_partial: allow_partial
|
327
328
|
}
|
328
329
|
end
|
329
330
|
end
|
@@ -391,8 +392,8 @@ module TonSdk
|
|
391
392
|
end
|
392
393
|
end
|
393
394
|
|
394
|
-
ParamsOfDecodeMessageBody = KwStruct.new(:abi, :body, :is_internal) do
|
395
|
-
def initialize(abi:, body:, is_internal:)
|
395
|
+
ParamsOfDecodeMessageBody = KwStruct.new(:abi, :body, :is_internal, :allow_partial) do
|
396
|
+
def initialize(abi:, body:, is_internal:, allow_partial: false)
|
396
397
|
super
|
397
398
|
end
|
398
399
|
|
@@ -400,7 +401,8 @@ module TonSdk
|
|
400
401
|
{
|
401
402
|
abi: abi&.to_h,
|
402
403
|
body: body,
|
403
|
-
is_internal: is_internal
|
404
|
+
is_internal: is_internal,
|
405
|
+
allow_partial: allow_partial
|
404
406
|
}
|
405
407
|
end
|
406
408
|
end
|
@@ -725,11 +727,16 @@ module TonSdk
|
|
725
727
|
end
|
726
728
|
end
|
727
729
|
|
728
|
-
ParamsOfDecodeAccountData = KwStruct.new(:abi, :data) do
|
730
|
+
ParamsOfDecodeAccountData = KwStruct.new(:abi, :data, :allow_partial) do
|
731
|
+
def initialize(abi:, data:, allow_partial: false)
|
732
|
+
super
|
733
|
+
end
|
734
|
+
|
729
735
|
def to_h
|
730
736
|
{
|
731
737
|
abi: abi&.to_h,
|
732
|
-
data: data
|
738
|
+
data: data,
|
739
|
+
allow_partial: allow_partial
|
733
740
|
}
|
734
741
|
end
|
735
742
|
end
|
@@ -769,11 +776,16 @@ module TonSdk
|
|
769
776
|
|
770
777
|
ResultOfEncodeInitialData = KwStruct.new(:data)
|
771
778
|
|
772
|
-
ParamsOfDecodeInitialData = KwStruct.new(:data, :abi) do
|
779
|
+
ParamsOfDecodeInitialData = KwStruct.new(:data, :abi, :allow_partial) do
|
780
|
+
def initialize(data:, abi:, allow_partial: false)
|
781
|
+
super
|
782
|
+
end
|
783
|
+
|
773
784
|
def to_h
|
774
785
|
{
|
775
786
|
data: data,
|
776
|
-
abi: abi&.to_h
|
787
|
+
abi: abi&.to_h,
|
788
|
+
allow_partial: allow_partial
|
777
789
|
}
|
778
790
|
end
|
779
791
|
end
|
@@ -792,6 +804,18 @@ module TonSdk
|
|
792
804
|
|
793
805
|
ResultOfDecodeBoc = KwStruct.new(:data)
|
794
806
|
|
807
|
+
ParamsOfAbiEncodeBoc = KwStruct.new(:params, :data, :boc_cache) do
|
808
|
+
def to_h
|
809
|
+
{
|
810
|
+
params: params&.map(&:to_h),
|
811
|
+
data: data,
|
812
|
+
boc_cache: boc_cache&.to_h
|
813
|
+
}
|
814
|
+
end
|
815
|
+
end
|
816
|
+
|
817
|
+
ResultOfAbiEncodeBoc = KwStruct.new(:boc)
|
818
|
+
|
795
819
|
#
|
796
820
|
# functions
|
797
821
|
#
|
@@ -978,5 +1002,19 @@ module TonSdk
|
|
978
1002
|
end
|
979
1003
|
end
|
980
1004
|
end
|
1005
|
+
|
1006
|
+
def self.encode_boc(ctx, params)
|
1007
|
+
Interop::request_to_native_lib(ctx, "abi.encode_boc", params) do |resp|
|
1008
|
+
if resp.success?
|
1009
|
+
yield NativeLibResponseResult.new(
|
1010
|
+
result: ResultOfAbiEncodeBoc.new(
|
1011
|
+
boc: resp.result["boc"]
|
1012
|
+
)
|
1013
|
+
)
|
1014
|
+
else
|
1015
|
+
yield resp
|
1016
|
+
end
|
1017
|
+
end
|
1018
|
+
end
|
981
1019
|
end
|
982
1020
|
end
|
data/lib/ton_sdk_client/boc.rb
CHANGED
@@ -130,6 +130,20 @@ module TonSdk
|
|
130
130
|
|
131
131
|
ResultOfEncodeTvc = KwStruct.new(:tvc)
|
132
132
|
|
133
|
+
ParamsOfEncodeExternalInMessage = KwStruct.new(:src, :dst, :init, :body, :boc_cache) do
|
134
|
+
def to_h
|
135
|
+
{
|
136
|
+
src: src,
|
137
|
+
dst: dst,
|
138
|
+
init: init,
|
139
|
+
body: body,
|
140
|
+
boc_cache: boc_cache&.to_h
|
141
|
+
}
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
ResultOfEncodeExternalInMessage = KwStruct.new(:message, :message_id)
|
146
|
+
|
133
147
|
ParamsOfGetCompilerVersion = KwStruct.new(:code)
|
134
148
|
|
135
149
|
ResultOfGetCompilerVersion = KwStruct.new(:version)
|
@@ -370,6 +384,21 @@ module TonSdk
|
|
370
384
|
end
|
371
385
|
end
|
372
386
|
|
387
|
+
def self.encode_external_in_message(ctx, params)
|
388
|
+
Interop::request_to_native_lib(ctx, "boc.encode_external_in_message", params) do |resp|
|
389
|
+
if resp.success?
|
390
|
+
yield NativeLibResponseResult.new(
|
391
|
+
result: ResultOfEncodeExternalInMessage.new(
|
392
|
+
message: resp.result["message"],
|
393
|
+
message_id: resp.result["message_id"]
|
394
|
+
)
|
395
|
+
)
|
396
|
+
else
|
397
|
+
yield resp
|
398
|
+
end
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
373
402
|
def self.get_compiler_version(ctx, params)
|
374
403
|
Interop::request_to_native_lib(ctx, "boc.get_compiler_version", params) do |resp|
|
375
404
|
if resp.success?
|
@@ -122,6 +122,23 @@ module TonSdk
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
+
def self.config(ctx)
|
126
|
+
Interop::request_to_native_lib(ctx, "client.config") do |resp|
|
127
|
+
if resp.success?
|
128
|
+
yield NativeLibResponseResult.new(
|
129
|
+
result: ClientConfig.new(
|
130
|
+
network: resp.result["network"],
|
131
|
+
crypto: resp.result["crypto"],
|
132
|
+
abi: resp.result["abi"],
|
133
|
+
boc: resp.result["boc"]
|
134
|
+
)
|
135
|
+
)
|
136
|
+
else
|
137
|
+
yield resp
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
125
142
|
def self.get_api_reference(ctx)
|
126
143
|
Interop::request_to_native_lib(ctx, "client.get_api_reference") do |resp|
|
127
144
|
if resp.success?
|
@@ -15,6 +15,9 @@ module TonSdk
|
|
15
15
|
:latency_detection_interval,
|
16
16
|
:max_latency,
|
17
17
|
:query_timeout,
|
18
|
+
:queries_protocol,
|
19
|
+
:first_remp_status_timeout,
|
20
|
+
:next_remp_status_timeout,
|
18
21
|
:access_key
|
19
22
|
) do
|
20
23
|
def initialize(
|
@@ -31,12 +34,20 @@ module TonSdk
|
|
31
34
|
latency_detection_interval: 60000,
|
32
35
|
max_latency: 60000,
|
33
36
|
query_timeout: 60000,
|
37
|
+
queries_protocol: nil,
|
38
|
+
first_remp_status_timeout: nil,
|
39
|
+
next_remp_status_timeout: nil,
|
34
40
|
access_key: nil
|
35
41
|
)
|
36
42
|
super
|
37
43
|
end
|
38
44
|
end
|
39
45
|
|
46
|
+
module NetworkQueriesProtocol
|
47
|
+
HTTP = "HTTP".freeze
|
48
|
+
WS = "WS".freeze
|
49
|
+
end
|
50
|
+
|
40
51
|
AbiConfig = KwStruct.new(
|
41
52
|
:workchain,
|
42
53
|
:message_expiration_timeout,
|
@@ -63,5 +74,4 @@ module TonSdk
|
|
63
74
|
}
|
64
75
|
end
|
65
76
|
end
|
66
|
-
|
67
77
|
end
|
@@ -5,24 +5,24 @@ module TonSdk
|
|
5
5
|
# types
|
6
6
|
#
|
7
7
|
module ErrorCode
|
8
|
-
|
9
|
-
|
8
|
+
INVALID_PUBLIC_KEY = 100
|
9
|
+
INVALID_SECRET_KEY = 101
|
10
10
|
INVALID_KEY = 102
|
11
11
|
INVALID_FACTORIZE_CHALLENGE = 106
|
12
|
-
|
12
|
+
INVALID_BIG_INT = 107
|
13
13
|
SCRYPT_FAILED = 108
|
14
|
-
|
14
|
+
INVALID_KEY_SIZE = 109
|
15
15
|
NACL_SECRET_BOX_FAILED = 110
|
16
16
|
NACL_BOX_FAILED = 111
|
17
17
|
NACL_SIGN_FAILED = 112
|
18
18
|
BIP39_INVALID_ENTROPY = 113
|
19
19
|
BIP39_INVALID_PHRASE = 114
|
20
20
|
BIP32_INVALID_KEY = 115
|
21
|
-
|
21
|
+
BIP32_INVALID_DERIVE_PATH = 116
|
22
22
|
BIP39_INVALID_DICTIONARY = 117
|
23
|
-
|
23
|
+
BIP39_INVALID_WORD_COUNT = 118
|
24
24
|
MNEMONIC_GENERATION_FAILED = 119
|
25
|
-
|
25
|
+
MNEMONIC_FROM_ENTROPY_FAILED = 120
|
26
26
|
SIGNING_BOX_NOT_REGISTERED = 121
|
27
27
|
INVALID_SIGNATURE = 122
|
28
28
|
ENCRYPTION_BOX_NOT_REGISTERED = 123
|
@@ -32,6 +32,11 @@ module TonSdk
|
|
32
32
|
ENCRYPT_DATA_ERROR = 127
|
33
33
|
DECRYPT_DATA_ERROR = 128
|
34
34
|
IV_REQUIRED = 129
|
35
|
+
CRYPTO_BOX_NOT_REGISTERED = 130
|
36
|
+
INVALID_CRYPTO_BOX_TYPE = 131
|
37
|
+
CRYPTO_BOX_SECRET_SERIALIZATION_ERROR = 132
|
38
|
+
CRYPTO_BOX_SECRET_DESERIALIZATION_ERROR = 133
|
39
|
+
INVALID_NONCE_SIZE = 134
|
35
40
|
end
|
36
41
|
|
37
42
|
ParamsOfFactorize = KwStruct.new(:composite)
|
@@ -178,7 +183,9 @@ module TonSdk
|
|
178
183
|
ParamsOfSigningBoxSign = KwStruct.new(:signing_box, :unsigned)
|
179
184
|
|
180
185
|
ResultOfSigningBoxSign = KwStruct.new(:signature)
|
186
|
+
|
181
187
|
RegisteredSigningBox = KwStruct.new(:handle)
|
188
|
+
|
182
189
|
ResultOfSigningBoxGetPublicKey = KwStruct.new(:pubkey)
|
183
190
|
|
184
191
|
ParamsOfNaclSignDetachedVerify = KwStruct.new(:unsigned, :signature, :public_) do
|
@@ -194,10 +201,7 @@ module TonSdk
|
|
194
201
|
ResultOfNaclSignDetachedVerify = KwStruct.new(:succeeded)
|
195
202
|
|
196
203
|
class ParamsOfAppSigningBox
|
197
|
-
TYPES = [
|
198
|
-
:get_public_key,
|
199
|
-
:sign
|
200
|
-
]
|
204
|
+
TYPES = [:get_public_key, :sign]
|
201
205
|
|
202
206
|
attr_reader :type_, :unsigned
|
203
207
|
|
@@ -218,11 +222,150 @@ module TonSdk
|
|
218
222
|
end
|
219
223
|
|
220
224
|
EncryptionBoxInfo = KwStruct.new(:hdpath, :algorithm, :options, :public)
|
225
|
+
|
221
226
|
ParamsOfEncryptionBoxGetInfo = KwStruct.new(:encryption_box)
|
227
|
+
|
222
228
|
ResultOfEncryptionBoxGetInfo = KwStruct.new(:info)
|
229
|
+
|
230
|
+
ParamsOfEncryptionBoxEncrypt = KwStruct.new(:encryption_box, :data)
|
231
|
+
|
223
232
|
RegisteredEncryptionBox = KwStruct.new(:handle)
|
233
|
+
|
234
|
+
ResultOfEncryptionBoxEncrypt = KwStruct.new(:data)
|
235
|
+
|
236
|
+
ParamsOfEncryptionBoxDecrypt = KwStruct.new(:encryption_box, :data)
|
237
|
+
|
238
|
+
ResultOfEncryptionBoxDecrypt = KwStruct.new(:data)
|
239
|
+
|
224
240
|
ParamsOfCreateEncryptionBox = KwStruct.new(:algorithm)
|
225
241
|
|
242
|
+
class CryptoBoxSecret
|
243
|
+
TYPES = %i[random_seed_phrase predefined_seed_phrase encrypted_secret]
|
244
|
+
attr_reader :type, :args
|
245
|
+
|
246
|
+
def initialize(type:, **args)
|
247
|
+
unless TYPES.include?(type)
|
248
|
+
raise ArgumentError.new("type #{type} is unknown; known types: #{TYPES}")
|
249
|
+
end
|
250
|
+
@type = type
|
251
|
+
@args = args
|
252
|
+
end
|
253
|
+
|
254
|
+
def to_h
|
255
|
+
hash = case type
|
256
|
+
when :random_seed_phrase
|
257
|
+
{
|
258
|
+
dictionary: args[:dictionary],
|
259
|
+
wordcount: args[:wordcount]
|
260
|
+
}
|
261
|
+
when :predefined_seed_phrase
|
262
|
+
{
|
263
|
+
phrase: args[:phrase],
|
264
|
+
dictionary: args[:dictionary],
|
265
|
+
wordcount: args[:wordcount]
|
266
|
+
}
|
267
|
+
when :encrypted_secret
|
268
|
+
{
|
269
|
+
encrypted_secret: args[:encrypted_secret]
|
270
|
+
}
|
271
|
+
end
|
272
|
+
{
|
273
|
+
type: Helper.sym_to_capitalized_case_str(type)
|
274
|
+
}.merge(hash)
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
class BoxEncryptionAlgorithm
|
279
|
+
TYPES = %i[cha_cha20 nacl_box nacl_secret_box]
|
280
|
+
attr_reader :type, :args
|
281
|
+
|
282
|
+
def initialize(type:, **args)
|
283
|
+
unless TYPES.include?(type)
|
284
|
+
raise ArgumentError.new("type #{type} is unknown; known types: #{TYPES}")
|
285
|
+
end
|
286
|
+
@type = type
|
287
|
+
@args = args
|
288
|
+
end
|
289
|
+
|
290
|
+
def to_h
|
291
|
+
hash = case type
|
292
|
+
when :cha_cha20
|
293
|
+
{
|
294
|
+
nonce: args[:nonce]
|
295
|
+
}
|
296
|
+
when :nacl_box
|
297
|
+
{
|
298
|
+
their_public: args[:their_public],
|
299
|
+
nonce: args[:nonce]
|
300
|
+
}
|
301
|
+
when :nacl_secret_box
|
302
|
+
{
|
303
|
+
nonce: args[:nonce]
|
304
|
+
}
|
305
|
+
end
|
306
|
+
{
|
307
|
+
type: Helper.sym_to_capitalized_case_str(type)
|
308
|
+
}.merge(hash)
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
class ParamsOfAppEncryptionBox
|
313
|
+
TYPES = %i[get_info encrypt decrypt]
|
314
|
+
attr_reader :type, :args
|
315
|
+
|
316
|
+
def initialize(type:, **args)
|
317
|
+
unless TYPES.include?(type)
|
318
|
+
raise ArgumentError.new("type #{type} is unknown; known types: #{TYPES}")
|
319
|
+
end
|
320
|
+
@type = type
|
321
|
+
@args = args
|
322
|
+
end
|
323
|
+
|
324
|
+
def to_h
|
325
|
+
hash = case type
|
326
|
+
when :get_info
|
327
|
+
{}
|
328
|
+
when :encrypt, :decrypt
|
329
|
+
{
|
330
|
+
data: args[:data]
|
331
|
+
}
|
332
|
+
end
|
333
|
+
{
|
334
|
+
type: Helper.sym_to_capitalized_case_str(type)
|
335
|
+
}.merge(hash)
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
ParamsOfCreateCryptoBox = KwStruct.new(:secret_encryption_salt, :secret)
|
340
|
+
|
341
|
+
RegisteredCryptoBox = KwStruct.new(:handle)
|
342
|
+
|
343
|
+
ParamsOfAppPasswordProvider = KwStruct.new(:encryption_public_key) do
|
344
|
+
attr_reader :type, :encryption_public_key
|
345
|
+
|
346
|
+
def initialize(encryption_public_key:)
|
347
|
+
@type = "GetPassword"
|
348
|
+
@encryption_public_key = encryption_public_key
|
349
|
+
end
|
350
|
+
|
351
|
+
def to_h
|
352
|
+
{
|
353
|
+
type: type,
|
354
|
+
encryption_public_key: encryption_public_key
|
355
|
+
}
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
ResultOfAppPasswordProvider = KwStruct.new(:type, :encrypted_password, :app_encryption_pubkey)
|
360
|
+
|
361
|
+
ResultOfGetCryptoBoxInfo = KwStruct.new(:encrypted_secret)
|
362
|
+
|
363
|
+
ResultOfGetCryptoBoxSeedPhrase = KwStruct.new(:phrase, :dictionary, :wordcount)
|
364
|
+
|
365
|
+
ParamsOfGetSigningBoxFromCryptoBox = KwStruct.new(:handle, :hdpath, :secret_lifetime)
|
366
|
+
|
367
|
+
ParamsOfGetEncryptionBoxFromCryptoBox = KwStruct.new(:handle, :hdpath, :algorithm, :secret_lifetime)
|
368
|
+
|
226
369
|
class EncryptionAlgorithm
|
227
370
|
private_class_method :new
|
228
371
|
|
@@ -234,8 +377,6 @@ module TonSdk
|
|
234
377
|
end
|
235
378
|
end
|
236
379
|
|
237
|
-
|
238
|
-
|
239
380
|
#
|
240
381
|
# functions
|
241
382
|
#
|
@@ -654,34 +795,13 @@ module TonSdk
|
|
654
795
|
end
|
655
796
|
end
|
656
797
|
|
657
|
-
def self.register_signing_box(ctx,
|
658
|
-
client_callback = Proc.new do |type_, x|
|
659
|
-
app_res = app_obj.request(x["request_data"])
|
660
|
-
app_req_result = case app_res
|
661
|
-
in [:success, result]
|
662
|
-
TonSdk::Client::AppRequestResult.new(
|
663
|
-
type_: :ok,
|
664
|
-
result: result
|
665
|
-
)
|
666
|
-
in [:error, text]
|
667
|
-
TonSdk::Client::AppRequestResult.new(
|
668
|
-
type_: :error,
|
669
|
-
text: text
|
670
|
-
)
|
671
|
-
end
|
672
|
-
|
673
|
-
params = TonSdk::Client::ParamsOfResolveAppRequest.new(
|
674
|
-
app_request_id: x["app_request_id"],
|
675
|
-
result: app_req_result
|
676
|
-
)
|
677
|
-
TonSdk::Client.resolve_app_request(ctx, params)
|
678
|
-
end
|
679
|
-
|
798
|
+
def self.register_signing_box(ctx, callback:)
|
680
799
|
Interop::request_to_native_lib(
|
681
800
|
ctx,
|
682
801
|
"crypto.register_signing_box",
|
683
802
|
nil,
|
684
|
-
|
803
|
+
client_callback: callback,
|
804
|
+
is_single_thread_only: false
|
685
805
|
) do |resp|
|
686
806
|
if resp.success?
|
687
807
|
yield NativeLibResponseResult.new(
|
@@ -746,34 +866,12 @@ module TonSdk
|
|
746
866
|
end
|
747
867
|
end
|
748
868
|
|
749
|
-
def self.register_encryption_box(ctx,
|
750
|
-
client_callback = Proc.new do |type_, x|
|
751
|
-
app_res = app_obj.request(x["request_data"])
|
752
|
-
app_req_result = case app_res
|
753
|
-
in [:success, result]
|
754
|
-
TonSdk::Client::AppRequestResult.new(
|
755
|
-
type_: :ok,
|
756
|
-
result: result
|
757
|
-
)
|
758
|
-
in [:error, text]
|
759
|
-
TonSdk::Client::AppRequestResult.new(
|
760
|
-
type_: :error,
|
761
|
-
text: text
|
762
|
-
)
|
763
|
-
end
|
764
|
-
|
765
|
-
params = TonSdk::Client::ParamsOfResolveAppRequest.new(
|
766
|
-
app_request_id: x["app_request_id"],
|
767
|
-
result: app_req_result
|
768
|
-
)
|
769
|
-
TonSdk::Client.resolve_app_request(ctx, params)
|
770
|
-
end
|
771
|
-
|
869
|
+
def self.register_encryption_box(ctx, callback:)
|
772
870
|
Interop::request_to_native_lib(
|
773
871
|
ctx,
|
774
872
|
"crypto.register_encryption_box",
|
775
873
|
nil,
|
776
|
-
client_callback:
|
874
|
+
client_callback: callback,
|
777
875
|
is_single_thread_only: false
|
778
876
|
) do |resp|
|
779
877
|
if resp.success?
|
@@ -786,6 +884,18 @@ module TonSdk
|
|
786
884
|
end
|
787
885
|
end
|
788
886
|
|
887
|
+
def self.remove_encryption_box(ctx, params)
|
888
|
+
Interop::request_to_native_lib(ctx, "crypto.remove_encryption_box", params) do |resp|
|
889
|
+
if resp.success?
|
890
|
+
yield NativeLibResponseResult.new(
|
891
|
+
result: nil
|
892
|
+
)
|
893
|
+
else
|
894
|
+
yield resp
|
895
|
+
end
|
896
|
+
end
|
897
|
+
end
|
898
|
+
|
789
899
|
def self.encryption_box_get_info(ctx, params)
|
790
900
|
Interop::request_to_native_lib(ctx, "crypto.encryption_box_get_info", params) do |resp|
|
791
901
|
if resp.success?
|
@@ -798,6 +908,30 @@ module TonSdk
|
|
798
908
|
end
|
799
909
|
end
|
800
910
|
|
911
|
+
def self.encryption_box_encrypt(ctx, params)
|
912
|
+
Interop::request_to_native_lib(ctx, "crypto.encryption_box_encrypt", params) do |resp|
|
913
|
+
if resp.success?
|
914
|
+
yield NativeLibResponseResult.new(
|
915
|
+
result: ResultOfEncryptionBoxEncrypt.new(data: resp.result["data"])
|
916
|
+
)
|
917
|
+
else
|
918
|
+
yield resp
|
919
|
+
end
|
920
|
+
end
|
921
|
+
end
|
922
|
+
|
923
|
+
def self.encryption_box_decrypt(ctx, params)
|
924
|
+
Interop::request_to_native_lib(ctx, "crypto.encryption_box_decrypt", params) do |resp|
|
925
|
+
if resp.success?
|
926
|
+
yield NativeLibResponseResult.new(
|
927
|
+
result: ResultOfEncryptionBoxDecrypt.new(data: resp.result["data"])
|
928
|
+
)
|
929
|
+
else
|
930
|
+
yield resp
|
931
|
+
end
|
932
|
+
end
|
933
|
+
end
|
934
|
+
|
801
935
|
def self.create_encryption_box(ctx, params)
|
802
936
|
Interop::request_to_native_lib(ctx, "crypto.create_encryption_box", params) do |resp|
|
803
937
|
if resp.success?
|
@@ -809,5 +943,105 @@ module TonSdk
|
|
809
943
|
end
|
810
944
|
end
|
811
945
|
end
|
946
|
+
|
947
|
+
def self.create_crypto_box(ctx, params, callback:)
|
948
|
+
Interop::request_to_native_lib(
|
949
|
+
ctx,
|
950
|
+
"crypto.create_crypto_box",
|
951
|
+
params,
|
952
|
+
client_callback: callback,
|
953
|
+
is_single_thread_only: false
|
954
|
+
) do |resp|
|
955
|
+
if resp.success?
|
956
|
+
yield NativeLibResponseResult.new(
|
957
|
+
result: RegisteredCryptoBox.new(handle: resp.result["handle"])
|
958
|
+
)
|
959
|
+
else
|
960
|
+
yield resp
|
961
|
+
end
|
962
|
+
end
|
963
|
+
end
|
964
|
+
|
965
|
+
def self.remove_crypto_box(ctx, params)
|
966
|
+
Interop::request_to_native_lib(ctx, "crypto.remove_crypto_box", params) do |resp|
|
967
|
+
if resp.success?
|
968
|
+
yield NativeLibResponseResult.new(
|
969
|
+
result: nil
|
970
|
+
)
|
971
|
+
else
|
972
|
+
yield resp
|
973
|
+
end
|
974
|
+
end
|
975
|
+
end
|
976
|
+
|
977
|
+
def self.get_crypto_box_info(ctx, params)
|
978
|
+
Interop::request_to_native_lib(ctx, "crypto.get_crypto_box_info", params) do |resp|
|
979
|
+
if resp.success?
|
980
|
+
yield NativeLibResponseResult.new(
|
981
|
+
result: ResultOfGetCryptoBoxInfo.new(
|
982
|
+
encrypted_secret: resp.result["encrypted_secret"]
|
983
|
+
)
|
984
|
+
)
|
985
|
+
else
|
986
|
+
yield resp
|
987
|
+
end
|
988
|
+
end
|
989
|
+
end
|
990
|
+
|
991
|
+
def self.get_crypto_box_seed_phrase(ctx, params)
|
992
|
+
Interop::request_to_native_lib(ctx, "crypto.get_crypto_box_seed_phrase", params) do |resp|
|
993
|
+
if resp.success?
|
994
|
+
yield NativeLibResponseResult.new(
|
995
|
+
result: ResultOfGetCryptoBoxSeedPhrase.new(
|
996
|
+
phrase: resp.result["phrase"],
|
997
|
+
dictionary: resp.result["dictionary"],
|
998
|
+
wordcount: resp.result["wordcount"]
|
999
|
+
)
|
1000
|
+
)
|
1001
|
+
else
|
1002
|
+
yield resp
|
1003
|
+
end
|
1004
|
+
end
|
1005
|
+
end
|
1006
|
+
|
1007
|
+
def self.get_signing_box_from_crypto_box(ctx, params)
|
1008
|
+
Interop::request_to_native_lib(ctx, "crypto.get_signing_box_from_crypto_box", params) do |resp|
|
1009
|
+
if resp.success?
|
1010
|
+
yield NativeLibResponseResult.new(
|
1011
|
+
result: RegisteredSigningBox.new(handle: resp.result["handle"])
|
1012
|
+
)
|
1013
|
+
else
|
1014
|
+
yield resp
|
1015
|
+
end
|
1016
|
+
end
|
1017
|
+
end
|
1018
|
+
|
1019
|
+
def self.get_encryption_box_from_crypto_box(ctx, params)
|
1020
|
+
Interop::request_to_native_lib(ctx, "crypto.get_encryption_box_from_crypto_box", params) do |resp|
|
1021
|
+
if resp.success?
|
1022
|
+
yield NativeLibResponseResult.new(
|
1023
|
+
result: RegisteredEncryptionBox.new(handle: resp.result["handle"])
|
1024
|
+
)
|
1025
|
+
else
|
1026
|
+
yield resp
|
1027
|
+
end
|
1028
|
+
end
|
1029
|
+
end
|
1030
|
+
|
1031
|
+
def self.clear_crypto_box_secret_cache(ctx, params)
|
1032
|
+
Interop::request_to_native_lib(
|
1033
|
+
ctx,
|
1034
|
+
"crypto.clear_crypto_box_secret_cache",
|
1035
|
+
params
|
1036
|
+
) do |resp|
|
1037
|
+
if resp.success?
|
1038
|
+
yield NativeLibResponseResult.new(
|
1039
|
+
result: nil
|
1040
|
+
)
|
1041
|
+
else
|
1042
|
+
yield resp
|
1043
|
+
end
|
1044
|
+
end
|
1045
|
+
end
|
812
1046
|
end
|
813
1047
|
end
|
data/lib/ton_sdk_client/net.rb
CHANGED
@@ -74,7 +74,10 @@ module TonSdk
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
+
ParamsOfSubscribe = KwStruct.new(:subscription, :variables)
|
78
|
+
|
77
79
|
ResultOfSubscribeCollection = KwStruct.new(:handle)
|
80
|
+
|
78
81
|
ParamsOfQuery = KwStruct.new(:query, :variables) do
|
79
82
|
def initialize(query:, variables: nil)
|
80
83
|
super
|
@@ -317,6 +320,24 @@ module TonSdk
|
|
317
320
|
end
|
318
321
|
end
|
319
322
|
|
323
|
+
def self.subscribe(ctx, params, client_callback: nil)
|
324
|
+
Interop::request_to_native_lib(
|
325
|
+
ctx,
|
326
|
+
"net.subscribe",
|
327
|
+
params,
|
328
|
+
client_callback: client_callback,
|
329
|
+
is_single_thread_only: false
|
330
|
+
) do |resp|
|
331
|
+
if resp.success?
|
332
|
+
yield NativeLibResponseResult.new(
|
333
|
+
result: ResultOfSubscribeCollection.new(handle: resp.result["handle"])
|
334
|
+
)
|
335
|
+
else
|
336
|
+
yield resp
|
337
|
+
end
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
320
341
|
def self.query(ctx, params)
|
321
342
|
Interop::request_to_native_lib(ctx, "net.query", params) do |resp|
|
322
343
|
if resp.success?
|
@@ -526,6 +547,5 @@ module TonSdk
|
|
526
547
|
end
|
527
548
|
end
|
528
549
|
end
|
529
|
-
|
530
550
|
end
|
531
551
|
end
|
@@ -1,10 +1,28 @@
|
|
1
1
|
module TonSdk
|
2
2
|
module Processing
|
3
|
-
|
4
3
|
#
|
5
4
|
# types
|
6
5
|
#
|
7
6
|
|
7
|
+
module ErrorCode
|
8
|
+
MESSAGE_ALREADY_EXPIRED = 501
|
9
|
+
MESSAGE_HAS_NOT_DESTINATION_ADDRESS = 502
|
10
|
+
CAN_NOT_BUILD_MESSAGE_CELL = 503
|
11
|
+
FETCH_BLOCK_FAILED = 504
|
12
|
+
SEND_MESSAGE_FAILED = 505
|
13
|
+
INVALID_MESSAGE_BOC = 506
|
14
|
+
MESSAGE_EXPIRED = 507
|
15
|
+
TRANSACTION_WAIT_TIMEOUT = 508
|
16
|
+
INVALID_BLOCK_RECEIVED = 509
|
17
|
+
CAN_NOT_CHECK_BLOCK_SHARD = 510
|
18
|
+
BLOCK_NOT_FOUND = 511
|
19
|
+
INVALID_DATA = 512
|
20
|
+
EXTERNAL_SIGNER_MUST_NOT_BE_USED = 513
|
21
|
+
MESSAGE_REJECTED = 514
|
22
|
+
INVALID_REMP_STATUS = 515
|
23
|
+
NEXT_REMP_STATUS_TIMEOUT = 516
|
24
|
+
end
|
25
|
+
|
8
26
|
class ParamsOfSendMessage
|
9
27
|
attr_reader :message, :abi, :send_events
|
10
28
|
|
@@ -66,20 +84,25 @@ module TonSdk
|
|
66
84
|
end
|
67
85
|
|
68
86
|
class ProcessingEvent
|
69
|
-
TYPES = [
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
87
|
+
TYPES = %i[
|
88
|
+
will_fetch_first_block
|
89
|
+
fetch_first_block_failed
|
90
|
+
will_send
|
91
|
+
did_send
|
92
|
+
send_failed
|
93
|
+
will_fetch_next_block
|
94
|
+
fetch_next_block_failed
|
95
|
+
message_expired
|
96
|
+
remp_sent_to_validators
|
97
|
+
remp_included_into_block
|
98
|
+
remp_included_into_accepted_block
|
99
|
+
remp_other
|
100
|
+
remp_error
|
78
101
|
]
|
79
102
|
|
80
|
-
attr_reader :type_, :error, :shard_block_id, :message_id, :message
|
103
|
+
attr_reader :type_, :error, :shard_block_id, :message_id, :message, :args
|
81
104
|
|
82
|
-
def initialize(type_:, error: nil, shard_block_id: nil, message_id: nil, message: nil)
|
105
|
+
def initialize(type_:, error: nil, shard_block_id: nil, message_id: nil, message: nil, **args)
|
83
106
|
unless TYPES.include?(type_)
|
84
107
|
raise ArgumentError.new("type #{type_} is unknown; known types: #{TYPES}")
|
85
108
|
end
|
@@ -88,6 +111,7 @@ module TonSdk
|
|
88
111
|
@shard_block_id = shard_block_id
|
89
112
|
@message_id = message_id
|
90
113
|
@message = message
|
114
|
+
@args = args
|
91
115
|
end
|
92
116
|
|
93
117
|
def to_h
|
@@ -96,34 +120,40 @@ module TonSdk
|
|
96
120
|
}
|
97
121
|
|
98
122
|
h2 = case @type_
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
123
|
+
when :will_fetch_first_block
|
124
|
+
{ }
|
125
|
+
when :fetch_first_block_failed
|
126
|
+
{
|
127
|
+
error: @error
|
128
|
+
}
|
129
|
+
when :will_send, :did_send, :will_fetch_next_block
|
130
|
+
{
|
131
|
+
shard_block_id: @shard_block_id,
|
132
|
+
message_id: @message_id,
|
133
|
+
message: @message
|
134
|
+
}
|
135
|
+
when :send_failed, :fetch_next_block_failed
|
136
|
+
{
|
137
|
+
shard_block_id: @shard_block_id,
|
138
|
+
message_id: @message_id,
|
139
|
+
message: @message,
|
140
|
+
error: @error
|
141
|
+
}
|
142
|
+
when :message_expired
|
143
|
+
{
|
144
|
+
message_id: @message_id,
|
145
|
+
message: @message,
|
146
|
+
error: @error
|
147
|
+
}
|
148
|
+
when :remp_sent_to_validators, :remp_included_into_block, :remp_included_into_accepted_block, :remp_other, :remp_error
|
149
|
+
{
|
150
|
+
message_id: message_id,
|
151
|
+
timestamp: args[:timestamp],
|
152
|
+
json: args[:json]
|
153
|
+
}
|
154
|
+
else
|
155
|
+
raise ArgumentError.new("unsupported type: #{@type_}")
|
156
|
+
end
|
127
157
|
|
128
158
|
h1.merge(h2)
|
129
159
|
end
|
data/lib/ton_sdk_client/tvm.rb
CHANGED
@@ -162,7 +162,10 @@ module TonSdk
|
|
162
162
|
:gas_fee,
|
163
163
|
:out_msgs_fwd_fee,
|
164
164
|
:total_account_fees,
|
165
|
-
:total_output
|
165
|
+
:total_output,
|
166
|
+
:ext_in_msg_fee,
|
167
|
+
:total_fwd_fees,
|
168
|
+
:account_fees
|
166
169
|
) do
|
167
170
|
def initialize(
|
168
171
|
in_msg_fwd_fee:,
|
@@ -170,7 +173,10 @@ module TonSdk
|
|
170
173
|
gas_fee:,
|
171
174
|
out_msgs_fwd_fee:,
|
172
175
|
total_account_fees:,
|
173
|
-
total_output
|
176
|
+
total_output:,
|
177
|
+
ext_in_msg_fee:,
|
178
|
+
total_fwd_fees:,
|
179
|
+
account_fees:
|
174
180
|
)
|
175
181
|
super
|
176
182
|
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.34.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: 2022-
|
11
|
+
date: 2022-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|