Skip to content

Commit

Permalink
fix duplicate symbol oracle
Browse files Browse the repository at this point in the history
  • Loading branch information
DongLieu committed Nov 13, 2024
1 parent 2d4a307 commit 4ccb6c3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions x/oracle/keeper/band_oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"
"fmt"
"slices"
"strconv"
"time"

Expand Down Expand Up @@ -269,11 +270,13 @@ func (k Keeper) AddNewSymbolToBandOracleRequest(ctx context.Context, symbol stri
// check if new symbol's oracle script id is existing
for _, req := range allBandOracleRequests {
if req.OracleScriptId == oracleScriptId {
req.Symbols = append(req.Symbols, symbol)
err := k.SetBandOracleRequest(ctx, *req)
if err != nil {
return errorsmod.Wrapf(types.ErrSetBandOracleRequest, "can not set symbol %s with oracle script id %v", symbol, oracleScriptId)
if !slices.Contains(req.Symbols, symbol) {
req.Symbols = append(req.Symbols, symbol)
if err := k.SetBandOracleRequest(ctx, *req); err != nil {
return errorsmod.Wrapf(types.ErrSetBandOracleRequest, "can not set symbol %s with oracle script id %v", symbol, oracleScriptId)
}
}

return nil
}
}
Expand Down

0 comments on commit 4ccb6c3

Please sign in to comment.