@zkp2p/contracts-v2 0.0.1-rc5 → 0.0.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 +92 -32
- package/_cjs/addresses/base.json +1 -1
- package/_cjs/addresses/baseSepolia.json +1 -1
- package/_cjs/paymentMethods/baseSepolia.json +1 -1
- package/_cjs/paymentMethods/index.json +1 -1
- package/_esm/addresses/base.json +1 -1
- package/_esm/addresses/baseSepolia.json +1 -1
- package/_esm/paymentMethods/baseSepolia.json +1 -1
- package/_esm/paymentMethods/index.json +1 -1
- package/addresses/base.json +1 -1
- package/addresses/baseSepolia.json +1 -1
- package/package.json +1 -1
- package/paymentMethods/baseSepolia.json +1 -1
- 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
|
|
15
|
+
## Quick Start
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
|
-
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
// Import addresses for specific networks
|
|
19
|
+
import { base, baseSepolia } from "@zkp2p/contracts-v2/addresses"
|
|
20
|
+
|
|
21
|
+
// Import specific contract ABIs
|
|
22
|
+
import { Escrow, Orchestrator } from "@zkp2p/contracts-v2/abis/base"
|
|
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
|
-
|
|
28
|
-
|
|
41
|
+
base.Orchestrator,
|
|
42
|
+
Orchestrator,
|
|
29
43
|
provider
|
|
30
44
|
);
|
|
31
45
|
|
|
32
|
-
console.log('Intent expiration:',
|
|
33
|
-
console.log('Venmo config:',
|
|
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
|
|
54
|
+
Pre-configured addresses for all deployed networks:
|
|
41
55
|
|
|
42
56
|
```typescript
|
|
43
|
-
import base from
|
|
44
|
-
|
|
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,15 @@ Supported networks:
|
|
|
56
70
|
Minimal ABIs extracted from on-chain deployments:
|
|
57
71
|
|
|
58
72
|
```typescript
|
|
59
|
-
import
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
import { Orchestrator, Escrow } from "@zkp2p/contracts-v2/abis/base"
|
|
74
|
+
import * as baseSepoliaAbis from "@zkp2p/contracts-v2/abis/baseSepolia"
|
|
75
|
+
|
|
76
|
+
// Use the ABIs directly
|
|
77
|
+
const orchestratorABI = Orchestrator;
|
|
78
|
+
const escrowABI = Escrow;
|
|
79
|
+
|
|
80
|
+
// Or access all ABIs for a network
|
|
81
|
+
const unifiedVerifierABI = baseSepoliaAbis.UnifiedPaymentVerifier;
|
|
62
82
|
```
|
|
63
83
|
|
|
64
84
|
### 🔧 Network-Specific Protocol Constants
|
|
@@ -66,8 +86,15 @@ const escrowABI = baseAbis.Escrow;
|
|
|
66
86
|
All protocol parameters and configurations per network:
|
|
67
87
|
|
|
68
88
|
```typescript
|
|
69
|
-
import {
|
|
70
|
-
|
|
89
|
+
import { INTENT_EXPIRATION_PERIOD, MAX_INTENTS_PER_DEPOSIT, DUST_THRESHOLD } from "@zkp2p/contracts-v2/constants/base"
|
|
90
|
+
import * as baseSepoliaConstants from "@zkp2p/contracts-v2/constants/baseSepolia"
|
|
91
|
+
|
|
92
|
+
// Use specific constants
|
|
93
|
+
console.log('Intent expiration:', INTENT_EXPIRATION_PERIOD);
|
|
94
|
+
console.log('Max intents:', MAX_INTENTS_PER_DEPOSIT);
|
|
95
|
+
|
|
96
|
+
// Or access all constants for a network
|
|
97
|
+
console.log('USDC address:', baseSepoliaConstants.USDC);
|
|
71
98
|
```
|
|
72
99
|
|
|
73
100
|
### 💳 Payment Methods with Provider Hashes
|
|
@@ -75,12 +102,18 @@ const { INTENT_EXPIRATION_PERIOD, MAX_INTENTS_PER_DEPOSIT, DUST_THRESHOLD } = ba
|
|
|
75
102
|
Unified payment method configurations including provider hashes from deployment:
|
|
76
103
|
|
|
77
104
|
```typescript
|
|
78
|
-
import { base
|
|
79
|
-
|
|
105
|
+
import { base, baseSepolia } from "@zkp2p/contracts-v2/paymentMethods"
|
|
106
|
+
|
|
107
|
+
// Access payment method configurations
|
|
108
|
+
const venmoConfig = base.venmo;
|
|
80
109
|
console.log('Payment Method Hash:', venmoConfig.paymentMethodHash);
|
|
81
110
|
console.log('Provider Hashes:', venmoConfig.providerHashes);
|
|
82
111
|
console.log('Currencies:', venmoConfig.currencies);
|
|
83
112
|
console.log('Timestamp Buffer:', venmoConfig.timestampBuffer);
|
|
113
|
+
|
|
114
|
+
// Or use testnet configurations
|
|
115
|
+
const testnetPaymentMethods = baseSepolia;
|
|
116
|
+
console.log('Available methods:', Object.keys(testnetPaymentMethods));
|
|
84
117
|
```
|
|
85
118
|
|
|
86
119
|
### 🛠️ Utility Functions
|
|
@@ -88,8 +121,16 @@ console.log('Timestamp Buffer:', venmoConfig.timestampBuffer);
|
|
|
88
121
|
Protocol utility functions:
|
|
89
122
|
|
|
90
123
|
```typescript
|
|
91
|
-
|
|
92
|
-
|
|
124
|
+
// Import protocol utilities
|
|
125
|
+
import { getKeccak256Hash, calculateIntentHash, getCurrencyInfo } from "@zkp2p/contracts-v2/utils/protocolUtils"
|
|
126
|
+
import { Currency } from "@zkp2p/contracts-v2/utils/types"
|
|
127
|
+
|
|
128
|
+
// Use utility functions
|
|
129
|
+
const paymentMethodHash = getKeccak256Hash("venmo");
|
|
130
|
+
const intentHash = calculateIntentHash(depositor, depositId, signalIntentParams);
|
|
131
|
+
|
|
132
|
+
// Get currency information
|
|
133
|
+
const usdInfo = getCurrencyInfo(Currency.USD);
|
|
93
134
|
console.log('Currency code:', usdInfo.code);
|
|
94
135
|
console.log('Decimals:', usdInfo.decimals);
|
|
95
136
|
```
|
|
@@ -97,26 +138,45 @@ console.log('Decimals:', usdInfo.decimals);
|
|
|
97
138
|
|
|
98
139
|
## API Reference
|
|
99
140
|
|
|
100
|
-
###
|
|
141
|
+
### Package Structure
|
|
142
|
+
|
|
143
|
+
The package follows modern ESM/CJS patterns with clean subpath exports:
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
@zkp2p/contracts-v2/
|
|
147
|
+
├── addresses/ # Network-specific contract addresses
|
|
148
|
+
├── abis/ # Network-specific contract ABIs
|
|
149
|
+
├── constants/ # Protocol constants per network
|
|
150
|
+
├── paymentMethods/ # Payment method configurations
|
|
151
|
+
├── types/ # TypeScript type definitions
|
|
152
|
+
└── utils/ # Utility functions
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Import Patterns
|
|
156
|
+
|
|
157
|
+
All modules are directly accessible via subpath exports:
|
|
158
|
+
|
|
159
|
+
- `@zkp2p/contracts-v2/addresses` - Contract addresses
|
|
160
|
+
- `@zkp2p/contracts-v2/abis/<network>` - Contract ABIs per network
|
|
161
|
+
- `@zkp2p/contracts-v2/constants/<network>` - Constants per network
|
|
162
|
+
- `@zkp2p/contracts-v2/paymentMethods` - Payment method configs
|
|
163
|
+
- `@zkp2p/contracts-v2/utils/protocolUtils` - Protocol utilities
|
|
164
|
+
- `@zkp2p/contracts-v2/types` - TypeScript types
|
|
165
|
+
|
|
166
|
+
## Version
|
|
101
167
|
|
|
102
|
-
|
|
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`
|
|
168
|
+
Current version: `0.0.1-rc5`
|
|
109
169
|
|
|
110
170
|
## Development
|
|
111
171
|
|
|
112
172
|
### Build & Publish
|
|
113
173
|
|
|
114
174
|
From `packages/contracts`:
|
|
115
|
-
- `yarn build` – Clean, extract, and bundle
|
|
175
|
+
- `yarn build` – Clean, extract, and bundle package
|
|
116
176
|
- `npm pack` – Preview tarball contents
|
|
117
177
|
- `npm publish --access public` – Publish (runs prepublishOnly)
|
|
118
178
|
|
|
119
|
-
Note: The package
|
|
179
|
+
Note: The package uses modern module patterns with _esm/, _cjs/, and _types/ folders for optimal compatibility.
|
|
120
180
|
|
|
121
181
|
## License
|
|
122
182
|
|
package/_cjs/addresses/base.json
CHANGED
package/_esm/addresses/base.json
CHANGED
package/addresses/base.json
CHANGED
package/package.json
CHANGED