-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(store-indexer,store-sync): filter by table and key #1794
Conversation
🦋 Changeset detectedLatest commit: f7a366a The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
packages/store-sync/src/common.ts
Outdated
@@ -26,6 +26,14 @@ export type TableWithRecords = Table & { records: TableRecord[] }; | |||
export type StoreEventsLog = Log<bigint, number, false, StoreEventsAbiItem, true, StoreEventsAbi>; | |||
export type BlockLogs = { blockNumber: StoreEventsLog["blockNumber"]; logs: StoreEventsLog[] }; | |||
|
|||
// TODO: should we add address here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's best if we keep address
outside of this to align with eth_getLogs
filtering capability (where address is separate from topics): https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs
await waitForInitialSync(page); | ||
|
||
const entities = await callPageFunction(page, "getKeys", ["Position"]); | ||
expect(entities).toEqual([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't use toMatchInlineSnapshot
here due to the describe.each
above
```ts | ||
syncToRecs({ | ||
... | ||
filters: [{ tableId: '0x...', key0: '0x...' }], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i assume key0
and key1
need to be the Store encoded hex values correct? bytes32
encoded version of the key correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct, yep! can add to the typedoc
@@ -13,7 +14,10 @@ import { getAddress } from "viem"; | |||
*/ | |||
export async function createQueryAdapter(database: PgDatabase<any>): Promise<QueryAdapter> { | |||
const adapter: QueryAdapter = { | |||
async findAll({ chainId, address, tableIds = [] }) { | |||
async findAll({ chainId, address, filters = [] }) { | |||
// If _any_ filter has a table ID, this will filter down all data to just those tables. Which mean we can't yet mix table filters with key-only filters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add this to the changeset? Might make it easier to update in the docs later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up making tableId
required for now, so this comment doesn't really apply but I left it here so that we revisit this once we make tableId
optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳
Co-authored-by: alvarius <[email protected]>
Just making a note to myself: I decided to do the breaking change at the indexer level but probably should have done the backwards-compatibility one there too, to make it easier to safely bump the indexer without breaking clients (clients may start getting errors when sending |
closes #1639