Skip to content

Commit

Permalink
Add Socket Bridge Event (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ktl-XV authored Nov 1, 2023
1 parent f37d804 commit b4ed69c
Show file tree
Hide file tree
Showing 26 changed files with 549 additions and 181 deletions.
9 changes: 8 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ services:
ONCHAIN_GOVERNANCE_START_BLOCK: 16990159
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
FEAT_SOCKET_BRIDGE_EVENT: "true"
SOCKET_BRIDGE_CONTRACT_ADDRESS: "0x3a23f943181408eac424116af7b7790c94cb97a5"
SOCKET_BRIDGE_EVENT_START_BLOCK: 18473454

event-pipeline-bsc:
depends_on:
Expand Down Expand Up @@ -239,12 +242,16 @@ services:
EP_DEPLOYMENT_BLOCK: 1691335
MAX_BLOCKS_TO_SEARCH: 1000
MAX_BLOCKS_TO_PULL: 1000
SECONDS_BETWEEN_RUNS: 30
SECONDS_BETWEEN_RUNS: 1
EP_ADDRESS: "0xdef1abe32c034e558cdd535791643c58a13acc10"
FEAT_TRANSFORMED_ERC20_EVENT: "true"
FEAT_NFT: "true"
NFT_FEATURE_START_BLOCK: 4214981
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: "0x4200000000000000000000000000000000000006"
FEAT_SOCKET_BRIDGE_EVENT: "true"
SOCKET_BRIDGE_CONTRACT_ADDRESS: "0x3a23f943181408eac424116af7b7790c94cb97a5"
SOCKET_BRIDGE_EVENT_START_BLOCK: 110791294

event-pipeline-arbitrum:
depends_on:
Expand Down
36 changes: 36 additions & 0 deletions migrations/arbitrum/1698670784000-CreateSocketBridgeEventTable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { MigrationInterface, QueryRunner, getConnection } from 'typeorm';

export class CreateSocketBridgeEventTable1698670784000 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`
CREATE TABLE ${schema}.socket_bridge_events (
observed_timestamp BIGINT NOT NULL,
contract_address VARCHAR NOT NULL,
transaction_hash VARCHAR NOT NULL,
transaction_index BIGINT NOT NULL,
log_index BIGINT NOT NULL,
block_hash VARCHAR NOT NULL,
block_number BIGINT NOT NULL,
amount NUMERIC NOT NULL,
token VARCHAR NOT NULL,
to_chain_id NUMERIC NOT NULL,
bridge_name VARCHAR NOT NULL,
sender VARCHAR NOT NULL,
receiver VARCHAR NOT NULL,
metadata VARCHAR NOT NULL,
PRIMARY KEY (transaction_hash, log_index)
);
CREATE INDEX socket_bridge_events_block_number_idx ON ${schema}.socket_bridge_events (block_number);
CREATE INDEX socket_bridge_events_sender_idx ON ${schema}.socket_bridge_events (sender);
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`DROP TABLE ${schema}.socket_bridge_events;`);
}
}
36 changes: 36 additions & 0 deletions migrations/avalanche/1698670784000-CreateSocketBridgeEventTable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { MigrationInterface, QueryRunner, getConnection } from 'typeorm';

export class CreateSocketBridgeEventTable1698670784000 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`
CREATE TABLE ${schema}.socket_bridge_events (
observed_timestamp BIGINT NOT NULL,
contract_address VARCHAR NOT NULL,
transaction_hash VARCHAR NOT NULL,
transaction_index BIGINT NOT NULL,
log_index BIGINT NOT NULL,
block_hash VARCHAR NOT NULL,
block_number BIGINT NOT NULL,
amount NUMERIC NOT NULL,
token VARCHAR NOT NULL,
to_chain_id NUMERIC NOT NULL,
bridge_name VARCHAR NOT NULL,
sender VARCHAR NOT NULL,
receiver VARCHAR NOT NULL,
metadata VARCHAR NOT NULL,
PRIMARY KEY (transaction_hash, log_index)
);
CREATE INDEX socket_bridge_events_block_number_idx ON ${schema}.socket_bridge_events (block_number);
CREATE INDEX socket_bridge_events_sender_idx ON ${schema}.socket_bridge_events (sender);
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`DROP TABLE ${schema}.socket_bridge_events;`);
}
}
36 changes: 36 additions & 0 deletions migrations/base/1698670784000-CreateSocketBridgeEventTable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { MigrationInterface, QueryRunner, getConnection } from 'typeorm';

export class CreateSocketBridgeEventTable1698670784000 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`
CREATE TABLE ${schema}.socket_bridge_events (
observed_timestamp BIGINT NOT NULL,
contract_address VARCHAR NOT NULL,
transaction_hash VARCHAR NOT NULL,
transaction_index BIGINT NOT NULL,
log_index BIGINT NOT NULL,
block_hash VARCHAR NOT NULL,
block_number BIGINT NOT NULL,
amount NUMERIC NOT NULL,
token VARCHAR NOT NULL,
to_chain_id NUMERIC NOT NULL,
bridge_name VARCHAR NOT NULL,
sender VARCHAR NOT NULL,
receiver VARCHAR NOT NULL,
metadata VARCHAR NOT NULL,
PRIMARY KEY (transaction_hash, log_index)
);
CREATE INDEX socket_bridge_events_block_number_idx ON ${schema}.socket_bridge_events (block_number);
CREATE INDEX socket_bridge_events_sender_idx ON ${schema}.socket_bridge_events (sender);
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`DROP TABLE ${schema}.socket_bridge_events;`);
}
}
36 changes: 36 additions & 0 deletions migrations/bsc/1698670784000-CreateSocketBridgeEventTable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { MigrationInterface, QueryRunner, getConnection } from 'typeorm';

export class CreateSocketBridgeEventTable1698670784000 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`
CREATE TABLE ${schema}.socket_bridge_events (
observed_timestamp BIGINT NOT NULL,
contract_address VARCHAR NOT NULL,
transaction_hash VARCHAR NOT NULL,
transaction_index BIGINT NOT NULL,
log_index BIGINT NOT NULL,
block_hash VARCHAR NOT NULL,
block_number BIGINT NOT NULL,
amount NUMERIC NOT NULL,
token VARCHAR NOT NULL,
to_chain_id NUMERIC NOT NULL,
bridge_name VARCHAR NOT NULL,
sender VARCHAR NOT NULL,
receiver VARCHAR NOT NULL,
metadata VARCHAR NOT NULL,
PRIMARY KEY (transaction_hash, log_index)
);
CREATE INDEX socket_bridge_events_block_number_idx ON ${schema}.socket_bridge_events (block_number);
CREATE INDEX socket_bridge_events_sender_idx ON ${schema}.socket_bridge_events (sender);
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`DROP TABLE ${schema}.socket_bridge_events;`);
}
}
36 changes: 36 additions & 0 deletions migrations/celo/1698670784000-CreateSocketBridgeEventTable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { MigrationInterface, QueryRunner, getConnection } from 'typeorm';

export class CreateSocketBridgeEventTable1698670784000 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`
CREATE TABLE ${schema}.socket_bridge_events (
observed_timestamp BIGINT NOT NULL,
contract_address VARCHAR NOT NULL,
transaction_hash VARCHAR NOT NULL,
transaction_index BIGINT NOT NULL,
log_index BIGINT NOT NULL,
block_hash VARCHAR NOT NULL,
block_number BIGINT NOT NULL,
amount NUMERIC NOT NULL,
token VARCHAR NOT NULL,
to_chain_id NUMERIC NOT NULL,
bridge_name VARCHAR NOT NULL,
sender VARCHAR NOT NULL,
receiver VARCHAR NOT NULL,
metadata VARCHAR NOT NULL,
PRIMARY KEY (transaction_hash, log_index)
);
CREATE INDEX socket_bridge_events_block_number_idx ON ${schema}.socket_bridge_events (block_number);
CREATE INDEX socket_bridge_events_sender_idx ON ${schema}.socket_bridge_events (sender);
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`DROP TABLE ${schema}.socket_bridge_events;`);
}
}
36 changes: 36 additions & 0 deletions migrations/ethereum/1698670784000-CreateSocketBridgeEventTable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { MigrationInterface, QueryRunner, getConnection } from 'typeorm';

export class CreateSocketBridgeEventTable1698670784000 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`
CREATE TABLE ${schema}.socket_bridge_events (
observed_timestamp BIGINT NOT NULL,
contract_address VARCHAR NOT NULL,
transaction_hash VARCHAR NOT NULL,
transaction_index BIGINT NOT NULL,
log_index BIGINT NOT NULL,
block_hash VARCHAR NOT NULL,
block_number BIGINT NOT NULL,
amount NUMERIC NOT NULL,
token VARCHAR NOT NULL,
to_chain_id NUMERIC NOT NULL,
bridge_name VARCHAR NOT NULL,
sender VARCHAR NOT NULL,
receiver VARCHAR NOT NULL,
metadata VARCHAR NOT NULL,
PRIMARY KEY (transaction_hash, log_index)
);
CREATE INDEX socket_bridge_events_block_number_idx ON ${schema}.socket_bridge_events (block_number);
CREATE INDEX socket_bridge_events_sender_idx ON ${schema}.socket_bridge_events (sender);
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`DROP TABLE ${schema}.socket_bridge_events;`);
}
}
36 changes: 36 additions & 0 deletions migrations/fantom/1698670784000-CreateSocketBridgeEventTable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { MigrationInterface, QueryRunner, getConnection } from 'typeorm';

export class CreateSocketBridgeEventTable1698670784000 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`
CREATE TABLE ${schema}.socket_bridge_events (
observed_timestamp BIGINT NOT NULL,
contract_address VARCHAR NOT NULL,
transaction_hash VARCHAR NOT NULL,
transaction_index BIGINT NOT NULL,
log_index BIGINT NOT NULL,
block_hash VARCHAR NOT NULL,
block_number BIGINT NOT NULL,
amount NUMERIC NOT NULL,
token VARCHAR NOT NULL,
to_chain_id NUMERIC NOT NULL,
bridge_name VARCHAR NOT NULL,
sender VARCHAR NOT NULL,
receiver VARCHAR NOT NULL,
metadata VARCHAR NOT NULL,
PRIMARY KEY (transaction_hash, log_index)
);
CREATE INDEX socket_bridge_events_block_number_idx ON ${schema}.socket_bridge_events (block_number);
CREATE INDEX socket_bridge_events_sender_idx ON ${schema}.socket_bridge_events (sender);
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`DROP TABLE ${schema}.socket_bridge_events;`);
}
}
36 changes: 36 additions & 0 deletions migrations/optimism/1698670784000-CreateSocketBridgeEventTable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { MigrationInterface, QueryRunner, getConnection } from 'typeorm';

export class CreateSocketBridgeEventTable1698670784000 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`
CREATE TABLE ${schema}.socket_bridge_events (
observed_timestamp BIGINT NOT NULL,
contract_address VARCHAR NOT NULL,
transaction_hash VARCHAR NOT NULL,
transaction_index BIGINT NOT NULL,
log_index BIGINT NOT NULL,
block_hash VARCHAR NOT NULL,
block_number BIGINT NOT NULL,
amount NUMERIC NOT NULL,
token VARCHAR NOT NULL,
to_chain_id NUMERIC NOT NULL,
bridge_name VARCHAR NOT NULL,
sender VARCHAR NOT NULL,
receiver VARCHAR NOT NULL,
metadata VARCHAR NOT NULL,
PRIMARY KEY (transaction_hash, log_index)
);
CREATE INDEX socket_bridge_events_block_number_idx ON ${schema}.socket_bridge_events (block_number);
CREATE INDEX socket_bridge_events_sender_idx ON ${schema}.socket_bridge_events (sender);
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`DROP TABLE ${schema}.socket_bridge_events;`);
}
}
36 changes: 36 additions & 0 deletions migrations/polygon/1698670784000-CreateSocketBridgeEventTable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { MigrationInterface, QueryRunner, getConnection } from 'typeorm';

export class CreateSocketBridgeEventTable1698670784000 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`
CREATE TABLE ${schema}.socket_bridge_events (
observed_timestamp BIGINT NOT NULL,
contract_address VARCHAR NOT NULL,
transaction_hash VARCHAR NOT NULL,
transaction_index BIGINT NOT NULL,
log_index BIGINT NOT NULL,
block_hash VARCHAR NOT NULL,
block_number BIGINT NOT NULL,
amount NUMERIC NOT NULL,
token VARCHAR NOT NULL,
to_chain_id NUMERIC NOT NULL,
bridge_name VARCHAR NOT NULL,
sender VARCHAR NOT NULL,
receiver VARCHAR NOT NULL,
metadata VARCHAR NOT NULL,
PRIMARY KEY (transaction_hash, log_index)
);
CREATE INDEX socket_bridge_events_block_number_idx ON ${schema}.socket_bridge_events (block_number);
CREATE INDEX socket_bridge_events_sender_idx ON ${schema}.socket_bridge_events (sender);
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`DROP TABLE ${schema}.socket_bridge_events;`);
}
}
15 changes: 15 additions & 0 deletions src/abis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1024,3 +1024,18 @@ export const TRANSFER_ABI = {
name: 'Transfer',
type: 'event',
};

export const SOCKET_BRIDGE_ABI = {
anonymous: false,
inputs: [
{ indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
{ indexed: false, internalType: 'address', name: 'token', type: 'address' },
{ indexed: false, internalType: 'uint256', name: 'toChainId', type: 'uint256' },
{ indexed: false, internalType: 'bytes32', name: 'bridgeName', type: 'bytes32' },
{ indexed: false, internalType: 'address', name: 'sender', type: 'address' },
{ indexed: false, internalType: 'address', name: 'receiver', type: 'address' },
{ indexed: false, internalType: 'bytes32', name: 'metadata', type: 'bytes32' },
],
name: 'SocketBridge',
type: 'event',
};
Loading

0 comments on commit b4ed69c

Please sign in to comment.