ton_sdk_client 1.27.0 → 1.28.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de68cde3bf2772d6e041682e0c3b72653dbc10c88f9d3da6f6e38805392c79d9
4
- data.tar.gz: 711422d1ea613eade3fa88d04f6b04ac820ea7ad4d5cc290fb820fef7d9af531
3
+ metadata.gz: 5bd88aaed45cdcc1f73fffa49f4d5a94209bc5de5d397cab2a17be7c66d5a8cc
4
+ data.tar.gz: 464507ab3c62098609c6e1a7509c3ccc3980d1206da9b2e27e1ad17c935c6004
5
5
  SHA512:
6
- metadata.gz: 91abf0f72519493a45ab76f48099204cd7a00660d7da98a88bbf26d0ce9e73d8a45c8cbeba5555bce24c0ed5017abcb42e880a88a0f3c054b12b4555b2a3b51e
7
- data.tar.gz: fad6857d97f33b0b38ea00a6e107225e90a3dca58aafbc48ac61f9c28e4e608a2bc6c3de6d70b327503cd967ee7a4437f3c5bdc07237ea6a1b6ea5c9bd73df98
6
+ metadata.gz: f2d17c70082958459738405e2d0d82c7ca97dd88a8230f3bf8e4e978aa5612314550b3779225b36e62d6382f503156307dfc9af1e17814fb49f3114531aaccaf
7
+ data.tar.gz: e399086789160d65cf54eae69a3c6754505b08a14a7f10f07d75725455b4f9dde9d1ace169e352b15132f4580bea88b7677f5591ecbab517d7c3c911424b006c
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
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.28.0
6
+ -----
7
+ * Changes `1.28.0` https://github.com/tonlabs/TON-SDK/blob/master/CHANGELOG.md#1280--2021-12-24
8
+ * Implement Debot module
9
+
5
10
  1.27.0
6
11
  -----
7
12
  * Changes `1.27.0` https://github.com/tonlabs/TON-SDK/blob/master/CHANGELOG.md#1270--2021-12-03
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # 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
- [![TON SDK version](https://img.shields.io/badge/TON%20SDK%20version-1.26.0-green)](https://github.com/tonlabs/TON-SDK/tree/1.26.0)
4
+ [![TON SDK version](https://img.shields.io/badge/TON%20SDK%20version-1.28.0-green)](https://github.com/tonlabs/TON-SDK/tree/1.28.0)
5
5
 
6
6
  Ruby gem-client bindings for [TON SDK](https://github.com/tonlabs/TON-SDK) which allows one to communicate with [FreeTON](https://freeton.org) blockchain in Ruby.
7
7
 
@@ -1,7 +1,4 @@
1
1
  module TonSdk
2
-
3
- # NOTE
4
- # as of 28 apr 2021, in the main repository this module is still unstable
5
2
  module Debot
6
3
 
7
4
  #
@@ -21,22 +18,23 @@ module TonSdk
21
18
  EXTERNAL_CALL_FAILED = 810
22
19
  BROWSER_CALLBACK_FAILED = 811
23
20
  OPERATION_REJECTED = 812
21
+ DEBOT_NO_CODE = 813
24
22
  end
25
23
 
26
24
  DebotAction = KwStruct.new(:description, :name, :action_type, :to, :attributes, :misc) do
27
25
  def to_h
28
26
  {
29
- description: self.description,
30
- name: self.name,
31
- action_type: self.action_type,
32
- to: self.to,
33
- attributes: self.attributes,
34
- misc: self.misc
27
+ description: description,
28
+ name: name,
29
+ action_type: action_type,
30
+ to: to,
31
+ attributes: attributes,
32
+ misc: misc
35
33
  }
36
34
  end
37
35
 
38
36
  def self.from_json(j)
39
- return nil if j.nil?
37
+ return if j.nil?
40
38
 
41
39
  self.new(
42
40
  description: j["description"],
@@ -49,20 +47,59 @@ module TonSdk
49
47
  end
50
48
  end
51
49
 
52
- ParamsOfStart = KwStruct.new(:debot_handle)
50
+ DebotInfo = KwStruct.new(
51
+ :name,
52
+ :version,
53
+ :publisher,
54
+ :caption,
55
+ :author,
56
+ :support,
57
+ :hello,
58
+ :language,
59
+ :dabi,
60
+ :icon,
61
+ :interfaces,
62
+ :dabi_version
63
+ ) do
64
+ def initialize(
65
+ name: nil,
66
+ version: nil,
67
+ publisher: nil,
68
+ caption: nil,
69
+ author: nil,
70
+ support: nil,
71
+ hello: nil,
72
+ language: nil,
73
+ dabi: nil,
74
+ icon: nil,
75
+ interfaces: [],
76
+ dabi_version: nil
77
+ )
78
+ super
79
+ end
80
+ end
81
+
82
+ class DebotActivity
83
+ attr_reader :type, :msg, :dst, :out, :fee, :setcode, :signkey, :signing_box_handle
84
+ end
85
+
86
+ Spending = KwStruct.new(:amount, :dst)
87
+
88
+ ParamsOfInit = KwStruct.new(:address)
53
89
 
54
90
  RegisteredDebot = KwStruct.new(:debot_handle, :debot_abi, :info) do
55
- def to_h = {
56
- debot_handle: @debot_handle,
57
- debot_abi: @debot_abi,
58
- info: @info.to_h
59
- }
91
+ def to_h
92
+ {
93
+ debot_handle: debot_handle,
94
+ debot_abi: debot_abi,
95
+ info: info.to_h
96
+ }
97
+ end
60
98
  end
61
99
 
62
100
  class ParamsOfAppDebotBrowser
63
101
  private_class_method :new
64
102
 
65
- # todo remove?
66
103
  TYPE_VALUES = [
67
104
  :log,
68
105
  :switch,
@@ -75,61 +112,61 @@ module TonSdk
75
112
  :approve
76
113
  ]
77
114
 
78
- attr_reader :type_, :msg, :context_id, :action, :prompt, :debot_addr, :message, :activity
115
+ attr_reader :type, :msg, :context_id, :action, :prompt, :debot_addr, :message, :activity
79
116
 
80
117
  def self.new_with_type_log(msg)
81
- @type_ = :log
118
+ @type = :log
82
119
  @msg = msg
83
120
  end
84
121
 
85
122
  def self.new_with_type_switch(context_id)
86
- @type_ = :switch
123
+ @type = :switch
87
124
  @context_id = context_id
88
125
  end
89
126
 
90
127
  def self.new_with_type_switch_completed
91
- @type_ = :switch_completed
128
+ @type = :switch_completed
92
129
  end
93
130
 
94
131
  def self.new_with_type_show_action(action)
95
- @type_ = :show_action
132
+ @type = :show_action
96
133
  @action = action
97
134
  end
98
135
 
99
136
  def self.new_with_type_input(prompt)
100
- @type_ = :input
137
+ @type = :input
101
138
  @prompt = prompt
102
139
  end
103
140
 
104
141
  def self.new_with_type_get_signing_box
105
- @type_ = :get_signing_box
142
+ @type = :get_signing_box
106
143
  end
107
144
 
108
145
  def self.new_with_type_invoke_debot(debot_addr, action)
109
- @type_ = :invoke_debot
146
+ @type = :invoke_debot
110
147
  @debot_addr = debot_addr
111
148
  @action = action
112
149
  end
113
150
 
114
151
  def self.new_with_type_send(message)
115
- @type_ = :send
152
+ @type = :send
116
153
  @message = message
117
154
  end
118
155
 
119
156
  def self.new_with_type_approve(activity)
120
- @type_ = :approve
157
+ @type = :approve
121
158
  @activity = activity
122
159
  end
123
160
 
124
161
  def to_h
125
162
  {
126
- type: Helper.sym_to_capitalized_case_str(@type_),
127
- msg: @msg,
128
- context_id: @context_id,
129
- action: @action,
130
- prompt: @prompt,
131
- debot_addr: @debot_addr,
132
- message: @message
163
+ type: Helper.sym_to_capitalized_case_str(type),
164
+ msg: msg,
165
+ context_id: context_id,
166
+ action: action,
167
+ prompt: prompt,
168
+ debot_addr: debot_addr,
169
+ message: message
133
170
  }
134
171
  end
135
172
 
@@ -173,118 +210,79 @@ module TonSdk
173
210
  private
174
211
 
175
212
  def self.parse_type(type_str)
176
- types_str = TYPE_VALUES.map(Helper.capitalized_case_str_to_snake_case_sym)
177
- unless types_str.include?(type_str)
178
- raise ArgumentError.new("type #{type_str} is unknown; known types: #{types_str}")
213
+ parsed_type = Helper.capitalized_case_str_to_snake_case_sym(type_str)
214
+
215
+ unless TYPE_VALUES.include?(type_str)
216
+ raise ArgumentError.new("type #{type_str} is unknown; known types: #{TYPE_VALUES}")
179
217
  end
180
218
 
181
- Helper.capitalized_case_str_to_snake_case_sym(type_str)
219
+ parsed_type
182
220
  end
183
221
  end
184
222
 
185
223
  class ResultOfAppDebotBrowser
186
224
  private_class_method :new
187
225
 
188
- attr_reader :type_, :value, :signing_box, :is_approved
226
+ attr_reader :type, :value, :signing_box, :is_approved
189
227
 
190
228
  def self.new_with_type_input(a)
191
- @type_ = :input
229
+ @type = :input
192
230
  @value = a
193
231
  end
194
232
 
195
233
  def self.new_with_type_get_signing_box(a)
196
- @type_ = :get_signing_box
234
+ @type = :get_signing_box
197
235
  @signing_box = signing_box
198
236
  end
199
237
 
200
238
  def self.new_with_type_invoke_debot
201
- @type_ = :invoke_debot
239
+ @type = :invoke_debot
202
240
  end
203
241
 
204
242
  def self.new_with_type_approve(a)
205
- @type_ = :approve
243
+ @type = :approve
206
244
  @is_approved = a
207
245
  end
208
246
  end
209
247
 
248
+ ParamsOfStart = KwStruct.new(:debot_handle)
249
+
210
250
  ParamsOfFetch = KwStruct.new(:address)
211
251
 
252
+ ResultOfFetch = KwStruct.new(:info)
253
+
212
254
  ParamsOfExecute = KwStruct.new(:debot_handle, :action) do
213
255
  def to_h
214
256
  {
215
- debot_handle: @debot_handle,
216
- action: @action.to_h
257
+ debot_handle: debot_handle,
258
+ action: action.to_h
217
259
  }
218
260
  end
219
261
  end
220
262
 
221
263
  ParamsOfSend = KwStruct.new(:debot_handle, :message)
222
- ParamsOfInit = KwStruct.new(:address)
223
- DebotInfo = KwStruct.new(
224
- :name,
225
- :version,
226
- :publisher,
227
- :caption,
228
- :author,
229
- :support,
230
- :hello,
231
- :language,
232
- :dabi,
233
- :icon,
234
- :interfaces
235
- ) do
236
- def initialize(
237
- name: nil,
238
- version: nil,
239
- publisher: nil,
240
- caption: nil,
241
- author: nil,
242
- support: nil,
243
- hello: nil,
244
- language: nil,
245
- dabi: nil,
246
- icon: nil,
247
- interfaces: []
248
- )
249
- super
250
- end
251
- end
252
-
253
- ResultOfFetch = KwStruct.new(:info)
254
- Spending = KwStruct.new(:amount, :dst)
255
-
256
- class DebotActivity
257
- private_class_method :new
258
-
259
- attr_reader :type_, :msg, :dst, :out, :fee, :setcode, :signkey, :signing_box_handle
260
-
261
- def self.new_with_type_transaction(msg:, dst:, out:, fee:, setcode:, signkey:, signing_box_handle:)
262
- @type_ = :transaction
263
- @msg = msg
264
- @dst = dst
265
- @out = out
266
- @fee = fee
267
- @setcode = setcode
268
- @signkey = signkey
269
- @signing_box_handle = signing_box_handle
270
- end
271
-
272
- def self.from_json(j)
273
- # todo
274
- end
275
- end
276
-
277
264
 
265
+ ParamsOfRemove = KwStruct.new(:debot_handle)
278
266
 
279
267
  #
280
268
  # functions
281
269
  #
282
270
 
283
- def self.init(ctx, params, app_browser_obj)
284
- Interop::request_to_native_lib(ctx, "debot.init", params) do |resp|
271
+ def self.init(ctx, params, app_browser_obj = nil)
272
+ Interop::request_to_native_lib(
273
+ ctx,
274
+ "debot.init",
275
+ params
276
+ ) do |resp|
285
277
  if resp.success?
278
+ debot_info = resp.result["info"].transform_keys(&:to_sym)
279
+ debot_info[:dabi_version] = debot_info.delete(:dabiVersion)
286
280
  yield NativeLibResponseResult.new(
287
- result: nil
281
+ result: RegisteredDebot.new(
282
+ debot_handle: resp.result["debot_handle"],
283
+ debot_abi: resp.result["debot_abi"],
284
+ info: DebotInfo.new(**debot_info)
285
+ )
288
286
  )
289
287
  else
290
288
  yield resp
@@ -317,9 +315,12 @@ module TonSdk
317
315
  is_single_thread_only: false
318
316
  ) do |resp|
319
317
  if resp.success?
318
+ debot_info = resp.result["info"].transform_keys(&:to_sym)
319
+ debot_info[:dabi_version] = debot_info.delete(:dabiVersion)
320
320
  yield NativeLibResponseResult.new(
321
- # TODO: parse DebotInfo
322
- result: ResultOfFetch.new(info: resp.result["info"])
321
+ result: ResultOfFetch.new(
322
+ info: DebotInfo.new(**debot_info)
323
+ )
323
324
  )
324
325
  else
325
326
  yield resp
@@ -17,4 +17,4 @@ module TonSdk
17
17
 
18
18
  def self.base64_from_hex(hex_digest) = [[hex_digest].pack("H*")].pack("m0")
19
19
  end
20
- end
20
+ end
@@ -148,7 +148,7 @@ module TonSdk
148
148
 
149
149
  # using @@request_counter here to pass a @@request_counter and handlers and then retrieve them
150
150
  # is probably isn't needed.
151
- # Thanks to the way Ruby is, the same affect can be achived by a block which is an easier way.
151
+ # Thanks to the way Ruby is, the same affect can be achieved by a block which is an easier way.
152
152
  # Nonetheless, @@request_counter is incremented with each request and then sent out to a server
153
153
  # in order to keep a server happy,
154
154
  # because otherwise a server will, probably, reply in a wrong way.
@@ -135,7 +135,7 @@ module TonSdk
135
135
 
136
136
  def to_h
137
137
  h = super
138
- h[:fields] = self.fields.map(&:to_h)
138
+ h[:fields] = fields.map(&:to_h)
139
139
  h
140
140
  end
141
141
  end
@@ -222,7 +222,7 @@ module TonSdk
222
222
 
223
223
  def to_h
224
224
  h = super
225
- h[:abi_registry] = self.abi_registry&.map(&:to_h)
225
+ h[:abi_registry] = abi_registry&.map(&:to_h)
226
226
  h
227
227
  end
228
228
  end
@@ -409,8 +409,8 @@ module TonSdk
409
409
  end
410
410
  end
411
411
 
412
- def self.get_endpoints(ctx, params)
413
- Interop::request_to_native_lib(ctx, "net.get_endpoints", params) do |resp|
412
+ def self.get_endpoints(ctx)
413
+ Interop::request_to_native_lib(ctx, "net.get_endpoints") do |resp|
414
414
  if resp.success?
415
415
  yield NativeLibResponseResult.new(
416
416
  result: ResultOfGetEndpoints.new(
@@ -16,9 +16,9 @@ module TonSdk
16
16
 
17
17
  def to_h
18
18
  {
19
- message: @message,
20
- abi: @abi.nil? ? nil : @abi.to_h,
21
- send_events: @send_events
19
+ message: message,
20
+ abi: abi&.to_h,
21
+ send_events: send_events
22
22
  }
23
23
  end
24
24
  end
@@ -37,10 +37,10 @@ module TonSdk
37
37
 
38
38
  def to_h
39
39
  {
40
- abi: @abi.nil? ? nil : @abi.to_h,
41
- message: @message,
42
- shard_block_id: @shard_block_id,
43
- send_events: @send_events
40
+ abi: abi&.to_h,
41
+ message: message,
42
+ shard_block_id: shard_block_id,
43
+ send_events: send_events
44
44
  }
45
45
  end
46
46
  end
@@ -57,10 +57,10 @@ module TonSdk
57
57
 
58
58
  def to_h
59
59
  {
60
- transaction: @transaction,
61
- out_messages: @out_messages,
62
- decoded: @decoded,
63
- fees: @fees
60
+ transaction: transaction,
61
+ out_messages: out_messages,
62
+ decoded: decoded,
63
+ fees: fees
64
64
  }
65
65
  end
66
66
  end
@@ -136,6 +136,10 @@ module TonSdk
136
136
  end
137
137
 
138
138
  ParamsOfProcessMessage = KwStruct.new(:message_encode_params, :send_events) do
139
+ def initialize(message_encode_params:, send_events:)
140
+ super
141
+ end
142
+
139
143
  def to_h
140
144
  {
141
145
  message_encode_params: message_encode_params.to_h,
@@ -188,8 +192,11 @@ module TonSdk
188
192
  result: ResultOfProcessMessage.new(
189
193
  transaction: resp.result["transaction"],
190
194
  out_messages: resp.result["out_messages"],
191
- decoded: resp.result["decoded"],
192
- fees: resp.result["fees"]
195
+ decoded: DecodedOutput.new(
196
+ out_messages: resp.result.dig("decoded", "out_messages"),
197
+ output: resp.result.dig("decoded", "output")
198
+ ),
199
+ fees: Tvm::TransactionFees.new(**resp.result["fees"].transform_keys(&:to_sym))
193
200
  )
194
201
  )
195
202
  else
@@ -215,8 +222,11 @@ module TonSdk
215
222
  result: ResultOfProcessMessage.new(
216
223
  transaction: resp.result["transaction"],
217
224
  out_messages: resp.result["out_messages"],
218
- decoded: resp.result["decoded"],
219
- fees: resp.result["fees"]
225
+ decoded: DecodedOutput.new(
226
+ out_messages: resp.result.dig("decoded", "out_messages"),
227
+ output: resp.result.dig("decoded", "output")
228
+ ),
229
+ fees: Tvm::TransactionFees.new(**resp.result["fees"].transform_keys(&:to_sym))
220
230
  )
221
231
  )
222
232
  else
@@ -1,4 +1,4 @@
1
1
  module TonSdk
2
- VERSION = "1.27.0"
3
- NATIVE_SDK_VERSION = "1.27.0"
2
+ VERSION = "1.28.0"
3
+ NATIVE_SDK_VERSION = "1.28.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.27.0
4
+ version: 1.28.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-12-07 00:00:00.000000000 Z
11
+ date: 2022-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi