Skip to content

Commit 3b85371

Browse files
committed
fixup! Update lifi to provide chainId, pluginId, and tokenId
1 parent a1fd398 commit 3b85371

1 file changed

Lines changed: 50 additions & 61 deletions

File tree

src/partners/lifi.ts

Lines changed: 50 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,7 @@ export const lifi: PartnerPlugin = {
163163
}
164164

165165
export function processLifiTx(rawTx: unknown): StandardTx {
166-
let tx: Transfer
167-
try {
168-
tx = asTransfer(rawTx)
169-
} catch (e) {
170-
datelog(e)
171-
throw e
172-
}
166+
const tx = asTransfer(rawTx)
173167
const txTimestamp = tx.receiving.timestamp ?? tx.sending.timestamp ?? 0
174168
if (txTimestamp === 0) {
175169
throw new Error('No timestamp')
@@ -269,62 +263,57 @@ export function processLifiTx(rawTx: unknown): StandardTx {
269263
throw new Error('Missing token type')
270264
}
271265

272-
try {
273-
const depositTokenId = createTokenId(
274-
depositTokenType,
275-
depositToken.symbol,
276-
depositTokenAddress ?? undefined
277-
)
278-
const payoutTokenId = createTokenId(
279-
payoutTokenType,
280-
payoutToken.symbol,
281-
payoutTokenAddress ?? undefined
266+
const depositTokenId = createTokenId(
267+
depositTokenType,
268+
depositToken.symbol,
269+
depositTokenAddress ?? undefined
270+
)
271+
const payoutTokenId = createTokenId(
272+
payoutTokenType,
273+
payoutToken.symbol,
274+
payoutTokenAddress ?? undefined
275+
)
276+
277+
const standardTx: StandardTx = {
278+
status: statusMap[tx.status],
279+
orderId: tx.sending.txHash,
280+
countryCode: null,
281+
depositTxid: tx.sending.txHash,
282+
depositAddress: undefined,
283+
depositCurrency: depositToken.symbol,
284+
depositChainPluginId,
285+
depositEvmChainId,
286+
depositTokenId,
287+
depositAmount,
288+
direction: null,
289+
exchangeType: 'swap',
290+
paymentType: null,
291+
payoutTxid: tx.receiving.txHash,
292+
payoutAddress: tx.toAddress,
293+
payoutCurrency: payoutToken.symbol,
294+
payoutChainPluginId,
295+
payoutEvmChainId,
296+
payoutTokenId,
297+
payoutAmount,
298+
timestamp,
299+
isoDate,
300+
usdValue: Number(tx.sending.amountUSD ?? tx.receiving.amountUSD ?? '-1'),
301+
rawTx
302+
}
303+
if (statusMap[tx.status] === 'complete') {
304+
const { orderId, depositCurrency, payoutCurrency } = standardTx
305+
console.log(
306+
`${orderId} ${depositCurrency} ${depositChainPluginId} ${depositEvmChainId} ${depositTokenId?.slice(
307+
0,
308+
6
309+
) ??
310+
''} ${depositAmount} -> ${payoutCurrency} ${payoutChainPluginId} ${payoutEvmChainId} ${payoutTokenId?.slice(
311+
0,
312+
6
313+
) ?? ''} ${payoutAmount}`
282314
)
283-
284-
const standardTx: StandardTx = {
285-
status: statusMap[tx.status],
286-
orderId: tx.sending.txHash,
287-
countryCode: null,
288-
depositTxid: tx.sending.txHash,
289-
depositAddress: undefined,
290-
depositCurrency: depositToken.symbol,
291-
depositChainPluginId,
292-
depositEvmChainId,
293-
depositTokenId,
294-
depositAmount,
295-
direction: null,
296-
exchangeType: 'swap',
297-
paymentType: null,
298-
payoutTxid: tx.receiving.txHash,
299-
payoutAddress: tx.toAddress,
300-
payoutCurrency: payoutToken.symbol,
301-
payoutChainPluginId,
302-
payoutEvmChainId,
303-
payoutTokenId,
304-
payoutAmount,
305-
timestamp,
306-
isoDate,
307-
usdValue: Number(tx.sending.amountUSD ?? tx.receiving.amountUSD ?? '-1'),
308-
rawTx
309-
}
310-
if (statusMap[tx.status] === 'complete') {
311-
const { orderId, depositCurrency, payoutCurrency } = standardTx
312-
console.log(
313-
`${orderId} ${depositCurrency} ${depositChainPluginId} ${depositEvmChainId} ${depositTokenId?.slice(
314-
0,
315-
6
316-
) ??
317-
''} ${depositAmount} -> ${payoutCurrency} ${payoutChainPluginId} ${payoutEvmChainId} ${payoutTokenId?.slice(
318-
0,
319-
6
320-
) ?? ''} ${payoutAmount}`
321-
)
322-
}
323-
return standardTx
324-
} catch (e) {
325-
datelog(e)
326-
throw e
327315
}
316+
return standardTx
328317
}
329318

330319
const MAINNET_CODE_TRANSCRIPTION: Record<string, string> = {

0 commit comments

Comments
 (0)