Compare commits
No commits in common. "f9f25d898b0ec435c7fef41a1ab32277c1914478" and "d7232a53efab7acd5d9ba3bc378ccd42defc7add" have entirely different histories.
f9f25d898b
...
d7232a53ef
@ -135,7 +135,7 @@ func GetTemporaryVoucherData(ctx context.Context, store DataStore, sessionId str
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// UpdateVoucherData sets the active voucher data in the DataStore.
|
||||
// UpdateVoucherData sets the active voucher data and clears the temporary voucher data in the DataStore.
|
||||
func UpdateVoucherData(ctx context.Context, store DataStore, sessionId string, data *dataserviceapi.TokenHoldings) error {
|
||||
logg.TraceCtxf(ctx, "dtal", "data", data)
|
||||
// Active voucher data entries
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"path"
|
||||
"regexp"
|
||||
"strconv"
|
||||
@ -161,7 +162,7 @@ func (h *Handlers) SetLanguage(ctx context.Context, sym string, input []byte) (r
|
||||
|
||||
languageSetFlag, err := h.flagManager.GetFlag("flag_language_set")
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "Error setting the languageSetFlag", "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
res.FlagSet = append(res.FlagSet, languageSetFlag)
|
||||
@ -215,10 +216,10 @@ func (h *Handlers) CreateAccount(ctx context.Context, sym string, input []byte)
|
||||
_, err = store.ReadEntry(ctx, sessionId, common.DATA_ACCOUNT_CREATED)
|
||||
if err != nil {
|
||||
if db.IsNotFound(err) {
|
||||
logg.InfoCtxf(ctx, "Creating an account because it doesn't exist")
|
||||
logg.Printf(logging.LVL_INFO, "Creating an account because it doesn't exist")
|
||||
err = h.createAccountNoExist(ctx, sessionId, &res)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed on createAccountNoExist", "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
@ -237,12 +238,13 @@ func (h *Handlers) CheckPinMisMatch(ctx context.Context, sym string, input []byt
|
||||
store := h.userdataStore
|
||||
blockedNumber, err := store.ReadEntry(ctx, sessionId, common.DATA_BLOCKED_NUMBER)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read blockedNumber entry with", "key", common.DATA_BLOCKED_NUMBER, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
temporaryPin, err := store.ReadEntry(ctx, string(blockedNumber), common.DATA_TEMPORARY_VALUE)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read temporaryPin entry with", "key", common.DATA_TEMPORARY_VALUE, "error", err)
|
||||
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
if bytes.Equal(temporaryPin, input) {
|
||||
@ -295,7 +297,8 @@ func (h *Handlers) SaveTemporaryPin(ctx context.Context, sym string, input []byt
|
||||
store := h.userdataStore
|
||||
err = store.WriteEntry(ctx, sessionId, common.DATA_TEMPORARY_VALUE, []byte(accountPIN))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write temporaryAccountPIN entry with", "key", common.DATA_TEMPORARY_VALUE, "value", accountPIN, "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to write entry with", "key", common.DATA_TEMPORARY_VALUE, "value", accountPIN, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -313,14 +316,16 @@ func (h *Handlers) SaveOthersTemporaryPin(ctx context.Context, sym string, input
|
||||
}
|
||||
temporaryPin := string(input)
|
||||
blockedNumber, err := store.ReadEntry(ctx, sessionId, common.DATA_BLOCKED_NUMBER)
|
||||
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read blockedNumber entry with", "key", common.DATA_BLOCKED_NUMBER, "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to read entry with", "key", common.DATA_BLOCKED_NUMBER, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
err = store.WriteEntry(ctx, string(blockedNumber), common.DATA_TEMPORARY_VALUE, []byte(temporaryPin))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write temporaryPin entry with", "key", common.DATA_TEMPORARY_VALUE, "value", temporaryPin, "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to write entry with", "key", common.DATA_TEMPORARY_VALUE, "value", temporaryPin, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -338,7 +343,8 @@ func (h *Handlers) ConfirmPinChange(ctx context.Context, sym string, input []byt
|
||||
store := h.userdataStore
|
||||
temporaryPin, err := store.ReadEntry(ctx, sessionId, common.DATA_TEMPORARY_VALUE)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read temporaryPin entry with", "key", common.DATA_TEMPORARY_VALUE, "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to read entry with", "key", common.DATA_TEMPORARY_VALUE, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
if bytes.Equal(temporaryPin, input) {
|
||||
@ -348,7 +354,8 @@ func (h *Handlers) ConfirmPinChange(ctx context.Context, sym string, input []byt
|
||||
}
|
||||
err = store.WriteEntry(ctx, sessionId, common.DATA_ACCOUNT_PIN, []byte(temporaryPin))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write temporaryPin entry with", "key", common.DATA_ACCOUNT_PIN, "value", temporaryPin, "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to write entry with", "key", common.DATA_ACCOUNT_PIN, "value", temporaryPin, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
return res, nil
|
||||
@ -371,7 +378,7 @@ func (h *Handlers) VerifyCreatePin(ctx context.Context, sym string, input []byte
|
||||
store := h.userdataStore
|
||||
temporaryPin, err := store.ReadEntry(ctx, sessionId, common.DATA_TEMPORARY_VALUE)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read temporaryPin entry with", "key", common.DATA_TEMPORARY_VALUE, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
if bytes.Equal(input, temporaryPin) {
|
||||
@ -384,7 +391,8 @@ func (h *Handlers) VerifyCreatePin(ctx context.Context, sym string, input []byte
|
||||
|
||||
err = store.WriteEntry(ctx, sessionId, common.DATA_ACCOUNT_PIN, []byte(temporaryPin))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write temporaryPin entry with", "key", common.DATA_ACCOUNT_PIN, "value", temporaryPin, "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to write entry with", "key", common.DATA_ACCOUNT_PIN, "value", temporaryPin, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -417,13 +425,15 @@ func (h *Handlers) SaveFirstname(ctx context.Context, sym string, input []byte)
|
||||
temporaryFirstName, _ := store.ReadEntry(ctx, sessionId, common.DATA_TEMPORARY_VALUE)
|
||||
err = store.WriteEntry(ctx, sessionId, common.DATA_FIRST_NAME, []byte(temporaryFirstName))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write firstName entry with", "key", common.DATA_FIRST_NAME, "value", temporaryFirstName, "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to write entry with", "key", common.DATA_FIRST_NAME, "value", temporaryFirstName, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
} else {
|
||||
err = store.WriteEntry(ctx, sessionId, common.DATA_TEMPORARY_VALUE, []byte(firstName))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write temporaryFirstName entry with", "key", common.DATA_TEMPORARY_VALUE, "value", firstName, "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to write entry with", "key", common.DATA_TEMPORARY_VALUE, "value", firstName, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
@ -450,17 +460,16 @@ func (h *Handlers) SaveFamilyname(ctx context.Context, sym string, input []byte)
|
||||
temporaryFamilyName, _ := store.ReadEntry(ctx, sessionId, common.DATA_TEMPORARY_VALUE)
|
||||
err = store.WriteEntry(ctx, sessionId, common.DATA_FAMILY_NAME, []byte(temporaryFamilyName))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write familyName entry with", "key", common.DATA_FAMILY_NAME, "value", temporaryFamilyName, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
} else {
|
||||
err = store.WriteEntry(ctx, sessionId, common.DATA_TEMPORARY_VALUE, []byte(familyName))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write temporaryFamilyName entry with", "key", common.DATA_TEMPORARY_VALUE, "value", familyName, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@ -481,13 +490,15 @@ func (h *Handlers) SaveYob(ctx context.Context, sym string, input []byte) (resou
|
||||
temporaryYob, _ := store.ReadEntry(ctx, sessionId, common.DATA_TEMPORARY_VALUE)
|
||||
err = store.WriteEntry(ctx, sessionId, common.DATA_YOB, []byte(temporaryYob))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write yob entry with", "key", common.DATA_TEMPORARY_VALUE, "value", temporaryYob, "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to write entry with", "key", common.DATA_TEMPORARY_VALUE, "value", temporaryYob, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
} else {
|
||||
err = store.WriteEntry(ctx, sessionId, common.DATA_TEMPORARY_VALUE, []byte(yob))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write temporaryYob entry with", "key", common.DATA_TEMPORARY_VALUE, "value", yob, "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to write entry with", "key", common.DATA_TEMPORARY_VALUE, "value", yob, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
@ -513,13 +524,15 @@ func (h *Handlers) SaveLocation(ctx context.Context, sym string, input []byte) (
|
||||
temporaryLocation, _ := store.ReadEntry(ctx, sessionId, common.DATA_TEMPORARY_VALUE)
|
||||
err = store.WriteEntry(ctx, sessionId, common.DATA_LOCATION, []byte(temporaryLocation))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write location entry with", "key", common.DATA_LOCATION, "value", temporaryLocation, "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to write entry with", "key", common.DATA_LOCATION, "value", temporaryLocation, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
} else {
|
||||
err = store.WriteEntry(ctx, sessionId, common.DATA_TEMPORARY_VALUE, []byte(location))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write temporaryLocation entry with", "key", common.DATA_TEMPORARY_VALUE, "value", location, "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to write entry with", "key", common.DATA_TEMPORARY_VALUE, "value", location, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
@ -545,13 +558,15 @@ func (h *Handlers) SaveGender(ctx context.Context, sym string, input []byte) (re
|
||||
temporaryGender, _ := store.ReadEntry(ctx, sessionId, common.DATA_TEMPORARY_VALUE)
|
||||
err = store.WriteEntry(ctx, sessionId, common.DATA_GENDER, []byte(temporaryGender))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write gender entry with", "key", common.DATA_GENDER, "value", gender, "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to write entry with", "key", common.DATA_GENDER, "value", gender, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
} else {
|
||||
err = store.WriteEntry(ctx, sessionId, common.DATA_TEMPORARY_VALUE, []byte(gender))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write temporaryGender entry with", "key", common.DATA_TEMPORARY_VALUE, "value", gender, "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to write entry with", "key", common.DATA_TEMPORARY_VALUE, "value", gender, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
@ -578,13 +593,15 @@ func (h *Handlers) SaveOfferings(ctx context.Context, sym string, input []byte)
|
||||
temporaryOfferings, _ := store.ReadEntry(ctx, sessionId, common.DATA_TEMPORARY_VALUE)
|
||||
err = store.WriteEntry(ctx, sessionId, common.DATA_OFFERINGS, []byte(temporaryOfferings))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write offerings entry with", "key", common.DATA_TEMPORARY_VALUE, "value", offerings, "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to write entry with", "key", common.DATA_TEMPORARY_VALUE, "value", offerings, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
} else {
|
||||
err = store.WriteEntry(ctx, sessionId, common.DATA_TEMPORARY_VALUE, []byte(offerings))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write temporaryOfferings entry with", "key", common.DATA_TEMPORARY_VALUE, "value", offerings, "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to write entry with", "key", common.DATA_TEMPORARY_VALUE, "value", offerings, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
@ -595,7 +612,9 @@ func (h *Handlers) SaveOfferings(ctx context.Context, sym string, input []byte)
|
||||
// ResetAllowUpdate resets the allowupdate flag that allows a user to update profile data.
|
||||
func (h *Handlers) ResetAllowUpdate(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||
var res resource.Result
|
||||
|
||||
flag_allow_update, _ := h.flagManager.GetFlag("flag_allow_update")
|
||||
|
||||
res.FlagReset = append(res.FlagReset, flag_allow_update)
|
||||
return res, nil
|
||||
}
|
||||
@ -612,6 +631,7 @@ func (h *Handlers) ResetValidPin(ctx context.Context, sym string, input []byte)
|
||||
func (h *Handlers) ResetAccountAuthorized(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||
var res resource.Result
|
||||
flag_account_authorized, _ := h.flagManager.GetFlag("flag_account_authorized")
|
||||
|
||||
res.FlagReset = append(res.FlagReset, flag_account_authorized)
|
||||
return res, nil
|
||||
}
|
||||
@ -647,7 +667,7 @@ func (h *Handlers) Authorize(ctx context.Context, sym string, input []byte) (res
|
||||
store := h.userdataStore
|
||||
AccountPin, err := store.ReadEntry(ctx, sessionId, common.DATA_ACCOUNT_PIN)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read AccountPin entry with", "key", common.DATA_ACCOUNT_PIN, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
if len(input) == 4 {
|
||||
@ -695,19 +715,21 @@ func (h *Handlers) CheckAccountStatus(ctx context.Context, sym string, input []b
|
||||
store := h.userdataStore
|
||||
publicKey, err := store.ReadEntry(ctx, sessionId, common.DATA_PUBLIC_KEY)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read publicKey entry with", "key", common.DATA_PUBLIC_KEY, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
r, err := h.accountService.TrackAccountStatus(ctx, string(publicKey))
|
||||
|
||||
if err != nil {
|
||||
res.FlagSet = append(res.FlagSet, flag_api_error)
|
||||
logg.ErrorCtxf(ctx, "failed on TrackAccountStatus", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
res.FlagReset = append(res.FlagReset, flag_api_error)
|
||||
|
||||
if !ok {
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
if r.Active {
|
||||
res.FlagSet = append(res.FlagSet, flag_account_success)
|
||||
res.FlagReset = append(res.FlagReset, flag_account_pending)
|
||||
@ -715,7 +737,6 @@ func (h *Handlers) CheckAccountStatus(ctx context.Context, sym string, input []b
|
||||
res.FlagReset = append(res.FlagReset, flag_account_success)
|
||||
res.FlagSet = append(res.FlagSet, flag_account_pending)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@ -807,13 +828,13 @@ func (h *Handlers) CheckBalance(ctx context.Context, sym string, input []byte) (
|
||||
return res, nil
|
||||
}
|
||||
|
||||
logg.ErrorCtxf(ctx, "failed to read activeSym entry with", "key", common.DATA_ACTIVE_SYM, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
activeBal, err := store.ReadEntry(ctx, sessionId, common.DATA_ACTIVE_BAL)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read activeBal entry with", "key", common.DATA_ACTIVE_BAL, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -837,7 +858,7 @@ func (h *Handlers) FetchCustodialBalances(ctx context.Context, sym string, input
|
||||
store := h.userdataStore
|
||||
publicKey, err := store.ReadEntry(ctx, sessionId, common.DATA_PUBLIC_KEY)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read publicKey entry with", "key", common.DATA_PUBLIC_KEY, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -870,19 +891,18 @@ func (h *Handlers) ResetOthersPin(ctx context.Context, sym string, input []byte)
|
||||
}
|
||||
blockedPhonenumber, err := store.ReadEntry(ctx, sessionId, common.DATA_BLOCKED_NUMBER)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read blockedPhonenumber entry with", "key", common.DATA_BLOCKED_NUMBER, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
temporaryPin, err := store.ReadEntry(ctx, string(blockedPhonenumber), common.DATA_TEMPORARY_VALUE)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read temporaryPin entry with", "key", common.DATA_TEMPORARY_VALUE, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
err = store.WriteEntry(ctx, string(blockedPhonenumber), common.DATA_ACCOUNT_PIN, []byte(temporaryPin))
|
||||
if err != nil {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@ -911,11 +931,11 @@ func (h *Handlers) ValidateBlockedNumber(ctx context.Context, sym string, input
|
||||
}
|
||||
if err != nil {
|
||||
if db.IsNotFound(err) {
|
||||
logg.InfoCtxf(ctx, "Invalid or unregistered number")
|
||||
logg.Printf(logging.LVL_INFO, "Invalid or unregistered number")
|
||||
res.FlagSet = append(res.FlagSet, flag_unregistered_number)
|
||||
return res, nil
|
||||
} else {
|
||||
logg.ErrorCtxf(ctx, "Error on ValidateBlockedNumber", "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
@ -1023,7 +1043,7 @@ func (h *Handlers) MaxAmount(ctx context.Context, sym string, input []byte) (res
|
||||
|
||||
activeBal, err := store.ReadEntry(ctx, sessionId, common.DATA_ACTIVE_BAL)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read activeBal entry with", "key", common.DATA_ACTIVE_BAL, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -1049,12 +1069,12 @@ func (h *Handlers) ValidateAmount(ctx context.Context, sym string, input []byte)
|
||||
// retrieve the active balance
|
||||
activeBal, err := store.ReadEntry(ctx, sessionId, common.DATA_ACTIVE_BAL)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read activeBal entry with", "key", common.DATA_ACTIVE_BAL, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
balanceValue, err = strconv.ParseFloat(string(activeBal), 64)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "Failed to convert the activeBal to a float", "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -1077,11 +1097,11 @@ func (h *Handlers) ValidateAmount(ctx context.Context, sym string, input []byte)
|
||||
formattedAmount := fmt.Sprintf("%.2f", inputAmount)
|
||||
err = store.WriteEntry(ctx, sessionId, common.DATA_AMOUNT, []byte(formattedAmount))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write amount entry with", "key", common.DATA_AMOUNT, "value", formattedAmount, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
res.Content = formattedAmount
|
||||
res.Content = fmt.Sprintf("%s", formattedAmount)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@ -1144,7 +1164,7 @@ func (h *Handlers) GetAmount(ctx context.Context, sym string, input []byte) (res
|
||||
// retrieve the active symbol
|
||||
activeSym, err := store.ReadEntry(ctx, sessionId, common.DATA_ACTIVE_SYM)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read activeSym entry with", "key", common.DATA_ACTIVE_SYM, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -1182,7 +1202,7 @@ func (h *Handlers) InitiateTransaction(ctx context.Context, sym string, input []
|
||||
|
||||
account_authorized_flag, err := h.flagManager.GetFlag("flag_account_authorized")
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "Failed to set the flag_account_authorized", "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -1285,7 +1305,7 @@ func (h *Handlers) SetDefaultVoucher(ctx context.Context, sym string, input []by
|
||||
if db.IsNotFound(err) {
|
||||
publicKey, err := store.ReadEntry(ctx, sessionId, common.DATA_PUBLIC_KEY)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read publicKey entry with", "key", common.DATA_PUBLIC_KEY, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -1310,20 +1330,20 @@ func (h *Handlers) SetDefaultVoucher(ctx context.Context, sym string, input []by
|
||||
// set the active symbol
|
||||
err = store.WriteEntry(ctx, sessionId, common.DATA_ACTIVE_SYM, []byte(defaultSym))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write defaultSym entry with", "key", common.DATA_ACTIVE_SYM, "value", defaultSym, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
// set the active balance
|
||||
err = store.WriteEntry(ctx, sessionId, common.DATA_ACTIVE_BAL, []byte(defaultBal))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write defaultBal entry with", "key", common.DATA_ACTIVE_BAL, "value", defaultBal, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
logg.ErrorCtxf(ctx, "failed to read activeSym entry with", "key", common.DATA_ACTIVE_SYM, "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -1344,8 +1364,7 @@ func (h *Handlers) CheckVouchers(ctx context.Context, sym string, input []byte)
|
||||
store := h.userdataStore
|
||||
publicKey, err := store.ReadEntry(ctx, sessionId, common.DATA_PUBLIC_KEY)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read publicKey entry with", "key", common.DATA_PUBLIC_KEY, "error", err)
|
||||
return res, err
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// Fetch vouchers from the API using the public key
|
||||
@ -1380,7 +1399,7 @@ func (h *Handlers) GetVoucherList(ctx context.Context, sym string, input []byte)
|
||||
// Read vouchers from the store
|
||||
voucherData, err := h.prefixDb.Get(ctx, []byte("sym"))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "Failed to read the voucherData from prefixDb", "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -1416,7 +1435,7 @@ func (h *Handlers) ViewVoucher(ctx context.Context, sym string, input []byte) (r
|
||||
}
|
||||
|
||||
if err := common.StoreTemporaryVoucher(ctx, h.userdataStore, sessionId, metadata); err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed on StoreTemporaryVoucher", "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -1438,13 +1457,13 @@ func (h *Handlers) SetVoucher(ctx context.Context, sym string, input []byte) (re
|
||||
// Get temporary data
|
||||
tempData, err := common.GetTemporaryVoucherData(ctx, h.userdataStore, sessionId)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed on GetTemporaryVoucherData", "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// Set as active and clear temporary data
|
||||
if err := common.UpdateVoucherData(ctx, h.userdataStore, sessionId, tempData); err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed on UpdateVoucherData", "error", err)
|
||||
log.Printf("Error: %s", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user