@zkp2p/pay-shared 0.0.1 → 0.0.2

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 (2) hide show
  1. package/README.md +112 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # @zkp2p/pay-shared
2
+
3
+ Shared TypeScript types, enums, and chain utilities used by ZKP2P Pay API, SDK, and frontend apps.
4
+
5
+ - Package: `@zkp2p/pay-shared`
6
+ - Module format: ESM
7
+ - Contains runtime utilities and compile-time types
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @zkp2p/pay-shared
13
+ ```
14
+
15
+ ## What This Package Includes
16
+
17
+ - Checkout/session/order types (`CreateSessionRequest`, `CheckoutSession`, `Order`, `Quote`, etc.)
18
+ - Canonical constants (`PaymentPlatform`, `CheckoutMode`, `SessionStatus`, `OrderStatus`, `OrderErrorCode`)
19
+ - Merchant model types and environment constants (`Merchant`, `MerchantEnvironment`)
20
+ - Central chain/token helpers for supported destination chains and token aliases
21
+
22
+ ## Usage
23
+
24
+ ### Shared API Types
25
+
26
+ ```ts
27
+ import type { CreateSessionRequest, CheckoutSession } from '@zkp2p/pay-shared';
28
+
29
+ const request: CreateSessionRequest = {
30
+ merchantId: '<merchant-id>',
31
+ checkoutMode: 'exact-token',
32
+ amountUsdc: '25.00',
33
+ destinationChainId: 8453,
34
+ destinationToken: 'USDC',
35
+ recipientAddress: '0xYourRecipientAddress',
36
+ };
37
+
38
+ function readSession(session: CheckoutSession) {
39
+ console.log(session.status, session.amountUsdc, session.netAmountUsdc);
40
+ }
41
+ ```
42
+
43
+ ### Constants and Enums
44
+
45
+ ```ts
46
+ import { CheckoutMode, PaymentPlatform, SessionStatus } from '@zkp2p/pay-shared';
47
+
48
+ console.log(CheckoutMode.EXACT_TOKEN); // "exact-token"
49
+ console.log(PaymentPlatform.VENMO); // "venmo"
50
+ console.log(SessionStatus.ACTIVE); // "ACTIVE"
51
+ ```
52
+
53
+ ### Chain and Token Utilities
54
+
55
+ ```ts
56
+ import {
57
+ BASE_CHAIN_ID,
58
+ getSupportedChainIds,
59
+ parseSupportedChainSelection,
60
+ resolveDestinationTokenAddress,
61
+ getSupportedDestinationTokenAliasesForChain,
62
+ } from '@zkp2p/pay-shared';
63
+
64
+ const chainId = parseSupportedChainSelection('polygon'); // 137
65
+ const usdc = resolveDestinationTokenAddress('USDC', 137); // Chain-specific USDC address
66
+ const supportedAliases = getSupportedDestinationTokenAliasesForChain(BASE_CHAIN_ID); // ["USDC"]
67
+
68
+ console.log(getSupportedChainIds(), chainId, usdc, supportedAliases);
69
+ ```
70
+
71
+ ## Key Exports
72
+
73
+ Core type exports:
74
+
75
+ - `CreateSessionRequest`
76
+ - `CreateSessionResponse`
77
+ - `CheckoutSession`
78
+ - `Order`
79
+ - `Quote`
80
+ - `ProofAttempt`
81
+ - `Merchant`
82
+ - `BridgeInfo`
83
+
84
+ Core constants:
85
+
86
+ - `PaymentPlatform`
87
+ - `CheckoutMode`
88
+ - `SessionStatus`
89
+ - `OrderStatus`
90
+ - `ProofAttemptStatus`
91
+ - `OrderErrorCode`
92
+ - `MerchantEnvironment`
93
+
94
+ Chain constants and helpers:
95
+
96
+ - `BASE_CHAIN_ID`
97
+ - `HYPEREVM_CHAIN_ID`
98
+ - `SOLANA_CHAIN_ID`
99
+ - `SUPPORTED_DESTINATION_TOKEN_ALIASES`
100
+ - `parseSupportedChainSelection(...)`
101
+ - `resolveDestinationTokenAddress(...)`
102
+ - `getChainConfig(...)`
103
+ - `getSupportedChainIds(...)`
104
+ - `getDestinationChainIds(...)`
105
+ - `getEvmChainIds(...)`
106
+ - `getNonEvmChainIds(...)`
107
+
108
+ ## Notes
109
+
110
+ - Amount fields are strings to preserve precision across APIs and clients.
111
+ - `CheckoutSession.netAmountUsdc` represents the merchant net amount and may fall back to gross `amountUsdc` when fee configuration is unavailable.
112
+ - This package is ESM-only.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zkp2p/pay-shared",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",