-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1210 from ponder-sh/accounts
accounts + native transfers
- Loading branch information
Showing
57 changed files
with
8,142 additions
and
3,766 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Mainnet RPC URL used for fetching blockchain data. Alchemy is recommended. | ||
PONDER_RPC_URL_1=https://eth-mainnet.g.alchemy.com/v2/... | ||
|
||
# (Optional) Postgres database URL. If not provided, SQLite will be used. | ||
DATABASE_URL= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "ponder" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Dependencies | ||
/node_modules | ||
|
||
# Debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# Misc | ||
.DS_Store | ||
|
||
# Env files | ||
.env*.local | ||
|
||
# Ponder | ||
/generated/ | ||
/.ponder/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "ponder-examples-feature-accounts", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"dev": "ponder dev", | ||
"start": "ponder start", | ||
"codegen": "ponder codegen", | ||
"serve": "ponder serve", | ||
"lint": "eslint .", | ||
"typecheck": "tsc" | ||
}, | ||
"dependencies": { | ||
"@ponder/core": "workspace:*", | ||
"hono": "^4.5.0", | ||
"viem": "^2.21.3" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.10.0", | ||
"eslint": "^8.54.0", | ||
"eslint-config-ponder": "workspace:*", | ||
"typescript": "^5.3.2" | ||
}, | ||
"engines": { | ||
"node": ">=18.14" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// This file enables type checking and editor autocomplete for this Ponder project. | ||
// After upgrading, you may find that changes have been made to this file. | ||
// If this happens, please commit the changes. Do not manually edit this file. | ||
// See https://ponder.sh/docs/getting-started/installation#typescript for more information. | ||
|
||
declare module "@/generated" { | ||
import type { Virtual } from "@ponder/core"; | ||
|
||
type config = typeof import("./ponder.config.ts").default; | ||
type schema = typeof import("./ponder.schema.ts"); | ||
|
||
export const ponder: Virtual.Registry<config, schema>; | ||
|
||
export type EventNames = Virtual.EventNames<config>; | ||
export type Event<name extends EventNames = EventNames> = Virtual.Event< | ||
config, | ||
name | ||
>; | ||
export type Context<name extends EventNames = EventNames> = Virtual.Context< | ||
config, | ||
schema, | ||
name | ||
>; | ||
export type ApiContext = Virtual.ApiContext<schema>; | ||
export type IndexingFunctionArgs<name extends EventNames = EventNames> = | ||
Virtual.IndexingFunctionArgs<config, schema, name>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { createConfig } from "@ponder/core"; | ||
import { http, createPublicClient } from "viem"; | ||
|
||
const latestBlockMainnet = await createPublicClient({ | ||
transport: http(process.env.PONDER_RPC_URL_1), | ||
}).getBlock(); | ||
|
||
export default createConfig({ | ||
networks: { | ||
mainnet: { | ||
chainId: 1, | ||
transport: http(process.env.PONDER_RPC_URL_1), | ||
}, | ||
}, | ||
accounts: { | ||
BeaverBuilder: { | ||
network: "mainnet", | ||
startBlock: Number(latestBlockMainnet.number) - 100, | ||
address: "0x95222290DD7278Aa3Ddd389Cc1E1d165CC4BAfe5", | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { onchainTable } from "@ponder/core"; | ||
|
||
export const transactionEvents = onchainTable("transaction_events", (t) => ({ | ||
to: t.hex().primaryKey(), | ||
value: t.bigint().notNull(), | ||
data: t.hex().notNull(), | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ponder } from "@/generated"; | ||
import * as schema from "../ponder.schema"; | ||
|
||
ponder.on("BeaverBuilder:transaction:from", async ({ event, context }) => { | ||
if (event.transaction.to === null) return; | ||
|
||
await context.db | ||
.insert(schema.transactionEvents) | ||
.values({ | ||
to: event.transaction.to, | ||
value: event.transaction.value, | ||
data: event.transaction.input, | ||
}) | ||
.onConflictDoUpdate((row) => ({ | ||
value: row.value + event.transaction.value, | ||
data: event.transaction.input, | ||
})); | ||
}); | ||
|
||
ponder.on("BeaverBuilder:transfer:to", async ({ event }) => { | ||
console.log("sent", event.transfer); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"compilerOptions": { | ||
// Type checking | ||
"strict": true, | ||
"noUncheckedIndexedAccess": true, | ||
|
||
// Interop constraints | ||
"verbatimModuleSyntax": false, | ||
"esModuleInterop": true, | ||
"isolatedModules": true, | ||
"allowSyntheticDefaultImports": true, | ||
"resolveJsonModule": true, | ||
|
||
// Language and environment | ||
"moduleResolution": "bundler", | ||
"module": "ESNext", | ||
"noEmit": true, | ||
"lib": ["ES2022"], | ||
"target": "ES2022", | ||
|
||
// Skip type checking for node modules | ||
"skipLibCheck": true | ||
}, | ||
"include": ["./**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.