@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/index.d.cts CHANGED
@@ -1,37 +1,12 @@
1
- import z$1, { z } from 'zod';
2
1
  import { Address } from 'viem';
3
2
 
4
- declare class SdkError<TCode extends string = string> extends Error {
5
- readonly code: TCode;
6
- readonly cause?: unknown;
7
- readonly context?: Record<string, unknown>;
8
- constructor(message: string, options: {
9
- code: TCode;
10
- cause?: unknown;
11
- context?: Record<string, unknown>;
12
- });
13
- }
14
-
15
- declare const ZodCurrencySchema: z.ZodEnum<{
16
- [x: string]: string;
17
- }>;
18
-
19
- type CurrencyType = z$1.infer<typeof ZodCurrencySchema>;
20
-
21
3
  /**
22
- * Minimal viem PublicClient interface consumers pass their own client.
23
- * The SDK only needs `readContract` for on-chain reads.
4
+ * All supported currency symbols. Single source of truth for the SDK.
5
+ *
6
+ * Lives alongside the country metadata so that adding a currency is a
7
+ * single-folder operation: drop a new file in `currencies/<code>.ts`, add it
8
+ * to this map, and both `COUNTRY_OPTIONS` and `ZodCurrencySchema` pick it up.
24
9
  */
25
- interface PublicClientLike {
26
- readContract(args: {
27
- address: Address;
28
- abi: readonly unknown[];
29
- functionName: string;
30
- args: readonly unknown[];
31
- }): Promise<unknown>;
32
- }
33
-
34
- /** All supported currency symbols. Single source of truth for the SDK. */
35
10
  declare const CURRENCY: {
36
11
  readonly IDR: "IDR";
37
12
  readonly INR: "INR";
@@ -44,13 +19,43 @@ declare const CURRENCY: {
44
19
  readonly USD: "USD";
45
20
  readonly COP: "COP";
46
21
  };
22
+ /** Union of supported currency codes. */
23
+ type CurrencyCode = (typeof CURRENCY)[keyof typeof CURRENCY];
47
24
 
48
- declare const ORDER_TYPE: {
49
- readonly BUY: 0;
50
- readonly SELL: 1;
51
- readonly PAY: 2;
52
- };
25
+ /**
26
+ * Minimal viem PublicClient interface — consumers pass their own client.
27
+ * The SDK uses `readContract` for single reads and `multicall` where available
28
+ * to batch multiple reads into one RPC round-trip.
29
+ */
30
+ interface PublicClientLike {
31
+ readContract(args: {
32
+ address: Address;
33
+ abi: readonly unknown[];
34
+ functionName: string;
35
+ args: readonly unknown[];
36
+ }): Promise<unknown>;
37
+ multicall?(args: {
38
+ contracts: readonly {
39
+ address: Address;
40
+ abi: readonly unknown[];
41
+ functionName: string;
42
+ args?: readonly unknown[];
43
+ }[];
44
+ allowFailure?: boolean;
45
+ }): Promise<readonly unknown[]>;
46
+ }
47
+
48
+ declare class SdkError<TCode extends string = string> extends Error {
49
+ readonly code: TCode;
50
+ readonly cause?: unknown;
51
+ readonly context?: Record<string, unknown>;
52
+ constructor(message: string, options: {
53
+ code: TCode;
54
+ cause?: unknown;
55
+ context?: Record<string, unknown>;
56
+ });
57
+ }
53
58
 
54
59
  declare const VERSION: string;
55
60
 
56
- export { CURRENCY, type CurrencyType, ORDER_TYPE, type PublicClientLike, SdkError, VERSION };
61
+ export { type CurrencyCode, type PublicClientLike, SdkError, VERSION };
package/dist/index.d.ts CHANGED
@@ -1,37 +1,12 @@
1
- import z$1, { z } from 'zod';
2
1
  import { Address } from 'viem';
3
2
 
4
- declare class SdkError<TCode extends string = string> extends Error {
5
- readonly code: TCode;
6
- readonly cause?: unknown;
7
- readonly context?: Record<string, unknown>;
8
- constructor(message: string, options: {
9
- code: TCode;
10
- cause?: unknown;
11
- context?: Record<string, unknown>;
12
- });
13
- }
14
-
15
- declare const ZodCurrencySchema: z.ZodEnum<{
16
- [x: string]: string;
17
- }>;
18
-
19
- type CurrencyType = z$1.infer<typeof ZodCurrencySchema>;
20
-
21
3
  /**
22
- * Minimal viem PublicClient interface consumers pass their own client.
23
- * The SDK only needs `readContract` for on-chain reads.
4
+ * All supported currency symbols. Single source of truth for the SDK.
5
+ *
6
+ * Lives alongside the country metadata so that adding a currency is a
7
+ * single-folder operation: drop a new file in `currencies/<code>.ts`, add it
8
+ * to this map, and both `COUNTRY_OPTIONS` and `ZodCurrencySchema` pick it up.
24
9
  */
25
- interface PublicClientLike {
26
- readContract(args: {
27
- address: Address;
28
- abi: readonly unknown[];
29
- functionName: string;
30
- args: readonly unknown[];
31
- }): Promise<unknown>;
32
- }
33
-
34
- /** All supported currency symbols. Single source of truth for the SDK. */
35
10
  declare const CURRENCY: {
36
11
  readonly IDR: "IDR";
37
12
  readonly INR: "INR";
@@ -44,13 +19,43 @@ declare const CURRENCY: {
44
19
  readonly USD: "USD";
45
20
  readonly COP: "COP";
46
21
  };
22
+ /** Union of supported currency codes. */
23
+ type CurrencyCode = (typeof CURRENCY)[keyof typeof CURRENCY];
47
24
 
48
- declare const ORDER_TYPE: {
49
- readonly BUY: 0;
50
- readonly SELL: 1;
51
- readonly PAY: 2;
52
- };
25
+ /**
26
+ * Minimal viem PublicClient interface — consumers pass their own client.
27
+ * The SDK uses `readContract` for single reads and `multicall` where available
28
+ * to batch multiple reads into one RPC round-trip.
29
+ */
30
+ interface PublicClientLike {
31
+ readContract(args: {
32
+ address: Address;
33
+ abi: readonly unknown[];
34
+ functionName: string;
35
+ args: readonly unknown[];
36
+ }): Promise<unknown>;
37
+ multicall?(args: {
38
+ contracts: readonly {
39
+ address: Address;
40
+ abi: readonly unknown[];
41
+ functionName: string;
42
+ args?: readonly unknown[];
43
+ }[];
44
+ allowFailure?: boolean;
45
+ }): Promise<readonly unknown[]>;
46
+ }
47
+
48
+ declare class SdkError<TCode extends string = string> extends Error {
49
+ readonly code: TCode;
50
+ readonly cause?: unknown;
51
+ readonly context?: Record<string, unknown>;
52
+ constructor(message: string, options: {
53
+ code: TCode;
54
+ cause?: unknown;
55
+ context?: Record<string, unknown>;
56
+ });
57
+ }
53
58
 
54
59
  declare const VERSION: string;
55
60
 
56
- export { CURRENCY, type CurrencyType, ORDER_TYPE, type PublicClientLike, SdkError, VERSION };
61
+ export { type CurrencyCode, type PublicClientLike, SdkError, VERSION };
package/dist/index.mjs CHANGED
@@ -17,7 +17,7 @@ import { err, ok } from "neverthrow";
17
17
  import { isAddress } from "viem";
18
18
  import { z } from "zod";
19
19
 
20
- // src/constants/currencies.constant.ts
20
+ // src/country/currency.ts
21
21
  var CURRENCY = {
22
22
  IDR: "IDR",
23
23
  INR: "INR",
@@ -30,23 +30,15 @@ var CURRENCY = {
30
30
  USD: "USD",
31
31
  COP: "COP"
32
32
  };
33
-
34
- // src/constants/orders.constant.ts
35
- var ORDER_TYPE = {
36
- BUY: 0,
37
- SELL: 1,
38
- PAY: 2
39
- };
33
+ var CURRENCY_CODES = Object.values(CURRENCY);
40
34
 
41
35
  // src/validation/schemas.validation.ts
42
36
  var ZodAddressSchema = z.string().refine((s) => isAddress(s), { message: "Invalid Ethereum address" });
43
- var ZodCurrencySchema = z.enum(Object.values(CURRENCY));
37
+ var ZodCurrencySchema = z.enum(CURRENCY_CODES);
44
38
 
45
39
  // src/index.ts
46
- var VERSION = "1.0.5";
40
+ var VERSION = "1.1.1";
47
41
  export {
48
- CURRENCY,
49
- ORDER_TYPE,
50
42
  SdkError,
51
43
  VERSION
52
44
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/validation/errors.validation.ts","../src/validation/schemas.validation.ts","../src/constants/currencies.constant.ts","../src/constants/orders.constant.ts","../src/index.ts"],"sourcesContent":["export class SdkError<TCode extends string = string> extends Error {\n\treadonly code: TCode;\n\treadonly cause?: unknown;\n\treadonly context?: Record<string, unknown>;\n\n\tconstructor(\n\t\tmessage: string,\n\t\toptions: {\n\t\t\tcode: TCode;\n\t\t\tcause?: unknown;\n\t\t\tcontext?: Record<string, unknown>;\n\t\t},\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"SdkError\";\n\t\tthis.code = options.code;\n\t\tthis.cause = options.cause;\n\t\tthis.context = options.context;\n\t}\n}\n","import { err, ok, type Result } from \"neverthrow\";\nimport { isAddress } from \"viem\";\nimport { z } from \"zod\";\nimport { CURRENCY } from \"../constants\";\n\nexport const ZodAddressSchema = z\n\t.string()\n\t.refine((s) => isAddress(s), { message: \"Invalid Ethereum address\" });\n\nexport const ZodCurrencySchema = z.enum(Object.values(CURRENCY) as [string, ...string[]]);\n\nexport function validate<S extends z.ZodType, E>(\n\tschema: S,\n\tdata: unknown,\n\ttoError: (message: string, cause: unknown, data: unknown) => E,\n): Result<z.infer<S>, E> {\n\tconst result = schema.safeParse(data);\n\tif (result.success) {\n\t\treturn ok(result.data as z.infer<S>);\n\t}\n\treturn err(toError(z.prettifyError(result.error), result.error, data));\n}\n","/** All supported currency symbols. Single source of truth for the SDK. */\nexport const CURRENCY = {\n\tIDR: \"IDR\",\n\tINR: \"INR\",\n\tBRL: \"BRL\",\n\tARS: \"ARS\",\n\tMEX: \"MEX\",\n\tVEN: \"VEN\",\n\tEUR: \"EUR\",\n\tNGN: \"NGN\",\n\tUSD: \"USD\",\n\tCOP: \"COP\",\n} as const;\n","export const ORDER_TYPE = {\n\tBUY: 0,\n\tSELL: 1,\n\tPAY: 2,\n} as const;\n","// ── Version ──────────────────────────────────────────────────────────────\n\ndeclare const __SDK_VERSION__: string;\nexport const VERSION: string = __SDK_VERSION__;\n\n// ── Shared types ─────────────────────────────────────────────────────────\n\nexport type { CurrencyType, PublicClientLike } from \"./types\";\n\n// ── Shared errors ────────────────────────────────────────────────────────\n\nexport { SdkError } from \"./validation\";\n\n// ── Constants ────────────────────────────────────────────────────────────\n\nexport { CURRENCY, ORDER_TYPE } from \"./constants\";\n"],"mappings":";AAAO,IAAM,WAAN,cAAsD,MAAM;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EAET,YACC,SACA,SAKC;AACD,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO,QAAQ;AACpB,SAAK,QAAQ,QAAQ;AACrB,SAAK,UAAU,QAAQ;AAAA,EACxB;AACD;;;ACnBA,SAAS,KAAK,UAAuB;AACrC,SAAS,iBAAiB;AAC1B,SAAS,SAAS;;;ACDX,IAAM,WAAW;AAAA,EACvB,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AACN;;;ACZO,IAAM,aAAa;AAAA,EACzB,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AACN;;;AFCO,IAAM,mBAAmB,EAC9B,OAAO,EACP,OAAO,CAAC,MAAM,UAAU,CAAC,GAAG,EAAE,SAAS,2BAA2B,CAAC;AAE9D,IAAM,oBAAoB,EAAE,KAAK,OAAO,OAAO,QAAQ,CAA0B;;;AGNjF,IAAM,UAAkB;","names":[]}
1
+ {"version":3,"sources":["../src/validation/errors.validation.ts","../src/validation/schemas.validation.ts","../src/country/currency.ts","../src/index.ts"],"sourcesContent":["export class SdkError<TCode extends string = string> extends Error {\n\treadonly code: TCode;\n\treadonly cause?: unknown;\n\treadonly context?: Record<string, unknown>;\n\n\tconstructor(\n\t\tmessage: string,\n\t\toptions: {\n\t\t\tcode: TCode;\n\t\t\tcause?: unknown;\n\t\t\tcontext?: Record<string, unknown>;\n\t\t},\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"SdkError\";\n\t\tthis.code = options.code;\n\t\tthis.cause = options.cause;\n\t\tthis.context = options.context;\n\t}\n}\n","import { err, ok, type Result } from \"neverthrow\";\nimport { isAddress } from \"viem\";\nimport { z } from \"zod\";\nimport { CURRENCY_CODES } from \"../country/currency\";\n\nexport const ZodAddressSchema = z\n\t.string()\n\t.refine((s) => isAddress(s), { message: \"Invalid Ethereum address\" });\n\nexport const ZodCurrencySchema = z.enum(CURRENCY_CODES);\n\nexport function validate<S extends z.ZodType, E>(\n\tschema: S,\n\tdata: unknown,\n\ttoError: (message: string, cause: unknown, data: unknown) => E,\n): Result<z.infer<S>, E> {\n\tconst result = schema.safeParse(data);\n\tif (result.success) {\n\t\treturn ok(result.data as z.infer<S>);\n\t}\n\treturn err(toError(z.prettifyError(result.error), result.error, data));\n}\n","/**\n * All supported currency symbols. Single source of truth for the SDK.\n *\n * Lives alongside the country metadata so that adding a currency is a\n * single-folder operation: drop a new file in `currencies/<code>.ts`, add it\n * to this map, and both `COUNTRY_OPTIONS` and `ZodCurrencySchema` pick it up.\n */\nexport const CURRENCY = {\n\tIDR: \"IDR\",\n\tINR: \"INR\",\n\tBRL: \"BRL\",\n\tARS: \"ARS\",\n\tMEX: \"MEX\",\n\tVEN: \"VEN\",\n\tEUR: \"EUR\",\n\tNGN: \"NGN\",\n\tUSD: \"USD\",\n\tCOP: \"COP\",\n} as const;\n\n/** Union of supported currency codes. */\nexport type CurrencyCode = (typeof CURRENCY)[keyof typeof CURRENCY];\n\n/**\n * Tuple form of the currency codes — used by `z.enum(...)` in the shared\n * validation layer. Narrow tuple type required by Zod.\n */\nexport const CURRENCY_CODES = Object.values(CURRENCY) as [CurrencyCode, ...CurrencyCode[]];\n","// ── Version ──────────────────────────────────────────────────────────────\n\ndeclare const __SDK_VERSION__: string;\nexport const VERSION: string = __SDK_VERSION__;\n\n// ── Shared types ─────────────────────────────────────────────────────────\n\nexport type { CurrencyCode, PublicClientLike } from \"./types\";\n\n// ── Shared errors ────────────────────────────────────────────────────────\n\nexport { SdkError } from \"./validation\";\n"],"mappings":";AAAO,IAAM,WAAN,cAAsD,MAAM;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EAET,YACC,SACA,SAKC;AACD,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO,QAAQ;AACpB,SAAK,QAAQ,QAAQ;AACrB,SAAK,UAAU,QAAQ;AAAA,EACxB;AACD;;;ACnBA,SAAS,KAAK,UAAuB;AACrC,SAAS,iBAAiB;AAC1B,SAAS,SAAS;;;ACKX,IAAM,WAAW;AAAA,EACvB,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AACN;AASO,IAAM,iBAAiB,OAAO,OAAO,QAAQ;;;ADtB7C,IAAM,mBAAmB,EAC9B,OAAO,EACP,OAAO,CAAC,MAAM,UAAU,CAAC,GAAG,EAAE,SAAS,2BAA2B,CAAC;AAE9D,IAAM,oBAAoB,EAAE,KAAK,cAAc;;;AEN/C,IAAM,UAAkB;","names":[]}