Skip to content

Commit 6ddbc9a

Browse files
committed
feat: nft by owners 2
1 parent 0a40438 commit 6ddbc9a

File tree

4 files changed

+127
-14
lines changed

4 files changed

+127
-14
lines changed

.github/workflows/publish-dev.yaml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Publish CI (pull request)
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: '22.x'
20+
- run: npm ci
21+
- run: npm run build --if-present
22+
- run: |
23+
git config user.name github-actions
24+
git config user.email github-actions[bot]@users.noreply.github.com
25+
npm version prepatch --preid=${{ env.RELEVANT_SHA }}
26+
echo "NEW_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
27+
id: github-version
28+
env:
29+
RELEVANT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
30+
- run: npm publish --access restricted
31+
env:
32+
# NOTE: using the built-in GITHUB token here because we're publishing to THIS repository's packages.
33+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
- name: Create comment
35+
uses: peter-evans/create-or-update-comment@v4
36+
with:
37+
issue-number: ${{ github.event.pull_request.number }}
38+
body: |
39+
I just published a new version of this package :tada:
40+
```
41+
${{ env.NEW_VERSION }}
42+
```
43+
44+
reactions: '+1'

.github/workflows/publish.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
# Setup .npmrc file to publish to npm
1111
- uses: actions/setup-node@v3
1212
with:
13-
node-version: '16.x'
13+
node-version: '20.x'
1414
registry-url: 'https://registry.npmjs.org'
1515
- run: npm ci
1616
- run: npm run build --if-present

src/lib/core.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class SimpleHashAPI {
8383
): Promise<NFT[]> {
8484
const chain = chains.join(',');
8585
const wallet = walletAddresses.join(',');
86-
let url = `owners?chains=${chain}&wallet_addresses=${wallet}`;
86+
let url = `owners_v2?chains=${chain}&wallet_addresses=${wallet}`;
8787
if (queriedWalletBalances) {
8888
url += `&queried_wallet_balances=${queriedWalletBalances}`;
8989
}

src/lib/interfaces/index.ts

+81-12
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,20 @@ export interface TokenQuantity {
9898
last_acquired_date: string;
9999
}
100100

101+
export interface NFTPreview {
102+
image_small_url?: string;
103+
image_medium_url?: string;
104+
image_large_url?: string;
105+
image_opengraph_url?: string;
106+
blurhash?: string;
107+
}
108+
109+
export interface TokenContract {
110+
type: string;
111+
name: string;
112+
symbol: string;
113+
}
114+
101115
export interface NFT {
102116
nft_id: string;
103117
chain: Chain;
@@ -109,13 +123,7 @@ export interface NFT {
109123
video_url?: string;
110124
audio_url?: string;
111125
model_url?: string;
112-
previews: {
113-
image_small_url?: string;
114-
image_medium_url?: string;
115-
image_large_url?: string;
116-
image_opengraph_url?: string;
117-
blurhash?: string;
118-
};
126+
previews: NFTPreview;
119127
background_color?: string;
120128
external_url?: string;
121129
created_date?: Date;
@@ -124,11 +132,7 @@ export interface NFT {
124132
owner_count: number;
125133
owners: Owner[];
126134
last_sale?: Sale;
127-
contract: {
128-
type: string;
129-
name: string;
130-
symbol: string;
131-
};
135+
contract: TokenContract;
132136
collection: Collection;
133137
extra_metadata?: {
134138
[key: string]: any;
@@ -183,4 +187,69 @@ export interface FungibleTokenTransfer {
183187
log_index: number;
184188
batch_transfer_index: bigint;
185189
transaction_hash: string;
190+
}
191+
192+
export interface CollectionRoyalties {
193+
source: string;
194+
total_creator_fee_basis_points: number;
195+
recipients: any[];
196+
}
197+
198+
export interface ImageProperties {
199+
width: number;
200+
height: number;
201+
mime_type: string;
202+
}
203+
204+
export interface MarketplacePage {
205+
marketplace_id: string;
206+
marketplace_name: string;
207+
marketplace_collection_id: string;
208+
collection_url: string;
209+
verified: boolean | null;
210+
}
211+
212+
export interface CollectionDetails {
213+
collection_id: string;
214+
name: string;
215+
description: string;
216+
image_url: string;
217+
image_properties: ImageProperties;
218+
banner_image_url: string | null;
219+
category: string | null;
220+
is_nsfw: boolean;
221+
external_url: string | null;
222+
twitter_username: string | null;
223+
discord_url: string | null;
224+
instagram_username: string | null;
225+
medium_username: string | null;
226+
telegram_url: string | null;
227+
marketplace_pages: MarketplacePage[];
228+
metaplex_mint: string | null;
229+
metaplex_candy_machine: string | null;
230+
metaplex_first_verified_creator: string | null;
231+
mpl_core_collection_address: string | null;
232+
floor_prices: any[];
233+
top_bids: any[];
234+
distinct_owner_count: number;
235+
distinct_nft_count: number;
236+
total_quantity: number;
237+
chains: string[];
238+
top_contracts: string[];
239+
collection_royalties: CollectionRoyalties[];
240+
}
241+
242+
export interface NFTContract {
243+
primary_key: string;
244+
chain: string;
245+
contract_address: string;
246+
name: string;
247+
type: string;
248+
has_multiple_collections: boolean;
249+
distinct_nfts_owned: number;
250+
distinct_nfts_owned_string: string;
251+
total_copies_owned: number;
252+
total_copies_owned_string: string;
253+
last_acquired_date: string;
254+
collections: CollectionDetails[];
186255
}

0 commit comments

Comments
 (0)