Skip to content

Commit

Permalink
Removes unused block numbers from SettlerContract type.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrés Elizondo committed Jun 22, 2024
1 parent 8ed18d5 commit bb212a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
2 changes: 0 additions & 2 deletions src/parsers/events/settler_erc721_transfer_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export function parseSettlerERC721TransferEvent(eventLog: LogEntry): SettlerERC7
const newContract: SettlerContract[] = [
{
address: settlerERC721TransferEvent.to,
startBlock: settlerERC721TransferEvent.blockNumber,
endBlock: null,
},
];
settlerContractSingleton.addNewContracts(newContract);
Expand Down
23 changes: 4 additions & 19 deletions src/settlerContractSingleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { Connection } from 'typeorm';

export type SettlerContract = {
address: string;
startBlock: number;
endBlock: number | null;
};

export class SettlerContractSingleton {
Expand All @@ -25,30 +23,17 @@ export class SettlerContractSingleton {

const settlerContracts = await connection.query(
`
WITH creations AS (
SELECT "to" AS address, block_number
FROM ${SCHEMA}.settler_erc721_transfer_events
WHERE "to" <> '0x0000000000000000000000000000000000000000'
), destructions AS (
SELECT "from" AS address, block_number
FROM ${SCHEMA}.settler_erc721_transfer_events
)
SELECT
c.address,
c.block_number AS start_block_number,
d.block_number AS end_block_number
FROM creations c
LEFT JOIN destructions d ON c.address = d.address
ORDER BY c.block_number
SELECT "to" AS address
FROM ${SCHEMA}.settler_erc721_transfer_events
WHERE "to" <> '0x0000000000000000000000000000000000000000'
ORDER BY block_number
`,
);

const tmpSettlerContracts: SettlerContract[] = [];
for (const entry of settlerContracts) {
tmpSettlerContracts.push({
address: entry['address'],
startBlock: entry['start_block_number'],
endBlock: entry['end_block_number'],
});
}

Expand Down

0 comments on commit bb212a8

Please sign in to comment.