Compare commits

..

No commits in common. "672eebb8fb43ac8947730532a5d0830c1da93587" and "9ad7d5a5226619eac07e99bcd4ffe1f3ec89548b" have entirely different histories.

10 changed files with 9 additions and 53 deletions

View File

@ -87,7 +87,7 @@ func main() {
cfg := engine.Config{ cfg := engine.Config{
Root: "root", Root: "root",
OutputSize: uint32(size), OutputSize: uint32(size),
FlagCount: uint32(17), FlagCount: uint32(16),
} }
if engineDebug { if engineDebug {

View File

@ -60,7 +60,7 @@ func main() {
cfg := engine.Config{ cfg := engine.Config{
Root: "root", Root: "root",
OutputSize: uint32(size), OutputSize: uint32(size),
FlagCount: uint32(17), FlagCount: uint32(16),
} }
if engineDebug { if engineDebug {

View File

@ -48,7 +48,7 @@ func main() {
cfg := engine.Config{ cfg := engine.Config{
Root: "root", Root: "root",
OutputSize: uint32(size), OutputSize: uint32(size),
FlagCount: uint32(17), FlagCount: uint32(16),
} }
if engineDebug { if engineDebug {

View File

@ -40,7 +40,7 @@ func main() {
Root: "root", Root: "root",
SessionId: sessionId, SessionId: sessionId,
OutputSize: uint32(size), OutputSize: uint32(size),
FlagCount: uint32(17), FlagCount: uint32(16),
} }
resourceDir := scriptDir resourceDir := scriptDir

2
go.mod
View File

@ -3,7 +3,7 @@ module git.grassecon.net/urdt/ussd
go 1.22.6 go 1.22.6
require ( require (
git.defalsify.org/vise.git v0.2.0 git.defalsify.org/vise.git v0.1.0-rc.3.0.20240926120105-89b0529cf7ac
github.com/alecthomas/assert/v2 v2.2.2 github.com/alecthomas/assert/v2 v2.2.2
github.com/peteole/testdata-loader v0.3.0 github.com/peteole/testdata-loader v0.3.0
gopkg.in/leonelquinteros/gotext.v1 v1.3.1 gopkg.in/leonelquinteros/gotext.v1 v1.3.1

2
go.sum
View File

@ -2,8 +2,6 @@ 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.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 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.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 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=
github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ= github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
github.com/alecthomas/participle/v2 v2.0.0 h1:Fgrq+MbuSsJwIkw3fEj9h75vDP0Er5JzepJ0/HNHv0g= github.com/alecthomas/participle/v2 v2.0.0 h1:Fgrq+MbuSsJwIkw3fEj9h75vDP0Er5JzepJ0/HNHv0g=

View File

@ -660,28 +660,11 @@ func (h *Handlers) CheckBalance(ctx context.Context, sym string, input []byte) (
return res, err 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)) balance, err := h.accountService.CheckBalance(string(publicKey))
if err != nil { if err != nil {
return res, err
}
res.Content = balance
return res, nil 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 return res, nil
} }
@ -1140,10 +1123,6 @@ func (h *Handlers) ViewVoucher(ctx context.Context, sym string, input []byte) (r
if err != nil { if err != nil {
return res, err 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.Content = fmt.Sprintf("%s\n%s", matchedSymbol, matchedBalance)
res.FlagReset = append(res.FlagReset, flag_incorrect_voucher) res.FlagReset = append(res.FlagReset, flag_incorrect_voucher)
} else { } else {
@ -1170,33 +1149,18 @@ func (h *Handlers) SetVoucher(ctx context.Context, sym string, input []byte) (re
if err != nil { if err != nil {
return res, err 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 // set the active symbol
err = store.WriteEntry(ctx, sessionId, utils.DATA_ACTIVE_SYM, []byte(temporarySym)) err = store.WriteEntry(ctx, sessionId, utils.DATA_ACTIVE_SYM, []byte(temporarySym))
if err != nil { if err != nil {
return res, err 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 // reset the temporary symbol
err = store.WriteEntry(ctx, sessionId, utils.DATA_TEMPORARY_SYM, []byte("")) err = store.WriteEntry(ctx, sessionId, utils.DATA_TEMPORARY_SYM, []byte(""))
if err != nil { if err != nil {
return res, err 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) res.Content = string(temporarySym)

View File

@ -26,8 +26,6 @@ const (
DATA_VOUCHER_LIST DATA_VOUCHER_LIST
DATA_TEMPORARY_SYM DATA_TEMPORARY_SYM
DATA_ACTIVE_SYM DATA_ACTIVE_SYM
DATA_TEMPORARY_BAL
DATA_ACTIVE_BAL
) )
func typToBytes(typ DataTyp) []byte { func typToBytes(typ DataTyp) []byte {

View File

@ -12,6 +12,5 @@ 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_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_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_allow_update,21,this is set to allow a user to update their profile data
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_voucher,22,this is set when the selected voucher is invalid
flag,flag_incorrect_date_format,23,this is set when the given year of birth is invalid 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 flag flag_language_set 8 checks whether the user has set their prefered language
12 flag flag_incorrect_pin 19 this is set when the provided PIN is invalid or does not match the current account's PIN
13 flag flag_valid_pin 20 this is set when the given PIN is valid
14 flag flag_allow_update 21 this is set to allow a user to update their profile data
15 flag flag_single_edit flag_incorrect_voucher 22 this is set to allow a user to edit a single profile item such as year of birth this is set when the selected voucher is invalid
16 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

View File

@ -1,6 +1,3 @@
LOAD reset_incorrect 6
CATCH incorrect_pin flag_incorrect_pin 1
CATCH _ flag_account_authorized 0
LOAD set_voucher 12 LOAD set_voucher 12
MAP set_voucher MAP set_voucher
MOUT back 0 MOUT back 0