Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
352a5c0c
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,发现更多精彩内容 >>
提交
352a5c0c
编写于
2月 08, 2018
作者:
K
Kevin Heifner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add eos contract abi to eosio account abi
上级
f801c8f9
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
76 addition
and
32 deletion
+76
-32
contracts/eosio.system/eosio.system.abi
contracts/eosio.system/eosio.system.abi
+1
-5
contracts/eosio.system/eosio.system.cpp
contracts/eosio.system/eosio.system.cpp
+1
-1
contracts/eosio.system/eosio.system.hpp
contracts/eosio.system/eosio.system.hpp
+1
-1
contracts/test.system/test.system.abi
contracts/test.system/test.system.abi
+1
-5
libraries/chain/CMakeLists.txt
libraries/chain/CMakeLists.txt
+1
-1
libraries/chain/contracts/abi_serializer.cpp
libraries/chain/contracts/abi_serializer.cpp
+12
-0
libraries/chain/contracts/chain_initializer.cpp
libraries/chain/contracts/chain_initializer.cpp
+0
-6
libraries/chain/include/eosio/chain/contracts/abi_serializer.hpp
...es/chain/include/eosio/chain/contracts/abi_serializer.hpp
+3
-1
libraries/testing/include/eosio/testing/tester.hpp
libraries/testing/include/eosio/testing/tester.hpp
+1
-1
plugins/account_history_plugin/account_history_plugin.cpp
plugins/account_history_plugin/account_history_plugin.cpp
+1
-1
plugins/chain_plugin/chain_plugin.cpp
plugins/chain_plugin/chain_plugin.cpp
+5
-5
tests/wasm_tests/identity_tests.cpp
tests/wasm_tests/identity_tests.cpp
+2
-2
tests/wasm_tests/wasm_tests.cpp
tests/wasm_tests/wasm_tests.cpp
+47
-3
未找到文件。
contracts/eosio.system/eosio.system.abi
浏览文件 @
352a5c0c
{
"types": [{
"new_type_name": "account_name",
"type": "name"
}
],
"types": [],
"structs": [{
"name": "transfer",
"base": "",
...
...
contracts/eosio.system/eosio.system.cpp
浏览文件 @
352a5c0c
...
...
@@ -11,6 +11,6 @@ extern "C" {
/// The apply method implements the dispatch of events to this contract
void
apply
(
uint64_t
code
,
uint64_t
act
)
{
eosiosystem
::
contract
<
N
(
eosio
.
system
)
>::
apply
(
code
,
act
);
eosiosystem
::
contract
<
N
(
system_account
)
>::
apply
(
code
,
act
);
}
}
contracts/eosio.system/eosio.system.hpp
浏览文件 @
352a5c0c
...
...
@@ -17,7 +17,7 @@ namespace eosiosystem {
template
<
account_name
SystemAccount
>
class
contract
{
public:
static
const
account_name
system_account
=
N
(
eosio
.
system
);
static
const
account_name
system_account
=
N
(
eosio
);
typedef
eosio
::
generic_currency
<
eosio
::
token
<
system_account
,
S
(
4
,
EOS
)
>
>
currency
;
struct
total_bandwidth
{
...
...
contracts/test.system/test.system.abi
浏览文件 @
352a5c0c
{
"types": [{
"new_type_name": "account_name",
"type": "name"
}
],
"types": [],
"structs": [{
"name": "set_account_limits",
"base": "",
...
...
libraries/chain/CMakeLists.txt
浏览文件 @
352a5c0c
file
(
GLOB HEADERS
"include/eosio/chain/*.hpp"
)
file
(
GLOB HEADERS
"include/eosio/chain/*.hpp"
"include/eosio/chain/contracts/*.hpp"
)
## SORT .cpp by most likely to change / break compile
add_library
(
eosio_chain
...
...
libraries/chain/contracts/abi_serializer.cpp
浏览文件 @
352a5c0c
...
...
@@ -3,6 +3,7 @@
* @copyright defined in eos/LICENSE.txt
*/
#include <eosio/chain/contracts/abi_serializer.hpp>
#include <eosio/chain/contracts/chain_initializer.hpp>
#include <eosio/chain/contracts/types.hpp>
#include <eosio/chain/authority.hpp>
#include <eosio/chain/chain_config.hpp>
...
...
@@ -129,6 +130,17 @@ namespace eosio { namespace chain { namespace contracts {
FC_ASSERT
(
actions
.
size
()
==
abi
.
actions
.
size
()
);
FC_ASSERT
(
tables
.
size
()
==
abi
.
tables
.
size
()
);
}
void
abi_serializer
::
append_system_abi
(
account_name
account
,
abi_def
&
abi
)
{
if
(
account
==
eosio
::
chain
::
config
::
system_account_name
)
{
abi_def
eos_abi
=
chain_initializer
::
eos_contract_abi
();
abi
.
actions
.
insert
(
abi
.
actions
.
end
(),
eos_abi
.
actions
.
cbegin
(),
eos_abi
.
actions
.
cend
());
abi
.
structs
.
insert
(
abi
.
structs
.
end
(),
eos_abi
.
structs
.
cbegin
(),
eos_abi
.
structs
.
cend
());
abi
.
tables
.
insert
(
abi
.
tables
.
end
(),
eos_abi
.
tables
.
cbegin
(),
eos_abi
.
tables
.
cend
());
abi
.
types
.
insert
(
abi
.
types
.
end
(),
eos_abi
.
types
.
cbegin
(),
eos_abi
.
types
.
cend
());
}
}
bool
abi_serializer
::
is_builtin_type
(
const
type_name
&
type
)
const
{
return
built_in_types
.
find
(
type
)
!=
built_in_types
.
end
();
...
...
libraries/chain/contracts/chain_initializer.cpp
浏览文件 @
352a5c0c
...
...
@@ -151,12 +151,6 @@ abi_def chain_initializer::eos_contract_abi()
});
// DATABASE RECORDS
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"account"
,
""
,
{
{
"key"
,
"name"
},
{
"balance"
,
"uint64"
},
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"pending_recovery"
,
""
,
{
...
...
libraries/chain/include/eosio/chain/contracts/abi_serializer.hpp
浏览文件 @
352a5c0c
...
...
@@ -72,11 +72,12 @@ struct abi_serializer {
}
template
<
typename
Vec
>
static
bool
to_abi
(
const
Vec
&
abi_vec
,
abi_def
&
abi
)
static
bool
to_abi
(
account_name
account
,
const
Vec
&
abi_vec
,
abi_def
&
abi
)
{
if
(
!
is_empty_abi
(
abi_vec
)
)
{
/// 4 == packsize of empty Abi
fc
::
datastream
<
const
char
*>
ds
(
abi_vec
.
data
(),
abi_vec
.
size
()
);
fc
::
raw
::
unpack
(
ds
,
abi
);
append_system_abi
(
account
,
abi
);
return
true
;
}
return
false
;
...
...
@@ -84,6 +85,7 @@ struct abi_serializer {
private:
void
binary_to_variant
(
const
type_name
&
type
,
fc
::
datastream
<
const
char
*>&
stream
,
fc
::
mutable_variant_object
&
obj
)
const
;
static
void
append_system_abi
(
account_name
account
,
abi_def
&
abi
);
};
namespace
impl
{
...
...
libraries/testing/include/eosio/testing/tester.hpp
浏览文件 @
352a5c0c
...
...
@@ -85,7 +85,7 @@ namespace eosio { namespace testing {
try
{
const
auto
&
accnt
=
control
->
get_database
().
get
<
account_object
,
by_name
>
(
name
);
contracts
::
abi_def
abi
;
if
(
contracts
::
abi_serializer
::
to_abi
(
accnt
.
abi
,
abi
))
{
if
(
contracts
::
abi_serializer
::
to_abi
(
accnt
.
name
,
accnt
.
abi
,
abi
))
{
return
contracts
::
abi_serializer
(
abi
);
}
return
optional
<
contracts
::
abi_serializer
>
();
...
...
plugins/account_history_plugin/account_history_plugin.cpp
浏览文件 @
352a5c0c
...
...
@@ -413,7 +413,7 @@ fc::variant account_history_plugin_impl::transaction_to_variant(const packed_tra
const
auto
*
accnt
=
database
.
find
<
chain
::
account_object
,
chain
::
by_name
>
(
name
);
if
(
accnt
!=
nullptr
)
{
abi_def
abi
;
if
(
abi_serializer
::
to_abi
(
accnt
->
abi
,
abi
))
{
if
(
abi_serializer
::
to_abi
(
accnt
->
name
,
accnt
->
abi
,
abi
))
{
return
abi_serializer
(
abi
);
}
}
...
...
plugins/chain_plugin/chain_plugin.cpp
浏览文件 @
352a5c0c
...
...
@@ -280,7 +280,7 @@ abi_def get_abi( const chain_controller& db, const name& account ) {
const
auto
&
code_accnt
=
d
.
get
<
account_object
,
by_name
>
(
account
);
abi_def
abi
;
abi_serializer
::
to_abi
(
code_accnt
.
abi
,
abi
);
abi_serializer
::
to_abi
(
code_accnt
.
name
,
code_accnt
.
abi
,
abi
);
return
abi
;
}
...
...
@@ -379,7 +379,7 @@ read_write::push_transaction_results read_write::push_transaction(const read_wri
const
auto
*
accnt
=
db
.
get_database
().
find
<
account_object
,
by_name
>
(
name
);
if
(
accnt
!=
nullptr
)
{
abi_def
abi
;
if
(
abi_serializer
::
to_abi
(
accnt
->
abi
,
abi
))
{
if
(
abi_serializer
::
to_abi
(
accnt
->
name
,
accnt
->
abi
,
abi
))
{
return
abi_serializer
(
abi
);
}
}
...
...
@@ -423,7 +423,7 @@ read_only::get_code_results read_only::get_code( const get_code_params& params )
}
abi_def
abi
;
if
(
abi_serializer
::
to_abi
(
accnt
.
abi
,
abi
)
)
{
if
(
abi_serializer
::
to_abi
(
accnt
.
name
,
accnt
.
abi
,
abi
)
)
{
result
.
abi
=
std
::
move
(
abi
);
}
...
...
@@ -465,7 +465,7 @@ read_only::abi_json_to_bin_result read_only::abi_json_to_bin( const read_only::a
abi_json_to_bin_result
result
;
const
auto
&
code_account
=
db
.
get_database
().
get
<
account_object
,
by_name
>
(
params
.
code
);
abi_def
abi
;
if
(
abi_serializer
::
to_abi
(
code_account
.
abi
,
abi
)
)
{
if
(
abi_serializer
::
to_abi
(
code_account
.
name
,
code_account
.
abi
,
abi
)
)
{
abi_serializer
abis
(
abi
);
result
.
binargs
=
abis
.
variant_to_binary
(
abis
.
get_action_type
(
params
.
action
),
params
.
args
);
}
...
...
@@ -476,7 +476,7 @@ read_only::abi_bin_to_json_result read_only::abi_bin_to_json( const read_only::a
abi_bin_to_json_result
result
;
const
auto
&
code_account
=
db
.
get_database
().
get
<
account_object
,
by_name
>
(
params
.
code
);
abi_def
abi
;
if
(
abi_serializer
::
to_abi
(
code_account
.
abi
,
abi
)
)
{
if
(
abi_serializer
::
to_abi
(
code_account
.
name
,
code_account
.
abi
,
abi
)
)
{
abi_serializer
abis
(
abi
);
result
.
args
=
abis
.
binary_to_variant
(
abis
.
get_action_type
(
params
.
action
),
params
.
binargs
);
}
...
...
tests/wasm_tests/identity_tests.cpp
浏览文件 @
352a5c0c
...
...
@@ -38,12 +38,12 @@ public:
const
auto
&
accnt
=
control
->
get_database
().
get
<
account_object
,
by_name
>
(
N
(
identity
)
);
abi_def
abi
;
BOOST_REQUIRE_EQUAL
(
abi_serializer
::
to_abi
(
accnt
.
abi
,
abi
),
true
);
BOOST_REQUIRE_EQUAL
(
abi_serializer
::
to_abi
(
accnt
.
name
,
accnt
.
abi
,
abi
),
true
);
abi_ser
.
set_abi
(
abi
);
const
auto
&
acnt_test
=
control
->
get_database
().
get
<
account_object
,
by_name
>
(
N
(
identitytest
)
);
abi_def
abi_test
;
BOOST_REQUIRE_EQUAL
(
abi_serializer
::
to_abi
(
acnt_test
.
abi
,
abi_test
),
true
);
BOOST_REQUIRE_EQUAL
(
abi_serializer
::
to_abi
(
ac
cnt
.
name
,
ac
nt_test
.
abi
,
abi_test
),
true
);
abi_ser_test
.
set_abi
(
abi_test
);
const
global_property_object
&
gpo
=
control
->
get_global_properties
();
...
...
tests/wasm_tests/wasm_tests.cpp
浏览文件 @
352a5c0c
...
...
@@ -13,10 +13,13 @@
#include <noop/noop.wast.hpp>
#include <noop/noop.abi.hpp>
#include <eosio.system/eosio.system.wast.hpp>
#include <eosio.system/eosio.system.abi.hpp>
#include <Runtime/Runtime.h>
#include <fc/variant_object.hpp>
#include <fc/io/json.hpp>
#include "test_wasts.hpp"
...
...
@@ -187,7 +190,7 @@ BOOST_FIXTURE_TEST_CASE( abi_from_variant, tester ) try {
try
{
const
auto
&
accnt
=
this
->
control
->
get_database
().
get
<
account_object
,
by_name
>
(
name
);
abi_def
abi
;
if
(
abi_serializer
::
to_abi
(
accnt
.
abi
,
abi
))
{
if
(
abi_serializer
::
to_abi
(
accnt
.
name
,
accnt
.
abi
,
abi
))
{
return
abi_serializer
(
abi
);
}
return
optional
<
abi_serializer
>
();
...
...
@@ -361,7 +364,7 @@ BOOST_FIXTURE_TEST_CASE( stl_test, tester ) try {
const
auto
&
accnt
=
control
->
get_database
().
get
<
account_object
,
by_name
>
(
N
(
stltest
)
);
abi_def
abi
;
BOOST_REQUIRE_EQUAL
(
abi_serializer
::
to_abi
(
accnt
.
abi
,
abi
),
true
);
BOOST_REQUIRE_EQUAL
(
abi_serializer
::
to_abi
(
accnt
.
name
,
accnt
.
abi
,
abi
),
true
);
abi_serializer
abi_ser
(
abi
);
//send message
...
...
@@ -572,7 +575,7 @@ BOOST_FIXTURE_TEST_CASE(noop, tester) try {
set_abi
(
N
(
noop
),
noop_abi
);
const
auto
&
accnt
=
control
->
get_database
().
get
<
account_object
,
by_name
>
(
N
(
noop
));
abi_def
abi
;
BOOST_REQUIRE_EQUAL
(
abi_serializer
::
to_abi
(
accnt
.
abi
,
abi
),
true
);
BOOST_REQUIRE_EQUAL
(
abi_serializer
::
to_abi
(
accnt
.
name
,
accnt
.
abi
,
abi
),
true
);
abi_serializer
abi_ser
(
abi
);
{
...
...
@@ -625,6 +628,47 @@ BOOST_FIXTURE_TEST_CASE(noop, tester) try {
}
FC_LOG_AND_RETHROW
()
// abi_serializer::to_variant failed because eosio_system_abi modified via set_abi.
// This test also verifies that chain_initializer::eos_contract_abi() does not conflict
// with eosio_system_abi as they are not allowed to contain duplicates.
BOOST_FIXTURE_TEST_CASE
(
eosio_abi
,
tester
)
try
{
produce_blocks
(
2
);
set_code
(
config
::
system_account_name
,
eosio_system_wast
);
set_abi
(
config
::
system_account_name
,
eosio_system_abi
);
produce_block
();
const
auto
&
accnt
=
control
->
get_database
().
get
<
account_object
,
by_name
>
(
config
::
system_account_name
);
abi_def
abi
;
BOOST_REQUIRE_EQUAL
(
abi_serializer
::
to_abi
(
accnt
.
name
,
accnt
.
abi
,
abi
),
true
);
abi_serializer
abi_ser
(
abi
);
abi_ser
.
validate
();
signed_transaction
trx
;
name
a
=
N
(
alice
);
authority
owner_auth
=
authority
(
get_public_key
(
a
,
"owner"
)
);
trx
.
actions
.
emplace_back
(
vector
<
permission_level
>
{{
config
::
system_account_name
,
config
::
active_name
}},
contracts
::
newaccount
{
.
creator
=
config
::
system_account_name
,
.
name
=
a
,
.
owner
=
owner_auth
,
.
active
=
authority
(
get_public_key
(
a
,
"active"
)
),
.
recovery
=
authority
(
get_public_key
(
a
,
"recovery"
)
),
});
set_tapos
(
trx
);
trx
.
sign
(
get_private_key
(
config
::
system_account_name
,
"active"
),
chain_id_type
()
);
auto
result
=
push_transaction
(
trx
);
fc
::
variant
pretty_output
;
// verify to_variant works on eos native contract type: newaccount
// see abi_serializer::to_abi()
abi_serializer
::
to_variant
(
result
,
pretty_output
,
get_resolver
());
BOOST_TEST
(
fc
::
json
::
to_string
(
pretty_output
).
find
(
"newaccount"
)
!=
std
::
string
::
npos
);
produce_block
();
}
FC_LOG_AND_RETHROW
()
BOOST_FIXTURE_TEST_CASE
(
test_table_key_validation
,
tester
)
try
{
}
FC_LOG_AND_RETHROW
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录