Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
3bb488f6
Y
YTBP
项目概览
YottaChain
/
YTBP
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTBP
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
3bb488f6
编写于
5月 24, 2018
作者:
B
Brian Johnson
提交者:
GitHub
5月 24, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3371 from brianjohnson5972/3131-cleos-abi-and-wasm
cleos abi and wasm
上级
02e1bb90
f57b1fbb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
7 deletion
+40
-7
plugins/chain_plugin/chain_plugin.cpp
plugins/chain_plugin/chain_plugin.cpp
+5
-1
plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp
.../chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp
+4
-2
programs/cleos/main.cpp
programs/cleos/main.cpp
+31
-4
未找到文件。
plugins/chain_plugin/chain_plugin.cpp
浏览文件 @
3bb488f6
...
...
@@ -714,7 +714,11 @@ read_only::get_code_results read_only::get_code( const get_code_params& params )
const
auto
&
accnt
=
d
.
get
<
account_object
,
by_name
>
(
params
.
account_name
);
if
(
accnt
.
code
.
size
()
)
{
result
.
wast
=
wasm_to_wast
(
(
const
uint8_t
*
)
accnt
.
code
.
data
(),
accnt
.
code
.
size
()
);
if
(
params
.
code_as_wasm
)
{
result
.
wasm
=
string
(
accnt
.
code
.
begin
(),
accnt
.
code
.
end
());
}
else
{
result
.
wast
=
wasm_to_wast
(
(
const
uint8_t
*
)
accnt
.
code
.
data
(),
accnt
.
code
.
size
()
);
}
result
.
code_hash
=
fc
::
sha256
::
hash
(
accnt
.
code
.
data
(),
accnt
.
code
.
size
()
);
}
...
...
plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp
浏览文件 @
3bb488f6
...
...
@@ -113,12 +113,14 @@ public:
struct
get_code_results
{
name
account_name
;
string
wast
;
string
wasm
;
fc
::
sha256
code_hash
;
optional
<
abi_def
>
abi
;
};
struct
get_code_params
{
name
account_name
;
bool
code_as_wasm
=
false
;
};
get_code_results
get_code
(
const
get_code_params
&
params
)
const
;
...
...
@@ -403,9 +405,9 @@ FC_REFLECT( eosio::chain_apis::read_only::get_producers_params, (json)(lower_bou
FC_REFLECT
(
eosio
::
chain_apis
::
read_only
::
get_producers_result
,
(
rows
)(
total_producer_vote_weight
)(
more
)
);
FC_REFLECT
(
eosio
::
chain_apis
::
read_only
::
get_account_results
,
(
account_name
)(
privileged
)(
last_code_update
)(
created
)(
ram_quota
)(
net_weight
)(
cpu_weight
)(
net_limit
)(
cpu_limit
)(
ram_usage
)(
permissions
)(
total_resources
)(
delegated_bandwidth
)(
voter_info
)
)
FC_REFLECT
(
eosio
::
chain_apis
::
read_only
::
get_code_results
,
(
account_name
)(
code_hash
)(
wast
)(
abi
)
)
FC_REFLECT
(
eosio
::
chain_apis
::
read_only
::
get_code_results
,
(
account_name
)(
code_hash
)(
wast
)(
wasm
)(
abi
)
)
FC_REFLECT
(
eosio
::
chain_apis
::
read_only
::
get_account_params
,
(
account_name
)
)
FC_REFLECT
(
eosio
::
chain_apis
::
read_only
::
get_code_params
,
(
account_name
)
)
FC_REFLECT
(
eosio
::
chain_apis
::
read_only
::
get_code_params
,
(
account_name
)
(
code_as_wasm
)
)
FC_REFLECT
(
eosio
::
chain_apis
::
read_only
::
producer_info
,
(
producer_name
)
)
FC_REFLECT
(
eosio
::
chain_apis
::
read_only
::
abi_json_to_bin_params
,
(
code
)(
action
)(
args
)
)
FC_REFLECT
(
eosio
::
chain_apis
::
read_only
::
abi_json_to_bin_result
,
(
binargs
)
)
...
...
programs/cleos/main.cpp
浏览文件 @
3bb488f6
...
...
@@ -1525,18 +1525,27 @@ int main( int argc, char** argv ) {
// get code
string
codeFilename
;
string
abiFilename
;
bool
code_as_wasm
=
false
;
auto
getCode
=
get
->
add_subcommand
(
"code"
,
localized
(
"Retrieve the code and ABI for an account"
),
false
);
getCode
->
add_option
(
"name"
,
accountName
,
localized
(
"The name of the account whose code should be retrieved"
))
->
required
();
getCode
->
add_option
(
"-c,--code"
,
codeFilename
,
localized
(
"The name of the file to save the contract .wast to"
)
);
getCode
->
add_option
(
"-c,--code"
,
codeFilename
,
localized
(
"The name of the file to save the contract .wast
/wasm
to"
)
);
getCode
->
add_option
(
"-a,--abi"
,
abiFilename
,
localized
(
"The name of the file to save the contract .abi to"
)
);
getCode
->
add_flag
(
"--wasm"
,
code_as_wasm
,
localized
(
"Save contract as wasm"
));
getCode
->
set_callback
([
&
]
{
auto
result
=
call
(
get_code_func
,
fc
::
mutable_variant_object
(
"account_name"
,
accountName
));
auto
result
=
call
(
get_code_func
,
fc
::
mutable_variant_object
(
"account_name"
,
accountName
)
(
"code_as_wasm"
,
code_as_wasm
)
);
std
::
cout
<<
localized
(
"code hash: ${code_hash}"
,
(
"code_hash"
,
result
[
"code_hash"
].
as_string
()))
<<
std
::
endl
;
if
(
codeFilename
.
size
()
){
std
::
cout
<<
localized
(
"saving wast to ${codeFilename}"
,
(
"codeFilename"
,
codeFilename
))
<<
std
::
endl
;
auto
code
=
result
[
"wast"
].
as_string
();
std
::
cout
<<
localized
(
"saving ${type} to ${codeFilename}"
,
(
"type"
,
(
code_as_wasm
?
"wasm"
:
"wast"
))(
"codeFilename"
,
codeFilename
))
<<
std
::
endl
;
string
code
;
if
(
code_as_wasm
)
{
code
=
result
[
"wasm"
].
as_string
();
}
else
{
code
=
result
[
"wast"
].
as_string
();
}
std
::
ofstream
out
(
codeFilename
.
c_str
()
);
out
<<
code
;
}
...
...
@@ -1548,6 +1557,24 @@ int main( int argc, char** argv ) {
}
});
// get abi
string
filename
;
auto
getAbi
=
get
->
add_subcommand
(
"abi"
,
localized
(
"Retrieve the ABI for an account"
),
false
);
getAbi
->
add_option
(
"name"
,
accountName
,
localized
(
"The name of the account whose abi should be retrieved"
))
->
required
();
getAbi
->
add_option
(
"-f,--file"
,
filename
,
localized
(
"The name of the file to save the contract .abi to instead of writing to console"
)
);
getAbi
->
set_callback
([
&
]
{
auto
result
=
call
(
get_code_func
,
fc
::
mutable_variant_object
(
"account_name"
,
accountName
));
auto
abi
=
fc
::
json
::
to_pretty_string
(
result
[
"abi"
]
);
if
(
filename
.
size
()
)
{
std
::
cout
<<
localized
(
"saving abi to ${filename}"
,
(
"filename"
,
filename
))
<<
std
::
endl
;
std
::
ofstream
abiout
(
filename
.
c_str
()
);
abiout
<<
abi
;
}
else
{
std
::
cout
<<
abi
<<
"
\n
"
;
}
});
// get table
string
scope
;
string
code
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录