Compare commits

..

14 Commits

Author SHA1 Message Date
alfred-mk
5a9fdbd580 use the stored DATA_ACTIVE_POOL_ADDRESS or fall back to default config.DefaultPoolAddress() in loading the swapToList 2025-06-07 12:56:41 +03:00
alfred-mk
310f15d59d add a catch for the flag_api_call_error 2025-06-07 12:43:52 +03:00
alfred-mk
3bfc0169ee correctly set the flag_incorrect_pool flag 2025-06-07 05:59:19 +03:00
alfred-mk
5d8daf56bc add pool related functions 2025-06-07 04:41:48 +03:00
alfred-mk
6532dd89f4 add pool related helper functions, for storing, reading and updating pool data 2025-06-07 04:40:51 +03:00
alfred-mk
22cf59f82a add keys for the DATA_ACTIVE_POOL_NAME and DATA_ACTIVE_POOL_SYM 2025-06-07 04:40:03 +03:00
alfred-mk
b574db1c89 add the pool_set node that stores the selected pool as the default 2025-06-07 04:37:55 +03:00
alfred-mk
419a020346 add the view_pool node that requests for a PIN before setting the selected Pool 2025-06-07 04:37:08 +03:00
alfred-mk
57287183bd add the displayed menu item for the select_pool node 2025-06-07 04:36:13 +03:00
alfred-mk
3e08d19975 add the select_pool node that shows the current default pool 2025-06-07 04:35:37 +03:00
alfred-mk
626538f38e add the navigation to the select_pool node 2025-06-07 04:34:50 +03:00
alfred-mk
1eb51bf8f3 add the default swahili translation for the view pool node 2025-06-07 04:34:09 +03:00
alfred-mk
2f706c1c0f use updated sarafu-api package 2025-06-07 04:33:26 +03:00
alfred-mk
9a1d3c0176 remove misplaced CATCH for the flag_incorrect_pin 2025-06-07 03:34:56 +03:00
8 changed files with 12 additions and 33 deletions

2
go.mod
View File

@@ -3,7 +3,7 @@ module git.grassecon.net/grassrootseconomics/sarafu-vise
go 1.23.4
require (
git.defalsify.org/vise.git v0.3.2-0.20250528124150-03bf7bfc1b66
git.defalsify.org/vise.git v0.3.2-0.20250507135825-a170e8a79da0
git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20250417111317-2953f4c2f32e
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250606194235-b5ccaea57560
git.grassecon.net/grassrootseconomics/visedriver v0.9.0-beta.2.0.20250408094335-e2d1f65bb306

2
go.sum
View File

@@ -4,8 +4,6 @@ git.defalsify.org/vise.git v0.3.2-0.20250507135825-a170e8a79da0 h1:ByRD+b39zVOjO
git.defalsify.org/vise.git v0.3.2-0.20250507135825-a170e8a79da0/go.mod h1:flN+Gu+0BX0F6trZc5VpJcO4e6mj/+HUw0Z/UqVTFhk=
git.defalsify.org/vise.git v0.3.2-0.20250507172020-cb22240f1cb9 h1:4kjbYw25MHZe9fqSbujPzpFXrYutFfVipvLrcWYnYks=
git.defalsify.org/vise.git v0.3.2-0.20250507172020-cb22240f1cb9/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
git.defalsify.org/vise.git v0.3.2-0.20250528124150-03bf7bfc1b66 h1:hmtb2Q3lHxq+SXqG+Gn43pKhTRYx+sw5j1LpgBfXN1o=
git.defalsify.org/vise.git v0.3.2-0.20250528124150-03bf7bfc1b66/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20250417111317-2953f4c2f32e h1:DcC9qkNl9ny3hxQmsMK6W81+5R/j4ZwYUbvewMI/rlc=
git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20250417111317-2953f4c2f32e/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250428082711-5d221b8d565f h1:OAHCP3YR1C5h1WFnnEnLs5kn6jTxQHQYWYtQaMZJIMY=

View File

@@ -2820,7 +2820,7 @@ func (h *MenuHandlers) LoadSwapToList(ctx context.Context, sym string, input []b
return res, nil
}
// Get active pool address and symbol or fall back to default
// Get active pool address or fall back to default
var activePoolAddress []byte
activePoolAddress, err = userStore.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_POOL_ADDRESS)
if err != nil {
@@ -2839,24 +2839,6 @@ func (h *MenuHandlers) LoadSwapToList(ctx context.Context, sym string, input []b
}
}
var activePoolSymbol []byte
activePoolSymbol, err = userStore.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_POOL_SYM)
if err != nil {
if db.IsNotFound(err) {
defaultPoolSym := config.DefaultPoolName()
// store the default as the active pool symbol
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_ACTIVE_POOL_SYM, []byte(defaultPoolSym))
if err != nil {
logg.ErrorCtxf(ctx, "failed to write default Pool Symbol", "key", storedb.DATA_ACTIVE_POOL_SYM, "value", defaultPoolSym, "error", err)
return res, err
}
activePoolSymbol = []byte(defaultPoolSym)
} else {
logg.ErrorCtxf(ctx, "failed to read active Pool symbol", "key", storedb.DATA_ACTIVE_POOL_SYM, "error", err)
return res, err
}
}
// call the api using the ActivePoolAddress and ActiveVoucherAddress to check if it is part of the pool
r, err := h.accountService.CheckTokenInPool(ctx, string(activePoolAddress), string(activeAddress))
if err != nil {
@@ -2865,14 +2847,14 @@ func (h *MenuHandlers) LoadSwapToList(ctx context.Context, sym string, input []b
return res, err
}
logg.InfoCtxf(ctx, "CheckTokenInPool", "response", r, "active_pool_address", string(activePoolAddress), "active_symbol_address", string(activeAddress))
logg.InfoCtxf(ctx, "CheckTokenInPool", "response", r, "active_pool_address", activePoolAddress, "address", activeAddress)
if !r.CanSwapFrom {
res.FlagSet = append(res.FlagSet, flag_incorrect_voucher)
res.Content = l.Get(
"%s is not in %s. Please update your voucher and try again.",
activeSym,
activePoolSymbol,
config.DefaultPoolName(),
)
return res, nil
}
@@ -2956,11 +2938,10 @@ func (h *MenuHandlers) SwapMaxLimit(ctx context.Context, sym string, input []byt
}
// call the api using the ActivePoolAddress, ActiveSwapFromAddress, ActiveSwapToAddress and PublicKey to get the swap max limit
logg.InfoCtxf(ctx, "Call GetSwapFromTokenMaxLimit with:", "ActivePoolAddress", swapData.ActivePoolAddress, "ActiveSwapFromAddress", swapData.ActiveSwapFromAddress, "ActiveSwapToAddress", swapData.ActiveSwapToAddress, "publicKey", swapData.PublicKey)
r, err := h.accountService.GetSwapFromTokenMaxLimit(ctx, swapData.ActivePoolAddress, swapData.ActiveSwapFromAddress, swapData.ActiveSwapToAddress, swapData.PublicKey)
if err != nil {
res.FlagSet = append(res.FlagSet, flag_api_error)
logg.ErrorCtxf(ctx, "failed on GetSwapFromTokenMaxLimit", "error", err)
logg.ErrorCtxf(ctx, "failed on FetchTransactions", "error", err)
return res, err
}

View File

@@ -11,7 +11,7 @@
},
{
"input": "1",
"expectedContent": "Do you agree to terms and conditions?\nhttps://grassecon.org/tos\n\n1:Yes\n2:No"
"expectedContent": "Do you agree to terms and conditions?\nhttps://grassecon.org/pages/terms-and-conditions\n\n1:Yes\n2:No"
},
{
"input": "1",
@@ -31,7 +31,7 @@
},
{
"input": "1234",
"expectedContent": "Your account is being created. Thank you for using Sarafu. Goodbye!"
"expectedContent": "Your account is being created...Thank you for using Sarafu. Goodbye!"
}
]
},
@@ -44,7 +44,7 @@
},
{
"input": "1",
"expectedContent": "Do you agree to terms and conditions?\nhttps://grassecon.org/tos\n\n1:Yes\n2:No"
"expectedContent": "Do you agree to terms and conditions?\nhttps://grassecon.org/pages/terms-and-conditions\n\n1:Yes\n2:No"
},
{
"input": "2",

View File

@@ -1 +1 @@
Your account is being created.
Your account is being created...

View File

@@ -1,2 +1,2 @@
Do you agree to terms and conditions?
https://grassecon.org/tos
https://grassecon.org/pages/terms-and-conditions

View File

@@ -1,2 +1,2 @@
Kwa kutumia hii huduma umekubali sheria na masharti?
https://grassecon.org/tos
https://grassecon.org/pages/terms-and-conditions

View File

@@ -123,7 +123,7 @@ func GetTemporaryPoolData(ctx context.Context, store DataStore, sessionId string
// UpdatePoolData updates the active pool data in the DataStore.
func UpdatePoolData(ctx context.Context, store DataStore, sessionId string, data *dataserviceapi.PoolDetails) error {
logg.InfoCtxf(ctx, "UpdatePoolData", "data", data)
logg.TraceCtxf(ctx, "dtal", "data", data)
// Active pool data entry
activeEntries := map[storedb.DataTyp][]byte{
storedb.DATA_ACTIVE_POOL_NAME: []byte(data.PoolName),