@opensea/sdk 12.9.0 → 12.9.2
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/walletAuth.d.ts +29 -25
- package/lib/orders/attribution.d.ts +1 -1
- package/lib/orders/attribution.js.map +1 -1
- package/lib/sdk/base.d.ts +12 -6
- package/lib/sdk.js +1 -4
- package/lib/sdk.js.map +1 -1
- package/lib/utils/chain.d.ts +41 -1
- package/lib/utils/chain.js +53 -8
- package/lib/utils/chain.js.map +1 -1
- package/lib/viem.js +1 -4
- package/lib/viem.js.map +1 -1
- package/package.json +2 -2
- package/src/orders/attribution.ts +1 -1
- package/src/sdk.ts +2 -7
- package/src/utils/chain.ts +67 -9
- package/src/viem.ts +2 -7
package/lib/api/walletAuth.d.ts
CHANGED
|
@@ -13,9 +13,9 @@ export declare class WalletAuthAPI {
|
|
|
13
13
|
stages: {
|
|
14
14
|
stageUuid: string;
|
|
15
15
|
isEligible: boolean;
|
|
16
|
-
price?: string | undefined;
|
|
17
|
-
maxTotalMintableByWallet?: string | undefined;
|
|
18
|
-
maxTotalMintableByWalletPerToken?: string | undefined;
|
|
16
|
+
price?: string | null | undefined;
|
|
17
|
+
maxTotalMintableByWallet?: string | null | undefined;
|
|
18
|
+
maxTotalMintableByWalletPerToken?: string | null | undefined;
|
|
19
19
|
}[];
|
|
20
20
|
}>;
|
|
21
21
|
getFavorites(address: string, query?: WalletAuthQuery<"get_profile_favorites">): Promise<{
|
|
@@ -53,28 +53,28 @@ export declare class WalletAuthAPI {
|
|
|
53
53
|
chain: string;
|
|
54
54
|
name: string;
|
|
55
55
|
symbol: string;
|
|
56
|
-
imageUrl?: string | undefined;
|
|
56
|
+
imageUrl?: string | null | undefined;
|
|
57
57
|
usdPrice: string;
|
|
58
58
|
decimals: number;
|
|
59
59
|
openseaUrl: string;
|
|
60
|
-
marketCapUsd?: number | undefined;
|
|
61
|
-
volume24h?: number | undefined;
|
|
62
|
-
priceChange24h?: number | undefined;
|
|
63
|
-
holdersCount?: number | undefined;
|
|
60
|
+
marketCapUsd?: number | null | undefined;
|
|
61
|
+
volume24h?: number | null | undefined;
|
|
62
|
+
priceChange24h?: number | null | undefined;
|
|
63
|
+
holdersCount?: number | null | undefined;
|
|
64
64
|
isVerified: boolean;
|
|
65
|
-
createdAt?: number | undefined;
|
|
66
|
-
genesisDate?: number | undefined;
|
|
65
|
+
createdAt?: number | null | undefined;
|
|
66
|
+
genesisDate?: number | null | undefined;
|
|
67
67
|
}[];
|
|
68
|
-
next?: string | undefined;
|
|
68
|
+
next?: string | null | undefined;
|
|
69
69
|
}>;
|
|
70
70
|
getPerpetualWatchlist(address: string): Promise<{
|
|
71
71
|
perpetuals: {
|
|
72
72
|
id: string;
|
|
73
73
|
name: string;
|
|
74
74
|
symbol: string;
|
|
75
|
-
imageUrl?: string | undefined;
|
|
76
|
-
description?: string | undefined;
|
|
77
|
-
createdAt?: number | undefined;
|
|
75
|
+
imageUrl?: string | null | undefined;
|
|
76
|
+
description?: string | null | undefined;
|
|
77
|
+
createdAt?: number | null | undefined;
|
|
78
78
|
chain: string;
|
|
79
79
|
contractAddress: string;
|
|
80
80
|
maxLeverage: number;
|
|
@@ -82,18 +82,18 @@ export declare class WalletAuthAPI {
|
|
|
82
82
|
assetId: string;
|
|
83
83
|
version: number;
|
|
84
84
|
categories: string[];
|
|
85
|
-
market?: string | undefined;
|
|
85
|
+
market?: string | null | undefined;
|
|
86
86
|
stats?: {
|
|
87
|
-
priceUsd?: number | undefined;
|
|
88
|
-
priceChange24h?: number | undefined;
|
|
89
|
-
volume24h?: number | undefined;
|
|
90
|
-
markPrice?: number | undefined;
|
|
91
|
-
oraclePrice?: number | undefined;
|
|
92
|
-
fundingRate?: number | undefined;
|
|
93
|
-
openInterest?: number | undefined;
|
|
94
|
-
} | undefined;
|
|
87
|
+
priceUsd?: number | null | undefined;
|
|
88
|
+
priceChange24h?: number | null | undefined;
|
|
89
|
+
volume24h?: number | null | undefined;
|
|
90
|
+
markPrice?: number | null | undefined;
|
|
91
|
+
oraclePrice?: number | null | undefined;
|
|
92
|
+
fundingRate?: number | null | undefined;
|
|
93
|
+
openInterest?: number | null | undefined;
|
|
94
|
+
} | null | undefined;
|
|
95
95
|
}[];
|
|
96
|
-
next?: string | undefined;
|
|
96
|
+
next?: string | null | undefined;
|
|
97
97
|
}>;
|
|
98
98
|
addWatchlistEntry(body: WalletAuthRequest<"add_watchlist_entry">): Promise<{
|
|
99
99
|
success: boolean;
|
|
@@ -166,7 +166,7 @@ export declare class WalletAuthAPI {
|
|
|
166
166
|
registryChain: string;
|
|
167
167
|
registryAddr: string;
|
|
168
168
|
}[];
|
|
169
|
-
next?: string | undefined;
|
|
169
|
+
next?: string | null | undefined;
|
|
170
170
|
}>;
|
|
171
171
|
saveTool(body: WalletAuthRequest<"save_tool">): Promise<{
|
|
172
172
|
id: string;
|
|
@@ -197,15 +197,19 @@ export declare class WalletAuthAPI {
|
|
|
197
197
|
}>;
|
|
198
198
|
saveSelfMintDropItem(slug: string, body: WalletAuthRequest<"save_self_mint_drop_item">): Promise<{
|
|
199
199
|
to: string;
|
|
200
|
+
from: string;
|
|
200
201
|
data: string;
|
|
201
202
|
value: string;
|
|
202
203
|
chain: string;
|
|
204
|
+
tokenId: string;
|
|
203
205
|
}>;
|
|
204
206
|
updateSelfMintDropItem(slug: string, tokenId: string | number, body: WalletAuthRequest<"update_self_mint_drop_item">): Promise<{
|
|
205
207
|
to: string;
|
|
208
|
+
from: string;
|
|
206
209
|
data: string;
|
|
207
210
|
value: string;
|
|
208
211
|
chain: string;
|
|
212
|
+
tokenId: string;
|
|
209
213
|
}>;
|
|
210
214
|
updateDropItem(slug: string, tokenId: string | number, body: WalletAuthRequest<"update_drop_item">): Promise<{
|
|
211
215
|
tokenId: string;
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
* A missing or malformed suffix is ignored rather than raised. Attribution is
|
|
16
16
|
* optional by design and must never be the reason a fill fails.
|
|
17
17
|
*/
|
|
18
|
-
export declare function appendCalldataSuffix(calldata: string, suffix: string | undefined): string;
|
|
18
|
+
export declare function appendCalldataSuffix(calldata: string, suffix: string | null | undefined): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attribution.js","sourceRoot":"","sources":["../../src/orders/attribution.ts"],"names":[],"mappings":";;AAoBA,oDAQC;AA5BD,wEAAwE;AACxE,MAAM,uBAAuB,GAAG,kBAAkB,CAAA;AAElD;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,oBAAoB,CAClC,QAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"attribution.js","sourceRoot":"","sources":["../../src/orders/attribution.ts"],"names":[],"mappings":";;AAoBA,oDAQC;AA5BD,wEAAwE;AACxE,MAAM,uBAAuB,GAAG,kBAAkB,CAAA;AAElD;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,oBAAoB,CAClC,QAAgB,EAChB,MAAiC;IAEjC,IAAI,CAAC,MAAM,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACrD,OAAO,QAAQ,CAAA;IACjB,CAAC;IACD,OAAO,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AACnC,CAAC"}
|
package/lib/sdk/base.d.ts
CHANGED
|
@@ -281,10 +281,10 @@ export declare class BaseOpenSeaSDK {
|
|
|
281
281
|
}): Promise<{
|
|
282
282
|
transactions: {
|
|
283
283
|
chain: string;
|
|
284
|
-
to?: string | undefined;
|
|
284
|
+
to?: string | null | undefined;
|
|
285
285
|
data: string;
|
|
286
|
-
value?: string | undefined;
|
|
287
|
-
valueHex?: string | undefined;
|
|
286
|
+
value?: string | null | undefined;
|
|
287
|
+
valueHex?: string | null | undefined;
|
|
288
288
|
svm?: {
|
|
289
289
|
from: string;
|
|
290
290
|
instructions: {
|
|
@@ -294,11 +294,17 @@ export declare class BaseOpenSeaSDK {
|
|
|
294
294
|
signer: boolean;
|
|
295
295
|
writable: boolean;
|
|
296
296
|
}[];
|
|
297
|
-
data?: string | undefined;
|
|
297
|
+
data?: string | null | undefined;
|
|
298
298
|
}[];
|
|
299
299
|
addressLookupTables: string[];
|
|
300
|
-
|
|
301
|
-
|
|
300
|
+
transactionConfig?: {
|
|
301
|
+
priorityFeeLamports?: string | null | undefined;
|
|
302
|
+
computeUnitLimit?: number | null | undefined;
|
|
303
|
+
loadedAccountsDataSizeLimit?: number | null | undefined;
|
|
304
|
+
heapSizeBytes?: number | null | undefined;
|
|
305
|
+
} | null | undefined;
|
|
306
|
+
} | null | undefined;
|
|
307
|
+
gasLimit?: string | null | undefined;
|
|
302
308
|
}[];
|
|
303
309
|
}>;
|
|
304
310
|
/** Returns whether an order is fulfillable. */
|
package/lib/sdk.js
CHANGED
|
@@ -46,9 +46,6 @@ class OpenSeaSDK extends base_1.BaseOpenSeaSDK {
|
|
|
46
46
|
contractAddress: seaportAddress,
|
|
47
47
|
},
|
|
48
48
|
});
|
|
49
|
-
const cachedPaymentTokenDecimals = {};
|
|
50
|
-
cachedPaymentTokenDecimals[(0, utils_1.getOfferPaymentToken)(chain).toLowerCase()] = 18;
|
|
51
|
-
cachedPaymentTokenDecimals[(0, utils_1.getListingPaymentToken)(chain).toLowerCase()] = 18;
|
|
52
49
|
super({
|
|
53
50
|
wallet,
|
|
54
51
|
contractCaller,
|
|
@@ -57,7 +54,7 @@ class OpenSeaSDK extends base_1.BaseOpenSeaSDK {
|
|
|
57
54
|
chain,
|
|
58
55
|
logger: resolvedLogger,
|
|
59
56
|
getAvailableAccounts: () => (0, ethers_adapter_1.getEthersAccounts)(signerOrProvider, resolvedLogger),
|
|
60
|
-
cachedPaymentTokenDecimals,
|
|
57
|
+
cachedPaymentTokenDecimals: (0, utils_1.getDefaultPaymentTokenDecimals)(chain),
|
|
61
58
|
});
|
|
62
59
|
}
|
|
63
60
|
}
|
package/lib/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":";;;AAAA,oDAA6C;AAE7C,mCAAsC;AACtC,8DAIkC;AAClC,qCAA2C;AAC3C,mCAAsD;AACtD,
|
|
1
|
+
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":";;;AAAA,oDAA6C;AAE7C,mCAAsC;AACtC,8DAIkC;AAClC,qCAA2C;AAC3C,mCAAsD;AACtD,yCAIsB;AAEtB;;;;;;;;;;;;;GAaG;AACH,MAAa,UAAW,SAAQ,qBAAc;IAC5C;;;;;OAKG;IACH,YACE,gBAA0C,EAC1C,YAA8B,EAAE,EAChC,MAA8B;QAE9B,SAAS,CAAC,KAAK,KAAK,aAAK,CAAC,OAAO,CAAA;QACjC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAA;QAC7B,MAAM,GAAG,GAAG,IAAI,gBAAU,CAAC,SAAS,CAAC,CAAA;QACrC,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,CAAA;QAEvD,MAAM,MAAM,GAAG,IAAA,mCAAkB,EAAC,gBAAgB,CAAC,CAAA;QACnD,MAAM,cAAc,GAAG,IAAA,2CAA0B,EAAC,gBAAgB,CAAC,CAAA;QAEnE,MAAM,cAAc,GAAG,IAAA,yBAAiB,EAAC,KAAK,CAAC,CAAA;QAC/C,MAAM,cAAc,GAAG,IAAA,yBAAiB,EAAC,KAAK,CAAC,CAAA;QAC/C,MAAM,OAAO,GAAG,IAAI,oBAAO,CAAC,gBAAgB,EAAE;YAC5C,mBAAmB,EAAE;gBACnB,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,cAAc,CAAC,OAAO;aAC7C;YACD,SAAS,EAAE;gBACT,iBAAiB,EAAE,cAAc,CAAC,GAAG;gBACrC,eAAe,EAAE,cAAc;aAChC;SACF,CAAC,CAAA;QAEF,KAAK,CAAC;YACJ,MAAM;YACN,cAAc;YACd,OAAO;YACP,GAAG;YACH,KAAK;YACL,MAAM,EAAE,cAAc;YACtB,oBAAoB,EAAE,GAAG,EAAE,CACzB,IAAA,kCAAiB,EAAC,gBAAgB,EAAE,cAAc,CAAC;YACrD,0BAA0B,EAAE,IAAA,sCAA8B,EAAC,KAAK,CAAC;SAClE,CAAC,CAAA;IACJ,CAAC;CACF;AA5CD,gCA4CC"}
|
package/lib/utils/chain.d.ts
CHANGED
|
@@ -6,6 +6,30 @@ import { Chain } from "../types";
|
|
|
6
6
|
* @returns True if the chain uses alternate protocol addresses
|
|
7
7
|
*/
|
|
8
8
|
export declare const usesAlternateProtocol: (chain: Chain) => boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Chains whose default offer currency is an ERC-20 mirror of the native
|
|
11
|
+
* stablecoin rather than a wrapped native token. The mirror spends the native
|
|
12
|
+
* balance directly, so there is no wrap/unwrap contract, and its decimals
|
|
13
|
+
* differ from the native asset's. Adding a chain here opts it in everywhere.
|
|
14
|
+
*/
|
|
15
|
+
declare const NATIVE_STABLECOIN_OFFER_TOKENS: {
|
|
16
|
+
readonly arc: {
|
|
17
|
+
readonly address: "0x3600000000000000000000000000000000000000";
|
|
18
|
+
readonly decimals: 6;
|
|
19
|
+
};
|
|
20
|
+
readonly stablechain: {
|
|
21
|
+
readonly address: "0x779ded0c9e1022225f8e0630b35a9b54be713736";
|
|
22
|
+
readonly decimals: 6;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
type NativeStablecoinOfferChain = keyof typeof NATIVE_STABLECOIN_OFFER_TOKENS;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if a chain's default offer currency is a native stablecoin mirror
|
|
28
|
+
* instead of a wrapped native token.
|
|
29
|
+
* @param chain The chain to check
|
|
30
|
+
* @returns True if offers on the chain spend the native stablecoin through an ERC-20 mirror
|
|
31
|
+
*/
|
|
32
|
+
export declare const usesNativeStablecoinOffers: (chain: Chain) => chain is NativeStablecoinOfferChain;
|
|
9
33
|
/**
|
|
10
34
|
* Gets the chain ID for a given chain.
|
|
11
35
|
*
|
|
@@ -21,7 +45,22 @@ export declare const getChainId: (chain: Chain) => string;
|
|
|
21
45
|
* @param chain The chain to get the offer payment token for
|
|
22
46
|
* @returns The token address for offers
|
|
23
47
|
*/
|
|
24
|
-
export declare const getOfferPaymentToken: (chain: Chain) => "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" | "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619" | "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7" | "0x82af49447d8a07e3bd95bd0d56f35241523fbab1" | "0x4300000000000000000000000000000000000004" | "0x4200000000000000000000000000000000000006" | "0x164906a76f1a2ea933366c446ae0ec6a37062c42" | "0x6969696969696969696969696969696969696969" | "0xe30fedd158a2e3b13e9badaeabafc5516e95e8c7" | "0xd3bf53dac106a0290b0483ecbc89d40fcc961f3e" | "0x48b62137edfa95a428d35c09e44256a739f6b557" | "0xe514d9deb7966c8be0ca922de8a064264ea6bcd4" | "0x3439153eb7af838ad19d56e1571fbd09333c2809" | "0x5aad7bba61d95c2c4e525a35f4062040264611f1" | "0x5555555555555555555555555555555555555555" | "0x046ede9564a72571df6f5e44d0405360c0f4dcab" | "0x3bd359c1119da7da1d913d1c4d2b7c461115433a" | "0x0bd7d308f8e1639fab988df18a8011f41eacad73"
|
|
48
|
+
export declare const getOfferPaymentToken: (chain: Chain) => "0x3600000000000000000000000000000000000000" | "0x779ded0c9e1022225f8e0630b35a9b54be713736" | "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" | "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619" | "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7" | "0x82af49447d8a07e3bd95bd0d56f35241523fbab1" | "0x4300000000000000000000000000000000000004" | "0x4200000000000000000000000000000000000006" | "0x164906a76f1a2ea933366c446ae0ec6a37062c42" | "0x6969696969696969696969696969696969696969" | "0xe30fedd158a2e3b13e9badaeabafc5516e95e8c7" | "0xd3bf53dac106a0290b0483ecbc89d40fcc961f3e" | "0x48b62137edfa95a428d35c09e44256a739f6b557" | "0xe514d9deb7966c8be0ca922de8a064264ea6bcd4" | "0x3439153eb7af838ad19d56e1571fbd09333c2809" | "0x5aad7bba61d95c2c4e525a35f4062040264611f1" | "0x5555555555555555555555555555555555555555" | "0x046ede9564a72571df6f5e44d0405360c0f4dcab" | "0x3bd359c1119da7da1d913d1c4d2b7c461115433a" | "0x0bd7d308f8e1639fab988df18a8011f41eacad73";
|
|
49
|
+
/**
|
|
50
|
+
* Returns the decimals of the default offer currency on the given chain.
|
|
51
|
+
* @param chain The chain to get the offer payment token decimals for
|
|
52
|
+
* @returns The number of decimals the token uses
|
|
53
|
+
*/
|
|
54
|
+
export declare const getOfferPaymentTokenDecimals: (chain: Chain) => number;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the decimals of the chain's default offer and listing currencies,
|
|
57
|
+
* keyed by lowercase address, so pricing them never needs a metadata request.
|
|
58
|
+
* @param chain The chain to seed the payment token decimals cache for
|
|
59
|
+
* @returns A map of lowercase token address to decimals
|
|
60
|
+
*/
|
|
61
|
+
export declare const getDefaultPaymentTokenDecimals: (chain: Chain) => {
|
|
62
|
+
[address: string]: number;
|
|
63
|
+
};
|
|
25
64
|
/**
|
|
26
65
|
* Returns the default currency for listings on the given chain.
|
|
27
66
|
* @param chain The chain to get the listing payment token for
|
|
@@ -62,3 +101,4 @@ export declare const getFeeRecipient: (chain: Chain) => string;
|
|
|
62
101
|
* @returns The token address for wrap/unwrap operations
|
|
63
102
|
*/
|
|
64
103
|
export declare const getNativeWrapTokenAddress: (chain: Chain) => string;
|
|
104
|
+
export {};
|
package/lib/utils/chain.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getNativeWrapTokenAddress = exports.getFeeRecipient = exports.getSignedZone = exports.getSeaportAddress = exports.getDefaultConduit = exports.getListingPaymentToken = exports.getOfferPaymentToken = exports.getChainId = exports.usesAlternateProtocol = void 0;
|
|
3
|
+
exports.getNativeWrapTokenAddress = exports.getFeeRecipient = exports.getSignedZone = exports.getSeaportAddress = exports.getDefaultConduit = exports.getListingPaymentToken = exports.getDefaultPaymentTokenDecimals = exports.getOfferPaymentTokenDecimals = exports.getOfferPaymentToken = exports.getChainId = exports.usesNativeStablecoinOffers = exports.usesAlternateProtocol = void 0;
|
|
4
4
|
const constants_1 = require("@opensea/seaport-js/lib/constants");
|
|
5
5
|
const constants_2 = require("../constants");
|
|
6
6
|
const types_1 = require("../types");
|
|
@@ -13,6 +13,32 @@ const chainIds_generated_1 = require("./chainIds.generated");
|
|
|
13
13
|
*/
|
|
14
14
|
const usesAlternateProtocol = (chain) => chain === types_1.Chain.Gunzilla || chain === types_1.Chain.Somnia || chain === types_1.Chain.MegaETH;
|
|
15
15
|
exports.usesAlternateProtocol = usesAlternateProtocol;
|
|
16
|
+
/** Decimals of native assets and of every wrapped native token the SDK defaults to. */
|
|
17
|
+
const NATIVE_DECIMALS = 18;
|
|
18
|
+
/**
|
|
19
|
+
* Chains whose default offer currency is an ERC-20 mirror of the native
|
|
20
|
+
* stablecoin rather than a wrapped native token. The mirror spends the native
|
|
21
|
+
* balance directly, so there is no wrap/unwrap contract, and its decimals
|
|
22
|
+
* differ from the native asset's. Adding a chain here opts it in everywhere.
|
|
23
|
+
*/
|
|
24
|
+
const NATIVE_STABLECOIN_OFFER_TOKENS = {
|
|
25
|
+
[types_1.Chain.Arc]: {
|
|
26
|
+
address: "0x3600000000000000000000000000000000000000", // USDC
|
|
27
|
+
decimals: 6,
|
|
28
|
+
},
|
|
29
|
+
[types_1.Chain.StableChain]: {
|
|
30
|
+
address: "0x779ded0c9e1022225f8e0630b35a9b54be713736", // USDT0
|
|
31
|
+
decimals: 6,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Checks if a chain's default offer currency is a native stablecoin mirror
|
|
36
|
+
* instead of a wrapped native token.
|
|
37
|
+
* @param chain The chain to check
|
|
38
|
+
* @returns True if offers on the chain spend the native stablecoin through an ERC-20 mirror
|
|
39
|
+
*/
|
|
40
|
+
const usesNativeStablecoinOffers = (chain) => chain in NATIVE_STABLECOIN_OFFER_TOKENS;
|
|
41
|
+
exports.usesNativeStablecoinOffers = usesNativeStablecoinOffers;
|
|
16
42
|
/**
|
|
17
43
|
* Gets the chain ID for a given chain.
|
|
18
44
|
*
|
|
@@ -42,6 +68,9 @@ const getOfferPaymentToken = (chain) => {
|
|
|
42
68
|
if (chain === types_1.Chain.Solana || chain === types_1.Chain.Hyperliquid) {
|
|
43
69
|
throw new Error(`Chain ${chain} is not supported for OpenSea Seaport offers`);
|
|
44
70
|
}
|
|
71
|
+
if ((0, exports.usesNativeStablecoinOffers)(chain)) {
|
|
72
|
+
return NATIVE_STABLECOIN_OFFER_TOKENS[chain].address;
|
|
73
|
+
}
|
|
45
74
|
switch (chain) {
|
|
46
75
|
case types_1.Chain.Mainnet:
|
|
47
76
|
return "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"; // WETH
|
|
@@ -88,10 +117,6 @@ const getOfferPaymentToken = (chain) => {
|
|
|
88
117
|
return "0x3bd359c1119da7da1d913d1c4d2b7c461115433a"; // WMON
|
|
89
118
|
case types_1.Chain.Robinhood:
|
|
90
119
|
return "0x0bd7d308f8e1639fab988df18a8011f41eacad73"; // WETH
|
|
91
|
-
case types_1.Chain.Arc:
|
|
92
|
-
return "0x3600000000000000000000000000000000000000"; // USDC (6-decimal ERC20 mirror of native USDC)
|
|
93
|
-
case types_1.Chain.StableChain:
|
|
94
|
-
return "0x779ded0c9e1022225f8e0630b35a9b54be713736"; // USDT0 (6-decimal ERC20 mirror of native gUSDT0)
|
|
95
120
|
default: {
|
|
96
121
|
const exhaustiveChain = chain;
|
|
97
122
|
throw new Error(`Unknown offer currency for ${exhaustiveChain}`);
|
|
@@ -99,6 +124,26 @@ const getOfferPaymentToken = (chain) => {
|
|
|
99
124
|
}
|
|
100
125
|
};
|
|
101
126
|
exports.getOfferPaymentToken = getOfferPaymentToken;
|
|
127
|
+
/**
|
|
128
|
+
* Returns the decimals of the default offer currency on the given chain.
|
|
129
|
+
* @param chain The chain to get the offer payment token decimals for
|
|
130
|
+
* @returns The number of decimals the token uses
|
|
131
|
+
*/
|
|
132
|
+
const getOfferPaymentTokenDecimals = (chain) => (0, exports.usesNativeStablecoinOffers)(chain)
|
|
133
|
+
? NATIVE_STABLECOIN_OFFER_TOKENS[chain].decimals
|
|
134
|
+
: NATIVE_DECIMALS;
|
|
135
|
+
exports.getOfferPaymentTokenDecimals = getOfferPaymentTokenDecimals;
|
|
136
|
+
/**
|
|
137
|
+
* Returns the decimals of the chain's default offer and listing currencies,
|
|
138
|
+
* keyed by lowercase address, so pricing them never needs a metadata request.
|
|
139
|
+
* @param chain The chain to seed the payment token decimals cache for
|
|
140
|
+
* @returns A map of lowercase token address to decimals
|
|
141
|
+
*/
|
|
142
|
+
const getDefaultPaymentTokenDecimals = (chain) => ({
|
|
143
|
+
[(0, exports.getListingPaymentToken)(chain).toLowerCase()]: NATIVE_DECIMALS,
|
|
144
|
+
[(0, exports.getOfferPaymentToken)(chain).toLowerCase()]: (0, exports.getOfferPaymentTokenDecimals)(chain),
|
|
145
|
+
});
|
|
146
|
+
exports.getDefaultPaymentTokenDecimals = getDefaultPaymentTokenDecimals;
|
|
102
147
|
/**
|
|
103
148
|
* Returns the default currency for listings on the given chain.
|
|
104
149
|
* @param chain The chain to get the listing payment token for
|
|
@@ -235,12 +280,12 @@ exports.getFeeRecipient = getFeeRecipient;
|
|
|
235
280
|
* @returns The token address for wrap/unwrap operations
|
|
236
281
|
*/
|
|
237
282
|
const getNativeWrapTokenAddress = (chain) => {
|
|
283
|
+
if ((0, exports.usesNativeStablecoinOffers)(chain)) {
|
|
284
|
+
throw new Error(`Chain ${chain} has no wrapped native token; offers spend the native balance directly through ${(0, exports.getOfferPaymentToken)(chain)}`);
|
|
285
|
+
}
|
|
238
286
|
switch (chain) {
|
|
239
287
|
case types_1.Chain.Polygon:
|
|
240
288
|
return constants_2.WPOL_ADDRESS;
|
|
241
|
-
case types_1.Chain.Arc:
|
|
242
|
-
case types_1.Chain.StableChain:
|
|
243
|
-
throw new Error(`Chain ${chain} has no wrapped native token; offers spend the native balance directly through ${(0, exports.getOfferPaymentToken)(chain)}`);
|
|
244
289
|
default:
|
|
245
290
|
return (0, exports.getOfferPaymentToken)(chain);
|
|
246
291
|
}
|
package/lib/utils/chain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../src/utils/chain.ts"],"names":[],"mappings":";;;AAAA,iEAAoF;AACpF,4CAgBqB;AACrB,oCAAgC;AAChC,6DAAmD;AAEnD;;;;;GAKG;AACI,MAAM,qBAAqB,GAAG,CAAC,KAAY,EAAW,EAAE,CAC7D,KAAK,KAAK,aAAK,CAAC,QAAQ,IAAI,KAAK,KAAK,aAAK,CAAC,MAAM,IAAI,KAAK,KAAK,aAAK,CAAC,OAAO,CAAA;AADlE,QAAA,qBAAqB,yBAC6C;AAE/E;;;;;;;;GAQG;AACI,MAAM,UAAU,GAAG,CAAC,KAAY,EAAU,EAAE;IACjD,MAAM,EAAE,GAAG,iCAAY,CAAC,KAAK,CAAC,CAAA;IAC9B,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACrB,IAAI,MAAM,CAAC,MAAM,CAAC,aAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CACb,SAAS,KAAK,qDAAqD,CACpE,CAAA;QACH,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,uBAAuB,KAAK,EAAE,CAAC,CAAA;IACjD,CAAC;IACD,OAAO,EAAE,CAAA;AACX,CAAC,CAAA;AAXY,QAAA,UAAU,cAWtB;AAED;;;;GAIG;AACI,MAAM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AC,KAAK,CAAC;QACjC,CAAC,CAAC,4CAAgC;QAClC,CAAC,CAAC,kCAAsB,CAAA;AAC5B,CAAC,CAAA;AAJY,QAAA,aAAa,iBAIzB;AAED;;;;GAIG;AACI,MAAM,eAAe,GAAG,CAAC,KAAY,EAAU,EAAE;IACtD,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,aAAK,CAAC,QAAQ;YACjB,OAAO,kCAAsB,CAAA;QAC/B,KAAK,aAAK,CAAC,MAAM;YACf,OAAO,gCAAoB,CAAA;QAC7B,KAAK,aAAK,CAAC,OAAO;YAChB,OAAO,mCAAuB,CAAA;QAChC;YACE,OAAO,iCAAqB,CAAA;IAChC,CAAC;AACH,CAAC,CAAA;AAXY,QAAA,eAAe,mBAW3B;AAED;;;;;GAKG;AACI,MAAM,yBAAyB,GAAG,CAAC,KAAY,EAAU,EAAE;IAChE,IAAI,IAAA,kCAA0B,EAAC,KAAK,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CACb,SAAS,KAAK,kFAAkF,IAAA,4BAAoB,EAAC,KAAK,CAAC,EAAE,CAC9H,CAAA;IACH,CAAC;IACD,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,aAAK,CAAC,OAAO;YAChB,OAAO,wBAAY,CAAA;QACrB;YACE,OAAO,IAAA,4BAAoB,EAAC,KAAK,CAAC,CAAA;IACtC,CAAC;AACH,CAAC,CAAA;AAZY,QAAA,yBAAyB,6BAYrC"}
|
package/lib/viem.js
CHANGED
|
@@ -88,9 +88,6 @@ class OpenSeaSDK extends base_1.BaseOpenSeaSDK {
|
|
|
88
88
|
contractAddress: seaportAddress,
|
|
89
89
|
},
|
|
90
90
|
});
|
|
91
|
-
const cachedPaymentTokenDecimals = {};
|
|
92
|
-
cachedPaymentTokenDecimals[(0, utils_1.getOfferPaymentToken)(chain).toLowerCase()] = 18;
|
|
93
|
-
cachedPaymentTokenDecimals[(0, utils_1.getListingPaymentToken)(chain).toLowerCase()] = 18;
|
|
94
91
|
super({
|
|
95
92
|
wallet,
|
|
96
93
|
contractCaller,
|
|
@@ -110,7 +107,7 @@ class OpenSeaSDK extends base_1.BaseOpenSeaSDK {
|
|
|
110
107
|
}
|
|
111
108
|
return [];
|
|
112
109
|
},
|
|
113
|
-
cachedPaymentTokenDecimals,
|
|
110
|
+
cachedPaymentTokenDecimals: (0, utils_1.getDefaultPaymentTokenDecimals)(chain),
|
|
114
111
|
});
|
|
115
112
|
}
|
|
116
113
|
}
|
package/lib/viem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viem.js","sourceRoot":"","sources":["../src/viem.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;;AAEH,2EAA2E;AAC3E,mEAAmE;AACnE,oDAA6C;AAC7C,mCAAsC;AACtC,8DAA+D;AAC/D,0DAIgC;AAChC,qCAA2C;AAC3C,mCAAsD;AACtD,6CAAiD;AACjD,
|
|
1
|
+
{"version":3,"file":"viem.js","sourceRoot":"","sources":["../src/viem.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;;AAEH,2EAA2E;AAC3E,mEAAmE;AACnE,oDAA6C;AAC7C,mCAAsC;AACtC,8DAA+D;AAC/D,0DAIgC;AAChC,qCAA2C;AAC3C,mCAAsD;AACtD,6CAAiD;AACjD,yCAIsB;AAEtB,iDAAiD;AACjD,iCAAsC;AAA7B,iGAAA,UAAU,OAAA;AACnB,8CAA2B;AAC3B,mDAAgC;AAChC,yCAAsB;AACtB,8CAA2B;AAC3B,iDAA8B;AAQ9B,0CAAuB;AACvB,0CAAuB;AAEvB;;;;;;;GAOG;AACH,MAAa,UAAW,SAAQ,qBAAc;IAC5C;;;;;OAKG;IACH,YACE,WAA8B,EAC9B,YAA8B,EAAE,EAChC,MAA8B;QAE9B,SAAS,CAAC,KAAK,KAAK,aAAK,CAAC,OAAO,CAAA;QACjC,MAAM,KAAK,G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0BAA0B,EAAE,IAAA,sCAA8B,EAAC,KAAK,CAAC;SAClE,CAAC,CAAA;IACJ,CAAC;CACF;AA3DD,gCA2DC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensea/sdk",
|
|
3
|
-
"version": "12.9.
|
|
3
|
+
"version": "12.9.2",
|
|
4
4
|
"description": "TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs, tokens, and our marketplace data",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "OpenSea Developers",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"types": "lib/index.d.ts",
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@noble/hashes": "^2.0.1",
|
|
50
|
-
"@opensea/api-types": "^0.
|
|
50
|
+
"@opensea/api-types": "^0.13.0",
|
|
51
51
|
"@opensea/seaport-js": "^4.2.0",
|
|
52
52
|
"ethers": "^6.16.0"
|
|
53
53
|
},
|
|
@@ -20,7 +20,7 @@ const CALLDATA_SUFFIX_PATTERN = /^0x[0-9a-f]{8}$/i
|
|
|
20
20
|
*/
|
|
21
21
|
export function appendCalldataSuffix(
|
|
22
22
|
calldata: string,
|
|
23
|
-
suffix: string | undefined,
|
|
23
|
+
suffix: string | null | undefined,
|
|
24
24
|
): string {
|
|
25
25
|
if (!suffix || !CALLDATA_SUFFIX_PATTERN.test(suffix)) {
|
|
26
26
|
return calldata
|
package/src/sdk.ts
CHANGED
|
@@ -10,8 +10,7 @@ import { BaseOpenSeaSDK } from "./sdk/base"
|
|
|
10
10
|
import { Chain, type OpenSeaAPIConfig } from "./types"
|
|
11
11
|
import {
|
|
12
12
|
getDefaultConduit,
|
|
13
|
-
|
|
14
|
-
getOfferPaymentToken,
|
|
13
|
+
getDefaultPaymentTokenDecimals,
|
|
15
14
|
getSeaportAddress,
|
|
16
15
|
} from "./utils/utils"
|
|
17
16
|
|
|
@@ -61,10 +60,6 @@ export class OpenSeaSDK extends BaseOpenSeaSDK {
|
|
|
61
60
|
},
|
|
62
61
|
})
|
|
63
62
|
|
|
64
|
-
const cachedPaymentTokenDecimals: { [address: string]: number } = {}
|
|
65
|
-
cachedPaymentTokenDecimals[getOfferPaymentToken(chain).toLowerCase()] = 18
|
|
66
|
-
cachedPaymentTokenDecimals[getListingPaymentToken(chain).toLowerCase()] = 18
|
|
67
|
-
|
|
68
63
|
super({
|
|
69
64
|
wallet,
|
|
70
65
|
contractCaller,
|
|
@@ -74,7 +69,7 @@ export class OpenSeaSDK extends BaseOpenSeaSDK {
|
|
|
74
69
|
logger: resolvedLogger,
|
|
75
70
|
getAvailableAccounts: () =>
|
|
76
71
|
getEthersAccounts(signerOrProvider, resolvedLogger),
|
|
77
|
-
cachedPaymentTokenDecimals,
|
|
72
|
+
cachedPaymentTokenDecimals: getDefaultPaymentTokenDecimals(chain),
|
|
78
73
|
})
|
|
79
74
|
}
|
|
80
75
|
}
|
package/src/utils/chain.ts
CHANGED
|
@@ -28,6 +28,41 @@ import { CHAIN_ID_MAP } from "./chainIds.generated"
|
|
|
28
28
|
export const usesAlternateProtocol = (chain: Chain): boolean =>
|
|
29
29
|
chain === Chain.Gunzilla || chain === Chain.Somnia || chain === Chain.MegaETH
|
|
30
30
|
|
|
31
|
+
/** Decimals of native assets and of every wrapped native token the SDK defaults to. */
|
|
32
|
+
const NATIVE_DECIMALS = 18
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Chains whose default offer currency is an ERC-20 mirror of the native
|
|
36
|
+
* stablecoin rather than a wrapped native token. The mirror spends the native
|
|
37
|
+
* balance directly, so there is no wrap/unwrap contract, and its decimals
|
|
38
|
+
* differ from the native asset's. Adding a chain here opts it in everywhere.
|
|
39
|
+
*/
|
|
40
|
+
const NATIVE_STABLECOIN_OFFER_TOKENS = {
|
|
41
|
+
[Chain.Arc]: {
|
|
42
|
+
address: "0x3600000000000000000000000000000000000000", // USDC
|
|
43
|
+
decimals: 6,
|
|
44
|
+
},
|
|
45
|
+
[Chain.StableChain]: {
|
|
46
|
+
address: "0x779ded0c9e1022225f8e0630b35a9b54be713736", // USDT0
|
|
47
|
+
decimals: 6,
|
|
48
|
+
},
|
|
49
|
+
} as const satisfies Partial<
|
|
50
|
+
Record<Chain, { address: string; decimals: number }>
|
|
51
|
+
>
|
|
52
|
+
|
|
53
|
+
type NativeStablecoinOfferChain = keyof typeof NATIVE_STABLECOIN_OFFER_TOKENS
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Checks if a chain's default offer currency is a native stablecoin mirror
|
|
57
|
+
* instead of a wrapped native token.
|
|
58
|
+
* @param chain The chain to check
|
|
59
|
+
* @returns True if offers on the chain spend the native stablecoin through an ERC-20 mirror
|
|
60
|
+
*/
|
|
61
|
+
export const usesNativeStablecoinOffers = (
|
|
62
|
+
chain: Chain,
|
|
63
|
+
): chain is NativeStablecoinOfferChain =>
|
|
64
|
+
chain in NATIVE_STABLECOIN_OFFER_TOKENS
|
|
65
|
+
|
|
31
66
|
/**
|
|
32
67
|
* Gets the chain ID for a given chain.
|
|
33
68
|
*
|
|
@@ -61,6 +96,9 @@ export const getOfferPaymentToken = (chain: Chain) => {
|
|
|
61
96
|
`Chain ${chain} is not supported for OpenSea Seaport offers`,
|
|
62
97
|
)
|
|
63
98
|
}
|
|
99
|
+
if (usesNativeStablecoinOffers(chain)) {
|
|
100
|
+
return NATIVE_STABLECOIN_OFFER_TOKENS[chain].address
|
|
101
|
+
}
|
|
64
102
|
switch (chain) {
|
|
65
103
|
case Chain.Mainnet:
|
|
66
104
|
return "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" // WETH
|
|
@@ -107,10 +145,6 @@ export const getOfferPaymentToken = (chain: Chain) => {
|
|
|
107
145
|
return "0x3bd359c1119da7da1d913d1c4d2b7c461115433a" // WMON
|
|
108
146
|
case Chain.Robinhood:
|
|
109
147
|
return "0x0bd7d308f8e1639fab988df18a8011f41eacad73" // WETH
|
|
110
|
-
case Chain.Arc:
|
|
111
|
-
return "0x3600000000000000000000000000000000000000" // USDC (6-decimal ERC20 mirror of native USDC)
|
|
112
|
-
case Chain.StableChain:
|
|
113
|
-
return "0x779ded0c9e1022225f8e0630b35a9b54be713736" // USDT0 (6-decimal ERC20 mirror of native gUSDT0)
|
|
114
148
|
default: {
|
|
115
149
|
const exhaustiveChain: never = chain
|
|
116
150
|
throw new Error(`Unknown offer currency for ${exhaustiveChain}`)
|
|
@@ -118,6 +152,30 @@ export const getOfferPaymentToken = (chain: Chain) => {
|
|
|
118
152
|
}
|
|
119
153
|
}
|
|
120
154
|
|
|
155
|
+
/**
|
|
156
|
+
* Returns the decimals of the default offer currency on the given chain.
|
|
157
|
+
* @param chain The chain to get the offer payment token decimals for
|
|
158
|
+
* @returns The number of decimals the token uses
|
|
159
|
+
*/
|
|
160
|
+
export const getOfferPaymentTokenDecimals = (chain: Chain): number =>
|
|
161
|
+
usesNativeStablecoinOffers(chain)
|
|
162
|
+
? NATIVE_STABLECOIN_OFFER_TOKENS[chain].decimals
|
|
163
|
+
: NATIVE_DECIMALS
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Returns the decimals of the chain's default offer and listing currencies,
|
|
167
|
+
* keyed by lowercase address, so pricing them never needs a metadata request.
|
|
168
|
+
* @param chain The chain to seed the payment token decimals cache for
|
|
169
|
+
* @returns A map of lowercase token address to decimals
|
|
170
|
+
*/
|
|
171
|
+
export const getDefaultPaymentTokenDecimals = (
|
|
172
|
+
chain: Chain,
|
|
173
|
+
): { [address: string]: number } => ({
|
|
174
|
+
[getListingPaymentToken(chain).toLowerCase()]: NATIVE_DECIMALS,
|
|
175
|
+
[getOfferPaymentToken(chain).toLowerCase()]:
|
|
176
|
+
getOfferPaymentTokenDecimals(chain),
|
|
177
|
+
})
|
|
178
|
+
|
|
121
179
|
/**
|
|
122
180
|
* Returns the default currency for listings on the given chain.
|
|
123
181
|
* @param chain The chain to get the listing payment token for
|
|
@@ -258,14 +316,14 @@ export const getFeeRecipient = (chain: Chain): string => {
|
|
|
258
316
|
* @returns The token address for wrap/unwrap operations
|
|
259
317
|
*/
|
|
260
318
|
export const getNativeWrapTokenAddress = (chain: Chain): string => {
|
|
319
|
+
if (usesNativeStablecoinOffers(chain)) {
|
|
320
|
+
throw new Error(
|
|
321
|
+
`Chain ${chain} has no wrapped native token; offers spend the native balance directly through ${getOfferPaymentToken(chain)}`,
|
|
322
|
+
)
|
|
323
|
+
}
|
|
261
324
|
switch (chain) {
|
|
262
325
|
case Chain.Polygon:
|
|
263
326
|
return WPOL_ADDRESS
|
|
264
|
-
case Chain.Arc:
|
|
265
|
-
case Chain.StableChain:
|
|
266
|
-
throw new Error(
|
|
267
|
-
`Chain ${chain} has no wrapped native token; offers spend the native balance directly through ${getOfferPaymentToken(chain)}`,
|
|
268
|
-
)
|
|
269
327
|
default:
|
|
270
328
|
return getOfferPaymentToken(chain)
|
|
271
329
|
}
|
package/src/viem.ts
CHANGED
|
@@ -32,8 +32,7 @@ import { Chain, type OpenSeaAPIConfig } from "./types"
|
|
|
32
32
|
import { checksumAddress } from "./utils/address"
|
|
33
33
|
import {
|
|
34
34
|
getDefaultConduit,
|
|
35
|
-
|
|
36
|
-
getOfferPaymentToken,
|
|
35
|
+
getDefaultPaymentTokenDecimals,
|
|
37
36
|
getSeaportAddress,
|
|
38
37
|
} from "./utils/utils"
|
|
39
38
|
|
|
@@ -100,10 +99,6 @@ export class OpenSeaSDK extends BaseOpenSeaSDK {
|
|
|
100
99
|
},
|
|
101
100
|
})
|
|
102
101
|
|
|
103
|
-
const cachedPaymentTokenDecimals: { [address: string]: number } = {}
|
|
104
|
-
cachedPaymentTokenDecimals[getOfferPaymentToken(chain).toLowerCase()] = 18
|
|
105
|
-
cachedPaymentTokenDecimals[getListingPaymentToken(chain).toLowerCase()] = 18
|
|
106
|
-
|
|
107
102
|
super({
|
|
108
103
|
wallet,
|
|
109
104
|
contractCaller,
|
|
@@ -122,7 +117,7 @@ export class OpenSeaSDK extends BaseOpenSeaSDK {
|
|
|
122
117
|
}
|
|
123
118
|
return []
|
|
124
119
|
},
|
|
125
|
-
cachedPaymentTokenDecimals,
|
|
120
|
+
cachedPaymentTokenDecimals: getDefaultPaymentTokenDecimals(chain),
|
|
126
121
|
})
|
|
127
122
|
}
|
|
128
123
|
}
|