have-single-send-node #113
@ -258,6 +258,7 @@ func (h *MenuHandlers) TransactionReset(ctx context.Context, sym string, input [
|
|||||||
|
|
||||||
flag_invalid_recipient, _ := h.flagManager.GetFlag("flag_invalid_recipient")
|
flag_invalid_recipient, _ := h.flagManager.GetFlag("flag_invalid_recipient")
|
||||||
flag_invalid_recipient_with_invite, _ := h.flagManager.GetFlag("flag_invalid_recipient_with_invite")
|
flag_invalid_recipient_with_invite, _ := h.flagManager.GetFlag("flag_invalid_recipient_with_invite")
|
||||||
|
|
||||||
store := h.userdataStore
|
store := h.userdataStore
|
||||||
err = store.WriteEntry(ctx, sessionId, storedb.DATA_AMOUNT, []byte(""))
|
err = store.WriteEntry(ctx, sessionId, storedb.DATA_AMOUNT, []byte(""))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -336,28 +337,15 @@ func (h *MenuHandlers) MaxAmount(ctx context.Context, sym string, input []byte)
|
|||||||
// Format the active balance amount to 2 decimal places
|
// Format the active balance amount to 2 decimal places
|
||||||
formattedBalance, _ := store.TruncateDecimalString(string(activeBal), 2)
|
formattedBalance, _ := store.TruncateDecimalString(string(activeBal), 2)
|
||||||
|
|
||||||
// If normal transaction, or if the sym is send_max_amount, return balance
|
// If normal transaction return balance
|
||||||
if string(transactionType) == "normal" || sym == "send_max_amount" {
|
if string(transactionType) == "normal" {
|
||||||
res.FlagReset = append(res.FlagReset, flag_swap_transaction)
|
res.FlagReset = append(res.FlagReset, flag_swap_transaction)
|
||||||
|
|
||||||
res.Content = l.Get("Maximum amount: %s %s\nEnter amount:", formattedBalance, string(activeSym))
|
res.Content = l.Get("Maximum amount: %s %s\nEnter amount:", formattedBalance, string(activeSym))
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
res.FlagSet = append(res.FlagSet, flag_swap_transaction)
|
res.FlagSet = append(res.FlagSet, flag_swap_transaction)
|
||||||
|
|
||||||
// Get the recipient's phone number to read other data items
|
|
||||||
recipientPhoneNumber, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_RECIPIENT_PHONE_NUMBER)
|
|
||||||
if err != nil {
|
|
||||||
// invalid state
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
recipientActiveSym, recipientActiveAddress, recipientActiveDecimal, err := h.getRecipientData(ctx, string(recipientPhoneNumber))
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolve active pool address
|
// Resolve active pool address
|
||||||
activePoolAddress, err := h.resolveActivePoolAddress(ctx, sessionId)
|
activePoolAddress, err := h.resolveActivePoolAddress(ctx, sessionId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -372,11 +360,23 @@ func (h *MenuHandlers) MaxAmount(ctx context.Context, sym string, input []byte)
|
|||||||
logg.ErrorCtxf(ctx, "failed on CheckTokenInPool", "error", err)
|
logg.ErrorCtxf(ctx, "failed on CheckTokenInPool", "error", err)
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
res.FlagReset = append(res.FlagReset, flag_swap_transaction)
|
res.FlagReset = append(res.FlagReset, flag_swap_transaction)
|
||||||
res.Content = l.Get("Maximum amount: %s %s\nEnter amount:", formattedBalance, string(activeSym))
|
res.Content = l.Get("Maximum amount: %s %s\nEnter amount:", formattedBalance, string(activeSym))
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the recipient's phone number to read other data items
|
||||||
|
recipientPhoneNumber, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_RECIPIENT_PHONE_NUMBER)
|
||||||
|
if err != nil {
|
||||||
|
// invalid state
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
recipientActiveSym, recipientActiveAddress, recipientActiveDecimal, err := h.getRecipientData(ctx, string(recipientPhoneNumber))
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
// retrieve the max credit send amounts
|
// retrieve the max credit send amounts
|
||||||
maxSAT, maxRAT, err := h.calculateSendCreditLimits(ctx, activePoolAddress, activeAddress, recipientActiveAddress, publicKey, activeDecimal, recipientActiveDecimal)
|
maxSAT, maxRAT, err := h.calculateSendCreditLimits(ctx, activePoolAddress, activeAddress, recipientActiveAddress, publicKey, activeDecimal, recipientActiveDecimal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user