Skip to content

Commit

Permalink
Pass topic1 to (un/wrap) event decoders)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ktl-XV committed Oct 9, 2023
1 parent 654dfac commit 8cbef7a
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const wrapNativeEvent = new Table({
{ name: 'block_hash', type: 'varchar' },
{ name: 'block_number', type: 'bigint' },
{ name: 'dst', type: 'varchar' },
{ name: 'wad', type: 'bigint' },
{ name: 'wad', type: 'numeric' },
],
});

Expand Down Expand Up @@ -39,7 +39,7 @@ const unwrapNativeEvent = new Table({
{ name: 'block_hash', type: 'varchar' },
{ name: 'block_number', type: 'bigint' },
{ name: 'src', type: 'varchar' },
{ name: 'wad', type: 'bigint' },
{ name: 'wad', type: 'numeric' },
],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const wrapNativeEvent = new Table({
{ name: 'block_hash', type: 'varchar' },
{ name: 'block_number', type: 'bigint' },
{ name: 'dst', type: 'varchar' },
{ name: 'wad', type: 'bigint' },
{ name: 'wad', type: 'numeric' },
],
});

Expand Down Expand Up @@ -39,7 +39,7 @@ const unwrapNativeEvent = new Table({
{ name: 'block_hash', type: 'varchar' },
{ name: 'block_number', type: 'bigint' },
{ name: 'src', type: 'varchar' },
{ name: 'wad', type: 'bigint' },
{ name: 'wad', type: 'numeric' },
],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const wrapNativeEvent = new Table({
{ name: 'block_hash', type: 'varchar' },
{ name: 'block_number', type: 'bigint' },
{ name: 'dst', type: 'varchar' },
{ name: 'wad', type: 'bigint' },
{ name: 'wad', type: 'numeric' },
],
});

Expand Down Expand Up @@ -39,7 +39,7 @@ const unwrapNativeEvent = new Table({
{ name: 'block_hash', type: 'varchar' },
{ name: 'block_number', type: 'bigint' },
{ name: 'src', type: 'varchar' },
{ name: 'wad', type: 'bigint' },
{ name: 'wad', type: 'numeric' },
],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const wrapNativeEvent = new Table({
{ name: 'block_hash', type: 'varchar' },
{ name: 'block_number', type: 'bigint' },
{ name: 'dst', type: 'varchar' },
{ name: 'wad', type: 'bigint' },
{ name: 'wad', type: 'numeric' },
],
});

Expand Down Expand Up @@ -39,7 +39,7 @@ const unwrapNativeEvent = new Table({
{ name: 'block_hash', type: 'varchar' },
{ name: 'block_number', type: 'bigint' },
{ name: 'src', type: 'varchar' },
{ name: 'wad', type: 'bigint' },
{ name: 'wad', type: 'numeric' },
],
});

Expand Down
73 changes: 0 additions & 73 deletions migrations/celo/1696555657005-CreateWrapUnwrapNativeEventsTable.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const wrapNativeEvent = new Table({
{ name: 'block_hash', type: 'varchar' },
{ name: 'block_number', type: 'bigint' },
{ name: 'dst', type: 'varchar' },
{ name: 'wad', type: 'bigint' },
{ name: 'wad', type: 'numeric' },
],
});

Expand Down Expand Up @@ -39,7 +39,7 @@ const unwrapNativeEvent = new Table({
{ name: 'block_hash', type: 'varchar' },
{ name: 'block_number', type: 'bigint' },
{ name: 'src', type: 'varchar' },
{ name: 'wad', type: 'bigint' },
{ name: 'wad', type: 'numeric' },
],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const wrapNativeEvent = new Table({
{ name: 'block_hash', type: 'varchar' },
{ name: 'block_number', type: 'bigint' },
{ name: 'dst', type: 'varchar' },
{ name: 'wad', type: 'bigint' },
{ name: 'wad', type: 'numeric' },
],
});

Expand Down Expand Up @@ -39,7 +39,7 @@ const unwrapNativeEvent = new Table({
{ name: 'block_hash', type: 'varchar' },
{ name: 'block_number', type: 'bigint' },
{ name: 'src', type: 'varchar' },
{ name: 'wad', type: 'bigint' },
{ name: 'wad', type: 'numeric' },
],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const wrapNativeEvent = new Table({
{ name: 'block_hash', type: 'varchar' },
{ name: 'block_number', type: 'bigint' },
{ name: 'dst', type: 'varchar' },
{ name: 'wad', type: 'bigint' },
{ name: 'wad', type: 'numeric' },
],
});

Expand Down Expand Up @@ -39,7 +39,7 @@ const unwrapNativeEvent = new Table({
{ name: 'block_hash', type: 'varchar' },
{ name: 'block_number', type: 'bigint' },
{ name: 'src', type: 'varchar' },
{ name: 'wad', type: 'bigint' },
{ name: 'wad', type: 'numeric' },
],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const wrapNativeEvent = new Table({
{ name: 'block_hash', type: 'varchar' },
{ name: 'block_number', type: 'bigint' },
{ name: 'dst', type: 'varchar' },
{ name: 'wad', type: 'bigint' },
{ name: 'wad', type: 'numeric' },
],
});

Expand Down Expand Up @@ -39,7 +39,7 @@ const unwrapNativeEvent = new Table({
{ name: 'block_hash', type: 'varchar' },
{ name: 'block_number', type: 'bigint' },
{ name: 'src', type: 'varchar' },
{ name: 'wad', type: 'bigint' },
{ name: 'wad', type: 'numeric' },
],
});

Expand Down
9 changes: 4 additions & 5 deletions src/abis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -997,18 +997,17 @@ export const ONCHAIN_GOVERNANCE_CALL_SCHEDULED_ABI = {
export const WRAP_NATIVE_ABI = {
anonymous: false,
inputs: [
{ indexed: true, internalType: 'address', name: 'dst', type: 'address' },
{ indexed: false, internalType: 'uint256', name: 'wad', type: 'uint256' },
{ indexed: true, name: 'dst', type: 'address' },
{ indexed: false, name: 'wad', type: 'uint256' },
],
name: 'Deposit',
type: 'event',
};

export const UNWRAP_NATIVE_ABI = {
anonymous: false,
inputs: [
{ indexed: true, internalType: 'address', name: 'src', type: 'address' },
{ indexed: false, internalType: 'uint256', name: 'wad', type: 'uint256' },
{ indexed: true, name: 'src', type: 'address' },
{ indexed: false, name: 'wad', type: 'uint256' },
],
name: 'Withdrawal',
type: 'event',
Expand Down
6 changes: 3 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,9 @@ validateStartBlock(
DEFAULT_FEAT_WRAP_UNWRAP_NATIVE_EVENT,
);

export const WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS = process.env.WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS ? process.env.WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS : DEFAULT_WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS;
export const WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS = process.env.WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS
? process.env.WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS
: DEFAULT_WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS;

export const KAFKA_BROKERS = process.env.KAFKA_BROKERS ? process.env.KAFKA_BROKERS.split(',') : [];
if (KAFKA_BROKERS.length === 0) {
Expand Down Expand Up @@ -421,6 +423,4 @@ function validateStartBlock(startBlockVar: string, startBlock: number, featureFl
`${featureFlagVar} is enabled but ${startBlockVar} is not set. Please set ${startBlockVar} or disable the feature`,
);
}
console.log(startBlock)
console.log(featureFlag)
}
10 changes: 5 additions & 5 deletions src/parsers/events/wrap_unwrap_native_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ import { BigNumber } from '@0x/utils';

export function parseWrapNativeEvent(eventLog: RawLogEntry): WrapNativeEvent {
const wrapNativeEvent = new WrapNativeEvent();

parseEvent(eventLog, wrapNativeEvent);
// decode the basic info
const decodedLog = abiCoder.decodeLog(WRAP_NATIVE_ABI.inputs, eventLog.data);
//

const decodedLog = abiCoder.decodeLog(WRAP_NATIVE_ABI.inputs, eventLog.data, [eventLog.topics[1]]);

wrapNativeEvent.dst = decodedLog.dst.toLowerCase();
wrapNativeEvent.wad = new BigNumber(decodedLog.wad);

console.log(decodedLog);

return wrapNativeEvent;
}

export function parseUnwrapNativeEvent(eventLog: RawLogEntry): UnwrapNativeEvent {
const unwrapNativeEvent = new UnwrapNativeEvent();
parseEvent(eventLog, unwrapNativeEvent);
// decode the basic info
const decodedLog = abiCoder.decodeLog(UNWRAP_NATIVE_ABI.inputs, eventLog.data);
console.log(decodedLog);
const decodedLog = abiCoder.decodeLog(UNWRAP_NATIVE_ABI.inputs, eventLog.data, [eventLog.topics[1]]);

unwrapNativeEvent.src = decodedLog.src.toLowerCase();
unwrapNativeEvent.wad = new BigNumber(decodedLog.wad);
Expand Down
1 change: 0 additions & 1 deletion src/scripts/pull_and_save_events_by_topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export class EventsByTopicScraper {
),
);
}
console.log(props.name);
});

const txHashes = [
Expand Down

0 comments on commit 8cbef7a

Please sign in to comment.