Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
event-cache package (#1975)
Browse files Browse the repository at this point in the history
* initial commit of event-cache

* I should learn how to spell

* added IndexedDBBackend

* forgot the IndexedDBBackend serializer methods

* improved docstrings for IndexedDBBackend module

* Run tests for event-cache on travis CI

* fix path to mocha in event-cache package.json

* attempt to fix missing mocha on travis build

* might help if I altered the correct job

* set NODE_ENV for travis job and moved mocha to dependencies

* bootstrap, specifically @origin/contracts does not like NODE_ENV=test

* travis debugging

* trying relative path to mocha again in npm script

* Travis! debugging

* moving event-cache job def up higher in the order

* missing --scope from bootstrap command

* added missing --scope for @origin/ipfs

* missing babel packages from event-cache/package.json

* removed debugging from .travis.yml

* fixed docstring and improved README

* docstring fix

* removes event table from discovery

* added PostgreSQLBackend to event-cache

* added --migrations-path to npm migration script for event-cache

* added --config to migrate npm script

* pg must be installed explicitly, apparently

* can't index a column that doesn't exist

* load latestBlock from DB if the backend is persistent

* start event fetch from latest known to the cache unless otherwise provided

* make it prettier

* Added PostgreSQLBackend to platform resolution

* previous created_at field was for blocktime, as stolen from discovery.  Not necessary here.

* Make postgres backend's loadSerialized error more informative

* run migrations in the event-listener container

* don't allow the latestBlock to be walked back and a random eslint error that just showed up

* set timestamps:false to prevent sequelize from attempting to use them

* removes idb, adds Dexie, adds support for array "OR" args, and fixes bugs in memory backend

* merged master

* updates graphql, fixes a bug where latest block would not be fetched, adds event ordering, moved pg/sequelize to optionalDependencies, refacored to use require/module.exports, mobile will use memory for now, added webpack config

* deploy contracts for testing, and removed some localStorage stuff from a hinky merge

* prettier

* Try to make travis happy

* removed bad sortBy and made sure all returnValues args are strings, same as events

* fixing some missed EventCache calls in User resolver

* Increate test timeout

* removed garbage

* use a unique IndexedDB database for each contract instance, and let graphql manage the blockNumber if it wants

* address isn't always defined for a contract

* WIP mainnet fixes

* Efficiency fixes

* Removed listener code no longer needed for Nick's event cache.

* Event cache updates

* IPFS cache

* make background grey only in profile view (#2060)

* Fix Docker Compose for new contract configuration method (#2102)

* Replace linker-client with mobile-bridge in deployments

* Add open port in services in Docker to indicate ready

* Update service configs

* Fix fixtures and environment variables

* Update FractionalListing price calculation and booking availability (#2104)

* Update nightly price estimation for fractional listing

* Make checkout slots as available

* Prettify stuffs

* Update deployed image tag for origin-dapp [ci skip]

* Update deployed image tag for origin-dapp [ci skip]

* Update deployed image tag for origin-dapp [ci skip]

* Add country column to identity table (#2083)

* Add country column to identity table

* tweak comments

* Fix unit tests

* linter

* prettier

* Make call to handleEvent synchronous

* Update deployed image tag for origin-growth [ci skip]

* Update deployed image tag for event-listener [ci skip]

* New Crowdin translations (#1863)

* New translations all-messages.json (Spanish)

* New translations all-messages.json (Slovenian)

* New translations all-messages.json (Slovak)

* New translations all-messages.json (Serbian (Latin))

* New translations all-messages.json (Russian)

* New translations all-messages.json (Romanian)

* New translations all-messages.json (Portuguese)

* New translations all-messages.json (Polish)

* New translations all-messages.json (Lao)

* New translations all-messages.json (Japanese)

* New translations all-messages.json (Bosnian)

* New translations all-messages.json (Italian)

* New translations all-messages.json (Indonesian)

* New translations all-messages.json (Hindi)

* New translations all-messages.json (Greek)

* New translations all-messages.json (German)

* New translations all-messages.json (French)

* New translations all-messages.json (Filipino)

* New translations all-messages.json (Esperanto)

* New translations all-messages.json (Dutch)

* New translations all-messages.json (Danish)

* New translations all-messages.json (Czech)

* New translations all-messages.json (Croatian)

* New translations all-messages.json (Chinese Traditional)

* New translations all-messages.json (Chinese Simplified)

* New translations all-messages.json (Acholi)

* New translations all-messages.json (Bengali)

* New translations all-messages.json (Korean)

* New translations all-messages.json (Vietnamese)

* New translations all-messages.json (Ukrainian)

* New translations all-messages.json (Turkish)

* New translations all-messages.json (Thai)

* New translations all-messages.json (Telugu)

* New translations all-messages.json (Spanish)

* New translations all-messages.json (Slovenian)

* New translations all-messages.json (Slovak)

* New translations all-messages.json (Serbian (Latin))

* New translations all-messages.json (Russian)

* New translations all-messages.json (Romanian)

* New translations all-messages.json (Portuguese)

* New translations all-messages.json (Polish)

* New translations all-messages.json (Lao)

* New translations all-messages.json (Japanese)

* New translations all-messages.json (Bosnian)

* New translations all-messages.json (Italian)

* New translations all-messages.json (Indonesian)

* New translations all-messages.json (Hindi)

* New translations all-messages.json (Greek)

* New translations all-messages.json (German)

* New translations all-messages.json (French)

* New translations all-messages.json (Filipino)

* New translations all-messages.json (Esperanto)

* New translations all-messages.json (Dutch)

* New translations all-messages.json (Danish)

* New translations all-messages.json (Czech)

* New translations all-messages.json (Croatian)

* New translations all-messages.json (Chinese Traditional)

* New translations all-messages.json (Chinese Simplified)

* New translations all-messages.json (Acholi)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Chinese Simplified)

* New translations all-messages.json (Chinese Simplified)

* New translations all-messages.json (Chinese Simplified)

* New translations all-messages.json (Chinese Simplified)

* New translations all-messages.json (Chinese Simplified)

* New translations all-messages.json (Korean)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Bengali)

* New translations all-messages.json (Korean)

* New translations all-messages.json (Vietnamese)

* New translations all-messages.json (Ukrainian)

* New translations all-messages.json (Turkish)

* New translations all-messages.json (Thai)

* New translations all-messages.json (Telugu)

* New translations all-messages.json (Spanish)

* New translations all-messages.json (Slovenian)

* New translations all-messages.json (Slovak)

* New translations all-messages.json (Serbian (Latin))

* New translations all-messages.json (Russian)

* New translations all-messages.json (Romanian)

* New translations all-messages.json (Portuguese)

* New translations all-messages.json (Polish)

* New translations all-messages.json (Lao)

* New translations all-messages.json (Japanese)

* New translations all-messages.json (Bosnian)

* New translations all-messages.json (Italian)

* New translations all-messages.json (Indonesian)

* New translations all-messages.json (Hindi)

* New translations all-messages.json (Greek)

* New translations all-messages.json (German)

* New translations all-messages.json (French)

* New translations all-messages.json (Filipino)

* New translations all-messages.json (Esperanto)

* New translations all-messages.json (Dutch)

* New translations all-messages.json (Danish)

* New translations all-messages.json (Czech)

* New translations all-messages.json (Croatian)

* New translations all-messages.json (Chinese Traditional)

* New translations all-messages.json (Chinese Simplified)

* New translations all-messages.json (Acholi)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Italian)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Japanese)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Italian)

* New translations all-messages.json (Italian)

* New translations all-messages.json (Italian)

* New translations all-messages.json (Bengali)

* New translations all-messages.json (Indonesian)

* New translations all-messages.json (Slovenian)

* New translations all-messages.json (Slovak)

* New translations all-messages.json (Serbian (Latin))

* New translations all-messages.json (Russian)

* New translations all-messages.json (Romanian)

* New translations all-messages.json (Portuguese)

* New translations all-messages.json (Polish)

* New translations all-messages.json (Lao)

* New translations all-messages.json (Korean)

* New translations all-messages.json (Bosnian)

* New translations all-messages.json (Italian)

* New translations all-messages.json (Japanese)

* New translations all-messages.json (Hindi)

* New translations all-messages.json (Danish)

* New translations all-messages.json (Chinese Simplified)

* New translations all-messages.json (Chinese Traditional)

* New translations all-messages.json (Greek)

* New translations all-messages.json (Czech)

* New translations all-messages.json (Croatian)

* New translations all-messages.json (Dutch)

* New translations all-messages.json (Esperanto)

* New translations all-messages.json (Filipino)

* New translations all-messages.json (French)

* New translations all-messages.json (German)

* New translations all-messages.json (Spanish)

* New translations all-messages.json (Telugu)

* New translations all-messages.json (Thai)

* New translations all-messages.json (Turkish)

* New translations all-messages.json (Ukrainian)

* New translations all-messages.json (Vietnamese)

* New translations all-messages.json (Acholi)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Japanese)

* New translations all-messages.json (Japanese)

* New translations all-messages.json (Italian)

* New translations all-messages.json (Italian)

* New translations all-messages.json (German)

* New translations all-messages.json (Italian)

* New translations all-messages.json (German)

* New translations all-messages.json (Bengali)

* New translations all-messages.json (Korean)

* New translations all-messages.json (Vietnamese)

* New translations all-messages.json (Ukrainian)

* New translations all-messages.json (Turkish)

* New translations all-messages.json (Thai)

* New translations all-messages.json (Telugu)

* New translations all-messages.json (Spanish)

* New translations all-messages.json (Slovenian)

* New translations all-messages.json (Slovak)

* New translations all-messages.json (Serbian (Latin))

* New translations all-messages.json (Russian)

* New translations all-messages.json (Romanian)

* New translations all-messages.json (Portuguese)

* New translations all-messages.json (Polish)

* New translations all-messages.json (Lao)

* New translations all-messages.json (Japanese)

* New translations all-messages.json (Bosnian)

* New translations all-messages.json (Italian)

* New translations all-messages.json (Indonesian)

* New translations all-messages.json (Hindi)

* New translations all-messages.json (Greek)

* New translations all-messages.json (German)

* New translations all-messages.json (French)

* New translations all-messages.json (Filipino)

* New translations all-messages.json (Esperanto)

* New translations all-messages.json (Dutch)

* New translations all-messages.json (Danish)

* New translations all-messages.json (Czech)

* New translations all-messages.json (Croatian)

* New translations all-messages.json (Chinese Traditional)

* New translations all-messages.json (Chinese Simplified)

* New translations all-messages.json (Acholi)

* New translations all-messages.json (Italian)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Italian)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Japanese)

* New translations all-messages.json (Greek)

* New translations all-messages.json (Greek)

* New translations all-messages.json (Chinese Simplified)

* New translations all-messages.json (Chinese Simplified)

* New translations all-messages.json (Chinese Simplified)

* New translations all-messages.json (Chinese Simplified)

* New translations all-messages.json (Chinese Traditional)

* New translations all-messages.json (Chinese Traditional)

* New translations all-messages.json (Chinese Simplified)

* New translations all-messages.json (Bengali)

* New translations all-messages.json (Korean)

* New translations all-messages.json (Vietnamese)

* New translations all-messages.json (Ukrainian)

* New translations all-messages.json (Turkish)

* New translations all-messages.json (Thai)

* New translations all-messages.json (Telugu)

* New translations all-messages.json (Spanish)

* New translations all-messages.json (Slovenian)

* New translations all-messages.json (Slovak)

* New translations all-messages.json (Serbian (Latin))

* New translations all-messages.json (Russian)

* New translations all-messages.json (Romanian)

* New translations all-messages.json (Portuguese)

* New translations all-messages.json (Polish)

* New translations all-messages.json (Lao)

* New translations all-messages.json (Japanese)

* New translations all-messages.json (Bosnian)

* New translations all-messages.json (Italian)

* New translations all-messages.json (Indonesian)

* New translations all-messages.json (Hindi)

* New translations all-messages.json (Greek)

* New translations all-messages.json (German)

* New translations all-messages.json (French)

* New translations all-messages.json (Filipino)

* New translations all-messages.json (Esperanto)

* New translations all-messages.json (Dutch)

* New translations all-messages.json (Danish)

* New translations all-messages.json (Czech)

* New translations all-messages.json (Croatian)

* New translations all-messages.json (Chinese Traditional)

* New translations all-messages.json (Chinese Simplified)

* New translations all-messages.json (Acholi)

* New translations all-messages.json (Korean)

* New translations all-messages.json (Korean)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Russian)

* New translations all-messages.json (Korean)

* New translations all-messages.json (Korean)

* New translations all-messages.json (Korean)

* Update deployed image tag for origin-dapp [ci skip]

* Misc mobile fixes (#2106)

* Fix spelling mistake

* Handle global Notification on mobile

* Decrease balance poll interval

* Run prettier

* Tweak balance poll interval

* Update deployed image tag for origin-dapp [ci skip]

* Event cache dapp fixes

* Re-add indexeddb

* Add event-cache to dockerfiles

* Disable Postgres backend for now

* Revert "Disable Postgres backend for now"

This reverts commit 365d04a.

* Do not insert in the old event table

* Lint

* Fix for fresh deploy

* GraphQL test fix

* Block range fix

* Trigger build
  • Loading branch information
mikeshultz authored and nick committed May 3, 2019
1 parent 1fa8f23 commit 0dd4b5d
Show file tree
Hide file tree
Showing 51 changed files with 2,886 additions and 560 deletions.
22 changes: 20 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,28 @@ matrix:
node_js: 10
install:
- npm install --ignore-scripts
- npm run bootstrap -- --scope @origin/contracts --scope @origin/eventsource --scope @origin/ipfs --scope @origin/messaging-client --scope @origin/services --scope @origin/validator --scope @origin/mobile-bridge --scope @origin/graphql
- npm run bootstrap -- --scope @origin/contracts --scope @origin/eventsource --scope @origin/ipfs --scope @origin/messaging-client --scope @origin/services --scope @origin/validator --scope @origin/mobile-bridge --scope @origin/graphql --scope @origin/event-cache
script:
- npm run test --prefix packages/graphql

- name: "@origin/event-cache unit tests"
language: node_js
node_js: 10
addons:
postgresql: 9.6
services:
- postgresql
env:
- DATABASE_URL=postgres://postgres@localhost/travis_ci_test
before_script:
- psql -c 'create database travis_ci_test;' -U postgres
- lerna run migrate --scope @origin/event-cache
install:
- npm install --ignore-scripts
- npm run bootstrap -- --scope @origin/contracts --scope @origin/eventsource --scope @origin/ipfs --scope @origin/messaging-client --scope @origin/services --scope @origin/validator --scope @origin/mobile-bridge --scope @origin/graphql --scope @origin/event-cache
script:
- npm run test --prefix packages/event-cache

- name: "@origin/bridge unit tests"
language: node_js
node_js: 10
Expand Down Expand Up @@ -103,7 +121,7 @@ matrix:
- lerna run migrate --scope @origin/identity
install:
- npm install --ignore-scripts
- npm run bootstrap -- --scope @origin/contracts --scope @origin/eventsource --scope @origin/ipfs --scope @origin/messaging-client --scope @origin/services --scope @origin/validator --scope @origin/mobile-bridge --scope @origin/graphql --scope @origin/bridge --scope @origin/identity --scope @origin/token --scope @origin/growth
- npm run bootstrap -- --scope @origin/contracts --scope @origin/eventsource --scope @origin/ipfs --scope @origin/messaging-client --scope @origin/services --scope @origin/validator --scope @origin/mobile-bridge --scope @origin/graphql --scope @origin/bridge --scope @origin/identity --scope @origin/token --scope @origin/growth --scope @origin/event-cache
script:
- npm run test --prefix infra/growth

Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ COPY ./packages/validator/package.json ./packages/validator/
COPY ./packages/messaging-client/package.json ./packages/messaging-client/
COPY ./packages/mobile-bridge/package.json ./packages/mobile-bridge/
COPY ./packages/eventsource/package.json ./packages/eventsource/
COPY ./packages/event-cache/package.json ./packages/event-cache/
COPY ./packages/services/package.json ./packages/services/
COPY ./packages/token/package.json ./packages/token/
COPY ./infra/discovery/package.json ./infra/discovery/
Expand Down
2 changes: 1 addition & 1 deletion dapps/marketplace/src/pages/transactions/Listings.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class Listings extends Component {
</div>
<div className="title">
<Link to={`/listing/${listing.id}`}>
{listing.title}
{listing.title || <i>Untitled Listing</i>}
</Link>
</div>
<div className="date">
Expand Down
4 changes: 3 additions & 1 deletion devops/dockerfiles/event-listener
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ COPY package*.json ./
COPY lerna.json ./
COPY ./packages/contracts ./packages/contracts
COPY ./packages/eventsource ./packages/eventsource
COPY ./packages/event-cache ./packages/event-cache
COPY ./packages/graphql ./packages/graphql
COPY ./packages/ipfs ./packages/ipfs
COPY ./packages/messaging-client ./packages/messaging-client
Expand All @@ -35,6 +36,7 @@ RUN npm install --unsafe-perm
COPY ./packages/contracts/releases/0.8.6/build/ ./packages/contracts/build/

CMD eval $(envkey-source) && \
npm run migrate --prefix infra/discovery && \
npm run migrate --prefix infra/discovery && \
npm run migrate --prefix packages/event-cache && \
npm run migrate --prefix infra/identity && \
npm run start:listener --prefix infra/discovery
1 change: 1 addition & 0 deletions devops/dockerfiles/origin-admin
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ COPY package*.json ./
COPY lerna.json ./
COPY ./packages/contracts ./packages/contracts
COPY ./packages/eventsource/ ./packages/eventsource/
COPY ./packages/event-cache ./packages/event-cache
COPY ./packages/graphql/ ./packages/graphql/
COPY ./packages/ipfs/ ./packages/ipfs/
COPY ./packages/mobile-bridge/ ./packages/mobile-bridge/
Expand Down
1 change: 1 addition & 0 deletions devops/dockerfiles/origin-cron
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUN mv envkey-source /usr/local/bin
COPY package*.json ./
COPY lerna.json ./
COPY ./packages/eventsource ./packages/eventsource
COPY ./packages/event-cache ./packages/event-cache
COPY ./packages/graphql ./packages/graphql
COPY ./packages/ipfs ./packages/ipfs
COPY ./packages/mobile-bridge ./packages/mobile-bridge
Expand Down
1 change: 1 addition & 0 deletions devops/dockerfiles/origin-dapp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ COPY package*.json ./
COPY lerna.json ./
COPY ./packages/contracts ./packages/contracts
COPY ./packages/eventsource/ ./packages/eventsource
COPY ./packages/event-cache/ ./packages/event-cache
COPY ./packages/graphql/ ./packages/graphql
COPY ./packages/ipfs/ ./packages/ipfs
COPY ./packages/mobile-bridge/ ./packages/mobile-bridge
Expand Down
1 change: 1 addition & 0 deletions devops/dockerfiles/origin-dapp-creator-client
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ COPY lerna.json ./
# graphql and its dependencies
COPY ./packages/graphql ./packages/graphql
COPY ./packages/eventsource ./packages/eventsource
COPY ./packages/event-cache ./packages/event-cache
COPY ./packages/ipfs ./packages/ipfs
COPY ./packages/mobile-bridge ./packages/mobile-bridge
COPY ./packages/messaging-client ./packages/messaging-client
Expand Down
1 change: 1 addition & 0 deletions devops/dockerfiles/origin-discovery
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ COPY package*.json ./
COPY lerna.json ./
COPY ./packages/contracts ./packages/contracts
COPY ./packages/eventsource ./packages/eventsource
COPY ./packages/event-cache ./packages/event-cache
COPY ./packages/graphql ./packages/graphql
COPY ./packages/ipfs ./packages/ipfs
COPY ./packages/messaging-client ./packages/messaging-client
Expand Down
1 change: 1 addition & 0 deletions devops/dockerfiles/origin-growth
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUN mv envkey-source /usr/local/bin
COPY package*.json ./
COPY lerna.json ./
COPY ./packages/eventsource ./packages/eventsource
COPY ./packages/event-cache ./packages/event-cache
COPY ./packages/graphql ./packages/graphql
COPY ./packages/ipfs ./packages/ipfs
COPY ./packages/mobile-bridge ./packages/mobile-bridge
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ services:
- ./packages/services/:/app/packages/services/
- ./packages/graphql/:/app/packages/graphql/
- ./packages/eventsource/:/app/packages/eventsource/
- ./packages/event-cache/:/app/packages/event-cache/
- ./packages/ipfs/:/app/packages/ipfs/
- ./packages/messaging-client/:/app/packages/messaging-client/
- ./packages/mobile-bridge/:/app/packages/mobile-bridge/
Expand All @@ -68,6 +69,7 @@ services:
- /app/packages/services/node_modules/
- /app/packages/graphql/node_modules/
- /app/packages/eventsource/node_modules/
- /app/packages/event-cache/node_modules/
- /app/packages/ipfs/node_modules/
- /app/packages/messaging-client/node_modules/
- /app/packages/mobile-bridge/node_modules/
Expand Down
62 changes: 62 additions & 0 deletions infra/discovery/migrations/20190410191046-event-drop-table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
'use strict'

const TABLE_NAME = 'event'

module.exports = {
up: queryInterface => {
return queryInterface.dropTable(TABLE_NAME)
},

down: (queryInterface, Sequelize) => {
// The above is kind of irreversible, but...
return queryInterface
.createTable(TABLE_NAME, {
block_number: {
type: Sequelize.INTEGER,
primaryKey: true
},
log_index: {
type: Sequelize.INTEGER,
primaryKey: true
},
contract_address: {
type: Sequelize.CHAR(42),
allowNull: false
},
transaction_hash: {
type: Sequelize.CHAR(66),
allowNull: false
},
topic0: {
type: Sequelize.CHAR(66),
allowNull: false
},
topic1: {
type: Sequelize.CHAR(66),
allowNull: true
},
topic2: {
type: Sequelize.CHAR(66),
allowNull: true
},
topic3: {
type: Sequelize.CHAR(66),
allowNull: true
},
data: {
type: Sequelize.JSONB,
allowNull: false
},
created_at: {
type: Sequelize.DATE,
allowNull: true
}
})
.then(() => queryInterface.addIndex(TABLE_NAME, ['contract_address']))
.then(() => queryInterface.addIndex(TABLE_NAME, ['transaction_hash']))
.then(() => queryInterface.addIndex(TABLE_NAME, ['topic0']))
.then(() => queryInterface.addIndex(TABLE_NAME, ['topic1']))
.then(() => queryInterface.addIndex(TABLE_NAME, ['topic2']))
.then(() => queryInterface.addIndex(TABLE_NAME, ['topic3']))
}
}
18 changes: 0 additions & 18 deletions infra/discovery/src/listener/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const esmImport = require('esm')(module)
const graphqlClient = esmImport('@origin/graphql').default

const logger = require('./logger')
const db = require('../models')
const { withRetrys } = require('./utils')
const MarketplaceEventHandler = require('./handler_marketplace')
const IdentityEventHandler = require('./handler_identity')
Expand Down Expand Up @@ -47,29 +46,12 @@ async function handleEvent(event, context) {
await withRetrys(async () => {
block = await context.web3.eth.getBlock(event.blockNumber)
})
const blockDate = new Date(block.timestamp * 1000)

const eventDetails = `blockNumber=${event.blockNumber} \
transactionIndex=${event.transactionIndex} \
eventName=${event.event}`
logger.info(`Processing event: ${eventDetails}`)

// Record the event in the DB.
await withRetrys(async () => {
return db.Event.upsert({
blockNumber: event.blockNumber,
logIndex: event.logIndex,
contractAddress: event.address,
transactionHash: event.transactionHash,
topic0: event.raw.topics[0],
topic1: event.raw.topics[1],
topic2: event.raw.topics[2],
topic3: event.raw.topics[3],
data: event,
createdAt: blockDate
})
})

// Call the event handler.
//
// Note: we run the handler with a retry since we've seen in production cases where we fail loading
Expand Down
4 changes: 0 additions & 4 deletions infra/discovery/src/listener/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,6 @@ async function main() {
}
logger.info(`Querying events from ${processedToBlock} up to ${toBlock}`)

// Update the event caches to set their max block number.
contractsContext.marketplace.eventCache.updateBlock(toBlock)
contractsContext.identityEvents.eventCache.updateBlock(toBlock)

// Retrieve all events for the relevant contracts
const eventArrays = await Promise.all([
withRetrys(async () => {
Expand Down
39 changes: 0 additions & 39 deletions infra/discovery/src/models/event.js

This file was deleted.

Loading

0 comments on commit 0dd4b5d

Please sign in to comment.