forked from urdt/ussd
Compare commits
80 Commits
wip-menu-s
...
menu-api-e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
353e24de33
|
||
|
|
1c57c95d93
|
||
|
|
128a354b34
|
||
|
|
81c4189c8e
|
||
|
|
b8e12e5215
|
||
|
|
4f04362835
|
||
|
|
f73b7a8b04
|
||
|
|
0be570ae2d
|
||
|
|
6a36bc43b5
|
||
|
|
1d27a88908
|
||
|
|
4889e6d18b
|
||
|
|
368c25125a
|
||
|
|
283793a2ae
|
||
|
|
bec7e5c69f
|
||
|
|
d638aba85e
|
||
|
|
df7788dd0b
|
||
|
|
4a62773098
|
||
|
|
26d315b032
|
||
|
|
1927544533
|
||
|
|
c641a0c669
|
||
|
|
952da86931
|
||
|
|
be6391686f
|
||
|
|
65794c1b20
|
||
| b058f9d770 | |||
|
|
2a93ea7a0c
|
||
|
|
f89b1acc6c | ||
| ddeafe015b | |||
|
|
1dc8b054eb
|
||
|
|
a3ff3be5b1
|
||
|
|
ea52a7cf0a
|
||
|
|
a993026380
|
||
|
|
4ee241714b
|
||
|
|
d7dc743fa2 | ||
|
|
c220cbb767
|
||
| 0dc322729f | |||
| 726d6dd338 | |||
| a8b202bd79 | |||
|
|
6dbd250694
|
||
|
|
cc760e7698
|
||
|
|
8648ea599c
|
||
|
|
77e4c5d43a
|
||
|
|
b15ba367c4
|
||
|
|
4db862bc97
|
||
|
|
6ad67f6adc
|
||
| 0caf82a27e | |||
| a430857309 | |||
|
|
2643c0c9ff
|
||
|
|
b8852e1ab3
|
||
|
|
0dea34daab
|
||
|
|
8057313c78
|
||
|
|
1bd96d0689
|
||
|
|
bbfe46f162
|
||
|
|
eff2cbde8b
|
||
|
|
5c85ecffd1
|
||
|
|
ad1f9233ca | ||
| e9fdd1ddbe | |||
|
|
8a03b05c90
|
||
|
|
c18c40b1b8 | ||
|
|
5a38b40eaf | ||
|
|
6112ca175f | ||
|
|
c7ebca4729
|
||
|
|
fa0070b9a8
|
||
|
|
4a447fbb45
|
||
|
|
cb32cfe9d8
|
||
|
|
cf4e80dcb8
|
||
|
|
c02d70eaa4
|
||
|
|
909d1f3409
|
||
|
|
66cf90f044
|
||
|
|
74d5da3987 | ||
|
|
f215159725
|
||
|
|
a6301163eb
|
||
|
|
a07fce527f | ||
|
|
ddc8f6dad1
|
||
|
|
c2b68231f5
|
||
|
|
3f3dbf414c
|
||
|
|
e4c3e9f015
|
||
|
|
9b71244391 | ||
|
|
ada1f26b68
|
||
|
|
935b777e57
|
||
|
|
19372c17f4
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,3 +4,5 @@ go.work*
|
|||||||
**/*/*.bin
|
**/*/*.bin
|
||||||
**/*/.state/
|
**/*/.state/
|
||||||
cmd/.state/
|
cmd/.state/
|
||||||
|
id_*
|
||||||
|
*.gdbm
|
||||||
|
|||||||
@@ -69,13 +69,11 @@ func main() {
|
|||||||
var resourceDir string
|
var resourceDir string
|
||||||
var size uint
|
var size uint
|
||||||
var engineDebug bool
|
var engineDebug bool
|
||||||
var stateDebug bool
|
|
||||||
var host string
|
var host string
|
||||||
var port uint
|
var port uint
|
||||||
flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from")
|
flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from")
|
||||||
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
|
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
|
||||||
flag.BoolVar(&engineDebug, "engine-debug", false, "use engine debug output")
|
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||||
flag.BoolVar(&stateDebug, "state-debug", false, "use engine debug output")
|
|
||||||
flag.UintVar(&size, "s", 160, "max size of output")
|
flag.UintVar(&size, "s", 160, "max size of output")
|
||||||
flag.StringVar(&host, "h", "127.0.0.1", "http host")
|
flag.StringVar(&host, "h", "127.0.0.1", "http host")
|
||||||
flag.UintVar(&port, "p", 7123, "http port")
|
flag.UintVar(&port, "p", 7123, "http port")
|
||||||
@@ -89,11 +87,9 @@ func main() {
|
|||||||
cfg := engine.Config{
|
cfg := engine.Config{
|
||||||
Root: "root",
|
Root: "root",
|
||||||
OutputSize: uint32(size),
|
OutputSize: uint32(size),
|
||||||
FlagCount: uint32(16),
|
FlagCount: uint32(128),
|
||||||
}
|
|
||||||
if stateDebug {
|
|
||||||
cfg.StateDebug = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if engineDebug {
|
if engineDebug {
|
||||||
cfg.EngineDebug = true
|
cfg.EngineDebug = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,14 +41,12 @@ func main() {
|
|||||||
var resourceDir string
|
var resourceDir string
|
||||||
var size uint
|
var size uint
|
||||||
var engineDebug bool
|
var engineDebug bool
|
||||||
var stateDebug bool
|
|
||||||
var host string
|
var host string
|
||||||
var port uint
|
var port uint
|
||||||
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
||||||
flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from")
|
flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from")
|
||||||
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
|
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
|
||||||
flag.BoolVar(&engineDebug, "engine-debug", false, "use engine debug output")
|
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||||
flag.BoolVar(&stateDebug, "state-debug", false, "use engine debug output")
|
|
||||||
flag.UintVar(&size, "s", 160, "max size of output")
|
flag.UintVar(&size, "s", 160, "max size of output")
|
||||||
flag.StringVar(&host, "h", "127.0.0.1", "http host")
|
flag.StringVar(&host, "h", "127.0.0.1", "http host")
|
||||||
flag.UintVar(&port, "p", 7123, "http port")
|
flag.UintVar(&port, "p", 7123, "http port")
|
||||||
@@ -62,11 +60,9 @@ func main() {
|
|||||||
cfg := engine.Config{
|
cfg := engine.Config{
|
||||||
Root: "root",
|
Root: "root",
|
||||||
OutputSize: uint32(size),
|
OutputSize: uint32(size),
|
||||||
FlagCount: uint32(16),
|
FlagCount: uint32(128),
|
||||||
}
|
|
||||||
if stateDebug {
|
|
||||||
cfg.StateDebug = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if engineDebug {
|
if engineDebug {
|
||||||
cfg.EngineDebug = true
|
cfg.EngineDebug = true
|
||||||
}
|
}
|
||||||
@@ -138,22 +134,26 @@ func main() {
|
|||||||
for true {
|
for true {
|
||||||
rqs, err = sh.Process(rqs)
|
rqs, err = sh.Process(rqs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "error in process: %v", "err", err)
|
||||||
fmt.Errorf("error in process: %v", err)
|
fmt.Errorf("error in process: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
rqs, err = sh.Output(rqs)
|
rqs, err = sh.Output(rqs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "error in output: %v", "err", err)
|
||||||
fmt.Errorf("error in output: %v", err)
|
fmt.Errorf("error in output: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
rqs, err = sh.Reset(rqs)
|
rqs, err = sh.Reset(rqs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "error in reset: %v", "err", err)
|
||||||
fmt.Errorf("error in reset: %v", err)
|
fmt.Errorf("error in reset: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
_, err = fmt.Scanln(&rqs.Input)
|
_, err = fmt.Scanln(&rqs.Input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "error in input", "err", err)
|
||||||
fmt.Errorf("error in input: %v", err)
|
fmt.Errorf("error in input: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,13 +30,11 @@ func main() {
|
|||||||
var resourceDir string
|
var resourceDir string
|
||||||
var size uint
|
var size uint
|
||||||
var engineDebug bool
|
var engineDebug bool
|
||||||
var stateDebug bool
|
|
||||||
var host string
|
var host string
|
||||||
var port uint
|
var port uint
|
||||||
flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from")
|
flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from")
|
||||||
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
|
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
|
||||||
flag.BoolVar(&engineDebug, "engine-debug", false, "use engine debug output")
|
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||||
flag.BoolVar(&stateDebug, "state-debug", false, "use engine debug output")
|
|
||||||
flag.UintVar(&size, "s", 160, "max size of output")
|
flag.UintVar(&size, "s", 160, "max size of output")
|
||||||
flag.StringVar(&host, "h", "127.0.0.1", "http host")
|
flag.StringVar(&host, "h", "127.0.0.1", "http host")
|
||||||
flag.UintVar(&port, "p", 7123, "http port")
|
flag.UintVar(&port, "p", 7123, "http port")
|
||||||
@@ -50,11 +48,9 @@ func main() {
|
|||||||
cfg := engine.Config{
|
cfg := engine.Config{
|
||||||
Root: "root",
|
Root: "root",
|
||||||
OutputSize: uint32(size),
|
OutputSize: uint32(size),
|
||||||
FlagCount: uint32(16),
|
FlagCount: uint32(128),
|
||||||
}
|
|
||||||
if stateDebug {
|
|
||||||
cfg.StateDebug = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if engineDebug {
|
if engineDebug {
|
||||||
cfg.EngineDebug = true
|
cfg.EngineDebug = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ func main() {
|
|||||||
var dbDir string
|
var dbDir string
|
||||||
var size uint
|
var size uint
|
||||||
var sessionId string
|
var sessionId string
|
||||||
var debug bool
|
var engineDebug bool
|
||||||
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
||||||
flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from")
|
flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from")
|
||||||
flag.BoolVar(&debug, "d", false, "use engine debug output")
|
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||||
flag.UintVar(&size, "s", 160, "max size of output")
|
flag.UintVar(&size, "s", 160, "max size of output")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ func main() {
|
|||||||
Root: "root",
|
Root: "root",
|
||||||
SessionId: sessionId,
|
SessionId: sessionId,
|
||||||
OutputSize: uint32(size),
|
OutputSize: uint32(size),
|
||||||
FlagCount: uint32(16),
|
FlagCount: uint32(128),
|
||||||
}
|
}
|
||||||
|
|
||||||
resourceDir := scriptDir
|
resourceDir := scriptDir
|
||||||
@@ -93,7 +93,7 @@ func main() {
|
|||||||
|
|
||||||
en := lhs.GetEngine()
|
en := lhs.GetEngine()
|
||||||
en = en.WithFirst(hl.Init)
|
en = en.WithFirst(hl.Init)
|
||||||
if debug {
|
if engineDebug {
|
||||||
en = en.WithDebug(nil)
|
en = en.WithDebug(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
CreateAccountURL = "https://custodial.sarafu.africa/api/account/create"
|
CreateAccountURL = "http://localhost:5003/api/v2/account/create"
|
||||||
TrackStatusURL = "https://custodial.sarafu.africa/api/track/"
|
BalanceURL = "https://custodial.sarafu.africa/api/account/status/"
|
||||||
BalanceURL = "https://custodial.sarafu.africa/api/account/status/"
|
TrackURL = "http://localhost:5003/api/v2/account/status"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
5
go.mod
5
go.mod
@@ -3,15 +3,12 @@ module git.grassecon.net/urdt/ussd
|
|||||||
go 1.22.6
|
go 1.22.6
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240922152136-7ea16f9137b4
|
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240923162317-c20d557a3dbb
|
||||||
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
|
||||||
golang.org/x/crypto v0.17.0
|
|
||||||
gopkg.in/leonelquinteros/gotext.v1 v1.3.1
|
gopkg.in/leonelquinteros/gotext.v1 v1.3.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require golang.org/x/sys v0.15.0 // indirect
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/alecthomas/participle/v2 v2.0.0 // indirect
|
github.com/alecthomas/participle/v2 v2.0.0 // indirect
|
||||||
github.com/alecthomas/repr v0.2.0 // indirect
|
github.com/alecthomas/repr v0.2.0 // indirect
|
||||||
|
|||||||
10
go.sum
10
go.sum
@@ -1,5 +1,5 @@
|
|||||||
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240922152136-7ea16f9137b4 h1:IMVUK9OkZ/QtYZPHgTZ+XUs5VQ4eIewIaTyVSCF/nAY=
|
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240923162317-c20d557a3dbb h1:6P4kxihcwMjDKzvUFC6t2zGNb7MDW+l/ACGlSAN1N8Y=
|
||||||
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240922152136-7ea16f9137b4/go.mod h1:JDguWmcoWBdsnpw7PUjVZAEpdC/ubBmjdUBy3tjP63M=
|
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240923162317-c20d557a3dbb/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=
|
||||||
@@ -28,12 +28,6 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
|
|||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
||||||
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
|
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
|
||||||
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
|
|
||||||
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
|
||||||
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
|
|
||||||
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
|
||||||
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
|
|
||||||
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/leonelquinteros/gotext.v1 v1.3.1 h1:8d9/fdTG0kn/B7NNGV1BsEyvektXFAbkMsTZS2sFSCc=
|
gopkg.in/leonelquinteros/gotext.v1 v1.3.1 h1:8d9/fdTG0kn/B7NNGV1BsEyvektXFAbkMsTZS2sFSCc=
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ func(f *BaseSessionHandler) Process(rqs RequestSession) (RequestSession, error)
|
|||||||
var err error
|
var err error
|
||||||
var ok bool
|
var ok bool
|
||||||
|
|
||||||
logg.InfoCtxf(rqs.Ctx, "new request", rqs)
|
logg.InfoCtxf(rqs.Ctx, "new request", "data", rqs)
|
||||||
|
|
||||||
rqs.Storage, err = f.provider.Get(rqs.Config.SessionId)
|
rqs.Storage, err = f.provider.Get(rqs.Config.SessionId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -82,18 +82,17 @@ func (ls *LocalHandlerService) GetHandler() (*ussd.Handlers, error) {
|
|||||||
ls.DbRs.AddLocalFunc("save_location", ussdHandlers.SaveLocation)
|
ls.DbRs.AddLocalFunc("save_location", ussdHandlers.SaveLocation)
|
||||||
ls.DbRs.AddLocalFunc("save_yob", ussdHandlers.SaveYob)
|
ls.DbRs.AddLocalFunc("save_yob", ussdHandlers.SaveYob)
|
||||||
ls.DbRs.AddLocalFunc("save_offerings", ussdHandlers.SaveOfferings)
|
ls.DbRs.AddLocalFunc("save_offerings", ussdHandlers.SaveOfferings)
|
||||||
ls.DbRs.AddLocalFunc("quit_with_balance", ussdHandlers.QuitWithBalance)
|
|
||||||
ls.DbRs.AddLocalFunc("reset_account_authorized", ussdHandlers.ResetAccountAuthorized)
|
ls.DbRs.AddLocalFunc("reset_account_authorized", ussdHandlers.ResetAccountAuthorized)
|
||||||
ls.DbRs.AddLocalFunc("reset_allow_update", ussdHandlers.ResetAllowUpdate)
|
ls.DbRs.AddLocalFunc("reset_allow_update", ussdHandlers.ResetAllowUpdate)
|
||||||
ls.DbRs.AddLocalFunc("get_profile_info", ussdHandlers.GetProfileInfo)
|
ls.DbRs.AddLocalFunc("get_profile_info", ussdHandlers.GetProfileInfo)
|
||||||
ls.DbRs.AddLocalFunc("verify_yob", ussdHandlers.VerifyYob)
|
ls.DbRs.AddLocalFunc("verify_yob", ussdHandlers.VerifyYob)
|
||||||
ls.DbRs.AddLocalFunc("reset_incorrect_date_format", ussdHandlers.ResetIncorrectYob)
|
ls.DbRs.AddLocalFunc("reset_incorrect_date_format", ussdHandlers.ResetIncorrectYob)
|
||||||
ls.DbRs.AddLocalFunc("set_reset_single_edit", ussdHandlers.SetResetSingleEdit)
|
|
||||||
ls.DbRs.AddLocalFunc("initiate_transaction", ussdHandlers.InitiateTransaction)
|
ls.DbRs.AddLocalFunc("initiate_transaction", ussdHandlers.InitiateTransaction)
|
||||||
ls.DbRs.AddLocalFunc("save_temporary_pin", ussdHandlers.SaveTemporaryPin)
|
ls.DbRs.AddLocalFunc("save_temporary_pin", ussdHandlers.SaveTemporaryPin)
|
||||||
ls.DbRs.AddLocalFunc("verify_new_pin", ussdHandlers.VerifyNewPin)
|
ls.DbRs.AddLocalFunc("verify_new_pin", ussdHandlers.VerifyNewPin)
|
||||||
ls.DbRs.AddLocalFunc("confirm_pin_change", ussdHandlers.ConfirmPinChange)
|
ls.DbRs.AddLocalFunc("confirm_pin_change", ussdHandlers.ConfirmPinChange)
|
||||||
ls.DbRs.AddLocalFunc("quit_with_help", ussdHandlers.QuitWithHelp)
|
ls.DbRs.AddLocalFunc("quit_with_help", ussdHandlers.QuitWithHelp)
|
||||||
|
ls.DbRs.AddLocalFunc("fetch_custodial_balances", ussdHandlers.FetchCustodialBalances)
|
||||||
|
|
||||||
return ussdHandlers, nil
|
return ussdHandlers, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
@@ -9,104 +10,175 @@ import (
|
|||||||
"git.grassecon.net/urdt/ussd/internal/models"
|
"git.grassecon.net/urdt/ussd/internal/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var apiResponse struct {
|
||||||
|
Ok bool `json:"ok"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
}
|
||||||
|
|
||||||
type AccountServiceInterface interface {
|
type AccountServiceInterface interface {
|
||||||
CheckBalance(publicKey string) (string, error)
|
CheckBalance(publicKey string) (*models.BalanceResponse, error)
|
||||||
CreateAccount() (*models.AccountResponse, error)
|
CreateAccount() (*OKResponse, *ErrResponse)
|
||||||
CheckAccountStatus(trackingId string) (string, error)
|
CheckAccountStatus(trackingId string) (*models.TrackStatusResponse, error)
|
||||||
|
TrackAccountStatus(publicKey string) (*OKResponse, *ErrResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountService struct {
|
type AccountService struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// CheckAccountStatus retrieves the status of an account transaction based on the provided tracking ID.
|
|
||||||
//
|
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// - trackingId: A unique identifier for the account.This should be obtained from a previous call to
|
// - trackingId: A unique identifier for the account.This should be obtained from a previous call to
|
||||||
// CreateAccount or a similar function that returns an AccountResponse. The `trackingId` field in the
|
// CreateAccount or a similar function that returns an AccountResponse. The `trackingId` field in the
|
||||||
// AccountResponse struct can be used here to check the account status during a transaction.
|
// AccountResponse struct can be used here to check the account status during a transaction.
|
||||||
//
|
//
|
||||||
//
|
|
||||||
// Returns:
|
// Returns:
|
||||||
// - string: The status of the transaction as a string. If there is an error during the request or processing, this will be an empty string.
|
// - string: The status of the transaction as a string. If there is an error during the request or processing, this will be an empty string.
|
||||||
// - error: An error if any occurred during the HTTP request, reading the response, or unmarshalling the JSON data.
|
// - error: An error if any occurred during the HTTP request, reading the response, or unmarshalling the JSON data.
|
||||||
// If no error occurs, this will be nil.
|
// If no error occurs, this will be nil
|
||||||
//
|
func (as *AccountService) CheckAccountStatus(trackingId string) (*models.TrackStatusResponse, error) {
|
||||||
func (as *AccountService) CheckAccountStatus(trackingId string) (string, error) {
|
resp, err := http.Get(config.BalanceURL + trackingId)
|
||||||
resp, err := http.Get(config.TrackStatusURL + trackingId)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
body, err := io.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var trackResp models.TrackStatusResponse
|
var trackResp models.TrackStatusResponse
|
||||||
err = json.Unmarshal(body, &trackResp)
|
err = json.Unmarshal(body, &trackResp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
return &trackResp, nil
|
||||||
|
|
||||||
status := trackResp.Result.Transaction.Status
|
|
||||||
|
|
||||||
return status, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (as *AccountService) TrackAccountStatus(publicKey string) (*OKResponse, *ErrResponse) {
|
||||||
|
var errResponse ErrResponse
|
||||||
|
var okResponse OKResponse
|
||||||
|
var err error
|
||||||
|
// Construct the URL with the path parameter
|
||||||
|
url := fmt.Sprintf("%s/%s", config.TrackURL, publicKey)
|
||||||
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
errResponse.Description = err.Error()
|
||||||
|
return nil, &errResponse
|
||||||
|
}
|
||||||
|
// Set headers
|
||||||
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
req.Header.Set("X-GE-KEY", "xd")
|
||||||
|
|
||||||
|
// Send the request
|
||||||
|
resp, err := http.DefaultClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
errResponse.Description = err.Error()
|
||||||
|
return nil, &errResponse
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
// Read the response body
|
||||||
|
body, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
errResponse.Description = err.Error()
|
||||||
|
return nil, &errResponse
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 2: Unmarshal into the generic struct
|
||||||
|
err = json.Unmarshal([]byte(body), &apiResponse)
|
||||||
|
if err != nil {
|
||||||
|
errResponse.Description = err.Error()
|
||||||
|
return nil, &errResponse
|
||||||
|
}
|
||||||
|
if apiResponse.Ok {
|
||||||
|
err = json.Unmarshal([]byte(body), &okResponse)
|
||||||
|
if err != nil {
|
||||||
|
errResponse.Description = err.Error()
|
||||||
|
return nil, &errResponse
|
||||||
|
}
|
||||||
|
return &okResponse, nil
|
||||||
|
} else {
|
||||||
|
err := json.Unmarshal([]byte(body), &errResponse)
|
||||||
|
if err != nil {
|
||||||
|
errResponse.Description = err.Error()
|
||||||
|
return nil, &errResponse
|
||||||
|
}
|
||||||
|
return nil, &errResponse
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// CheckBalance retrieves the balance for a given public key from the custodial balance API endpoint.
|
// CheckBalance retrieves the balance for a given public key from the custodial balance API endpoint.
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// - publicKey: The public key associated with the account whose balance needs to be checked.
|
// - publicKey: The public key associated with the account whose balance needs to be checked.
|
||||||
func (as *AccountService) CheckBalance(publicKey string) (string, error) {
|
func (as *AccountService) CheckBalance(publicKey string) (*models.BalanceResponse, error) {
|
||||||
|
|
||||||
resp, err := http.Get(config.BalanceURL + publicKey)
|
resp, err := http.Get(config.BalanceURL + publicKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "0.0", err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
body, err := io.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "0.0", err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var balanceResp models.BalanceResponse
|
var balanceResp models.BalanceResponse
|
||||||
err = json.Unmarshal(body, &balanceResp)
|
err = json.Unmarshal(body, &balanceResp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "0.0", err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
return &balanceResp, nil
|
||||||
balance := balanceResp.Result.Balance
|
|
||||||
return balance, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateAccount creates a new account in the custodial system.
|
||||||
//CreateAccount creates a new account in the custodial system.
|
|
||||||
// Returns:
|
// Returns:
|
||||||
// - *models.AccountResponse: A pointer to an AccountResponse struct containing the details of the created account.
|
// - *models.AccountResponse: A pointer to an AccountResponse struct containing the details of the created account.
|
||||||
// If there is an error during the request or processing, this will be nil.
|
// If there is an error during the request or processing, this will be nil.
|
||||||
// - error: An error if any occurred during the HTTP request, reading the response, or unmarshalling the JSON data.
|
// - error: An error if any occurred during the HTTP request, reading the response, or unmarshalling the JSON data.
|
||||||
// If no error occurs, this will be nil.
|
// If no error occurs, this will be nil.
|
||||||
func (as *AccountService) CreateAccount() (*models.AccountResponse, error) {
|
func (as *AccountService) CreateAccount() (*OKResponse, *ErrResponse) {
|
||||||
resp, err := http.Post(config.CreateAccountURL, "application/json", nil)
|
|
||||||
|
var errResponse ErrResponse
|
||||||
|
var okResponse OKResponse
|
||||||
|
var err error
|
||||||
|
|
||||||
|
// Create a new request
|
||||||
|
req, err := http.NewRequest("POST", config.CreateAccountURL, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
errResponse.Description = err.Error()
|
||||||
|
return nil, &errResponse
|
||||||
|
}
|
||||||
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
req.Header.Set("X-GE-KEY", "xd")
|
||||||
|
|
||||||
|
resp, err := http.DefaultClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
errResponse.Description = err.Error()
|
||||||
|
return nil, &errResponse
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
body, err := io.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
errResponse.Description = err.Error()
|
||||||
|
return nil, &errResponse
|
||||||
}
|
}
|
||||||
|
err = json.Unmarshal([]byte(body), &apiResponse)
|
||||||
var accountResp models.AccountResponse
|
|
||||||
err = json.Unmarshal(body, &accountResp)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, &errResponse
|
||||||
|
}
|
||||||
|
if apiResponse.Ok {
|
||||||
|
err = json.Unmarshal([]byte(body), &okResponse)
|
||||||
|
if err != nil {
|
||||||
|
errResponse.Description = err.Error()
|
||||||
|
return nil, &errResponse
|
||||||
|
}
|
||||||
|
return &okResponse, nil
|
||||||
|
} else {
|
||||||
|
err := json.Unmarshal([]byte(body), &errResponse)
|
||||||
|
if err != nil {
|
||||||
|
errResponse.Description = err.Error()
|
||||||
|
return nil, &errResponse
|
||||||
|
}
|
||||||
|
return nil, &errResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
return &accountResp, nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
60
internal/handlers/server/api.go
Normal file
60
internal/handlers/server/api.go
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
type (
|
||||||
|
OKResponse struct {
|
||||||
|
Ok bool `json:"ok"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
Result map[string]any `json:"result"`
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrResponse struct {
|
||||||
|
Ok bool `json:"ok"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
ErrCode string `json:"errorCode"`
|
||||||
|
}
|
||||||
|
|
||||||
|
TransferRequest struct {
|
||||||
|
From string `json:"from" validate:"required,eth_addr_checksum"`
|
||||||
|
To string `json:"to" validate:"required,eth_addr_checksum"`
|
||||||
|
TokenAddress string `json:"tokenAddress" validate:"required,eth_addr_checksum"`
|
||||||
|
Amount string `json:"amount" validate:"required,number,gt=0"`
|
||||||
|
}
|
||||||
|
|
||||||
|
PoolSwapRequest struct {
|
||||||
|
From string `json:"from" validate:"required,eth_addr_checksum"`
|
||||||
|
FromTokenAddress string `json:"fromTokenAddress" validate:"required,eth_addr_checksum"`
|
||||||
|
ToTokenAddress string `json:"toTokenAddress" validate:"required,eth_addr_checksum"`
|
||||||
|
PoolAddress string `json:"poolAddress" validate:"required,eth_addr_checksum"`
|
||||||
|
Amount string `json:"amount" validate:"required,number,gt=0"`
|
||||||
|
}
|
||||||
|
|
||||||
|
PoolDepositRequest struct {
|
||||||
|
From string `json:"from" validate:"required,eth_addr_checksum"`
|
||||||
|
TokenAddress string `json:"tokenAddress" validate:"required,eth_addr_checksum"`
|
||||||
|
PoolAddress string `json:"poolAddress" validate:"required,eth_addr_checksum"`
|
||||||
|
Amount string `json:"amount" validate:"required,number,gt=0"`
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountAddressParam struct {
|
||||||
|
Address string `param:"address" validate:"required,eth_addr_checksum"`
|
||||||
|
}
|
||||||
|
|
||||||
|
TrackingIDParam struct {
|
||||||
|
TrackingID string `param:"trackingId" validate:"required,uuid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
OTXByAccountRequest struct {
|
||||||
|
Address string `param:"address" validate:"required,eth_addr_checksum"`
|
||||||
|
PerPage int `query:"perPage" validate:"required,number,gt=0"`
|
||||||
|
Cursor int `query:"cursor" validate:"number"`
|
||||||
|
Next bool `query:"next"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ErrCodeInternalServerError = "E01"
|
||||||
|
ErrCodeInvalidJSON = "E02"
|
||||||
|
ErrCodeInvalidAPIKey = "E03"
|
||||||
|
ErrCodeValidationFailed = "E04"
|
||||||
|
ErrCodeAccountNotExists = "E05"
|
||||||
|
)
|
||||||
@@ -27,6 +27,8 @@ var (
|
|||||||
logg = logging.NewVanilla().WithDomain("ussdmenuhandler")
|
logg = logging.NewVanilla().WithDomain("ussdmenuhandler")
|
||||||
scriptDir = path.Join("services", "registration")
|
scriptDir = path.Join("services", "registration")
|
||||||
translationDir = path.Join(scriptDir, "locale")
|
translationDir = path.Join(scriptDir, "locale")
|
||||||
|
okResponse *server.OKResponse
|
||||||
|
errResponse *server.ErrResponse
|
||||||
)
|
)
|
||||||
|
|
||||||
// FlagManager handles centralized flag management
|
// FlagManager handles centralized flag management
|
||||||
@@ -117,17 +119,14 @@ func (h *Handlers) Init(ctx context.Context, sym string, input []byte) (resource
|
|||||||
func (h *Handlers) SetLanguage(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) SetLanguage(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
var res resource.Result
|
var res resource.Result
|
||||||
|
|
||||||
sym, _ = h.st.Where()
|
symbol, _ := h.st.Where()
|
||||||
|
code := strings.Split(symbol, "_")[1]
|
||||||
|
|
||||||
switch sym {
|
if !utils.IsValidISO639(code) {
|
||||||
case "set_default":
|
return res, nil
|
||||||
res.FlagSet = append(res.FlagSet, state.FLAG_LANG)
|
|
||||||
res.Content = "eng"
|
|
||||||
case "set_swa":
|
|
||||||
res.FlagSet = append(res.FlagSet, state.FLAG_LANG)
|
|
||||||
res.Content = "swa"
|
|
||||||
default:
|
|
||||||
}
|
}
|
||||||
|
res.FlagSet = append(res.FlagSet, state.FLAG_LANG)
|
||||||
|
res.Content = code
|
||||||
|
|
||||||
languageSetFlag, err := h.flagManager.GetFlag("flag_language_set")
|
languageSetFlag, err := h.flagManager.GetFlag("flag_language_set")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -139,11 +138,16 @@ func (h *Handlers) SetLanguage(ctx context.Context, sym string, input []byte) (r
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handlers) createAccountNoExist(ctx context.Context, sessionId string, res *resource.Result) error {
|
func (h *Handlers) createAccountNoExist(ctx context.Context, sessionId string, res *resource.Result) error {
|
||||||
accountResp, err := h.accountService.CreateAccount()
|
okResponse, errResponse := h.accountService.CreateAccount()
|
||||||
|
if errResponse != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
trackingId := okResponse.Result["trackingId"].(string)
|
||||||
|
publicKey := okResponse.Result["publicKey"].(string)
|
||||||
|
|
||||||
data := map[utils.DataTyp]string{
|
data := map[utils.DataTyp]string{
|
||||||
utils.DATA_TRACKING_ID: accountResp.Result.TrackingId,
|
utils.DATA_TRACKING_ID: trackingId,
|
||||||
utils.DATA_PUBLIC_KEY: accountResp.Result.PublicKey,
|
utils.DATA_PUBLIC_KEY: publicKey,
|
||||||
utils.DATA_CUSTODIAL_ID: accountResp.Result.CustodialId.String(),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, value := range data {
|
for key, value := range data {
|
||||||
@@ -155,7 +159,7 @@ func (h *Handlers) createAccountNoExist(ctx context.Context, sessionId string, r
|
|||||||
}
|
}
|
||||||
flag_account_created, _ := h.flagManager.GetFlag("flag_account_created")
|
flag_account_created, _ := h.flagManager.GetFlag("flag_account_created")
|
||||||
res.FlagSet = append(res.FlagSet, flag_account_created)
|
res.FlagSet = append(res.FlagSet, flag_account_created)
|
||||||
return err
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +198,6 @@ func (h *Handlers) SavePin(ctx context.Context, sym string, input []byte) (resou
|
|||||||
}
|
}
|
||||||
|
|
||||||
flag_incorrect_pin, _ := h.flagManager.GetFlag("flag_incorrect_pin")
|
flag_incorrect_pin, _ := h.flagManager.GetFlag("flag_incorrect_pin")
|
||||||
|
|
||||||
accountPIN := string(input)
|
accountPIN := string(input)
|
||||||
// Validate that the PIN is a 4-digit number
|
// Validate that the PIN is a 4-digit number
|
||||||
if !isValidPIN(accountPIN) {
|
if !isValidPIN(accountPIN) {
|
||||||
@@ -279,32 +282,6 @@ func (h *Handlers) ConfirmPinChange(ctx context.Context, sym string, input []byt
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetResetSingleEdit sets and resets flags to allow gradual editing of profile information.
|
|
||||||
func (h *Handlers) SetResetSingleEdit(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
||||||
var res resource.Result
|
|
||||||
|
|
||||||
menuOption := string(input)
|
|
||||||
|
|
||||||
flag_allow_update, _ := h.flagManager.GetFlag("flag_allow_update")
|
|
||||||
flag_single_edit, _ := h.flagManager.GetFlag("flag_single_edit")
|
|
||||||
|
|
||||||
switch menuOption {
|
|
||||||
case "2":
|
|
||||||
res.FlagReset = append(res.FlagReset, flag_allow_update)
|
|
||||||
res.FlagSet = append(res.FlagSet, flag_single_edit)
|
|
||||||
case "3":
|
|
||||||
res.FlagReset = append(res.FlagReset, flag_allow_update)
|
|
||||||
res.FlagSet = append(res.FlagSet, flag_single_edit)
|
|
||||||
case "4":
|
|
||||||
res.FlagReset = append(res.FlagReset, flag_allow_update)
|
|
||||||
res.FlagSet = append(res.FlagSet, flag_single_edit)
|
|
||||||
default:
|
|
||||||
res.FlagReset = append(res.FlagReset, flag_single_edit)
|
|
||||||
}
|
|
||||||
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// VerifyPin checks whether the confirmation PIN is similar to the account PIN
|
// VerifyPin checks whether the confirmation PIN is similar to the account PIN
|
||||||
// If similar, it sets the USERFLAG_PIN_SET flag allowing the user
|
// If similar, it sets the USERFLAG_PIN_SET flag allowing the user
|
||||||
// to access the main menu
|
// to access the main menu
|
||||||
@@ -319,8 +296,6 @@ func (h *Handlers) VerifyPin(ctx context.Context, sym string, input []byte) (res
|
|||||||
if !ok {
|
if !ok {
|
||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
|
|
||||||
//AccountPin, _ := utils.ReadEntry(ctx, h.userdataStore, sessionId, utils.DATA_ACCOUNT_PIN)
|
|
||||||
store := h.userdataStore
|
store := h.userdataStore
|
||||||
AccountPin, err := store.ReadEntry(ctx, sessionId, utils.DATA_ACCOUNT_PIN)
|
AccountPin, err := store.ReadEntry(ctx, sessionId, utils.DATA_ACCOUNT_PIN)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -356,7 +331,6 @@ func (h *Handlers) SaveFirstname(ctx context.Context, sym string, input []byte)
|
|||||||
if !ok {
|
if !ok {
|
||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(input) > 0 {
|
if len(input) > 0 {
|
||||||
firstName := string(input)
|
firstName := string(input)
|
||||||
store := h.userdataStore
|
store := h.userdataStore
|
||||||
@@ -400,7 +374,6 @@ func (h *Handlers) SaveYob(ctx context.Context, sym string, input []byte) (resou
|
|||||||
if !ok {
|
if !ok {
|
||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(input) == 4 {
|
if len(input) == 4 {
|
||||||
yob := string(input)
|
yob := string(input)
|
||||||
store := h.userdataStore
|
store := h.userdataStore
|
||||||
@@ -436,28 +409,18 @@ func (h *Handlers) SaveLocation(ctx context.Context, sym string, input []byte) (
|
|||||||
|
|
||||||
// SaveGender updates the gender in the gdbm with the provided input.
|
// SaveGender updates the gender in the gdbm with the provided input.
|
||||||
func (h *Handlers) SaveGender(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) SaveGender(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
|
symbol, _ := h.st.Where()
|
||||||
var res resource.Result
|
var res resource.Result
|
||||||
var err error
|
var err error
|
||||||
sessionId, ok := ctx.Value("SessionId").(string)
|
sessionId, ok := ctx.Value("SessionId").(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
|
gender := strings.Split(symbol, "_")[1]
|
||||||
if len(input) > 0 {
|
store := h.userdataStore
|
||||||
gender := string(input)
|
err = store.WriteEntry(ctx, sessionId, utils.DATA_GENDER, []byte(gender))
|
||||||
switch gender {
|
if err != nil {
|
||||||
case "1":
|
return res, nil
|
||||||
gender = "Male"
|
|
||||||
case "2":
|
|
||||||
gender = "Female"
|
|
||||||
case "3":
|
|
||||||
gender = "Unspecified"
|
|
||||||
}
|
|
||||||
store := h.userdataStore
|
|
||||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_GENDER, []byte(gender))
|
|
||||||
if err != nil {
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
@@ -471,7 +434,6 @@ func (h *Handlers) SaveOfferings(ctx context.Context, sym string, input []byte)
|
|||||||
if !ok {
|
if !ok {
|
||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(input) > 0 {
|
if len(input) > 0 {
|
||||||
offerings := string(input)
|
offerings := string(input)
|
||||||
store := h.userdataStore
|
store := h.userdataStore
|
||||||
@@ -497,7 +459,6 @@ func (h *Handlers) ResetAllowUpdate(ctx context.Context, sym string, input []byt
|
|||||||
// ResetAccountAuthorized resets the account authorization flag after a successful PIN entry.
|
// ResetAccountAuthorized resets the account authorization flag after a successful PIN entry.
|
||||||
func (h *Handlers) ResetAccountAuthorized(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) ResetAccountAuthorized(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
var res resource.Result
|
var res resource.Result
|
||||||
|
|
||||||
flag_account_authorized, _ := h.flagManager.GetFlag("flag_account_authorized")
|
flag_account_authorized, _ := h.flagManager.GetFlag("flag_account_authorized")
|
||||||
|
|
||||||
res.FlagReset = append(res.FlagReset, flag_account_authorized)
|
res.FlagReset = append(res.FlagReset, flag_account_authorized)
|
||||||
@@ -507,12 +468,10 @@ func (h *Handlers) ResetAccountAuthorized(ctx context.Context, sym string, input
|
|||||||
// CheckIdentifier retrieves the PublicKey from the JSON data file.
|
// CheckIdentifier retrieves the PublicKey from the JSON data file.
|
||||||
func (h *Handlers) CheckIdentifier(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) CheckIdentifier(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
var res resource.Result
|
var res resource.Result
|
||||||
|
|
||||||
sessionId, ok := ctx.Value("SessionId").(string)
|
sessionId, ok := ctx.Value("SessionId").(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
|
|
||||||
store := h.userdataStore
|
store := h.userdataStore
|
||||||
publicKey, _ := store.ReadEntry(ctx, sessionId, utils.DATA_PUBLIC_KEY)
|
publicKey, _ := store.ReadEntry(ctx, sessionId, utils.DATA_PUBLIC_KEY)
|
||||||
|
|
||||||
@@ -526,12 +485,10 @@ func (h *Handlers) CheckIdentifier(ctx context.Context, sym string, input []byte
|
|||||||
func (h *Handlers) Authorize(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) Authorize(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
var res resource.Result
|
var res resource.Result
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
sessionId, ok := ctx.Value("SessionId").(string)
|
sessionId, ok := ctx.Value("SessionId").(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
|
|
||||||
flag_incorrect_pin, _ := h.flagManager.GetFlag("flag_incorrect_pin")
|
flag_incorrect_pin, _ := h.flagManager.GetFlag("flag_incorrect_pin")
|
||||||
flag_account_authorized, _ := h.flagManager.GetFlag("flag_account_authorized")
|
flag_account_authorized, _ := h.flagManager.GetFlag("flag_account_authorized")
|
||||||
flag_allow_update, _ := h.flagManager.GetFlag("flag_allow_update")
|
flag_allow_update, _ := h.flagManager.GetFlag("flag_allow_update")
|
||||||
@@ -564,9 +521,7 @@ func (h *Handlers) Authorize(ctx context.Context, sym string, input []byte) (res
|
|||||||
// ResetIncorrectPin resets the incorrect pin flag after a new PIN attempt.
|
// ResetIncorrectPin resets the incorrect pin flag after a new PIN attempt.
|
||||||
func (h *Handlers) ResetIncorrectPin(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) ResetIncorrectPin(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
var res resource.Result
|
var res resource.Result
|
||||||
|
|
||||||
flag_incorrect_pin, _ := h.flagManager.GetFlag("flag_incorrect_pin")
|
flag_incorrect_pin, _ := h.flagManager.GetFlag("flag_incorrect_pin")
|
||||||
|
|
||||||
res.FlagReset = append(res.FlagReset, flag_incorrect_pin)
|
res.FlagReset = append(res.FlagReset, flag_incorrect_pin)
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
@@ -578,29 +533,27 @@ func (h *Handlers) CheckAccountStatus(ctx context.Context, sym string, input []b
|
|||||||
|
|
||||||
flag_account_success, _ := h.flagManager.GetFlag("flag_account_success")
|
flag_account_success, _ := h.flagManager.GetFlag("flag_account_success")
|
||||||
flag_account_pending, _ := h.flagManager.GetFlag("flag_account_pending")
|
flag_account_pending, _ := h.flagManager.GetFlag("flag_account_pending")
|
||||||
|
flag_api_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||||
|
|
||||||
sessionId, ok := ctx.Value("SessionId").(string)
|
sessionId, ok := ctx.Value("SessionId").(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
store := h.userdataStore
|
store := h.userdataStore
|
||||||
trackingId, err := store.ReadEntry(ctx, sessionId, utils.DATA_TRACKING_ID)
|
publicKey, err := store.ReadEntry(ctx, sessionId, utils.DATA_PUBLIC_KEY)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
okResponse, errResponse = h.accountService.TrackAccountStatus(string(publicKey))
|
||||||
status, err := h.accountService.CheckAccountStatus(string(trackingId))
|
if errResponse != nil {
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error checking account status:", err)
|
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
res.FlagReset = append(res.FlagReset, flag_api_error)
|
||||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_ACCOUNT_STATUS, []byte(status))
|
isActive := okResponse.Result["active"].(bool)
|
||||||
if err != nil {
|
if !ok {
|
||||||
return res, nil
|
return res, err
|
||||||
}
|
}
|
||||||
|
if isActive {
|
||||||
if status == "SUCCESS" {
|
|
||||||
res.FlagSet = append(res.FlagSet, flag_account_success)
|
res.FlagSet = append(res.FlagSet, flag_account_success)
|
||||||
res.FlagReset = append(res.FlagReset, flag_account_pending)
|
res.FlagReset = append(res.FlagReset, flag_account_pending)
|
||||||
} else {
|
} else {
|
||||||
@@ -640,7 +593,6 @@ func (h *Handlers) QuitWithHelp(ctx context.Context, sym string, input []byte) (
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// VerifyYob verifies the length of the given input
|
// VerifyYob verifies the length of the given input
|
||||||
func (h *Handlers) VerifyYob(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) VerifyYob(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
var res resource.Result
|
var res resource.Result
|
||||||
@@ -681,6 +633,8 @@ func (h *Handlers) CheckBalance(ctx context.Context, sym string, input []byte) (
|
|||||||
var res resource.Result
|
var res resource.Result
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
flag_api_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||||
|
|
||||||
sessionId, ok := ctx.Value("SessionId").(string)
|
sessionId, ok := ctx.Value("SessionId").(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
@@ -692,15 +646,60 @@ func (h *Handlers) CheckBalance(ctx context.Context, sym string, input []byte) (
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
balance, err := h.accountService.CheckBalance(string(publicKey))
|
balanceResponse, err := h.accountService.CheckBalance(string(publicKey))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
if !balanceResponse.Ok {
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_api_error)
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
res.FlagReset = append(res.FlagReset, flag_api_error)
|
||||||
|
balance := balanceResponse.Result.Balance
|
||||||
res.Content = balance
|
res.Content = balance
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *Handlers) FetchCustodialBalances(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
|
var res resource.Result
|
||||||
|
flag_api_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||||
|
|
||||||
|
sessionId, ok := ctx.Value("SessionId").(string)
|
||||||
|
if !ok {
|
||||||
|
return res, fmt.Errorf("missing session")
|
||||||
|
}
|
||||||
|
symbol, _ := h.st.Where()
|
||||||
|
balanceType := strings.Split(symbol, "_")[0]
|
||||||
|
|
||||||
|
store := h.userdataStore
|
||||||
|
publicKey, err := store.ReadEntry(ctx, sessionId, utils.DATA_PUBLIC_KEY)
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
balanceResponse, err := h.accountService.CheckBalance(string(publicKey))
|
||||||
|
if err != nil {
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
if !balanceResponse.Ok {
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_api_error)
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
res.FlagReset = append(res.FlagReset, flag_api_error)
|
||||||
|
balance := balanceResponse.Result.Balance
|
||||||
|
|
||||||
|
switch balanceType {
|
||||||
|
case "my":
|
||||||
|
res.Content = fmt.Sprintf("Your balance is %s", balance)
|
||||||
|
case "community":
|
||||||
|
res.Content = fmt.Sprintf("Your community balance is %s", balance)
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
// ValidateRecipient validates that the given input is a valid phone number.
|
// ValidateRecipient validates that the given input is a valid phone number.
|
||||||
func (h *Handlers) ValidateRecipient(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) ValidateRecipient(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
var res resource.Result
|
var res resource.Result
|
||||||
@@ -797,10 +796,11 @@ func (h *Handlers) MaxAmount(ctx context.Context, sym string, input []byte) (res
|
|||||||
store := h.userdataStore
|
store := h.userdataStore
|
||||||
publicKey, _ := store.ReadEntry(ctx, sessionId, utils.DATA_PUBLIC_KEY)
|
publicKey, _ := store.ReadEntry(ctx, sessionId, utils.DATA_PUBLIC_KEY)
|
||||||
|
|
||||||
balance, err := h.accountService.CheckBalance(string(publicKey))
|
balanceResp, err := h.accountService.CheckBalance(string(publicKey))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
balance := balanceResp.Result.Balance
|
||||||
|
|
||||||
res.Content = balance
|
res.Content = balance
|
||||||
|
|
||||||
@@ -819,18 +819,25 @@ func (h *Handlers) ValidateAmount(ctx context.Context, sym string, input []byte)
|
|||||||
}
|
}
|
||||||
|
|
||||||
flag_invalid_amount, _ := h.flagManager.GetFlag("flag_invalid_amount")
|
flag_invalid_amount, _ := h.flagManager.GetFlag("flag_invalid_amount")
|
||||||
|
flag_api_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||||
|
|
||||||
store := h.userdataStore
|
store := h.userdataStore
|
||||||
publicKey, _ := store.ReadEntry(ctx, sessionId, utils.DATA_PUBLIC_KEY)
|
publicKey, _ := store.ReadEntry(ctx, sessionId, utils.DATA_PUBLIC_KEY)
|
||||||
|
|
||||||
amountStr := string(input)
|
amountStr := string(input)
|
||||||
|
|
||||||
balanceStr, err := h.accountService.CheckBalance(string(publicKey))
|
balanceRes, err := h.accountService.CheckBalance(string(publicKey))
|
||||||
|
balanceStr := balanceRes.Result.Balance
|
||||||
|
|
||||||
|
if !balanceRes.Ok {
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_api_error)
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
res.Content = balanceStr
|
res.Content = balanceStr
|
||||||
|
res.FlagReset = append(res.FlagReset, flag_api_error)
|
||||||
|
|
||||||
// Parse the balance
|
// Parse the balance
|
||||||
balanceParts := strings.Split(balanceStr, " ")
|
balanceParts := strings.Split(balanceStr, " ")
|
||||||
@@ -922,36 +929,6 @@ func (h *Handlers) GetAmount(ctx context.Context, sym string, input []byte) (res
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// QuickWithBalance retrieves the balance for a given public key from the custodial balance API endpoint before
|
|
||||||
// gracefully exiting the session.
|
|
||||||
func (h *Handlers) QuitWithBalance(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
||||||
var res resource.Result
|
|
||||||
var err error
|
|
||||||
sessionId, ok := ctx.Value("SessionId").(string)
|
|
||||||
if !ok {
|
|
||||||
return res, fmt.Errorf("missing session")
|
|
||||||
}
|
|
||||||
|
|
||||||
flag_account_authorized, _ := h.flagManager.GetFlag("flag_account_authorized")
|
|
||||||
|
|
||||||
code := codeFromCtx(ctx)
|
|
||||||
l := gotext.NewLocale(translationDir, code)
|
|
||||||
l.AddDomain("default")
|
|
||||||
|
|
||||||
store := h.userdataStore
|
|
||||||
publicKey, err := store.ReadEntry(ctx, sessionId, utils.DATA_PUBLIC_KEY)
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
balance, err := h.accountService.CheckBalance(string(publicKey))
|
|
||||||
if err != nil {
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
res.Content = l.Get("Your account balance is %s", balance)
|
|
||||||
res.FlagReset = append(res.FlagReset, flag_account_authorized)
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// InitiateTransaction returns a confirmation and resets the transaction data
|
// InitiateTransaction returns a confirmation and resets the transaction data
|
||||||
// on the gdbm store.
|
// on the gdbm store.
|
||||||
func (h *Handlers) InitiateTransaction(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) InitiateTransaction(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
@@ -985,16 +962,23 @@ func (h *Handlers) InitiateTransaction(ctx context.Context, sym string, input []
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetProfileInfo retrieves and formats the profile information of a user from a Gdbm backed storage.
|
|
||||||
func (h *Handlers) GetProfileInfo(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) GetProfileInfo(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
var res resource.Result
|
var res resource.Result
|
||||||
|
var defaultValue string
|
||||||
sessionId, ok := ctx.Value("SessionId").(string)
|
sessionId, ok := ctx.Value("SessionId").(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
|
language, ok := ctx.Value("Language").(lang.Language)
|
||||||
// Default value when an entry is not found
|
if !ok {
|
||||||
defaultValue := "Not Provided"
|
return res, fmt.Errorf("value for 'Language' is not of type lang.Language")
|
||||||
|
}
|
||||||
|
code := language.Code
|
||||||
|
if code == "swa" {
|
||||||
|
defaultValue = "Haipo"
|
||||||
|
} else {
|
||||||
|
defaultValue = "Not Provided"
|
||||||
|
}
|
||||||
|
|
||||||
// Helper function to handle nil byte slices and convert them to string
|
// Helper function to handle nil byte slices and convert them to string
|
||||||
getEntryOrDefault := func(entry []byte, err error) string {
|
getEntryOrDefault := func(entry []byte, err error) string {
|
||||||
@@ -1031,12 +1015,23 @@ func (h *Handlers) GetProfileInfo(ctx context.Context, sym string, input []byte)
|
|||||||
return res, fmt.Errorf("invalid year of birth: %v", err)
|
return res, fmt.Errorf("invalid year of birth: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
switch language.Code {
|
||||||
// Format the result
|
case "eng":
|
||||||
res.Content = fmt.Sprintf(
|
res.Content = fmt.Sprintf(
|
||||||
"Name: %s\nGender: %s\nAge: %s\nLocation: %s\nYou provide: %s\n",
|
"Name: %s\nGender: %s\nAge: %s\nLocation: %s\nYou provide: %s\n",
|
||||||
name, gender, age, location, offerings,
|
name, gender, age, location, offerings,
|
||||||
)
|
)
|
||||||
|
case "swa":
|
||||||
|
res.Content = fmt.Sprintf(
|
||||||
|
"Jina: %s\nJinsia: %s\nUmri: %s\nEneo: %s\nUnauza: %s\n",
|
||||||
|
name, gender, age, location, offerings,
|
||||||
|
)
|
||||||
|
default:
|
||||||
|
res.Content = fmt.Sprintf(
|
||||||
|
"Name: %s\nGender: %s\nAge: %s\nLocation: %s\nYou provide: %s\n",
|
||||||
|
name, gender, age, location, offerings,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
|||||||
package mocks
|
package mocks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.grassecon.net/urdt/ussd/internal/handlers/server"
|
||||||
"git.grassecon.net/urdt/ussd/internal/models"
|
"git.grassecon.net/urdt/ussd/internal/models"
|
||||||
"github.com/stretchr/testify/mock"
|
"github.com/stretchr/testify/mock"
|
||||||
)
|
)
|
||||||
@@ -10,17 +11,40 @@ type MockAccountService struct {
|
|||||||
mock.Mock
|
mock.Mock
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockAccountService) CreateAccount() (*models.AccountResponse, error) {
|
func (m *MockAccountService) CreateAccount() (*server.OKResponse, *server.ErrResponse) {
|
||||||
args := m.Called()
|
args := m.Called()
|
||||||
return args.Get(0).(*models.AccountResponse), args.Error(1)
|
okResponse, ok := args.Get(0).(*server.OKResponse)
|
||||||
|
errResponse, err := args.Get(1).(*server.ErrResponse)
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
return okResponse, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err {
|
||||||
|
return nil, errResponse
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockAccountService) CheckBalance(publicKey string) (string, error) {
|
func (m *MockAccountService) CheckBalance(publicKey string) (*models.BalanceResponse, error) {
|
||||||
args := m.Called(publicKey)
|
args := m.Called(publicKey)
|
||||||
return args.String(0), args.Error(1)
|
return args.Get(0).(*models.BalanceResponse), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockAccountService) CheckAccountStatus(trackingId string) (string, error) {
|
func (m *MockAccountService) CheckAccountStatus(trackingId string) (*models.TrackStatusResponse, error) {
|
||||||
args := m.Called(trackingId)
|
args := m.Called(trackingId)
|
||||||
return args.String(0), args.Error(1)
|
return args.Get(0).(*models.TrackStatusResponse), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MockAccountService) TrackAccountStatus(publicKey string) (*server.OKResponse, *server.ErrResponse) {
|
||||||
|
args := m.Called(publicKey)
|
||||||
|
okResponse, ok := args.Get(0).(*server.OKResponse)
|
||||||
|
errResponse, err := args.Get(1).(*server.ErrResponse)
|
||||||
|
if ok {
|
||||||
|
return okResponse, nil
|
||||||
|
}
|
||||||
|
if err {
|
||||||
|
return nil, errResponse
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
type AccountResponse struct {
|
type AccountResponse struct {
|
||||||
Ok bool `json:"ok"`
|
Ok bool `json:"ok"`
|
||||||
Result struct {
|
Description string `json:"description"` // Include the description field
|
||||||
CustodialId json.Number `json:"custodialId"`
|
Result struct {
|
||||||
PublicKey string `json:"publicKey"`
|
PublicKey string `json:"publicKey"`
|
||||||
TrackingId string `json:"trackingId"`
|
TrackingId string `json:"trackingId"`
|
||||||
} `json:"result"`
|
} `json:"result"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
type TrackStatusResponse struct {
|
type TrackStatusResponse struct {
|
||||||
Ok bool `json:"ok"`
|
Ok bool `json:"ok"`
|
||||||
Result struct {
|
Result struct {
|
||||||
@@ -17,4 +16,4 @@ type TrackStatusResponse struct {
|
|||||||
TxType string `json:"txType"`
|
TxType string `json:"txType"`
|
||||||
}
|
}
|
||||||
} `json:"result"`
|
} `json:"result"`
|
||||||
}
|
}
|
||||||
|
|||||||
43
internal/storage/db.go
Normal file
43
internal/storage/db.go
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package storage
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"git.defalsify.org/vise.git/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DATATYPE_USERSUB = 64
|
||||||
|
)
|
||||||
|
|
||||||
|
type SubPrefixDb struct {
|
||||||
|
store db.Db
|
||||||
|
pfx []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSubPrefixDb(store db.Db, pfx []byte) *SubPrefixDb {
|
||||||
|
return &SubPrefixDb{
|
||||||
|
store: store,
|
||||||
|
pfx: pfx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func(s *SubPrefixDb) toKey(k []byte) []byte {
|
||||||
|
return append(s.pfx, k...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func(s *SubPrefixDb) Get(ctx context.Context, key []byte) ([]byte, error) {
|
||||||
|
s.store.SetPrefix(DATATYPE_USERSUB)
|
||||||
|
key = s.toKey(key)
|
||||||
|
v, err := s.store.Get(ctx, key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func(s *SubPrefixDb) Put(ctx context.Context, key []byte, val []byte) error {
|
||||||
|
s.store.SetPrefix(DATATYPE_USERSUB)
|
||||||
|
key = s.toKey(key)
|
||||||
|
return s.store.Put(ctx, key, val)
|
||||||
|
}
|
||||||
54
internal/storage/db_test.go
Normal file
54
internal/storage/db_test.go
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
package storage
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
memdb "git.defalsify.org/vise.git/db/mem"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSubPrefix(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
db := memdb.NewMemDb()
|
||||||
|
err := db.Connect(ctx, "")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
sdba := NewSubPrefixDb(db, []byte("tinkywinky"))
|
||||||
|
err = sdba.Put(ctx, []byte("foo"), []byte("dipsy"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
r, err := sdba.Get(ctx, []byte("foo"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !bytes.Equal(r, []byte("dipsy")) {
|
||||||
|
t.Fatalf("expected 'dipsy', got %s", r)
|
||||||
|
}
|
||||||
|
|
||||||
|
sdbb := NewSubPrefixDb(db, []byte("lala"))
|
||||||
|
r, err = sdbb.Get(ctx, []byte("foo"))
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("expected not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = sdbb.Put(ctx, []byte("foo"), []byte("pu"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
r, err = sdbb.Get(ctx, []byte("foo"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !bytes.Equal(r, []byte("pu")) {
|
||||||
|
t.Fatalf("expected 'pu', got %s", r)
|
||||||
|
}
|
||||||
|
|
||||||
|
r, err = sdba.Get(ctx, []byte("foo"))
|
||||||
|
if !bytes.Equal(r, []byte("dipsy")) {
|
||||||
|
t.Fatalf("expected 'dipsy', got %s", r)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,10 +5,6 @@ import (
|
|||||||
"git.defalsify.org/vise.git/persist"
|
"git.defalsify.org/vise.git/persist"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
DATATYPE_CUSTOM = 128
|
|
||||||
)
|
|
||||||
|
|
||||||
type Storage struct {
|
type Storage struct {
|
||||||
Persister *persist.Persister
|
Persister *persist.Persister
|
||||||
UserdataDb db.Db
|
UserdataDb db.Db
|
||||||
|
|||||||
11
internal/utils/isocode.go
Normal file
11
internal/utils/isocode.go
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
var isoCodes = map[string]bool{
|
||||||
|
"eng": true, // English
|
||||||
|
"swa": true, // Swahili
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsValidISO639(code string) bool {
|
||||||
|
return isoCodes[code]
|
||||||
|
}
|
||||||
1
services/registration/_catch
Normal file
1
services/registration/_catch
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Something went wrong.Please try again
|
||||||
1
services/registration/_catch.vis
Normal file
1
services/registration/_catch.vis
Normal file
@@ -0,0 +1 @@
|
|||||||
|
HALT
|
||||||
@@ -5,8 +5,10 @@ MOUT back 0
|
|||||||
HALT
|
HALT
|
||||||
LOAD validate_amount 64
|
LOAD validate_amount 64
|
||||||
RELOAD validate_amount
|
RELOAD validate_amount
|
||||||
|
CATCH api_failure flag_api_call_error 1
|
||||||
CATCH invalid_amount flag_invalid_amount 1
|
CATCH invalid_amount flag_invalid_amount 1
|
||||||
INCMP _ 0
|
INCMP _ 0
|
||||||
LOAD get_recipient 12
|
LOAD get_recipient 12
|
||||||
LOAD get_sender 64
|
LOAD get_sender 64
|
||||||
|
LOAD get_amount 12
|
||||||
INCMP transaction_pin *
|
INCMP transaction_pin *
|
||||||
|
|||||||
1
services/registration/api_failure
Normal file
1
services/registration/api_failure
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Failed to connect to the custodial service.Please try again.
|
||||||
5
services/registration/api_failure.vis
Normal file
5
services/registration/api_failure.vis
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
MOUT retry 0
|
||||||
|
MOUT quit 9
|
||||||
|
HALT
|
||||||
|
INCMP _ 0
|
||||||
|
INCMP quit 9
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
LOAD reset_account_authorized 0
|
LOAD reset_account_authorized 0
|
||||||
|
RELOAD reset_account_authorized
|
||||||
MOUT my_balance 1
|
MOUT my_balance 1
|
||||||
MOUT community_balance 2
|
MOUT community_balance 2
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
Your community balance is: 0.00SRF
|
{{.fetch_custodial_balances}}
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
LOAD reset_incorrect 0
|
LOAD reset_incorrect 6
|
||||||
|
LOAD fetch_custodial_balances 0
|
||||||
|
CATCH api_failure flag_api_call_error 1
|
||||||
|
MAP fetch_custodial_balances
|
||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
CATCH pin_entry flag_account_authorized 0
|
CATCH pin_entry flag_account_authorized 0
|
||||||
LOAD quit_with_balance 0
|
MOUT back 0
|
||||||
|
MOUT quit 9
|
||||||
HALT
|
HALT
|
||||||
|
INCMP _ 0
|
||||||
|
INCMP quit 9
|
||||||
|
|||||||
1
services/registration/edit_familyname_menu
Normal file
1
services/registration/edit_familyname_menu
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Edit family name
|
||||||
1
services/registration/edit_familyname_menu_swa
Normal file
1
services/registration/edit_familyname_menu_swa
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Weka jina la familia
|
||||||
@@ -2,19 +2,19 @@ LOAD reset_account_authorized 16
|
|||||||
LOAD reset_allow_update 0
|
LOAD reset_allow_update 0
|
||||||
RELOAD reset_allow_update
|
RELOAD reset_allow_update
|
||||||
MOUT edit_name 1
|
MOUT edit_name 1
|
||||||
MOUT edit_gender 2
|
MOUT edit_familyname 2
|
||||||
MOUT edit_yob 3
|
MOUT edit_gender 3
|
||||||
MOUT edit_location 4
|
MOUT edit_yob 4
|
||||||
MOUT edit_offerings 5
|
MOUT edit_location 5
|
||||||
MOUT view 6
|
MOUT edit_offerings 6
|
||||||
|
MOUT view 7
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
HALT
|
HALT
|
||||||
INCMP _ 0
|
INCMP my_account 0
|
||||||
LOAD set_reset_single_edit 0
|
|
||||||
RELOAD set_reset_single_edit
|
|
||||||
INCMP enter_name 1
|
INCMP enter_name 1
|
||||||
INCMP select_gender 2
|
INCMP enter_familyname 2
|
||||||
INCMP enter_yob 3
|
INCMP select_gender 3
|
||||||
INCMP enter_location 4
|
INCMP enter_yob 4
|
||||||
INCMP enter_offerings 5
|
INCMP enter_location 5
|
||||||
INCMP view_profile 6
|
INCMP enter_offerings 6
|
||||||
|
INCMP view_profile 7
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
LOAD save_firstname 0
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
|
CATCH profile_update_success flag_allow_update 1
|
||||||
|
LOAD save_familyname 0
|
||||||
|
RELOAD save_familyname
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
HALT
|
HALT
|
||||||
|
RELOAD save_familyname
|
||||||
INCMP _ 0
|
INCMP _ 0
|
||||||
INCMP select_gender *
|
INCMP pin_entry *
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Weka jina la familia
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
CATCH incorrect_date_format flag_incorrect_date_format 1
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
LOAD save_yob 0
|
CATCH profile_update_success flag_allow_update 1
|
||||||
CATCH update_success flag_allow_update 1
|
LOAD save_location 0
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
HALT
|
HALT
|
||||||
|
RELOAD save_location
|
||||||
INCMP _ 0
|
INCMP _ 0
|
||||||
LOAD save_location 0
|
INCMP pin_entry *
|
||||||
CATCH pin_entry flag_single_edit 1
|
|
||||||
INCMP enter_offerings *
|
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
|
CATCH profile_update_success flag_allow_update 1
|
||||||
|
LOAD save_firstname 0
|
||||||
|
RELOAD save_firstname
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
HALT
|
HALT
|
||||||
|
RELOAD save_firstname
|
||||||
INCMP _ 0
|
INCMP _ 0
|
||||||
INCMP enter_familyname *
|
INCMP pin_entry *
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
LOAD save_location 0
|
|
||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
CATCH update_success flag_allow_update 1
|
CATCH profile_update_success flag_allow_update 1
|
||||||
|
LOAD save_offerings 0
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
HALT
|
HALT
|
||||||
LOAD save_offerings 0
|
RELOAD save_offerings
|
||||||
INCMP _ 0
|
INCMP _ 0
|
||||||
INCMP pin_entry *
|
INCMP pin_entry *
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
LOAD save_gender 0
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
CATCH update_success flag_allow_update 1
|
CATCH profile_update_success flag_allow_update 1
|
||||||
|
LOAD save_yob 0
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
HALT
|
HALT
|
||||||
|
LOAD verify_yob 0
|
||||||
|
CATCH incorrect_date_format flag_incorrect_date_format 1
|
||||||
|
RELOAD save_yob
|
||||||
INCMP _ 0
|
INCMP _ 0
|
||||||
LOAD verify_yob 8
|
INCMP pin_entry *
|
||||||
LOAD save_yob 0
|
|
||||||
CATCH pin_entry flag_single_edit 1
|
|
||||||
INCMP enter_location *
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
LOAD check_balance 64
|
LOAD check_balance 64
|
||||||
RELOAD check_balance
|
RELOAD check_balance
|
||||||
|
CATCH api_failure flag_api_call_error 1
|
||||||
MAP check_balance
|
MAP check_balance
|
||||||
MOUT send 1
|
MOUT send 1
|
||||||
MOUT vouchers 2
|
MOUT vouchers 2
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ MOUT pin_options 5
|
|||||||
MOUT my_address 6
|
MOUT my_address 6
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
HALT
|
HALT
|
||||||
INCMP _ 0
|
INCMP main 0
|
||||||
INCMP edit_profile 1
|
INCMP edit_profile 1
|
||||||
INCMP change_language 2
|
INCMP change_language 2
|
||||||
INCMP balances 3
|
INCMP balances 3
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
Your balance is: 0.00 SRF
|
{{.fetch_custodial_balances}}
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
LOAD reset_incorrect 0
|
LOAD reset_incorrect 6
|
||||||
|
LOAD fetch_custodial_balances 0
|
||||||
|
CATCH api_failure flag_api_call_error 1
|
||||||
|
MAP fetch_custodial_balances
|
||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
CATCH pin_entry flag_account_authorized 0
|
CATCH pin_entry flag_account_authorized 0
|
||||||
LOAD quit_with_balance 0
|
MOUT back 0
|
||||||
|
MOUT quit 9
|
||||||
HALT
|
HALT
|
||||||
|
INCMP _ 0
|
||||||
|
INCMP quit 9
|
||||||
|
|||||||
@@ -14,3 +14,4 @@ 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_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_date_format,23,this is set when the given year of birth is invalid
|
||||||
|
flag,flag_api_call_error,25,this is set when communication to an external service fails
|
||||||
|
|||||||
|
1
services/registration/profile_update_success
Normal file
1
services/registration/profile_update_success
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Profile updated successfully
|
||||||
5
services/registration/profile_update_success.vis
Normal file
5
services/registration/profile_update_success.vis
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
MOUT back 0
|
||||||
|
MOUT quit 9
|
||||||
|
HALT
|
||||||
|
INCMP edit_profile 0
|
||||||
|
INCMP quit 9
|
||||||
1
services/registration/profile_update_success_swa
Normal file
1
services/registration/profile_update_success_swa
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Ombi la Kuweka wasifu limefanikiwa
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
CATCH select_language flag_language_set 0
|
CATCH select_language flag_language_set 0
|
||||||
CATCH terms flag_account_created 0
|
CATCH terms flag_account_created 0
|
||||||
LOAD check_account_status 0
|
LOAD check_account_status 0
|
||||||
|
RELOAD check_account_status
|
||||||
|
CATCH api_failure flag_api_call_error 1
|
||||||
CATCH account_pending flag_account_pending 1
|
CATCH account_pending flag_account_pending 1
|
||||||
CATCH create_pin flag_pin_set 0
|
CATCH create_pin flag_pin_set 0
|
||||||
CATCH main flag_account_success 1
|
CATCH main flag_account_success 1
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
LOAD save_familyname 0
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
CATCH update_success flag_allow_update 1
|
CATCH profile_update_success flag_allow_update 1
|
||||||
MOUT male 1
|
MOUT male 1
|
||||||
MOUT female 2
|
MOUT female 2
|
||||||
MOUT unspecified 3
|
MOUT unspecified 3
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
HALT
|
HALT
|
||||||
LOAD save_gender 0
|
|
||||||
CATCH pin_entry flag_single_edit 1
|
|
||||||
INCMP _ 0
|
INCMP _ 0
|
||||||
INCMP enter_yob 1
|
INCMP set_male 1
|
||||||
INCMP enter_yob 2
|
INCMP set_female 2
|
||||||
INCMP enter_yob 3
|
INCMP set_unspecified 3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
MOUT english 0
|
MOUT english 0
|
||||||
MOUT kiswahili 1
|
MOUT kiswahili 1
|
||||||
HALT
|
HALT
|
||||||
INCMP set_default 0
|
INCMP set_eng 0
|
||||||
INCMP set_swa 1
|
INCMP set_swa 1
|
||||||
INCMP . *
|
INCMP . *
|
||||||
|
|||||||
4
services/registration/set_female.vis
Normal file
4
services/registration/set_female.vis
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
LOAD save_gender 0
|
||||||
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
|
CATCH profile_update_success flag_allow_update 1
|
||||||
|
MOVE pin_entry
|
||||||
4
services/registration/set_male.vis
Normal file
4
services/registration/set_male.vis
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
LOAD save_gender 0
|
||||||
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
|
CATCH profile_update_success flag_allow_update 1
|
||||||
|
MOVE pin_entry
|
||||||
4
services/registration/set_unspecified.vis
Normal file
4
services/registration/set_unspecified.vis
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
LOAD save_gender 0
|
||||||
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
|
CATCH profile_update_success flag_allow_update 1
|
||||||
|
MOVE pin_entry
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
LOAD reset_incorrect 6
|
LOAD reset_incorrect 6
|
||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
CATCH _ flag_account_authorized 0
|
CATCH _ flag_account_authorized 0
|
||||||
LOAD get_amount 10
|
RELOAD get_amount
|
||||||
MAP get_amount
|
MAP get_amount
|
||||||
RELOAD get_recipient
|
RELOAD get_recipient
|
||||||
MAP get_recipient
|
MAP get_recipient
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
{{.get_recipient}} will receive {{.validate_amount}} from {{.get_sender}}
|
{{.get_recipient}} will receive {{.get_amount}} from {{.get_sender}}
|
||||||
Please enter your PIN to confirm:
|
Please enter your PIN to confirm:
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
MAP validate_amount
|
RELOAD get_amount
|
||||||
|
MAP get_amount
|
||||||
RELOAD get_recipient
|
RELOAD get_recipient
|
||||||
MAP get_recipient
|
MAP get_recipient
|
||||||
RELOAD get_sender
|
RELOAD get_sender
|
||||||
MAP get_sender
|
MAP get_sender
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
MOUT quit 9
|
MOUT quit 9
|
||||||
HALT
|
|
||||||
LOAD authorize_account 6
|
LOAD authorize_account 6
|
||||||
|
HALT
|
||||||
RELOAD authorize_account
|
RELOAD authorize_account
|
||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
INCMP _ 0
|
INCMP _ 0
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
{{.get_recipient}} atapokea {{.validate_amount}} kutoka kwa {{.get_sender}}
|
{{.get_recipient}} atapokea {{.get_amount}} kutoka kwa {{.get_sender}}
|
||||||
Tafadhali weka PIN yako kudhibitisha:
|
Tafadhali weka PIN yako kudhibitisha:
|
||||||
1
services/registration/view_menu_swa
Normal file
1
services/registration/view_menu_swa
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Angalia Wasifu
|
||||||
Reference in New Issue
Block a user