Skip to content

Commit

Permalink
cleanup: delete the unused methods and files (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
yutianwu authored Sep 9, 2022
1 parent 9f3341f commit 04824fc
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 90 deletions.
37 changes: 0 additions & 37 deletions common/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,8 @@ package common

import (
"bytes"
"errors"
"math/big"
"strings"
"unicode"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)

func LowerCase(s string) string {
Expand Down Expand Up @@ -53,35 +48,3 @@ func CleanAccountName(name string) string {
func SerializeAccountName(a []byte) string {
return string(bytes.Trim(a[:], "\x00")) + ".legend"
}

func keccakHash(value []byte) []byte {
hashVal := crypto.Keccak256Hash(value)
return hashVal[:]
}

func AccountNameHash(accountName string) (res string, err error) {
// TODO Keccak256
words := strings.Split(accountName, ".")
if len(words) != 2 {
return "", errors.New("[AccountNameHash] invalid account name")
}

q, _ := big.NewInt(0).SetString("21888242871839275222246405745257275088548364400416034343698204186575808495617", 10)

rootNode := make([]byte, 32)
hashOfBaseNode := keccakHash(append(rootNode, keccakHash([]byte(words[1]))...))

baseNode := big.NewInt(0).Mod(big.NewInt(0).SetBytes(hashOfBaseNode), q)
baseNodeBytes := make([]byte, 32)
baseNode.FillBytes(baseNodeBytes)

nameHash := keccakHash([]byte(words[0]))
subNameHash := keccakHash(append(baseNodeBytes, nameHash...))

subNode := big.NewInt(0).Mod(big.NewInt(0).SetBytes(subNameHash), q)
subNodeBytes := make([]byte, 32)
subNode.FillBytes(subNodeBytes)

res = common.Bytes2Hex(subNodeBytes)
return res, nil
}
27 changes: 0 additions & 27 deletions common/uuid.go

This file was deleted.

8 changes: 4 additions & 4 deletions service/apiserver/internal/fetcher/price/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ func (f *fetcher) GetCurrencyPrice(_ context.Context, symbol string) (float64, e
func (f *fetcher) getLatestQuotes(symbol string) (map[string]QuoteLatest, error) {
client := &http.Client{}
url := fmt.Sprintf("%s%s", f.cmcUrl, symbol)
reqest, err := http.NewRequest("GET", url, nil)
request, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, types.HttpErrFailToRequest
}
reqest.Header.Add("X-CMC_PRO_API_KEY", f.cmcToken)
reqest.Header.Add("Accept", "application/json")
resp, err := client.Do(reqest)
request.Header.Add("X-CMC_PRO_API_KEY", f.cmcToken)
request.Header.Add("Accept", "application/json")
resp, err := client.Do(request)
if err != nil {
return nil, types.HttpErrClientDo
}
Expand Down
17 changes: 0 additions & 17 deletions service/witness/witness/types.go

This file was deleted.

5 changes: 2 additions & 3 deletions tools/dbinitializer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func Initialize(
nftHistoryModel: nft.NewL2NftHistoryModel(db),
}

dropTables(dao, bscTestNetworkRPC, localTestNetworkRPC)
dropTables(dao)
initTable(dao, &svrConf, bscTestNetworkRPC, localTestNetworkRPC)

return nil
Expand Down Expand Up @@ -193,8 +193,7 @@ func initAssetsInfo() []*asset.Asset {
}
}

func dropTables(
dao *dao, bscTestNetworkRPC, localTestNetworkRPC string) {
func dropTables(dao *dao) {
assert.Nil(nil, dao.sysConfigModel.DropSysConfigTable())
assert.Nil(nil, dao.accountModel.DropAccountTable())
assert.Nil(nil, dao.accountHistoryModel.DropAccountHistoryTable())
Expand Down
2 changes: 0 additions & 2 deletions types/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ const (
NilExpiredAt = math.MaxInt64
NilAssetAmount = "0"

MaxNftIndex = 1099511627775 // 2^40-1

BNBAssetId = 0
BNBDecimals = "1000000000000000000"
)
Expand Down

0 comments on commit 04824fc

Please sign in to comment.