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

add const for fork name

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