Просмотр исходного кода

contrib/token: Minify JSON lists for production, smaller binaries.

parazyd 4 лет назад
Родитель
Сommit
a22531386b
2 измененных файлов с 19 добавлено и 5 удалено
  1. 1 0
      contrib/token/.gitignore
  2. 18 5
      contrib/token/Makefile

+ 1 - 0
contrib/token/.gitignore

@@ -0,0 +1 @@
+*.min.json

+ 18 - 5
contrib/token/Makefile

@@ -3,13 +3,23 @@
 DLTOOL = wget -nv --show-progress -O-
 
 LISTS = \
-	erc20_token_list.json \
-	solana_token_list.json
+	bitcoin_token_list \
+	erc20_token_list \
+	solana_token_list
+
+LISTS_JSON = $(LISTS:=.json)
+LISTS_MIN  = $(LISTS:=.min.json)
 
 ERC20 = https://tokens.coingecko.com/uniswap/all.json
-SOL = https://github.com/solana-labs/token-list/raw/main/src/tokens/solana.tokenlist.json
+SOL   = https://github.com/solana-labs/token-list/raw/main/src/tokens/solana.tokenlist.json
+
+all: $(LISTS_MIN)
 
-all: $(LISTS)
+$(LISTS_MIN): $(LISTS_JSON)
+	jq -r -c < $< > $@
+
+bitcoin_token_list.json:
+	git checkout -- $@
 
 erc20_token_list.json:
 	$(DLTOOL) $(ERC20) | jq -r > $@
@@ -20,4 +30,7 @@ solana_token_list.json:
 		-e 's@"symbol": "ETH"@"symbol": "SETH"@' \
 		| jq -r > $@
 
-.PHONY: all $(LISTS)
+clean:
+	rm -f $(LISTS_JSON) $(LISTS_MIN)
+
+.PHONY: all