Commit 9337b61e authored by linj's avatar linj Committed by vipwzw

add const for fork name

parent 7bf10caa
......@@ -18,7 +18,7 @@ import (
"github.com/33cn/chain33/common/crypto"
cty "github.com/33cn/chain33/system/dapp/coins/types"
"github.com/33cn/chain33/types"
tokenty "github.com/33cn/plugin/plugin/dapp/token/types"
pty "github.com/33cn/plugin/plugin/dapp/token/types"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
)
......@@ -150,7 +150,7 @@ func TestPrecreate(t *testing.T) {
fmt.Println("TestPrecreate start")
defer fmt.Println("TestPrecreate end")
v := &tokenty.TokenPreCreate{
v := &pty.TokenPreCreate{
Name: tokenName,
Symbol: tokenSym,
Introduction: tokenIntro,
......@@ -158,9 +158,9 @@ func TestPrecreate(t *testing.T) {
Price: tokenPrice,
Owner: addr,
}
precreate := &tokenty.TokenAction{
Ty: tokenty.TokenActionPreCreate,
Value: &tokenty.TokenAction_TokenPreCreate{TokenPreCreate: v},
precreate := &pty.TokenAction{
Ty: pty.TokenActionPreCreate,
Value: &pty.TokenAction_TokenPreCreate{TokenPreCreate: v},
}
tx := &types.Transaction{
Execer: []byte(execName),
......@@ -198,10 +198,10 @@ func TestFinish(t *testing.T) {
fmt.Println("TestFinish start")
defer fmt.Println("TestFinish end")
v := &tokenty.TokenFinishCreate{Symbol: tokenSym, Owner: addr}
finish := &tokenty.TokenAction{
Ty: tokenty.TokenActionFinishCreate,
Value: &tokenty.TokenAction_TokenFinishCreate{TokenFinishCreate: v},
v := &pty.TokenFinishCreate{Symbol: tokenSym, Owner: addr}
finish := &pty.TokenAction{
Ty: pty.TokenActionFinishCreate,
Value: &pty.TokenAction_TokenFinishCreate{TokenFinishCreate: v},
}
tx := &types.Transaction{
Execer: []byte(execName),
......@@ -239,8 +239,8 @@ func TestTransferToken(t *testing.T) {
fmt.Println("TestTransferToken start")
defer fmt.Println("TestTransferToken end")
v := &tokenty.TokenAction_Transfer{Transfer: &types.AssetsTransfer{Cointoken: tokenSym, Amount: transAmount, Note: []byte(""), To: transToAddr}}
transfer := &tokenty.TokenAction{Value: v, Ty: tokenty.ActionTransfer}
v := &pty.TokenAction_Transfer{Transfer: &types.AssetsTransfer{Cointoken: tokenSym, Amount: transAmount, Note: []byte(""), To: transToAddr}}
transfer := &pty.TokenAction{Value: v, Ty: pty.ActionTransfer}
tx := &types.Transaction{Execer: []byte(execName), Payload: types.Encode(transfer), Fee: fee, To: addrexec}
tx.Nonce = r.Int63()
......@@ -276,7 +276,7 @@ func TestQueryAsset(t *testing.T) {
req.Driver = execName
req.FuncName = "GetAccountTokenAssets"
var reqAsset tokenty.ReqAccountTokenAssets
var reqAsset pty.ReqAccountTokenAssets
reqAsset.Address = addr
reqAsset.Execer = execName
......@@ -293,7 +293,7 @@ func TestQueryAsset(t *testing.T) {
t.Error(ErrTest)
return
}
var res tokenty.ReplyAccountTokenAssets
var res pty.ReplyAccountTokenAssets
err = types.Decode(reply.Msg, &res)
if err != nil {
t.Error(err)
......@@ -386,8 +386,8 @@ func getprivkey(key string) crypto.PrivKey {
func TestToken_validSymbolWithHeight(t *testing.T) {
types.SetTitleOnlyForTest("chain33")
forkBadTokenSymbol := types.GetDappFork(tokenty.TokenX, "ForkBadTokenSymbol")
forkTokenSymbolWithNumber := types.GetDappFork(tokenty.TokenX, "ForkTokenSymbolWithNumber")
forkBadTokenSymbol := types.GetDappFork(pty.TokenX, pty.ForkBadTokenSymbolX)
forkTokenSymbolWithNumber := types.GetDappFork(pty.TokenX, pty.ForkTokenSymbolWithNumberX)
t.Log("x", "1", forkBadTokenSymbol, "2", forkTokenSymbolWithNumber)
assert.Equal(t, true, (forkTokenSymbolWithNumber >= forkBadTokenSymbol))
......
......@@ -122,7 +122,7 @@ func (action *tokenAction) preCreate(token *pty.TokenPreCreate) (*types.Receipt,
return nil, pty.ErrTokenHavePrecreated
}
if types.IsDappFork(action.height, pty.TokenX, "ForkTokenBlackList") {
if types.IsDappFork(action.height, pty.TokenX, pty.ForkTokenBlackListX) {
found, err := inBlacklist(token.GetSymbol(), blacklist, action.db)
if err != nil {
return nil, err
......@@ -135,7 +135,7 @@ func (action *tokenAction) preCreate(token *pty.TokenPreCreate) (*types.Receipt,
var logs []*types.ReceiptLog
var kv []*types.KeyValue
if types.IsDappFork(action.height, pty.TokenX, "ForkTokenPrice") && token.GetPrice() == 0 {
if types.IsDappFork(action.height, pty.TokenX, pty.ForkTokenPriceX) && token.GetPrice() == 0 {
// pay for create token offline
} else {
receipt, err := action.coinsAccount.ExecFrozen(action.fromaddr, action.execaddr, token.GetPrice())
......@@ -271,7 +271,7 @@ func (action *tokenAction) revokeCreate(tokenRevoke *pty.TokenRevokeCreate) (*ty
var logs []*types.ReceiptLog
var kv []*types.KeyValue
if types.IsDappFork(action.height, pty.TokenX, "ForkTokenPrice") && token.GetPrice() == 0 {
if types.IsDappFork(action.height, pty.TokenX, pty.ForkTokenPriceX) && token.GetPrice() == 0 {
// pay for create token offline
} else {
//解锁之前冻结的资金
......@@ -453,11 +453,10 @@ func validSymbolOriginal(cs []byte) bool {
}
func validSymbolWithHeight(cs []byte, height int64) bool {
if types.IsDappFork(height, pty.TokenX, "ForkTokenSymbolWithNumber") {
if types.IsDappFork(height, pty.TokenX, pty.ForkTokenSymbolWithNumberX) {
return validSymbolForkTokenSymbolWithNumber(cs)
} else if types.IsDappFork(height, pty.TokenX, "ForkBadTokenSymbol") {
} else if types.IsDappFork(height, pty.TokenX, pty.ForkBadTokenSymbolX) {
return validSymbolForkBadTokenSymbol(cs)
}
return validSymbolOriginal(cs)
}
......@@ -34,6 +34,11 @@ const (
var (
// TokenX token name
TokenX = "token"
ForkTokenBlackListX = "ForkTokenBlackList"
ForkBadTokenSymbolX = "ForkBadTokenSymbol"
ForkTokenPriceX = "ForkTokenPrice"
ForkTokenSymbolWithNumberX = "ForkTokenSymbolWithNumber"
)
const (
......
......@@ -19,10 +19,10 @@ func init() {
types.AllowUserExec = append(types.AllowUserExec, []byte(TokenX))
types.RegistorExecutor(TokenX, NewType())
types.RegisterDappFork(TokenX, "Enable", 100899)
types.RegisterDappFork(TokenX, "ForkTokenBlackList", 190000)
types.RegisterDappFork(TokenX, "ForkBadTokenSymbol", 184000)
types.RegisterDappFork(TokenX, "ForkTokenPrice", 560000)
types.RegisterDappFork(TokenX, "ForkTokenSymbolWithNumber", 1500000)
types.RegisterDappFork(TokenX, ForkTokenBlackListX, 190000)
types.RegisterDappFork(TokenX, ForkBadTokenSymbolX, 184000)
types.RegisterDappFork(TokenX, ForkTokenPriceX, 560000)
types.RegisterDappFork(TokenX, ForkTokenSymbolWithNumberX, 1500000)
}
// TokenType 执行器基类结构体
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment