everscale-client-ruby 1.1.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/ton-client-ruby +50 -0
- data/lib/code_generator/api.json +13837 -0
- data/lib/code_generator/api_converter.rb +400 -0
- data/lib/code_generator/code_generator.rb +339 -0
- data/lib/code_generator/helpers.rb +13 -0
- data/lib/code_generator/release.rb +48 -0
- data/lib/everscale-client-ruby/Binding/binding.rb +209 -0
- data/lib/everscale-client-ruby/Binding/struct.rb +21 -0
- data/lib/everscale-client-ruby/Client/Abi.rb +196 -0
- data/lib/everscale-client-ruby/Client/Boc.rb +196 -0
- data/lib/everscale-client-ruby/Client/Client.rb +83 -0
- data/lib/everscale-client-ruby/Client/Context.rb +34 -0
- data/lib/everscale-client-ruby/Client/Crypto.rb +465 -0
- data/lib/everscale-client-ruby/Client/Debot.rb +60 -0
- data/lib/everscale-client-ruby/Client/Net.rb +237 -0
- data/lib/everscale-client-ruby/Client/Processing.rb +59 -0
- data/lib/everscale-client-ruby/Client/Proofs.rb +34 -0
- data/lib/everscale-client-ruby/Client/Tvm.rb +62 -0
- data/lib/everscale-client-ruby/Client/Utils.rb +59 -0
- data/lib/everscale-client-ruby/Helpers/CommonHelpers.rb +70 -0
- data/lib/everscale-client-ruby/version.rb +4 -0
- data/lib/everscale-client-ruby.rb +44 -0
- metadata +164 -0
@@ -0,0 +1,237 @@
|
|
1
|
+
module TonClient
|
2
|
+
|
3
|
+
class Net
|
4
|
+
include CommonInstanceHelpers
|
5
|
+
|
6
|
+
attr_reader :core, :context
|
7
|
+
MODULE = self.to_s.downcase.gsub(/^(.+::|)(\w+)$/, '\2').freeze
|
8
|
+
|
9
|
+
def initialize(context: Context.new, core: TonClient::TonBinding)
|
10
|
+
@context = context
|
11
|
+
@core = core
|
12
|
+
end
|
13
|
+
|
14
|
+
# INPUT: ParamsOfQuery
|
15
|
+
# query: String - # # GraphQL query text.
|
16
|
+
# variables: Value - # # Variables used in query. # # Must be a map with named values that can be used in query.
|
17
|
+
# RESPONSE: ResultOfQuery
|
18
|
+
# result: Value - # # Result provided by DAppServer.
|
19
|
+
def query(payload, &block)
|
20
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
21
|
+
end
|
22
|
+
|
23
|
+
# INPUT: ParamsOfBatchQuery
|
24
|
+
# operations: Array - # # List of query operations that must be performed per single fetch.
|
25
|
+
# RESPONSE: ResultOfBatchQuery
|
26
|
+
# results: Array - # # Result values for batched queries. # # Returns an array of values. Each value corresponds to `queries` item.
|
27
|
+
def batch_query(payload, &block)
|
28
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
29
|
+
end
|
30
|
+
|
31
|
+
# INPUT: ParamsOfQueryCollection
|
32
|
+
# collection: String - # # Collection name (accounts, blocks, transactions, messages, block_signatures)
|
33
|
+
# filter: Value - # # Collection filter
|
34
|
+
# result: String - # # Projection (result) string
|
35
|
+
# order: Array<Optional> - # # Sorting order
|
36
|
+
# limit: Number<Optional> - # # Number of documents to return
|
37
|
+
# RESPONSE: ResultOfQueryCollection
|
38
|
+
# result: Array - # # Objects that match the provided criteria
|
39
|
+
def query_collection(payload, &block)
|
40
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
41
|
+
end
|
42
|
+
|
43
|
+
# INPUT: ParamsOfAggregateCollection
|
44
|
+
# collection: String - # # Collection name (accounts, blocks, transactions, messages, block_signatures)
|
45
|
+
# filter: Value - # # Collection filter
|
46
|
+
# fields: Array<Optional> - # # Projection (result) string
|
47
|
+
# RESPONSE: ResultOfAggregateCollection
|
48
|
+
# values: Value - # # Values for requested fields. # # Returns an array of strings. Each string refers to the corresponding `fields` item.
|
49
|
+
# Numeric value is returned as a decimal string representations.
|
50
|
+
def aggregate_collection(payload, &block)
|
51
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
52
|
+
end
|
53
|
+
|
54
|
+
# INPUT: ParamsOfWaitForCollection
|
55
|
+
# collection: String - # # Collection name (accounts, blocks, transactions, messages, block_signatures)
|
56
|
+
# filter: Value - # # Collection filter
|
57
|
+
# result: String - # # Projection (result) string
|
58
|
+
# timeout: Number<Optional> - # # Query timeout
|
59
|
+
# RESPONSE: ResultOfWaitForCollection
|
60
|
+
# result: Value - # # First found object that matches the provided criteria
|
61
|
+
def wait_for_collection(payload, &block)
|
62
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
63
|
+
end
|
64
|
+
|
65
|
+
# INPUT: ResultOfSubscribeCollection
|
66
|
+
# handle: Number - # # Subscription handle. # # Must be closed with `unsubscribe`
|
67
|
+
def unsubscribe(payload, &block)
|
68
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
69
|
+
end
|
70
|
+
|
71
|
+
# INPUT: ParamsOfSubscribeCollection
|
72
|
+
# collection: String - # # Collection name (accounts, blocks, transactions, messages, block_signatures)
|
73
|
+
# filter: Value - # # Collection filter
|
74
|
+
# result: String - # # Projection (result) string
|
75
|
+
# RESPONSE: ResultOfSubscribeCollection
|
76
|
+
# handle: Number - # # Subscription handle. # # Must be closed with `unsubscribe`
|
77
|
+
def subscribe_collection(payload, &block)
|
78
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
79
|
+
end
|
80
|
+
|
81
|
+
# INPUT: ParamsOfSubscribe
|
82
|
+
# subscription: String - # # GraphQL subscription text.
|
83
|
+
# variables: Value - # # Variables used in subscription. # # Must be a map with named values that can be used in query.
|
84
|
+
# RESPONSE: ResultOfSubscribeCollection
|
85
|
+
# handle: Number - # # Subscription handle. # # Must be closed with `unsubscribe`
|
86
|
+
def subscribe(payload, &block)
|
87
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
88
|
+
end
|
89
|
+
|
90
|
+
def suspend(&block)
|
91
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: {}, &block)
|
92
|
+
end
|
93
|
+
|
94
|
+
def resume(&block)
|
95
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: {}, &block)
|
96
|
+
end
|
97
|
+
|
98
|
+
# INPUT: ParamsOfFindLastShardBlock
|
99
|
+
# address: String - # # Account address
|
100
|
+
# RESPONSE: ResultOfFindLastShardBlock
|
101
|
+
# block_id: String - # # Account shard last block ID
|
102
|
+
def find_last_shard_block(payload, &block)
|
103
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
104
|
+
end
|
105
|
+
|
106
|
+
# RESPONSE: EndpointsSet
|
107
|
+
# endpoints: Array - # # List of endpoints provided by server
|
108
|
+
def fetch_endpoints(&block)
|
109
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: {}, &block)
|
110
|
+
end
|
111
|
+
|
112
|
+
# INPUT: EndpointsSet
|
113
|
+
# endpoints: Array - # # List of endpoints provided by server
|
114
|
+
def set_endpoints(payload, &block)
|
115
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
116
|
+
end
|
117
|
+
|
118
|
+
# RESPONSE: ResultOfGetEndpoints
|
119
|
+
# query: String - # # Current query endpoint
|
120
|
+
# endpoints: Array - # # List of all endpoints used by client
|
121
|
+
def get_endpoints(&block)
|
122
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: {}, &block)
|
123
|
+
end
|
124
|
+
|
125
|
+
# INPUT: ParamsOfQueryCounterparties
|
126
|
+
# account: String - # # Account address
|
127
|
+
# result: String - # # Projection (result) string
|
128
|
+
# first: Number<Optional> - # # Number of counterparties to return
|
129
|
+
# after: String<Optional> - # # `cursor` field of the last received result
|
130
|
+
# RESPONSE: ResultOfQueryCollection
|
131
|
+
# result: Array - # # Objects that match the provided criteria
|
132
|
+
def query_counterparties(payload, &block)
|
133
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
134
|
+
end
|
135
|
+
|
136
|
+
# INPUT: ParamsOfQueryTransactionTree
|
137
|
+
# in_msg: String - # # Input message id.
|
138
|
+
# abi_registry: Array<Optional> - # # List of contract ABIs that will be used to decode message bodies. Library will try to decode each returned message body using any ABI from the registry.
|
139
|
+
# timeout: Number<Optional> - # # Timeout used to limit waiting time for the missing messages and transaction. # # If some of the following messages and transactions are missing yetThe maximum waiting time is regulated by this option.
|
140
|
+
# Default value is 60000 (1 min).
|
141
|
+
# RESPONSE: ResultOfQueryTransactionTree
|
142
|
+
# messages: Array - # # Messages.
|
143
|
+
# transactions: Array - # # Transactions.
|
144
|
+
def query_transaction_tree(payload, &block)
|
145
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
146
|
+
end
|
147
|
+
|
148
|
+
# INPUT: ParamsOfCreateBlockIterator
|
149
|
+
# start_time: Number<Optional> - # # Starting time to iterate from. # # If the application specifies this parameter then the iterationincludes blocks with `gen_utime` >= `start_time`.
|
150
|
+
# Otherwise the iteration starts from zero state.
|
151
|
+
# Must be specified in seconds.
|
152
|
+
# end_time: Number<Optional> - # # Optional end time to iterate for. # # If the application specifies this parameter then the iterationincludes blocks with `gen_utime` < `end_time`.
|
153
|
+
# Otherwise the iteration never stops.
|
154
|
+
# Must be specified in seconds.
|
155
|
+
# shard_filter: Array<Optional> - # # Shard prefix filter. # # If the application specifies this parameter and it is not the empty arraythen the iteration will include items related to accounts that belongs tothe specified shard prefixes.
|
156
|
+
# Shard prefix must be represented as a string "workchain:prefix".
|
157
|
+
# Where `workchain` is a signed integer and the `prefix` if a hexadecimalrepresentation if the 64-bit unsigned integer with tagged shard prefix.
|
158
|
+
# For example: "0:3800000000000000".
|
159
|
+
# result: String<Optional> - # # Projection (result) string. # # List of the fields that must be returned for iterated items.
|
160
|
+
# This field is the same as the `result` parameter ofthe `query_collection` function.
|
161
|
+
# Note that iterated items can contains additional fields that arenot requested in the `result`.
|
162
|
+
# RESPONSE: RegisteredIterator
|
163
|
+
# handle: Number - # # Iterator handle. # # Must be removed using `remove_iterator`when it is no more needed for the application.
|
164
|
+
def create_block_iterator(payload, &block)
|
165
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
166
|
+
end
|
167
|
+
|
168
|
+
# INPUT: ParamsOfResumeBlockIterator
|
169
|
+
# resume_state: Value - # # Iterator state from which to resume. # # Same as value returned from `iterator_next`.
|
170
|
+
# RESPONSE: RegisteredIterator
|
171
|
+
# handle: Number - # # Iterator handle. # # Must be removed using `remove_iterator`when it is no more needed for the application.
|
172
|
+
def resume_block_iterator(payload, &block)
|
173
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
174
|
+
end
|
175
|
+
|
176
|
+
# INPUT: ParamsOfCreateTransactionIterator
|
177
|
+
# start_time: Number<Optional> - # # Starting time to iterate from. # # If the application specifies this parameter then the iterationincludes blocks with `gen_utime` >= `start_time`.
|
178
|
+
# Otherwise the iteration starts from zero state.
|
179
|
+
# Must be specified in seconds.
|
180
|
+
# end_time: Number<Optional> - # # Optional end time to iterate for. # # If the application specifies this parameter then the iterationincludes blocks with `gen_utime` < `end_time`.
|
181
|
+
# Otherwise the iteration never stops.
|
182
|
+
# Must be specified in seconds.
|
183
|
+
# shard_filter: Array<Optional> - # # Shard prefix filters. # # If the application specifies this parameter and it is not an empty arraythen the iteration will include items related to accounts that belongs tothe specified shard prefixes.
|
184
|
+
# Shard prefix must be represented as a string "workchain:prefix".
|
185
|
+
# Where `workchain` is a signed integer and the `prefix` if a hexadecimalrepresentation if the 64-bit unsigned integer with tagged shard prefix.
|
186
|
+
# For example: "0:3800000000000000".
|
187
|
+
# Account address conforms to the shard filter ifit belongs to the filter workchain and the first bits of address match tothe shard prefix. Only transactions with suitable account addresses are iterated.
|
188
|
+
# accounts_filter: Array<Optional> - # # Account address filter. # # Application can specify the list of accounts for whichit wants to iterate transactions.
|
189
|
+
# If this parameter is missing or an empty list then the library iteratestransactions for all accounts that pass the shard filter.
|
190
|
+
# Note that the library doesn't detect conflicts between the account filter and the shard filterif both are specified.
|
191
|
+
# So it is an application responsibility to specify the correct filter combination.
|
192
|
+
# result: String<Optional> - # # Projection (result) string. # # List of the fields that must be returned for iterated items.
|
193
|
+
# This field is the same as the `result` parameter ofthe `query_collection` function.
|
194
|
+
# Note that iterated items can contain additional fields that arenot requested in the `result`.
|
195
|
+
# include_transfers: Boolean<Optional> - # # Include `transfers` field in iterated transactions. # # If this parameter is `true` then each transaction contains field`transfers` with list of transfer. See more about this structure in function description.
|
196
|
+
# RESPONSE: RegisteredIterator
|
197
|
+
# handle: Number - # # Iterator handle. # # Must be removed using `remove_iterator`when it is no more needed for the application.
|
198
|
+
def create_transaction_iterator(payload, &block)
|
199
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
200
|
+
end
|
201
|
+
|
202
|
+
# INPUT: ParamsOfResumeTransactionIterator
|
203
|
+
# resume_state: Value - # # Iterator state from which to resume. # # Same as value returned from `iterator_next`.
|
204
|
+
# accounts_filter: Array<Optional> - # # Account address filter. # # Application can specify the list of accounts for whichit wants to iterate transactions.
|
205
|
+
# If this parameter is missing or an empty list then the library iteratestransactions for all accounts that passes the shard filter.
|
206
|
+
# Note that the library doesn't detect conflicts between the account filter and the shard filterif both are specified.
|
207
|
+
# So it is the application's responsibility to specify the correct filter combination.
|
208
|
+
# RESPONSE: RegisteredIterator
|
209
|
+
# handle: Number - # # Iterator handle. # # Must be removed using `remove_iterator`when it is no more needed for the application.
|
210
|
+
def resume_transaction_iterator(payload, &block)
|
211
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
212
|
+
end
|
213
|
+
|
214
|
+
# INPUT: ParamsOfIteratorNext
|
215
|
+
# iterator: Number - # # Iterator handle
|
216
|
+
# limit: Number<Optional> - # # Maximum count of the returned items. # # If value is missing or is less than 1 the library uses 1.
|
217
|
+
# return_resume_state: Boolean<Optional> - # # Indicates that function must return the iterator state that can be used for resuming iteration.
|
218
|
+
# RESPONSE: ResultOfIteratorNext
|
219
|
+
# items: Array - # # Next available items. # # Note that `iterator_next` can return an empty items and `has_more` equals to `true`.
|
220
|
+
# In this case the application have to continue iteration.
|
221
|
+
# Such situation can take place when there is no data yet butthe requested `end_time` is not reached.
|
222
|
+
# has_more: Boolean - # # Indicates that there are more available items in iterated range.
|
223
|
+
# resume_state: Value<Optional> - # # Optional iterator state that can be used for resuming iteration. # # This field is returned only if the `return_resume_state` parameteris specified.
|
224
|
+
# Note that `resume_state` corresponds to the iteration positionafter the returned items.
|
225
|
+
def iterator_next(payload, &block)
|
226
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
227
|
+
end
|
228
|
+
|
229
|
+
# INPUT: RegisteredIterator
|
230
|
+
# handle: Number - # # Iterator handle. # # Must be removed using `remove_iterator`when it is no more needed for the application.
|
231
|
+
def remove_iterator(payload, &block)
|
232
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
233
|
+
end
|
234
|
+
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module TonClient
|
2
|
+
|
3
|
+
class Processing
|
4
|
+
include CommonInstanceHelpers
|
5
|
+
|
6
|
+
attr_reader :core, :context
|
7
|
+
MODULE = self.to_s.downcase.gsub(/^(.+::|)(\w+)$/, '\2').freeze
|
8
|
+
|
9
|
+
def initialize(context: Context.new, core: TonClient::TonBinding)
|
10
|
+
@context = context
|
11
|
+
@core = core
|
12
|
+
end
|
13
|
+
|
14
|
+
# INPUT: ParamsOfSendMessage
|
15
|
+
# message: String - # # Message BOC.
|
16
|
+
# abi: Value<Optional> - # # Optional message ABI. # # If this parameter is specified and the message has the`expire` header then expiration time will be checked againstthe current time to prevent unnecessary sending of already expired message.
|
17
|
+
# The `message already expired` error will be returned in thiscase.
|
18
|
+
# Note, that specifying `abi` for ABI compliant contracts isstrongly recommended, so that proper processing strategy can bechosen.
|
19
|
+
# send_events: Boolean - # # Flag for requesting events sending
|
20
|
+
# RESPONSE: ResultOfSendMessage
|
21
|
+
# shard_block_id: String - # # The last generated shard block of the message destination account before the message was sent. # # This block id must be used as a parameter of the`wait_for_transaction`.
|
22
|
+
# sending_endpoints: Array - # # The list of endpoints to which the message was sent. # # This list id must be used as a parameter of the`wait_for_transaction`.
|
23
|
+
def send_message(payload, &block)
|
24
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
25
|
+
end
|
26
|
+
|
27
|
+
# INPUT: ParamsOfWaitForTransaction
|
28
|
+
# abi: Value<Optional> - # # Optional ABI for decoding the transaction result. # # If it is specified, then the output messages' bodies will bedecoded according to this ABI.
|
29
|
+
# The `abi_decoded` result field will be filled out.
|
30
|
+
# message: String - # # Message BOC. # # Encoded with `base64`.
|
31
|
+
# shard_block_id: String - # # The last generated block id of the destination account shard before the message was sent. # # You must provide the same value as the `send_message` has returned.
|
32
|
+
# send_events: Boolean - # # Flag that enables/disables intermediate events
|
33
|
+
# sending_endpoints: Array<Optional> - # # The list of endpoints to which the message was sent. # # Use this field to get more informative errors.
|
34
|
+
# Provide the same value as the `send_message` has returned.
|
35
|
+
# If the message was not delivered (expired), SDK will log the endpoint URLs, used for its sending.
|
36
|
+
# RESPONSE: ResultOfProcessMessage
|
37
|
+
# transaction: Value - # # Parsed transaction. # # In addition to the regular transaction fields there is a`boc` field encoded with `base64` which contains sourcetransaction BOC.
|
38
|
+
# out_messages: Array - # # List of output messages' BOCs. # # Encoded as `base64`
|
39
|
+
# decoded: DecodedOutput<Optional> - # # Optional decoded message bodies according to the optional `abi` parameter.
|
40
|
+
# fees: TransactionFees - # # Transaction fees
|
41
|
+
def wait_for_transaction(payload, &block)
|
42
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
43
|
+
end
|
44
|
+
|
45
|
+
# INPUT: ParamsOfProcessMessage
|
46
|
+
# message_encode_params: ParamsOfEncodeMessage - # # Message encode parameters.
|
47
|
+
# send_events: Boolean - # # Flag for requesting events sending
|
48
|
+
# RESPONSE: ResultOfProcessMessage
|
49
|
+
# transaction: Value - # # Parsed transaction. # # In addition to the regular transaction fields there is a`boc` field encoded with `base64` which contains sourcetransaction BOC.
|
50
|
+
# out_messages: Array - # # List of output messages' BOCs. # # Encoded as `base64`
|
51
|
+
# decoded: DecodedOutput<Optional> - # # Optional decoded message bodies according to the optional `abi` parameter.
|
52
|
+
# fees: TransactionFees - # # Transaction fees
|
53
|
+
def process_message(payload, &block)
|
54
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module TonClient
|
2
|
+
|
3
|
+
class Proofs
|
4
|
+
include CommonInstanceHelpers
|
5
|
+
|
6
|
+
attr_reader :core, :context
|
7
|
+
MODULE = self.to_s.downcase.gsub(/^(.+::|)(\w+)$/, '\2').freeze
|
8
|
+
|
9
|
+
def initialize(context: Context.new, core: TonClient::TonBinding)
|
10
|
+
@context = context
|
11
|
+
@core = core
|
12
|
+
end
|
13
|
+
|
14
|
+
# INPUT: ParamsOfProofBlockData
|
15
|
+
# block: Value - # # Single block's data, retrieved from TONOS API, that needs proof. Required fields are `id` and/or top-level `boc` (for block identification), others are optional.
|
16
|
+
def proof_block_data(payload, &block)
|
17
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
18
|
+
end
|
19
|
+
|
20
|
+
# INPUT: ParamsOfProofTransactionData
|
21
|
+
# transaction: Value - # # Single transaction's data as queried from DApp server, without modifications. The required fields are `id` and/or top-level `boc`, others are optional. In order to reduce network requests count, it is recommended to provide `block_id` and `boc` of transaction.
|
22
|
+
def proof_transaction_data(payload, &block)
|
23
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
24
|
+
end
|
25
|
+
|
26
|
+
# INPUT: ParamsOfProofMessageData
|
27
|
+
# message: Value - # # Single message's data as queried from DApp server, without modifications. The required fields are `id` and/or top-level `boc`, others are optional. In order to reduce network requests count, it is recommended to provide at least `boc` of message and non-null `src_transaction.id` or `dst_transaction.id`.
|
28
|
+
def proof_message_data(payload, &block)
|
29
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module TonClient
|
2
|
+
|
3
|
+
class Tvm
|
4
|
+
include CommonInstanceHelpers
|
5
|
+
|
6
|
+
attr_reader :core, :context
|
7
|
+
MODULE = self.to_s.downcase.gsub(/^(.+::|)(\w+)$/, '\2').freeze
|
8
|
+
|
9
|
+
def initialize(context: Context.new, core: TonClient::TonBinding)
|
10
|
+
@context = context
|
11
|
+
@core = core
|
12
|
+
end
|
13
|
+
|
14
|
+
# INPUT: ParamsOfRunExecutor
|
15
|
+
# message: String - # # Input message BOC. # # Must be encoded as base64.
|
16
|
+
# account: AccountForExecutor - # # Account to run on executor
|
17
|
+
# execution_options: ExecutionOptions<Optional> - # # Execution options.
|
18
|
+
# abi: Value<Optional> - # # Contract ABI for decoding output messages
|
19
|
+
# skip_transaction_check: Boolean<Optional> - # # Skip transaction check flag
|
20
|
+
# boc_cache: BocCacheType<Optional> - # # Cache type to put the result. # # The BOC itself returned if no cache type provided
|
21
|
+
# return_updated_account: Boolean<Optional> - # # Return updated account flag. # # Empty string is returned if the flag is `false`
|
22
|
+
# RESPONSE: ResultOfRunExecutor
|
23
|
+
# transaction: Value - # # Parsed transaction. # # In addition to the regular transaction fields there is a`boc` field encoded with `base64` which contains sourcetransaction BOC.
|
24
|
+
# out_messages: Array - # # List of output messages' BOCs. # # Encoded as `base64`
|
25
|
+
# decoded: DecodedOutput<Optional> - # # Optional decoded message bodies according to the optional `abi` parameter.
|
26
|
+
# account: String - # # Updated account state BOC. # # Encoded as `base64`
|
27
|
+
# fees: TransactionFees - # # Transaction fees
|
28
|
+
def run_executor(payload, &block)
|
29
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
30
|
+
end
|
31
|
+
|
32
|
+
# INPUT: ParamsOfRunTvm
|
33
|
+
# message: String - # # Input message BOC. # # Must be encoded as base64.
|
34
|
+
# account: String - # # Account BOC. # # Must be encoded as base64.
|
35
|
+
# execution_options: ExecutionOptions<Optional> - # # Execution options.
|
36
|
+
# abi: Value<Optional> - # # Contract ABI for decoding output messages
|
37
|
+
# boc_cache: BocCacheType<Optional> - # # Cache type to put the result. # # The BOC itself returned if no cache type provided
|
38
|
+
# return_updated_account: Boolean<Optional> - # # Return updated account flag. # # Empty string is returned if the flag is `false`
|
39
|
+
# RESPONSE: ResultOfRunTvm
|
40
|
+
# out_messages: Array - # # List of output messages' BOCs. # # Encoded as `base64`
|
41
|
+
# decoded: DecodedOutput<Optional> - # # Optional decoded message bodies according to the optional `abi` parameter.
|
42
|
+
# account: String - # # Updated account state BOC. # # Encoded as `base64`. Attention! Only `account_state.storage.state.data` part of the BOC is updated.
|
43
|
+
def run_tvm(payload, &block)
|
44
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
45
|
+
end
|
46
|
+
|
47
|
+
# INPUT: ParamsOfRunGet
|
48
|
+
# account: String - # # Account BOC in `base64`
|
49
|
+
# function_name: String - # # Function name
|
50
|
+
# input: Value - # # Input parameters
|
51
|
+
# execution_options: ExecutionOptions<Optional> - # # Execution options
|
52
|
+
# tuple_list_as_array: Boolean<Optional> - # # Convert lists based on nested tuples in the **result** into plain arrays. # # Default is `false`. Input parameters may use any of lists representationsIf you receive this error on Web: "Runtime error. Unreachable code should not be executed...",set this flag to true.
|
53
|
+
# This may happen, for example, when elector contract contains too many participants
|
54
|
+
# RESPONSE: ResultOfRunGet
|
55
|
+
# output: Value - # # Values returned by get-method on stack
|
56
|
+
def run_get(payload, &block)
|
57
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module TonClient
|
2
|
+
|
3
|
+
class Utils
|
4
|
+
include CommonInstanceHelpers
|
5
|
+
|
6
|
+
attr_reader :core, :context
|
7
|
+
MODULE = self.to_s.downcase.gsub(/^(.+::|)(\w+)$/, '\2').freeze
|
8
|
+
|
9
|
+
def initialize(context: Context.new, core: TonClient::TonBinding)
|
10
|
+
@context = context
|
11
|
+
@core = core
|
12
|
+
end
|
13
|
+
|
14
|
+
# INPUT: ParamsOfConvertAddress
|
15
|
+
# address: String - # # Account address in any TON format.
|
16
|
+
# output_format: AddressStringFormat - # # Specify the format to convert to.
|
17
|
+
# RESPONSE: ResultOfConvertAddress
|
18
|
+
# address: String - # # Address in the specified format
|
19
|
+
def convert_address(payload, &block)
|
20
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
21
|
+
end
|
22
|
+
|
23
|
+
# INPUT: ParamsOfGetAddressType
|
24
|
+
# address: String - # # Account address in any TON format.
|
25
|
+
# RESPONSE: ResultOfGetAddressType
|
26
|
+
# address_type: AccountAddressType - # # Account address type.
|
27
|
+
def get_address_type(payload, &block)
|
28
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
29
|
+
end
|
30
|
+
|
31
|
+
# INPUT: ParamsOfCalcStorageFee
|
32
|
+
# account: String -
|
33
|
+
# period: Number -
|
34
|
+
# RESPONSE: ResultOfCalcStorageFee
|
35
|
+
# fee: String -
|
36
|
+
def calc_storage_fee(payload, &block)
|
37
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
38
|
+
end
|
39
|
+
|
40
|
+
# INPUT: ParamsOfCompressZstd
|
41
|
+
# uncompressed: String - # # Uncompressed data. # # Must be encoded as base64.
|
42
|
+
# level: Number<Optional> - # # Compression level, from 1 to 21. Where: 1 - lowest compression level (fastest compression); 21 - highest compression level (slowest compression). If level is omitted, the default compression level is used (currently `3`).
|
43
|
+
# RESPONSE: ResultOfCompressZstd
|
44
|
+
# compressed: String - # # Compressed data. # # Must be encoded as base64.
|
45
|
+
def compress_zstd(payload, &block)
|
46
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
47
|
+
end
|
48
|
+
|
49
|
+
# INPUT: ParamsOfDecompressZstd
|
50
|
+
# compressed: String - # # Compressed data. # # Must be encoded as base64.
|
51
|
+
# RESPONSE: ResultOfDecompressZstd
|
52
|
+
# decompressed: String - # # Decompressed data. # # Must be encoded as base64.
|
53
|
+
def decompress_zstd(payload, &block)
|
54
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
|
2
|
+
module TonClient
|
3
|
+
|
4
|
+
def self.read_abi(path_to_file)
|
5
|
+
file = File.read(path_to_file)
|
6
|
+
JSON.parse(file)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.read_tvc(path_to_file)
|
10
|
+
data = File.open(path_to_file).read
|
11
|
+
# Encode the puppy
|
12
|
+
encoded = Base64.encode64(data)
|
13
|
+
# Spit it out into one continous string
|
14
|
+
encoded.gsub(/\n/, '')
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.callLibraryMethodSync(method, *args)
|
18
|
+
responses = []
|
19
|
+
queue = Queue.new
|
20
|
+
method.call(*args) do |response|
|
21
|
+
responses << response
|
22
|
+
yield(responses) if block_given?
|
23
|
+
queue.push 1 if response.finished == true
|
24
|
+
end
|
25
|
+
queue.pop
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
module CommonClassHelpers
|
30
|
+
|
31
|
+
def class_attr_accessor(*names)
|
32
|
+
names.each do |name|
|
33
|
+
class_variable_set("@@#{name.to_s}", nil)
|
34
|
+
|
35
|
+
define_singleton_method("#{name.to_s}=".to_sym) do |attr|
|
36
|
+
class_variable_set("@@#{name.to_s}", attr)
|
37
|
+
end
|
38
|
+
|
39
|
+
define_singleton_method(name.to_sym) do
|
40
|
+
class_variable_get("@@#{name.to_s}")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
module CommonInstanceHelpers
|
49
|
+
|
50
|
+
def full_method_name(module_name, method_name)
|
51
|
+
"#{module_name}.#{method_name}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def base64?(value)
|
55
|
+
value.is_a?(String) && (Base64.encode64(Base64.decode64(value)).strip == value)
|
56
|
+
end
|
57
|
+
|
58
|
+
def encode_to_base64(message)
|
59
|
+
Base64.encode64(message.force_encoding('UTF-8')).strip
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
class << Object
|
64
|
+
def private_accessor(*names)
|
65
|
+
names.each do |name|
|
66
|
+
attr_accessor name
|
67
|
+
private "#{name}="
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
require "base64"
|
3
|
+
require 'json'
|
4
|
+
require 'byebug'
|
5
|
+
require 'dotenv'
|
6
|
+
require 'fileutils'
|
7
|
+
require_relative './everscale-client-ruby/Helpers/CommonHelpers.rb'
|
8
|
+
require_relative './everscale-client-ruby/Binding/struct.rb'
|
9
|
+
require_relative './everscale-client-ruby/Binding/binding.rb'
|
10
|
+
require_relative './everscale-client-ruby/Client/Context.rb'
|
11
|
+
require_relative './everscale-client-ruby/Client/Client.rb'
|
12
|
+
require_relative './everscale-client-ruby/Client/Crypto.rb'
|
13
|
+
require_relative './everscale-client-ruby/Client/Abi.rb'
|
14
|
+
require_relative './everscale-client-ruby/Client/Boc.rb'
|
15
|
+
require_relative './everscale-client-ruby/Client/Net.rb'
|
16
|
+
require_relative './everscale-client-ruby/Client/Processing.rb'
|
17
|
+
require_relative './everscale-client-ruby/Client/Tvm.rb'
|
18
|
+
require_relative './everscale-client-ruby/Client/Utils.rb'
|
19
|
+
require_relative './everscale-client-ruby/Client/Debot.rb'
|
20
|
+
require_relative './everscale-client-ruby/version'
|
21
|
+
|
22
|
+
module TonClient
|
23
|
+
|
24
|
+
@@configured = false
|
25
|
+
|
26
|
+
def self.check_configuration
|
27
|
+
raise "Not configured! Please configure TonClient: call ffi_lib(dylib_path)" unless !!@@configured
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.configure
|
31
|
+
yield self
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.ffi_lib(dylib_path = nil)
|
35
|
+
TonBinding.ffi_lib(dylib_path)
|
36
|
+
TonBinding.setup_bindings()
|
37
|
+
@@configured = true
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.create(config: {})
|
41
|
+
check_configuration
|
42
|
+
Client.new(context: Context.new(config: config))
|
43
|
+
end
|
44
|
+
end
|