Compare commits

..

13 Commits

Author SHA1 Message Date
Carlosokumu
c81b17994a remove redundant cast on sanitized input 2025-03-24 16:03:30 +03:00
Carlosokumu
64b42b92ec Merge branch 'master' into fix-multiple-alias-requests 2025-03-24 16:00:20 +03:00
Carlosokumu
493f64157b sanitize alias hint before request 2025-03-24 15:59:13 +03:00
Carlosokumu
f6c9d54a65 register check-account_created handler
Some checks failed
release / docker (push) Has been cancelled
2025-03-24 12:39:03 +03:00
Carlosokumu
74c82de472 add check for if public key exists,then explicitly set flag_account_created
Some checks failed
release / docker (push) Has been cancelled
2025-03-24 12:29:40 +03:00
Carlosokumu
ddb8c6e748 add lowercase balance text translation 2025-03-22 18:39:05 +03:00
Carlosokumu
87ebd0029b chore: show default value when profile info is not set 2025-03-22 18:38:35 +03:00
Carlosokumu
b941cf2562 chore: match profile text prompt 2025-03-22 18:37:27 +03:00
Carlosokumu
1c8bda5ded fix(alias): remove alias requests made when a profile item is edited,show a default value when an alias is not set 2025-03-22 09:49:19 +03:00
alfred-mk
30cb800450 Added log lines for voucherlist
Some checks failed
release / docker (push) Has been cancelled
2025-03-21 13:58:30 +03:00
alfred-mk
680a1e9681 Use userstore for the voucher data instead of subprefixdb
Some checks failed
release / docker (push) Has been cancelled
2025-03-21 13:46:13 +03:00
Carlosokumu
b327b569fb fix failing test 2025-03-21 09:05:51 +03:00
alfred-mk
445ca0d0ff Add a default alias to remove bug in retrieving the data
Some checks failed
release / docker (push) Has been cancelled
2025-03-20 22:34:04 +03:00
8 changed files with 116 additions and 88 deletions

View File

@@ -8,6 +8,7 @@ import (
"path" "path"
"strconv" "strconv"
"strings" "strings"
"unicode"
"gopkg.in/leonelquinteros/gotext.v1" "gopkg.in/leonelquinteros/gotext.v1"
@@ -193,8 +194,9 @@ func (h *MenuHandlers) createAccountNoExist(ctx context.Context, sessionId strin
publicKey := r.PublicKey publicKey := r.PublicKey
data := map[storedb.DataTyp]string{ data := map[storedb.DataTyp]string{
storedb.DATA_TRACKING_ID: trackingId, storedb.DATA_TRACKING_ID: trackingId,
storedb.DATA_PUBLIC_KEY: publicKey, storedb.DATA_PUBLIC_KEY: publicKey,
storedb.DATA_ACCOUNT_ALIAS: "",
} }
store := h.userdataStore store := h.userdataStore
for key, value := range data { for key, value := range data {
@@ -241,6 +243,28 @@ func (h *MenuHandlers) CreateAccount(ctx context.Context, sym string, input []by
return res, nil return res, nil
} }
func (h *MenuHandlers) CheckAccountCreated(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
flag_account_created, _ := h.flagManager.GetFlag("flag_account_created")
store := h.userdataStore
sessionId, ok := ctx.Value("SessionId").(string)
if !ok {
return res, fmt.Errorf("missing session")
}
_, err := store.ReadEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY)
if err != nil {
if !db.IsNotFound(err) {
return res, err
}
return res, nil
}
res.FlagSet = append(res.FlagSet, flag_account_created)
return res, nil
}
// ResetValidPin resets the flag_valid_pin flag. // ResetValidPin resets the flag_valid_pin flag.
func (h *MenuHandlers) ResetValidPin(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (h *MenuHandlers) ResetValidPin(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result var res resource.Result
@@ -1120,7 +1144,12 @@ func (h *MenuHandlers) GetCurrentProfileInfo(ctx context.Context, sym string, in
logg.ErrorCtxf(ctx, "Failed to read account alias entry with", "key", "error", storedb.DATA_ACCOUNT_ALIAS, err) logg.ErrorCtxf(ctx, "Failed to read account alias entry with", "key", "error", storedb.DATA_ACCOUNT_ALIAS, err)
return res, err return res, err
} }
res.Content = string(profileInfo) alias := string(profileInfo)
if alias == "" {
res.Content = defaultValue
} else {
res.Content = alias
}
default: default:
break break
} }
@@ -1164,8 +1193,10 @@ func (h *MenuHandlers) GetProfileInfo(ctx context.Context, sym string, input []b
offerings := getEntryOrDefault(store.ReadEntry(ctx, sessionId, storedb.DATA_OFFERINGS)) offerings := getEntryOrDefault(store.ReadEntry(ctx, sessionId, storedb.DATA_OFFERINGS))
alias := getEntryOrDefault(store.ReadEntry(ctx, sessionId, storedb.DATA_ACCOUNT_ALIAS)) alias := getEntryOrDefault(store.ReadEntry(ctx, sessionId, storedb.DATA_ACCOUNT_ALIAS))
if alias != defaultValue { if alias != defaultValue && alias != "" {
alias = strings.Split(alias, ".")[0] alias = strings.Split(alias, ".")[0]
} else {
alias = defaultValue
} }
// Construct the full name // Construct the full name
@@ -1246,20 +1277,10 @@ func (h *MenuHandlers) UpdateAllProfileItems(ctx context.Context, sym string, in
if !ok { if !ok {
return res, fmt.Errorf("missing session") return res, fmt.Errorf("missing session")
} }
flag_alias_set, _ := h.flagManager.GetFlag("flag_alias_set")
aliasSet := h.st.MatchFlag(flag_alias_set, true)
err := h.insertProfileItems(ctx, sessionId, &res) err := h.insertProfileItems(ctx, sessionId, &res)
if err != nil { if err != nil {
return res, err return res, err
} }
//Only request an alias if it has not been set yet:
if !aliasSet {
err = h.constructAccountAlias(ctx)
if err != nil {
return res, err
}
}
return res, nil return res, nil
} }
@@ -1460,7 +1481,7 @@ func loadUserContent(ctx context.Context, activeSym string, balance string, alia
if alias != "" { if alias != "" {
content = l.Get("%s balance: %s\n", alias, balStr) content = l.Get("%s balance: %s\n", alias, balStr)
} else { } else {
content = l.Get("balance: %s\n", balStr) content = l.Get("Balance: %s\n", balStr)
} }
return content, nil return content, nil
} }
@@ -1482,6 +1503,24 @@ func (h *MenuHandlers) CheckBalance(ctx context.Context, sym string, input []byt
store := h.userdataStore store := h.userdataStore
// get the active sym and active balance
activeSym, err := store.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_SYM)
if err != nil {
logg.InfoCtxf(ctx, "could not find the activeSym in checkBalance:", "err", err)
if !db.IsNotFound(err) {
logg.ErrorCtxf(ctx, "failed to read activeSym entry with", "key", storedb.DATA_ACTIVE_SYM, "error", err)
return res, err
}
}
activeBal, err := store.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_BAL)
if err != nil {
if !db.IsNotFound(err) {
logg.ErrorCtxf(ctx, "failed to read activeBal entry with", "key", storedb.DATA_ACTIVE_BAL, "error", err)
return res, err
}
}
accAlias, err := store.ReadEntry(ctx, sessionId, storedb.DATA_ACCOUNT_ALIAS) accAlias, err := store.ReadEntry(ctx, sessionId, storedb.DATA_ACCOUNT_ALIAS)
if err != nil { if err != nil {
if !db.IsNotFound(err) { if !db.IsNotFound(err) {
@@ -1492,27 +1531,6 @@ func (h *MenuHandlers) CheckBalance(ctx context.Context, sym string, input []byt
alias = strings.Split(string(accAlias), ".")[0] alias = strings.Split(string(accAlias), ".")[0]
} }
// get the active sym and active balance
activeSym, err := store.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_SYM)
if err != nil {
fmt.Println("could not find the activeSym in checkBalance:", err)
if !db.IsNotFound(err) {
fmt.Println("the err:", err)
logg.ErrorCtxf(ctx, "failed to read activeSym entry with", "key", storedb.DATA_ACTIVE_SYM, "error", err)
return res, err
}
}
fmt.Println("The active data in CheckBalance:", string(activeSym))
activeBal, err := store.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_BAL)
if err != nil {
if !db.IsNotFound(err) {
logg.ErrorCtxf(ctx, "failed to read activeBal entry with", "key", storedb.DATA_ACTIVE_BAL, "error", err)
return res, err
}
}
content, err = loadUserContent(ctx, string(activeSym), string(activeBal), alias) content, err = loadUserContent(ctx, string(activeSym), string(activeBal), alias)
if err != nil { if err != nil {
return res, err return res, err
@@ -1942,12 +1960,8 @@ func (h *MenuHandlers) SetDefaultVoucher(ctx context.Context, sym string, input
flag_no_active_voucher, _ := h.flagManager.GetFlag("flag_no_active_voucher") flag_no_active_voucher, _ := h.flagManager.GetFlag("flag_no_active_voucher")
// check if the user has an active sym // check if the user has an active sym
activeSym, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_SYM) _, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_SYM)
fmt.Println("The activeSym in SetDefaultVoucher:", string(activeSym))
if err != nil { if err != nil {
fmt.Println("The err", err)
fmt.Println("Checking the data as no activeSym", "DATA_ACTIVE_SYM", storedb.DATA_ACTIVE_SYM)
if db.IsNotFound(err) { if db.IsNotFound(err) {
publicKey, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY) publicKey, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY)
if err != nil { if err != nil {
@@ -1958,25 +1972,12 @@ func (h *MenuHandlers) SetDefaultVoucher(ctx context.Context, sym string, input
// Fetch vouchers from the API using the public key // Fetch vouchers from the API using the public key
vouchersResp, err := h.accountService.FetchVouchers(ctx, string(publicKey)) vouchersResp, err := h.accountService.FetchVouchers(ctx, string(publicKey))
if err != nil { if err != nil {
fmt.Println("setting the flag_no_active_voucher")
res.FlagSet = append(res.FlagSet, flag_no_active_voucher) res.FlagSet = append(res.FlagSet, flag_no_active_voucher)
return res, nil return res, nil
} }
// vouchersResp := []dataserviceapi.TokenHoldings{
// {
// ContractAddress: "0xcB453B742Bc8BE1BAa03Ce1927e287788d0aF065",
// TokenSymbol: "PES",
// TokenDecimals: "6",
// Balance: "10000000",
// },
// }
fmt.Println("fetched user vouchers in SetDefaultVoucher", "public_key", string(publicKey), "vouchers", vouchersResp)
// Return if there is no voucher // Return if there is no voucher
if len(vouchersResp) == 0 { if len(vouchersResp) == 0 {
fmt.Println("setting the flag_no_active_voucher in SetDefaultVoucher")
res.FlagSet = append(res.FlagSet, flag_no_active_voucher) res.FlagSet = append(res.FlagSet, flag_no_active_voucher)
return res, nil return res, nil
} }
@@ -1991,14 +1992,10 @@ func (h *MenuHandlers) SetDefaultVoucher(ctx context.Context, sym string, input
// Scale down the balance // Scale down the balance
scaledBalance := store.ScaleDownBalance(defaultBal, defaultDec) scaledBalance := store.ScaleDownBalance(defaultBal, defaultDec)
fmt.Println("firstVoucher data", "defaultSym", defaultSym, "defaultBal", defaultBal, "defaultDec", defaultDec, "defaultAddr", defaultAddr)
// TODO: implement atomic transaction // TODO: implement atomic transaction
// set the active symbol // set the active symbol
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_ACTIVE_SYM, []byte(defaultSym)) err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_ACTIVE_SYM, []byte(defaultSym))
if err != nil { if err != nil {
fmt.Println("got an error in writing DATA_ACTIVE_SYM", "defaultSym", defaultSym)
logg.ErrorCtxf(ctx, "failed to write defaultSym entry with", "key", storedb.DATA_ACTIVE_SYM, "value", defaultSym, "error", err) logg.ErrorCtxf(ctx, "failed to write defaultSym entry with", "key", storedb.DATA_ACTIVE_SYM, "value", defaultSym, "error", err)
return res, err return res, err
} }
@@ -2024,7 +2021,7 @@ func (h *MenuHandlers) SetDefaultVoucher(ctx context.Context, sym string, input
return res, nil return res, nil
} }
fmt.Println("failed to read activeSym entry with", "key", storedb.DATA_ACTIVE_SYM, "error", err) logg.ErrorCtxf(ctx, "failed to read activeSym entry with", "key", storedb.DATA_ACTIVE_SYM, "error", err)
return res, err return res, err
} }
@@ -2055,16 +2052,7 @@ func (h *MenuHandlers) CheckVouchers(ctx context.Context, sym string, input []by
return res, nil return res, nil
} }
// vouchersResp := []dataserviceapi.TokenHoldings{ logg.InfoCtxf(ctx, "fetched user vouchers", "public_key", string(publicKey), "vouchers", vouchersResp)
// {
// ContractAddress: "0xcB453B742Bc8BE1BAa03Ce1927e287788d0aF065",
// TokenSymbol: "PES",
// TokenDecimals: "6",
// Balance: "10000000",
// },
// }
fmt.Println("fetched user vouchers", "public_key", string(publicKey), "vouchers", vouchersResp)
// check the current active sym and update the data // check the current active sym and update the data
activeSym, _ := userStore.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_SYM) activeSym, _ := userStore.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_SYM)
@@ -2101,12 +2089,10 @@ func (h *MenuHandlers) CheckVouchers(ctx context.Context, sym string, input []by
activeBal, _ := userStore.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_BAL) activeBal, _ := userStore.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_BAL)
activeAddr, _ := userStore.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_ADDRESS) activeAddr, _ := userStore.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_ADDRESS)
fmt.Println(ctx, "The active data in CheckVouchers:", "activeSym", string(activeSym), string(activeBal), string(activeAddr)) logg.InfoCtxf(ctx, "The active data in CheckVouchers:", "activeSym", string(activeSym), string(activeBal), string(activeAddr))
data := store.ProcessVouchers(vouchersResp) data := store.ProcessVouchers(vouchersResp)
fmt.Println(ctx, "The data in CheckVouchers:", "data", data)
// Store all voucher data // Store all voucher data
dataMap := map[storedb.DataTyp]string{ dataMap := map[storedb.DataTyp]string{
storedb.DATA_VOUCHER_SYMBOLS: data.Symbols, storedb.DATA_VOUCHER_SYMBOLS: data.Symbols,
@@ -2115,28 +2101,51 @@ func (h *MenuHandlers) CheckVouchers(ctx context.Context, sym string, input []by
storedb.DATA_VOUCHER_ADDRESSES: data.Addresses, storedb.DATA_VOUCHER_ADDRESSES: data.Addresses,
} }
// Write data entries
for key, value := range dataMap { for key, value := range dataMap {
if err := h.prefixDb.Put(ctx, []byte(storedb.ToBytes(key)), []byte(value)); err != nil { logg.InfoCtxf(ctx, "Writing data entry for sessionId: %s", sessionId, "key", key, "value", value)
return res, nil if err := userStore.WriteEntry(ctx, sessionId, key, []byte(value)); err != nil {
logg.ErrorCtxf(ctx, "Failed to write data entry for sessionId: %s", sessionId, "key", key, "error", err)
continue
} }
} }
// for key, value := range dataMap {
// if err := h.prefixDb.Put(ctx, []byte(storedb.ToBytes(key)), []byte(value)); err != nil {
// return res, nil
// }
// }
return res, nil return res, nil
} }
// GetVoucherList fetches the list of vouchers and formats them. // GetVoucherList fetches the list of vouchers and formats them.
func (h *MenuHandlers) GetVoucherList(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (h *MenuHandlers) GetVoucherList(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result var res resource.Result
sessionId, ok := ctx.Value("SessionId").(string)
// Read vouchers from the store if !ok {
voucherData, err := h.prefixDb.Get(ctx, storedb.ToBytes(storedb.DATA_VOUCHER_SYMBOLS)) return res, fmt.Errorf("missing session")
if err != nil {
logg.ErrorCtxf(ctx, "Failed to read the voucherData from prefixDb", "error", err)
return res, err
} }
userStore := h.userdataStore
// Read vouchers from the store
voucherData, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_VOUCHER_SYMBOLS)
logg.InfoCtxf(ctx, "reading GetVoucherList entries for sessionId: %s", sessionId, "key", storedb.DATA_VOUCHER_SYMBOLS, "voucherData", voucherData)
if err != nil {
logg.ErrorCtxf(ctx, "failed to read voucherData entires with", "key", storedb.DATA_VOUCHER_SYMBOLS, "error", err)
return res, err
}
// voucherData, err := h.prefixDb.Get(ctx, storedb.ToBytes(storedb.DATA_VOUCHER_SYMBOLS))
// if err != nil {
// logg.ErrorCtxf(ctx, "Failed to read the voucherData from prefixDb", "error", err)
// return res, err
// }
formattedData := h.ReplaceSeparatorFunc(string(voucherData)) formattedData := h.ReplaceSeparatorFunc(string(voucherData))
logg.InfoCtxf(ctx, "final output for sessionId: %s", sessionId, "key", storedb.DATA_VOUCHER_SYMBOLS, "formattedData", formattedData)
res.Content = string(formattedData) res.Content = string(formattedData)
return res, nil return res, nil
@@ -2163,7 +2172,7 @@ func (h *MenuHandlers) ViewVoucher(ctx context.Context, sym string, input []byte
return res, nil return res, nil
} }
metadata, err := store.GetVoucherData(ctx, h.prefixDb, inputStr) metadata, err := store.GetVoucherData(ctx, h.userdataStore, sessionId, inputStr)
if err != nil { if err != nil {
return res, fmt.Errorf("failed to retrieve voucher data: %v", err) return res, fmt.Errorf("failed to retrieve voucher data: %v", err)
} }
@@ -2523,7 +2532,8 @@ func (h *MenuHandlers) RequestCustomAlias(ctx context.Context, sym string, input
return res, nil return res, nil
} }
} }
aliasResult, err := h.accountService.RequestAlias(ctx, string(pubKey), string(input)) sanitizedInput := sanitizeAliasHint(string(input))
aliasResult, err := h.accountService.RequestAlias(ctx, string(pubKey), sanitizedInput)
if err != nil { if err != nil {
logg.ErrorCtxf(ctx, "failed to retrieve alias", "alias", string(aliasHint), "error_alias_request", err) logg.ErrorCtxf(ctx, "failed to retrieve alias", "alias", string(aliasHint), "error_alias_request", err)
return res, fmt.Errorf("Failed to retrieve alias: %s", err.Error()) return res, fmt.Errorf("Failed to retrieve alias: %s", err.Error())
@@ -2540,6 +2550,17 @@ func (h *MenuHandlers) RequestCustomAlias(ctx context.Context, sym string, input
return res, nil return res, nil
} }
func sanitizeAliasHint(input string) string {
for i, r := range input {
// Check if the character is a special character (non-alphanumeric)
if !unicode.IsLetter(r) && !unicode.IsNumber(r) {
return input[:i]
}
}
// If no special character is found, return the whole input
return input
}
// GetSuggestedAlias loads and displays the suggested alias name from the temporary value // GetSuggestedAlias loads and displays the suggested alias name from the temporary value
func (h *MenuHandlers) GetSuggestedAlias(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (h *MenuHandlers) GetSuggestedAlias(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result var res resource.Result

View File

@@ -1727,7 +1727,7 @@ func TestCheckBalance(t *testing.T) {
publicKey: "0X98765432109", publicKey: "0X98765432109",
activeSym: "ETH", activeSym: "ETH",
activeBal: "1.5", activeBal: "1.5",
expectedResult: resource.Result{Content: "balance: 1.50 ETH\n"}, expectedResult: resource.Result{Content: "Balance: 1.50 ETH\n"},
expectError: false, expectError: false,
}, },
} }

View File

@@ -128,6 +128,7 @@ func (ls *LocalHandlerService) GetHandler(accountService remote.AccountService)
ls.DbRs.AddLocalFunc("request_custom_alias", appHandlers.RequestCustomAlias) ls.DbRs.AddLocalFunc("request_custom_alias", appHandlers.RequestCustomAlias)
ls.DbRs.AddLocalFunc("get_suggested_alias", appHandlers.GetSuggestedAlias) ls.DbRs.AddLocalFunc("get_suggested_alias", appHandlers.GetSuggestedAlias)
ls.DbRs.AddLocalFunc("confirm_new_alias", appHandlers.ConfirmNewAlias) ls.DbRs.AddLocalFunc("confirm_new_alias", appHandlers.ConfirmNewAlias)
ls.DbRs.AddLocalFunc("check_account_created", appHandlers.CheckAccountCreated)
ls.first = appHandlers.Init ls.first = appHandlers.Init

View File

@@ -30,3 +30,7 @@ msgstr "Salio la Kikundi: 0.00"
msgid "Symbol: %s\nBalance: %s" msgid "Symbol: %s\nBalance: %s"
msgstr "Sarafu: %s\nSalio: %s" msgstr "Sarafu: %s\nSalio: %s"
msgid "%s balance: %s\n"
msgstr "%s salio: %s\n"

View File

@@ -1,2 +1,2 @@
Current alias: {{.get_current_profile_info}} Current alias: {{.get_current_profile_info}}
Edit my alias: Enter your preferred alias::

View File

@@ -1,2 +1,2 @@
Lakabu ya sasa: {{.get_current_profile_info}} Lakabu ya sasa: {{.get_current_profile_info}}
Badilisha Lakabu yangu: Weka lakabu unalopendelea::

View File

@@ -1,5 +1,7 @@
LOAD check_blocked_status 1 LOAD check_blocked_status 1
RELOAD check_blocked_status RELOAD check_blocked_status
LOAD check_account_created 2
RELOAD check_account_created
CATCH blocked_account flag_account_blocked 1 CATCH blocked_account flag_account_blocked 1
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

View File

@@ -68,7 +68,7 @@ func ScaleDownBalance(balance, decimals string) string {
} }
// GetVoucherData retrieves and matches voucher data // GetVoucherData retrieves and matches voucher data
func GetVoucherData(ctx context.Context, db storedb.PrefixDb, input string) (*dataserviceapi.TokenHoldings, error) { func GetVoucherData(ctx context.Context, store DataStore, sessionId string, input string) (*dataserviceapi.TokenHoldings, error) {
keys := []storedb.DataTyp{ keys := []storedb.DataTyp{
storedb.DATA_VOUCHER_SYMBOLS, storedb.DATA_VOUCHER_SYMBOLS,
storedb.DATA_VOUCHER_BALANCES, storedb.DATA_VOUCHER_BALANCES,
@@ -78,9 +78,9 @@ func GetVoucherData(ctx context.Context, db storedb.PrefixDb, input string) (*da
data := make(map[storedb.DataTyp]string) data := make(map[storedb.DataTyp]string)
for _, key := range keys { for _, key := range keys {
value, err := db.Get(ctx, storedb.ToBytes(key)) value, err := store.ReadEntry(ctx, sessionId, key)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to get prefix key %x: %v", storedb.ToBytes(key), err) return nil, fmt.Errorf("failed to get data key %x: %v", key, err)
} }
data[key] = string(value) data[key] = string(value)
} }