Skip to content

Commit

Permalink
set customerid while creating oracle
Browse files Browse the repository at this point in the history
  • Loading branch information
nnn-gif committed Aug 22, 2024
1 parent 1bb98f0 commit b375caa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions cmd/http/oraclebuilder/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,20 @@ type ViewInput struct {
}

func (ob *Env) ViewAccount(context *gin.Context) {
requestId := context.GetString(REQUEST_ID)

var input ViewInput
if err := context.ShouldBind(&input); err != nil {
log.Errorln("ShouldBind", err)
log.Errorf("Request ID: %s, ShouldBind err %v ", requestId, err)

context.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
//TODO check permission
customer, err := ob.RelDB.GetCustomerByPublicKey(input.Creator)
if err != nil {
log.Errorln("AddWalletKeys", err)

log.Errorf("Request ID: %s, ViewAccount err %v ", requestId, err)
context.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/model/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ func (rdb *RelDB) GetKeyPairID(publicKey string) string {
return keypairId
}

func (rdb *RelDB) SetOracleConfig(address, feederID, owner, feederAddress, symbols, feedSelection, chainID, frequency, sleepseconds, deviationpermille, blockchainnode, mandatoryFrequency string) error {
func (rdb *RelDB) SetOracleConfig(ctx context.Context, customerId, address, feederID, owner, feederAddress, symbols, feedSelection, chainID, frequency, sleepseconds, deviationpermille, blockchainnode, mandatoryFrequency string) error {
currentTime := time.Now()
query := fmt.Sprintf(`
INSERT INTO %s (address,feeder_id,owner,symbols,chainID,frequency,sleepseconds,deviationpermille,blockchainnode,mandatory_frequency,feeder_address,createddate,lastupdate,feedSelection)
INSERT INTO %s (customer_id, address,feeder_id,owner,symbols,chainID,frequency,sleepseconds,deviationpermille,blockchainnode,mandatory_frequency,feeder_address,createddate,lastupdate,feedSelection)
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14)
ON CONFLICT(feeder_id)
DO UPDATE SET symbols=$4,frequency=$6,sleepseconds=$7,deviationpermille=$8,blockchainnode=$9,mandatory_frequency=$10,feeder_address=$11,lastupdate=$13,feedSelection=$14`,
oracleconfigTable,
)

log.Infoln("SetOracleConfig Query", query)
_, err := rdb.postgresClient.Exec(context.Background(), query, address, feederID, owner, symbols, chainID, frequency, sleepseconds, deviationpermille, blockchainnode, mandatoryFrequency, feederAddress, currentTime, currentTime, feedSelection)
_, err := rdb.postgresClient.Exec(ctx, query, customerId, address, feederID, owner, symbols, chainID, frequency, sleepseconds, deviationpermille, blockchainnode, mandatoryFrequency, feederAddress, currentTime, currentTime, feedSelection)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/relDB.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ type RelDatastore interface {
GetKeyPairID(publickey string) string
GetFeederAccessByID(id string) (owner string)
GetFeederByID(id string) (owner string)
SetOracleConfig(address, feederID, owner, feederAddress, symbols, feedSelection, chainID, frequency, sleepseconds, deviationpermille, blockchainnode, mandatoryFrequency string) error
SetOracleConfig(ctx context.Context, customerId, address, feederID, owner, feederAddress, symbols, feedSelection, chainID, frequency, sleepseconds, deviationpermille, blockchainnode, mandatoryFrequency string) error
SetFeederConfig(feederid, oracleconfigid string) error
GetFeederID(address string) (feederId string)
GetFeederLimit(owner string) (limit int)
Expand Down

0 comments on commit b375caa

Please sign in to comment.