@zkp2p/contracts-v2 0.0.1-rc5 → 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 (130) hide show
  1. package/README.md +118 -32
  2. package/_cjs/abis/base/CashappReclaimVerifier.json +513 -0
  3. package/_cjs/abis/base/Escrow.json +2315 -0
  4. package/_cjs/abis/base/MercadoPagoReclaimVerifier.json +539 -0
  5. package/_cjs/abis/base/NullifierRegistry.json +213 -0
  6. package/_cjs/abis/base/RevolutReclaimVerifier.json +513 -0
  7. package/_cjs/abis/base/VenmoReclaimVerifier.json +500 -0
  8. package/_cjs/abis/base/WiseReclaimVerifier.json +513 -0
  9. package/_cjs/abis/base/ZelleBaseVerifier.json +377 -0
  10. package/_cjs/abis/base/ZelleBoAReclaimVerifier.json +424 -0
  11. package/_cjs/abis/base/ZelleChaseReclaimVerifier.json +437 -0
  12. package/_cjs/abis/base/ZelleCitiReclaimVerifier.json +424 -0
  13. package/_cjs/abis/base/index.js +11 -0
  14. package/_cjs/abis/base.cjs +14 -0
  15. package/_cjs/abis/base.mjs +16 -0
  16. package/_cjs/abis/baseSepolia/Escrow.json +2222 -0
  17. package/_cjs/abis/baseSepolia/EscrowRegistry.json +214 -0
  18. package/_cjs/abis/baseSepolia/NullifierRegistry.json +213 -0
  19. package/_cjs/abis/baseSepolia/Orchestrator.json +1121 -0
  20. package/_cjs/abis/baseSepolia/PaymentVerifierRegistry.json +332 -0
  21. package/_cjs/abis/baseSepolia/PostIntentHookRegistry.json +181 -0
  22. package/_cjs/abis/baseSepolia/ProtocolViewer.json +1382 -0
  23. package/_cjs/abis/baseSepolia/RelayerRegistry.json +162 -0
  24. package/_cjs/abis/baseSepolia/SimpleAttestationVerifier.json +215 -0
  25. package/_cjs/abis/baseSepolia/USDCMock.json +293 -0
  26. package/_cjs/abis/baseSepolia/UnifiedPaymentVerifier.json +545 -0
  27. package/_cjs/abis/baseSepolia/index.js +11 -0
  28. package/_cjs/abis/baseSepolia.cjs +14 -0
  29. package/_cjs/abis/baseSepolia.mjs +16 -0
  30. package/_cjs/addresses/base.json +1 -1
  31. package/_cjs/addresses/baseSepolia.json +1 -1
  32. package/_cjs/paymentMethods/baseSepolia.json +1 -1
  33. package/_cjs/paymentMethods/index.json +1 -1
  34. package/_cjs/types/contracts/Escrow.js +2688 -0
  35. package/_cjs/types/contracts/Orchestrator.js +1290 -0
  36. package/_cjs/types/contracts/ProtocolViewer.js +527 -0
  37. package/_cjs/types/contracts/index.js +12 -0
  38. package/_cjs/types/contracts/interfaces/IAttestationVerifier.js +114 -0
  39. package/_cjs/types/contracts/interfaces/IEscrow.js +1434 -0
  40. package/_cjs/types/contracts/interfaces/IEscrowRegistry.js +150 -0
  41. package/_cjs/types/contracts/interfaces/INullifierRegistry.js +141 -0
  42. package/_cjs/types/contracts/interfaces/IOrchestrator.js +704 -0
  43. package/_cjs/types/contracts/interfaces/IPaymentVerifier.js +154 -0
  44. package/_cjs/types/contracts/interfaces/IPaymentVerifierRegistry.js +233 -0
  45. package/_cjs/types/contracts/interfaces/IPostIntentHook.js +165 -0
  46. package/_cjs/types/contracts/interfaces/IPostIntentHookRegistry.js +126 -0
  47. package/_cjs/types/contracts/interfaces/IProtocolViewer.js +334 -0
  48. package/_cjs/types/contracts/interfaces/IRelayerRegistry.js +126 -0
  49. package/_cjs/types/contracts/interfaces/index.js +14 -0
  50. package/_cjs/types/contracts/registries/EscrowRegistry.js +463 -0
  51. package/_cjs/types/contracts/registries/NullifierRegistry.js +447 -0
  52. package/_cjs/types/contracts/registries/PaymentVerifierRegistry.js +657 -0
  53. package/_cjs/types/contracts/registries/PostIntentHookRegistry.js +414 -0
  54. package/_cjs/types/contracts/registries/RelayerRegistry.js +371 -0
  55. package/_cjs/types/contracts/registries/index.js +8 -0
  56. package/_cjs/types/contracts/unifiedVerifier/BaseUnifiedPaymentVerifier.js +828 -0
  57. package/_cjs/types/contracts/unifiedVerifier/SimpleAttestationVerifier.js +415 -0
  58. package/_cjs/types/contracts/unifiedVerifier/UnifiedPaymentVerifier.js +931 -0
  59. package/_cjs/types/contracts/unifiedVerifier/index.js +6 -0
  60. package/_esm/abis/base/CashappReclaimVerifier.json +513 -0
  61. package/_esm/abis/base/Escrow.json +2315 -0
  62. package/_esm/abis/base/MercadoPagoReclaimVerifier.json +539 -0
  63. package/_esm/abis/base/NullifierRegistry.json +213 -0
  64. package/_esm/abis/base/RevolutReclaimVerifier.json +513 -0
  65. package/_esm/abis/base/VenmoReclaimVerifier.json +500 -0
  66. package/_esm/abis/base/WiseReclaimVerifier.json +513 -0
  67. package/_esm/abis/base/ZelleBaseVerifier.json +377 -0
  68. package/_esm/abis/base/ZelleBoAReclaimVerifier.json +424 -0
  69. package/_esm/abis/base/ZelleChaseReclaimVerifier.json +437 -0
  70. package/_esm/abis/base/ZelleCitiReclaimVerifier.json +424 -0
  71. package/_esm/abis/base/index.js +11 -0
  72. package/_esm/abis/base.cjs +14 -0
  73. package/_esm/abis/base.mjs +16 -0
  74. package/_esm/abis/baseSepolia/Escrow.json +2222 -0
  75. package/_esm/abis/baseSepolia/EscrowRegistry.json +214 -0
  76. package/_esm/abis/baseSepolia/NullifierRegistry.json +213 -0
  77. package/_esm/abis/baseSepolia/Orchestrator.json +1121 -0
  78. package/_esm/abis/baseSepolia/PaymentVerifierRegistry.json +332 -0
  79. package/_esm/abis/baseSepolia/PostIntentHookRegistry.json +181 -0
  80. package/_esm/abis/baseSepolia/ProtocolViewer.json +1382 -0
  81. package/_esm/abis/baseSepolia/RelayerRegistry.json +162 -0
  82. package/_esm/abis/baseSepolia/SimpleAttestationVerifier.json +215 -0
  83. package/_esm/abis/baseSepolia/USDCMock.json +293 -0
  84. package/_esm/abis/baseSepolia/UnifiedPaymentVerifier.json +545 -0
  85. package/_esm/abis/baseSepolia/index.js +11 -0
  86. package/_esm/abis/baseSepolia.cjs +14 -0
  87. package/_esm/abis/baseSepolia.mjs +16 -0
  88. package/_esm/addresses/base.json +1 -1
  89. package/_esm/addresses/baseSepolia.json +1 -1
  90. package/_esm/paymentMethods/baseSepolia.json +1 -1
  91. package/_esm/paymentMethods/index.json +1 -1
  92. package/_esm/types/contracts/Escrow.js +2688 -0
  93. package/_esm/types/contracts/Orchestrator.js +1290 -0
  94. package/_esm/types/contracts/ProtocolViewer.js +527 -0
  95. package/_esm/types/contracts/index.js +12 -0
  96. package/_esm/types/contracts/interfaces/IAttestationVerifier.js +114 -0
  97. package/_esm/types/contracts/interfaces/IEscrow.js +1434 -0
  98. package/_esm/types/contracts/interfaces/IEscrowRegistry.js +150 -0
  99. package/_esm/types/contracts/interfaces/INullifierRegistry.js +141 -0
  100. package/_esm/types/contracts/interfaces/IOrchestrator.js +704 -0
  101. package/_esm/types/contracts/interfaces/IPaymentVerifier.js +154 -0
  102. package/_esm/types/contracts/interfaces/IPaymentVerifierRegistry.js +233 -0
  103. package/_esm/types/contracts/interfaces/IPostIntentHook.js +165 -0
  104. package/_esm/types/contracts/interfaces/IPostIntentHookRegistry.js +126 -0
  105. package/_esm/types/contracts/interfaces/IProtocolViewer.js +334 -0
  106. package/_esm/types/contracts/interfaces/IRelayerRegistry.js +126 -0
  107. package/_esm/types/contracts/interfaces/index.js +14 -0
  108. package/_esm/types/contracts/registries/EscrowRegistry.js +463 -0
  109. package/_esm/types/contracts/registries/NullifierRegistry.js +447 -0
  110. package/_esm/types/contracts/registries/PaymentVerifierRegistry.js +657 -0
  111. package/_esm/types/contracts/registries/PostIntentHookRegistry.js +414 -0
  112. package/_esm/types/contracts/registries/RelayerRegistry.js +371 -0
  113. package/_esm/types/contracts/registries/index.js +8 -0
  114. package/_esm/types/contracts/unifiedVerifier/BaseUnifiedPaymentVerifier.js +828 -0
  115. package/_esm/types/contracts/unifiedVerifier/SimpleAttestationVerifier.js +415 -0
  116. package/_esm/types/contracts/unifiedVerifier/UnifiedPaymentVerifier.js +931 -0
  117. package/_esm/types/contracts/unifiedVerifier/index.js +6 -0
  118. package/_types/abis/base.d.ts +12 -0
  119. package/_types/abis/baseSepolia.d.ts +12 -0
  120. package/abis/base.cjs +14 -0
  121. package/abis/base.d.ts +12 -0
  122. package/abis/base.mjs +16 -0
  123. package/abis/baseSepolia.cjs +14 -0
  124. package/abis/baseSepolia.d.ts +12 -0
  125. package/abis/baseSepolia.mjs +16 -0
  126. package/addresses/base.json +1 -1
  127. package/addresses/baseSepolia.json +1 -1
  128. package/package.json +23 -6
  129. package/paymentMethods/baseSepolia.json +1 -1
  130. package/paymentMethods/index.json +1 -1
package/README.md CHANGED
@@ -12,36 +12,50 @@ yarn add @zkp2p/contracts-v2
12
12
  pnpm add @zkp2p/contracts-v2
13
13
  ```
14
14
 
15
- ## Quick Start (subpath imports)
15
+ ## Quick Start
16
16
 
17
17
  ```typescript
18
- import baseAddresses from '@zkp2p/contracts-v2/addresses/base.json';
19
- import * as baseAbis from '@zkp2p/contracts-v2/abis/base';
20
- import { base as baseConstants } from '@zkp2p/contracts-v2/constants';
21
- import { base as basePaymentMethods } from '@zkp2p/contracts-v2/paymentMethods';
18
+ // Import addresses for specific networks
19
+ import { base, baseSepolia } from "@zkp2p/contracts-v2/addresses"
20
+
21
+ // Import specific contract ABIs from a network
22
+ import { Escrow, Orchestrator } from "@zkp2p/contracts-v2/abis/baseSepolia"
23
+
24
+ // Import constants
25
+ import { USDC, INTENT_EXPIRATION_PERIOD } from "@zkp2p/contracts-v2/constants/base"
26
+
27
+ // Import payment method configurations
28
+ import { baseSepolia as paymentMethods } from "@zkp2p/contracts-v2/paymentMethods"
29
+
30
+ // Import TypeScript types
31
+ import type { Escrow, Orchestrator } from "@zkp2p/contracts-v2/types"
32
+
33
+ // Import utility functions
34
+ import { getKeccak256Hash, calculateIntentHash } from "@zkp2p/contracts-v2/utils/protocolUtils"
35
+
36
+ // Example: Create contract instance with ethers
22
37
  import { ethers } from 'ethers';
23
38
 
24
- // Create contract instance
25
39
  const provider = new ethers.providers.JsonRpcProvider('https://mainnet.base.org');
26
40
  const orchestrator = new ethers.Contract(
27
- baseAddresses.Orchestrator,
28
- baseAbis.Orchestrator,
41
+ base.Orchestrator,
42
+ Orchestrator,
29
43
  provider
30
44
  );
31
45
 
32
- console.log('Intent expiration:', baseConstants.INTENT_EXPIRATION_PERIOD);
33
- console.log('Venmo config:', basePaymentMethods.venmo);
46
+ console.log('Intent expiration:', INTENT_EXPIRATION_PERIOD);
47
+ console.log('Venmo config:', paymentMethods.venmo);
34
48
  ```
35
49
 
36
50
  ## Features
37
51
 
38
52
  ### 📍 Network-Specific Contract Addresses
39
53
 
40
- Pre-configured addresses for all deployed networks, exported per-network:
54
+ Pre-configured addresses for all deployed networks:
41
55
 
42
56
  ```typescript
43
- import base from '@zkp2p/contracts-v2/addresses/base.json';
44
- import baseSepolia from '@zkp2p/contracts-v2/addresses/baseSepolia.json';
57
+ import { base, baseSepolia } from "@zkp2p/contracts-v2/addresses"
58
+
45
59
  console.log(base.Orchestrator);
46
60
  console.log(base.Escrow);
47
61
  console.log(baseSepolia.UnifiedPaymentVerifier);
@@ -56,9 +70,19 @@ Supported networks:
56
70
  Minimal ABIs extracted from on-chain deployments:
57
71
 
58
72
  ```typescript
59
- import * as baseAbis from '@zkp2p/contracts-v2/abis/base';
60
- const orchestratorABI = baseAbis.Orchestrator;
61
- const escrowABI = baseAbis.Escrow;
73
+ // Import specific contracts from a network
74
+ import { Orchestrator, Escrow } from "@zkp2p/contracts-v2/abis/baseSepolia"
75
+
76
+ // Use the ABIs directly with ethers or viem
77
+ const orchestratorABI = Orchestrator;
78
+ const escrowABI = Escrow;
79
+
80
+ // Alternative: Import all ABIs for a network
81
+ import * as baseSepoliaAbis from "@zkp2p/contracts-v2/abis/baseSepolia"
82
+ const unifiedVerifierABI = baseSepoliaAbis.UnifiedPaymentVerifier;
83
+
84
+ // Also supports direct JSON imports for bundle optimization
85
+ import EscrowABI from "@zkp2p/contracts-v2/abis/baseSepolia/Escrow.json"
62
86
  ```
63
87
 
64
88
  ### 🔧 Network-Specific Protocol Constants
@@ -66,8 +90,15 @@ const escrowABI = baseAbis.Escrow;
66
90
  All protocol parameters and configurations per network:
67
91
 
68
92
  ```typescript
69
- import { base as baseConstants } from '@zkp2p/contracts-v2/constants';
70
- const { INTENT_EXPIRATION_PERIOD, MAX_INTENTS_PER_DEPOSIT, DUST_THRESHOLD } = baseConstants;
93
+ import { INTENT_EXPIRATION_PERIOD, MAX_INTENTS_PER_DEPOSIT, DUST_THRESHOLD } from "@zkp2p/contracts-v2/constants/base"
94
+ import * as baseSepoliaConstants from "@zkp2p/contracts-v2/constants/baseSepolia"
95
+
96
+ // Use specific constants
97
+ console.log('Intent expiration:', INTENT_EXPIRATION_PERIOD);
98
+ console.log('Max intents:', MAX_INTENTS_PER_DEPOSIT);
99
+
100
+ // Or access all constants for a network
101
+ console.log('USDC address:', baseSepoliaConstants.USDC);
71
102
  ```
72
103
 
73
104
  ### 💳 Payment Methods with Provider Hashes
@@ -75,12 +106,18 @@ const { INTENT_EXPIRATION_PERIOD, MAX_INTENTS_PER_DEPOSIT, DUST_THRESHOLD } = ba
75
106
  Unified payment method configurations including provider hashes from deployment:
76
107
 
77
108
  ```typescript
78
- import { base as basePaymentMethods } from '@zkp2p/contracts-v2/paymentMethods';
79
- const venmoConfig = basePaymentMethods.venmo;
109
+ import { base, baseSepolia } from "@zkp2p/contracts-v2/paymentMethods"
110
+
111
+ // Access payment method configurations
112
+ const venmoConfig = base.venmo;
80
113
  console.log('Payment Method Hash:', venmoConfig.paymentMethodHash);
81
114
  console.log('Provider Hashes:', venmoConfig.providerHashes);
82
115
  console.log('Currencies:', venmoConfig.currencies);
83
116
  console.log('Timestamp Buffer:', venmoConfig.timestampBuffer);
117
+
118
+ // Or use testnet configurations
119
+ const testnetPaymentMethods = baseSepolia;
120
+ console.log('Available methods:', Object.keys(testnetPaymentMethods));
84
121
  ```
85
122
 
86
123
  ### 🛠️ Utility Functions
@@ -88,8 +125,16 @@ console.log('Timestamp Buffer:', venmoConfig.timestampBuffer);
88
125
  Protocol utility functions:
89
126
 
90
127
  ```typescript
91
- import * as utils from '@zkp2p/contracts-v2/utils';
92
- const usdInfo = utils.getCurrencyInfo(utils.Currency.USD);
128
+ // Import protocol utilities
129
+ import { getKeccak256Hash, calculateIntentHash, getCurrencyInfo } from "@zkp2p/contracts-v2/utils/protocolUtils"
130
+ import { Currency } from "@zkp2p/contracts-v2/utils/types"
131
+
132
+ // Use utility functions
133
+ const paymentMethodHash = getKeccak256Hash("venmo");
134
+ const intentHash = calculateIntentHash(depositor, depositId, signalIntentParams);
135
+
136
+ // Get currency information
137
+ const usdInfo = getCurrencyInfo(Currency.USD);
93
138
  console.log('Currency code:', usdInfo.code);
94
139
  console.log('Decimals:', usdInfo.decimals);
95
140
  ```
@@ -97,26 +142,67 @@ console.log('Decimals:', usdInfo.decimals);
97
142
 
98
143
  ## API Reference
99
144
 
100
- ### Imports
145
+ ### Package Structure
146
+
147
+ The package follows modern ESM/CJS patterns with clean subpath exports:
148
+
149
+ ```
150
+ @zkp2p/contracts-v2/
151
+ ├── addresses/ # Network-specific contract addresses
152
+ ├── abis/ # Network-specific contract ABIs
153
+ ├── constants/ # Protocol constants per network
154
+ ├── paymentMethods/ # Payment method configurations
155
+ ├── types/ # TypeScript type definitions
156
+ └── utils/ # Utility functions
157
+ ```
158
+
159
+ ### Import Patterns
160
+
161
+ All modules are directly accessible via subpath exports:
162
+
163
+ - `@zkp2p/contracts-v2/addresses` - Contract addresses for all networks
164
+ - `@zkp2p/contracts-v2/abis/<network>` - Contract ABIs per network (e.g., `/abis/baseSepolia`)
165
+ - `@zkp2p/contracts-v2/abis/<network>/<contract>.json` - Direct JSON import for specific contracts
166
+ - `@zkp2p/contracts-v2/constants/<network>` - Constants per network
167
+ - `@zkp2p/contracts-v2/paymentMethods` - Payment method configs
168
+ - `@zkp2p/contracts-v2/utils/protocolUtils` - Protocol utilities
169
+ - `@zkp2p/contracts-v2/types` - TypeScript types
170
+
171
+ ### Export Format Details
172
+
173
+ The package now uses explicit wrapper modules for each network to ensure reliable imports across all environments:
174
+
175
+ ```typescript
176
+ // Recommended: Import from network-specific wrappers
177
+ import { Escrow, Orchestrator } from "@zkp2p/contracts-v2/abis/baseSepolia"
178
+
179
+ // Alternative: Direct JSON imports for bundle size optimization
180
+ import EscrowABI from "@zkp2p/contracts-v2/abis/baseSepolia/Escrow.json"
181
+
182
+ // CommonJS compatibility
183
+ const { Escrow } = require("@zkp2p/contracts-v2/abis/baseSepolia")
184
+ ```
185
+
186
+ Each network export provides:
187
+ - CommonJS support (`.cjs`)
188
+ - ESM support (`.mjs`)
189
+ - TypeScript definitions (`.d.ts`)
190
+ - Direct JSON file access
191
+
192
+ ## Version
101
193
 
102
- - Prefer subpaths for clarity and smaller bundles:
103
- - `@zkp2p/contracts-v2/addresses` and `@zkp2p/contracts-v2/addresses/*.json`
104
- - `@zkp2p/contracts-v2/abis/<network>`
105
- - `@zkp2p/contracts-v2/constants`
106
- - `@zkp2p/contracts-v2/paymentMethods`
107
- - `@zkp2p/contracts-v2/utils`
108
- - `@zkp2p/contracts-v2/types`
194
+ Current version: `0.0.1-rc5`
109
195
 
110
196
  ## Development
111
197
 
112
198
  ### Build & Publish
113
199
 
114
200
  From `packages/contracts`:
115
- - `yarn build` – Clean, extract, and bundle to `dist/`
201
+ - `yarn build` – Clean, extract, and bundle package
116
202
  - `npm pack` – Preview tarball contents
117
203
  - `npm publish --access public` – Publish (runs prepublishOnly)
118
204
 
119
- Note: The package publishes `dist/` only. Tests and config files are excluded.
205
+ Note: The package uses modern module patterns with _esm/, _cjs/, and _types/ folders for optimal compatibility.
120
206
 
121
207
  ## License
122
208