Skip to content

Commit af5e65a

Browse files
authored
Add payer to data sets (#20)
* feat(datasets): add payer to data sets Signed-off-by: Jakub Sztandera <oss@kubuxu.com> * feat(datasets): add source metadata Signed-off-by: Jakub Sztandera <oss@kubuxu.com> --------- Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
1 parent be41f39 commit af5e65a

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

apps/ponder/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ Ponder owns the on-chain write schema in `apps/ponder/ponder.schema.ts`, with ta
1111

1212
- `providers`: current ServiceProviderRegistry state, including provider name from block-scoped `eth_call`s, the PDP
1313
product `serviceURL`, FWSS approval status, and endorsement status from the canonical ProviderIdSet.
14-
- `data_sets`: current FWSS dataset state. `with_cdn` and `with_ipfs_indexing` are extracted from dataset metadata.
15-
`pdp_end_epoch IS NOT NULL` means PDP payment termination has started.
14+
- `data_sets`: current FWSS dataset state, including the dataset payer and optional metadata `source`. `with_cdn` and
15+
`with_ipfs_indexing` are extracted from dataset metadata. `pdp_end_epoch IS NOT NULL` means PDP payment termination has
16+
started.
1617
- `pieces`: current piece inventory keyed by `(data_set_id, piece_id)`, with a secondary CID index for finding alternate
1718
providers.
1819

apps/ponder/ponder.schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export const dataSets = onchainTable(
2525
(t) => ({
2626
dataSetId: t.int8({ mode: 'bigint' }).primaryKey(),
2727
providerId: t.int8({ mode: 'bigint' }).notNull(),
28+
payer: t.text().notNull(),
29+
source: t.text(),
2830
metadata: t.jsonb(),
2931
withCdn: t.boolean().notNull(),
3032
withIpfsIndexing: t.boolean().notNull(),

apps/ponder/src/fwss.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ import { decodePiece } from './cid-utils.ts'
44
import { eventBlock, metadataFromEntries, metadataHasEmptyFlag } from './event-utils.ts'
55

66
ponder.on('FWSS:DataSetCreated', async ({ event, context }) => {
7-
const { dataSetId, providerId, metadataKeys, metadataValues } = event.args as {
7+
const { dataSetId, providerId, payer, metadataKeys, metadataValues } = event.args as {
88
dataSetId: bigint
99
providerId: bigint
10+
payer: `0x${string}`
1011
metadataKeys?: readonly string[]
1112
metadataValues?: readonly string[]
1213
}
1314

1415
const metadata = metadataFromEntries(metadataKeys, metadataValues)
16+
const source = metadata?.source ?? null
1517
const block = eventBlock(event)
1618
const withCdn = metadataHasEmptyFlag(metadata, 'withCDN')
1719
const withIpfsIndexing = metadataHasEmptyFlag(metadata, 'withIPFSIndexing')
@@ -21,6 +23,8 @@ ponder.on('FWSS:DataSetCreated', async ({ event, context }) => {
2123
.values({
2224
dataSetId,
2325
providerId,
26+
payer,
27+
source,
2428
metadata,
2529
withCdn,
2630
withIpfsIndexing,
@@ -31,6 +35,8 @@ ponder.on('FWSS:DataSetCreated', async ({ event, context }) => {
3135
})
3236
.onConflictDoUpdate({
3337
providerId,
38+
payer,
39+
source,
3440
metadata,
3541
withCdn,
3642
withIpfsIndexing,

packages/repair-db/src/schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export const dataSets = pgTable(
2525
{
2626
dataSetId: bigint('data_set_id', { mode: 'bigint' }).primaryKey(),
2727
providerId: bigint('provider_id', { mode: 'bigint' }).notNull(),
28+
payer: text('payer').notNull(),
29+
source: text('source'),
2830
metadata: jsonb('metadata').$type<JsonRecord | null>(),
2931
withCdn: boolean('with_cdn').notNull(),
3032
withIpfsIndexing: boolean('with_ipfs_indexing').notNull(),

0 commit comments

Comments
 (0)