Skip to content

Commit 2794a27

Browse files
authored
Add command for adding asset template (trustwallet#17338)
* Add command for adding asset template * Fix explorer links for terra
1 parent 0cfb242 commit 2794a27

File tree

18 files changed

+970
-96
lines changed

18 files changed

+970
-96
lines changed

.github/workflows/check.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
uses: actions/checkout@v2
1818

1919
- name: Run check
20-
run: go run ./cmd/main.go --config=./.github/assets.config.yaml --script=checker
20+
run: make check
2121

2222
- name: Unit Test
2323
run: make test

.github/workflows/fix-dryrun.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
uses: actions/checkout@v2
1818

1919
- name: Run fix
20-
run: go run ./cmd/main.go --config=./.github/assets.config.yaml --script=fixer
20+
run: make fix
2121

2222
- name: Show fix result (diff)
2323
run: |
@@ -26,4 +26,4 @@ jobs:
2626
git diff
2727
2828
- name: Run check
29-
run: go run ./cmd/main.go --config=./.github/assets.config.yaml --script=checker
29+
run: make check

.github/workflows/fix.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ jobs:
3333
go-version: 1.17
3434
id: go
3535

36-
- name: Run fix script (trustwallet repo, sanity and consistency)
36+
- name: Run fix
3737
if: github.repository_owner == 'trustwallet'
38-
run: go run ./cmd/main.go --config=./.github/assets.config.yaml --script=fixer
38+
run: make fix
3939

4040
- name: Show fix result (diff)
4141
run: |
4242
git status
4343
git diff
4444
4545
- name: Run check
46-
run: go run ./cmd/main.go --config=./.github/assets.config.yaml --script=checker
46+
run: make check
4747

4848
- name: Commit changes
4949
if: success()

.github/workflows/periodic-update.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
id: go
2121

2222
- name: Run update auto
23-
run: go run ./cmd/main.go --config=./.github/assets.config.yaml --script=updater-auto
23+
run: make update-auto
2424

2525
- name: Show update result (diff)
2626
if: success()
@@ -29,7 +29,7 @@ jobs:
2929
git diff
3030
3131
- name: Run check
32-
run: go run ./cmd/main.go --config=./.github/assets.config.yaml --script=checker
32+
run: make check
3333

3434
- name: Commit changes
3535
if: success()

.github/workflows/pr-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
uses: actions/checkout@v2
2222

2323
- name: Run check
24-
run: go run ./cmd/main.go --config=./.github/assets.config.yaml --script=checker
24+
run: make check
2525

2626
- name: Unit Test
2727
run: make test

Makefile

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
#! /usr/bin/make -f
22

3+
34
# Go related variables.
45
GOBASE := $(shell pwd)
56
GOBIN := $(GOBASE)/bin
67

8+
79
# Go files.
810
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
911

12+
13+
# Common commands.
1014
all: fmt lint test
1115

1216
test:
@@ -27,14 +31,21 @@ lint: lint-install
2731
@echo " > Running golint"
2832
bin/golangci-lint run --timeout=2m
2933

34+
35+
# Assets commands.
3036
check:
31-
go run ./cmd/main.go --script=checker
37+
go run cmd/main.go check
3238

3339
fix:
34-
go run ./cmd/main.go --script=fixer
40+
go run cmd/main.go fix
3541

3642
update-auto:
37-
go run ./cmd/main.go --script=updater-auto
43+
go run cmd/main.go update-auto
3844

3945
update-manual:
40-
go run ./cmd/main.go --script=updater-manual
46+
go run cmd/main.go update-manual
47+
48+
49+
# Helper commands.
50+
add-token:
51+
go run cmd/main.go add-token $(token)

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ There are several scripts available for maintainers:
5858
- `make fix` -- Perform automatic fixes where possible
5959
- `make update-auto` -- Run automatic updates from external sources, executed regularly (GitHub action)
6060
- `make update-manual` -- Run manual updates from external sources, for manual use.
61+
- `make add-token token=c60_t0x4Fabb145d64652a948d72533023f6E7A623C7C53` -- Create `info.json` file as asset template.
6162

6263
## On Checks
6364

blockchains/terra/assets/ukrw/info.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "TerraKRW",
33
"website": "https://terra.money",
44
"description": "TerraKRW is the first decentralized stablecoin that is scalable, yield bearing and interchain.",
5-
"explorer": "https://finder.terra.money/columbus-4/ukrw",
5+
"explorer": "https://finder.terra.money/mainnet/address/ukrw",
66
"type": "TERRA",
77
"symbol": "KRT",
88
"decimals": 6,

blockchains/terra/assets/umnt/info.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "TerraUMNT",
33
"website": "https://terra.money",
44
"description": "TerraUMNT is the first decentralized stablecoin that is scalable, yield bearing and interchain.",
5-
"explorer": "https://finder.terra.money/columbus-4/umnt",
5+
"explorer": "https://finder.terra.money/mainnet/address/umnt",
66
"type": "TERRA",
77
"symbol": "UMNT",
88
"decimals": 6,

blockchains/terra/assets/usdr/info.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "TerraSDT",
33
"website": "https://terra.money",
44
"description": "TerraSDT is the first decentralized stablecoin that is scalable, yield bearing and interchain.",
5-
"explorer": "https://finder.terra.money/columbus-4/usdr",
5+
"explorer": "https://finder.terra.money/mainnet/address/usdr",
66
"type": "TERRA",
77
"symbol": "SDT",
88
"decimals": 6,

blockchains/terra/assets/uusd/info.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "TerraUSD",
33
"website": "https://terra.money",
44
"description": "TerraUSD is the first decentralized stablecoin that is scalable, yield bearing and interchain.",
5-
"explorer": "https://finder.terra.money/columbus-4/uusd",
5+
"explorer": "https://finder.terra.money/mainnet/address/uusd",
66
"type": "TERRA",
77
"symbol": "UST",
88
"decimals": 6,

cmd/main.go

+3-64
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,10 @@
11
package main
22

33
import (
4-
"flag"
5-
6-
log "github.com/sirupsen/logrus"
7-
8-
"github.com/trustwallet/assets/internal/config"
9-
"github.com/trustwallet/assets/internal/file"
10-
"github.com/trustwallet/assets/internal/processor"
11-
"github.com/trustwallet/assets/internal/report"
12-
"github.com/trustwallet/assets/internal/service"
13-
)
14-
15-
var (
16-
configPath, root, script string
4+
"github.com/trustwallet/assets/internal/manager"
175
)
186

197
func main() {
20-
setup()
21-
22-
paths, err := file.ReadLocalFileStructure(root, config.Default.ValidatorsSettings.RootFolder.SkipFiles)
23-
if err != nil {
24-
log.WithError(err).Fatal("Failed to load file structure.")
25-
}
26-
27-
fileService := file.NewService(paths...)
28-
validatorsService := processor.NewService(fileService)
29-
reportService := report.NewService()
30-
assetfsProcessor := service.NewService(fileService, validatorsService, reportService)
31-
32-
switch script {
33-
case "checker":
34-
assetfsProcessor.RunJob(paths, assetfsProcessor.Check)
35-
case "fixer":
36-
assetfsProcessor.RunJob(paths, assetfsProcessor.Fix)
37-
case "updater-auto":
38-
assetfsProcessor.RunUpdateAuto()
39-
case "updater-manual":
40-
assetfsProcessor.RunUpdateManual()
41-
default:
42-
log.Info("Nothing to launch. Use --script flag to choose a script to run.")
43-
}
44-
45-
reportMsg := reportService.GetReport()
46-
47-
if reportService.IsFailed() {
48-
log.Fatal(reportMsg)
49-
} else {
50-
log.Info(reportMsg)
51-
}
52-
}
53-
54-
func setup() {
55-
flag.StringVar(&configPath, "config", "./.github/assets.config.yaml", "path to config file")
56-
flag.StringVar(&root, "root", "./", "path to the root of the dir")
57-
flag.StringVar(&script, "script", "", "script type to run")
58-
59-
flag.Parse()
60-
61-
if err := config.SetConfig(configPath); err != nil {
62-
log.WithError(err).Fatal("Failed to set config.")
63-
}
64-
65-
logLevel, err := log.ParseLevel(config.Default.App.LogLevel)
66-
if err != nil {
67-
log.WithError(err).Fatal("Failed to parse log level.")
68-
}
69-
70-
log.SetLevel(logLevel)
8+
manager.InitCommands()
9+
manager.Execute()
7110
}

go.mod

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ go 1.17
44

55
require (
66
github.com/sirupsen/logrus v1.8.1
7-
github.com/trustwallet/assets-go-libs v0.0.24
8-
github.com/trustwallet/go-libs v0.2.21
9-
github.com/trustwallet/go-primitives v0.0.19
7+
github.com/spf13/cobra v1.3.0
8+
github.com/trustwallet/assets-go-libs v0.0.25
9+
github.com/trustwallet/go-libs v0.2.23
10+
github.com/trustwallet/go-primitives v0.0.20
1011
)
1112

1213
require (
1314
github.com/deckarep/golang-set v1.7.1 // indirect
1415
github.com/fsnotify/fsnotify v1.5.1 // indirect
1516
github.com/hashicorp/hcl v1.0.0 // indirect
17+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
1618
github.com/magiconair/properties v1.8.5 // indirect
1719
github.com/mitchellh/mapstructure v1.4.3 // indirect
1820
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect

0 commit comments

Comments
 (0)