Skip to content
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

live queries #1408

Open
wants to merge 20 commits into
base: v0.9
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 0 additions & 147 deletions examples/with-client/ponder/abis/erc20ABI.ts

This file was deleted.

153 changes: 153 additions & 0 deletions examples/with-client/ponder/abis/weth9Abi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
export const weth9Abi = [
{
constant: true,
payable: false,
stateMutability: "view",
type: "function",
inputs: [],
name: "name",
outputs: [{ name: "", type: "string" }],
},
{
constant: false,
payable: false,
stateMutability: "nonpayable",
type: "function",
inputs: [
{ name: "guy", type: "address" },
{ name: "wad", type: "uint256" },
],
name: "approve",
outputs: [{ name: "", type: "bool" }],
},
{
constant: true,
payable: false,
stateMutability: "view",
type: "function",
inputs: [],
name: "totalSupply",
outputs: [{ name: "", type: "uint256" }],
},
{
constant: false,
payable: false,
stateMutability: "nonpayable",
type: "function",
inputs: [
{ name: "src", type: "address" },
{ name: "dst", type: "address" },
{ name: "wad", type: "uint256" },
],
name: "transferFrom",
outputs: [{ name: "", type: "bool" }],
},
{
constant: false,
payable: false,
stateMutability: "nonpayable",
type: "function",
inputs: [{ name: "wad", type: "uint256" }],
name: "withdraw",
outputs: [],
},
{
constant: true,
payable: false,
stateMutability: "view",
type: "function",
inputs: [],
name: "decimals",
outputs: [{ name: "", type: "uint8" }],
},
{
constant: true,
payable: false,
stateMutability: "view",
type: "function",
inputs: [{ name: "", type: "address" }],
name: "balanceOf",
outputs: [{ name: "", type: "uint256" }],
},
{
constant: true,
payable: false,
stateMutability: "view",
type: "function",
inputs: [],
name: "symbol",
outputs: [{ name: "", type: "string" }],
},
{
constant: false,
payable: false,
stateMutability: "nonpayable",
type: "function",
inputs: [
{ name: "dst", type: "address" },
{ name: "wad", type: "uint256" },
],
name: "transfer",
outputs: [{ name: "", type: "bool" }],
},
{
constant: false,
payable: true,
stateMutability: "payable",
type: "function",
inputs: [],
name: "deposit",
outputs: [],
},
{
constant: true,
payable: false,
stateMutability: "view",
type: "function",
inputs: [
{ name: "", type: "address" },
{ name: "", type: "address" },
],
name: "allowance",
outputs: [{ name: "", type: "uint256" }],
},
{ payable: true, stateMutability: "payable", type: "fallback" },
{
type: "event",
anonymous: false,
inputs: [
{ name: "src", type: "address", indexed: true },
{ name: "guy", type: "address", indexed: true },
{ name: "wad", type: "uint256", indexed: false },
],
name: "Approval",
},
{
type: "event",
anonymous: false,
inputs: [
{ name: "src", type: "address", indexed: true },
{ name: "dst", type: "address", indexed: true },
{ name: "wad", type: "uint256", indexed: false },
],
name: "Transfer",
},
{
type: "event",
anonymous: false,
inputs: [
{ name: "dst", type: "address", indexed: true },
{ name: "wad", type: "uint256", indexed: false },
],
name: "Deposit",
},
{
type: "event",
anonymous: false,
inputs: [
{ name: "src", type: "address", indexed: true },
{ name: "wad", type: "uint256", indexed: false },
],
name: "Withdrawal",
},
] as const;
26 changes: 15 additions & 11 deletions examples/with-client/ponder/ponder.config.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import { createConfig } from "ponder";
import { http } from "viem";
import { erc20ABI } from "./abis/erc20ABI";
import { http, createPublicClient } from "viem";

import { weth9Abi } from "./abis/weth9Abi";

const latestBlockBase = await createPublicClient({
transport: http(process.env.PONDER_RPC_URL_8453),
}).getBlock();

export default createConfig({
networks: {
mainnet: {
chainId: 1,
transport: http(process.env.PONDER_RPC_URL_1),
base: {
chainId: 8453,
transport: http(process.env.PONDER_RPC_URL_8453),
},
},
contracts: {
ERC20: {
network: "mainnet",
abi: erc20ABI,
address: "0x32353A6C91143bfd6C7d363B546e62a9A2489A20",
startBlock: 13142655,
endBlock: 13150000,
weth9: {
abi: weth9Abi,
network: "base",
address: "0x4200000000000000000000000000000000000006",
startBlock: Number(latestBlockBase.number),
},
},
});
37 changes: 1 addition & 36 deletions examples/with-client/ponder/ponder.schema.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,6 @@
import { index, onchainTable, primaryKey } from "ponder";
import { onchainTable } from "ponder";

export const account = onchainTable("account", (t) => ({
address: t.hex().primaryKey(),
balance: t.bigint().notNull(),
isOwner: t.boolean().notNull(),
}));

export const allowance = onchainTable(
"allowance",
(t) => ({
owner: t.hex(),
spender: t.hex(),
amount: t.bigint().notNull(),
}),
(table) => ({
pk: primaryKey({ columns: [table.owner, table.spender] }),
}),
);

export const transferEvent = onchainTable(
"transfer_event",
(t) => ({
id: t.text().primaryKey(),
amount: t.bigint().notNull(),
timestamp: t.integer().notNull(),
from: t.hex().notNull(),
to: t.hex().notNull(),
}),
(table) => ({
fromIdx: index("from_index").on(table.from),
}),
);

export const approvalEvent = onchainTable("approval_event", (t) => ({
id: t.text().primaryKey(),
amount: t.bigint().notNull(),
timestamp: t.integer().notNull(),
owner: t.hex().notNull(),
spender: t.hex().notNull(),
}));
Loading
Loading