wip-account-creation #4

Merged
lash merged 143 commits from wip-account-creation into master 2024-08-30 14:37:58 +02:00
6 changed files with 47 additions and 1 deletions
Showing only changes of commit 3501a79aea - Show all commits

View File

@ -101,6 +101,7 @@ func main() {
rfs.AddLocalFunc("reset_transaction_amount", ussdHandlers.ResetTransactionAmount)
rfs.AddLocalFunc("get_recipient", ussdHandlers.GetRecipient)
rfs.AddLocalFunc("get_sender", ussdHandlers.GetSender)
rfs.AddLocalFunc("get_amount", ussdHandlers.GetAmount)
rfs.AddLocalFunc("reset_incorrect", ussdHandlers.ResetIncorrectPin)
rfs.AddLocalFunc("save_firstname", ussdHandlers.SaveFirstname)
rfs.AddLocalFunc("save_familyname", ussdHandlers.SaveFamilyname)
@ -115,6 +116,7 @@ func main() {
rfs.AddLocalFunc("verify_yob", ussdHandlers.VerifyYob)
rfs.AddLocalFunc("reset_incorrect_date_format", ussdHandlers.ResetIncorrectYob)
rfs.AddLocalFunc("set_reset_single_edit", ussdHandlers.SetResetSingleEdit)
rfs.AddLocalFunc("initiate_transaction", ussdHandlers.InitiateTransaction)
cont, err := en.Init(ctx)
en.SetDebugger(engine.NewSimpleDebug(nil))

View File

@ -501,8 +501,9 @@ func (h *Handlers) TransactionReset(ctx context.Context, sym string, input []byt
return res, err
}
// reset the recipient
// reset the transaction
accountData["Recipient"] = ""
accountData["Amount"] = ""
err = h.accountFileHandler.WriteAccountData(accountData)
if err != nil {
@ -669,6 +670,21 @@ func (h *Handlers) GetSender(ctx context.Context, sym string, input []byte) (res
return res, nil
}
// GetAmount retrieves the amount from a JSON data file.
func (h *Handlers) GetAmount(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{}
accountData, err := h.accountFileHandler.ReadAccountData()
if err != nil {
return res, err
}
res.Content = accountData["Amount"]
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) {
@ -686,3 +702,13 @@ func (h *Handlers) QuitWithBalance(ctx context.Context, sym string, input []byte
res.FlagReset = append(res.FlagReset, models.USERFLAG_ACCOUNT_UNLOCKED)
return res, nil
}
func (h *Handlers) InitiateTransaction(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{}
// TODO
// Use the amount, recipient and sender to call the API and initialize the transaction
res.FlagReset = append(res.FlagReset, models.USERFLAG_ACCOUNT_UNLOCKED)
return res, nil
}

View File

@ -0,0 +1 @@
Your request has been sent. {{.get_recipient}} will receive {{.get_amount}} from {{.get_sender}}.

View File

@ -0,0 +1,12 @@
LOAD reset_incorrect 0
LOAD get_amount 10
MAP get_amount
RELOAD get_recipient
MAP get_recipient
RELOAD get_sender
MAP get_sender
LOAD initiate_transaction 0
RELOAD transaction_reset
MOUT quit 9
HALT
INCMP quit 9

View File

@ -0,0 +1 @@
Ombi lako limetumwa. {{.get_recipient}} atapokea {{.get_amount}} kutoka kwa {{.get_sender}}.

View File

@ -6,5 +6,9 @@ MAP get_sender
MOUT back 0
MOUT quit 9
HALT
LOAD unlock_account 1
RELOAD unlock_account
Alfred-mk marked this conversation as resolved Outdated
Outdated
Review

This stops and gets stuck on correct pin put:

124125 will receive 22 from 0xA780F64fC93D8e78C20c4120f9E18AeEBeaD9631
Please enter your PIN to confirm:
0:Back
9:quit
1234
[I] engine:engine.go:173 new VM execution with input    input=1234
[D] engine:engine.go:182 start new VM run       code=0008015f0130000804717569740139
[T] vm:runner.go:81 new vm run
[D] vm:runner.go:113 execute code       opcode=8, op=INCMP, code=015f0130000804717569740139
[D] vm:runner.go:114 state=moves: 44 idx: 0 flags: 0x081b09 path: root/main/send/amount/transaction_pin lang: eng (English)
[T] vm:runner.go:361 testing sym        sym=_, input=31323334
[D] vm:runner.go:113 execute code       opcode=8, op=INCMP, code=04717569740139
[D] vm:runner.go:114 state=moves: 44 idx: 0 flags: 0x091b09 path: root/main/send/amount/transaction_pin lang: eng (English)
[T] vm:runner.go:361 testing sym        sym=quit, input=31323334
[T] vm:runner.go:200 no code remaining but not terminating
[D] vm:runner.go:113 execute code       opcode=6, op=MOVE, code=065f6361746368
[D] vm:runner.go:114 state=moves: 44 idx: 0 flags: 0x091b09 path: root/main/send/amount/transaction_pin lang: eng (English)
[T] engine:persist.go:47 that's a wrap  engine={0xc000140b00 0xc0000721a0}
[D] persist:fs.go:70 saved state and cache      key=aaaaa, bytecode=, flags=091b09
loop exited with error: unexpected termination: open /srv/git/grassrootseconomics/urdt-ussd.git/services/registration/_catch.bin: no such file or directory

exit status 1

This stops and gets stuck on correct pin put: ``` 124125 will receive 22 from 0xA780F64fC93D8e78C20c4120f9E18AeEBeaD9631 Please enter your PIN to confirm: 0:Back 9:quit 1234 [I] engine:engine.go:173 new VM execution with input input=1234 [D] engine:engine.go:182 start new VM run code=0008015f0130000804717569740139 [T] vm:runner.go:81 new vm run [D] vm:runner.go:113 execute code opcode=8, op=INCMP, code=015f0130000804717569740139 [D] vm:runner.go:114 state=moves: 44 idx: 0 flags: 0x081b09 path: root/main/send/amount/transaction_pin lang: eng (English) [T] vm:runner.go:361 testing sym sym=_, input=31323334 [D] vm:runner.go:113 execute code opcode=8, op=INCMP, code=04717569740139 [D] vm:runner.go:114 state=moves: 44 idx: 0 flags: 0x091b09 path: root/main/send/amount/transaction_pin lang: eng (English) [T] vm:runner.go:361 testing sym sym=quit, input=31323334 [T] vm:runner.go:200 no code remaining but not terminating [D] vm:runner.go:113 execute code opcode=6, op=MOVE, code=065f6361746368 [D] vm:runner.go:114 state=moves: 44 idx: 0 flags: 0x091b09 path: root/main/send/amount/transaction_pin lang: eng (English) [T] engine:persist.go:47 that's a wrap engine={0xc000140b00 0xc0000721a0} [D] persist:fs.go:70 saved state and cache key=aaaaa, bytecode=, flags=091b09 loop exited with error: unexpected termination: open /srv/git/grassrootseconomics/urdt-ussd.git/services/registration/_catch.bin: no such file or directory exit status 1 ```
CATCH incorrect_pin 15 1
INCMP _ 0
INCMP quit 9
MOVE transaction_initiated