Skip to content

Commit

Permalink
Implement tokenlist/tokenlist-extended duplicate validaton, refactor …
Browse files Browse the repository at this point in the history
…code (trustwallet#17782)

Co-authored-by: Daniil Lee <[email protected]>
  • Loading branch information
unanoc and unanoc authored Jan 31, 2022
1 parent 7597a43 commit 72854d0
Show file tree
Hide file tree
Showing 17 changed files with 66 additions and 175 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"decimals": 18,
"description": "A blockchain-based middleware, acting as a bridge between cryptocurrency smart contracts, data feeds, APIs and traditional bank account payments.",
"website": "https://chain.link/",
"explorer": "https://optimistic.etherscan.io/address/0x350a791Bfc2C21F9Ed5d10980Dad2e2638ffa7f6",
"explorer": "https://optimistic.etherscan.io/token/0x350a791Bfc2C21F9Ed5d10980Dad2e2638ffa7f6",
"status": "active",
"id": "0x350a791Bfc2C21F9Ed5d10980Dad2e2638ffa7f6",
"links": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"decimals": 18,
"description": "wETH is wrapped ETH",
"website": "https://weth.io/",
"explorer": "https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000006",
"explorer": "https://optimistic.etherscan.io/token/0x4200000000000000000000000000000000000006",
"status": "active",
"id": "0x4200000000000000000000000000000000000006",
"links": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"decimals": 18,
"description": "BitANT is a governance token of BitBTC Protocol.10 billion BitANT have been minted at genesis, the team does not own any tokens: 80% liquidity is locked in DEX for 8 years; 15%,community airdrops; 5%,community mining. The exchange fee of the platform is mainly used to repurchase and burn BitANT.",
"website": "https://bitbtc.money/",
"explorer": "https://optimistic.etherscan.io/address/0x5029C236320b8f15eF0a657054B84d90bfBEDED3",
"explorer": "https://optimistic.etherscan.io/token/0x5029C236320b8f15eF0a657054B84d90bfBEDED3",
"status": "active",
"id": "0x5029C236320b8f15eF0a657054B84d90bfBEDED3",
"links": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"decimals": 18,
"description": "Lyra is an options trading protocol accessing the scalability of Layer 2 Ethereum to provide a robust, lightning-fast and reliable trading experience.",
"website": "https://www.lyra.finance",
"explorer": "https://optimistic.etherscan.io/address/0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
"explorer": "https://optimistic.etherscan.io/token/0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
"status": "active",
"id": "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
"links": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"decimals": 18,
"description": "Aelin is a fundraising protocol built on Ethereum and launched on Optimism",
"website": "https://aelin.xyz",
"explorer": "https://optimistic.etherscan.io/address/0x61BAADcF22d2565B0F471b291C475db5555e0b76",
"explorer": "https://optimistic.etherscan.io/token/0x61BAADcF22d2565B0F471b291C475db5555e0b76",
"status": "active",
"id": "0x61BAADcF22d2565B0F471b291C475db5555e0b76",
"links": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "Synthetix Network",
"website": "https://synthetix.io",
"description": "Synthetix is a derivatives liquidity protocol on Ethereum that enables the issuance and trading of synthetic assets.",
"explorer": "https://optimistic.etherscan.io/address/0x8700daec35af8ff88c16bdf0418774cb3d7599b4",
"research": "https://research.binance.com/en/projects/synthetix",
"type": "OPTIMISM",
"symbol": "SNX",
"type": "OPTIMISM",
"decimals": 18,
"description": "Synthetix is a derivatives liquidity protocol on Ethereum that enables the issuance and trading of synthetic assets.",
"website": "https://synthetix.io",
"explorer": "https://optimistic.etherscan.io/token/0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4",
"research": "https://research.binance.com/en/projects/synthetix",
"status": "active",
"id": "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4",
"links": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"decimals": 18,
"description": "Rocket Pool is the first truly decentralised Ethereum staking pool.",
"website": "https://rocketpool.net",
"explorer": "https://optimistic.etherscan.io/address/0x9Bcef72be871e61ED4fBbc7630889beE758eb81D",
"explorer": "https://optimistic.etherscan.io/token/0x9Bcef72be871e61ED4fBbc7630889beE758eb81D",
"status": "active",
"id": "0x9Bcef72be871e61ED4fBbc7630889beE758eb81D",
"links": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"decimals": 18,
"description": "On-chain derivative DEX with liquidity provisioning and up to 10x leverage for makers and takers.",
"website": "https://www.perp.com/",
"explorer": "https://optimistic.etherscan.io/address/0x9e1028F5F1D5eDE59748FFceE5532509976840E0",
"explorer": "https://optimistic.etherscan.io/token/0x9e1028F5F1D5eDE59748FFceE5532509976840E0",
"status": "active",
"id": "0x9e1028F5F1D5eDE59748FFceE5532509976840E0",
"links": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"decimals": 18,
"description": "Non-mintable ERC20 token deployed on Ethereum, secured by OpenZepellin and audited by MythX with a total supply of 100 million.",
"website": "https://kromatika.finance",
"explorer": "https://optimistic.etherscan.io/address/0xF98dCd95217E15E05d8638da4c91125E59590B07",
"explorer": "https://optimistic.etherscan.io/token/0xF98dCd95217E15E05d8638da4c91125E59590B07",
"status": "active",
"id": "0xF98dCd95217E15E05d8638da4c91125E59590B07",
"links": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"decimals": 18,
"description": "The Rubicon Protocol is a decentralized exchange protocol on the Ethereum blockchain.",
"website": "https://www.rubicon.finance",
"explorer": "https://optimistic.etherscan.io/address/0xffD27b572246f35c992EfB28DD8cB730b93Ed301",
"explorer": "https://optimistic.etherscan.io/token/0xffD27b572246f35c992EfB28DD8cB730b93Ed301",
"status": "active",
"id": "0xffD27b572246f35c992EfB28DD8cB730b93Ed301",
"links": [
Expand Down
3 changes: 1 addition & 2 deletions blockchains/polygon/tokenlist-extended.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"name": "Trust Wallet: Polygon Extended List",
"logoURI": "https://trustwallet.com/assets/images/favicon.png",
"timestamp": "2022-01-27T14:33:26.183301",
"tokens": [
],
"tokens": [],
"version": {
"major": 1,
"minor": 0,
Expand Down
4 changes: 1 addition & 3 deletions blockchains/smartchain/tokenlist-extended.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"name": "Trust Wallet: SmartChain Extended List",
"logoURI": "https://trustwallet.com/assets/images/favicon.png",
"timestamp": "2022-01-27T14:33:26.183301",
"tokens": [

],
"tokens": [],
"version": {
"major": 1,
"minor": 0,
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ go 1.17
require (
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.3.0
github.com/trustwallet/assets-go-libs v0.0.35
github.com/trustwallet/assets-go-libs v0.0.37
github.com/trustwallet/go-libs v0.2.26
github.com/trustwallet/go-primitives v0.0.24
github.com/trustwallet/go-primitives v0.0.28
)

require (
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,12 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/trustwallet/assets-go-libs v0.0.35 h1:iOTjuFsXkmCAYhGxMu17zfL2pYUbsNac/zfwA+xGi24=
github.com/trustwallet/assets-go-libs v0.0.35/go.mod h1:O0lGt8p+ffhEbNDMLSuuYBBAnNUI7nSQIcHRjWBxbgo=
github.com/trustwallet/assets-go-libs v0.0.37 h1:qddLNa0CfnDPf5LYjZsjhVLxfPhzJLjh77VG3ZxFcX0=
github.com/trustwallet/assets-go-libs v0.0.37/go.mod h1:1h30Q29B61gfrkR3Q5rS582dtyB67ozPnWy07BGf2ik=
github.com/trustwallet/go-libs v0.2.26 h1:WpDc7X23EQwdrMRZ1JqXWXUk15+8pfej4pTt/3hBIJo=
github.com/trustwallet/go-libs v0.2.26/go.mod h1:7QdAp1lcteKKI0DYqGoaO8KO4eTNYjGmg8vHy0YXkKc=
github.com/trustwallet/go-primitives v0.0.24 h1:C1QGcX3dRL7gS2miJvSrRT732zRjob1Gd4D4dJvVwq8=
github.com/trustwallet/go-primitives v0.0.24/go.mod h1:jLqd7rm+4EYG5JdpxhngM9HwbqfEXzKy/wK4vUB7STs=
github.com/trustwallet/go-primitives v0.0.28 h1:aJGjxggsxFH9GCXyqlVxv9nqmUe6lxvAZncwp1MCLVw=
github.com/trustwallet/go-primitives v0.0.28/go.mod h1:jLqd7rm+4EYG5JdpxhngM9HwbqfEXzKy/wK4vUB7STs=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
4 changes: 2 additions & 2 deletions internal/processor/fixers.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func calculateTargetDimension(width, height int) (targetW, targetH int) {
}

func (s *Service) FixChainInfoJSON(f *file.AssetFile) error {
chainInfo := info.CoinModel{}
var chainInfo info.CoinModel

err := fileLib.ReadJSONFile(f.Path(), &chainInfo)
if err != nil {
Expand All @@ -119,7 +119,7 @@ func (s *Service) FixChainInfoJSON(f *file.AssetFile) error {
}

func (s *Service) FixAssetInfo(f *file.AssetFile) error {
assetInfo := info.AssetModel{}
var assetInfo info.AssetModel

err := fileLib.ReadJSONFile(f.Path(), &assetInfo)
if err != nil {
Expand Down
22 changes: 2 additions & 20 deletions internal/processor/updaters_auto.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package processor

import (
"bytes"
"encoding/json"
"fmt"
"os"
"reflect"
"sort"
"strconv"
Expand Down Expand Up @@ -257,24 +254,9 @@ func isTokenExistOrActive(symbol string) bool {

assetPath := path.GetAssetInfoPath(coin.Coins[coin.BINANCE].Handle, symbol)

infoFile, err := os.Open(assetPath)
if err != nil {
log.Debugf("asset file open error: %s", err.Error())
return false
}

buf := bytes.NewBuffer(nil)
if _, err = buf.ReadFrom(infoFile); err != nil {
log.Debugf("buffer read error: %s", err.Error())
return false
}

infoFile.Close()

var infoAsset info.AssetModel
err = json.Unmarshal(buf.Bytes(), &infoAsset)
if err != nil {
log.Debugf("json unmarshalling error: %s", err.Error())
if err := fileLib.ReadJSONFile(assetPath, infoAsset); err != nil {
log.Debug(err)
return false
}

Expand Down
Loading

0 comments on commit 72854d0

Please sign in to comment.