@opensea/sdk 10.3.1 → 10.5.0
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/lib/api/accounts.d.ts +29 -1
- package/lib/api/accounts.js +63 -0
- package/lib/api/accounts.js.map +1 -1
- package/lib/api/api.d.ts +129 -41
- package/lib/api/api.js +180 -48
- package/lib/api/api.js.map +1 -1
- package/lib/api/apiPaths.d.ts +29 -2
- package/lib/api/apiPaths.js +121 -6
- package/lib/api/apiPaths.js.map +1 -1
- package/lib/api/assets.d.ts +18 -0
- package/lib/api/assets.js +26 -0
- package/lib/api/assets.js.map +1 -0
- package/lib/api/collections.d.ts +19 -1
- package/lib/api/collections.js +26 -0
- package/lib/api/collections.js.map +1 -1
- package/lib/api/drops.d.ts +12 -1
- package/lib/api/drops.js +14 -0
- package/lib/api/drops.js.map +1 -1
- package/lib/api/listings.d.ts +16 -14
- package/lib/api/listings.js +21 -30
- package/lib/api/listings.js.map +1 -1
- package/lib/api/nfts.d.ts +14 -1
- package/lib/api/nfts.js +19 -0
- package/lib/api/nfts.js.map +1 -1
- package/lib/api/offers.d.ts +2 -2
- package/lib/api/offers.js +2 -9
- package/lib/api/offers.js.map +1 -1
- package/lib/api/orders.d.ts +4 -21
- package/lib/api/orders.js +15 -96
- package/lib/api/orders.js.map +1 -1
- package/lib/api/tokens.d.ts +27 -1
- package/lib/api/tokens.js +33 -0
- package/lib/api/tokens.js.map +1 -1
- package/lib/api/transactions.d.ts +16 -0
- package/lib/api/transactions.js +24 -0
- package/lib/api/transactions.js.map +1 -0
- package/lib/api/types.d.ts +147 -10
- package/lib/api/types.js.map +1 -1
- package/lib/orders/types.d.ts +0 -67
- package/lib/orders/types.js.map +1 -1
- package/lib/orders/utils.d.ts +1 -19
- package/lib/orders/utils.js +1 -62
- package/lib/orders/utils.js.map +1 -1
- package/lib/sdk/base.d.ts +6 -6
- package/lib/sdk/base.js +2 -2
- package/lib/sdk/orders.d.ts +13 -10
- package/lib/sdk/orders.js +6 -22
- package/lib/sdk/orders.js.map +1 -1
- package/lib/types.d.ts +0 -6
- package/package.json +2 -2
- package/src/api/accounts.ts +130 -0
- package/src/api/api.ts +324 -86
- package/src/api/apiPaths.ts +138 -8
- package/src/api/assets.ts +22 -0
- package/src/api/collections.ts +65 -0
- package/src/api/drops.ts +34 -1
- package/src/api/listings.ts +37 -41
- package/src/api/nfts.ts +44 -0
- package/src/api/offers.ts +8 -16
- package/src/api/orders.ts +40 -177
- package/src/api/tokens.ts +76 -0
- package/src/api/transactions.ts +28 -0
- package/src/api/types.ts +205 -15
- package/src/orders/types.ts +0 -74
- package/src/orders/utils.ts +2 -73
- package/src/sdk/base.ts +6 -6
- package/src/sdk/orders.ts +31 -32
- package/src/types.ts +0 -6
package/src/sdk/orders.ts
CHANGED
|
@@ -3,9 +3,9 @@ import type {
|
|
|
3
3
|
CreateInputItem,
|
|
4
4
|
OrderComponents,
|
|
5
5
|
} from "@opensea/seaport-js/lib/types"
|
|
6
|
-
import type { CollectionOffer, NFT } from "../api/types"
|
|
6
|
+
import type { CollectionOffer, Listing, NFT, Offer } from "../api/types"
|
|
7
7
|
import { INVERSE_BASIS_POINT, ZERO_ADDRESS } from "../constants"
|
|
8
|
-
import type {
|
|
8
|
+
import type { ProtocolData } from "../orders/types"
|
|
9
9
|
import {
|
|
10
10
|
type Amount,
|
|
11
11
|
type AssetWithTokenId,
|
|
@@ -31,10 +31,13 @@ import type { SDKContext } from "./context"
|
|
|
31
31
|
/**
|
|
32
32
|
* Result type for bulk operations that may partially succeed.
|
|
33
33
|
* Contains successfully submitted orders and any failures with error information.
|
|
34
|
+
*
|
|
35
|
+
* Generic in the success type so listing-side callers see {@link Listing}[] and
|
|
36
|
+
* offer-side callers see {@link Offer}[].
|
|
34
37
|
*/
|
|
35
|
-
export interface BulkOrderResult {
|
|
38
|
+
export interface BulkOrderResult<T extends Listing | Offer = Listing | Offer> {
|
|
36
39
|
/** Successfully submitted orders */
|
|
37
|
-
successful:
|
|
40
|
+
successful: T[]
|
|
38
41
|
/** Failed order submissions with error information */
|
|
39
42
|
failed: Array<{
|
|
40
43
|
/** Index of the failed order in the original input array */
|
|
@@ -405,7 +408,7 @@ export class OrdersManager {
|
|
|
405
408
|
* @param options.expirationTime Expiration time for the order, in UTC seconds
|
|
406
409
|
* @param options.zone Zone for order protection. Defaults to chain's signed zone.
|
|
407
410
|
*
|
|
408
|
-
* @returns The {@link
|
|
411
|
+
* @returns The {@link Offer} that was created.
|
|
409
412
|
*
|
|
410
413
|
* @throws Error if the asset does not contain a token id.
|
|
411
414
|
* @throws Error if the accountAddress is not available through wallet or provider.
|
|
@@ -429,7 +432,7 @@ export class OrdersManager {
|
|
|
429
432
|
salt?: Amount
|
|
430
433
|
expirationTime?: Amount
|
|
431
434
|
zone?: string
|
|
432
|
-
}): Promise<
|
|
435
|
+
}): Promise<Offer> {
|
|
433
436
|
const order = await this._buildOfferOrder({
|
|
434
437
|
asset,
|
|
435
438
|
accountAddress,
|
|
@@ -441,11 +444,10 @@ export class OrdersManager {
|
|
|
441
444
|
zone,
|
|
442
445
|
})
|
|
443
446
|
|
|
444
|
-
return this.context.api.
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
})
|
|
447
|
+
return this.context.api.postOffer(
|
|
448
|
+
order,
|
|
449
|
+
this.context.seaport.contract.target as string,
|
|
450
|
+
)
|
|
449
451
|
}
|
|
450
452
|
|
|
451
453
|
/**
|
|
@@ -462,7 +464,7 @@ export class OrdersManager {
|
|
|
462
464
|
* @param options.buyerAddress Optional address that's allowed to purchase this item. If specified, no other address will be able to take the order, unless its value is the null address.
|
|
463
465
|
* @param options.includeOptionalCreatorFees If true, optional creator fees will be included in the listing. Default: false.
|
|
464
466
|
* @param options.zone Zone for order protection. Defaults to no zone.
|
|
465
|
-
* @returns The {@link
|
|
467
|
+
* @returns The {@link Listing} that was created.
|
|
466
468
|
*
|
|
467
469
|
* @throws Error if the asset does not contain a token id.
|
|
468
470
|
* @throws Error if the accountAddress is not available through wallet or provider.
|
|
@@ -492,7 +494,7 @@ export class OrdersManager {
|
|
|
492
494
|
buyerAddress?: string
|
|
493
495
|
includeOptionalCreatorFees?: boolean
|
|
494
496
|
zone?: string
|
|
495
|
-
}): Promise<
|
|
497
|
+
}): Promise<Listing> {
|
|
496
498
|
const order = await this._buildListingOrder({
|
|
497
499
|
asset,
|
|
498
500
|
accountAddress,
|
|
@@ -507,11 +509,10 @@ export class OrdersManager {
|
|
|
507
509
|
zone,
|
|
508
510
|
})
|
|
509
511
|
|
|
510
|
-
return this.context.api.
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
})
|
|
512
|
+
return this.context.api.postListing(
|
|
513
|
+
order,
|
|
514
|
+
this.context.seaport.contract.target as string,
|
|
515
|
+
)
|
|
515
516
|
}
|
|
516
517
|
|
|
517
518
|
/**
|
|
@@ -555,7 +556,7 @@ export class OrdersManager {
|
|
|
555
556
|
accountAddress: string
|
|
556
557
|
continueOnError?: boolean
|
|
557
558
|
onProgress?: (completed: number, total: number) => void
|
|
558
|
-
}): Promise<BulkOrderResult
|
|
559
|
+
}): Promise<BulkOrderResult<Listing>> {
|
|
559
560
|
if (listings.length === 0) {
|
|
560
561
|
throw new Error("Listings array cannot be empty")
|
|
561
562
|
}
|
|
@@ -743,17 +744,16 @@ export class OrdersManager {
|
|
|
743
744
|
`Starting submission of ${orders.length} bulk-signed ${pluralize(orders.length, "listing")} to OpenSea API...`,
|
|
744
745
|
)
|
|
745
746
|
|
|
746
|
-
const submittedOrders:
|
|
747
|
+
const submittedOrders: Listing[] = []
|
|
747
748
|
const failedOrders: BulkOrderResult["failed"] = []
|
|
748
749
|
|
|
749
750
|
for (let i = 0; i < orders.length; i++) {
|
|
750
751
|
this.context.logger(`Submitting listing ${i + 1}/${orders.length}...`)
|
|
751
752
|
try {
|
|
752
|
-
const submittedOrder = await this.context.api.
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
})
|
|
753
|
+
const submittedOrder = await this.context.api.postListing(
|
|
754
|
+
orders[i],
|
|
755
|
+
this.context.seaport.contract.target as string,
|
|
756
|
+
)
|
|
757
757
|
submittedOrders.push(submittedOrder)
|
|
758
758
|
this.context.logger(`Completed listing ${i + 1}/${orders.length}`)
|
|
759
759
|
} catch (error) {
|
|
@@ -833,7 +833,7 @@ export class OrdersManager {
|
|
|
833
833
|
accountAddress: string
|
|
834
834
|
continueOnError?: boolean
|
|
835
835
|
onProgress?: (completed: number, total: number) => void
|
|
836
|
-
}): Promise<BulkOrderResult
|
|
836
|
+
}): Promise<BulkOrderResult<Offer>> {
|
|
837
837
|
if (offers.length === 0) {
|
|
838
838
|
throw new Error("Offers array cannot be empty")
|
|
839
839
|
}
|
|
@@ -975,17 +975,16 @@ export class OrdersManager {
|
|
|
975
975
|
`Starting submission of ${orders.length} bulk-signed ${pluralize(orders.length, "offer")} to OpenSea API...`,
|
|
976
976
|
)
|
|
977
977
|
|
|
978
|
-
const submittedOrders:
|
|
978
|
+
const submittedOrders: Offer[] = []
|
|
979
979
|
const failedOrders: BulkOrderResult["failed"] = []
|
|
980
980
|
|
|
981
981
|
for (let i = 0; i < orders.length; i++) {
|
|
982
982
|
this.context.logger(`Submitting offer ${i + 1}/${orders.length}...`)
|
|
983
983
|
try {
|
|
984
|
-
const submittedOrder = await this.context.api.
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
})
|
|
984
|
+
const submittedOrder = await this.context.api.postOffer(
|
|
985
|
+
orders[i],
|
|
986
|
+
this.context.seaport.contract.target as string,
|
|
987
|
+
)
|
|
989
988
|
submittedOrders.push(submittedOrder)
|
|
990
989
|
this.context.logger(`Completed offer ${i + 1}/${orders.length}`)
|
|
991
990
|
} catch (error) {
|
package/src/types.ts
CHANGED
|
@@ -243,11 +243,7 @@ export interface AssetWithTokenStandard extends Asset {
|
|
|
243
243
|
interface OpenSeaCollectionStatsIntervalData {
|
|
244
244
|
interval: "one_day" | "seven_day" | "thirty_day"
|
|
245
245
|
volume: number
|
|
246
|
-
volume_diff: number
|
|
247
|
-
volume_change: number
|
|
248
246
|
sales: number
|
|
249
|
-
sales_diff: number
|
|
250
|
-
average_price: number
|
|
251
247
|
}
|
|
252
248
|
|
|
253
249
|
/**
|
|
@@ -258,9 +254,7 @@ export interface OpenSeaCollectionStats {
|
|
|
258
254
|
total: {
|
|
259
255
|
volume: number
|
|
260
256
|
sales: number
|
|
261
|
-
average_price: number
|
|
262
257
|
num_owners: number
|
|
263
|
-
market_cap: number
|
|
264
258
|
floor_price: number
|
|
265
259
|
floor_price_symbol: string
|
|
266
260
|
}
|