use the TemporaryValue to store the user's swap amount input
Some checks failed
release / docker (push) Has been cancelled

This commit is contained in:
Alfred Kamanda 2025-05-22 15:18:52 +03:00
parent dcadea8737
commit 8dc203d111
Signed by: Alfred-mk
GPG Key ID: 7EA3D01708908703
2 changed files with 9 additions and 1 deletions

View File

@ -2940,6 +2940,12 @@ func (h *MenuHandlers) SwapPreview(ctx context.Context, sym string, input []byte
logg.ErrorCtxf(ctx, "failed to write swap amount entry with", "key", storedb.DATA_ACTIVE_SWAP_AMOUNT, "value", finalAmountStr, "error", err) logg.ErrorCtxf(ctx, "failed to write swap amount entry with", "key", storedb.DATA_ACTIVE_SWAP_AMOUNT, "value", finalAmountStr, "error", err)
return res, err return res, err
} }
// store the user's input amount in the temporary value
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(inputStr))
if err != nil {
logg.ErrorCtxf(ctx, "failed to write swap amount entry with", "key", storedb.DATA_ACTIVE_SWAP_AMOUNT, "value", finalAmountStr, "error", err)
return res, err
}
// call the API to get the quote // call the API to get the quote
r, err := h.accountService.GetPoolSwapQuote(ctx, finalAmountStr, swapData.PublicKey, swapData.ActiveSwapFromAddress, swapData.ActivePoolAddress, swapData.ActiveSwapToAddress) r, err := h.accountService.GetPoolSwapQuote(ctx, finalAmountStr, swapData.PublicKey, swapData.ActiveSwapFromAddress, swapData.ActivePoolAddress, swapData.ActiveSwapToAddress)
@ -3015,7 +3021,7 @@ func (h *MenuHandlers) InitiateSwap(ctx context.Context, sym string, input []byt
res.Content = l.Get( res.Content = l.Get(
"Your request has been sent. You will receive an SMS when your %s %s has been swapped for %s.", "Your request has been sent. You will receive an SMS when your %s %s has been swapped for %s.",
swapAmountStr, swapData.TemporaryValue,
swapData.ActiveSwapFromSym, swapData.ActiveSwapFromSym,
swapData.ActiveSwapToSym, swapData.ActiveSwapToSym,
) )

View File

@ -22,6 +22,7 @@ type SwapData struct {
} }
type SwapPreviewData struct { type SwapPreviewData struct {
TemporaryValue string
PublicKey string PublicKey string
ActiveSwapMaxAmount string ActiveSwapMaxAmount string
ActiveSwapFromDecimal string ActiveSwapFromDecimal string
@ -65,6 +66,7 @@ func ReadSwapData(ctx context.Context, store DataStore, sessionId string) (SwapD
func ReadSwapPreviewData(ctx context.Context, store DataStore, sessionId string) (SwapPreviewData, error) { func ReadSwapPreviewData(ctx context.Context, store DataStore, sessionId string) (SwapPreviewData, error) {
data := SwapPreviewData{} data := SwapPreviewData{}
fieldToKey := map[string]storedb.DataTyp{ fieldToKey := map[string]storedb.DataTyp{
"TemporaryValue": storedb.DATA_TEMPORARY_VALUE,
"PublicKey": storedb.DATA_PUBLIC_KEY, "PublicKey": storedb.DATA_PUBLIC_KEY,
"ActiveSwapMaxAmount": storedb.DATA_ACTIVE_SWAP_MAX_AMOUNT, "ActiveSwapMaxAmount": storedb.DATA_ACTIVE_SWAP_MAX_AMOUNT,
"ActiveSwapFromDecimal": storedb.DATA_ACTIVE_DECIMAL, "ActiveSwapFromDecimal": storedb.DATA_ACTIVE_DECIMAL,