@zkp2p/contracts-v2 0.0.1-rc2 → 0.0.1-rc4
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
CHANGED
|
@@ -12,20 +12,15 @@ yarn add @zkp2p/contracts-v2
|
|
|
12
12
|
pnpm add @zkp2p/contracts-v2
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
## Quick Start
|
|
15
|
+
## Quick Start (subpath imports)
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
|
-
import
|
|
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';
|
|
19
22
|
import { ethers } from 'ethers';
|
|
20
23
|
|
|
21
|
-
// Get contract addresses for Base mainnet
|
|
22
|
-
const baseAddresses = addresses.base;
|
|
23
|
-
console.log('Orchestrator:', baseAddresses.Orchestrator);
|
|
24
|
-
console.log('Escrow:', baseAddresses.Escrow);
|
|
25
|
-
|
|
26
|
-
// Get ABIs for Base mainnet
|
|
27
|
-
const baseAbis = abis.base;
|
|
28
|
-
|
|
29
24
|
// Create contract instance
|
|
30
25
|
const provider = new ethers.providers.JsonRpcProvider('https://mainnet.base.org');
|
|
31
26
|
const orchestrator = new ethers.Contract(
|
|
@@ -34,12 +29,7 @@ const orchestrator = new ethers.Contract(
|
|
|
34
29
|
provider
|
|
35
30
|
);
|
|
36
31
|
|
|
37
|
-
// Use network-specific constants
|
|
38
|
-
const baseConstants = constants.base;
|
|
39
32
|
console.log('Intent expiration:', baseConstants.INTENT_EXPIRATION_PERIOD);
|
|
40
|
-
|
|
41
|
-
// Access payment methods with provider hashes
|
|
42
|
-
const basePaymentMethods = paymentMethods.base;
|
|
43
33
|
console.log('Venmo config:', basePaymentMethods.venmo);
|
|
44
34
|
```
|
|
45
35
|
|
|
@@ -50,17 +40,11 @@ console.log('Venmo config:', basePaymentMethods.venmo);
|
|
|
50
40
|
Pre-configured addresses for all deployed networks, exported per-network:
|
|
51
41
|
|
|
52
42
|
```typescript
|
|
53
|
-
import
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// Access individual contracts
|
|
60
|
-
console.log(baseAddresses.Orchestrator);
|
|
61
|
-
console.log(baseAddresses.Escrow);
|
|
62
|
-
console.log(baseAddresses.UnifiedPaymentVerifier);
|
|
63
|
-
console.log(baseAddresses.SimpleAttestationVerifier);
|
|
43
|
+
import base from '@zkp2p/contracts-v2/addresses/base.json';
|
|
44
|
+
import baseSepolia from '@zkp2p/contracts-v2/addresses/baseSepolia.json';
|
|
45
|
+
console.log(base.Orchestrator);
|
|
46
|
+
console.log(base.Escrow);
|
|
47
|
+
console.log(baseSepolia.UnifiedPaymentVerifier);
|
|
64
48
|
```
|
|
65
49
|
|
|
66
50
|
Supported networks:
|
|
@@ -72,13 +56,7 @@ Supported networks:
|
|
|
72
56
|
Minimal ABIs extracted from on-chain deployments:
|
|
73
57
|
|
|
74
58
|
```typescript
|
|
75
|
-
import
|
|
76
|
-
|
|
77
|
-
// Network-specific ABIs
|
|
78
|
-
const baseAbis = abis.base;
|
|
79
|
-
const baseSepoliaAbis = abis.baseSepolia;
|
|
80
|
-
|
|
81
|
-
// Individual contract ABIs
|
|
59
|
+
import * as baseAbis from '@zkp2p/contracts-v2/abis/base';
|
|
82
60
|
const orchestratorABI = baseAbis.Orchestrator;
|
|
83
61
|
const escrowABI = baseAbis.Escrow;
|
|
84
62
|
```
|
|
@@ -88,18 +66,8 @@ const escrowABI = baseAbis.Escrow;
|
|
|
88
66
|
All protocol parameters and configurations per network:
|
|
89
67
|
|
|
90
68
|
```typescript
|
|
91
|
-
import {
|
|
92
|
-
|
|
93
|
-
// Network-specific constants
|
|
94
|
-
const baseConstants = constants.base;
|
|
95
|
-
|
|
96
|
-
// Protocol parameters
|
|
97
|
-
const {
|
|
98
|
-
INTENT_EXPIRATION_PERIOD,
|
|
99
|
-
MAX_INTENTS_PER_DEPOSIT,
|
|
100
|
-
DUST_THRESHOLD,
|
|
101
|
-
PARTIAL_MANUAL_RELEASE_DELAY
|
|
102
|
-
} = baseConstants;
|
|
69
|
+
import { base as baseConstants } from '@zkp2p/contracts-v2/constants';
|
|
70
|
+
const { INTENT_EXPIRATION_PERIOD, MAX_INTENTS_PER_DEPOSIT, DUST_THRESHOLD } = baseConstants;
|
|
103
71
|
```
|
|
104
72
|
|
|
105
73
|
### 💳 Payment Methods with Provider Hashes
|
|
@@ -107,15 +75,10 @@ const {
|
|
|
107
75
|
Unified payment method configurations including provider hashes from deployment:
|
|
108
76
|
|
|
109
77
|
```typescript
|
|
110
|
-
import {
|
|
111
|
-
|
|
112
|
-
// Network-specific payment methods
|
|
113
|
-
const basePaymentMethods = paymentMethods.base;
|
|
114
|
-
|
|
115
|
-
// Access payment method configuration
|
|
78
|
+
import { base as basePaymentMethods } from '@zkp2p/contracts-v2/paymentMethods';
|
|
116
79
|
const venmoConfig = basePaymentMethods.venmo;
|
|
117
|
-
console.log('Payment
|
|
118
|
-
console.log('Provider
|
|
80
|
+
console.log('Payment Method Hash:', venmoConfig.paymentMethodHash);
|
|
81
|
+
console.log('Provider Hashes:', venmoConfig.providerHashes);
|
|
119
82
|
console.log('Currencies:', venmoConfig.currencies);
|
|
120
83
|
console.log('Timestamp Buffer:', venmoConfig.timestampBuffer);
|
|
121
84
|
```
|
|
@@ -125,68 +88,35 @@ console.log('Timestamp Buffer:', venmoConfig.timestampBuffer);
|
|
|
125
88
|
Protocol utility functions:
|
|
126
89
|
|
|
127
90
|
```typescript
|
|
128
|
-
import
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
// Currency utilities
|
|
132
|
-
const usdInfo = getCurrencyInfo(Currency.USD);
|
|
91
|
+
import * as utils from '@zkp2p/contracts-v2/utils';
|
|
92
|
+
const usdInfo = utils.getCurrencyInfo(utils.Currency.USD);
|
|
133
93
|
console.log('Currency code:', usdInfo.code);
|
|
134
94
|
console.log('Decimals:', usdInfo.decimals);
|
|
135
|
-
|
|
136
|
-
// Payment method utilities
|
|
137
|
-
const venmoId = getPaymentMethodId('venmo');
|
|
138
95
|
```
|
|
139
96
|
|
|
140
97
|
|
|
141
98
|
## API Reference
|
|
142
99
|
|
|
143
|
-
###
|
|
144
|
-
|
|
145
|
-
| Export | Type | Description |
|
|
146
|
-
|--------|------|-------------|
|
|
147
|
-
| `addresses` | Object | Network-specific contract addresses |
|
|
148
|
-
| `abis` | Object | Network-specific contract ABIs |
|
|
149
|
-
| `constants` | Object | Network-specific protocol constants |
|
|
150
|
-
| `paymentMethods` | Object | Network-specific payment method configs |
|
|
151
|
-
| `utils` | Object | Protocol utility functions |
|
|
152
|
-
| `Currency` | Enum | Currency enumeration |
|
|
153
|
-
| `getCurrencyInfo` | Function | Get currency details |
|
|
154
|
-
| `getPaymentMethodId` | Function | Get payment method identifier |
|
|
155
|
-
|
|
156
|
-
### Package Exports
|
|
157
|
-
|
|
158
|
-
The package provides multiple entry points:
|
|
159
|
-
|
|
160
|
-
```json
|
|
161
|
-
{
|
|
162
|
-
"@zkp2p/contracts-v2": "Main package exports",
|
|
163
|
-
"@zkp2p/contracts-v2/addresses": "Address exports only",
|
|
164
|
-
"@zkp2p/contracts-v2/addresses/*": "Network-specific addresses",
|
|
165
|
-
"@zkp2p/contracts-v2/abis/*": "Network-specific ABIs",
|
|
166
|
-
"@zkp2p/contracts-v2/constants": "Constants exports",
|
|
167
|
-
"@zkp2p/contracts-v2/constants/*": "Network-specific constants",
|
|
168
|
-
"@zkp2p/contracts-v2/paymentMethods": "Payment method configs",
|
|
169
|
-
"@zkp2p/contracts-v2/paymentMethods/*": "Network-specific payment methods",
|
|
170
|
-
"@zkp2p/contracts-v2/types": "TypeChain types",
|
|
171
|
-
"@zkp2p/contracts-v2/utils": "Utility functions"
|
|
172
|
-
}
|
|
173
|
-
```
|
|
100
|
+
### Imports
|
|
174
101
|
|
|
175
|
-
|
|
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`
|
|
176
109
|
|
|
177
|
-
|
|
110
|
+
## Development
|
|
178
111
|
|
|
179
|
-
|
|
180
|
-
- `yarn package:extract` - Extract addresses, ABIs, and constants from deployments
|
|
181
|
-
- `yarn package:build` - Build the package for distribution
|
|
112
|
+
### Build & Publish
|
|
182
113
|
|
|
183
|
-
From
|
|
184
|
-
- `yarn
|
|
185
|
-
- `
|
|
186
|
-
- `
|
|
187
|
-
- `yarn test` - Run package tests
|
|
114
|
+
From `packages/contracts`:
|
|
115
|
+
- `yarn build` – Clean, extract, and bundle to `dist/`
|
|
116
|
+
- `npm pack` – Preview tarball contents
|
|
117
|
+
- `npm publish --access public` – Publish (runs prepublishOnly)
|
|
188
118
|
|
|
189
|
-
|
|
119
|
+
Note: The package publishes `dist/` only. Tests and config files are excluded.
|
|
190
120
|
|
|
191
121
|
## License
|
|
192
122
|
|
|
@@ -196,4 +126,4 @@ MIT
|
|
|
196
126
|
|
|
197
127
|
- [GitHub Repository](https://github.com/zkp2p/zkp2p-v2-contracts)
|
|
198
128
|
- [Documentation](https://docs.zkp2p.xyz)
|
|
199
|
-
- [Website](https://zkp2p.xyz)
|
|
129
|
+
- [Website](https://zkp2p.xyz)
|
package/dist/addresses/base.json
CHANGED
package/dist/index.esm.js
CHANGED
package/dist/index.js
CHANGED