@provex/utils 1.0.16 → 1.2.3

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 (122) hide show
  1. package/dist/src/chain.d.ts +436 -4
  2. package/dist/src/chain.js +80 -0
  3. package/dist/src/chain.test.d.ts +1 -0
  4. package/dist/src/chain.test.js +112 -0
  5. package/dist/src/contracts.d.ts +196 -20
  6. package/dist/src/contracts.js +245 -17
  7. package/dist/src/contracts.test.d.ts +1 -0
  8. package/dist/src/contracts.test.js +243 -0
  9. package/dist/src/conversionRates.d.ts +99 -8
  10. package/dist/src/conversionRates.js +74 -4
  11. package/dist/src/conversionRates.test.d.ts +1 -0
  12. package/dist/src/conversionRates.test.js +473 -0
  13. package/dist/src/currencies.d.ts +113 -9
  14. package/dist/src/currencies.js +119 -38
  15. package/dist/src/currencies.test.d.ts +1 -0
  16. package/dist/src/currencies.test.js +343 -0
  17. package/dist/src/data/countries.json +166 -166
  18. package/dist/src/deposit.d.ts +69 -1
  19. package/dist/src/deposit.js +52 -1
  20. package/dist/src/depositKeys.d.ts +154 -0
  21. package/dist/src/depositKeys.js +104 -0
  22. package/dist/src/depositKeys.test.d.ts +1 -0
  23. package/dist/src/depositKeys.test.js +231 -0
  24. package/dist/src/endpoints.d.ts +51 -0
  25. package/dist/src/endpoints.js +70 -0
  26. package/dist/src/endpoints.test.d.ts +1 -0
  27. package/dist/src/endpoints.test.js +54 -0
  28. package/dist/src/events.d.ts +40 -2
  29. package/dist/src/events.js +86 -10
  30. package/dist/src/events.test.d.ts +1 -0
  31. package/dist/src/events.test.js +111 -0
  32. package/dist/src/fees.d.ts +136 -0
  33. package/dist/src/fees.js +178 -0
  34. package/dist/src/fees.test.d.ts +1 -0
  35. package/dist/src/fees.test.js +165 -0
  36. package/dist/src/ids.d.ts +125 -22
  37. package/dist/src/ids.js +211 -61
  38. package/dist/src/ids.test.d.ts +1 -0
  39. package/dist/src/ids.test.js +607 -0
  40. package/dist/src/index.d.ts +30 -1
  41. package/dist/src/index.js +30 -1
  42. package/dist/src/input.d.ts +23 -4
  43. package/dist/src/input.js +23 -4
  44. package/dist/src/intent.d.ts +38 -2
  45. package/dist/src/intent.js +28 -1
  46. package/dist/src/intent.test.d.ts +1 -0
  47. package/dist/src/intent.test.js +119 -0
  48. package/dist/src/json.d.ts +38 -1
  49. package/dist/src/json.js +38 -2
  50. package/dist/src/normalization.d.ts +224 -0
  51. package/dist/src/normalization.js +119 -0
  52. package/dist/src/normalization.test.d.ts +1 -0
  53. package/dist/src/normalization.test.js +284 -0
  54. package/dist/src/participants.d.ts +19 -4
  55. package/dist/src/participants.js +19 -4
  56. package/dist/src/payment.d.ts +333 -16
  57. package/dist/src/payment.js +768 -58
  58. package/dist/src/payment.test.d.ts +1 -0
  59. package/dist/src/payment.test.js +272 -0
  60. package/dist/src/peer-types.d.ts +327 -0
  61. package/dist/src/peer-types.js +169 -0
  62. package/dist/src/profit.d.ts +26 -5
  63. package/dist/src/profit.js +31 -8
  64. package/dist/src/profit.test.d.ts +1 -0
  65. package/dist/src/profit.test.js +315 -0
  66. package/dist/src/reputation.d.ts +125 -0
  67. package/dist/src/reputation.js +188 -0
  68. package/dist/src/reputation.test.d.ts +1 -0
  69. package/dist/src/reputation.test.js +156 -0
  70. package/dist/src/sort.d.ts +49 -10
  71. package/dist/src/sort.js +40 -9
  72. package/dist/src/sort.test.d.ts +1 -0
  73. package/dist/src/sort.test.js +216 -0
  74. package/dist/src/stateKey.d.ts +35 -0
  75. package/dist/src/stateKey.js +36 -0
  76. package/dist/src/stats.d.ts +55 -1
  77. package/dist/src/stats.js +46 -1
  78. package/dist/src/stats.test.d.ts +1 -0
  79. package/dist/src/stats.test.js +104 -0
  80. package/dist/src/time.d.ts +59 -9
  81. package/dist/src/time.js +71 -15
  82. package/dist/src/time.test.d.ts +1 -0
  83. package/dist/src/time.test.js +231 -0
  84. package/dist/src/tokens.d.ts +11972 -145
  85. package/dist/src/tokens.js +98 -17
  86. package/dist/src/tokens.test.d.ts +1 -0
  87. package/dist/src/tokens.test.js +193 -0
  88. package/dist/src/units.d.ts +183 -0
  89. package/dist/src/units.js +206 -6
  90. package/dist/src/units.test.d.ts +1 -0
  91. package/dist/src/units.test.js +327 -0
  92. package/dist/src/zkp2p-types.d.ts +273 -4
  93. package/dist/src/zkp2p-types.js +169 -1
  94. package/dist/tsconfig.tsbuildinfo +1 -1
  95. package/package.json +116 -26
  96. package/scripts/convert-svg.ts +0 -22
  97. package/src/chain.ts +0 -27
  98. package/src/contracts.ts +0 -89
  99. package/src/conversionRates.ts +0 -356
  100. package/src/currencies.ts +0 -286
  101. package/src/data/countries.json +0 -1099
  102. package/src/deposit.ts +0 -2
  103. package/src/events.ts +0 -21
  104. package/src/flags/eur.svg +0 -4
  105. package/src/flags/usd.svg +0 -25
  106. package/src/flags.ts +0 -4
  107. package/src/global.d.ts +0 -9
  108. package/src/ids.ts +0 -137
  109. package/src/index.ts +0 -16
  110. package/src/input.ts +0 -35
  111. package/src/intent.ts +0 -15
  112. package/src/json.ts +0 -42
  113. package/src/participants.ts +0 -14
  114. package/src/payment.ts +0 -573
  115. package/src/profit.ts +0 -55
  116. package/src/sort.ts +0 -49
  117. package/src/stats.ts +0 -10
  118. package/src/time.ts +0 -123
  119. package/src/tokens.ts +0 -159
  120. package/src/units.ts +0 -120
  121. package/src/zkp2p-types.ts +0 -55
  122. package/tsconfig.json +0 -18
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,272 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { base } from 'viem/chains';
4
+ import { providerConfigs, getCurrenciesForProvider, verifierGetsKey, providerKeyToContractId } from './payment.js';
5
+ import { SUPPORTED_CURRENCIES } from './currencies.js';
6
+ describe('getCurrenciesForProvider', () => {
7
+ const configs = providerConfigs(base.id);
8
+ describe('Zelle (USD only)', () => {
9
+ it('returns exactly 1 currency', () => {
10
+ const currencies = getCurrenciesForProvider(configs.zelle);
11
+ assert.equal(currencies.length, 1, `Expected 1 currency for Zelle, got ${currencies.length}`);
12
+ });
13
+ it('returns USD', () => {
14
+ const currencies = getCurrenciesForProvider(configs.zelle);
15
+ assert.equal(currencies[0].ticker, 'USD');
16
+ });
17
+ it('does not include EUR', () => {
18
+ const currencies = getCurrenciesForProvider(configs.zelle);
19
+ const tickers = currencies.map(c => c.ticker);
20
+ assert.ok(!tickers.includes('EUR'), 'Zelle should not include EUR');
21
+ });
22
+ });
23
+ describe('Revolut (multi-currency)', () => {
24
+ it('returns more than 10 currencies', () => {
25
+ const currencies = getCurrenciesForProvider(configs.revolut);
26
+ assert.ok(currencies.length > 10, `Expected >10 currencies for Revolut, got ${currencies.length}`);
27
+ });
28
+ it('includes USD', () => {
29
+ const currencies = getCurrenciesForProvider(configs.revolut);
30
+ const tickers = currencies.map(c => c.ticker);
31
+ assert.ok(tickers.includes('USD'), 'Revolut should include USD');
32
+ });
33
+ it('includes EUR', () => {
34
+ const currencies = getCurrenciesForProvider(configs.revolut);
35
+ const tickers = currencies.map(c => c.ticker);
36
+ assert.ok(tickers.includes('EUR'), 'Revolut should include EUR');
37
+ });
38
+ it('includes GBP', () => {
39
+ const currencies = getCurrenciesForProvider(configs.revolut);
40
+ const tickers = currencies.map(c => c.ticker);
41
+ assert.ok(tickers.includes('GBP'), 'Revolut should include GBP');
42
+ });
43
+ });
44
+ describe('Wise (multi-currency)', () => {
45
+ it('returns more than 15 currencies', () => {
46
+ const currencies = getCurrenciesForProvider(configs.wise);
47
+ assert.ok(currencies.length > 15, `Expected >15 currencies for Wise, got ${currencies.length}`);
48
+ });
49
+ it('includes JPY (zero-decimal currency)', () => {
50
+ const currencies = getCurrenciesForProvider(configs.wise);
51
+ const tickers = currencies.map(c => c.ticker);
52
+ assert.ok(tickers.includes('JPY'), 'Wise should include JPY');
53
+ });
54
+ it('includes CNY', () => {
55
+ const currencies = getCurrenciesForProvider(configs.wise);
56
+ const tickers = currencies.map(c => c.ticker);
57
+ assert.ok(tickers.includes('CNY'), 'Wise should include CNY');
58
+ });
59
+ });
60
+ describe('Venmo (USD only)', () => {
61
+ it('returns exactly 1 currency', () => {
62
+ const currencies = getCurrenciesForProvider(configs.venmo);
63
+ assert.equal(currencies.length, 1, `Expected 1 currency for Venmo, got ${currencies.length}`);
64
+ });
65
+ it('returns USD', () => {
66
+ const currencies = getCurrenciesForProvider(configs.venmo);
67
+ assert.equal(currencies[0].ticker, 'USD');
68
+ });
69
+ });
70
+ describe('Monzo (GBP only)', () => {
71
+ it('returns exactly 1 currency', () => {
72
+ const currencies = getCurrenciesForProvider(configs.monzo);
73
+ assert.equal(currencies.length, 1, `Expected 1 currency for Monzo, got ${currencies.length}`);
74
+ });
75
+ it('returns GBP', () => {
76
+ const currencies = getCurrenciesForProvider(configs.monzo);
77
+ assert.equal(currencies[0].ticker, 'GBP');
78
+ });
79
+ });
80
+ describe('MercadoPago (ARS only)', () => {
81
+ it('returns exactly 1 currency', () => {
82
+ const currencies = getCurrenciesForProvider(configs.mercadopago);
83
+ assert.equal(currencies.length, 1, `Expected 1 currency for MercadoPago, got ${currencies.length}`);
84
+ });
85
+ it('returns ARS', () => {
86
+ const currencies = getCurrenciesForProvider(configs.mercadopago);
87
+ assert.equal(currencies[0].ticker, 'ARS');
88
+ });
89
+ });
90
+ describe('return type validation', () => {
91
+ it('returns Currency instances with all expected properties', () => {
92
+ const currencies = getCurrenciesForProvider(configs.zelle);
93
+ const usd = currencies[0];
94
+ assert.ok(usd.ticker, 'Currency should have ticker');
95
+ assert.ok(usd.symbol, 'Currency should have symbol');
96
+ assert.ok(usd.name, 'Currency should have name');
97
+ assert.ok(typeof usd.decimals === 'number', 'Currency should have decimals as number');
98
+ assert.ok(usd.contractId, 'Currency should have contractId');
99
+ });
100
+ it('returns currencies matching SUPPORTED_CURRENCIES', () => {
101
+ const currencies = getCurrenciesForProvider(configs.zelle);
102
+ const usd = currencies[0];
103
+ assert.equal(usd.ticker, SUPPORTED_CURRENCIES.USD.ticker);
104
+ assert.equal(usd.contractId, SUPPORTED_CURRENCIES.USD.contractId);
105
+ });
106
+ });
107
+ });
108
+ /**
109
+ * Tests for verifierGetsKey - handles both V2 (address) and V3 (bytes32 hash)
110
+ */
111
+ describe('verifierGetsKey', () => {
112
+ describe('32-byte paymentMethod hash (V3)', () => {
113
+ it('returns correct provider key for venmo hash', () => {
114
+ // Generate the venmo contract ID (keccak256 hash)
115
+ const venmoHash = providerKeyToContractId('venmo');
116
+ const result = verifierGetsKey(base.id, venmoHash);
117
+ assert.equal(result, 'venmo', `Expected 'venmo' for hash ${venmoHash}, got '${result}'`);
118
+ });
119
+ it('returns correct provider key for zelle hash', () => {
120
+ const zelleHash = providerKeyToContractId('zelle');
121
+ const result = verifierGetsKey(base.id, zelleHash);
122
+ assert.equal(result, 'zelle', `Expected 'zelle' for hash ${zelleHash}, got '${result}'`);
123
+ });
124
+ it('returns correct provider key for revolut hash', () => {
125
+ const revolutHash = providerKeyToContractId('revolut');
126
+ const result = verifierGetsKey(base.id, revolutHash);
127
+ assert.equal(result, 'revolut', `Expected 'revolut' for hash ${revolutHash}, got '${result}'`);
128
+ });
129
+ it('returns correct provider key for wise hash', () => {
130
+ const wiseHash = providerKeyToContractId('wise');
131
+ const result = verifierGetsKey(base.id, wiseHash);
132
+ assert.equal(result, 'wise', `Expected 'wise' for hash ${wiseHash}, got '${result}'`);
133
+ });
134
+ it('returns MANUAL for unknown 32-byte hash', () => {
135
+ const unknownHash = '0x0000000000000000000000000000000000000000000000000000000000000001';
136
+ const result = verifierGetsKey(base.id, unknownHash);
137
+ assert.equal(result, 'manual', `Expected 'manual' for unknown hash, got '${result}'`);
138
+ });
139
+ });
140
+ describe('20-byte verifier address (V2)', () => {
141
+ it('returns correct provider key for venmo verifier address', () => {
142
+ // V2 venmo verifier on Base
143
+ const venmoVerifier = '0x9a733B55a875D0DB4915c6B36350b24F8AB99dF5';
144
+ const result = verifierGetsKey(base.id, venmoVerifier);
145
+ assert.equal(result, 'venmo', `Expected 'venmo' for address ${venmoVerifier}, got '${result}'`);
146
+ });
147
+ it('returns correct provider key for revolut verifier address', () => {
148
+ // V2 revolut verifier on Base
149
+ const revolutVerifier = '0xAA5A1B62B01781E789C900d616300717CD9A41aB';
150
+ const result = verifierGetsKey(base.id, revolutVerifier);
151
+ assert.equal(result, 'revolut', `Expected 'revolut' for address ${revolutVerifier}, got '${result}'`);
152
+ });
153
+ it('returns MANUAL for unknown address', () => {
154
+ const unknownAddress = '0x0000000000000000000000000000000000000001';
155
+ const result = verifierGetsKey(base.id, unknownAddress);
156
+ assert.equal(result, 'manual', `Expected 'manual' for unknown address, got '${result}'`);
157
+ });
158
+ });
159
+ describe('edge cases', () => {
160
+ it('returns MANUAL for empty string', () => {
161
+ const result = verifierGetsKey(base.id, '');
162
+ assert.equal(result, 'manual');
163
+ });
164
+ it('returns MANUAL for 0x', () => {
165
+ const result = verifierGetsKey(base.id, '0x');
166
+ assert.equal(result, 'manual');
167
+ });
168
+ it('handles null chainId gracefully', () => {
169
+ const venmoHash = providerKeyToContractId('venmo');
170
+ const result = verifierGetsKey(null, venmoHash);
171
+ // Should still work via contractId lookup
172
+ assert.ok(['venmo', 'manual'].includes(result), `Expected 'venmo' or 'manual', got '${result}'`);
173
+ });
174
+ });
175
+ });
176
+ /**
177
+ * Tests for providerConfigs - payment provider configuration
178
+ */
179
+ describe('providerConfigs', () => {
180
+ const configs = providerConfigs(base.id);
181
+ describe('sendLink functions', () => {
182
+ it('venmo sendLink generates correct URL without QR code', () => {
183
+ const result = configs.venmo.sendLink?.({ username: 'testuser', amount: 100n });
184
+ assert.ok(result?.includes('account.venmo.com/pay'), 'Should use web URL');
185
+ assert.ok(result?.includes('testuser'), 'Should include username');
186
+ assert.ok(result?.includes('100'), 'Should include amount');
187
+ });
188
+ it('venmo sendLink generates correct URL with QR code', () => {
189
+ const result = configs.venmo.sendLink?.({ username: 'testuser', amount: 100n, qrCode: true });
190
+ assert.ok(result?.startsWith('venmo://'), 'Should use venmo:// protocol');
191
+ });
192
+ it('cashapp sendLink generates correct URL', () => {
193
+ const result = configs.cashapp.sendLink?.({ username: '$testuser', amount: 100n });
194
+ assert.ok(result?.includes('cash.app'), 'Should use cash.app URL');
195
+ });
196
+ it('cashapp sendLink handles username without $ prefix', () => {
197
+ const result = configs.cashapp.sendLink?.({ username: 'testuser', amount: 100n });
198
+ assert.ok(result?.includes('$testuser'), 'Should add $ prefix to username');
199
+ });
200
+ it('revolut sendLink generates correct URL', () => {
201
+ const result = configs.revolut.sendLink?.({ username: 'testuser', amount: 100n });
202
+ assert.ok(result?.includes('revolut.me'), 'Should use revolut.me URL');
203
+ });
204
+ it('wise sendLink generates correct URL', () => {
205
+ const result = configs.wise.sendLink?.({ username: 'testuser', amount: 100n });
206
+ assert.ok(result?.includes('wise.com/pay/me'), 'Should use wise.com URL');
207
+ });
208
+ it('mercadopago sendLink generates correct URL', () => {
209
+ const result = configs.mercadopago.sendLink?.({ username: 'testuser', amount: 100n });
210
+ assert.ok(result?.includes('mercadopago.com'), 'Should use mercadopago URL');
211
+ });
212
+ // PayPal sendLink tests removed — provider disabled
213
+ });
214
+ describe('risk levels', () => {
215
+ it('zelle has medium risk level', () => {
216
+ assert.equal(configs.zelle.riskLevel, 'medium');
217
+ });
218
+ it('venmo has high risk level', () => {
219
+ assert.equal(configs.venmo.riskLevel, 'high');
220
+ });
221
+ it('cashapp has high risk level', () => {
222
+ assert.equal(configs.cashapp.riskLevel, 'high');
223
+ });
224
+ it('revolut has low risk level', () => {
225
+ assert.equal(configs.revolut.riskLevel, 'low');
226
+ });
227
+ it('wise has low risk level', () => {
228
+ assert.equal(configs.wise.riskLevel, 'low');
229
+ });
230
+ });
231
+ describe('cooldown settings', () => {
232
+ it('zelle has cooldown', () => {
233
+ assert.equal(configs.zelle.hasCooldown, true);
234
+ });
235
+ it('venmo has cooldown', () => {
236
+ assert.equal(configs.venmo.hasCooldown, true);
237
+ });
238
+ it('revolut has no cooldown', () => {
239
+ assert.equal(configs.revolut.hasCooldown, false);
240
+ });
241
+ it('wise has no cooldown', () => {
242
+ assert.equal(configs.wise.hasCooldown, false);
243
+ });
244
+ });
245
+ describe('cap multipliers', () => {
246
+ it('zelle has cap multiplier of 1.5', () => {
247
+ assert.equal(configs.zelle.capMultiplier, 1.5);
248
+ });
249
+ it('venmo has cap multiplier of 1', () => {
250
+ assert.equal(configs.venmo.capMultiplier, 1);
251
+ });
252
+ it('revolut has cap multiplier of 5', () => {
253
+ assert.equal(configs.revolut.capMultiplier, 5);
254
+ });
255
+ });
256
+ describe('sub-providers', () => {
257
+ it('zelle has sub-providers', () => {
258
+ assert.ok(configs.zelle.subProviders.size > 0, 'Zelle should have sub-providers');
259
+ });
260
+ it('venmo has no sub-providers', () => {
261
+ assert.equal(configs.venmo.subProviders.size, 0, 'Venmo should not have sub-providers');
262
+ });
263
+ });
264
+ describe('currency lists', () => {
265
+ it('revolut has more than 10 currencies', () => {
266
+ assert.ok(configs.revolut.list.length > 10, `Expected >10 currencies for Revolut, got ${configs.revolut.list.length}`);
267
+ });
268
+ it('wise has more than 15 currencies', () => {
269
+ assert.ok(configs.wise.list.length > 15, `Expected >15 currencies for Wise, got ${configs.wise.list.length}`);
270
+ });
271
+ });
272
+ });
@@ -0,0 +1,327 @@
1
+ /**
2
+ * @fileoverview Peer protocol types for attestation and proof verification.
3
+ *
4
+ * This module defines the type system for the V3 attestation flow, including:
5
+ * - Notarized proofs from the PeerAuth browser extension
6
+ * - Attestation requests/responses from the peer attestation service
7
+ * - EIP-712 typed data structures for on-chain verification
8
+ * - Payment proof encoding for the UnifiedPaymentVerifier contract
9
+ *
10
+ * @remarks
11
+ * **V3 Attestation Flow:**
12
+ * 1. Buyer generates zkTLS proof via PeerAuth extension (NotarizedProofData)
13
+ * 2. Proof + intent data sent to attestation service (V3AttestationRequest)
14
+ * 3. Service validates and returns EIP-712 signed attestation (V3AttestationResponse)
15
+ * 4. Attestation encoded as paymentProof bytes (encodeV3PaymentProof)
16
+ * 5. Buyer calls fulfillIntent() with encoded proof
17
+ *
18
+ * **Type Aliases:**
19
+ * For cleaner imports, V3-prefixed types have unprefixed aliases:
20
+ * - AttestationOptions = V3AttestationOptions
21
+ * - AttestationResponse = V3AttestationResponse
22
+ * - IntentData = V3IntentData
23
+ *
24
+ * @see {@link intent} for intent data structures
25
+ * @see {@link payment} for provider definitions
26
+ */
27
+ import { type Hex } from "viem";
28
+ import type { ProviderKey, SubProviderKey, ValidationDepositData } from "./payment.js";
29
+ /**
30
+ * Options for validating a depositor's payee details with the peer gating service.
31
+ */
32
+ export type ValidationOptions = {
33
+ providerKey: ProviderKey;
34
+ telegramHandle: string;
35
+ providerId: string;
36
+ };
37
+ export type PeerResponse<T> = {
38
+ success: boolean;
39
+ message: string;
40
+ statusCode: number;
41
+ responseObject: T;
42
+ };
43
+ export type CreateResponse = {
44
+ id: number;
45
+ processorName: string;
46
+ depositData: string;
47
+ hashedOnchainId: Hex;
48
+ createdAt: string;
49
+ };
50
+ export type PayeeDetails = {
51
+ /** Present in ZKP2P API responses; absent from locally-registered makers. */
52
+ id?: number;
53
+ processorName: string;
54
+ /** Present from local maker registration; may be absent in ZKP2P API responses. */
55
+ createdAt?: string;
56
+ hashedOnchainId: Hex;
57
+ /** Double-hash of the on-chain ID — returned by ZKP2P API, not locally generated. */
58
+ hashedHashedOnchainId?: Hex;
59
+ depositData: ValidationDepositData;
60
+ /**
61
+ * Account type string from ZKP2P API. Derived from their `isBusiness` flag:
62
+ * `true` → `'business'`, `false` → `'personal'`.
63
+ * Stored as a string to accommodate future types without a schema change.
64
+ */
65
+ accountType?: string;
66
+ };
67
+ export type IntentValidationOptions = {
68
+ processorName: ProviderKey;
69
+ depositId: string;
70
+ /** Token amount (was tokenAmount, renamed to amount for v2 API) */
71
+ amount: string;
72
+ payeeDetails: Hex;
73
+ toAddress: Hex;
74
+ /** Payment method bytes32 hash */
75
+ paymentMethod: Hex;
76
+ /** Fiat currency bytes32 hash */
77
+ fiatCurrency: Hex;
78
+ /** Conversion rate as string */
79
+ conversionRate: string;
80
+ chainId: string;
81
+ /** Orchestrator contract address */
82
+ orchestratorAddress: Hex;
83
+ /** Escrow contract address */
84
+ escrowAddress: Hex;
85
+ /** Optional sub-provider for providers like Zelle that have multiple banks (e.g., 'zelle-chase', 'zelle-bofa') */
86
+ subProvider?: SubProviderKey;
87
+ };
88
+ export type IntentValidation = {
89
+ signedIntent: Hex;
90
+ intentData: {
91
+ depositId: string;
92
+ tokenAmount: string;
93
+ recipientAddress: Hex;
94
+ verifierAddress: Hex;
95
+ currencyCodeHash: Hex;
96
+ gatingServiceSignature: Hex;
97
+ };
98
+ depositData: ValidationDepositData;
99
+ };
100
+ /**
101
+ * Notarized proof from PeerAuth extension.
102
+ * This is the zkTLS proof that proves a payment transaction occurred.
103
+ * Mirrors the NotarizedProof type from @provex/extension-react.
104
+ */
105
+ export type NotarizedProofData = {
106
+ claim: {
107
+ context: string;
108
+ epoch: number;
109
+ identifier: Hex;
110
+ owner: Hex;
111
+ parameters: string;
112
+ provider: string;
113
+ timestampS: number;
114
+ };
115
+ signatures: {
116
+ attestorAddress: Hex;
117
+ claimSignature: Record<number, number>;
118
+ resultSignature: Record<number, number>;
119
+ };
120
+ };
121
+ /**
122
+ * Intent data required by the peer attestation service.
123
+ * This contains all the on-chain intent parameters needed to verify
124
+ * that the off-chain payment matches the signaled intent.
125
+ */
126
+ export type V3IntentData = {
127
+ /** The intent hash from signalIntent */
128
+ intentHash: Hex;
129
+ /** Token amount in smallest unit (e.g., USDC with 6 decimals) */
130
+ amount: string;
131
+ /** Intent timestamp in milliseconds */
132
+ timestampMs: string;
133
+ /** Payment method bytes32 hash */
134
+ paymentMethod: Hex;
135
+ /** Fiat currency bytes32 hash */
136
+ fiatCurrency: Hex;
137
+ /** Conversion rate as string (scaled by 1e18) */
138
+ conversionRate: string;
139
+ /** Payee details hash */
140
+ payeeDetails: Hex;
141
+ /** Optional timestamp buffer in milliseconds (default: 3000) */
142
+ timestampBufferMs?: string;
143
+ };
144
+ /**
145
+ * V3 attestation request sent to the peer attestation service.
146
+ * The service validates Reclaim proofs and returns an EIP-712 signed attestation.
147
+ *
148
+ * Endpoint: POST /verify/{platform}/{action_type}
149
+ * Example: POST /verify/chase/transfer_zelle
150
+ */
151
+ export type V3AttestationRequest = {
152
+ /** Type of proof being submitted */
153
+ proofType: 'reclaim';
154
+ /** JSON stringified array of Reclaim proofs */
155
+ proof: string;
156
+ /** Chain ID (e.g., 8453 for Base) */
157
+ chainId: number;
158
+ /** UnifiedPaymentVerifier contract address */
159
+ verifyingContract: Hex;
160
+ /** Intent data from on-chain signalIntent */
161
+ intent: V3IntentData;
162
+ };
163
+ /**
164
+ * Options passed to the v3 getAttestation API.
165
+ * These are transformed into V3AttestationRequest format.
166
+ */
167
+ export type V3AttestationOptions = {
168
+ /** Platform for the attestation service path (e.g., 'chase') */
169
+ platform: string;
170
+ /** Action type for the attestation service path (e.g., 'transfer_zelle') */
171
+ actionType: string;
172
+ /** Chain ID */
173
+ chainId: number;
174
+ /** UnifiedPaymentVerifier contract address */
175
+ verifyingContract: Hex;
176
+ /** Array of Reclaim proofs from PeerAuth */
177
+ proofs: NotarizedProofData[];
178
+ /** Intent data from on-chain intent */
179
+ intent: V3IntentData;
180
+ };
181
+ /**
182
+ * EIP-712 typed data specification from attestation service.
183
+ */
184
+ export type V3TypedDataSpec = {
185
+ primaryType: string;
186
+ types: Record<string, Array<{
187
+ name: string;
188
+ type: string;
189
+ }>>;
190
+ };
191
+ /**
192
+ * EIP-712 typed data values from attestation service.
193
+ * These are the actual values that were signed.
194
+ */
195
+ export type V3TypedDataValue = {
196
+ intentHash: Hex;
197
+ releaseAmount: string;
198
+ dataHash: Hex;
199
+ };
200
+ /**
201
+ * Response object from the peer attestation service.
202
+ * Contains the EIP-712 signed attestation for on-chain verification.
203
+ */
204
+ export type V3AttestationResponseObject = {
205
+ /** EIP-712 signature to submit to fulfillIntent as paymentProof */
206
+ signature: Hex;
207
+ /** Address of the attestation signer */
208
+ signer: Hex;
209
+ /** EIP-712 domain separator */
210
+ domainSeparator: Hex;
211
+ /** EIP-712 type hash */
212
+ typeHash: Hex;
213
+ /** EIP-712 type specification */
214
+ typedDataSpec: V3TypedDataSpec;
215
+ /** The actual values that were signed */
216
+ typedDataValue: V3TypedDataValue;
217
+ /** ABI-encoded payment details for on-chain verification */
218
+ encodedPaymentDetails: Hex;
219
+ /** Additional metadata */
220
+ metadata: Hex;
221
+ /** Original proof input (for debugging) */
222
+ proofInput: string;
223
+ /** Platform used (e.g., 'chase') */
224
+ platform: string;
225
+ /** Action type (e.g., 'transfer_zelle') */
226
+ actionType: string;
227
+ };
228
+ /**
229
+ * Full response from the peer attestation service.
230
+ * Wrapped in standard PeerResponse format.
231
+ */
232
+ export type V3AttestationResponse = PeerResponse<V3AttestationResponseObject>;
233
+ /**
234
+ * @deprecated Use V3AttestationResponseObject for the inner response data
235
+ */
236
+ export type V3PaymentAttestation = {
237
+ depositor: Hex;
238
+ depositId: string;
239
+ amount: string;
240
+ paymentId: string;
241
+ timestamp: number;
242
+ };
243
+ export type V3IntentSignalOptions = {
244
+ depositId: string;
245
+ amount: string;
246
+ attestation: V3AttestationResponse;
247
+ chainId: number;
248
+ };
249
+ export type V3IntentFulfillOptions = {
250
+ intentId: string;
251
+ chainId: number;
252
+ };
253
+ /**
254
+ * EIP-712 domain separator fields.
255
+ * Used for typed structured data hashing and signing per EIP-712.
256
+ * @see https://eips.ethereum.org/EIPS/eip-712
257
+ */
258
+ export type EIP712Domain = {
259
+ /** Human-readable name of the signing domain (e.g., "Peer") */
260
+ name: string;
261
+ /** Version of the signing domain (e.g., "1") */
262
+ version: string;
263
+ /** Chain ID of the network where the contract is deployed */
264
+ chainId: number;
265
+ /** Address of the contract that will verify the signature */
266
+ verifyingContract: Hex;
267
+ };
268
+ /**
269
+ * A payment attestation with its EIP-712 signature.
270
+ * This is the complete attestation package sent to the contract for verification.
271
+ */
272
+ export type SignedAttestation = {
273
+ /** The payment attestation data */
274
+ attestation: V3PaymentAttestation;
275
+ /** EIP-712 typed signature of the attestation */
276
+ signature: Hex;
277
+ };
278
+ /**
279
+ * Encodes a V3 attestation response into the paymentProof bytes format
280
+ * expected by the UnifiedPaymentVerifier contract's fulfillIntent function.
281
+ *
282
+ * The encoded struct contains (wrapped in outer tuple for offset prefix):
283
+ * - PaymentAttestation: { intentHash, releaseAmount, dataHash }
284
+ * - signatures: [signature] (array with the EIP-712 signature)
285
+ * - encodedPaymentDetails: payment details for on-chain verification
286
+ * - metadata: additional metadata bytes
287
+ * - attestorAddresses: [signer] (array with the attestor address)
288
+ *
289
+ * @param attestation - The V3AttestationResponseObject from the attestation service
290
+ * @returns ABI-encoded bytes to pass as paymentProof in fulfillIntent
291
+ */
292
+ export declare function encodeV3PaymentProof(attestation: V3AttestationResponseObject): Hex;
293
+ /**
294
+ * Extracts the Reclaim attestor address from the attestation proofInput.
295
+ * This is needed for the verificationData field in fulfillIntent.
296
+ *
297
+ * @param attestation - The V3AttestationResponseObject from the attestation service
298
+ * @returns The Reclaim attestor address as Hex, or null if not found
299
+ */
300
+ export declare function extractReclaimAttestorAddress(attestation: V3AttestationResponseObject): Hex | null;
301
+ /**
302
+ * Extracts the nullifier from a V3 attestation response.
303
+ *
304
+ * The nullifier is NOT directly stored in `encodedPaymentDetails`. Instead, it's derived
305
+ * from `paymentMethod` and `paymentId` using:
306
+ * `keccak256(abi.encodePacked(paymentMethod, paymentId))`
307
+ *
308
+ * The `encodedPaymentDetails` contains a tuple of `(PaymentDetails, IntentSnapshot)`.
309
+ * This function decodes the PaymentDetails struct to extract paymentMethod and paymentId,
310
+ * then derives the nullifier.
311
+ *
312
+ * @param attestation - The V3AttestationResponseObject from the attestation service
313
+ * @returns The derived nullifier as Hex, or null if extraction fails
314
+ */
315
+ export declare function extractNullifier(attestation: V3AttestationResponseObject): Hex | null;
316
+ /** @alias V3AttestationOptions */
317
+ export type AttestationOptions = V3AttestationOptions;
318
+ /** @alias V3AttestationRequest */
319
+ export type AttestationRequest = V3AttestationRequest;
320
+ /** @alias V3AttestationResponse */
321
+ export type AttestationResponse = V3AttestationResponse;
322
+ /** @alias V3AttestationResponseObject */
323
+ export type AttestationResponseObject = V3AttestationResponseObject;
324
+ /** @alias V3PaymentAttestation - @deprecated use V3AttestationResponseObject */
325
+ export type PaymentAttestation = V3PaymentAttestation;
326
+ /** @alias V3IntentData */
327
+ export type IntentData = V3IntentData;