ton-client-ruby 1.1.4 → 1.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ton-client-ruby +4 -4
- data/lib/code_generator/api.json +12230 -0
- data/lib/code_generator/code_generator.rb +12 -3
- data/lib/code_generator/release.rb +48 -0
- data/lib/ton-client-ruby/Client/Abi.rb +22 -0
- data/lib/ton-client-ruby/Client/Boc.rb +56 -1
- data/lib/ton-client-ruby/Client/Debot.rb +1 -1
- data/lib/ton-client-ruby/version.rb +1 -1
- metadata +5 -3
@@ -46,7 +46,8 @@ class CodeGenerator
|
|
46
46
|
content = %{
|
47
47
|
# Ruby Client for Free TON SDK
|
48
48
|
|
49
|
-
[![GEM](https://img.shields.io/badge/ruby-gem-
|
49
|
+
[![GEM](https://img.shields.io/badge/ruby-gem-orange)](https://rubygems.org/gems/ton-client-ruby)
|
50
|
+
[![SPM](https://img.shields.io/badge/SDK%20VERSION-#{types.version}-green)](https://github.com/tonlabs/TON-SDK)
|
50
51
|
|
51
52
|
## Install
|
52
53
|
|
@@ -174,6 +175,13 @@ curl https://raw.githubusercontent.com/tonlabs/TON-SDK/master/tools/api.json > a
|
|
174
175
|
```\n\n
|
175
176
|
```\n
|
176
177
|
ton-client-ruby update ./api.json\n
|
178
|
+
```\n
|
179
|
+
or\n\n
|
180
|
+
```\n
|
181
|
+
cd ton-client-ruby\n
|
182
|
+
```\n\n
|
183
|
+
```\n
|
184
|
+
./bin/ton-client-ruby update\n
|
177
185
|
```\n
|
178
186
|
}
|
179
187
|
content = checkContent(content)
|
@@ -275,12 +283,13 @@ ton-client-ruby update ./api.json\n
|
|
275
283
|
private def gen_function(function, types)
|
276
284
|
content = getFunctionComment(function, types)
|
277
285
|
content << "#{TAB}#{TAB}def #{function.name}"
|
286
|
+
sdk_method_name = function.name == 'init' ? "'initialize'" : '__method__.to_s'
|
278
287
|
if function.arguments.empty?
|
279
288
|
content << "(&block)\n"
|
280
|
-
content << "#{TAB}#{TAB}#{TAB}core.requestLibrary(context: context.id, method_name: full_method_name(MODULE,
|
289
|
+
content << "#{TAB}#{TAB}#{TAB}core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, #{sdk_method_name}), payload: {}, &block)\n"
|
281
290
|
else
|
282
291
|
content << "(payload, &block)\n"
|
283
|
-
content << "#{TAB}#{TAB}#{TAB}core.requestLibrary(context: context.id, method_name: full_method_name(MODULE,
|
292
|
+
content << "#{TAB}#{TAB}#{TAB}core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, #{sdk_method_name}), payload: payload, &block)\n"
|
284
293
|
end
|
285
294
|
content << "#{TAB}#{TAB}end\n\n"
|
286
295
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
script_file_path = File.expand_path(File.dirname(__FILE__))
|
4
|
+
|
5
|
+
require "#{script_file_path}/api_converter.rb"
|
6
|
+
require "#{script_file_path}/code_generator.rb"
|
7
|
+
GEM_DIR = "#{script_file_path}/../.."
|
8
|
+
|
9
|
+
|
10
|
+
`cd #{script_file_path} && curl https://raw.githubusercontent.com/tonlabs/TON-SDK/master/tools/api.json > api.json`
|
11
|
+
api_json_path = "#{script_file_path}/../../api.json"
|
12
|
+
json = ''
|
13
|
+
if File.exists?(api_json_path)
|
14
|
+
json = File.read(api_json_path)
|
15
|
+
else
|
16
|
+
p "File #{api_json_path} is not exist"
|
17
|
+
exit 0
|
18
|
+
end
|
19
|
+
converter = ApiConverter.new(json)
|
20
|
+
types = converter.convert
|
21
|
+
generator = CodeGenerator.new(types, GEM_DIR)
|
22
|
+
generator.generate_self_code
|
23
|
+
|
24
|
+
version_file = "#{script_file_path}/../ton-client-ruby/version.rb"
|
25
|
+
file = File.read(version_file)
|
26
|
+
|
27
|
+
p 'check version'
|
28
|
+
if file[/VERSION = "(\d+)\.(\d+)\.(\d+)"/]
|
29
|
+
major = $1
|
30
|
+
minor = $2
|
31
|
+
current = $3
|
32
|
+
version = "#{major}.#{minor}.#{current.to_i + 1}"
|
33
|
+
p version
|
34
|
+
data = "module TonClient\n VERSION = \"#{version}\"\nend\n\n"
|
35
|
+
p data
|
36
|
+
p version_file
|
37
|
+
File.open(version_file, 'wb') { |f| f.write(data) }
|
38
|
+
p 'update version'
|
39
|
+
|
40
|
+
puts "make release? Y/N"
|
41
|
+
option = gets
|
42
|
+
if option.strip.downcase == 'y'
|
43
|
+
system(%{cd #{GEM_DIR} && git add .})
|
44
|
+
system(%{cd #{GEM_DIR} && git commit -m 'version #{version}'})
|
45
|
+
system(%{cd #{GEM_DIR} && bash -lc 'rake release'})
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
@@ -138,6 +138,28 @@ module TonClient
|
|
138
138
|
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
139
139
|
end
|
140
140
|
|
141
|
+
# INPUT: ParamsOfUpdateInitialData
|
142
|
+
# abi: Value<Optional> - # # Contract ABI
|
143
|
+
# data: String - # # Data BOC or BOC handle
|
144
|
+
# initial_data: Value - # # List of initial values for contract's static variables. # # `abi` parameter should be provided to set initial data
|
145
|
+
# initial_pubkey: String<Optional> - # # Initial account owner's public key to set into account data
|
146
|
+
# boc_cache: BocCacheType<Optional> - # # Cache type to put the result. The BOC itself returned if no cache type provided.
|
147
|
+
# RESPONSE: ResultOfUpdateInitialData
|
148
|
+
# data: String - # # Updated data BOC or BOC handle
|
149
|
+
def update_initial_data(payload, &block)
|
150
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
151
|
+
end
|
152
|
+
|
153
|
+
# INPUT: ParamsOfDecodeInitialData
|
154
|
+
# abi: Value<Optional> - # # Contract ABI. # # Initial data is decoded if this parameter is provided
|
155
|
+
# data: String - # # Data BOC or BOC handle
|
156
|
+
# RESPONSE: ResultOfDecodeInitialData
|
157
|
+
# initial_data: Value<Optional> - # # List of initial values of contract's public variables. # # Initial data is decoded if `abi` input parameter is provided
|
158
|
+
# initial_pubkey: String - # # Initial account owner's public key
|
159
|
+
def decode_initial_data(payload, &block)
|
160
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
161
|
+
end
|
162
|
+
|
141
163
|
end
|
142
164
|
end
|
143
165
|
|
@@ -70,7 +70,7 @@ module TonClient
|
|
70
70
|
end
|
71
71
|
|
72
72
|
# INPUT: ParamsOfGetCodeFromTvc
|
73
|
-
# tvc: String - # # Contract TVC image
|
73
|
+
# tvc: String - # # Contract TVC image or image BOC handle
|
74
74
|
# RESPONSE: ResultOfGetCodeFromTvc
|
75
75
|
# code: String - # # Contract code encoded as base64
|
76
76
|
def get_code_from_tvc(payload, &block)
|
@@ -110,6 +110,61 @@ module TonClient
|
|
110
110
|
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
111
111
|
end
|
112
112
|
|
113
|
+
# INPUT: ParamsOfGetCodeSalt
|
114
|
+
# code: String - # # Contract code BOC encoded as base64 or code BOC handle
|
115
|
+
# boc_cache: BocCacheType<Optional> - # # Cache type to put the result. The BOC itself returned if no cache type provided.
|
116
|
+
# RESPONSE: ResultOfGetCodeSalt
|
117
|
+
# salt: String<Optional> - # # Contract code salt if present. # # BOC encoded as base64 or BOC handle
|
118
|
+
def get_code_salt(payload, &block)
|
119
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
120
|
+
end
|
121
|
+
|
122
|
+
# INPUT: ParamsOfSetCodeSalt
|
123
|
+
# code: String - # # Contract code BOC encoded as base64 or code BOC handle
|
124
|
+
# salt: String - # # Code salt to set. # # BOC encoded as base64 or BOC handle
|
125
|
+
# boc_cache: BocCacheType<Optional> - # # Cache type to put the result. The BOC itself returned if no cache type provided.
|
126
|
+
# RESPONSE: ResultOfSetCodeSalt
|
127
|
+
# code: String - # # Contract code with salt set. # # BOC encoded as base64 or BOC handle
|
128
|
+
def set_code_salt(payload, &block)
|
129
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
130
|
+
end
|
131
|
+
|
132
|
+
# INPUT: ParamsOfDecodeTvc
|
133
|
+
# tvc: String - # # Contract TVC image BOC encoded as base64 or BOC handle
|
134
|
+
# boc_cache: BocCacheType<Optional> - # # Cache type to put the result. The BOC itself returned if no cache type provided.
|
135
|
+
# RESPONSE: ResultOfDecodeTvc
|
136
|
+
# code: String<Optional> - # # Contract code BOC encoded as base64 or BOC handle
|
137
|
+
# data: String<Optional> - # # Contract data BOC encoded as base64 or BOC handle
|
138
|
+
# library: String<Optional> - # # Contract library BOC encoded as base64 or BOC handle
|
139
|
+
# tick: Boolean<Optional> - # # `special.tick` field. # # Specifies the contract ability to handle tick transactions
|
140
|
+
# tock: Boolean<Optional> - # # `special.tock` field. # # Specifies the contract ability to handle tock transactions
|
141
|
+
# split_depth: Number<Optional> - # # Is present and non-zero only in instances of large smart contracts
|
142
|
+
def decode_tvc(payload, &block)
|
143
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
144
|
+
end
|
145
|
+
|
146
|
+
# INPUT: ParamsOfEncodeTvc
|
147
|
+
# code: String<Optional> - # # Contract code BOC encoded as base64 or BOC handle
|
148
|
+
# data: String<Optional> - # # Contract data BOC encoded as base64 or BOC handle
|
149
|
+
# library: String<Optional> - # # Contract library BOC encoded as base64 or BOC handle
|
150
|
+
# tick: Boolean<Optional> - # # `special.tick` field. # # Specifies the contract ability to handle tick transactions
|
151
|
+
# tock: Boolean<Optional> - # # `special.tock` field. # # Specifies the contract ability to handle tock transactions
|
152
|
+
# split_depth: Number<Optional> - # # Is present and non-zero only in instances of large smart contracts
|
153
|
+
# boc_cache: BocCacheType<Optional> - # # Cache type to put the result. The BOC itself returned if no cache type provided.
|
154
|
+
# RESPONSE: ResultOfEncodeTvc
|
155
|
+
# tvc: String - # # Contract TVC image BOC encoded as base64 or BOC handle of boc_cache parameter was specified
|
156
|
+
def encode_tvc(payload, &block)
|
157
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
158
|
+
end
|
159
|
+
|
160
|
+
# INPUT: ParamsOfGetCompilerVersion
|
161
|
+
# code: String - # # Contract code BOC encoded as base64 or code BOC handle
|
162
|
+
# RESPONSE: ResultOfGetCompilerVersion
|
163
|
+
# version: String<Optional> - # # Compiler version, for example 'sol 0.49.0'
|
164
|
+
def get_compiler_version(payload, &block)
|
165
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, __method__.to_s), payload: payload, &block)
|
166
|
+
end
|
167
|
+
|
113
168
|
end
|
114
169
|
end
|
115
170
|
|
@@ -18,7 +18,7 @@ module TonClient
|
|
18
18
|
# debot_abi: String - # # Debot abi as json string.
|
19
19
|
# info: DebotInfo - # # Debot metadata.
|
20
20
|
def init(payload, &block)
|
21
|
-
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE,
|
21
|
+
core.requestLibrary(context: context.id, method_name: full_method_name(MODULE, 'initialize'), payload: payload, &block)
|
22
22
|
end
|
23
23
|
|
24
24
|
# INPUT: ParamsOfStart
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ton-client-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nerzh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -117,9 +117,11 @@ extensions: []
|
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
119
|
- bin/ton-client-ruby
|
120
|
+
- lib/code_generator/api.json
|
120
121
|
- lib/code_generator/api_converter.rb
|
121
122
|
- lib/code_generator/code_generator.rb
|
122
123
|
- lib/code_generator/helpers.rb
|
124
|
+
- lib/code_generator/release.rb
|
123
125
|
- lib/ton-client-ruby.rb
|
124
126
|
- lib/ton-client-ruby/Binding/binding.rb
|
125
127
|
- lib/ton-client-ruby/Binding/struct.rb
|
@@ -154,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
156
|
- !ruby/object:Gem::Version
|
155
157
|
version: '0'
|
156
158
|
requirements: []
|
157
|
-
rubygems_version: 3.
|
159
|
+
rubygems_version: 3.1.6
|
158
160
|
signing_key:
|
159
161
|
specification_version: 4
|
160
162
|
summary: This is gem ton-client-ruby
|