Commit 61485a4a authored by liuyuhang's avatar liuyuhang

modify newAccountDB Adaptive

parent dc4202e3
......@@ -66,16 +66,16 @@ func TestGame(t *testing.T) {
stateDB, _ := dbm.NewGoMemDB("1", "2", 1000)
_, _, kvdb := util.CreateTestDB()
accA, _ := account.NewAccountDB("coins", "bty", stateDB)
accA, _ := account.NewAccountDB(cfg, "coins", "bty", stateDB)
accA.SaveExecAccount(execAddr, &accountA)
accB, _ := account.NewAccountDB("coins", "bty", stateDB)
accB, _ := account.NewAccountDB(cfg, "coins", "bty", stateDB)
accB.SaveExecAccount(execAddr, &accountB)
accC, _ := account.NewAccountDB("coins", "bty", stateDB)
accC, _ := account.NewAccountDB(cfg, "coins", "bty", stateDB)
accC.SaveExecAccount(execAddr, &accountC)
accD, _ := account.NewAccountDB("coins", "bty", stateDB)
accD, _ := account.NewAccountDB(cfg, "coins", "bty", stateDB)
accD.SaveExecAccount(execAddr, &accountD)
env := execEnv{
10,
......
......@@ -65,7 +65,8 @@ func (u *js) getAccount(args otto.Value) (*account.DB, error) {
if err != nil {
return nil, err
}
return account.NewAccountDB(execer, symbol, u.GetStateDB())
cfg := u.GetAPI().GetConfig()
return account.NewAccountDB(cfg, execer, symbol, u.GetStateDB())
}
func (u *js) genesisInitExecFunc(vm *otto.Otto) {
......
......@@ -269,7 +269,8 @@ func (a *action) MultiSigExecTransferTo(execTransfer *mty.MultiSigExecTransferTo
//将指定账户上的资产从balance转账到多重签名账户的balance上
symbol := getRealSymbol(execTransfer.Symbol)
newAccountDB, err := account.NewAccountDB(execTransfer.Execname, symbol, a.db)
cfg := a.api.GetConfig()
newAccountDB, err := account.NewAccountDB(cfg, execTransfer.Execname, symbol, a.db)
if err != nil {
return nil, err
}
......@@ -768,7 +769,8 @@ func (a *action) executeTransferTx(multiSigAcc *mty.MultiSig, newMultiSigTx *mty
//执行此交易,从多重签名账户转币到指定账户,在multiSig合约中转账
symbol := getRealSymbol(transfer.Symbol)
execerAccDB, err := account.NewAccountDB(transfer.Execname, symbol, a.db)
cfg := a.api.GetConfig()
execerAccDB, err := account.NewAccountDB(cfg, transfer.Execname, symbol, a.db)
if err != nil {
multisiglog.Error("executeTransaction:NewAccountDB", "From", transfer.From, "To", transfer.To,
"execaddr", a.execaddr, "amount", amount, "Execer", transfer.Execname, "Symbol", transfer.Symbol, "error", err)
......
......@@ -881,14 +881,13 @@ func (m *MultiSig) saveMultiSigTxCountUpdate(accTxCount mty.ReceiptTxCountUpdate
//获取多重签名账户的指定资产
func (m *MultiSig) getMultiSigAccAssets(multiSigAddr string, assets *mty.Assets) (*types.Account, error) {
symbol := getRealSymbol(assets.Symbol)
acc, err := account.NewAccountDB(assets.Execer, symbol, m.GetStateDB())
cfg := m.GetAPI().GetConfig()
acc, err := account.NewAccountDB(cfg, assets.Execer, symbol, m.GetStateDB())
if err != nil {
return &types.Account{}, err
}
var acc1 *types.Account
cfg := m.GetAPI().GetConfig()
execaddress := dapp.ExecAddress(cfg.ExecName(m.GetName()))
acc1 = acc.LoadExecAccount(multiSigAddr, execaddress)
return acc1, nil
......
......@@ -20,13 +20,13 @@ import (
// symbol: coins.bty, token.{TEST}
// 完整的帐号地址 mavl-{paracross}-coins.bty-{user-address} 不带title{paracross}
// 对应主链上paracross 子帐号 malv-coins-bty-exec-{Address(paracross)}:{Address(user.p.{guodun}.paracross)}
func NewParaAccount(paraTitle, mainExecName, mainSymbol string, db db.KV) (*account.DB, error) {
func NewParaAccount(cfg *types.Chain33Config, paraTitle, mainExecName, mainSymbol string, db db.KV) (*account.DB, error) {
// 按照现在的配置, title 是 带 "." 做结尾
// paraExec := paraTitle + types.ParaX
paraExec := pt.ParaX // 现在平行链是执行器注册和算地址是不带前缀的,
// 如果能确保(或规定) tokne 的 symbol 和 coins 中的 symbol 不会混淆, localExecName 可以不要
paraSymbol := mainExecName + "." + mainSymbol
return account.NewAccountDB(paraExec, paraSymbol, db)
return account.NewAccountDB(cfg, paraExec, paraSymbol, db)
}
//NewMainAccount create new Main account
......@@ -35,9 +35,9 @@ func NewParaAccount(paraTitle, mainExecName, mainSymbol string, db db.KV) (*acco
// symbol: user.p.{guodun}.coins.{guodun} user.p.{guodun}.token.{TEST}
// 完整的帐号地址 mavl-paracross-user.p.{guodun}.coins.guodun-{user-address}
// 对应平行链上子地址 mavl-coins-{guodun}-exec-{Address(paracross)}:{Address(paracross)}
func NewMainAccount(paraTitle, paraExecName, paraSymbol string, db db.KV) (*account.DB, error) {
func NewMainAccount(cfg *types.Chain33Config, paraTitle, paraExecName, paraSymbol string, db db.KV) (*account.DB, error) {
mainSymbol := paraTitle + paraExecName + "." + paraSymbol
return account.NewAccountDB(pt.ParaX, mainSymbol, db)
return account.NewAccountDB(cfg, pt.ParaX, mainSymbol, db)
}
func assetDepositBalance(acc *account.DB, addr string, amount int64) (*types.Receipt, error) {
......
......@@ -965,7 +965,7 @@ func (a *action) Miner(miner *pt.ParacrossMinerAction) (*types.Receipt, error) {
totalReward *= types.Coin
if totalReward > 0 {
issueReceipt, err := a.coinsAccount.ExecIssueCoins(cfg, a.execaddr, totalReward)
issueReceipt, err := a.coinsAccount.ExecIssueCoins(a.execaddr, totalReward)
if err != nil {
clog.Error("paracross miner issue err", "height", miner.Status.Height,
......@@ -1016,7 +1016,8 @@ func (a *action) Transfer(transfer *types.AssetsTransfer, tx *types.Transaction,
transfer.Amount, "to", tx.To)
from := tx.From()
acc, err := account.NewAccountDB(pt.ParaX, transfer.Cointoken, a.db)
cfg := a.api.GetConfig()
acc, err := account.NewAccountDB(cfg, pt.ParaX, transfer.Cointoken, a.db)
if err != nil {
clog.Error("Transfer failed", "err", err)
return nil, err
......@@ -1031,7 +1032,8 @@ func (a *action) Transfer(transfer *types.AssetsTransfer, tx *types.Transaction,
func (a *action) Withdraw(withdraw *types.AssetsWithdraw, tx *types.Transaction, index int) (*types.Receipt, error) {
clog.Debug("Paracross.Exec Withdraw", "symbol", withdraw.Cointoken, "amount",
withdraw.Amount, "to", tx.To)
acc, err := account.NewAccountDB(pt.ParaX, withdraw.Cointoken, a.db)
cfg := a.api.GetConfig()
acc, err := account.NewAccountDB(cfg, pt.ParaX, withdraw.Cointoken, a.db)
if err != nil {
clog.Error("Withdraw failed", "err", err)
return nil, err
......@@ -1047,7 +1049,8 @@ func (a *action) TransferToExec(transfer *types.AssetsTransferToExec, tx *types.
transfer.Amount, "to", tx.To)
from := tx.From()
acc, err := account.NewAccountDB(pt.ParaX, transfer.Cointoken, a.db)
cfg := a.api.GetConfig()
acc, err := account.NewAccountDB(cfg, pt.ParaX, transfer.Cointoken, a.db)
if err != nil {
clog.Error("TransferToExec failed", "err", err)
return nil, err
......
......@@ -41,9 +41,9 @@ func (a *action) assetTransfer(transfer *types.AssetsTransfer) (*types.Receipt,
}
var paraAcc *account.DB
if transfer.Cointoken == "" {
paraAcc, err = NewParaAccount(string(paraTitle), "coins", "bty", a.db)
paraAcc, err = NewParaAccount(cfg, string(paraTitle), "coins", "bty", a.db)
} else {
paraAcc, err = NewParaAccount(string(paraTitle), "token", transfer.Cointoken, a.db)
paraAcc, err = NewParaAccount(cfg, string(paraTitle), "token", transfer.Cointoken, a.db)
}
if err != nil {
return nil, errors.Wrap(err, "assetTransferCoins call NewParaAccount failed")
......@@ -75,9 +75,9 @@ func (a *action) assetWithdraw(withdraw *types.AssetsWithdraw, withdrawTx *types
}
var paraAcc *account.DB
if withdraw.Cointoken == "" {
paraAcc, err = NewParaAccount(string(paraTitle), "coins", "bty", a.db)
paraAcc, err = NewParaAccount(cfg, string(paraTitle), "coins", "bty", a.db)
} else {
paraAcc, err = NewParaAccount(string(paraTitle), "token", withdraw.Cointoken, a.db)
paraAcc, err = NewParaAccount(cfg, string(paraTitle), "token", withdraw.Cointoken, a.db)
}
if err != nil {
return nil, errors.Wrap(err, "assetWithdrawCoins call NewParaAccount failed")
......@@ -94,7 +94,7 @@ func createAccount(cfg *types.Chain33Config, db db.KV, symbol string) (*account.
accDB = account.NewCoinsAccount(cfg)
accDB.SetDB(db)
} else {
accDB, err = account.NewAccountDB("token", symbol, db)
accDB, err = account.NewAccountDB(cfg, "token", symbol, db)
}
return accDB, err
}
......@@ -197,7 +197,7 @@ func (suite *AssetTransferTestSuite) TestExecTransferInPara() {
suite.T().Log(string(kv.Key), v)
}
acc, _ := NewParaAccount(Title, "coins", "bty", suite.stateDB)
acc, _ := NewParaAccount(chain33TestCfg, Title, "coins", "bty", suite.stateDB)
resultB := acc.LoadAccount(string(toB))
assert.Equal(suite.T(), Amount, resultB.Balance)
}
......@@ -244,7 +244,7 @@ func (suite *AssetTransferTestSuite) TestExecTransferToken() {
Frozen: 0,
Addr: string(Nodes[0]),
}
acc, _ := account.NewAccountDB("token", TestSymbol, suite.stateDB)
acc, _ := account.NewAccountDB(chain33TestMainCfg, "token", TestSymbol, suite.stateDB)
addrMain := address.ExecAddress(pt.ParaX)
addrPara := address.ExecAddress(Title + pt.ParaX)
......@@ -306,7 +306,7 @@ func (suite *AssetTransferTestSuite) TestExecTransferTokenInPara() {
suite.T().Log(string(kv.Key), v)
}
acc, _ := NewParaAccount(Title, "token", TestSymbol, suite.stateDB)
acc, _ := NewParaAccount(chain33TestCfg, Title, "token", TestSymbol, suite.stateDB)
resultB := acc.LoadAccount(string(toB))
assert.Equal(suite.T(), Amount, resultB.Balance)
}
......
......@@ -120,7 +120,7 @@ func (suite *AssetWithdrawTestSuite) TestExecAssetWithdrawOnParaChain() {
Frozen: 0,
Addr: string(Nodes[0]),
}
paraAcc, _ := NewParaAccount(Title, "coins", "bty", suite.stateDB)
paraAcc, _ := NewParaAccount(chain33TestCfg, Title, "coins", "bty", suite.stateDB)
paraAcc.SaveAccount(&accountA)
tx, err := createAssetWithdrawTx(suite.Suite, PrivKeyA, Nodes[1])
......
......@@ -152,6 +152,6 @@ func (p *privacy) createAccountDB(exec, symbol string) (*account.DB, error) {
if exec == "" || exec == "coins" {
return p.GetCoinsAccount(), nil
}
return account.NewAccountDB(exec, symbol, p.GetStateDB())
cfg := p.GetAPI().GetConfig()
return account.NewAccountDB(cfg, exec, symbol, p.GetStateDB())
}
......@@ -219,7 +219,7 @@ func (action *Action) RetrievePerformAssets(perfRet *rt.PerformRetrieve, default
}
for _, asset := range perfRet.Assets {
accdb, err := account.NewAccountDB(asset.Exec, asset.Symbol, action.db)
accdb, err := account.NewAccountDB(cfg, asset.Exec, asset.Symbol, action.db)
if err != nil {
rlog.Error("RetrievePerform", "NewAccountDB", err)
return nil, err
......
......@@ -339,7 +339,7 @@ func (action *Action) TicketMiner(miner *ty.TicketMiner, index int) (*types.Rece
var logs []*types.ReceiptLog
var kv []*types.KeyValue
//user
receipt1, err := action.coinsAccount.ExecDepositFrozen(chain33Cfg, t.ReturnAddress, action.execaddr, ticket.MinerValue)
receipt1, err := action.coinsAccount.ExecDepositFrozen(t.ReturnAddress, action.execaddr, ticket.MinerValue)
if err != nil {
tlog.Error("TicketMiner.ExecDepositFrozen user", "addr", t.ReturnAddress, "execaddr", action.execaddr)
return nil, err
......@@ -349,13 +349,13 @@ func (action *Action) TicketMiner(miner *ty.TicketMiner, index int) (*types.Rece
if chain33Cfg.IsFork(action.height, "ForkTicketFundAddrV1") {
// issue coins to exec addr
addr := chain33Cfg.MGStr("mver.consensus.fundKeyAddr", action.height)
receipt2, err = action.coinsAccount.ExecIssueCoins(chain33Cfg, addr, cfg.CoinDevFund)
receipt2, err = action.coinsAccount.ExecIssueCoins(addr, cfg.CoinDevFund)
if err != nil {
tlog.Error("TicketMiner.ExecDepositFrozen fund to autonomy fund", "addr", addr, "error", err)
return nil, err
}
} else {
receipt2, err = action.coinsAccount.ExecDepositFrozen(chain33Cfg, chain33Cfg.GetFundAddr(), action.execaddr, cfg.CoinDevFund)
receipt2, err = action.coinsAccount.ExecDepositFrozen(chain33Cfg.GetFundAddr(), action.execaddr, cfg.CoinDevFund)
if err != nil {
tlog.Error("TicketMiner.ExecDepositFrozen fund", "addr", chain33Cfg.GetFundAddr(), "execaddr", action.execaddr, "error", err)
return nil, err
......
......@@ -12,7 +12,8 @@ import (
func (t *token) Exec_Transfer(payload *types.AssetsTransfer, tx *types.Transaction, index int) (*types.Receipt, error) {
token := payload.GetCointoken()
db, err := account.NewAccountDB(t.GetName(), token, t.GetStateDB())
cfg := t.GetAPI().GetConfig()
db, err := account.NewAccountDB(cfg, t.GetName(), token, t.GetStateDB())
if err != nil {
return nil, err
}
......@@ -27,7 +28,8 @@ func (t *token) Exec_Transfer(payload *types.AssetsTransfer, tx *types.Transacti
func (t *token) Exec_Withdraw(payload *types.AssetsWithdraw, tx *types.Transaction, index int) (*types.Receipt, error) {
token := payload.GetCointoken()
db, err := account.NewAccountDB(t.GetName(), token, t.GetStateDB())
cfg := t.GetAPI().GetConfig()
db, err := account.NewAccountDB(cfg, t.GetName(), token, t.GetStateDB())
if err != nil {
return nil, err
}
......@@ -58,7 +60,8 @@ func (t *token) Exec_TokenRevokeCreate(payload *tokenty.TokenRevokeCreate, tx *t
func (t *token) Exec_TransferToExec(payload *types.AssetsTransferToExec, tx *types.Transaction, index int) (*types.Receipt, error) {
token := payload.GetCointoken()
db, err := account.NewAccountDB(t.GetName(), token, t.GetStateDB())
cfg := t.GetAPI().GetConfig()
db, err := account.NewAccountDB(cfg, t.GetName(), token, t.GetStateDB())
if err != nil {
return nil, err
}
......
......@@ -32,7 +32,7 @@ func (t *token) ExecDelLocal_Transfer(payload *types.AssetsTransfer, tx *types.T
if err != nil {
return nil, err
}
if cfg.SaveTokenTxList {
if subCfg.SaveTokenTxList {
tokenAction := tokenty.TokenAction{
Ty: tokenty.ActionTransfer,
Value: &tokenty.TokenAction_Transfer{
......@@ -53,7 +53,7 @@ func (t *token) ExecDelLocal_Withdraw(payload *types.AssetsWithdraw, tx *types.T
if err != nil {
return nil, err
}
if cfg.SaveTokenTxList {
if subCfg.SaveTokenTxList {
tokenAction := tokenty.TokenAction{
Ty: tokenty.ActionWithdraw,
Value: &tokenty.TokenAction_Withdraw{
......@@ -74,7 +74,7 @@ func (t *token) ExecDelLocal_TransferToExec(payload *types.AssetsTransferToExec,
if err != nil {
return nil, err
}
if cfg.SaveTokenTxList {
if subCfg.SaveTokenTxList {
tokenAction := tokenty.TokenAction{
Ty: tokenty.TokenActionTransferToExec,
Value: &tokenty.TokenAction_TransferToExec{
......
......@@ -24,7 +24,7 @@ func (t *token) ExecLocal_Transfer(payload *types.AssetsTransfer, tx *types.Tran
if kv != nil {
set.KV = append(set.KV, kv...)
}
if cfg.SaveTokenTxList {
if subCfg.SaveTokenTxList {
tokenAction := tokenty.TokenAction{
Ty: tokenty.ActionTransfer,
Value: &tokenty.TokenAction_Transfer{
......@@ -50,7 +50,7 @@ func (t *token) ExecLocal_Withdraw(payload *types.AssetsWithdraw, tx *types.Tran
if kv != nil {
set.KV = append(set.KV, kv...)
}
if cfg.SaveTokenTxList {
if subCfg.SaveTokenTxList {
tokenAction := tokenty.TokenAction{
Ty: tokenty.ActionWithdraw,
Value: &tokenty.TokenAction_Withdraw{
......@@ -71,7 +71,7 @@ func (t *token) ExecLocal_TransferToExec(payload *types.AssetsTransferToExec, tx
if err != nil {
return nil, err
}
if cfg.SaveTokenTxList {
if subCfg.SaveTokenTxList {
tokenAction := tokenty.TokenAction{
Ty: tokenty.TokenActionTransferToExec,
Value: &tokenty.TokenAction_TransferToExec{
......
......@@ -64,7 +64,7 @@ func (t *token) Query_GetTxByToken(in *tokenty.ReqTokenTx) (types.Message, error
if in == nil {
return nil, types.ErrInvalidParam
}
if !cfg.SaveTokenTxList {
if !subCfg.SaveTokenTxList {
return nil, types.ErrActionNotSupport
}
return t.getTxByToken(in)
......
......@@ -38,12 +38,12 @@ type subConfig struct {
SaveTokenTxList bool `json:"saveTokenTxList"`
}
var cfg subConfig
var subCfg subConfig
// Init 重命名执行器名称
func Init(name string, cfg *types.Chain33Config, sub []byte) {
if sub != nil {
types.MustDecode(sub, &cfg)
types.MustDecode(sub, &subCfg)
}
drivers.Register(cfg, GetName(), newToken, cfg.GetDappFork(driverName, "Enable"))
InitExecType()
......@@ -102,8 +102,9 @@ func (t *token) getAccountTokenAssets(req *tokenty.ReqAccountTokenAssets) (types
if err != nil {
return nil, err
}
cfg := t.GetAPI().GetConfig()
for _, asset := range assets.Datas {
acc, err := account.NewAccountDB(t.GetName(), asset, t.GetStateDB())
acc, err := account.NewAccountDB(cfg, t.GetName(), asset, t.GetStateDB())
if err != nil {
return nil, err
}
......
......@@ -66,10 +66,10 @@ func TestToken(t *testing.T) {
stateDB, _ := dbm.NewGoMemDB("1", "2", 100)
_, _, kvdb := util.CreateTestDB()
accA, _ := account.NewAccountDB(AssetExecPara, Symbol, stateDB)
accA, _ := account.NewAccountDB(cfg, AssetExecPara, Symbol, stateDB)
accA.SaveExecAccount(execAddr, &accountA)
accB, _ := account.NewAccountDB(AssetExecPara, Symbol, stateDB)
accB, _ := account.NewAccountDB(cfg, AssetExecPara, Symbol, stateDB)
accB.SaveExecAccount(execAddr, &accountB)
env := execEnv{
......@@ -188,7 +188,7 @@ func TestToken(t *testing.T) {
for _, kv := range receipt.KV {
stateDB.Set(kv.Key, kv.Value)
}
accDB, _ := account.NewAccountDB(pty.TokenX, Symbol, stateDB)
accDB, _ := account.NewAccountDB(cfg, pty.TokenX, Symbol, stateDB)
accCheck := accDB.LoadAccount(string(Nodes[0]))
assert.Equal(t, tokenTotal, accCheck.Balance)
......
......@@ -276,7 +276,7 @@ func (action *tokenAction) finishCreate(tokenFinish *pty.TokenFinishCreate) (*ty
//创建token类型的账户,同时需要创建的额度存入
tokenAccount, err := account.NewAccountDB("token", tokenFinish.GetSymbol(), action.db)
tokenAccount, err := account.NewAccountDB(cfg, "token", tokenFinish.GetSymbol(), action.db)
if err != nil {
return nil, err
}
......@@ -575,7 +575,8 @@ func (action *tokenAction) mint(mint *pty.TokenMint) (*types.Receipt, error) {
return nil, err
}
tokenAccount, err := account.NewAccountDB("token", mint.GetSymbol(), action.db)
cfg := action.api.GetConfig()
tokenAccount, err := account.NewAccountDB(cfg, "token", mint.GetSymbol(), action.db)
if err != nil {
return nil, err
}
......@@ -614,8 +615,8 @@ func (action *tokenAction) burn(burn *pty.TokenBurn) (*types.Receipt, error) {
tokenlog.Error("token burn ", "symbol", burn.GetSymbol(), "error", err, "from", action.fromaddr, "owner", tokendb.token.Owner)
return nil, err
}
tokenAccount, err := account.NewAccountDB("token", burn.GetSymbol(), action.db)
chain33cfg := action.api.GetConfig()
tokenAccount, err := account.NewAccountDB(chain33cfg, "token", burn.GetSymbol(), action.db)
if err != nil {
return nil, err
}
......
......@@ -17,11 +17,12 @@ import (
//TODO:和GetBalance进行泛化处理,同时LoadAccounts和LoadExecAccountQueue也需要进行泛化处理, added by hzj
func (c *channelClient) getTokenBalance(in *tokenty.ReqTokenBalance) ([]*types.Account, error) {
accountTokendb, err := account.NewAccountDB(tokenty.TokenX, in.GetTokenSymbol(), nil)
cfg := c.GetConfig()
accountTokendb, err := account.NewAccountDB(cfg, tokenty.TokenX, in.GetTokenSymbol(), nil)
if err != nil {
return nil, err
}
cfg := c.GetConfig()
switch in.GetExecer() {
case cfg.ExecName(tokenty.TokenX):
addrs := in.GetAddresses()
......
......@@ -91,7 +91,7 @@ func TestTrade_Exec_SellLimit(t *testing.T) {
accB.SetDB(kvdb)
accB.SaveExecAccount(address.ExecAddress("trade"), &accountB)
accA, _ := account.NewAccountDB(AssetExecToken, Symbol, kvdb)
accA, _ := account.NewAccountDB(chain33TestCfg, AssetExecToken, Symbol, kvdb)
accA.SaveExecAccount(address.ExecAddress("trade"), &accountA)
api := new(apimock.QueueProtocolAPI)
......@@ -233,11 +233,11 @@ func TestTrade_Exec_BuyLimit(t *testing.T) {
stateDB, _ := dbm.NewGoMemDB("1", "2", 100)
_, ldb, kvdb := util.CreateTestDB()
accB, _ := account.NewAccountDB(AssetExecToken, SymbolA, stateDB)
accB, _ := account.NewAccountDB(chain33TestCfg, AssetExecToken, SymbolA, stateDB)
accB.SetDB(stateDB)
accB.SaveExecAccount(address.ExecAddress("trade"), &accountB)
accA, _ := account.NewAccountDB(AssetExecPara, Symbol, stateDB)
accA, _ := account.NewAccountDB(chain33TestCfg, AssetExecPara, Symbol, stateDB)
accA.SaveExecAccount(address.ExecAddress("trade"), &accountA)
api := new(apimock.QueueProtocolAPI)
......@@ -410,7 +410,7 @@ func TestTradeSellFixAssetDB(t *testing.T) {
accB.SetDB(kvdb)
accB.SaveExecAccount(address.ExecAddress("trade"), &accountB)
accA, _ := account.NewAccountDB(AssetExecToken, Symbol, kvdb)
accA, _ := account.NewAccountDB(chain33TestCfg, AssetExecToken, Symbol, kvdb)
accA.SaveExecAccount(address.ExecAddress("trade"), &accountA)
api := new(apimock.QueueProtocolAPI)
......
......@@ -74,12 +74,12 @@ func createAccountDB(cfg *types.Chain33Config, height int64, db db.KV, exec, sym
if exec == "" {
exec = defaultAssetExec
}
return account.NewAccountDB(exec, symbol, db)
return account.NewAccountDB(cfg, exec, symbol, db)
} else if cfg.IsDappFork(height, pt.TradeX, pt.ForkTradeAssetX) {
return account.NewAccountDB(exec, symbol, db)
return account.NewAccountDB(cfg, exec, symbol, db)
}
return account.NewAccountDB(defaultAssetExec, symbol, db)
return account.NewAccountDB(cfg, defaultAssetExec, symbol, db)
}
func createPriceDB(cfg *types.Chain33Config, height int64, db db.KV, exec, symbol string) (*account.DB, error) {
......@@ -90,7 +90,7 @@ func createPriceDB(cfg *types.Chain33Config, height int64, db db.KV, exec, symbo
acc.SetDB(db)
return acc, nil
}
return account.NewAccountDB(exec, symbol, db)
return account.NewAccountDB(cfg, exec, symbol, db)
}
acc := account.NewCoinsAccount(cfg)
acc.SetDB(db)
......
......@@ -30,7 +30,8 @@ func (u *Unfreeze) Exec_Create(payload *pty.UnfreezeCreate, tx *types.Transactio
return nil, err
}
acc, err := account.NewAccountDB(payload.AssetExec, payload.AssetSymbol, u.GetStateDB())
cfg := u.GetAPI().GetConfig()
acc, err := account.NewAccountDB(cfg, payload.AssetExec, payload.AssetSymbol, u.GetStateDB())
if err != nil {
uflog.Error("unfreeze create new account", "addr", tx.From(), "execAddr",
dapp.ExecAddress(string(tx.Execer)), "exec", payload.AssetExec, "symbol", payload.AssetSymbol)
......@@ -71,7 +72,7 @@ func (u *Unfreeze) Exec_Withdraw(payload *pty.UnfreezeWithdraw, tx *types.Transa
return nil, err
}
acc, err := account.NewAccountDB(unfreeze.AssetExec, unfreeze.AssetSymbol, u.GetStateDB())
acc, err := account.NewAccountDB(cfg, unfreeze.AssetExec, unfreeze.AssetSymbol, u.GetStateDB())
if err != nil {
return nil, err
}
......@@ -108,7 +109,7 @@ func (u *Unfreeze) Exec_Terminate(payload *pty.UnfreezeTerminate, tx *types.Tran
return nil, err
}
acc, err := account.NewAccountDB(unfreeze.AssetExec, unfreeze.AssetSymbol, u.GetStateDB())
acc, err := account.NewAccountDB(cfg, unfreeze.AssetExec, unfreeze.AssetSymbol, u.GetStateDB())
if err != nil {
return nil, err
}
......
......@@ -70,10 +70,10 @@ func TestUnfreeze(t *testing.T) {
stateDB, _ := dbm.NewGoMemDB("1", "2", 100)
_, ldb, kvdb := util.CreateTestDB()
accA, _ := account.NewAccountDB(AssetExecPara, Symbol, stateDB)
accA, _ := account.NewAccountDB(chain33TestCfg, AssetExecPara, Symbol, stateDB)
accA.SaveExecAccount(execAddr, &accountA)
accB, _ := account.NewAccountDB(AssetExecPara, Symbol, stateDB)
accB, _ := account.NewAccountDB(chain33TestCfg, AssetExecPara, Symbol, stateDB)
accB.SaveExecAccount(execAddr, &accountB)
env := execEnv{
......
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