@opensea/sdk 12.15.0 → 13.0.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/lib/abi/abis.d.ts +0 -30
- package/lib/abi/abis.js +1 -29
- package/lib/abi/abis.js.map +1 -1
- package/lib/api/accounts.js.map +1 -1
- package/lib/api/api.d.ts +3 -0
- package/lib/api/api.js +4 -0
- package/lib/api/api.js.map +1 -1
- package/lib/api/apiPaths.d.ts +2 -0
- package/lib/api/apiPaths.js +9 -1
- package/lib/api/apiPaths.js.map +1 -1
- package/lib/api/assets.js.map +1 -1
- package/lib/api/chains.js.map +1 -1
- package/lib/api/collections.js.map +1 -1
- package/lib/api/drops.js.map +1 -1
- package/lib/api/events.js.map +1 -1
- package/lib/api/listings.js.map +1 -1
- package/lib/api/nfts.js.map +1 -1
- package/lib/api/offers.js.map +1 -1
- package/lib/api/orders.js.map +1 -1
- package/lib/api/search.js.map +1 -1
- package/lib/api/signals.d.ts +21 -0
- package/lib/api/signals.js +31 -0
- package/lib/api/signals.js.map +1 -0
- package/lib/api/tokens.js.map +1 -1
- package/lib/api/tools.js.map +1 -1
- package/lib/api/transactions.js.map +1 -1
- package/lib/api/types.d.ts +18 -1
- package/lib/api/types.js.map +1 -1
- package/lib/api/uploadContext.js.map +1 -1
- package/lib/api/walletAuth.d.ts +264 -259
- package/lib/api/walletAuth.js +17 -10
- package/lib/api/walletAuth.js.map +1 -1
- package/lib/auth/index.js.map +1 -1
- package/lib/auth/oauth.d.ts +3 -1
- package/lib/auth/oauth.js +47 -30
- package/lib/auth/oauth.js.map +1 -1
- package/lib/auth/siwx.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/orders/attribution.js.map +1 -1
- package/lib/orders/erc20Fulfillment.js.map +1 -1
- package/lib/orders/orderUseCase.js.map +1 -1
- package/lib/orders/privateListings.js.map +1 -1
- package/lib/orders/types.js.map +1 -1
- package/lib/orders/utils.js.map +1 -1
- package/lib/provider/ethers-adapter.js.map +1 -1
- package/lib/provider/seaport-bridge.js.map +1 -1
- package/lib/provider/viem-adapter.js.map +1 -1
- package/lib/scopes.js.map +1 -1
- package/lib/sdk/assets.d.ts +6 -5
- package/lib/sdk/assets.js +24 -36
- package/lib/sdk/assets.js.map +1 -1
- package/lib/sdk/base.d.ts +8 -8
- package/lib/sdk/base.js.map +1 -1
- package/lib/sdk/cancellation.js.map +1 -1
- package/lib/sdk/fulfillment.js.map +1 -1
- package/lib/sdk/orders.js.map +1 -1
- package/lib/sdk/tokens.js.map +1 -1
- package/lib/sdk.js.map +1 -1
- package/lib/stream/client.js.map +1 -1
- package/lib/stream/helpers.js.map +1 -1
- package/lib/stream/transport/phoenix.js.map +1 -1
- package/lib/stream/types.js.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils/address.js.map +1 -1
- package/lib/utils/case.js.map +1 -1
- package/lib/utils/chain.d.ts +1 -1
- package/lib/utils/chain.js.map +1 -1
- package/lib/utils/dateHelper.js.map +1 -1
- package/lib/utils/eip712.js.map +1 -1
- package/lib/utils/fees.js.map +1 -1
- package/lib/utils/fetchTransport.js.map +1 -1
- package/lib/utils/protocol.js.map +1 -1
- package/lib/utils/rateLimit.js +3 -3
- package/lib/utils/rateLimit.js.map +1 -1
- package/lib/utils/stringHelper.js.map +1 -1
- package/lib/utils/units.js.map +1 -1
- package/lib/utils/utils.js.map +1 -1
- package/lib/viem.js.map +1 -1
- package/package.json +3 -4
- package/src/abi/abis.ts +0 -29
- package/src/api/api.ts +4 -0
- package/src/api/apiPaths.ts +8 -0
- package/src/api/signals.ts +33 -0
- package/src/api/types.ts +22 -0
- package/src/api/walletAuth.ts +26 -18
- package/src/auth/oauth.ts +86 -53
- package/src/sdk/assets.ts +30 -54
- package/src/utils/rateLimit.ts +3 -3
package/src/sdk/assets.ts
CHANGED
|
@@ -3,15 +3,10 @@ import {
|
|
|
3
3
|
ERC20_ABI,
|
|
4
4
|
ERC721_ABI,
|
|
5
5
|
ERC1155_ABI,
|
|
6
|
-
MULTICALL3_ABI,
|
|
7
6
|
SET_APPROVAL_FOR_ALL_ABI,
|
|
8
7
|
TRANSFER_HELPER_ABI,
|
|
9
8
|
} from "../abi/abis"
|
|
10
|
-
import {
|
|
11
|
-
MAX_UINT256,
|
|
12
|
-
MULTICALL3_ADDRESS,
|
|
13
|
-
TRANSFER_HELPER_ADDRESS,
|
|
14
|
-
} from "../constants"
|
|
9
|
+
import { MAX_UINT256, TRANSFER_HELPER_ADDRESS } from "../constants"
|
|
15
10
|
import {
|
|
16
11
|
type Amount,
|
|
17
12
|
type AssetWithTokenStandard,
|
|
@@ -299,7 +294,7 @@ export class AssetsManager {
|
|
|
299
294
|
if (unapprovedAssets.length > 0) {
|
|
300
295
|
throw new Error(
|
|
301
296
|
`The following asset(s) are not approved for transfer to the OpenSea conduit:\n${unapprovedAssets.join("\n")}\n\n` +
|
|
302
|
-
`Please approve these assets before transferring. You can use the batchApproveAssets() method to approve
|
|
297
|
+
`Please approve these assets before transferring. You can use the batchApproveAssets() method to approve them.`,
|
|
303
298
|
)
|
|
304
299
|
}
|
|
305
300
|
|
|
@@ -336,16 +331,17 @@ export class AssetsManager {
|
|
|
336
331
|
|
|
337
332
|
/**
|
|
338
333
|
* Batch approve multiple assets for transfer to the OpenSea conduit.
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
334
|
+
* Sends one approval transaction per token contract that is not yet
|
|
335
|
+
* approved, skipping contracts that already are. Each approval is sent from
|
|
336
|
+
* `fromAddress`, because a token grants an approval to `msg.sender`: routing
|
|
337
|
+
* them through a batching contract such as Multicall3 would approve that
|
|
338
|
+
* contract instead of the owner.
|
|
343
339
|
*
|
|
344
340
|
* @param options
|
|
345
341
|
* @param options.assets Array of assets to approve for transfer
|
|
346
342
|
* @param options.fromAddress The address that owns the assets
|
|
347
343
|
* @param options.overrides Transaction overrides, ignored if not set.
|
|
348
|
-
* @returns
|
|
344
|
+
* @returns Hash of the last approval transaction, or undefined if no approvals needed
|
|
349
345
|
*
|
|
350
346
|
* @throws Error if the fromAddress is not available through wallet or provider.
|
|
351
347
|
*/
|
|
@@ -444,52 +440,30 @@ export class AssetsManager {
|
|
|
444
440
|
return undefined
|
|
445
441
|
}
|
|
446
442
|
|
|
447
|
-
|
|
448
|
-
if (
|
|
449
|
-
|
|
450
|
-
const wallet = this.context.wallet
|
|
451
|
-
if (!("signer" in wallet)) {
|
|
452
|
-
throw new Error("A signer is required to approve assets")
|
|
453
|
-
}
|
|
454
|
-
const tx = await wallet.signer.sendTransaction({
|
|
455
|
-
to: target,
|
|
456
|
-
data: callData,
|
|
457
|
-
from: fromAddress,
|
|
458
|
-
overrides: overrides as Record<string, unknown>,
|
|
459
|
-
})
|
|
460
|
-
|
|
461
|
-
await this.context.confirmTransaction(
|
|
462
|
-
tx.hash,
|
|
463
|
-
EventType.ApproveAllAssets,
|
|
464
|
-
"Approving asset for transfer",
|
|
465
|
-
)
|
|
466
|
-
|
|
467
|
-
return tx.hash
|
|
443
|
+
const wallet = this.context.wallet
|
|
444
|
+
if (!("signer" in wallet)) {
|
|
445
|
+
throw new Error("A signer is required to approve assets")
|
|
468
446
|
}
|
|
469
447
|
|
|
470
|
-
|
|
471
|
-
const calls = approvalsNeeded.map(({ target, callData }) => ({
|
|
472
|
-
target,
|
|
473
|
-
allowFailure: false,
|
|
474
|
-
callData,
|
|
475
|
-
}))
|
|
476
|
-
|
|
448
|
+
let lastHash: string | undefined
|
|
477
449
|
try {
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
await this.context.confirmTransaction(
|
|
487
|
-
transaction.hash,
|
|
488
|
-
EventType.ApproveAllAssets,
|
|
489
|
-
`Batch approving ${approvalsNeeded.length} asset(s) for transfer`,
|
|
490
|
-
)
|
|
450
|
+
for (const [index, { target, callData }] of approvalsNeeded.entries()) {
|
|
451
|
+
const tx = await wallet.signer.sendTransaction({
|
|
452
|
+
to: target,
|
|
453
|
+
data: callData,
|
|
454
|
+
from: fromAddress,
|
|
455
|
+
overrides: overrides as Record<string, unknown>,
|
|
456
|
+
})
|
|
491
457
|
|
|
492
|
-
|
|
458
|
+
await this.context.confirmTransaction(
|
|
459
|
+
tx.hash,
|
|
460
|
+
EventType.ApproveAllAssets,
|
|
461
|
+
approvalsNeeded.length === 1
|
|
462
|
+
? "Approving asset for transfer"
|
|
463
|
+
: `Approving asset ${index + 1} of ${approvalsNeeded.length} for transfer`,
|
|
464
|
+
)
|
|
465
|
+
lastHash = tx.hash
|
|
466
|
+
}
|
|
493
467
|
} catch (error) {
|
|
494
468
|
console.error(error)
|
|
495
469
|
this.context.dispatch(EventType.TransactionDenied, {
|
|
@@ -498,6 +472,8 @@ export class AssetsManager {
|
|
|
498
472
|
})
|
|
499
473
|
throw error
|
|
500
474
|
}
|
|
475
|
+
|
|
476
|
+
return lastHash
|
|
501
477
|
}
|
|
502
478
|
|
|
503
479
|
/**
|
package/src/utils/rateLimit.ts
CHANGED
|
@@ -92,9 +92,9 @@ export async function executeWithRateLimit<T>(
|
|
|
92
92
|
|
|
93
93
|
// Check if this is a rate limit error by status code (robust) or retry-after header
|
|
94
94
|
const isRateLimitError =
|
|
95
|
-
rateLimitError
|
|
96
|
-
rateLimitError
|
|
97
|
-
rateLimitError
|
|
95
|
+
rateLimitError?.statusCode === RATE_LIMIT_STATUS_CODE ||
|
|
96
|
+
rateLimitError?.statusCode === CUSTOM_RATE_LIMIT_STATUS_CODE ||
|
|
97
|
+
rateLimitError?.retryAfter !== undefined
|
|
98
98
|
|
|
99
99
|
if (!isRateLimitError || attempt === maxRetries) {
|
|
100
100
|
// Not a rate limit error or out of retries, throw the error
|