@coin-voyage/shared 2.4.1 → 2.4.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/dist/api/client.d.ts +5 -5
- package/dist/api/client.js +22 -11
- package/dist/currency/currencies.d.ts +1 -1
- package/dist/currency/currencies.js +1 -1
- package/dist/payment/payment-steps.d.ts +8 -8
- package/dist/schemas/pay-order.d.ts +4 -2
- package/dist/schemas/pay-order.js +2 -1
- package/dist/types/api.d.ts +90 -39
- package/dist/types/api.js +0 -8
- package/dist/types/enums.d.ts +3 -1
- package/dist/types/enums.js +2 -0
- package/dist/types/model.d.ts +54 -28
- package/package.json +1 -1
package/dist/api/client.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { ClaimFeesRequest, ClaimFeesResponse, CreateWebhookRequest, GetFeeBalancesResponse, OrderStatusSocket, PaymentDetails, PaymentDetailsParams, PaymentMethodsResponse, PayOrderParams, PayOrderQuoteParams, RouteQuote, SwapDataRequest, SwapDataResponse, SwapQuoteRequest, SwapQuoteResponse, UpdateWebhookRequest, WebhookResponse } from "../types/api";
|
|
2
|
-
import { PayOrderMode } from "../types/enums";
|
|
1
|
+
import type { ClaimFeesRequest, ClaimFeesResponse, CreatePayOrderMode, CreateWebhookRequest, GetFeeBalancesResponse, OrderStatusSocket, PaymentDetails, PaymentDetailsParams, PaymentMethodsResponse, PayOrderParams, PayOrderQuoteParams, RouteQuote, SwapDataRequest, SwapDataResponse, SwapQuoteRequest, SwapQuoteResponse, UpdateWebhookRequest, WebhookResponse } from "../types/api";
|
|
3
2
|
import type { PayOrder } from "../types/model";
|
|
4
3
|
import { type APIEnvironment } from "./config";
|
|
5
4
|
import { type APIResponse } from "./fetcher";
|
|
@@ -18,6 +17,7 @@ export declare class ApiClient {
|
|
|
18
17
|
version?: string;
|
|
19
18
|
});
|
|
20
19
|
private request;
|
|
20
|
+
private withAuthorizationSignature;
|
|
21
21
|
private getErrorMessage;
|
|
22
22
|
private createBadRequestResponse;
|
|
23
23
|
private validatePayOrderParams;
|
|
@@ -152,7 +152,7 @@ export declare class ApiClient {
|
|
|
152
152
|
* }
|
|
153
153
|
*/
|
|
154
154
|
createRefundPayOrder(payOrderId: string, params: PayOrderParams, apiSecret: string, opts?: Opts): Promise<APIResponse<PayOrder>>;
|
|
155
|
-
createPayOrder(params: PayOrderParams, mode:
|
|
155
|
+
createPayOrder(params: PayOrderParams, mode: CreatePayOrderMode, signature?: string, opts?: Opts): Promise<APIResponse<PayOrder>>;
|
|
156
156
|
/**
|
|
157
157
|
* Generates a PayOrder Quote.
|
|
158
158
|
*
|
|
@@ -160,7 +160,7 @@ export declare class ApiClient {
|
|
|
160
160
|
* This function requires an API key for authentication.
|
|
161
161
|
*
|
|
162
162
|
* @param {string} orderId - The unique identifier of the PayOrder for which the quote is requested.
|
|
163
|
-
* @param {PayOrderQuoteParams} quoteParams - Contains `wallet_address`, `chain_type`, `
|
|
163
|
+
* @param {PayOrderQuoteParams} quoteParams - Contains `wallet_address`, `chain_type`, and optional `chain_ids`.
|
|
164
164
|
* @param {Opts} [opts] - Optional parameters for the request.
|
|
165
165
|
* @returns {Promise<APIResponse<RouteQuote[]>>} - An array of PayTokens wrapped in an API response if the request was successful.
|
|
166
166
|
*
|
|
@@ -169,7 +169,7 @@ export declare class ApiClient {
|
|
|
169
169
|
* const quoteParams = {
|
|
170
170
|
* wallet_address: '0x1234...abcd',
|
|
171
171
|
* chain_type: ChainType.EVM,
|
|
172
|
-
*
|
|
172
|
+
* chain_ids: [1, 10, 137]
|
|
173
173
|
* };
|
|
174
174
|
*
|
|
175
175
|
* const response = await payOrderQuote(orderId, quoteParams);
|
package/dist/api/client.js
CHANGED
|
@@ -26,6 +26,17 @@ export class ApiClient {
|
|
|
26
26
|
},
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
+
withAuthorizationSignature(signature, headers) {
|
|
30
|
+
return {
|
|
31
|
+
...(signature
|
|
32
|
+
? {
|
|
33
|
+
Authorization: signature,
|
|
34
|
+
"Authorization-Signature": signature,
|
|
35
|
+
}
|
|
36
|
+
: {}),
|
|
37
|
+
...headers,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
29
40
|
getErrorMessage(error) {
|
|
30
41
|
if (error instanceof Error) {
|
|
31
42
|
return error.message;
|
|
@@ -220,7 +231,7 @@ export class ApiClient {
|
|
|
220
231
|
options: {
|
|
221
232
|
method: "POST",
|
|
222
233
|
body: JSON.stringify({ ...params }),
|
|
223
|
-
headers:
|
|
234
|
+
headers: this.withAuthorizationSignature(signature, opts?.headers),
|
|
224
235
|
},
|
|
225
236
|
});
|
|
226
237
|
}
|
|
@@ -230,7 +241,7 @@ export class ApiClient {
|
|
|
230
241
|
}
|
|
231
242
|
async createPayOrder(params, mode, signature, opts) {
|
|
232
243
|
this.validatePayOrderParams(params);
|
|
233
|
-
if (
|
|
244
|
+
if (mode === PayOrderMode.SALE && !signature) {
|
|
234
245
|
throw new Error(`Signature is required for ${mode} PayOrders`);
|
|
235
246
|
}
|
|
236
247
|
return this.request({
|
|
@@ -238,7 +249,7 @@ export class ApiClient {
|
|
|
238
249
|
options: {
|
|
239
250
|
method: "POST",
|
|
240
251
|
body: JSON.stringify({ mode, ...params }),
|
|
241
|
-
headers:
|
|
252
|
+
headers: this.withAuthorizationSignature(signature, opts?.headers),
|
|
242
253
|
},
|
|
243
254
|
});
|
|
244
255
|
}
|
|
@@ -249,7 +260,7 @@ export class ApiClient {
|
|
|
249
260
|
* This function requires an API key for authentication.
|
|
250
261
|
*
|
|
251
262
|
* @param {string} orderId - The unique identifier of the PayOrder for which the quote is requested.
|
|
252
|
-
* @param {PayOrderQuoteParams} quoteParams - Contains `wallet_address`, `chain_type`, `
|
|
263
|
+
* @param {PayOrderQuoteParams} quoteParams - Contains `wallet_address`, `chain_type`, and optional `chain_ids`.
|
|
253
264
|
* @param {Opts} [opts] - Optional parameters for the request.
|
|
254
265
|
* @returns {Promise<APIResponse<RouteQuote[]>>} - An array of PayTokens wrapped in an API response if the request was successful.
|
|
255
266
|
*
|
|
@@ -258,7 +269,7 @@ export class ApiClient {
|
|
|
258
269
|
* const quoteParams = {
|
|
259
270
|
* wallet_address: '0x1234...abcd',
|
|
260
271
|
* chain_type: ChainType.EVM,
|
|
261
|
-
*
|
|
272
|
+
* chain_ids: [1, 10, 137]
|
|
262
273
|
* };
|
|
263
274
|
*
|
|
264
275
|
* const response = await payOrderQuote(orderId, quoteParams);
|
|
@@ -334,7 +345,7 @@ export class ApiClient {
|
|
|
334
345
|
path: "/fees/balance",
|
|
335
346
|
options: {
|
|
336
347
|
method: "GET",
|
|
337
|
-
headers:
|
|
348
|
+
headers: this.withAuthorizationSignature(signature, opts?.headers),
|
|
338
349
|
},
|
|
339
350
|
});
|
|
340
351
|
}
|
|
@@ -353,7 +364,7 @@ export class ApiClient {
|
|
|
353
364
|
options: {
|
|
354
365
|
method: "POST",
|
|
355
366
|
body: JSON.stringify(params),
|
|
356
|
-
headers:
|
|
367
|
+
headers: this.withAuthorizationSignature(signature, opts?.headers),
|
|
357
368
|
},
|
|
358
369
|
});
|
|
359
370
|
}
|
|
@@ -373,7 +384,7 @@ export class ApiClient {
|
|
|
373
384
|
path: "/webhooks",
|
|
374
385
|
options: {
|
|
375
386
|
method: "GET",
|
|
376
|
-
headers:
|
|
387
|
+
headers: this.withAuthorizationSignature(signature, opts?.headers),
|
|
377
388
|
},
|
|
378
389
|
});
|
|
379
390
|
}
|
|
@@ -392,7 +403,7 @@ export class ApiClient {
|
|
|
392
403
|
options: {
|
|
393
404
|
method: "POST",
|
|
394
405
|
body: JSON.stringify(params),
|
|
395
|
-
headers:
|
|
406
|
+
headers: this.withAuthorizationSignature(signature, opts?.headers),
|
|
396
407
|
},
|
|
397
408
|
});
|
|
398
409
|
}
|
|
@@ -412,7 +423,7 @@ export class ApiClient {
|
|
|
412
423
|
options: {
|
|
413
424
|
method: "PUT",
|
|
414
425
|
body: JSON.stringify(params),
|
|
415
|
-
headers:
|
|
426
|
+
headers: this.withAuthorizationSignature(signature, opts?.headers),
|
|
416
427
|
},
|
|
417
428
|
});
|
|
418
429
|
}
|
|
@@ -430,7 +441,7 @@ export class ApiClient {
|
|
|
430
441
|
path: `/webhooks/${webhookId}`,
|
|
431
442
|
options: {
|
|
432
443
|
method: "DELETE",
|
|
433
|
-
headers:
|
|
444
|
+
headers: this.withAuthorizationSignature(signature, opts?.headers),
|
|
434
445
|
},
|
|
435
446
|
});
|
|
436
447
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { BitcoinPaymentData, CryptoPaymentData, EVMPaymentData, FiatPaymentData,
|
|
2
|
-
export declare function getFiatPaymentStep(payment?:
|
|
3
|
-
export declare function getFiatPaymentData(payment?:
|
|
4
|
-
export declare function getCryptoDepositStep(payment?:
|
|
5
|
-
export declare function getCryptoTransactionStep(payment?:
|
|
6
|
-
export declare function getWalletPaymentStep(payment?:
|
|
7
|
-
export declare function getWalletPaymentData(payment?:
|
|
8
|
-
export declare function getDepositAddress(payment?:
|
|
1
|
+
import type { BitcoinPaymentData, CryptoPaymentData, EVMPaymentData, FiatPaymentData, PaymentDataBase, PaymentStep, SolanaPaymentData, SuiPaymentData } from "../types/model";
|
|
2
|
+
export declare function getFiatPaymentStep(payment?: PaymentDataBase): PaymentStep | undefined;
|
|
3
|
+
export declare function getFiatPaymentData(payment?: PaymentDataBase): FiatPaymentData | undefined;
|
|
4
|
+
export declare function getCryptoDepositStep(payment?: PaymentDataBase): PaymentStep | undefined;
|
|
5
|
+
export declare function getCryptoTransactionStep(payment?: PaymentDataBase): PaymentStep | undefined;
|
|
6
|
+
export declare function getWalletPaymentStep(payment?: PaymentDataBase): PaymentStep | undefined;
|
|
7
|
+
export declare function getWalletPaymentData(payment?: PaymentDataBase): CryptoPaymentData | undefined;
|
|
8
|
+
export declare function getDepositAddress(payment?: PaymentDataBase): string | undefined;
|
|
9
9
|
export declare function getEvmPaymentData(paymentData?: CryptoPaymentData): EVMPaymentData | undefined;
|
|
10
10
|
export declare function getBitcoinPaymentData(paymentData?: CryptoPaymentData): BitcoinPaymentData | undefined;
|
|
11
11
|
export declare function getSolanaPaymentData(paymentData?: CryptoPaymentData): SolanaPaymentData | undefined;
|
|
@@ -19,7 +19,7 @@ export declare const zPayOrderMetadata: z.ZodObject<{
|
|
|
19
19
|
export declare const zPayOrderSettings: z.ZodObject<{
|
|
20
20
|
hide_footer: z.ZodOptional<z.ZodBoolean>;
|
|
21
21
|
card_payments: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
-
}, z.core.$
|
|
22
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
23
23
|
export declare const zPayOrder: z.ZodObject<{
|
|
24
24
|
metadata: z.ZodOptional<z.ZodObject<{
|
|
25
25
|
items: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -41,7 +41,7 @@ export declare const zPayOrder: z.ZodObject<{
|
|
|
41
41
|
settings: z.ZodOptional<z.ZodObject<{
|
|
42
42
|
hide_footer: z.ZodOptional<z.ZodBoolean>;
|
|
43
43
|
card_payments: z.ZodOptional<z.ZodBoolean>;
|
|
44
|
-
}, z.core.$
|
|
44
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
45
45
|
intent: z.ZodObject<{
|
|
46
46
|
asset: z.ZodOptional<z.ZodObject<{
|
|
47
47
|
chain_id: z.ZodNumber;
|
|
@@ -53,9 +53,11 @@ export declare const zPayOrder: z.ZodObject<{
|
|
|
53
53
|
amount: z.ZodNumber;
|
|
54
54
|
unit: z.ZodEnum<{
|
|
55
55
|
USD: "USD";
|
|
56
|
+
EUR: "EUR";
|
|
56
57
|
}>;
|
|
57
58
|
}, z.core.$strip>>;
|
|
58
59
|
}, z.core.$strip>;
|
|
59
60
|
receiving_address: z.ZodOptional<z.ZodString>;
|
|
61
|
+
custom_fee_bps: z.ZodOptional<z.ZodNumber>;
|
|
60
62
|
}, z.core.$strip>;
|
|
61
63
|
}, z.core.$strip>;
|
|
@@ -49,7 +49,7 @@ export const zPayOrderSettings = z.object({
|
|
|
49
49
|
.boolean()
|
|
50
50
|
.optional()
|
|
51
51
|
.describe("Whether to enable card payments for this order. Requires approval from CoinVoyage."),
|
|
52
|
-
});
|
|
52
|
+
}).catchall(z.unknown());
|
|
53
53
|
// also validate not both token_amount and fiat are present
|
|
54
54
|
export const zPayOrder = z.object({
|
|
55
55
|
metadata: zPayOrderMetadata.optional(),
|
|
@@ -81,6 +81,7 @@ export const zPayOrder = z.object({
|
|
|
81
81
|
.optional(),
|
|
82
82
|
}),
|
|
83
83
|
receiving_address: z.string().optional(),
|
|
84
|
+
custom_fee_bps: z.number().int().optional(),
|
|
84
85
|
})
|
|
85
86
|
.superRefine((data, ctx) => {
|
|
86
87
|
const isFiat = data.amount.fiat?.amount !== undefined;
|
package/dist/types/api.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { FiatCurrency } from "../currency/currencies";
|
|
2
|
-
import { ChainId, ChainType, PaymentMethod, PaymentRail, PayOrderStatus } from "./enums";
|
|
2
|
+
import { ChainId, ChainType, PaymentMethod, PaymentRail, PayOrderMode, PayOrderStatus } from "./enums";
|
|
3
3
|
import { PayOrderEvent } from "./events";
|
|
4
|
-
import { CurrencyAmount, CurrencyBase, CurrencyWithAmount, FiatAmount,
|
|
4
|
+
import { CurrencyAmount, CurrencyBase, CurrencyWithAmount, FiatAmount, PaymentDataBase, PayOrder, PayOrderMetadata, QuoteWithCurrency } from "./model";
|
|
5
|
+
export type CreatePayOrderMode = PayOrderMode.SALE | PayOrderMode.DEPOSIT;
|
|
6
|
+
export type OrderRequest = PayOrderParams & {
|
|
7
|
+
mode: CreatePayOrderMode;
|
|
8
|
+
};
|
|
5
9
|
export type PayOrderParams = {
|
|
6
10
|
/**
|
|
7
11
|
* Intent of the order.
|
|
@@ -11,37 +15,23 @@ export type PayOrderParams = {
|
|
|
11
15
|
* Metadata to attach to the payOrder.
|
|
12
16
|
*/
|
|
13
17
|
metadata?: PayOrderMetadata;
|
|
14
|
-
/**
|
|
15
|
-
* UI and behavior settings to attach to the payOrder.
|
|
16
|
-
*/
|
|
17
|
-
settings?: PayOrderSettings;
|
|
18
18
|
};
|
|
19
19
|
export type PayOrderQuoteParams = {
|
|
20
20
|
wallet_address: string;
|
|
21
21
|
chain_type: ChainType;
|
|
22
|
-
|
|
22
|
+
chain_ids?: ChainId[];
|
|
23
23
|
};
|
|
24
|
-
type
|
|
24
|
+
export type PaymentDetailsParams = {
|
|
25
25
|
payorder_id: string;
|
|
26
26
|
payment_rail?: PaymentRail;
|
|
27
|
-
|
|
28
|
-
export type PaymentDetailsParams = (PaymentDetailsBaseParams & {
|
|
29
|
-
source_currency?: never;
|
|
30
|
-
refund_address?: never;
|
|
31
|
-
quote_id?: never;
|
|
32
|
-
}) | (PaymentDetailsBaseParams & {
|
|
33
|
-
source_currency: CurrencyBase;
|
|
27
|
+
source_currency?: CurrencyBase;
|
|
34
28
|
refund_address?: string;
|
|
35
|
-
quote_id?:
|
|
36
|
-
}
|
|
37
|
-
source_currency?: never;
|
|
38
|
-
refund_address?: never;
|
|
39
|
-
quote_id: string;
|
|
40
|
-
});
|
|
29
|
+
quote_id?: string;
|
|
30
|
+
};
|
|
41
31
|
export type PaymentDetails = {
|
|
42
32
|
payorder_id: string;
|
|
43
33
|
status: PayOrderStatus;
|
|
44
|
-
data:
|
|
34
|
+
data: PaymentDataBase;
|
|
45
35
|
};
|
|
46
36
|
export type PaymentMethodAvailability = {
|
|
47
37
|
method: PaymentMethod;
|
|
@@ -65,6 +55,10 @@ export type PayOrderIntent = {
|
|
|
65
55
|
* Optional receiving address to fulfill the order to. If not provided, a settlement address will be selected.
|
|
66
56
|
*/
|
|
67
57
|
receiving_address?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Optional custom fee in basis points.
|
|
60
|
+
*/
|
|
61
|
+
custom_fee_bps?: number;
|
|
68
62
|
};
|
|
69
63
|
export type IntentAmount = {
|
|
70
64
|
/**
|
|
@@ -95,6 +89,44 @@ export type ClaimFeesResponse = {
|
|
|
95
89
|
source_chain_id: ChainId;
|
|
96
90
|
currency: CurrencyAmount;
|
|
97
91
|
};
|
|
92
|
+
export type EndorsementName = "base" | "sepa" | "spei" | "pix";
|
|
93
|
+
export type KYCLinkType = "individual" | "business";
|
|
94
|
+
export type KYCStatus = "not_started" | "incomplete" | "awaiting_questionnaire" | "awaiting_ubo" | "under_review" | "approved" | "rejected" | "paused" | "offboarded";
|
|
95
|
+
export type TOSStatus = "pending" | "approved";
|
|
96
|
+
export type KYCRejectionReason = {
|
|
97
|
+
developer_reason: string;
|
|
98
|
+
reason: string;
|
|
99
|
+
created_at: string;
|
|
100
|
+
};
|
|
101
|
+
export type KYCLinkRequest = {
|
|
102
|
+
email: string;
|
|
103
|
+
type: KYCLinkType;
|
|
104
|
+
full_name?: string;
|
|
105
|
+
endorsements?: EndorsementName[];
|
|
106
|
+
redirect_uri?: string;
|
|
107
|
+
};
|
|
108
|
+
export type KYCLinkResponse = {
|
|
109
|
+
id: string;
|
|
110
|
+
type: KYCLinkType;
|
|
111
|
+
customer_id?: string | null;
|
|
112
|
+
full_name?: string | null;
|
|
113
|
+
email: string;
|
|
114
|
+
kyc_link: string;
|
|
115
|
+
kyc_status: KYCStatus;
|
|
116
|
+
rejection_reasons?: KYCRejectionReason[];
|
|
117
|
+
tos_link: string;
|
|
118
|
+
tos_status: TOSStatus;
|
|
119
|
+
created_at?: string | null;
|
|
120
|
+
};
|
|
121
|
+
export type Pagination = {
|
|
122
|
+
total_count: number;
|
|
123
|
+
limit: number;
|
|
124
|
+
offset: number;
|
|
125
|
+
};
|
|
126
|
+
export type ResponseWithPagination = {
|
|
127
|
+
data: PayOrder[];
|
|
128
|
+
pagination: Pagination;
|
|
129
|
+
};
|
|
98
130
|
export type WebhookResponse = {
|
|
99
131
|
id: string;
|
|
100
132
|
url: string;
|
|
@@ -112,13 +144,18 @@ export type UpdateWebhookRequest = {
|
|
|
112
144
|
active?: boolean;
|
|
113
145
|
};
|
|
114
146
|
export type SwapMode = "ExactIn" | "ExactOut";
|
|
115
|
-
export type
|
|
147
|
+
export type CryptoSwapInput = {
|
|
148
|
+
slippage_bps?: number;
|
|
116
149
|
source_currency: CurrencyBase;
|
|
150
|
+
sender_address?: string;
|
|
151
|
+
};
|
|
152
|
+
export type SwapIntent = {
|
|
153
|
+
payment_rail?: PaymentRail;
|
|
117
154
|
destination_currency: CurrencyBase;
|
|
118
155
|
amount: string;
|
|
119
156
|
swap_mode: SwapMode;
|
|
120
157
|
receiving_address?: string;
|
|
121
|
-
|
|
158
|
+
crypto?: CryptoSwapInput;
|
|
122
159
|
custom_fee_bps?: number;
|
|
123
160
|
};
|
|
124
161
|
export type SwapQuoteRequest = {
|
|
@@ -133,34 +170,49 @@ export type SwapQuoteResponse = {
|
|
|
133
170
|
swap_mode: SwapMode;
|
|
134
171
|
};
|
|
135
172
|
export type RouteQuote = QuoteWithBalance & {
|
|
136
|
-
|
|
173
|
+
quote_id: string;
|
|
137
174
|
output: CurrencyWithAmount;
|
|
138
175
|
swap_mode: SwapMode;
|
|
139
176
|
slippage_bps?: number;
|
|
140
|
-
price_impact
|
|
177
|
+
price_impact: number;
|
|
141
178
|
};
|
|
142
179
|
export type QuoteWithBalance = QuoteWithCurrency & {
|
|
143
180
|
balance?: CurrencyAmount;
|
|
144
181
|
};
|
|
145
|
-
export type
|
|
182
|
+
export type OrderQuoteResponse = RouteQuote[];
|
|
183
|
+
export type SwapDataRequest = {
|
|
184
|
+
metadata?: PayOrderMetadata;
|
|
185
|
+
intent: SwapIntent;
|
|
146
186
|
receiving_address: string;
|
|
147
|
-
refund_address: string;
|
|
148
187
|
};
|
|
149
188
|
export type SwapDataResponse = PaymentDetails;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
189
|
+
export type WsConnectMessage = {
|
|
190
|
+
type: "connect";
|
|
191
|
+
data: {
|
|
192
|
+
api_key: string;
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
export type WsSubscribeMessage = {
|
|
196
|
+
type: "subscribe";
|
|
197
|
+
data: {
|
|
198
|
+
order_id?: string | null;
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
export type WsUnsubscribeMessage = {
|
|
202
|
+
type: "unsubscribe";
|
|
203
|
+
data: {
|
|
204
|
+
order_id?: string | null;
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
export type WsClientMessage = WsConnectMessage | WsSubscribeMessage | WsUnsubscribeMessage;
|
|
156
208
|
export type WsConnectedMessage = {
|
|
157
|
-
type:
|
|
209
|
+
type: "connected";
|
|
158
210
|
data: {
|
|
159
211
|
status: "authenticated";
|
|
160
212
|
};
|
|
161
213
|
};
|
|
162
214
|
export type WsSubscriptionMessage = {
|
|
163
|
-
type:
|
|
215
|
+
type: "subscription";
|
|
164
216
|
data: {
|
|
165
217
|
order_id?: string;
|
|
166
218
|
scope: "order" | "organization";
|
|
@@ -168,11 +220,11 @@ export type WsSubscriptionMessage = {
|
|
|
168
220
|
};
|
|
169
221
|
};
|
|
170
222
|
export type WsEventMessage = {
|
|
171
|
-
type:
|
|
223
|
+
type: "event";
|
|
172
224
|
data: PayOrderEvent;
|
|
173
225
|
};
|
|
174
226
|
export type WsErrorMessage = {
|
|
175
|
-
type:
|
|
227
|
+
type: "error";
|
|
176
228
|
data: {
|
|
177
229
|
message: string;
|
|
178
230
|
};
|
|
@@ -189,4 +241,3 @@ export type OrderStatusSocket = {
|
|
|
189
241
|
onError: (callback: (event: Event) => void) => void;
|
|
190
242
|
close: () => void;
|
|
191
243
|
};
|
|
192
|
-
export {};
|
package/dist/types/api.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
// ======== WebSocket ========
|
|
2
|
-
var WsMessageType;
|
|
3
|
-
(function (WsMessageType) {
|
|
4
|
-
WsMessageType["Connected"] = "connected";
|
|
5
|
-
WsMessageType["Subscription"] = "subscription";
|
|
6
|
-
WsMessageType["Event"] = "event";
|
|
7
|
-
WsMessageType["Error"] = "error";
|
|
8
|
-
})(WsMessageType || (WsMessageType = {}));
|
|
9
1
|
export {};
|
package/dist/types/enums.d.ts
CHANGED
|
@@ -43,7 +43,9 @@ export declare enum StepKind {
|
|
|
43
43
|
export declare enum PayOrderMode {
|
|
44
44
|
SALE = "SALE",
|
|
45
45
|
DEPOSIT = "DEPOSIT",
|
|
46
|
-
REFUND = "REFUND"
|
|
46
|
+
REFUND = "REFUND",
|
|
47
|
+
SWAP = "SWAP",
|
|
48
|
+
FEE_CLAIM = "FEE_CLAIM"
|
|
47
49
|
}
|
|
48
50
|
export declare enum PayOrderStatus {
|
|
49
51
|
PENDING = "PENDING",
|
package/dist/types/enums.js
CHANGED
|
@@ -58,6 +58,8 @@ export var PayOrderMode;
|
|
|
58
58
|
PayOrderMode["SALE"] = "SALE";
|
|
59
59
|
PayOrderMode["DEPOSIT"] = "DEPOSIT";
|
|
60
60
|
PayOrderMode["REFUND"] = "REFUND";
|
|
61
|
+
PayOrderMode["SWAP"] = "SWAP";
|
|
62
|
+
PayOrderMode["FEE_CLAIM"] = "FEE_CLAIM";
|
|
61
63
|
})(PayOrderMode || (PayOrderMode = {}));
|
|
62
64
|
export var PayOrderStatus;
|
|
63
65
|
(function (PayOrderStatus) {
|
package/dist/types/model.d.ts
CHANGED
|
@@ -4,18 +4,24 @@ import { zPayOrderMetadata, zPayOrderSettings } from "../schemas/pay-order";
|
|
|
4
4
|
import { ChainId, PaymentRail, PayOrderMode, PayOrderStatus, ProviderStatus, StepKind } from "./enums";
|
|
5
5
|
export type PayOrder = {
|
|
6
6
|
id: string;
|
|
7
|
+
organization_id: string;
|
|
7
8
|
mode: PayOrderMode;
|
|
8
9
|
status: PayOrderStatus;
|
|
9
10
|
metadata?: ParsedPayOrderMetadata;
|
|
10
11
|
settings?: ParsedPayOrderSettings;
|
|
11
12
|
fulfillment: FulfillmentData;
|
|
12
13
|
payment?: PaymentData;
|
|
14
|
+
hosted_url: string;
|
|
15
|
+
created_at: Date;
|
|
16
|
+
updated_at: Date;
|
|
13
17
|
};
|
|
14
18
|
type MetadataExtraFields = Record<string, unknown>;
|
|
19
|
+
type SettingsExtraFields = Record<string, unknown>;
|
|
15
20
|
export type ParsedPayOrderMetadata = z.output<typeof zPayOrderMetadata> & MetadataExtraFields;
|
|
16
21
|
export type PayOrderMetadata = z.infer<typeof zPayOrderMetadata>;
|
|
17
|
-
export type ParsedPayOrderSettings = z.output<typeof zPayOrderSettings
|
|
18
|
-
export type PayOrderSettings = z.infer<typeof zPayOrderSettings
|
|
22
|
+
export type ParsedPayOrderSettings = z.output<typeof zPayOrderSettings> & SettingsExtraFields;
|
|
23
|
+
export type PayOrderSettings = z.infer<typeof zPayOrderSettings> & SettingsExtraFields;
|
|
24
|
+
export type OrganizationSettings = ParsedPayOrderSettings;
|
|
19
25
|
export interface Currency extends CurrencyBase {
|
|
20
26
|
id?: string;
|
|
21
27
|
name: string;
|
|
@@ -38,6 +44,7 @@ export interface QuoteWithCurrency extends CurrencyWithAmount {
|
|
|
38
44
|
gas?: CurrencyAmount;
|
|
39
45
|
}
|
|
40
46
|
export interface CurrencyWithBalance extends CurrencyWithAmount {
|
|
47
|
+
owner?: string;
|
|
41
48
|
balance?: CurrencyAmount;
|
|
42
49
|
}
|
|
43
50
|
export interface CurrencyAmount {
|
|
@@ -51,28 +58,40 @@ export interface FeeBreakdown {
|
|
|
51
58
|
protocol_fee?: CurrencyAmount;
|
|
52
59
|
custom_fee?: CurrencyAmount;
|
|
53
60
|
}
|
|
54
|
-
export interface
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
export interface FeeCurrencyBreakdown {
|
|
62
|
+
currency: Currency;
|
|
63
|
+
total_fee: CurrencyAmount;
|
|
64
|
+
protocol_fee?: CurrencyAmount;
|
|
65
|
+
custom_fee?: CurrencyAmount;
|
|
66
|
+
}
|
|
67
|
+
export type OnrampDestinationCurrency = "btc" | "eth" | "pol" | "sol" | "usdc";
|
|
68
|
+
export type OnrampDestinationNetwork = "base" | "ethereum" | "optimism" | "polygon" | "solana";
|
|
69
|
+
export interface OnrampQuote {
|
|
70
|
+
source_currency?: string;
|
|
71
|
+
source_amount?: string;
|
|
72
|
+
source_total_amount?: string;
|
|
73
|
+
destination_currency: OnrampDestinationCurrency;
|
|
74
|
+
destination_network: OnrampDestinationNetwork;
|
|
60
75
|
destination_amount: string;
|
|
76
|
+
exchange_rate?: string;
|
|
61
77
|
network_fee_amount?: string;
|
|
62
78
|
transaction_fee_amount?: string;
|
|
63
79
|
}
|
|
64
|
-
export
|
|
80
|
+
export type FiatQuoteData = OnrampQuote;
|
|
81
|
+
export interface OnrampPaymentData {
|
|
65
82
|
session_id: string;
|
|
66
83
|
stripe_publishable_key: string;
|
|
67
84
|
client_secret: string;
|
|
68
85
|
status: string;
|
|
86
|
+
hosted_url?: string;
|
|
69
87
|
source_currency?: string;
|
|
70
|
-
destination_currency
|
|
71
|
-
destination_network
|
|
72
|
-
destination_amount
|
|
73
|
-
wallet_address
|
|
74
|
-
quote?:
|
|
88
|
+
destination_currency: OnrampDestinationCurrency;
|
|
89
|
+
destination_network: OnrampDestinationNetwork;
|
|
90
|
+
destination_amount: string;
|
|
91
|
+
wallet_address: string;
|
|
92
|
+
quote?: OnrampQuote;
|
|
75
93
|
}
|
|
94
|
+
export type FiatPaymentData = OnrampPaymentData;
|
|
76
95
|
export type SerializedSuiTransaction = unknown;
|
|
77
96
|
export type SerializedSolanaTransaction = unknown;
|
|
78
97
|
export interface CryptoPaymentData {
|
|
@@ -105,7 +124,7 @@ export type TokenAmount = {
|
|
|
105
124
|
};
|
|
106
125
|
export type FiatAmount = {
|
|
107
126
|
amount: number;
|
|
108
|
-
unit:
|
|
127
|
+
unit: FiatCurrency;
|
|
109
128
|
};
|
|
110
129
|
export type RequestData = {
|
|
111
130
|
currency: Currency | null;
|
|
@@ -119,22 +138,25 @@ export type FulfillmentData = {
|
|
|
119
138
|
asset?: Currency;
|
|
120
139
|
fiat?: FiatCurrency;
|
|
121
140
|
amount: CurrencyAmount;
|
|
122
|
-
rate_usd?:
|
|
141
|
+
rate_usd?: string;
|
|
123
142
|
receiving_address?: string;
|
|
124
143
|
custom_fee_bps?: number;
|
|
125
144
|
};
|
|
126
|
-
export type
|
|
145
|
+
export type PaymentDataBase = {
|
|
146
|
+
payment_rail: PaymentRail;
|
|
127
147
|
src: QuoteWithCurrency;
|
|
128
148
|
dst: CurrencyWithAmount;
|
|
129
149
|
deposit_address: string;
|
|
130
150
|
receiving_address: string;
|
|
131
|
-
refund_address
|
|
151
|
+
refund_address?: string;
|
|
152
|
+
steps: PaymentStep[];
|
|
153
|
+
expires_at: string;
|
|
154
|
+
};
|
|
155
|
+
export type PaymentData = PaymentDataBase & {
|
|
132
156
|
source_tx_hash?: string;
|
|
133
157
|
destination_tx_hash?: string;
|
|
134
158
|
refund_tx_hash?: string;
|
|
135
159
|
fee_tx_hash?: string;
|
|
136
|
-
steps: PaymentStep[];
|
|
137
|
-
expires_at: Date;
|
|
138
160
|
};
|
|
139
161
|
export type PaymentStep = {
|
|
140
162
|
rail: PaymentRail;
|
|
@@ -152,20 +174,24 @@ export type ExecutionStep = {
|
|
|
152
174
|
provider: string;
|
|
153
175
|
receiver: string;
|
|
154
176
|
deposit_address: string;
|
|
155
|
-
source_tx_hash?: string
|
|
156
|
-
destination_tx_hash?: string
|
|
157
|
-
error?:
|
|
177
|
+
source_tx_hash?: string;
|
|
178
|
+
destination_tx_hash?: string;
|
|
179
|
+
error?: string;
|
|
158
180
|
cleanup_tx_hash?: Record<string, string>;
|
|
159
|
-
cleanup_error?:
|
|
181
|
+
cleanup_error?: string;
|
|
182
|
+
cleanup_recipient?: string;
|
|
160
183
|
source_currency: CurrencyWithAmount;
|
|
161
184
|
destination_currency: CurrencyWithAmount;
|
|
162
|
-
|
|
163
|
-
|
|
185
|
+
chain_data?: CryptoPaymentData;
|
|
186
|
+
gas?: CurrencyWithAmount;
|
|
187
|
+
fees?: FeeCurrencyBreakdown;
|
|
164
188
|
fee_tx_hash?: string;
|
|
165
|
-
fee_error?:
|
|
166
|
-
|
|
189
|
+
fee_error?: string;
|
|
190
|
+
fee_plan?: FeePlan;
|
|
191
|
+
price_impact?: number;
|
|
167
192
|
};
|
|
168
193
|
export interface FeePlan extends CurrencyWithAmount {
|
|
194
|
+
placement: string;
|
|
169
195
|
fee_bps?: number;
|
|
170
196
|
}
|
|
171
197
|
export type BigIntStr = `${bigint}`;
|