mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
Update merge-fee-bot config, refactor validators (#17118)
This commit is contained in:
parent
e7f9efcd2c
commit
bd78bf44db
13
.github/merge-fee-bot.config.yml
vendored
13
.github/merge-fee-bot.config.yml
vendored
|
@ -44,7 +44,11 @@ message:
|
||||||
* One PR should be for a single project; PR's with more than 10 logos will be rejected.\n
|
* One PR should be for a single project; PR's with more than 10 logos will be rejected.\n
|
||||||
* Payment evaluation happens automatically, but with a few minutes delay. When payment is detected, an Accept Review is automatically placed on the PR, which is a condition for merge.\n
|
* Payment evaluation happens automatically, but with a few minutes delay. When payment is detected, an Accept Review is automatically placed on the PR, which is a condition for merge.\n
|
||||||
* Evaluating the PR is done manually, and it is merged only if all conditions are satisfied.\n
|
* Evaluating the PR is done manually, and it is merged only if all conditions are satisfied.\n
|
||||||
* TWT-BEP2 is supported (Binance Chain), TWT-BEP20 version on Smart Chain is not."
|
* TWT-BEP2 is supported (Binance Chain), TWT-BEP20 version on Smart Chain is not.\n\n
|
||||||
|
There will be a fee to process this request. None of it goes to the developers.\n
|
||||||
|
Before paying the fee, make sure new tokens fulfill the minimum circulation and other acceptance criteria.\n
|
||||||
|
If you are paying TWT for the submission, this will be burned automatically. There will be no refunds."
|
||||||
|
|
||||||
not_received: "Fee has not been received yet (or not fully).\n\n"
|
not_received: "Fee has not been received yet (or not fully).\n\n"
|
||||||
received: "Fee is PAID, fantastic! Thanks!\n\n
|
received: "Fee is PAID, fantastic! Thanks!\n\n
|
||||||
The PR will be evaluated soon by a maintainer, and if merged, the new logos should be visible in Trust Wallet.\n
|
The PR will be evaluated soon by a maintainer, and if merged, the new logos should be visible in Trust Wallet.\n
|
||||||
|
@ -59,6 +63,7 @@ message:
|
||||||
See the [Pull Request Fee FAQ](https://developer.trustwallet.com/add_new_asset/pr-fee)."
|
See the [Pull Request Fee FAQ](https://developer.trustwallet.com/add_new_asset/pr-fee)."
|
||||||
closing_old_pr: "This PR is being closed due to inactivity. If you wish to continue, please have us reopen the PR before sending your payment, or just create a new one.\n
|
closing_old_pr: "This PR is being closed due to inactivity. If you wish to continue, please have us reopen the PR before sending your payment, or just create a new one.\n
|
||||||
Do NOT send payments for closed PR, as the fee may by lost!"
|
Do NOT send payments for closed PR, as the fee may by lost!"
|
||||||
|
burned: "$PAID_AMOUNT $PAID_SYMBOL have been successfully [burned]($BURN_EXPLORER_LINK)"
|
||||||
|
|
||||||
label:
|
label:
|
||||||
requested: 'Payment Status: Requested'
|
requested: 'Payment Status: Requested'
|
||||||
|
@ -70,9 +75,9 @@ user:
|
||||||
moderators: Iamdeadlyz,Cryptocool1,cryptomanz
|
moderators: Iamdeadlyz,Cryptocool1,cryptomanz
|
||||||
|
|
||||||
timeout:
|
timeout:
|
||||||
max_age_close_hours: 48
|
max_age_close: 48h
|
||||||
max_idle_remind_hours: 22
|
max_idle_remind: 22h
|
||||||
bg_check_delay_sec: 300
|
background_check: 1m
|
||||||
|
|
||||||
limitations:
|
limitations:
|
||||||
pr_files: 20
|
pr_files: 20
|
||||||
|
|
|
@ -13,6 +13,8 @@ func NewService(fileProvider *file.Service) *Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) GetValidator(f *file.AssetFile) []Validator {
|
func (s *Service) GetValidator(f *file.AssetFile) []Validator {
|
||||||
|
jsonValidator := Validator{Name: "JSON validation", Run: s.ValidateJSON}
|
||||||
|
|
||||||
switch f.Type() {
|
switch f.Type() {
|
||||||
case file.TypeRootFolder:
|
case file.TypeRootFolder:
|
||||||
return []Validator{
|
return []Validator{
|
||||||
|
@ -36,18 +38,21 @@ func (s *Service) GetValidator(f *file.AssetFile) []Validator {
|
||||||
}
|
}
|
||||||
case file.TypeAssetInfoFile:
|
case file.TypeAssetInfoFile:
|
||||||
return []Validator{
|
return []Validator{
|
||||||
{Name: "Asset info (is valid json, fields)", Run: s.ValidateAssetInfoFile},
|
jsonValidator,
|
||||||
|
{Name: "Asset info", Run: s.ValidateAssetInfoFile},
|
||||||
}
|
}
|
||||||
case file.TypeChainInfoFile:
|
case file.TypeChainInfoFile:
|
||||||
return []Validator{
|
return []Validator{
|
||||||
{Name: "Chain Info (is valid json, fields)", Run: s.ValidateChainInfoFile},
|
{Name: "Chain Info", Run: s.ValidateChainInfoFile},
|
||||||
}
|
}
|
||||||
case file.TypeValidatorsListFile:
|
case file.TypeValidatorsListFile:
|
||||||
return []Validator{
|
return []Validator{
|
||||||
|
jsonValidator,
|
||||||
{Name: "Validators list file", Run: s.ValidateValidatorsListFile},
|
{Name: "Validators list file", Run: s.ValidateValidatorsListFile},
|
||||||
}
|
}
|
||||||
case file.TypeTokenListFile:
|
case file.TypeTokenListFile:
|
||||||
return []Validator{
|
return []Validator{
|
||||||
|
jsonValidator,
|
||||||
{Name: "Token list (if assets from list present in chain)", Run: s.ValidateTokenListFile},
|
{Name: "Token list (if assets from list present in chain)", Run: s.ValidateTokenListFile},
|
||||||
}
|
}
|
||||||
case file.TypeChainInfoFolder:
|
case file.TypeChainInfoFolder:
|
||||||
|
|
|
@ -17,6 +17,27 @@ import (
|
||||||
"github.com/trustwallet/go-primitives/types"
|
"github.com/trustwallet/go-primitives/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (s *Service) ValidateJSON(f *file.AssetFile) error {
|
||||||
|
file, err := os.Open(f.Path())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
buf := bytes.NewBuffer(nil)
|
||||||
|
_, err = buf.ReadFrom(file)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validation.ValidateJson(buf.Bytes())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Service) ValidateRootFolder(f *file.AssetFile) error {
|
func (s *Service) ValidateRootFolder(f *file.AssetFile) error {
|
||||||
file, err := os.Open(f.Path())
|
file, err := os.Open(f.Path())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -202,11 +223,6 @@ func (s *Service) ValidateChainInfoFile(f *file.AssetFile) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = validation.ValidateJson(buf.Bytes())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = file.Seek(0, io.SeekStart)
|
_, err = file.Seek(0, io.SeekStart)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%w: failed to seek reader", validation.ErrInvalidJson)
|
return fmt.Errorf("%w: failed to seek reader", validation.ErrInvalidJson)
|
||||||
|
@ -243,11 +259,6 @@ func (s *Service) ValidateAssetInfoFile(f *file.AssetFile) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = validation.ValidateJson(buf.Bytes())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = file.Seek(0, io.SeekStart)
|
_, err = file.Seek(0, io.SeekStart)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%w: failed to seek reader", validation.ErrInvalidJson)
|
return fmt.Errorf("%w: failed to seek reader", validation.ErrInvalidJson)
|
||||||
|
@ -283,11 +294,6 @@ func (s *Service) ValidateValidatorsListFile(f *file.AssetFile) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = validation.ValidateJson(buf.Bytes())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var model []list.Model
|
var model []list.Model
|
||||||
err = json.Unmarshal(buf.Bytes(), &model)
|
err = json.Unmarshal(buf.Bytes(), &model)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -336,6 +342,7 @@ func isStackingChain(c coin.Coin) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint:funlen
|
||||||
func (s *Service) ValidateTokenListFile(f *file.AssetFile) error {
|
func (s *Service) ValidateTokenListFile(f *file.AssetFile) error {
|
||||||
file, err := os.Open(f.Path())
|
file, err := os.Open(f.Path())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -348,34 +355,20 @@ func (s *Service) ValidateTokenListFile(f *file.AssetFile) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = validation.ValidateJson(buf.Bytes())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var model TokenList
|
var model TokenList
|
||||||
err = json.Unmarshal(buf.Bytes(), &model)
|
err = json.Unmarshal(buf.Bytes(), &model)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = compareTokenlistWithAssets(model.Tokens, f.Chain().Handle)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func compareTokenlistWithAssets(tokens []TokenItem, chain string) error {
|
|
||||||
compErr := validation.NewErrComposite()
|
compErr := validation.NewErrComposite()
|
||||||
|
|
||||||
for _, token := range tokens {
|
for _, token := range model.Tokens {
|
||||||
if token.Type == types.Coin {
|
if token.Type == types.Coin {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
assetPath := path.GetAssetInfoPath(chain, token.Address)
|
assetPath := path.GetAssetInfoPath(f.Chain().Handle, token.Address)
|
||||||
|
|
||||||
infoFile, err := os.Open(assetPath)
|
infoFile, err := os.Open(assetPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -396,15 +389,15 @@ func compareTokenlistWithAssets(tokens []TokenItem, chain string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if string(token.Type) != *infoAsset.Type {
|
if string(token.Type) != *infoAsset.Type {
|
||||||
compErr.Append(fmt.Errorf("field type differs from %s", assetPath))
|
compErr.Append(fmt.Errorf("field 'type' differs from %s", assetPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
if token.Symbol != *infoAsset.Symbol {
|
if token.Symbol != *infoAsset.Symbol {
|
||||||
compErr.Append(fmt.Errorf("field symbol differs from %s", assetPath))
|
compErr.Append(fmt.Errorf("field 'symbol' differs from %s", assetPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
if token.Decimals != uint(*infoAsset.Decimals) {
|
if token.Decimals != uint(*infoAsset.Decimals) {
|
||||||
compErr.Append(fmt.Errorf("field decimals differs from %s", assetPath))
|
compErr.Append(fmt.Errorf("field 'decimals' differs from %s", assetPath))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user