Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
9337b61e
Commit
9337b61e
authored
Jan 26, 2019
by
linj
Committed by
vipwzw
Jan 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add const for fork name
parent
7bf10caa
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
25 deletions
+29
-25
token_new_test.go
plugin/dapp/token/executor/token_new_test.go
+15
-15
tokendb.go
plugin/dapp/token/executor/tokendb.go
+5
-6
const.go
plugin/dapp/token/types/const.go
+5
-0
types.go
plugin/dapp/token/types/types.go
+4
-4
No files found.
plugin/dapp/token/executor/token_new_test.go
View file @
9337b61e
...
...
@@ -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"
token
ty
"github.com/33cn/plugin/plugin/dapp/token/types"
p
ty
"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
:=
&
token
ty
.
TokenPreCreate
{
v
:=
&
p
ty
.
TokenPreCreate
{
Name
:
tokenName
,
Symbol
:
tokenSym
,
Introduction
:
tokenIntro
,
...
...
@@ -158,9 +158,9 @@ func TestPrecreate(t *testing.T) {
Price
:
tokenPrice
,
Owner
:
addr
,
}
precreate
:=
&
token
ty
.
TokenAction
{
Ty
:
token
ty
.
TokenActionPreCreate
,
Value
:
&
token
ty
.
TokenAction_TokenPreCreate
{
TokenPreCreate
:
v
},
precreate
:=
&
p
ty
.
TokenAction
{
Ty
:
p
ty
.
TokenActionPreCreate
,
Value
:
&
p
ty
.
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
:=
&
token
ty
.
TokenFinishCreate
{
Symbol
:
tokenSym
,
Owner
:
addr
}
finish
:=
&
token
ty
.
TokenAction
{
Ty
:
token
ty
.
TokenActionFinishCreate
,
Value
:
&
token
ty
.
TokenAction_TokenFinishCreate
{
TokenFinishCreate
:
v
},
v
:=
&
p
ty
.
TokenFinishCreate
{
Symbol
:
tokenSym
,
Owner
:
addr
}
finish
:=
&
p
ty
.
TokenAction
{
Ty
:
p
ty
.
TokenActionFinishCreate
,
Value
:
&
p
ty
.
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
:=
&
token
ty
.
TokenAction_Transfer
{
Transfer
:
&
types
.
AssetsTransfer
{
Cointoken
:
tokenSym
,
Amount
:
transAmount
,
Note
:
[]
byte
(
""
),
To
:
transToAddr
}}
transfer
:=
&
tokenty
.
TokenAction
{
Value
:
v
,
Ty
:
token
ty
.
ActionTransfer
}
v
:=
&
p
ty
.
TokenAction_Transfer
{
Transfer
:
&
types
.
AssetsTransfer
{
Cointoken
:
tokenSym
,
Amount
:
transAmount
,
Note
:
[]
byte
(
""
),
To
:
transToAddr
}}
transfer
:=
&
pty
.
TokenAction
{
Value
:
v
,
Ty
:
p
ty
.
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
token
ty
.
ReqAccountTokenAssets
var
reqAsset
p
ty
.
ReqAccountTokenAssets
reqAsset
.
Address
=
addr
reqAsset
.
Execer
=
execName
...
...
@@ -293,7 +293,7 @@ func TestQueryAsset(t *testing.T) {
t
.
Error
(
ErrTest
)
return
}
var
res
token
ty
.
ReplyAccountTokenAssets
var
res
p
ty
.
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
))
...
...
plugin/dapp/token/executor/tokendb.go
View file @
9337b61e
...
...
@@ -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
)
}
plugin/dapp/token/types/const.go
View file @
9337b61e
...
...
@@ -34,6 +34,11 @@ const (
var
(
// TokenX token name
TokenX
=
"token"
ForkTokenBlackListX
=
"ForkTokenBlackList"
ForkBadTokenSymbolX
=
"ForkBadTokenSymbol"
ForkTokenPriceX
=
"ForkTokenPrice"
ForkTokenSymbolWithNumberX
=
"ForkTokenSymbolWithNumber"
)
const
(
...
...
plugin/dapp/token/types/types.go
View file @
9337b61e
...
...
@@ -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 执行器基类结构体
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment