@opensea/sdk 11.9.0 → 12.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/README.md +5 -2
- package/lib/api/types.d.ts +20 -64
- package/lib/api/types.js.map +1 -1
- package/lib/api/walletAuth.d.ts +95 -8
- package/lib/api/walletAuth.js +75 -6
- package/lib/api/walletAuth.js.map +1 -1
- package/lib/orders/attribution.d.ts +18 -0
- package/lib/orders/attribution.js +29 -0
- package/lib/orders/attribution.js.map +1 -0
- package/lib/orders/erc20Fulfillment.js +67 -4
- package/lib/orders/erc20Fulfillment.js.map +1 -1
- package/lib/orders/types.d.ts +16 -28
- package/lib/orders/types.js.map +1 -1
- package/lib/provider/seaport-bridge.js +2 -2
- package/lib/provider/seaport-bridge.js.map +1 -1
- package/lib/provider/viem-adapter.js +3 -3
- package/lib/provider/viem-adapter.js.map +1 -1
- package/lib/scopes.d.ts +1 -0
- package/lib/scopes.js +1 -0
- package/lib/scopes.js.map +1 -1
- package/lib/sdk/assets.js +8 -0
- package/lib/sdk/assets.js.map +1 -1
- package/lib/sdk/cancellation.js +6 -1
- package/lib/sdk/cancellation.js.map +1 -1
- package/lib/sdk/fulfillment.js +7 -3
- package/lib/sdk/fulfillment.js.map +1 -1
- package/lib/stream/client.d.ts +14 -1
- package/lib/stream/client.js +39 -22
- package/lib/stream/client.js.map +1 -1
- package/lib/stream/types.d.ts +32 -63
- package/lib/stream/types.js +7 -0
- package/lib/stream/types.js.map +1 -1
- package/lib/utils/eip712.d.ts +21 -0
- package/lib/utils/eip712.js +54 -0
- package/lib/utils/eip712.js.map +1 -0
- package/package.json +2 -2
- package/src/api/types.ts +27 -64
- package/src/api/walletAuth.ts +100 -13
- package/src/orders/attribution.ts +29 -0
- package/src/orders/erc20Fulfillment.ts +74 -4
- package/src/orders/types.ts +21 -44
- package/src/provider/seaport-bridge.ts +2 -3
- package/src/provider/viem-adapter.ts +3 -4
- package/src/scopes.ts +1 -0
- package/src/sdk/assets.ts +9 -0
- package/src/sdk/cancellation.ts +6 -1
- package/src/sdk/fulfillment.ts +8 -3
- package/src/stream/client.ts +45 -23
- package/src/stream/types.ts +39 -64
- package/src/utils/eip712.ts +57 -0
package/lib/stream/types.d.ts
CHANGED
|
@@ -61,6 +61,13 @@ export declare enum EventType {
|
|
|
61
61
|
ITEM_LISTED = "item_listed",
|
|
62
62
|
ITEM_SOLD = "item_sold",
|
|
63
63
|
ITEM_TRANSFERRED = "item_transferred",
|
|
64
|
+
/**
|
|
65
|
+
* Never emitted by the Stream API. Item-level offers arrive as
|
|
66
|
+
* {@link EventType.ITEM_RECEIVED_BID}. Kept so existing references compile.
|
|
67
|
+
*
|
|
68
|
+
* @deprecated Use {@link EventType.ITEM_RECEIVED_BID}.
|
|
69
|
+
* @hidden
|
|
70
|
+
*/
|
|
64
71
|
ITEM_RECEIVED_OFFER = "item_received_offer",
|
|
65
72
|
ITEM_RECEIVED_BID = "item_received_bid",
|
|
66
73
|
ITEM_CANCELLED = "item_cancelled",
|
|
@@ -133,36 +140,34 @@ export type AssetContractCriteria = {
|
|
|
133
140
|
export type CollectionIdentifier = {
|
|
134
141
|
slug: string;
|
|
135
142
|
};
|
|
136
|
-
|
|
143
|
+
interface BaseOrderEventPayload extends Payload {
|
|
137
144
|
quantity: number;
|
|
138
|
-
listing_type: string;
|
|
139
|
-
listing_date: string;
|
|
140
|
-
expiration_date: string;
|
|
141
145
|
maker: Account;
|
|
142
146
|
taker: Account;
|
|
143
|
-
base_price: string;
|
|
144
|
-
payment_token: PaymentToken;
|
|
145
|
-
is_private: boolean;
|
|
146
147
|
order_hash: string;
|
|
148
|
+
payment_token: PaymentToken;
|
|
147
149
|
event_timestamp: string;
|
|
148
150
|
}
|
|
151
|
+
interface BasePricedOrderEventPayload extends BaseOrderEventPayload {
|
|
152
|
+
base_price: string;
|
|
153
|
+
expiration_date: string;
|
|
154
|
+
}
|
|
155
|
+
export interface ItemListedEventPayload extends BasePricedOrderEventPayload {
|
|
156
|
+
listing_type: string;
|
|
157
|
+
listing_date: string;
|
|
158
|
+
is_private: boolean;
|
|
159
|
+
}
|
|
149
160
|
export type ItemListedEvent = BaseStreamMessage<ItemListedEventPayload>;
|
|
150
161
|
export type Transaction = {
|
|
151
162
|
hash: string;
|
|
152
163
|
timestamp: string;
|
|
153
164
|
};
|
|
154
|
-
export interface ItemSoldEventPayload extends
|
|
155
|
-
quantity: number;
|
|
165
|
+
export interface ItemSoldEventPayload extends BaseOrderEventPayload {
|
|
156
166
|
listing_type: string;
|
|
157
167
|
closing_date: string;
|
|
158
168
|
transaction: Transaction;
|
|
159
|
-
maker: Account;
|
|
160
|
-
taker: Account;
|
|
161
|
-
order_hash: string;
|
|
162
169
|
sale_price: string;
|
|
163
|
-
payment_token: PaymentToken;
|
|
164
170
|
is_private: boolean;
|
|
165
|
-
event_timestamp: string;
|
|
166
171
|
}
|
|
167
172
|
export type ItemSoldEvent = BaseStreamMessage<ItemSoldEventPayload>;
|
|
168
173
|
export interface ItemTransferredEventPayload extends Payload {
|
|
@@ -173,77 +178,41 @@ export interface ItemTransferredEventPayload extends Payload {
|
|
|
173
178
|
event_timestamp: string;
|
|
174
179
|
}
|
|
175
180
|
export type ItemTransferredEvent = BaseStreamMessage<ItemTransferredEventPayload>;
|
|
176
|
-
export interface ItemReceivedBidEventPayload extends
|
|
177
|
-
quantity: number;
|
|
181
|
+
export interface ItemReceivedBidEventPayload extends BasePricedOrderEventPayload {
|
|
178
182
|
created_date: string;
|
|
179
|
-
expiration_date: string;
|
|
180
|
-
maker: Account;
|
|
181
|
-
taker: Account;
|
|
182
|
-
order_hash: string;
|
|
183
|
-
base_price: string;
|
|
184
|
-
payment_token: PaymentToken;
|
|
185
|
-
event_timestamp: string;
|
|
186
183
|
}
|
|
187
184
|
export type ItemReceivedBidEvent = BaseStreamMessage<ItemReceivedBidEventPayload>;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
taker: Account;
|
|
194
|
-
order_hash: string;
|
|
195
|
-
base_price: string;
|
|
196
|
-
payment_token: PaymentToken;
|
|
197
|
-
event_timestamp: string;
|
|
185
|
+
/**
|
|
186
|
+
* @deprecated Never emitted. Use {@link ItemReceivedBidEventPayload}.
|
|
187
|
+
* @hidden
|
|
188
|
+
*/
|
|
189
|
+
export interface ItemReceivedOfferEventPayload extends ItemReceivedBidEventPayload {
|
|
198
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* @deprecated Never emitted. Use {@link ItemReceivedBidEvent}.
|
|
193
|
+
* @hidden
|
|
194
|
+
*/
|
|
199
195
|
export type ItemReceivedOfferEvent = BaseStreamMessage<ItemReceivedOfferEventPayload>;
|
|
200
|
-
export interface ItemCancelledEventPayload extends
|
|
201
|
-
quantity: number;
|
|
202
|
-
base_price: string;
|
|
203
|
-
expiration_date: string;
|
|
204
|
-
maker: Account;
|
|
205
|
-
taker: Account;
|
|
196
|
+
export interface ItemCancelledEventPayload extends BasePricedOrderEventPayload {
|
|
206
197
|
listing_type: string;
|
|
207
198
|
listing_date: string;
|
|
208
199
|
transaction: Transaction;
|
|
209
|
-
payment_token: PaymentToken;
|
|
210
|
-
order_hash: string;
|
|
211
200
|
is_private: boolean;
|
|
212
|
-
event_timestamp: string;
|
|
213
201
|
}
|
|
214
202
|
export type ItemCancelledEvent = BaseStreamMessage<ItemCancelledEventPayload>;
|
|
215
|
-
export interface CollectionOfferEventPayload extends
|
|
216
|
-
quantity: number;
|
|
203
|
+
export interface CollectionOfferEventPayload extends BasePricedOrderEventPayload {
|
|
217
204
|
created_date: string;
|
|
218
|
-
expiration_date: string;
|
|
219
|
-
maker: Account;
|
|
220
|
-
taker: Account;
|
|
221
|
-
base_price: string;
|
|
222
|
-
order_hash: string;
|
|
223
|
-
payment_token: PaymentToken;
|
|
224
205
|
collection_criteria: CollectionIdentifier;
|
|
225
206
|
asset_contract_criteria: AssetContractCriteria;
|
|
226
|
-
event_timestamp: string;
|
|
227
207
|
}
|
|
228
208
|
export type CollectionOfferEvent = BaseStreamMessage<CollectionOfferEventPayload>;
|
|
229
209
|
export type TraitCriteria = {
|
|
230
210
|
trait_type: string;
|
|
231
211
|
trait_name: string;
|
|
232
212
|
};
|
|
233
|
-
export interface TraitOfferEventPayload extends
|
|
234
|
-
quantity: number;
|
|
235
|
-
created_date: string;
|
|
236
|
-
expiration_date: string;
|
|
237
|
-
maker: Account;
|
|
238
|
-
taker: Account;
|
|
239
|
-
base_price: string;
|
|
240
|
-
order_hash: string;
|
|
241
|
-
payment_token: PaymentToken;
|
|
242
|
-
collection_criteria: CollectionIdentifier;
|
|
243
|
-
asset_contract_criteria: AssetContractCriteria;
|
|
213
|
+
export interface TraitOfferEventPayload extends CollectionOfferEventPayload {
|
|
244
214
|
trait_criteria?: TraitCriteria;
|
|
245
215
|
trait_criteria_list?: TraitCriteria[];
|
|
246
|
-
event_timestamp: string;
|
|
247
216
|
}
|
|
248
217
|
export type TraitOfferEvent = BaseStreamMessage<TraitOfferEventPayload>;
|
|
249
218
|
export interface OrderValidationEventPayload {
|
package/lib/stream/types.js
CHANGED
|
@@ -11,6 +11,13 @@ var EventType;
|
|
|
11
11
|
EventType["ITEM_LISTED"] = "item_listed";
|
|
12
12
|
EventType["ITEM_SOLD"] = "item_sold";
|
|
13
13
|
EventType["ITEM_TRANSFERRED"] = "item_transferred";
|
|
14
|
+
/**
|
|
15
|
+
* Never emitted by the Stream API. Item-level offers arrive as
|
|
16
|
+
* {@link EventType.ITEM_RECEIVED_BID}. Kept so existing references compile.
|
|
17
|
+
*
|
|
18
|
+
* @deprecated Use {@link EventType.ITEM_RECEIVED_BID}.
|
|
19
|
+
* @hidden
|
|
20
|
+
*/
|
|
14
21
|
EventType["ITEM_RECEIVED_OFFER"] = "item_received_offer";
|
|
15
22
|
EventType["ITEM_RECEIVED_BID"] = "item_received_bid";
|
|
16
23
|
EventType["ITEM_CANCELLED"] = "item_cancelled";
|
package/lib/stream/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/stream/types.ts"],"names":[],"mappings":";;;AA+DA,IAAY,OAEX;AAFD,WAAY,OAAO;IACjB,8BAAmB,CAAA;AACrB,CAAC,EAFW,OAAO,uBAAP,OAAO,QAElB;AAED,IAAY,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/stream/types.ts"],"names":[],"mappings":";;;AA+DA,IAAY,OAEX;AAFD,WAAY,OAAO;IACjB,8BAAmB,CAAA;AACrB,CAAC,EAFW,OAAO,uBAAP,OAAO,QAElB;AAED,IAAY,SAmBX;AAnBD,WAAY,SAAS;IACnB,4DAA+C,CAAA;IAC/C,wCAA2B,CAAA;IAC3B,oCAAuB,CAAA;IACvB,kDAAqC,CAAA;IACrC;;;;;;OAMG;IACH,wDAA2C,CAAA;IAC3C,oDAAuC,CAAA;IACvC,8CAAiC,CAAA;IACjC,kDAAqC,CAAA;IACrC,wCAA2B,CAAA;IAC3B,kDAAqC,CAAA;IACrC,kDAAqC,CAAA;AACvC,CAAC,EAnBW,SAAS,yBAAT,SAAS,QAmBpB;AAqMD,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,0CAAU,CAAA;IACV,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,0CAAU,CAAA;AACZ,CAAC,EALW,QAAQ,wBAAR,QAAQ,QAKnB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kept in step with `inferPrimaryType` in @opensea/wallet-adapters
|
|
3
|
+
* (`src/bridges/ethers.ts`). The two are deliberately separate copies: the sdk
|
|
4
|
+
* does not depend on wallet-adapters, and adding that edge would couple the
|
|
5
|
+
* sdk's release to it for one pure function. Change both together.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Infer the EIP-712 primary type: the struct that no other struct references,
|
|
9
|
+
* which is the root of the type graph.
|
|
10
|
+
*
|
|
11
|
+
* Taking the first key in `types` instead is wrong whenever a dependency is
|
|
12
|
+
* declared before the root, and it fails silently by signing the wrong struct.
|
|
13
|
+
* ethers resolves this the same way.
|
|
14
|
+
*
|
|
15
|
+
* Refuses rather than guessing when the graph is circular or has more than one
|
|
16
|
+
* root. Both are invalid EIP-712 and ethers rejects them itself ("circular type
|
|
17
|
+
* reference", "ambiguous primary types or unused types"), so throwing costs
|
|
18
|
+
* nothing where the signer validates and prevents a wrong signature where it
|
|
19
|
+
* does not.
|
|
20
|
+
*/
|
|
21
|
+
export declare function inferPrimaryType(types: Record<string, unknown>): string;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inferPrimaryType = inferPrimaryType;
|
|
4
|
+
/**
|
|
5
|
+
* Kept in step with `inferPrimaryType` in @opensea/wallet-adapters
|
|
6
|
+
* (`src/bridges/ethers.ts`). The two are deliberately separate copies: the sdk
|
|
7
|
+
* does not depend on wallet-adapters, and adding that edge would couple the
|
|
8
|
+
* sdk's release to it for one pure function. Change both together.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Infer the EIP-712 primary type: the struct that no other struct references,
|
|
12
|
+
* which is the root of the type graph.
|
|
13
|
+
*
|
|
14
|
+
* Taking the first key in `types` instead is wrong whenever a dependency is
|
|
15
|
+
* declared before the root, and it fails silently by signing the wrong struct.
|
|
16
|
+
* ethers resolves this the same way.
|
|
17
|
+
*
|
|
18
|
+
* Refuses rather than guessing when the graph is circular or has more than one
|
|
19
|
+
* root. Both are invalid EIP-712 and ethers rejects them itself ("circular type
|
|
20
|
+
* reference", "ambiguous primary types or unused types"), so throwing costs
|
|
21
|
+
* nothing where the signer validates and prevents a wrong signature where it
|
|
22
|
+
* does not.
|
|
23
|
+
*/
|
|
24
|
+
function inferPrimaryType(types) {
|
|
25
|
+
const named = Object.keys(types).filter(t => t !== "EIP712Domain");
|
|
26
|
+
if (named.length === 0) {
|
|
27
|
+
return "";
|
|
28
|
+
}
|
|
29
|
+
const referenced = new Set();
|
|
30
|
+
for (const name of named) {
|
|
31
|
+
const fields = types[name];
|
|
32
|
+
if (!Array.isArray(fields))
|
|
33
|
+
continue;
|
|
34
|
+
for (const field of fields) {
|
|
35
|
+
// Strips trailing array suffixes, including repeated ones: Person[],
|
|
36
|
+
// Person[2] and Mail[2][] all reduce to the struct name. EIP-712 field
|
|
37
|
+
// types are an atomic type, an array of those, or a struct name, so there
|
|
38
|
+
// is no further nesting to unwrap. Solidity tuple syntax is not part of
|
|
39
|
+
// the format.
|
|
40
|
+
const base = String(field.type).replace(/(\[\d*\])+$/, "");
|
|
41
|
+
if (base in types)
|
|
42
|
+
referenced.add(base);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const roots = named.filter(t => !referenced.has(t));
|
|
46
|
+
if (roots.length === 0) {
|
|
47
|
+
throw new Error(`Cannot infer EIP-712 primaryType: every type is referenced by another, so the type graph is circular (${named.join(", ")}). Pass primaryType explicitly.`);
|
|
48
|
+
}
|
|
49
|
+
if (roots.length > 1) {
|
|
50
|
+
throw new Error(`Cannot infer EIP-712 primaryType: ${roots.join(", ")} are all unreferenced, so the root is ambiguous. Pass primaryType explicitly.`);
|
|
51
|
+
}
|
|
52
|
+
return roots[0];
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=eip712.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eip712.js","sourceRoot":"","sources":["../../src/utils/eip712.ts"],"names":[],"mappings":";;AAoBA,4CAoCC;AAxDD;;;;;GAKG;AACH;;;;;;;;;;;;;GAaG;AACH,SAAgB,gBAAgB,CAAC,KAA8B;IAC7D,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,cAAc,CAAC,CAAA;IAClE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,CAAA;IACX,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAA;IACpC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAA;QAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,SAAQ;QACpC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,qEAAqE;YACrE,uEAAuE;YACvE,0EAA0E;YAC1E,wEAAwE;YACxE,cAAc;YACd,MAAM,IAAI,GAAG,MAAM,CAAE,KAA4B,CAAC,IAAI,CAAC,CAAC,OAAO,CAC7D,aAAa,EACb,EAAE,CACH,CAAA;YACD,IAAI,IAAI,IAAI,KAAK;gBAAE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACzC,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACnD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,yGAAyG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,iCAAiC,CAC3J,CAAA;IACH,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,qCAAqC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,+EAA+E,CACrI,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensea/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.1",
|
|
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.8.
|
|
50
|
+
"@opensea/api-types": "^0.8.10",
|
|
51
51
|
"@opensea/seaport-js": "^4.2.0",
|
|
52
52
|
"ethers": "^6.16.0"
|
|
53
53
|
},
|
package/src/api/types.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
AccountResolveResponse,
|
|
2
3
|
AccountSearchResponse as ApiAccountSearchResponse,
|
|
3
4
|
AgentProfileRelationshipsResponse as ApiAgentProfileRelationshipsResponse,
|
|
4
5
|
BuildOfferResponse as ApiBuildOfferResponse,
|
|
5
6
|
CancelResponse as ApiCancelResponse,
|
|
6
7
|
CollectionSearchResponse as ApiCollectionSearchResponse,
|
|
8
|
+
DropMintRequest as ApiDropMintRequest,
|
|
9
|
+
DropMintResponse as ApiDropMintResponse,
|
|
7
10
|
Listing as ApiListing,
|
|
8
11
|
Nft as ApiNft,
|
|
9
12
|
NftSearchResponse as ApiNftSearchResponse,
|
|
@@ -28,8 +31,10 @@ import type {
|
|
|
28
31
|
Trait as ApiTrait,
|
|
29
32
|
TransactionReceiptRequest as ApiTransactionReceiptRequest,
|
|
30
33
|
TransactionReceiptResponse as ApiTransactionReceiptResponse,
|
|
34
|
+
ValidateMetadataResponse as ApiValidateMetadataResponse,
|
|
31
35
|
WalletVisibilityResponse as ApiWalletVisibilityResponse,
|
|
32
36
|
AssetMetadataResponse,
|
|
37
|
+
ChainListResponse,
|
|
33
38
|
ChainResponse,
|
|
34
39
|
ContractResponse,
|
|
35
40
|
DropDetailedResponse,
|
|
@@ -354,11 +359,25 @@ export type SvmTransactionDetailsResponse =
|
|
|
354
359
|
export type WalletVisibilityResponse = Camelize<ApiWalletVisibilityResponse>
|
|
355
360
|
|
|
356
361
|
/**
|
|
357
|
-
* Public agent profile relationships for an account.
|
|
362
|
+
* Public agent profile relationships for an account. Only relationships both
|
|
363
|
+
* accounts confirmed appear here; a pending proposal is visible to the two
|
|
364
|
+
* parties alone, through `listOwnAgentRelationships`.
|
|
365
|
+
*
|
|
366
|
+
* `agentOwner` is the account confirmed to own this one, and is null when
|
|
367
|
+
* there is none. That is ordinary rather than exceptional: an agent nobody
|
|
368
|
+
* declared is a valid agent account. `agents` holds the accounts this one is
|
|
369
|
+
* the confirmed owner of, newest first.
|
|
370
|
+
*
|
|
371
|
+
* The wire response also carries `agent_owner_profile` and
|
|
372
|
+
* `public_agent_wallets`. Both read the retired wallet-level designation, are
|
|
373
|
+
* permanently null and empty, and are removed by AGE-51, so they are omitted
|
|
374
|
+
* here rather than offered as fields a caller might reasonably read.
|
|
358
375
|
* @category API Response Types
|
|
359
376
|
*/
|
|
360
|
-
export type AgentProfileRelationshipsResponse =
|
|
361
|
-
Camelize<ApiAgentProfileRelationshipsResponse
|
|
377
|
+
export type AgentProfileRelationshipsResponse = Omit<
|
|
378
|
+
Camelize<ApiAgentProfileRelationshipsResponse>,
|
|
379
|
+
"agentOwnerProfile" | "publicAgentWallets"
|
|
380
|
+
>
|
|
362
381
|
|
|
363
382
|
/**
|
|
364
383
|
* Request body for fetching a transaction receipt.
|
|
@@ -971,10 +990,7 @@ export type ChainInfo = Camelize<ChainResponse>
|
|
|
971
990
|
* Response from OpenSea API for listing supported chains.
|
|
972
991
|
* @category API Response Types
|
|
973
992
|
*/
|
|
974
|
-
export type GetChainsResponse =
|
|
975
|
-
/** List of supported chains */
|
|
976
|
-
chains: ChainInfo[]
|
|
977
|
-
}
|
|
993
|
+
export type GetChainsResponse = Camelize<ChainListResponse>
|
|
978
994
|
|
|
979
995
|
/**
|
|
980
996
|
* Token balance for a wallet address. Sourced from `@opensea/api-types`
|
|
@@ -1075,27 +1091,13 @@ export interface GetDropsArgs {
|
|
|
1075
1091
|
* Request body for building a drop mint transaction.
|
|
1076
1092
|
* @category API Request Types
|
|
1077
1093
|
*/
|
|
1078
|
-
export type DropMintRequest =
|
|
1079
|
-
/** Wallet address that will receive the minted tokens */
|
|
1080
|
-
minter: string
|
|
1081
|
-
/** Number of tokens to mint (1-100) */
|
|
1082
|
-
quantity: number
|
|
1083
|
-
}
|
|
1094
|
+
export type DropMintRequest = Camelize<ApiDropMintRequest>
|
|
1084
1095
|
|
|
1085
1096
|
/**
|
|
1086
1097
|
* Response from OpenSea API for building a drop mint transaction.
|
|
1087
1098
|
* @category API Response Types
|
|
1088
1099
|
*/
|
|
1089
|
-
export type DropMintResponse =
|
|
1090
|
-
/** Transaction target contract address */
|
|
1091
|
-
to: string
|
|
1092
|
-
/** Encoded transaction data (hex) */
|
|
1093
|
-
data: string
|
|
1094
|
-
/** Transaction value in wei (hex) */
|
|
1095
|
-
value: string
|
|
1096
|
-
/** Chain identifier */
|
|
1097
|
-
chain: string
|
|
1098
|
-
}
|
|
1100
|
+
export type DropMintResponse = Camelize<ApiDropMintResponse>
|
|
1099
1101
|
|
|
1100
1102
|
/**
|
|
1101
1103
|
* Query args for Get Trending Collections endpoint.
|
|
@@ -1143,52 +1145,13 @@ export type GetCollectionsPaginatedResponse = QueryCursorsV2 & {
|
|
|
1143
1145
|
* Response from OpenSea API for resolving an account identifier.
|
|
1144
1146
|
* @category API Response Types
|
|
1145
1147
|
*/
|
|
1146
|
-
export type ResolveAccountResponse =
|
|
1147
|
-
/** The resolved wallet address */
|
|
1148
|
-
address: string
|
|
1149
|
-
/** OpenSea username, if available */
|
|
1150
|
-
username?: string
|
|
1151
|
-
/** Primary ENS name, if available */
|
|
1152
|
-
ensName?: string
|
|
1153
|
-
}
|
|
1148
|
+
export type ResolveAccountResponse = Camelize<AccountResolveResponse>
|
|
1154
1149
|
|
|
1155
1150
|
/**
|
|
1156
1151
|
* Response from OpenSea API for validating NFT metadata.
|
|
1157
1152
|
* @category API Response Types
|
|
1158
1153
|
*/
|
|
1159
|
-
export type ValidateMetadataResponse =
|
|
1160
|
-
/** The asset being validated */
|
|
1161
|
-
assetIdentifier: {
|
|
1162
|
-
chain: string
|
|
1163
|
-
contractAddress: string
|
|
1164
|
-
tokenId: string
|
|
1165
|
-
}
|
|
1166
|
-
/** The token URI */
|
|
1167
|
-
tokenUri?: string
|
|
1168
|
-
/** Parsed metadata details */
|
|
1169
|
-
metadata?: {
|
|
1170
|
-
name?: string
|
|
1171
|
-
description?: string
|
|
1172
|
-
originalImageUrl?: string
|
|
1173
|
-
processedImageUrl?: string
|
|
1174
|
-
originalAnimationUrl?: string
|
|
1175
|
-
processedAnimationUrl?: string
|
|
1176
|
-
externalUrl?: string
|
|
1177
|
-
backgroundColor?: string
|
|
1178
|
-
attributes: {
|
|
1179
|
-
traitType: string
|
|
1180
|
-
value: string
|
|
1181
|
-
displayType?: string
|
|
1182
|
-
}[]
|
|
1183
|
-
}
|
|
1184
|
-
/** Error encountered during metadata ingestion */
|
|
1185
|
-
error?: {
|
|
1186
|
-
errorType: string
|
|
1187
|
-
message: string
|
|
1188
|
-
url?: string
|
|
1189
|
-
statusCode?: number
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1154
|
+
export type ValidateMetadataResponse = Camelize<ApiValidateMetadataResponse>
|
|
1192
1155
|
|
|
1193
1156
|
/**
|
|
1194
1157
|
* Response from OpenSea API for fetching raw NFT metadata.
|
package/src/api/walletAuth.ts
CHANGED
|
@@ -424,19 +424,6 @@ export class WalletAuthAPI {
|
|
|
424
424
|
)
|
|
425
425
|
}
|
|
426
426
|
|
|
427
|
-
markWalletAsAgent(wallet: string) {
|
|
428
|
-
return this.fetcher.request<OperationResponse<"mark_wallet_as_agent">>(
|
|
429
|
-
"PUT",
|
|
430
|
-
`/api/v2/accounts/wallets/${segment(wallet)}/agent`,
|
|
431
|
-
)
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
removeWalletAgentDesignation(wallet: string) {
|
|
435
|
-
return this.fetcher.request<
|
|
436
|
-
OperationResponse<"remove_wallet_agent_designation">
|
|
437
|
-
>("DELETE", `/api/v2/accounts/wallets/${segment(wallet)}/agent`)
|
|
438
|
-
}
|
|
439
|
-
|
|
440
427
|
makeWalletPrivate(wallet: string) {
|
|
441
428
|
return this.fetcher.request<OperationResponse<"make_wallet_private">>(
|
|
442
429
|
"PUT",
|
|
@@ -450,4 +437,104 @@ export class WalletAuthAPI {
|
|
|
450
437
|
`/api/v2/accounts/wallets/${segment(wallet)}/private`,
|
|
451
438
|
)
|
|
452
439
|
}
|
|
440
|
+
|
|
441
|
+
// ── Agent accounts ────────────────────────────────────────────────
|
|
442
|
+
//
|
|
443
|
+
// An agent is an account, not a flag on a wallet, and ownership is a
|
|
444
|
+
// relationship between two accounts that both sides confirm. It is a
|
|
445
|
+
// declaration, not an authorization: naming an account as your agent
|
|
446
|
+
// grants it nothing. It is self-reported and OpenSea does not verify it.
|
|
447
|
+
//
|
|
448
|
+
// The five writes below need `write:wallets`. `listOwnAgentRelationships`
|
|
449
|
+
// needs `read:wallets`. A client driving the whole handshake needs both, or
|
|
450
|
+
// the list call fails with "Insufficient permissions".
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Declare the authenticated account an agent. Requires `write:wallets`.
|
|
454
|
+
*
|
|
455
|
+
* Independent of ownership: an agent nobody owns is valid. `changed` is
|
|
456
|
+
* false when the account was already an agent, so a retry is
|
|
457
|
+
* distinguishable from a real change.
|
|
458
|
+
*/
|
|
459
|
+
declareAgentAccount() {
|
|
460
|
+
return this.fetcher.request<OperationResponse<"declare_agent_account">>(
|
|
461
|
+
"PUT",
|
|
462
|
+
"/api/v2/accounts/agent",
|
|
463
|
+
)
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Withdraw the authenticated account's agent declaration. Requires
|
|
468
|
+
* `write:wallets`.
|
|
469
|
+
*/
|
|
470
|
+
withdrawAgentAccountDeclaration() {
|
|
471
|
+
return this.fetcher.request<
|
|
472
|
+
OperationResponse<"withdraw_agent_account_declaration">
|
|
473
|
+
>("DELETE", "/api/v2/accounts/agent")
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Propose an agent ownership relationship. Requires `write:wallets`.
|
|
478
|
+
*
|
|
479
|
+
* `callerRole` says which side the caller is on: `AGENT` means "I am an
|
|
480
|
+
* agent and the counterparty owns me". The caller's own account is never in
|
|
481
|
+
* the body; it comes from the bearer token.
|
|
482
|
+
*
|
|
483
|
+
* Proposing a relationship that is already awaiting you confirms it, so a
|
|
484
|
+
* client that cannot tell who moved first can just propose.
|
|
485
|
+
*/
|
|
486
|
+
proposeAgentRelationship(
|
|
487
|
+
body: WalletAuthRequest<"propose_agent_relationship">,
|
|
488
|
+
) {
|
|
489
|
+
return this.fetcher.request<
|
|
490
|
+
OperationResponse<"propose_agent_relationship">
|
|
491
|
+
>("POST", "/api/v2/accounts/agent-relationships", body)
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Confirm a relationship proposed to the authenticated account. Requires
|
|
496
|
+
* `write:wallets`. An agent ends up with at most one confirmed owner.
|
|
497
|
+
*/
|
|
498
|
+
confirmAgentRelationship(
|
|
499
|
+
body: WalletAuthRequest<"confirm_agent_relationship">,
|
|
500
|
+
) {
|
|
501
|
+
return this.fetcher.request<
|
|
502
|
+
OperationResponse<"confirm_agent_relationship">
|
|
503
|
+
>("POST", "/api/v2/accounts/agent-relationships/confirm", body)
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Withdraw a proposal or revoke a confirmed relationship. Requires
|
|
508
|
+
* `write:wallets`. Either side may do this at any point, and it deletes the
|
|
509
|
+
* relationship rather than marking it inactive.
|
|
510
|
+
*
|
|
511
|
+
* `removed` is false when no such relationship existed, which covers both a
|
|
512
|
+
* counterparty you never proposed to and someone else's relationship.
|
|
513
|
+
*
|
|
514
|
+
* Sent as query parameters rather than a body on purpose: fetch, OkHttp and
|
|
515
|
+
* urllib all drop DELETE bodies by default, and proxies may strip them.
|
|
516
|
+
*/
|
|
517
|
+
revokeAgentRelationship(query: WalletAuthQuery<"revoke_agent_relationship">) {
|
|
518
|
+
const params = new URLSearchParams({
|
|
519
|
+
counterparty_address: query.counterpartyAddress,
|
|
520
|
+
caller_role: query.callerRole,
|
|
521
|
+
})
|
|
522
|
+
return this.fetcher.request<OperationResponse<"revoke_agent_relationship">>(
|
|
523
|
+
"DELETE",
|
|
524
|
+
`/api/v2/accounts/agent-relationships?${params}`,
|
|
525
|
+
)
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* List the authenticated account's own relationships. Requires
|
|
530
|
+
* `read:wallets`, not `write:wallets`.
|
|
531
|
+
*
|
|
532
|
+
* Includes proposals still awaiting either side. Pending relationships show
|
|
533
|
+
* up here only; a public profile shows confirmed ones alone.
|
|
534
|
+
*/
|
|
535
|
+
listOwnAgentRelationships() {
|
|
536
|
+
return this.fetcher.get<OperationResponse<"list_own_agent_relationships">>(
|
|
537
|
+
"/api/v2/accounts/agent-relationships",
|
|
538
|
+
)
|
|
539
|
+
}
|
|
453
540
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** A 4-byte hex string, the only shape the attribution suffix takes. */
|
|
2
|
+
const CALLDATA_SUFFIX_PATTERN = /^0x[0-9a-f]{8}$/i
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Append the OpenSea attribution suffix to ABI-encoded calldata.
|
|
6
|
+
*
|
|
7
|
+
* The fulfillment endpoints return `calldata_suffix` alongside the transaction
|
|
8
|
+
* they describe: the first four bytes of `keccak256("api.opensea.io")`, which
|
|
9
|
+
* OpenSea's own fills carry as trailing calldata. Seaport reads its arguments
|
|
10
|
+
* from offsets and ignores trailing bytes, so the suffix attributes the fill
|
|
11
|
+
* without affecting execution.
|
|
12
|
+
*
|
|
13
|
+
* This matters because the SDK does not submit the API's calldata. It re-encodes
|
|
14
|
+
* the call from `input_data` and signs that, which drops anything the API had
|
|
15
|
+
* appended, so the suffix has to be re-attached here or the fill lands
|
|
16
|
+
* unattributed.
|
|
17
|
+
*
|
|
18
|
+
* A missing or malformed suffix is ignored rather than raised. Attribution is
|
|
19
|
+
* optional by design and must never be the reason a fill fails.
|
|
20
|
+
*/
|
|
21
|
+
export function appendCalldataSuffix(
|
|
22
|
+
calldata: string,
|
|
23
|
+
suffix: string | undefined,
|
|
24
|
+
): string {
|
|
25
|
+
if (!suffix || !CALLDATA_SUFFIX_PATTERN.test(suffix)) {
|
|
26
|
+
return calldata
|
|
27
|
+
}
|
|
28
|
+
return calldata + suffix.slice(2)
|
|
29
|
+
}
|