ton_sdk_client 1.13.0 → 1.15.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.
@@ -23,13 +23,7 @@ module TonSdk
23
23
  end
24
24
  end
25
25
 
26
- ResultOfSendMessage = Struct.new(:shard_block_id) do
27
- def to_h
28
- {
29
- shard_block_id: @shard_block_id
30
- }
31
- end
32
- end
26
+ ResultOfSendMessage = Struct.new(:shard_block_id)
33
27
 
34
28
  class ParamsOfWaitForTransaction
35
29
  attr_reader :abi, :message, :shard_block_id, :send_events
@@ -135,19 +129,9 @@ module TonSdk
135
129
  end
136
130
  end
137
131
 
138
- class DecodedOutput
139
- attr_reader :out_messages, :output
140
-
132
+ DecodedOutput = Struct.new(:out_messages, :output) do
141
133
  def initialize(out_messages:, output: nil)
142
- @out_messages = out_messages
143
- @output = output
144
- end
145
-
146
- def to_h
147
- {
148
- out_messages: @out_messages,
149
- output: @output
150
- }
134
+ super
151
135
  end
152
136
  end
153
137
 
@@ -173,7 +157,7 @@ module TonSdk
173
157
  Interop::request_to_native_lib(
174
158
  ctx,
175
159
  "processing.send_message",
176
- params.to_h.to_json,
160
+ params,
177
161
  client_callback: client_callback,
178
162
  is_single_thread_only: false
179
163
  ) do |resp|
@@ -195,7 +179,7 @@ module TonSdk
195
179
  Interop::request_to_native_lib(
196
180
  ctx,
197
181
  "processing.wait_for_transaction",
198
- params.to_h.to_json,
182
+ params,
199
183
  client_callback: client_callback,
200
184
  is_single_thread_only: false
201
185
  ) do |resp|
@@ -222,7 +206,7 @@ module TonSdk
222
206
  Interop::request_to_native_lib(
223
207
  ctx,
224
208
  "processing.process_message",
225
- params.to_h.to_json,
209
+ params,
226
210
  client_callback: client_callback,
227
211
  is_single_thread_only: false
228
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,7 +32,7 @@ module TonSdk
32
32
  end
33
33
  end
34
34
 
35
- ParamsOfConvertAddress = Struct.new(:address, :output_format) do
35
+ ParamsOfConvertAddress = Struct.new(:address, :output_format, keyword_init: true) do
36
36
  def to_h
37
37
  {
38
38
  address: @address,
@@ -42,33 +42,13 @@ module TonSdk
42
42
  end
43
43
 
44
44
  ResultOfConvertAddress = Struct.new(:address)
45
-
46
- ParamsOfCalcStorageFee = Struct.new(:account, :period) do
47
- def to_h
48
- {
49
- account: @account,
50
- period: @period
51
- }
52
- end
53
- end
54
-
45
+ ParamsOfCalcStorageFee = Struct.new(:account, :period, keyword_init: true)
55
46
  ResultOfCalcStorageFee = Struct.new(:fee)
56
47
 
57
- ParamsOfCompressZstd = Struct.new(:uncompressed, :level) do
58
- def to_h
59
- {
60
- uncompressed: @uncompressed,
61
- level: @level
62
- }
63
- end
64
- end
65
-
48
+ ParamsOfCompressZstd = Struct.new(:uncompressed, :level, keyword_init: true)
66
49
  ResultOfCompressZstd = Struct.new(:compressed)
67
50
 
68
- ParamsOfDecompressZstd = Struct.new(:compressed) do
69
- def to_h = { compressed: @compressed }
70
- end
71
-
51
+ ParamsOfDecompressZstd = Struct.new(:compressed)
72
52
  ResultOfDecompressZstd = Struct.new(:decompressed)
73
53
 
74
54
 
@@ -76,8 +56,8 @@ module TonSdk
76
56
  # functions
77
57
  #
78
58
 
79
- def self.convert_address(ctx, prm)
80
- 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|
81
61
  if resp.success?
82
62
  yield NativeLibResponsetResult.new(
83
63
  result: Utils::ResultOfConvertAddress.new(resp.result["address"])
@@ -88,8 +68,8 @@ module TonSdk
88
68
  end
89
69
  end
90
70
 
91
- def self.calc_storage_fee(ctx, prm)
92
- 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|
93
73
  if resp.success?
94
74
  yield NativeLibResponsetResult.new(
95
75
  result: Utils::ResultOfCalcStorageFee.new(resp.result["fee"])
@@ -100,8 +80,8 @@ module TonSdk
100
80
  end
101
81
  end
102
82
 
103
- def self.compress_zstd(ctx, prm)
104
- Interop::request_to_native_lib(ctx, "utils.compress_zstd", prm.to_h.to_json) do |resp|
83
+ def self.compress_zstd(ctx, params)
84
+ Interop::request_to_native_lib(ctx, "utils.compress_zstd", params) do |resp|
105
85
  if resp.success?
106
86
  yield NativeLibResponsetResult.new(
107
87
  result: Utils::ResultOfCompressZstd.new(resp.result["compressed"])
@@ -112,8 +92,8 @@ module TonSdk
112
92
  end
113
93
  end
114
94
 
115
- def self.decompress_zstd(ctx, prm)
116
- Interop::request_to_native_lib(ctx, "utils.decompress_zstd", prm.to_h.to_json) do |resp|
95
+ def self.decompress_zstd(ctx, params)
96
+ Interop::request_to_native_lib(ctx, "utils.decompress_zstd", params) do |resp|
117
97
  if resp.success?
118
98
  yield NativeLibResponsetResult.new(
119
99
  result: Utils::ParamsOfDecompressZstd.new(resp.result["decompressed"])
@@ -1,4 +1,4 @@
1
1
  module TonSdk
2
- VERSION = "1.13.0"
3
- NATIVE_SDK_VERSION = "1.13.0"
2
+ VERSION = "1.15.0"
3
+ NATIVE_SDK_VERSION = "1.15.0"
4
4
  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.13.0
4
+ version: 1.15.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: 2021-05-03 00:00:00.000000000 Z
11
+ date: 2021-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi