@opensea/sdk 10.5.0 → 11.0.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.js +12 -8
- package/lib/api/accounts.js.map +1 -1
- package/lib/api/api.d.ts +16 -10
- package/lib/api/api.js +42 -18
- package/lib/api/api.js.map +1 -1
- package/lib/api/collections.js +7 -15
- package/lib/api/collections.js.map +1 -1
- package/lib/api/fetcher.d.ts +35 -5
- package/lib/api/listings.js +3 -3
- package/lib/api/listings.js.map +1 -1
- package/lib/api/nfts.d.ts +1 -1
- package/lib/api/nfts.js +2 -5
- package/lib/api/nfts.js.map +1 -1
- package/lib/api/offers.d.ts +11 -0
- package/lib/api/offers.js +14 -11
- package/lib/api/offers.js.map +1 -1
- package/lib/api/orders.d.ts +16 -1
- package/lib/api/orders.js +17 -3
- package/lib/api/orders.js.map +1 -1
- package/lib/api/tokens.d.ts +2 -2
- package/lib/api/tokens.js +1 -1
- package/lib/api/tokens.js.map +1 -1
- package/lib/api/types.d.ts +196 -356
- package/lib/api/types.js +2 -1
- package/lib/api/types.js.map +1 -1
- package/lib/orders/types.d.ts +2 -2
- package/lib/orders/utils.d.ts +53 -13
- package/lib/orders/utils.js +33 -50
- package/lib/orders/utils.js.map +1 -1
- package/lib/sdk/base.d.ts +11 -4
- package/lib/sdk/base.js +4 -4
- package/lib/sdk/base.js.map +1 -1
- package/lib/sdk/cancellation.d.ts +3 -1
- package/lib/sdk/cancellation.js +12 -6
- package/lib/sdk/cancellation.js.map +1 -1
- package/lib/sdk/fulfillment.js +7 -4
- package/lib/sdk/fulfillment.js.map +1 -1
- package/lib/sdk/orders.js +1 -1
- package/lib/sdk/orders.js.map +1 -1
- package/lib/types.d.ts +22 -122
- package/lib/types.js.map +1 -1
- package/lib/utils/case.d.ts +63 -0
- package/lib/utils/case.js +83 -0
- package/lib/utils/case.js.map +1 -0
- package/lib/utils/utils.d.ts +0 -1
- package/lib/utils/utils.js +0 -1
- package/lib/utils/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/api/accounts.ts +14 -8
- package/src/api/api.ts +60 -25
- package/src/api/collections.ts +7 -21
- package/src/api/fetcher.ts +41 -6
- package/src/api/listings.ts +3 -3
- package/src/api/nfts.ts +3 -7
- package/src/api/offers.ts +17 -10
- package/src/api/orders.ts +29 -5
- package/src/api/tokens.ts +2 -2
- package/src/api/types.ts +265 -399
- package/src/orders/types.ts +2 -2
- package/src/orders/utils.ts +57 -79
- package/src/sdk/base.ts +4 -4
- package/src/sdk/cancellation.ts +16 -6
- package/src/sdk/fulfillment.ts +7 -6
- package/src/sdk/orders.ts +1 -1
- package/src/types.ts +33 -120
- package/src/utils/case.ts +150 -0
- package/src/utils/utils.ts +0 -1
- package/lib/utils/converters.d.ts +0 -37
- package/lib/utils/converters.js +0 -137
- package/lib/utils/converters.js.map +0 -1
- package/src/utils/converters.ts +0 -145
package/src/utils/utils.ts
CHANGED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Fee, OpenSeaAccount, OpenSeaCollection, OpenSeaPaymentToken, PricingCurrencies, RarityStrategy } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
* Converts a collection JSON response to an OpenSeaCollection object.
|
|
4
|
-
* @param collection The raw collection JSON from the API
|
|
5
|
-
* @returns OpenSeaCollection object
|
|
6
|
-
*/
|
|
7
|
-
export declare const collectionFromJSON: (collection: any) => OpenSeaCollection;
|
|
8
|
-
/**
|
|
9
|
-
* Converts a rarity JSON response to a RarityStrategy object.
|
|
10
|
-
* @param rarity The raw rarity JSON from the API
|
|
11
|
-
* @returns RarityStrategy object or null
|
|
12
|
-
*/
|
|
13
|
-
export declare const rarityFromJSON: (rarity: any) => RarityStrategy | null;
|
|
14
|
-
/**
|
|
15
|
-
* Converts a payment token JSON response to an OpenSeaPaymentToken object.
|
|
16
|
-
* @param token The raw payment token JSON from the API
|
|
17
|
-
* @returns OpenSeaPaymentToken object
|
|
18
|
-
*/
|
|
19
|
-
export declare const paymentTokenFromJSON: (token: any) => OpenSeaPaymentToken;
|
|
20
|
-
/**
|
|
21
|
-
* Converts a pricing currencies JSON response to a PricingCurrencies object.
|
|
22
|
-
* @param pricingCurrencies The raw pricing currencies JSON from the API
|
|
23
|
-
* @returns PricingCurrencies object or undefined
|
|
24
|
-
*/
|
|
25
|
-
export declare const pricingCurrenciesFromJSON: (pricingCurrencies: any) => PricingCurrencies | undefined;
|
|
26
|
-
/**
|
|
27
|
-
* Converts an account JSON response to an OpenSeaAccount object.
|
|
28
|
-
* @param account The raw account JSON from the API
|
|
29
|
-
* @returns OpenSeaAccount object
|
|
30
|
-
*/
|
|
31
|
-
export declare const accountFromJSON: (account: any) => OpenSeaAccount;
|
|
32
|
-
/**
|
|
33
|
-
* Converts a fee JSON response to a Fee object.
|
|
34
|
-
* @param fee The raw fee JSON from the API
|
|
35
|
-
* @returns Fee object
|
|
36
|
-
*/
|
|
37
|
-
export declare const feeFromJSON: (fee: any) => Fee;
|
package/lib/utils/converters.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.feeFromJSON = exports.accountFromJSON = exports.pricingCurrenciesFromJSON = exports.paymentTokenFromJSON = exports.rarityFromJSON = exports.collectionFromJSON = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Converts a collection JSON response to an OpenSeaCollection object.
|
|
6
|
-
* @param collection The raw collection JSON from the API
|
|
7
|
-
* @returns OpenSeaCollection object
|
|
8
|
-
*/
|
|
9
|
-
const collectionFromJSON = (collection) => {
|
|
10
|
-
return {
|
|
11
|
-
name: collection.name,
|
|
12
|
-
collection: collection.collection,
|
|
13
|
-
description: collection.description,
|
|
14
|
-
imageUrl: collection.image_url,
|
|
15
|
-
bannerImageUrl: collection.banner_image_url,
|
|
16
|
-
owner: collection.owner,
|
|
17
|
-
safelistStatus: collection.safelist_status,
|
|
18
|
-
category: collection.category,
|
|
19
|
-
isDisabled: collection.is_disabled,
|
|
20
|
-
isNSFW: collection.is_nsfw,
|
|
21
|
-
traitOffersEnabled: collection.trait_offers_enabled,
|
|
22
|
-
collectionOffersEnabled: collection.collection_offers_enabled,
|
|
23
|
-
openseaUrl: collection.opensea_url,
|
|
24
|
-
projectUrl: collection.project_url,
|
|
25
|
-
wikiUrl: collection.wiki_url,
|
|
26
|
-
discordUrl: collection.discord_url,
|
|
27
|
-
telegramUrl: collection.telegram_url,
|
|
28
|
-
twitterUsername: collection.twitter_username,
|
|
29
|
-
instagramUsername: collection.instagram_username,
|
|
30
|
-
contracts: (collection.contracts ?? []).map((contract) => ({
|
|
31
|
-
address: contract.address,
|
|
32
|
-
chain: contract.chain,
|
|
33
|
-
})),
|
|
34
|
-
editors: collection.editors,
|
|
35
|
-
fees: (collection.fees ?? []).map(exports.feeFromJSON),
|
|
36
|
-
rarity: (0, exports.rarityFromJSON)(collection.rarity),
|
|
37
|
-
pricingCurrencies: (0, exports.pricingCurrenciesFromJSON)(collection.pricing_currencies),
|
|
38
|
-
totalSupply: collection.total_supply,
|
|
39
|
-
uniqueItemCount: collection.unique_item_count,
|
|
40
|
-
createdDate: collection.created_date,
|
|
41
|
-
requiredZone: collection.required_zone,
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
exports.collectionFromJSON = collectionFromJSON;
|
|
45
|
-
/**
|
|
46
|
-
* Converts a rarity JSON response to a RarityStrategy object.
|
|
47
|
-
* @param rarity The raw rarity JSON from the API
|
|
48
|
-
* @returns RarityStrategy object or null
|
|
49
|
-
*/
|
|
50
|
-
const rarityFromJSON = (rarity) => {
|
|
51
|
-
if (!rarity) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
const fromJSON = {
|
|
55
|
-
strategyId: rarity.strategy_id,
|
|
56
|
-
strategyVersion: rarity.strategy_version,
|
|
57
|
-
calculatedAt: rarity.calculated_at,
|
|
58
|
-
maxRank: rarity.max_rank,
|
|
59
|
-
tokensScored: rarity.tokens_scored,
|
|
60
|
-
};
|
|
61
|
-
return fromJSON;
|
|
62
|
-
};
|
|
63
|
-
exports.rarityFromJSON = rarityFromJSON;
|
|
64
|
-
/**
|
|
65
|
-
* Converts a payment token JSON response to an OpenSeaPaymentToken object.
|
|
66
|
-
* @param token The raw payment token JSON from the API
|
|
67
|
-
* @returns OpenSeaPaymentToken object
|
|
68
|
-
*/
|
|
69
|
-
const paymentTokenFromJSON = (token) => {
|
|
70
|
-
const fromJSON = {
|
|
71
|
-
name: token.name,
|
|
72
|
-
symbol: token.symbol,
|
|
73
|
-
decimals: token.decimals,
|
|
74
|
-
address: token.address,
|
|
75
|
-
chain: token.chain,
|
|
76
|
-
imageUrl: token.image,
|
|
77
|
-
ethPrice: token.eth_price,
|
|
78
|
-
usdPrice: token.usd_price,
|
|
79
|
-
};
|
|
80
|
-
return fromJSON;
|
|
81
|
-
};
|
|
82
|
-
exports.paymentTokenFromJSON = paymentTokenFromJSON;
|
|
83
|
-
/**
|
|
84
|
-
* Converts a pricing currencies JSON response to a PricingCurrencies object.
|
|
85
|
-
* @param pricingCurrencies The raw pricing currencies JSON from the API
|
|
86
|
-
* @returns PricingCurrencies object or undefined
|
|
87
|
-
*/
|
|
88
|
-
const pricingCurrenciesFromJSON = (pricingCurrencies) => {
|
|
89
|
-
if (!pricingCurrencies) {
|
|
90
|
-
return undefined;
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
listingCurrency: pricingCurrencies.listing_currency
|
|
94
|
-
? (0, exports.paymentTokenFromJSON)(pricingCurrencies.listing_currency)
|
|
95
|
-
: undefined,
|
|
96
|
-
offerCurrency: pricingCurrencies.offer_currency
|
|
97
|
-
? (0, exports.paymentTokenFromJSON)(pricingCurrencies.offer_currency)
|
|
98
|
-
: undefined,
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
exports.pricingCurrenciesFromJSON = pricingCurrenciesFromJSON;
|
|
102
|
-
/**
|
|
103
|
-
* Converts an account JSON response to an OpenSeaAccount object.
|
|
104
|
-
* @param account The raw account JSON from the API
|
|
105
|
-
* @returns OpenSeaAccount object
|
|
106
|
-
*/
|
|
107
|
-
const accountFromJSON = (account) => {
|
|
108
|
-
return {
|
|
109
|
-
address: account.address,
|
|
110
|
-
username: account.username,
|
|
111
|
-
profileImageUrl: account.profile_image_url,
|
|
112
|
-
bannerImageUrl: account.banner_image_url,
|
|
113
|
-
website: account.website,
|
|
114
|
-
socialMediaAccounts: (account.social_media_accounts ?? []).map((acct) => ({
|
|
115
|
-
platform: acct.platform,
|
|
116
|
-
username: acct.username,
|
|
117
|
-
})),
|
|
118
|
-
bio: account.bio,
|
|
119
|
-
joinedDate: account.joined_date,
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
exports.accountFromJSON = accountFromJSON;
|
|
123
|
-
/**
|
|
124
|
-
* Converts a fee JSON response to a Fee object.
|
|
125
|
-
* @param fee The raw fee JSON from the API
|
|
126
|
-
* @returns Fee object
|
|
127
|
-
*/
|
|
128
|
-
const feeFromJSON = (fee) => {
|
|
129
|
-
const fromJSON = {
|
|
130
|
-
fee: fee.fee,
|
|
131
|
-
recipient: fee.recipient,
|
|
132
|
-
required: fee.required,
|
|
133
|
-
};
|
|
134
|
-
return fromJSON;
|
|
135
|
-
};
|
|
136
|
-
exports.feeFromJSON = feeFromJSON;
|
|
137
|
-
//# sourceMappingURL=converters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"converters.js","sourceRoot":"","sources":["../../src/utils/converters.ts"],"names":[],"mappings":";;;AASA;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,CAAC,UAAe,EAAqB,EAAE;IACvE,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,QAAQ,EAAE,UAAU,CAAC,SAAS;QAC9B,cAAc,EAAE,UAAU,CAAC,gBAAgB;QAC3C,K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
|
10
|
-
/**
|
|
11
|
-
* Converts a collection JSON response to an OpenSeaCollection object.
|
|
12
|
-
* @param collection The raw collection JSON from the API
|
|
13
|
-
* @returns OpenSeaCollection object
|
|
14
|
-
*/
|
|
15
|
-
export const collectionFromJSON = (collection: any): OpenSeaCollection => {
|
|
16
|
-
return {
|
|
17
|
-
name: collection.name,
|
|
18
|
-
collection: collection.collection,
|
|
19
|
-
description: collection.description,
|
|
20
|
-
imageUrl: collection.image_url,
|
|
21
|
-
bannerImageUrl: collection.banner_image_url,
|
|
22
|
-
owner: collection.owner,
|
|
23
|
-
safelistStatus: collection.safelist_status,
|
|
24
|
-
category: collection.category,
|
|
25
|
-
isDisabled: collection.is_disabled,
|
|
26
|
-
isNSFW: collection.is_nsfw,
|
|
27
|
-
traitOffersEnabled: collection.trait_offers_enabled,
|
|
28
|
-
collectionOffersEnabled: collection.collection_offers_enabled,
|
|
29
|
-
openseaUrl: collection.opensea_url,
|
|
30
|
-
projectUrl: collection.project_url,
|
|
31
|
-
wikiUrl: collection.wiki_url,
|
|
32
|
-
discordUrl: collection.discord_url,
|
|
33
|
-
telegramUrl: collection.telegram_url,
|
|
34
|
-
twitterUsername: collection.twitter_username,
|
|
35
|
-
instagramUsername: collection.instagram_username,
|
|
36
|
-
contracts: (collection.contracts ?? []).map((contract: any) => ({
|
|
37
|
-
address: contract.address,
|
|
38
|
-
chain: contract.chain,
|
|
39
|
-
})),
|
|
40
|
-
editors: collection.editors,
|
|
41
|
-
fees: (collection.fees ?? []).map(feeFromJSON),
|
|
42
|
-
rarity: rarityFromJSON(collection.rarity),
|
|
43
|
-
pricingCurrencies: pricingCurrenciesFromJSON(collection.pricing_currencies),
|
|
44
|
-
totalSupply: collection.total_supply,
|
|
45
|
-
uniqueItemCount: collection.unique_item_count,
|
|
46
|
-
createdDate: collection.created_date,
|
|
47
|
-
requiredZone: collection.required_zone,
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Converts a rarity JSON response to a RarityStrategy object.
|
|
53
|
-
* @param rarity The raw rarity JSON from the API
|
|
54
|
-
* @returns RarityStrategy object or null
|
|
55
|
-
*/
|
|
56
|
-
export const rarityFromJSON = (rarity: any): RarityStrategy | null => {
|
|
57
|
-
if (!rarity) {
|
|
58
|
-
return null
|
|
59
|
-
}
|
|
60
|
-
const fromJSON: RarityStrategy = {
|
|
61
|
-
strategyId: rarity.strategy_id,
|
|
62
|
-
strategyVersion: rarity.strategy_version,
|
|
63
|
-
calculatedAt: rarity.calculated_at,
|
|
64
|
-
maxRank: rarity.max_rank,
|
|
65
|
-
tokensScored: rarity.tokens_scored,
|
|
66
|
-
}
|
|
67
|
-
return fromJSON
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Converts a payment token JSON response to an OpenSeaPaymentToken object.
|
|
72
|
-
* @param token The raw payment token JSON from the API
|
|
73
|
-
* @returns OpenSeaPaymentToken object
|
|
74
|
-
*/
|
|
75
|
-
export const paymentTokenFromJSON = (token: any): OpenSeaPaymentToken => {
|
|
76
|
-
const fromJSON: OpenSeaPaymentToken = {
|
|
77
|
-
name: token.name,
|
|
78
|
-
symbol: token.symbol,
|
|
79
|
-
decimals: token.decimals,
|
|
80
|
-
address: token.address,
|
|
81
|
-
chain: token.chain,
|
|
82
|
-
imageUrl: token.image,
|
|
83
|
-
ethPrice: token.eth_price,
|
|
84
|
-
usdPrice: token.usd_price,
|
|
85
|
-
}
|
|
86
|
-
return fromJSON
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Converts a pricing currencies JSON response to a PricingCurrencies object.
|
|
91
|
-
* @param pricingCurrencies The raw pricing currencies JSON from the API
|
|
92
|
-
* @returns PricingCurrencies object or undefined
|
|
93
|
-
*/
|
|
94
|
-
export const pricingCurrenciesFromJSON = (
|
|
95
|
-
pricingCurrencies: any,
|
|
96
|
-
): PricingCurrencies | undefined => {
|
|
97
|
-
if (!pricingCurrencies) {
|
|
98
|
-
return undefined
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
listingCurrency: pricingCurrencies.listing_currency
|
|
102
|
-
? paymentTokenFromJSON(pricingCurrencies.listing_currency)
|
|
103
|
-
: undefined,
|
|
104
|
-
offerCurrency: pricingCurrencies.offer_currency
|
|
105
|
-
? paymentTokenFromJSON(pricingCurrencies.offer_currency)
|
|
106
|
-
: undefined,
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Converts an account JSON response to an OpenSeaAccount object.
|
|
112
|
-
* @param account The raw account JSON from the API
|
|
113
|
-
* @returns OpenSeaAccount object
|
|
114
|
-
*/
|
|
115
|
-
export const accountFromJSON = (account: any): OpenSeaAccount => {
|
|
116
|
-
return {
|
|
117
|
-
address: account.address,
|
|
118
|
-
username: account.username,
|
|
119
|
-
profileImageUrl: account.profile_image_url,
|
|
120
|
-
bannerImageUrl: account.banner_image_url,
|
|
121
|
-
website: account.website,
|
|
122
|
-
socialMediaAccounts: (account.social_media_accounts ?? []).map(
|
|
123
|
-
(acct: any) => ({
|
|
124
|
-
platform: acct.platform,
|
|
125
|
-
username: acct.username,
|
|
126
|
-
}),
|
|
127
|
-
),
|
|
128
|
-
bio: account.bio,
|
|
129
|
-
joinedDate: account.joined_date,
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Converts a fee JSON response to a Fee object.
|
|
135
|
-
* @param fee The raw fee JSON from the API
|
|
136
|
-
* @returns Fee object
|
|
137
|
-
*/
|
|
138
|
-
export const feeFromJSON = (fee: any): Fee => {
|
|
139
|
-
const fromJSON: Fee = {
|
|
140
|
-
fee: fee.fee,
|
|
141
|
-
recipient: fee.recipient,
|
|
142
|
-
required: fee.required,
|
|
143
|
-
}
|
|
144
|
-
return fromJSON
|
|
145
|
-
}
|