@opensea/sdk 11.4.9 → 11.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/api/types.ts CHANGED
@@ -1,23 +1,32 @@
1
1
  import type {
2
+ AccountSearchResponse as ApiAccountSearchResponse,
2
3
  BuildOfferResponse as ApiBuildOfferResponse,
3
4
  CancelResponse as ApiCancelResponse,
5
+ CollectionSearchResponse as ApiCollectionSearchResponse,
4
6
  Listing as ApiListing,
5
7
  Nft as ApiNft,
8
+ NftSearchResponse as ApiNftSearchResponse,
6
9
  Offer as ApiOffer,
7
10
  Order as ApiOrder,
8
11
  OrderAsset as ApiOrderAsset,
9
12
  Payment as ApiPayment,
10
13
  Price as ApiPrice,
14
+ SearchResponse as ApiSearchResponse,
15
+ SearchResultResponse as ApiSearchResultResponse,
11
16
  SwapExecuteRequest as ApiSwapExecuteRequest,
12
17
  SwapExecuteResponse as ApiSwapExecuteResponse,
13
18
  SwapQuoteResponse as ApiSwapQuoteResponse,
14
19
  SweepCollectionRequest as ApiSweepCollectionRequest,
15
20
  SweepCollectionResponse as ApiSweepCollectionResponse,
21
+ TokenDetailedResponse as ApiTokenDetailedResponse,
22
+ TokenResponse as ApiTokenResponse,
23
+ TokenSearchResponse as ApiTokenSearchResponse,
16
24
  Trait as ApiTrait,
17
25
  TransactionReceiptRequest as ApiTransactionReceiptRequest,
18
26
  TransactionReceiptResponse as ApiTransactionReceiptResponse,
19
27
  AssetMetadataResponse,
20
28
  ChainResponse,
29
+ ContractResponse,
21
30
  DropDetailedResponse,
22
31
  DropResponse,
23
32
  DropStageResponse,
@@ -27,9 +36,12 @@ import type {
27
36
  NftListResponse,
28
37
  NftResponse,
29
38
  OffersResponse,
39
+ TokenAccountActivityPaginatedResponse,
40
+ TokenBalancePaginatedResponse,
30
41
  TokenBalanceResponse,
31
42
  TokenGroupPaginatedResponse,
32
43
  TokenGroupResponse,
44
+ TokenPaginatedResponse,
33
45
  } from "@opensea/api-types"
34
46
  import type { OrderType, ProtocolData } from "../orders/types"
35
47
  import type { OpenSeaCollection } from "../types"
@@ -643,25 +655,15 @@ export type GetEventsResponse = QueryCursorsV2 & {
643
655
  }
644
656
 
645
657
  /**
646
- * Contract information returned by OpenSea API.
658
+ * Contract information returned by OpenSea API. Sourced from
659
+ * `@opensea/api-types` (`ContractResponse`) with `collection` widened to
660
+ * `string | null` because the live API returns `null` for contracts without an
661
+ * associated collection even though the spec models it as required non-null.
647
662
  * @category API Models
648
663
  */
649
- export type Contract = {
650
- /** Contract address */
651
- address: string
652
- /** Chain the contract is deployed on */
653
- chain: string
654
- /**
655
- * Associated collection slug. `null` for contracts without an associated
656
- * collection on OpenSea. TODO(api-types): the OpenAPI spec marks this as
657
- * required non-null, but the live API returns null for standalone contracts —
658
- * swap to `Camelize<ContractResponse>` once the spec is updated.
659
- */
664
+ export type Contract = Camelize<Omit<ContractResponse, "collection">> & {
665
+ /** Associated collection slug (null when the contract has no collection) */
660
666
  collection: string | null
661
- /** Contract name */
662
- name: string
663
- /** Contract standard (e.g., erc721, erc1155) */
664
- contractStandard: string
665
667
  }
666
668
 
667
669
  /**
@@ -700,45 +702,41 @@ export type GetTraitsResponse = {
700
702
  }
701
703
 
702
704
  /**
703
- * Token model returned by OpenSea API.
705
+ * Token model returned by OpenSea API token list endpoints.
704
706
  *
705
- * TODO(api-types): swap to `Camelize<TokenResponse>` once the OpenAPI spec
706
- * marks `image_url` as nullable (the live API returns `null` for tokens
707
- * without an image). Currently the spec models it as optional non-null.
707
+ * Camelized from `@opensea/api-types` `TokenResponse`. `imageUrl` is widened
708
+ * to `string | null` because the live API returns `null` for tokens without
709
+ * an image even though the spec models it as optional non-null.
708
710
  *
709
711
  * @category API Models
710
712
  */
711
- export type Token = {
712
- /** Token contract address */
713
- address: string
714
- /** Chain the token is on */
715
- chain: string
716
- /** Token name */
717
- name: string
718
- /** Token symbol */
719
- symbol: string
720
- /** Number of decimals */
721
- decimals: number
713
+ export type Token = Camelize<Omit<ApiTokenResponse, "image_url">> & {
722
714
  /** URL of the token image (null when the token has no image) */
723
- imageUrl: string | null
724
- /** URL on OpenSea */
725
- openseaUrl: string
715
+ imageUrl?: string | null
726
716
  }
727
717
 
728
718
  /**
729
- * Response from OpenSea API for fetching trending tokens.
719
+ * Response from OpenSea API for fetching trending tokens. Sourced from
720
+ * `@opensea/api-types` (`TokenPaginatedResponse`) with `tokens` overridden to
721
+ * use the SDK's nullable-image `Token` type.
730
722
  * @category API Response Types
731
723
  */
732
- export type GetTrendingTokensResponse = QueryCursorsV2 & {
724
+ export type GetTrendingTokensResponse = Camelize<
725
+ Omit<TokenPaginatedResponse, "tokens">
726
+ > & {
733
727
  /** List of {@link Token} */
734
728
  tokens: Token[]
735
729
  }
736
730
 
737
731
  /**
738
- * Response from OpenSea API for fetching top tokens.
732
+ * Response from OpenSea API for fetching top tokens. Sourced from
733
+ * `@opensea/api-types` (`TokenPaginatedResponse`) with `tokens` overridden to
734
+ * use the SDK's nullable-image `Token` type.
739
735
  * @category API Response Types
740
736
  */
741
- export type GetTopTokensResponse = QueryCursorsV2 & {
737
+ export type GetTopTokensResponse = Camelize<
738
+ Omit<TokenPaginatedResponse, "tokens">
739
+ > & {
742
740
  /** List of {@link Token} */
743
741
  tokens: Token[]
744
742
  }
@@ -788,7 +786,12 @@ export type GetSwapQuoteResponse = Camelize<ApiSwapQuoteResponse>
788
786
  * Response from OpenSea API for fetching token details.
789
787
  * @category API Response Types
790
788
  */
791
- export type GetTokenResponse = Token
789
+ export type GetTokenResponse = Camelize<
790
+ Omit<ApiTokenDetailedResponse, "image_url">
791
+ > & {
792
+ /** URL of the token image (null when the token has no image) */
793
+ imageUrl?: string | null
794
+ }
792
795
 
793
796
  /**
794
797
  * Response from OpenSea API for fetching a token group by slug.
@@ -835,88 +838,70 @@ export interface SearchArgs {
835
838
  }
836
839
 
837
840
  /**
838
- * Collection search result.
841
+ * Collection search result. Sourced from `@opensea/api-types`
842
+ * (`CollectionSearchResponse`). `imageUrl` is widened to `string | null` to
843
+ * match the live API response for collections without an image.
839
844
  * @category API Models
840
845
  */
841
- export type CollectionSearchResult = {
842
- /** The collection slug */
843
- collection: string
844
- /** The collection name */
845
- name: string
846
- /** URL of the collection image */
847
- imageUrl: string | null
848
- /** Whether trading is disabled for this collection */
849
- isDisabled: boolean
850
- /** Whether this collection is marked as NSFW */
851
- isNsfw: boolean
852
- /** URL to the collection on OpenSea */
853
- openseaUrl: string
846
+ export type CollectionSearchResult = Camelize<
847
+ Omit<ApiCollectionSearchResponse, "image_url">
848
+ > & {
849
+ /** URL of the collection image (null when no image) */
850
+ imageUrl?: string | null
854
851
  }
855
852
 
856
853
  /**
857
- * Token (currency) search result.
854
+ * Token (currency) search result. Sourced from `@opensea/api-types`
855
+ * (`TokenSearchResponse`). `imageUrl` is widened to `string | null` to match
856
+ * the live API response for tokens without an image.
858
857
  * @category API Models
859
858
  */
860
- export type TokenSearchResult = {
861
- /** Contract address of the token */
862
- address: string
863
- /** Blockchain the token is on */
864
- chain: string
865
- /** Token name */
866
- name: string
867
- /** Token symbol */
868
- symbol: string
869
- /** URL of the token image */
870
- imageUrl: string | null
871
- /** Current USD price of the token */
872
- usdPrice: string
873
- /** Number of decimal places for the token */
874
- decimals: number
875
- /** URL to the token on OpenSea */
876
- openseaUrl: string
877
- }
878
-
879
- /**
880
- * NFT search result.
859
+ export type TokenSearchResult = Camelize<
860
+ Omit<ApiTokenSearchResponse, "image_url">
861
+ > & {
862
+ /** URL of the token image (null when no image) */
863
+ imageUrl?: string | null
864
+ }
865
+
866
+ /**
867
+ * NFT search result. Sourced from `@opensea/api-types`
868
+ * (`NftSearchResponse`). `name` and `imageUrl` are widened to `string | null`
869
+ * to match the live API response.
881
870
  * @category API Models
882
871
  */
883
- export type NftSearchResult = {
884
- /** Token ID of the NFT */
885
- identifier: string
886
- /** Collection slug the NFT belongs to */
887
- collection: string
888
- /** Contract address of the NFT */
889
- contract: string
890
- /** Name of the NFT */
891
- name: string | null
892
- /** URL of the NFT image */
893
- imageUrl: string | null
894
- /** URL to the NFT on OpenSea */
895
- openseaUrl: string
872
+ export type NftSearchResult = Camelize<
873
+ Omit<ApiNftSearchResponse, "image_url" | "name">
874
+ > & {
875
+ /** Name of the NFT (null when not named) */
876
+ name?: string | null
877
+ /** URL of the NFT image (null when no image) */
878
+ imageUrl?: string | null
896
879
  }
897
880
 
898
881
  /**
899
- * Account search result.
882
+ * Account search result. Sourced from `@opensea/api-types`
883
+ * (`AccountSearchResponse`). `username` and `profileImageUrl` are widened to
884
+ * `string | null` to match the live API response.
900
885
  * @category API Models
901
886
  */
902
- export type AccountSearchResult = {
903
- /** Primary wallet address of the account */
904
- address: string
905
- /** Username of the account */
906
- username: string | null
907
- /** URL of the account's profile image */
908
- profileImageUrl: string | null
909
- /** URL to the account on OpenSea */
910
- openseaUrl: string
887
+ export type AccountSearchResult = Camelize<
888
+ Omit<ApiAccountSearchResponse, "username" | "profile_image_url">
889
+ > & {
890
+ /** Username of the account (null when not set) */
891
+ username?: string | null
892
+ /** URL of the account's profile image (null when not set) */
893
+ profileImageUrl?: string | null
911
894
  }
912
895
 
913
896
  /**
914
- * A single search result with a type discriminator and the corresponding typed object.
897
+ * A single search result with a type discriminator and the corresponding typed
898
+ * object. Built from `@opensea/api-types` (`SearchResultResponse`) with nested
899
+ * search-result types using the SDK's nullable-image overrides.
915
900
  * @category API Models
916
901
  */
917
- export type SearchResult = {
918
- /** The type of search result */
919
- type: string
902
+ export type SearchResult = Camelize<
903
+ Omit<ApiSearchResultResponse, "collection" | "token" | "nft" | "account">
904
+ > & {
920
905
  /** Collection details, present when type is 'collection' */
921
906
  collection?: CollectionSearchResult
922
907
  /** Token details, present when type is 'token' */
@@ -928,10 +913,11 @@ export type SearchResult = {
928
913
  }
929
914
 
930
915
  /**
931
- * Response from OpenSea API for search.
916
+ * Response from OpenSea API for search. Built from `@opensea/api-types`
917
+ * (`SearchResponse`) with the SDK's `SearchResult` type.
932
918
  * @category API Response Types
933
919
  */
934
- export type SearchResponse = {
920
+ export type SearchResponse = Camelize<Omit<ApiSearchResponse, "results">> & {
935
921
  /** List of search results ranked by relevance */
936
922
  results: SearchResult[]
937
923
  }
@@ -954,11 +940,17 @@ export type GetChainsResponse = {
954
940
 
955
941
  /**
956
942
  * Token balance for a wallet address. Sourced from `@opensea/api-types`
957
- * (`TokenBalanceResponse`). Gains optional `status`, `base_token_liquidity_usd`,
958
- * and `quote_token_liquidity_usd` fields the hand-rolled version didn't expose.
943
+ * (`TokenBalanceResponse`). Gains optional `status`, `baseTokenLiquidityUsd`,
944
+ * and `quoteTokenLiquidityUsd` fields the hand-rolled version didn't expose.
945
+ * `imageUrl` is widened to `string | null` because the live API returns `null`
946
+ * for tokens without an image even though the spec models it as optional
947
+ * non-null.
959
948
  * @category API Models
960
949
  */
961
- export type TokenBalance = Camelize<TokenBalanceResponse>
950
+ export type TokenBalance = Camelize<Omit<TokenBalanceResponse, "image_url">> & {
951
+ /** URL of the token image (null when the token has no image) */
952
+ imageUrl?: string | null
953
+ }
962
954
 
963
955
  /**
964
956
  * Query args for Get Account Tokens endpoint.
@@ -980,10 +972,14 @@ export interface GetAccountTokensArgs {
980
972
  }
981
973
 
982
974
  /**
983
- * Response from OpenSea API for fetching account token balances.
975
+ * Response from OpenSea API for fetching account token balances. Sourced from
976
+ * `@opensea/api-types` (`TokenBalancePaginatedResponse`) with `token_balances`
977
+ * overridden to use the SDK's nullable-image `TokenBalance` type.
984
978
  * @category API Response Types
985
979
  */
986
- export type GetAccountTokensResponse = QueryCursorsV2 & {
980
+ export type GetAccountTokensResponse = Camelize<
981
+ Omit<TokenBalancePaginatedResponse, "token_balances">
982
+ > & {
987
983
  /** List of token balances */
988
984
  tokenBalances: TokenBalance[]
989
985
  }
@@ -1311,6 +1307,30 @@ export interface TokenActivityArgs {
1311
1307
  cursor?: string
1312
1308
  }
1313
1309
 
1310
+ /**
1311
+ * Query args for the account token activity endpoint.
1312
+ * @category API Query Args
1313
+ */
1314
+ export interface GetAccountTokenActivityArgs {
1315
+ /** Chain(s) to filter by. Repeat for multiple chains. */
1316
+ chains?: string[]
1317
+ /** Token contract address(es) to filter by. */
1318
+ tokens?: string[]
1319
+ /** Activity types to include (send, receive, swap, wrap, unwrap). */
1320
+ type?: string[]
1321
+ /** Number of items to return per page. */
1322
+ limit?: number
1323
+ /** Pagination cursor for the next page. */
1324
+ next?: string
1325
+ }
1326
+
1327
+ /**
1328
+ * Response from OpenSea API for fetching account token activity.
1329
+ * @category API Response Types
1330
+ */
1331
+ export type GetAccountTokenActivityResponse =
1332
+ Camelize<TokenAccountActivityPaginatedResponse>
1333
+
1314
1334
  /**
1315
1335
  * Query args for the token holders endpoint (paginated with `cursor`,
1316
1336
  * sortable by `QUANTITY`).
@@ -68,11 +68,95 @@ export class WalletAuthAPI {
68
68
  )
69
69
  }
70
70
 
71
+ getAccountRelationship(addressOrUsername: string) {
72
+ return this.fetcher.get<OperationResponse<"get_account_relationship">>(
73
+ `/api/v2/accounts/${segment(addressOrUsername)}/relationship`,
74
+ )
75
+ }
76
+
77
+ getAccountFollowing(
78
+ addressOrUsername: string,
79
+ query?: WalletAuthQuery<"get_account_following">,
80
+ ) {
81
+ return this.fetcher.get<OperationResponse<"get_account_following">>(
82
+ `/api/v2/accounts/${segment(addressOrUsername)}/following`,
83
+ query,
84
+ )
85
+ }
86
+
87
+ getAccountFollowers(
88
+ addressOrUsername: string,
89
+ query?: WalletAuthQuery<"get_account_followers">,
90
+ ) {
91
+ return this.fetcher.get<OperationResponse<"get_account_followers">>(
92
+ `/api/v2/accounts/${segment(addressOrUsername)}/followers`,
93
+ query,
94
+ )
95
+ }
96
+
97
+ followAccount(addressOrUsername: string) {
98
+ return this.fetcher.request<OperationResponse<"follow_account">>(
99
+ "POST",
100
+ `/api/v2/accounts/${segment(addressOrUsername)}/follow`,
101
+ )
102
+ }
103
+
104
+ unfollowAccount(addressOrUsername: string) {
105
+ return this.fetcher.request<OperationResponse<"unfollow_account">>(
106
+ "DELETE",
107
+ `/api/v2/accounts/${segment(addressOrUsername)}/follow`,
108
+ )
109
+ }
110
+
111
+ watchAccount(addressOrUsername: string) {
112
+ return this.fetcher.request<OperationResponse<"watch_account">>(
113
+ "POST",
114
+ `/api/v2/accounts/${segment(addressOrUsername)}/watch`,
115
+ )
116
+ }
117
+
118
+ unwatchAccount(addressOrUsername: string) {
119
+ return this.fetcher.request<OperationResponse<"unwatch_account">>(
120
+ "DELETE",
121
+ `/api/v2/accounts/${segment(addressOrUsername)}/watch`,
122
+ )
123
+ }
124
+
125
+ listSavedTools(query?: WalletAuthQuery<"list_saved_tools">) {
126
+ return this.fetcher.get<OperationResponse<"list_saved_tools">>(
127
+ "/api/v2/saved-tools",
128
+ query,
129
+ )
130
+ }
131
+
132
+ saveTool(body: WalletAuthRequest<"save_tool">) {
133
+ return this.fetcher.request<OperationResponse<"save_tool">>(
134
+ "POST",
135
+ "/api/v2/saved-tools",
136
+ body,
137
+ )
138
+ }
139
+
140
+ removeSavedTool(query: WalletAuthQuery<"unsave_tool">) {
141
+ const params = new URLSearchParams({
142
+ tool_id: query.toolId,
143
+ registry_chain: query.registryChain,
144
+ registry_addr: query.registryAddr,
145
+ })
146
+ if (query.toolkitName != null) {
147
+ params.set("toolkit_name", query.toolkitName)
148
+ }
149
+ return this.fetcher.request<OperationResponse<"unsave_tool">>(
150
+ "DELETE",
151
+ `/api/v2/saved-tools?${params}`,
152
+ )
153
+ }
154
+
71
155
  cancelOrder(
72
156
  chain: string,
73
157
  protocolAddress: string,
74
158
  orderHash: string,
75
- body: WalletAuthRequest<"cancel_order">,
159
+ body?: WalletAuthRequest<"cancel_order">,
76
160
  ) {
77
161
  return this.fetcher.request<OperationResponse<"cancel_order">>(
78
162
  "POST",
@@ -201,10 +285,15 @@ export class WalletAuthAPI {
201
285
  )
202
286
  }
203
287
 
204
- createCollectionImageUpload(slug: string, imageType: string) {
288
+ createCollectionImageUpload(
289
+ slug: string,
290
+ imageType: string,
291
+ contentType: WalletAuthQuery<"upload_collection_image">["contentType"],
292
+ ) {
293
+ const query = new URLSearchParams({ content_type: contentType })
205
294
  return this.fetcher.request<OperationResponse<"upload_collection_image">>(
206
295
  "POST",
207
- `/api/v2/collections/${segment(slug)}/images/${segment(imageType)}`,
296
+ `/api/v2/collections/${segment(slug)}/images/${segment(imageType)}?${query}`,
208
297
  )
209
298
  }
210
299
 
@@ -232,6 +321,21 @@ export class WalletAuthAPI {
232
321
  )
233
322
  }
234
323
 
324
+ setProfileNftPfp(body: WalletAuthRequest<"set_profile_nft_pfp">) {
325
+ return this.fetcher.request<OperationResponse<"set_profile_nft_pfp">>(
326
+ "POST",
327
+ "/api/v2/profile/nft-pfp",
328
+ body,
329
+ )
330
+ }
331
+
332
+ clearProfileNftPfp() {
333
+ return this.fetcher.request<OperationResponse<"clear_profile_nft_pfp">>(
334
+ "DELETE",
335
+ "/api/v2/profile/nft-pfp",
336
+ )
337
+ }
338
+
235
339
  createProfileShelf(body: WalletAuthRequest<"create_profile_shelf">) {
236
340
  return this.fetcher.request<OperationResponse<"create_profile_shelf">>(
237
341
  "POST",