From c02aa99ed07202bfb260a50faeb8a062cd9f46b2 Mon Sep 17 00:00:00 2001 From: Alfred Kamanda Date: Fri, 13 Feb 2026 03:56:24 +0300 Subject: [PATCH] store the active swap from voucher data --- store/swap.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/store/swap.go b/store/swap.go index 097ad4a..3359a6f 100644 --- a/store/swap.go +++ b/store/swap.go @@ -189,3 +189,24 @@ func UpdateSwapToVoucherData(ctx context.Context, store DataStore, sessionId str return nil } + +// UpdateSwapFromVoucherData updates the active swap from voucher data in the DataStore. +func UpdateSwapFromVoucherData(ctx context.Context, store DataStore, sessionId string, data *dataserviceapi.TokenHoldings) error { + logg.InfoCtxf(ctx, "UpdateSwapFromVoucherData", "data", data) + // Active swap to voucher data entries + activeEntries := map[storedb.DataTyp][]byte{ + storedb.DATA_ACTIVE_SWAP_FROM_SYM: []byte(data.TokenSymbol), + storedb.DATA_ACTIVE_SWAP_FROM_DECIMAL: []byte(data.TokenDecimals), + storedb.DATA_ACTIVE_SWAP_FROM_ADDRESS: []byte(data.TokenAddress), + storedb.DATA_ACTIVE_SWAP_FROM_BALANCE: []byte(data.Balance), + } + + // Write active data + for key, value := range activeEntries { + if err := store.WriteEntry(ctx, sessionId, key, value); err != nil { + return err + } + } + + return nil +} \ No newline at end of file