b5-api-client 0.0.31 → 0.0.32
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.
|
@@ -37,6 +37,11 @@ declare class P2PMarketplaceAPIClient {
|
|
|
37
37
|
releaseFunds(order: Order, testParams?: TestEventParams, headers?: Record<string, string>): Promise<string>;
|
|
38
38
|
getTransactionStatus(txHash: string, headers?: Record<string, string>): Promise<TransactionStatusResponse>;
|
|
39
39
|
createDispute(request: CreateDisputeRequest, headers?: Record<string, string>): Promise<DisputesResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Cancel/delete an order by its ID
|
|
42
|
+
* Only allowed for orders in PENDING or WAITING_PAYMENT status
|
|
43
|
+
*/
|
|
44
|
+
cancelOrder(orderId: string, headers?: Record<string, string>): Promise<void>;
|
|
40
45
|
/**
|
|
41
46
|
* Save a UserOperation receipt to the database
|
|
42
47
|
* @param request - The SaveOpsLogRequest containing chainId, userOp, and optional orderId/opsType
|
|
@@ -308,6 +308,23 @@ class P2PMarketplaceAPIClient {
|
|
|
308
308
|
return this.post(url, request, headers);
|
|
309
309
|
});
|
|
310
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* Cancel/delete an order by its ID
|
|
313
|
+
* Only allowed for orders in PENDING or WAITING_PAYMENT status
|
|
314
|
+
*/
|
|
315
|
+
cancelOrder(orderId, headers) {
|
|
316
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
317
|
+
const url = `/api/orders/${orderId}`;
|
|
318
|
+
const config = this.createConfig(headers);
|
|
319
|
+
try {
|
|
320
|
+
yield this.client.delete(url, config);
|
|
321
|
+
}
|
|
322
|
+
catch (error) {
|
|
323
|
+
console.error(`DELETE request to ${url} failed:`, error);
|
|
324
|
+
throw error;
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
}
|
|
311
328
|
// OpsLog
|
|
312
329
|
/**
|
|
313
330
|
* Save a UserOperation receipt to the database
|
package/dist/types.d.ts
CHANGED
|
@@ -179,6 +179,34 @@ export interface ReleaseOrderEvent {
|
|
|
179
179
|
adminAction: boolean;
|
|
180
180
|
timestamp: string;
|
|
181
181
|
}
|
|
182
|
+
export interface OrderCanceledEvent {
|
|
183
|
+
type: string;
|
|
184
|
+
orderId: string;
|
|
185
|
+
buyerAddress: string;
|
|
186
|
+
amount?: string;
|
|
187
|
+
transaction?: {
|
|
188
|
+
hash: string;
|
|
189
|
+
} | null;
|
|
190
|
+
tokenContractAddress: string;
|
|
191
|
+
cancelCreatorId: string;
|
|
192
|
+
previousStatus: string;
|
|
193
|
+
timestamp: string;
|
|
194
|
+
blockchain?: string;
|
|
195
|
+
}
|
|
196
|
+
export interface OrderDisputedEvent {
|
|
197
|
+
type: string;
|
|
198
|
+
orderId: string;
|
|
199
|
+
buyerAddress: string;
|
|
200
|
+
amount?: string;
|
|
201
|
+
transaction?: {
|
|
202
|
+
hash: string;
|
|
203
|
+
} | null;
|
|
204
|
+
tokenContractAddress: string;
|
|
205
|
+
disputeCreatorId: string;
|
|
206
|
+
reason: string;
|
|
207
|
+
timestamp: string;
|
|
208
|
+
blockchain?: string;
|
|
209
|
+
}
|
|
182
210
|
export interface OrderEvent {
|
|
183
211
|
orderId: string;
|
|
184
212
|
timestamp: string;
|
package/package.json
CHANGED
|
@@ -291,6 +291,21 @@ class P2PMarketplaceAPIClient {
|
|
|
291
291
|
return this.post<DisputesResponse>(url, request, headers);
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Cancel/delete an order by its ID
|
|
296
|
+
* Only allowed for orders in PENDING or WAITING_PAYMENT status
|
|
297
|
+
*/
|
|
298
|
+
public async cancelOrder(orderId: string, headers?: Record<string, string>): Promise<void> {
|
|
299
|
+
const url = `/api/orders/${orderId}`;
|
|
300
|
+
const config = this.createConfig(headers);
|
|
301
|
+
try {
|
|
302
|
+
await this.client.delete(url, config);
|
|
303
|
+
} catch (error) {
|
|
304
|
+
console.error(`DELETE request to ${url} failed:`, error);
|
|
305
|
+
throw error;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
294
309
|
// OpsLog
|
|
295
310
|
|
|
296
311
|
/**
|
package/src/types.ts
CHANGED
|
@@ -221,6 +221,32 @@ export interface ReleaseOrderEvent {
|
|
|
221
221
|
timestamp: string;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
+
export interface OrderCanceledEvent {
|
|
225
|
+
type: string;
|
|
226
|
+
orderId: string;
|
|
227
|
+
buyerAddress: string;
|
|
228
|
+
amount?: string;
|
|
229
|
+
transaction?: { hash: string } | null;
|
|
230
|
+
tokenContractAddress: string;
|
|
231
|
+
cancelCreatorId: string;
|
|
232
|
+
previousStatus: string;
|
|
233
|
+
timestamp: string;
|
|
234
|
+
blockchain?: string;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export interface OrderDisputedEvent {
|
|
238
|
+
type: string;
|
|
239
|
+
orderId: string;
|
|
240
|
+
buyerAddress: string;
|
|
241
|
+
amount?: string;
|
|
242
|
+
transaction?: { hash: string } | null;
|
|
243
|
+
tokenContractAddress: string;
|
|
244
|
+
disputeCreatorId: string;
|
|
245
|
+
reason: string;
|
|
246
|
+
timestamp: string;
|
|
247
|
+
blockchain?: string;
|
|
248
|
+
}
|
|
249
|
+
|
|
224
250
|
export interface OrderEvent {
|
|
225
251
|
orderId: string;
|
|
226
252
|
timestamp: string;
|