ton_sdk_client 1.11.0 → 1.16.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,19 +23,7 @@ module TonSdk
23
23
  end
24
24
  end
25
25
 
26
- class ResultOfSendMessage
27
- attr_reader :shard_block_id
28
-
29
- def initialize(a)
30
- @shard_block_id = a
31
- end
32
-
33
- def to_h
34
- {
35
- shard_block_id: @shard_block_id
36
- }
37
- end
38
- end
26
+ ResultOfSendMessage = Struct.new(:shard_block_id)
39
27
 
40
28
  class ParamsOfWaitForTransaction
41
29
  attr_reader :abi, :message, :shard_block_id, :send_events
@@ -141,30 +129,13 @@ module TonSdk
141
129
  end
142
130
  end
143
131
 
144
- class DecodedOutput
145
- attr_reader :out_messages, :output
146
-
132
+ DecodedOutput = Struct.new(:out_messages, :output) do
147
133
  def initialize(out_messages:, output: nil)
148
- @out_messages = out_messages
149
- @output = output
150
- end
151
-
152
- def to_h
153
- {
154
- out_messages: @out_messages,
155
- output: @output
156
- }
134
+ super
157
135
  end
158
136
  end
159
137
 
160
- class ParamsOfProcessMessage
161
- attr_reader :message_encode_params, :send_events
162
-
163
- def initialize(message_encode_params:, send_events:)
164
- @message_encode_params = message_encode_params
165
- @send_events = send_events
166
- end
167
-
138
+ ParamsOfProcessMessage = Struct.new(:message_encode_params, :send_events) do
168
139
  def to_h
169
140
  {
170
141
  message_encode_params: @message_encode_params.to_h,
@@ -186,7 +157,7 @@ module TonSdk
186
157
  Interop::request_to_native_lib(
187
158
  ctx,
188
159
  "processing.send_message",
189
- params.to_h.to_json,
160
+ params,
190
161
  client_callback: client_callback,
191
162
  is_single_thread_only: false
192
163
  ) do |resp|
@@ -208,7 +179,7 @@ module TonSdk
208
179
  Interop::request_to_native_lib(
209
180
  ctx,
210
181
  "processing.wait_for_transaction",
211
- params.to_h.to_json,
182
+ params,
212
183
  client_callback: client_callback,
213
184
  is_single_thread_only: false
214
185
  ) do |resp|
@@ -235,7 +206,7 @@ module TonSdk
235
206
  Interop::request_to_native_lib(
236
207
  ctx,
237
208
  "processing.process_message",
238
- params.to_h.to_json,
209
+ params,
239
210
  client_callback: client_callback,
240
211
  is_single_thread_only: false
241
212
  ) do |resp|
@@ -22,30 +22,27 @@ module TonSdk
22
22
  CONTRACT_EXECUTION_ERROR = 414
23
23
  end
24
24
 
25
- class ExecutionOptions
26
- attr_reader :blockchain_config, :block_time, :block_lt, :transaction_lt
27
-
25
+ ExecutionOptions = Struct.new(:blockchain_config, :block_time, :block_lt, :transaction_lt, keyword_init: true) do
28
26
  def initialize(blockchain_config: nil, block_time: nil, block_lt: nil, transaction_lt: nil)
29
- @blockchain_config = blockchain_config
30
- @block_time = block_time
31
- @block_lt = block_lt
32
- @transaction_lt = transaction_lt
27
+ super
33
28
  end
34
29
  end
35
30
 
36
31
  class AccountForExecutor
32
+ private_class_method :new
33
+
37
34
  TYPES = [:none, :uninit, :account]
38
35
  attr_reader :type_, :boc, :unlimited_balance
39
36
 
40
- def new_with_type_none
37
+ def self.new_with_type_none
41
38
  @type_ = :none
42
39
  end
43
40
 
44
- def new_with_type_uninit
41
+ def self.new_with_type_uninit
45
42
  @type_ = :uninit
46
43
  end
47
44
 
48
- def new_with_type_account(boc:, unlimited_balance: nil)
45
+ def self.new_with_type_account(boc:, unlimited_balance: nil)
49
46
  @type_ = :account
50
47
  @boc = boc
51
48
  @unlimited_balance = unlimited_balance
@@ -67,10 +64,16 @@ module TonSdk
67
64
  end
68
65
  end
69
66
 
70
- class ParamsOfRunExecutor
71
- attr_reader :message, :account, :execution_options, :abi, :skip_transaction_check,
72
- :boc_cache, :return_updated_account
73
-
67
+ ParamsOfRunExecutor = Struct.new(
68
+ :message,
69
+ :account,
70
+ :execution_options,
71
+ :abi,
72
+ :skip_transaction_check,
73
+ :boc_cache,
74
+ :return_updated_account,
75
+ keyword_init: true
76
+ ) do
74
77
  def initialize(
75
78
  message:,
76
79
  account:,
@@ -80,41 +83,22 @@ module TonSdk
80
83
  boc_cache: nil,
81
84
  return_updated_account: nil
82
85
  )
83
- @message = message
84
- @account = account
85
- @execution_options = execution_options
86
- @abi = abi
87
- @skip_transaction_check = skip_transaction_check
88
- @boc_cache = boc_cache
89
- @return_updated_account = return_updated_account
86
+ super
90
87
  end
91
88
 
92
89
  def to_h
93
- abi_val = @abi.nil? ? nil : @abi.to_h
94
- exe_opt_val = @execution_options.nil? ? nil : @execution_options.to_h
95
- boc_cache_val = @boc_cache.nil? ? nil : @boc_cache.to_h
96
-
97
- {
98
- message: @message,
99
- account: @account.to_h,
100
- execution_options: exe_opt_val,
101
- abi: abi_val,
102
- skip_transaction_check: @skip_transaction_check,
103
- boc_cache: boc_cache_val,
104
- return_updated_account: @return_updated_account
105
- }
90
+ h = super
91
+ h[:account] = self.account.to_h
92
+ h[:execution_options] = self.execution_options&.to_h
93
+ h[:abi] = self.abi&.to_h
94
+ h[:boc_cache] = self.boc_cache&.to_h
95
+ h
106
96
  end
107
97
  end
108
98
 
109
- class ResultOfRunExecutor
110
- attr_reader :transaction, :out_messages, :decoded, :account, :fees
111
-
99
+ ResultOfRunExecutor = Struct.new(:transaction, :out_messages, :decoded, :account, :fees, keyword_init: true) do
112
100
  def initialize(transaction:, out_messages:, decoded: nil, account:, fees:)
113
- @transaction = transaction
114
- @out_messages = out_messages
115
- @decoded = decoded
116
- @account = account
117
- @fees = fees
101
+ super
118
102
  end
119
103
  end
120
104
 
@@ -132,28 +116,20 @@ module TonSdk
132
116
  end
133
117
 
134
118
  def to_h
135
- abi_val = @abi.nil? ? nil : @abi.to_h
136
- exe_opt_val = @execution_options.nil? ? nil : @execution_options.to_h
137
- boc_cache_val = @boc_cache.nil? ? nil : @boc_cache.to_h
138
-
139
119
  {
140
120
  message: @message,
141
121
  account: @account,
142
- execution_options: exe_opt_val,
143
- abi: abi_val,
144
- boc_cache: boc_cache_val,
122
+ execution_options: @execution_options&.to_h,
123
+ abi: @abi&.to_h,
124
+ boc_cache: @boc_cache&.to_h,
145
125
  return_updated_account: @return_updated_account
146
126
  }
147
127
  end
148
128
  end
149
129
 
150
- class ResultOfRunTvm
151
- attr_reader :out_messages, :decoded, :account
152
-
130
+ ResultOfRunTvm = Struct.new(:out_messages, :decoded, :account, keyword_init: true) do
153
131
  def initialize(out_messages:, decoded: nil, account:)
154
- @out_messages = out_messages
155
- @decoded = decoded
156
- @account = account
132
+ super
157
133
  end
158
134
  end
159
135
 
@@ -169,59 +145,49 @@ module TonSdk
169
145
  end
170
146
 
171
147
  def to_h
172
- exe_opt_val = @execution_options.nil? ? nil : @execution_options.to_h
173
-
174
148
  {
175
149
  account: @account,
176
150
  function_name: @function_name,
177
151
  input: @input,
178
- execution_options: exe_opt_val,
152
+ execution_options: @execution_options&.to_h,
179
153
  tuple_list_as_array: @tuple_list_as_array
180
154
  }
181
155
  end
182
156
  end
183
157
 
184
- class ResultOfRunGet
185
- attr_reader :output
186
-
187
- def initialize(a)
188
- @output = a
158
+ ResultOfRunGet = Struct.new(:output)
159
+
160
+ TransactionFees = Struct.new(
161
+ :in_msg_fwd_fee,
162
+ :storage_fee,
163
+ :gas_fee,
164
+ :out_msgs_fwd_fee,
165
+ :total_account_fees,
166
+ :total_output,
167
+ keyword_init: true
168
+ ) do
169
+ def initialize(
170
+ in_msg_fwd_fee:,
171
+ storage_fee:,
172
+ gas_fee:,
173
+ out_msgs_fwd_fee:,
174
+ total_account_fees:,
175
+ total_output:
176
+ )
177
+ super
189
178
  end
190
179
  end
191
180
 
192
- class TransactionFees
193
- attr_reader :in_msg_fwd_fee, :storage_fee, :gas_fee, :out_msgs_fwd_fee,
194
- :total_account_fees
195
181
 
196
- def initialize(in_msg_fwd_fee:, storage_fee: , gas_fee:, out_msgs_fwd_fee:,
197
- total_account_fees:, total_output:
198
- )
199
- @in_msg_fwd_fee = in_msg_fwd_fee
200
- @storage_fee = storage_fee
201
- @gas_fee = gas_fee
202
- @out_msgs_fwd_fee = out_msgs_fwd_fee
203
- @total_account_fees = total_account_fees
204
- @total_output = total_output
205
- end
206
-
207
- def to_h
208
- {
209
- in_msg_fwd_fee: @in_msg_fwd_fee,
210
- storage_fee: @storage_fee,
211
- gas_fee: @gas_fee,
212
- out_msgs_fwd_fee: @out_msgs_fwd_fee,
213
- total_account_fees: @total_account_fees,
214
- total_output: @total_output
215
- }
216
- end
217
- end
182
+ #
183
+ # functions
184
+ #
218
185
 
219
186
  def self.run_executor(ctx, params)
220
- pr_json = params.to_h.to_json
221
187
  Interop::request_to_native_lib(
222
188
  ctx,
223
189
  "tvm.run_executor",
224
- pr_json,
190
+ params,
225
191
  is_single_thread_only: false
226
192
  ) do |resp|
227
193
  if resp.success?
@@ -241,11 +207,10 @@ module TonSdk
241
207
  end
242
208
 
243
209
  def self.run_tvm(ctx, params)
244
- pr_json = params.to_h.to_json
245
210
  Interop::request_to_native_lib(
246
211
  ctx,
247
212
  "tvm.run_tvm",
248
- pr_json,
213
+ params,
249
214
  is_single_thread_only: false
250
215
  ) do |resp|
251
216
  if resp.success?
@@ -263,11 +228,10 @@ module TonSdk
263
228
  end
264
229
 
265
230
  def self.run_get(ctx, params)
266
- pr_json = params.to_h.to_json
267
231
  Interop::request_to_native_lib(
268
232
  ctx,
269
233
  "tvm.run_get",
270
- pr_json,
234
+ params,
271
235
  is_single_thread_only: false
272
236
  ) do |resp|
273
237
  if resp.success?
@@ -32,14 +32,7 @@ module TonSdk
32
32
  end
33
33
  end
34
34
 
35
- class ParamsOfConvertAddress
36
- attr_reader :address, :output_format
37
-
38
- def initialize(address:, output_format:)
39
- @address = address
40
- @output_format = output_format
41
- end
42
-
35
+ ParamsOfConvertAddress = Struct.new(:address, :output_format, keyword_init: true) do
43
36
  def to_h
44
37
  {
45
38
  address: @address,
@@ -48,45 +41,23 @@ module TonSdk
48
41
  end
49
42
  end
50
43
 
51
- class ResultOfConvertAddress
52
- attr_reader :address
53
-
54
- def initialize(a)
55
- @address = a
56
- end
57
- end
58
-
59
- class ParamsOfCalcStorageFee
60
- attr_reader :account, :period
61
-
62
- def initialize(account:, period:)
63
- @account = account
64
- @period = period
65
- end
66
-
67
- def to_h
68
- {
69
- account: @account,
70
- period: @period
71
- }
72
- end
73
- end
44
+ ResultOfConvertAddress = Struct.new(:address)
45
+ ParamsOfCalcStorageFee = Struct.new(:account, :period, keyword_init: true)
46
+ ResultOfCalcStorageFee = Struct.new(:fee)
74
47
 
75
- class ResultOfCalcStorageFee
76
- attr_reader :fee
48
+ ParamsOfCompressZstd = Struct.new(:uncompressed, :level, keyword_init: true)
49
+ ResultOfCompressZstd = Struct.new(:compressed)
77
50
 
78
- def initialize(a)
79
- @fee = a
80
- end
81
- end
51
+ ParamsOfDecompressZstd = Struct.new(:compressed)
52
+ ResultOfDecompressZstd = Struct.new(:decompressed)
82
53
 
83
54
 
84
55
  #
85
56
  # functions
86
57
  #
87
58
 
88
- def self.convert_address(ctx, prm)
89
- Interop::request_to_native_lib(ctx, "utils.convert_address", prm.to_h.to_json) do |resp|
59
+ def self.convert_address(ctx, params)
60
+ Interop::request_to_native_lib(ctx, "utils.convert_address", params) do |resp|
90
61
  if resp.success?
91
62
  yield NativeLibResponsetResult.new(
92
63
  result: Utils::ResultOfConvertAddress.new(resp.result["address"])
@@ -97,9 +68,8 @@ module TonSdk
97
68
  end
98
69
  end
99
70
 
100
-
101
- def self.calc_storage_fee(ctx, prm)
102
- Interop::request_to_native_lib(ctx, "utils.calc_storage_fee", prm.to_h.to_json) do |resp|
71
+ def self.calc_storage_fee(ctx, params)
72
+ Interop::request_to_native_lib(ctx, "utils.calc_storage_fee", params) do |resp|
103
73
  if resp.success?
104
74
  yield NativeLibResponsetResult.new(
105
75
  result: Utils::ResultOfCalcStorageFee.new(resp.result["fee"])
@@ -109,5 +79,29 @@ module TonSdk
109
79
  end
110
80
  end
111
81
  end
82
+
83
+ def self.compress_zstd(ctx, params)
84
+ Interop::request_to_native_lib(ctx, "utils.compress_zstd", params) do |resp|
85
+ if resp.success?
86
+ yield NativeLibResponsetResult.new(
87
+ result: Utils::ResultOfCompressZstd.new(resp.result["compressed"])
88
+ )
89
+ else
90
+ yield resp
91
+ end
92
+ end
93
+ end
94
+
95
+ def self.decompress_zstd(ctx, params)
96
+ Interop::request_to_native_lib(ctx, "utils.decompress_zstd", params) do |resp|
97
+ if resp.success?
98
+ yield NativeLibResponsetResult.new(
99
+ result: Utils::ParamsOfDecompressZstd.new(resp.result["decompressed"])
100
+ )
101
+ else
102
+ yield resp
103
+ end
104
+ end
105
+ end
112
106
  end
113
107
  end
@@ -1,4 +1,4 @@
1
1
  module TonSdk
2
- VERSION = "1.11.0"
3
- NATIVE_SDK_VERSION = "1.11.0"
2
+ VERSION = "1.16.1"
3
+ NATIVE_SDK_VERSION = "1.16.1"
4
4
  end