Compare commits
15 Commits
v1.4.4-rc.
...
have-singl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
523f680276
|
||
|
|
b337c9260b
|
||
|
|
c380915100
|
||
|
|
7d8fd065f0
|
||
|
|
40292ebcdd
|
||
|
|
4edcdfa987
|
||
|
|
a56f94896d
|
||
|
|
a447f230ca
|
||
|
|
65badc4ccc
|
||
| 89d3d19d77 | |||
|
|
817b523135 | ||
| e0e3d9b6cf | |||
|
|
2cabae1e74
|
||
|
|
f949b83a51
|
||
|
|
d586c41cca
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,3 +8,4 @@ id_*
|
||||
*.gdbm
|
||||
*.log
|
||||
user-data
|
||||
**/*/vise-asm
|
||||
|
||||
@@ -11,7 +11,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libgdbm-dev \
|
||||
git \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
RUN git clone https://git.defalsify.org/vise.git go-vise
|
||||
RUN git clone https://github.com/nolash/go-vise go-vise
|
||||
COPY . ./sarafu-vise
|
||||
|
||||
WORKDIR /build/sarafu-vise/services/registration
|
||||
|
||||
@@ -79,11 +79,12 @@ func main() {
|
||||
pfp := path.Join(scriptDir, "pp.csv")
|
||||
|
||||
cfg := engine.Config{
|
||||
Root: "root",
|
||||
OutputSize: uint32(size),
|
||||
FlagCount: uint32(128),
|
||||
MenuSeparator: menuSeparator,
|
||||
Root: "root",
|
||||
OutputSize: uint32(size),
|
||||
FlagCount: uint32(128),
|
||||
MenuSeparator: menuSeparator,
|
||||
ResetOnEmptyInput: true,
|
||||
ResetRoot: true, // clear the cache once a user quits
|
||||
}
|
||||
|
||||
if engineDebug {
|
||||
|
||||
@@ -94,11 +94,12 @@ func main() {
|
||||
pfp := path.Join(scriptDir, "pp.csv")
|
||||
|
||||
cfg := engine.Config{
|
||||
Root: "root",
|
||||
OutputSize: uint32(size),
|
||||
FlagCount: uint32(128),
|
||||
MenuSeparator: menuSeparator,
|
||||
Root: "root",
|
||||
OutputSize: uint32(size),
|
||||
FlagCount: uint32(128),
|
||||
MenuSeparator: menuSeparator,
|
||||
ResetOnEmptyInput: true,
|
||||
ResetRoot: true, // clear the cache once a user quits
|
||||
}
|
||||
|
||||
if engineDebug {
|
||||
|
||||
@@ -82,6 +82,7 @@ func main() {
|
||||
MenuSeparator: menuSeparator,
|
||||
EngineDebug: engineDebug,
|
||||
ResetOnEmptyInput: true,
|
||||
ResetRoot: true, // clear the cache once a user quits
|
||||
}
|
||||
|
||||
menuStorageService := storage.NewMenuStorageService(conns)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
"git.grassecon.net/grassrootseconomics/common/hex"
|
||||
@@ -411,7 +412,10 @@ func (h *MenuHandlers) InitiateGetMpesa(ctx context.Context, sym string, input [
|
||||
return res, nil
|
||||
}
|
||||
|
||||
logg.InfoCtxf(ctx, "poolSwap", "swapTrackingId", poolSwap.TrackingId)
|
||||
logg.InfoCtxf(ctx, "mpesa poolSwap before transfer", "swapTrackingId", poolSwap.TrackingId)
|
||||
|
||||
// TODO: remove this temporary time delay and replace with a swap and send endpoint
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
finalKshStr, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE)
|
||||
if err != nil {
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.defalsify.org/vise.git/db"
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
@@ -257,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_with_invite, _ := h.flagManager.GetFlag("flag_invalid_recipient_with_invite")
|
||||
|
||||
store := h.userdataStore
|
||||
err = store.WriteEntry(ctx, sessionId, storedb.DATA_AMOUNT, []byte(""))
|
||||
if err != nil {
|
||||
@@ -335,28 +337,13 @@ 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)
|
||||
|
||||
// If normal transaction, or if the sym is send_max_amount, return balance
|
||||
if string(transactionType) == "normal" || sym == "send_max_amount" {
|
||||
// If normal transaction return balance
|
||||
if string(transactionType) == "normal" {
|
||||
res.FlagReset = append(res.FlagReset, flag_swap_transaction)
|
||||
|
||||
res.Content = l.Get("Maximum amount: %s %s\nEnter amount:", formattedBalance, string(activeSym))
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
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
|
||||
activePoolAddress, err := h.resolveActivePoolAddress(ctx, sessionId)
|
||||
if err != nil {
|
||||
@@ -371,16 +358,31 @@ func (h *MenuHandlers) MaxAmount(ctx context.Context, sym string, input []byte)
|
||||
logg.ErrorCtxf(ctx, "failed on CheckTokenInPool", "error", err)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
res.FlagReset = append(res.FlagReset, flag_swap_transaction)
|
||||
res.Content = l.Get("Maximum amount: %s %s\nEnter amount:", formattedBalance, string(activeSym))
|
||||
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
|
||||
maxSAT, maxRAT, err := h.calculateSendCreditLimits(ctx, activePoolAddress, activeAddress, recipientActiveAddress, publicKey, activeDecimal, recipientActiveDecimal)
|
||||
if err != nil {
|
||||
res.FlagSet = append(res.FlagSet, flag_api_call_error)
|
||||
// if an error (such as Swap rates not found for the speficied pool and tokens), fall back to a normal transaction
|
||||
logg.ErrorCtxf(ctx, "failed on calculateSendCreditLimits", "error", err)
|
||||
res.FlagReset = append(res.FlagReset, flag_swap_transaction)
|
||||
res.Content = l.Get("Maximum amount: %s %s\nEnter amount:", formattedBalance, string(activeSym))
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@@ -412,6 +414,9 @@ func (h *MenuHandlers) MaxAmount(ctx context.Context, sym string, input []byte)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// only set the flag once all checks pass
|
||||
res.FlagSet = append(res.FlagSet, flag_swap_transaction)
|
||||
|
||||
res.Content = l.Get(
|
||||
"Credit Available: %s %s\n(You can swap up to %s %s -> %s %s).\nEnter %s amount:",
|
||||
maxRAT,
|
||||
@@ -842,7 +847,10 @@ func (h *MenuHandlers) TransactionInitiateSwap(ctx context.Context, sym string,
|
||||
}
|
||||
|
||||
swapTrackingId := poolSwap.TrackingId
|
||||
logg.InfoCtxf(ctx, "poolSwap", "swapTrackingId", swapTrackingId)
|
||||
logg.InfoCtxf(ctx, "send poolSwap before transfer", "swapTrackingId", swapTrackingId)
|
||||
|
||||
// TODO: remove this temporary time delay and replace with a swap and send endpoint
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
// Initiate a send
|
||||
recipientPublicKey, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_RECIPIENT)
|
||||
@@ -874,7 +882,7 @@ func (h *MenuHandlers) TransactionInitiateSwap(ctx context.Context, sym string,
|
||||
}
|
||||
|
||||
trackingId := tokenTransfer.TrackingId
|
||||
logg.InfoCtxf(ctx, "TokenTransfer", "trackingId", trackingId)
|
||||
logg.InfoCtxf(ctx, "send TokenTransfer after swap", "trackingId", trackingId)
|
||||
|
||||
res.Content = l.Get(
|
||||
"Your request has been sent. %s will receive %s %s from %s.",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
LOAD reset_transaction_amount 10
|
||||
RELOAD reset_transaction_amount
|
||||
LOAD credit_max_amount 160
|
||||
RELOAD credit_max_amount
|
||||
CATCH api_failure flag_api_call_error 1
|
||||
@@ -10,7 +11,6 @@ RELOAD clear_trans_type_flag
|
||||
CATCH transaction_swap flag_swap_transaction 1
|
||||
LOAD validate_amount 64
|
||||
RELOAD validate_amount
|
||||
CATCH api_failure flag_api_call_error 1
|
||||
CATCH invalid_amount flag_invalid_amount 1
|
||||
INCMP _ 0
|
||||
LOAD get_recipient 0
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Credit-Send
|
||||
@@ -1 +0,0 @@
|
||||
Tuma-Mkopo
|
||||
@@ -7,22 +7,20 @@ LOAD check_balance 128
|
||||
RELOAD check_balance
|
||||
MAP check_balance
|
||||
MOUT send 1
|
||||
MOUT credit_send 2
|
||||
MOUT swap 3
|
||||
MOUT vouchers 4
|
||||
MOUT select_pool 5
|
||||
MOUT mpesa 6
|
||||
MOUT account 7
|
||||
MOUT help 8
|
||||
MOUT swap 2
|
||||
MOUT vouchers 3
|
||||
MOUT select_pool 4
|
||||
MOUT mpesa 5
|
||||
MOUT account 6
|
||||
MOUT help 7
|
||||
MOUT quit 9
|
||||
HALT
|
||||
INCMP send 1
|
||||
INCMP credit_send 2
|
||||
INCMP swap_to_list 3
|
||||
INCMP my_vouchers 4
|
||||
INCMP select_pool 5
|
||||
INCMP mpesa 6
|
||||
INCMP my_account 7
|
||||
INCMP help 8
|
||||
INCMP credit_send 1
|
||||
INCMP swap_to_list 2
|
||||
INCMP my_vouchers 3
|
||||
INCMP select_pool 4
|
||||
INCMP mpesa 5
|
||||
INCMP my_account 6
|
||||
INCMP help 7
|
||||
INCMP quit 9
|
||||
INCMP . *
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Enter recipient's phone number/address/alias:
|
||||
@@ -1,12 +0,0 @@
|
||||
LOAD transaction_reset 0
|
||||
RELOAD transaction_reset
|
||||
CATCH no_voucher flag_no_active_voucher 1
|
||||
MOUT back 0
|
||||
HALT
|
||||
LOAD validate_recipient 50
|
||||
RELOAD validate_recipient
|
||||
CATCH api_failure flag_api_call_error 1
|
||||
CATCH invalid_recipient flag_invalid_recipient 1
|
||||
CATCH invite_recipient flag_invalid_recipient_with_invite 1
|
||||
INCMP _ 0
|
||||
INCMP amount *
|
||||
@@ -1 +0,0 @@
|
||||
Weka nambari ya simu/Anwani/Lakabu:
|
||||
Reference in New Issue
Block a user