Compare commits
5 Commits
9ad7d5a522
...
672eebb8fb
Author | SHA1 | Date | |
---|---|---|---|
672eebb8fb | |||
8f834b3d76 | |||
6c93fb76b1 | |||
ea2df55295 | |||
7c08a0f0af |
@ -87,7 +87,7 @@ func main() {
|
||||
cfg := engine.Config{
|
||||
Root: "root",
|
||||
OutputSize: uint32(size),
|
||||
FlagCount: uint32(16),
|
||||
FlagCount: uint32(17),
|
||||
}
|
||||
|
||||
if engineDebug {
|
||||
|
@ -60,7 +60,7 @@ func main() {
|
||||
cfg := engine.Config{
|
||||
Root: "root",
|
||||
OutputSize: uint32(size),
|
||||
FlagCount: uint32(16),
|
||||
FlagCount: uint32(17),
|
||||
}
|
||||
|
||||
if engineDebug {
|
||||
|
@ -48,7 +48,7 @@ func main() {
|
||||
cfg := engine.Config{
|
||||
Root: "root",
|
||||
OutputSize: uint32(size),
|
||||
FlagCount: uint32(16),
|
||||
FlagCount: uint32(17),
|
||||
}
|
||||
|
||||
if engineDebug {
|
||||
|
@ -40,7 +40,7 @@ func main() {
|
||||
Root: "root",
|
||||
SessionId: sessionId,
|
||||
OutputSize: uint32(size),
|
||||
FlagCount: uint32(16),
|
||||
FlagCount: uint32(17),
|
||||
}
|
||||
|
||||
resourceDir := scriptDir
|
||||
|
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module git.grassecon.net/urdt/ussd
|
||||
go 1.22.6
|
||||
|
||||
require (
|
||||
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240926120105-89b0529cf7ac
|
||||
git.defalsify.org/vise.git v0.2.0
|
||||
github.com/alecthomas/assert/v2 v2.2.2
|
||||
github.com/peteole/testdata-loader v0.3.0
|
||||
gopkg.in/leonelquinteros/gotext.v1 v1.3.1
|
||||
|
2
go.sum
2
go.sum
@ -2,6 +2,8 @@ git.defalsify.org/vise.git v0.1.0-rc.3.0.20240923162317-c20d557a3dbb h1:6P4kxihc
|
||||
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240923162317-c20d557a3dbb/go.mod h1:JDguWmcoWBdsnpw7PUjVZAEpdC/ubBmjdUBy3tjP63M=
|
||||
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240926120105-89b0529cf7ac h1:D4KI22KWXT8S66sHIjWhTBX6SXRfnd7j8VErq3PPbok=
|
||||
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240926120105-89b0529cf7ac/go.mod h1:JDguWmcoWBdsnpw7PUjVZAEpdC/ubBmjdUBy3tjP63M=
|
||||
git.defalsify.org/vise.git v0.2.0 h1:X2ZgiGRq4C+9qOlDMP0b/oE5QHjVQNT4aEFZB88ST0Q=
|
||||
git.defalsify.org/vise.git v0.2.0/go.mod h1:JDguWmcoWBdsnpw7PUjVZAEpdC/ubBmjdUBy3tjP63M=
|
||||
github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=
|
||||
github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
|
||||
github.com/alecthomas/participle/v2 v2.0.0 h1:Fgrq+MbuSsJwIkw3fEj9h75vDP0Er5JzepJ0/HNHv0g=
|
||||
|
@ -660,11 +660,28 @@ func (h *Handlers) CheckBalance(ctx context.Context, sym string, input []byte) (
|
||||
return res, err
|
||||
}
|
||||
|
||||
// check if the user has an active sym
|
||||
activeSym, err := store.ReadEntry(ctx, sessionId, utils.DATA_ACTIVE_SYM)
|
||||
if err != nil {
|
||||
if db.IsNotFound(err) {
|
||||
logg.Printf(logging.LVL_INFO, "Using the default sym to fetch balance")
|
||||
balance, err := h.accountService.CheckBalance(string(publicKey))
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
res.Content = balance
|
||||
|
||||
return res, nil
|
||||
}
|
||||
res.Content = balance
|
||||
}
|
||||
|
||||
activeBal, err := store.ReadEntry(ctx, sessionId, utils.DATA_ACTIVE_BAL)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
res.Content = fmt.Sprintf("%s %s", activeBal, activeSym)
|
||||
|
||||
return res, nil
|
||||
}
|
||||
@ -1123,6 +1140,10 @@ func (h *Handlers) ViewVoucher(ctx context.Context, sym string, input []byte) (r
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_TEMPORARY_BAL, []byte(matchedBalance))
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
res.Content = fmt.Sprintf("%s\n%s", matchedSymbol, matchedBalance)
|
||||
res.FlagReset = append(res.FlagReset, flag_incorrect_voucher)
|
||||
} else {
|
||||
@ -1149,18 +1170,33 @@ func (h *Handlers) SetVoucher(ctx context.Context, sym string, input []byte) (re
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
// get the current temporary balance
|
||||
temporaryBal, err := store.ReadEntry(ctx, sessionId, utils.DATA_TEMPORARY_BAL)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
// set the active symbol
|
||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_ACTIVE_SYM, []byte(temporarySym))
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
// set the active balance
|
||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_ACTIVE_BAL, []byte(temporaryBal))
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
// reset the temporary symbol
|
||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_TEMPORARY_SYM, []byte(""))
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
// reset the temporary balance
|
||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_TEMPORARY_BAL, []byte(""))
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
res.Content = string(temporarySym)
|
||||
|
||||
|
@ -26,6 +26,8 @@ const (
|
||||
DATA_VOUCHER_LIST
|
||||
DATA_TEMPORARY_SYM
|
||||
DATA_ACTIVE_SYM
|
||||
DATA_TEMPORARY_BAL
|
||||
DATA_ACTIVE_BAL
|
||||
)
|
||||
|
||||
func typToBytes(typ DataTyp) []byte {
|
||||
|
@ -12,5 +12,6 @@ flag,flag_invalid_amount,18,this is set when the given transaction amount is inv
|
||||
flag,flag_incorrect_pin,19,this is set when the provided PIN is invalid or does not match the current account's PIN
|
||||
flag,flag_valid_pin,20,this is set when the given PIN is valid
|
||||
flag,flag_allow_update,21,this is set to allow a user to update their profile data
|
||||
flag,flag_incorrect_voucher,22,this is set when the selected voucher is invalid
|
||||
flag,flag_single_edit,22,this is set to allow a user to edit a single profile item such as year of birth
|
||||
flag,flag_incorrect_date_format,23,this is set when the given year of birth is invalid
|
||||
flag,flag_incorrect_voucher,24,this is set when the selected voucher is invalid
|
||||
|
|
@ -1,3 +1,6 @@
|
||||
LOAD reset_incorrect 6
|
||||
CATCH incorrect_pin flag_incorrect_pin 1
|
||||
CATCH _ flag_account_authorized 0
|
||||
LOAD set_voucher 12
|
||||
MAP set_voucher
|
||||
MOUT back 0
|
||||
|
Loading…
Reference in New Issue
Block a user