Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
6afdb793
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,发现更多精彩内容 >>
未验证
提交
6afdb793
编写于
11月 15, 2017
作者:
M
Matias Romeo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* Fix examples in AUTOMATED_ABI_GENERATOR.md
* Fix currency.abi / exchange.abi / proxi.abi
上级
c2e954d5
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
133 addition
and
110 deletion
+133
-110
AUTOMATED_ABI_GENERATOR.md
AUTOMATED_ABI_GENERATOR.md
+91
-89
contracts/currency/currency.abi
contracts/currency/currency.abi
+3
-3
contracts/eoslib/raw.hpp
contracts/eoslib/raw.hpp
+18
-0
contracts/eoslib/raw_fwd.hpp
contracts/eoslib/raw_fwd.hpp
+2
-0
contracts/exchange/exchange.abi
contracts/exchange/exchange.abi
+0
-6
contracts/exchange/exchange.hpp
contracts/exchange/exchange.hpp
+2
-2
contracts/proxy/proxy.abi
contracts/proxy/proxy.abi
+7
-1
programs/codegen/main.cpp
programs/codegen/main.cpp
+10
-9
未找到文件。
AUTOMATED_ABI_GENERATOR.md
浏览文件 @
6afdb793
...
...
@@ -32,10 +32,10 @@ Generated types.gen.hpp ...
#include <eoslib/string.hpp>
//@abi action
struct
ActionN
ame
{
struct
action_n
ame
{
uint64_t
param1
;
uint64_t
param2
;
eos
::
string
param3
;
eos
io
::
string
param3
;
};
```
...
...
@@ -43,35 +43,35 @@ struct ActionName {
{
"types"
:
[],
"structs"
:
[{
"name"
:
"
ActionN
ame"
,
"name"
:
"
action_n
ame"
,
"base"
:
""
,
"fields"
:
{
"param1"
:
"
UI
nt64"
,
"param2"
:
"
UI
nt64"
,
"param3"
:
"
S
tring"
"param1"
:
"
ui
nt64"
,
"param2"
:
"
ui
nt64"
,
"param3"
:
"
s
tring"
}
}
],
"actions"
:
[{
"action"
:
"actionname"
,
"type"
:
"
ActionN
ame"
"action
_name
"
:
"actionname"
,
"type"
:
"
action_n
ame"
}
],
"tables"
:
[]
}
```
### Declaring multiple actions
that use the same struct
.
### Declaring multiple actions
using the same interface
.
```
c++
#include <eoslib/types.hpp>
#include <eoslib/string.hpp>
//@abi action action1 action2
struct
ActionN
ame
{
struct
action_n
ame
{
uint64_t
param1
;
uint64_t
param2
;
eos
::
string
param3
;
eos
io
::
string
param3
;
};
```
...
...
@@ -79,21 +79,21 @@ struct ActionName {
{
"types"
:
[],
"structs"
:
[{
"name"
:
"
ActionN
ame"
,
"name"
:
"
action_n
ame"
,
"base"
:
""
,
"fields"
:
{
"param1"
:
"
UI
nt64"
,
"param2"
:
"
UI
nt64"
,
"param3"
:
"
S
tring"
"param1"
:
"
ui
nt64"
,
"param2"
:
"
ui
nt64"
,
"param3"
:
"
s
tring"
}
}
],
"actions"
:
[{
"action"
:
"action1"
,
"type"
:
"
ActionN
ame"
"action
_name
"
:
"action1"
,
"type"
:
"
action_n
ame"
},{
"action"
:
"action2"
,
"type"
:
"
ActionN
ame"
"action
_name
"
:
"action2"
,
"type"
:
"
action_n
ame"
}
],
"tables"
:
[]
...
...
@@ -106,7 +106,7 @@ struct ActionName {
#include <eoslib/string.hpp>
//@abi table
struct
MyT
able
{
struct
my_t
able
{
uint64_t
key
;
};
```
...
...
@@ -115,24 +115,24 @@ struct MyTable {
{
"types"
:
[],
"structs"
:
[{
"name"
:
"
MyT
able"
,
"name"
:
"
my_t
able"
,
"base"
:
""
,
"fields"
:
{
"key"
:
"
UI
nt64"
"key"
:
"
ui
nt64"
}
}
],
"actions"
:
[],
"tables"
:
[{
"table"
:
"mytable"
,
"indextype"
:
"i64"
,
"keynames"
:
[
"table
_name
"
:
"mytable"
,
"index
_
type"
:
"i64"
,
"key
_
names"
:
[
"key"
],
"keytypes"
:
[
"
UI
nt64"
"key
_
types"
:
[
"
ui
nt64"
],
"type"
:
"
MyT
able"
"type"
:
"
my_t
able"
}
]
}
...
...
@@ -143,7 +143,7 @@ _a struct with 3 uint64_t can be both i64 or i64i64i64_
#include <eoslib/types.hpp>
//@abi table i64
struct
MyNewT
able
{
struct
my_new_t
able
{
uint64_t
key
;
uint64_t
name
;
uint64_t
age
;
...
...
@@ -154,26 +154,26 @@ struct MyNewTable {
{
"types"
:
[],
"structs"
:
[{
"name"
:
"
MyNewT
able"
,
"name"
:
"
my_new_t
able"
,
"base"
:
""
,
"fields"
:
{
"key"
:
"
UI
nt64"
,
"name"
:
"
UI
nt64"
,
"age"
:
"
UI
nt64"
"key"
:
"
ui
nt64"
,
"name"
:
"
ui
nt64"
,
"age"
:
"
ui
nt64"
}
}
],
"actions"
:
[],
"tables"
:
[{
"table"
:
"mynewtable"
,
"indextype"
:
"i64"
,
"keynames"
:
[
"table
_name
"
:
"mynewtable"
,
"index
_
type"
:
"i64"
,
"key
_
names"
:
[
"key"
],
"keytypes"
:
[
"
UI
nt64"
"key
_
types"
:
[
"
ui
nt64"
],
"type"
:
"
MyNewT
able"
"type"
:
"
my_new_t
able"
}
]
}
...
...
@@ -188,38 +188,39 @@ struct MyNewTable {
* @abi table
* @abi action
*/
struct
MyT
ype
{
eos
::
string
key
;
eos
::
N
ame
value
;
struct
my_t
ype
{
eos
io
::
string
key
;
eos
io
::
n
ame
value
;
};
```
```
json
{
"types"
:
[],
"structs"
:
[{
"name"
:
"
MyT
ype"
,
"name"
:
"
my_t
ype"
,
"base"
:
""
,
"fields"
:
{
"key"
:
"
S
tring"
,
"value"
:
"
N
ame"
"key"
:
"
s
tring"
,
"value"
:
"
n
ame"
}
}
],
"actions"
:
[{
"action"
:
"mytype"
,
"type"
:
"
MyT
ype"
"action
_name
"
:
"mytype"
,
"type"
:
"
my_t
ype"
}
],
"tables"
:
[{
"table"
:
"mytype"
,
"indextype"
:
"str"
,
"keynames"
:
[
"table
_name
"
:
"mytype"
,
"index
_
type"
:
"str"
,
"key
_
names"
:
[
"key"
],
"keytypes"
:
[
"
S
tring"
"key
_
types"
:
[
"
s
tring"
],
"type"
:
"
MyT
ype"
"type"
:
"
my_t
ype"
}
]
}
...
...
@@ -229,47 +230,48 @@ struct MyType {
```
c++
#include <eoslib/types.hpp>
struct
S
imple
{
struct
s
imple
{
uint64_t
u64
;
};
typedef
Simple
SimpleA
lias
;
typedef
eos
::
Name
NameA
lias
;
typedef
simple
simple_a
lias
;
typedef
eos
io
::
name
name_a
lias
;
//@abi action
struct
ActionOne
:
SimpleA
lias
{
struct
action_one
:
simple_a
lias
{
uint32_t
u32
;
NameA
lias
name
;
name_a
lias
name
;
};
```
```
json
{
"types"
:
[{
"new
TypeName"
:
"SimpleA
lias"
,
"type"
:
"
S
imple"
"new
_type_name"
:
"simple_a
lias"
,
"type"
:
"
s
imple"
},{
"new
TypeName"
:
"NameA
lias"
,
"type"
:
"
N
ame"
"new
_type_name"
:
"name_a
lias"
,
"type"
:
"
n
ame"
}
],
"structs"
:
[{
"name"
:
"
S
imple"
,
"name"
:
"
s
imple"
,
"base"
:
""
,
"fields"
:
{
"u64"
:
"
UI
nt64"
"u64"
:
"
ui
nt64"
}
},{
"name"
:
"
ActionO
ne"
,
"base"
:
"
SimpleA
lias"
,
"name"
:
"
action_o
ne"
,
"base"
:
"
simple_a
lias"
,
"fields"
:
{
"u32"
:
"
UI
nt32"
,
"name"
:
"
NameA
lias"
"u32"
:
"
ui
nt32"
,
"name"
:
"
name_a
lias"
}
}
],
"actions"
:
[{
"action"
:
"actionone"
,
"type"
:
"
ActionO
ne"
"action
_name
"
:
"actionone"
,
"type"
:
"
action_o
ne"
}
],
"tables"
:
[]
...
...
@@ -281,25 +283,25 @@ struct ActionOne : SimpleAlias {
#include <eoslib/types.hpp>
#include <eoslib/string.hpp>
struct
S
imple
{
struct
s
imple
{
uint32_t
u32
;
FixedS
tring16
s16
;
fixed_s
tring16
s16
;
};
struct
MyComplexT
ype
{
struct
my_complex_t
ype
{
uint64_t
u64
;
eos
::
string
str
;
S
imple
simple
;
B
ytes
bytes
;
PublicK
ey
pub
;
eos
io
::
string
str
;
s
imple
simple
;
b
ytes
bytes
;
public_k
ey
pub
;
};
typedef
MyComplexType
C
omplex
;
typedef
my_complex_type
c
omplex
;
//@abi action
struct
TestA
ction
{
struct
test_a
ction
{
uint32_t
u32
;
Complex
comple
x
;
complex
cpl
x
;
};
```
...
...
@@ -307,26 +309,26 @@ struct TestAction {
void
apply
(
uint64_t
code
,
uint64_t
action
)
{
if
(
code
==
N
(
mycontract
)
)
{
if
(
action
==
N
(
testaction
)
)
{
auto
test_action
=
eos
::
current_message_ex
<
TestA
ction
>
();
eos
::
print
(
"TestA
ction content
\n
"
);
eos
::
dump
(
test_action
);
auto
msg
=
eosio
::
current_message
<
test_a
ction
>
();
eos
io
::
print
(
"test_a
ction content
\n
"
);
eos
io
::
dump
(
msg
);
Bytes
bytes
=
eos
::
raw
::
to_bytes
(
test_action
);
printhex
(
b
ytes
.
data
,
bytes
.
len
);
bytes
b
=
eosio
::
raw
::
pack
(
msg
);
printhex
(
b
.
data
,
b
.
len
);
}
}
}
```
Calling
the contract with some
test values
Calling
contract with
test values
```
bash
eosc push message mycontract testaction
'{"u32":"1000", "c
omple
x":{"u64":"472", "str":"hello", "bytes":"B0CA", "pub":"EOS8CY2pCW5THmzvPTgEh5WLEAxgpVFXaPogPvgvVpVWCYMRdzmwx", "simple":{"u32":"164","s16":"small-string"}}}'
-S
mycontract
eosc push message mycontract testaction
'{"u32":"1000", "c
pl
x":{"u64":"472", "str":"hello", "bytes":"B0CA", "pub":"EOS8CY2pCW5THmzvPTgEh5WLEAxgpVFXaPogPvgvVpVWCYMRdzmwx", "simple":{"u32":"164","s16":"small-string"}}}'
-S
mycontract
```
Will produce the following output in eosd console
```
bash
TestA
ction content
test_a
ction content
u32:[1000]
c
omple
x:[
c
pl
x:[
u64:[472]
str:[hello]
simple:[
...
...
contracts/currency/currency.abi
浏览文件 @
6afdb793
...
...
@@ -5,7 +5,7 @@
}
],
"structs": [{
"name": "
T
ransfer",
"name": "
t
ransfer",
"base": "",
"fields": {
"from": "account_name",
...
...
@@ -13,7 +13,7 @@
"amount": "uint64"
}
},{
"name": "
A
ccount",
"name": "
a
ccount",
"base": "",
"fields": {
"key": "uint64",
...
...
@@ -30,7 +30,7 @@
"table_name": "account",
"type": "account",
"index_type": "i64",
"key_names" : ["
account
"],
"key_names" : ["
key
"],
"key_types" : ["name"]
}
]
...
...
contracts/eoslib/raw.hpp
浏览文件 @
6afdb793
...
...
@@ -131,6 +131,24 @@ namespace eosio {
}
}
/**
* Serialize a public_key into a stream
* @param s stream to write
* @param v value to be serialized
*/
template
<
typename
Stream
>
inline
void
pack
(
Stream
&
s
,
const
public_key
&
value
)
{
s
.
write
(
(
char
*
)
value
.
data
,
sizeof
(
public_key
)
);
}
/**
* Deserialize a public_key from a stream
* @param s stream to read
* @param v destination of deserialized public_key
*/
template
<
typename
Stream
>
inline
void
unpack
(
Stream
&
s
,
public_key
&
value
)
{
s
.
read
(
(
char
*
)
value
.
data
,
sizeof
(
public_key
)
);
}
/**
* Serialize a string into a stream
* @param s stream to write
...
...
contracts/eoslib/raw_fwd.hpp
浏览文件 @
6afdb793
...
...
@@ -15,6 +15,8 @@ namespace eosio { namespace raw {
template
<
typename
Stream
>
inline
void
unpack
(
Stream
&
s
,
unsigned_int
&
vi
);
template
<
typename
Stream
>
inline
void
pack
(
Stream
&
s
,
const
bytes
&
value
);
template
<
typename
Stream
>
inline
void
unpack
(
Stream
&
s
,
bytes
&
value
);
template
<
typename
Stream
>
inline
void
pack
(
Stream
&
s
,
const
public_key
&
value
);
template
<
typename
Stream
>
inline
void
unpack
(
Stream
&
s
,
public_key
&
value
);
template
<
typename
Stream
>
inline
void
pack
(
Stream
&
s
,
const
string
&
v
);
template
<
typename
Stream
>
inline
void
unpack
(
Stream
&
s
,
string
&
v
);
template
<
typename
Stream
>
inline
void
pack
(
Stream
&
s
,
const
fixed_string32
&
v
);
...
...
contracts/exchange/exchange.abi
浏览文件 @
6afdb793
...
...
@@ -49,12 +49,6 @@
}
],
"actions": [{
"action": "cancelbuy",
"type": "OrderID"
},{
"action": "cancelsell",
"type": "OrderID"
},{
"action": "buy",
"type": "buy_order"
},{
...
...
contracts/exchange/exchange.hpp
浏览文件 @
6afdb793
...
...
@@ -9,7 +9,7 @@ namespace exchange {
using
currency
::
currency_tokens
;
using
eos_tokens
=
eosio
::
tokens
;
//@abi
exchange
action cancelbuy cancelsell
//@abi action cancelbuy cancelsell
struct
order_id
{
account_name
name
=
0
;
uint64_t
number
=
0
;
...
...
@@ -21,7 +21,7 @@ namespace exchange {
struct
PACKED
(
bid
)
{
order_id
buyer
;
price
at_price
;
eosio
::
tokens
quantity
;
eosio
::
tokens
quantity
;
time
expiration
;
void
print
()
{
...
...
contracts/proxy/proxy.abi
浏览文件 @
6afdb793
...
...
@@ -11,11 +11,17 @@
"key": "name",
"owner": "name"
}
},{
"name": "setowner",
"base": "",
"fields": {
"owner": "name"
}
}
],
"actions": [{
"action_name": "setowner",
"type": "
name
"
"type": "
setowner
"
}
],
"tables": [{
...
...
programs/codegen/main.cpp
浏览文件 @
6afdb793
...
...
@@ -40,9 +40,9 @@ struct codegen {
if
(
abis
.
is_struct
(
field_type
)
)
{
output
<<
"print(
\"\\
n
\"
); eosio::dump(value."
<<
field
.
name
<<
", tab+1);"
;
output
<<
"print_ident(tab);"
;
}
else
if
(
field_type
==
"
S
tring"
)
{
}
else
if
(
field_type
==
"
s
tring"
)
{
output
<<
"prints_l(value."
<<
field
.
name
<<
".get_data(), value."
<<
field
.
name
<<
".get_size());"
;
}
else
if
(
field_type
==
"
FixedString32"
||
field_type
==
"FixedS
tring16"
)
{
}
else
if
(
field_type
==
"
fixed_string32"
||
field_type
==
"fixed_s
tring16"
)
{
output
<<
"prints_l(value."
<<
field
.
name
<<
".str, value."
<<
field
.
name
<<
".len);"
;
}
else
if
(
field_type
==
"Bytes"
)
{
output
<<
"printhex(value."
<<
field
.
name
<<
".data, value."
<<
field
.
name
<<
".len);"
;
...
...
@@ -56,16 +56,16 @@ struct codegen {
output
<<
"printhex((void*)&value."
<<
field
.
name
<<
", sizeof(value."
<<
field
.
name
<<
"));"
;
}
}
else
if
(
field_type
==
"
B
ytes"
)
{
output
<<
"printhex(value."
<<
field
.
name
<<
".data, value."
<<
field
.
name
<<
".len)
)
;"
;
}
else
if
(
field_type
==
"
Name"
||
field_type
==
"AccountName"
||
field_type
==
"PermissionN
ame"
||
\
field_type
==
"
TokenName"
||
field_type
==
"TableName"
||
field_type
==
"FuncN
ame"
)
{
}
else
if
(
field_type
==
"
b
ytes"
)
{
output
<<
"printhex(value."
<<
field
.
name
<<
".data, value."
<<
field
.
name
<<
".len);"
;
}
else
if
(
field_type
==
"
name"
||
field_type
==
"account_name"
||
field_type
==
"permission_n
ame"
||
\
field_type
==
"
token_name"
||
field_type
==
"table_name"
||
field_type
==
"func_n
ame"
)
{
output
<<
"printn(value."
<<
field
.
name
<<
");"
;
}
else
if
(
field_type
==
"
PublicK
ey"
)
{
}
else
if
(
field_type
==
"
public_k
ey"
)
{
output
<<
"printhex((void*)value."
<<
field
.
name
<<
".data, 33);"
;
}
else
if
(
field_type
==
"
T
ime"
)
{
}
else
if
(
field_type
==
"
t
ime"
)
{
output
<<
"printi(value."
<<
field
.
name
<<
");"
;
}
else
if
(
field_type
==
"
P
rice"
)
{
}
else
if
(
field_type
==
"
p
rice"
)
{
output
<<
"printi(value."
<<
field
.
name
<<
".base.amount);print(
\"
/
\"
);printi(value."
<<
field
.
name
<<
".quote.amount);"
;
}
else
{
...
...
@@ -119,6 +119,7 @@ struct codegen {
ostringstream
output
;
output
<<
"#pragma once"
<<
endl
;
output
<<
"#include <eoslib/types.hpp>"
<<
endl
;
output
<<
"#include <eoslib/message.hpp>"
<<
endl
;
output
<<
"#include <eoslib/datastream.hpp>"
<<
endl
;
output
<<
"#include <eoslib/raw_fwd.hpp>"
<<
endl
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录