Skip to content

Commit 6d25a44

Browse files
committed
update examples and bump version
1 parent 0b76850 commit 6d25a44

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Make a one-time query to get historical data:
1717
```typescript
1818
import { query } from "@indexsupply/indexsupply.js";
1919

20-
const { blockNumber, result } = await query({
20+
const { cursor, rows } = await query({
2121
apiKey: "face",
2222
chainId: 8453,
2323
query: 'select "from", "to", value from transfer limit 1',
@@ -29,7 +29,7 @@ const { blockNumber, result } = await query({
2929
}),
3030
})
3131

32-
console.log(`Block ${blockNumber}:`, result)
32+
console.log(`Block ${cursor}:`, rows)
3333
```
3434

3535
### Live Query
@@ -52,8 +52,8 @@ const q = queryLive({
5252
}),
5353
})
5454

55-
for await (const { blockNumber, result } of q) {
56-
console.log(`New data at block ${blockNumber}:`, result)
55+
for await (const { cursor, rows } of q) {
56+
console.log(`New data at block ${cursor}:`, rows)
5757
}
5858
```
5959

@@ -71,7 +71,7 @@ const liveQuery = queryLive({
7171
},
7272
...
7373
});
74-
for await (const { blockNumber, result } of liveQuery) {
74+
for await (const { cursor, rows } of liveQuery) {
7575
await pg.query("insert into my_table(block_num, ...) values (blockNumber, ...)");
7676
}
7777
```
@@ -90,12 +90,12 @@ See [this page](https://indexsupply.github.io/indexsupply.js/examples/index.html
9090
</head>
9191
<script type="module">
9292
import { query } from "https://static.indexsupply.net/indexsupply.js";
93-
const { blockNumber, result } = await query({
93+
const { cursor, rows } = await query({
9494
chainId: 8453n,
9595
signatures: [],
9696
query: "select block_num from logs limit 1",
9797
});
98-
document.querySelector("body pre").textContent = JSON.stringify({ blockNumber, result });
98+
document.querySelector("body pre").textContent = JSON.stringify({ cursor, rows});
9999
</script>
100100
<body>
101101
<pre></pre>

examples/ox-seaport/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ setLogLevel(LogLevel.DEBUG);
66
const orderFulfilled = AbiEvent.from("event OrderFulfilled(bytes32 orderHash, address indexed offerer, address indexed zone, address recipient, (uint8, address, uint256, uint256)[] offer, (uint8, address, uint256, uint256, address)[] consideration)");
77

88
async function main() {
9-
const { blockNumber, result } = await query({
9+
const { cursor, rows } = await query({
1010
chainId: 1n,
1111
query: `
1212
select topics, data
@@ -24,7 +24,7 @@ async function main() {
2424
},
2525
});
2626

27-
result.forEach((order) => {
27+
rows.forEach((order) => {
2828
console.log({ offer: order.offer, consideration: order.consideration });
2929
})
3030
}

examples/save-to-postgres/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ async function main() {
7777
};
7878
},
7979
});
80-
for await (const { result } of query) {
81-
await Promise.all(result.map(async (row) => {
80+
for await (const { rows } of query) {
81+
await Promise.all(rows.map(async (row) => {
8282
await pg.client!.query(`
8383
insert into my_transfers(block_num, "from", "to", value)
8484
values ($1, $2, $3, $4)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.0.15",
2+
"version": "2.0.0",
33
"name": "@indexsupply/indexsupply.js",
44
"keywords": [
55
"ethereum",

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// generated by: scripts/replace-version.js
2-
const userAgentVersion = "0.0.15";
2+
const userAgentVersion = "2.0.0";
33

44
export type Hex = `0x${string}`;
55

@@ -79,7 +79,7 @@ type FetchRequest = globalThis.Request;
7979
type FetchResponse = globalThis.Response;
8080

8181
/**
82-
* A mapping of the chain-id to block-number
82+
* A mapping of: chain-id to block-number
8383
* When a cursor is returned from a request the block number
8484
* is the latest block indexed by the API.
8585
* When a cursor is sent to the server it requests data past the block number.

0 commit comments

Comments
 (0)