@p2pdotme/sdk 1.0.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 +155 -0
- package/dist/fraud-engine.cjs +598 -0
- package/dist/fraud-engine.cjs.map +1 -0
- package/dist/fraud-engine.d.cts +194 -0
- package/dist/fraud-engine.d.ts +194 -0
- package/dist/fraud-engine.mjs +549 -0
- package/dist/fraud-engine.mjs.map +1 -0
- package/dist/index.cjs +75 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +49 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.mjs +46 -0
- package/dist/index.mjs.map +1 -0
- package/dist/order-routing.cjs +882 -0
- package/dist/order-routing.cjs.map +1 -0
- package/dist/order-routing.d.cts +68 -0
- package/dist/order-routing.d.ts +68 -0
- package/dist/order-routing.mjs +854 -0
- package/dist/order-routing.mjs.map +1 -0
- package/dist/payload.cjs +3164 -0
- package/dist/payload.cjs.map +1 -0
- package/dist/payload.d.cts +162 -0
- package/dist/payload.d.ts +162 -0
- package/dist/payload.mjs +3120 -0
- package/dist/payload.mjs.map +1 -0
- package/dist/profile.cjs +695 -0
- package/dist/profile.cjs.map +1 -0
- package/dist/profile.d.cts +133 -0
- package/dist/profile.d.ts +133 -0
- package/dist/profile.mjs +667 -0
- package/dist/profile.mjs.map +1 -0
- package/dist/qr-parsers.cjs +366 -0
- package/dist/qr-parsers.cjs.map +1 -0
- package/dist/qr-parsers.d.cts +41 -0
- package/dist/qr-parsers.d.ts +41 -0
- package/dist/qr-parsers.mjs +338 -0
- package/dist/qr-parsers.mjs.map +1 -0
- package/dist/react.cjs +4803 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +511 -0
- package/dist/react.d.ts +511 -0
- package/dist/react.mjs +4759 -0
- package/dist/react.mjs.map +1 -0
- package/dist/zkkyc.cjs +868 -0
- package/dist/zkkyc.cjs.map +1 -0
- package/dist/zkkyc.d.cts +230 -0
- package/dist/zkkyc.d.ts +230 -0
- package/dist/zkkyc.mjs +824 -0
- package/dist/zkkyc.mjs.map +1 -0
- package/package.json +130 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/profile/index.ts","../src/contracts/abis/index.ts","../src/contracts/abis/order-flow-facet.ts","../src/contracts/abis/p2p-config-facet.ts","../src/contracts/abis/reputation-manager.ts","../src/contracts/order-flow/index.ts","../src/validation/errors.ts","../src/validation/schemas.ts","../src/order-routing/validation.ts","../src/contracts/p2p-config/index.ts","../src/profile/errors.ts","../src/profile/validation.ts","../src/contracts/reputation-manager/writes.ts","../src/zkkyc/validation.ts","../src/contracts/tx-limits/index.ts","../src/contracts/usdc/index.ts","../src/profile/contracts/actions.ts","../src/profile/client.ts"],"sourcesContent":["// ── Main entry point ────────────────────────────────────────────────────\n\nexport { createProfile, type Profile } from \"./client\";\n\n// ── Types ───────────────────────────────────────────────────────────────\n\nexport type { RpPerUsdtLimit, TxLimits } from \"../contracts/tx-limits\";\nexport type {\n\tBalances,\n\tGetBalancesParams,\n\tPriceConfig,\n\tPriceConfigParams,\n\tProfileConfig,\n\tPublicClientLike,\n\tTxLimitsParams,\n\tUsdcBalanceParams,\n} from \"./types\";\n\n// ── Errors ──────────────────────────────────────────────────────────────\n\nexport { ProfileError, type ProfileErrorCode } from \"./errors\";\n","import { erc20Abi } from \"viem\";\nimport { orderFlowFacetAbi } from \"./order-flow-facet\";\nimport { p2pConfigFacetAbi } from \"./p2p-config-facet\";\nimport { reputationManagerAbi } from \"./reputation-manager\";\n\nconst DIAMOND_ABI = [...orderFlowFacetAbi, ...p2pConfigFacetAbi] as const;\n\nexport const ABIS = {\n\tDIAMOND: DIAMOND_ABI,\n\tFACETS: {\n\t\tORDER_FLOW: orderFlowFacetAbi,\n\t\tCONFIG: p2pConfigFacetAbi,\n\t},\n\tEXTERNAL: {\n\t\tUSDC: erc20Abi,\n\t\tREPUTATION_MANAGER: reputationManagerAbi,\n\t},\n} as const;\n","export const orderFlowFacetAbi = [\n\t{\n\t\tinputs: [\n\t\t\t{ internalType: \"uint256\", name: \"circleId\", type: \"uint256\" },\n\t\t\t{ internalType: \"uint256\", name: \"assignUpto\", type: \"uint256\" },\n\t\t\t{ internalType: \"bytes32\", name: \"currency\", type: \"bytes32\" },\n\t\t\t{ internalType: \"address\", name: \"user\", type: \"address\" },\n\t\t\t{ internalType: \"uint256\", name: \"usdtAmount\", type: \"uint256\" },\n\t\t\t{ internalType: \"uint256\", name: \"fiatAmount\", type: \"uint256\" },\n\t\t\t{ internalType: \"int256\", name: \"orderType\", type: \"int256\" },\n\t\t\t{ internalType: \"uint256\", name: \"preferredPCConfigId\", type: \"uint256\" },\n\t\t],\n\t\tname: \"getAssignableMerchantsFromCircle\",\n\t\toutputs: [{ internalType: \"address[]\", name: \"\", type: \"address[]\" }],\n\t\tstateMutability: \"view\",\n\t\ttype: \"function\",\n\t},\n\t{\n\t\tinputs: [\n\t\t\t{ internalType: \"address\", name: \"_user\", type: \"address\" },\n\t\t\t{ internalType: \"bytes32\", name: \"_nativeCurrency\", type: \"bytes32\" },\n\t\t],\n\t\tname: \"userTxLimit\",\n\t\toutputs: [\n\t\t\t{ internalType: \"uint256\", name: \"\", type: \"uint256\" },\n\t\t\t{ internalType: \"uint256\", name: \"\", type: \"uint256\" },\n\t\t],\n\t\tstateMutability: \"view\",\n\t\ttype: \"function\",\n\t},\n] as const;\n","export const p2pConfigFacetAbi = [\n\t{\n\t\tinputs: [\n\t\t\t{\n\t\t\t\tinternalType: \"bytes32\",\n\t\t\t\tname: \"_currency\",\n\t\t\t\ttype: \"bytes32\",\n\t\t\t},\n\t\t],\n\t\tname: \"getPriceConfig\",\n\t\toutputs: [\n\t\t\t{\n\t\t\t\tcomponents: [\n\t\t\t\t\t{\n\t\t\t\t\t\tinternalType: \"uint256\",\n\t\t\t\t\t\tname: \"buyPrice\",\n\t\t\t\t\t\ttype: \"uint256\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tinternalType: \"uint256\",\n\t\t\t\t\t\tname: \"sellPrice\",\n\t\t\t\t\t\ttype: \"uint256\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tinternalType: \"int256\",\n\t\t\t\t\t\tname: \"buyPriceOffset\",\n\t\t\t\t\t\ttype: \"int256\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tinternalType: \"uint256\",\n\t\t\t\t\t\tname: \"baseSpread\",\n\t\t\t\t\t\ttype: \"uint256\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tinternalType: \"struct P2pConfigStorage.PriceConfig\",\n\t\t\t\tname: \"\",\n\t\t\t\ttype: \"tuple\",\n\t\t\t},\n\t\t],\n\t\tstateMutability: \"view\",\n\t\ttype: \"function\",\n\t},\n\t{\n\t\tinputs: [\n\t\t\t{\n\t\t\t\tinternalType: \"bytes32\",\n\t\t\t\tname: \"_nativeCurrency\",\n\t\t\t\ttype: \"bytes32\",\n\t\t\t},\n\t\t],\n\t\tname: \"getRpPerUsdtLimitRational\",\n\t\toutputs: [\n\t\t\t{\n\t\t\t\tinternalType: \"uint256\",\n\t\t\t\tname: \"numerator\",\n\t\t\t\ttype: \"uint256\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tinternalType: \"uint256\",\n\t\t\t\tname: \"denominator\",\n\t\t\t\ttype: \"uint256\",\n\t\t\t},\n\t\t],\n\t\tstateMutability: \"view\",\n\t\ttype: \"function\",\n\t},\n] as const;\n","export const reputationManagerAbi = [\n\t{\n\t\tinputs: [\n\t\t\t{\n\t\t\t\tinternalType: \"string\",\n\t\t\t\tname: \"_socialName\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tcomponents: [\n\t\t\t\t\t{\n\t\t\t\t\t\tcomponents: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"string\",\n\t\t\t\t\t\t\t\tname: \"provider\",\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"string\",\n\t\t\t\t\t\t\t\tname: \"parameters\",\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"string\",\n\t\t\t\t\t\t\t\tname: \"context\",\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tinternalType: \"struct IReclaimSDK.ClaimInfo\",\n\t\t\t\t\t\tname: \"claimInfo\",\n\t\t\t\t\t\ttype: \"tuple\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tcomponents: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcomponents: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tinternalType: \"bytes32\",\n\t\t\t\t\t\t\t\t\t\tname: \"identifier\",\n\t\t\t\t\t\t\t\t\t\ttype: \"bytes32\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tinternalType: \"address\",\n\t\t\t\t\t\t\t\t\t\tname: \"owner\",\n\t\t\t\t\t\t\t\t\t\ttype: \"address\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tinternalType: \"uint32\",\n\t\t\t\t\t\t\t\t\t\tname: \"timestampS\",\n\t\t\t\t\t\t\t\t\t\ttype: \"uint32\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tinternalType: \"uint32\",\n\t\t\t\t\t\t\t\t\t\tname: \"epoch\",\n\t\t\t\t\t\t\t\t\t\ttype: \"uint32\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tinternalType: \"struct IReclaimSDK.CompleteClaimData\",\n\t\t\t\t\t\t\t\tname: \"claim\",\n\t\t\t\t\t\t\t\ttype: \"tuple\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"bytes[]\",\n\t\t\t\t\t\t\t\tname: \"signatures\",\n\t\t\t\t\t\t\t\ttype: \"bytes[]\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tinternalType: \"struct IReclaimSDK.SignedClaim\",\n\t\t\t\t\t\tname: \"signedClaim\",\n\t\t\t\t\t\ttype: \"tuple\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tinternalType: \"struct IReclaimSDK.Proof[]\",\n\t\t\t\tname: \"proofs\",\n\t\t\t\ttype: \"tuple[]\",\n\t\t\t},\n\t\t],\n\t\tname: \"socialVerify\",\n\t\toutputs: [],\n\t\tstateMutability: \"nonpayable\",\n\t\ttype: \"function\",\n\t},\n\t{\n\t\tinputs: [\n\t\t\t{\n\t\t\t\tinternalType: \"uint256\",\n\t\t\t\tname: \"nullifierSeed\",\n\t\t\t\ttype: \"uint256\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tinternalType: \"uint256\",\n\t\t\t\tname: \"nullifier\",\n\t\t\t\ttype: \"uint256\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tinternalType: \"uint256\",\n\t\t\t\tname: \"timestamp\",\n\t\t\t\ttype: \"uint256\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tinternalType: \"uint256\",\n\t\t\t\tname: \"signal\",\n\t\t\t\ttype: \"uint256\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tinternalType: \"uint256[4]\",\n\t\t\t\tname: \"revealArray\",\n\t\t\t\ttype: \"uint256[4]\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tinternalType: \"uint256[8]\",\n\t\t\t\tname: \"groth16Proof\",\n\t\t\t\ttype: \"uint256[8]\",\n\t\t\t},\n\t\t],\n\t\tname: \"submitAnonAadharProof\",\n\t\toutputs: [],\n\t\tstateMutability: \"nonpayable\",\n\t\ttype: \"function\",\n\t},\n\t{\n\t\tinputs: [\n\t\t\t{\n\t\t\t\tcomponents: [\n\t\t\t\t\t{\n\t\t\t\t\t\tinternalType: \"bytes32\",\n\t\t\t\t\t\tname: \"version\",\n\t\t\t\t\t\ttype: \"bytes32\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tcomponents: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"bytes32\",\n\t\t\t\t\t\t\t\tname: \"vkeyHash\",\n\t\t\t\t\t\t\t\ttype: \"bytes32\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"bytes\",\n\t\t\t\t\t\t\t\tname: \"proof\",\n\t\t\t\t\t\t\t\ttype: \"bytes\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"bytes32[]\",\n\t\t\t\t\t\t\t\tname: \"publicInputs\",\n\t\t\t\t\t\t\t\ttype: \"bytes32[]\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tinternalType: \"struct ProofVerificationData\",\n\t\t\t\t\t\tname: \"proofVerificationData\",\n\t\t\t\t\t\ttype: \"tuple\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tinternalType: \"bytes\",\n\t\t\t\t\t\tname: \"committedInputs\",\n\t\t\t\t\t\ttype: \"bytes\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tcomponents: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"uint256\",\n\t\t\t\t\t\t\t\tname: \"validityPeriodInSeconds\",\n\t\t\t\t\t\t\t\ttype: \"uint256\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"string\",\n\t\t\t\t\t\t\t\tname: \"domain\",\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"string\",\n\t\t\t\t\t\t\t\tname: \"scope\",\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"bool\",\n\t\t\t\t\t\t\t\tname: \"devMode\",\n\t\t\t\t\t\t\t\ttype: \"bool\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tinternalType: \"struct ServiceConfig\",\n\t\t\t\t\t\tname: \"serviceConfig\",\n\t\t\t\t\t\ttype: \"tuple\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tinternalType: \"struct ProofVerificationParams\",\n\t\t\t\tname: \"params\",\n\t\t\t\ttype: \"tuple\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tinternalType: \"bool\",\n\t\t\t\tname: \"isIDCard\",\n\t\t\t\ttype: \"bool\",\n\t\t\t},\n\t\t],\n\t\tname: \"zkPassportRegister\",\n\t\toutputs: [],\n\t\tstateMutability: \"nonpayable\",\n\t\ttype: \"function\",\n\t},\n] as const;\n","import { ResultAsync } from \"neverthrow\";\nimport type { Address } from \"viem\";\nimport { noopLogger } from \"../../lib\";\nimport { OrderRoutingError } from \"../../order-routing/errors\";\nimport type { CheckCircleEligibilityParams, Logger } from \"../../order-routing/types\";\nimport { ZodCheckCircleEligibilityParamsSchema } from \"../../order-routing/validation\";\nimport type { PublicClientLike } from \"../../types\";\nimport { validate } from \"../../validation\";\nimport { ABIS } from \"../abis\";\n\n/** Checks on-chain eligibility for a given circle by reading assignable merchants. */\nexport function checkCircleEligibility(\n\tpublicClient: PublicClientLike,\n\tcontractAddress: Address,\n\tparams: CheckCircleEligibilityParams,\n\tlogger: Logger = noopLogger,\n): ResultAsync<boolean, OrderRoutingError> {\n\treturn validate(\n\t\tZodCheckCircleEligibilityParamsSchema,\n\t\tparams,\n\t\t(message, cause, d) =>\n\t\t\tnew OrderRoutingError(message, { code: \"VALIDATION_ERROR\", cause, context: { data: d } }),\n\t)\n\t\t.asyncAndThen((validated) => {\n\t\t\tlogger.debug(\"checking on-chain eligibility\", {\n\t\t\t\tcircleId: String(validated.circleId),\n\t\t\t\tcontractAddress,\n\t\t\t});\n\n\t\t\treturn ResultAsync.fromPromise(\n\t\t\t\tpublicClient.readContract({\n\t\t\t\t\taddress: contractAddress,\n\t\t\t\t\tabi: ABIS.FACETS.ORDER_FLOW,\n\t\t\t\t\tfunctionName: \"getAssignableMerchantsFromCircle\",\n\t\t\t\t\targs: [\n\t\t\t\t\t\tvalidated.circleId,\n\t\t\t\t\t\t1n,\n\t\t\t\t\t\tvalidated.currency,\n\t\t\t\t\t\tvalidated.user as Address,\n\t\t\t\t\t\tvalidated.usdtAmount,\n\t\t\t\t\t\tvalidated.fiatAmount,\n\t\t\t\t\t\tvalidated.orderType,\n\t\t\t\t\t\tvalidated.preferredPCConfigId,\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t\t(error) =>\n\t\t\t\t\tnew OrderRoutingError(\"Eligibility check failed\", {\n\t\t\t\t\t\tcode: \"CONTRACT_READ_ERROR\",\n\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\tcontext: { circleId: String(params.circleId) },\n\t\t\t\t\t}),\n\t\t\t);\n\t\t})\n\t\t.map((merchants) => {\n\t\t\tconst arr = merchants as readonly Address[];\n\t\t\tconst eligible = arr.length >= 1;\n\t\t\tlogger.debug(\"eligibility check result\", {\n\t\t\t\tcircleId: String(params.circleId),\n\t\t\t\tassignableMerchants: arr.length,\n\t\t\t\teligible,\n\t\t\t});\n\t\t\treturn eligible;\n\t\t});\n}\n","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\";\n\nexport const ZodAddressSchema = z\n\t.string()\n\t.refine((s) => isAddress(s), { message: \"Invalid Ethereum address\" });\n\nexport const ZodCurrencySchema = z.enum([\n\t\"IDR\",\n\t\"INR\",\n\t\"BRL\",\n\t\"ARS\",\n\t\"MEX\",\n\t\"VEN\",\n\t\"EUR\",\n\t\"NGN\",\n\t\"USD\",\n]);\n\nexport type CurrencyType = z.infer<typeof ZodCurrencySchema>;\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","import { z } from \"zod\";\nimport { ZodAddressSchema } from \"../validation/schemas\";\n\n// ── Circle schemas ──────────────────────────────────────────────────────\n\nexport const ZodCircleScoreStateSchema = z.object({\n\tactiveMerchantsCount: z.coerce.number(),\n});\n\nexport const ZodCircleMetricsForRoutingSchema = z.object({\n\tcircleScore: z.coerce.number(),\n\tcircleStatus: z.string(),\n\tscoreState: ZodCircleScoreStateSchema,\n});\n\nexport const ZodCircleForRoutingSchema = z.object({\n\tcircleId: z.string(),\n\tcurrency: z.string(),\n\tmetrics: ZodCircleMetricsForRoutingSchema,\n});\n\nexport const ZodCirclesForRoutingResponseSchema = z.object({\n\tcircles: z.array(ZodCircleForRoutingSchema),\n});\n\n// ── Eligibility check schema ────────────────────────────────────────────\n\nexport const ZodCheckCircleEligibilityParamsSchema = z.object({\n\tcircleId: z.bigint(),\n\tcurrency: z.string(),\n\tuser: ZodAddressSchema,\n\tusdtAmount: z.bigint(),\n\tfiatAmount: z.bigint(),\n\torderType: z.bigint(),\n\tpreferredPCConfigId: z.bigint(),\n});\n\n// ── Select circle schema ────────────────────────────────────────────────\n\nexport const ZodSelectCircleParamsSchema = z.object({\n\tcurrency: z.string().min(1),\n\tuser: ZodAddressSchema,\n\tusdtAmount: z.bigint(),\n\tfiatAmount: z.bigint(),\n\torderType: z.bigint(),\n\tpreferredPCConfigId: z.bigint(),\n});\n","import { ResultAsync } from \"neverthrow\";\nimport { type Address, stringToHex } from \"viem\";\nimport { ProfileError } from \"../../profile/errors\";\nimport type { PriceConfig } from \"../../profile/types\";\nimport type { PriceConfigParams } from \"../../profile/validation\";\nimport { ZodPriceConfigParamsSchema } from \"../../profile/validation\";\nimport type { PublicClientLike } from \"../../types\";\nimport { validate } from \"../../validation\";\nimport { ABIS } from \"../abis\";\n\n/** Reads the price config (buy/sell prices) for a given currency. */\nexport function getPriceConfig(\n\tpublicClient: PublicClientLike,\n\tdiamondAddress: Address,\n\tparams: PriceConfigParams,\n): ResultAsync<PriceConfig, ProfileError> {\n\treturn validate(\n\t\tZodPriceConfigParamsSchema,\n\t\tparams,\n\t\t(message, cause, data) =>\n\t\t\tnew ProfileError(message, {\n\t\t\t\tcode: \"VALIDATION_ERROR\",\n\t\t\t\tcause,\n\t\t\t\tcontext: { params: data },\n\t\t\t}),\n\t).asyncAndThen((validated) =>\n\t\tResultAsync.fromPromise(\n\t\t\tpublicClient.readContract({\n\t\t\t\taddress: diamondAddress,\n\t\t\t\tabi: ABIS.FACETS.CONFIG,\n\t\t\t\tfunctionName: \"getPriceConfig\",\n\t\t\t\targs: [stringToHex(validated.currency, { size: 32 })],\n\t\t\t}) as Promise<PriceConfig>,\n\t\t\t(error) =>\n\t\t\t\tnew ProfileError(\"Failed to read price config\", {\n\t\t\t\t\tcode: \"CONTRACT_READ_ERROR\",\n\t\t\t\t\tcause: error,\n\t\t\t\t\tcontext: { currency: validated.currency, diamondAddress },\n\t\t\t\t}),\n\t\t),\n\t);\n}\n","import { SdkError } from \"../validation\";\n\nexport type ProfileErrorCode = \"VALIDATION_ERROR\" | \"CONTRACT_READ_ERROR\";\n\nexport class ProfileError extends SdkError<ProfileErrorCode> {\n\tconstructor(\n\t\tmessage: string,\n\t\toptions: {\n\t\t\tcode: ProfileErrorCode;\n\t\t\tcause?: unknown;\n\t\t\tcontext?: Record<string, unknown>;\n\t\t},\n\t) {\n\t\tsuper(message, options);\n\t\tthis.name = \"ProfileError\";\n\t}\n}\n","import { z } from \"zod\";\nimport { ZodAddressSchema, ZodCurrencySchema } from \"../validation/schemas\";\n\nexport const ZodUsdcBalanceParamsSchema = z.object({\n\taddress: ZodAddressSchema,\n});\n\nexport type UsdcBalanceParams = z.infer<typeof ZodUsdcBalanceParamsSchema>;\n\nexport const ZodGetBalancesParamsSchema = z.object({\n\taddress: ZodAddressSchema,\n\tcurrency: ZodCurrencySchema,\n});\n\nexport type GetBalancesParams = z.infer<typeof ZodGetBalancesParamsSchema>;\n\nexport const ZodTxLimitsParamsSchema = z.object({\n\taddress: ZodAddressSchema,\n\tcurrency: ZodCurrencySchema,\n});\n\nexport type TxLimitsParams = z.infer<typeof ZodTxLimitsParamsSchema>;\n\nexport const ZodPriceConfigParamsSchema = z.object({\n\tcurrency: ZodCurrencySchema,\n});\n\nexport type PriceConfigParams = z.infer<typeof ZodPriceConfigParamsSchema>;\n","import { Result } from \"neverthrow\";\nimport { type Address, encodeFunctionData } from \"viem\";\nimport { validate } from \"../../validation\";\nimport { ZkkycError } from \"../../zkkyc/errors\";\nimport type {\n\tAnonAadharProofParams,\n\tSocialVerifyParams,\n\tZkPassportRegisterParams,\n} from \"../../zkkyc/validation\";\nimport {\n\tZodAnonAadharProofParamsSchema,\n\tZodSocialVerifyParamsSchema,\n\tZodZkPassportRegisterParamsSchema,\n} from \"../../zkkyc/validation\";\nimport { ABIS } from \"../abis\";\n\n/** Prepares a social verification transaction. */\nexport function prepareSocialVerify(\n\treputationManagerAddress: Address,\n\tparams: SocialVerifyParams,\n): Result<{ to: Address; data: `0x${string}` }, ZkkycError> {\n\treturn validate(\n\t\tZodSocialVerifyParamsSchema,\n\t\tparams,\n\t\t(message, cause, data) =>\n\t\t\tnew ZkkycError(message, { code: \"VALIDATION_ERROR\", cause, context: { params: data } }),\n\t).andThen((validated) =>\n\t\tResult.fromThrowable(\n\t\t\t() => ({\n\t\t\t\tto: reputationManagerAddress,\n\t\t\t\tdata: encodeFunctionData({\n\t\t\t\t\tabi: ABIS.EXTERNAL.REPUTATION_MANAGER,\n\t\t\t\t\tfunctionName: \"socialVerify\",\n\t\t\t\t\targs: [\n\t\t\t\t\t\tvalidated._socialName,\n\t\t\t\t\t\tvalidated.proofs.map((proof) => ({\n\t\t\t\t\t\t\t...proof,\n\t\t\t\t\t\t\tsignedClaim: {\n\t\t\t\t\t\t\t\t...proof.signedClaim,\n\t\t\t\t\t\t\t\tclaim: {\n\t\t\t\t\t\t\t\t\t...proof.signedClaim.claim,\n\t\t\t\t\t\t\t\t\tidentifier: proof.signedClaim.claim.identifier as `0x${string}`,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tsignatures: proof.signedClaim.signatures as readonly `0x${string}`[],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})),\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t}),\n\t\t\t(error) =>\n\t\t\t\tnew ZkkycError(\"Failed to encode socialVerify\", {\n\t\t\t\t\tcode: \"ENCODE_ERROR\",\n\t\t\t\t\tcause: error,\n\t\t\t\t}),\n\t\t)(),\n\t);\n}\n\n/** Prepares a submit anon Aadhaar proof transaction. */\nexport function prepareSubmitAnonAadharProof(\n\treputationManagerAddress: Address,\n\tparams: AnonAadharProofParams,\n): Result<{ to: Address; data: `0x${string}` }, ZkkycError> {\n\treturn validate(\n\t\tZodAnonAadharProofParamsSchema,\n\t\tparams,\n\t\t(message, cause, data) =>\n\t\t\tnew ZkkycError(message, { code: \"VALIDATION_ERROR\", cause, context: { params: data } }),\n\t).andThen((validated) =>\n\t\tResult.fromThrowable(\n\t\t\t() => ({\n\t\t\t\tto: reputationManagerAddress,\n\t\t\t\tdata: encodeFunctionData({\n\t\t\t\t\tabi: ABIS.EXTERNAL.REPUTATION_MANAGER,\n\t\t\t\t\tfunctionName: \"submitAnonAadharProof\",\n\t\t\t\t\targs: [\n\t\t\t\t\t\tvalidated.nullifierSeed,\n\t\t\t\t\t\tvalidated.nullifier,\n\t\t\t\t\t\tvalidated.timestamp,\n\t\t\t\t\t\tvalidated.signal,\n\t\t\t\t\t\tvalidated.revealArray,\n\t\t\t\t\t\tvalidated.packedGroth16Proof,\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t}),\n\t\t\t(error) =>\n\t\t\t\tnew ZkkycError(\"Failed to encode submitAnonAadharProof\", {\n\t\t\t\t\tcode: \"ENCODE_ERROR\",\n\t\t\t\t\tcause: error,\n\t\t\t\t}),\n\t\t)(),\n\t);\n}\n\n/** Prepares a zkPassport registration transaction. */\nexport function prepareZkPassportRegister(\n\treputationManagerAddress: Address,\n\tparams: ZkPassportRegisterParams,\n): Result<{ to: Address; data: `0x${string}` }, ZkkycError> {\n\treturn validate(\n\t\tZodZkPassportRegisterParamsSchema,\n\t\tparams,\n\t\t(message, cause, data) =>\n\t\t\tnew ZkkycError(message, { code: \"VALIDATION_ERROR\", cause, context: { params: data } }),\n\t).andThen((validated) =>\n\t\tResult.fromThrowable(\n\t\t\t() => {\n\t\t\t\tconst { proofVerificationData, serviceConfig, committedInputs, version } = validated.params;\n\n\t\t\t\tconst proofVerificationParams = {\n\t\t\t\t\tversion: version as `0x${string}`,\n\t\t\t\t\tproofVerificationData: {\n\t\t\t\t\t\tvkeyHash: proofVerificationData.vkeyHash as `0x${string}`,\n\t\t\t\t\t\tproof: proofVerificationData.proof as `0x${string}`,\n\t\t\t\t\t\tpublicInputs: proofVerificationData.publicInputs as `0x${string}`[],\n\t\t\t\t\t},\n\t\t\t\t\tcommittedInputs: committedInputs as `0x${string}`,\n\t\t\t\t\tserviceConfig: {\n\t\t\t\t\t\tvalidityPeriodInSeconds: BigInt(serviceConfig.validityPeriodInSeconds),\n\t\t\t\t\t\tdomain: serviceConfig.domain,\n\t\t\t\t\t\tscope: serviceConfig.scope,\n\t\t\t\t\t\tdevMode: serviceConfig.devMode,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\treturn {\n\t\t\t\t\tto: reputationManagerAddress,\n\t\t\t\t\tdata: encodeFunctionData({\n\t\t\t\t\t\tabi: ABIS.EXTERNAL.REPUTATION_MANAGER,\n\t\t\t\t\t\tfunctionName: \"zkPassportRegister\",\n\t\t\t\t\t\targs: [proofVerificationParams, validated.isIDCard],\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t},\n\t\t\t(error) =>\n\t\t\t\tnew ZkkycError(\"Failed to encode zkPassportRegister\", {\n\t\t\t\t\tcode: \"ENCODE_ERROR\",\n\t\t\t\t\tcause: error,\n\t\t\t\t}),\n\t\t)(),\n\t);\n}\n","import { z } from \"zod\";\nimport { ZodAddressSchema } from \"../validation\";\n\n// ── Write param schemas ──────────────────────────────────────────────────────\n\nexport const ZodAnonAadharProofParamsSchema = z.object({\n\tnullifierSeed: z.bigint(),\n\tnullifier: z.bigint(),\n\ttimestamp: z.bigint(),\n\tsignal: z.bigint(),\n\trevealArray: z.tuple([z.bigint(), z.bigint(), z.bigint(), z.bigint()]),\n\tpackedGroth16Proof: z.tuple([\n\t\tz.bigint(),\n\t\tz.bigint(),\n\t\tz.bigint(),\n\t\tz.bigint(),\n\t\tz.bigint(),\n\t\tz.bigint(),\n\t\tz.bigint(),\n\t\tz.bigint(),\n\t]),\n});\n\nexport type AnonAadharProofParams = z.infer<typeof ZodAnonAadharProofParamsSchema>;\n\nexport const ZodSocialVerifyParamsSchema = z.object({\n\t_socialName: z.string(),\n\tproofs: z.array(\n\t\tz.object({\n\t\t\tclaimInfo: z.object({\n\t\t\t\tprovider: z.string(),\n\t\t\t\tparameters: z.string(),\n\t\t\t\tcontext: z.string(),\n\t\t\t}),\n\t\t\tsignedClaim: z.object({\n\t\t\t\tclaim: z.object({\n\t\t\t\t\tidentifier: z.string(),\n\t\t\t\t\towner: ZodAddressSchema,\n\t\t\t\t\ttimestampS: z.number(),\n\t\t\t\t\tepoch: z.number(),\n\t\t\t\t}),\n\t\t\t\tsignatures: z.array(z.string()),\n\t\t\t}),\n\t\t}),\n\t),\n});\n\nexport type SocialVerifyParams = z.infer<typeof ZodSocialVerifyParamsSchema>;\n\n// Schema matching SolidityVerifierParameters from @zkpassport/sdk (structural definition)\nexport const ZodSolidityVerifierParametersSchema = z.object({\n\tversion: z.string().refine((val) => val.startsWith(\"0x\"), {\n\t\tmessage: \"Version must be a hex string\",\n\t}),\n\tproofVerificationData: z.object({\n\t\tvkeyHash: z.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {\n\t\t\tmessage: \"Invalid bytes32 hex string\",\n\t\t}),\n\t\tproof: z.string().refine((val) => val.startsWith(\"0x\"), {\n\t\t\tmessage: \"Proof must be a hex string\",\n\t\t}),\n\t\tpublicInputs: z.array(\n\t\t\tz.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {\n\t\t\t\tmessage: \"Each public input must be a valid bytes32 hex string\",\n\t\t\t}),\n\t\t),\n\t}),\n\tcommittedInputs: z.string().refine((val) => val.startsWith(\"0x\"), {\n\t\tmessage: \"Committed inputs must be a hex string\",\n\t}),\n\tserviceConfig: z.object({\n\t\tvalidityPeriodInSeconds: z.number().int().nonnegative(),\n\t\tdomain: z.string(),\n\t\tscope: z.string(),\n\t\tdevMode: z.boolean(),\n\t}),\n});\n\nexport type SolidityVerifierParameters = z.infer<typeof ZodSolidityVerifierParametersSchema>;\n\nexport const ZodZkPassportRegisterParamsSchema = z.object({\n\tparams: ZodSolidityVerifierParametersSchema,\n\tisIDCard: z.boolean(),\n});\n\nexport type ZkPassportRegisterParams = z.infer<typeof ZodZkPassportRegisterParamsSchema>;\n","import { ResultAsync } from \"neverthrow\";\nimport { type Address, formatUnits, stringToHex } from \"viem\";\nimport { ProfileError } from \"../../profile/errors\";\nimport type { PriceConfigParams, TxLimitsParams } from \"../../profile/validation\";\nimport { ZodPriceConfigParamsSchema, ZodTxLimitsParamsSchema } from \"../../profile/validation\";\nimport type { PublicClientLike } from \"../../types\";\nimport { validate } from \"../../validation\";\nimport { ABIS } from \"../abis\";\n\nexport interface TxLimits {\n\treadonly buyLimit: number;\n\treadonly sellLimit: number;\n}\n\nexport interface RpPerUsdtLimit {\n\treadonly numerator: bigint;\n\treadonly denominator: bigint;\n\t/** The USDC multiplier per RP: denominator / numerator. */\n\treadonly multiplier: number;\n}\n\n/** Reads the buy and sell transaction limits for a given address and currency. */\nexport function getTxLimits(\n\tpublicClient: PublicClientLike,\n\tdiamondAddress: Address,\n\tparams: TxLimitsParams,\n): ResultAsync<TxLimits, ProfileError> {\n\treturn validate(\n\t\tZodTxLimitsParamsSchema,\n\t\tparams,\n\t\t(message, cause, data) =>\n\t\t\tnew ProfileError(message, {\n\t\t\t\tcode: \"VALIDATION_ERROR\",\n\t\t\t\tcause,\n\t\t\t\tcontext: { params: data },\n\t\t\t}),\n\t).asyncAndThen((validated) =>\n\t\tResultAsync.fromPromise(\n\t\t\tpublicClient.readContract({\n\t\t\t\taddress: diamondAddress,\n\t\t\t\tabi: ABIS.FACETS.ORDER_FLOW,\n\t\t\t\tfunctionName: \"userTxLimit\",\n\t\t\t\targs: [validated.address, stringToHex(validated.currency, { size: 32 })],\n\t\t\t}) as Promise<readonly [bigint, bigint]>,\n\t\t\t(error) =>\n\t\t\t\tnew ProfileError(\"Failed to read tx limits\", {\n\t\t\t\t\tcode: \"CONTRACT_READ_ERROR\",\n\t\t\t\t\tcause: error,\n\t\t\t\t\tcontext: { address: validated.address, currency: validated.currency, diamondAddress },\n\t\t\t\t}),\n\t\t).map(([buyLimit, sellLimit]) => ({\n\t\t\tbuyLimit: Number(formatUnits(buyLimit, 6)),\n\t\t\tsellLimit: Number(formatUnits(sellLimit, 6)),\n\t\t})),\n\t);\n}\n/** Reads the RP-to-USDC limit ratio for a given currency from the Diamond contract. */\nexport function getRpPerUsdtLimitRational(\n\tpublicClient: PublicClientLike,\n\tdiamondAddress: Address,\n\tparams: PriceConfigParams,\n): ResultAsync<RpPerUsdtLimit, ProfileError> {\n\treturn validate(\n\t\tZodPriceConfigParamsSchema,\n\t\tparams,\n\t\t(message, cause, data) =>\n\t\t\tnew ProfileError(message, {\n\t\t\t\tcode: \"VALIDATION_ERROR\",\n\t\t\t\tcause,\n\t\t\t\tcontext: { params: data },\n\t\t\t}),\n\t).asyncAndThen((validated) =>\n\t\tResultAsync.fromPromise(\n\t\t\tpublicClient.readContract({\n\t\t\t\taddress: diamondAddress,\n\t\t\t\tabi: ABIS.DIAMOND,\n\t\t\t\tfunctionName: \"getRpPerUsdtLimitRational\",\n\t\t\t\targs: [stringToHex(validated.currency, { size: 32 })],\n\t\t\t}) as Promise<readonly [bigint, bigint]>,\n\t\t\t(error) =>\n\t\t\t\tnew ProfileError(\"Failed to read RP per USDT limit rational\", {\n\t\t\t\t\tcode: \"CONTRACT_READ_ERROR\",\n\t\t\t\t\tcause: error,\n\t\t\t\t\tcontext: { currency: validated.currency, diamondAddress },\n\t\t\t\t}),\n\t\t).map(([numerator, denominator]) => ({\n\t\t\tnumerator,\n\t\t\tdenominator,\n\t\t\tmultiplier: numerator > 0n ? Number(denominator) / Number(numerator) : 0,\n\t\t})),\n\t);\n}\n","import { ResultAsync } from \"neverthrow\";\nimport type { Address } from \"viem\";\nimport { ProfileError } from \"../../profile/errors\";\nimport type { UsdcBalanceParams } from \"../../profile/validation\";\nimport { ZodUsdcBalanceParamsSchema } from \"../../profile/validation\";\nimport type { PublicClientLike } from \"../../types\";\nimport { validate } from \"../../validation\";\nimport { ABIS } from \"../abis\";\n\n/** Reads the USDC balance for a given address. */\nexport function getUsdcBalance(\n\tpublicClient: PublicClientLike,\n\tusdcAddress: Address,\n\tparams: UsdcBalanceParams,\n): ResultAsync<bigint, ProfileError> {\n\treturn validate(\n\t\tZodUsdcBalanceParamsSchema,\n\t\tparams,\n\t\t(message, cause, data) =>\n\t\t\tnew ProfileError(message, {\n\t\t\t\tcode: \"VALIDATION_ERROR\",\n\t\t\t\tcause,\n\t\t\t\tcontext: { params: data },\n\t\t\t}),\n\t).asyncAndThen((validated) =>\n\t\tResultAsync.fromPromise(\n\t\t\tpublicClient.readContract({\n\t\t\t\taddress: usdcAddress,\n\t\t\t\tabi: ABIS.EXTERNAL.USDC,\n\t\t\t\tfunctionName: \"balanceOf\",\n\t\t\t\targs: [validated.address],\n\t\t\t}) as Promise<bigint>,\n\t\t\t(error) =>\n\t\t\t\tnew ProfileError(\"Failed to read USDC balance\", {\n\t\t\t\t\tcode: \"CONTRACT_READ_ERROR\",\n\t\t\t\t\tcause: error,\n\t\t\t\t\tcontext: { address: validated.address, usdcAddress },\n\t\t\t\t}),\n\t\t),\n\t);\n}\n","import { ResultAsync } from \"neverthrow\";\nimport { type Address, formatUnits } from \"viem\";\nimport { getPriceConfig, getUsdcBalance } from \"../../contracts\";\nimport { validate } from \"../../validation\";\nimport { ProfileError } from \"../errors\";\nimport type { Balances, GetBalancesParams, PublicClientLike } from \"../types\";\nimport { ZodGetBalancesParamsSchema } from \"../validation\";\n\n/** Fetches USDC balance and fiat equivalent in parallel for a given address and currency. */\nexport function getBalances(\n\tpublicClient: PublicClientLike,\n\tusdcAddress: Address,\n\tdiamondAddress: Address,\n\tparams: GetBalancesParams,\n): ResultAsync<Balances, ProfileError> {\n\treturn validate(\n\t\tZodGetBalancesParamsSchema,\n\t\tparams,\n\t\t(message, cause, data) =>\n\t\t\tnew ProfileError(message, {\n\t\t\t\tcode: \"VALIDATION_ERROR\",\n\t\t\t\tcause,\n\t\t\t\tcontext: { params: data },\n\t\t\t}),\n\t).asyncAndThen((validated) =>\n\t\tResultAsync.combine([\n\t\t\tgetUsdcBalance(publicClient, usdcAddress, {\n\t\t\t\taddress: validated.address,\n\t\t\t}),\n\t\t\tgetPriceConfig(publicClient, diamondAddress, {\n\t\t\t\tcurrency: validated.currency,\n\t\t\t}),\n\t\t]).map(([usdc, priceConfig]) => {\n\t\t\tconst usdcFormatted = Number(formatUnits(usdc, 6));\n\t\t\tconst sellPriceFormatted = Number(formatUnits(priceConfig.sellPrice, 6));\n\t\t\treturn {\n\t\t\t\tusdc: usdcFormatted,\n\t\t\t\tfiat: usdcFormatted * sellPriceFormatted,\n\t\t\t\tsellPrice: sellPriceFormatted,\n\t\t\t};\n\t\t}),\n\t);\n}\n","import type { ResultAsync } from \"neverthrow\";\nimport {\n\tgetPriceConfig,\n\tgetRpPerUsdtLimitRational,\n\tgetTxLimits,\n\tgetUsdcBalance,\n} from \"../contracts\";\nimport type { RpPerUsdtLimit, TxLimits } from \"../contracts/tx-limits\";\nimport { getBalances } from \"./contracts\";\nimport type { ProfileError } from \"./errors\";\nimport type {\n\tBalances,\n\tGetBalancesParams,\n\tPriceConfig,\n\tPriceConfigParams,\n\tProfileConfig,\n\tTxLimitsParams,\n\tUsdcBalanceParams,\n} from \"./types\";\n\nexport interface Profile {\n\t/** Reads the USDC balance for a given address (raw bigint, 6 decimals). */\n\tgetUsdcBalance(params: UsdcBalanceParams): ResultAsync<bigint, ProfileError>;\n\n\t/** Reads buy/sell price config for a given currency (raw bigint, 6 decimals). */\n\tgetPriceConfig(params: PriceConfigParams): ResultAsync<PriceConfig, ProfileError>;\n\n\t/** Fetches USDC and fiat balance in parallel for a given address and currency. */\n\tgetBalances(params: GetBalancesParams): ResultAsync<Balances, ProfileError>;\n\n\t/** Reads buy and sell transaction limits for a given address and currency. */\n\tgetTxLimits(params: TxLimitsParams): ResultAsync<TxLimits, ProfileError>;\n\n\t/** Reads the RP-to-USDC limit ratio for a given currency. */\n\tgetRpPerUsdtLimitRational(params: PriceConfigParams): ResultAsync<RpPerUsdtLimit, ProfileError>;\n}\n\n/** Creates a Profile SDK instance for reading account balance and price data. */\nexport function createProfile(config: ProfileConfig): Profile {\n\tconst { publicClient, diamondAddress, usdcAddress } = config;\n\n\treturn {\n\t\tgetUsdcBalance: (params: UsdcBalanceParams) =>\n\t\t\tgetUsdcBalance(publicClient, usdcAddress, params),\n\n\t\tgetPriceConfig: (params: PriceConfigParams) =>\n\t\t\tgetPriceConfig(publicClient, diamondAddress, params),\n\n\t\tgetBalances: (params: GetBalancesParams) =>\n\t\t\tgetBalances(publicClient, usdcAddress, diamondAddress, params),\n\n\t\tgetTxLimits: (params: TxLimitsParams) => getTxLimits(publicClient, diamondAddress, params),\n\n\t\tgetRpPerUsdtLimitRational: (params: PriceConfigParams) =>\n\t\t\tgetRpPerUsdtLimitRational(publicClient, diamondAddress, params),\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAyB;;;ACAlB,IAAM,oBAAoB;AAAA,EAChC;AAAA,IACC,QAAQ;AAAA,MACP,EAAE,cAAc,WAAW,MAAM,YAAY,MAAM,UAAU;AAAA,MAC7D,EAAE,cAAc,WAAW,MAAM,cAAc,MAAM,UAAU;AAAA,MAC/D,EAAE,cAAc,WAAW,MAAM,YAAY,MAAM,UAAU;AAAA,MAC7D,EAAE,cAAc,WAAW,MAAM,QAAQ,MAAM,UAAU;AAAA,MACzD,EAAE,cAAc,WAAW,MAAM,cAAc,MAAM,UAAU;AAAA,MAC/D,EAAE,cAAc,WAAW,MAAM,cAAc,MAAM,UAAU;AAAA,MAC/D,EAAE,cAAc,UAAU,MAAM,aAAa,MAAM,SAAS;AAAA,MAC5D,EAAE,cAAc,WAAW,MAAM,uBAAuB,MAAM,UAAU;AAAA,IACzE;AAAA,IACA,MAAM;AAAA,IACN,SAAS,CAAC,EAAE,cAAc,aAAa,MAAM,IAAI,MAAM,YAAY,C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ACtB,WAAW;AAAA,MACZ;AAAA,IACD,CAAC;AAAA,EACF;AACD;;;ACJO,SAAS,cAAc,QAAgC;AAC7D,QAAM,EAAE,cAAc,gBAAgB,YAAY,IAAI;AAEtD,SAAO;AAAA,IACN,gBAAgB,CAAC,WAChB,eAAe,cAAc,aAAa,MAAM;AAAA,IAEjD,gBAAgB,CAAC,WAChB,eAAe,cAAc,gBAAgB,MAAM;AAAA,IAEpD,aAAa,CAAC,WACb,YAAY,cAAc,aAAa,gBAAgB,MAAM;AAAA,IAE9D,aAAa,CAAC,WAA2B,YAAY,cAAc,gBAAgB,MAAM;AAAA,IAEzF,2BAA2B,CAAC,WAC3B,0BAA0B,cAAc,gBAAgB,MAAM;AAAA,EAChE;AACD;","names":["import_neverthrow","import_viem","import_zod","import_neverthrow","import_viem","import_zod","import_neverthrow","import_viem","import_zod","import_neverthrow","import_viem","import_neverthrow","import_neverthrow","import_viem"]}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { ResultAsync } from 'neverthrow';
|
|
2
|
+
import { Address } from 'viem';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
declare class SdkError<TCode extends string = string> extends Error {
|
|
6
|
+
readonly code: TCode;
|
|
7
|
+
readonly cause?: unknown;
|
|
8
|
+
readonly context?: Record<string, unknown>;
|
|
9
|
+
constructor(message: string, options: {
|
|
10
|
+
code: TCode;
|
|
11
|
+
cause?: unknown;
|
|
12
|
+
context?: Record<string, unknown>;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type ProfileErrorCode = "VALIDATION_ERROR" | "CONTRACT_READ_ERROR";
|
|
17
|
+
declare class ProfileError extends SdkError<ProfileErrorCode> {
|
|
18
|
+
constructor(message: string, options: {
|
|
19
|
+
code: ProfileErrorCode;
|
|
20
|
+
cause?: unknown;
|
|
21
|
+
context?: Record<string, unknown>;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare const ZodUsdcBalanceParamsSchema: z.ZodObject<{
|
|
26
|
+
address: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
type UsdcBalanceParams = z.infer<typeof ZodUsdcBalanceParamsSchema>;
|
|
29
|
+
declare const ZodGetBalancesParamsSchema: z.ZodObject<{
|
|
30
|
+
address: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
|
|
31
|
+
currency: z.ZodEnum<{
|
|
32
|
+
IDR: "IDR";
|
|
33
|
+
INR: "INR";
|
|
34
|
+
BRL: "BRL";
|
|
35
|
+
ARS: "ARS";
|
|
36
|
+
MEX: "MEX";
|
|
37
|
+
VEN: "VEN";
|
|
38
|
+
EUR: "EUR";
|
|
39
|
+
NGN: "NGN";
|
|
40
|
+
USD: "USD";
|
|
41
|
+
}>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
type GetBalancesParams = z.infer<typeof ZodGetBalancesParamsSchema>;
|
|
44
|
+
declare const ZodTxLimitsParamsSchema: z.ZodObject<{
|
|
45
|
+
address: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
|
|
46
|
+
currency: z.ZodEnum<{
|
|
47
|
+
IDR: "IDR";
|
|
48
|
+
INR: "INR";
|
|
49
|
+
BRL: "BRL";
|
|
50
|
+
ARS: "ARS";
|
|
51
|
+
MEX: "MEX";
|
|
52
|
+
VEN: "VEN";
|
|
53
|
+
EUR: "EUR";
|
|
54
|
+
NGN: "NGN";
|
|
55
|
+
USD: "USD";
|
|
56
|
+
}>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
type TxLimitsParams = z.infer<typeof ZodTxLimitsParamsSchema>;
|
|
59
|
+
declare const ZodPriceConfigParamsSchema: z.ZodObject<{
|
|
60
|
+
currency: z.ZodEnum<{
|
|
61
|
+
IDR: "IDR";
|
|
62
|
+
INR: "INR";
|
|
63
|
+
BRL: "BRL";
|
|
64
|
+
ARS: "ARS";
|
|
65
|
+
MEX: "MEX";
|
|
66
|
+
VEN: "VEN";
|
|
67
|
+
EUR: "EUR";
|
|
68
|
+
NGN: "NGN";
|
|
69
|
+
USD: "USD";
|
|
70
|
+
}>;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
type PriceConfigParams = z.infer<typeof ZodPriceConfigParamsSchema>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Minimal viem PublicClient interface — consumers pass their own client.
|
|
76
|
+
* The SDK only needs `readContract` for on-chain reads.
|
|
77
|
+
*/
|
|
78
|
+
interface PublicClientLike {
|
|
79
|
+
readContract(args: {
|
|
80
|
+
address: Address;
|
|
81
|
+
abi: readonly unknown[];
|
|
82
|
+
functionName: string;
|
|
83
|
+
args: readonly unknown[];
|
|
84
|
+
}): Promise<unknown>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface TxLimits {
|
|
88
|
+
readonly buyLimit: number;
|
|
89
|
+
readonly sellLimit: number;
|
|
90
|
+
}
|
|
91
|
+
interface RpPerUsdtLimit {
|
|
92
|
+
readonly numerator: bigint;
|
|
93
|
+
readonly denominator: bigint;
|
|
94
|
+
/** The USDC multiplier per RP: denominator / numerator. */
|
|
95
|
+
readonly multiplier: number;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
interface ProfileConfig {
|
|
99
|
+
readonly publicClient: PublicClientLike;
|
|
100
|
+
readonly diamondAddress: Address;
|
|
101
|
+
readonly usdcAddress: Address;
|
|
102
|
+
}
|
|
103
|
+
interface Balances {
|
|
104
|
+
/** USDC balance formatted to a number. */
|
|
105
|
+
readonly usdc: number;
|
|
106
|
+
/** Fiat equivalent: usdc * sellPrice. */
|
|
107
|
+
readonly fiat: number;
|
|
108
|
+
/** The sell price used for conversion. */
|
|
109
|
+
readonly sellPrice: number;
|
|
110
|
+
}
|
|
111
|
+
interface PriceConfig {
|
|
112
|
+
readonly buyPrice: bigint;
|
|
113
|
+
readonly sellPrice: bigint;
|
|
114
|
+
readonly buyPriceOffset: bigint;
|
|
115
|
+
readonly baseSpread: bigint;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
interface Profile {
|
|
119
|
+
/** Reads the USDC balance for a given address (raw bigint, 6 decimals). */
|
|
120
|
+
getUsdcBalance(params: UsdcBalanceParams): ResultAsync<bigint, ProfileError>;
|
|
121
|
+
/** Reads buy/sell price config for a given currency (raw bigint, 6 decimals). */
|
|
122
|
+
getPriceConfig(params: PriceConfigParams): ResultAsync<PriceConfig, ProfileError>;
|
|
123
|
+
/** Fetches USDC and fiat balance in parallel for a given address and currency. */
|
|
124
|
+
getBalances(params: GetBalancesParams): ResultAsync<Balances, ProfileError>;
|
|
125
|
+
/** Reads buy and sell transaction limits for a given address and currency. */
|
|
126
|
+
getTxLimits(params: TxLimitsParams): ResultAsync<TxLimits, ProfileError>;
|
|
127
|
+
/** Reads the RP-to-USDC limit ratio for a given currency. */
|
|
128
|
+
getRpPerUsdtLimitRational(params: PriceConfigParams): ResultAsync<RpPerUsdtLimit, ProfileError>;
|
|
129
|
+
}
|
|
130
|
+
/** Creates a Profile SDK instance for reading account balance and price data. */
|
|
131
|
+
declare function createProfile(config: ProfileConfig): Profile;
|
|
132
|
+
|
|
133
|
+
export { type Balances, type GetBalancesParams, type PriceConfig, type PriceConfigParams, type Profile, type ProfileConfig, ProfileError, type ProfileErrorCode, type PublicClientLike, type RpPerUsdtLimit, type TxLimits, type TxLimitsParams, type UsdcBalanceParams, createProfile };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { ResultAsync } from 'neverthrow';
|
|
2
|
+
import { Address } from 'viem';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
declare class SdkError<TCode extends string = string> extends Error {
|
|
6
|
+
readonly code: TCode;
|
|
7
|
+
readonly cause?: unknown;
|
|
8
|
+
readonly context?: Record<string, unknown>;
|
|
9
|
+
constructor(message: string, options: {
|
|
10
|
+
code: TCode;
|
|
11
|
+
cause?: unknown;
|
|
12
|
+
context?: Record<string, unknown>;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type ProfileErrorCode = "VALIDATION_ERROR" | "CONTRACT_READ_ERROR";
|
|
17
|
+
declare class ProfileError extends SdkError<ProfileErrorCode> {
|
|
18
|
+
constructor(message: string, options: {
|
|
19
|
+
code: ProfileErrorCode;
|
|
20
|
+
cause?: unknown;
|
|
21
|
+
context?: Record<string, unknown>;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare const ZodUsdcBalanceParamsSchema: z.ZodObject<{
|
|
26
|
+
address: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
type UsdcBalanceParams = z.infer<typeof ZodUsdcBalanceParamsSchema>;
|
|
29
|
+
declare const ZodGetBalancesParamsSchema: z.ZodObject<{
|
|
30
|
+
address: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
|
|
31
|
+
currency: z.ZodEnum<{
|
|
32
|
+
IDR: "IDR";
|
|
33
|
+
INR: "INR";
|
|
34
|
+
BRL: "BRL";
|
|
35
|
+
ARS: "ARS";
|
|
36
|
+
MEX: "MEX";
|
|
37
|
+
VEN: "VEN";
|
|
38
|
+
EUR: "EUR";
|
|
39
|
+
NGN: "NGN";
|
|
40
|
+
USD: "USD";
|
|
41
|
+
}>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
type GetBalancesParams = z.infer<typeof ZodGetBalancesParamsSchema>;
|
|
44
|
+
declare const ZodTxLimitsParamsSchema: z.ZodObject<{
|
|
45
|
+
address: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
|
|
46
|
+
currency: z.ZodEnum<{
|
|
47
|
+
IDR: "IDR";
|
|
48
|
+
INR: "INR";
|
|
49
|
+
BRL: "BRL";
|
|
50
|
+
ARS: "ARS";
|
|
51
|
+
MEX: "MEX";
|
|
52
|
+
VEN: "VEN";
|
|
53
|
+
EUR: "EUR";
|
|
54
|
+
NGN: "NGN";
|
|
55
|
+
USD: "USD";
|
|
56
|
+
}>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
type TxLimitsParams = z.infer<typeof ZodTxLimitsParamsSchema>;
|
|
59
|
+
declare const ZodPriceConfigParamsSchema: z.ZodObject<{
|
|
60
|
+
currency: z.ZodEnum<{
|
|
61
|
+
IDR: "IDR";
|
|
62
|
+
INR: "INR";
|
|
63
|
+
BRL: "BRL";
|
|
64
|
+
ARS: "ARS";
|
|
65
|
+
MEX: "MEX";
|
|
66
|
+
VEN: "VEN";
|
|
67
|
+
EUR: "EUR";
|
|
68
|
+
NGN: "NGN";
|
|
69
|
+
USD: "USD";
|
|
70
|
+
}>;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
type PriceConfigParams = z.infer<typeof ZodPriceConfigParamsSchema>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Minimal viem PublicClient interface — consumers pass their own client.
|
|
76
|
+
* The SDK only needs `readContract` for on-chain reads.
|
|
77
|
+
*/
|
|
78
|
+
interface PublicClientLike {
|
|
79
|
+
readContract(args: {
|
|
80
|
+
address: Address;
|
|
81
|
+
abi: readonly unknown[];
|
|
82
|
+
functionName: string;
|
|
83
|
+
args: readonly unknown[];
|
|
84
|
+
}): Promise<unknown>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface TxLimits {
|
|
88
|
+
readonly buyLimit: number;
|
|
89
|
+
readonly sellLimit: number;
|
|
90
|
+
}
|
|
91
|
+
interface RpPerUsdtLimit {
|
|
92
|
+
readonly numerator: bigint;
|
|
93
|
+
readonly denominator: bigint;
|
|
94
|
+
/** The USDC multiplier per RP: denominator / numerator. */
|
|
95
|
+
readonly multiplier: number;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
interface ProfileConfig {
|
|
99
|
+
readonly publicClient: PublicClientLike;
|
|
100
|
+
readonly diamondAddress: Address;
|
|
101
|
+
readonly usdcAddress: Address;
|
|
102
|
+
}
|
|
103
|
+
interface Balances {
|
|
104
|
+
/** USDC balance formatted to a number. */
|
|
105
|
+
readonly usdc: number;
|
|
106
|
+
/** Fiat equivalent: usdc * sellPrice. */
|
|
107
|
+
readonly fiat: number;
|
|
108
|
+
/** The sell price used for conversion. */
|
|
109
|
+
readonly sellPrice: number;
|
|
110
|
+
}
|
|
111
|
+
interface PriceConfig {
|
|
112
|
+
readonly buyPrice: bigint;
|
|
113
|
+
readonly sellPrice: bigint;
|
|
114
|
+
readonly buyPriceOffset: bigint;
|
|
115
|
+
readonly baseSpread: bigint;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
interface Profile {
|
|
119
|
+
/** Reads the USDC balance for a given address (raw bigint, 6 decimals). */
|
|
120
|
+
getUsdcBalance(params: UsdcBalanceParams): ResultAsync<bigint, ProfileError>;
|
|
121
|
+
/** Reads buy/sell price config for a given currency (raw bigint, 6 decimals). */
|
|
122
|
+
getPriceConfig(params: PriceConfigParams): ResultAsync<PriceConfig, ProfileError>;
|
|
123
|
+
/** Fetches USDC and fiat balance in parallel for a given address and currency. */
|
|
124
|
+
getBalances(params: GetBalancesParams): ResultAsync<Balances, ProfileError>;
|
|
125
|
+
/** Reads buy and sell transaction limits for a given address and currency. */
|
|
126
|
+
getTxLimits(params: TxLimitsParams): ResultAsync<TxLimits, ProfileError>;
|
|
127
|
+
/** Reads the RP-to-USDC limit ratio for a given currency. */
|
|
128
|
+
getRpPerUsdtLimitRational(params: PriceConfigParams): ResultAsync<RpPerUsdtLimit, ProfileError>;
|
|
129
|
+
}
|
|
130
|
+
/** Creates a Profile SDK instance for reading account balance and price data. */
|
|
131
|
+
declare function createProfile(config: ProfileConfig): Profile;
|
|
132
|
+
|
|
133
|
+
export { type Balances, type GetBalancesParams, type PriceConfig, type PriceConfigParams, type Profile, type ProfileConfig, ProfileError, type ProfileErrorCode, type PublicClientLike, type RpPerUsdtLimit, type TxLimits, type TxLimitsParams, type UsdcBalanceParams, createProfile };
|