Compare commits

..

7 Commits

Author SHA1 Message Date
Alfred Kamanda
388785f1b5 set a different output length to fix the: sink already set to symbol 'calculate_max_pay_debt' error
Some checks failed
release / docker (push) Has been cancelled
2026-03-16 11:29:41 +03:00
Alfred Kamanda
78e028b2b6 reset the state of DATA_TRANSACTION_CUSTOM_VOUCHER_STATE when performing a transaction reset
Some checks failed
release / docker (push) Has been cancelled
2026-03-13 11:13:55 +03:00
b5015e8831 Merge pull request 'send-max-amount-hotfix' (#120) from send-max-amount-hotfix into master
Reviewed-on: #120
2026-03-03 11:32:56 +01:00
alfred-mk
7fdc734c7f Merge branch 'master' into send-max-amount-hotfix
Some checks failed
release / docker (push) Has been cancelled
2026-03-03 12:14:06 +03:00
bf75d2cea4 Merge pull request 'shorten-menus' (#119) from shorten-menus into master
Reviewed-on: #119
2026-03-03 10:13:05 +01:00
alfred-mk
5b995c9d9c log the error for new user cases and return nil 2026-03-03 11:48:59 +03:00
alfred-mk
1a7d160ae6 return a normal transaction if the recipient isn't registered on the USSD 2026-03-03 10:01:50 +03:00
2 changed files with 19 additions and 9 deletions

View File

@@ -242,7 +242,9 @@ func (h *MenuHandlers) determineAndSaveTransactionType(
// fetch data for use (to_voucher data)
recipientActiveSym, recipientActiveAddress, recipientActiveDecimal, err := h.getRecipientData(ctx, string(recipientPhoneNumber))
if err != nil {
return err
// missing key (case for new users)
logg.ErrorCtxf(ctx, "failed on getRecipientData", "error", err)
return nil
}
swapMetadata := &dataserviceapi.TokenHoldings{
TokenAddress: string(recipientActiveAddress),
@@ -297,6 +299,11 @@ func (h *MenuHandlers) TransactionReset(ctx context.Context, sym string, input [
return res, nil
}
err = store.WriteEntry(ctx, sessionId, storedb.DATA_TRANSACTION_CUSTOM_VOUCHER_STATE, []byte(""))
if err != nil {
return res, nil
}
res.FlagReset = append(res.FlagReset, flag_invalid_recipient, flag_invalid_recipient_with_invite)
return res, nil
@@ -373,13 +380,6 @@ func (h *MenuHandlers) MaxAmount(ctx context.Context, sym string, input []byte)
// Format the active balance amount to 2 decimal places
formattedBalance, _ := store.TruncateDecimalString(string(activeBal), 2)
// confirm the transaction type
swapToVoucher, err := store.ReadSwapToVoucher(ctx, h.userdataStore, sessionId)
if err != nil {
logg.ErrorCtxf(ctx, "failed on ReadSwapFromVoucher", "error", err)
return res, err
}
// Case for M-Pesa
// if the recipient is Mpesa (address), check if the sender's voucher is a stable coin
recipientAddress, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_RECIPIENT)
@@ -393,6 +393,16 @@ func (h *MenuHandlers) MaxAmount(ctx context.Context, sym string, input []byte)
return res, nil
}
// confirm the transaction type
swapToVoucher, err := store.ReadSwapToVoucher(ctx, h.userdataStore, sessionId)
if err != nil {
logg.ErrorCtxf(ctx, "failed on ReadSwapFromVoucher", "error", err)
// switch to normal transaction as the recipient isn't registered (pool or alias only on sarafu)
res.FlagReset = append(res.FlagReset, flag_swap_transaction)
res.Content = l.Get("Maximum amount: %s %s\nEnter amount:", formattedBalance, string(activeSym))
return res, nil
}
if string(swapToVoucher.TokenAddress) == string(activeAddress) {
// recipient has active token same as selected token → normal transaction
transactionType = []byte("normal")

View File

@@ -10,7 +10,7 @@ INCMP > 88
INCMP < 98
INCMP _ 0
INCMP quit 99
LOAD calculate_max_pay_debt 0
LOAD calculate_max_pay_debt 128
RELOAD calculate_max_pay_debt
CATCH . flag_incorrect_voucher 1
CATCH low_pay_debt_amount flag_low_swap_amount 1