use the pool symbol in place of the pool name
This commit is contained in:
parent
29863d385d
commit
dec8fbc3f0
@ -43,7 +43,7 @@ func (h *MenuHandlers) CalculateMaxPayDebt(ctx context.Context, sym string, inpu
|
||||
}
|
||||
|
||||
// Resolve active pool
|
||||
activePoolAddress, activePoolName, err := h.resolveActivePoolDetails(ctx, sessionId)
|
||||
activePoolAddress, activePoolSymbol, err := h.resolveActivePoolDetails(ctx, sessionId)
|
||||
if err != nil {
|
||||
res.FlagReset = append(res.FlagReset, flag_low_swap_amount, flag_api_call_error)
|
||||
return res, err
|
||||
@ -129,7 +129,7 @@ func (h *MenuHandlers) CalculateMaxPayDebt(ctx context.Context, sym string, inpu
|
||||
"You can remove a max of %s %s from '%s'\nEnter amount of %s:(Max: %s)",
|
||||
quoteStr,
|
||||
string(activeSym),
|
||||
string(activePoolName),
|
||||
string(activePoolSymbol),
|
||||
metadata.TokenSymbol,
|
||||
maxStr,
|
||||
)
|
||||
@ -268,7 +268,7 @@ func (h *MenuHandlers) InitiatePayDebt(ctx context.Context, sym string, input []
|
||||
}
|
||||
|
||||
// Resolve active pool
|
||||
activePoolAddress, activePoolName, err := h.resolveActivePoolDetails(ctx, sessionId)
|
||||
activePoolAddress, activePoolSymbol, err := h.resolveActivePoolDetails(ctx, sessionId)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
@ -310,7 +310,7 @@ func (h *MenuHandlers) InitiatePayDebt(ctx context.Context, sym string, input []
|
||||
"Your request has been sent. You will receive an SMS when your debt of %s %s has been removed from %s.",
|
||||
string(debtQuotedAmount),
|
||||
string(activeSym),
|
||||
activePoolName,
|
||||
activePoolSymbol,
|
||||
)
|
||||
|
||||
res.FlagReset = append(res.FlagReset, flag_account_authorized)
|
||||
|
||||
@ -145,14 +145,14 @@ func (h *MenuHandlers) ConfirmPoolDeposit(ctx context.Context, sym string, input
|
||||
}
|
||||
|
||||
// Resolve active pool
|
||||
_, activePoolName, err := h.resolveActivePoolDetails(ctx, sessionId)
|
||||
_, activePoolSymbol, err := h.resolveActivePoolDetails(ctx, sessionId)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
res.Content = l.Get(
|
||||
"You will deposit %s %s into %s\n",
|
||||
inputStr, poolDepositVoucher.TokenSymbol, activePoolName,
|
||||
inputStr, poolDepositVoucher.TokenSymbol, activePoolSymbol,
|
||||
)
|
||||
|
||||
return res, nil
|
||||
@ -174,7 +174,7 @@ func (h *MenuHandlers) InitiatePoolDeposit(ctx context.Context, sym string, inpu
|
||||
l.AddDomain("default")
|
||||
|
||||
// Resolve active pool
|
||||
activePoolAddress, activePoolName, err := h.resolveActivePoolDetails(ctx, sessionId)
|
||||
activePoolAddress, activePoolSymbol, err := h.resolveActivePoolDetails(ctx, sessionId)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
@ -212,7 +212,7 @@ func (h *MenuHandlers) InitiatePoolDeposit(ctx context.Context, sym string, inpu
|
||||
"Your request has been sent. You will receive an SMS when %s %s has been deposited into %s.",
|
||||
poolDepositdata.Amount,
|
||||
poolDepositVoucher.TokenSymbol,
|
||||
activePoolName,
|
||||
activePoolSymbol,
|
||||
)
|
||||
|
||||
res.FlagReset = append(res.FlagReset, flag_account_authorized)
|
||||
|
||||
@ -530,7 +530,7 @@ func (h *MenuHandlers) getRecipientData(ctx context.Context, sessionId string) (
|
||||
return
|
||||
}
|
||||
|
||||
func (h *MenuHandlers) resolveActivePoolDetails(ctx context.Context, sessionId string) (defaultPoolAddress, defaultPoolName []byte, err error) {
|
||||
func (h *MenuHandlers) resolveActivePoolDetails(ctx context.Context, sessionId string) (defaultPoolAddress, defaultPoolSymbol []byte, err error) {
|
||||
store := h.userdataStore
|
||||
|
||||
// Try read address
|
||||
@ -540,21 +540,21 @@ func (h *MenuHandlers) resolveActivePoolDetails(ctx context.Context, sessionId s
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// Try read name
|
||||
defaultPoolName, err = store.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_POOL_NAME)
|
||||
// Try read symbol
|
||||
defaultPoolSymbol, err = store.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_POOL_SYM)
|
||||
if err != nil && !db.IsNotFound(err) {
|
||||
logg.ErrorCtxf(ctx, "failed to read active pool name", "error", err)
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// If both exist, return them
|
||||
if defaultPoolAddress != nil && defaultPoolName != nil {
|
||||
return defaultPoolAddress, defaultPoolName, nil
|
||||
if defaultPoolAddress != nil && defaultPoolSymbol != nil {
|
||||
return defaultPoolAddress, defaultPoolSymbol, nil
|
||||
}
|
||||
|
||||
// Fallback to config defaults
|
||||
defaultPoolAddress = []byte(config.DefaultPoolAddress())
|
||||
defaultPoolName = []byte(config.DefaultPoolName())
|
||||
defaultPoolSymbol = []byte(config.DefaultPoolSymbol())
|
||||
|
||||
if err := store.WriteEntry(
|
||||
ctx,
|
||||
@ -569,14 +569,14 @@ func (h *MenuHandlers) resolveActivePoolDetails(ctx context.Context, sessionId s
|
||||
if err := store.WriteEntry(
|
||||
ctx,
|
||||
sessionId,
|
||||
storedb.DATA_ACTIVE_POOL_NAME,
|
||||
defaultPoolName,
|
||||
storedb.DATA_ACTIVE_POOL_SYM,
|
||||
defaultPoolSymbol,
|
||||
); err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write default pool name", "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to write default pool symbol", "error", err)
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return defaultPoolAddress, defaultPoolName, nil
|
||||
return defaultPoolAddress, defaultPoolSymbol, nil
|
||||
}
|
||||
|
||||
func (h *MenuHandlers) calculateSendCreditLimits(ctx context.Context, poolAddress, fromAddress, toAddress, publicKey, fromDecimal, toDecimal []byte) (string, string, error) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user