@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.
- package/README.md +103 -41
- package/dist/country.cjs +9 -2
- 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 +6 -2
- 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/orders.cjs +5961 -0
- package/dist/orders.cjs.map +1 -0
- package/dist/orders.d.cts +620 -0
- package/dist/orders.d.ts +620 -0
- package/dist/orders.mjs +5911 -0
- package/dist/orders.mjs.map +1 -0
- package/dist/prices.cjs +1432 -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 +1404 -0
- package/dist/prices.mjs.map +1 -0
- package/dist/profile.cjs +899 -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 +892 -62
- package/dist/profile.mjs.map +1 -1
- package/dist/qr-parsers.cjs +88 -7
- 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 +88 -7
- package/dist/qr-parsers.mjs.map +1 -1
- package/dist/react.cjs +2955 -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 +2841 -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 +0 -3168
- 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 +0 -3124
- 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
|
-
*
|
|
23
|
-
*
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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 {
|
|
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
|
-
*
|
|
23
|
-
*
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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 {
|
|
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/
|
|
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(
|
|
37
|
+
var ZodCurrencySchema = z.enum(CURRENCY_CODES);
|
|
44
38
|
|
|
45
39
|
// src/index.ts
|
|
46
|
-
var VERSION = "1.
|
|
40
|
+
var VERSION = "1.1.1";
|
|
47
41
|
export {
|
|
48
|
-
CURRENCY,
|
|
49
|
-
ORDER_TYPE,
|
|
50
42
|
SdkError,
|
|
51
43
|
VERSION
|
|
52
44
|
};
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/validation/errors.validation.ts","../src/validation/schemas.validation.ts","../src/
|
|
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":[]}
|