@p2pdotme/sdk 1.0.5 → 1.1.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.
Files changed (66) hide show
  1. package/README.md +103 -41
  2. package/dist/country.cjs +9 -2
  3. package/dist/country.cjs.map +1 -1
  4. package/dist/country.d.cts +35 -10
  5. package/dist/country.d.ts +35 -10
  6. package/dist/country.mjs +6 -2
  7. package/dist/country.mjs.map +1 -1
  8. package/dist/fraud-engine.cjs +52 -48
  9. package/dist/fraud-engine.cjs.map +1 -1
  10. package/dist/fraud-engine.mjs +46 -42
  11. package/dist/fraud-engine.mjs.map +1 -1
  12. package/dist/index.cjs +4 -14
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +41 -36
  15. package/dist/index.d.ts +41 -36
  16. package/dist/index.mjs +4 -12
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/orders.cjs +5961 -0
  19. package/dist/orders.cjs.map +1 -0
  20. package/dist/orders.d.cts +620 -0
  21. package/dist/orders.d.ts +620 -0
  22. package/dist/orders.mjs +5911 -0
  23. package/dist/orders.mjs.map +1 -0
  24. package/dist/prices.cjs +1432 -0
  25. package/dist/prices.cjs.map +1 -0
  26. package/dist/prices.d.cts +109 -0
  27. package/dist/prices.d.ts +109 -0
  28. package/dist/prices.mjs +1404 -0
  29. package/dist/prices.mjs.map +1 -0
  30. package/dist/profile.cjs +899 -69
  31. package/dist/profile.cjs.map +1 -1
  32. package/dist/profile.d.cts +39 -27
  33. package/dist/profile.d.ts +39 -27
  34. package/dist/profile.mjs +892 -62
  35. package/dist/profile.mjs.map +1 -1
  36. package/dist/qr-parsers.cjs +88 -7
  37. package/dist/qr-parsers.cjs.map +1 -1
  38. package/dist/qr-parsers.d.cts +38 -16
  39. package/dist/qr-parsers.d.ts +38 -16
  40. package/dist/qr-parsers.mjs +88 -7
  41. package/dist/qr-parsers.mjs.map +1 -1
  42. package/dist/react.cjs +2955 -1105
  43. package/dist/react.cjs.map +1 -1
  44. package/dist/react.d.cts +384 -104
  45. package/dist/react.d.ts +384 -104
  46. package/dist/react.mjs +2841 -992
  47. package/dist/react.mjs.map +1 -1
  48. package/dist/zkkyc.cjs +405 -24
  49. package/dist/zkkyc.cjs.map +1 -1
  50. package/dist/zkkyc.d.cts +14 -9
  51. package/dist/zkkyc.d.ts +14 -9
  52. package/dist/zkkyc.mjs +405 -24
  53. package/dist/zkkyc.mjs.map +1 -1
  54. package/package.json +12 -12
  55. package/dist/order-routing.cjs +0 -888
  56. package/dist/order-routing.cjs.map +0 -1
  57. package/dist/order-routing.d.cts +0 -68
  58. package/dist/order-routing.d.ts +0 -68
  59. package/dist/order-routing.mjs +0 -860
  60. package/dist/order-routing.mjs.map +0 -1
  61. package/dist/payload.cjs +0 -3168
  62. package/dist/payload.cjs.map +0 -1
  63. package/dist/payload.d.cts +0 -147
  64. package/dist/payload.d.ts +0 -147
  65. package/dist/payload.mjs +0 -3124
  66. package/dist/payload.mjs.map +0 -1
package/dist/react.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as neverthrow from 'neverthrow';
2
2
  import { Result, ResultAsync } from 'neverthrow';
3
- import { Address } from 'viem';
4
- import z$1, { z } from 'zod';
3
+ import { Address, WalletClient, TransactionReceipt } from 'viem';
4
+ import { z } from 'zod';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { ReactNode } from 'react';
7
7
 
@@ -16,10 +16,6 @@ declare class SdkError<TCode extends string = string> extends Error {
16
16
  });
17
17
  }
18
18
 
19
- declare const ZodCurrencySchema: z.ZodEnum<{
20
- [x: string]: string;
21
- }>;
22
-
23
19
  type ZkkycErrorCode = "VALIDATION_ERROR" | "CONTRACT_READ_ERROR" | "ENCODE_ERROR" | "RECLAIM_INIT_FAILED" | "RECLAIM_SESSION_NOT_FOUND" | "RECLAIM_PROOF_GENERATION_FAILED" | "RECLAIM_PROOF_INVALID" | "RECLAIM_POLLING_ABORTED" | "ZK_PASSPORT_INIT_FAILED" | "ZK_PASSPORT_REJECTED" | "ZK_PASSPORT_VERIFICATION_FAILED" | "ZK_PASSPORT_ABORTED" | "PEER_DEPENDENCY_MISSING";
24
20
  declare class ZkkycError extends SdkError<ZkkycErrorCode> {
25
21
  constructor(message: string, options: {
@@ -93,36 +89,10 @@ interface Zkkyc {
93
89
  }, ZkkycError>;
94
90
  }
95
91
 
96
- type PayloadErrorCode = "VALIDATION_ERROR" | "CIRCLE_SELECTION_ERROR" | "ENCRYPTION_ERROR" | "DECRYPTION_ERROR";
97
- declare class PayloadError extends SdkError<PayloadErrorCode> {
98
- constructor(message: string, options: {
99
- code: PayloadErrorCode;
100
- cause?: unknown;
101
- context?: Record<string, unknown>;
102
- });
103
- }
104
-
105
- type OrderRoutingErrorCode = "NO_ELIGIBLE_CIRCLES" | "SUBGRAPH_ERROR" | "SUBGRAPH_NOT_CONFIGURED" | "VALIDATION_ERROR" | "CONTRACT_READ_ERROR";
106
- declare class OrderRoutingError extends SdkError<OrderRoutingErrorCode> {
107
- constructor(message: string, options: {
108
- code: OrderRoutingErrorCode;
109
- cause?: unknown;
110
- context?: Record<string, unknown>;
111
- });
112
- }
113
-
114
- interface Logger {
115
- debug(message: string, data?: Record<string, unknown>): void;
116
- info(message: string, data?: Record<string, unknown>): void;
117
- warn(message: string, data?: Record<string, unknown>): void;
118
- error(message: string, data?: Record<string, unknown>): void;
119
- }
120
-
121
- type CurrencyType = z$1.infer<typeof ZodCurrencySchema>;
122
-
123
92
  /**
124
93
  * Minimal viem PublicClient interface — consumers pass their own client.
125
- * The SDK only needs `readContract` for on-chain reads.
94
+ * The SDK uses `readContract` for single reads and `multicall` where available
95
+ * to batch multiple reads into one RPC round-trip.
126
96
  */
127
97
  interface PublicClientLike {
128
98
  readContract(args: {
@@ -131,68 +101,361 @@ interface PublicClientLike {
131
101
  functionName: string;
132
102
  args: readonly unknown[];
133
103
  }): Promise<unknown>;
104
+ multicall?(args: {
105
+ contracts: readonly {
106
+ address: Address;
107
+ abi: readonly unknown[];
108
+ functionName: string;
109
+ args?: readonly unknown[];
110
+ }[];
111
+ allowFailure?: boolean;
112
+ }): Promise<readonly unknown[]>;
134
113
  }
135
114
 
136
- interface SelectCircleParams {
137
- readonly currency: string;
138
- readonly user: Address;
139
- readonly usdtAmount: bigint;
140
- readonly fiatAmount: bigint;
141
- readonly orderType: bigint;
142
- readonly preferredPCConfigId: bigint;
115
+ 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";
116
+ declare class OrdersError extends SdkError<OrdersErrorCode> {
117
+ constructor(message: string, options: {
118
+ code: OrdersErrorCode;
119
+ cause?: unknown;
120
+ context?: Record<string, unknown>;
121
+ });
143
122
  }
144
123
 
145
- interface OrderRouter {
146
- /**
147
- * Full flow: fetch circles from subgraph → epsilon-greedy selection →
148
- * on-chain eligibility validation return circleId.
149
- */
150
- selectCircle(params: SelectCircleParams): ResultAsync<bigint, OrderRoutingError>;
124
+ interface Logger {
125
+ debug(message: string, data?: Record<string, unknown>): void;
126
+ info(message: string, data?: Record<string, unknown>): void;
127
+ warn(message: string, data?: Record<string, unknown>): void;
128
+ error(message: string, data?: Record<string, unknown>): void;
151
129
  }
152
130
 
153
- interface PlaceOrderPayload {
154
- readonly pubKey: string;
155
- readonly amount: bigint;
156
- readonly recipientAddr: `0x${string}`;
157
- readonly orderType: number;
158
- readonly userUpi: string;
159
- readonly userPubKey: string;
160
- readonly currency: CurrencyType;
161
- readonly preferredPaymentChannelConfigId: bigint;
162
- readonly fiatAmountLimit: bigint;
163
- readonly circleId: bigint;
131
+ interface RelayIdentity {
132
+ readonly address: `0x${string}`;
133
+ readonly publicKey: string;
134
+ readonly privateKey: `0x${string}`;
164
135
  }
165
- interface SetSellOrderUpiPayload {
166
- readonly orderId: number;
167
- readonly userEncUpi: string;
168
- readonly updatedAmount: bigint;
136
+
137
+ interface RelayIdentityStore {
138
+ get(): Promise<RelayIdentity | null>;
139
+ set(identity: RelayIdentity): Promise<void>;
169
140
  }
170
141
 
142
+ declare const ZodGetOrderParamsSchema: z.ZodObject<{
143
+ orderId: z.ZodBigInt;
144
+ }, z.core.$strip>;
145
+ type GetOrderParams = z.infer<typeof ZodGetOrderParamsSchema>;
146
+ declare const ZodGetFeeConfigParamsSchema: z.ZodObject<{
147
+ currency: z.ZodEnum<{
148
+ IDR: "IDR";
149
+ INR: "INR";
150
+ BRL: "BRL";
151
+ ARS: "ARS";
152
+ MEX: "MEX";
153
+ VEN: "VEN";
154
+ EUR: "EUR";
155
+ NGN: "NGN";
156
+ USD: "USD";
157
+ COP: "COP";
158
+ }>;
159
+ }, z.core.$strip>;
160
+ type GetFeeConfigParams = z.infer<typeof ZodGetFeeConfigParamsSchema>;
161
+ declare const ZodGetOrdersParamsSchema: z.ZodObject<{
162
+ userAddress: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
163
+ skip: z.ZodDefault<z.ZodNumber>;
164
+ limit: z.ZodDefault<z.ZodNumber>;
165
+ }, z.core.$strip>;
166
+ type GetOrdersParams = z.input<typeof ZodGetOrdersParamsSchema>;
171
167
  declare const ZodPlaceOrderParamsSchema: z.ZodObject<{
172
- amount: z.ZodBigInt;
173
- recipientAddr: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
174
168
  orderType: z.ZodNumber;
175
169
  currency: z.ZodEnum<{
176
- [x: string]: string;
170
+ IDR: "IDR";
171
+ INR: "INR";
172
+ BRL: "BRL";
173
+ ARS: "ARS";
174
+ MEX: "MEX";
175
+ VEN: "VEN";
176
+ EUR: "EUR";
177
+ NGN: "NGN";
178
+ USD: "USD";
179
+ COP: "COP";
177
180
  }>;
178
- fiatAmount: z.ZodBigInt;
179
181
  user: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
180
- pubKey: z.ZodOptional<z.ZodString>;
181
- preferredPaymentChannelConfigId: z.ZodOptional<z.ZodBigInt>;
182
+ amount: z.ZodBigInt;
183
+ fiatAmount: z.ZodBigInt;
182
184
  fiatAmountLimit: z.ZodDefault<z.ZodOptional<z.ZodBigInt>>;
185
+ recipientAddr: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
186
+ preferredPaymentChannelConfigId: z.ZodOptional<z.ZodBigInt>;
187
+ pubKey: z.ZodOptional<z.ZodString>;
183
188
  }, z.core.$strip>;
184
189
  type PlaceOrderParams = z.input<typeof ZodPlaceOrderParamsSchema>;
190
+ declare const ZodCancelOrderParamsSchema: z.ZodObject<{
191
+ orderId: z.ZodBigInt;
192
+ }, z.core.$strip>;
193
+ type CancelOrderParams = z.infer<typeof ZodCancelOrderParamsSchema>;
185
194
  declare const ZodSetSellOrderUpiParamsSchema: z.ZodObject<{
186
- orderId: z.ZodNumber;
195
+ orderId: z.ZodBigInt;
187
196
  paymentAddress: z.ZodString;
188
197
  merchantPublicKey: z.ZodString;
189
198
  updatedAmount: z.ZodBigInt;
190
199
  }, z.core.$strip>;
191
200
  type SetSellOrderUpiParams = z.infer<typeof ZodSetSellOrderUpiParamsSchema>;
201
+ declare const ZodRaiseDisputeParamsSchema: z.ZodObject<{
202
+ orderId: z.ZodBigInt;
203
+ redactTransId: z.ZodBigInt;
204
+ }, z.core.$strip>;
205
+ type RaiseDisputeParams = z.infer<typeof ZodRaiseDisputeParamsSchema>;
206
+ declare const ZodApproveUsdcParamsSchema: z.ZodObject<{
207
+ amount: z.ZodBigInt;
208
+ }, z.core.$strip>;
209
+ type ApproveUsdcParams = z.infer<typeof ZodApproveUsdcParamsSchema>;
210
+ declare const ZodPaidBuyOrderParamsSchema: z.ZodObject<{
211
+ orderId: z.ZodBigInt;
212
+ }, z.core.$strip>;
213
+ type PaidBuyOrderParams = z.infer<typeof ZodPaidBuyOrderParamsSchema>;
214
+
215
+ type OrderType = "buy" | "sell" | "pay";
216
+ type OrderStatus = "placed" | "accepted" | "paid" | "completed" | "cancelled";
217
+ type DisputeStatus = "none" | "open" | "resolved";
218
+ /**
219
+ * Normalized order record returned by both `getOrder` and `getOrders`.
220
+ * Amounts are 6-decimal bigints; timestamps are unix seconds.
221
+ */
222
+ interface Order {
223
+ orderId: bigint;
224
+ type: OrderType;
225
+ status: OrderStatus;
226
+ usdcAmount: bigint;
227
+ fiatAmount: bigint;
228
+ actualUsdcAmount: bigint;
229
+ actualFiatAmount: bigint;
230
+ currency: string;
231
+ user: Address;
232
+ recipient: Address;
233
+ acceptedMerchant: Address;
234
+ placedAt: bigint;
235
+ acceptedAt: bigint;
236
+ paidAt: bigint;
237
+ completedAt: bigint;
238
+ circleId: bigint;
239
+ fixedFeePaid: bigint;
240
+ tipsPaid: bigint;
241
+ disputeStatus: DisputeStatus;
242
+ /**
243
+ * Encrypted UPI / payment address that the merchant published for this order
244
+ * (set when the merchant accepts a buy order). Empty string until set.
245
+ * Decrypt with `decryptPaymentAddress`.
246
+ */
247
+ encUpi: string;
248
+ /**
249
+ * Encrypted merchant UPI for the seller-side flow (set by `setSellOrderUpi`).
250
+ * Empty string until set.
251
+ */
252
+ encMerchantUpi: string;
253
+ /** Public key associated with the order, used for ECIES encryption setup. */
254
+ pubkey: string;
255
+ }
256
+ /**
257
+ * Per-currency small-order fee config read from the Diamond.
258
+ * Amounts are 6-decimal bigints.
259
+ */
260
+ interface FeeConfig {
261
+ /** Order amounts at or below this threshold are billed the fixed fee. */
262
+ smallOrderThreshold: bigint;
263
+ /** Fixed fee applied to small orders (6 decimals). */
264
+ smallOrderFixedFee: bigint;
265
+ }
266
+ interface PreparedTxMeta {
267
+ readonly circleId?: bigint;
268
+ readonly relayIdentity?: RelayIdentity;
269
+ }
270
+ interface PreparedTx {
271
+ readonly to: `0x${string}`;
272
+ readonly data: `0x${string}`;
273
+ readonly value: bigint;
274
+ readonly meta?: PreparedTxMeta;
275
+ }
276
+ interface TxResultMeta extends PreparedTxMeta {
277
+ /**
278
+ * Populated on `placeOrder.execute({ waitForReceipt: true })` — the orderId
279
+ * parsed from the `OrderPlaced` event in the receipt's logs. Undefined when
280
+ * `waitForReceipt` is not set (no receipt means no logs to parse).
281
+ */
282
+ readonly orderId?: bigint;
283
+ }
284
+ interface TxResult {
285
+ readonly hash: `0x${string}`;
286
+ readonly receipt?: TransactionReceipt;
287
+ readonly meta?: TxResultMeta;
288
+ }
289
+ interface ExecuteBase {
290
+ readonly walletClient: WalletClient;
291
+ readonly waitForReceipt?: boolean;
292
+ }
293
+ type OrderEvent = {
294
+ readonly type: "placed";
295
+ readonly orderId: bigint;
296
+ readonly user: Address;
297
+ readonly orderType: 0 | 1 | 2;
298
+ readonly blockNumber: bigint;
299
+ readonly txHash: `0x${string}`;
300
+ } | {
301
+ readonly type: "accepted";
302
+ readonly orderId: bigint;
303
+ readonly merchant: Address;
304
+ readonly blockNumber: bigint;
305
+ readonly txHash: `0x${string}`;
306
+ } | {
307
+ readonly type: "paid";
308
+ readonly orderId: bigint;
309
+ readonly blockNumber: bigint;
310
+ readonly txHash: `0x${string}`;
311
+ } | {
312
+ readonly type: "completed";
313
+ readonly orderId: bigint;
314
+ readonly blockNumber: bigint;
315
+ readonly txHash: `0x${string}`;
316
+ } | {
317
+ readonly type: "cancelled";
318
+ readonly orderId: bigint;
319
+ readonly blockNumber: bigint;
320
+ readonly txHash: `0x${string}`;
321
+ };
322
+
323
+ interface ApproveUsdcAction {
324
+ prepare(params: ApproveUsdcParams): ResultAsync<PreparedTx, OrdersError>;
325
+ execute(params: ApproveUsdcParams & ExecuteBase): ResultAsync<TxResult, OrdersError>;
326
+ }
327
+
328
+ interface CancelOrderAction {
329
+ prepare(params: CancelOrderParams): ResultAsync<PreparedTx, OrdersError>;
330
+ execute(params: CancelOrderParams & ExecuteBase): ResultAsync<TxResult, OrdersError>;
331
+ }
332
+
333
+ interface PaidBuyOrderAction {
334
+ prepare(params: PaidBuyOrderParams): ResultAsync<PreparedTx, OrdersError>;
335
+ execute(params: PaidBuyOrderParams & ExecuteBase): ResultAsync<TxResult, OrdersError>;
336
+ }
337
+
338
+ interface PlaceOrderAction {
339
+ prepare(params: PlaceOrderParams): ResultAsync<PreparedTx, OrdersError>;
340
+ execute(params: PlaceOrderParams & ExecuteBase): ResultAsync<TxResult, OrdersError>;
341
+ }
342
+
343
+ interface RaiseDisputeAction {
344
+ prepare(params: RaiseDisputeParams): ResultAsync<PreparedTx, OrdersError>;
345
+ execute(params: RaiseDisputeParams & ExecuteBase): ResultAsync<TxResult, OrdersError>;
346
+ }
347
+
348
+ interface SetSellOrderUpiAction {
349
+ prepare(params: SetSellOrderUpiParams): ResultAsync<PreparedTx, OrdersError>;
350
+ execute(params: SetSellOrderUpiParams & ExecuteBase): ResultAsync<TxResult, OrdersError>;
351
+ }
352
+
353
+ interface WatchEventsParams {
354
+ readonly user?: Address;
355
+ readonly onEvent: (event: OrderEvent) => void;
356
+ readonly onError?: (error: OrdersError) => void;
357
+ }
358
+ type WatchEvents = (params: WatchEventsParams) => () => void;
359
+
360
+ interface OrdersClient {
361
+ /** Reads a single order by id from the Diamond contract. */
362
+ getOrder(params: GetOrderParams): ResultAsync<Order, OrdersError>;
363
+ /**
364
+ * Lists orders created by `userAddress` from the subgraph, newest first.
365
+ * Defaults: `skip = 0`, `limit = 20`. Max `limit` is 100.
366
+ */
367
+ getOrders(params: GetOrdersParams): ResultAsync<Order[], OrdersError>;
368
+ /**
369
+ * Reads the per-currency small-order fee config from the Diamond via
370
+ * multicall: threshold (below which the fixed fee applies) and the fixed
371
+ * fee itself. Both are 6-decimal bigints.
372
+ */
373
+ getFeeConfig(params: GetFeeConfigParams): ResultAsync<FeeConfig, OrdersError>;
374
+ readonly placeOrder: PlaceOrderAction;
375
+ readonly cancelOrder: CancelOrderAction;
376
+ readonly setSellOrderUpi: SetSellOrderUpiAction;
377
+ readonly raiseDispute: RaiseDisputeAction;
378
+ readonly approveUsdc: ApproveUsdcAction;
379
+ readonly paidBuyOrder: PaidBuyOrderAction;
380
+ watchEvents: WatchEvents;
381
+ /**
382
+ * Decrypts an `encUpi` / `encMerchantUpi` ciphertext from an order using the
383
+ * relay identity resolved from the configured store. Returns the plaintext
384
+ * payment address.
385
+ */
386
+ decryptPaymentAddress(params: {
387
+ encrypted: string;
388
+ }): ResultAsync<string, OrdersError>;
389
+ /**
390
+ * Signs `paymentAddress` with the resolved relay identity and ECIES-encrypts
391
+ * the payload for `recipientPublicKey`. Returns the hex-stringified ciphertext
392
+ * suitable for on-chain storage (e.g. as the merchant's encUpi when calling
393
+ * `setSellOrderUpi`).
394
+ */
395
+ encryptPaymentAddress(params: {
396
+ paymentAddress: string;
397
+ recipientPublicKey: string;
398
+ }): ResultAsync<string, OrdersError>;
399
+ }
400
+
401
+ type PricesErrorCode = "VALIDATION_ERROR" | "CONTRACT_READ_ERROR";
402
+ declare class PricesError extends SdkError<PricesErrorCode> {
403
+ constructor(message: string, options: {
404
+ code: PricesErrorCode;
405
+ cause?: unknown;
406
+ context?: Record<string, unknown>;
407
+ });
408
+ }
409
+
410
+ /**
411
+ * Shared param shape for every currency-scoped read in this module
412
+ * (`getPriceConfig`, `getReputationPerUsdcLimit`). All methods take `{ currency }`.
413
+ */
414
+ declare const ZodCurrencyScopedParamsSchema: z.ZodObject<{
415
+ currency: z.ZodEnum<{
416
+ IDR: "IDR";
417
+ INR: "INR";
418
+ BRL: "BRL";
419
+ ARS: "ARS";
420
+ MEX: "MEX";
421
+ VEN: "VEN";
422
+ EUR: "EUR";
423
+ NGN: "NGN";
424
+ USD: "USD";
425
+ COP: "COP";
426
+ }>;
427
+ }, z.core.$strip>;
428
+ type CurrencyScopedParams = z.infer<typeof ZodCurrencyScopedParamsSchema>;
192
429
 
193
- interface PayloadGenerator {
194
- placeOrder(params: PlaceOrderParams): ResultAsync<PlaceOrderPayload, PayloadError>;
195
- setSellOrderUpi(params: SetSellOrderUpiParams): ResultAsync<SetSellOrderUpiPayload, PayloadError>;
430
+ interface PriceConfig {
431
+ readonly buyPrice: bigint;
432
+ readonly sellPrice: bigint;
433
+ readonly buyPriceOffset: bigint;
434
+ readonly baseSpread: bigint;
435
+ }
436
+ /**
437
+ * Per-currency USDC transaction limit granted per Reputation Point (RP).
438
+ * Default is 1 RP = 2 USDC everywhere except India (INR), which has its own
439
+ * multiplier set on-chain.
440
+ *
441
+ * multiplier = denominator / numerator // USDC per RP
442
+ */
443
+ interface ReputationLimit {
444
+ readonly numerator: bigint;
445
+ readonly denominator: bigint;
446
+ /** USDC per Reputation Point, computed from the rational form. */
447
+ readonly multiplier: number;
448
+ }
449
+
450
+ interface Prices {
451
+ /** Reads buy/sell price config for a given currency (raw bigint, 6 decimals). */
452
+ getPriceConfig(params: CurrencyScopedParams): ResultAsync<PriceConfig, PricesError>;
453
+ /**
454
+ * Reads the per-currency USDC transaction limit granted per Reputation Point
455
+ * (RP). Default is 1 RP = 2 USDC everywhere except INR, which uses its own
456
+ * on-chain multiplier.
457
+ */
458
+ getReputationPerUsdcLimit(params: CurrencyScopedParams): ResultAsync<ReputationLimit, PricesError>;
196
459
  }
197
460
 
198
461
  type ProfileErrorCode = "VALIDATION_ERROR" | "CONTRACT_READ_ERROR";
@@ -208,37 +471,47 @@ declare const ZodUsdcBalanceParamsSchema: z.ZodObject<{
208
471
  address: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
209
472
  }, z.core.$strip>;
210
473
  type UsdcBalanceParams = z.infer<typeof ZodUsdcBalanceParamsSchema>;
474
+ declare const ZodUsdcAllowanceParamsSchema: z.ZodObject<{
475
+ owner: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
476
+ }, z.core.$strip>;
477
+ type UsdcAllowanceParams = z.infer<typeof ZodUsdcAllowanceParamsSchema>;
211
478
  declare const ZodGetBalancesParamsSchema: z.ZodObject<{
212
479
  address: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
213
480
  currency: z.ZodEnum<{
214
- [x: string]: string;
481
+ IDR: "IDR";
482
+ INR: "INR";
483
+ BRL: "BRL";
484
+ ARS: "ARS";
485
+ MEX: "MEX";
486
+ VEN: "VEN";
487
+ EUR: "EUR";
488
+ NGN: "NGN";
489
+ USD: "USD";
490
+ COP: "COP";
215
491
  }>;
216
492
  }, z.core.$strip>;
217
493
  type GetBalancesParams = z.infer<typeof ZodGetBalancesParamsSchema>;
218
494
  declare const ZodTxLimitsParamsSchema: z.ZodObject<{
219
495
  address: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
220
496
  currency: z.ZodEnum<{
221
- [x: string]: string;
497
+ IDR: "IDR";
498
+ INR: "INR";
499
+ BRL: "BRL";
500
+ ARS: "ARS";
501
+ MEX: "MEX";
502
+ VEN: "VEN";
503
+ EUR: "EUR";
504
+ NGN: "NGN";
505
+ USD: "USD";
506
+ COP: "COP";
222
507
  }>;
223
508
  }, z.core.$strip>;
224
509
  type TxLimitsParams = z.infer<typeof ZodTxLimitsParamsSchema>;
225
- declare const ZodPriceConfigParamsSchema: z.ZodObject<{
226
- currency: z.ZodEnum<{
227
- [x: string]: string;
228
- }>;
229
- }, z.core.$strip>;
230
- type PriceConfigParams = z.infer<typeof ZodPriceConfigParamsSchema>;
231
510
 
232
511
  interface TxLimits {
233
512
  readonly buyLimit: number;
234
513
  readonly sellLimit: number;
235
514
  }
236
- interface RpPerUsdtLimit {
237
- readonly numerator: bigint;
238
- readonly denominator: bigint;
239
- /** The USDC multiplier per RP: denominator / numerator. */
240
- readonly multiplier: number;
241
- }
242
515
 
243
516
  interface Balances {
244
517
  /** USDC balance formatted to a number. */
@@ -248,24 +521,16 @@ interface Balances {
248
521
  /** The sell price used for conversion. */
249
522
  readonly sellPrice: number;
250
523
  }
251
- interface PriceConfig {
252
- readonly buyPrice: bigint;
253
- readonly sellPrice: bigint;
254
- readonly buyPriceOffset: bigint;
255
- readonly baseSpread: bigint;
256
- }
257
524
 
258
525
  interface Profile {
259
526
  /** Reads the USDC balance for a given address (raw bigint, 6 decimals). */
260
527
  getUsdcBalance(params: UsdcBalanceParams): ResultAsync<bigint, ProfileError>;
261
- /** Reads buy/sell price config for a given currency (raw bigint, 6 decimals). */
262
- getPriceConfig(params: PriceConfigParams): ResultAsync<PriceConfig, ProfileError>;
528
+ /** Reads the USDC allowance `owner diamond` (raw bigint, 6 decimals). */
529
+ getUsdcAllowance(params: UsdcAllowanceParams): ResultAsync<bigint, ProfileError>;
263
530
  /** Fetches USDC and fiat balance in parallel for a given address and currency. */
264
531
  getBalances(params: GetBalancesParams): ResultAsync<Balances, ProfileError>;
265
532
  /** Reads buy and sell transaction limits for a given address and currency. */
266
533
  getTxLimits(params: TxLimitsParams): ResultAsync<TxLimits, ProfileError>;
267
- /** Reads the RP-to-USDC limit ratio for a given currency. */
268
- getRpPerUsdtLimitRational(params: PriceConfigParams): ResultAsync<RpPerUsdtLimit, ProfileError>;
269
534
  }
270
535
 
271
536
  type FraudEngineErrorCode = "API_ERROR" | "ENCRYPTION_ERROR" | "SIGNING_ERROR" | "VALIDATION_ERROR" | "NETWORK_ERROR" | "PLACE_ORDER_ERROR";
@@ -412,6 +677,10 @@ interface FraudEngineSdkConfig {
412
677
  readonly encryptionKey: string;
413
678
  readonly seonRegion?: string;
414
679
  }
680
+ interface OrdersSdkConfig {
681
+ readonly relayIdentityStore?: RelayIdentityStore;
682
+ readonly relayIdentity?: RelayIdentity;
683
+ }
415
684
  interface SdkConfig {
416
685
  readonly publicClient: PublicClientLike;
417
686
  readonly subgraphUrl: string;
@@ -419,18 +688,19 @@ interface SdkConfig {
419
688
  readonly usdcAddress: Address;
420
689
  readonly reputationManagerAddress?: Address;
421
690
  readonly fraudEngine?: FraudEngineSdkConfig;
691
+ readonly orders?: OrdersSdkConfig;
422
692
  readonly logger?: Logger;
423
693
  }
424
694
  interface Sdk {
425
695
  readonly profile: Profile;
426
- readonly orderRouter: OrderRouter;
427
- readonly payload: PayloadGenerator;
696
+ readonly prices: Prices;
697
+ readonly orders: OrdersClient;
428
698
  readonly zkkyc?: Zkkyc;
429
699
  readonly fraudEngine?: FraudEngine;
430
700
  }
431
701
 
432
702
  /**
433
- * Provides Profile, OrderRouter, PayloadGenerator, Zkkyc, and FraudEngine instances to all children.
703
+ * Provides Profile, Orders, Zkkyc, and FraudEngine instances to all children.
434
704
  *
435
705
  * Object props (`publicClient`, `logger`) are captured on mount and do **not** trigger
436
706
  * re-instantiation on subsequent renders. To swap them (e.g. switching chains), remount
@@ -450,15 +720,25 @@ declare function SdkProvider({ children, ...config }: SdkConfig & {
450
720
  declare function useSdk(): Sdk;
451
721
  /** Returns the Profile instance from the nearest SdkProvider. */
452
722
  declare function useProfile(): Profile;
453
- /** Returns the OrderRouter instance from the nearest SdkProvider. */
454
- declare function useOrderRouter(): OrderRouter;
455
- /** Returns the PayloadGenerator instance from the nearest SdkProvider. */
456
- declare function usePayloadGenerator(): PayloadGenerator;
723
+ /** Returns the Prices instance from the nearest SdkProvider. */
724
+ declare function usePrices(): Prices;
725
+ /** Returns the Orders instance from the nearest SdkProvider. */
726
+ declare function useOrders(): OrdersClient;
457
727
  /** Returns the Zkkyc instance from the nearest SdkProvider. */
458
728
  declare function useZkkyc(): Zkkyc;
459
729
  /** Returns the FraudEngine instance from the nearest SdkProvider. */
460
730
  declare function useFraudEngine(): FraudEngine;
461
731
 
732
+ /**
733
+ * Subscribes to Diamond order lifecycle events for the lifetime of the
734
+ * component. Unsubscribes automatically on unmount or when `user` changes.
735
+ *
736
+ * Callbacks are captured in refs so consumers may pass inline arrow
737
+ * functions without causing the underlying subscriptions to thrash on
738
+ * every render.
739
+ */
740
+ declare function useWatchOrders(params: WatchEventsParams): void;
741
+
462
742
  interface UseFingerprintResult {
463
743
  data: {
464
744
  visitorId: string;
@@ -469,4 +749,4 @@ interface UseFingerprintResult {
469
749
  }
470
750
  declare function useFingerprint(enabled: boolean): UseFingerprintResult;
471
751
 
472
- export { type FraudEngineSdkConfig, type SdkConfig, SdkProvider, useFingerprint, useFraudEngine, useOrderRouter, usePayloadGenerator, useProfile, useSdk, useZkkyc };
752
+ export { type FraudEngineSdkConfig, type OrdersSdkConfig, type SdkConfig, SdkProvider, useFingerprint, useFraudEngine, useOrders, usePrices, useProfile, useSdk, useWatchOrders, useZkkyc };