Compare commits
No commits in common. "master" and "v1.4.6-rc.12" have entirely different histories.
master
...
v1.4.6-rc.
@ -39,7 +39,7 @@ DEFAULT_MPESA_ASSET=cUSD
|
|||||||
MPESA_BEARER_TOKEN=eyJeSIsInRcCI6IkpXVCJ.yJwdWJsaWNLZXkiOiIwrrrrrr
|
MPESA_BEARER_TOKEN=eyJeSIsInRcCI6IkpXVCJ.yJwdWJsaWNLZXkiOiIwrrrrrr
|
||||||
MPESA_ONRAMP_BASE=https://pretium.v1.grassecon.net
|
MPESA_ONRAMP_BASE=https://pretium.v1.grassecon.net
|
||||||
|
|
||||||
# Known stable voucher addresses (USDm, USD₮, USDC)
|
# Known stable voucher addresses (USDm, USD₮)
|
||||||
STABLE_VOUCHER_ADDRESSES=0x765DE816845861e75A25fCA122bb6898B8B1282a,0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e,0xcebA9300f2b948710d2653dD7B07f33A8B32118C
|
STABLE_VOUCHER_ADDRESSES=0x765DE816845861e75A25fCA122bb6898B8B1282a,0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e
|
||||||
DEFAULT_STABLE_VOUCHER_ADDRESS=0x765DE816845861e75A25fCA122bb6898B8B1282a
|
DEFAULT_STABLE_VOUCHER_ADDRESS=0x765DE816845861e75A25fCA122bb6898B8B1282a
|
||||||
DEFAULT_STABLE_VOUCHER_DECIMALS=18
|
DEFAULT_STABLE_VOUCHER_DECIMALS=18
|
||||||
|
|||||||
@ -160,7 +160,7 @@ func (h *MenuHandlers) CalculateCreditAndDebt(ctx context.Context, sym string, i
|
|||||||
|
|
||||||
scaledCredit := "0"
|
scaledCredit := "0"
|
||||||
|
|
||||||
// 1. Find first stable voucher in POOL (for swap target)
|
// 1️. Find first stable voucher in POOL (for swap target)
|
||||||
var firstPoolStable *dataserviceapi.TokenHoldings
|
var firstPoolStable *dataserviceapi.TokenHoldings
|
||||||
for i := range swappableVouchers {
|
for i := range swappableVouchers {
|
||||||
if isStableVoucher(swappableVouchers[i].TokenAddress) {
|
if isStableVoucher(swappableVouchers[i].TokenAddress) {
|
||||||
@ -169,7 +169,7 @@ func (h *MenuHandlers) CalculateCreditAndDebt(ctx context.Context, sym string, i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. If pool has a stable, get swap quote
|
// 2️. If pool has a stable, get swap quote
|
||||||
if firstPoolStable != nil {
|
if firstPoolStable != nil {
|
||||||
finalAmountStr, err := store.ParseAndScaleAmount(
|
finalAmountStr, err := store.ParseAndScaleAmount(
|
||||||
string(activeBal),
|
string(activeBal),
|
||||||
@ -194,7 +194,7 @@ func (h *MenuHandlers) CalculateCreditAndDebt(ctx context.Context, sym string, i
|
|||||||
scaledCredit = store.AddDecimalStrings(scaledCredit, finalQuote)
|
scaledCredit = store.AddDecimalStrings(scaledCredit, finalQuote)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Add ALL wallet stable balances (from FetchVouchers)
|
// 3️. Add ALL wallet stable balances (from FetchVouchers)
|
||||||
for _, v := range allVouchers {
|
for _, v := range allVouchers {
|
||||||
if isStableVoucher(v.TokenAddress) {
|
if isStableVoucher(v.TokenAddress) {
|
||||||
scaled := store.ScaleDownBalance(v.Balance, v.TokenDecimals)
|
scaled := store.ScaleDownBalance(v.Balance, v.TokenDecimals)
|
||||||
|
|||||||
@ -100,13 +100,11 @@ func (h *MenuHandlers) GetMpesaMaxLimit(ctx context.Context, sym string, input [
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch min withdrawal amount from config/env
|
// Fetch min withdrawal amount from config/env
|
||||||
minWithdraw := config.MinMpesaWithdrawAmount() // float64 (20)
|
minksh := fmt.Sprintf("%f", config.MinMpesaWithdrawAmount())
|
||||||
minKshFormatted, _ := store.TruncateDecimalString(fmt.Sprintf("%f", minWithdraw), 0)
|
minKshFormatted, _ := store.TruncateDecimalString(minksh, 0)
|
||||||
|
|
||||||
// If SAT is the same as RAT (default USDm),
|
// If SAT is the same as RAT, return early with KSH format
|
||||||
// or if the voucher is a stable coin
|
if string(metadata.TokenAddress) == string(recipientActiveAddress) {
|
||||||
// return early with KSH format
|
|
||||||
if string(metadata.TokenAddress) == string(recipientActiveAddress) || isStableVoucher(metadata.TokenAddress) {
|
|
||||||
txType = "normal"
|
txType = "normal"
|
||||||
// Save the transaction type
|
// Save the transaction type
|
||||||
if err := userStore.WriteEntry(ctx, sessionId, storedb.DATA_SEND_TRANSACTION_TYPE, []byte(txType)); err != nil {
|
if err := userStore.WriteEntry(ctx, sessionId, storedb.DATA_SEND_TRANSACTION_TYPE, []byte(txType)); err != nil {
|
||||||
@ -115,16 +113,9 @@ func (h *MenuHandlers) GetMpesaMaxLimit(ctx context.Context, sym string, input [
|
|||||||
}
|
}
|
||||||
|
|
||||||
activeFloat, _ := strconv.ParseFloat(string(metadata.Balance), 64)
|
activeFloat, _ := strconv.ParseFloat(string(metadata.Balance), 64)
|
||||||
kshValue := activeFloat * rates.Buy
|
ksh := fmt.Sprintf("%f", activeFloat*rates.Buy)
|
||||||
|
|
||||||
maxKshFormatted, _ := store.TruncateDecimalString(fmt.Sprintf("%f", kshValue), 0)
|
maxKshFormatted, _ := store.TruncateDecimalString(ksh, 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(
|
res.Content = l.Get(
|
||||||
"Enter the amount of Mpesa to withdraw: (Min: Ksh %s, Max %s Ksh)\n",
|
"Enter the amount of Mpesa to withdraw: (Min: Ksh %s, Max %s Ksh)\n",
|
||||||
@ -544,7 +535,7 @@ func (h *MenuHandlers) SendMpesaMinLimit(ctx context.Context, sym string, input
|
|||||||
kshFormatted, _ := store.TruncateDecimalString(ksh, 0)
|
kshFormatted, _ := store.TruncateDecimalString(ksh, 0)
|
||||||
|
|
||||||
res.Content = l.Get(
|
res.Content = l.Get(
|
||||||
"Enter the amount of credit to deposit: (Minimum %s Ksh)\n",
|
"Enter the amount of credit to receive: (Minimum %s Ksh)\n",
|
||||||
kshFormatted,
|
kshFormatted,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -616,7 +607,7 @@ func (h *MenuHandlers) SendMpesaPreview(ctx context.Context, sym string, input [
|
|||||||
defaultAsset := config.DefaultMpesaAsset()
|
defaultAsset := config.DefaultMpesaAsset()
|
||||||
|
|
||||||
res.Content = l.Get(
|
res.Content = l.Get(
|
||||||
"You will get a prompt for your Mpesa PIN shortly to send %s ksh and receive ~ %s %s",
|
"You will get a prompt for your M-Pesa PIN shortly to send %s ksh and receive ~ %s %s",
|
||||||
inputStr, estimateFormatted, defaultAsset,
|
inputStr, estimateFormatted, defaultAsset,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -238,7 +238,7 @@ func (h *MenuHandlers) ConfirmDebtRemoval(ctx context.Context, sym string, input
|
|||||||
}
|
}
|
||||||
|
|
||||||
res.Content = l.Get(
|
res.Content = l.Get(
|
||||||
"Please confirm that you will use %s %s to remove your debt of %s %s\nEnter your PIN:",
|
"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),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -206,8 +206,8 @@ func (h *MenuHandlers) InitiatePoolDeposit(ctx context.Context, sym string, inpu
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call token transfer API and send the token to the pool address
|
// Call pool deposit API
|
||||||
r, err := h.accountService.TokenTransfer(ctx, finalAmountStr, string(publicKey), string(activePoolAddress), poolDepositVoucher.TokenAddress)
|
r, err := h.accountService.PoolDeposit(ctx, finalAmountStr, string(publicKey), string(activePoolAddress), poolDepositVoucher.TokenAddress)
|
||||||
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)
|
||||||
|
|||||||
@ -175,10 +175,6 @@ func (h *MenuHandlers) SwapMaxLimit(ctx context.Context, sym string, input []byt
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
code := codeFromCtx(ctx)
|
|
||||||
l := gotext.NewLocale(translationDir, code)
|
|
||||||
l.AddDomain("default")
|
|
||||||
|
|
||||||
userStore := h.userdataStore
|
userStore := h.userdataStore
|
||||||
metadata, err := store.GetSwapToVoucherData(ctx, userStore, sessionId, inputStr)
|
metadata, err := store.GetSwapToVoucherData(ctx, userStore, sessionId, inputStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -239,7 +235,7 @@ func (h *MenuHandlers) SwapMaxLimit(ctx context.Context, sym string, input []byt
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res.Content = l.Get(
|
res.Content = fmt.Sprintf(
|
||||||
"Maximum: %s %s\n\nEnter amount of %s to swap for %s:",
|
"Maximum: %s %s\n\nEnter amount of %s to swap for %s:",
|
||||||
maxStr, swapData.ActiveSwapFromSym, swapData.ActiveSwapFromSym, swapData.ActiveSwapToSym,
|
maxStr, swapData.ActiveSwapFromSym, swapData.ActiveSwapFromSym, swapData.ActiveSwapToSym,
|
||||||
)
|
)
|
||||||
@ -327,8 +323,8 @@ func (h *MenuHandlers) SwapPreview(ctx context.Context, sym string, input []byte
|
|||||||
// Format to 2 decimal places
|
// Format to 2 decimal places
|
||||||
qouteStr, _ := store.TruncateDecimalString(string(quoteAmountStr), 2)
|
qouteStr, _ := store.TruncateDecimalString(string(quoteAmountStr), 2)
|
||||||
|
|
||||||
res.Content = l.Get(
|
res.Content = fmt.Sprintf(
|
||||||
"You will swap %s %s for %s %s:",
|
"You will swap:\n%s %s for %s %s:",
|
||||||
inputStr, swapData.ActiveSwapFromSym, qouteStr, swapData.ActiveSwapToSym,
|
inputStr, swapData.ActiveSwapFromSym, qouteStr, swapData.ActiveSwapToSym,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -380,19 +380,6 @@ func (h *MenuHandlers) MaxAmount(ctx context.Context, sym string, input []byte)
|
|||||||
return res, 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)
|
|
||||||
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) {
|
if string(swapToVoucher.TokenAddress) == string(activeAddress) {
|
||||||
// recipient has active token same as selected token → normal transaction
|
// recipient has active token same as selected token → normal transaction
|
||||||
transactionType = []byte("normal")
|
transactionType = []byte("normal")
|
||||||
|
|||||||
@ -1 +1,2 @@
|
|||||||
{{.confirm_debt_removal}}
|
{{.confirm_debt_removal}}
|
||||||
|
Enter your PIN:
|
||||||
@ -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"
|
msgstr "Weka kiasi cha M-Pesa cha kupata: (Kikomo %s Ksh)\n"
|
||||||
|
|
||||||
msgid "You are sending %s %s in order to receive ~ %s ksh"
|
msgid "You are sending %s %s in order to receive ~ %s ksh"
|
||||||
msgstr "Unatuma ~ %s %s ili upokee %s ksh"
|
msgstr "Unatuma ~ %s %s ili upoke %s ksh"
|
||||||
|
|
||||||
msgid "Your request has been sent. Please await confirmation"
|
msgid "Your request has been sent. Please await confirmation"
|
||||||
msgstr "Ombi lako limetumwa. Tafadhali subiri"
|
msgstr "Ombi lako limetumwa. Tafadhali subiri"
|
||||||
@ -67,8 +67,8 @@ msgstr "Ombi lako limetumwa. Tafadhali subiri"
|
|||||||
msgid "Enter the amount of M-Pesa to send: (Minimum %s Ksh)\n"
|
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"
|
msgstr "Weka kiasi cha M-Pesa cha kutuma: (Kima cha chini %s Ksh)\n"
|
||||||
|
|
||||||
msgid "You will get a prompt for your Mpesa PIN shortly to send %s ksh and receive ~ %s %s"
|
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 Mpesa hivi karibuni kutuma %s ksh na kupokea ~ %s %s"
|
msgstr "Utapokea kidokezo cha PIN yako ya M-Pesa hivi karibuni kutuma %s ksh na kupokea ~ %s cUSD"
|
||||||
|
|
||||||
msgid "Your request has been sent. Thank you for using Sarafu"
|
msgid "Your request has been sent. Thank you for using Sarafu"
|
||||||
msgstr "Ombi lako limetumwa. Asante kwa kutumia huduma ya Sarafu"
|
msgstr "Ombi lako limetumwa. Asante kwa kutumia huduma ya Sarafu"
|
||||||
@ -76,7 +76,7 @@ msgstr "Ombi lako limetumwa. Asante kwa kutumia huduma ya Sarafu"
|
|||||||
msgid "You can remove a max of %s %s from '%s' pool\nEnter amount of %s:(Max: %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)"
|
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\nEnter your PIN:"
|
msgid "Please confirm that you will use %s %s to remove your debt of %s %s\n"
|
||||||
msgstr "Tafadhali thibitisha kwamba utatumia %s %s kulipa deni lako la %s %s.\nWeka PIN yako:"
|
msgstr "Tafadhali thibitisha kwamba utatumia %s %s kulipa deni lako la %s %s.\nWeka PIN yako:"
|
||||||
|
|
||||||
msgid "Your active voucher %s is already set"
|
msgid "Your active voucher %s is already set"
|
||||||
@ -95,19 +95,4 @@ msgid "%s will receive %s %s from %s"
|
|||||||
msgstr %s atapokea %s %s kutoka kwa %s"
|
msgstr %s atapokea %s %s kutoka kwa %s"
|
||||||
|
|
||||||
msgid "You need another voucher to proceed. Only found %s."
|
msgid "You need another voucher to proceed. Only found %s."
|
||||||
msgstr "Unahitaji kua na sarafu nyingine. Tumepata tu %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 @@
|
|||||||
{{.get_paydebt_voucher_list}}
|
{{.get_paydebt_voucher_list}}
|
||||||
|
|||||||
1
services/registration/pay_debt_swa
Normal file
1
services/registration/pay_debt_swa
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{.calculate_max_pay_debt}}
|
||||||
@ -1,2 +1,3 @@
|
|||||||
{{.send_mpesa_preview}}
|
{{.send_mpesa_preview}}
|
||||||
Enter your PIN to confirm:
|
|
||||||
|
Please enter your account PIN to confirm:
|
||||||
@ -1,2 +1,3 @@
|
|||||||
{{.send_mpesa_preview}}
|
{{.send_mpesa_preview}}
|
||||||
Weka PIN yako kudhibitisha:
|
|
||||||
|
Tafadhali weka PIN ya akaunti yako kudhibitisha:
|
||||||
@ -12,7 +12,7 @@ INCMP > 88
|
|||||||
INCMP < 98
|
INCMP < 98
|
||||||
INCMP _ 0
|
INCMP _ 0
|
||||||
INCMP quit 99
|
INCMP quit 99
|
||||||
LOAD swap_max_limit 138
|
LOAD swap_max_limit 64
|
||||||
RELOAD swap_max_limit
|
RELOAD swap_max_limit
|
||||||
CATCH api_failure flag_api_call_error 1
|
CATCH api_failure flag_api_call_error 1
|
||||||
CATCH . flag_incorrect_voucher 1
|
CATCH . flag_incorrect_voucher 1
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user