Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
YingQm authored and mdj33 committed Feb 16, 2023
1 parent eeccf8d commit 6995b7e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 153 deletions.
5 changes: 4 additions & 1 deletion plugin/dapp/zksync/commands/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,23 +557,26 @@ func getL2TotalDepositCmd() *cobra.Command {
func getL2TotalDepositFlag(cmd *cobra.Command) {
cmd.Flags().Int32P("tokenId", "t", 0, "token id")
_ = cmd.MarkFlagRequired("tokenId")
cmd.Flags().Uint32P("decimal", "d", 0, "1:show with token's decimal, 0: real value")
}

func getL2TotalDeposit(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
tokenId, _ := cmd.Flags().GetInt32("tokenId")
decimal, _ := cmd.Flags().GetUint32("decimal")

var params rpctypes.Query4Jrpc

params.Execer = zt.Zksync
req := &zt.ZkQueryReq{
TokenId: uint64(tokenId),
Decimal: decimal,
}

params.FuncName = "GetTotalDeposit"
params.Payload = types.MustPBToJSON(req)

var resp zt.ZkTotalDeposit
var resp zt.TokenBalance
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &resp)
ctx.Run()
}
10 changes: 1 addition & 9 deletions plugin/dapp/zksync/executor/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,6 @@ func (z *zksync) Query_GetTotalDeposit(in *zt.ZkQueryReq) (types.Message, error)
if in == nil {
return nil, types.ErrInvalidParam
}
//根据id查询symbol
idStr := new(big.Int).SetUint64(in.TokenId).String()
info, err := GetTokenByTokenId(z.GetStateDB(), idStr)
if err != nil {
return nil, err
}

totalBalance := new(big.Int)
lastAccountID, err := getLatestAccountID(z.GetStateDB())
if err != nil {
Expand All @@ -439,6 +432,5 @@ func (z *zksync) Query_GetTotalDeposit(in *zt.ZkQueryReq) (types.Message, error)
totalBalance = new(big.Int).Add(totalBalance, balance)
}
}

return &zt.ZkTotalDeposit{TokenId: info.Id, Symbol: info.Symbol, Decimal: info.Decimal, Balance: totalBalance.String()}, nil
return &zt.TokenBalance{TokenId: in.TokenId, Balance: decimalVal(totalBalance.String(), in.Decimal)}, nil
}
7 changes: 0 additions & 7 deletions plugin/dapp/zksync/proto/zksync.proto
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,3 @@ message Priority2QueueId {
}

service zksync{}

message ZkTotalDeposit {
string tokenId = 1;
string symbol = 2;
uint32 decimal = 3;
string balance = 4;
}
181 changes: 45 additions & 136 deletions plugin/dapp/zksync/types/zksync.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6995b7e

Please sign in to comment.