ton_sdk_client 1.9.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.
@@ -5,30 +5,44 @@ module TonSdk
5
5
  # types
6
6
  #
7
7
 
8
- class ExecutionOptions
9
- attr_reader :blockchain_config, :block_time, :block_lt, :transaction_lt
8
+ module ErrorCode
9
+ CANNOT_READ_TRANSACTION = 401
10
+ CANNOT_READ_BLOCKCHAIN_CONFIG = 402
11
+ TRANSACTION_ABORTED = 403
12
+ INTERNAL_ERROR = 404
13
+ ACTION_PHASE_FAILED = 405
14
+ ACCOUNT_CODE_MISSING = 406
15
+ LOW_BALANCE = 407
16
+ ACCOUNT_FROZEN_OR_DELETED = 408
17
+ ACCOUNT_MISSING = 409
18
+ UNKNOWN_EXECUTION_ERROR = 410
19
+ INVALID_INPUT_STACK = 411
20
+ INVALID_ACCOUNT_BOC = 412
21
+ INVALID_MESSAGE_TYPE = 413
22
+ CONTRACT_EXECUTION_ERROR = 414
23
+ end
10
24
 
25
+ ExecutionOptions = Struct.new(:blockchain_config, :block_time, :block_lt, :transaction_lt, keyword_init: true) do
11
26
  def initialize(blockchain_config: nil, block_time: nil, block_lt: nil, transaction_lt: nil)
12
- @blockchain_config = blockchain_config
13
- @block_time = block_time
14
- @block_lt = block_lt
15
- @transaction_lt = transaction_lt
27
+ super
16
28
  end
17
29
  end
18
30
 
19
31
  class AccountForExecutor
32
+ private_class_method :new
33
+
20
34
  TYPES = [:none, :uninit, :account]
21
35
  attr_reader :type_, :boc, :unlimited_balance
22
36
 
23
- def new_with_type_none
37
+ def self.new_with_type_none
24
38
  @type_ = :none
25
39
  end
26
40
 
27
- def new_with_type_uninit
41
+ def self.new_with_type_uninit
28
42
  @type_ = :uninit
29
43
  end
30
44
 
31
- def new_with_type_account(boc:, unlimited_balance: nil)
45
+ def self.new_with_type_account(boc:, unlimited_balance: nil)
32
46
  @type_ = :account
33
47
  @boc = boc
34
48
  @unlimited_balance = unlimited_balance
@@ -50,10 +64,16 @@ module TonSdk
50
64
  end
51
65
  end
52
66
 
53
- class ParamsOfRunExecutor
54
- attr_reader :message, :account, :execution_options, :abi, :skip_transaction_check,
55
- :boc_cache, :return_updated_account
56
-
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
57
77
  def initialize(
58
78
  message:,
59
79
  account:,
@@ -63,41 +83,22 @@ module TonSdk
63
83
  boc_cache: nil,
64
84
  return_updated_account: nil
65
85
  )
66
- @message = message
67
- @account = account
68
- @execution_options = execution_options
69
- @abi = abi
70
- @skip_transaction_check = skip_transaction_check
71
- @boc_cache = boc_cache
72
- @return_updated_account = return_updated_account
86
+ super
73
87
  end
74
88
 
75
89
  def to_h
76
- abi_val = @abi.nil? ? nil : @abi.to_h
77
- exe_opt_val = @execution_options.nil? ? nil : @execution_options.to_h
78
- boc_cache_val = @boc_cache.nil? ? nil : @boc_cache.to_h
79
-
80
- {
81
- message: @message,
82
- account: @account.to_h,
83
- execution_options: exe_opt_val,
84
- abi: abi_val,
85
- skip_transaction_check: @skip_transaction_check,
86
- boc_cache: boc_cache_val,
87
- return_updated_account: @return_updated_account
88
- }
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
89
96
  end
90
97
  end
91
98
 
92
- class ResultOfRunExecutor
93
- attr_reader :transaction, :out_messages, :decoded, :account, :fees
94
-
99
+ ResultOfRunExecutor = Struct.new(:transaction, :out_messages, :decoded, :account, :fees, keyword_init: true) do
95
100
  def initialize(transaction:, out_messages:, decoded: nil, account:, fees:)
96
- @transaction = transaction
97
- @out_messages = out_messages
98
- @decoded = decoded
99
- @account = account
100
- @fees = fees
101
+ super
101
102
  end
102
103
  end
103
104
 
@@ -115,28 +116,20 @@ module TonSdk
115
116
  end
116
117
 
117
118
  def to_h
118
- abi_val = @abi.nil? ? nil : @abi.to_h
119
- exe_opt_val = @execution_options.nil? ? nil : @execution_options.to_h
120
- boc_cache_val = @boc_cache.nil? ? nil : @boc_cache.to_h
121
-
122
119
  {
123
120
  message: @message,
124
121
  account: @account,
125
- execution_options: exe_opt_val,
126
- abi: abi_val,
127
- boc_cache: boc_cache_val,
122
+ execution_options: @execution_options&.to_h,
123
+ abi: @abi&.to_h,
124
+ boc_cache: @boc_cache&.to_h,
128
125
  return_updated_account: @return_updated_account
129
126
  }
130
127
  end
131
128
  end
132
129
 
133
- class ResultOfRunTvm
134
- attr_reader :out_messages, :decoded, :account
135
-
130
+ ResultOfRunTvm = Struct.new(:out_messages, :decoded, :account, keyword_init: true) do
136
131
  def initialize(out_messages:, decoded: nil, account:)
137
- @out_messages = out_messages
138
- @decoded = decoded
139
- @account = account
132
+ super
140
133
  end
141
134
  end
142
135
 
@@ -152,59 +145,49 @@ module TonSdk
152
145
  end
153
146
 
154
147
  def to_h
155
- exe_opt_val = @execution_options.nil? ? nil : @execution_options.to_h
156
-
157
148
  {
158
149
  account: @account,
159
150
  function_name: @function_name,
160
151
  input: @input,
161
- execution_options: exe_opt_val,
152
+ execution_options: @execution_options&.to_h,
162
153
  tuple_list_as_array: @tuple_list_as_array
163
154
  }
164
155
  end
165
156
  end
166
157
 
167
- class ResultOfRunGet
168
- attr_reader :output
169
-
170
- def initialize(a)
171
- @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
172
178
  end
173
179
  end
174
180
 
175
- class TransactionFees
176
- attr_reader :in_msg_fwd_fee, :storage_fee, :gas_fee, :out_msgs_fwd_fee,
177
- :total_account_fees
178
181
 
179
- def initialize(in_msg_fwd_fee:, storage_fee: , gas_fee:, out_msgs_fwd_fee:,
180
- total_account_fees:, total_output:
181
- )
182
- @in_msg_fwd_fee = in_msg_fwd_fee
183
- @storage_fee = storage_fee
184
- @gas_fee = gas_fee
185
- @out_msgs_fwd_fee = out_msgs_fwd_fee
186
- @total_account_fees = total_account_fees
187
- @total_output = total_output
188
- end
189
-
190
- def to_h
191
- {
192
- in_msg_fwd_fee: @in_msg_fwd_fee,
193
- storage_fee: @storage_fee,
194
- gas_fee: @gas_fee,
195
- out_msgs_fwd_fee: @out_msgs_fwd_fee,
196
- total_account_fees: @total_account_fees,
197
- total_output: @total_output
198
- }
199
- end
200
- end
182
+ #
183
+ # functions
184
+ #
201
185
 
202
186
  def self.run_executor(ctx, params)
203
- pr_json = params.to_h.to_json
204
187
  Interop::request_to_native_lib(
205
188
  ctx,
206
189
  "tvm.run_executor",
207
- pr_json,
190
+ params,
208
191
  is_single_thread_only: false
209
192
  ) do |resp|
210
193
  if resp.success?
@@ -224,11 +207,10 @@ module TonSdk
224
207
  end
225
208
 
226
209
  def self.run_tvm(ctx, params)
227
- pr_json = params.to_h.to_json
228
210
  Interop::request_to_native_lib(
229
211
  ctx,
230
212
  "tvm.run_tvm",
231
- pr_json,
213
+ params,
232
214
  is_single_thread_only: false
233
215
  ) do |resp|
234
216
  if resp.success?
@@ -246,11 +228,10 @@ module TonSdk
246
228
  end
247
229
 
248
230
  def self.run_get(ctx, params)
249
- pr_json = params.to_h.to_json
250
231
  Interop::request_to_native_lib(
251
232
  ctx,
252
233
  "tvm.run_get",
253
- pr_json,
234
+ params,
254
235
  is_single_thread_only: false
255
236
  ) do |resp|
256
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,21 +41,23 @@ module TonSdk
48
41
  end
49
42
  end
50
43
 
51
- class ResultOfConvertAddress
52
- attr_reader :address
44
+ ResultOfConvertAddress = Struct.new(:address)
45
+ ParamsOfCalcStorageFee = Struct.new(:account, :period, keyword_init: true)
46
+ ResultOfCalcStorageFee = Struct.new(:fee)
53
47
 
54
- def initialize(a)
55
- @address = a
56
- end
57
- end
48
+ ParamsOfCompressZstd = Struct.new(:uncompressed, :level, keyword_init: true)
49
+ ResultOfCompressZstd = Struct.new(:compressed)
50
+
51
+ ParamsOfDecompressZstd = Struct.new(:compressed)
52
+ ResultOfDecompressZstd = Struct.new(:decompressed)
58
53
 
59
54
 
60
55
  #
61
56
  # functions
62
57
  #
63
58
 
64
- def self.convert_address(ctx, prm)
65
- 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|
66
61
  if resp.success?
67
62
  yield NativeLibResponsetResult.new(
68
63
  result: Utils::ResultOfConvertAddress.new(resp.result["address"])
@@ -72,5 +67,41 @@ module TonSdk
72
67
  end
73
68
  end
74
69
  end
70
+
71
+ def self.calc_storage_fee(ctx, params)
72
+ Interop::request_to_native_lib(ctx, "utils.calc_storage_fee", params) do |resp|
73
+ if resp.success?
74
+ yield NativeLibResponsetResult.new(
75
+ result: Utils::ResultOfCalcStorageFee.new(resp.result["fee"])
76
+ )
77
+ else
78
+ yield resp
79
+ end
80
+ end
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
75
106
  end
76
107
  end
@@ -1,4 +1,4 @@
1
1
  module TonSdk
2
- VERSION = "1.9.0"
3
- NATIVE_SDK_VERSION = "1.9.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.9.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-04-12 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