diff --git a/src/contextualizers/bridges/opStack/destination.ts b/src/contextualizers/bridges/opStack/destination.ts index 2c64ddb0..8a0d5345 100644 --- a/src/contextualizers/bridges/opStack/destination.ts +++ b/src/contextualizers/bridges/opStack/destination.ts @@ -42,7 +42,7 @@ export function generate(transaction: Transaction): Transaction { switch (assetTransfer.type) { case AssetType.ETH: asset = { - type: formatNativeToken(transaction.chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: assetTransfer.value, unit: 'wei', } as ContextETHType; diff --git a/src/contextualizers/bridges/opStack/source.ts b/src/contextualizers/bridges/opStack/source.ts index da0abe5e..f346625a 100644 --- a/src/contextualizers/bridges/opStack/source.ts +++ b/src/contextualizers/bridges/opStack/source.ts @@ -69,7 +69,7 @@ export function generate(transaction: Transaction): Transaction { switch (assetTransfer.type) { case AssetType.ETH: asset = { - type: formatNativeToken(transaction.chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: assetTransfer.value, unit: 'wei', } as ContextETHType; diff --git a/src/contextualizers/bridges/reservoir/destination.ts b/src/contextualizers/bridges/reservoir/destination.ts index 20d12b07..04b5ec5e 100644 --- a/src/contextualizers/bridges/reservoir/destination.ts +++ b/src/contextualizers/bridges/reservoir/destination.ts @@ -71,7 +71,7 @@ export function generate(transaction: Transaction): Transaction { value: 'BRIDGED', }, asset: { - type: formatNativeToken(transaction.chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: assetTransfer.value, unit: 'wei', }, diff --git a/src/contextualizers/heuristics/erc1155Mint/erc1155Mint.ts b/src/contextualizers/heuristics/erc1155Mint/erc1155Mint.ts index 98a26561..b782ca7a 100644 --- a/src/contextualizers/heuristics/erc1155Mint/erc1155Mint.ts +++ b/src/contextualizers/heuristics/erc1155Mint/erc1155Mint.ts @@ -113,7 +113,7 @@ export function generate(transaction: Transaction): Transaction { }, minted: { type: 'contextAction', value: 'MINTED' }, price: { - type: formatNativeToken(transaction.chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: price, unit: 'wei', }, diff --git a/src/contextualizers/heuristics/erc1155Purchase/erc1155Purchase.ts b/src/contextualizers/heuristics/erc1155Purchase/erc1155Purchase.ts index 98e29cf4..4f4c0f74 100644 --- a/src/contextualizers/heuristics/erc1155Purchase/erc1155Purchase.ts +++ b/src/contextualizers/heuristics/erc1155Purchase/erc1155Purchase.ts @@ -186,7 +186,7 @@ function generate(transaction: Transaction): Transaction { } : ethPayments.length > 0 ? { - type: formatNativeToken(transaction.chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: totalETHPayment.toString(), unit: 'wei', } diff --git a/src/contextualizers/heuristics/erc1155Sale/erc1155Sale.ts b/src/contextualizers/heuristics/erc1155Sale/erc1155Sale.ts index e7726bc3..b3ec8f28 100644 --- a/src/contextualizers/heuristics/erc1155Sale/erc1155Sale.ts +++ b/src/contextualizers/heuristics/erc1155Sale/erc1155Sale.ts @@ -160,7 +160,7 @@ function generate(transaction: Transaction): Transaction { } : ethPayments.length > 0 ? { - type: formatNativeToken(transaction.chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: totalETHPayment.toString(), unit: 'wei', } diff --git a/src/contextualizers/heuristics/erc20Mint/erc20Mint.ts b/src/contextualizers/heuristics/erc20Mint/erc20Mint.ts index fb3cd2bc..930adb2c 100644 --- a/src/contextualizers/heuristics/erc20Mint/erc20Mint.ts +++ b/src/contextualizers/heuristics/erc20Mint/erc20Mint.ts @@ -116,7 +116,7 @@ export function generate(transaction: Transaction): Transaction { value: recipient, }, price: { - type: formatNativeToken(transaction.chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: price, unit: 'wei', }, diff --git a/src/contextualizers/heuristics/erc721Mint/erc721Mint.ts b/src/contextualizers/heuristics/erc721Mint/erc721Mint.ts index f38271b9..186614b6 100644 --- a/src/contextualizers/heuristics/erc721Mint/erc721Mint.ts +++ b/src/contextualizers/heuristics/erc721Mint/erc721Mint.ts @@ -101,7 +101,7 @@ export function generate(transaction: Transaction): Transaction { value: sender, }, price: { - type: formatNativeToken(transaction.chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: price, unit: 'wei', }, diff --git a/src/contextualizers/heuristics/erc721Purchase/erc721Purchase.ts b/src/contextualizers/heuristics/erc721Purchase/erc721Purchase.ts index d3ec96ef..7195578c 100644 --- a/src/contextualizers/heuristics/erc721Purchase/erc721Purchase.ts +++ b/src/contextualizers/heuristics/erc721Purchase/erc721Purchase.ts @@ -177,7 +177,7 @@ export function generate(transaction: Transaction): Transaction { } : ethPayments.length > 0 ? { - type: formatNativeToken(transaction.chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: totalETHPayment.toString(), unit: 'wei', } diff --git a/src/contextualizers/heuristics/erc721Sale/erc721Sale.ts b/src/contextualizers/heuristics/erc721Sale/erc721Sale.ts index 57be8437..f330d908 100644 --- a/src/contextualizers/heuristics/erc721Sale/erc721Sale.ts +++ b/src/contextualizers/heuristics/erc721Sale/erc721Sale.ts @@ -169,7 +169,7 @@ export function generate(transaction: Transaction): Transaction { } : ethPayments.length > 0 ? { - type: formatNativeToken(transaction.chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: totalETHPayment.toString(), unit: 'wei', } diff --git a/src/contextualizers/heuristics/ethTransfer/ethTransfer.ts b/src/contextualizers/heuristics/ethTransfer/ethTransfer.ts index ea593edf..af8a9895 100644 --- a/src/contextualizers/heuristics/ethTransfer/ethTransfer.ts +++ b/src/contextualizers/heuristics/ethTransfer/ethTransfer.ts @@ -27,8 +27,6 @@ export function generate(transaction: Transaction): Transaction { return transaction; } - const chainId = transaction.chainId ?? 1; - transaction.context = { variables: { sender: { @@ -37,7 +35,7 @@ export function generate(transaction: Transaction): Transaction { }, amount: { - type: formatNativeToken(chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: transaction.value.toString(), unit: 'wei', }, diff --git a/src/contextualizers/protocol/basepaint/basepaint.ts b/src/contextualizers/protocol/basepaint/basepaint.ts index f200ce1b..489845c0 100644 --- a/src/contextualizers/protocol/basepaint/basepaint.ts +++ b/src/contextualizers/protocol/basepaint/basepaint.ts @@ -121,7 +121,7 @@ export const generate = (transaction: Transaction): Transaction => { value: transaction.from, }, amount: { - type: formatNativeToken(transaction.chainId), + type: formatNativeToken(transaction.chainId ?? 1), value, unit: 'wei', }, diff --git a/src/contextualizers/protocol/cryptopunks/cryptopunks.ts b/src/contextualizers/protocol/cryptopunks/cryptopunks.ts index 65855d24..9baa6fdc 100644 --- a/src/contextualizers/protocol/cryptopunks/cryptopunks.ts +++ b/src/contextualizers/protocol/cryptopunks/cryptopunks.ts @@ -63,7 +63,6 @@ export const generate = (transaction: Transaction): Transaction => { ) { return transaction; } - const chainId = transaction.chainId ?? 1; const decoded = decodeTransactionInput( transaction.input as Hex, @@ -132,7 +131,7 @@ export const generate = (transaction: Transaction): Transaction => { tokenId: decoded.args[0].toString(), }; const price: ContextSummaryVariableType = { - type: formatNativeToken(chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: decoded.args[1].toString(), unit: 'wei', }; @@ -192,7 +191,7 @@ export const generate = (transaction: Transaction): Transaction => { if (!ethAssetTransfer) return transaction; const price: ContextSummaryVariableType = { - type: formatNativeToken(chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: ethAssetTransfer.value, unit: 'wei', }; @@ -248,7 +247,7 @@ export const generate = (transaction: Transaction): Transaction => { tokenId: decoded.args[0].toString(), }; const price: ContextSummaryVariableType = { - type: formatNativeToken(chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: transaction.value.toString(), unit: 'wei', }; @@ -301,7 +300,7 @@ export const generate = (transaction: Transaction): Transaction => { const ethAssetTransfer = transaction .assetTransfers?.[0] as ETHAssetTransfer; const amount: ContextSummaryVariableType = { - type: formatNativeToken(chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: ethAssetTransfer.value, unit: 'wei', }; @@ -355,7 +354,7 @@ export const generate = (transaction: Transaction): Transaction => { tokenId: decoded.args[0].toString(), }; const price: ContextSummaryVariableType = { - type: formatNativeToken(chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: transaction.value.toString(), unit: 'wei', }; @@ -530,7 +529,7 @@ export const generate = (transaction: Transaction): Transaction => { tokenId: decoded.args[0].toString(), }; const price: ContextSummaryVariableType = { - type: formatNativeToken(chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: decoded.args[1].toString(), unit: 'wei', }; diff --git a/src/contextualizers/protocol/disperse/disperse.ts b/src/contextualizers/protocol/disperse/disperse.ts index 0970dc54..4b777c12 100644 --- a/src/contextualizers/protocol/disperse/disperse.ts +++ b/src/contextualizers/protocol/disperse/disperse.ts @@ -89,7 +89,7 @@ export const generate = (transaction: Transaction): Transaction => { value: tipTransfer.to, }, numOfEth: { - type: formatNativeToken(transaction.chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: tipTransfer.value, unit: 'wei', }, diff --git a/src/contextualizers/protocol/farcaster/bundler.ts b/src/contextualizers/protocol/farcaster/bundler.ts index 52d4018f..63179462 100644 --- a/src/contextualizers/protocol/farcaster/bundler.ts +++ b/src/contextualizers/protocol/farcaster/bundler.ts @@ -51,10 +51,9 @@ export const generate = (transaction: Transaction): Transaction => { case 'register': { const owner = decoded.args[0].to; const callerIsOwner = owner.toLowerCase() === caller.toLowerCase(); - const chainId = transaction.chainId ?? 1; // Capture cost to register const cost: ContextSummaryVariableType = { - type: formatNativeToken(chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: transaction.value.toString(), unit: 'wei', }; diff --git a/src/contextualizers/protocol/friendTech/friendTech.ts b/src/contextualizers/protocol/friendTech/friendTech.ts index 5ca92df7..007e629d 100644 --- a/src/contextualizers/protocol/friendTech/friendTech.ts +++ b/src/contextualizers/protocol/friendTech/friendTech.ts @@ -17,7 +17,6 @@ export const contextualize = (transaction: Transaction): Transaction => { // Contextualize for txs export const generate = (transaction: Transaction): Transaction => { - const chainId = transaction.chainId ?? 1; // Failed transaction if (!transaction.receipt?.status) { // buyShares(address sharesSubject, uint256 amount) @@ -33,7 +32,7 @@ export const generate = (transaction: Transaction): Transaction => { transaction.context = { variables: { price: { - type: formatNativeToken(chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: transaction.value.toString(), unit: 'wei', }, @@ -114,7 +113,7 @@ export const generate = (transaction: Transaction): Transaction => { transaction.context = { variables: { price: { - type: formatNativeToken(chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: ethAmount, unit: 'wei', }, @@ -174,7 +173,7 @@ export const generate = (transaction: Transaction): Transaction => { transaction.context = { variables: { price: { - type: formatNativeToken(chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: ethAmount, unit: 'wei', }, diff --git a/src/contextualizers/protocol/leeroy/leeroy.ts b/src/contextualizers/protocol/leeroy/leeroy.ts index fae3d87f..50c9c3ec 100644 --- a/src/contextualizers/protocol/leeroy/leeroy.ts +++ b/src/contextualizers/protocol/leeroy/leeroy.ts @@ -44,7 +44,6 @@ export const detect = (transaction: Transaction): boolean => { // Contextualize for mined txs export const generate = (transaction: Transaction): Transaction => { - const chainId = transaction.chainId ?? 1; switch (transaction.sigHash) { case '0x8ee93cf3': { // post(string) @@ -214,7 +213,7 @@ export const generate = (transaction: Transaction): Transaction => { value: transaction.from, }; const tipAmount: ContextSummaryVariableType = { - type: formatNativeToken(chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: transaction.value.toString(), unit: 'wei', }; @@ -232,7 +231,7 @@ export const generate = (transaction: Transaction): Transaction => { const asset = transaction.netAssetTransfers[transaction.to] .received[0] as ETHAsset; const leeroyTake: ContextSummaryVariableType = { - type: formatNativeToken(chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: asset.value, unit: 'wei', }; diff --git a/src/contextualizers/protocol/nouns/auctionHouse.ts b/src/contextualizers/protocol/nouns/auctionHouse.ts index d742dbb8..9ff7cdac 100644 --- a/src/contextualizers/protocol/nouns/auctionHouse.ts +++ b/src/contextualizers/protocol/nouns/auctionHouse.ts @@ -55,7 +55,6 @@ export const generate = (transaction: Transaction): Transaction => { ); if (!decoded) return transaction; - const chainId = transaction.chainId ?? 1; switch (decoded.functionName) { case 'createBid': { transaction.context = { @@ -74,7 +73,7 @@ export const generate = (transaction: Transaction): Transaction => { tokenId: decoded.args[0].toString(), }, amount: { - type: formatNativeToken(chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: transaction.value.toString(), unit: 'wei', }, diff --git a/src/contextualizers/protocol/nounsBuilder/auction.ts b/src/contextualizers/protocol/nounsBuilder/auction.ts index 310373ef..e18a81ae 100644 --- a/src/contextualizers/protocol/nounsBuilder/auction.ts +++ b/src/contextualizers/protocol/nounsBuilder/auction.ts @@ -63,8 +63,6 @@ export const generate = (transaction: Transaction): Transaction => { ); if (!decoded) return transaction; - const chainId = transaction.chainId ?? 1; - switch (decoded.functionName) { case 'createBid': { const variables: ContextVariable = { @@ -81,7 +79,7 @@ export const generate = (transaction: Transaction): Transaction => { value: decoded.args[0].toString(), }, amount: { - type: formatNativeToken(chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: transaction.value.toString(), unit: 'wei', }, diff --git a/src/contextualizers/protocol/superchainFaucet/superchainFaucet.ts b/src/contextualizers/protocol/superchainFaucet/superchainFaucet.ts index dff5c159..366b7808 100644 --- a/src/contextualizers/protocol/superchainFaucet/superchainFaucet.ts +++ b/src/contextualizers/protocol/superchainFaucet/superchainFaucet.ts @@ -36,7 +36,7 @@ export function generate(transaction: Transaction): Transaction { value: ethTransfer.to, }, amount: { - type: formatNativeToken(transaction.chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: ethTransfer.value, unit: 'wei', }, diff --git a/src/contextualizers/protocol/uniswapV2/uniswapV2Router.ts b/src/contextualizers/protocol/uniswapV2/uniswapV2Router.ts index c79f01ed..12c73f80 100644 --- a/src/contextualizers/protocol/uniswapV2/uniswapV2Router.ts +++ b/src/contextualizers/protocol/uniswapV2/uniswapV2Router.ts @@ -51,8 +51,6 @@ export const generate = (transaction: Transaction): Transaction => { ); if (!decoded) return transaction; - const chainId = transaction.chainId ?? 1; - switch (decoded.functionName) { case 'addLiquidityETH': { transaction.context = { @@ -66,7 +64,7 @@ export const generate = (transaction: Transaction): Transaction => { value: 'ADDED_LIQUIDITY', }, numETH: { - type: formatNativeToken(chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: transaction.value.toString(), unit: 'wei', }, diff --git a/src/contextualizers/protocol/weth/weth.ts b/src/contextualizers/protocol/weth/weth.ts index ca9a7869..22b70c8b 100644 --- a/src/contextualizers/protocol/weth/weth.ts +++ b/src/contextualizers/protocol/weth/weth.ts @@ -82,7 +82,7 @@ export const generate = (transaction: Transaction): Transaction => { value: transaction.from, }; const withdrawalAmount: ContextSummaryVariableType = { - type: formatNativeToken(transaction.chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: decode.args ? decode.args[0].toString() : '0', unit: 'wei', }; diff --git a/src/contextualizers/protocol/zoraCreator/zoraCreator.ts b/src/contextualizers/protocol/zoraCreator/zoraCreator.ts index 992dd698..c7835808 100644 --- a/src/contextualizers/protocol/zoraCreator/zoraCreator.ts +++ b/src/contextualizers/protocol/zoraCreator/zoraCreator.ts @@ -96,13 +96,13 @@ export const generate = (transaction: Transaction): Transaction => { value: sender, }, price: { - type: formatNativeToken(transaction.chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: price, unit: 'wei', }, minted: { type: 'contextAction', value: 'MINTED' }, numOfEth: { - type: formatNativeToken(transaction.chainId), + type: formatNativeToken(transaction.chainId ?? 1), value: decodedLog.args['mintReferralReward'].toString(), unit: 'wei', },