Skip to content

Commit

Permalink
handle single address for faucet, handle send token from holder itsel…
Browse files Browse the repository at this point in the history
…f if distributor is empty (#568)
  • Loading branch information
Anmol1696 authored Oct 14, 2024
1 parent 2b9ef44 commit 49ceb11
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion starship/charts/devnet/templates/registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ data:
],
"coingecko_id": "{{ $chain.name }}"
}
]
]
{{- end }}
}
chain.json: |-
Expand Down
7 changes: 6 additions & 1 deletion starship/faucet/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,12 @@ func (a *AppServer) Run() error {
}
}()

// start distributor
// start distributor if distrubutor.Addrs is not empty
if a.distributor.Addrs == nil {
a.logger.Info("no distributor addresses provided")
return nil
}

go func() {
for {
disStatus, err := a.distributor.Status()
Expand Down
7 changes: 6 additions & 1 deletion starship/faucet/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,13 @@ func (d *Distributor) Status() ([]AccountBalances, error) {

// SendTokens will transfer tokens to the given address and denom from one of distributor addresses
func (d *Distributor) SendTokens(address string, denom string) error {
randIndex := rand.Intn(len(d.Addrs))
amount := d.CreditCoins.GetDenomAmount(denom)

if d.Addrs == nil {
return d.Holder.SendTokens(address, denom, amount)
}

randIndex := rand.Intn(len(d.Addrs))
if amount == "" {
return fmt.Errorf("invalid denom: %s, expected denoms: %s", denom, d.CreditCoins.GetDenoms())
}
Expand Down

0 comments on commit 49ceb11

Please sign in to comment.