debt-menu #115

Open
Alfred-mk wants to merge 74 commits from debt-menu into master
Showing only changes of commit 43b963995f - Show all commits

View File

@ -222,6 +222,13 @@ func (h *MenuHandlers) ConfirmDebtRemoval(ctx context.Context, sym string, input
// Format to 2 decimal places // Format to 2 decimal places
qouteStr, _ := store.TruncateDecimalString(string(quoteAmountStr), 2) qouteStr, _ := store.TruncateDecimalString(string(quoteAmountStr), 2)
// store the quote in the temporary value key
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(qouteStr))
if err != nil {
logg.ErrorCtxf(ctx, "failed to write swap max amount entry with", "key", storedb.DATA_TEMPORARY_VALUE, "value", qouteStr, "error", err)
return res, err
}
res.Content = l.Get( res.Content = l.Get(
"Please confirm that you will use %s %s to remove your debt of %s %s\n", "Please confirm that you will use %s %s to remove your debt of %s %s\n",
inputStr, payDebtVoucher.TokenSymbol, qouteStr, string(activeSym), inputStr, payDebtVoucher.TokenSymbol, qouteStr, string(activeSym),
@ -247,9 +254,21 @@ func (h *MenuHandlers) InitiatePayDebt(ctx context.Context, sym string, input []
userStore := h.userdataStore userStore := h.userdataStore
// Resolve active pool // Fetch session data
_, activePoolName, err := h.resolveActivePoolDetails(ctx, sessionId) _, _, activeSym, activeAddress, publicKey, _, err := h.getSessionData(ctx, sessionId)
if err != nil { if err != nil {
return res, nil
}
// Resolve active pool
activePoolAddress, activePoolName, err := h.resolveActivePoolDetails(ctx, sessionId)
if err != nil {
return res, err
}
payDebtVoucher, err := store.ReadSwapFromVoucher(ctx, h.userdataStore, sessionId)
if err != nil {
logg.ErrorCtxf(ctx, "failed on ReadSwapFromVoucher", "error", err)
return res, err return res, err
} }
@ -267,7 +286,7 @@ func (h *MenuHandlers) InitiatePayDebt(ctx context.Context, sym string, input []
swapAmountStr := string(swapAmount) swapAmountStr := string(swapAmount)
// Call the poolSwap API // Call the poolSwap API
r, err := h.accountService.PoolSwap(ctx, swapAmountStr, swapData.PublicKey, swapData.ActiveSwapToAddress, swapData.ActivePoolAddress, swapData.ActiveSwapFromAddress) r, err := h.accountService.PoolSwap(ctx, swapAmountStr, string(publicKey), payDebtVoucher.TokenAddress, string(activePoolAddress), string(activeAddress))
if err != nil { if err != nil {
flag_api_call_error, _ := h.flagManager.GetFlag("flag_api_call_error") flag_api_call_error, _ := h.flagManager.GetFlag("flag_api_call_error")
res.FlagSet = append(res.FlagSet, flag_api_call_error) res.FlagSet = append(res.FlagSet, flag_api_call_error)
@ -282,7 +301,7 @@ func (h *MenuHandlers) InitiatePayDebt(ctx context.Context, sym string, input []
res.Content = l.Get( res.Content = l.Get(
"Your request has been sent. You will receive an SMS when your debt of %s %s has been removed from %s.", "Your request has been sent. You will receive an SMS when your debt of %s %s has been removed from %s.",
swapData.TemporaryValue, swapData.TemporaryValue,
swapData.ActiveSwapToSym, string(activeSym),
activePoolName, activePoolName,
) )