Skip to content

Commit f9bff75

Browse files
Add Insight API client for blockchain data access
1 parent 52261a5 commit f9bff75

40 files changed

+6864
-250
lines changed

.changeset/quick-bugs-remain.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
"@thirdweb-dev/insight": major
3+
---
4+
5+
Initial release of dedicated insight TS sdk
6+
7+
This package is a thin openAPI wrapper for insight, our in-house indexer.
8+
9+
## Configuration
10+
11+
```ts
12+
import { configure } from "@thirdweb-dev/insight";
13+
14+
// call this once at the startup of your application
15+
configure({
16+
clientId: "<YOUR_CLIENT_ID>",
17+
});
18+
```
19+
20+
## Example Usage
21+
22+
```ts
23+
import { getV1Events } from "@thirdweb-dev/insight";
24+
25+
const events = await getV1Events({
26+
query: {
27+
chain: [1, 137],
28+
filter_address: "0x1234567890123456789012345678901234567890",
29+
},
30+
});
31+
```

.changeset/wicked-pianos-carry.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
"thirdweb": minor
3+
---
4+
5+
Expose getOwnedTokens, getOwnedNFTs and getTransaction functions
6+
7+
You can now use Insight, our in-house indexer directly from the SDK with a simple API:
8+
9+
## Get Owned ERC20 tokens
10+
11+
```ts
12+
import { Insight } from "thirdweb";
13+
14+
const tokens = await Insight.getOwnedTokens({
15+
client,
16+
ownerAddress,
17+
chains: [base, polygon, arbitrum],
18+
});
19+
```
20+
21+
## Get Owned NFTs (ERC721 and ERC1155)
22+
23+
```ts
24+
import { Insight } from "thirdweb";
25+
26+
const nfts = await Insight.getOwnedNFTs({
27+
client,
28+
ownerAddress,
29+
chains: [sepolia],
30+
});
31+
```
32+
33+
## Get Transactions for a given wallet address
34+
35+
```ts
36+
import { Insight } from "thirdweb";
37+
38+
const transactions = await Insight.getTransactions({
39+
client,
40+
walletAddress,
41+
chains: [sepolia],
42+
});
43+
```
44+
45+
All functions come with extra query filters for more granular queries, refer to the documentation for more details.

.github/workflows/CI.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ jobs:
123123
mkdir test-project
124124
cd test-project
125125
npm init -y
126-
${{ matrix.package_manager }} add react react-dom ../packages/thirdweb
126+
# Add workspace dependencies to package.json
127+
npm pkg set dependencies.react=latest dependencies."react-dom"=latest dependencies.thirdweb="workspace:../packages/thirdweb" dependencies."@thirdweb-dev/insight"="workspace:../packages/insight"
128+
${{ matrix.package_manager }} install
127129
- name: Create test file
128130
run: |
129131
cd test-project
@@ -177,6 +179,9 @@ jobs:
177179
- name: Setup & Install
178180
uses: ./.github/composite-actions/install
179181

182+
- name: Build Packages
183+
run: pnpm build
184+
180185
- name: Report bundle size
181186
uses: andresz1/size-limit-action@94bc357df29c36c8f8d50ea497c3e225c3c95d1d # v1.8.0
182187
with:

apps/playground-web/src/components/pay/embed.tsx

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
defineChain,
1010
treasure,
1111
} from "thirdweb/chains";
12-
import { PayEmbed, getDefaultToken } from "thirdweb/react";
12+
import { PayEmbed } from "thirdweb/react";
1313
import { StyledConnectButton } from "../styled-connect-button";
1414
export function StyledPayEmbedPreview() {
1515
const { theme } = useTheme();
@@ -18,33 +18,6 @@ export function StyledPayEmbedPreview() {
1818
<div className="flex flex-col items-center justify-center">
1919
<StyledConnectButton
2020
chains={[base, defineChain(466), arbitrum, treasure, arbitrumNova]}
21-
supportedTokens={{
22-
466: [
23-
{
24-
address: "0x675C3ce7F43b00045a4Dab954AF36160fb57cB45",
25-
name: "USDC",
26-
symbol: "USDC",
27-
icon: getDefaultToken(base, "USDC")?.icon,
28-
},
29-
],
30-
// biome-ignore lint/style/noNonNullAssertion: <explanation>
31-
8453: [getDefaultToken(base, "USDC")!],
32-
42161: [
33-
{
34-
address: "0x539bde0d7dbd336b79148aa742883198bbf60342",
35-
name: "MAGIC",
36-
symbol: "MAGIC",
37-
},
38-
],
39-
[arbitrumNova.id]: [
40-
{
41-
name: "Godcoin",
42-
symbol: "GOD",
43-
address: "0xb5130f4767ab0acc579f25a76e8f9e977cb3f948",
44-
icon: "https://assets.coingecko.com/coins/images/53848/standard/GodcoinTickerIcon_02.png",
45-
},
46-
],
47-
}}
4821
/>
4922
<div className="h-10" />
5023
<PayEmbed

apps/playground-web/src/components/styled-connect-button.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ export function StyledConnectButton(
3030
abstract,
3131
]}
3232
wallets={WALLETS}
33-
supportedNFTs={{
34-
"84532": ["0x638263e3eAa3917a53630e61B1fBa685308024fa"],
35-
}}
3633
client={THIRDWEB_CLIENT}
3734
theme={theme === "light" ? "light" : "dark"}
3835
{...props}

apps/portal/src/app/references/components/TDoc/utils/getSidebarLinkgroups.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const tagsToGroup = {
4444
"@client": "Client",
4545
"@account": "Account",
4646
"@nebula": "Nebula",
47+
"@insight": "Insight",
4748
} as const;
4849

4950
type TagKey = keyof typeof tagsToGroup;
@@ -61,6 +62,7 @@ const sidebarGroupOrder: TagKey[] = [
6162
"@account",
6263
"@contract",
6364
"@transaction",
65+
"@insight",
6466
"@bridge",
6567
"@nebula",
6668
"@social",

packages/insight/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Insight TypeScript SDK
2+
3+
This package is a thin openAPI wrapper for insight, our in-house indexer.
4+
5+
## Configuration
6+
7+
```ts
8+
import { configure } from "@thirdweb-dev/insight";
9+
10+
// call this once at the startup of your application
11+
configure({
12+
clientId: "<YOUR_CLIENT_ID>",
13+
});
14+
```
15+
16+
## Example Usage
17+
18+
```ts
19+
import { getV1Events } from "@thirdweb-dev/insight";
20+
21+
const events = await getV1Events({
22+
query: {
23+
chain: [1, 137],
24+
filter_address: "0x1234567890123456789012345678901234567890",
25+
},
26+
});
27+
```
28+
29+
This package was autogenerated from the [Insight openAPI spec](https://insight-api.thirdweb.com/reference) using [@hey-api/openapi-ts](https://github.com/hey-api/openapi-ts)

packages/insight/biome.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
3+
"extends": ["../../biome.json"],
4+
"files": {
5+
"ignore": ["src/client/**"]
6+
}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig } from "@hey-api/openapi-ts";
2+
3+
export default defineConfig({
4+
input: "https://insight.thirdweb.com/openapi.json",
5+
output: { path: "src/client" },
6+
plugins: ["@hey-api/client-fetch"],
7+
});

packages/insight/package.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "@thirdweb-dev/insight",
3+
"version": "0.0.1",
4+
"repository": {
5+
"type": "git",
6+
"url": "git+https://github.com/thirdweb-dev/js.git#main"
7+
},
8+
"license": "Apache-2.0",
9+
"bugs": {
10+
"url": "https://github.com/thirdweb-dev/js/issues"
11+
},
12+
"author": "thirdweb eng <[email protected]>",
13+
"type": "module",
14+
"main": "./dist/cjs/exports/thirdweb.js",
15+
"module": "./dist/esm/exports/thirdweb.js",
16+
"types": "./dist/types/exports/thirdweb.d.ts",
17+
"typings": "./dist/types/exports/thirdweb.d.ts",
18+
"exports": {
19+
".": {
20+
"types": "./dist/types/exports/thirdweb.d.ts",
21+
"import": "./dist/esm/exports/thirdweb.js",
22+
"default": "./dist/cjs/exports/thirdweb.js"
23+
},
24+
"./package.json": "./package.json"
25+
},
26+
"files": ["dist/*", "src/*"],
27+
"dependencies": {
28+
"@hey-api/client-fetch": "0.10.0",
29+
"tslib": "^2.8.1"
30+
},
31+
"devDependencies": {
32+
"@hey-api/openapi-ts": "0.66.1",
33+
"rimraf": "6.0.1"
34+
},
35+
"peerDependencies": {
36+
"typescript": ">=5.0.4"
37+
},
38+
"peerDependenciesMeta": {
39+
"typescript": {
40+
"optional": true
41+
}
42+
},
43+
"scripts": {
44+
"format": "biome format ./src --write",
45+
"lint": "biome check ./src",
46+
"fix": "biome check ./src --fix",
47+
"build": "pnpm clean && pnpm build:cjs && pnpm build:esm && pnpm build:types",
48+
"build:cjs": "tsc --project ./tsconfig.build.json --module commonjs --outDir ./dist/cjs --verbatimModuleSyntax false && printf '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json",
49+
"build:esm": "tsc --project ./tsconfig.build.json --module es2020 --outDir ./dist/esm && printf '{\"type\": \"module\",\"sideEffects\":false}' > ./dist/esm/package.json",
50+
"build:types": "tsc --project ./tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
51+
"clean": "rimraf dist",
52+
"build:generate": "openapi-ts && pnpm format"
53+
},
54+
"engines": {
55+
"node": ">=18"
56+
}
57+
}

0 commit comments

Comments
 (0)