@p2pdotme/sdk 1.0.5 → 1.1.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 +71 -41
- package/dist/country.cjs +8 -1
- package/dist/country.cjs.map +1 -1
- package/dist/country.d.cts +35 -10
- package/dist/country.d.ts +35 -10
- package/dist/country.mjs +5 -1
- package/dist/country.mjs.map +1 -1
- package/dist/fraud-engine.cjs +52 -48
- package/dist/fraud-engine.cjs.map +1 -1
- package/dist/fraud-engine.mjs +46 -42
- package/dist/fraud-engine.mjs.map +1 -1
- package/dist/index.cjs +4 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -36
- package/dist/index.d.ts +41 -36
- package/dist/index.mjs +4 -12
- package/dist/index.mjs.map +1 -1
- package/dist/{payload.cjs → orders.cjs} +2357 -253
- package/dist/orders.cjs.map +1 -0
- package/dist/orders.d.cts +399 -0
- package/dist/orders.d.ts +399 -0
- package/dist/{payload.mjs → orders.mjs} +2340 -237
- package/dist/orders.mjs.map +1 -0
- package/dist/prices.cjs +1008 -0
- package/dist/prices.cjs.map +1 -0
- package/dist/prices.d.cts +109 -0
- package/dist/prices.d.ts +109 -0
- package/dist/prices.mjs +980 -0
- package/dist/prices.mjs.map +1 -0
- package/dist/profile.cjs +475 -69
- package/dist/profile.cjs.map +1 -1
- package/dist/profile.d.cts +39 -27
- package/dist/profile.d.ts +39 -27
- package/dist/profile.mjs +468 -62
- package/dist/profile.mjs.map +1 -1
- package/dist/qr-parsers.cjs +6 -6
- package/dist/qr-parsers.cjs.map +1 -1
- package/dist/qr-parsers.d.cts +38 -16
- package/dist/qr-parsers.d.ts +38 -16
- package/dist/qr-parsers.mjs +6 -6
- package/dist/qr-parsers.mjs.map +1 -1
- package/dist/react.cjs +2531 -1105
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +384 -104
- package/dist/react.d.ts +384 -104
- package/dist/react.mjs +2417 -992
- package/dist/react.mjs.map +1 -1
- package/dist/zkkyc.cjs +405 -24
- package/dist/zkkyc.cjs.map +1 -1
- package/dist/zkkyc.d.cts +14 -9
- package/dist/zkkyc.d.ts +14 -9
- package/dist/zkkyc.mjs +405 -24
- package/dist/zkkyc.mjs.map +1 -1
- package/package.json +12 -12
- package/dist/order-routing.cjs +0 -888
- package/dist/order-routing.cjs.map +0 -1
- package/dist/order-routing.d.cts +0 -68
- package/dist/order-routing.d.ts +0 -68
- package/dist/order-routing.mjs +0 -860
- package/dist/order-routing.mjs.map +0 -1
- package/dist/payload.cjs.map +0 -1
- package/dist/payload.d.cts +0 -147
- package/dist/payload.d.ts +0 -147
- package/dist/payload.mjs.map +0 -1
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { ResultAsync } from 'neverthrow';
|
|
2
|
+
import { Address, WalletClient, TransactionReceipt } from 'viem';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Minimal viem PublicClient interface — consumers pass their own client.
|
|
7
|
+
* The SDK uses `readContract` for single reads and `multicall` where available
|
|
8
|
+
* to batch multiple reads into one RPC round-trip.
|
|
9
|
+
*/
|
|
10
|
+
interface PublicClientLike {
|
|
11
|
+
readContract(args: {
|
|
12
|
+
address: Address;
|
|
13
|
+
abi: readonly unknown[];
|
|
14
|
+
functionName: string;
|
|
15
|
+
args: readonly unknown[];
|
|
16
|
+
}): Promise<unknown>;
|
|
17
|
+
multicall?(args: {
|
|
18
|
+
contracts: readonly {
|
|
19
|
+
address: Address;
|
|
20
|
+
abi: readonly unknown[];
|
|
21
|
+
functionName: string;
|
|
22
|
+
args?: readonly unknown[];
|
|
23
|
+
}[];
|
|
24
|
+
allowFailure?: boolean;
|
|
25
|
+
}): Promise<readonly unknown[]>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare class SdkError<TCode extends string = string> extends Error {
|
|
29
|
+
readonly code: TCode;
|
|
30
|
+
readonly cause?: unknown;
|
|
31
|
+
readonly context?: Record<string, unknown>;
|
|
32
|
+
constructor(message: string, options: {
|
|
33
|
+
code: TCode;
|
|
34
|
+
cause?: unknown;
|
|
35
|
+
context?: Record<string, unknown>;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type OrdersErrorCode = "VALIDATION_ERROR" | "INVALID_ORDER_ID" | "INVALID_GET_ORDERS_PARAMS" | "INVALID_FEE_CONFIG_PARAMS" | "ORDER_NOT_FOUND" | "CONTRACT_READ_FAILED" | "SUBGRAPH_REQUEST_FAILED" | "SUBGRAPH_VALIDATION_FAILED" | "MALFORMED_ORDER" | "CIRCLE_SELECTION_FAILED" | "ENCRYPTION_FAILED" | "RELAY_IDENTITY_CORRUPT" | "RELAY_IDENTITY_STORE_FAILED" | "TX_SUBMISSION_FAILED" | "RECEIPT_TIMEOUT" | "TX_REVERTED" | "EVENT_WATCH_FAILED";
|
|
40
|
+
declare class OrdersError extends SdkError<OrdersErrorCode> {
|
|
41
|
+
constructor(message: string, options: {
|
|
42
|
+
code: OrdersErrorCode;
|
|
43
|
+
cause?: unknown;
|
|
44
|
+
context?: Record<string, unknown>;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface Logger {
|
|
49
|
+
debug(message: string, data?: Record<string, unknown>): void;
|
|
50
|
+
info(message: string, data?: Record<string, unknown>): void;
|
|
51
|
+
warn(message: string, data?: Record<string, unknown>): void;
|
|
52
|
+
error(message: string, data?: Record<string, unknown>): void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface RelayIdentity {
|
|
56
|
+
readonly address: `0x${string}`;
|
|
57
|
+
readonly publicKey: string;
|
|
58
|
+
readonly privateKey: `0x${string}`;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Generates a fresh relay identity keypair. Pure — no side effects.
|
|
62
|
+
* Consumers decide how to persist the result via a `RelayIdentityStore`.
|
|
63
|
+
*/
|
|
64
|
+
declare function createRelayIdentity(): RelayIdentity;
|
|
65
|
+
|
|
66
|
+
interface RelayIdentityStore {
|
|
67
|
+
get(): Promise<RelayIdentity | null>;
|
|
68
|
+
set(identity: RelayIdentity): Promise<void>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Ephemeral in-process store. Lost on process restart. Used as the default
|
|
72
|
+
* when the consumer doesn't supply one.
|
|
73
|
+
*/
|
|
74
|
+
declare function createInMemoryRelayStore(): RelayIdentityStore;
|
|
75
|
+
/**
|
|
76
|
+
* Browser-only adapter that persists the identity as JSON in `localStorage`.
|
|
77
|
+
* Throws at call time if `localStorage` is unavailable — do not use in SSR/RN.
|
|
78
|
+
*/
|
|
79
|
+
declare function createLocalStorageRelayStore(options?: {
|
|
80
|
+
key?: string;
|
|
81
|
+
}): RelayIdentityStore;
|
|
82
|
+
|
|
83
|
+
declare const ZodGetOrderParamsSchema: z.ZodObject<{
|
|
84
|
+
orderId: z.ZodBigInt;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
type GetOrderParams = z.infer<typeof ZodGetOrderParamsSchema>;
|
|
87
|
+
declare const ZodGetFeeConfigParamsSchema: z.ZodObject<{
|
|
88
|
+
currency: z.ZodEnum<{
|
|
89
|
+
IDR: "IDR";
|
|
90
|
+
INR: "INR";
|
|
91
|
+
BRL: "BRL";
|
|
92
|
+
ARS: "ARS";
|
|
93
|
+
MEX: "MEX";
|
|
94
|
+
VEN: "VEN";
|
|
95
|
+
EUR: "EUR";
|
|
96
|
+
NGN: "NGN";
|
|
97
|
+
USD: "USD";
|
|
98
|
+
COP: "COP";
|
|
99
|
+
}>;
|
|
100
|
+
}, z.core.$strip>;
|
|
101
|
+
type GetFeeConfigParams = z.infer<typeof ZodGetFeeConfigParamsSchema>;
|
|
102
|
+
declare const ZodGetOrdersParamsSchema: z.ZodObject<{
|
|
103
|
+
userAddress: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
|
|
104
|
+
skip: z.ZodDefault<z.ZodNumber>;
|
|
105
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
106
|
+
}, z.core.$strip>;
|
|
107
|
+
type GetOrdersParams = z.input<typeof ZodGetOrdersParamsSchema>;
|
|
108
|
+
declare const ZodPlaceOrderParamsSchema: z.ZodObject<{
|
|
109
|
+
orderType: z.ZodNumber;
|
|
110
|
+
currency: z.ZodEnum<{
|
|
111
|
+
IDR: "IDR";
|
|
112
|
+
INR: "INR";
|
|
113
|
+
BRL: "BRL";
|
|
114
|
+
ARS: "ARS";
|
|
115
|
+
MEX: "MEX";
|
|
116
|
+
VEN: "VEN";
|
|
117
|
+
EUR: "EUR";
|
|
118
|
+
NGN: "NGN";
|
|
119
|
+
USD: "USD";
|
|
120
|
+
COP: "COP";
|
|
121
|
+
}>;
|
|
122
|
+
user: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
|
|
123
|
+
amount: z.ZodBigInt;
|
|
124
|
+
fiatAmount: z.ZodBigInt;
|
|
125
|
+
fiatAmountLimit: z.ZodDefault<z.ZodOptional<z.ZodBigInt>>;
|
|
126
|
+
recipientAddr: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
|
|
127
|
+
preferredPaymentChannelConfigId: z.ZodOptional<z.ZodBigInt>;
|
|
128
|
+
pubKey: z.ZodOptional<z.ZodString>;
|
|
129
|
+
}, z.core.$strip>;
|
|
130
|
+
type PlaceOrderParams = z.input<typeof ZodPlaceOrderParamsSchema>;
|
|
131
|
+
declare const ZodCancelOrderParamsSchema: z.ZodObject<{
|
|
132
|
+
orderId: z.ZodBigInt;
|
|
133
|
+
}, z.core.$strip>;
|
|
134
|
+
type CancelOrderParams = z.infer<typeof ZodCancelOrderParamsSchema>;
|
|
135
|
+
declare const ZodSetSellOrderUpiParamsSchema: z.ZodObject<{
|
|
136
|
+
orderId: z.ZodBigInt;
|
|
137
|
+
paymentAddress: z.ZodString;
|
|
138
|
+
merchantPublicKey: z.ZodString;
|
|
139
|
+
updatedAmount: z.ZodBigInt;
|
|
140
|
+
}, z.core.$strip>;
|
|
141
|
+
type SetSellOrderUpiParams = z.infer<typeof ZodSetSellOrderUpiParamsSchema>;
|
|
142
|
+
declare const ZodRaiseDisputeParamsSchema: z.ZodObject<{
|
|
143
|
+
orderId: z.ZodBigInt;
|
|
144
|
+
redactTransId: z.ZodBigInt;
|
|
145
|
+
}, z.core.$strip>;
|
|
146
|
+
type RaiseDisputeParams = z.infer<typeof ZodRaiseDisputeParamsSchema>;
|
|
147
|
+
declare const ZodApproveUsdcParamsSchema: z.ZodObject<{
|
|
148
|
+
amount: z.ZodBigInt;
|
|
149
|
+
}, z.core.$strip>;
|
|
150
|
+
type ApproveUsdcParams = z.infer<typeof ZodApproveUsdcParamsSchema>;
|
|
151
|
+
declare const ZodPaidBuyOrderParamsSchema: z.ZodObject<{
|
|
152
|
+
orderId: z.ZodBigInt;
|
|
153
|
+
}, z.core.$strip>;
|
|
154
|
+
type PaidBuyOrderParams = z.infer<typeof ZodPaidBuyOrderParamsSchema>;
|
|
155
|
+
|
|
156
|
+
type OrderType = "buy" | "sell" | "pay";
|
|
157
|
+
type OrderStatus = "placed" | "accepted" | "paid" | "completed" | "cancelled";
|
|
158
|
+
type DisputeStatus = "none" | "open" | "resolved";
|
|
159
|
+
/**
|
|
160
|
+
* Normalized order record returned by both `getOrder` and `getOrders`.
|
|
161
|
+
* Amounts are 6-decimal bigints; timestamps are unix seconds.
|
|
162
|
+
*/
|
|
163
|
+
interface Order {
|
|
164
|
+
orderId: bigint;
|
|
165
|
+
type: OrderType;
|
|
166
|
+
status: OrderStatus;
|
|
167
|
+
usdcAmount: bigint;
|
|
168
|
+
fiatAmount: bigint;
|
|
169
|
+
actualUsdcAmount: bigint;
|
|
170
|
+
actualFiatAmount: bigint;
|
|
171
|
+
currency: string;
|
|
172
|
+
user: Address;
|
|
173
|
+
recipient: Address;
|
|
174
|
+
acceptedMerchant: Address;
|
|
175
|
+
placedAt: bigint;
|
|
176
|
+
acceptedAt: bigint;
|
|
177
|
+
paidAt: bigint;
|
|
178
|
+
completedAt: bigint;
|
|
179
|
+
circleId: bigint;
|
|
180
|
+
fixedFeePaid: bigint;
|
|
181
|
+
tipsPaid: bigint;
|
|
182
|
+
disputeStatus: DisputeStatus;
|
|
183
|
+
/**
|
|
184
|
+
* Encrypted UPI / payment address that the merchant published for this order
|
|
185
|
+
* (set when the merchant accepts a buy order). Empty string until set.
|
|
186
|
+
* Decrypt with `decryptPaymentAddress`.
|
|
187
|
+
*/
|
|
188
|
+
encUpi: string;
|
|
189
|
+
/**
|
|
190
|
+
* Encrypted merchant UPI for the seller-side flow (set by `setSellOrderUpi`).
|
|
191
|
+
* Empty string until set.
|
|
192
|
+
*/
|
|
193
|
+
encMerchantUpi: string;
|
|
194
|
+
/** Public key associated with the order, used for ECIES encryption setup. */
|
|
195
|
+
pubkey: string;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Per-currency small-order fee config read from the Diamond.
|
|
199
|
+
* Amounts are 6-decimal bigints.
|
|
200
|
+
*/
|
|
201
|
+
interface FeeConfig {
|
|
202
|
+
/** Order amounts at or below this threshold are billed the fixed fee. */
|
|
203
|
+
smallOrderThreshold: bigint;
|
|
204
|
+
/** Fixed fee applied to small orders (6 decimals). */
|
|
205
|
+
smallOrderFixedFee: bigint;
|
|
206
|
+
}
|
|
207
|
+
interface OrdersConfig {
|
|
208
|
+
readonly publicClient: PublicClientLike;
|
|
209
|
+
readonly diamondAddress: Address;
|
|
210
|
+
readonly usdcAddress: Address;
|
|
211
|
+
readonly subgraphUrl: string;
|
|
212
|
+
readonly relayIdentityStore?: RelayIdentityStore;
|
|
213
|
+
readonly relayIdentity?: RelayIdentity;
|
|
214
|
+
readonly logger?: Logger;
|
|
215
|
+
}
|
|
216
|
+
interface PreparedTxMeta {
|
|
217
|
+
readonly circleId?: bigint;
|
|
218
|
+
readonly relayIdentity?: RelayIdentity;
|
|
219
|
+
}
|
|
220
|
+
interface PreparedTx {
|
|
221
|
+
readonly to: `0x${string}`;
|
|
222
|
+
readonly data: `0x${string}`;
|
|
223
|
+
readonly value: bigint;
|
|
224
|
+
readonly meta?: PreparedTxMeta;
|
|
225
|
+
}
|
|
226
|
+
interface TxResultMeta extends PreparedTxMeta {
|
|
227
|
+
/**
|
|
228
|
+
* Populated on `placeOrder.execute({ waitForReceipt: true })` — the orderId
|
|
229
|
+
* parsed from the `OrderPlaced` event in the receipt's logs. Undefined when
|
|
230
|
+
* `waitForReceipt` is not set (no receipt means no logs to parse).
|
|
231
|
+
*/
|
|
232
|
+
readonly orderId?: bigint;
|
|
233
|
+
}
|
|
234
|
+
interface TxResult {
|
|
235
|
+
readonly hash: `0x${string}`;
|
|
236
|
+
readonly receipt?: TransactionReceipt;
|
|
237
|
+
readonly meta?: TxResultMeta;
|
|
238
|
+
}
|
|
239
|
+
interface ExecuteBase {
|
|
240
|
+
readonly walletClient: WalletClient;
|
|
241
|
+
readonly waitForReceipt?: boolean;
|
|
242
|
+
}
|
|
243
|
+
type OrderEvent = {
|
|
244
|
+
readonly type: "placed";
|
|
245
|
+
readonly orderId: bigint;
|
|
246
|
+
readonly user: Address;
|
|
247
|
+
readonly orderType: 0 | 1 | 2;
|
|
248
|
+
readonly blockNumber: bigint;
|
|
249
|
+
readonly txHash: `0x${string}`;
|
|
250
|
+
} | {
|
|
251
|
+
readonly type: "accepted";
|
|
252
|
+
readonly orderId: bigint;
|
|
253
|
+
readonly merchant: Address;
|
|
254
|
+
readonly blockNumber: bigint;
|
|
255
|
+
readonly txHash: `0x${string}`;
|
|
256
|
+
} | {
|
|
257
|
+
readonly type: "paid";
|
|
258
|
+
readonly orderId: bigint;
|
|
259
|
+
readonly blockNumber: bigint;
|
|
260
|
+
readonly txHash: `0x${string}`;
|
|
261
|
+
} | {
|
|
262
|
+
readonly type: "completed";
|
|
263
|
+
readonly orderId: bigint;
|
|
264
|
+
readonly blockNumber: bigint;
|
|
265
|
+
readonly txHash: `0x${string}`;
|
|
266
|
+
} | {
|
|
267
|
+
readonly type: "cancelled";
|
|
268
|
+
readonly orderId: bigint;
|
|
269
|
+
readonly blockNumber: bigint;
|
|
270
|
+
readonly txHash: `0x${string}`;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
interface ApproveUsdcAction {
|
|
274
|
+
prepare(params: ApproveUsdcParams): ResultAsync<PreparedTx, OrdersError>;
|
|
275
|
+
execute(params: ApproveUsdcParams & ExecuteBase): ResultAsync<TxResult, OrdersError>;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
interface CancelOrderAction {
|
|
279
|
+
prepare(params: CancelOrderParams): ResultAsync<PreparedTx, OrdersError>;
|
|
280
|
+
execute(params: CancelOrderParams & ExecuteBase): ResultAsync<TxResult, OrdersError>;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
interface PaidBuyOrderAction {
|
|
284
|
+
prepare(params: PaidBuyOrderParams): ResultAsync<PreparedTx, OrdersError>;
|
|
285
|
+
execute(params: PaidBuyOrderParams & ExecuteBase): ResultAsync<TxResult, OrdersError>;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
interface PlaceOrderAction {
|
|
289
|
+
prepare(params: PlaceOrderParams): ResultAsync<PreparedTx, OrdersError>;
|
|
290
|
+
execute(params: PlaceOrderParams & ExecuteBase): ResultAsync<TxResult, OrdersError>;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
interface RaiseDisputeAction {
|
|
294
|
+
prepare(params: RaiseDisputeParams): ResultAsync<PreparedTx, OrdersError>;
|
|
295
|
+
execute(params: RaiseDisputeParams & ExecuteBase): ResultAsync<TxResult, OrdersError>;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
interface SetSellOrderUpiAction {
|
|
299
|
+
prepare(params: SetSellOrderUpiParams): ResultAsync<PreparedTx, OrdersError>;
|
|
300
|
+
execute(params: SetSellOrderUpiParams & ExecuteBase): ResultAsync<TxResult, OrdersError>;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
interface WatchEventsParams {
|
|
304
|
+
readonly user?: Address;
|
|
305
|
+
readonly onEvent: (event: OrderEvent) => void;
|
|
306
|
+
readonly onError?: (error: OrdersError) => void;
|
|
307
|
+
}
|
|
308
|
+
type WatchEvents = (params: WatchEventsParams) => () => void;
|
|
309
|
+
|
|
310
|
+
interface OrdersClient {
|
|
311
|
+
/** Reads a single order by id from the Diamond contract. */
|
|
312
|
+
getOrder(params: GetOrderParams): ResultAsync<Order, OrdersError>;
|
|
313
|
+
/**
|
|
314
|
+
* Lists orders created by `userAddress` from the subgraph, newest first.
|
|
315
|
+
* Defaults: `skip = 0`, `limit = 20`. Max `limit` is 100.
|
|
316
|
+
*/
|
|
317
|
+
getOrders(params: GetOrdersParams): ResultAsync<Order[], OrdersError>;
|
|
318
|
+
/**
|
|
319
|
+
* Reads the per-currency small-order fee config from the Diamond via
|
|
320
|
+
* multicall: threshold (below which the fixed fee applies) and the fixed
|
|
321
|
+
* fee itself. Both are 6-decimal bigints.
|
|
322
|
+
*/
|
|
323
|
+
getFeeConfig(params: GetFeeConfigParams): ResultAsync<FeeConfig, OrdersError>;
|
|
324
|
+
readonly placeOrder: PlaceOrderAction;
|
|
325
|
+
readonly cancelOrder: CancelOrderAction;
|
|
326
|
+
readonly setSellOrderUpi: SetSellOrderUpiAction;
|
|
327
|
+
readonly raiseDispute: RaiseDisputeAction;
|
|
328
|
+
readonly approveUsdc: ApproveUsdcAction;
|
|
329
|
+
readonly paidBuyOrder: PaidBuyOrderAction;
|
|
330
|
+
watchEvents: WatchEvents;
|
|
331
|
+
/**
|
|
332
|
+
* Decrypts an `encUpi` / `encMerchantUpi` ciphertext from an order using the
|
|
333
|
+
* relay identity resolved from the configured store. Returns the plaintext
|
|
334
|
+
* payment address.
|
|
335
|
+
*/
|
|
336
|
+
decryptPaymentAddress(params: {
|
|
337
|
+
encrypted: string;
|
|
338
|
+
}): ResultAsync<string, OrdersError>;
|
|
339
|
+
/**
|
|
340
|
+
* Signs `paymentAddress` with the resolved relay identity and ECIES-encrypts
|
|
341
|
+
* the payload for `recipientPublicKey`. Returns the hex-stringified ciphertext
|
|
342
|
+
* suitable for on-chain storage (e.g. as the merchant's encUpi when calling
|
|
343
|
+
* `setSellOrderUpi`).
|
|
344
|
+
*/
|
|
345
|
+
encryptPaymentAddress(params: {
|
|
346
|
+
paymentAddress: string;
|
|
347
|
+
recipientPublicKey: string;
|
|
348
|
+
}): ResultAsync<string, OrdersError>;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Creates the unified orders client — reads (getOrder, getOrders, getFeeConfig)
|
|
352
|
+
* and circle-routing-backed writes (placeOrder, cancelOrder, setSellOrderUpi,
|
|
353
|
+
* raiseDispute, approveUsdc). The relay identity store defaults to in-memory
|
|
354
|
+
* when none is supplied.
|
|
355
|
+
*
|
|
356
|
+
* For USDC balance / allowance reads use `@p2pdotme/sdk/profile` (those are
|
|
357
|
+
* user-scoped and live there).
|
|
358
|
+
*/
|
|
359
|
+
declare function createOrders(config: OrdersConfig): OrdersClient;
|
|
360
|
+
|
|
361
|
+
interface Encrypted {
|
|
362
|
+
readonly iv: string;
|
|
363
|
+
readonly ephemPublicKey: string;
|
|
364
|
+
readonly ciphertext: string;
|
|
365
|
+
readonly mac: string;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Serializes an Encrypted object to a compact hex string.
|
|
369
|
+
* Format: IV (16 bytes) || compressed ephemPublicKey (33 bytes) || MAC (32 bytes) || ciphertext.
|
|
370
|
+
*/
|
|
371
|
+
declare function cipherStringify(encrypted: Encrypted): string;
|
|
372
|
+
/**
|
|
373
|
+
* Parses a compact hex string back into an Encrypted object.
|
|
374
|
+
* Inverse of cipherStringify.
|
|
375
|
+
*/
|
|
376
|
+
declare function cipherParse(str: string): Encrypted;
|
|
377
|
+
|
|
378
|
+
interface EncryptPaymentAddressInput {
|
|
379
|
+
readonly paymentAddress: string;
|
|
380
|
+
readonly recipientPublicKey: string;
|
|
381
|
+
readonly senderIdentity: RelayIdentity;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Signs `paymentAddress` with the sender relay identity's private key, then
|
|
385
|
+
* ECIES-encrypts the `{ message, signature }` payload for the recipient. Returns
|
|
386
|
+
* the hex-stringified ciphertext suitable for on-chain storage.
|
|
387
|
+
*/
|
|
388
|
+
declare function encryptPaymentAddress(input: EncryptPaymentAddressInput): ResultAsync<string, OrdersError>;
|
|
389
|
+
interface DecryptPaymentAddressInput {
|
|
390
|
+
readonly encrypted: string;
|
|
391
|
+
readonly recipientIdentity: RelayIdentity;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Decrypts a ciphertext produced by `encryptPaymentAddress` using the recipient
|
|
395
|
+
* relay identity's private key. Returns the plaintext payment address.
|
|
396
|
+
*/
|
|
397
|
+
declare function decryptPaymentAddress(input: DecryptPaymentAddressInput): ResultAsync<string, OrdersError>;
|
|
398
|
+
|
|
399
|
+
export { type ApproveUsdcParams, type CancelOrderParams, type DisputeStatus, type ExecuteBase, type FeeConfig, type GetFeeConfigParams, type GetOrderParams, type GetOrdersParams, type Order, type OrderEvent, type OrderStatus, type OrderType, type OrdersClient, type OrdersConfig, OrdersError, type OrdersErrorCode, type PaidBuyOrderAction, type PaidBuyOrderParams, type PlaceOrderParams, type PreparedTx, type PreparedTxMeta, type RaiseDisputeParams, type RelayIdentity, type RelayIdentityStore, type SetSellOrderUpiParams, type TxResult, type TxResultMeta, type WatchEventsParams, cipherParse, cipherStringify, createInMemoryRelayStore, createLocalStorageRelayStore, createOrders, createRelayIdentity, decryptPaymentAddress, encryptPaymentAddress };
|