From 14737b5f1254fc5ee9ada948ab6e6811baf9d0f9 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Thu, 5 Dec 2024 17:58:51 +0300 Subject: [PATCH] Removed redundant naming of transfer related data --- common/db.go | 16 ++++++++-------- common/transfer_statements.go | 16 ++++++++-------- internal/handlers/ussd/menuhandler.go | 24 ++++++++++++------------ 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/common/db.go b/common/db.go index b8fdb51..5532dc9 100644 --- a/common/db.go +++ b/common/db.go @@ -37,14 +37,14 @@ const ( DATA_VOUCHER_BALANCES DATA_VOUCHER_DECIMALS DATA_VOUCHER_ADDRESSES - DATA_PREFIX_TX_SENDERS - DATA_PREFIX_TX_RECIPIENTS - DATA_PREFIX_TX_VALUES - DATA_PREFIX_TX_ADDRESSES - DATA_PREFIX_TX_HASHES - DATA_PREFIX_TX_DATES - DATA_PREFIX_TX_SYMBOLS - DATA_PREFIX_TX_DECIMALS + DATA_TX_SENDERS + DATA_TX_RECIPIENTS + DATA_TX_VALUES + DATA_TX_ADDRESSES + DATA_TX_HASHES + DATA_TX_DATES + DATA_TX_SYMBOLS + DATA_TX_DECIMALS ) var ( diff --git a/common/transfer_statements.go b/common/transfer_statements.go index 8567557..4e6f66b 100644 --- a/common/transfer_statements.go +++ b/common/transfer_statements.go @@ -57,7 +57,7 @@ func ProcessTransfers(transfers []dataserviceapi.Last10TxResponse) TransferMetad // GetTransferData retrieves and matches transfer data // returns a formatted string of the full transaction/statement func GetTransferData(ctx context.Context, db storage.PrefixDb, publicKey string, index int) (string, error) { - keys := []DataTyp{DATA_PREFIX_TX_SENDERS, DATA_PREFIX_TX_RECIPIENTS, DATA_PREFIX_TX_VALUES, DATA_PREFIX_TX_ADDRESSES, DATA_PREFIX_TX_HASHES, DATA_PREFIX_TX_DATES, DATA_PREFIX_TX_SYMBOLS} + keys := []DataTyp{DATA_TX_SENDERS, DATA_TX_RECIPIENTS, DATA_TX_VALUES, DATA_TX_ADDRESSES, DATA_TX_HASHES, DATA_TX_DATES, DATA_TX_SYMBOLS} data := make(map[DataTyp]string) for _, key := range keys { @@ -69,13 +69,13 @@ func GetTransferData(ctx context.Context, db storage.PrefixDb, publicKey string, } // Split the data - senders := strings.Split(string(data[DATA_PREFIX_TX_SENDERS]), "\n") - recipients := strings.Split(string(data[DATA_PREFIX_TX_RECIPIENTS]), "\n") - values := strings.Split(string(data[DATA_PREFIX_TX_VALUES]), "\n") - addresses := strings.Split(string(data[DATA_PREFIX_TX_ADDRESSES]), "\n") - hashes := strings.Split(string(data[DATA_PREFIX_TX_HASHES]), "\n") - dates := strings.Split(string(data[DATA_PREFIX_TX_DATES]), "\n") - syms := strings.Split(string(data[DATA_PREFIX_TX_SYMBOLS]), "\n") + senders := strings.Split(string(data[DATA_TX_SENDERS]), "\n") + recipients := strings.Split(string(data[DATA_TX_RECIPIENTS]), "\n") + values := strings.Split(string(data[DATA_TX_VALUES]), "\n") + addresses := strings.Split(string(data[DATA_TX_ADDRESSES]), "\n") + hashes := strings.Split(string(data[DATA_TX_HASHES]), "\n") + dates := strings.Split(string(data[DATA_TX_DATES]), "\n") + syms := strings.Split(string(data[DATA_TX_SYMBOLS]), "\n") // Check if index is within range if index < 1 || index > len(senders) { diff --git a/internal/handlers/ussd/menuhandler.go b/internal/handlers/ussd/menuhandler.go index c860771..b47e31f 100644 --- a/internal/handlers/ussd/menuhandler.go +++ b/internal/handlers/ussd/menuhandler.go @@ -1746,14 +1746,14 @@ func (h *Handlers) CheckTransactions(ctx context.Context, sym string, input []by // Store all transaction data dataMap := map[common.DataTyp]string{ - common.DATA_PREFIX_TX_SENDERS: data.Senders, - common.DATA_PREFIX_TX_RECIPIENTS: data.Recipients, - common.DATA_PREFIX_TX_VALUES: data.TransferValues, - common.DATA_PREFIX_TX_ADDRESSES: data.Addresses, - common.DATA_PREFIX_TX_HASHES: data.TxHashes, - common.DATA_PREFIX_TX_DATES: data.Dates, - common.DATA_PREFIX_TX_SYMBOLS: data.Symbols, - common.DATA_PREFIX_TX_DECIMALS: data.Decimals, + common.DATA_TX_SENDERS: data.Senders, + common.DATA_TX_RECIPIENTS: data.Recipients, + common.DATA_TX_VALUES: data.TransferValues, + common.DATA_TX_ADDRESSES: data.Addresses, + common.DATA_TX_HASHES: data.TxHashes, + common.DATA_TX_DATES: data.Dates, + common.DATA_TX_SYMBOLS: data.Symbols, + common.DATA_TX_DECIMALS: data.Decimals, } for key, value := range dataMap { @@ -1783,22 +1783,22 @@ func (h *Handlers) GetTransactionsList(ctx context.Context, sym string, input [] } // Read transactions from the store and format them - TransactionSenders, err := h.prefixDb.Get(ctx, common.ToBytes(common.DATA_PREFIX_TX_SENDERS)) + TransactionSenders, err := h.prefixDb.Get(ctx, common.ToBytes(common.DATA_TX_SENDERS)) if err != nil { logg.ErrorCtxf(ctx, "Failed to read the TransactionSenders from prefixDb", "error", err) return res, err } - TransactionSyms, err := h.prefixDb.Get(ctx, common.ToBytes(common.DATA_PREFIX_TX_SYMBOLS)) + TransactionSyms, err := h.prefixDb.Get(ctx, common.ToBytes(common.DATA_TX_SYMBOLS)) if err != nil { logg.ErrorCtxf(ctx, "Failed to read the TransactionSyms from prefixDb", "error", err) return res, err } - TransactionValues, err := h.prefixDb.Get(ctx, common.ToBytes(common.DATA_PREFIX_TX_VALUES)) + TransactionValues, err := h.prefixDb.Get(ctx, common.ToBytes(common.DATA_TX_VALUES)) if err != nil { logg.ErrorCtxf(ctx, "Failed to read the TransactionValues from prefixDb", "error", err) return res, err } - TransactionDates, err := h.prefixDb.Get(ctx, common.ToBytes(common.DATA_PREFIX_TX_DATES)) + TransactionDates, err := h.prefixDb.Get(ctx, common.ToBytes(common.DATA_TX_DATES)) if err != nil { logg.ErrorCtxf(ctx, "Failed to read the TransactionDates from prefixDb", "error", err) return res, err