@@ -375,8 +375,6 @@ export const queryXgram = async (
375375 if ( previousTimestamp < 0 ) previousTimestamp = 0
376376 const targetIsoDate = new Date ( previousTimestamp ) . toISOString ( )
377377
378- const currencies = await fetchCurrencyCache ( apiKey , log )
379-
380378 // Because Xgram pages from newest to oldest, the watermark can only be
381379 // advanced once the entire newer-than-target range has been fetched and
382380 // processed without error. Track the candidate watermark separately and only
@@ -427,7 +425,7 @@ export const queryXgram = async (
427425 }
428426 let oldestIsoDate = '999999999999999999999999999999999999'
429427 for ( const rawTx of txs ) {
430- const standardTx = processXgramTx ( rawTx , currencies )
428+ const standardTx = await processXgramTx ( rawTx , pluginParams )
431429 if ( standardTx . isoDate < oldestIsoDate ) {
432430 oldestIsoDate = standardTx . isoDate
433431 }
@@ -462,7 +460,20 @@ export const xgram: PartnerPlugin = {
462460 pluginId : 'xgram'
463461}
464462
465- export function processXgramTx (
463+ export async function processXgramTx (
464+ rawTx : unknown ,
465+ pluginParams : PluginParams
466+ ) : Promise < StandardTx > {
467+ const { log } = pluginParams
468+ const { apiKeys } = asStandardPluginParams ( pluginParams )
469+ const { apiKey } = apiKeys
470+ if ( apiKey == null ) throw new Error ( 'Missing Xgram apiKey' )
471+ const currencies = await fetchCurrencyCache ( apiKey , log )
472+
473+ return processXgramTxWithCurrencies ( rawTx , currencies )
474+ }
475+
476+ export function processXgramTxWithCurrencies (
466477 rawTx : unknown ,
467478 currencies : XgramCurrencies
468479) : StandardTx {
0 commit comments