@opensea/sdk 9.0.0 → 10.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/README.md +25 -4
- package/lib/abi/abis.d.ts +301 -0
- package/lib/abi/abis.js +231 -0
- package/lib/abi/abis.js.map +1 -0
- package/lib/api/api.d.ts +6 -1
- package/lib/api/api.js +60 -51
- package/lib/api/api.js.map +1 -1
- package/lib/api/orders.js +2 -2
- package/lib/api/orders.js.map +1 -1
- package/lib/constants.d.ts +2 -2
- package/lib/constants.js +7 -4
- package/lib/constants.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/orders/privateListings.js +2 -2
- package/lib/orders/privateListings.js.map +1 -1
- package/lib/orders/utils.js +9 -1
- package/lib/orders/utils.js.map +1 -1
- package/lib/provider/ethers-adapter.d.ts +17 -0
- package/lib/provider/ethers-adapter.js +135 -0
- package/lib/provider/ethers-adapter.js.map +1 -0
- package/lib/provider/seaport-bridge.d.ts +11 -0
- package/lib/provider/seaport-bridge.js +130 -0
- package/lib/provider/seaport-bridge.js.map +1 -0
- package/lib/provider/types.d.ts +62 -0
- package/lib/provider/types.js +7 -0
- package/lib/provider/types.js.map +1 -0
- package/lib/provider/viem-adapter.d.ts +27 -0
- package/lib/provider/viem-adapter.js +122 -0
- package/lib/provider/viem-adapter.js.map +1 -0
- package/lib/sdk/assets.d.ts +7 -23
- package/lib/sdk/assets.js +101 -77
- package/lib/sdk/assets.js.map +1 -1
- package/lib/sdk/base.d.ts +334 -0
- package/lib/sdk/base.js +312 -0
- package/lib/sdk/base.js.map +1 -0
- package/lib/sdk/cancellation.d.ts +1 -2
- package/lib/sdk/cancellation.js +4 -4
- package/lib/sdk/cancellation.js.map +1 -1
- package/lib/sdk/context.d.ts +5 -5
- package/lib/sdk/fulfillment.d.ts +13 -58
- package/lib/sdk/fulfillment.js +16 -58
- package/lib/sdk/fulfillment.js.map +1 -1
- package/lib/sdk/orders.d.ts +25 -26
- package/lib/sdk/orders.js +8 -9
- package/lib/sdk/orders.js.map +1 -1
- package/lib/sdk/tokens.d.ts +3 -3
- package/lib/sdk/tokens.js +17 -7
- package/lib/sdk/tokens.js.map +1 -1
- package/lib/sdk.d.ts +16 -550
- package/lib/sdk.js +35 -663
- package/lib/sdk.js.map +1 -1
- package/lib/types.d.ts +11 -6
- package/lib/types.js +3 -3
- package/lib/types.js.map +1 -1
- package/lib/utils/address.d.ts +12 -0
- package/lib/utils/address.js +39 -0
- package/lib/utils/address.js.map +1 -0
- package/lib/utils/chain.d.ts +1 -1
- package/lib/utils/fees.d.ts +5 -0
- package/lib/utils/fees.js +24 -6
- package/lib/utils/fees.js.map +1 -1
- package/lib/utils/protocol.js +5 -5
- package/lib/utils/protocol.js.map +1 -1
- package/lib/utils/units.d.ts +12 -0
- package/lib/utils/units.js +43 -0
- package/lib/utils/units.js.map +1 -0
- package/lib/utils/utils.d.ts +2 -10
- package/lib/utils/utils.js +2 -17
- package/lib/utils/utils.js.map +1 -1
- package/lib/viem.d.ts +44 -0
- package/lib/viem.js +114 -0
- package/lib/viem.js.map +1 -0
- package/package.json +25 -8
- package/src/abi/abis.ts +236 -0
- package/src/api/api.ts +66 -59
- package/src/api/orders.ts +2 -2
- package/src/constants.ts +7 -3
- package/src/index.ts +8 -0
- package/src/orders/privateListings.ts +2 -2
- package/src/orders/utils.ts +8 -1
- package/src/provider/ethers-adapter.ts +182 -0
- package/src/provider/seaport-bridge.ts +163 -0
- package/src/provider/types.ts +67 -0
- package/src/provider/viem-adapter.ts +165 -0
- package/src/sdk/assets.ts +128 -158
- package/src/sdk/base.ts +558 -0
- package/src/sdk/cancellation.ts +6 -9
- package/src/sdk/context.ts +5 -5
- package/src/sdk/fulfillment.ts +31 -72
- package/src/sdk/orders.ts +44 -44
- package/src/sdk/tokens.ts +18 -18
- package/src/sdk.ts +40 -1011
- package/src/types.ts +12 -6
- package/src/utils/address.ts +40 -0
- package/src/utils/fees.ts +28 -8
- package/src/utils/protocol.ts +5 -5
- package/src/utils/units.ts +47 -0
- package/src/utils/utils.ts +2 -22
- package/src/viem.ts +125 -0
- package/lib/src/api/accounts.d.ts +0 -18
- package/lib/src/api/accounts.js +0 -30
- package/lib/src/api/accounts.js.map +0 -1
- package/lib/src/api/api.d.ts +0 -429
- package/lib/src/api/api.js +0 -652
- package/lib/src/api/api.js.map +0 -1
- package/lib/src/api/apiPaths.d.ts +0 -37
- package/lib/src/api/apiPaths.js +0 -140
- package/lib/src/api/apiPaths.js.map +0 -1
- package/lib/src/api/collections.d.ts +0 -26
- package/lib/src/api/collections.js +0 -57
- package/lib/src/api/collections.js.map +0 -1
- package/lib/src/api/events.d.ts +0 -26
- package/lib/src/api/events.js +0 -42
- package/lib/src/api/events.js.map +0 -1
- package/lib/src/api/fetcher.d.ts +0 -24
- package/lib/src/api/fetcher.js +0 -3
- package/lib/src/api/fetcher.js.map +0 -1
- package/lib/src/api/index.d.ts +0 -2
- package/lib/src/api/index.js +0 -19
- package/lib/src/api/index.js.map +0 -1
- package/lib/src/api/listings.d.ts +0 -44
- package/lib/src/api/listings.js +0 -86
- package/lib/src/api/listings.js.map +0 -1
- package/lib/src/api/nfts.d.ts +0 -35
- package/lib/src/api/nfts.js +0 -66
- package/lib/src/api/nfts.js.map +0 -1
- package/lib/src/api/offers.d.ts +0 -54
- package/lib/src/api/offers.js +0 -122
- package/lib/src/api/offers.js.map +0 -1
- package/lib/src/api/orders.d.ts +0 -50
- package/lib/src/api/orders.js +0 -151
- package/lib/src/api/orders.js.map +0 -1
- package/lib/src/api/search.d.ts +0 -13
- package/lib/src/api/search.js +0 -21
- package/lib/src/api/search.js.map +0 -1
- package/lib/src/api/tokens.d.ts +0 -25
- package/lib/src/api/tokens.js +0 -42
- package/lib/src/api/tokens.js.map +0 -1
- package/lib/src/api/types.d.ts +0 -840
- package/lib/src/api/types.js +0 -65
- package/lib/src/api/types.js.map +0 -1
- package/lib/src/constants.d.ts +0 -22
- package/lib/src/constants.js +0 -52
- package/lib/src/constants.js.map +0 -1
- package/lib/src/index.d.ts +0 -18
- package/lib/src/index.js +0 -24
- package/lib/src/index.js.map +0 -1
- package/lib/src/orders/privateListings.d.ts +0 -12
- package/lib/src/orders/privateListings.js +0 -130
- package/lib/src/orders/privateListings.js.map +0 -1
- package/lib/src/orders/types.d.ts +0 -160
- package/lib/src/orders/types.js +0 -10
- package/lib/src/orders/types.js.map +0 -1
- package/lib/src/orders/utils.d.ts +0 -89
- package/lib/src/orders/utils.js +0 -177
- package/lib/src/orders/utils.js.map +0 -1
- package/lib/src/sdk/assets.d.ts +0 -104
- package/lib/src/sdk/assets.js +0 -397
- package/lib/src/sdk/assets.js.map +0 -1
- package/lib/src/sdk/cancellation.d.ts +0 -97
- package/lib/src/sdk/cancellation.js +0 -234
- package/lib/src/sdk/cancellation.js.map +0 -1
- package/lib/src/sdk/context.d.ts +0 -28
- package/lib/src/sdk/context.js +0 -3
- package/lib/src/sdk/context.js.map +0 -1
- package/lib/src/sdk/fulfillment.d.ts +0 -153
- package/lib/src/sdk/fulfillment.js +0 -296
- package/lib/src/sdk/fulfillment.js.map +0 -1
- package/lib/src/sdk/orders.d.ts +0 -253
- package/lib/src/sdk/orders.js +0 -677
- package/lib/src/sdk/orders.js.map +0 -1
- package/lib/src/sdk/tokens.d.ts +0 -31
- package/lib/src/sdk/tokens.js +0 -64
- package/lib/src/sdk/tokens.js.map +0 -1
- package/lib/src/sdk.d.ts +0 -560
- package/lib/src/sdk.js +0 -675
- package/lib/src/sdk.js.map +0 -1
- package/lib/src/typechain/contracts/ERC1155.d.ts +0 -236
- package/lib/src/typechain/contracts/ERC1155.js +0 -3
- package/lib/src/typechain/contracts/ERC1155.js.map +0 -1
- package/lib/src/typechain/contracts/ERC20.d.ts +0 -141
- package/lib/src/typechain/contracts/ERC20.js +0 -3
- package/lib/src/typechain/contracts/ERC20.js.map +0 -1
- package/lib/src/typechain/contracts/ERC721.d.ts +0 -213
- package/lib/src/typechain/contracts/ERC721.js +0 -3
- package/lib/src/typechain/contracts/ERC721.js.map +0 -1
- package/lib/src/typechain/contracts/Multicall3.d.ts +0 -57
- package/lib/src/typechain/contracts/Multicall3.js +0 -3
- package/lib/src/typechain/contracts/Multicall3.js.map +0 -1
- package/lib/src/typechain/contracts/TransferHelper.d.ts +0 -55
- package/lib/src/typechain/contracts/TransferHelper.js +0 -3
- package/lib/src/typechain/contracts/TransferHelper.js.map +0 -1
- package/lib/src/typechain/contracts/common.d.ts +0 -50
- package/lib/src/typechain/contracts/common.js +0 -3
- package/lib/src/typechain/contracts/common.js.map +0 -1
- package/lib/src/typechain/contracts/factories/ERC1155__factory.d.ts +0 -250
- package/lib/src/typechain/contracts/factories/ERC1155__factory.js +0 -332
- package/lib/src/typechain/contracts/factories/ERC1155__factory.js.map +0 -1
- package/lib/src/typechain/contracts/factories/ERC20__factory.d.ts +0 -174
- package/lib/src/typechain/contracts/factories/ERC20__factory.js +0 -240
- package/lib/src/typechain/contracts/factories/ERC20__factory.js.map +0 -1
- package/lib/src/typechain/contracts/factories/ERC721__factory.d.ts +0 -268
- package/lib/src/typechain/contracts/factories/ERC721__factory.js +0 -351
- package/lib/src/typechain/contracts/factories/ERC721__factory.js.map +0 -1
- package/lib/src/typechain/contracts/factories/Multicall3__factory.d.ts +0 -43
- package/lib/src/typechain/contracts/factories/Multicall3__factory.js +0 -68
- package/lib/src/typechain/contracts/factories/Multicall3__factory.js.map +0 -1
- package/lib/src/typechain/contracts/factories/TransferHelper__factory.d.ts +0 -46
- package/lib/src/typechain/contracts/factories/TransferHelper__factory.js +0 -71
- package/lib/src/typechain/contracts/factories/TransferHelper__factory.js.map +0 -1
- package/lib/src/typechain/contracts/factories/index.d.ts +0 -5
- package/lib/src/typechain/contracts/factories/index.js +0 -17
- package/lib/src/typechain/contracts/factories/index.js.map +0 -1
- package/lib/src/typechain/contracts/index.d.ts +0 -11
- package/lib/src/typechain/contracts/index.js +0 -48
- package/lib/src/typechain/contracts/index.js.map +0 -1
- package/lib/src/types.d.ts +0 -387
- package/lib/src/types.js +0 -127
- package/lib/src/types.js.map +0 -1
- package/lib/src/utils/chain.d.ts +0 -60
- package/lib/src/utils/chain.js +0 -248
- package/lib/src/utils/chain.js.map +0 -1
- package/lib/src/utils/converters.d.ts +0 -37
- package/lib/src/utils/converters.js +0 -137
- package/lib/src/utils/converters.js.map +0 -1
- package/lib/src/utils/dateHelper.d.ts +0 -38
- package/lib/src/utils/dateHelper.js +0 -52
- package/lib/src/utils/dateHelper.js.map +0 -1
- package/lib/src/utils/fees.d.ts +0 -13
- package/lib/src/utils/fees.js +0 -29
- package/lib/src/utils/fees.js.map +0 -1
- package/lib/src/utils/index.d.ts +0 -2
- package/lib/src/utils/index.js +0 -19
- package/lib/src/utils/index.js.map +0 -1
- package/lib/src/utils/protocol.d.ts +0 -75
- package/lib/src/utils/protocol.js +0 -161
- package/lib/src/utils/protocol.js.map +0 -1
- package/lib/src/utils/rateLimit.d.ts +0 -34
- package/lib/src/utils/rateLimit.js +0 -97
- package/lib/src/utils/rateLimit.js.map +0 -1
- package/lib/src/utils/stringHelper.d.ts +0 -18
- package/lib/src/utils/stringHelper.js +0 -24
- package/lib/src/utils/stringHelper.js.map +0 -1
- package/lib/src/utils/utils.d.ts +0 -18
- package/lib/src/utils/utils.js +0 -45
- package/lib/src/utils/utils.js.map +0 -1
- package/lib/typechain/contracts/ERC1155.d.ts +0 -236
- package/lib/typechain/contracts/ERC1155.js +0 -3
- package/lib/typechain/contracts/ERC1155.js.map +0 -1
- package/lib/typechain/contracts/ERC20.d.ts +0 -141
- package/lib/typechain/contracts/ERC20.js +0 -3
- package/lib/typechain/contracts/ERC20.js.map +0 -1
- package/lib/typechain/contracts/ERC721.d.ts +0 -213
- package/lib/typechain/contracts/ERC721.js +0 -3
- package/lib/typechain/contracts/ERC721.js.map +0 -1
- package/lib/typechain/contracts/Multicall3.d.ts +0 -57
- package/lib/typechain/contracts/Multicall3.js +0 -3
- package/lib/typechain/contracts/Multicall3.js.map +0 -1
- package/lib/typechain/contracts/TransferHelper.d.ts +0 -55
- package/lib/typechain/contracts/TransferHelper.js +0 -3
- package/lib/typechain/contracts/TransferHelper.js.map +0 -1
- package/lib/typechain/contracts/common.d.ts +0 -50
- package/lib/typechain/contracts/common.js +0 -3
- package/lib/typechain/contracts/common.js.map +0 -1
- package/lib/typechain/contracts/factories/ERC1155__factory.d.ts +0 -250
- package/lib/typechain/contracts/factories/ERC1155__factory.js +0 -332
- package/lib/typechain/contracts/factories/ERC1155__factory.js.map +0 -1
- package/lib/typechain/contracts/factories/ERC20__factory.d.ts +0 -174
- package/lib/typechain/contracts/factories/ERC20__factory.js +0 -240
- package/lib/typechain/contracts/factories/ERC20__factory.js.map +0 -1
- package/lib/typechain/contracts/factories/ERC721__factory.d.ts +0 -268
- package/lib/typechain/contracts/factories/ERC721__factory.js +0 -351
- package/lib/typechain/contracts/factories/ERC721__factory.js.map +0 -1
- package/lib/typechain/contracts/factories/Multicall3__factory.d.ts +0 -43
- package/lib/typechain/contracts/factories/Multicall3__factory.js +0 -68
- package/lib/typechain/contracts/factories/Multicall3__factory.js.map +0 -1
- package/lib/typechain/contracts/factories/TransferHelper__factory.d.ts +0 -46
- package/lib/typechain/contracts/factories/TransferHelper__factory.js +0 -71
- package/lib/typechain/contracts/factories/TransferHelper__factory.js.map +0 -1
- package/lib/typechain/contracts/factories/index.d.ts +0 -5
- package/lib/typechain/contracts/factories/index.js +0 -17
- package/lib/typechain/contracts/factories/index.js.map +0 -1
- package/lib/typechain/contracts/index.d.ts +0 -11
- package/lib/typechain/contracts/index.js +0 -48
- package/lib/typechain/contracts/index.js.map +0 -1
- package/src/typechain/contracts/ERC1155.ts +0 -440
- package/src/typechain/contracts/ERC20.ts +0 -286
- package/src/typechain/contracts/ERC721.ts +0 -412
- package/src/typechain/contracts/Multicall3.ts +0 -117
- package/src/typechain/contracts/TransferHelper.ts +0 -122
- package/src/typechain/contracts/common.ts +0 -131
- package/src/typechain/contracts/factories/ERC1155__factory.ts +0 -331
- package/src/typechain/contracts/factories/ERC20__factory.ts +0 -239
- package/src/typechain/contracts/factories/ERC721__factory.ts +0 -350
- package/src/typechain/contracts/factories/Multicall3__factory.ts +0 -67
- package/src/typechain/contracts/factories/TransferHelper__factory.ts +0 -76
- package/src/typechain/contracts/factories/index.ts +0 -8
- package/src/typechain/contracts/index.ts +0 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensea/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "OpenSea Developers",
|
|
@@ -14,19 +14,28 @@
|
|
|
14
14
|
},
|
|
15
15
|
"type": "commonjs",
|
|
16
16
|
"main": "lib/index.js",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./lib/index.d.ts",
|
|
20
|
+
"default": "./lib/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./viem": {
|
|
23
|
+
"types": "./lib/viem.d.ts",
|
|
24
|
+
"default": "./lib/viem.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
17
27
|
"files": [
|
|
18
28
|
"lib",
|
|
19
29
|
"src"
|
|
20
30
|
],
|
|
21
31
|
"scripts": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"check-types": "tsc --noEmit --project tsconfig.json",
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"check-types": "tsc -p tsconfig.check.json",
|
|
25
34
|
"docs-build": "typedoc",
|
|
26
35
|
"docs-build-md": "typedoc --plugin typedoc-plugin-markdown",
|
|
27
36
|
"format": "biome format --config-path ../.. --write .",
|
|
28
37
|
"format:check": "biome format --config-path ../.. .",
|
|
29
|
-
"lint": "
|
|
38
|
+
"lint": "biome check --config-path ../.. .",
|
|
30
39
|
"lint:fix": "biome check --config-path ../.. --write .",
|
|
31
40
|
"test": "vitest run",
|
|
32
41
|
"test:all": "concurrently \"npm run test\" \"npm run test:integration\"",
|
|
@@ -35,17 +44,25 @@
|
|
|
35
44
|
},
|
|
36
45
|
"types": "lib/index.d.ts",
|
|
37
46
|
"dependencies": {
|
|
38
|
-
"@
|
|
47
|
+
"@noble/hashes": "^2.0.1",
|
|
48
|
+
"@opensea/api-types": "^0.2.0",
|
|
39
49
|
"@opensea/seaport-js": "^4.0.7",
|
|
40
50
|
"ethers": "^6.16.0"
|
|
41
51
|
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"viem": "^2.0.0"
|
|
54
|
+
},
|
|
55
|
+
"peerDependenciesMeta": {
|
|
56
|
+
"viem": {
|
|
57
|
+
"optional": true
|
|
58
|
+
}
|
|
59
|
+
},
|
|
42
60
|
"devDependencies": {
|
|
43
|
-
"@typechain/ethers-v6": "^0.5.1",
|
|
44
61
|
"@types/node": "^25.4.0",
|
|
62
|
+
"viem": "2.23.2",
|
|
45
63
|
"@vitest/coverage-v8": "^3.2.4",
|
|
46
64
|
"concurrently": "^9.2.1",
|
|
47
65
|
"dotenv": "^17.3.1",
|
|
48
|
-
"typechain": "^8.0.0",
|
|
49
66
|
"typedoc": "^0.28.17",
|
|
50
67
|
"typedoc-plugin-markdown": "^4.10.0",
|
|
51
68
|
"typescript": "^6.0.2",
|
package/src/abi/abis.ts
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal ABI definitions for the contract calls the SDK makes.
|
|
3
|
+
* These replace the TypeChain-generated factories from v9.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const ERC20_ABI = [
|
|
7
|
+
{
|
|
8
|
+
name: "balanceOf",
|
|
9
|
+
type: "function",
|
|
10
|
+
stateMutability: "view",
|
|
11
|
+
inputs: [{ name: "account", type: "address" }],
|
|
12
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: "transfer",
|
|
16
|
+
type: "function",
|
|
17
|
+
stateMutability: "nonpayable",
|
|
18
|
+
inputs: [
|
|
19
|
+
{ name: "to", type: "address" },
|
|
20
|
+
{ name: "amount", type: "uint256" },
|
|
21
|
+
],
|
|
22
|
+
outputs: [{ name: "", type: "bool" }],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "allowance",
|
|
26
|
+
type: "function",
|
|
27
|
+
stateMutability: "view",
|
|
28
|
+
inputs: [
|
|
29
|
+
{ name: "owner", type: "address" },
|
|
30
|
+
{ name: "spender", type: "address" },
|
|
31
|
+
],
|
|
32
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "approve",
|
|
36
|
+
type: "function",
|
|
37
|
+
stateMutability: "nonpayable",
|
|
38
|
+
inputs: [
|
|
39
|
+
{ name: "spender", type: "address" },
|
|
40
|
+
{ name: "amount", type: "uint256" },
|
|
41
|
+
],
|
|
42
|
+
outputs: [{ name: "", type: "bool" }],
|
|
43
|
+
},
|
|
44
|
+
] as const
|
|
45
|
+
|
|
46
|
+
export const ERC721_ABI = [
|
|
47
|
+
{
|
|
48
|
+
name: "ownerOf",
|
|
49
|
+
type: "function",
|
|
50
|
+
stateMutability: "view",
|
|
51
|
+
inputs: [{ name: "tokenId", type: "uint256" }],
|
|
52
|
+
outputs: [{ name: "", type: "address" }],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "transferFrom",
|
|
56
|
+
type: "function",
|
|
57
|
+
stateMutability: "nonpayable",
|
|
58
|
+
inputs: [
|
|
59
|
+
{ name: "from", type: "address" },
|
|
60
|
+
{ name: "to", type: "address" },
|
|
61
|
+
{ name: "tokenId", type: "uint256" },
|
|
62
|
+
],
|
|
63
|
+
outputs: [],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "isApprovedForAll",
|
|
67
|
+
type: "function",
|
|
68
|
+
stateMutability: "view",
|
|
69
|
+
inputs: [
|
|
70
|
+
{ name: "owner", type: "address" },
|
|
71
|
+
{ name: "operator", type: "address" },
|
|
72
|
+
],
|
|
73
|
+
outputs: [{ name: "", type: "bool" }],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "getApproved",
|
|
77
|
+
type: "function",
|
|
78
|
+
stateMutability: "view",
|
|
79
|
+
inputs: [{ name: "tokenId", type: "uint256" }],
|
|
80
|
+
outputs: [{ name: "", type: "address" }],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "setApprovalForAll",
|
|
84
|
+
type: "function",
|
|
85
|
+
stateMutability: "nonpayable",
|
|
86
|
+
inputs: [
|
|
87
|
+
{ name: "operator", type: "address" },
|
|
88
|
+
{ name: "approved", type: "bool" },
|
|
89
|
+
],
|
|
90
|
+
outputs: [],
|
|
91
|
+
},
|
|
92
|
+
] as const
|
|
93
|
+
|
|
94
|
+
export const ERC1155_ABI = [
|
|
95
|
+
{
|
|
96
|
+
name: "balanceOf",
|
|
97
|
+
type: "function",
|
|
98
|
+
stateMutability: "view",
|
|
99
|
+
inputs: [
|
|
100
|
+
{ name: "account", type: "address" },
|
|
101
|
+
{ name: "id", type: "uint256" },
|
|
102
|
+
],
|
|
103
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "safeTransferFrom",
|
|
107
|
+
type: "function",
|
|
108
|
+
stateMutability: "nonpayable",
|
|
109
|
+
inputs: [
|
|
110
|
+
{ name: "from", type: "address" },
|
|
111
|
+
{ name: "to", type: "address" },
|
|
112
|
+
{ name: "id", type: "uint256" },
|
|
113
|
+
{ name: "amount", type: "uint256" },
|
|
114
|
+
{ name: "data", type: "bytes" },
|
|
115
|
+
],
|
|
116
|
+
outputs: [],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "isApprovedForAll",
|
|
120
|
+
type: "function",
|
|
121
|
+
stateMutability: "view",
|
|
122
|
+
inputs: [
|
|
123
|
+
{ name: "owner", type: "address" },
|
|
124
|
+
{ name: "operator", type: "address" },
|
|
125
|
+
],
|
|
126
|
+
outputs: [{ name: "", type: "bool" }],
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "setApprovalForAll",
|
|
130
|
+
type: "function",
|
|
131
|
+
stateMutability: "nonpayable",
|
|
132
|
+
inputs: [
|
|
133
|
+
{ name: "operator", type: "address" },
|
|
134
|
+
{ name: "approved", type: "bool" },
|
|
135
|
+
],
|
|
136
|
+
outputs: [],
|
|
137
|
+
},
|
|
138
|
+
] as const
|
|
139
|
+
|
|
140
|
+
export const WETH_DEPOSIT_ABI = [
|
|
141
|
+
{
|
|
142
|
+
name: "deposit",
|
|
143
|
+
type: "function",
|
|
144
|
+
stateMutability: "payable",
|
|
145
|
+
inputs: [],
|
|
146
|
+
outputs: [],
|
|
147
|
+
},
|
|
148
|
+
] as const
|
|
149
|
+
|
|
150
|
+
export const WETH_WITHDRAW_ABI = [
|
|
151
|
+
{
|
|
152
|
+
name: "withdraw",
|
|
153
|
+
type: "function",
|
|
154
|
+
stateMutability: "nonpayable",
|
|
155
|
+
inputs: [{ name: "wad", type: "uint256" }],
|
|
156
|
+
outputs: [],
|
|
157
|
+
},
|
|
158
|
+
] as const
|
|
159
|
+
|
|
160
|
+
export const TRANSFER_HELPER_ABI = [
|
|
161
|
+
{
|
|
162
|
+
name: "bulkTransfer",
|
|
163
|
+
type: "function",
|
|
164
|
+
stateMutability: "nonpayable",
|
|
165
|
+
inputs: [
|
|
166
|
+
{
|
|
167
|
+
name: "items",
|
|
168
|
+
type: "tuple[]",
|
|
169
|
+
components: [
|
|
170
|
+
{ name: "itemType", type: "uint8" },
|
|
171
|
+
{ name: "token", type: "address" },
|
|
172
|
+
{ name: "identifier", type: "uint256" },
|
|
173
|
+
{ name: "amount", type: "uint256" },
|
|
174
|
+
{ name: "recipient", type: "address" },
|
|
175
|
+
],
|
|
176
|
+
},
|
|
177
|
+
{ name: "conduitKey", type: "bytes32" },
|
|
178
|
+
],
|
|
179
|
+
outputs: [{ name: "", type: "bytes4" }],
|
|
180
|
+
},
|
|
181
|
+
] as const
|
|
182
|
+
|
|
183
|
+
export const MULTICALL3_ABI = [
|
|
184
|
+
{
|
|
185
|
+
name: "aggregate3",
|
|
186
|
+
type: "function",
|
|
187
|
+
stateMutability: "payable",
|
|
188
|
+
inputs: [
|
|
189
|
+
{
|
|
190
|
+
name: "calls",
|
|
191
|
+
type: "tuple[]",
|
|
192
|
+
components: [
|
|
193
|
+
{ name: "target", type: "address" },
|
|
194
|
+
{ name: "allowFailure", type: "bool" },
|
|
195
|
+
{ name: "callData", type: "bytes" },
|
|
196
|
+
],
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
outputs: [
|
|
200
|
+
{
|
|
201
|
+
name: "returnData",
|
|
202
|
+
type: "tuple[]",
|
|
203
|
+
components: [
|
|
204
|
+
{ name: "success", type: "bool" },
|
|
205
|
+
{ name: "returnData", type: "bytes" },
|
|
206
|
+
],
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
},
|
|
210
|
+
] as const
|
|
211
|
+
|
|
212
|
+
export const SET_APPROVAL_FOR_ALL_ABI = [
|
|
213
|
+
{
|
|
214
|
+
name: "setApprovalForAll",
|
|
215
|
+
type: "function",
|
|
216
|
+
stateMutability: "nonpayable",
|
|
217
|
+
inputs: [
|
|
218
|
+
{ name: "operator", type: "address" },
|
|
219
|
+
{ name: "approved", type: "bool" },
|
|
220
|
+
],
|
|
221
|
+
outputs: [],
|
|
222
|
+
},
|
|
223
|
+
] as const
|
|
224
|
+
|
|
225
|
+
export const APPROVE_ABI = [
|
|
226
|
+
{
|
|
227
|
+
name: "approve",
|
|
228
|
+
type: "function",
|
|
229
|
+
stateMutability: "nonpayable",
|
|
230
|
+
inputs: [
|
|
231
|
+
{ name: "spender", type: "address" },
|
|
232
|
+
{ name: "amount", type: "uint256" },
|
|
233
|
+
],
|
|
234
|
+
outputs: [{ name: "", type: "bool" }],
|
|
235
|
+
},
|
|
236
|
+
] as const
|
package/src/api/api.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ethers } from "ethers"
|
|
2
1
|
import { API_BASE_MAINNET } from "../constants"
|
|
3
2
|
import type {
|
|
4
3
|
FulfillmentDataResponse,
|
|
@@ -999,7 +998,9 @@ export class OpenSeaAPI {
|
|
|
999
998
|
* Fetch from an API Endpoint, sending auth token in headers
|
|
1000
999
|
* @param url The URL to fetch
|
|
1001
1000
|
* @param headers Additional headers to send with the request
|
|
1002
|
-
* @param body Optional body to send.
|
|
1001
|
+
* @param body Optional body to send. HTTP method is inferred: POST if body is
|
|
1002
|
+
* provided (non-nullish), GET otherwise. This covers all OpenSea API
|
|
1003
|
+
* endpoints which only use GET and POST.
|
|
1003
1004
|
* @param options Request options like timeout and abort signal
|
|
1004
1005
|
*/
|
|
1005
1006
|
private async _fetch(
|
|
@@ -1008,61 +1009,64 @@ export class OpenSeaAPI {
|
|
|
1008
1009
|
body?: object,
|
|
1009
1010
|
options?: RequestOptions,
|
|
1010
1011
|
) {
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
// Set the headers
|
|
1015
|
-
headers = {
|
|
1012
|
+
const mergedHeaders: Record<string, string> = {
|
|
1013
|
+
// Kept as "opensea-js" for server-side analytics continuity after package rename
|
|
1016
1014
|
"x-app-id": "opensea-js",
|
|
1017
1015
|
...(this.apiKey ? { "X-API-KEY": this.apiKey } : {}),
|
|
1016
|
+
...(body != null ? { "Content-Type": "application/json" } : {}),
|
|
1018
1017
|
...headers,
|
|
1019
1018
|
}
|
|
1020
|
-
for (const [key, value] of Object.entries(headers)) {
|
|
1021
|
-
req.setHeader(key, value)
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
// Set the body if provided
|
|
1025
|
-
if (body) {
|
|
1026
|
-
req.body = body
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
// Apply request options
|
|
1030
|
-
if (options?.timeout !== undefined) {
|
|
1031
|
-
req.timeout = options.timeout
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
// Set up abort signal handling
|
|
1035
|
-
let abortHandler: (() => void) | undefined
|
|
1036
|
-
if (options?.signal) {
|
|
1037
|
-
if (options.signal.aborted) {
|
|
1038
|
-
throw new Error("Request aborted")
|
|
1039
|
-
}
|
|
1040
|
-
abortHandler = () => req.cancel()
|
|
1041
|
-
options.signal.addEventListener("abort", abortHandler)
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
// Set the throttle params
|
|
1045
|
-
req.setThrottleParams({ slotInterval: 1000 })
|
|
1046
1019
|
|
|
1047
|
-
const sanitizedHeaders = { ...
|
|
1020
|
+
const sanitizedHeaders = { ...mergedHeaders }
|
|
1048
1021
|
delete sanitizedHeaders["X-API-KEY"]
|
|
1049
1022
|
this.logger(
|
|
1050
1023
|
`Sending request: ${url} ${JSON.stringify({
|
|
1051
|
-
method: body ? "POST" : "GET",
|
|
1024
|
+
method: body != null ? "POST" : "GET",
|
|
1052
1025
|
headers: sanitizedHeaders,
|
|
1053
|
-
body: body ? JSON.stringify(body, null, 2) : undefined,
|
|
1026
|
+
body: body != null ? JSON.stringify(body, null, 2) : undefined,
|
|
1054
1027
|
})}`,
|
|
1055
1028
|
)
|
|
1056
1029
|
|
|
1030
|
+
// Build abort signal (merge timeout + user-provided signal)
|
|
1031
|
+
let controller: AbortController | undefined
|
|
1032
|
+
let timeoutId: ReturnType<typeof setTimeout> | undefined
|
|
1033
|
+
let userAbortHandler: (() => void) | undefined
|
|
1034
|
+
let signal = options?.signal
|
|
1035
|
+
if (options?.timeout !== undefined) {
|
|
1036
|
+
controller = new AbortController()
|
|
1037
|
+
timeoutId = setTimeout(() => controller!.abort(), options.timeout)
|
|
1038
|
+
// If user provided their own signal, abort ours if theirs fires
|
|
1039
|
+
if (options.signal) {
|
|
1040
|
+
if (options.signal.aborted) {
|
|
1041
|
+
clearTimeout(timeoutId)
|
|
1042
|
+
throw new Error("Request aborted")
|
|
1043
|
+
}
|
|
1044
|
+
userAbortHandler = () => {
|
|
1045
|
+
controller!.abort()
|
|
1046
|
+
clearTimeout(timeoutId)
|
|
1047
|
+
}
|
|
1048
|
+
options.signal.addEventListener("abort", userAbortHandler)
|
|
1049
|
+
}
|
|
1050
|
+
signal = controller.signal
|
|
1051
|
+
} else if (options?.signal?.aborted) {
|
|
1052
|
+
throw new Error("Request aborted")
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1057
1055
|
try {
|
|
1058
|
-
const response = await
|
|
1059
|
-
|
|
1056
|
+
const response = await fetch(url, {
|
|
1057
|
+
method: body != null ? "POST" : "GET",
|
|
1058
|
+
headers: mergedHeaders,
|
|
1059
|
+
body: body != null ? JSON.stringify(body) : undefined,
|
|
1060
|
+
signal,
|
|
1061
|
+
})
|
|
1062
|
+
|
|
1063
|
+
if (!response.ok) {
|
|
1060
1064
|
// Handle rate limit errors (429 Too Many Requests and 599 custom rate limit)
|
|
1061
|
-
if (response.
|
|
1062
|
-
throw this._createRateLimitError(response)
|
|
1065
|
+
if (response.status === 599 || response.status === 429) {
|
|
1066
|
+
throw await this._createRateLimitError(response)
|
|
1063
1067
|
}
|
|
1064
|
-
|
|
1065
|
-
const errors =
|
|
1068
|
+
const responseBody = await response.json().catch(() => ({}))
|
|
1069
|
+
const errors = responseBody?.errors
|
|
1066
1070
|
if (errors?.length > 0) {
|
|
1067
1071
|
let errorMessage = Array.isArray(errors)
|
|
1068
1072
|
? errors.join(", ")
|
|
@@ -1071,17 +1075,18 @@ export class OpenSeaAPI {
|
|
|
1071
1075
|
errorMessage = JSON.stringify(errors)
|
|
1072
1076
|
}
|
|
1073
1077
|
throw new Error(`Server Error: ${errorMessage}`)
|
|
1074
|
-
} else {
|
|
1075
|
-
// Otherwise, let ethers throw a SERVER_ERROR since it will include
|
|
1076
|
-
// more context about the request and response.
|
|
1077
|
-
response.assertOk()
|
|
1078
1078
|
}
|
|
1079
|
+
throw new Error(
|
|
1080
|
+
`Server Error (${response.status}): ${response.statusText}`,
|
|
1081
|
+
)
|
|
1079
1082
|
}
|
|
1080
|
-
return response.
|
|
1083
|
+
return response.json()
|
|
1081
1084
|
} finally {
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
+
if (timeoutId !== undefined) {
|
|
1086
|
+
clearTimeout(timeoutId)
|
|
1087
|
+
}
|
|
1088
|
+
if (userAbortHandler && options?.signal) {
|
|
1089
|
+
options.signal.removeEventListener("abort", userAbortHandler)
|
|
1085
1090
|
}
|
|
1086
1091
|
}
|
|
1087
1092
|
}
|
|
@@ -1097,9 +1102,8 @@ export class OpenSeaAPI {
|
|
|
1097
1102
|
* @param response The HTTP response object from the API
|
|
1098
1103
|
* @returns The retry-after value in seconds (capped at 5 minutes), or undefined if not present or invalid
|
|
1099
1104
|
*/
|
|
1100
|
-
private _parseRetryAfter(response:
|
|
1101
|
-
const retryAfterHeader =
|
|
1102
|
-
response.headers["retry-after"] || response.headers["Retry-After"]
|
|
1105
|
+
private _parseRetryAfter(response: Response): number | undefined {
|
|
1106
|
+
const retryAfterHeader = response.headers.get("retry-after")
|
|
1103
1107
|
if (retryAfterHeader) {
|
|
1104
1108
|
const trimmed = retryAfterHeader.trim()
|
|
1105
1109
|
|
|
@@ -1132,21 +1136,24 @@ export class OpenSeaAPI {
|
|
|
1132
1136
|
|
|
1133
1137
|
/**
|
|
1134
1138
|
* Creates a rate limit error with status code and retry-after information.
|
|
1139
|
+
* This is async because it attempts to parse the response body. If the body
|
|
1140
|
+
* is malformed JSON, responseBody will be undefined (intentional — the error
|
|
1141
|
+
* itself is more important than the body).
|
|
1135
1142
|
* @param response The HTTP response object from the API
|
|
1136
1143
|
* @returns An enhanced Error object with statusCode, retryAfter and responseBody properties
|
|
1137
1144
|
*/
|
|
1138
|
-
private _createRateLimitError(
|
|
1139
|
-
response:
|
|
1140
|
-
): OpenSeaRateLimitError {
|
|
1145
|
+
private async _createRateLimitError(
|
|
1146
|
+
response: Response,
|
|
1147
|
+
): Promise<OpenSeaRateLimitError> {
|
|
1141
1148
|
const retryAfter = this._parseRetryAfter(response)
|
|
1142
1149
|
const error = new Error(
|
|
1143
|
-
`${response.
|
|
1150
|
+
`${response.status} ${response.statusText}`,
|
|
1144
1151
|
) as OpenSeaRateLimitError
|
|
1145
1152
|
|
|
1146
1153
|
// Add status code and retry-after information to the error object
|
|
1147
|
-
error.statusCode = response.
|
|
1154
|
+
error.statusCode = response.status
|
|
1148
1155
|
error.retryAfter = retryAfter
|
|
1149
|
-
error.responseBody = response.
|
|
1156
|
+
error.responseBody = await response.json().catch(() => undefined)
|
|
1150
1157
|
return error
|
|
1151
1158
|
}
|
|
1152
1159
|
}
|
package/src/api/orders.ts
CHANGED
|
@@ -207,8 +207,8 @@ export class OrdersAPI {
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
// Validate side value
|
|
210
|
-
if (side !== "
|
|
211
|
-
throw new Error("side must be either '
|
|
210
|
+
if (side !== "listing" && side !== "offer") {
|
|
211
|
+
throw new Error("side must be either 'listing' or 'offer'")
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
// Validate protocolAddress format
|
package/src/constants.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { FixedNumber } from "ethers"
|
|
2
|
-
|
|
3
1
|
// =============================================================================
|
|
4
2
|
// Math & Calculation Constants
|
|
5
3
|
// =============================================================================
|
|
6
4
|
|
|
7
|
-
export const FIXED_NUMBER_100 = FixedNumber.fromValue(100)
|
|
8
5
|
export const INVERSE_BASIS_POINT = 10_000n // 100 basis points per 1%
|
|
9
6
|
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// Ethereum Constants
|
|
9
|
+
// =============================================================================
|
|
10
|
+
|
|
11
|
+
export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"
|
|
12
|
+
export const MAX_UINT256 = 2n ** 256n - 1n
|
|
13
|
+
|
|
10
14
|
// =============================================================================
|
|
11
15
|
// API Configuration
|
|
12
16
|
// =============================================================================
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { OpenSeaSDK } from "./sdk"
|
|
2
2
|
|
|
3
3
|
export * from "./api/types"
|
|
4
|
+
export * from "./constants"
|
|
4
5
|
export * from "./orders/types"
|
|
6
|
+
export type {
|
|
7
|
+
ContractCaller,
|
|
8
|
+
OpenSeaProvider,
|
|
9
|
+
OpenSeaSigner,
|
|
10
|
+
OpenSeaWallet,
|
|
11
|
+
TransactionResponse,
|
|
12
|
+
} from "./provider/types"
|
|
5
13
|
export * from "./types"
|
|
6
14
|
export * from "./utils"
|
|
7
15
|
/**
|
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
} from "@opensea/seaport-js/lib/types"
|
|
9
9
|
import { isCurrencyItem } from "@opensea/seaport-js/lib/utils/item"
|
|
10
10
|
import { generateRandomSalt } from "@opensea/seaport-js/lib/utils/order"
|
|
11
|
-
import {
|
|
11
|
+
import { ZERO_ADDRESS } from "../constants"
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Compute the native currency (ETH) value required to fulfill a private listing.
|
|
@@ -25,7 +25,7 @@ export const computePrivateListingValue = (
|
|
|
25
25
|
.filter(
|
|
26
26
|
item =>
|
|
27
27
|
item.recipient.toLowerCase() !== takerAddress.toLowerCase() &&
|
|
28
|
-
item.token.toLowerCase() ===
|
|
28
|
+
item.token.toLowerCase() === ZERO_ADDRESS.toLowerCase() &&
|
|
29
29
|
item.itemType === ItemType.NATIVE,
|
|
30
30
|
)
|
|
31
31
|
.reduce((sum, item) => sum + BigInt(item.startAmount), 0n)
|
package/src/orders/utils.ts
CHANGED
|
@@ -222,6 +222,13 @@ export const serializeOrdersQueryOptions = (
|
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
+
/** Map API side values ("ask"/"bid") to SDK OrderSide enum values */
|
|
226
|
+
const mapApiSide = (side: string): OrderSide => {
|
|
227
|
+
if (side === "ask" || side === OrderSide.LISTING) return OrderSide.LISTING
|
|
228
|
+
if (side === "bid" || side === OrderSide.OFFER) return OrderSide.OFFER
|
|
229
|
+
return side as OrderSide
|
|
230
|
+
}
|
|
231
|
+
|
|
225
232
|
export const deserializeOrder = (order: SerializedOrderV2): OrderV2 => {
|
|
226
233
|
return {
|
|
227
234
|
createdDate: order.created_date,
|
|
@@ -242,7 +249,7 @@ export const deserializeOrder = (order: SerializedOrderV2): OrderV2 => {
|
|
|
242
249
|
account: accountFromJSON(account),
|
|
243
250
|
basisPoints: basis_points,
|
|
244
251
|
})),
|
|
245
|
-
side: order.side,
|
|
252
|
+
side: mapApiSide(order.side as string),
|
|
246
253
|
orderType: order.order_type,
|
|
247
254
|
cancelled: order.cancelled,
|
|
248
255
|
finalized: order.finalized,
|