ton_sdk_client 1.13.0 → 1.18.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 +9 -53
- data/README.md +1 -1
- data/lib/ton_sdk_client/abi.rb +114 -294
- data/lib/ton_sdk_client/boc.rb +24 -74
- data/lib/ton_sdk_client/client.rb +2 -2
- data/lib/ton_sdk_client/client_context.rb +2 -0
- data/lib/ton_sdk_client/config.rb +48 -101
- data/lib/ton_sdk_client/crypto.rb +138 -436
- data/lib/ton_sdk_client/debot.rb +117 -54
- data/lib/ton_sdk_client/interop.rb +2 -2
- data/lib/ton_sdk_client/net.rb +249 -135
- data/lib/ton_sdk_client/processing.rb +6 -22
- data/lib/ton_sdk_client/tvm.rb +58 -94
- data/lib/ton_sdk_client/utils.rb +12 -32
- data/lib/ton_sdk_client/version.rb +2 -2
- metadata +2 -2
data/lib/ton_sdk_client/boc.rb
CHANGED
|
@@ -5,64 +5,31 @@ module TonSdk
|
|
|
5
5
|
# types
|
|
6
6
|
#
|
|
7
7
|
|
|
8
|
-
ParamsOfParse = Struct.new(:boc)
|
|
9
|
-
def to_h = { boc: @boc }
|
|
10
|
-
end
|
|
11
|
-
|
|
8
|
+
ParamsOfParse = Struct.new(:boc)
|
|
12
9
|
ResultOfParse = Struct.new(:parsed)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def to_h
|
|
16
|
-
{
|
|
17
|
-
boc: @boc,
|
|
18
|
-
id: @id_,
|
|
19
|
-
workchain_id: @workchain_id
|
|
20
|
-
}
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
ParamsOfGetBlockchainConfig = Struct.new(:block_boc) do
|
|
25
|
-
def to_h = { block_boc: @block_boc }
|
|
26
|
-
end
|
|
27
|
-
|
|
10
|
+
ParamsOfParseShardstate = Struct.new(:boc, :id_, :workchain_id, keyword_init: true)
|
|
11
|
+
ParamsOfGetBlockchainConfig = Struct.new(:block_boc)
|
|
28
12
|
ResultOfGetBlockchainConfig = Struct.new(:config_boc)
|
|
29
13
|
|
|
30
|
-
ParamsOfGetBocHash = Struct.new(:boc)
|
|
31
|
-
def to_h
|
|
32
|
-
{
|
|
33
|
-
boc: @boc
|
|
34
|
-
}
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
14
|
+
ParamsOfGetBocHash = Struct.new(:boc)
|
|
38
15
|
ResultOfGetBocHash = Struct.new(:hash)
|
|
39
|
-
|
|
40
|
-
ParamsOfGetCodeFromTvc = Struct.new(:hash) do
|
|
41
|
-
def to_h = { tvc: @tvc }
|
|
42
|
-
end
|
|
43
|
-
|
|
16
|
+
ParamsOfGetCodeFromTvc = Struct.new(:hash)
|
|
44
17
|
ResultOfGetCodeFromTvc = Struct.new(:code)
|
|
45
|
-
|
|
46
|
-
ParamsOfBocCacheGet = Struct.new(:boc_ref) do
|
|
47
|
-
def to_h = { boc_ref: @boc_ref }
|
|
48
|
-
end
|
|
18
|
+
ParamsOfBocCacheGet = Struct.new(:boc_ref)
|
|
49
19
|
|
|
50
20
|
ResultOfBocCacheGet = Struct.new(:boc)
|
|
51
21
|
|
|
52
22
|
class BocCacheType
|
|
53
|
-
|
|
54
|
-
:pinned,
|
|
55
|
-
:unpinned
|
|
56
|
-
]
|
|
23
|
+
private_class_method :new
|
|
57
24
|
|
|
58
25
|
attr_reader :type_, :pin
|
|
59
26
|
|
|
60
|
-
def new_with_type_pinned(pin)
|
|
27
|
+
def self.new_with_type_pinned(pin)
|
|
61
28
|
@type_ = :pinned
|
|
62
29
|
@pin = pin
|
|
63
30
|
end
|
|
64
31
|
|
|
65
|
-
def new_with_type_unpinned
|
|
32
|
+
def self.new_with_type_unpinned
|
|
66
33
|
@type_ = :unpinned
|
|
67
34
|
end
|
|
68
35
|
|
|
@@ -93,25 +60,8 @@ module TonSdk
|
|
|
93
60
|
end
|
|
94
61
|
|
|
95
62
|
ResultOfBocCacheSet = Struct.new(:boc_ref)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def to_h
|
|
99
|
-
{
|
|
100
|
-
boc: @boc,
|
|
101
|
-
boc_ref: @boc_ref
|
|
102
|
-
}
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
ParamsOfEncodeBoc = Struct.new(:builder, :boc_cache) do
|
|
107
|
-
def to_h
|
|
108
|
-
{
|
|
109
|
-
boc: @boc,
|
|
110
|
-
boc_ref: @boc_ref
|
|
111
|
-
}
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
63
|
+
ParamsOfBocCacheUnpin = Struct.new(:boc, :boc_ref)
|
|
64
|
+
ParamsOfEncodeBoc = Struct.new(:builder, :boc_cache)
|
|
115
65
|
ResultOfEncodeBoc = Struct.new(:boc)
|
|
116
66
|
|
|
117
67
|
|
|
@@ -121,7 +71,7 @@ module TonSdk
|
|
|
121
71
|
#
|
|
122
72
|
|
|
123
73
|
def self.parse_message(ctx, params)
|
|
124
|
-
Interop::request_to_native_lib(ctx, "boc.parse_message", params
|
|
74
|
+
Interop::request_to_native_lib(ctx, "boc.parse_message", params) do |resp|
|
|
125
75
|
if resp.success?
|
|
126
76
|
yield NativeLibResponsetResult.new(
|
|
127
77
|
result: ResultOfParse.new(resp.result["parsed"])
|
|
@@ -133,7 +83,7 @@ module TonSdk
|
|
|
133
83
|
end
|
|
134
84
|
|
|
135
85
|
def self.parse_transaction(ctx, params)
|
|
136
|
-
Interop::request_to_native_lib(ctx, "boc.parse_transaction", params
|
|
86
|
+
Interop::request_to_native_lib(ctx, "boc.parse_transaction", params) do |resp|
|
|
137
87
|
if resp.success?
|
|
138
88
|
yield NativeLibResponsetResult.new(
|
|
139
89
|
result: ResultOfParse.new(resp.result["parsed"])
|
|
@@ -145,7 +95,7 @@ module TonSdk
|
|
|
145
95
|
end
|
|
146
96
|
|
|
147
97
|
def self.parse_account(ctx, params)
|
|
148
|
-
Interop::request_to_native_lib(ctx, "boc.parse_account", params
|
|
98
|
+
Interop::request_to_native_lib(ctx, "boc.parse_account", params) do |resp|
|
|
149
99
|
if resp.success?
|
|
150
100
|
yield NativeLibResponsetResult.new(
|
|
151
101
|
result: ResultOfParse.new(resp.result["parsed"])
|
|
@@ -157,7 +107,7 @@ module TonSdk
|
|
|
157
107
|
end
|
|
158
108
|
|
|
159
109
|
def self.parse_block(ctx, params)
|
|
160
|
-
Interop::request_to_native_lib(ctx, "boc.parse_block", params
|
|
110
|
+
Interop::request_to_native_lib(ctx, "boc.parse_block", params) do |resp|
|
|
161
111
|
if resp.success?
|
|
162
112
|
yield NativeLibResponsetResult.new(
|
|
163
113
|
result: ResultOfParse.new(resp.result["parsed"])
|
|
@@ -169,7 +119,7 @@ module TonSdk
|
|
|
169
119
|
end
|
|
170
120
|
|
|
171
121
|
def self.parse_shardstate(ctx, params)
|
|
172
|
-
Interop::request_to_native_lib(ctx, "boc.parse_shardstate", params
|
|
122
|
+
Interop::request_to_native_lib(ctx, "boc.parse_shardstate", params) do |resp|
|
|
173
123
|
if resp.success?
|
|
174
124
|
yield NativeLibResponsetResult.new(
|
|
175
125
|
result: ResultOfParse.new(resp.result["parsed"])
|
|
@@ -181,7 +131,7 @@ module TonSdk
|
|
|
181
131
|
end
|
|
182
132
|
|
|
183
133
|
def self.get_blockchain_config(ctx, params)
|
|
184
|
-
Interop::request_to_native_lib(ctx, "boc.get_blockchain_config", params
|
|
134
|
+
Interop::request_to_native_lib(ctx, "boc.get_blockchain_config", params) do |resp|
|
|
185
135
|
if resp.success?
|
|
186
136
|
yield NativeLibResponsetResult.new(
|
|
187
137
|
result: ResultOfGetBlockchainConfig.new(resp.result["config_boc"])
|
|
@@ -193,7 +143,7 @@ module TonSdk
|
|
|
193
143
|
end
|
|
194
144
|
|
|
195
145
|
def self.get_boc_hash(ctx, params)
|
|
196
|
-
Interop::request_to_native_lib(ctx, "boc.get_boc_hash", params
|
|
146
|
+
Interop::request_to_native_lib(ctx, "boc.get_boc_hash", params) do |resp|
|
|
197
147
|
if resp.success?
|
|
198
148
|
yield NativeLibResponsetResult.new(
|
|
199
149
|
result: ResultOfGetBocHash.new(resp.result["hash"])
|
|
@@ -205,7 +155,7 @@ module TonSdk
|
|
|
205
155
|
end
|
|
206
156
|
|
|
207
157
|
def self.get_code_from_tvc(ctx, params)
|
|
208
|
-
Interop::request_to_native_lib(ctx, "boc.get_code_from_tvc", params
|
|
158
|
+
Interop::request_to_native_lib(ctx, "boc.get_code_from_tvc", params) do |resp|
|
|
209
159
|
if resp.success?
|
|
210
160
|
yield NativeLibResponsetResult.new(
|
|
211
161
|
result: ResultOfGetCodeFromTvc.new(resp.result["code"])
|
|
@@ -217,7 +167,7 @@ module TonSdk
|
|
|
217
167
|
end
|
|
218
168
|
|
|
219
169
|
def self.cache_get(ctx, params)
|
|
220
|
-
Interop::request_to_native_lib(ctx, "boc.cache_get", params
|
|
170
|
+
Interop::request_to_native_lib(ctx, "boc.cache_get", params) do |resp|
|
|
221
171
|
if resp.success?
|
|
222
172
|
yield NativeLibResponsetResult.new(
|
|
223
173
|
result: ResultOfBocCacheGet.new(
|
|
@@ -231,7 +181,7 @@ module TonSdk
|
|
|
231
181
|
end
|
|
232
182
|
|
|
233
183
|
def self.cache_set(ctx, params)
|
|
234
|
-
Interop::request_to_native_lib(ctx, "boc.cache_set", params
|
|
184
|
+
Interop::request_to_native_lib(ctx, "boc.cache_set", params) do |resp|
|
|
235
185
|
if resp.success?
|
|
236
186
|
yield NativeLibResponsetResult.new(
|
|
237
187
|
result: ResultOfBocCacheSet.new(
|
|
@@ -245,7 +195,7 @@ module TonSdk
|
|
|
245
195
|
end
|
|
246
196
|
|
|
247
197
|
def self.cache_unpin(ctx, params)
|
|
248
|
-
Interop::request_to_native_lib(ctx, "boc.cache_unpin", params
|
|
198
|
+
Interop::request_to_native_lib(ctx, "boc.cache_unpin", params) do |resp|
|
|
249
199
|
if resp.success?
|
|
250
200
|
yield NativeLibResponsetResult.new(
|
|
251
201
|
result: nil
|
|
@@ -257,7 +207,7 @@ module TonSdk
|
|
|
257
207
|
end
|
|
258
208
|
|
|
259
209
|
def self.encode_boc(ctx, params)
|
|
260
|
-
Interop::request_to_native_lib(ctx, "boc.encode_boc", params
|
|
210
|
+
Interop::request_to_native_lib(ctx, "boc.encode_boc", params) do |resp|
|
|
261
211
|
if resp.success?
|
|
262
212
|
yield NativeLibResponsetResult.new(
|
|
263
213
|
result: ResultOfEncodeBoc.new(
|
|
@@ -271,7 +221,7 @@ module TonSdk
|
|
|
271
221
|
end
|
|
272
222
|
|
|
273
223
|
def self.get_blockchain_config(ctx, params)
|
|
274
|
-
Interop::request_to_native_lib(ctx, "boc.get_blockchain_config", params
|
|
224
|
+
Interop::request_to_native_lib(ctx, "boc.get_blockchain_config", params) do |resp|
|
|
275
225
|
if resp.success?
|
|
276
226
|
yield NativeLibResponsetResult.new(
|
|
277
227
|
result: ResultOfGetBlockchainConfig.new(
|
|
@@ -42,10 +42,10 @@ module TonSdk
|
|
|
42
42
|
UNEXPECTED_CALLBACK_RESPONSE = 31
|
|
43
43
|
CANNOT_PARSE_NUMBER = 32
|
|
44
44
|
INTERNAL_ERROR = 33
|
|
45
|
+
INVALID_HANDLE = 34
|
|
45
46
|
end
|
|
46
47
|
|
|
47
48
|
ResultOfVersion = Struct.new(:version)
|
|
48
|
-
|
|
49
49
|
ResultOfGetApiReference = Struct.new(:api)
|
|
50
50
|
|
|
51
51
|
BuildInfoDependency = Struct.new(:name, :git_commit, keyword_init: true) do
|
|
@@ -153,7 +153,7 @@ module TonSdk
|
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
def self.resolve_app_request(ctx, params)
|
|
156
|
-
Interop::request_to_native_lib(ctx, "client.resolve_app_request", params
|
|
156
|
+
Interop::request_to_native_lib(ctx, "client.resolve_app_request", params) do |resp|
|
|
157
157
|
if resp.success?
|
|
158
158
|
yield NativeLibResponsetResult.new(
|
|
159
159
|
result: ""
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'json'
|
|
2
|
+
|
|
2
3
|
require_relative './interop.rb'
|
|
3
4
|
require_relative './types.rb'
|
|
4
5
|
require_relative './helper.rb'
|
|
@@ -14,6 +15,7 @@ require_relative './tvm.rb'
|
|
|
14
15
|
require_relative './processing.rb'
|
|
15
16
|
require_relative './debot.rb'
|
|
16
17
|
|
|
18
|
+
|
|
17
19
|
module TonSdk
|
|
18
20
|
class ClientContext
|
|
19
21
|
attr_reader :context
|
|
@@ -1,120 +1,67 @@
|
|
|
1
1
|
module TonSdk
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
class NetworkConfig
|
|
25
|
-
DEFAULT_NETWORK_RETRIES_COUNT = 5
|
|
26
|
-
DEFAULT_MAX_RECONNECT_TIMEOUT = 120000
|
|
27
|
-
DEFAULT_RECONNECT_TIMEOUT = 1000
|
|
28
|
-
DEFAULT_MESSAGE_RETRIES_COUNT = 5
|
|
29
|
-
|
|
30
|
-
DEFAULT_MESSAGE_PROCESSING_TIMEOUT = 40000
|
|
31
|
-
DEFAULT_WAIT_TIMEOUT = 40000
|
|
32
|
-
DEFAULT_OUT_OF_SYNC_THRESHOLD = 15000
|
|
33
|
-
DEFAULT_SENDING_ENDPOINT_COUNT = 2
|
|
34
|
-
|
|
35
|
-
attr_reader :server_address, :endpoints, :network_retries_count,
|
|
36
|
-
:message_retries_count, :message_processing_timeout,
|
|
37
|
-
:wait_for_timeout, :out_of_sync_threshold, :reconnect_timeout,
|
|
38
|
-
:max_reconnect_timeout,
|
|
39
|
-
:sending_endpoint_count,
|
|
40
|
-
:access_key
|
|
41
|
-
|
|
2
|
+
CryptoConfig = Struct.new(:mnemonic_dictionary, :mnemonic_word_count, :hdkey_derivation_path, keyword_init: true)
|
|
3
|
+
BocConfig = Struct.new(:cache_max_size)
|
|
4
|
+
NetworkConfig = Struct.new(
|
|
5
|
+
:server_address,
|
|
6
|
+
:endpoints,
|
|
7
|
+
:network_retries_count,
|
|
8
|
+
:message_retries_count,
|
|
9
|
+
:message_processing_timeout,
|
|
10
|
+
:wait_for_timeout,
|
|
11
|
+
:out_of_sync_threshold,
|
|
12
|
+
:reconnect_timeout,
|
|
13
|
+
:max_reconnect_timeout,
|
|
14
|
+
:sending_endpoint_count,
|
|
15
|
+
:latency_detection_interval,
|
|
16
|
+
:max_latency,
|
|
17
|
+
:access_key,
|
|
18
|
+
keyword_init: true
|
|
19
|
+
) do
|
|
42
20
|
def initialize(
|
|
43
21
|
server_address: "",
|
|
44
22
|
endpoints: [],
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
23
|
+
network_retries_count: 5,
|
|
24
|
+
max_reconnect_timeout: 120000,
|
|
25
|
+
reconnect_timeout: 1000,
|
|
26
|
+
message_retries_count: 5,
|
|
27
|
+
message_processing_timeout: 40000,
|
|
28
|
+
wait_for_timeout: 40000,
|
|
29
|
+
out_of_sync_threshold: 15000,
|
|
30
|
+
sending_endpoint_count: 2,
|
|
31
|
+
latency_detection_interval: 60000,
|
|
32
|
+
max_latency: 60000,
|
|
56
33
|
access_key: nil
|
|
57
34
|
)
|
|
58
|
-
|
|
59
|
-
@server_address = server_address
|
|
60
|
-
@endpoints = endpoints
|
|
61
|
-
|
|
62
|
-
@network_retries_count = network_retries_count
|
|
63
|
-
@max_reconnect_timeout = max_reconnect_timeout
|
|
64
|
-
@reconnect_timeout = reconnect_timeout
|
|
65
|
-
@message_retries_count = message_retries_count
|
|
66
|
-
|
|
67
|
-
@message_processing_timeout = message_processing_timeout
|
|
68
|
-
@wait_for_timeout = wait_for_timeout
|
|
69
|
-
@out_of_sync_threshold = out_of_sync_threshold
|
|
70
|
-
@sending_endpoint_count = sending_endpoint_count
|
|
71
|
-
|
|
72
|
-
@access_key = access_key
|
|
35
|
+
super
|
|
73
36
|
end
|
|
74
|
-
|
|
75
|
-
def to_h
|
|
76
|
-
{
|
|
77
|
-
server_address: @server_address,
|
|
78
|
-
endpoints: @endpoints,
|
|
79
|
-
|
|
80
|
-
network_retries_count: @network_retries_count,
|
|
81
|
-
max_reconnect_timeout: @max_reconnect_timeout,
|
|
82
|
-
reconnect_timeout: @reconnect_timeout,
|
|
83
|
-
message_retries_count: @message_retries_count,
|
|
84
|
-
|
|
85
|
-
message_processing_timeout: @message_processing_timeout,
|
|
86
|
-
wait_for_timeout: @wait_for_timeout,
|
|
87
|
-
out_of_sync_threshold: @out_of_sync_threshold,
|
|
88
|
-
sending_endpoint_count: @sending_endpoint_count,
|
|
89
|
-
|
|
90
|
-
access_key: @access_key
|
|
91
|
-
}
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
CryptoConfig = Struct.new(:fish_param) do
|
|
96
|
-
def to_h = { fish_param: @fish_param }
|
|
97
37
|
end
|
|
98
38
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
39
|
+
AbiConfig = Struct.new(
|
|
40
|
+
:workchain,
|
|
41
|
+
:message_expiration_timeout,
|
|
42
|
+
:message_expiration_timeout_grow_factor,
|
|
43
|
+
keyword_init: true
|
|
44
|
+
) do
|
|
105
45
|
def initialize(
|
|
106
|
-
|
|
107
|
-
|
|
46
|
+
workchain: nil,
|
|
47
|
+
message_expiration_timeout: 40000,
|
|
48
|
+
message_expiration_timeout_grow_factor: 1.5
|
|
108
49
|
)
|
|
109
|
-
|
|
110
|
-
@message_expiration_timeout_grow_factor = message_expiration_timeout_grow_factor
|
|
50
|
+
super
|
|
111
51
|
end
|
|
52
|
+
end
|
|
112
53
|
|
|
54
|
+
ClientConfig = Struct.new(:network, :crypto, :abi, :boc, keyword_init: true) do
|
|
113
55
|
def to_h
|
|
56
|
+
res = super.to_h
|
|
57
|
+
|
|
114
58
|
{
|
|
115
|
-
|
|
116
|
-
|
|
59
|
+
network: res[:network]&.to_h,
|
|
60
|
+
crypto: res[:crypto]&.to_h,
|
|
61
|
+
abi: res[:abi]&.to_h,
|
|
62
|
+
boc: res[:boc]&.to_h
|
|
117
63
|
}
|
|
118
64
|
end
|
|
119
65
|
end
|
|
66
|
+
|
|
120
67
|
end
|
|
@@ -27,255 +27,70 @@ module TonSdk
|
|
|
27
27
|
INVALID_SIGNATURE = 122
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
ParamsOfFactorize = Struct.new(:composite)
|
|
31
|
-
def to_h = { composite: @composite }
|
|
32
|
-
end
|
|
33
|
-
|
|
30
|
+
ParamsOfFactorize = Struct.new(:composite)
|
|
34
31
|
ResultOfFactorize = Struct.new(:factors)
|
|
35
|
-
|
|
36
|
-
ParamsOfModularPower = Struct.new(:base, :exponent, :modulus) do
|
|
37
|
-
def to_h
|
|
38
|
-
{
|
|
39
|
-
base: @base,
|
|
40
|
-
exponent: @exponent,
|
|
41
|
-
modulus: @modulus
|
|
42
|
-
}
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
32
|
+
ParamsOfModularPower = Struct.new(:base, :exponent, :modulus, keyword_init: true)
|
|
46
33
|
ResultOfModularPower = Struct.new(:modular_power)
|
|
47
|
-
|
|
48
|
-
ParamsOfTonCrc16 = Struct.new(:data) do
|
|
49
|
-
def to_h = { data: @data }
|
|
50
|
-
end
|
|
34
|
+
ParamsOfTonCrc16 = Struct.new(:data)
|
|
51
35
|
|
|
52
36
|
ResultOfTonCrc16 = Struct.new(:crc)
|
|
53
|
-
|
|
54
|
-
ParamsOfGenerateRandomBytes = Struct.new(:length) do
|
|
55
|
-
def to_h = { length: @length }
|
|
56
|
-
end
|
|
57
|
-
|
|
37
|
+
ParamsOfGenerateRandomBytes = Struct.new(:length)
|
|
58
38
|
ResultOfGenerateRandomBytes = Struct.new(:bytes)
|
|
59
|
-
|
|
60
|
-
ParamsOfConvertPublicKeyToTonSafeFormat = Struct.new(:public_key) do
|
|
61
|
-
def to_h = { public_key: @public_key }
|
|
62
|
-
end
|
|
63
|
-
|
|
39
|
+
ParamsOfConvertPublicKeyToTonSafeFormat = Struct.new(:public_key)
|
|
64
40
|
ResultOfConvertPublicKeyToTonSafeFormat = Struct.new(:ton_public_key)
|
|
65
41
|
|
|
66
|
-
KeyPair = Struct.new(:public_, :secret)
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
public: @public_,
|
|
70
|
-
secret: @secret
|
|
71
|
-
}
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
ParamsOfSign = Struct.new(:unsigned, :keys) do
|
|
76
|
-
def to_h
|
|
77
|
-
{
|
|
78
|
-
unsigned: @unsigned,
|
|
79
|
-
keys: @keys.to_h
|
|
80
|
-
}
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
42
|
+
KeyPair = Struct.new(:public_, :secret)
|
|
43
|
+
ParamsOfSign = Struct.new(:unsigned, :keys)
|
|
84
44
|
ResultOfSign = Struct.new(:signed, :signature)
|
|
85
|
-
|
|
86
|
-
ParamsOfVerifySignature = Struct.new(:signed, :public_) do
|
|
87
|
-
def to_h
|
|
88
|
-
{
|
|
89
|
-
signed: @signed,
|
|
90
|
-
public: @public_
|
|
91
|
-
}
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
45
|
+
ParamsOfVerifySignature = Struct.new(:signed, :public_)
|
|
95
46
|
ResultOfVerifySignature = Struct.new(:unsigned)
|
|
96
47
|
|
|
97
|
-
ParamsOfHash = Struct.new(:data)
|
|
98
|
-
def to_h = { data: @data }
|
|
99
|
-
end
|
|
100
|
-
|
|
48
|
+
ParamsOfHash = Struct.new(:data)
|
|
101
49
|
ResultOfHash = Struct.new(:hash)
|
|
102
|
-
|
|
103
|
-
ParamsOfScrypt = Struct.new(:password, :salt, :log_n, :r, :p_, :dk_len) do
|
|
104
|
-
def to_h
|
|
105
|
-
{
|
|
106
|
-
password: @password,
|
|
107
|
-
salt: @salt,
|
|
108
|
-
log_n: @log_n,
|
|
109
|
-
r: @r,
|
|
110
|
-
p: @p_,
|
|
111
|
-
dk_len: @dk_len
|
|
112
|
-
}
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
50
|
+
ParamsOfScrypt = Struct.new(:password, :salt, :log_n, :r, :p_, :dk_len, keyword_init: true)
|
|
116
51
|
ResultOfScrypt = Struct.new(:key)
|
|
52
|
+
ParamsOfNaclSignKeyPairFromSecret = Struct.new(:secret)
|
|
117
53
|
|
|
118
|
-
|
|
119
|
-
def to_h = { secret: @secret }
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
ParamsOfNaclSign = Struct.new(:unsigned, :secret) do
|
|
123
|
-
def to_h
|
|
124
|
-
{
|
|
125
|
-
unsigned: @unsigned,
|
|
126
|
-
secret: @secret
|
|
127
|
-
}
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
|
|
54
|
+
ParamsOfNaclSign = Struct.new(:unsigned, :secret)
|
|
131
55
|
ResultOfNaclSign = Struct.new(:signed)
|
|
132
|
-
|
|
133
|
-
class ParamsOfNaclSignOpen
|
|
134
|
-
attr_reader :signed, :public_
|
|
135
|
-
|
|
56
|
+
ParamsOfNaclSignOpen = Struct.new(:signed, :public_) do
|
|
136
57
|
def initialize(signed:, public_:)
|
|
137
|
-
|
|
138
|
-
@public_ = public_
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
def to_h
|
|
142
|
-
{
|
|
143
|
-
signed: @signed,
|
|
144
|
-
public: @public_
|
|
145
|
-
}
|
|
58
|
+
super
|
|
146
59
|
end
|
|
147
60
|
end
|
|
148
61
|
|
|
149
62
|
ResultOfNaclSignOpen = Struct.new(:unsigned)
|
|
150
|
-
|
|
151
63
|
ResultOfNaclSignDetached = Struct.new(:signature)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
attr_reader :secret
|
|
155
|
-
|
|
156
|
-
def initialize(a)
|
|
157
|
-
@secret = a
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
def to_h
|
|
161
|
-
{
|
|
162
|
-
secret: @secret
|
|
163
|
-
}
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
class ParamsOfNaclBox
|
|
168
|
-
attr_reader :decrypted, :nonce, :their_public, :secret
|
|
169
|
-
|
|
64
|
+
ParamsOfNaclBoxKeyPairFromSecret = Struct.new(:secret)
|
|
65
|
+
ParamsOfNaclBox = Struct.new(:decrypted, :nonce, :their_public, :secret) do
|
|
170
66
|
def initialize(decrypted:, nonce:, their_public:, secret:)
|
|
171
|
-
|
|
172
|
-
@nonce = nonce
|
|
173
|
-
@their_public = their_public
|
|
174
|
-
@secret = secret
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
def to_h
|
|
178
|
-
{
|
|
179
|
-
decrypted: @decrypted,
|
|
180
|
-
nonce: @nonce,
|
|
181
|
-
their_public: @their_public,
|
|
182
|
-
secret: @secret
|
|
183
|
-
}
|
|
67
|
+
super
|
|
184
68
|
end
|
|
185
69
|
end
|
|
186
70
|
|
|
187
71
|
ResultOfNaclBox = Struct.new(:encrypted)
|
|
188
|
-
|
|
189
|
-
class ParamsOfNaclBoxOpen
|
|
190
|
-
attr_reader :encrypted, :nonce, :their_public, :secret
|
|
191
|
-
|
|
72
|
+
ParamsOfNaclBoxOpen = Struct.new(:encrypted, :nonce, :their_public, :secret) do
|
|
192
73
|
def initialize(encrypted:, nonce:, their_public:, secret:)
|
|
193
|
-
|
|
194
|
-
@nonce = nonce
|
|
195
|
-
@their_public = their_public
|
|
196
|
-
@secret = secret
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
def to_h
|
|
200
|
-
{
|
|
201
|
-
encrypted: @encrypted,
|
|
202
|
-
nonce: @nonce,
|
|
203
|
-
their_public: @their_public,
|
|
204
|
-
secret: @secret
|
|
205
|
-
}
|
|
74
|
+
super
|
|
206
75
|
end
|
|
207
76
|
end
|
|
208
77
|
|
|
209
78
|
ResultOfNaclBoxOpen = Struct.new(:decrypted)
|
|
210
|
-
|
|
211
|
-
class ParamsOfNaclSecretBox
|
|
212
|
-
attr_reader :decrypted, :nonce, :key
|
|
213
|
-
|
|
79
|
+
ParamsOfNaclSecretBox = Struct.new(:decrypted, :nonce, :key) do
|
|
214
80
|
def initialize(decrypted:, nonce:, key:)
|
|
215
|
-
|
|
216
|
-
@nonce = nonce
|
|
217
|
-
@key = key
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
def to_h
|
|
221
|
-
{
|
|
222
|
-
decrypted: @decrypted,
|
|
223
|
-
nonce: @nonce,
|
|
224
|
-
key: @key
|
|
225
|
-
}
|
|
81
|
+
super
|
|
226
82
|
end
|
|
227
83
|
end
|
|
228
84
|
|
|
229
|
-
|
|
230
|
-
attr_reader :encrypted, :nonce, :key
|
|
231
|
-
|
|
85
|
+
ParamsOfNaclSecretBoxOpen = Struct.new(:encrypted, :nonce, :key) do
|
|
232
86
|
def initialize(encrypted:, nonce:, key:)
|
|
233
|
-
|
|
234
|
-
@nonce = nonce
|
|
235
|
-
@key = key
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
def to_h
|
|
239
|
-
{
|
|
240
|
-
encrypted: @encrypted,
|
|
241
|
-
nonce: @nonce,
|
|
242
|
-
key: @key
|
|
243
|
-
}
|
|
244
|
-
end
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
class ParamsOfMnemonicWords
|
|
248
|
-
attr_reader :dictionary
|
|
249
|
-
|
|
250
|
-
def initialize(a: nil)
|
|
251
|
-
@dictionary = a
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
def to_h
|
|
255
|
-
{
|
|
256
|
-
dictionary: @dictionary
|
|
257
|
-
}
|
|
87
|
+
super
|
|
258
88
|
end
|
|
259
89
|
end
|
|
260
90
|
|
|
91
|
+
ParamsOfMnemonicWords = Struct.new(:dictionary)
|
|
261
92
|
ResultOfMnemonicWords = Struct.new(:words)
|
|
262
|
-
|
|
263
|
-
class ParamsOfMnemonicFromRandom
|
|
264
|
-
attr_reader :dictionary, :word_count
|
|
265
|
-
|
|
266
|
-
def initialize(dictionary: nil, word_count: nil)
|
|
267
|
-
@dictionary = dictionary
|
|
268
|
-
@word_count = word_count
|
|
269
|
-
end
|
|
270
|
-
|
|
271
|
-
def to_h
|
|
272
|
-
{
|
|
273
|
-
dictionary: @dictionary,
|
|
274
|
-
word_count: @word_count
|
|
275
|
-
}
|
|
276
|
-
end
|
|
277
|
-
end
|
|
278
|
-
|
|
93
|
+
ParamsOfMnemonicFromRandom = Struct.new(:dictionary, :word_count, keyword_init: true)
|
|
279
94
|
ResultOfMnemonicFromRandom = Struct.new(:phrase)
|
|
280
95
|
|
|
281
96
|
class ParamsOfMnemonicFromEntropy
|
|
@@ -356,13 +171,7 @@ module TonSdk
|
|
|
356
171
|
end
|
|
357
172
|
end
|
|
358
173
|
|
|
359
|
-
|
|
360
|
-
attr_reader :xprv
|
|
361
|
-
|
|
362
|
-
def initialize(a)
|
|
363
|
-
@xprv = a
|
|
364
|
-
end
|
|
365
|
-
end
|
|
174
|
+
ResultOfHDKeyXPrvFromMnemonic = Struct.new(:xprv)
|
|
366
175
|
|
|
367
176
|
class ParamsOfHDKeyDeriveFromXPrv
|
|
368
177
|
attr_reader :xprv, :child_index, :hardened
|
|
@@ -382,162 +191,37 @@ module TonSdk
|
|
|
382
191
|
end
|
|
383
192
|
end
|
|
384
193
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
end
|
|
391
|
-
|
|
392
|
-
def to_h
|
|
393
|
-
{
|
|
394
|
-
xprv: @xprv,
|
|
395
|
-
path: @path
|
|
396
|
-
}
|
|
397
|
-
end
|
|
398
|
-
end
|
|
399
|
-
|
|
400
|
-
class ParamsOfHDKeySecretFromXPrv
|
|
401
|
-
attr_reader :xprv
|
|
402
|
-
|
|
403
|
-
def initialize(a)
|
|
404
|
-
@xprv = a
|
|
405
|
-
end
|
|
406
|
-
|
|
407
|
-
def to_h
|
|
408
|
-
{
|
|
409
|
-
xprv: @xprv
|
|
410
|
-
}
|
|
411
|
-
end
|
|
412
|
-
end
|
|
413
|
-
|
|
414
|
-
class ResultOfHDKeySecretFromXPrv
|
|
415
|
-
attr_reader :secret
|
|
416
|
-
|
|
417
|
-
def initialize(a)
|
|
418
|
-
@secret = a
|
|
419
|
-
end
|
|
420
|
-
end
|
|
421
|
-
|
|
422
|
-
class ParamsOfHDKeyPublicFromXPrv
|
|
423
|
-
attr_reader :xprv
|
|
424
|
-
|
|
425
|
-
def initialize(a)
|
|
426
|
-
@xprv = a
|
|
427
|
-
end
|
|
428
|
-
|
|
429
|
-
def to_h
|
|
430
|
-
{
|
|
431
|
-
xprv: @xprv
|
|
432
|
-
}
|
|
433
|
-
end
|
|
434
|
-
end
|
|
435
|
-
|
|
436
|
-
class ResultOfHDKeyPublicFromXPrv
|
|
437
|
-
attr_reader :public_
|
|
438
|
-
|
|
439
|
-
def initialize(a)
|
|
440
|
-
@public_ = a
|
|
441
|
-
end
|
|
442
|
-
end
|
|
443
|
-
|
|
444
|
-
class ParamsOfHDKeyDeriveFromXPrvPath
|
|
445
|
-
attr_reader :xprv, :path
|
|
194
|
+
ResultOfHDKeyDeriveFromXPrv = Struct.new(:xprv)
|
|
195
|
+
ParamsOfHDKeySecretFromXPrv = Struct.new(:xprv)
|
|
196
|
+
ResultOfHDKeySecretFromXPrv = Struct.new(:secret)
|
|
197
|
+
ParamsOfHDKeyPublicFromXPrv = Struct.new(:xprv)
|
|
198
|
+
ResultOfHDKeyPublicFromXPrv = Struct.new(:public_)
|
|
446
199
|
|
|
200
|
+
ParamsOfHDKeyDeriveFromXPrvPath = Struct.new(:xprv, :path) do
|
|
447
201
|
def initialize(xprv:, path:)
|
|
448
|
-
|
|
449
|
-
@path = path
|
|
450
|
-
end
|
|
451
|
-
|
|
452
|
-
def to_h
|
|
453
|
-
{
|
|
454
|
-
xprv: @xprv,
|
|
455
|
-
path: @path
|
|
456
|
-
}
|
|
202
|
+
super
|
|
457
203
|
end
|
|
458
204
|
end
|
|
459
205
|
|
|
460
|
-
|
|
461
|
-
attr_reader :xprv
|
|
462
|
-
|
|
463
|
-
def initialize(a)
|
|
464
|
-
@xprv = a
|
|
465
|
-
end
|
|
466
|
-
end
|
|
467
|
-
|
|
468
|
-
class ParamsOfChaCha20
|
|
469
|
-
attr_reader :data, :key, :nonce
|
|
206
|
+
ResultOfHDKeyDeriveFromXPrvPath = Struct.new(:xprv)
|
|
470
207
|
|
|
208
|
+
ParamsOfChaCha20 = Struct.new(:data, :key, :nonce) do
|
|
471
209
|
def initialize(data:, key:, nonce:)
|
|
472
|
-
|
|
473
|
-
@key = key
|
|
474
|
-
@nonce = nonce
|
|
475
|
-
end
|
|
476
|
-
|
|
477
|
-
def to_h
|
|
478
|
-
{
|
|
479
|
-
data: @data,
|
|
480
|
-
key: @key,
|
|
481
|
-
nonce: @nonce
|
|
482
|
-
}
|
|
210
|
+
super
|
|
483
211
|
end
|
|
484
212
|
end
|
|
485
213
|
|
|
486
|
-
|
|
487
|
-
attr_reader :data
|
|
488
|
-
|
|
489
|
-
def initialize(a)
|
|
490
|
-
@data = a
|
|
491
|
-
end
|
|
492
|
-
end
|
|
493
|
-
|
|
494
|
-
class ParamsOfSigningBoxSign
|
|
495
|
-
attr_reader :signing_box, :unsigned
|
|
214
|
+
ResultOfChaCha20 = Struct.new(:data)
|
|
496
215
|
|
|
216
|
+
ParamsOfSigningBoxSign = Struct.new(:signing_box, :unsigned) do
|
|
497
217
|
def initialize(signing_box:, unsigned:)
|
|
498
|
-
|
|
499
|
-
@unsigned = unsigned
|
|
500
|
-
end
|
|
501
|
-
|
|
502
|
-
def to_h
|
|
503
|
-
{
|
|
504
|
-
signing_box: @signing_box,
|
|
505
|
-
unsigned: @unsigned
|
|
506
|
-
}
|
|
507
|
-
end
|
|
508
|
-
end
|
|
509
|
-
|
|
510
|
-
class ResultOfSigningBoxSign
|
|
511
|
-
attr_reader :signature
|
|
512
|
-
|
|
513
|
-
def initialize(a)
|
|
514
|
-
@signature = a
|
|
218
|
+
super
|
|
515
219
|
end
|
|
516
220
|
end
|
|
517
221
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
def initialize(a)
|
|
522
|
-
@handle = a
|
|
523
|
-
end
|
|
524
|
-
|
|
525
|
-
def to_h
|
|
526
|
-
{
|
|
527
|
-
handle: @handle
|
|
528
|
-
}
|
|
529
|
-
end
|
|
530
|
-
end
|
|
531
|
-
|
|
532
|
-
class ResultOfSigningBoxGetPublicKey
|
|
533
|
-
attr_reader :pubkey
|
|
534
|
-
|
|
535
|
-
def initialize(a)
|
|
536
|
-
@pubkey = a
|
|
537
|
-
end
|
|
538
|
-
|
|
539
|
-
def to_h = { pubkey: @pubkey }
|
|
540
|
-
end
|
|
222
|
+
ResultOfSigningBoxSign = Struct.new(:signature)
|
|
223
|
+
RegisteredSigningBox = Struct.new(:handle)
|
|
224
|
+
ResultOfSigningBoxGetPublicKey = Struct.new(:pubkey)
|
|
541
225
|
|
|
542
226
|
class ParamsOfNaclSignDetachedVerify
|
|
543
227
|
attr_reader :unsigned, :signature, :public
|
|
@@ -555,15 +239,7 @@ module TonSdk
|
|
|
555
239
|
end
|
|
556
240
|
end
|
|
557
241
|
|
|
558
|
-
|
|
559
|
-
attr_reader :succeeded
|
|
560
|
-
|
|
561
|
-
def initialize(a)
|
|
562
|
-
@succeeded = a
|
|
563
|
-
end
|
|
564
|
-
|
|
565
|
-
def to_h = { succeeded: @succeeded }
|
|
566
|
-
end
|
|
242
|
+
ResultOfNaclSignDetachedVerify = Struct.new(:succeeded)
|
|
567
243
|
|
|
568
244
|
class ParamsOfAppSigningBox
|
|
569
245
|
TYPES = [
|
|
@@ -589,14 +265,18 @@ module TonSdk
|
|
|
589
265
|
end
|
|
590
266
|
end
|
|
591
267
|
|
|
268
|
+
EncryptionBoxInfo = Struct.new(:hdpath, :algorithm, :options, :public, keyword_init: true)
|
|
269
|
+
ParamsOfEncryptionBoxGetInfo = Struct.new(:encryption_box)
|
|
270
|
+
ResultOfEncryptionBoxGetInfo = Struct.new(:info)
|
|
271
|
+
RegisteredEncryptionBox = Struct.new(:handle)
|
|
272
|
+
|
|
592
273
|
|
|
593
274
|
#
|
|
594
275
|
# functions
|
|
595
276
|
#
|
|
596
277
|
|
|
597
278
|
def self.factorize(ctx, params)
|
|
598
|
-
|
|
599
|
-
Interop::request_to_native_lib(ctx, "crypto.factorize", pr_json) do |resp|
|
|
279
|
+
Interop::request_to_native_lib(ctx, "crypto.factorize", params) do |resp|
|
|
600
280
|
if resp.success?
|
|
601
281
|
yield NativeLibResponsetResult.new(
|
|
602
282
|
result: ResultOfFactorize.new(resp.result["factors"])
|
|
@@ -608,8 +288,7 @@ module TonSdk
|
|
|
608
288
|
end
|
|
609
289
|
|
|
610
290
|
def self.modular_power(ctx, params)
|
|
611
|
-
|
|
612
|
-
Interop::request_to_native_lib(ctx, "crypto.modular_power", pr_json) do |resp|
|
|
291
|
+
Interop::request_to_native_lib(ctx, "crypto.modular_power", params) do |resp|
|
|
613
292
|
if resp.success?
|
|
614
293
|
yield NativeLibResponsetResult.new(
|
|
615
294
|
result: ResultOfModularPower.new(resp.result["modular_power"])
|
|
@@ -621,8 +300,7 @@ module TonSdk
|
|
|
621
300
|
end
|
|
622
301
|
|
|
623
302
|
def self.ton_crc16(ctx, params)
|
|
624
|
-
|
|
625
|
-
Interop::request_to_native_lib(ctx, "crypto.ton_crc16", pr_json) do |resp|
|
|
303
|
+
Interop::request_to_native_lib(ctx, "crypto.ton_crc16", params) do |resp|
|
|
626
304
|
if resp.success?
|
|
627
305
|
yield NativeLibResponsetResult.new(
|
|
628
306
|
result: ResultOfTonCrc16.new(resp.result["crc"])
|
|
@@ -634,8 +312,7 @@ module TonSdk
|
|
|
634
312
|
end
|
|
635
313
|
|
|
636
314
|
def self.generate_random_bytes(ctx, params)
|
|
637
|
-
|
|
638
|
-
Interop::request_to_native_lib(ctx, "crypto.generate_random_bytes", pr_json) do |resp|
|
|
315
|
+
Interop::request_to_native_lib(ctx, "crypto.generate_random_bytes", params) do |resp|
|
|
639
316
|
if resp.success?
|
|
640
317
|
yield NativeLibResponsetResult.new(
|
|
641
318
|
result: ResultOfGenerateRandomBytes.new(resp.result["bytes"])
|
|
@@ -647,8 +324,7 @@ module TonSdk
|
|
|
647
324
|
end
|
|
648
325
|
|
|
649
326
|
def self.convert_public_key_to_ton_safe_format(ctx, params)
|
|
650
|
-
|
|
651
|
-
Interop::request_to_native_lib(ctx, "crypto.convert_public_key_to_ton_safe_format", pr_json) do |resp|
|
|
327
|
+
Interop::request_to_native_lib(ctx, "crypto.convert_public_key_to_ton_safe_format", params) do |resp|
|
|
652
328
|
if resp.success?
|
|
653
329
|
yield NativeLibResponsetResult.new(
|
|
654
330
|
result: ResultOfConvertPublicKeyToTonSafeFormat.new(resp.result["ton_public_key"])
|
|
@@ -675,8 +351,7 @@ module TonSdk
|
|
|
675
351
|
end
|
|
676
352
|
|
|
677
353
|
def self.sign(ctx, params)
|
|
678
|
-
|
|
679
|
-
Interop::request_to_native_lib(ctx, "crypto.sign", pr_json) do |resp|
|
|
354
|
+
Interop::request_to_native_lib(ctx, "crypto.sign", params) do |resp|
|
|
680
355
|
if resp.success?
|
|
681
356
|
yield NativeLibResponsetResult.new(
|
|
682
357
|
result: ResultOfSign.new(
|
|
@@ -691,8 +366,7 @@ module TonSdk
|
|
|
691
366
|
end
|
|
692
367
|
|
|
693
368
|
def self.verify_signature(ctx, params)
|
|
694
|
-
|
|
695
|
-
Interop::request_to_native_lib(ctx, "crypto.verify_signature", pr_json) do |resp|
|
|
369
|
+
Interop::request_to_native_lib(ctx, "crypto.verify_signature", params) do |resp|
|
|
696
370
|
if resp.success?
|
|
697
371
|
yield NativeLibResponsetResult.new(
|
|
698
372
|
result: ResultOfVerifySignature.new(resp.result["unsigned"])
|
|
@@ -704,8 +378,7 @@ module TonSdk
|
|
|
704
378
|
end
|
|
705
379
|
|
|
706
380
|
def self.sha256(ctx, params)
|
|
707
|
-
|
|
708
|
-
Interop::request_to_native_lib(ctx, "crypto.sha256", pr_json) do |resp|
|
|
381
|
+
Interop::request_to_native_lib(ctx, "crypto.sha256", params) do |resp|
|
|
709
382
|
if resp.success?
|
|
710
383
|
yield NativeLibResponsetResult.new(
|
|
711
384
|
result: ResultOfHash.new(resp.result["hash"])
|
|
@@ -717,8 +390,7 @@ module TonSdk
|
|
|
717
390
|
end
|
|
718
391
|
|
|
719
392
|
def self.sha512(ctx, params)
|
|
720
|
-
|
|
721
|
-
Interop::request_to_native_lib(ctx, "crypto.sha512", pr_json) do |resp|
|
|
393
|
+
Interop::request_to_native_lib(ctx, "crypto.sha512", params) do |resp|
|
|
722
394
|
if resp.success?
|
|
723
395
|
yield NativeLibResponsetResult.new(
|
|
724
396
|
result: ResultOfHash.new(resp.result["hash"])
|
|
@@ -730,8 +402,7 @@ module TonSdk
|
|
|
730
402
|
end
|
|
731
403
|
|
|
732
404
|
def self.scrypt(ctx, params)
|
|
733
|
-
|
|
734
|
-
Interop::request_to_native_lib(ctx, "crypto.scrypt", pr_json) do |resp|
|
|
405
|
+
Interop::request_to_native_lib(ctx, "crypto.scrypt", params) do |resp|
|
|
735
406
|
if resp.success?
|
|
736
407
|
yield NativeLibResponsetResult.new(
|
|
737
408
|
result: ResultOfScrypt.new(resp.result["key"])
|
|
@@ -743,8 +414,7 @@ module TonSdk
|
|
|
743
414
|
end
|
|
744
415
|
|
|
745
416
|
def self.nacl_sign_keypair_from_secret_key(ctx, params)
|
|
746
|
-
|
|
747
|
-
Interop::request_to_native_lib(ctx, "crypto.nacl_sign_keypair_from_secret_key", pr_json) do |resp|
|
|
417
|
+
Interop::request_to_native_lib(ctx, "crypto.nacl_sign_keypair_from_secret_key", params) do |resp|
|
|
748
418
|
if resp.success?
|
|
749
419
|
yield NativeLibResponsetResult.new(
|
|
750
420
|
result: KeyPair.new(public_: resp.result["public"], secret: resp.result["secret"])
|
|
@@ -756,8 +426,7 @@ module TonSdk
|
|
|
756
426
|
end
|
|
757
427
|
|
|
758
428
|
def self.nacl_sign(ctx, params)
|
|
759
|
-
|
|
760
|
-
Interop::request_to_native_lib(ctx, "crypto.nacl_sign", pr_json) do |resp|
|
|
429
|
+
Interop::request_to_native_lib(ctx, "crypto.nacl_sign", params) do |resp|
|
|
761
430
|
if resp.success?
|
|
762
431
|
yield NativeLibResponsetResult.new(
|
|
763
432
|
result: ResultOfNaclSign.new(resp.result["signed"])
|
|
@@ -769,8 +438,7 @@ module TonSdk
|
|
|
769
438
|
end
|
|
770
439
|
|
|
771
440
|
def self.nacl_sign_open(ctx, params)
|
|
772
|
-
|
|
773
|
-
Interop::request_to_native_lib(ctx, "crypto.nacl_sign_open", pr_json) do |resp|
|
|
441
|
+
Interop::request_to_native_lib(ctx, "crypto.nacl_sign_open", params) do |resp|
|
|
774
442
|
if resp.success?
|
|
775
443
|
yield NativeLibResponsetResult.new(
|
|
776
444
|
result: ResultOfNaclSignOpen.new(resp.result["unsigned"])
|
|
@@ -782,8 +450,7 @@ module TonSdk
|
|
|
782
450
|
end
|
|
783
451
|
|
|
784
452
|
def self.nacl_sign_detached(ctx, params)
|
|
785
|
-
|
|
786
|
-
Interop::request_to_native_lib(ctx, "crypto.nacl_sign_detached", pr_json) do |resp|
|
|
453
|
+
Interop::request_to_native_lib(ctx, "crypto.nacl_sign_detached", params) do |resp|
|
|
787
454
|
if resp.success?
|
|
788
455
|
yield NativeLibResponsetResult.new(
|
|
789
456
|
result: ResultOfNaclSignDetached.new(resp.result["signature"])
|
|
@@ -794,8 +461,20 @@ module TonSdk
|
|
|
794
461
|
end
|
|
795
462
|
end
|
|
796
463
|
|
|
464
|
+
def self.nacl_sign_detached_verify(ctx, params)
|
|
465
|
+
Interop::request_to_native_lib(ctx, "crypto.nacl_sign_detached_verify", params) do |resp|
|
|
466
|
+
if resp.success?
|
|
467
|
+
yield NativeLibResponsetResult.new(
|
|
468
|
+
result: ResultOfNaclSignDetachedVerify.new(resp.result["succeeded"])
|
|
469
|
+
)
|
|
470
|
+
else
|
|
471
|
+
yield resp
|
|
472
|
+
end
|
|
473
|
+
end
|
|
474
|
+
end
|
|
475
|
+
|
|
797
476
|
def self.nacl_box_keypair(ctx)
|
|
798
|
-
Interop::request_to_native_lib(ctx, "crypto.nacl_box_keypair"
|
|
477
|
+
Interop::request_to_native_lib(ctx, "crypto.nacl_box_keypair") do |resp|
|
|
799
478
|
if resp.success?
|
|
800
479
|
yield NativeLibResponsetResult.new(
|
|
801
480
|
result: KeyPair.new(public_: resp.result["public"], secret: resp.result["secret"])
|
|
@@ -807,8 +486,7 @@ module TonSdk
|
|
|
807
486
|
end
|
|
808
487
|
|
|
809
488
|
def self.nacl_box_keypair_from_secret_key(ctx, params)
|
|
810
|
-
|
|
811
|
-
Interop::request_to_native_lib(ctx, "crypto.nacl_box_keypair_from_secret_key", pr_json) do |resp|
|
|
489
|
+
Interop::request_to_native_lib(ctx, "crypto.nacl_box_keypair_from_secret_key", params) do |resp|
|
|
812
490
|
if resp.success?
|
|
813
491
|
yield NativeLibResponsetResult.new(
|
|
814
492
|
result: KeyPair.new(public_: resp.result["public"], secret: resp.result["secret"])
|
|
@@ -820,8 +498,7 @@ module TonSdk
|
|
|
820
498
|
end
|
|
821
499
|
|
|
822
500
|
def self.nacl_box(ctx, params)
|
|
823
|
-
|
|
824
|
-
Interop::request_to_native_lib(ctx, "crypto.nacl_box", pr_json) do |resp|
|
|
501
|
+
Interop::request_to_native_lib(ctx, "crypto.nacl_box", params) do |resp|
|
|
825
502
|
if resp.success?
|
|
826
503
|
yield NativeLibResponsetResult.new(
|
|
827
504
|
result: ResultOfNaclBox.new(resp.result["encrypted"])
|
|
@@ -833,8 +510,7 @@ module TonSdk
|
|
|
833
510
|
end
|
|
834
511
|
|
|
835
512
|
def self.nacl_box_open(ctx, params)
|
|
836
|
-
|
|
837
|
-
Interop::request_to_native_lib(ctx, "crypto.nacl_box_open", pr_json) do |resp|
|
|
513
|
+
Interop::request_to_native_lib(ctx, "crypto.nacl_box_open", params) do |resp|
|
|
838
514
|
if resp.success?
|
|
839
515
|
yield NativeLibResponsetResult.new(
|
|
840
516
|
result: ResultOfNaclBoxOpen.new(resp.result["decrypted"])
|
|
@@ -846,8 +522,7 @@ module TonSdk
|
|
|
846
522
|
end
|
|
847
523
|
|
|
848
524
|
def self.nacl_secret_box(ctx, params)
|
|
849
|
-
|
|
850
|
-
Interop::request_to_native_lib(ctx, "crypto.nacl_secret_box", pr_json) do |resp|
|
|
525
|
+
Interop::request_to_native_lib(ctx, "crypto.nacl_secret_box", params) do |resp|
|
|
851
526
|
if resp.success?
|
|
852
527
|
yield NativeLibResponsetResult.new(
|
|
853
528
|
result: ResultOfNaclBox.new(resp.result["encrypted"])
|
|
@@ -859,8 +534,7 @@ module TonSdk
|
|
|
859
534
|
end
|
|
860
535
|
|
|
861
536
|
def self.nacl_secret_box_open(ctx, params)
|
|
862
|
-
|
|
863
|
-
Interop::request_to_native_lib(ctx, "crypto.nacl_secret_box_open", pr_json) do |resp|
|
|
537
|
+
Interop::request_to_native_lib(ctx, "crypto.nacl_secret_box_open", params) do |resp|
|
|
864
538
|
if resp.success?
|
|
865
539
|
yield NativeLibResponsetResult.new(
|
|
866
540
|
result: ResultOfNaclBoxOpen.new(resp.result["decrypted"])
|
|
@@ -872,8 +546,7 @@ module TonSdk
|
|
|
872
546
|
end
|
|
873
547
|
|
|
874
548
|
def self.mnemonic_words(ctx, params)
|
|
875
|
-
|
|
876
|
-
Interop::request_to_native_lib(ctx, "crypto.mnemonic_words", pr_json) do |resp|
|
|
549
|
+
Interop::request_to_native_lib(ctx, "crypto.mnemonic_words", params) do |resp|
|
|
877
550
|
if resp.success?
|
|
878
551
|
yield NativeLibResponsetResult.new(
|
|
879
552
|
result: ResultOfMnemonicWords.new(resp.result["words"])
|
|
@@ -885,8 +558,7 @@ module TonSdk
|
|
|
885
558
|
end
|
|
886
559
|
|
|
887
560
|
def self.mnemonic_from_random(ctx, params)
|
|
888
|
-
|
|
889
|
-
Interop::request_to_native_lib(ctx, "crypto.mnemonic_from_random", pr_json) do |resp|
|
|
561
|
+
Interop::request_to_native_lib(ctx, "crypto.mnemonic_from_random", params) do |resp|
|
|
890
562
|
if resp.success?
|
|
891
563
|
yield NativeLibResponsetResult.new(
|
|
892
564
|
result: ResultOfMnemonicFromRandom.new(resp.result["phrase"])
|
|
@@ -898,8 +570,7 @@ module TonSdk
|
|
|
898
570
|
end
|
|
899
571
|
|
|
900
572
|
def self.mnemonic_from_entropy(ctx, params)
|
|
901
|
-
|
|
902
|
-
Interop::request_to_native_lib(ctx, "crypto.mnemonic_from_entropy", pr_json) do |resp|
|
|
573
|
+
Interop::request_to_native_lib(ctx, "crypto.mnemonic_from_entropy", params) do |resp|
|
|
903
574
|
if resp.success?
|
|
904
575
|
yield NativeLibResponsetResult.new(
|
|
905
576
|
result: ResultOfMnemonicFromEntropy.new(resp.result["phrase"])
|
|
@@ -911,8 +582,7 @@ module TonSdk
|
|
|
911
582
|
end
|
|
912
583
|
|
|
913
584
|
def self.mnemonic_verify(ctx, params)
|
|
914
|
-
|
|
915
|
-
Interop::request_to_native_lib(ctx, "crypto.mnemonic_verify", pr_json) do |resp|
|
|
585
|
+
Interop::request_to_native_lib(ctx, "crypto.mnemonic_verify", params) do |resp|
|
|
916
586
|
if resp.success?
|
|
917
587
|
yield NativeLibResponsetResult.new(
|
|
918
588
|
result: ResultOfMnemonicVerify.new(resp.result["valid"])
|
|
@@ -924,8 +594,7 @@ module TonSdk
|
|
|
924
594
|
end
|
|
925
595
|
|
|
926
596
|
def self.mnemonic_derive_sign_keys(ctx, params)
|
|
927
|
-
|
|
928
|
-
Interop::request_to_native_lib(ctx, "crypto.mnemonic_derive_sign_keys", pr_json) do |resp|
|
|
597
|
+
Interop::request_to_native_lib(ctx, "crypto.mnemonic_derive_sign_keys", params) do |resp|
|
|
929
598
|
if resp.success?
|
|
930
599
|
yield NativeLibResponsetResult.new(
|
|
931
600
|
result: KeyPair.new(public_: resp.result["public"], secret: resp.result["secret"])
|
|
@@ -937,8 +606,7 @@ module TonSdk
|
|
|
937
606
|
end
|
|
938
607
|
|
|
939
608
|
def self.hdkey_xprv_from_mnemonic(ctx, params)
|
|
940
|
-
|
|
941
|
-
Interop::request_to_native_lib(ctx, "crypto.hdkey_xprv_from_mnemonic", pr_json) do |resp|
|
|
609
|
+
Interop::request_to_native_lib(ctx, "crypto.hdkey_xprv_from_mnemonic", params) do |resp|
|
|
942
610
|
if resp.success?
|
|
943
611
|
yield NativeLibResponsetResult.new(
|
|
944
612
|
result: ResultOfHDKeyXPrvFromMnemonic.new(resp.result["xprv"])
|
|
@@ -950,8 +618,7 @@ module TonSdk
|
|
|
950
618
|
end
|
|
951
619
|
|
|
952
620
|
def self.hdkey_derive_from_xprv(ctx, params)
|
|
953
|
-
|
|
954
|
-
Interop::request_to_native_lib(ctx, "crypto.hdkey_derive_from_xprv", pr_json) do |resp|
|
|
621
|
+
Interop::request_to_native_lib(ctx, "crypto.hdkey_derive_from_xprv", params) do |resp|
|
|
955
622
|
if resp.success?
|
|
956
623
|
yield NativeLibResponsetResult.new(
|
|
957
624
|
result: ResultOfHDKeyDeriveFromXPrv.new(resp.result["xprv"])
|
|
@@ -963,8 +630,7 @@ module TonSdk
|
|
|
963
630
|
end
|
|
964
631
|
|
|
965
632
|
def self.hdkey_derive_from_xprv_path(ctx, params)
|
|
966
|
-
|
|
967
|
-
Interop::request_to_native_lib(ctx, "crypto.hdkey_derive_from_xprv_path", pr_json) do |resp|
|
|
633
|
+
Interop::request_to_native_lib(ctx, "crypto.hdkey_derive_from_xprv_path", params) do |resp|
|
|
968
634
|
if resp.success?
|
|
969
635
|
yield NativeLibResponsetResult.new(
|
|
970
636
|
result: ResultOfHDKeyDeriveFromXPrvPath.new(resp.result["xprv"])
|
|
@@ -976,8 +642,7 @@ module TonSdk
|
|
|
976
642
|
end
|
|
977
643
|
|
|
978
644
|
def self.hdkey_secret_from_xprv(ctx, params)
|
|
979
|
-
|
|
980
|
-
Interop::request_to_native_lib(ctx, "crypto.hdkey_secret_from_xprv", pr_json) do |resp|
|
|
645
|
+
Interop::request_to_native_lib(ctx, "crypto.hdkey_secret_from_xprv", params) do |resp|
|
|
981
646
|
if resp.success?
|
|
982
647
|
yield NativeLibResponsetResult.new(
|
|
983
648
|
result: ResultOfHDKeySecretFromXPrv.new(resp.result["secret"])
|
|
@@ -989,8 +654,7 @@ module TonSdk
|
|
|
989
654
|
end
|
|
990
655
|
|
|
991
656
|
def self.hdkey_public_from_xprv(ctx, params)
|
|
992
|
-
|
|
993
|
-
Interop::request_to_native_lib(ctx, "crypto.hdkey_public_from_xprv", pr_json) do |resp|
|
|
657
|
+
Interop::request_to_native_lib(ctx, "crypto.hdkey_public_from_xprv", params) do |resp|
|
|
994
658
|
if resp.success?
|
|
995
659
|
yield NativeLibResponsetResult.new(
|
|
996
660
|
result: ResultOfHDKeyPublicFromXPrv.new(resp.result["public"])
|
|
@@ -1002,8 +666,7 @@ module TonSdk
|
|
|
1002
666
|
end
|
|
1003
667
|
|
|
1004
668
|
def self.chacha20(ctx, params)
|
|
1005
|
-
|
|
1006
|
-
Interop::request_to_native_lib(ctx, "crypto.chacha20", pr_json) do |resp|
|
|
669
|
+
Interop::request_to_native_lib(ctx, "crypto.chacha20", params) do |resp|
|
|
1007
670
|
if resp.success?
|
|
1008
671
|
yield NativeLibResponsetResult.new(
|
|
1009
672
|
result: ResultOfChaCha20.new(resp.result["data"])
|
|
@@ -1054,7 +717,7 @@ module TonSdk
|
|
|
1054
717
|
end
|
|
1055
718
|
|
|
1056
719
|
def self.get_signing_box(ctx, params)
|
|
1057
|
-
Interop::request_to_native_lib(ctx, "crypto.get_signing_box", params
|
|
720
|
+
Interop::request_to_native_lib(ctx, "crypto.get_signing_box", params) do |resp|
|
|
1058
721
|
if resp.success?
|
|
1059
722
|
yield NativeLibResponsetResult.new(
|
|
1060
723
|
result: RegisteredSigningBox.new(resp.result["handle"])
|
|
@@ -1069,7 +732,6 @@ module TonSdk
|
|
|
1069
732
|
Interop::request_to_native_lib(
|
|
1070
733
|
ctx,
|
|
1071
734
|
"crypto.signing_box_get_public_key",
|
|
1072
|
-
params.to_h.to_json,
|
|
1073
735
|
is_single_thread_only: is_single_thread_only
|
|
1074
736
|
) do |resp|
|
|
1075
737
|
if resp.success?
|
|
@@ -1083,7 +745,7 @@ module TonSdk
|
|
|
1083
745
|
end
|
|
1084
746
|
|
|
1085
747
|
def self.signing_box_sign(ctx, params)
|
|
1086
|
-
Interop::request_to_native_lib(ctx, "crypto.signing_box_sign", params
|
|
748
|
+
Interop::request_to_native_lib(ctx, "crypto.signing_box_sign", params) do |resp|
|
|
1087
749
|
if resp.success?
|
|
1088
750
|
yield NativeLibResponsetResult.new(
|
|
1089
751
|
result: ResultOfSigningBoxSign.new(resp.result["signature"])
|
|
@@ -1095,10 +757,10 @@ module TonSdk
|
|
|
1095
757
|
end
|
|
1096
758
|
|
|
1097
759
|
def self.remove_signing_box(ctx, params)
|
|
1098
|
-
Interop::request_to_native_lib(ctx, "crypto.remove_signing_box", params
|
|
760
|
+
Interop::request_to_native_lib(ctx, "crypto.remove_signing_box", params) do |resp|
|
|
1099
761
|
if resp.success?
|
|
1100
762
|
yield NativeLibResponsetResult.new(
|
|
1101
|
-
result:
|
|
763
|
+
result: nil
|
|
1102
764
|
)
|
|
1103
765
|
else
|
|
1104
766
|
yield resp
|
|
@@ -1106,11 +768,51 @@ module TonSdk
|
|
|
1106
768
|
end
|
|
1107
769
|
end
|
|
1108
770
|
|
|
1109
|
-
def self.
|
|
1110
|
-
|
|
771
|
+
def self.register_encryption_box(ctx, app_obj:)
|
|
772
|
+
client_callback = Proc.new do |type_, x|
|
|
773
|
+
app_res = app_obj.request(x["request_data"])
|
|
774
|
+
app_req_result = case app_res
|
|
775
|
+
in [:success, result]
|
|
776
|
+
TonSdk::Client::AppRequestResult.new(
|
|
777
|
+
type_: :ok,
|
|
778
|
+
result: result
|
|
779
|
+
)
|
|
780
|
+
in [:error, text]
|
|
781
|
+
TonSdk::Client::AppRequestResult.new(
|
|
782
|
+
type_: :error,
|
|
783
|
+
text: text
|
|
784
|
+
)
|
|
785
|
+
end
|
|
786
|
+
|
|
787
|
+
params = TonSdk::Client::ParamsOfResolveAppRequest.new(
|
|
788
|
+
app_request_id: x["app_request_id"],
|
|
789
|
+
result: app_req_result
|
|
790
|
+
)
|
|
791
|
+
TonSdk::Client.resolve_app_request(ctx, params)
|
|
792
|
+
end
|
|
793
|
+
|
|
794
|
+
Interop::request_to_native_lib(
|
|
795
|
+
ctx,
|
|
796
|
+
"crypto.register_encryption_box",
|
|
797
|
+
nil,
|
|
798
|
+
client_callback: client_callback,
|
|
799
|
+
is_single_thread_only: false
|
|
800
|
+
) do |resp|
|
|
1111
801
|
if resp.success?
|
|
1112
802
|
yield NativeLibResponsetResult.new(
|
|
1113
|
-
result:
|
|
803
|
+
result: RegisteredEncryptionBox.new(resp.result["handle"])
|
|
804
|
+
)
|
|
805
|
+
else
|
|
806
|
+
yield resp
|
|
807
|
+
end
|
|
808
|
+
end
|
|
809
|
+
end
|
|
810
|
+
|
|
811
|
+
def self.encryption_box_get_info(ctx, params)
|
|
812
|
+
Interop::request_to_native_lib(ctx, "crypto.encryption_box_get_info", params) do |resp|
|
|
813
|
+
if resp.success?
|
|
814
|
+
yield NativeLibResponsetResult.new(
|
|
815
|
+
result: ResultOfEncryptionBoxGetInfo.new(resp.result["info"])
|
|
1114
816
|
)
|
|
1115
817
|
else
|
|
1116
818
|
yield resp
|