From f6c613abd6eedd8b53ec7086c13d527052f2c256 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Wed, 18 Feb 2026 17:07:38 +0300 Subject: [PATCH] rename the func to match updated functionality --- handlers/application/mpesa.go | 12 ++++++------ handlers/application/pool_deposit.go | 12 ++++++------ handlers/application/send.go | 18 +++++++++--------- handlers/application/vouchers.go | 12 ++++++------ store/vouchers.go | 8 ++++---- store/vouchers_test.go | 8 ++++---- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/handlers/application/mpesa.go b/handlers/application/mpesa.go index d095bc1..82b63ed 100644 --- a/handlers/application/mpesa.go +++ b/handlers/application/mpesa.go @@ -51,8 +51,8 @@ func (h *MenuHandlers) GetMpesaMaxLimit(ctx context.Context, sym string, input [ } // Store the active transaction voucher data (from token) - if err := store.StoreTemporaryVoucher(ctx, h.userdataStore, sessionId, metadata); err != nil { - logg.ErrorCtxf(ctx, "failed on StoreTemporaryVoucher", "error", err) + if err := store.StoreTransactionVoucher(ctx, h.userdataStore, sessionId, metadata); err != nil { + logg.ErrorCtxf(ctx, "failed on StoreTransactionVoucher", "error", err) return res, err } @@ -265,9 +265,9 @@ func (h *MenuHandlers) GetMpesaPreview(ctx context.Context, sym string, input [] } // get the selected voucher - mpesaWithdrawalVoucher, err := store.GetTemporaryVoucherData(ctx, h.userdataStore, sessionId) + mpesaWithdrawalVoucher, err := store.GetTransactionVoucherData(ctx, h.userdataStore, sessionId) if err != nil { - logg.ErrorCtxf(ctx, "failed on GetTemporaryVoucherData", "error", err) + logg.ErrorCtxf(ctx, "failed on GetTransactionVoucherData", "error", err) return res, err } @@ -406,9 +406,9 @@ func (h *MenuHandlers) InitiateGetMpesa(ctx context.Context, sym string, input [ } // get the selected voucher - mpesaWithdrawalVoucher, err := store.GetTemporaryVoucherData(ctx, h.userdataStore, sessionId) + mpesaWithdrawalVoucher, err := store.GetTransactionVoucherData(ctx, h.userdataStore, sessionId) if err != nil { - logg.ErrorCtxf(ctx, "failed on GetTemporaryVoucherData", "error", err) + logg.ErrorCtxf(ctx, "failed on GetTransactionVoucherData", "error", err) return res, err } diff --git a/handlers/application/pool_deposit.go b/handlers/application/pool_deposit.go index b12b5d2..16336b8 100644 --- a/handlers/application/pool_deposit.go +++ b/handlers/application/pool_deposit.go @@ -83,8 +83,8 @@ func (h *MenuHandlers) PoolDepositMaxAmount(ctx context.Context, sym string, inp } // Store the pool deposit voucher data - if err := store.StoreTemporaryVoucher(ctx, h.userdataStore, sessionId, metadata); err != nil { - logg.ErrorCtxf(ctx, "failed on StoreTemporaryVoucher", "error", err) + if err := store.StoreTransactionVoucher(ctx, h.userdataStore, sessionId, metadata); err != nil { + logg.ErrorCtxf(ctx, "failed on StoreTransactionVoucher", "error", err) return res, err } @@ -119,9 +119,9 @@ func (h *MenuHandlers) ConfirmPoolDeposit(ctx context.Context, sym string, input userStore := h.userdataStore - poolDepositVoucher, err := store.GetTemporaryVoucherData(ctx, h.userdataStore, sessionId) + poolDepositVoucher, err := store.GetTransactionVoucherData(ctx, h.userdataStore, sessionId) if err != nil { - logg.ErrorCtxf(ctx, "failed on GetTemporaryVoucherData", "error", err) + logg.ErrorCtxf(ctx, "failed on GetTransactionVoucherData", "error", err) return res, err } @@ -179,9 +179,9 @@ func (h *MenuHandlers) InitiatePoolDeposit(ctx context.Context, sym string, inpu return res, err } - poolDepositVoucher, err := store.GetTemporaryVoucherData(ctx, h.userdataStore, sessionId) + poolDepositVoucher, err := store.GetTransactionVoucherData(ctx, h.userdataStore, sessionId) if err != nil { - logg.ErrorCtxf(ctx, "failed on GetTemporaryVoucherData", "error", err) + logg.ErrorCtxf(ctx, "failed on GetTransactionVoucherData", "error", err) return res, err } diff --git a/handlers/application/send.go b/handlers/application/send.go index b103168..13209a2 100644 --- a/handlers/application/send.go +++ b/handlers/application/send.go @@ -357,9 +357,9 @@ func (h *MenuHandlers) MaxAmount(ctx context.Context, sym string, input []byte) customVoucherValue, _ := strconv.ParseUint(string(customVoucherSelection), 0, 64) if customVoucherValue == 1 { // use the custom voucher - customTransactionVoucher, err := store.GetTemporaryVoucherData(ctx, h.userdataStore, sessionId) + customTransactionVoucher, err := store.GetTransactionVoucherData(ctx, h.userdataStore, sessionId) if err != nil { - logg.ErrorCtxf(ctx, "failed on GetTemporaryVoucherData", "error", err) + logg.ErrorCtxf(ctx, "failed on GetTransactionVoucherData", "error", err) return res, err } @@ -625,15 +625,15 @@ func (h *MenuHandlers) ValidateAmount(ctx context.Context, sym string, input []b logg.ErrorCtxf(ctx, "failed to read activeBal entry with", "key", storedb.DATA_ACTIVE_BAL, "error", err) return res, err } - + customVoucherSelection, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_TRANSACTION_CUSTOM_VOUCHER_STATE) if err == nil { customVoucherValue, _ := strconv.ParseUint(string(customVoucherSelection), 0, 64) if customVoucherValue == 1 { // use the custom voucher - customTransactionVoucher, err := store.GetTemporaryVoucherData(ctx, h.userdataStore, sessionId) + customTransactionVoucher, err := store.GetTransactionVoucherData(ctx, h.userdataStore, sessionId) if err != nil { - logg.ErrorCtxf(ctx, "failed on GetTemporaryVoucherData", "error", err) + logg.ErrorCtxf(ctx, "failed on GetTransactionVoucherData", "error", err) return res, err } @@ -760,9 +760,9 @@ func (h *MenuHandlers) NormalTransactionPreview(ctx context.Context, sym string, customVoucherValue, _ := strconv.ParseUint(string(customVoucherSelection), 0, 64) if customVoucherValue == 1 { // use the custom voucher - customTransactionVoucher, err := store.GetTemporaryVoucherData(ctx, h.userdataStore, sessionId) + customTransactionVoucher, err := store.GetTransactionVoucherData(ctx, h.userdataStore, sessionId) if err != nil { - logg.ErrorCtxf(ctx, "failed on GetTemporaryVoucherData", "error", err) + logg.ErrorCtxf(ctx, "failed on GetTransactionVoucherData", "error", err) return res, err } @@ -811,9 +811,9 @@ func (h *MenuHandlers) InitiateNormalTransaction(ctx context.Context, sym string customVoucherValue, _ := strconv.ParseUint(string(customVoucherSelection), 0, 64) if customVoucherValue == 1 { // use the custom voucher - customTransactionVoucher, err := store.GetTemporaryVoucherData(ctx, h.userdataStore, sessionId) + customTransactionVoucher, err := store.GetTransactionVoucherData(ctx, h.userdataStore, sessionId) if err != nil { - logg.ErrorCtxf(ctx, "failed on GetTemporaryVoucherData", "error", err) + logg.ErrorCtxf(ctx, "failed on GetTransactionVoucherData", "error", err) return res, err } diff --git a/handlers/application/vouchers.go b/handlers/application/vouchers.go index 50dd86b..0828232 100644 --- a/handlers/application/vouchers.go +++ b/handlers/application/vouchers.go @@ -333,8 +333,8 @@ func (h *MenuHandlers) ViewVoucher(ctx context.Context, sym string, input []byte return res, nil } - if err := store.StoreTemporaryVoucher(ctx, h.userdataStore, sessionId, metadata); err != nil { - logg.ErrorCtxf(ctx, "failed on StoreTemporaryVoucher", "error", err) + if err := store.StoreTransactionVoucher(ctx, h.userdataStore, sessionId, metadata); err != nil { + logg.ErrorCtxf(ctx, "failed on StoreTransactionVoucher", "error", err) return res, err } @@ -362,9 +362,9 @@ func (h *MenuHandlers) SetVoucher(ctx context.Context, sym string, input []byte) } // Get temporary data - tempData, err := store.GetTemporaryVoucherData(ctx, h.userdataStore, sessionId) + tempData, err := store.GetTransactionVoucherData(ctx, h.userdataStore, sessionId) if err != nil { - logg.ErrorCtxf(ctx, "failed on GetTemporaryVoucherData", "error", err) + logg.ErrorCtxf(ctx, "failed on GetTransactionVoucherData", "error", err) return res, err } @@ -445,8 +445,8 @@ func (h *MenuHandlers) ValidateCreditVoucher(ctx context.Context, sym string, in } // Store the transaction voucher data - if err := store.StoreTemporaryVoucher(ctx, h.userdataStore, sessionId, metadata); err != nil { - logg.ErrorCtxf(ctx, "failed on StoreTemporaryVoucher", "error", err) + if err := store.StoreTransactionVoucher(ctx, h.userdataStore, sessionId, metadata); err != nil { + logg.ErrorCtxf(ctx, "failed on StoreTransactionVoucher", "error", err) return res, err } diff --git a/store/vouchers.go b/store/vouchers.go index ee4202e..dbdd326 100644 --- a/store/vouchers.go +++ b/store/vouchers.go @@ -185,8 +185,8 @@ func MatchVoucher(input, symbols, balances, decimals, addresses string) (symbol, return } -// StoreTemporaryVoucher saves voucher metadata as temporary entries in the DataStore. -func StoreTemporaryVoucher(ctx context.Context, store DataStore, sessionId string, data *dataserviceapi.TokenHoldings) error { +// StoreTransactionVoucher saves voucher metadata in the DataStore. +func StoreTransactionVoucher(ctx context.Context, store DataStore, sessionId string, data *dataserviceapi.TokenHoldings) error { tempData := fmt.Sprintf("%s,%s,%s,%s", data.TokenSymbol, data.Balance, data.TokenDecimals, data.TokenAddress) if err := store.WriteEntry(ctx, sessionId, storedb.DATA_TRANSACTION_CUSTOM_VOUCHER, []byte(tempData)); err != nil { @@ -196,8 +196,8 @@ func StoreTemporaryVoucher(ctx context.Context, store DataStore, sessionId strin return nil } -// GetTemporaryVoucherData retrieves temporary voucher metadata from the DataStore. -func GetTemporaryVoucherData(ctx context.Context, store DataStore, sessionId string) (*dataserviceapi.TokenHoldings, error) { +// GetTransactionVoucherData retrieves the transaction voucher metadata from the DataStore. +func GetTransactionVoucherData(ctx context.Context, store DataStore, sessionId string) (*dataserviceapi.TokenHoldings, error) { temp_data, err := store.ReadEntry(ctx, sessionId, storedb.DATA_TRANSACTION_CUSTOM_VOUCHER) if err != nil { return nil, err diff --git a/store/vouchers_test.go b/store/vouchers_test.go index ff756b6..ade788d 100644 --- a/store/vouchers_test.go +++ b/store/vouchers_test.go @@ -118,7 +118,7 @@ func TestStoreTemporaryVoucher(t *testing.T) { } // Execute the function being tested - err := StoreTemporaryVoucher(ctx, store, sessionId, voucherData) + err := StoreTransactionVoucher(ctx, store, sessionId, voucherData) require.NoError(t, err) // Verify stored data @@ -142,11 +142,11 @@ func TestGetTemporaryVoucherData(t *testing.T) { } // Store the data - err := StoreTemporaryVoucher(ctx, store, sessionId, tempData) + err := StoreTransactionVoucher(ctx, store, sessionId, tempData) require.NoError(t, err) // Execute the function being tested - data, err := GetTemporaryVoucherData(ctx, store, sessionId) + data, err := GetTransactionVoucherData(ctx, store, sessionId) require.NoError(t, err) require.Equal(t, tempData, data) } @@ -170,7 +170,7 @@ func TestUpdateVoucherData(t *testing.T) { TokenDecimals: "8", TokenAddress: "0xold", } - require.NoError(t, StoreTemporaryVoucher(ctx, store, sessionId, tempData)) + require.NoError(t, StoreTransactionVoucher(ctx, store, sessionId, tempData)) // Execute update err := UpdateVoucherData(ctx, store, sessionId, newData)