ever_sdk_client 1.36.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 +7 -0
- data/CHANGELOG.md +72 -0
- data/LICENSE +201 -0
- data/README.md +194 -0
- data/lib/ever_sdk_client/abi.rb +1070 -0
- data/lib/ever_sdk_client/boc.rb +416 -0
- data/lib/ever_sdk_client/client.rb +180 -0
- data/lib/ever_sdk_client/client_context.rb +55 -0
- data/lib/ever_sdk_client/config.rb +77 -0
- data/lib/ever_sdk_client/crypto.rb +1047 -0
- data/lib/ever_sdk_client/debot.rb +367 -0
- data/lib/ever_sdk_client/helper.rb +20 -0
- data/lib/ever_sdk_client/interop.rb +230 -0
- data/lib/ever_sdk_client/kw_struct.rb +7 -0
- data/lib/ever_sdk_client/net.rb +551 -0
- data/lib/ever_sdk_client/processing.rb +268 -0
- data/lib/ever_sdk_client/proofs.rb +61 -0
- data/lib/ever_sdk_client/tvm.rb +251 -0
- data/lib/ever_sdk_client/types.rb +45 -0
- data/lib/ever_sdk_client/utils.rb +122 -0
- data/lib/ever_sdk_client/version.rb +4 -0
- data/lib/ever_sdk_client.rb +6 -0
- metadata +136 -0
@@ -0,0 +1,268 @@
|
|
1
|
+
module EverSdk
|
2
|
+
module Processing
|
3
|
+
#
|
4
|
+
# types
|
5
|
+
#
|
6
|
+
|
7
|
+
module ErrorCode
|
8
|
+
MESSAGE_ALREADY_EXPIRED = 501
|
9
|
+
MESSAGE_HAS_NOT_DESTINATION_ADDRESS = 502
|
10
|
+
CAN_NOT_BUILD_MESSAGE_CELL = 503
|
11
|
+
FETCH_BLOCK_FAILED = 504
|
12
|
+
SEND_MESSAGE_FAILED = 505
|
13
|
+
INVALID_MESSAGE_BOC = 506
|
14
|
+
MESSAGE_EXPIRED = 507
|
15
|
+
TRANSACTION_WAIT_TIMEOUT = 508
|
16
|
+
INVALID_BLOCK_RECEIVED = 509
|
17
|
+
CAN_NOT_CHECK_BLOCK_SHARD = 510
|
18
|
+
BLOCK_NOT_FOUND = 511
|
19
|
+
INVALID_DATA = 512
|
20
|
+
EXTERNAL_SIGNER_MUST_NOT_BE_USED = 513
|
21
|
+
MESSAGE_REJECTED = 514
|
22
|
+
INVALID_REMP_STATUS = 515
|
23
|
+
NEXT_REMP_STATUS_TIMEOUT = 516
|
24
|
+
end
|
25
|
+
|
26
|
+
class ParamsOfSendMessage
|
27
|
+
attr_reader :message, :abi, :send_events
|
28
|
+
|
29
|
+
def initialize(message:, abi: nil, send_events:)
|
30
|
+
@message = message
|
31
|
+
@abi = abi
|
32
|
+
@send_events = send_events
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_h
|
36
|
+
{
|
37
|
+
message: message,
|
38
|
+
abi: abi&.to_h,
|
39
|
+
send_events: send_events
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
ResultOfSendMessage = KwStruct.new(:shard_block_id)
|
45
|
+
|
46
|
+
class ParamsOfWaitForTransaction
|
47
|
+
attr_reader :abi, :message, :shard_block_id, :send_events
|
48
|
+
|
49
|
+
def initialize(abi: nil, message:, shard_block_id:, send_events:)
|
50
|
+
@abi = abi
|
51
|
+
@message = message
|
52
|
+
@shard_block_id = shard_block_id
|
53
|
+
@send_events = send_events
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_h
|
57
|
+
{
|
58
|
+
abi: abi&.to_h,
|
59
|
+
message: message,
|
60
|
+
shard_block_id: shard_block_id,
|
61
|
+
send_events: send_events
|
62
|
+
}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class ResultOfProcessMessage
|
67
|
+
attr_reader :transaction, :out_messages, :decoded, :fees
|
68
|
+
|
69
|
+
def initialize(transaction:, out_messages:, decoded: nil, fees:)
|
70
|
+
@transaction = transaction
|
71
|
+
@out_messages = out_messages
|
72
|
+
@decoded = decoded
|
73
|
+
@fees = fees
|
74
|
+
end
|
75
|
+
|
76
|
+
def to_h
|
77
|
+
{
|
78
|
+
transaction: transaction,
|
79
|
+
out_messages: out_messages,
|
80
|
+
decoded: decoded,
|
81
|
+
fees: fees
|
82
|
+
}
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class ProcessingEvent
|
87
|
+
TYPES = %i[
|
88
|
+
will_fetch_first_block
|
89
|
+
fetch_first_block_failed
|
90
|
+
will_send
|
91
|
+
did_send
|
92
|
+
send_failed
|
93
|
+
will_fetch_next_block
|
94
|
+
fetch_next_block_failed
|
95
|
+
message_expired
|
96
|
+
remp_sent_to_validators
|
97
|
+
remp_included_into_block
|
98
|
+
remp_included_into_accepted_block
|
99
|
+
remp_other
|
100
|
+
remp_error
|
101
|
+
]
|
102
|
+
|
103
|
+
attr_reader :type_, :error, :shard_block_id, :message_id, :message, :args
|
104
|
+
|
105
|
+
def initialize(type_:, error: nil, shard_block_id: nil, message_id: nil, message: nil, **args)
|
106
|
+
unless TYPES.include?(type_)
|
107
|
+
raise ArgumentError.new("type #{type_} is unknown; known types: #{TYPES}")
|
108
|
+
end
|
109
|
+
@type_ = type_
|
110
|
+
@error = error
|
111
|
+
@shard_block_id = shard_block_id
|
112
|
+
@message_id = message_id
|
113
|
+
@message = message
|
114
|
+
@args = args
|
115
|
+
end
|
116
|
+
|
117
|
+
def to_h
|
118
|
+
h1 = {
|
119
|
+
type: @type
|
120
|
+
}
|
121
|
+
|
122
|
+
h2 = case @type_
|
123
|
+
when :will_fetch_first_block
|
124
|
+
{ }
|
125
|
+
when :fetch_first_block_failed
|
126
|
+
{
|
127
|
+
error: @error
|
128
|
+
}
|
129
|
+
when :will_send, :did_send, :will_fetch_next_block
|
130
|
+
{
|
131
|
+
shard_block_id: @shard_block_id,
|
132
|
+
message_id: @message_id,
|
133
|
+
message: @message
|
134
|
+
}
|
135
|
+
when :send_failed, :fetch_next_block_failed
|
136
|
+
{
|
137
|
+
shard_block_id: @shard_block_id,
|
138
|
+
message_id: @message_id,
|
139
|
+
message: @message,
|
140
|
+
error: @error
|
141
|
+
}
|
142
|
+
when :message_expired
|
143
|
+
{
|
144
|
+
message_id: @message_id,
|
145
|
+
message: @message,
|
146
|
+
error: @error
|
147
|
+
}
|
148
|
+
when :remp_sent_to_validators, :remp_included_into_block, :remp_included_into_accepted_block, :remp_other, :remp_error
|
149
|
+
{
|
150
|
+
message_id: message_id,
|
151
|
+
timestamp: args[:timestamp],
|
152
|
+
json: args[:json]
|
153
|
+
}
|
154
|
+
else
|
155
|
+
raise ArgumentError.new("unsupported type: #{@type_}")
|
156
|
+
end
|
157
|
+
|
158
|
+
h1.merge(h2)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
DecodedOutput = KwStruct.new(:out_messages, :output) do
|
163
|
+
def initialize(out_messages:, output: nil)
|
164
|
+
super
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
ParamsOfProcessMessage = KwStruct.new(:message_encode_params, :send_events) do
|
169
|
+
def initialize(message_encode_params:, send_events:)
|
170
|
+
super
|
171
|
+
end
|
172
|
+
|
173
|
+
def to_h
|
174
|
+
{
|
175
|
+
message_encode_params: message_encode_params.to_h,
|
176
|
+
send_events: send_events
|
177
|
+
}
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
|
182
|
+
#
|
183
|
+
# functions
|
184
|
+
#
|
185
|
+
|
186
|
+
def self.send_message(ctx, params, client_callback = nil)
|
187
|
+
if (params.send_events == true) && client_callback.nil?
|
188
|
+
raise ArgumentError.new("with `send_events` set to true, `client_callback` may not be nil")
|
189
|
+
end
|
190
|
+
|
191
|
+
Interop::request_to_native_lib(
|
192
|
+
ctx,
|
193
|
+
"processing.send_message",
|
194
|
+
params,
|
195
|
+
client_callback: client_callback,
|
196
|
+
is_single_thread_only: false
|
197
|
+
) do |resp|
|
198
|
+
if resp.success?
|
199
|
+
yield NativeLibResponseResult.new(
|
200
|
+
result: ResultOfSendMessage.new(shard_block_id: resp.result["shard_block_id"])
|
201
|
+
)
|
202
|
+
else
|
203
|
+
yield resp
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def self.wait_for_transaction(ctx, params, client_callback = nil)
|
209
|
+
if (params.send_events == true) && client_callback.nil?
|
210
|
+
raise ArgumentError.new("with `send_events` set to true, `client_callback` may not be nil")
|
211
|
+
end
|
212
|
+
|
213
|
+
Interop::request_to_native_lib(
|
214
|
+
ctx,
|
215
|
+
"processing.wait_for_transaction",
|
216
|
+
params,
|
217
|
+
client_callback: client_callback,
|
218
|
+
is_single_thread_only: false
|
219
|
+
) do |resp|
|
220
|
+
if resp.success?
|
221
|
+
yield NativeLibResponseResult.new(
|
222
|
+
result: ResultOfProcessMessage.new(
|
223
|
+
transaction: resp.result["transaction"],
|
224
|
+
out_messages: resp.result["out_messages"],
|
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))
|
230
|
+
)
|
231
|
+
)
|
232
|
+
else
|
233
|
+
yield resp
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
def self.process_message(ctx, params, client_callback = nil)
|
239
|
+
if (params.send_events == true) && client_callback.nil?
|
240
|
+
raise ArgumentError.new("with `send_events` set to true `client_callback` may not be nil")
|
241
|
+
end
|
242
|
+
|
243
|
+
Interop::request_to_native_lib(
|
244
|
+
ctx,
|
245
|
+
"processing.process_message",
|
246
|
+
params,
|
247
|
+
client_callback: client_callback,
|
248
|
+
is_single_thread_only: false
|
249
|
+
) do |resp|
|
250
|
+
if resp.success?
|
251
|
+
yield NativeLibResponseResult.new(
|
252
|
+
result: ResultOfProcessMessage.new(
|
253
|
+
transaction: resp.result["transaction"],
|
254
|
+
out_messages: resp.result["out_messages"],
|
255
|
+
decoded: DecodedOutput.new(
|
256
|
+
out_messages: resp.result.dig("decoded", "out_messages"),
|
257
|
+
output: resp.result.dig("decoded", "output")
|
258
|
+
),
|
259
|
+
fees: Tvm::TransactionFees.new(**resp.result["fees"].transform_keys(&:to_sym))
|
260
|
+
)
|
261
|
+
)
|
262
|
+
else
|
263
|
+
yield resp
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module EverSdk
|
2
|
+
module Proofs
|
3
|
+
|
4
|
+
#
|
5
|
+
# types
|
6
|
+
#
|
7
|
+
|
8
|
+
module ErrorCode
|
9
|
+
INVALID_DATA = 901
|
10
|
+
PROOF_CHECK_FAILED = 902
|
11
|
+
INTERNAL_ERROR = 903
|
12
|
+
DATA_DIFFERS_FROM_PROVEN = 904
|
13
|
+
end
|
14
|
+
|
15
|
+
ParamsOfProofBlockData = KwStruct.new(:block)
|
16
|
+
|
17
|
+
ParamsOfProofTransactionData = KwStruct.new(:transaction)
|
18
|
+
|
19
|
+
ParamsOfProofMessageData = KwStruct.new(:message)
|
20
|
+
|
21
|
+
#
|
22
|
+
# functions
|
23
|
+
#
|
24
|
+
|
25
|
+
def self.proof_block_data(ctx, params)
|
26
|
+
Interop::request_to_native_lib(ctx, "proofs.proof_block_data", params) do |resp|
|
27
|
+
if resp.success?
|
28
|
+
yield NativeLibResponseResult.new(
|
29
|
+
result: ""
|
30
|
+
)
|
31
|
+
else
|
32
|
+
yield resp
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.proof_transaction_data(ctx, params)
|
38
|
+
Interop::request_to_native_lib(ctx, "proofs.proof_transaction_data", params) do |resp|
|
39
|
+
if resp.success?
|
40
|
+
yield NativeLibResponseResult.new(
|
41
|
+
result: ""
|
42
|
+
)
|
43
|
+
else
|
44
|
+
yield resp
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.proof_message_data(ctx, params)
|
50
|
+
Interop::request_to_native_lib(ctx, "proofs.proof_message_data", params) do |resp|
|
51
|
+
if resp.success?
|
52
|
+
yield NativeLibResponseResult.new(
|
53
|
+
result: ""
|
54
|
+
)
|
55
|
+
else
|
56
|
+
yield resp
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,251 @@
|
|
1
|
+
module EverSdk
|
2
|
+
module Tvm
|
3
|
+
|
4
|
+
#
|
5
|
+
# types
|
6
|
+
#
|
7
|
+
|
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
|
24
|
+
|
25
|
+
ExecutionOptions = KwStruct.new(:blockchain_config, :block_time, :block_lt, :transaction_lt, :chksig_always_succeed) do
|
26
|
+
def initialize(blockchain_config: nil, block_time: nil, block_lt: nil, transaction_lt: nil, chksig_always_succeed: false)
|
27
|
+
super
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class AccountForExecutor
|
32
|
+
private_class_method :new
|
33
|
+
|
34
|
+
TYPES = [:none, :uninit, :account]
|
35
|
+
attr_reader :type_, :boc, :unlimited_balance
|
36
|
+
|
37
|
+
def self.new_with_type_none
|
38
|
+
@type_ = :none
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.new_with_type_uninit
|
42
|
+
@type_ = :uninit
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.new_with_type_account(boc:, unlimited_balance: nil)
|
46
|
+
@type_ = :account
|
47
|
+
@boc = boc
|
48
|
+
@unlimited_balance = unlimited_balance
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_h
|
52
|
+
h1 = case @type_
|
53
|
+
when :none, :uninit
|
54
|
+
{
|
55
|
+
type: Helper.sym_to_capitalized_case_str(@type_),
|
56
|
+
}
|
57
|
+
when :account
|
58
|
+
{
|
59
|
+
type: Helper.sym_to_capitalized_case_str(@type_),
|
60
|
+
boc: @boc,
|
61
|
+
unlimited_balance: @unlimited_balance
|
62
|
+
}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
ParamsOfRunExecutor = KwStruct.new(
|
68
|
+
:message,
|
69
|
+
:account,
|
70
|
+
:execution_options,
|
71
|
+
:abi,
|
72
|
+
:skip_transaction_check,
|
73
|
+
:boc_cache,
|
74
|
+
:return_updated_account
|
75
|
+
) do
|
76
|
+
def initialize(
|
77
|
+
message:,
|
78
|
+
account:,
|
79
|
+
execution_options: nil,
|
80
|
+
abi: nil,
|
81
|
+
skip_transaction_check: nil,
|
82
|
+
boc_cache: nil,
|
83
|
+
return_updated_account: nil
|
84
|
+
)
|
85
|
+
super
|
86
|
+
end
|
87
|
+
|
88
|
+
def to_h
|
89
|
+
h = super
|
90
|
+
h[:account] = self.account.to_h
|
91
|
+
h[:execution_options] = self.execution_options&.to_h
|
92
|
+
h[:abi] = self.abi&.to_h
|
93
|
+
h[:boc_cache] = self.boc_cache&.to_h
|
94
|
+
h
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
ResultOfRunExecutor = KwStruct.new(:transaction, :out_messages, :decoded, :account, :fees) do
|
99
|
+
def initialize(transaction:, out_messages:, decoded: nil, account:, fees:)
|
100
|
+
super
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
class ParamsOfRunTvm
|
105
|
+
attr_reader :message, :account, :execution_options, :abi,
|
106
|
+
:boc_cache, :return_updated_account
|
107
|
+
|
108
|
+
def initialize(message:, account:, execution_options: nil, abi: nil, boc_cache: nil, return_updated_account: nil)
|
109
|
+
@message = message
|
110
|
+
@account = account
|
111
|
+
@execution_options = execution_options
|
112
|
+
@abi = abi
|
113
|
+
@boc_cache = boc_cache
|
114
|
+
@return_updated_account = return_updated_account
|
115
|
+
end
|
116
|
+
|
117
|
+
def to_h
|
118
|
+
{
|
119
|
+
message: @message,
|
120
|
+
account: @account,
|
121
|
+
execution_options: @execution_options&.to_h,
|
122
|
+
abi: @abi&.to_h,
|
123
|
+
boc_cache: @boc_cache&.to_h,
|
124
|
+
return_updated_account: @return_updated_account
|
125
|
+
}
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
ResultOfRunTvm = KwStruct.new(:out_messages, :decoded, :account) do
|
130
|
+
def initialize(out_messages:, decoded: nil, account:)
|
131
|
+
super
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
class ParamsOfRunGet
|
136
|
+
attr_reader :account, :function_name, :input, :execution_options, :tuple_list_as_array
|
137
|
+
|
138
|
+
def initialize(account:, function_name:, input: nil, execution_options: nil, tuple_list_as_array: nil)
|
139
|
+
@account = account
|
140
|
+
@function_name = function_name
|
141
|
+
@input = input
|
142
|
+
@execution_options = execution_options
|
143
|
+
@tuple_list_as_array = tuple_list_as_array
|
144
|
+
end
|
145
|
+
|
146
|
+
def to_h
|
147
|
+
{
|
148
|
+
account: @account,
|
149
|
+
function_name: @function_name,
|
150
|
+
input: @input,
|
151
|
+
execution_options: @execution_options&.to_h,
|
152
|
+
tuple_list_as_array: @tuple_list_as_array
|
153
|
+
}
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
ResultOfRunGet = KwStruct.new(:output)
|
158
|
+
|
159
|
+
TransactionFees = KwStruct.new(
|
160
|
+
:in_msg_fwd_fee,
|
161
|
+
:storage_fee,
|
162
|
+
:gas_fee,
|
163
|
+
:out_msgs_fwd_fee,
|
164
|
+
:total_account_fees,
|
165
|
+
:total_output,
|
166
|
+
:ext_in_msg_fee,
|
167
|
+
:total_fwd_fees,
|
168
|
+
:account_fees
|
169
|
+
) do
|
170
|
+
def initialize(
|
171
|
+
in_msg_fwd_fee:,
|
172
|
+
storage_fee:,
|
173
|
+
gas_fee:,
|
174
|
+
out_msgs_fwd_fee:,
|
175
|
+
total_account_fees:,
|
176
|
+
total_output:,
|
177
|
+
ext_in_msg_fee:,
|
178
|
+
total_fwd_fees:,
|
179
|
+
account_fees:
|
180
|
+
)
|
181
|
+
super
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
|
186
|
+
#
|
187
|
+
# functions
|
188
|
+
#
|
189
|
+
|
190
|
+
def self.run_executor(ctx, params)
|
191
|
+
Interop::request_to_native_lib(
|
192
|
+
ctx,
|
193
|
+
"tvm.run_executor",
|
194
|
+
params,
|
195
|
+
is_single_thread_only: false
|
196
|
+
) do |resp|
|
197
|
+
if resp.success?
|
198
|
+
yield NativeLibResponseResult.new(
|
199
|
+
result: ResultOfRunExecutor.new(
|
200
|
+
transaction: resp.result["transaction"],
|
201
|
+
out_messages: resp.result["out_messages"],
|
202
|
+
decoded: resp.result["decoded"],
|
203
|
+
account: resp.result["account"],
|
204
|
+
fees: resp.result["fees"]
|
205
|
+
)
|
206
|
+
)
|
207
|
+
else
|
208
|
+
yield resp
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def self.run_tvm(ctx, params)
|
214
|
+
Interop::request_to_native_lib(
|
215
|
+
ctx,
|
216
|
+
"tvm.run_tvm",
|
217
|
+
params,
|
218
|
+
is_single_thread_only: false
|
219
|
+
) do |resp|
|
220
|
+
if resp.success?
|
221
|
+
yield NativeLibResponseResult.new(
|
222
|
+
result: ResultOfRunTvm.new(
|
223
|
+
out_messages: resp.result["out_messages"],
|
224
|
+
decoded: resp.result["decoded"],
|
225
|
+
account: resp.result["account"]
|
226
|
+
)
|
227
|
+
)
|
228
|
+
else
|
229
|
+
yield resp
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
def self.run_get(ctx, params)
|
235
|
+
Interop::request_to_native_lib(
|
236
|
+
ctx,
|
237
|
+
"tvm.run_get",
|
238
|
+
params,
|
239
|
+
is_single_thread_only: false
|
240
|
+
) do |resp|
|
241
|
+
if resp.success?
|
242
|
+
yield NativeLibResponseResult.new(
|
243
|
+
result: ResultOfRunGet.new(output: resp.result["output"])
|
244
|
+
)
|
245
|
+
else
|
246
|
+
yield resp
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module EverSdk
|
2
|
+
class ResultOfConvertAddress
|
3
|
+
attr_reader :address
|
4
|
+
|
5
|
+
def initialize(a)
|
6
|
+
@address = a
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class SdkError < StandardError
|
11
|
+
attr_reader :code, :message, :data
|
12
|
+
|
13
|
+
def initialize(code: nil, message: nil, data: nil)
|
14
|
+
@code = code
|
15
|
+
@message = message
|
16
|
+
@data = data
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class NativeLibResponseResult
|
21
|
+
attr_reader :result, :error
|
22
|
+
|
23
|
+
def initialize(result: nil, error: nil)
|
24
|
+
if !result.nil? && !error.nil?
|
25
|
+
raise ArgumentError.new('only either argument, result or error, should be specified')
|
26
|
+
elsif !result.nil?
|
27
|
+
@result = result
|
28
|
+
elsif !error.nil?
|
29
|
+
@error = SdkError.new(
|
30
|
+
code: error["code"],
|
31
|
+
message: error["message"],
|
32
|
+
data: error["data"]
|
33
|
+
)
|
34
|
+
else
|
35
|
+
# Some methods like unsubscribe will trigger this error. Should be refactored
|
36
|
+
raise ArgumentError.new('some arguments are wrong; provide either result or error')
|
37
|
+
end
|
38
|
+
|
39
|
+
self
|
40
|
+
end
|
41
|
+
|
42
|
+
def success? = !@result.nil?
|
43
|
+
def failure? = !@error.nil?
|
44
|
+
end
|
45
|
+
end
|