Compare commits
42 Commits
v1.4.6-rc.
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 7bf71cbfff | |||
| 295ca6e53e | |||
| de32deab80 | |||
| 1a9dd64dd6 | |||
| 0d92872d90 | |||
| 77f0585b56 | |||
| 38f0058d0a | |||
| c16c39f289 | |||
| 185ff0dc45 | |||
| 45ccefe1fe | |||
| eea51ea40d | |||
| 43c4b64b42 | |||
| 686f119a9e | |||
| 759e424805 | |||
| a270079008 | |||
| 62eb132b32 | |||
| f198ecd913 | |||
| 6e426bf6a0 | |||
| 3bfa9820dd | |||
| a2e2c0d68e | |||
| e5b9a8955d | |||
| 301d4f4232 | |||
| 9e93bb4b59 | |||
| 6553c5a773 | |||
| f948f7f27e | |||
| 9646cc2955 | |||
| bfef77e20e | |||
| 3108cb2f22 | |||
| 320d10890c | |||
| 3595ff0d61 | |||
| 29cc4c63eb | |||
| 0280211197 | |||
| 2e48fbad00 | |||
| cdd83dfd73 | |||
| 0ef706a47e | |||
| dec8fbc3f0 | |||
| 29863d385d | |||
| da8c8c711f | |||
| 0d76b970d2 | |||
| f32f93dff2 | |||
| 5ee99cdcd8 | |||
| 6abcb97f3a |
@ -39,7 +39,7 @@ DEFAULT_MPESA_ASSET=cUSD
|
||||
MPESA_BEARER_TOKEN=eyJeSIsInRcCI6IkpXVCJ.yJwdWJsaWNLZXkiOiIwrrrrrr
|
||||
MPESA_ONRAMP_BASE=https://pretium.v1.grassecon.net
|
||||
|
||||
# Known stable voucher addresses (USDm, USD₮)
|
||||
STABLE_VOUCHER_ADDRESSES=0x765DE816845861e75A25fCA122bb6898B8B1282a,0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e
|
||||
# Known stable voucher addresses (USDm, USD₮, USDC)
|
||||
STABLE_VOUCHER_ADDRESSES=0x765DE816845861e75A25fCA122bb6898B8B1282a,0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e,0xcebA9300f2b948710d2653dD7B07f33A8B32118C
|
||||
DEFAULT_STABLE_VOUCHER_ADDRESS=0x765DE816845861e75A25fCA122bb6898B8B1282a
|
||||
DEFAULT_STABLE_VOUCHER_DECIMALS=18
|
||||
|
||||
@ -3,12 +3,10 @@ package application
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
||||
"git.defalsify.org/vise.git/db"
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
||||
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
|
||||
@ -114,8 +112,6 @@ func (h *MenuHandlers) CalculateCreditAndDebt(ctx context.Context, sym string, i
|
||||
return res, fmt.Errorf("missing session")
|
||||
}
|
||||
|
||||
userStore := h.userdataStore
|
||||
|
||||
code := codeFromCtx(ctx)
|
||||
l := gotext.NewLocale(translationDir, code)
|
||||
l.AddDomain("default")
|
||||
@ -125,13 +121,11 @@ func (h *MenuHandlers) CalculateCreditAndDebt(ctx context.Context, sym string, i
|
||||
// Fetch session data
|
||||
_, activeBal, activeSym, activeAddress, publicKey, activeDecimal, err := h.getSessionData(ctx, sessionId)
|
||||
if err != nil {
|
||||
res.Content = l.Get("Credit: %s KSH\nDebt: %s %s\n", "0", "0", string(activeSym))
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// default response
|
||||
formattedDebt, _ := store.TruncateDecimalString(string(activeBal), 2)
|
||||
res.FlagReset = append(res.FlagReset, flag_api_call_error)
|
||||
res.Content = l.Get("Credit: %s KSH\nDebt: %s %s\n", "0", formattedDebt, string(activeSym))
|
||||
|
||||
// Resolve active pool
|
||||
activePoolAddress, _, err := h.resolveActivePoolDetails(ctx, sessionId)
|
||||
@ -139,106 +133,93 @@ func (h *MenuHandlers) CalculateCreditAndDebt(ctx context.Context, sym string, i
|
||||
return res, err
|
||||
}
|
||||
|
||||
// Fetch swappable vouchers
|
||||
// Fetch swappable vouchers (pool view)
|
||||
swappableVouchers, err := h.accountService.GetPoolSwappableFromVouchers(ctx, string(activePoolAddress), string(publicKey))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed on GetPoolSwappableFromVouchers", "error", err)
|
||||
res.Content = l.Get("Credit: %s KSH\nDebt: %s %s\n", "0", "0", string(activeSym))
|
||||
return res, nil
|
||||
}
|
||||
|
||||
if len(swappableVouchers) == 0 {
|
||||
res.Content = l.Get("Credit: %s KSH\nDebt: %s %s\n", "0", "0", string(activeSym))
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// Build stable voucher priority (lower index = higher priority)
|
||||
stablePriority := make(map[string]int)
|
||||
stableAddresses := config.StableVoucherAddresses()
|
||||
for i, addr := range stableAddresses {
|
||||
stablePriority[addr] = i
|
||||
// Fetch ALL wallet vouchers (voucher holdings view)
|
||||
allVouchers, err := h.accountService.FetchVouchers(ctx, string(publicKey))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed on FetchVouchers", "error", err)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
stable := make([]dataserviceapi.TokenHoldings, 0)
|
||||
nonStable := make([]dataserviceapi.TokenHoldings, 0)
|
||||
// CREDIT calculation
|
||||
// Rule:
|
||||
// 1. Swap quote of active voucher → first stable in pool from GetPoolSwappableFromVouchers
|
||||
// 2. PLUS all stable balances from FetchVouchers
|
||||
|
||||
// Helper: order vouchers (stable first, priority-based)
|
||||
orderVouchers := func(vouchers []dataserviceapi.TokenHoldings) []dataserviceapi.TokenHoldings {
|
||||
for _, v := range vouchers {
|
||||
if isStableVoucher(v.TokenAddress) {
|
||||
stable = append(stable, v)
|
||||
} else {
|
||||
nonStable = append(nonStable, v)
|
||||
}
|
||||
}
|
||||
|
||||
sort.SliceStable(stable, func(i, j int) bool {
|
||||
ai := stablePriority[stable[i].TokenAddress]
|
||||
aj := stablePriority[stable[j].TokenAddress]
|
||||
return ai < aj
|
||||
})
|
||||
|
||||
return append(stable, nonStable...)
|
||||
}
|
||||
|
||||
// Remove active voucher
|
||||
filteredVouchers := make([]dataserviceapi.TokenHoldings, 0, len(swappableVouchers))
|
||||
for _, v := range swappableVouchers {
|
||||
if v.TokenSymbol != string(activeSym) {
|
||||
filteredVouchers = append(filteredVouchers, v)
|
||||
}
|
||||
}
|
||||
|
||||
// Order remaining vouchers
|
||||
orderedFilteredVouchers := orderVouchers(filteredVouchers)
|
||||
|
||||
// Process & store
|
||||
data := store.ProcessVouchers(orderedFilteredVouchers)
|
||||
|
||||
dataMap := map[storedb.DataTyp]string{
|
||||
storedb.DATA_VOUCHER_SYMBOLS: data.Symbols,
|
||||
storedb.DATA_VOUCHER_BALANCES: data.Balances,
|
||||
storedb.DATA_VOUCHER_DECIMALS: data.Decimals,
|
||||
storedb.DATA_VOUCHER_ADDRESSES: data.Addresses,
|
||||
}
|
||||
|
||||
for key, value := range dataMap {
|
||||
if err := userStore.WriteEntry(ctx, sessionId, key, []byte(value)); err != nil {
|
||||
logg.ErrorCtxf(ctx, "Failed to write data entry for sessionId: %s", sessionId, "key", key, "error", err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// Credit calculation: How much Active Token that can be swapped for a stable coin
|
||||
// + any stables sendable to Pretium (in KSH value)
|
||||
scaledCredit := "0"
|
||||
|
||||
finalAmountStr, err := store.ParseAndScaleAmount(string(activeBal), string(activeDecimal))
|
||||
// 1. Find first stable voucher in POOL (for swap target)
|
||||
var firstPoolStable *dataserviceapi.TokenHoldings
|
||||
for i := range swappableVouchers {
|
||||
if isStableVoucher(swappableVouchers[i].TokenAddress) {
|
||||
firstPoolStable = &swappableVouchers[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// 2. If pool has a stable, get swap quote
|
||||
if firstPoolStable != nil {
|
||||
finalAmountStr, err := store.ParseAndScaleAmount(
|
||||
string(activeBal),
|
||||
string(activeDecimal),
|
||||
)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
// do a swap quote for default stable coin from active voucher
|
||||
stableAddress := config.DefaultStableVoucherAddress()
|
||||
stableDecimals := config.DefaultStableVoucherDecimals()
|
||||
|
||||
r, err := h.accountService.GetPoolSwapQuote(ctx, finalAmountStr, string(publicKey), string(activeAddress), string(activePoolAddress), stableAddress)
|
||||
// swap active -> FIRST stable from pool list
|
||||
r, err := h.accountService.GetPoolSwapQuote(ctx, finalAmountStr, string(publicKey), string(activeAddress), string(activePoolAddress), firstPoolStable.TokenAddress)
|
||||
if err != nil {
|
||||
flag_api_call_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||
res.FlagSet = append(res.FlagSet, flag_api_call_error)
|
||||
res.Content = l.Get("Your request failed. Please try again later.")
|
||||
logg.ErrorCtxf(ctx, "failed on poolSwap", "error", err)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
finalQuote := store.ScaleDownBalance(r.OutValue, stableDecimals)
|
||||
// scale using REAL stable decimals
|
||||
finalQuote := store.ScaleDownBalance(r.OutValue, firstPoolStable.TokenDecimals)
|
||||
|
||||
scaledCredit = store.AddDecimalStrings(scaledCredit, finalQuote)
|
||||
}
|
||||
|
||||
for _, v := range stable {
|
||||
// 3. Add ALL wallet stable balances (from FetchVouchers)
|
||||
for _, v := range allVouchers {
|
||||
if isStableVoucher(v.TokenAddress) {
|
||||
scaled := store.ScaleDownBalance(v.Balance, v.TokenDecimals)
|
||||
scaledCredit = store.AddDecimalStrings(scaledCredit, scaled)
|
||||
}
|
||||
}
|
||||
|
||||
// DEBT calculation: All outstanding active token that is in the current pool
|
||||
// (how much of AT that is in the active Pool)
|
||||
// DEBT calculation
|
||||
// Rule:
|
||||
// - Default = 0
|
||||
// - If active is stable → remain 0
|
||||
// - If active is non-stable and exists in pool → use pool balance
|
||||
|
||||
scaledDebt := "0"
|
||||
|
||||
if !isStableVoucher(string(activeAddress)) {
|
||||
for _, v := range swappableVouchers {
|
||||
if v.TokenSymbol == string(activeSym) {
|
||||
scaledDebt = store.ScaleDownBalance(v.Balance, v.TokenDecimals)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
formattedDebt, _ := store.TruncateDecimalString(scaledDebt, 2)
|
||||
|
||||
// Fetch MPESA rates
|
||||
rates, err := h.accountService.GetMpesaOnrampRates(ctx)
|
||||
@ -250,9 +231,7 @@ func (h *MenuHandlers) CalculateCreditAndDebt(ctx context.Context, sym string, i
|
||||
}
|
||||
|
||||
creditFloat, _ := strconv.ParseFloat(scaledCredit, 64)
|
||||
|
||||
creditKsh := fmt.Sprintf("%f", creditFloat*rates.Buy)
|
||||
|
||||
kshFormattedCredit, _ := store.TruncateDecimalString(creditKsh, 0)
|
||||
|
||||
res.Content = l.Get(
|
||||
|
||||
@ -36,7 +36,7 @@ func (h *MenuHandlers) GetMpesaMaxLimit(ctx context.Context, sym string, input [
|
||||
|
||||
inputStr := string(input)
|
||||
if inputStr == "0" || inputStr == "99" || inputStr == "88" || inputStr == "98" {
|
||||
res.FlagReset = append(res.FlagReset, flag_low_swap_amount, flag_api_call_error, flag_incorrect_voucher)
|
||||
res.FlagReset = append(res.FlagReset, flag_low_swap_amount, flag_api_call_error, flag_incorrect_voucher, flag_incorrect_pool)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@ -100,11 +100,13 @@ func (h *MenuHandlers) GetMpesaMaxLimit(ctx context.Context, sym string, input [
|
||||
}
|
||||
|
||||
// Fetch min withdrawal amount from config/env
|
||||
minksh := fmt.Sprintf("%f", config.MinMpesaWithdrawAmount())
|
||||
minKshFormatted, _ := store.TruncateDecimalString(minksh, 0)
|
||||
minWithdraw := config.MinMpesaWithdrawAmount() // float64 (20)
|
||||
minKshFormatted, _ := store.TruncateDecimalString(fmt.Sprintf("%f", minWithdraw), 0)
|
||||
|
||||
// If SAT is the same as RAT, return early with KSH format
|
||||
if string(metadata.TokenAddress) == string(recipientActiveAddress) {
|
||||
// If SAT is the same as RAT (default USDm),
|
||||
// or if the voucher is a stable coin
|
||||
// return early with KSH format
|
||||
if string(metadata.TokenAddress) == string(recipientActiveAddress) || isStableVoucher(metadata.TokenAddress) {
|
||||
txType = "normal"
|
||||
// Save the transaction type
|
||||
if err := userStore.WriteEntry(ctx, sessionId, storedb.DATA_SEND_TRANSACTION_TYPE, []byte(txType)); err != nil {
|
||||
@ -113,9 +115,16 @@ func (h *MenuHandlers) GetMpesaMaxLimit(ctx context.Context, sym string, input [
|
||||
}
|
||||
|
||||
activeFloat, _ := strconv.ParseFloat(string(metadata.Balance), 64)
|
||||
ksh := fmt.Sprintf("%f", activeFloat*rates.Buy)
|
||||
kshValue := activeFloat * rates.Buy
|
||||
|
||||
maxKshFormatted, _ := store.TruncateDecimalString(ksh, 0)
|
||||
maxKshFormatted, _ := store.TruncateDecimalString(fmt.Sprintf("%f", kshValue), 0)
|
||||
|
||||
// Ensure that the max is greater than the min
|
||||
if kshValue < minWithdraw {
|
||||
res.FlagSet = append(res.FlagSet, flag_low_swap_amount)
|
||||
res.Content = l.Get("%s Ksh", maxKshFormatted)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
res.Content = l.Get(
|
||||
"Enter the amount of Mpesa to withdraw: (Min: Ksh %s, Max %s Ksh)\n",
|
||||
@ -123,6 +132,8 @@ func (h *MenuHandlers) GetMpesaMaxLimit(ctx context.Context, sym string, input [
|
||||
maxKshFormatted,
|
||||
)
|
||||
|
||||
res.FlagReset = append(res.FlagReset, flag_low_swap_amount, flag_api_call_error, flag_incorrect_voucher, flag_incorrect_pool)
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@ -142,6 +153,7 @@ func (h *MenuHandlers) GetMpesaMaxLimit(ctx context.Context, sym string, input [
|
||||
|
||||
if !canSwap.CanSwapFrom { // pool issue (CATCH on .vis)
|
||||
res.FlagSet = append(res.FlagSet, flag_incorrect_pool)
|
||||
res.Content = "0"
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@ -149,10 +161,13 @@ func (h *MenuHandlers) GetMpesaMaxLimit(ctx context.Context, sym string, input [
|
||||
_, maxRAT, err := h.calculateSendCreditLimits(ctx, activePoolAddress, []byte(metadata.TokenAddress), recipientActiveAddress, publicKey, []byte(metadata.TokenDecimals), recipientActiveDecimal)
|
||||
if err != nil {
|
||||
res.FlagSet = append(res.FlagSet, flag_api_call_error)
|
||||
res.Content = "0"
|
||||
logg.ErrorCtxf(ctx, "failed on calculateSendCreditLimits", "error", err)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
res.FlagReset = append(res.FlagReset, flag_api_call_error)
|
||||
|
||||
// Fallback if below minimum
|
||||
maxFloat, _ := strconv.ParseFloat(maxRAT, 64)
|
||||
if maxFloat < 0.1 {
|
||||
@ -162,6 +177,8 @@ func (h *MenuHandlers) GetMpesaMaxLimit(ctx context.Context, sym string, input [
|
||||
return res, nil
|
||||
}
|
||||
|
||||
res.FlagReset = append(res.FlagReset, flag_low_swap_amount)
|
||||
|
||||
// Save max RAT amount to be used in validating the user's input
|
||||
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_ACTIVE_SWAP_MAX_AMOUNT, []byte(maxRAT))
|
||||
if err != nil {
|
||||
@ -198,6 +215,8 @@ func (h *MenuHandlers) GetMpesaMaxLimit(ctx context.Context, sym string, input [
|
||||
maxKshFormatted,
|
||||
)
|
||||
|
||||
res.FlagReset = append(res.FlagReset, flag_low_swap_amount, flag_api_call_error, flag_incorrect_voucher, flag_incorrect_pool)
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@ -525,7 +544,7 @@ func (h *MenuHandlers) SendMpesaMinLimit(ctx context.Context, sym string, input
|
||||
kshFormatted, _ := store.TruncateDecimalString(ksh, 0)
|
||||
|
||||
res.Content = l.Get(
|
||||
"Enter the amount of credit to receive: (Minimum %s Ksh)\n",
|
||||
"Enter the amount of credit to deposit: (Minimum %s Ksh)\n",
|
||||
kshFormatted,
|
||||
)
|
||||
|
||||
@ -597,7 +616,7 @@ func (h *MenuHandlers) SendMpesaPreview(ctx context.Context, sym string, input [
|
||||
defaultAsset := config.DefaultMpesaAsset()
|
||||
|
||||
res.Content = l.Get(
|
||||
"You will get a prompt for your M-Pesa PIN shortly to send %s ksh and receive ~ %s %s",
|
||||
"You will get a prompt for your Mpesa PIN shortly to send %s ksh and receive ~ %s %s",
|
||||
inputStr, estimateFormatted, defaultAsset,
|
||||
)
|
||||
|
||||
|
||||
@ -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
|
||||
@ -64,6 +64,7 @@ func (h *MenuHandlers) CalculateMaxPayDebt(ctx context.Context, sym string, inpu
|
||||
r, err := h.accountService.GetSwapFromTokenMaxLimit(ctx, string(activePoolAddress), metadata.TokenAddress, string(activeAddress), string(publicKey))
|
||||
if err != nil {
|
||||
res.FlagSet = append(res.FlagSet, flag_api_call_error)
|
||||
res.Content = "0"
|
||||
logg.ErrorCtxf(ctx, "failed on GetSwapFromTokenMaxLimit", "error", err)
|
||||
return res, nil
|
||||
}
|
||||
@ -126,10 +127,10 @@ func (h *MenuHandlers) CalculateMaxPayDebt(ctx context.Context, sym string, inpu
|
||||
quoteStr, _ := store.TruncateDecimalString(string(quoteAmountStr), 2)
|
||||
|
||||
res.Content = l.Get(
|
||||
"You can remove a max of %s %s from '%s'\nEnter amount of %s:(Max: %s)",
|
||||
"You can remove a max of %s %s from '%s' pool\nEnter amount of %s:(Max: %s)",
|
||||
quoteStr,
|
||||
string(activeSym),
|
||||
string(activePoolName),
|
||||
string(activePoolSymbol),
|
||||
metadata.TokenSymbol,
|
||||
maxStr,
|
||||
)
|
||||
@ -237,7 +238,7 @@ func (h *MenuHandlers) ConfirmDebtRemoval(ctx context.Context, sym string, input
|
||||
}
|
||||
|
||||
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\nEnter your PIN:",
|
||||
inputStr, payDebtVoucher.TokenSymbol, qouteStr, string(activeSym),
|
||||
)
|
||||
|
||||
@ -268,7 +269,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 +311,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
|
||||
@ -173,9 +173,12 @@ func (h *MenuHandlers) InitiatePoolDeposit(ctx context.Context, sym string, inpu
|
||||
l := gotext.NewLocale(translationDir, code)
|
||||
l.AddDomain("default")
|
||||
|
||||
userStore := h.userdataStore
|
||||
|
||||
// Resolve active pool
|
||||
activePoolAddress, activePoolName, err := h.resolveActivePoolDetails(ctx, sessionId)
|
||||
activePoolAddress, activePoolSymbol, err := h.resolveActivePoolDetails(ctx, sessionId)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed on resolveActivePoolDetails", "error", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -185,18 +188,26 @@ func (h *MenuHandlers) InitiatePoolDeposit(ctx context.Context, sym string, inpu
|
||||
return res, err
|
||||
}
|
||||
|
||||
poolDepositdata, err := store.ReadTransactionData(ctx, h.userdataStore, sessionId)
|
||||
publicKey, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read publicKey entry", "key", storedb.DATA_PUBLIC_KEY, "error", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
finalAmountStr, err := store.ParseAndScaleAmount(poolDepositdata.Amount, poolDepositVoucher.TokenDecimals)
|
||||
amount, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_AMOUNT)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read amount entry", "key", storedb.DATA_AMOUNT, "error", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// Call pool deposit API
|
||||
r, err := h.accountService.PoolDeposit(ctx, finalAmountStr, poolDepositdata.PublicKey, string(activePoolAddress), poolDepositVoucher.TokenAddress)
|
||||
finalAmountStr, err := store.ParseAndScaleAmount(string(amount), poolDepositVoucher.TokenDecimals)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed on ParseAndScaleAmount", "error", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// Call token transfer API and send the token to the pool address
|
||||
r, err := h.accountService.TokenTransfer(ctx, finalAmountStr, string(publicKey), string(activePoolAddress), poolDepositVoucher.TokenAddress)
|
||||
if err != nil {
|
||||
flag_api_call_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||
res.FlagSet = append(res.FlagSet, flag_api_call_error)
|
||||
@ -210,9 +221,9 @@ func (h *MenuHandlers) InitiatePoolDeposit(ctx context.Context, sym string, inpu
|
||||
|
||||
res.Content = l.Get(
|
||||
"Your request has been sent. You will receive an SMS when %s %s has been deposited into %s.",
|
||||
poolDepositdata.Amount,
|
||||
string(amount),
|
||||
poolDepositVoucher.TokenSymbol,
|
||||
activePoolName,
|
||||
activePoolSymbol,
|
||||
)
|
||||
|
||||
res.FlagReset = append(res.FlagReset, flag_account_authorized)
|
||||
|
||||
@ -3,6 +3,7 @@ package application
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.defalsify.org/vise.git/db"
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
@ -104,6 +105,7 @@ func (h *MenuHandlers) GetDefaultPool(ctx context.Context, sym string, input []b
|
||||
|
||||
// ViewPool retrieves the pool details from the user store
|
||||
// and displays it to the user for them to select it.
|
||||
// if the data does not exist, it calls the API to get the pool details
|
||||
func (h *MenuHandlers) ViewPool(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||
var res resource.Result
|
||||
sessionId, ok := ctx.Value("SessionId").(string)
|
||||
@ -131,8 +133,11 @@ func (h *MenuHandlers) ViewPool(ctx context.Context, sym string, input []byte) (
|
||||
if poolData == nil {
|
||||
flag_api_call_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||
|
||||
// convert to uppercase before the call
|
||||
poolSymbol := strings.ToUpper(inputStr)
|
||||
|
||||
// no match found. Call the API using the inputStr as the symbol
|
||||
poolResp, err := h.accountService.RetrievePoolDetails(ctx, inputStr)
|
||||
poolResp, err := h.accountService.RetrievePoolDetails(ctx, poolSymbol)
|
||||
if err != nil {
|
||||
res.FlagSet = append(res.FlagSet, flag_api_call_error)
|
||||
return res, nil
|
||||
|
||||
@ -175,6 +175,10 @@ func (h *MenuHandlers) SwapMaxLimit(ctx context.Context, sym string, input []byt
|
||||
return res, nil
|
||||
}
|
||||
|
||||
code := codeFromCtx(ctx)
|
||||
l := gotext.NewLocale(translationDir, code)
|
||||
l.AddDomain("default")
|
||||
|
||||
userStore := h.userdataStore
|
||||
metadata, err := store.GetSwapToVoucherData(ctx, userStore, sessionId, inputStr)
|
||||
if err != nil {
|
||||
@ -235,9 +239,9 @@ func (h *MenuHandlers) SwapMaxLimit(ctx context.Context, sym string, input []byt
|
||||
return res, err
|
||||
}
|
||||
|
||||
res.Content = fmt.Sprintf(
|
||||
"Maximum: %s\n\nEnter amount of %s to swap for %s:",
|
||||
maxStr, swapData.ActiveSwapFromSym, swapData.ActiveSwapToSym,
|
||||
res.Content = l.Get(
|
||||
"Maximum: %s %s\n\nEnter amount of %s to swap for %s:",
|
||||
maxStr, swapData.ActiveSwapFromSym, swapData.ActiveSwapFromSym, swapData.ActiveSwapToSym,
|
||||
)
|
||||
|
||||
return res, nil
|
||||
@ -323,8 +327,8 @@ func (h *MenuHandlers) SwapPreview(ctx context.Context, sym string, input []byte
|
||||
// Format to 2 decimal places
|
||||
qouteStr, _ := store.TruncateDecimalString(string(quoteAmountStr), 2)
|
||||
|
||||
res.Content = fmt.Sprintf(
|
||||
"You will swap:\n%s %s for %s %s:",
|
||||
res.Content = l.Get(
|
||||
"You will swap %s %s for %s %s:",
|
||||
inputStr, swapData.ActiveSwapFromSym, qouteStr, swapData.ActiveSwapToSym,
|
||||
)
|
||||
|
||||
|
||||
@ -380,6 +380,19 @@ func (h *MenuHandlers) MaxAmount(ctx context.Context, sym string, input []byte)
|
||||
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)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "Failed to read recipient's address", "error", err)
|
||||
return res, err
|
||||
}
|
||||
if string(recipientAddress) == config.DefaultMpesaAddress() && isStableVoucher(string(activeAddress)) {
|
||||
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")
|
||||
@ -414,12 +427,15 @@ func (h *MenuHandlers) MaxAmount(ctx context.Context, sym string, input []byte)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// Get the recipient's phone number to read other data items
|
||||
// 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
|
||||
if err != nil || !phone.IsValidPhoneNumber(string(recipientPhoneNumber)) {
|
||||
// revert to normal transaction
|
||||
res.FlagReset = append(res.FlagReset, flag_swap_transaction)
|
||||
res.Content = l.Get("Maximum amount: %s %s\nEnter amount:", formattedBalance, string(activeSym))
|
||||
return res, nil
|
||||
}
|
||||
|
||||
recipientActiveSym, recipientActiveAddress, recipientActiveDecimal, err := h.getRecipientData(ctx, string(recipientPhoneNumber))
|
||||
if err != nil {
|
||||
return res, err
|
||||
@ -529,7 +545,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
|
||||
@ -539,21 +555,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,
|
||||
@ -568,14 +584,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) {
|
||||
@ -956,25 +972,18 @@ func (h *MenuHandlers) TransactionSwapPreview(ctx context.Context, sym string, i
|
||||
}
|
||||
|
||||
sendInputAmount := r.InputAmount // amount of SAT that should be swapped
|
||||
sendOutputAmount := r.OutputAmount // amount of RAT that will be received
|
||||
|
||||
// store the sendOutputAmount as the final amount (that will be sent)
|
||||
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_AMOUNT, []byte(sendOutputAmount))
|
||||
// store the finalAmountStr as the final amount (that will be sent after the swap)
|
||||
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_AMOUNT, []byte(finalAmountStr))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write output amount value entry with", "key", storedb.DATA_AMOUNT, "value", sendOutputAmount, "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to write output amount value entry with", "key", storedb.DATA_AMOUNT, "value", finalAmountStr, "error", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// Scale down the quoted output amount
|
||||
quoteAmountStr := store.ScaleDownBalance(sendOutputAmount, swapToVoucher.TokenDecimals)
|
||||
|
||||
// Format the qouteAmount amount to 2 decimal places
|
||||
qouteAmount, _ := store.TruncateDecimalString(quoteAmountStr, 2)
|
||||
|
||||
// store the qouteAmount in the temporary value (display)
|
||||
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(qouteAmount))
|
||||
// store the qouteAmount in the temporary value
|
||||
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(inputStr))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write temporary qouteAmount entry with", "key", storedb.DATA_TEMPORARY_VALUE, "value", qouteAmount, "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed to write temporary inputStr entry with", "key", storedb.DATA_TEMPORARY_VALUE, "value", inputStr, "error", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -988,7 +997,7 @@ func (h *MenuHandlers) TransactionSwapPreview(ctx context.Context, sym string, i
|
||||
res.Content = l.Get(
|
||||
"%s will receive %s %s",
|
||||
string(recipientInput),
|
||||
qouteAmount,
|
||||
inputStr,
|
||||
swapToVoucher.TokenSymbol,
|
||||
)
|
||||
|
||||
|
||||
@ -17,8 +17,8 @@ import (
|
||||
|
||||
// ManageVouchers retrieves the token holdings from the API using the "PublicKey" and
|
||||
// 1. sets the first as the default voucher if no active voucher is set.
|
||||
// 2. Stores list of vouchers
|
||||
// 3. Stores list of filtered stable vouchers
|
||||
// 2. Stores list of filtered ordered vouchers (exclude the active voucher)
|
||||
// 3. Stores list of ordered vouchers (all vouchers)
|
||||
// 4. updates the balance of the active voucher
|
||||
func (h *MenuHandlers) ManageVouchers(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||
var res resource.Result
|
||||
@ -32,7 +32,6 @@ func (h *MenuHandlers) ManageVouchers(ctx context.Context, sym string, input []b
|
||||
|
||||
flag_no_active_voucher, _ := h.flagManager.GetFlag("flag_no_active_voucher")
|
||||
flag_api_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||
flag_no_stable_vouchers, _ := h.flagManager.GetFlag("flag_no_stable_vouchers")
|
||||
flag_multiple_voucher, _ := h.flagManager.GetFlag("flag_multiple_voucher")
|
||||
|
||||
publicKey, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY)
|
||||
@ -216,21 +215,6 @@ func (h *MenuHandlers) ManageVouchers(ctx context.Context, sym string, input []b
|
||||
// Order all vouchers
|
||||
orderedVouchers := orderVouchers(vouchersResp)
|
||||
|
||||
// Stable voucher presence flag (based on full list)
|
||||
hasStable := false
|
||||
for _, v := range orderedVouchers {
|
||||
if isStableVoucher(v.TokenAddress) {
|
||||
hasStable = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !hasStable {
|
||||
res.FlagSet = append(res.FlagSet, flag_no_stable_vouchers)
|
||||
} else {
|
||||
res.FlagReset = append(res.FlagReset, flag_no_stable_vouchers)
|
||||
}
|
||||
|
||||
// Process ALL vouchers (stable first)
|
||||
orderedVoucherData := store.ProcessVouchers(orderedVouchers)
|
||||
|
||||
@ -253,6 +237,7 @@ func (h *MenuHandlers) ManageVouchers(ctx context.Context, sym string, input []b
|
||||
}
|
||||
|
||||
// GetVoucherList fetches the list of vouchers from the store and formats them.
|
||||
// does not include the active voucher and is used in select_voucher and pay_debt
|
||||
func (h *MenuHandlers) GetVoucherList(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||
var res resource.Result
|
||||
sessionId, ok := ctx.Value("SessionId").(string)
|
||||
@ -281,7 +266,12 @@ func (h *MenuHandlers) GetVoucherList(ctx context.Context, sym string, input []b
|
||||
}
|
||||
|
||||
if len(voucherData) == 0 {
|
||||
if sym == "get_paydebt_voucher_list" {
|
||||
res.Content = l.Get("You need another voucher to proceed. Only found %s.", string(activeSym))
|
||||
} else {
|
||||
res.Content = l.Get("Your active voucher %s is already set", string(activeSym))
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
|
||||
@ -111,7 +111,8 @@ func (ls *LocalHandlerService) GetHandler(accountService remote.AccountService)
|
||||
ls.DbRs.AddLocalFunc("quit_with_help", appHandlers.QuitWithHelp)
|
||||
ls.DbRs.AddLocalFunc("fetch_community_balance", appHandlers.FetchCommunityBalance)
|
||||
ls.DbRs.AddLocalFunc("manage_vouchers", appHandlers.ManageVouchers)
|
||||
ls.DbRs.AddLocalFunc("get_vouchers", appHandlers.GetVoucherList)
|
||||
ls.DbRs.AddLocalFunc("get_voucher_list", appHandlers.GetVoucherList)
|
||||
ls.DbRs.AddLocalFunc("get_paydebt_voucher_list", appHandlers.GetVoucherList)
|
||||
ls.DbRs.AddLocalFunc("view_voucher", appHandlers.ViewVoucher)
|
||||
ls.DbRs.AddLocalFunc("set_voucher", appHandlers.SetVoucher)
|
||||
ls.DbRs.AddLocalFunc("get_voucher_details", appHandlers.GetVoucherDetails)
|
||||
|
||||
@ -1,2 +1 @@
|
||||
{{.confirm_debt_removal}}
|
||||
Enter your PIN:
|
||||
@ -10,6 +10,10 @@ INCMP > 88
|
||||
INCMP < 98
|
||||
INCMP _ 0
|
||||
INCMP quit 99
|
||||
LOAD get_mpesa_max_limit 0
|
||||
LOAD get_mpesa_max_limit 89
|
||||
RELOAD get_mpesa_max_limit
|
||||
CATCH . flag_incorrect_voucher 1
|
||||
CATCH low_withdraw_mpesa_amount flag_incorrect_pool 1
|
||||
CATCH low_withdraw_mpesa_amount flag_low_swap_amount 1
|
||||
CATCH low_withdraw_mpesa_amount flag_api_call_error 1
|
||||
INCMP mpesa_max_limit *
|
||||
|
||||
@ -59,7 +59,7 @@ msgid "Enter the amount of M-Pesa to get: (Max %s Ksh)\n"
|
||||
msgstr "Weka kiasi cha M-Pesa cha kupata: (Kikomo %s Ksh)\n"
|
||||
|
||||
msgid "You are sending %s %s in order to receive ~ %s ksh"
|
||||
msgstr "Unatuma ~ %s %s ili upoke %s ksh"
|
||||
msgstr "Unatuma ~ %s %s ili upokee %s ksh"
|
||||
|
||||
msgid "Your request has been sent. Please await confirmation"
|
||||
msgstr "Ombi lako limetumwa. Tafadhali subiri"
|
||||
@ -67,16 +67,16 @@ msgstr "Ombi lako limetumwa. Tafadhali subiri"
|
||||
msgid "Enter the amount of M-Pesa to send: (Minimum %s Ksh)\n"
|
||||
msgstr "Weka kiasi cha M-Pesa cha kutuma: (Kima cha chini %s Ksh)\n"
|
||||
|
||||
msgid "You will get a prompt for your M-Pesa PIN shortly to send %s ksh and receive ~ %s cUSD"
|
||||
msgstr "Utapokea kidokezo cha PIN yako ya M-Pesa hivi karibuni kutuma %s ksh na kupokea ~ %s cUSD"
|
||||
msgid "You will get a prompt for your Mpesa PIN shortly to send %s ksh and receive ~ %s %s"
|
||||
msgstr "Utapokea kidokezo cha PIN yako ya Mpesa hivi karibuni kutuma %s ksh na kupokea ~ %s %s"
|
||||
|
||||
msgid "Your request has been sent. Thank you for using Sarafu"
|
||||
msgstr "Ombi lako limetumwa. Asante kwa kutumia huduma ya Sarafu"
|
||||
|
||||
msgid "You can remove a maximum of %s %s from '%s' pool\n\nEnter amount of %s:"
|
||||
msgstr "Unaweza kuondoa kiwango cha juu cha %s %s kutoka kwenye '%s'\n\nWeka kiwango cha %s:"
|
||||
msgid "You can remove a max of %s %s from '%s' pool\nEnter amount of %s:(Max: %s)"
|
||||
msgstr "Unaweza kuondoa kiwango cha juu cha %s %s kutoka kwenye '%s'\n\nWeka kiwango cha %s:(Kikomo: %s)"
|
||||
|
||||
msgid "Please confirm that you will use %s %s to remove your debt of %s %s\n"
|
||||
msgid "Please confirm that you will use %s %s to remove your debt of %s %s\nEnter your PIN:"
|
||||
msgstr "Tafadhali thibitisha kwamba utatumia %s %s kulipa deni lako la %s %s.\nWeka PIN yako:"
|
||||
|
||||
msgid "Your active voucher %s is already set"
|
||||
@ -93,3 +93,21 @@ msgstr "Ombi lako limetumwa. Utapokea ujumbe wakati %s %s itawekwa kwenye %s."
|
||||
|
||||
msgid "%s will receive %s %s from %s"
|
||||
msgstr %s atapokea %s %s kutoka kwa %s"
|
||||
|
||||
msgid "You need another voucher to proceed. Only found %s."
|
||||
msgstr "Unahitaji kua na sarafu nyingine. Tumepata tu %s."
|
||||
|
||||
msgid "Maximum: %s %s\n\nEnter amount of %s to swap for %s:"
|
||||
msgstr "Kikimo: %s %s\n\nWeka kiasi cha %s kitakacho badilishwa kua %s:"
|
||||
|
||||
msgid "You will swap %s %s for %s %s:"
|
||||
msgstr "Utabadilisha %s %s kua %s %s:"
|
||||
|
||||
msgid "Your request has been sent. You will receive an SMS when your debt of %s %s has been removed from %s."
|
||||
msgstr "Ombi lako limetumwa. Utapokea ujumbe wakati deni lako la %s %s litatolewa kwa %s."
|
||||
|
||||
msgid "Enter the amount of Mpesa to withdraw: (Min: Ksh %s, Max %s Ksh)\n"
|
||||
msgstr "Weka kiasi cha Mpesa utakacho toa: (Min: Ksh %s, Max %s Ksh)\n"
|
||||
|
||||
msgid "Enter the amount of credit to deposit: (Minimum %s Ksh)\n"
|
||||
msgstr "Weka kiasi utakacho weka (Kima cha chini: %s Ksh)\n"
|
||||
@ -1 +1 @@
|
||||
You have a low debt amount
|
||||
Available amount {{.calculate_max_pay_debt}} is too low, please choose a different voucher:
|
||||
@ -1,5 +1,6 @@
|
||||
MAP calculate_max_pay_debt
|
||||
MOUT back 0
|
||||
MOUT quit 9
|
||||
HALT
|
||||
INCMP ^ 0
|
||||
INCMP _ 0
|
||||
INCMP quit 9
|
||||
|
||||
@ -1 +1 @@
|
||||
Kiasi cha deni lako ni cha chini sana
|
||||
Kiasi kinachopatikana {{.calculate_max_pay_debt}} ni cha chini sana, tafadhali chagua sarafu tofauti:
|
||||
@ -1 +1 @@
|
||||
Available amount {{.swap_max_limit}} is too low, please try again:
|
||||
Available amount {{.swap_max_limit}} is too low, please choose a different voucher:
|
||||
@ -1 +1 @@
|
||||
Kiasi kinachopatikana {{.swap_max_limit}} ni cha chini sana, tafadhali jaribu tena:
|
||||
Kiasi kinachopatikana {{.swap_max_limit}} ni cha chini sana, tafadhali chagua sarafu tofauti:
|
||||
1
services/registration/low_withdraw_mpesa_amount
Normal file
1
services/registration/low_withdraw_mpesa_amount
Normal file
@ -0,0 +1 @@
|
||||
Available amount {{.get_mpesa_max_limit}} is too low, please choose a different voucher:
|
||||
6
services/registration/low_withdraw_mpesa_amount.vis
Normal file
6
services/registration/low_withdraw_mpesa_amount.vis
Normal file
@ -0,0 +1,6 @@
|
||||
MAP get_mpesa_max_limit
|
||||
MOUT back 0
|
||||
MOUT quit 9
|
||||
HALT
|
||||
INCMP _ 0
|
||||
INCMP quit 9
|
||||
1
services/registration/low_withdraw_mpesa_amount_swa
Normal file
1
services/registration/low_withdraw_mpesa_amount_swa
Normal file
@ -0,0 +1 @@
|
||||
Kiasi kinachopatikana {{.get_mpesa_max_limit}} ni cha chini sana, tafadhali chagua sarafu tofauti:
|
||||
@ -1 +1 @@
|
||||
{{.get_vouchers}}
|
||||
{{.get_paydebt_voucher_list}}
|
||||
@ -1,6 +1,6 @@
|
||||
CATCH no_voucher flag_no_active_voucher 1
|
||||
LOAD get_vouchers 0
|
||||
MAP get_vouchers
|
||||
LOAD get_paydebt_voucher_list 0
|
||||
MAP get_paydebt_voucher_list
|
||||
MOUT back 0
|
||||
MOUT quit 99
|
||||
MNEXT next 88
|
||||
@ -13,4 +13,6 @@ INCMP quit 99
|
||||
LOAD calculate_max_pay_debt 0
|
||||
RELOAD calculate_max_pay_debt
|
||||
CATCH . flag_incorrect_voucher 1
|
||||
CATCH low_pay_debt_amount flag_low_swap_amount 1
|
||||
CATCH low_pay_debt_amount flag_api_call_error 1
|
||||
INCMP calculate_max_pay_debt *
|
||||
|
||||
@ -1 +0,0 @@
|
||||
{{.calculate_max_pay_debt}}
|
||||
@ -1,5 +1,4 @@
|
||||
CATCH no_voucher flag_no_active_voucher 1
|
||||
CATCH no_stable_voucher flag_no_stable_vouchers 1
|
||||
LOAD get_ordered_vouchers 0
|
||||
MAP get_ordered_vouchers
|
||||
MOUT back 0
|
||||
|
||||
@ -1 +1 @@
|
||||
{{.get_vouchers}}
|
||||
{{.get_voucher_list}}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
CATCH no_voucher flag_no_active_voucher 1
|
||||
LOAD get_vouchers 0
|
||||
MAP get_vouchers
|
||||
LOAD get_voucher_list 0
|
||||
MAP get_voucher_list
|
||||
MOUT back 0
|
||||
MOUT quit 99
|
||||
MNEXT next 88
|
||||
|
||||
@ -1,3 +1,2 @@
|
||||
{{.send_mpesa_preview}}
|
||||
|
||||
Please enter your account PIN to confirm:
|
||||
Enter your PIN to confirm:
|
||||
@ -1,3 +1,2 @@
|
||||
{{.send_mpesa_preview}}
|
||||
|
||||
Tafadhali weka PIN ya akaunti yako kudhibitisha:
|
||||
Weka PIN yako kudhibitisha:
|
||||
@ -12,7 +12,7 @@ INCMP > 88
|
||||
INCMP < 98
|
||||
INCMP _ 0
|
||||
INCMP quit 99
|
||||
LOAD swap_max_limit 64
|
||||
LOAD swap_max_limit 138
|
||||
RELOAD swap_max_limit
|
||||
CATCH api_failure flag_api_call_error 1
|
||||
CATCH . flag_incorrect_voucher 1
|
||||
|
||||
@ -159,6 +159,10 @@ func GetOrderedVoucherData(ctx context.Context, store DataStore, sessionId strin
|
||||
|
||||
// MatchVoucher finds the matching voucher symbol, balance, decimals and contract address based on the input.
|
||||
func MatchVoucher(input, symbols, balances, decimals, addresses string) (symbol, balance, decimal, address string) {
|
||||
// case for invalid input with no current symbols
|
||||
if symbols == "" {
|
||||
return
|
||||
}
|
||||
symList := strings.Split(symbols, "\n")
|
||||
balList := strings.Split(balances, "\n")
|
||||
decList := strings.Split(decimals, "\n")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user