Skip to content

Commit 49ceb11

Browse files
authored
handle single address for faucet, handle send token from holder itself if distributor is empty (#568)
1 parent 2b9ef44 commit 49ceb11

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

starship/charts/devnet/templates/registry.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ data:
145145
],
146146
"coingecko_id": "{{ $chain.name }}"
147147
}
148-
]
148+
]
149149
{{- end }}
150150
}
151151
chain.json: |-

starship/faucet/app.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,12 @@ func (a *AppServer) Run() error {
208208
}
209209
}()
210210

211-
// start distributor
211+
// start distributor if distrubutor.Addrs is not empty
212+
if a.distributor.Addrs == nil {
213+
a.logger.Info("no distributor addresses provided")
214+
return nil
215+
}
216+
212217
go func() {
213218
for {
214219
disStatus, err := a.distributor.Status()

starship/faucet/distributor.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,13 @@ func (d *Distributor) Status() ([]AccountBalances, error) {
163163

164164
// SendTokens will transfer tokens to the given address and denom from one of distributor addresses
165165
func (d *Distributor) SendTokens(address string, denom string) error {
166-
randIndex := rand.Intn(len(d.Addrs))
167166
amount := d.CreditCoins.GetDenomAmount(denom)
167+
168+
if d.Addrs == nil {
169+
return d.Holder.SendTokens(address, denom, amount)
170+
}
171+
172+
randIndex := rand.Intn(len(d.Addrs))
168173
if amount == "" {
169174
return fmt.Errorf("invalid denom: %s, expected denoms: %s", denom, d.CreditCoins.GetDenoms())
170175
}

0 commit comments

Comments
 (0)