@provex/utils 1.0.16 → 1.2.4
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/dist/chain.d.ts +446 -0
- package/dist/chain.js +98 -0
- package/dist/chain.test.js +112 -0
- package/dist/contracts.d.ts +206 -0
- package/dist/contracts.js +292 -0
- package/dist/contracts.test.js +243 -0
- package/dist/conversionRates.d.ts +215 -0
- package/dist/{src/conversionRates.js → conversionRates.js} +74 -4
- package/dist/conversionRates.test.js +473 -0
- package/dist/currencies.d.ts +248 -0
- package/dist/{src/currencies.js → currencies.js} +119 -38
- package/dist/currencies.test.js +343 -0
- package/dist/data/countries.json +1099 -0
- package/dist/deposit.d.ts +69 -0
- package/dist/deposit.js +52 -0
- package/dist/depositKeys.d.ts +154 -0
- package/dist/depositKeys.js +104 -0
- package/dist/depositKeys.test.d.ts +1 -0
- package/dist/depositKeys.test.js +231 -0
- package/dist/events.d.ts +41 -0
- package/dist/events.js +92 -0
- package/dist/events.test.d.ts +1 -0
- package/dist/events.test.js +111 -0
- package/dist/fees.d.ts +136 -0
- package/dist/fees.js +178 -0
- package/dist/fees.test.d.ts +1 -0
- package/dist/fees.test.js +165 -0
- package/dist/ids.d.ts +175 -0
- package/dist/ids.js +231 -0
- package/dist/ids.test.d.ts +1 -0
- package/dist/ids.test.js +607 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +45 -0
- package/dist/input.d.ts +26 -0
- package/dist/{src/input.js → input.js} +23 -4
- package/dist/intent.d.ts +50 -0
- package/dist/intent.js +28 -0
- package/dist/intent.test.d.ts +1 -0
- package/dist/intent.test.js +119 -0
- package/dist/json.d.ts +55 -0
- package/dist/json.js +80 -0
- package/dist/participants.d.ts +22 -0
- package/dist/participants.js +28 -0
- package/dist/payment.d.ts +481 -0
- package/dist/payment.js +1149 -0
- package/dist/payment.test.d.ts +1 -0
- package/dist/payment.test.js +272 -0
- package/dist/peer-types.d.ts +327 -0
- package/dist/peer-types.js +169 -0
- package/dist/profit.d.ts +49 -0
- package/dist/profit.js +57 -0
- package/dist/profit.test.d.ts +1 -0
- package/dist/profit.test.js +315 -0
- package/dist/reputation.d.ts +125 -0
- package/dist/reputation.js +188 -0
- package/dist/reputation.test.d.ts +1 -0
- package/dist/reputation.test.js +156 -0
- package/dist/sort.d.ts +75 -0
- package/dist/sort.js +70 -0
- package/dist/sort.test.d.ts +1 -0
- package/dist/sort.test.js +216 -0
- package/dist/stateKey.d.ts +35 -0
- package/dist/stateKey.js +36 -0
- package/dist/stats.d.ts +61 -0
- package/dist/stats.js +53 -0
- package/dist/stats.test.d.ts +1 -0
- package/dist/stats.test.js +104 -0
- package/dist/time.d.ts +104 -0
- package/dist/time.js +162 -0
- package/dist/time.test.d.ts +1 -0
- package/dist/time.test.js +231 -0
- package/dist/tokens.d.ts +15502 -0
- package/dist/{src/tokens.js → tokens.js} +98 -17
- package/dist/tokens.test.d.ts +1 -0
- package/dist/tokens.test.js +193 -0
- package/dist/units.d.ts +200 -0
- package/dist/units.js +279 -0
- package/dist/units.test.d.ts +1 -0
- package/dist/units.test.js +327 -0
- package/package.json +119 -29
- package/dist/scripts/convert-svg.js +0 -17
- package/dist/src/chain.d.ts +0 -14
- package/dist/src/chain.js +0 -18
- package/dist/src/contracts.d.ts +0 -30
- package/dist/src/contracts.js +0 -64
- package/dist/src/conversionRates.d.ts +0 -124
- package/dist/src/currencies.d.ts +0 -144
- package/dist/src/data/countries.json +0 -1099
- package/dist/src/deposit.d.ts +0 -1
- package/dist/src/events.d.ts +0 -3
- package/dist/src/events.js +0 -16
- package/dist/src/ids.d.ts +0 -72
- package/dist/src/ids.js +0 -81
- package/dist/src/index.d.ts +0 -16
- package/dist/src/index.js +0 -16
- package/dist/src/input.d.ts +0 -7
- package/dist/src/intent.d.ts +0 -14
- package/dist/src/json.d.ts +0 -18
- package/dist/src/json.js +0 -44
- package/dist/src/participants.d.ts +0 -7
- package/dist/src/participants.js +0 -13
- package/dist/src/payment.d.ts +0 -164
- package/dist/src/payment.js +0 -439
- package/dist/src/profit.d.ts +0 -28
- package/dist/src/profit.js +0 -34
- package/dist/src/sort.d.ts +0 -36
- package/dist/src/sort.js +0 -39
- package/dist/src/stats.d.ts +0 -7
- package/dist/src/stats.js +0 -8
- package/dist/src/time.d.ts +0 -54
- package/dist/src/time.js +0 -106
- package/dist/src/tokens.d.ts +0 -3675
- package/dist/src/units.d.ts +0 -17
- package/dist/src/units.js +0 -79
- package/dist/src/zkp2p-types.d.ts +0 -48
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/scripts/convert-svg.ts +0 -22
- package/src/chain.ts +0 -27
- package/src/contracts.ts +0 -89
- package/src/conversionRates.ts +0 -356
- package/src/currencies.ts +0 -286
- package/src/data/countries.json +0 -1099
- package/src/deposit.ts +0 -2
- package/src/events.ts +0 -21
- package/src/flags/eur.svg +0 -4
- package/src/flags/usd.svg +0 -25
- package/src/flags.ts +0 -4
- package/src/global.d.ts +0 -9
- package/src/ids.ts +0 -137
- package/src/index.ts +0 -16
- package/src/input.ts +0 -35
- package/src/intent.ts +0 -15
- package/src/json.ts +0 -42
- package/src/participants.ts +0 -14
- package/src/payment.ts +0 -573
- package/src/profit.ts +0 -55
- package/src/sort.ts +0 -49
- package/src/stats.ts +0 -10
- package/src/time.ts +0 -123
- package/src/tokens.ts +0 -159
- package/src/units.ts +0 -120
- package/src/zkp2p-types.ts +0 -55
- package/tsconfig.json +0 -18
- /package/dist/{scripts/convert-svg.d.ts → chain.test.d.ts} +0 -0
- /package/dist/{src/deposit.js → contracts.test.d.ts} +0 -0
- /package/dist/{src/intent.js → conversionRates.test.d.ts} +0 -0
- /package/dist/{src/zkp2p-types.js → currencies.test.d.ts} +0 -0
- /package/dist/{src/flags.d.ts → flags.d.ts} +0 -0
- /package/dist/{src/flags.js → flags.js} +0 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Contract addresses and configuration for the Peer protocol.
|
|
3
|
+
*
|
|
4
|
+
* This module is the single source of truth for all deployed contract addresses
|
|
5
|
+
* across supported chains (Base, Pulsechain) and protocol versions (V2, V3).
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* **Version Strategy:**
|
|
9
|
+
* - V3 is the active version for all new transactions on both Base and Pulsechain
|
|
10
|
+
* - V2 contracts remain available for historical data access only
|
|
11
|
+
*
|
|
12
|
+
* **Contract Architecture (V3):**
|
|
13
|
+
* - Escrow: Holds depositor funds, manages deposit lifecycle
|
|
14
|
+
* - Orchestrator: Coordinates intents across escrows (read via escrow.orchestrator())
|
|
15
|
+
* - UnifiedPaymentVerifier: Verifies zkTLS proofs for all payment methods
|
|
16
|
+
* - PaymentVerifierRegistry: Maps payment method IDs to verifier contracts
|
|
17
|
+
*
|
|
18
|
+
* **Contract Architecture (V2 - Deprecated):**
|
|
19
|
+
* - Escrow: Simpler escrow without orchestrator
|
|
20
|
+
* - Per-provider verifiers: Separate contracts for Venmo, Zelle, etc.
|
|
21
|
+
*
|
|
22
|
+
* @see {@link chain} for chain configuration
|
|
23
|
+
* @see {@link abis} for contract ABIs
|
|
24
|
+
*/
|
|
25
|
+
import { type Hex } from 'viem';
|
|
26
|
+
import type { ChainId } from './chain.js';
|
|
27
|
+
/**
|
|
28
|
+
* Contract type definitions for the app.
|
|
29
|
+
*/
|
|
30
|
+
type NonEmptyArray<T> = [T, ...T[]];
|
|
31
|
+
export type V2Contracts = {
|
|
32
|
+
gatingService: Hex;
|
|
33
|
+
usdc: Hex;
|
|
34
|
+
escrow: NonEmptyArray<Hex>;
|
|
35
|
+
venmoReclaimVerifier: NonEmptyArray<Hex>;
|
|
36
|
+
revolutReclaimVerifier: NonEmptyArray<Hex>;
|
|
37
|
+
cashappReclaimVerifier: NonEmptyArray<Hex>;
|
|
38
|
+
wiseReclaimVerifier: NonEmptyArray<Hex>;
|
|
39
|
+
mercadopagoReclaimVerifier: NonEmptyArray<Hex>;
|
|
40
|
+
zelleBaseVerifier: NonEmptyArray<Hex>;
|
|
41
|
+
zelleBoAReclaimVerifier: NonEmptyArray<Hex>;
|
|
42
|
+
zelleChaseReclaimVerifier: NonEmptyArray<Hex>;
|
|
43
|
+
zelleCitiReclaimVerifier: NonEmptyArray<Hex>;
|
|
44
|
+
paypalReclaimVerifier: NonEmptyArray<Hex>;
|
|
45
|
+
monzoReclaimVerifier: NonEmptyArray<Hex>;
|
|
46
|
+
};
|
|
47
|
+
export type V3Contracts = {
|
|
48
|
+
usdc: Hex;
|
|
49
|
+
gatingService: Hex;
|
|
50
|
+
escrow: NonEmptyArray<Hex>;
|
|
51
|
+
unifiedPaymentVerifier: NonEmptyArray<Hex>;
|
|
52
|
+
};
|
|
53
|
+
export type ContractKey = keyof V2Contracts | keyof V3Contracts;
|
|
54
|
+
export declare const reclaimSigners: {
|
|
55
|
+
readonly peerWitnessSigner: "0x0636c417755E3ae25C6c166D181c0607F4C572A3";
|
|
56
|
+
readonly reclaimWitnessSigner: "0x244897572368eadf65bfbc5aec98d8e5443a9072";
|
|
57
|
+
};
|
|
58
|
+
export declare const v2BaseContracts: V2Contracts;
|
|
59
|
+
export declare const v2PulsechainContracts: V2Contracts;
|
|
60
|
+
export declare const v3BaseContracts: V3Contracts;
|
|
61
|
+
/**
|
|
62
|
+
* V3 contracts deployed to Pulsechain (Chain ID 369)
|
|
63
|
+
* Deployed: 2026-01-12
|
|
64
|
+
* Deployer: 0xC3c7e05D1BA19563693D891e5c38f0FC988A5d11
|
|
65
|
+
* MultiSig: 0x948eB6D3A08BEb29Dc1D08d09753862573A94122
|
|
66
|
+
*/
|
|
67
|
+
export declare const v3PulsechainContracts: V3Contracts;
|
|
68
|
+
/**
|
|
69
|
+
* V3 Pulsechain protocol contract addresses - FOR REFERENCE ONLY
|
|
70
|
+
*
|
|
71
|
+
* DO NOT use these directly in code. The orchestrator and paymentVerifierRegistry
|
|
72
|
+
* addresses should be read dynamically from the escrow contract at runtime.
|
|
73
|
+
* See ponder.config.ts `callEach()` for the correct pattern.
|
|
74
|
+
*/
|
|
75
|
+
export declare const V3_PULSECHAIN_DEPLOYMENT_REFERENCE: {
|
|
76
|
+
readonly orchestrator: "0x742d48639F44701Bff5A0A441600AD6DA4A3b080";
|
|
77
|
+
readonly paymentVerifierRegistry: "0x6a4fF1950Be05995dEe75920cf27CD8FEbB6597A";
|
|
78
|
+
readonly protocolViewer: "0x31dD72E1a385F98F4e6A94330c8121d2Ed62Ab72";
|
|
79
|
+
readonly escrowRegistry: "0x7238d0B6a28a3a6e3DfCd281D7Cb9b3250B30EA6";
|
|
80
|
+
readonly postIntentHookRegistry: "0x94F510fa245843Ff5eDa2d18479FE63ac51F8fE6";
|
|
81
|
+
readonly relayerRegistry: "0x689F82b4078aA07F443af9ae308534bD2Ff545D3";
|
|
82
|
+
readonly nullifierRegistry: "0x4AeA2288ec542963256b66D70EfddF4cB8754f82";
|
|
83
|
+
readonly simpleAttestationVerifier: "0x49DAd1f29a3FE2E4D90a59e6687d9f7A2836B4a8";
|
|
84
|
+
};
|
|
85
|
+
export declare const versions: {
|
|
86
|
+
readonly V2: "v2";
|
|
87
|
+
readonly V3: "v3";
|
|
88
|
+
};
|
|
89
|
+
export declare const versionKeys: ("v2" | "v3")[];
|
|
90
|
+
export type Version = (typeof versionKeys)[number];
|
|
91
|
+
/**
|
|
92
|
+
* Contract addresses organized by version and chain.
|
|
93
|
+
*
|
|
94
|
+
* @important v3 on Base is the active version for the buy/sell UI.
|
|
95
|
+
* v2 contracts are deprecated but remain for historical data access.
|
|
96
|
+
*/
|
|
97
|
+
export declare const contracts: {
|
|
98
|
+
v2: {
|
|
99
|
+
8453: V2Contracts;
|
|
100
|
+
369: V2Contracts;
|
|
101
|
+
};
|
|
102
|
+
v3: {
|
|
103
|
+
8453: V3Contracts;
|
|
104
|
+
369: V3Contracts;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Get contracts for a specific version and chain.
|
|
109
|
+
* @param version - The contract version (v2 or v3)
|
|
110
|
+
* @param chainId - The chain ID
|
|
111
|
+
* @returns The contracts for that version and chain, or null if not found
|
|
112
|
+
*/
|
|
113
|
+
export declare const getContracts: (version: Version, chainId: ChainId) => V2Contracts | V3Contracts;
|
|
114
|
+
/**
|
|
115
|
+
* Get the latest deployed contract address for a given key.
|
|
116
|
+
*
|
|
117
|
+
* @important This function defaults to Base v3 contracts for the buy/sell UI.
|
|
118
|
+
* v2 contracts are deprecated for new transactions.
|
|
119
|
+
*
|
|
120
|
+
* When contracts are upgraded, the latest version is at the end of the array.
|
|
121
|
+
*
|
|
122
|
+
* @param chainId - The chain ID
|
|
123
|
+
* @param key - The contract key (e.g., 'escrow', 'usdc', 'unifiedPaymentVerifier')
|
|
124
|
+
* @param version - Optional version override for accessing historical v2 data
|
|
125
|
+
* @returns The contract address, or null if not found
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* // Get Base v3 escrow (default for buy/sell UI)
|
|
129
|
+
* const escrow = getLatestContract(base.id, 'escrow')
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* // Explicitly get v2 contract for historical data
|
|
133
|
+
* const v2Escrow = getLatestContract(pulsechain.id, 'escrow', 'v2')
|
|
134
|
+
*/
|
|
135
|
+
export declare const getLatestContract: (chainId: ChainId, key: ContractKey, version?: Version) => Hex | null;
|
|
136
|
+
/**
|
|
137
|
+
* Represents a unique escrow location identified by version, chain, and address
|
|
138
|
+
*/
|
|
139
|
+
export type EscrowLocation = {
|
|
140
|
+
version: Version;
|
|
141
|
+
chainId: ChainId;
|
|
142
|
+
escrow: Hex;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Get all escrow contracts across all versions and chains.
|
|
146
|
+
* Returns a flat list of all escrow locations for querying deposits.
|
|
147
|
+
*
|
|
148
|
+
* @returns Array of escrow locations with version, chainId, and escrow address
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* // Get all escrows to search for a deposit
|
|
152
|
+
* const escrows = getAllEscrowContracts()
|
|
153
|
+
* // [
|
|
154
|
+
* // { version: 'v2', chainId: 8453, escrow: '0xCA38...' },
|
|
155
|
+
* // { version: 'v2', chainId: 369, escrow: '0x2932...' },
|
|
156
|
+
* // { version: 'v3', chainId: 8453, escrow: '0x2f12...' },
|
|
157
|
+
* // ]
|
|
158
|
+
*/
|
|
159
|
+
export declare function getAllEscrowContracts(): EscrowLocation[];
|
|
160
|
+
/**
|
|
161
|
+
* Get all V3 escrow contracts across all chains.
|
|
162
|
+
* Used for cross-chain nullifier checking to prevent double-spending.
|
|
163
|
+
*
|
|
164
|
+
* @returns Array of V3 escrow locations with chainId and escrow address
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* const v3Escrows = getAllV3EscrowContracts()
|
|
168
|
+
* // [
|
|
169
|
+
* // { version: 'v3', chainId: 8453, escrow: '0x2f12...' },
|
|
170
|
+
* // { version: 'v3', chainId: 369, escrow: '0x0B42...' },
|
|
171
|
+
* // ]
|
|
172
|
+
*/
|
|
173
|
+
export declare function getAllV3EscrowContracts(): EscrowLocation[];
|
|
174
|
+
/**
|
|
175
|
+
* Get a short display label for an escrow address (first 6 + last 4 chars)
|
|
176
|
+
* @param escrow - The escrow address
|
|
177
|
+
* @returns Shortened address string
|
|
178
|
+
*/
|
|
179
|
+
export declare function shortenEscrowAddress(escrow: Hex): string;
|
|
180
|
+
/**
|
|
181
|
+
* Get the version of an escrow contract by looking up its address.
|
|
182
|
+
*
|
|
183
|
+
* @param escrowAddress - The escrow contract address to look up
|
|
184
|
+
* @param chainId - Optional chain ID to narrow down the search
|
|
185
|
+
* @returns The escrow version ('v2' or 'v3'), or null if not found
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* // Determine if escrow supports V3 features
|
|
189
|
+
* const version = getEscrowVersion(deposit.escrow, deposit.chainId)
|
|
190
|
+
* const isV3 = version === 'v3'
|
|
191
|
+
*/
|
|
192
|
+
export declare function getEscrowVersion(escrowAddress: Hex, chainId?: ChainId): Version | null;
|
|
193
|
+
/**
|
|
194
|
+
* Check if an escrow address is a V3 contract.
|
|
195
|
+
* Convenience function for feature gating V3-only functionality.
|
|
196
|
+
*
|
|
197
|
+
* @param escrowAddress - The escrow contract address
|
|
198
|
+
* @param chainId - The chain ID
|
|
199
|
+
* @returns true if the escrow is V3, false otherwise
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* // Gate V3-only features in UI
|
|
203
|
+
* const showRetainToggle = isV3Escrow(deposit.escrow, deposit.chainId) && isOwner
|
|
204
|
+
*/
|
|
205
|
+
export declare function isV3Escrow(escrowAddress: Hex, chainId: ChainId): boolean;
|
|
206
|
+
export {};
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Contract addresses and configuration for the Peer protocol.
|
|
3
|
+
*
|
|
4
|
+
* This module is the single source of truth for all deployed contract addresses
|
|
5
|
+
* across supported chains (Base, Pulsechain) and protocol versions (V2, V3).
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* **Version Strategy:**
|
|
9
|
+
* - V3 is the active version for all new transactions on both Base and Pulsechain
|
|
10
|
+
* - V2 contracts remain available for historical data access only
|
|
11
|
+
*
|
|
12
|
+
* **Contract Architecture (V3):**
|
|
13
|
+
* - Escrow: Holds depositor funds, manages deposit lifecycle
|
|
14
|
+
* - Orchestrator: Coordinates intents across escrows (read via escrow.orchestrator())
|
|
15
|
+
* - UnifiedPaymentVerifier: Verifies zkTLS proofs for all payment methods
|
|
16
|
+
* - PaymentVerifierRegistry: Maps payment method IDs to verifier contracts
|
|
17
|
+
*
|
|
18
|
+
* **Contract Architecture (V2 - Deprecated):**
|
|
19
|
+
* - Escrow: Simpler escrow without orchestrator
|
|
20
|
+
* - Per-provider verifiers: Separate contracts for Venmo, Zelle, etc.
|
|
21
|
+
*
|
|
22
|
+
* @see {@link chain} for chain configuration
|
|
23
|
+
* @see {@link abis} for contract ABIs
|
|
24
|
+
*/
|
|
25
|
+
import { getAddress } from 'viem';
|
|
26
|
+
import { base, pulsechain } from 'viem/chains';
|
|
27
|
+
export const reclaimSigners = {
|
|
28
|
+
peerWitnessSigner: '0x0636c417755E3ae25C6c166D181c0607F4C572A3',
|
|
29
|
+
reclaimWitnessSigner: '0x244897572368eadf65bfbc5aec98d8e5443a9072',
|
|
30
|
+
};
|
|
31
|
+
export const v2BaseContracts = {
|
|
32
|
+
gatingService: getAddress('0x396D31055Db28C0C6f36e8b36f18FE7227248a97'),
|
|
33
|
+
usdc: getAddress('0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'),
|
|
34
|
+
escrow: [getAddress('0xCA38607D85E8F6294Dc10728669605E6664C2D70')],
|
|
35
|
+
venmoReclaimVerifier: [getAddress('0x9a733B55a875D0DB4915c6B36350b24F8AB99dF5')],
|
|
36
|
+
revolutReclaimVerifier: [getAddress('0xAA5A1B62B01781E789C900d616300717CD9A41aB')],
|
|
37
|
+
cashappReclaimVerifier: [getAddress('0x76D33A33068D86016B806dF02376dDBb23Dd3703')],
|
|
38
|
+
wiseReclaimVerifier: [getAddress('0xFF0149799631D7A5bdE2e7eA9b306c42b3d9a9ca')],
|
|
39
|
+
mercadopagoReclaimVerifier: [
|
|
40
|
+
// getAddress('0x00d003c73eab8feaec04bab976235915fe7641e3'),
|
|
41
|
+
getAddress('0xf2AC5be14F32Cbe6A613CFF8931d95460D6c33A3'),
|
|
42
|
+
],
|
|
43
|
+
zelleBaseVerifier: [
|
|
44
|
+
// getAddress('0x1783f040783c0827fb64d128ece548d9b3613ad5'),
|
|
45
|
+
getAddress('0x431a078A5029146aAB239c768A615CD484519aF7'),
|
|
46
|
+
],
|
|
47
|
+
zelleChaseReclaimVerifier: [getAddress('0xBcD7C6BBcA5869fBefe3E322263EE1090221D7A9')],
|
|
48
|
+
zelleBoAReclaimVerifier: [getAddress('0x809c7A20A2dbBB3210fC73Dd7C01Cd7Fa70C195F')],
|
|
49
|
+
zelleCitiReclaimVerifier: [getAddress('0x3128badc46dbe2e37bdd2d64f33fb3b3a639570e')],
|
|
50
|
+
paypalReclaimVerifier: [getAddress('0x03d17E9371C858072E171276979f6B44571C5DeA')],
|
|
51
|
+
monzoReclaimVerifier: [getAddress('0x0dE46433bD251027f73eD8f28E01eF05DA36a2E0')],
|
|
52
|
+
};
|
|
53
|
+
export const v2PulsechainContracts = {
|
|
54
|
+
gatingService: getAddress('0x4Bd6364FCC4D8A537aBfee33B16E959794fDf9Cf'),
|
|
55
|
+
usdc: getAddress('0x15D38573d2feeb82e7ad5187aB8c1D52810B1f07'),
|
|
56
|
+
escrow: [getAddress('0x2932E08BFD212Ef0732257bDd6463BF55E9b97d7')],
|
|
57
|
+
cashappReclaimVerifier: [getAddress('0x9224433D6AD9a5A774ca74Ca33c01747FA710A9d')],
|
|
58
|
+
mercadopagoReclaimVerifier: [getAddress('0xc4D0cf4DF12e329f9c951d1D9BB815da6138850A')],
|
|
59
|
+
monzoReclaimVerifier: [getAddress('0xBde2c79c1897459e66C0fdF6764EED0c6839C878')],
|
|
60
|
+
nullifierRegistry: [getAddress('0x471D3c6C9E32CE2556d0117aC161Aa82AEac17d8')],
|
|
61
|
+
paypalReclaimVerifier: [getAddress('0x1DdBfd39a141C5A2329d849CADa6a83404E0Ce4F')],
|
|
62
|
+
revolutReclaimVerifier: [getAddress('0x8234AA463C8B94778f58eA0bFEfcBAC3683341A9')],
|
|
63
|
+
venmoReclaimVerifier: [getAddress('0x0Dd524dA03f610480aF3F433B411b6016cFBDeab')],
|
|
64
|
+
wiseReclaimVerifier: [getAddress('0x7B72d7CfAfDfD397E2460c933e84D16dc121845a')],
|
|
65
|
+
zelleBaseVerifier: [getAddress('0x539566771f9c38c6038aafc1946bf11af9cdb201')],
|
|
66
|
+
zelleBoAReclaimVerifier: [getAddress('0x506a746b8228F9f9d4522105b973Dc7223A64EAC')],
|
|
67
|
+
zelleChaseReclaimVerifier: [getAddress('0xB0aA0a58959465bBCf0eCbD62A84B743A5435c99')],
|
|
68
|
+
zelleCitiReclaimVerifier: [getAddress('0x5624E479924eBFb25B51F36e3FDaE605dADb448b')],
|
|
69
|
+
};
|
|
70
|
+
export const v3BaseContracts = {
|
|
71
|
+
usdc: getAddress('0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'),
|
|
72
|
+
gatingService: getAddress('0x5106a86819ed6bb82c77ccbfc151250e1d369dba'),
|
|
73
|
+
escrow: [
|
|
74
|
+
getAddress('0x2f121CDDCA6d652f35e8B3E560f9760898888888'),
|
|
75
|
+
getAddress('0x777777779d229cdf3110e9de47943791c26300ef'),
|
|
76
|
+
],
|
|
77
|
+
unifiedPaymentVerifier: [
|
|
78
|
+
getAddress('0x16b3e4a3CA36D3A4bCA281767f15C7ADeF4ab163'),
|
|
79
|
+
getAddress('0x46A58Dc65587D4D7B8198C6A25eEdf5b2535Da94'),
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* V3 contracts deployed to Pulsechain (Chain ID 369)
|
|
84
|
+
* Deployed: 2026-01-12
|
|
85
|
+
* Deployer: 0xC3c7e05D1BA19563693D891e5c38f0FC988A5d11
|
|
86
|
+
* MultiSig: 0x948eB6D3A08BEb29Dc1D08d09753862573A94122
|
|
87
|
+
*/
|
|
88
|
+
export const v3PulsechainContracts = {
|
|
89
|
+
usdc: getAddress('0x15D38573d2feeb82e7ad5187aB8c1D52810B1f07'),
|
|
90
|
+
gatingService: getAddress('0x4Bd6364FCC4D8A537aBfee33B16E959794fDf9Cf'),
|
|
91
|
+
escrow: [getAddress('0x0B42393d4DBA08892d339b32Cd3064248003f11a')],
|
|
92
|
+
unifiedPaymentVerifier: [getAddress('0x0e73181a60C6a58Eb9298bCf28781E1d46cd81Db')],
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* V3 Pulsechain protocol contract addresses - FOR REFERENCE ONLY
|
|
96
|
+
*
|
|
97
|
+
* DO NOT use these directly in code. The orchestrator and paymentVerifierRegistry
|
|
98
|
+
* addresses should be read dynamically from the escrow contract at runtime.
|
|
99
|
+
* See ponder.config.ts `callEach()` for the correct pattern.
|
|
100
|
+
*/
|
|
101
|
+
export const V3_PULSECHAIN_DEPLOYMENT_REFERENCE = {
|
|
102
|
+
orchestrator: '0x742d48639F44701Bff5A0A441600AD6DA4A3b080', // read via escrow.orchestrator()
|
|
103
|
+
paymentVerifierRegistry: '0x6a4fF1950Be05995dEe75920cf27CD8FEbB6597A', // read via escrow.paymentVerifierRegistry()
|
|
104
|
+
protocolViewer: '0x31dD72E1a385F98F4e6A94330c8121d2Ed62Ab72', // static registry
|
|
105
|
+
escrowRegistry: '0x7238d0B6a28a3a6e3DfCd281D7Cb9b3250B30EA6',
|
|
106
|
+
postIntentHookRegistry: '0x94F510fa245843Ff5eDa2d18479FE63ac51F8fE6',
|
|
107
|
+
relayerRegistry: '0x689F82b4078aA07F443af9ae308534bD2Ff545D3',
|
|
108
|
+
nullifierRegistry: '0x4AeA2288ec542963256b66D70EfddF4cB8754f82',
|
|
109
|
+
simpleAttestationVerifier: '0x49DAd1f29a3FE2E4D90a59e6687d9f7A2836B4a8',
|
|
110
|
+
};
|
|
111
|
+
export const versions = {
|
|
112
|
+
V2: 'v2', // Deprecated: Historical data only
|
|
113
|
+
V3: 'v3', // Active: Primary version for Base buy/sell UI
|
|
114
|
+
};
|
|
115
|
+
export const versionKeys = Object.values(versions);
|
|
116
|
+
/**
|
|
117
|
+
* Contract addresses organized by version and chain.
|
|
118
|
+
*
|
|
119
|
+
* @important v3 on Base is the active version for the buy/sell UI.
|
|
120
|
+
* v2 contracts are deprecated but remain for historical data access.
|
|
121
|
+
*/
|
|
122
|
+
export const contracts = {
|
|
123
|
+
v2: {
|
|
124
|
+
// Deprecated: Historical data only
|
|
125
|
+
[base.id]: v2BaseContracts,
|
|
126
|
+
[pulsechain.id]: v2PulsechainContracts,
|
|
127
|
+
},
|
|
128
|
+
v3: {
|
|
129
|
+
// Active: Primary version for buy/sell UI
|
|
130
|
+
[base.id]: v3BaseContracts,
|
|
131
|
+
[pulsechain.id]: v3PulsechainContracts,
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Get the default version for a given chain.
|
|
136
|
+
*
|
|
137
|
+
* @important Both Base and Pulsechain now use v3 as the primary version.
|
|
138
|
+
* v2 contracts are deprecated for new transactions but remain available for historical data.
|
|
139
|
+
*
|
|
140
|
+
* @param chainId - The chain ID
|
|
141
|
+
* @returns The default contract version for the chain
|
|
142
|
+
*
|
|
143
|
+
* Defaults:
|
|
144
|
+
* - Base: v3 (active, used for all new transactions)
|
|
145
|
+
* - PulseChain: v3 (active, deployed 2026-01-12)
|
|
146
|
+
* - All others: v3
|
|
147
|
+
*/
|
|
148
|
+
const getDefaultVersion = (_chainId) => {
|
|
149
|
+
// Both Base and Pulsechain use v3 for all new transactions
|
|
150
|
+
return 'v3';
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Get contracts for a specific version and chain.
|
|
154
|
+
* @param version - The contract version (v2 or v3)
|
|
155
|
+
* @param chainId - The chain ID
|
|
156
|
+
* @returns The contracts for that version and chain, or null if not found
|
|
157
|
+
*/
|
|
158
|
+
export const getContracts = (version, chainId) => {
|
|
159
|
+
return version === 'v2' ? contracts.v2[chainId] : contracts.v3[chainId];
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Get the latest deployed contract address for a given key.
|
|
163
|
+
*
|
|
164
|
+
* @important This function defaults to Base v3 contracts for the buy/sell UI.
|
|
165
|
+
* v2 contracts are deprecated for new transactions.
|
|
166
|
+
*
|
|
167
|
+
* When contracts are upgraded, the latest version is at the end of the array.
|
|
168
|
+
*
|
|
169
|
+
* @param chainId - The chain ID
|
|
170
|
+
* @param key - The contract key (e.g., 'escrow', 'usdc', 'unifiedPaymentVerifier')
|
|
171
|
+
* @param version - Optional version override for accessing historical v2 data
|
|
172
|
+
* @returns The contract address, or null if not found
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* // Get Base v3 escrow (default for buy/sell UI)
|
|
176
|
+
* const escrow = getLatestContract(base.id, 'escrow')
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* // Explicitly get v2 contract for historical data
|
|
180
|
+
* const v2Escrow = getLatestContract(pulsechain.id, 'escrow', 'v2')
|
|
181
|
+
*/
|
|
182
|
+
export const getLatestContract = (chainId, key, version) => {
|
|
183
|
+
const v = version ?? getDefaultVersion(chainId);
|
|
184
|
+
const chainContracts = getContracts(v, chainId);
|
|
185
|
+
if (!chainContracts) {
|
|
186
|
+
console.log('No contracts found for chainId', v, chainId);
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
const target = chainContracts[key];
|
|
190
|
+
if (!target)
|
|
191
|
+
return null;
|
|
192
|
+
return Array.isArray(target) ? target.at(-1) : target;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Get all escrow contracts across all versions and chains.
|
|
196
|
+
* Returns a flat list of all escrow locations for querying deposits.
|
|
197
|
+
*
|
|
198
|
+
* @returns Array of escrow locations with version, chainId, and escrow address
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* // Get all escrows to search for a deposit
|
|
202
|
+
* const escrows = getAllEscrowContracts()
|
|
203
|
+
* // [
|
|
204
|
+
* // { version: 'v2', chainId: 8453, escrow: '0xCA38...' },
|
|
205
|
+
* // { version: 'v2', chainId: 369, escrow: '0x2932...' },
|
|
206
|
+
* // { version: 'v3', chainId: 8453, escrow: '0x2f12...' },
|
|
207
|
+
* // ]
|
|
208
|
+
*/
|
|
209
|
+
export function getAllEscrowContracts() {
|
|
210
|
+
const escrows = [];
|
|
211
|
+
for (const [version, chainContracts] of Object.entries(contracts)) {
|
|
212
|
+
for (const [chainIdStr, c] of Object.entries(chainContracts)) {
|
|
213
|
+
const chainId = Number(chainIdStr);
|
|
214
|
+
const contractsForChain = c;
|
|
215
|
+
if (contractsForChain.escrow) {
|
|
216
|
+
for (const escrow of contractsForChain.escrow) {
|
|
217
|
+
escrows.push({
|
|
218
|
+
version: version,
|
|
219
|
+
chainId,
|
|
220
|
+
escrow,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return escrows;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Get all V3 escrow contracts across all chains.
|
|
230
|
+
* Used for cross-chain nullifier checking to prevent double-spending.
|
|
231
|
+
*
|
|
232
|
+
* @returns Array of V3 escrow locations with chainId and escrow address
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* const v3Escrows = getAllV3EscrowContracts()
|
|
236
|
+
* // [
|
|
237
|
+
* // { version: 'v3', chainId: 8453, escrow: '0x2f12...' },
|
|
238
|
+
* // { version: 'v3', chainId: 369, escrow: '0x0B42...' },
|
|
239
|
+
* // ]
|
|
240
|
+
*/
|
|
241
|
+
export function getAllV3EscrowContracts() {
|
|
242
|
+
return getAllEscrowContracts().filter((loc) => loc.version === 'v3');
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Get a short display label for an escrow address (first 6 + last 4 chars)
|
|
246
|
+
* @param escrow - The escrow address
|
|
247
|
+
* @returns Shortened address string
|
|
248
|
+
*/
|
|
249
|
+
export function shortenEscrowAddress(escrow) {
|
|
250
|
+
return `${escrow.slice(0, 6)}...${escrow.slice(-4)}`;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Get the version of an escrow contract by looking up its address.
|
|
254
|
+
*
|
|
255
|
+
* @param escrowAddress - The escrow contract address to look up
|
|
256
|
+
* @param chainId - Optional chain ID to narrow down the search
|
|
257
|
+
* @returns The escrow version ('v2' or 'v3'), or null if not found
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* // Determine if escrow supports V3 features
|
|
261
|
+
* const version = getEscrowVersion(deposit.escrow, deposit.chainId)
|
|
262
|
+
* const isV3 = version === 'v3'
|
|
263
|
+
*/
|
|
264
|
+
export function getEscrowVersion(escrowAddress, chainId) {
|
|
265
|
+
const normalizedAddress = escrowAddress.toLowerCase();
|
|
266
|
+
const allEscrows = getAllEscrowContracts();
|
|
267
|
+
for (const location of allEscrows) {
|
|
268
|
+
// If chainId is provided, skip non-matching chains
|
|
269
|
+
if (chainId !== undefined && location.chainId !== chainId) {
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
if (location.escrow.toLowerCase() === normalizedAddress) {
|
|
273
|
+
return location.version;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Check if an escrow address is a V3 contract.
|
|
280
|
+
* Convenience function for feature gating V3-only functionality.
|
|
281
|
+
*
|
|
282
|
+
* @param escrowAddress - The escrow contract address
|
|
283
|
+
* @param chainId - The chain ID
|
|
284
|
+
* @returns true if the escrow is V3, false otherwise
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* // Gate V3-only features in UI
|
|
288
|
+
* const showRetainToggle = isV3Escrow(deposit.escrow, deposit.chainId) && isOwner
|
|
289
|
+
*/
|
|
290
|
+
export function isV3Escrow(escrowAddress, chainId) {
|
|
291
|
+
return getEscrowVersion(escrowAddress, chainId) === 'v3';
|
|
292
|
+
}
|