Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If chain id is degen's, 6666..., use a different type #276

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/contextualizers/bridges/opStack/destination.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { formatNativeToken } from '../../../helpers/utils';
import {
Transaction,
AssetType,
Expand Down Expand Up @@ -41,7 +42,7 @@ export function generate(transaction: Transaction): Transaction {
switch (assetTransfer.type) {
case AssetType.ETH:
asset = {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: assetTransfer.value,
unit: 'wei',
} as ContextETHType;
Expand Down
4 changes: 2 additions & 2 deletions src/contextualizers/bridges/opStack/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
TRANSACTION_DEPOSITED_EVENT_ABI,
TRANSACTION_DEPOSITED_EVENT_HASH,
} from './constants';
import { decodeLog } from '../../../helpers/utils';
import { decodeLog, formatNativeToken } from '../../../helpers/utils';

export function contextualize(transaction: Transaction): Transaction {
const isOpStack = detect(transaction);
Expand Down Expand Up @@ -69,7 +69,7 @@ export function generate(transaction: Transaction): Transaction {
switch (assetTransfer.type) {
case AssetType.ETH:
asset = {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: assetTransfer.value,
unit: 'wei',
} as ContextETHType;
Expand Down
3 changes: 2 additions & 1 deletion src/contextualizers/bridges/reservoir/destination.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { formatNativeToken } from '../../../helpers/utils';
import { Transaction, AssetType, ETHAsset } from '../../../types';
import { BRIDGE_ZORA_ENERGY } from './constants';

Expand Down Expand Up @@ -70,7 +71,7 @@ export function generate(transaction: Transaction): Transaction {
value: 'BRIDGED',
},
asset: {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: assetTransfer.value,
unit: 'wei',
},
Expand Down
3 changes: 2 additions & 1 deletion src/contextualizers/heuristics/erc1155Mint/erc1155Mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ERC1155AssetTransfer,
} from '../../../types';
import { KNOWN_ADDRESSES } from '../../../helpers/constants';
import { formatNativeToken } from '../../../helpers/utils';

export function contextualize(transaction: Transaction): Transaction {
const isTokenMint = detect(transaction);
Expand Down Expand Up @@ -112,7 +113,7 @@ export function generate(transaction: Transaction): Transaction {
},
minted: { type: 'contextAction', value: 'MINTED' },
price: {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: price,
unit: 'wei',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { formatNativeToken } from '../../../helpers/utils';
import {
AssetType,
ERC1155Asset,
Expand Down Expand Up @@ -185,7 +186,7 @@ function generate(transaction: Transaction): Transaction {
}
: ethPayments.length > 0
? {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: totalETHPayment.toString(),
unit: 'wei',
}
Expand Down
3 changes: 2 additions & 1 deletion src/contextualizers/heuristics/erc1155Sale/erc1155Sale.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { formatNativeToken } from '../../../helpers/utils';
import {
AssetType,
ERC1155Asset,
Expand Down Expand Up @@ -159,7 +160,7 @@ function generate(transaction: Transaction): Transaction {
}
: ethPayments.length > 0
? {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: totalETHPayment.toString(),
unit: 'wei',
}
Expand Down
3 changes: 2 additions & 1 deletion src/contextualizers/heuristics/erc20Mint/erc20Mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ERC20AssetTransfer,
} from '../../../types';
import { KNOWN_ADDRESSES, WETH_ADDRESSES } from '../../../helpers/constants';
import { formatNativeToken } from '../../../helpers/utils';

export function contextualize(transaction: Transaction): Transaction {
const isTokenMint = detect(transaction);
Expand Down Expand Up @@ -115,7 +116,7 @@ export function generate(transaction: Transaction): Transaction {
value: recipient,
},
price: {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: price,
unit: 'wei',
},
Expand Down
3 changes: 2 additions & 1 deletion src/contextualizers/heuristics/erc721Mint/erc721Mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Transaction,
} from '../../../types';
import { KNOWN_ADDRESSES } from '../../../helpers/constants';
import { formatNativeToken } from '../../../helpers/utils';

export function contextualize(transaction: Transaction): Transaction {
const isTokenMint = detect(transaction);
Expand Down Expand Up @@ -100,7 +101,7 @@ export function generate(transaction: Transaction): Transaction {
value: sender,
},
price: {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: price,
unit: 'wei',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { formatNativeToken } from '../../../helpers/utils';
import {
AssetType,
ERC20Asset,
Expand Down Expand Up @@ -176,7 +177,7 @@ export function generate(transaction: Transaction): Transaction {
}
: ethPayments.length > 0
? {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: totalETHPayment.toString(),
unit: 'wei',
}
Expand Down
3 changes: 2 additions & 1 deletion src/contextualizers/heuristics/erc721Sale/erc721Sale.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { formatNativeToken } from '../../../helpers/utils';
import {
AssetType,
ERC20Asset,
Expand Down Expand Up @@ -168,7 +169,7 @@ export function generate(transaction: Transaction): Transaction {
}
: ethPayments.length > 0
? {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: totalETHPayment.toString(),
unit: 'wei',
}
Expand Down
5 changes: 3 additions & 2 deletions src/contextualizers/heuristics/ethTransfer/ethTransfer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AssetType, Transaction } from '../../../types';
import { formatNativeToken } from '../../../helpers/utils';
import { Transaction } from '../../../types';

export function contextualize(transaction: Transaction): Transaction {
const isEthTransfer = detect(transaction);
Expand Down Expand Up @@ -34,7 +35,7 @@ export function generate(transaction: Transaction): Transaction {
},

amount: {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: transaction.value.toString(),
unit: 'wei',
},
Expand Down
7 changes: 5 additions & 2 deletions src/contextualizers/protocol/basepaint/basepaint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import {
Transaction,
} from '../../../types';
import { BASEPAINT_CONTRACT, BRUSHES_CONTRACT, ABIs } from './constants';
import { decodeTransactionInput } from '../../../helpers/utils';
import {
decodeTransactionInput,
formatNativeToken,
} from '../../../helpers/utils';

export const contextualize = (transaction: Transaction): Transaction => {
const isBasepaint = detect(transaction);
Expand Down Expand Up @@ -118,7 +121,7 @@ export const generate = (transaction: Transaction): Transaction => {
value: transaction.from,
},
amount: {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value,
unit: 'wei',
},
Expand Down
17 changes: 10 additions & 7 deletions src/contextualizers/protocol/cryptopunks/cryptopunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {
Transaction,
} from '../../../types';
import { CryptopunksContracts, CRYPTOPUNK_ABIS } from './constants';
import { decodeTransactionInput } from '../../../helpers/utils';
import {
decodeTransactionInput,
formatNativeToken,
} from '../../../helpers/utils';

export const contextualize = (transaction: Transaction): Transaction => {
const isENS = detect(transaction);
Expand Down Expand Up @@ -128,7 +131,7 @@ export const generate = (transaction: Transaction): Transaction => {
tokenId: decoded.args[0].toString(),
};
const price: ContextSummaryVariableType = {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: decoded.args[1].toString(),
unit: 'wei',
};
Expand Down Expand Up @@ -188,7 +191,7 @@ export const generate = (transaction: Transaction): Transaction => {
if (!ethAssetTransfer) return transaction;

const price: ContextSummaryVariableType = {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: ethAssetTransfer.value,
unit: 'wei',
};
Expand Down Expand Up @@ -244,7 +247,7 @@ export const generate = (transaction: Transaction): Transaction => {
tokenId: decoded.args[0].toString(),
};
const price: ContextSummaryVariableType = {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: transaction.value.toString(),
unit: 'wei',
};
Expand Down Expand Up @@ -297,7 +300,7 @@ export const generate = (transaction: Transaction): Transaction => {
const ethAssetTransfer = transaction
.assetTransfers?.[0] as ETHAssetTransfer;
const amount: ContextSummaryVariableType = {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: ethAssetTransfer.value,
unit: 'wei',
};
Expand Down Expand Up @@ -351,7 +354,7 @@ export const generate = (transaction: Transaction): Transaction => {
tokenId: decoded.args[0].toString(),
};
const price: ContextSummaryVariableType = {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: transaction.value.toString(),
unit: 'wei',
};
Expand Down Expand Up @@ -526,7 +529,7 @@ export const generate = (transaction: Transaction): Transaction => {
tokenId: decoded.args[0].toString(),
};
const price: ContextSummaryVariableType = {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: decoded.args[1].toString(),
unit: 'wei',
};
Expand Down
7 changes: 5 additions & 2 deletions src/contextualizers/protocol/disperse/disperse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import {
DISPERSE_CONTRACTS,
TIP_FEE_RECEIVER,
} from './constants';
import { decodeTransactionInput } from '../../../helpers/utils';
import {
decodeTransactionInput,
formatNativeToken,
} from '../../../helpers/utils';

export const contextualize = (transaction: Transaction): Transaction => {
const isEnjoy = detect(transaction);
Expand Down Expand Up @@ -86,7 +89,7 @@ export const generate = (transaction: Transaction): Transaction => {
value: tipTransfer.to,
},
numOfEth: {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: tipTransfer.value,
unit: 'wei',
},
Expand Down
10 changes: 6 additions & 4 deletions src/contextualizers/protocol/farcaster/bundler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { Hex } from 'viem';
import {
AssetType,
ContextSummaryVariableType,
EventLogTopics,
Transaction,
} from '../../../types';
import { FarcasterContracts } from './constants';
import { decodeTransactionInput, decodeLog } from '../../../helpers/utils';
import {
decodeTransactionInput,
decodeLog,
formatNativeToken,
} from '../../../helpers/utils';

// Contextualizer for the Bundler contract:
// https://github.com/farcasterxyz/contracts/blob/main/src/interfaces/IBundler.sol
Expand Down Expand Up @@ -48,10 +51,9 @@ export const generate = (transaction: Transaction): Transaction => {
case 'register': {
const owner = decoded.args[0].to;
const callerIsOwner = owner.toLowerCase() === caller.toLowerCase();

// Capture cost to register
const cost: ContextSummaryVariableType = {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: transaction.value.toString(),
unit: 'wei',
};
Expand Down
14 changes: 9 additions & 5 deletions src/contextualizers/protocol/friendTech/friendTech.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Hex } from 'viem';
import { AssetType, EventLogTopics, Transaction } from '../../../types';
import { EventLogTopics, Transaction } from '../../../types';
import { ABIs } from './constants';
import { decodeTransactionInput, decodeLog } from '../../../helpers/utils';
import {
decodeTransactionInput,
decodeLog,
formatNativeToken,
} from '../../../helpers/utils';
import { detect } from './detect';

export const contextualize = (transaction: Transaction): Transaction => {
Expand All @@ -28,7 +32,7 @@ export const generate = (transaction: Transaction): Transaction => {
transaction.context = {
variables: {
price: {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: transaction.value.toString(),
unit: 'wei',
},
Expand Down Expand Up @@ -109,7 +113,7 @@ export const generate = (transaction: Transaction): Transaction => {
transaction.context = {
variables: {
price: {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: ethAmount,
unit: 'wei',
},
Expand Down Expand Up @@ -169,7 +173,7 @@ export const generate = (transaction: Transaction): Transaction => {
transaction.context = {
variables: {
price: {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: ethAmount,
unit: 'wei',
},
Expand Down
7 changes: 3 additions & 4 deletions src/contextualizers/protocol/leeroy/leeroy.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Hex, toBytes } from 'viem';
import {
AssetType,
ContextSummaryVariableType,
ETHAsset,
Transaction,
} from '../../../types';
import { LeeroyContracts } from './constants';
import { decodeFunction } from '../../../helpers/utils';
import { decodeFunction, formatNativeToken } from '../../../helpers/utils';

export const contextualize = (transaction: Transaction): Transaction => {
const isLeeroy = detect(transaction);
Expand Down Expand Up @@ -214,7 +213,7 @@ export const generate = (transaction: Transaction): Transaction => {
value: transaction.from,
};
const tipAmount: ContextSummaryVariableType = {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: transaction.value.toString(),
unit: 'wei',
};
Expand All @@ -232,7 +231,7 @@ export const generate = (transaction: Transaction): Transaction => {
const asset = transaction.netAssetTransfers[transaction.to]
.received[0] as ETHAsset;
const leeroyTake: ContextSummaryVariableType = {
type: AssetType.ETH,
type: formatNativeToken(transaction.chainId ?? 1),
value: asset.value,
unit: 'wei',
};
Expand Down
Loading
Loading