Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
85abd227
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,发现更多精彩内容 >>
提交
85abd227
编写于
4月 20, 2018
作者:
K
Khaled Al-Hassanieh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Delete token class and currency contract, refactor noop
上级
18df341d
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
49 addition
and
657 deletion
+49
-657
contracts/CMakeLists.txt
contracts/CMakeLists.txt
+0
-1
contracts/currency/CMakeLists.txt
contracts/currency/CMakeLists.txt
+0
-8
contracts/currency/currency.abi
contracts/currency/currency.abi
+0
-87
contracts/currency/currency.cpp
contracts/currency/currency.cpp
+0
-15
contracts/eosiolib/token.hpp
contracts/eosiolib/token.hpp
+0
-465
contracts/exchange/CMakeLists.txt
contracts/exchange/CMakeLists.txt
+0
-1
contracts/noop/noop.cpp
contracts/noop/noop.cpp
+18
-10
contracts/noop/noop.hpp
contracts/noop/noop.hpp
+0
-38
contracts/proxy/proxy.cpp
contracts/proxy/proxy.cpp
+10
-3
contracts/stltest/stltest.cpp
contracts/stltest/stltest.cpp
+0
-4
plugins/txn_test_gen_plugin/CMakeLists.txt
plugins/txn_test_gen_plugin/CMakeLists.txt
+0
-2
tests/CMakeLists.txt
tests/CMakeLists.txt
+1
-1
tests/chain_tests/delay_tests.cpp
tests/chain_tests/delay_tests.cpp
+18
-18
tests/wasm_tests/currency_tests.cpp
tests/wasm_tests/currency_tests.cpp
+2
-4
未找到文件。
contracts/CMakeLists.txt
浏览文件 @
85abd227
...
...
@@ -13,7 +13,6 @@ add_subdirectory(eosio.msig)
add_subdirectory
(
multi_index_test
)
add_subdirectory
(
eosio.system
)
add_subdirectory
(
identity
)
add_subdirectory
(
currency
)
add_subdirectory
(
stltest
)
add_subdirectory
(
exchange
)
add_subdirectory
(
test.inline
)
...
...
contracts/currency/CMakeLists.txt
已删除
100644 → 0
浏览文件 @
18df341d
file
(
GLOB ABI_FILES
"*.abi"
)
configure_file
(
"
${
ABI_FILES
}
"
"
${
CMAKE_CURRENT_BINARY_DIR
}
"
COPYONLY
)
add_wast_executable
(
TARGET currency
INCLUDE_FOLDERS
"
${
STANDARD_INCLUDE_FOLDERS
}
"
LIBRARIES libc++ libc eosiolib
DESTINATION_FOLDER
${
CMAKE_CURRENT_BINARY_DIR
}
)
contracts/currency/currency.abi
已删除
100644 → 0
浏览文件 @
18df341d
{
"types": [{
"new_type_name": "account_name",
"type": "name"
}
],
"structs": [{
"name": "transfer",
"base": "",
"fields": [
{"name":"from", "type":"account_name"},
{"name":"to", "type":"account_name"},
{"name":"quantity", "type":"asset"},
{"name":"memo", "type":"string"}
]
},{
"name": "create",
"base": "",
"fields": [
{"name":"issuer", "type":"account_name"},
{"name":"maximum_supply", "type":"asset"},
{"name":"can_freeze", "type":"uint8"},
{"name":"can_recall", "type":"uint8"},
{"name":"can_whitelist", "type":"uint8"}
]
},{
"name": "issue",
"base": "",
"fields": [
{"name":"to", "type":"account_name"},
{"name":"quantity", "type":"asset"},
{"name":"memo", "type":"string"}
]
},{
"name": "account",
"base": "",
"fields": [
{"name":"balance", "type":"asset"},
{"name":"frozen", "type":"uint8"},
{"name":"whitelist", "type":"uint8"}
]
},{
"name": "currency_stats",
"base": "",
"fields": [
{"name":"supply", "type":"asset"},
{"name":"max_supply", "type":"asset"},
{"name":"issuer", "type":"account_name"},
{"name":"can_freeze", "type":"uint8"},
{"name":"can_recall", "type":"uint8"},
{"name":"can_whitelist", "type":"uint8"},
{"name":"is_frozen", "type":"uint8"},
{"name":"enforce_whitelist", "type":"uint8"}
]
}
],
"actions": [{
"name": "transfer",
"type": "transfer",
"ricardian_contract": ""
},{
"name": "issue",
"type": "issue",
"ricardian_contract": ""
}, {
"name": "create",
"type": "create",
"ricardian_contract": ""
}
],
"tables": [{
"name": "accounts",
"type": "account",
"index_type": "i64",
"key_names" : ["currency"],
"key_types" : ["uint64"]
},{
"name": "stat",
"type": "currency_stats",
"index_type": "i64",
"key_names" : ["currency"],
"key_types" : ["uint64"]
}
],
"ricardian_clauses": []
}
contracts/currency/currency.cpp
已删除
100644 → 0
浏览文件 @
18df341d
#if 0
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#include <eosiolib/currency.hpp>
extern "C" {
/// The apply method implements the dispatch of events to this contract
void apply( uint64_t receiver, uint64_t code, uint64_t action ) {
eosio::currency(receiver).apply( code, action );
}
}
#endif
contracts/eosiolib/token.hpp
已删除
100644 → 0
浏览文件 @
18df341d
/**
* @file token.hpp
* @copyright defined in eos/LICENSE.txt
* @brief Defines types and ABI for standard token messages and database tables
*
*/
#pragma once
#include <eosiolib/math.hpp>
#include <eosiolib/print.hpp>
#include <eosiolib/reflect.hpp>
#include <eosiolib/asset.hpp>
#include <eosiolib/serialize.hpp>
namespace
eosio
{
/**
* @defgroup tokens Token API
* @brief Defines the ABI for interfacing with standard-compatible token messages and database tables.
* @ingroup contractdev
*
* @{
*/
template
<
typename
BaseToken
,
typename
QuoteToken
>
struct
price
;
template
<
uint64_t
Code
,
uint64_t
Symbol
,
typename
NumberType
=
uint64_t
>
struct
token
{
/**
* Type of the currency (e.g. eos) represented as an unsigned 64 bit integer
* @brief Type of the currency
*/
static
const
uint64_t
code
=
Code
;
static
const
uint64_t
symbol
=
Symbol
;
/**
* Default constructor
* @brief Default constructor
*/
token
(){}
template
<
typename
Base
,
typename
Quote
>
friend
price
<
Base
,
Quote
>
operator
/
(
const
Base
&
b
,
const
Quote
&
q
);
explicit
operator
asset
()
const
{
return
asset
(
int64_t
(
quantity
),
Symbol
);
}
token
(
const
asset
&
a
)
:
quantity
(
NumberType
(
a
.
amount
))
{
eosio_assert
(
a
.
symbol
==
Symbol
,
"attempt to construct token from asset with different symbol"
);
eosio_assert
(
0
<=
a
.
amount
,
"attemt to convert asset with negative value to token"
);
}
/**
* Constructor for token given quantity of tokens available
* @brief Constructor for token given quantity of tokens available
* @param v - quantity of tokens available
*/
explicit
token
(
NumberType
v
)
:
quantity
(
v
){}
/**
* Quantity of tokens available
* @brief Quantity of tokens available
*/
NumberType
quantity
=
0
;
/**
* Subtracts quantity of token from this object
* Throws an exception if underflow
* @brief Subtracts quantity of token from this object
* @param a token to be subtracted
* @return this token after subtraction
*/
token
&
operator
-=
(
const
token
&
a
)
{
eosio_assert
(
quantity
>=
a
.
quantity
,
"integer underflow subtracting token balance"
);
quantity
-=
a
.
quantity
;
return
*
this
;
}
/**
* Adds quantity of token to this object
* Throws an exception if overflow
* @brief Adds quantity of token to this object
* @param a token to be added
* @return this token after addition
*/
token
&
operator
+=
(
const
token
&
a
)
{
eosio_assert
(
quantity
+
a
.
quantity
>=
a
.
quantity
,
"integer overflow adding token balance"
);
quantity
+=
a
.
quantity
;
return
*
this
;
}
/**
* Adds quantity of two tokens and return a new token
* Throws an exception if overflow
* @brief Adds quantity of two tokens and return a new token
* @param a token to be added
* @param b token to be added
* @return result of addition as a new token
*/
inline
friend
token
operator
+
(
const
token
&
a
,
const
token
&
b
)
{
token
result
=
a
;
result
+=
b
;
return
result
;
}
/**
* Subtracts quantity of two tokens and return a new token
* Throws an exception if underflow
* @brief Subtracts quantity of two tokens and return a new token
* @param a token to be subtracted
* @param b token to be subtracted
* @return result of subtraction as a new token
*/
inline
friend
token
operator
-
(
const
token
&
a
,
const
token
&
b
)
{
token
result
=
a
;
result
-=
b
;
return
result
;
}
/**
* Multiplies quantity of token by an integer
* Throws an exception if overflow
* @brief Multiplies quantity of token by an integer
* @param a multipier
* @return this token after addition
*/
token
&
operator
*=
(
uint64_t
a
)
{
eosio_assert
(
a
==
0
||
(
quantity
*
a
)
/
a
==
quantity
,
"integer overflow multiplying token balance"
);
quantity
*=
a
;
return
*
this
;
}
/**
* Multiplies token and integer
* Throws an exception if overflow
* @brief Multiplies quantity of two tokens and return a new token
* @param a token to be multiplied
* @param b multipier
* @return result of addition as a new token
*/
inline
friend
token
operator
*
(
const
token
&
a
,
uint64_t
b
)
{
token
result
=
a
;
result
*=
b
;
return
result
;
}
/**
* Multiplies token and integer
* Throws an exception if overflow
* @brief Multiplies quantity of two tokens and return a new token
* @param a token to be multiplied
* @param b multipier
* @return result of addition as a new token
*/
inline
friend
token
operator
*
(
uint64_t
b
,
const
token
&
a
)
{
token
result
=
a
;
result
*=
b
;
return
result
;
}
/**
* Divides quantity of token by an integer
* Throws an exception if overflow
* @brief Divides quantity of token by an integer
* @param a multipier
* @return this token after addition
*/
token
&
operator
/=
(
uint64_t
a
)
{
quantity
/=
a
;
return
*
this
;
}
/**
* Divides token and integer
* Throws an exception if overflow
* @brief Divides quantity of two tokens and return a new token
* @param a token to be multiplied
* @param b multipier
* @return result of addition as a new token
*/
inline
friend
token
operator
/
(
const
token
&
a
,
uint64_t
b
)
{
token
result
=
a
;
result
/=
b
;
return
result
;
}
/**
* Divides two tokens
* Throws an exception if overflow
* @brief Divides quantity of two tokens and return a new token
* @param a token
* @param b token
* @return result of addition as a new token
*/
inline
friend
NumberType
operator
/
(
const
token
&
a
,
const
token
&
b
)
{
return
a
.
quantity
/
b
.
quantity
;
}
/**
* Less than or equal to comparison operator
* @brief Less than or equal to comparison operator
* @param a token to be compared
* @param b token to be compared
* @return true if quantity of a is less than or equal to quantity of b
*/
friend
bool
operator
<=
(
const
token
&
a
,
const
token
&
b
)
{
return
a
.
quantity
<=
b
.
quantity
;
}
/**
* Less than comparison operator
* @brief Less than comparison operator
* @param a token to be compared
* @param b token to be compared
* @return true if quantity of a is less than quantity of b
*/
friend
bool
operator
<
(
const
token
&
a
,
const
token
&
b
)
{
return
a
.
quantity
<
b
.
quantity
;
}
/**
* Greater than or equal to comparison operator
* @brief Greater than or equal to comparison operator
* @param a token to be compared
* @param b token to be compared
* @return true if quantity of a is greater than or equal to quantity of b
*/
friend
bool
operator
>=
(
const
token
&
a
,
const
token
&
b
)
{
return
a
.
quantity
>=
b
.
quantity
;
}
/**
* Greater than comparison operator
* @brief Greater than comparison operator
* @param a token to be compared
* @param b token to be compared
* @return true if quantity of a is greater than quantity of b
*/
friend
bool
operator
>
(
const
token
&
a
,
const
token
&
b
)
{
return
a
.
quantity
>
b
.
quantity
;
}
/**
* Equality comparison operator
* @brief Equality comparison operator
* @param a token to be compared
* @param b token to be compared
* @return true if quantity of a is equal to quantity of b
*/
friend
bool
operator
==
(
const
token
&
a
,
const
token
&
b
)
{
return
a
.
quantity
==
b
.
quantity
;
}
/**
* Inequality comparison operator
* @brief Inequality comparison operator
* @param a token to be compared
* @param b token to be compared
* @return true if quantity of a is not equal to quantity of b
*/
friend
bool
operator
!=
(
const
token
&
a
,
const
token
&
b
)
{
return
a
.
quantity
!=
b
.
quantity
;
}
/**
* Boolean conversion operator
* @brief Boolean conversion operator
* @return true if quantity is not zero
*/
explicit
operator
bool
()
const
{
return
quantity
!=
0
;
}
template
<
typename
DataStream
>
friend
DataStream
&
operator
<<
(
DataStream
&
ds
,
const
token
&
t
){
return
ds
<<
t
.
quantity
;
}
template
<
typename
DataStream
>
friend
DataStream
&
operator
>>
(
DataStream
&
ds
,
token
&
t
){
return
ds
>>
t
.
quantity
;
}
};
/// @}
template
<
typename
BaseToken
,
typename
QuoteToken
>
struct
price_ratio
{
BaseToken
base
;
QuoteToken
quote
;
};
template
<
typename
Base
,
typename
Quote
>
price
<
Base
,
Quote
>
operator
/
(
const
Base
&
b
,
const
Quote
&
q
)
{
return
price
<
Base
,
Quote
>
(
b
,
q
);
}
/**
*
* @brief Defines a fixed precision price between two tokens.
* @tparam BaseToken - represents the type of the base token
* @tparam QuoteToken - represents the type of the quote token
* @ingroup tokens
*
* @details Defines a fixed precision price between two tokens.
* A price is written as X Base/Quote. Where X is a power of 10 which makes it simpler to just shift the decimal.
* It supports the following operator: /, \, <=, <, ==, !=, >=, > and also print functionality
*
* Example:
* @code
* typedef eosio::token<uint64_t, N(MyBaseToken)> MyBaseToken;
* typedef eosio::token<uint64_t, N(MyQuoteToken)> MyQuoteToken;
* typedef price<MyBaseToken, MyQuoteToken> MyBaseToQuotePrice;
* MyBaseToken zeroBaseToken;
* MyQuoteToken zeroQuoteToken;
* MyBaseToQuotePrice zeroBaseToQuote(zeroBaseToken, zeroQuoteToken); // throws invalid price exception
* MyBaseToken baseToken(128);
* MyQuoteToken quoteToken(128);
* MyBaseToQuotePrice aPrice(baseToken, quoteToken);
* aPrice.print(); // Output: 1e+15. MyBaseToken / MyQuoteToken
* MyQuoteToken anotherQuote = baseToken / price;
* std::cout << (anotherQuote == quoteToken); // Output: true
* MyBaseToken anotherBase = quoteToken * price;
* std::cout << (anotherBase == baseToken); // Output: true
* MyBaseToQuotePrice anotherPrice(baseToken, quoteToken);
* std::cout << (aPrice == anotherPrice); // Output: true
* std::cout << (aPrice != anotherPrice); // Output: false
* MyBaseToken base256(256);
* MyBaseToQuotePrice price2(base256, quoteToken);
* std::cout << (price2 > aPrice); // Output: true
* std::cout << (aPrice < price2); // Output: true
* @endcode
*
* @{
*/
template
<
typename
BaseToken
,
typename
QuoteToken
>
struct
price
{
typedef
BaseToken
base_token_type
;
typedef
QuoteToken
quote_token_type
;
/**
* The largest base 10 integer that can be represented with 53 bits of
* a double. This number keeps the math in range of JavaScript. By
* being a power of 10 it makes it easier for developers to read and
* interpret the integer by simply shifting the decimal.
* @brief Precision of the price.
*/
static
const
uint64_t
precision
=
1000ll
*
1000ll
*
1000ll
*
1000ll
*
1000ll
;
/**
* Default constructor.
* Initialize base per quote to be 1.
* @brief Default constructor.
*/
price
()
:
base_per_quote
(
1ul
){}
explicit
price
(
uint128_t
b
)
:
base_per_quote
(
b
){}
price
&
operator
=
(
uint128_t
b
)
{
base_per_quote
=
b
;
return
*
this
;
}
/**
* Construction for price given the base token and quote token.
* @brief Construction for price given the base token and quote token.
* @param base - base token
* @param quote - quote token
*/
price
(
BaseToken
base
,
QuoteToken
quote
)
{
eosio_assert
(
base
>=
BaseToken
(
1ul
),
"invalid price"
);
eosio_assert
(
quote
>=
QuoteToken
(
1ul
),
"invalid price"
);
base_per_quote
=
base
.
quantity
;
base_per_quote
*=
precision
;
base_per_quote
/=
quote
.
quantity
;
}
/**
* Operator returns a quote token given a base token and the conversion price.
* @brief Operator returns a quote token given a base token and the conversion price.
* @param b - base token
* @param q - price
* @return quote token
*/
friend
QuoteToken
operator
/
(
BaseToken
b
,
const
price
&
q
)
{
return
QuoteToken
(
uint64_t
((
uint128
(
b
.
quantity
)
*
uint128
(
precision
)
/
q
.
base_per_quote
))
);
}
/**
* Operator returns a base token given a quote token and the conversion price.
* @brief Operator returns a base token given a quote token and the conversion price.
* @param b - quote token
* @param q - price
* @return base token
*/
friend
BaseToken
operator
*
(
const
QuoteToken
&
b
,
const
price
&
q
)
{
//return QuoteToken( uint64_t( mult_div_i128( b.quantity, q.base_per_quote, precision ) ) );
return
BaseToken
(
uint64_t
((
b
.
quantity
*
q
.
base_per_quote
)
/
precision
)
);
}
/**
* Less than or equal to comparison operator.
* @brief Less than or equal to comparison operator.
* @param a price to be compared
* @param b price to be compared
* @return true if base per quote of a is less than or equal to base per quote of b
*/
friend
bool
operator
<=
(
const
price
&
a
,
const
price
&
b
)
{
return
a
.
base_per_quote
<=
b
.
base_per_quote
;
}
/**
* Less than comparison operator.
* @brief Less than comparison operator.
* @param a price to be compared
* @param b price to be compared
* @return true if base per quote of a is less than base per quote of b
*/
friend
bool
operator
<
(
const
price
&
a
,
const
price
&
b
)
{
return
a
.
base_per_quote
<
b
.
base_per_quote
;
}
/**
* Greater than or equal to comparison operator.
* @brief Greater than or equal to comparison operator.
* @param a price to be compared
* @param b price to be compared
* @return true if base per quote of a is greater than or equal to base per quote of b
*/
friend
bool
operator
>=
(
const
price
&
a
,
const
price
&
b
)
{
return
a
.
base_per_quote
>=
b
.
base_per_quote
;
}
/**
* Greater than comparison operator.
* @brief Greater than comparison operator.
* @param a price to be compared
* @param b price to be compared
* @return true if base per quote of a is greater than base per quote of b
*/
friend
bool
operator
>
(
const
price
&
a
,
const
price
&
b
)
{
return
a
.
base_per_quote
>
b
.
base_per_quote
;
}
/**
* Equality comparison operator.
* @brief Equality comparison operator.
* @param a price to be compared
* @param b price to be compared
* @return true if base per quote of a is equal to base per quote of b
*/
friend
bool
operator
==
(
const
price
&
a
,
const
price
&
b
)
{
return
a
.
base_per_quote
==
b
.
base_per_quote
;
}
/**
* Inequality comparison operator.
* @brief Inequality comparison operator.
* @param a price to be compared
* @param b price to be compared
* @return true if base per quote of a is not equal to base per quote of b
*/
friend
bool
operator
!=
(
const
price
&
a
,
const
price
&
b
)
{
return
a
.
base_per_quote
!=
b
.
base_per_quote
;
}
operator
uint128_t
()
const
{
return
base_per_quote
;
}
EOSLIB_SERIALIZE
(
price
,
(
base_per_quote
)
)
private:
/**
* Represents as number of base tokens to purchase 1 quote token.
* @brief Represents number of base tokens to purchase 1 quote token.
*/
uint128_t
base_per_quote
;
};
/// @}
/// @} tokenhppapi
}
contracts/exchange/CMakeLists.txt
浏览文件 @
85abd227
...
...
@@ -5,7 +5,6 @@ add_wast_executable(TARGET exchange
DESTINATION_FOLDER
${
CMAKE_CURRENT_BINARY_DIR
}
)
configure_file
(
"
${
ABI_FILES
}
"
"
${
CMAKE_CURRENT_BINARY_DIR
}
"
COPYONLY
)
add_dependencies
(
exchange currency
)
add_executable
(
test_exchange test_exchange.cpp
)
#bfp/lib/pack.c bfp/lib/posit.cpp bfp/lib/util.c bfp/lib/op2.c)
...
...
contracts/noop/noop.cpp
浏览文件 @
85abd227
...
...
@@ -3,13 +3,21 @@
* @copyright defined in eos/LICENSE.txt
*/
#include <noop/noop.hpp>
namespace
noop
{
extern
"C"
{
/// The apply method implements the dispatch of events to this contract
void
apply
(
uint64_t
receiver
,
uint64_t
code
,
uint64_t
action
)
{
eosio
::
dispatch
<
noop
,
noop
::
anyaction
>
(
code
,
action
);
}
}
}
#include <eosiolib/eosio.hpp>
namespace
eosio
{
class
noop
:
public
contract
{
public:
noop
(
account_name
self
)
:
contract
(
self
)
{
}
void
anyaction
(
account_name
from
,
const
std
::
string
&
/*type*/
,
const
std
::
string
&
/*data*/
)
{
require_auth
(
from
);
}
};
EOSIO_ABI
(
noop
,
(
anyaction
)
)
}
/// eosio
contracts/noop/noop.hpp
已删除
100644 → 0
浏览文件 @
18df341d
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#pragma once
#include <eosiolib/eosio.hpp>
#include <eosiolib/dispatcher.hpp>
namespace
noop
{
using
std
::
string
;
/**
noop contract
All it does is require sender authorization.
Actions: anyaction
*/
class
noop
{
public:
ACTION
(
N
(
noop
),
anyaction
)
{
anyaction
()
{
}
anyaction
(
account_name
f
,
const
string
&
t
,
const
string
&
d
)
:
from
(
f
),
type
(
t
),
data
(
d
)
{
}
account_name
from
;
string
type
;
string
data
;
EOSLIB_SERIALIZE
(
anyaction
,
(
from
)(
type
)(
data
))
};
static
void
on
(
const
anyaction
&
act
)
{
require_auth
(
act
.
from
);
}
};
}
/// noop
contracts/proxy/proxy.cpp
浏览文件 @
85abd227
...
...
@@ -53,7 +53,7 @@ namespace proxy {
configs
::
store
(
code_config
,
self
);
transaction
out
;
out
.
actions
.
emplace_back
(
permission_level
{
self
,
N
(
active
)},
N
(
currency
),
N
(
transfer
),
new_transfer
);
out
.
actions
.
emplace_back
(
permission_level
{
self
,
N
(
active
)},
N
(
eosio
.
token
),
N
(
transfer
),
new_transfer
);
out
.
delay_sec
=
code_config
.
delay
;
out
.
send
(
id
,
self
);
}
...
...
@@ -90,6 +90,13 @@ namespace proxy {
using
namespace
proxy
;
using
namespace
eosio
;
struct
transfer_args
{
account_name
from
;
account_name
to
;
asset
quantity
;
string
memo
;
};
extern
"C"
{
/// The apply method implements the dispatch of events to this contract
...
...
@@ -101,9 +108,9 @@ extern "C" {
// Comment this out for now so that the contract compiles, this will change with refactoring to use eosio.token
// apply_transfer(receiver, code, unpack_action_data<eosiosystem::contract<N(eosio.system)>::currency::transfer_memo>());
}
}
else
if
(
code
==
N
(
currency
)
)
{
}
else
if
(
code
==
N
(
eosio
.
token
)
)
{
if
(
action
==
N
(
transfer
)
)
{
// apply_transfer(receiver, code, unpack_action_data<eosio::currency::transfer
>());
apply_transfer
(
receiver
,
code
,
unpack_action_data
<
transfer_args
>
());
}
}
else
if
(
code
==
receiver
)
{
if
(
action
==
N
(
setowner
))
{
...
...
contracts/stltest/stltest.cpp
浏览文件 @
85abd227
...
...
@@ -136,7 +136,6 @@
#include <stdexcept>
*/
//include <eosiolib/eos.hpp>
#include <eosiolib/token.hpp>
#include <eosiolib/dispatcher.hpp>
using
namespace
eosio
;
...
...
@@ -159,9 +158,6 @@ namespace stltest {
class
contract
{
public:
typedef
eosio
::
token
<
N
(
mycurrency
),
S
(
4
,
MYCUR
)
>
token_type
;
static
const
uint64_t
code
=
token_type
::
code
;
static
const
uint64_t
symbol
=
token_type
::
symbol
;
static
const
uint64_t
sent_table_name
=
N
(
sent
);
static
const
uint64_t
received_table_name
=
N
(
received
);
...
...
plugins/txn_test_gen_plugin/CMakeLists.txt
浏览文件 @
85abd227
...
...
@@ -6,5 +6,3 @@ add_library( txn_test_gen_plugin
target_link_libraries
(
txn_test_gen_plugin appbase fc http_plugin chain_plugin
)
target_include_directories
(
txn_test_gen_plugin PUBLIC
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include"
)
target_include_directories
(
txn_test_gen_plugin PUBLIC
${
CMAKE_BINARY_DIR
}
/contracts
)
add_dependencies
(
txn_test_gen_plugin currency
)
tests/CMakeLists.txt
浏览文件 @
85abd227
...
...
@@ -28,7 +28,7 @@ target_include_directories( chain_test PUBLIC ${CMAKE_BINARY_DIR}/contracts ${CM
target_include_directories
(
chain_test PUBLIC
${
CMAKE_CURRENT_SOURCE_DIR
}
/wasm_tests
)
target_include_directories
(
chain_test PUBLIC
${
CMAKE_SOURCE_DIR
}
/plugins/net_plugin/include
)
target_include_directories
(
chain_test PUBLIC
${
CMAKE_CURRENT_SOURCE_DIR
}
/include
)
add_dependencies
(
chain_test asserter test_api test_api_mem test_api_db test_api_multi_index exchange
currency
proxy identity identity_test stltest infinite eosio.system eosio.token eosio.bios test.inline multi_index_test noop dice eosio.msig
)
add_dependencies
(
chain_test asserter test_api test_api_mem test_api_db test_api_multi_index exchange proxy identity identity_test stltest infinite eosio.system eosio.token eosio.bios test.inline multi_index_test noop dice eosio.msig
)
#
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/p2p_tests/sync/test.sh
${
CMAKE_CURRENT_BINARY_DIR
}
/p2p_tests/sync/test.sh COPYONLY
)
...
...
tests/chain_tests/delay_tests.cpp
浏览文件 @
85abd227
...
...
@@ -928,7 +928,7 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_test ) { try {
BOOST_REQUIRE_EXCEPTION
(
chain
.
push_action
(
config
::
system_account_name
,
contracts
::
linkauth
::
get_name
(),
tester_account
,
fc
::
mutable_variant_object
()
(
"account"
,
"tester"
)
(
"code"
,
"currency"
)
(
"code"
,
eosio_token
)
(
"type"
,
"transfer"
)
(
"requirement"
,
"second"
),
30
,
3
),
...
...
@@ -1071,27 +1071,27 @@ BOOST_AUTO_TEST_CASE( link_delay_unlink_test ) { try {
(
"delay"
,
10
));
chain
.
push_action
(
config
::
system_account_name
,
contracts
::
linkauth
::
get_name
(),
tester_account
,
fc
::
mutable_variant_object
()
(
"account"
,
"tester"
)
(
"code"
,
"currency"
)
(
"code"
,
eosio_token
)
(
"type"
,
"transfer"
)
(
"requirement"
,
"first"
));
chain
.
produce_blocks
();
chain
.
push_action
(
N
(
currency
),
N
(
create
),
N
(
currency
),
mutable_variant_object
()
(
"issuer"
,
"currency"
)
chain
.
push_action
(
N
(
eosio
.
token
),
N
(
create
),
N
(
eosio
.
token
),
mutable_variant_object
()
(
"issuer"
,
eosio_token
)
(
"maximum_supply"
,
"9000000.0000 CUR"
)
(
"can_freeze"
,
0
)
(
"can_recall"
,
0
)
(
"can_whitelist"
,
0
)
);
chain
.
push_action
(
N
(
currency
),
name
(
"issue"
),
N
(
currency
),
fc
::
mutable_variant_object
()
(
"to"
,
"currency"
)
chain
.
push_action
(
N
(
eosio
.
token
),
name
(
"issue"
),
N
(
eosio
.
token
),
fc
::
mutable_variant_object
()
(
"to"
,
eosio_token
)
(
"quantity"
,
"1000000.0000 CUR"
)
(
"memo"
,
"for stuff"
)
);
auto
trace
=
chain
.
push_action
(
N
(
currency
),
name
(
"transfer"
),
N
(
currency
),
fc
::
mutable_variant_object
()
(
"from"
,
"currency"
)
auto
trace
=
chain
.
push_action
(
N
(
eosio
.
token
),
name
(
"transfer"
),
N
(
eosio
.
token
),
fc
::
mutable_variant_object
()
(
"from"
,
eosio_token
)
(
"to"
,
"tester"
)
(
"quantity"
,
"100.0000 CUR"
)
(
"memo"
,
"hi"
)
...
...
@@ -1131,7 +1131,7 @@ BOOST_AUTO_TEST_CASE( link_delay_unlink_test ) { try {
BOOST_REQUIRE_EXCEPTION
(
chain
.
push_action
(
config
::
system_account_name
,
contracts
::
unlinkauth
::
get_name
(),
tester_account
,
fc
::
mutable_variant_object
()
(
"account"
,
"tester"
)
(
"code"
,
"currency"
)
(
"code"
,
eosio_token
)
(
"type"
,
"transfer"
),
30
,
7
),
transaction_exception
,
...
...
@@ -1145,7 +1145,7 @@ BOOST_AUTO_TEST_CASE( link_delay_unlink_test ) { try {
// this transaction will be delayed 20 blocks
chain
.
push_action
(
config
::
system_account_name
,
contracts
::
unlinkauth
::
get_name
(),
tester_account
,
fc
::
mutable_variant_object
()
(
"account"
,
"tester"
)
(
"code"
,
"currency"
)
(
"code"
,
eosio_token
)
(
"type"
,
"transfer"
),
30
,
10
);
...
...
@@ -1313,13 +1313,13 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_heirarchy_test ) { try {
chain
.
produce_blocks
();
auto
liquid_balance
=
get_currency_balance
(
chain
,
N
(
currency
));
auto
liquid_balance
=
get_currency_balance
(
chain
,
N
(
eosio
.
token
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"999900.0000 CUR"
),
liquid_balance
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"100.0000 CUR"
),
liquid_balance
);
// this transaction will be delayed 20 blocks
trace
=
chain
.
push_action
(
N
(
currency
),
name
(
"transfer"
),
N
(
tester
),
fc
::
mutable_variant_object
()
trace
=
chain
.
push_action
(
N
(
eosio
.
token
),
name
(
"transfer"
),
N
(
tester
),
fc
::
mutable_variant_object
()
(
"from"
,
"tester"
)
(
"to"
,
"tester2"
)
(
"quantity"
,
"1.0000 CUR"
)
...
...
@@ -1401,7 +1401,7 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_heirarchy_test ) { try {
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1.0000 CUR"
),
liquid_balance
);
// this transfer is performed right away since delay is removed
trace
=
chain
.
push_action
(
N
(
currency
),
name
(
"transfer"
),
N
(
tester
),
fc
::
mutable_variant_object
()
trace
=
chain
.
push_action
(
N
(
eosio
.
token
),
name
(
"transfer"
),
N
(
tester
),
fc
::
mutable_variant_object
()
(
"from"
,
"tester"
)
(
"to"
,
"tester2"
)
(
"quantity"
,
"10.0000 CUR"
)
...
...
@@ -1585,11 +1585,11 @@ BOOST_AUTO_TEST_CASE( canceldelay_test ) { try {
chain
.
set_abi
(
config
::
system_account_name
,
eosio_system_abi
);
chain
.
produce_blocks
();
chain
.
create_account
(
N
(
currency
));
chain
.
create_account
(
N
(
eosio
.
token
));
chain
.
produce_blocks
(
10
);
chain
.
set_code
(
N
(
currency
),
currency
_wast
);
chain
.
set_abi
(
N
(
currency
),
currency
_abi
);
chain
.
set_code
(
N
(
eosio
.
token
),
eosio_token
_wast
);
chain
.
set_abi
(
N
(
eosio
.
token
),
eosio_token
_abi
);
chain
.
produce_blocks
();
chain
.
create_account
(
N
(
tester
));
...
...
@@ -1655,7 +1655,7 @@ BOOST_AUTO_TEST_CASE( canceldelay_test ) { try {
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
currency
));
liquid_balance
=
get_currency_balance
(
chain
,
N
(
eosio
.
token
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"999900.0000 CUR"
),
liquid_balance
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"100.0000 CUR"
),
liquid_balance
);
...
...
@@ -1708,7 +1708,7 @@ BOOST_AUTO_TEST_CASE( canceldelay_test ) { try {
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 CUR"
),
liquid_balance
);
// this transaction will be delayed 20 blocks
trace
=
chain
.
push_action
(
N
(
currency
),
name
(
"transfer"
),
N
(
tester
),
fc
::
mutable_variant_object
()
trace
=
chain
.
push_action
(
N
(
eosio
.
token
),
name
(
"transfer"
),
N
(
tester
),
fc
::
mutable_variant_object
()
(
"from"
,
"tester"
)
(
"to"
,
"tester2"
)
(
"quantity"
,
"5.0000 CUR"
)
...
...
tests/wasm_tests/currency_tests.cpp
浏览文件 @
85abd227
...
...
@@ -366,7 +366,7 @@ BOOST_FIXTURE_TEST_CASE(test_symbol, TESTER) try {
}
}
FC_LOG_AND_RETHROW
()
/// test_symbol
#if 0
BOOST_FIXTURE_TEST_CASE
(
test_proxy
,
currency_tester
)
try
{
produce_blocks
(
2
);
...
...
@@ -420,8 +420,7 @@ BOOST_FIXTURE_TEST_CASE( test_proxy, currency_tester ) try {
BOOST_REQUIRE_EQUAL
(
get_balance
(
N
(
alice
)),
asset
::
from_string
(
"5.0000 CUR"
));
}
FC_LOG_AND_RETHROW
()
/// test_currency
#endif
#if 0
BOOST_FIXTURE_TEST_CASE
(
test_deferred_failure
,
currency_tester
)
try
{
produce_blocks
(
2
);
...
...
@@ -518,6 +517,5 @@ BOOST_FIXTURE_TEST_CASE( test_deferred_failure, currency_tester ) try {
BOOST_REQUIRE_EQUAL
(
get_balance
(
N
(
bob
)),
asset
::
from_string
(
"0.0000 CUR"
));
}
FC_LOG_AND_RETHROW
()
/// test_currency
#endif
BOOST_AUTO_TEST_SUITE_END
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录