ponder 0.9.2 → 0.9.4-debug.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/ponder.js +2470 -3762
- package/dist/bin/ponder.js.map +1 -1
- package/dist/chunk-6AOFLZJ4.js +1692 -0
- package/dist/chunk-6AOFLZJ4.js.map +1 -0
- package/dist/chunk-DZFRP3KH.js +70 -0
- package/dist/chunk-DZFRP3KH.js.map +1 -0
- package/dist/{chunk-IFTUFVCL.js → chunk-MJKRYIBO.js} +3 -73
- package/dist/chunk-MJKRYIBO.js.map +1 -0
- package/dist/db-in86nyw7.d.ts +625 -0
- package/dist/experimental_unsafe_stores.d.ts +375 -0
- package/dist/experimental_unsafe_stores.js +11 -0
- package/dist/experimental_unsafe_stores.js.map +1 -0
- package/dist/index.d.ts +17 -429
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/package.json +5 -1
- package/src/bin/commands/codegen.ts +8 -10
- package/src/bin/commands/dev.ts +30 -42
- package/src/bin/commands/list.ts +9 -14
- package/src/bin/commands/serve.ts +26 -39
- package/src/bin/commands/start.ts +29 -42
- package/src/bin/utils/{shutdown.ts → exit.ts} +23 -37
- package/src/bin/utils/run.ts +275 -175
- package/src/bin/utils/runServer.ts +1 -5
- package/src/build/configAndIndexingFunctions.ts +547 -512
- package/src/build/index.ts +5 -8
- package/src/build/pre.ts +3 -0
- package/src/config/index.ts +9 -6
- package/src/database/index.ts +72 -72
- package/src/drizzle/kit/index.ts +3 -3
- package/src/experimental_unsafe_stores.ts +4 -0
- package/src/indexing/index.ts +0 -4
- package/src/indexing/service.ts +31 -93
- package/src/indexing-store/historical.ts +2 -4
- package/src/internal/common.ts +2 -0
- package/src/internal/errors.ts +9 -9
- package/src/internal/logger.ts +1 -1
- package/src/internal/metrics.ts +75 -103
- package/src/internal/shutdown.ts +25 -0
- package/src/internal/telemetry.ts +16 -18
- package/src/internal/types.ts +9 -1
- package/src/server/index.ts +3 -5
- package/src/sync/events.ts +4 -4
- package/src/sync/filter.ts +1 -0
- package/src/sync/index.ts +1046 -805
- package/src/sync-historical/index.ts +0 -37
- package/src/sync-realtime/index.ts +48 -48
- package/src/sync-store/encoding.ts +5 -5
- package/src/sync-store/index.ts +5 -23
- package/src/ui/index.ts +2 -11
- package/src/utils/checkpoint.ts +17 -3
- package/src/utils/chunk.ts +7 -0
- package/src/utils/generators.ts +66 -0
- package/src/utils/mutex.ts +34 -0
- package/src/utils/partition.ts +41 -0
- package/src/utils/requestQueue.ts +19 -10
- package/src/utils/zipper.ts +80 -0
- package/dist/chunk-IFTUFVCL.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { P as Prettify
|
|
1
|
+
import { P as Prettify } from './utils-ceNucOJb.js';
|
|
2
2
|
import { Abi, AbiEvent as AbiEvent$1, AbiFunction, AbiParametersToPrimitiveTypes, FormatAbiItem } from 'abitype';
|
|
3
|
-
import { AbiEvent, GetEventArgs, ParseAbiItem, Abi as Abi$1, Narrow, Transport,
|
|
4
|
-
import {
|
|
3
|
+
import { AbiEvent, GetEventArgs, ParseAbiItem, Abi as Abi$1, Narrow, Transport, Chain, Client, PublicRpcSchema, publicActions, MulticallParameters, MulticallReturnType, ContractFunctionName, ContractFunctionArgs, ReadContractParameters, ReadContractReturnType, SimulateContractParameters, SimulateContractReturnType, GetBlockReturnType, Address, GetTransactionCountReturnType, GetBlockTransactionCountReturnType, PublicActions, Hash } from 'viem';
|
|
4
|
+
import { T as TransactionReceipt, B as Block, a as Transaction, b as Transfer, c as Trace, L as Log, S as Schema, D as Db, R as ReadonlyDrizzle } from './db-in86nyw7.js';
|
|
5
|
+
export { MergeAbis, ReplaceBigInts, loadBalance, mergeAbis, rateLimit, replaceBigInts } from '@ponder/utils';
|
|
5
6
|
export { bigint, hex, onchainEnum, onchainTable, primaryKey } from './drizzle/onchain.js';
|
|
6
|
-
import
|
|
7
|
+
import * as hono from 'hono';
|
|
7
8
|
export { and, asc, avg, avgDistinct, between, count, countDistinct, desc, eq, exists, gt, gte, ilike, inArray, isNotNull, isNull, like, lt, lte, max, min, ne, not, notBetween, notExists, notIlike, notInArray, notLike, or, relations, sql, sum, sumDistinct } from 'drizzle-orm';
|
|
8
|
-
import { NodePgDatabase } from 'drizzle-orm/node-postgres';
|
|
9
|
-
import { TableConfig, PgTableExtraConfig } from 'drizzle-orm/pg-core';
|
|
10
9
|
export { alias, boolean, char, cidr, date, doublePrecision, except, exceptAll, foreignKey, index, inet, bigint as int8, integer, intersect, intersectAll, interval, json, jsonb, line, macaddr, macaddr8, numeric, point, real, smallint, text, time, timestamp, union, unionAll, uniqueIndex, uuid, varchar } from 'drizzle-orm/pg-core';
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
import * as hono from 'hono';
|
|
10
|
+
import 'drizzle-orm/node-postgres';
|
|
11
|
+
import 'drizzle-orm/pglite';
|
|
14
12
|
import 'drizzle-orm/pg-core/columns/all';
|
|
15
13
|
|
|
16
14
|
type Factory<event extends AbiEvent = AbiEvent> = {
|
|
@@ -80,6 +78,8 @@ type GetEventFilter<abi extends Abi$1, safeEventNames extends string = SafeEvent
|
|
|
80
78
|
};
|
|
81
79
|
|
|
82
80
|
type Config = {
|
|
81
|
+
database?: DatabaseConfig$1;
|
|
82
|
+
ordering?: "omnichain" | "multichain";
|
|
83
83
|
networks: {
|
|
84
84
|
[networkName: string]: NetworkConfig$1<unknown>;
|
|
85
85
|
};
|
|
@@ -89,20 +89,21 @@ type Config = {
|
|
|
89
89
|
accounts: {
|
|
90
90
|
[accountName: string]: AccountConfig<unknown>;
|
|
91
91
|
};
|
|
92
|
-
database?: DatabaseConfig$1;
|
|
93
92
|
blocks: {
|
|
94
93
|
[sourceName: string]: GetBlockFilter<unknown>;
|
|
95
94
|
};
|
|
96
95
|
};
|
|
97
96
|
type CreateConfigReturnType<networks, contracts, accounts, blocks> = {
|
|
97
|
+
database?: DatabaseConfig$1;
|
|
98
|
+
ordering?: "omnichain" | "multichain";
|
|
98
99
|
networks: networks;
|
|
99
100
|
contracts: contracts;
|
|
100
101
|
accounts: accounts;
|
|
101
|
-
database?: DatabaseConfig$1;
|
|
102
102
|
blocks: blocks;
|
|
103
103
|
};
|
|
104
104
|
declare const createConfig: <const networks, const contracts = {}, const accounts = {}, const blocks = {}>(config: {
|
|
105
105
|
database?: DatabaseConfig$1 | undefined;
|
|
106
|
+
ordering?: "omnichain" | "multichain" | undefined;
|
|
106
107
|
networks: NetworksConfig<Narrow<networks>>;
|
|
107
108
|
contracts?: ContractsConfig<networks, Narrow<contracts>> | undefined;
|
|
108
109
|
accounts?: AccountsConfig<networks, Narrow<accounts>> | undefined;
|
|
@@ -124,9 +125,9 @@ type DatabaseConfig$1 = {
|
|
|
124
125
|
};
|
|
125
126
|
type BlockConfig$1 = {
|
|
126
127
|
/** Block number at which to start indexing events (inclusive). If `undefined`, events will be processed from block 0. Default: `undefined`. */
|
|
127
|
-
startBlock?: number;
|
|
128
|
+
startBlock?: number | "latest";
|
|
128
129
|
/** Block number at which to stop indexing events (inclusive). If `undefined`, events will be processed in real-time. Default: `undefined`. */
|
|
129
|
-
endBlock?: number;
|
|
130
|
+
endBlock?: number | "latest";
|
|
130
131
|
};
|
|
131
132
|
type TransactionReceiptConfig = {
|
|
132
133
|
includeTransactionReceipts?: boolean;
|
|
@@ -199,9 +200,9 @@ type AccountsConfig<networks, accounts> = {} extends accounts ? {} : {
|
|
|
199
200
|
};
|
|
200
201
|
type BlockFilterConfig = {
|
|
201
202
|
/** Block number at which to start indexing events (inclusive). If `undefined`, events will be processed from block 0. Default: `undefined`. */
|
|
202
|
-
startBlock?: number;
|
|
203
|
+
startBlock?: number | "latest";
|
|
203
204
|
/** Block number at which to stop indexing events (inclusive). If `undefined`, events will be processed in real-time. Default: `undefined`. */
|
|
204
|
-
endBlock?: number;
|
|
205
|
+
endBlock?: number | "latest";
|
|
205
206
|
interval?: number;
|
|
206
207
|
};
|
|
207
208
|
type GetBlockFilter<networks, allNetworkNames extends string = [keyof networks] extends [never] ? string : keyof networks & string> = BlockFilterConfig & {
|
|
@@ -213,419 +214,6 @@ type BlockFiltersConfig<networks = unknown, blocks = unknown> = {} extends block
|
|
|
213
214
|
[name in keyof blocks]: GetBlockFilter<networks>;
|
|
214
215
|
};
|
|
215
216
|
|
|
216
|
-
/**
|
|
217
|
-
* A confirmed Ethereum block.
|
|
218
|
-
*
|
|
219
|
-
* @link https://docs.soliditylang.org/en/v0.8.20/introduction-to-smart-contracts.html#blocks
|
|
220
|
-
*/
|
|
221
|
-
type Block = {
|
|
222
|
-
/** Base fee per gas */
|
|
223
|
-
baseFeePerGas: bigint | null;
|
|
224
|
-
/** Difficulty for this block */
|
|
225
|
-
difficulty: bigint;
|
|
226
|
-
/** "Extra data" field of this block */
|
|
227
|
-
extraData: Hex;
|
|
228
|
-
/** Maximum gas allowed in this block */
|
|
229
|
-
gasLimit: bigint;
|
|
230
|
-
/** Total used gas by all transactions in this block */
|
|
231
|
-
gasUsed: bigint;
|
|
232
|
-
/** Block hash */
|
|
233
|
-
hash: Hash;
|
|
234
|
-
/** Logs bloom filter */
|
|
235
|
-
logsBloom: Hex;
|
|
236
|
-
/** Address that received this block’s mining rewards */
|
|
237
|
-
miner: Address;
|
|
238
|
-
/** Unique identifier for the block. */
|
|
239
|
-
mixHash: Hash | null;
|
|
240
|
-
/** Proof-of-work hash */
|
|
241
|
-
nonce: Hex | null;
|
|
242
|
-
/** Block number */
|
|
243
|
-
number: bigint;
|
|
244
|
-
/** Parent block hash */
|
|
245
|
-
parentHash: Hash;
|
|
246
|
-
/** Root of the this block’s receipts trie */
|
|
247
|
-
receiptsRoot: Hex;
|
|
248
|
-
/** SHA3 of the uncles data in this block */
|
|
249
|
-
sha3Uncles: Hash | null;
|
|
250
|
-
/** Size of this block in bytes */
|
|
251
|
-
size: bigint;
|
|
252
|
-
/** Root of this block’s final state trie */
|
|
253
|
-
stateRoot: Hash;
|
|
254
|
-
/** Unix timestamp of when this block was collated */
|
|
255
|
-
timestamp: bigint;
|
|
256
|
-
/** Total difficulty of the chain until this block */
|
|
257
|
-
totalDifficulty: bigint | null;
|
|
258
|
-
/** Root of this block’s transaction trie */
|
|
259
|
-
transactionsRoot: Hash;
|
|
260
|
-
};
|
|
261
|
-
/**
|
|
262
|
-
* A confirmed Ethereum transaction. Contains `legacy`, `EIP-1559`, or `EIP-2930` fee values depending on the transaction `type`.
|
|
263
|
-
*
|
|
264
|
-
* @link https://docs.soliditylang.org/en/v0.8.20/introduction-to-smart-contracts.html#transactions
|
|
265
|
-
*/
|
|
266
|
-
type Transaction = Prettify<{
|
|
267
|
-
/** Transaction sender */
|
|
268
|
-
from: Address;
|
|
269
|
-
/** Gas provided for transaction execution */
|
|
270
|
-
gas: bigint;
|
|
271
|
-
/** Hash of this transaction */
|
|
272
|
-
hash: Hash;
|
|
273
|
-
/** Contract code or a hashed method call */
|
|
274
|
-
input: Hex;
|
|
275
|
-
/** Unique number identifying this transaction */
|
|
276
|
-
nonce: number;
|
|
277
|
-
/** ECDSA signature r */
|
|
278
|
-
r: Hex | null;
|
|
279
|
-
/** ECDSA signature s */
|
|
280
|
-
s: Hex | null;
|
|
281
|
-
/** Transaction recipient or `null` if deploying a contract */
|
|
282
|
-
to: Address | null;
|
|
283
|
-
/** Index of this transaction in the block */
|
|
284
|
-
transactionIndex: number;
|
|
285
|
-
/** ECDSA recovery ID */
|
|
286
|
-
v: bigint | null;
|
|
287
|
-
/** Value in wei sent with this transaction */
|
|
288
|
-
value: bigint;
|
|
289
|
-
} & ({
|
|
290
|
-
/** Transaction type. */
|
|
291
|
-
type: "legacy";
|
|
292
|
-
accessList?: never;
|
|
293
|
-
/** Base fee per gas. Only present in legacy and EIP-2930 transactions. */
|
|
294
|
-
gasPrice: bigint;
|
|
295
|
-
maxFeePerGas?: never;
|
|
296
|
-
maxPriorityFeePerGas?: never;
|
|
297
|
-
} | {
|
|
298
|
-
/** Transaction type. */
|
|
299
|
-
type: "eip2930";
|
|
300
|
-
/** List of addresses and storage keys the transaction will access. */
|
|
301
|
-
accessList: AccessList;
|
|
302
|
-
/** Base fee per gas. Only present in legacy and EIP-2930 transactions. */
|
|
303
|
-
gasPrice: bigint;
|
|
304
|
-
maxFeePerGas?: never;
|
|
305
|
-
maxPriorityFeePerGas?: never;
|
|
306
|
-
} | {
|
|
307
|
-
/** Transaction type. */
|
|
308
|
-
type: "eip1559";
|
|
309
|
-
accessList?: never;
|
|
310
|
-
gasPrice?: never;
|
|
311
|
-
/** Total fee per gas in wei (gasPrice/baseFeePerGas + maxPriorityFeePerGas). Only present in EIP-1559 transactions. */
|
|
312
|
-
maxFeePerGas: bigint;
|
|
313
|
-
/** Max priority fee per gas (in wei). Only present in EIP-1559 transactions. */
|
|
314
|
-
maxPriorityFeePerGas: bigint;
|
|
315
|
-
} | {
|
|
316
|
-
/** Transaction type. */
|
|
317
|
-
type: "deposit";
|
|
318
|
-
accessList?: never;
|
|
319
|
-
gasPrice?: never;
|
|
320
|
-
/** Total fee per gas in wei (gasPrice/baseFeePerGas + maxPriorityFeePerGas). Only present in EIP-1559 transactions. */
|
|
321
|
-
maxFeePerGas?: bigint;
|
|
322
|
-
/** Max priority fee per gas (in wei). Only present in EIP-1559 transactions. */
|
|
323
|
-
maxPriorityFeePerGas?: bigint;
|
|
324
|
-
} | {
|
|
325
|
-
/** Transaction type. */
|
|
326
|
-
type: Hex;
|
|
327
|
-
gasPrice?: never;
|
|
328
|
-
accessList?: never;
|
|
329
|
-
maxFeePerGas?: never;
|
|
330
|
-
maxPriorityFeePerGas?: never;
|
|
331
|
-
})>;
|
|
332
|
-
/**
|
|
333
|
-
* A confirmed Ethereum log.
|
|
334
|
-
*
|
|
335
|
-
* @link https://docs.soliditylang.org/en/v0.8.20/abi-spec.html#events
|
|
336
|
-
*/
|
|
337
|
-
type Log = {
|
|
338
|
-
/** Globally unique identifier for this log (`${blockHash}-${logIndex}`) */
|
|
339
|
-
id: string;
|
|
340
|
-
/** The address from which this log originated */
|
|
341
|
-
address: Address;
|
|
342
|
-
/** Contains the non-indexed arguments of the log */
|
|
343
|
-
data: Hex;
|
|
344
|
-
/** Index of this log within its block */
|
|
345
|
-
logIndex: number;
|
|
346
|
-
/** `true` if this log has been removed in a chain reorganization */
|
|
347
|
-
removed: boolean;
|
|
348
|
-
/** List of order-dependent topics */
|
|
349
|
-
topics: [Hex, ...Hex[]] | [];
|
|
350
|
-
};
|
|
351
|
-
/** A confirmed Ethereum transaction receipt. */
|
|
352
|
-
type TransactionReceipt = {
|
|
353
|
-
/** Address of new contract or `null` if no contract was created */
|
|
354
|
-
contractAddress: Address | null;
|
|
355
|
-
/** Gas used by this and all preceding transactions in this block */
|
|
356
|
-
cumulativeGasUsed: bigint;
|
|
357
|
-
/** Pre-London, it is equal to the transaction's gasPrice. Post-London, it is equal to the actual gas price paid for inclusion. */
|
|
358
|
-
effectiveGasPrice: bigint;
|
|
359
|
-
/** Transaction sender */
|
|
360
|
-
from: Address;
|
|
361
|
-
/** Gas used by this transaction */
|
|
362
|
-
gasUsed: bigint;
|
|
363
|
-
/** Logs bloom filter */
|
|
364
|
-
logsBloom: Hex;
|
|
365
|
-
/** `success` if this transaction was successful or `reverted` if it failed */
|
|
366
|
-
status: "success" | "reverted";
|
|
367
|
-
/** Transaction recipient or `null` if deploying a contract */
|
|
368
|
-
to: Address | null;
|
|
369
|
-
/** Transaction type */
|
|
370
|
-
type: TransactionType;
|
|
371
|
-
};
|
|
372
|
-
type Trace = {
|
|
373
|
-
/** Globally unique identifier for this trace (`${transactionHash}-${tracePosition}`) */
|
|
374
|
-
id: string;
|
|
375
|
-
/** The type of the call. */
|
|
376
|
-
type: "CALL" | "CALLCODE" | "DELEGATECALL" | "STATICCALL" | "CREATE" | "CREATE2" | "SELFDESTRUCT";
|
|
377
|
-
/** The address of that initiated the call. */
|
|
378
|
-
from: Address;
|
|
379
|
-
/** The address of the contract that was called. */
|
|
380
|
-
to: Address | null;
|
|
381
|
-
/** How much gas was left before the call. */
|
|
382
|
-
gas: bigint;
|
|
383
|
-
/** How much gas was used by the call. */
|
|
384
|
-
gasUsed: bigint;
|
|
385
|
-
/** Calldata input. */
|
|
386
|
-
input: Hex;
|
|
387
|
-
/** Output of the call, if any. */
|
|
388
|
-
output?: Hex;
|
|
389
|
-
/** Error message, if any. */
|
|
390
|
-
error?: string;
|
|
391
|
-
/** Why this call reverted, if it reverted. */
|
|
392
|
-
revertReason?: string;
|
|
393
|
-
/** Value transferred. */
|
|
394
|
-
value: bigint | null;
|
|
395
|
-
/** Index of this trace in the transaction. */
|
|
396
|
-
traceIndex: number;
|
|
397
|
-
/** Number of subcalls. */
|
|
398
|
-
subcalls: number;
|
|
399
|
-
};
|
|
400
|
-
/** A native token transfer. */
|
|
401
|
-
type Transfer = {
|
|
402
|
-
/** The address that sent the transfer */
|
|
403
|
-
from: Address;
|
|
404
|
-
/** The address that received the transfer */
|
|
405
|
-
to: Address;
|
|
406
|
-
/** The amount of tokens transferred */
|
|
407
|
-
value: bigint;
|
|
408
|
-
};
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Fix issue with Array.isArray not checking readonly arrays
|
|
412
|
-
* {@link https://github.com/microsoft/TypeScript/issues/17002}
|
|
413
|
-
*/
|
|
414
|
-
declare global {
|
|
415
|
-
interface ArrayConstructor {
|
|
416
|
-
isArray(arg: ReadonlyArray<any> | any): arg is ReadonlyArray<any>;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/** User-defined tables, enums, and indexes. */
|
|
421
|
-
type Schema = {
|
|
422
|
-
[name: string]: unknown;
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
type Drizzle<TSchema extends Schema = {
|
|
426
|
-
[name: string]: never;
|
|
427
|
-
}> = NodePgDatabase<TSchema> | PgliteDatabase<TSchema>;
|
|
428
|
-
type ReadonlyDrizzle<TSchema extends Schema = {
|
|
429
|
-
[name: string]: never;
|
|
430
|
-
}> = Omit<Drizzle<TSchema>, "insert" | "update" | "delete" | "transaction" | "refreshMaterializedView" | "_">;
|
|
431
|
-
type Db<schema extends Schema> = {
|
|
432
|
-
/**
|
|
433
|
-
* Find a row
|
|
434
|
-
*
|
|
435
|
-
* - Docs: https://ponder.sh/docs/indexing/write-to-the-database#find
|
|
436
|
-
*
|
|
437
|
-
* @example
|
|
438
|
-
* ```ts twoslash
|
|
439
|
-
* const result = await db.find(table, { id: 10 });
|
|
440
|
-
* ```
|
|
441
|
-
*
|
|
442
|
-
* @param table - The table to select from.
|
|
443
|
-
* @param key - The primary key.
|
|
444
|
-
* @returns The row if it exists or undefined if it doesn't.
|
|
445
|
-
*/
|
|
446
|
-
find: Find;
|
|
447
|
-
/**
|
|
448
|
-
* Create new rows
|
|
449
|
-
*
|
|
450
|
-
* - Docs: https://ponder.sh/docs/indexing/write-to-the-database#insert
|
|
451
|
-
*
|
|
452
|
-
* @example
|
|
453
|
-
* ```ts twoslash
|
|
454
|
-
* await db.insert(table).values({ id: 10, name: "joe" });
|
|
455
|
-
* ```
|
|
456
|
-
*
|
|
457
|
-
* @example
|
|
458
|
-
* ```ts twoslash
|
|
459
|
-
* await db.insert(table).values([
|
|
460
|
-
* { id: 10, name: "joe" },
|
|
461
|
-
* { id: 3, name: "rob" }
|
|
462
|
-
* ]);
|
|
463
|
-
* ```
|
|
464
|
-
*
|
|
465
|
-
* @example
|
|
466
|
-
* ```ts twoslash
|
|
467
|
-
* await db.insert(table).values({ id: 10, name: "joe" }).onConflictDoNothing();
|
|
468
|
-
* ```
|
|
469
|
-
*
|
|
470
|
-
* @example
|
|
471
|
-
* ```ts twoslash
|
|
472
|
-
* await db
|
|
473
|
-
* .insert(table)
|
|
474
|
-
* .values({ id: 10, name: "joe" })
|
|
475
|
-
* .onConflictDoUpdate((row) => ({ age: row.age + 3 }));
|
|
476
|
-
* ```
|
|
477
|
-
*
|
|
478
|
-
* @param table - The table to insert into.
|
|
479
|
-
*/
|
|
480
|
-
insert: Insert;
|
|
481
|
-
/**
|
|
482
|
-
* Update a row
|
|
483
|
-
*
|
|
484
|
-
* - Docs: https://ponder.sh/docs/indexing/write-to-the-database#update
|
|
485
|
-
*
|
|
486
|
-
* @example
|
|
487
|
-
* ```ts twoslash
|
|
488
|
-
* await db
|
|
489
|
-
* .update(table, { id: 10 })
|
|
490
|
-
* .set({ age: 19 });
|
|
491
|
-
* ```
|
|
492
|
-
*
|
|
493
|
-
* @example
|
|
494
|
-
* ```ts twoslash
|
|
495
|
-
* await db
|
|
496
|
-
* .update(table, { id: 10 })
|
|
497
|
-
* .set((row) => ({ age: row.age + 3 }));
|
|
498
|
-
* ```
|
|
499
|
-
*
|
|
500
|
-
* @param table - The table to select from.
|
|
501
|
-
* @param key - The primary key.
|
|
502
|
-
*/
|
|
503
|
-
update: Update;
|
|
504
|
-
/**
|
|
505
|
-
* Delete a row
|
|
506
|
-
*
|
|
507
|
-
* - Docs: https://ponder.sh/docs/indexing/write-to-the-database#delete
|
|
508
|
-
*
|
|
509
|
-
* @example
|
|
510
|
-
* ```ts twoslash
|
|
511
|
-
* const deleted = await db.delete(table, { id: 10 });
|
|
512
|
-
* ```
|
|
513
|
-
*
|
|
514
|
-
* @param table - The table to select from.
|
|
515
|
-
* @param key - The primary key.
|
|
516
|
-
* @returns `true` if the row existed.
|
|
517
|
-
*/
|
|
518
|
-
delete: Delete;
|
|
519
|
-
/**
|
|
520
|
-
* Access the raw drizzle object
|
|
521
|
-
*
|
|
522
|
-
* - Docs: https://ponder.sh/docs/indexing/write-to-the-database#raw-sql
|
|
523
|
-
*/
|
|
524
|
-
sql: Prettify<Omit<Drizzle<schema>, "refreshMaterializedView" | "_">>;
|
|
525
|
-
};
|
|
526
|
-
type InferPrimaryKey<table extends Table, columns extends Record<string, Column> = table["_"]["columns"], columnNames extends keyof columns & string = keyof columns & string> = columnNames extends columnNames ? columns[columnNames]["_"]["isPrimaryKey"] extends true ? columnNames : never : never;
|
|
527
|
-
type Key<table extends Table, compositePrimaryKey extends keyof table["_"]["columns"] = InferCompositePrimaryKey<table>, primaryKey extends keyof table["_"]["columns"] = [
|
|
528
|
-
compositePrimaryKey
|
|
529
|
-
] extends [never] ? InferPrimaryKey<table> : compositePrimaryKey> = {
|
|
530
|
-
[columnName in primaryKey]: GetColumnData<table["_"]["columns"][columnName]>;
|
|
531
|
-
};
|
|
532
|
-
type InferCompositePrimaryKey<table extends OnchainTable<TableConfig & {
|
|
533
|
-
extra: PgTableExtraConfig | undefined;
|
|
534
|
-
}>, extra extends PgTableExtraConfig | undefined = table["_"]["config"]["extra"], builders = extra[keyof extra]> = builders extends builders ? builders extends PrimaryKeyBuilder ? builders["columnNames"] : never : never;
|
|
535
|
-
type Find = <table extends Table>(table: table extends {
|
|
536
|
-
[onchain]: true;
|
|
537
|
-
} ? table : PonderTypeError<`db.find() can only be used with onchain tables, and '${table["_"]["name"]}' is an offchain table.`>, key: Key<table>) => Promise<InferSelectModel<table> | null>;
|
|
538
|
-
type Insert = <table extends Table, insertModel = InferInsertModel<table>, selectModel = InferSelectModel<table>, updateModel = Prettify<Omit<insertModel, keyof Key<table>>>, updateFn = (row: selectModel) => Partial<updateModel>>(table: table extends {
|
|
539
|
-
[onchain]: true;
|
|
540
|
-
} ? table : PonderTypeError<`Indexing functions can only write to onchain tables, and '${table["_"]["name"]}' is an offchain table.`>) => {
|
|
541
|
-
/**
|
|
542
|
-
* Create new rows
|
|
543
|
-
*
|
|
544
|
-
* - Docs: https://ponder.sh/docs/indexing/write-to-the-database#insert
|
|
545
|
-
*
|
|
546
|
-
* @example
|
|
547
|
-
* ```ts twoslash
|
|
548
|
-
* await db.insert(table).values({ id: 10, name: "joe" });
|
|
549
|
-
* ```
|
|
550
|
-
*
|
|
551
|
-
* @example
|
|
552
|
-
* ```ts twoslash
|
|
553
|
-
* await db.insert(table).values([
|
|
554
|
-
* { id: 10, name: "joe" },
|
|
555
|
-
* { id: 3, name: "rob" }
|
|
556
|
-
* ]);
|
|
557
|
-
* ```
|
|
558
|
-
* @param table - The table to insert into.
|
|
559
|
-
*/
|
|
560
|
-
values: <values extends insertModel | insertModel[]>(values: values) => Promise<values extends unknown[] ? selectModel[] : selectModel> & {
|
|
561
|
-
/**
|
|
562
|
-
* Create new rows, cancelling the insert if there is a conflict
|
|
563
|
-
*
|
|
564
|
-
* - Docs: https://ponder.sh/docs/indexing/write-to-the-database#upsert--conflict-resolution
|
|
565
|
-
* @example
|
|
566
|
-
* ```ts twoslash
|
|
567
|
-
* await db.insert(table).values({ id: 10, name: "joe" }).onConflictDoNothing();
|
|
568
|
-
* ```
|
|
569
|
-
* @param table - The table to insert into.
|
|
570
|
-
*/
|
|
571
|
-
onConflictDoNothing: () => Promise<values extends unknown[] ? (selectModel | null)[] : selectModel | null>;
|
|
572
|
-
/**
|
|
573
|
-
* Create new rows, updating the row if there is a conflict
|
|
574
|
-
*
|
|
575
|
-
* - Docs: https://ponder.sh/docs/indexing/write-to-the-database#upsert--conflict-resolution
|
|
576
|
-
*
|
|
577
|
-
* @example
|
|
578
|
-
* ```ts twoslash
|
|
579
|
-
* await db
|
|
580
|
-
* .insert(table)
|
|
581
|
-
* .values({ id: 10, name: "joe" })
|
|
582
|
-
* .onConflictDoUpdate({ age: 24 });
|
|
583
|
-
* ```
|
|
584
|
-
*
|
|
585
|
-
* @example
|
|
586
|
-
* ```ts twoslash
|
|
587
|
-
* await db
|
|
588
|
-
* .insert(table)
|
|
589
|
-
* .values({ id: 10, name: "joe" })
|
|
590
|
-
* .onConflictDoUpdate((row) => ({ age: row.age + 3 }));
|
|
591
|
-
* ```
|
|
592
|
-
*
|
|
593
|
-
* @param table - The table to insert into.
|
|
594
|
-
*/
|
|
595
|
-
onConflictDoUpdate: (values: Partial<updateModel> | updateFn) => Promise<values extends unknown[] ? selectModel[] : selectModel>;
|
|
596
|
-
};
|
|
597
|
-
};
|
|
598
|
-
type Update = <table extends Table, insertModel = InferInsertModel<table>, selectModel = InferSelectModel<table>, insertValues = Prettify<Omit<insertModel, keyof Key<table>>>, updateFn = (row: selectModel) => Partial<insertModel>>(table: table extends {
|
|
599
|
-
[onchain]: true;
|
|
600
|
-
} ? table : PonderTypeError<`Indexing functions can only write to onchain tables, and '${table["_"]["name"]}' is an offchain table.`>, key: Key<table>) => {
|
|
601
|
-
/**
|
|
602
|
-
* Update a row
|
|
603
|
-
*
|
|
604
|
-
* - Docs: https://ponder.sh/docs/indexing/write-to-the-database#update
|
|
605
|
-
*
|
|
606
|
-
* @example
|
|
607
|
-
* ```ts twoslash
|
|
608
|
-
* await db
|
|
609
|
-
* .update(table, { id: 10 })
|
|
610
|
-
* .set({ age: 19 });
|
|
611
|
-
* ```
|
|
612
|
-
*
|
|
613
|
-
* @example
|
|
614
|
-
* ```ts twoslash
|
|
615
|
-
* await db
|
|
616
|
-
* .update(table, { id: 10 })
|
|
617
|
-
* .set((row) => ({ age: row.age + 3 }));
|
|
618
|
-
* ```
|
|
619
|
-
*
|
|
620
|
-
* @param table - The table to select from.
|
|
621
|
-
* @param key - The primary key.
|
|
622
|
-
*/
|
|
623
|
-
set: (values: Partial<insertValues> | updateFn) => Promise<selectModel>;
|
|
624
|
-
};
|
|
625
|
-
type Delete = <table extends Table>(table: table extends {
|
|
626
|
-
[onchain]: true;
|
|
627
|
-
} ? table : PonderTypeError<`Indexing functions can only write to onchain tables, and '${table["_"]["name"]}' is an offchain table.`>, key: Key<table>) => Promise<boolean>;
|
|
628
|
-
|
|
629
217
|
/** Viem actions where the `block` property is optional and implicit. */
|
|
630
218
|
declare const blockDependentActions: readonly ["getBalance", "call", "estimateGas", "getFeeHistory", "getProof", "getCode", "getStorageAt", "getEnsAddress", "getEnsAvatar", "getEnsName", "getEnsResolver", "getEnsText"];
|
|
631
219
|
/** Viem actions where the `block` property is non-existent. */
|
|
@@ -813,4 +401,4 @@ type NetworkConfig = Prettify<Config["networks"][string]>;
|
|
|
813
401
|
type BlockConfig = Prettify<Config["blocks"][string]>;
|
|
814
402
|
type DatabaseConfig = Prettify<Config["database"]>;
|
|
815
403
|
|
|
816
|
-
export {
|
|
404
|
+
export { Block, type BlockConfig, type ContractConfig, type DatabaseConfig, Log, type NetworkConfig, ReadonlyDrizzle, Transaction, TransactionReceipt, Virtual, client, createConfig, factory, graphql };
|
package/dist/index.js
CHANGED