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

enrichedParties and assetsEnriched #373

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
]
},
"decoded": null,
"pseudoTransactions": [],
"pseudotransactions": [],
guscost marked this conversation as resolved.
Show resolved Hide resolved
"assetTransfers": [
{
"contract": "0xe2f275b2a5c376fd10006b67a9be0cc3bd5488e8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
]
},
"decoded": null,
"pseudoTransactions": [],
"pseudotransactions": [],
"assetTransfers": [
{
"contract": "0xe2f275b2a5c376fd10006b67a9be0cc3bd5488e8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
]
},
"decoded": null,
"pseudoTransactions": [],
"pseudotransactions": [],
"assetTransfers": [
{
"contract": "0x12f885808f616b8056a37be00fdd029e1c59ab08",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
]
},
"decoded": null,
"pseudoTransactions": [],
"pseudotransactions": [],
"assetTransfers": [
{
"contract": "0x12f885808f616b8056a37be00fdd029e1c59ab08",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
]
},
"decoded": null,
"pseudoTransactions": [],
"pseudotransactions": [],
"assetTransfers": [
{
"from": "0x1e474b50bdc2b39dccaa2b8ddf37b3f022b128a8",
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ export const makeTransform = (
block.transactions = block.transactions.map((txn) => {
const xformed = childTransformer(block, txn);

xformed.pseudoTransactions = xformed.pseudoTransactions?.map(
xformed.pseudotransactions = xformed.pseudotransactions?.map(
(pseudoTxn) => childTransformer(block, pseudoTxn),
);

Expand Down
26 changes: 13 additions & 13 deletions src/transformers/_common/accountAbstraction/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ERC20_TRANSFER_EVENT } from '../../../helpers/constants';
const transform = makeTransform({ test: _transform });

describe('erc4337userOps', () => {
it('should unpack pseudoTransactions', () => {
it('should unpack pseudotransactions', () => {
const block = loadBlockFixture('ethereum', 19_298_068);
const result = transform(block);

Expand All @@ -19,10 +19,10 @@ describe('erc4337userOps', () => {
);
expect(txn).toBeDefined();

expect(txn?.pseudoTransactions).toBeDefined();
expect(txn?.pseudoTransactions?.length).toBe(1);
expect(txn?.pseudotransactions).toBeDefined();
expect(txn?.pseudotransactions?.length).toBe(1);

const pseudoTransaction = txn!.pseudoTransactions![0];
const pseudoTransaction = txn!.pseudotransactions![0];

expect(pseudoTransaction).toMatchObject({
from: '0x2991c3845396c9f1d262b2ca0674111a59e2c90a',
Expand All @@ -41,7 +41,7 @@ describe('erc4337userOps', () => {
'0x7a5e7d32380ae2ca3064b7fbc41e0d698cb7826f61a941737902f4a74a979ca7',
);

const pseudoTransaction = txn!.pseudoTransactions![0];
const pseudoTransaction = txn!.pseudotransactions![0];
expect(pseudoTransaction).toMatchObject({
from: '0x2991c3845396c9f1d262b2ca0674111a59e2c90a',
to: '0x5d72015cc621025c265fabffc2fa55ac4821d79f',
Expand Down Expand Up @@ -70,7 +70,7 @@ describe('erc4337userOps', () => {
});

// Check that the pseudoTransaction does NOT have logs from the entry point
const pseudoTransaction = txn.pseudoTransactions![0];
const pseudoTransaction = txn.pseudotransactions![0];
expect(pseudoTransaction.receipt).toMatchObject({
logs: expect.not.arrayContaining([
expect.objectContaining({
Expand Down Expand Up @@ -101,10 +101,10 @@ describe('erc4337userOps', () => {
'0xc7d4c93fefb9f56383d9a9e4cbafa53696610b777ac5797f751652db928b9ad1',
)!;

expect(txn.pseudoTransactions!.length).toBe(2);
expect(txn.pseudotransactions!.length).toBe(2);

expect(txn.pseudoTransactions![0].receipt.logs.length).toBe(1);
expect(txn.pseudoTransactions![1].receipt.logs.length).toBe(4);
expect(txn.pseudotransactions![0].receipt.logs.length).toBe(1);
expect(txn.pseudotransactions![1].receipt.logs.length).toBe(4);
});

it('should only include traces from user op', () => {
Expand All @@ -117,7 +117,7 @@ describe('erc4337userOps', () => {
'0xa8c9957193c0be795a1a032564728bda9bcea9899317b2e6298ec55ce19a689f',
)!;

const pseudoTxn = txn.pseudoTransactions![0];
const pseudoTxn = txn.pseudotransactions![0];

expect(txn.traces.length > pseudoTxn.traces.length);
expect(pseudoTxn.traces.map((v) => v.traceAddress)).toEqual([
Expand All @@ -139,10 +139,10 @@ describe('erc4337userOps', () => {
)!;

expect(
txn.pseudoTransactions![0].traces.map((v) => v.traceAddress),
txn.pseudotransactions![0].traces.map((v) => v.traceAddress),
).toEqual([[4], [4, 0], [4, 0, 0], [4, 0, 0, 0], [4, 0, 0, 0, 0]]);

expect(txn.pseudoTransactions![1].traces.map((v) => v.traceAddress)).toEqual([
expect(txn.pseudotransactions![1].traces.map((v) => v.traceAddress)).toEqual([
[5],
[5, 0],
[5, 0, 0],
Expand All @@ -168,7 +168,7 @@ describe('erc4337userOps', () => {
'0x2f54574405fda5bedfa9d6df46188550033d3a18829f46456fa009199911b596',
)!;

const pseudoTxn = txn.pseudoTransactions![0];
const pseudoTxn = txn.pseudotransactions![0];

expect(pseudoTxn.receipt.status).toBe(0);
});
Expand Down
4 changes: 2 additions & 2 deletions src/transformers/_common/accountAbstraction/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export const unpackERC4337Transactions = (
export const transform: TxnTransformer = (_block, tx) => {
if (!isRawTransaction(tx)) return tx;

const pseudoTransactions = unpackERC4337Transactions(tx);
const pseudotransactions = unpackERC4337Transactions(tx);

return { ...tx, pseudoTransactions };
return { ...tx, pseudotransactions };
};
8 changes: 4 additions & 4 deletions src/transformers/transformer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ describe('transformations', () => {
});
});

it('should unpack and transform pseudoTransactions', () => {
it('should unpack and transform pseudotransactions', () => {
const block = loadBlockFixture('ethereum', 19_298_068);
const result = transformer.transform(block);

Expand All @@ -519,11 +519,11 @@ describe('transformations', () => {
]),
});

expect(txn?.pseudoTransactions).toBeDefined();
expect(txn?.pseudoTransactions?.length).toBe(1);
expect(txn?.pseudotransactions).toBeDefined();
expect(txn?.pseudotransactions?.length).toBe(1);

// pseudo transaction should NOT include eth transfer from entry point to beneficiary
const pseudoTransaction = txn!.pseudoTransactions![0];
const pseudoTransaction = txn!.pseudotransactions![0];
expect(pseudoTransaction).toMatchObject({
from: '0x2991c3845396c9f1d262b2ca0674111a59e2c90a',
to: '0x5d72015cc621025c265fabffc2fa55ac4821d79f',
Expand Down
32 changes: 30 additions & 2 deletions src/types/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from 'viem';
import { Log, RawReceipt } from './log';
import { ContextVariable, ContextSummaryType } from './context';
import { NetAssetTransfers, AssetTransfer } from './asset';
import { NetAssetTransfers, AssetTransfer, Asset } from './asset';
import { InternalHashType, StdObj } from './shared';
import { Contract } from './contract';

Expand Down Expand Up @@ -69,6 +69,32 @@ export type Receipt = TransactionReceipt & {
l1GasUsed?: string;
};

export type AddressMeta = {
chainId: number;
isContract: boolean;
ensNew: {
handle: string | null;
avatar: string | null;
};
bns: {
handle: string | null;
avatar: string | null;
};
farcaster: {
handle: string | null;
avatar: string | null;
fid: number | null;
};
};

export type TransactionEnrichedParties = {
[address: string]: AddressMeta[];
};

export type TransactionAssetsEnriched = {
[address: string]: Asset & { imageUrl: string | null };
};

export type TransactionContextType = {
variables?: ContextVariable;
summaries?: ContextSummaryType;
Expand All @@ -79,6 +105,8 @@ export type TransactionContextType = {
export type Transaction = BaseTransaction & {
assetTransfers?: AssetTransfer[];
pseudotransactions?: PseudoTransaction[];
enrichedParties?: TransactionEnrichedParties;
assetsEnriched?: TransactionAssetsEnriched;
sigHash: string;
internalSigHashes: SigHash[];
parties: string[];
Expand Down Expand Up @@ -126,7 +154,7 @@ export type RawTransaction = PartialTransaction & {
hash: Hex;
accessList?: StdObj[];

pseudoTransactions?: PseudoTransaction[];
pseudotransactions?: PseudoTransaction[];
};

export type RawTraceAction = StdObj & {
Expand Down
Loading