Skip to content

Commit

Permalink
fix event type in event handler context
Browse files Browse the repository at this point in the history
  • Loading branch information
hazelnutcloud committed Aug 8, 2023
1 parent 9bc5bbc commit ef1fe59
Show file tree
Hide file tree
Showing 17 changed files with 750 additions and 290 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# v0.4.21
- Fix event type in event handler contexts

# v0.4.20
- Add two new utility functions:
- `getClosestTimestamp`
Expand Down
2 changes: 1 addition & 1 deletion cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from './cli/mod.ts'
import 'https://deno.land/[email protected]/dotenv/load.ts'

export const version = 'v0.4.20'
export const version = 'v0.4.21'

const command = new Command()
.name('arkiver')
Expand Down
4 changes: 2 additions & 2 deletions cli/start/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { colors, mongoose, SchemaComposer } from '../../src/deps.ts'
import { logger } from '../../src/logger.ts'
import { collectRpcUrls } from '../utils.ts'


export const action = async (
options: {
manifest?: string
Expand Down Expand Up @@ -133,7 +132,8 @@ export const action = async (
'mongodb://admin:password@localhost:27017'
await mongoose.connect(connectionString, {
dbName: '0-0',
})
// deno-lint-ignore no-explicit-any
} as any)
logger('arkiver').debug(`Connected to database`)

if (!options.gqlOnly) {
Expand Down
990 changes: 722 additions & 268 deletions deno.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/block-handler-vaults/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export {
createEntity,
type EventHandlerFor,
Manifest,
} from 'https://deno.land/x/[email protected].20/mod.ts'
} from 'https://deno.land/x/[email protected].21/mod.ts'
2 changes: 1 addition & 1 deletion examples/block-handler-vaults/handlers/vault.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { formatUnits, getContract } from 'npm:viem'
import { type BlockHandler } from 'https://deno.land/x/[email protected].20/mod.ts'
import { type BlockHandler } from 'https://deno.land/x/[email protected].21/mod.ts'
import { VaultSnapshot } from '../entities/vault.ts'
import { YEARN_V2_ABI } from '../abis/YearnV2.ts'

Expand Down
2 changes: 1 addition & 1 deletion examples/block-handler-vaults/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Manifest } from 'https://deno.land/x/[email protected].20/mod.ts'
import { Manifest } from 'https://deno.land/x/[email protected].21/mod.ts'
import { VaultSnapshot } from './entities/vault.ts'
import { snapshotVault } from './handlers/vault.ts'

Expand Down
2 changes: 1 addition & 1 deletion examples/erc20-balance-history/entities.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createEntity } from 'https://deno.land/x/[email protected].20/mod.ts'
import { createEntity } from 'https://deno.land/x/[email protected].21/mod.ts'

// @note: "Index: true" enhances graphql queries

Expand Down
2 changes: 1 addition & 1 deletion examples/erc20-balance-history/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { formatUnits, fromHex, numberToHex } from 'npm:viem'
import { type EventHandlerFor } from 'https://deno.land/x/[email protected].20/mod.ts'
import { type EventHandlerFor } from 'https://deno.land/x/[email protected].21/mod.ts'
import erc20 from './erc20.ts'
import { Balance, BalanceHistory, Transfer } from './entities.ts'

Expand Down
2 changes: 1 addition & 1 deletion examples/erc20-balance-history/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Manifest } from 'https://deno.land/x/[email protected].20/mod.ts'
import { Manifest } from 'https://deno.land/x/[email protected].21/mod.ts'
import { ERC_20_ABI } from './Erc20.ts'
import { Entities } from './entities.ts'
import { onTransfer } from './handlers.ts'
Expand Down
2 changes: 1 addition & 1 deletion examples/erc20-events/entities.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createEntity } from 'https://deno.land/x/[email protected].20/mod.ts'
import { createEntity } from 'https://deno.land/x/[email protected].21/mod.ts'

// @note: "Index: true" enhances graphql queries
export const Transfer = createEntity<any>('Transfer', {
Expand Down
2 changes: 1 addition & 1 deletion examples/erc20-events/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { formatUnits } from 'npm:viem'
import { type EventHandlerFor } from 'https://deno.land/x/[email protected].20/mod.ts'
import { type EventHandlerFor } from 'https://deno.land/x/[email protected].21/mod.ts'
import { ERC_20_ABI } from './Erc20.ts'
import { Approval, Transfer } from './entities.ts'

Expand Down
2 changes: 1 addition & 1 deletion examples/erc20-events/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Manifest } from 'https://deno.land/x/[email protected].20/mod.ts'
import { Manifest } from 'https://deno.land/x/[email protected].21/mod.ts'
import { ERC_20_ABI } from './Erc20.ts'
import { Approval, Transfer } from './entities.ts'
import { onApproval, onTransfer } from './handlers.ts'
Expand Down
2 changes: 1 addition & 1 deletion examples/event-wildcard/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export {
createEntity,
type EventHandlerFor,
Manifest,
} from 'https://deno.land/x/[email protected].20/mod.ts'
} from 'https://deno.land/x/[email protected].21/mod.ts'
4 changes: 2 additions & 2 deletions examples/library/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ export {
createEntity,
type EventHandlerFor,
Manifest,
} from 'https://deno.land/x/[email protected].20/mod.ts'
} from 'https://deno.land/x/[email protected].21/mod.ts'
export {
Erc721Lib,
type Erc721Opts,
} from 'https://deno.land/x/[email protected].20/libs.ts'
} from 'https://deno.land/x/[email protected].21/libs.ts'
2 changes: 1 addition & 1 deletion examples/simple/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export {
createEntity,
type EventHandlerFor,
Manifest,
} from 'https://deno.land/x/[email protected].20/mod.ts'
} from 'https://deno.land/x/[email protected].21/mod.ts'
15 changes: 9 additions & 6 deletions src/arkiver/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,16 @@ export type EventHandlerFor<
TEventName extends ExtractAbiEventNames<TAbi>,
> = EventHandler<ExtractAbiEvent<TAbi, TEventName>, TEventName, TAbi>

type RecursiveNonNullable<T> = T extends Record<string, unknown> ? {
[K in keyof T]-?: RecursiveNonNullable<T[K]>
}
: NonNullable<T>
type RecursiveNonNullable<T> = {
[K in keyof T]-?: RecursiveNonNullable<NonNullable<T[K]>>
}

export type SafeLog<TAbiEvent extends AbiEvent> = RecursiveNonNullable<
Log<bigint, number, TAbiEvent, true, [TAbiEvent]>
export type SafeLog<TAbiEvent extends AbiEvent> = Log<
bigint,
number,
false,
TAbiEvent,
true
>

export type SafeRpcLog = RecursiveNonNullable<RpcLog>
Expand Down

0 comments on commit ef1fe59

Please sign in to comment.