@fiatsend/core 0.1.0

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/index.mjs ADDED
@@ -0,0 +1,4366 @@
1
+ import { getContract, createPublicClient, http } from 'viem';
2
+ import { FiatsendError, FiatsendErrorCode } from '@fiatsend/types';
3
+ import { validateOfframpParams } from '@fiatsend/utils';
4
+
5
+ // src/client.ts
6
+
7
+ // src/config.ts
8
+ var ZERO = "0x0000000000000000000000000000000000000000";
9
+ var CHAINS = {
10
+ bsc: {
11
+ chainId: 56,
12
+ name: "BNB Smart Chain",
13
+ rpcUrl: "https://bsc-dataseed.binance.org",
14
+ contracts: {
15
+ mobileNumberNFT: ZERO,
16
+ gateway: ZERO,
17
+ paymentRouter: ZERO,
18
+ withdrawals: ZERO,
19
+ liquidityPool: ZERO,
20
+ vaultController: ZERO,
21
+ ghsFiat: ZERO,
22
+ payoutEscrow: ZERO,
23
+ p2pExchange: ZERO
24
+ }
25
+ },
26
+ polygon: {
27
+ chainId: 137,
28
+ name: "Polygon",
29
+ rpcUrl: "https://polygon-rpc.com",
30
+ contracts: {
31
+ mobileNumberNFT: ZERO,
32
+ gateway: ZERO,
33
+ paymentRouter: ZERO,
34
+ withdrawals: ZERO,
35
+ liquidityPool: ZERO,
36
+ vaultController: ZERO,
37
+ ghsFiat: ZERO,
38
+ payoutEscrow: ZERO,
39
+ p2pExchange: ZERO
40
+ }
41
+ },
42
+ bscTestnet: {
43
+ chainId: 97,
44
+ name: "BNB Smart Chain Testnet",
45
+ rpcUrl: "https://bnb-testnet.g.alchemy.com/v2/f-aLkrbDR0Yn9cafkJrazWwWCh8DrbVF",
46
+ contracts: {
47
+ mobileNumberNFT: "0x9f9914d4F528268CE070C52605852BB5207f0767",
48
+ gateway: "0x284f2D3f65aCAdD30B06F963c316161385728B88",
49
+ paymentRouter: "0x701ECdb6823fc3e258c7E291D2D8C16BC52Fbe94",
50
+ withdrawals: "0x008864a6937cF16acbb0D08cBFE0a1b59FbDA2aB",
51
+ liquidityPool: "0x915Be609c7aA429322447951c8905220D82a4e20",
52
+ vaultController: "0x6c15230473422471ae0653B3530C840836092dd5",
53
+ ghsFiat: "0x4D0FB402146204636f663f179828D409d4B578bf",
54
+ payoutEscrow: "0xE3d86823f533a400D24AB3F01f9c907Ea07012AB",
55
+ p2pExchange: "0x3364A46C779B60A6aCe8825C1e5A52dDB40cF256"
56
+ }
57
+ },
58
+ polygonMumbai: {
59
+ chainId: 80001,
60
+ name: "Polygon Mumbai Testnet",
61
+ rpcUrl: "https://rpc-mumbai.maticvigil.com",
62
+ contracts: {
63
+ mobileNumberNFT: ZERO,
64
+ gateway: ZERO,
65
+ paymentRouter: ZERO,
66
+ withdrawals: ZERO,
67
+ liquidityPool: ZERO,
68
+ vaultController: ZERO,
69
+ ghsFiat: ZERO,
70
+ payoutEscrow: ZERO,
71
+ p2pExchange: ZERO
72
+ }
73
+ }
74
+ };
75
+ function getChainConfig(chainIdOrName) {
76
+ if (typeof chainIdOrName === "string") {
77
+ const config2 = CHAINS[chainIdOrName];
78
+ if (!config2) {
79
+ throw new Error(
80
+ `Chain "${chainIdOrName}" is not configured. Available chains: ${Object.keys(CHAINS).join(", ")}`
81
+ );
82
+ }
83
+ return config2;
84
+ }
85
+ const config = Object.values(CHAINS).find((c) => c.chainId === chainIdOrName);
86
+ if (!config) {
87
+ throw new Error(
88
+ `Chain ID ${chainIdOrName} is not configured. Available chain IDs: ${Object.values(CHAINS).map((c) => c.chainId).join(", ")}`
89
+ );
90
+ }
91
+ return config;
92
+ }
93
+
94
+ // src/abis/MobileNumberNFT.ts
95
+ var MobileNumberNFTABI = [
96
+ // ─── Custom Errors ────────────────────────────────────────────────────────
97
+ {
98
+ type: "error",
99
+ name: "AlreadyRegistered",
100
+ inputs: []
101
+ },
102
+ {
103
+ type: "error",
104
+ name: "PhoneAlreadyRegistered",
105
+ inputs: []
106
+ },
107
+ {
108
+ type: "error",
109
+ name: "NotAuthorized",
110
+ inputs: []
111
+ },
112
+ {
113
+ type: "error",
114
+ name: "InvalidKYCLevel",
115
+ inputs: []
116
+ },
117
+ {
118
+ type: "error",
119
+ name: "TransferNotAllowed",
120
+ inputs: []
121
+ },
122
+ {
123
+ type: "error",
124
+ name: "SignatureExpired",
125
+ inputs: []
126
+ },
127
+ {
128
+ type: "error",
129
+ name: "InvalidSignature",
130
+ inputs: []
131
+ },
132
+ {
133
+ type: "error",
134
+ name: "ZeroAddress",
135
+ inputs: []
136
+ },
137
+ // ─── Events ───────────────────────────────────────────────────────────────
138
+ {
139
+ type: "event",
140
+ name: "MobileNumberRegistered",
141
+ inputs: [
142
+ { name: "user", type: "address", indexed: true, internalType: "address" },
143
+ { name: "tokenId", type: "uint256", indexed: true, internalType: "uint256" },
144
+ { name: "countryCode", type: "string", indexed: false, internalType: "string" }
145
+ ],
146
+ anonymous: false
147
+ },
148
+ {
149
+ type: "event",
150
+ name: "KYCLevelUpdated",
151
+ inputs: [
152
+ { name: "user", type: "address", indexed: true, internalType: "address" },
153
+ { name: "tokenId", type: "uint256", indexed: true, internalType: "uint256" },
154
+ { name: "newLevel", type: "uint8", indexed: false, internalType: "uint8" }
155
+ ],
156
+ anonymous: false
157
+ },
158
+ {
159
+ type: "event",
160
+ name: "Transfer",
161
+ inputs: [
162
+ { name: "from", type: "address", indexed: true, internalType: "address" },
163
+ { name: "to", type: "address", indexed: true, internalType: "address" },
164
+ { name: "tokenId", type: "uint256", indexed: true, internalType: "uint256" }
165
+ ],
166
+ anonymous: false
167
+ },
168
+ {
169
+ type: "event",
170
+ name: "Approval",
171
+ inputs: [
172
+ { name: "owner", type: "address", indexed: true, internalType: "address" },
173
+ { name: "approved", type: "address", indexed: true, internalType: "address" },
174
+ { name: "tokenId", type: "uint256", indexed: true, internalType: "uint256" }
175
+ ],
176
+ anonymous: false
177
+ },
178
+ {
179
+ type: "event",
180
+ name: "ApprovalForAll",
181
+ inputs: [
182
+ { name: "owner", type: "address", indexed: true, internalType: "address" },
183
+ { name: "operator", type: "address", indexed: true, internalType: "address" },
184
+ { name: "approved", type: "bool", indexed: false, internalType: "bool" }
185
+ ],
186
+ anonymous: false
187
+ },
188
+ {
189
+ type: "event",
190
+ name: "OwnershipTransferred",
191
+ inputs: [
192
+ { name: "previousOwner", type: "address", indexed: true, internalType: "address" },
193
+ { name: "newOwner", type: "address", indexed: true, internalType: "address" }
194
+ ],
195
+ anonymous: false
196
+ },
197
+ // ─── Constructor ──────────────────────────────────────────────────────────
198
+ {
199
+ type: "constructor",
200
+ inputs: [{ name: "baseURI", type: "string", internalType: "string" }],
201
+ stateMutability: "nonpayable"
202
+ },
203
+ // ─── Functions: Registration ──────────────────────────────────────────────
204
+ {
205
+ type: "function",
206
+ name: "registerMobile",
207
+ inputs: [
208
+ { name: "encryptedPhone", type: "bytes", internalType: "bytes" },
209
+ { name: "countryCode", type: "string", internalType: "string" }
210
+ ],
211
+ outputs: [],
212
+ stateMutability: "nonpayable"
213
+ },
214
+ {
215
+ type: "function",
216
+ name: "registerMobileWithSignature",
217
+ inputs: [
218
+ { name: "user", type: "address", internalType: "address" },
219
+ { name: "encryptedPhone", type: "bytes", internalType: "bytes" },
220
+ { name: "countryCode", type: "string", internalType: "string" },
221
+ { name: "deadline", type: "uint256", internalType: "uint256" },
222
+ { name: "signature", type: "bytes", internalType: "bytes" }
223
+ ],
224
+ outputs: [],
225
+ stateMutability: "nonpayable"
226
+ },
227
+ // ─── Functions: KYC ───────────────────────────────────────────────────────
228
+ {
229
+ type: "function",
230
+ name: "updateKYCLevel",
231
+ inputs: [
232
+ { name: "tokenId", type: "uint256", internalType: "uint256" },
233
+ { name: "newLevel", type: "uint8", internalType: "uint8" }
234
+ ],
235
+ outputs: [],
236
+ stateMutability: "nonpayable"
237
+ },
238
+ // ─── Functions: Admin ─────────────────────────────────────────────────────
239
+ {
240
+ type: "function",
241
+ name: "setAuthorizedMinter",
242
+ inputs: [
243
+ { name: "minter", type: "address", internalType: "address" },
244
+ { name: "authorized", type: "bool", internalType: "bool" }
245
+ ],
246
+ outputs: [],
247
+ stateMutability: "nonpayable"
248
+ },
249
+ {
250
+ type: "function",
251
+ name: "setBaseURI",
252
+ inputs: [{ name: "baseURI", type: "string", internalType: "string" }],
253
+ outputs: [],
254
+ stateMutability: "nonpayable"
255
+ },
256
+ {
257
+ type: "function",
258
+ name: "transferOwnership",
259
+ inputs: [{ name: "newOwner", type: "address", internalType: "address" }],
260
+ outputs: [],
261
+ stateMutability: "nonpayable"
262
+ },
263
+ {
264
+ type: "function",
265
+ name: "renounceOwnership",
266
+ inputs: [],
267
+ outputs: [],
268
+ stateMutability: "nonpayable"
269
+ },
270
+ // ─── Functions: View ──────────────────────────────────────────────────────
271
+ {
272
+ type: "function",
273
+ name: "getTokenId",
274
+ inputs: [{ name: "user", type: "address", internalType: "address" }],
275
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
276
+ stateMutability: "view"
277
+ },
278
+ {
279
+ type: "function",
280
+ name: "getTokenIdByPhone",
281
+ inputs: [{ name: "encryptedPhone", type: "bytes", internalType: "bytes" }],
282
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
283
+ stateMutability: "view"
284
+ },
285
+ {
286
+ type: "function",
287
+ name: "getKYCLevel",
288
+ inputs: [{ name: "tokenId", type: "uint256", internalType: "uint256" }],
289
+ outputs: [{ name: "", type: "uint8", internalType: "uint8" }],
290
+ stateMutability: "view"
291
+ },
292
+ {
293
+ type: "function",
294
+ name: "getKYCLevelByAddress",
295
+ inputs: [{ name: "user", type: "address", internalType: "address" }],
296
+ outputs: [{ name: "", type: "uint8", internalType: "uint8" }],
297
+ stateMutability: "view"
298
+ },
299
+ {
300
+ type: "function",
301
+ name: "getCountryCode",
302
+ inputs: [{ name: "tokenId", type: "uint256", internalType: "uint256" }],
303
+ outputs: [{ name: "", type: "string", internalType: "string" }],
304
+ stateMutability: "view"
305
+ },
306
+ {
307
+ type: "function",
308
+ name: "getEncryptedPhone",
309
+ inputs: [{ name: "tokenId", type: "uint256", internalType: "uint256" }],
310
+ outputs: [{ name: "", type: "bytes", internalType: "bytes" }],
311
+ stateMutability: "view"
312
+ },
313
+ {
314
+ type: "function",
315
+ name: "nonces",
316
+ inputs: [{ name: "user", type: "address", internalType: "address" }],
317
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
318
+ stateMutability: "view"
319
+ },
320
+ {
321
+ type: "function",
322
+ name: "owner",
323
+ inputs: [],
324
+ outputs: [{ name: "", type: "address", internalType: "address" }],
325
+ stateMutability: "view"
326
+ },
327
+ {
328
+ type: "function",
329
+ name: "ownerOf",
330
+ inputs: [{ name: "tokenId", type: "uint256", internalType: "uint256" }],
331
+ outputs: [{ name: "", type: "address", internalType: "address" }],
332
+ stateMutability: "view"
333
+ },
334
+ {
335
+ type: "function",
336
+ name: "balanceOf",
337
+ inputs: [{ name: "owner", type: "address", internalType: "address" }],
338
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
339
+ stateMutability: "view"
340
+ },
341
+ {
342
+ type: "function",
343
+ name: "tokenURI",
344
+ inputs: [{ name: "tokenId", type: "uint256", internalType: "uint256" }],
345
+ outputs: [{ name: "", type: "string", internalType: "string" }],
346
+ stateMutability: "view"
347
+ },
348
+ {
349
+ type: "function",
350
+ name: "totalSupply",
351
+ inputs: [],
352
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
353
+ stateMutability: "view"
354
+ },
355
+ {
356
+ type: "function",
357
+ name: "tokenByIndex",
358
+ inputs: [{ name: "index", type: "uint256", internalType: "uint256" }],
359
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
360
+ stateMutability: "view"
361
+ },
362
+ {
363
+ type: "function",
364
+ name: "tokenOfOwnerByIndex",
365
+ inputs: [
366
+ { name: "owner", type: "address", internalType: "address" },
367
+ { name: "index", type: "uint256", internalType: "uint256" }
368
+ ],
369
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
370
+ stateMutability: "view"
371
+ },
372
+ {
373
+ type: "function",
374
+ name: "supportsInterface",
375
+ inputs: [{ name: "interfaceId", type: "bytes4", internalType: "bytes4" }],
376
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
377
+ stateMutability: "view"
378
+ },
379
+ {
380
+ type: "function",
381
+ name: "name",
382
+ inputs: [],
383
+ outputs: [{ name: "", type: "string", internalType: "string" }],
384
+ stateMutability: "view"
385
+ },
386
+ {
387
+ type: "function",
388
+ name: "symbol",
389
+ inputs: [],
390
+ outputs: [{ name: "", type: "string", internalType: "string" }],
391
+ stateMutability: "view"
392
+ }
393
+ ];
394
+
395
+ // src/abis/FiatsendGateway.ts
396
+ var FiatsendGatewayABI = [
397
+ // ─── Custom Errors ────────────────────────────────────────────────────────
398
+ { type: "error", name: "TokenNotSupported", inputs: [] },
399
+ { type: "error", name: "NoMobileNFT", inputs: [] },
400
+ { type: "error", name: "KYCRequired", inputs: [] },
401
+ { type: "error", name: "BelowMinimum", inputs: [] },
402
+ { type: "error", name: "DailyLimitExceeded", inputs: [] },
403
+ { type: "error", name: "ZeroAddress", inputs: [] },
404
+ { type: "error", name: "ZeroAmount", inputs: [] },
405
+ { type: "error", name: "InvalidFeeRate", inputs: [] },
406
+ { type: "error", name: "NotAuthorizedOnramp", inputs: [] },
407
+ { type: "error", name: "NotAuthorizedContract", inputs: [] },
408
+ // ─── Events ───────────────────────────────────────────────────────────────
409
+ {
410
+ type: "event",
411
+ name: "OfframpInitiated",
412
+ inputs: [
413
+ { name: "user", type: "address", indexed: true, internalType: "address" },
414
+ { name: "token", type: "address", indexed: true, internalType: "address" },
415
+ { name: "amount", type: "uint256", indexed: false, internalType: "uint256" },
416
+ { name: "fee", type: "uint256", indexed: false, internalType: "uint256" },
417
+ { name: "phoneNumber", type: "string", indexed: false, internalType: "string" }
418
+ ],
419
+ anonymous: false
420
+ },
421
+ {
422
+ type: "event",
423
+ name: "OnrampCompleted",
424
+ inputs: [
425
+ { name: "user", type: "address", indexed: true, internalType: "address" },
426
+ { name: "amount", type: "uint256", indexed: false, internalType: "uint256" }
427
+ ],
428
+ anonymous: false
429
+ },
430
+ {
431
+ type: "event",
432
+ name: "ConversionRateUpdated",
433
+ inputs: [
434
+ { name: "token", type: "address", indexed: true, internalType: "address" },
435
+ { name: "rate", type: "uint256", indexed: false, internalType: "uint256" }
436
+ ],
437
+ anonymous: false
438
+ },
439
+ {
440
+ type: "event",
441
+ name: "TokenAdded",
442
+ inputs: [{ name: "token", type: "address", indexed: true, internalType: "address" }],
443
+ anonymous: false
444
+ },
445
+ {
446
+ type: "event",
447
+ name: "TokenRemoved",
448
+ inputs: [{ name: "token", type: "address", indexed: true, internalType: "address" }],
449
+ anonymous: false
450
+ },
451
+ {
452
+ type: "event",
453
+ name: "FeeCollected",
454
+ inputs: [
455
+ { name: "token", type: "address", indexed: true, internalType: "address" },
456
+ { name: "feeAmount", type: "uint256", indexed: false, internalType: "uint256" },
457
+ { name: "treasury", type: "address", indexed: false, internalType: "address" }
458
+ ],
459
+ anonymous: false
460
+ },
461
+ {
462
+ type: "event",
463
+ name: "Paused",
464
+ inputs: [{ name: "account", type: "address", indexed: false, internalType: "address" }],
465
+ anonymous: false
466
+ },
467
+ {
468
+ type: "event",
469
+ name: "Unpaused",
470
+ inputs: [{ name: "account", type: "address", indexed: false, internalType: "address" }],
471
+ anonymous: false
472
+ },
473
+ {
474
+ type: "event",
475
+ name: "OwnershipTransferred",
476
+ inputs: [
477
+ { name: "previousOwner", type: "address", indexed: true, internalType: "address" },
478
+ { name: "newOwner", type: "address", indexed: true, internalType: "address" }
479
+ ],
480
+ anonymous: false
481
+ },
482
+ {
483
+ type: "event",
484
+ name: "Upgraded",
485
+ inputs: [{ name: "implementation", type: "address", indexed: true, internalType: "address" }],
486
+ anonymous: false
487
+ },
488
+ {
489
+ type: "event",
490
+ name: "Initialized",
491
+ inputs: [{ name: "version", type: "uint64", indexed: false, internalType: "uint64" }],
492
+ anonymous: false
493
+ },
494
+ // ─── Functions: Initializer ───────────────────────────────────────────────
495
+ {
496
+ type: "function",
497
+ name: "initialize",
498
+ inputs: [
499
+ { name: "_ghsFiatToken", type: "address", internalType: "address" },
500
+ { name: "_mobileNumberNFT", type: "address", internalType: "address" },
501
+ { name: "_treasury", type: "address", internalType: "address" },
502
+ { name: "_feeRate", type: "uint256", internalType: "uint256" }
503
+ ],
504
+ outputs: [],
505
+ stateMutability: "nonpayable"
506
+ },
507
+ // ─── Functions: Core operations ───────────────────────────────────────────
508
+ {
509
+ type: "function",
510
+ name: "offrampFor",
511
+ inputs: [
512
+ { name: "user", type: "address", internalType: "address" },
513
+ { name: "token", type: "address", internalType: "address" },
514
+ { name: "amount", type: "uint256", internalType: "uint256" },
515
+ { name: "phoneNumber", type: "string", internalType: "string" }
516
+ ],
517
+ outputs: [],
518
+ stateMutability: "nonpayable"
519
+ },
520
+ {
521
+ type: "function",
522
+ name: "offramp",
523
+ inputs: [
524
+ { name: "token", type: "address", internalType: "address" },
525
+ { name: "amount", type: "uint256", internalType: "uint256" },
526
+ { name: "phoneNumber", type: "string", internalType: "string" }
527
+ ],
528
+ outputs: [],
529
+ stateMutability: "nonpayable"
530
+ },
531
+ {
532
+ type: "function",
533
+ name: "onramp",
534
+ inputs: [
535
+ { name: "user", type: "address", internalType: "address" },
536
+ { name: "amount", type: "uint256", internalType: "uint256" }
537
+ ],
538
+ outputs: [],
539
+ stateMutability: "nonpayable"
540
+ },
541
+ // ─── Functions: Admin — Configuration ────────────────────────────────────
542
+ {
543
+ type: "function",
544
+ name: "setConversionRate",
545
+ inputs: [
546
+ { name: "token", type: "address", internalType: "address" },
547
+ { name: "rate", type: "uint256", internalType: "uint256" }
548
+ ],
549
+ outputs: [],
550
+ stateMutability: "nonpayable"
551
+ },
552
+ {
553
+ type: "function",
554
+ name: "addSupportedToken",
555
+ inputs: [{ name: "token", type: "address", internalType: "address" }],
556
+ outputs: [],
557
+ stateMutability: "nonpayable"
558
+ },
559
+ {
560
+ type: "function",
561
+ name: "removeSupportedToken",
562
+ inputs: [{ name: "token", type: "address", internalType: "address" }],
563
+ outputs: [],
564
+ stateMutability: "nonpayable"
565
+ },
566
+ {
567
+ type: "function",
568
+ name: "setKYC",
569
+ inputs: [
570
+ { name: "user", type: "address", internalType: "address" },
571
+ { name: "status", type: "bool", internalType: "bool" }
572
+ ],
573
+ outputs: [],
574
+ stateMutability: "nonpayable"
575
+ },
576
+ {
577
+ type: "function",
578
+ name: "setProtocolFee",
579
+ inputs: [{ name: "newFeeRate", type: "uint256", internalType: "uint256" }],
580
+ outputs: [],
581
+ stateMutability: "nonpayable"
582
+ },
583
+ {
584
+ type: "function",
585
+ name: "setMinWithdrawAmount",
586
+ inputs: [{ name: "amount", type: "uint256", internalType: "uint256" }],
587
+ outputs: [],
588
+ stateMutability: "nonpayable"
589
+ },
590
+ {
591
+ type: "function",
592
+ name: "setDailyLimit",
593
+ inputs: [{ name: "limit", type: "uint256", internalType: "uint256" }],
594
+ outputs: [],
595
+ stateMutability: "nonpayable"
596
+ },
597
+ {
598
+ type: "function",
599
+ name: "setWithdrawalsContract",
600
+ inputs: [{ name: "_withdrawals", type: "address", internalType: "address" }],
601
+ outputs: [],
602
+ stateMutability: "nonpayable"
603
+ },
604
+ {
605
+ type: "function",
606
+ name: "setAuthorizedOnramper",
607
+ inputs: [
608
+ { name: "onramper", type: "address", internalType: "address" },
609
+ { name: "authorized", type: "bool", internalType: "bool" }
610
+ ],
611
+ outputs: [],
612
+ stateMutability: "nonpayable"
613
+ },
614
+ {
615
+ type: "function",
616
+ name: "setAuthorizedContract",
617
+ inputs: [
618
+ { name: "contractAddr", type: "address", internalType: "address" },
619
+ { name: "authorized", type: "bool", internalType: "bool" }
620
+ ],
621
+ outputs: [],
622
+ stateMutability: "nonpayable"
623
+ },
624
+ {
625
+ type: "function",
626
+ name: "setProtocolTreasury",
627
+ inputs: [{ name: "treasury", type: "address", internalType: "address" }],
628
+ outputs: [],
629
+ stateMutability: "nonpayable"
630
+ },
631
+ {
632
+ type: "function",
633
+ name: "emergencyWithdraw",
634
+ inputs: [
635
+ { name: "token", type: "address", internalType: "address" },
636
+ { name: "amount", type: "uint256", internalType: "uint256" }
637
+ ],
638
+ outputs: [],
639
+ stateMutability: "nonpayable"
640
+ },
641
+ {
642
+ type: "function",
643
+ name: "pause",
644
+ inputs: [],
645
+ outputs: [],
646
+ stateMutability: "nonpayable"
647
+ },
648
+ {
649
+ type: "function",
650
+ name: "unpause",
651
+ inputs: [],
652
+ outputs: [],
653
+ stateMutability: "nonpayable"
654
+ },
655
+ {
656
+ type: "function",
657
+ name: "transferOwnership",
658
+ inputs: [{ name: "newOwner", type: "address", internalType: "address" }],
659
+ outputs: [],
660
+ stateMutability: "nonpayable"
661
+ },
662
+ {
663
+ type: "function",
664
+ name: "renounceOwnership",
665
+ inputs: [],
666
+ outputs: [],
667
+ stateMutability: "nonpayable"
668
+ },
669
+ {
670
+ type: "function",
671
+ name: "upgradeTo",
672
+ inputs: [{ name: "newImplementation", type: "address", internalType: "address" }],
673
+ outputs: [],
674
+ stateMutability: "nonpayable"
675
+ },
676
+ {
677
+ type: "function",
678
+ name: "upgradeToAndCall",
679
+ inputs: [
680
+ { name: "newImplementation", type: "address", internalType: "address" },
681
+ { name: "data", type: "bytes", internalType: "bytes" }
682
+ ],
683
+ outputs: [],
684
+ stateMutability: "payable"
685
+ },
686
+ // ─── Functions: View ──────────────────────────────────────────────────────
687
+ {
688
+ type: "function",
689
+ name: "isTokenSupported",
690
+ inputs: [{ name: "token", type: "address", internalType: "address" }],
691
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
692
+ stateMutability: "view"
693
+ },
694
+ {
695
+ type: "function",
696
+ name: "getConversionRate",
697
+ inputs: [{ name: "token", type: "address", internalType: "address" }],
698
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
699
+ stateMutability: "view"
700
+ },
701
+ {
702
+ type: "function",
703
+ name: "isKYCPassed",
704
+ inputs: [{ name: "user", type: "address", internalType: "address" }],
705
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
706
+ stateMutability: "view"
707
+ },
708
+ {
709
+ type: "function",
710
+ name: "getDailyVolume",
711
+ inputs: [{ name: "user", type: "address", internalType: "address" }],
712
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
713
+ stateMutability: "view"
714
+ },
715
+ {
716
+ type: "function",
717
+ name: "isAuthorizedContract",
718
+ inputs: [{ name: "contractAddr", type: "address", internalType: "address" }],
719
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
720
+ stateMutability: "view"
721
+ },
722
+ {
723
+ type: "function",
724
+ name: "protocolFeeRate",
725
+ inputs: [],
726
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
727
+ stateMutability: "view"
728
+ },
729
+ {
730
+ type: "function",
731
+ name: "protocolTreasury",
732
+ inputs: [],
733
+ outputs: [{ name: "", type: "address", internalType: "address" }],
734
+ stateMutability: "view"
735
+ },
736
+ {
737
+ type: "function",
738
+ name: "minWithdrawAmount",
739
+ inputs: [],
740
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
741
+ stateMutability: "view"
742
+ },
743
+ {
744
+ type: "function",
745
+ name: "dailyLimit",
746
+ inputs: [],
747
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
748
+ stateMutability: "view"
749
+ },
750
+ {
751
+ type: "function",
752
+ name: "paused",
753
+ inputs: [],
754
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
755
+ stateMutability: "view"
756
+ },
757
+ {
758
+ type: "function",
759
+ name: "owner",
760
+ inputs: [],
761
+ outputs: [{ name: "", type: "address", internalType: "address" }],
762
+ stateMutability: "view"
763
+ },
764
+ {
765
+ type: "function",
766
+ name: "MAX_FEE_RATE",
767
+ inputs: [],
768
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
769
+ stateMutability: "view"
770
+ },
771
+ {
772
+ type: "function",
773
+ name: "KYC_THRESHOLD",
774
+ inputs: [],
775
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
776
+ stateMutability: "view"
777
+ },
778
+ {
779
+ type: "function",
780
+ name: "ghsFiatToken",
781
+ inputs: [],
782
+ outputs: [{ name: "", type: "address", internalType: "address" }],
783
+ stateMutability: "view"
784
+ },
785
+ {
786
+ type: "function",
787
+ name: "mobileNumberNFT",
788
+ inputs: [],
789
+ outputs: [{ name: "", type: "address", internalType: "address" }],
790
+ stateMutability: "view"
791
+ },
792
+ {
793
+ type: "function",
794
+ name: "withdrawalsContract",
795
+ inputs: [],
796
+ outputs: [{ name: "", type: "address", internalType: "address" }],
797
+ stateMutability: "view"
798
+ },
799
+ {
800
+ type: "function",
801
+ name: "proxiableUUID",
802
+ inputs: [],
803
+ outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
804
+ stateMutability: "view"
805
+ }
806
+ ];
807
+
808
+ // src/abis/PaymentRouter.ts
809
+ var PaymentRouterABI = [
810
+ // ─── Custom Errors ────────────────────────────────────────────────────────
811
+ { type: "error", name: "ZeroAddress", inputs: [] },
812
+ { type: "error", name: "ZeroAmount", inputs: [] },
813
+ { type: "error", name: "PhoneNotRegistered", inputs: [] },
814
+ { type: "error", name: "RequestNotFound", inputs: [] },
815
+ { type: "error", name: "RequestNotPending", inputs: [] },
816
+ { type: "error", name: "NotRequestOwner", inputs: [] },
817
+ { type: "error", name: "NotRequestRecipient", inputs: [] },
818
+ { type: "error", name: "SelfPayment", inputs: [] },
819
+ // ─── Events ───────────────────────────────────────────────────────────────
820
+ {
821
+ type: "event",
822
+ name: "PaymentSent",
823
+ inputs: [
824
+ { name: "from", type: "address", indexed: true, internalType: "address" },
825
+ { name: "to", type: "address", indexed: true, internalType: "address" },
826
+ { name: "token", type: "address", indexed: false, internalType: "address" },
827
+ { name: "amount", type: "uint256", indexed: false, internalType: "uint256" },
828
+ { name: "memo", type: "string", indexed: false, internalType: "string" }
829
+ ],
830
+ anonymous: false
831
+ },
832
+ {
833
+ type: "event",
834
+ name: "PaymentRequestCreated",
835
+ inputs: [
836
+ { name: "requestId", type: "uint256", indexed: true, internalType: "uint256" },
837
+ { name: "from", type: "address", indexed: true, internalType: "address" },
838
+ { name: "to", type: "address", indexed: true, internalType: "address" },
839
+ { name: "token", type: "address", indexed: false, internalType: "address" },
840
+ { name: "amount", type: "uint256", indexed: false, internalType: "uint256" }
841
+ ],
842
+ anonymous: false
843
+ },
844
+ {
845
+ type: "event",
846
+ name: "PaymentRequestPaid",
847
+ inputs: [
848
+ { name: "requestId", type: "uint256", indexed: true, internalType: "uint256" },
849
+ { name: "paidBy", type: "address", indexed: true, internalType: "address" }
850
+ ],
851
+ anonymous: false
852
+ },
853
+ {
854
+ type: "event",
855
+ name: "PaymentRequestCancelled",
856
+ inputs: [{ name: "requestId", type: "uint256", indexed: true, internalType: "uint256" }],
857
+ anonymous: false
858
+ },
859
+ {
860
+ type: "event",
861
+ name: "OwnershipTransferred",
862
+ inputs: [
863
+ { name: "previousOwner", type: "address", indexed: true, internalType: "address" },
864
+ { name: "newOwner", type: "address", indexed: true, internalType: "address" }
865
+ ],
866
+ anonymous: false
867
+ },
868
+ // ─── Constructor ──────────────────────────────────────────────────────────
869
+ {
870
+ type: "constructor",
871
+ inputs: [
872
+ { name: "_mobileNumberNFT", type: "address", internalType: "address" },
873
+ { name: "_feeTreasury", type: "address", internalType: "address" }
874
+ ],
875
+ stateMutability: "nonpayable"
876
+ },
877
+ // ─── Functions: Payments ──────────────────────────────────────────────────
878
+ {
879
+ type: "function",
880
+ name: "send",
881
+ inputs: [
882
+ { name: "token", type: "address", internalType: "address" },
883
+ { name: "to", type: "address", internalType: "address" },
884
+ { name: "amount", type: "uint256", internalType: "uint256" },
885
+ { name: "memo", type: "string", internalType: "string" }
886
+ ],
887
+ outputs: [],
888
+ stateMutability: "nonpayable"
889
+ },
890
+ {
891
+ type: "function",
892
+ name: "sendToPhone",
893
+ inputs: [
894
+ { name: "token", type: "address", internalType: "address" },
895
+ { name: "encryptedPhone", type: "bytes", internalType: "bytes" },
896
+ { name: "amount", type: "uint256", internalType: "uint256" },
897
+ { name: "memo", type: "string", internalType: "string" }
898
+ ],
899
+ outputs: [],
900
+ stateMutability: "nonpayable"
901
+ },
902
+ // ─── Functions: Payment Requests ─────────────────────────────────────────
903
+ {
904
+ type: "function",
905
+ name: "createPaymentRequest",
906
+ inputs: [
907
+ { name: "token", type: "address", internalType: "address" },
908
+ { name: "from", type: "address", internalType: "address" },
909
+ { name: "amount", type: "uint256", internalType: "uint256" },
910
+ { name: "memo", type: "string", internalType: "string" }
911
+ ],
912
+ outputs: [{ name: "requestId", type: "uint256", internalType: "uint256" }],
913
+ stateMutability: "nonpayable"
914
+ },
915
+ {
916
+ type: "function",
917
+ name: "payRequest",
918
+ inputs: [{ name: "requestId", type: "uint256", internalType: "uint256" }],
919
+ outputs: [],
920
+ stateMutability: "nonpayable"
921
+ },
922
+ {
923
+ type: "function",
924
+ name: "cancelRequest",
925
+ inputs: [{ name: "requestId", type: "uint256", internalType: "uint256" }],
926
+ outputs: [],
927
+ stateMutability: "nonpayable"
928
+ },
929
+ // ─── Functions: Admin ─────────────────────────────────────────────────────
930
+ {
931
+ type: "function",
932
+ name: "setP2PFeeRate",
933
+ inputs: [{ name: "rate", type: "uint256", internalType: "uint256" }],
934
+ outputs: [],
935
+ stateMutability: "nonpayable"
936
+ },
937
+ {
938
+ type: "function",
939
+ name: "setFeeTreasury",
940
+ inputs: [{ name: "treasury", type: "address", internalType: "address" }],
941
+ outputs: [],
942
+ stateMutability: "nonpayable"
943
+ },
944
+ {
945
+ type: "function",
946
+ name: "transferOwnership",
947
+ inputs: [{ name: "newOwner", type: "address", internalType: "address" }],
948
+ outputs: [],
949
+ stateMutability: "nonpayable"
950
+ },
951
+ {
952
+ type: "function",
953
+ name: "renounceOwnership",
954
+ inputs: [],
955
+ outputs: [],
956
+ stateMutability: "nonpayable"
957
+ },
958
+ // ─── Functions: View ──────────────────────────────────────────────────────
959
+ {
960
+ type: "function",
961
+ name: "getPaymentRequest",
962
+ inputs: [{ name: "requestId", type: "uint256", internalType: "uint256" }],
963
+ outputs: [
964
+ {
965
+ name: "",
966
+ type: "tuple",
967
+ internalType: "struct IPaymentRouter.PaymentRequest",
968
+ components: [
969
+ { name: "id", type: "uint256", internalType: "uint256" },
970
+ { name: "from", type: "address", internalType: "address" },
971
+ { name: "to", type: "address", internalType: "address" },
972
+ { name: "token", type: "address", internalType: "address" },
973
+ { name: "amount", type: "uint256", internalType: "uint256" },
974
+ { name: "memo", type: "string", internalType: "string" },
975
+ { name: "status", type: "uint8", internalType: "enum IPaymentRouter.RequestStatus" },
976
+ { name: "createdAt", type: "uint256", internalType: "uint256" }
977
+ ]
978
+ }
979
+ ],
980
+ stateMutability: "view"
981
+ },
982
+ {
983
+ type: "function",
984
+ name: "paymentRequestCounter",
985
+ inputs: [],
986
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
987
+ stateMutability: "view"
988
+ },
989
+ {
990
+ type: "function",
991
+ name: "p2pFeeRate",
992
+ inputs: [],
993
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
994
+ stateMutability: "view"
995
+ },
996
+ {
997
+ type: "function",
998
+ name: "feeTreasury",
999
+ inputs: [],
1000
+ outputs: [{ name: "", type: "address", internalType: "address" }],
1001
+ stateMutability: "view"
1002
+ },
1003
+ {
1004
+ type: "function",
1005
+ name: "mobileNumberNFT",
1006
+ inputs: [],
1007
+ outputs: [{ name: "", type: "address", internalType: "address" }],
1008
+ stateMutability: "view"
1009
+ },
1010
+ {
1011
+ type: "function",
1012
+ name: "owner",
1013
+ inputs: [],
1014
+ outputs: [{ name: "", type: "address", internalType: "address" }],
1015
+ stateMutability: "view"
1016
+ }
1017
+ ];
1018
+
1019
+ // src/abis/Withdrawals.ts
1020
+ var WithdrawalsABI = [
1021
+ // ─── Custom Errors ────────────────────────────────────────────────────────
1022
+ { type: "error", name: "OnlyGateway", inputs: [] },
1023
+ { type: "error", name: "WithdrawalNotFound", inputs: [] },
1024
+ { type: "error", name: "InvalidStatus", inputs: [] },
1025
+ { type: "error", name: "ZeroAddress", inputs: [] },
1026
+ { type: "error", name: "ZeroAmount", inputs: [] },
1027
+ // ─── Events ───────────────────────────────────────────────────────────────
1028
+ {
1029
+ type: "event",
1030
+ name: "WithdrawalCreated",
1031
+ inputs: [
1032
+ { name: "id", type: "uint256", indexed: true, internalType: "uint256" },
1033
+ { name: "user", type: "address", indexed: true, internalType: "address" },
1034
+ { name: "token", type: "address", indexed: false, internalType: "address" },
1035
+ { name: "amount", type: "uint256", indexed: false, internalType: "uint256" },
1036
+ { name: "fee", type: "uint256", indexed: false, internalType: "uint256" },
1037
+ { name: "phoneNumber", type: "string", indexed: false, internalType: "string" }
1038
+ ],
1039
+ anonymous: false
1040
+ },
1041
+ {
1042
+ type: "event",
1043
+ name: "WithdrawalProcessing",
1044
+ inputs: [{ name: "id", type: "uint256", indexed: true, internalType: "uint256" }],
1045
+ anonymous: false
1046
+ },
1047
+ {
1048
+ type: "event",
1049
+ name: "WithdrawalCompleted",
1050
+ inputs: [
1051
+ { name: "id", type: "uint256", indexed: true, internalType: "uint256" },
1052
+ { name: "completedAt", type: "uint256", indexed: false, internalType: "uint256" }
1053
+ ],
1054
+ anonymous: false
1055
+ },
1056
+ {
1057
+ type: "event",
1058
+ name: "WithdrawalFailed",
1059
+ inputs: [
1060
+ { name: "id", type: "uint256", indexed: true, internalType: "uint256" },
1061
+ { name: "user", type: "address", indexed: true, internalType: "address" },
1062
+ { name: "refundAmount", type: "uint256", indexed: false, internalType: "uint256" }
1063
+ ],
1064
+ anonymous: false
1065
+ },
1066
+ {
1067
+ type: "event",
1068
+ name: "GatewayUpdated",
1069
+ inputs: [{ name: "gateway", type: "address", indexed: true, internalType: "address" }],
1070
+ anonymous: false
1071
+ },
1072
+ {
1073
+ type: "event",
1074
+ name: "OwnershipTransferred",
1075
+ inputs: [
1076
+ { name: "previousOwner", type: "address", indexed: true, internalType: "address" },
1077
+ { name: "newOwner", type: "address", indexed: true, internalType: "address" }
1078
+ ],
1079
+ anonymous: false
1080
+ },
1081
+ // ─── Constructor ──────────────────────────────────────────────────────────
1082
+ {
1083
+ type: "constructor",
1084
+ inputs: [],
1085
+ stateMutability: "nonpayable"
1086
+ },
1087
+ // ─── Functions: Admin ─────────────────────────────────────────────────────
1088
+ {
1089
+ type: "function",
1090
+ name: "setGateway",
1091
+ inputs: [{ name: "_gateway", type: "address", internalType: "address" }],
1092
+ outputs: [],
1093
+ stateMutability: "nonpayable"
1094
+ },
1095
+ {
1096
+ type: "function",
1097
+ name: "processWithdrawal",
1098
+ inputs: [{ name: "id", type: "uint256", internalType: "uint256" }],
1099
+ outputs: [],
1100
+ stateMutability: "nonpayable"
1101
+ },
1102
+ {
1103
+ type: "function",
1104
+ name: "completeWithdrawal",
1105
+ inputs: [{ name: "id", type: "uint256", internalType: "uint256" }],
1106
+ outputs: [],
1107
+ stateMutability: "nonpayable"
1108
+ },
1109
+ {
1110
+ type: "function",
1111
+ name: "failWithdrawal",
1112
+ inputs: [{ name: "id", type: "uint256", internalType: "uint256" }],
1113
+ outputs: [],
1114
+ stateMutability: "nonpayable"
1115
+ },
1116
+ // ─── Functions: Gateway-only ──────────────────────────────────────────────
1117
+ {
1118
+ type: "function",
1119
+ name: "createWithdrawal",
1120
+ inputs: [
1121
+ { name: "user", type: "address", internalType: "address" },
1122
+ { name: "token", type: "address", internalType: "address" },
1123
+ { name: "amount", type: "uint256", internalType: "uint256" },
1124
+ { name: "fee", type: "uint256", internalType: "uint256" },
1125
+ { name: "paymentMethod", type: "uint8", internalType: "uint8" },
1126
+ { name: "phoneNumber", type: "string", internalType: "string" }
1127
+ ],
1128
+ outputs: [{ name: "id", type: "uint256", internalType: "uint256" }],
1129
+ stateMutability: "nonpayable"
1130
+ },
1131
+ // ─── Functions: View ──────────────────────────────────────────────────────
1132
+ {
1133
+ type: "function",
1134
+ name: "getWithdrawal",
1135
+ inputs: [{ name: "id", type: "uint256", internalType: "uint256" }],
1136
+ outputs: [
1137
+ {
1138
+ name: "",
1139
+ type: "tuple",
1140
+ internalType: "struct Withdrawals.Withdrawal",
1141
+ components: [
1142
+ { name: "id", type: "uint256", internalType: "uint256" },
1143
+ { name: "user", type: "address", internalType: "address" },
1144
+ { name: "token", type: "address", internalType: "address" },
1145
+ { name: "amount", type: "uint256", internalType: "uint256" },
1146
+ { name: "fee", type: "uint256", internalType: "uint256" },
1147
+ { name: "status", type: "uint8", internalType: "uint8" },
1148
+ { name: "paymentMethod", type: "uint8", internalType: "uint8" },
1149
+ { name: "phoneNumber", type: "string", internalType: "string" },
1150
+ { name: "createdAt", type: "uint256", internalType: "uint256" },
1151
+ { name: "completedAt", type: "uint256", internalType: "uint256" }
1152
+ ]
1153
+ }
1154
+ ],
1155
+ stateMutability: "view"
1156
+ },
1157
+ {
1158
+ type: "function",
1159
+ name: "getUserWithdrawals",
1160
+ inputs: [{ name: "user", type: "address", internalType: "address" }],
1161
+ outputs: [{ name: "", type: "uint256[]", internalType: "uint256[]" }],
1162
+ stateMutability: "view"
1163
+ },
1164
+ {
1165
+ type: "function",
1166
+ name: "withdrawalCounter",
1167
+ inputs: [],
1168
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
1169
+ stateMutability: "view"
1170
+ },
1171
+ {
1172
+ type: "function",
1173
+ name: "gateway",
1174
+ inputs: [],
1175
+ outputs: [{ name: "", type: "address", internalType: "address" }],
1176
+ stateMutability: "view"
1177
+ },
1178
+ {
1179
+ type: "function",
1180
+ name: "STATUS_PENDING",
1181
+ inputs: [],
1182
+ outputs: [{ name: "", type: "uint8", internalType: "uint8" }],
1183
+ stateMutability: "view"
1184
+ },
1185
+ {
1186
+ type: "function",
1187
+ name: "STATUS_PROCESSING",
1188
+ inputs: [],
1189
+ outputs: [{ name: "", type: "uint8", internalType: "uint8" }],
1190
+ stateMutability: "view"
1191
+ },
1192
+ {
1193
+ type: "function",
1194
+ name: "STATUS_COMPLETED",
1195
+ inputs: [],
1196
+ outputs: [{ name: "", type: "uint8", internalType: "uint8" }],
1197
+ stateMutability: "view"
1198
+ },
1199
+ {
1200
+ type: "function",
1201
+ name: "STATUS_FAILED",
1202
+ inputs: [],
1203
+ outputs: [{ name: "", type: "uint8", internalType: "uint8" }],
1204
+ stateMutability: "view"
1205
+ },
1206
+ {
1207
+ type: "function",
1208
+ name: "owner",
1209
+ inputs: [],
1210
+ outputs: [{ name: "", type: "address", internalType: "address" }],
1211
+ stateMutability: "view"
1212
+ }
1213
+ ];
1214
+
1215
+ // src/abis/LiquidityPool.ts
1216
+ var LiquidityPoolABI = [
1217
+ // ─── Custom Errors ────────────────────────────────────────────────────────
1218
+ { type: "error", name: "BelowMinDeposit", inputs: [] },
1219
+ { type: "error", name: "ZeroAmount", inputs: [] },
1220
+ { type: "error", name: "LockPeriodActive", inputs: [] },
1221
+ { type: "error", name: "InsufficientBalance", inputs: [] },
1222
+ { type: "error", name: "OnlyGateway", inputs: [] },
1223
+ { type: "error", name: "ZeroAddress", inputs: [] },
1224
+ // ─── Events ───────────────────────────────────────────────────────────────
1225
+ {
1226
+ type: "event",
1227
+ name: "Deposited",
1228
+ inputs: [
1229
+ { name: "user", type: "address", indexed: true, internalType: "address" },
1230
+ { name: "amount", type: "uint256", indexed: false, internalType: "uint256" }
1231
+ ],
1232
+ anonymous: false
1233
+ },
1234
+ {
1235
+ type: "event",
1236
+ name: "Withdrawn",
1237
+ inputs: [
1238
+ { name: "user", type: "address", indexed: true, internalType: "address" },
1239
+ { name: "amount", type: "uint256", indexed: false, internalType: "uint256" }
1240
+ ],
1241
+ anonymous: false
1242
+ },
1243
+ {
1244
+ type: "event",
1245
+ name: "RewardsClaimed",
1246
+ inputs: [
1247
+ { name: "user", type: "address", indexed: true, internalType: "address" },
1248
+ { name: "amount", type: "uint256", indexed: false, internalType: "uint256" }
1249
+ ],
1250
+ anonymous: false
1251
+ },
1252
+ {
1253
+ type: "event",
1254
+ name: "RewardsDistributed",
1255
+ inputs: [{ name: "amount", type: "uint256", indexed: false, internalType: "uint256" }],
1256
+ anonymous: false
1257
+ },
1258
+ {
1259
+ type: "event",
1260
+ name: "OwnershipTransferred",
1261
+ inputs: [
1262
+ { name: "previousOwner", type: "address", indexed: true, internalType: "address" },
1263
+ { name: "newOwner", type: "address", indexed: true, internalType: "address" }
1264
+ ],
1265
+ anonymous: false
1266
+ },
1267
+ // ─── Constructor ──────────────────────────────────────────────────────────
1268
+ {
1269
+ type: "constructor",
1270
+ inputs: [
1271
+ { name: "_supportedToken", type: "address", internalType: "address" },
1272
+ { name: "_gateway", type: "address", internalType: "address" },
1273
+ { name: "_minDeposit", type: "uint256", internalType: "uint256" },
1274
+ { name: "_lockPeriod", type: "uint256", internalType: "uint256" }
1275
+ ],
1276
+ stateMutability: "nonpayable"
1277
+ },
1278
+ // ─── Functions: LP actions ────────────────────────────────────────────────
1279
+ {
1280
+ type: "function",
1281
+ name: "deposit",
1282
+ inputs: [{ name: "amount", type: "uint256", internalType: "uint256" }],
1283
+ outputs: [],
1284
+ stateMutability: "nonpayable"
1285
+ },
1286
+ {
1287
+ type: "function",
1288
+ name: "withdraw",
1289
+ inputs: [{ name: "amount", type: "uint256", internalType: "uint256" }],
1290
+ outputs: [],
1291
+ stateMutability: "nonpayable"
1292
+ },
1293
+ {
1294
+ type: "function",
1295
+ name: "claimRewards",
1296
+ inputs: [],
1297
+ outputs: [],
1298
+ stateMutability: "nonpayable"
1299
+ },
1300
+ {
1301
+ type: "function",
1302
+ name: "distributeRewards",
1303
+ inputs: [{ name: "amount", type: "uint256", internalType: "uint256" }],
1304
+ outputs: [],
1305
+ stateMutability: "nonpayable"
1306
+ },
1307
+ // ─── Functions: Admin ─────────────────────────────────────────────────────
1308
+ {
1309
+ type: "function",
1310
+ name: "setGateway",
1311
+ inputs: [{ name: "_gateway", type: "address", internalType: "address" }],
1312
+ outputs: [],
1313
+ stateMutability: "nonpayable"
1314
+ },
1315
+ {
1316
+ type: "function",
1317
+ name: "setMinDeposit",
1318
+ inputs: [{ name: "_minDeposit", type: "uint256", internalType: "uint256" }],
1319
+ outputs: [],
1320
+ stateMutability: "nonpayable"
1321
+ },
1322
+ {
1323
+ type: "function",
1324
+ name: "setLockPeriod",
1325
+ inputs: [{ name: "_lockPeriod", type: "uint256", internalType: "uint256" }],
1326
+ outputs: [],
1327
+ stateMutability: "nonpayable"
1328
+ },
1329
+ // ─── Functions: View ──────────────────────────────────────────────────────
1330
+ {
1331
+ type: "function",
1332
+ name: "getRewards",
1333
+ inputs: [{ name: "user", type: "address", internalType: "address" }],
1334
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
1335
+ stateMutability: "view"
1336
+ },
1337
+ {
1338
+ type: "function",
1339
+ name: "getDeposit",
1340
+ inputs: [{ name: "user", type: "address", internalType: "address" }],
1341
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
1342
+ stateMutability: "view"
1343
+ },
1344
+ {
1345
+ type: "function",
1346
+ name: "getPoolInfo",
1347
+ inputs: [],
1348
+ outputs: [
1349
+ {
1350
+ name: "",
1351
+ type: "tuple",
1352
+ internalType: "struct ILiquidityPool.PoolInfo",
1353
+ components: [
1354
+ { name: "totalDeposits", type: "uint256", internalType: "uint256" },
1355
+ { name: "rewardPerToken", type: "uint256", internalType: "uint256" },
1356
+ { name: "supportedToken", type: "address", internalType: "address" },
1357
+ { name: "minDeposit", type: "uint256", internalType: "uint256" },
1358
+ { name: "lockPeriod", type: "uint256", internalType: "uint256" }
1359
+ ]
1360
+ }
1361
+ ],
1362
+ stateMutability: "view"
1363
+ },
1364
+ {
1365
+ type: "function",
1366
+ name: "supportedToken",
1367
+ inputs: [],
1368
+ outputs: [{ name: "", type: "address", internalType: "address" }],
1369
+ stateMutability: "view"
1370
+ },
1371
+ {
1372
+ type: "function",
1373
+ name: "totalDeposits",
1374
+ inputs: [],
1375
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
1376
+ stateMutability: "view"
1377
+ },
1378
+ {
1379
+ type: "function",
1380
+ name: "minDeposit",
1381
+ inputs: [],
1382
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
1383
+ stateMutability: "view"
1384
+ },
1385
+ {
1386
+ type: "function",
1387
+ name: "lockPeriod",
1388
+ inputs: [],
1389
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
1390
+ stateMutability: "view"
1391
+ },
1392
+ {
1393
+ type: "function",
1394
+ name: "accRewardPerShare",
1395
+ inputs: [],
1396
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
1397
+ stateMutability: "view"
1398
+ },
1399
+ {
1400
+ type: "function",
1401
+ name: "gateway",
1402
+ inputs: [],
1403
+ outputs: [{ name: "", type: "address", internalType: "address" }],
1404
+ stateMutability: "view"
1405
+ },
1406
+ {
1407
+ type: "function",
1408
+ name: "owner",
1409
+ inputs: [],
1410
+ outputs: [{ name: "", type: "address", internalType: "address" }],
1411
+ stateMutability: "view"
1412
+ }
1413
+ ];
1414
+
1415
+ // src/abis/VaultController.ts
1416
+ var VaultControllerABI = [
1417
+ // ─── Custom Errors ────────────────────────────────────────────────────────
1418
+ { type: "error", name: "BelowMinDeposit", inputs: [] },
1419
+ { type: "error", name: "ZeroAmount", inputs: [] },
1420
+ { type: "error", name: "InsufficientBalance", inputs: [] },
1421
+ { type: "error", name: "NoYieldAvailable", inputs: [] },
1422
+ { type: "error", name: "ZeroAddress", inputs: [] },
1423
+ { type: "error", name: "InvalidYieldRate", inputs: [] },
1424
+ // ─── Events ───────────────────────────────────────────────────────────────
1425
+ {
1426
+ type: "event",
1427
+ name: "VaultDeposited",
1428
+ inputs: [
1429
+ { name: "user", type: "address", indexed: true, internalType: "address" },
1430
+ { name: "amount", type: "uint256", indexed: false, internalType: "uint256" }
1431
+ ],
1432
+ anonymous: false
1433
+ },
1434
+ {
1435
+ type: "event",
1436
+ name: "VaultWithdrawn",
1437
+ inputs: [
1438
+ { name: "user", type: "address", indexed: true, internalType: "address" },
1439
+ { name: "amount", type: "uint256", indexed: false, internalType: "uint256" }
1440
+ ],
1441
+ anonymous: false
1442
+ },
1443
+ {
1444
+ type: "event",
1445
+ name: "YieldClaimed",
1446
+ inputs: [
1447
+ { name: "user", type: "address", indexed: true, internalType: "address" },
1448
+ { name: "yieldAmount", type: "uint256", indexed: false, internalType: "uint256" }
1449
+ ],
1450
+ anonymous: false
1451
+ },
1452
+ {
1453
+ type: "event",
1454
+ name: "YieldRateUpdated",
1455
+ inputs: [{ name: "newRate", type: "uint256", indexed: false, internalType: "uint256" }],
1456
+ anonymous: false
1457
+ },
1458
+ {
1459
+ type: "event",
1460
+ name: "OwnershipTransferred",
1461
+ inputs: [
1462
+ { name: "previousOwner", type: "address", indexed: true, internalType: "address" },
1463
+ { name: "newOwner", type: "address", indexed: true, internalType: "address" }
1464
+ ],
1465
+ anonymous: false
1466
+ },
1467
+ // ─── Constructor ──────────────────────────────────────────────────────────
1468
+ {
1469
+ type: "constructor",
1470
+ inputs: [
1471
+ { name: "_supportedToken", type: "address", internalType: "address" },
1472
+ { name: "_annualYieldRate", type: "uint256", internalType: "uint256" },
1473
+ { name: "_minDeposit", type: "uint256", internalType: "uint256" }
1474
+ ],
1475
+ stateMutability: "nonpayable"
1476
+ },
1477
+ // ─── Functions: Vault actions ─────────────────────────────────────────────
1478
+ {
1479
+ type: "function",
1480
+ name: "deposit",
1481
+ inputs: [{ name: "amount", type: "uint256", internalType: "uint256" }],
1482
+ outputs: [],
1483
+ stateMutability: "nonpayable"
1484
+ },
1485
+ {
1486
+ type: "function",
1487
+ name: "withdraw",
1488
+ inputs: [{ name: "amount", type: "uint256", internalType: "uint256" }],
1489
+ outputs: [],
1490
+ stateMutability: "nonpayable"
1491
+ },
1492
+ {
1493
+ type: "function",
1494
+ name: "claimYield",
1495
+ inputs: [],
1496
+ outputs: [],
1497
+ stateMutability: "nonpayable"
1498
+ },
1499
+ // ─── Functions: Admin ─────────────────────────────────────────────────────
1500
+ {
1501
+ type: "function",
1502
+ name: "setAnnualYieldRate",
1503
+ inputs: [{ name: "rate", type: "uint256", internalType: "uint256" }],
1504
+ outputs: [],
1505
+ stateMutability: "nonpayable"
1506
+ },
1507
+ {
1508
+ type: "function",
1509
+ name: "setMinDeposit",
1510
+ inputs: [{ name: "amount", type: "uint256", internalType: "uint256" }],
1511
+ outputs: [],
1512
+ stateMutability: "nonpayable"
1513
+ },
1514
+ {
1515
+ type: "function",
1516
+ name: "transferOwnership",
1517
+ inputs: [{ name: "newOwner", type: "address", internalType: "address" }],
1518
+ outputs: [],
1519
+ stateMutability: "nonpayable"
1520
+ },
1521
+ {
1522
+ type: "function",
1523
+ name: "renounceOwnership",
1524
+ inputs: [],
1525
+ outputs: [],
1526
+ stateMutability: "nonpayable"
1527
+ },
1528
+ // ─── Functions: View ──────────────────────────────────────────────────────
1529
+ {
1530
+ type: "function",
1531
+ name: "getVault",
1532
+ inputs: [{ name: "user", type: "address", internalType: "address" }],
1533
+ outputs: [
1534
+ {
1535
+ name: "",
1536
+ type: "tuple",
1537
+ internalType: "struct IVault.VaultInfo",
1538
+ components: [
1539
+ { name: "balance", type: "uint256", internalType: "uint256" },
1540
+ { name: "depositedAt", type: "uint256", internalType: "uint256" },
1541
+ { name: "lastYieldClaim", type: "uint256", internalType: "uint256" }
1542
+ ]
1543
+ }
1544
+ ],
1545
+ stateMutability: "view"
1546
+ },
1547
+ {
1548
+ type: "function",
1549
+ name: "calculateYield",
1550
+ inputs: [{ name: "user", type: "address", internalType: "address" }],
1551
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
1552
+ stateMutability: "view"
1553
+ },
1554
+ {
1555
+ type: "function",
1556
+ name: "annualYieldRate",
1557
+ inputs: [],
1558
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
1559
+ stateMutability: "view"
1560
+ },
1561
+ {
1562
+ type: "function",
1563
+ name: "minDeposit",
1564
+ inputs: [],
1565
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
1566
+ stateMutability: "view"
1567
+ },
1568
+ {
1569
+ type: "function",
1570
+ name: "totalDeposited",
1571
+ inputs: [],
1572
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
1573
+ stateMutability: "view"
1574
+ },
1575
+ {
1576
+ type: "function",
1577
+ name: "supportedToken",
1578
+ inputs: [],
1579
+ outputs: [{ name: "", type: "address", internalType: "address" }],
1580
+ stateMutability: "view"
1581
+ },
1582
+ {
1583
+ type: "function",
1584
+ name: "MAX_YIELD_RATE",
1585
+ inputs: [],
1586
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
1587
+ stateMutability: "view"
1588
+ },
1589
+ {
1590
+ type: "function",
1591
+ name: "owner",
1592
+ inputs: [],
1593
+ outputs: [{ name: "", type: "address", internalType: "address" }],
1594
+ stateMutability: "view"
1595
+ }
1596
+ ];
1597
+
1598
+ // src/abis/GHSFIAT.ts
1599
+ var GHSFIATABI = [
1600
+ // ─── Custom Errors ────────────────────────────────────────────────────────
1601
+ { type: "error", name: "ZeroAddress", inputs: [] },
1602
+ { type: "error", name: "ZeroAmount", inputs: [] },
1603
+ // ─── Events ───────────────────────────────────────────────────────────────
1604
+ {
1605
+ type: "event",
1606
+ name: "Transfer",
1607
+ inputs: [
1608
+ { name: "from", type: "address", indexed: true, internalType: "address" },
1609
+ { name: "to", type: "address", indexed: true, internalType: "address" },
1610
+ { name: "value", type: "uint256", indexed: false, internalType: "uint256" }
1611
+ ],
1612
+ anonymous: false
1613
+ },
1614
+ {
1615
+ type: "event",
1616
+ name: "Approval",
1617
+ inputs: [
1618
+ { name: "owner", type: "address", indexed: true, internalType: "address" },
1619
+ { name: "spender", type: "address", indexed: true, internalType: "address" },
1620
+ { name: "value", type: "uint256", indexed: false, internalType: "uint256" }
1621
+ ],
1622
+ anonymous: false
1623
+ },
1624
+ {
1625
+ type: "event",
1626
+ name: "Paused",
1627
+ inputs: [{ name: "account", type: "address", indexed: false, internalType: "address" }],
1628
+ anonymous: false
1629
+ },
1630
+ {
1631
+ type: "event",
1632
+ name: "Unpaused",
1633
+ inputs: [{ name: "account", type: "address", indexed: false, internalType: "address" }],
1634
+ anonymous: false
1635
+ },
1636
+ {
1637
+ type: "event",
1638
+ name: "RoleGranted",
1639
+ inputs: [
1640
+ { name: "role", type: "bytes32", indexed: true, internalType: "bytes32" },
1641
+ { name: "account", type: "address", indexed: true, internalType: "address" },
1642
+ { name: "sender", type: "address", indexed: true, internalType: "address" }
1643
+ ],
1644
+ anonymous: false
1645
+ },
1646
+ {
1647
+ type: "event",
1648
+ name: "RoleRevoked",
1649
+ inputs: [
1650
+ { name: "role", type: "bytes32", indexed: true, internalType: "bytes32" },
1651
+ { name: "account", type: "address", indexed: true, internalType: "address" },
1652
+ { name: "sender", type: "address", indexed: true, internalType: "address" }
1653
+ ],
1654
+ anonymous: false
1655
+ },
1656
+ // ─── Constructor ──────────────────────────────────────────────────────────
1657
+ {
1658
+ type: "constructor",
1659
+ inputs: [{ name: "admin", type: "address", internalType: "address" }],
1660
+ stateMutability: "nonpayable"
1661
+ },
1662
+ // ─── Functions: Mint / Burn ───────────────────────────────────────────────
1663
+ {
1664
+ type: "function",
1665
+ name: "mint",
1666
+ inputs: [
1667
+ { name: "to", type: "address", internalType: "address" },
1668
+ { name: "amount", type: "uint256", internalType: "uint256" }
1669
+ ],
1670
+ outputs: [],
1671
+ stateMutability: "nonpayable"
1672
+ },
1673
+ {
1674
+ type: "function",
1675
+ name: "burn",
1676
+ inputs: [{ name: "amount", type: "uint256", internalType: "uint256" }],
1677
+ outputs: [],
1678
+ stateMutability: "nonpayable"
1679
+ },
1680
+ {
1681
+ type: "function",
1682
+ name: "burnFrom",
1683
+ inputs: [
1684
+ { name: "account", type: "address", internalType: "address" },
1685
+ { name: "amount", type: "uint256", internalType: "uint256" }
1686
+ ],
1687
+ outputs: [],
1688
+ stateMutability: "nonpayable"
1689
+ },
1690
+ // ─── Functions: Pause / Unpause ───────────────────────────────────────────
1691
+ {
1692
+ type: "function",
1693
+ name: "pause",
1694
+ inputs: [],
1695
+ outputs: [],
1696
+ stateMutability: "nonpayable"
1697
+ },
1698
+ {
1699
+ type: "function",
1700
+ name: "unpause",
1701
+ inputs: [],
1702
+ outputs: [],
1703
+ stateMutability: "nonpayable"
1704
+ },
1705
+ // ─── Functions: ERC20 ─────────────────────────────────────────────────────
1706
+ {
1707
+ type: "function",
1708
+ name: "transfer",
1709
+ inputs: [
1710
+ { name: "to", type: "address", internalType: "address" },
1711
+ { name: "value", type: "uint256", internalType: "uint256" }
1712
+ ],
1713
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
1714
+ stateMutability: "nonpayable"
1715
+ },
1716
+ {
1717
+ type: "function",
1718
+ name: "transferFrom",
1719
+ inputs: [
1720
+ { name: "from", type: "address", internalType: "address" },
1721
+ { name: "to", type: "address", internalType: "address" },
1722
+ { name: "value", type: "uint256", internalType: "uint256" }
1723
+ ],
1724
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
1725
+ stateMutability: "nonpayable"
1726
+ },
1727
+ {
1728
+ type: "function",
1729
+ name: "approve",
1730
+ inputs: [
1731
+ { name: "spender", type: "address", internalType: "address" },
1732
+ { name: "value", type: "uint256", internalType: "uint256" }
1733
+ ],
1734
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
1735
+ stateMutability: "nonpayable"
1736
+ },
1737
+ // ─── Functions: AccessControl ─────────────────────────────────────────────
1738
+ {
1739
+ type: "function",
1740
+ name: "grantRole",
1741
+ inputs: [
1742
+ { name: "role", type: "bytes32", internalType: "bytes32" },
1743
+ { name: "account", type: "address", internalType: "address" }
1744
+ ],
1745
+ outputs: [],
1746
+ stateMutability: "nonpayable"
1747
+ },
1748
+ {
1749
+ type: "function",
1750
+ name: "revokeRole",
1751
+ inputs: [
1752
+ { name: "role", type: "bytes32", internalType: "bytes32" },
1753
+ { name: "account", type: "address", internalType: "address" }
1754
+ ],
1755
+ outputs: [],
1756
+ stateMutability: "nonpayable"
1757
+ },
1758
+ {
1759
+ type: "function",
1760
+ name: "renounceRole",
1761
+ inputs: [
1762
+ { name: "role", type: "bytes32", internalType: "bytes32" },
1763
+ { name: "callerConfirmation", type: "address", internalType: "address" }
1764
+ ],
1765
+ outputs: [],
1766
+ stateMutability: "nonpayable"
1767
+ },
1768
+ // ─── Functions: View ──────────────────────────────────────────────────────
1769
+ {
1770
+ type: "function",
1771
+ name: "balanceOf",
1772
+ inputs: [{ name: "account", type: "address", internalType: "address" }],
1773
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
1774
+ stateMutability: "view"
1775
+ },
1776
+ {
1777
+ type: "function",
1778
+ name: "allowance",
1779
+ inputs: [
1780
+ { name: "owner", type: "address", internalType: "address" },
1781
+ { name: "spender", type: "address", internalType: "address" }
1782
+ ],
1783
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
1784
+ stateMutability: "view"
1785
+ },
1786
+ {
1787
+ type: "function",
1788
+ name: "totalSupply",
1789
+ inputs: [],
1790
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
1791
+ stateMutability: "view"
1792
+ },
1793
+ {
1794
+ type: "function",
1795
+ name: "name",
1796
+ inputs: [],
1797
+ outputs: [{ name: "", type: "string", internalType: "string" }],
1798
+ stateMutability: "view"
1799
+ },
1800
+ {
1801
+ type: "function",
1802
+ name: "symbol",
1803
+ inputs: [],
1804
+ outputs: [{ name: "", type: "string", internalType: "string" }],
1805
+ stateMutability: "view"
1806
+ },
1807
+ {
1808
+ type: "function",
1809
+ name: "decimals",
1810
+ inputs: [],
1811
+ outputs: [{ name: "", type: "uint8", internalType: "uint8" }],
1812
+ stateMutability: "view"
1813
+ },
1814
+ {
1815
+ type: "function",
1816
+ name: "paused",
1817
+ inputs: [],
1818
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
1819
+ stateMutability: "view"
1820
+ },
1821
+ {
1822
+ type: "function",
1823
+ name: "MINTER_ROLE",
1824
+ inputs: [],
1825
+ outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
1826
+ stateMutability: "view"
1827
+ },
1828
+ {
1829
+ type: "function",
1830
+ name: "PAUSER_ROLE",
1831
+ inputs: [],
1832
+ outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
1833
+ stateMutability: "view"
1834
+ },
1835
+ {
1836
+ type: "function",
1837
+ name: "DEFAULT_ADMIN_ROLE",
1838
+ inputs: [],
1839
+ outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
1840
+ stateMutability: "view"
1841
+ },
1842
+ {
1843
+ type: "function",
1844
+ name: "hasRole",
1845
+ inputs: [
1846
+ { name: "role", type: "bytes32", internalType: "bytes32" },
1847
+ { name: "account", type: "address", internalType: "address" }
1848
+ ],
1849
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
1850
+ stateMutability: "view"
1851
+ },
1852
+ {
1853
+ type: "function",
1854
+ name: "getRoleAdmin",
1855
+ inputs: [{ name: "role", type: "bytes32", internalType: "bytes32" }],
1856
+ outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
1857
+ stateMutability: "view"
1858
+ },
1859
+ {
1860
+ type: "function",
1861
+ name: "supportsInterface",
1862
+ inputs: [{ name: "interfaceId", type: "bytes4", internalType: "bytes4" }],
1863
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
1864
+ stateMutability: "view"
1865
+ }
1866
+ ];
1867
+
1868
+ // src/abis/PayoutEscrow.ts
1869
+ var PayoutEscrowABI = [
1870
+ // ─── Custom Errors ────────────────────────────────────────────────────────
1871
+ { type: "error", name: "PayoutAlreadyExists", inputs: [] },
1872
+ { type: "error", name: "PayoutNotFound", inputs: [] },
1873
+ { type: "error", name: "NotAuthorizedSender", inputs: [] },
1874
+ { type: "error", name: "NotPending", inputs: [] },
1875
+ { type: "error", name: "NotExpiredYet", inputs: [] },
1876
+ { type: "error", name: "NotRefundEligible", inputs: [] },
1877
+ { type: "error", name: "PhoneHashMismatch", inputs: [] },
1878
+ { type: "error", name: "NoMobileNFT", inputs: [] },
1879
+ { type: "error", name: "ZeroAddress", inputs: [] },
1880
+ { type: "error", name: "ZeroAmount", inputs: [] },
1881
+ { type: "error", name: "ArrayLengthMismatch", inputs: [] },
1882
+ { type: "error", name: "InvalidExpiry", inputs: [] },
1883
+ { type: "error", name: "GatewayNotSet", inputs: [] },
1884
+ { type: "error", name: "TokenNotSupportedByGateway", inputs: [] },
1885
+ // ─── Events ───────────────────────────────────────────────────────────────
1886
+ {
1887
+ type: "event",
1888
+ name: "PayoutCreated",
1889
+ inputs: [
1890
+ { name: "payoutId", type: "bytes32", indexed: true, internalType: "bytes32" },
1891
+ { name: "sender", type: "address", indexed: true, internalType: "address" },
1892
+ { name: "token", type: "address", indexed: false, internalType: "address" },
1893
+ { name: "amount", type: "uint256", indexed: false, internalType: "uint256" },
1894
+ { name: "phoneHash", type: "bytes32", indexed: true, internalType: "bytes32" }
1895
+ ],
1896
+ anonymous: false
1897
+ },
1898
+ {
1899
+ type: "event",
1900
+ name: "PayoutClaimed",
1901
+ inputs: [
1902
+ { name: "payoutId", type: "bytes32", indexed: true, internalType: "bytes32" },
1903
+ { name: "recipient", type: "address", indexed: true, internalType: "address" },
1904
+ { name: "amount", type: "uint256", indexed: false, internalType: "uint256" }
1905
+ ],
1906
+ anonymous: false
1907
+ },
1908
+ {
1909
+ type: "event",
1910
+ name: "PayoutRefunded",
1911
+ inputs: [
1912
+ { name: "payoutId", type: "bytes32", indexed: true, internalType: "bytes32" },
1913
+ { name: "sender", type: "address", indexed: true, internalType: "address" },
1914
+ { name: "amount", type: "uint256", indexed: false, internalType: "uint256" }
1915
+ ],
1916
+ anonymous: false
1917
+ },
1918
+ {
1919
+ type: "event",
1920
+ name: "PayoutExpired",
1921
+ inputs: [
1922
+ { name: "payoutId", type: "bytes32", indexed: true, internalType: "bytes32" }
1923
+ ],
1924
+ anonymous: false
1925
+ },
1926
+ {
1927
+ type: "event",
1928
+ name: "AuthorizedSenderSet",
1929
+ inputs: [
1930
+ { name: "sender", type: "address", indexed: true, internalType: "address" },
1931
+ { name: "authorized", type: "bool", indexed: false, internalType: "bool" }
1932
+ ],
1933
+ anonymous: false
1934
+ },
1935
+ {
1936
+ type: "event",
1937
+ name: "GatewaySet",
1938
+ inputs: [
1939
+ { name: "gateway", type: "address", indexed: true, internalType: "address" }
1940
+ ],
1941
+ anonymous: false
1942
+ },
1943
+ {
1944
+ type: "event",
1945
+ name: "DefaultExpiryDurationSet",
1946
+ inputs: [
1947
+ { name: "duration", type: "uint256", indexed: false, internalType: "uint256" }
1948
+ ],
1949
+ anonymous: false
1950
+ },
1951
+ {
1952
+ type: "event",
1953
+ name: "OwnershipTransferred",
1954
+ inputs: [
1955
+ { name: "previousOwner", type: "address", indexed: true, internalType: "address" },
1956
+ { name: "newOwner", type: "address", indexed: true, internalType: "address" }
1957
+ ],
1958
+ anonymous: false
1959
+ },
1960
+ {
1961
+ type: "event",
1962
+ name: "Paused",
1963
+ inputs: [{ name: "account", type: "address", indexed: false, internalType: "address" }],
1964
+ anonymous: false
1965
+ },
1966
+ {
1967
+ type: "event",
1968
+ name: "Unpaused",
1969
+ inputs: [{ name: "account", type: "address", indexed: false, internalType: "address" }],
1970
+ anonymous: false
1971
+ },
1972
+ // ─── Constructor ──────────────────────────────────────────────────────────
1973
+ {
1974
+ type: "constructor",
1975
+ inputs: [
1976
+ { name: "_mobileNumberNFT", type: "address", internalType: "address" },
1977
+ { name: "_gateway", type: "address", internalType: "address" },
1978
+ { name: "_expiryDuration", type: "uint256", internalType: "uint256" }
1979
+ ],
1980
+ stateMutability: "nonpayable"
1981
+ },
1982
+ // ─── Functions: Payout creation ───────────────────────────────────────────
1983
+ {
1984
+ type: "function",
1985
+ name: "createPayout",
1986
+ inputs: [
1987
+ { name: "payoutId", type: "bytes32", internalType: "bytes32" },
1988
+ { name: "token", type: "address", internalType: "address" },
1989
+ { name: "amount", type: "uint256", internalType: "uint256" },
1990
+ { name: "phoneHash", type: "bytes32", internalType: "bytes32" },
1991
+ { name: "expiresAt", type: "uint256", internalType: "uint256" }
1992
+ ],
1993
+ outputs: [],
1994
+ stateMutability: "nonpayable"
1995
+ },
1996
+ {
1997
+ type: "function",
1998
+ name: "createBatchPayout",
1999
+ inputs: [
2000
+ { name: "payoutIds", type: "bytes32[]", internalType: "bytes32[]" },
2001
+ { name: "token", type: "address", internalType: "address" },
2002
+ { name: "amounts", type: "uint256[]", internalType: "uint256[]" },
2003
+ { name: "phoneHashes", type: "bytes32[]", internalType: "bytes32[]" },
2004
+ { name: "expiresAt", type: "uint256", internalType: "uint256" }
2005
+ ],
2006
+ outputs: [],
2007
+ stateMutability: "nonpayable"
2008
+ },
2009
+ // ─── Functions: Claim ─────────────────────────────────────────────────────
2010
+ {
2011
+ type: "function",
2012
+ name: "claim",
2013
+ inputs: [
2014
+ { name: "payoutId", type: "bytes32", internalType: "bytes32" }
2015
+ ],
2016
+ outputs: [],
2017
+ stateMutability: "nonpayable"
2018
+ },
2019
+ {
2020
+ type: "function",
2021
+ name: "claimToMoMo",
2022
+ inputs: [
2023
+ { name: "payoutId", type: "bytes32", internalType: "bytes32" },
2024
+ { name: "phoneNumber", type: "string", internalType: "string" }
2025
+ ],
2026
+ outputs: [],
2027
+ stateMutability: "nonpayable"
2028
+ },
2029
+ // ─── Functions: Refund ────────────────────────────────────────────────────
2030
+ {
2031
+ type: "function",
2032
+ name: "refund",
2033
+ inputs: [
2034
+ { name: "payoutId", type: "bytes32", internalType: "bytes32" }
2035
+ ],
2036
+ outputs: [],
2037
+ stateMutability: "nonpayable"
2038
+ },
2039
+ // ─── Functions: View ──────────────────────────────────────────────────────
2040
+ {
2041
+ type: "function",
2042
+ name: "getPayout",
2043
+ inputs: [
2044
+ { name: "payoutId", type: "bytes32", internalType: "bytes32" }
2045
+ ],
2046
+ outputs: [
2047
+ {
2048
+ name: "",
2049
+ type: "tuple",
2050
+ internalType: "struct IPayoutEscrow.Payout",
2051
+ components: [
2052
+ { name: "id", type: "bytes32", internalType: "bytes32" },
2053
+ { name: "sender", type: "address", internalType: "address" },
2054
+ { name: "recipient", type: "address", internalType: "address" },
2055
+ { name: "token", type: "address", internalType: "address" },
2056
+ { name: "amount", type: "uint256", internalType: "uint256" },
2057
+ { name: "phoneHash", type: "bytes32", internalType: "bytes32" },
2058
+ { name: "status", type: "uint8", internalType: "enum IPayoutEscrow.PayoutStatus" },
2059
+ { name: "expiresAt", type: "uint256", internalType: "uint256" },
2060
+ { name: "createdAt", type: "uint256", internalType: "uint256" },
2061
+ { name: "claimedAt", type: "uint256", internalType: "uint256" }
2062
+ ]
2063
+ }
2064
+ ],
2065
+ stateMutability: "view"
2066
+ },
2067
+ {
2068
+ type: "function",
2069
+ name: "getPayoutsForPhone",
2070
+ inputs: [
2071
+ { name: "phoneHash", type: "bytes32", internalType: "bytes32" }
2072
+ ],
2073
+ outputs: [
2074
+ { name: "", type: "bytes32[]", internalType: "bytes32[]" }
2075
+ ],
2076
+ stateMutability: "view"
2077
+ },
2078
+ {
2079
+ type: "function",
2080
+ name: "getPayoutsByStatus",
2081
+ inputs: [
2082
+ { name: "phoneHash", type: "bytes32", internalType: "bytes32" },
2083
+ { name: "status", type: "uint8", internalType: "enum IPayoutEscrow.PayoutStatus" }
2084
+ ],
2085
+ outputs: [
2086
+ { name: "", type: "bytes32[]", internalType: "bytes32[]" }
2087
+ ],
2088
+ stateMutability: "view"
2089
+ },
2090
+ // ─── Functions: Admin ─────────────────────────────────────────────────────
2091
+ {
2092
+ type: "function",
2093
+ name: "setAuthorizedSender",
2094
+ inputs: [
2095
+ { name: "sender", type: "address", internalType: "address" },
2096
+ { name: "authorized", type: "bool", internalType: "bool" }
2097
+ ],
2098
+ outputs: [],
2099
+ stateMutability: "nonpayable"
2100
+ },
2101
+ {
2102
+ type: "function",
2103
+ name: "setDefaultExpiryDuration",
2104
+ inputs: [
2105
+ { name: "duration", type: "uint256", internalType: "uint256" }
2106
+ ],
2107
+ outputs: [],
2108
+ stateMutability: "nonpayable"
2109
+ },
2110
+ {
2111
+ type: "function",
2112
+ name: "setGateway",
2113
+ inputs: [
2114
+ { name: "_gateway", type: "address", internalType: "address" }
2115
+ ],
2116
+ outputs: [],
2117
+ stateMutability: "nonpayable"
2118
+ },
2119
+ {
2120
+ type: "function",
2121
+ name: "pause",
2122
+ inputs: [],
2123
+ outputs: [],
2124
+ stateMutability: "nonpayable"
2125
+ },
2126
+ {
2127
+ type: "function",
2128
+ name: "unpause",
2129
+ inputs: [],
2130
+ outputs: [],
2131
+ stateMutability: "nonpayable"
2132
+ },
2133
+ {
2134
+ type: "function",
2135
+ name: "transferOwnership",
2136
+ inputs: [{ name: "newOwner", type: "address", internalType: "address" }],
2137
+ outputs: [],
2138
+ stateMutability: "nonpayable"
2139
+ },
2140
+ {
2141
+ type: "function",
2142
+ name: "renounceOwnership",
2143
+ inputs: [],
2144
+ outputs: [],
2145
+ stateMutability: "nonpayable"
2146
+ },
2147
+ // ─── Functions: State vars ────────────────────────────────────────────────
2148
+ {
2149
+ type: "function",
2150
+ name: "mobileNumberNFT",
2151
+ inputs: [],
2152
+ outputs: [{ name: "", type: "address", internalType: "address" }],
2153
+ stateMutability: "view"
2154
+ },
2155
+ {
2156
+ type: "function",
2157
+ name: "gateway",
2158
+ inputs: [],
2159
+ outputs: [{ name: "", type: "address", internalType: "address" }],
2160
+ stateMutability: "view"
2161
+ },
2162
+ {
2163
+ type: "function",
2164
+ name: "defaultExpiryDuration",
2165
+ inputs: [],
2166
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
2167
+ stateMutability: "view"
2168
+ },
2169
+ {
2170
+ type: "function",
2171
+ name: "authorizedSenders",
2172
+ inputs: [{ name: "sender", type: "address", internalType: "address" }],
2173
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
2174
+ stateMutability: "view"
2175
+ },
2176
+ {
2177
+ type: "function",
2178
+ name: "owner",
2179
+ inputs: [],
2180
+ outputs: [{ name: "", type: "address", internalType: "address" }],
2181
+ stateMutability: "view"
2182
+ },
2183
+ {
2184
+ type: "function",
2185
+ name: "paused",
2186
+ inputs: [],
2187
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
2188
+ stateMutability: "view"
2189
+ }
2190
+ ];
2191
+
2192
+ // src/abis/P2PExchange.ts
2193
+ var P2PExchangeABI = [
2194
+ // ─── Custom Errors ────────────────────────────────────────────────────────
2195
+ { type: "error", name: "OrderAlreadyExists", inputs: [] },
2196
+ { type: "error", name: "OrderNotFound", inputs: [] },
2197
+ { type: "error", name: "NotMaker", inputs: [] },
2198
+ { type: "error", name: "NotParty", inputs: [] },
2199
+ { type: "error", name: "NotDisputeResolver", inputs: [] },
2200
+ { type: "error", name: "OrderNotOpen", inputs: [] },
2201
+ { type: "error", name: "OrderNotLocked", inputs: [] },
2202
+ { type: "error", name: "OrderNotDisputed", inputs: [] },
2203
+ { type: "error", name: "AlreadyTaken", inputs: [] },
2204
+ { type: "error", name: "SelfTake", inputs: [] },
2205
+ { type: "error", name: "ZeroAddress", inputs: [] },
2206
+ { type: "error", name: "ZeroAmount", inputs: [] },
2207
+ { type: "error", name: "ZeroExpiryDuration", inputs: [] },
2208
+ { type: "error", name: "InvalidWinner", inputs: [] },
2209
+ // ─── Events ───────────────────────────────────────────────────────────────
2210
+ {
2211
+ type: "event",
2212
+ name: "OrderCreated",
2213
+ inputs: [
2214
+ { name: "orderId", type: "bytes32", indexed: true, internalType: "bytes32" },
2215
+ { name: "maker", type: "address", indexed: true, internalType: "address" },
2216
+ { name: "token", type: "address", indexed: false, internalType: "address" },
2217
+ { name: "amount", type: "uint256", indexed: false, internalType: "uint256" },
2218
+ { name: "paymentReference", type: "string", indexed: false, internalType: "string" },
2219
+ { name: "exchangePlatform", type: "string", indexed: false, internalType: "string" }
2220
+ ],
2221
+ anonymous: false
2222
+ },
2223
+ {
2224
+ type: "event",
2225
+ name: "OrderTaken",
2226
+ inputs: [
2227
+ { name: "orderId", type: "bytes32", indexed: true, internalType: "bytes32" },
2228
+ { name: "taker", type: "address", indexed: true, internalType: "address" }
2229
+ ],
2230
+ anonymous: false
2231
+ },
2232
+ {
2233
+ type: "event",
2234
+ name: "OrderCompleted",
2235
+ inputs: [
2236
+ { name: "orderId", type: "bytes32", indexed: true, internalType: "bytes32" },
2237
+ { name: "taker", type: "address", indexed: true, internalType: "address" },
2238
+ { name: "amount", type: "uint256", indexed: false, internalType: "uint256" }
2239
+ ],
2240
+ anonymous: false
2241
+ },
2242
+ {
2243
+ type: "event",
2244
+ name: "OrderCancelled",
2245
+ inputs: [
2246
+ { name: "orderId", type: "bytes32", indexed: true, internalType: "bytes32" }
2247
+ ],
2248
+ anonymous: false
2249
+ },
2250
+ {
2251
+ type: "event",
2252
+ name: "OrderDisputed",
2253
+ inputs: [
2254
+ { name: "orderId", type: "bytes32", indexed: true, internalType: "bytes32" },
2255
+ { name: "disputedBy", type: "address", indexed: true, internalType: "address" }
2256
+ ],
2257
+ anonymous: false
2258
+ },
2259
+ {
2260
+ type: "event",
2261
+ name: "DisputeResolved",
2262
+ inputs: [
2263
+ { name: "orderId", type: "bytes32", indexed: true, internalType: "bytes32" },
2264
+ { name: "winner", type: "address", indexed: true, internalType: "address" },
2265
+ { name: "amount", type: "uint256", indexed: false, internalType: "uint256" }
2266
+ ],
2267
+ anonymous: false
2268
+ },
2269
+ {
2270
+ type: "event",
2271
+ name: "DisputeResolverSet",
2272
+ inputs: [
2273
+ { name: "resolver", type: "address", indexed: true, internalType: "address" }
2274
+ ],
2275
+ anonymous: false
2276
+ },
2277
+ {
2278
+ type: "event",
2279
+ name: "OwnershipTransferred",
2280
+ inputs: [
2281
+ { name: "previousOwner", type: "address", indexed: true, internalType: "address" },
2282
+ { name: "newOwner", type: "address", indexed: true, internalType: "address" }
2283
+ ],
2284
+ anonymous: false
2285
+ },
2286
+ {
2287
+ type: "event",
2288
+ name: "Paused",
2289
+ inputs: [{ name: "account", type: "address", indexed: false, internalType: "address" }],
2290
+ anonymous: false
2291
+ },
2292
+ {
2293
+ type: "event",
2294
+ name: "Unpaused",
2295
+ inputs: [{ name: "account", type: "address", indexed: false, internalType: "address" }],
2296
+ anonymous: false
2297
+ },
2298
+ // ─── Constructor ──────────────────────────────────────────────────────────
2299
+ {
2300
+ type: "constructor",
2301
+ inputs: [
2302
+ { name: "_disputeResolver", type: "address", internalType: "address" }
2303
+ ],
2304
+ stateMutability: "nonpayable"
2305
+ },
2306
+ // ─── Functions: Order lifecycle ───────────────────────────────────────────
2307
+ {
2308
+ type: "function",
2309
+ name: "createOrder",
2310
+ inputs: [
2311
+ { name: "orderId", type: "bytes32", internalType: "bytes32" },
2312
+ { name: "token", type: "address", internalType: "address" },
2313
+ { name: "amount", type: "uint256", internalType: "uint256" },
2314
+ { name: "paymentReference", type: "string", internalType: "string" },
2315
+ { name: "exchangePlatform", type: "string", internalType: "string" },
2316
+ { name: "expiryDuration", type: "uint256", internalType: "uint256" }
2317
+ ],
2318
+ outputs: [],
2319
+ stateMutability: "nonpayable"
2320
+ },
2321
+ {
2322
+ type: "function",
2323
+ name: "takeOrder",
2324
+ inputs: [
2325
+ { name: "orderId", type: "bytes32", internalType: "bytes32" }
2326
+ ],
2327
+ outputs: [],
2328
+ stateMutability: "nonpayable"
2329
+ },
2330
+ {
2331
+ type: "function",
2332
+ name: "confirmPayment",
2333
+ inputs: [
2334
+ { name: "orderId", type: "bytes32", internalType: "bytes32" }
2335
+ ],
2336
+ outputs: [],
2337
+ stateMutability: "nonpayable"
2338
+ },
2339
+ {
2340
+ type: "function",
2341
+ name: "cancelOrder",
2342
+ inputs: [
2343
+ { name: "orderId", type: "bytes32", internalType: "bytes32" }
2344
+ ],
2345
+ outputs: [],
2346
+ stateMutability: "nonpayable"
2347
+ },
2348
+ {
2349
+ type: "function",
2350
+ name: "disputeOrder",
2351
+ inputs: [
2352
+ { name: "orderId", type: "bytes32", internalType: "bytes32" }
2353
+ ],
2354
+ outputs: [],
2355
+ stateMutability: "nonpayable"
2356
+ },
2357
+ {
2358
+ type: "function",
2359
+ name: "resolveDispute",
2360
+ inputs: [
2361
+ { name: "orderId", type: "bytes32", internalType: "bytes32" },
2362
+ { name: "winner", type: "address", internalType: "address" }
2363
+ ],
2364
+ outputs: [],
2365
+ stateMutability: "nonpayable"
2366
+ },
2367
+ // ─── Functions: View ──────────────────────────────────────────────────────
2368
+ {
2369
+ type: "function",
2370
+ name: "getOrder",
2371
+ inputs: [
2372
+ { name: "orderId", type: "bytes32", internalType: "bytes32" }
2373
+ ],
2374
+ outputs: [
2375
+ {
2376
+ name: "",
2377
+ type: "tuple",
2378
+ internalType: "struct IP2PExchange.P2POrder",
2379
+ components: [
2380
+ { name: "id", type: "bytes32", internalType: "bytes32" },
2381
+ { name: "maker", type: "address", internalType: "address" },
2382
+ { name: "taker", type: "address", internalType: "address" },
2383
+ { name: "token", type: "address", internalType: "address" },
2384
+ { name: "amount", type: "uint256", internalType: "uint256" },
2385
+ { name: "paymentReference", type: "string", internalType: "string" },
2386
+ { name: "exchangePlatform", type: "string", internalType: "string" },
2387
+ { name: "status", type: "uint8", internalType: "enum IP2PExchange.OrderStatus" },
2388
+ { name: "createdAt", type: "uint256", internalType: "uint256" },
2389
+ { name: "lockedAt", type: "uint256", internalType: "uint256" },
2390
+ { name: "completedAt", type: "uint256", internalType: "uint256" },
2391
+ { name: "expiryDuration", type: "uint256", internalType: "uint256" }
2392
+ ]
2393
+ }
2394
+ ],
2395
+ stateMutability: "view"
2396
+ },
2397
+ {
2398
+ type: "function",
2399
+ name: "getUserOrders",
2400
+ inputs: [
2401
+ { name: "user", type: "address", internalType: "address" }
2402
+ ],
2403
+ outputs: [
2404
+ { name: "", type: "bytes32[]", internalType: "bytes32[]" }
2405
+ ],
2406
+ stateMutability: "view"
2407
+ },
2408
+ {
2409
+ type: "function",
2410
+ name: "getOpenOrders",
2411
+ inputs: [
2412
+ { name: "limit", type: "uint256", internalType: "uint256" }
2413
+ ],
2414
+ outputs: [
2415
+ { name: "", type: "bytes32[]", internalType: "bytes32[]" }
2416
+ ],
2417
+ stateMutability: "view"
2418
+ },
2419
+ // ─── Functions: Admin ─────────────────────────────────────────────────────
2420
+ {
2421
+ type: "function",
2422
+ name: "setDisputeResolver",
2423
+ inputs: [
2424
+ { name: "resolver", type: "address", internalType: "address" }
2425
+ ],
2426
+ outputs: [],
2427
+ stateMutability: "nonpayable"
2428
+ },
2429
+ {
2430
+ type: "function",
2431
+ name: "pause",
2432
+ inputs: [],
2433
+ outputs: [],
2434
+ stateMutability: "nonpayable"
2435
+ },
2436
+ {
2437
+ type: "function",
2438
+ name: "unpause",
2439
+ inputs: [],
2440
+ outputs: [],
2441
+ stateMutability: "nonpayable"
2442
+ },
2443
+ {
2444
+ type: "function",
2445
+ name: "transferOwnership",
2446
+ inputs: [{ name: "newOwner", type: "address", internalType: "address" }],
2447
+ outputs: [],
2448
+ stateMutability: "nonpayable"
2449
+ },
2450
+ {
2451
+ type: "function",
2452
+ name: "renounceOwnership",
2453
+ inputs: [],
2454
+ outputs: [],
2455
+ stateMutability: "nonpayable"
2456
+ },
2457
+ // ─── Functions: State vars ────────────────────────────────────────────────
2458
+ {
2459
+ type: "function",
2460
+ name: "disputeResolver",
2461
+ inputs: [],
2462
+ outputs: [{ name: "", type: "address", internalType: "address" }],
2463
+ stateMutability: "view"
2464
+ },
2465
+ {
2466
+ type: "function",
2467
+ name: "owner",
2468
+ inputs: [],
2469
+ outputs: [{ name: "", type: "address", internalType: "address" }],
2470
+ stateMutability: "view"
2471
+ },
2472
+ {
2473
+ type: "function",
2474
+ name: "paused",
2475
+ inputs: [],
2476
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
2477
+ stateMutability: "view"
2478
+ }
2479
+ ];
2480
+
2481
+ // src/resources/identity.ts
2482
+ function wrapError(err, contractAddress) {
2483
+ if (err instanceof FiatsendError) return err;
2484
+ const message = err instanceof Error ? err.message : String(err);
2485
+ if (message.includes("AlreadyRegistered")) {
2486
+ return new FiatsendError("Address already has a registered MobileNumber NFT", FiatsendErrorCode.UNAUTHORIZED, { contractAddress, ...err instanceof Error && { cause: err } });
2487
+ }
2488
+ if (message.includes("PhoneAlreadyRegistered")) {
2489
+ return new FiatsendError("Phone number is already registered to another address", FiatsendErrorCode.UNAUTHORIZED, { contractAddress, ...err instanceof Error && { cause: err } });
2490
+ }
2491
+ if (message.includes("NotAuthorized")) {
2492
+ return new FiatsendError("Caller is not an authorized minter", FiatsendErrorCode.UNAUTHORIZED, { contractAddress, ...err instanceof Error && { cause: err } });
2493
+ }
2494
+ if (message.includes("SignatureExpired")) {
2495
+ return new FiatsendError("Gasless registration signature has expired", FiatsendErrorCode.UNAUTHORIZED, { contractAddress, ...err instanceof Error && { cause: err } });
2496
+ }
2497
+ if (message.includes("InvalidSignature")) {
2498
+ return new FiatsendError("Invalid EIP-712 signature for gasless registration", FiatsendErrorCode.UNAUTHORIZED, { contractAddress, ...err instanceof Error && { cause: err } });
2499
+ }
2500
+ return new FiatsendError(message, FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress, ...err instanceof Error && { cause: err } });
2501
+ }
2502
+ var IdentityResource = class {
2503
+ publicClient;
2504
+ walletClient;
2505
+ contractAddress;
2506
+ constructor(params) {
2507
+ this.publicClient = params.publicClient;
2508
+ this.walletClient = params.walletClient;
2509
+ this.contractAddress = params.contractAddress;
2510
+ }
2511
+ get readContract() {
2512
+ return getContract({
2513
+ address: this.contractAddress,
2514
+ abi: MobileNumberNFTABI,
2515
+ client: this.publicClient
2516
+ });
2517
+ }
2518
+ requireWallet() {
2519
+ if (!this.walletClient) {
2520
+ throw new FiatsendError(
2521
+ "A walletClient is required for write operations. Pass one to FiatsendClient.",
2522
+ FiatsendErrorCode.UNAUTHORIZED
2523
+ );
2524
+ }
2525
+ return this.walletClient;
2526
+ }
2527
+ /**
2528
+ * Mints a soulbound MobileNumber NFT for the connected wallet.
2529
+ *
2530
+ * @param params - Encrypted phone bytes and ISO country code
2531
+ * @returns Transaction result with hash and wait() function
2532
+ */
2533
+ async register(params) {
2534
+ try {
2535
+ const wallet = this.requireWallet();
2536
+ const hash = await wallet.writeContract({
2537
+ address: this.contractAddress,
2538
+ abi: MobileNumberNFTABI,
2539
+ functionName: "registerMobile",
2540
+ args: [params.encryptedPhone, params.countryCode],
2541
+ account: wallet.account,
2542
+ chain: wallet.chain ?? null
2543
+ });
2544
+ return {
2545
+ hash,
2546
+ wait: async () => {
2547
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
2548
+ return {
2549
+ hash: receipt.transactionHash,
2550
+ status: receipt.status,
2551
+ blockNumber: receipt.blockNumber,
2552
+ gasUsed: receipt.gasUsed
2553
+ };
2554
+ }
2555
+ };
2556
+ } catch (err) {
2557
+ throw wrapError(err, this.contractAddress);
2558
+ }
2559
+ }
2560
+ /**
2561
+ * Gasless NFT mint: the authorized minter submits the transaction on behalf
2562
+ * of the user. The user must have previously signed the EIP-712 typed data.
2563
+ *
2564
+ * @param params - User address, encrypted phone, country code, deadline, and signature
2565
+ * @returns Transaction result with hash and wait() function
2566
+ */
2567
+ async registerWithSignature(params) {
2568
+ try {
2569
+ const wallet = this.requireWallet();
2570
+ const hash = await wallet.writeContract({
2571
+ address: this.contractAddress,
2572
+ abi: MobileNumberNFTABI,
2573
+ functionName: "registerMobileWithSignature",
2574
+ args: [
2575
+ params.user,
2576
+ params.encryptedPhone,
2577
+ params.countryCode,
2578
+ params.deadline,
2579
+ params.signature
2580
+ ],
2581
+ account: wallet.account,
2582
+ chain: wallet.chain ?? null
2583
+ });
2584
+ return {
2585
+ hash,
2586
+ wait: async () => {
2587
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
2588
+ return {
2589
+ hash: receipt.transactionHash,
2590
+ status: receipt.status,
2591
+ blockNumber: receipt.blockNumber,
2592
+ gasUsed: receipt.gasUsed
2593
+ };
2594
+ }
2595
+ };
2596
+ } catch (err) {
2597
+ throw wrapError(err, this.contractAddress);
2598
+ }
2599
+ }
2600
+ /**
2601
+ * Returns the MobileNumber NFT data for an address, or null if not registered.
2602
+ *
2603
+ * @param address - Wallet address to query
2604
+ */
2605
+ async getNFT(address) {
2606
+ try {
2607
+ const contract = this.readContract;
2608
+ const tokenId = await contract.read.getTokenId([address]);
2609
+ if (tokenId === 0n) return null;
2610
+ const [countryCode, kycLevel, encryptedPhone] = await Promise.all([
2611
+ contract.read.getCountryCode([tokenId]),
2612
+ contract.read.getKYCLevel([tokenId]),
2613
+ contract.read.getEncryptedPhone([tokenId])
2614
+ ]);
2615
+ return {
2616
+ tokenId,
2617
+ owner: address,
2618
+ encryptedPhone,
2619
+ countryCode,
2620
+ kycLevel: Math.min(kycLevel, 2)
2621
+ };
2622
+ } catch (err) {
2623
+ throw wrapError(err, this.contractAddress);
2624
+ }
2625
+ }
2626
+ /**
2627
+ * Returns the KYC level for an address (0 if no NFT).
2628
+ *
2629
+ * @param address - Wallet address to query
2630
+ */
2631
+ async getKYCLevel(address) {
2632
+ try {
2633
+ const level = await this.readContract.read.getKYCLevelByAddress([address]);
2634
+ return Math.min(level, 2);
2635
+ } catch (err) {
2636
+ throw wrapError(err, this.contractAddress);
2637
+ }
2638
+ }
2639
+ /**
2640
+ * Resolves an encrypted phone hash to the owner address.
2641
+ *
2642
+ * @param encryptedPhone - Encrypted phone bytes (0x-prefixed)
2643
+ * @returns Owner address or null if not registered
2644
+ */
2645
+ async getOwnerByPhone(encryptedPhone) {
2646
+ try {
2647
+ const contract = this.readContract;
2648
+ const tokenId = await contract.read.getTokenIdByPhone([encryptedPhone]);
2649
+ if (tokenId === 0n) return null;
2650
+ const owner = await this.publicClient.readContract({
2651
+ address: this.contractAddress,
2652
+ abi: MobileNumberNFTABI,
2653
+ functionName: "ownerOf",
2654
+ args: [tokenId]
2655
+ });
2656
+ return owner;
2657
+ } catch (err) {
2658
+ throw wrapError(err, this.contractAddress);
2659
+ }
2660
+ }
2661
+ /**
2662
+ * Returns the token ID for an address (null if not registered).
2663
+ *
2664
+ * @param address - Wallet address
2665
+ */
2666
+ async getTokenId(address) {
2667
+ try {
2668
+ const tokenId = await this.readContract.read.getTokenId([address]);
2669
+ return tokenId === 0n ? null : tokenId;
2670
+ } catch (err) {
2671
+ throw wrapError(err, this.contractAddress);
2672
+ }
2673
+ }
2674
+ /**
2675
+ * Returns the user's nonce for EIP-712 replay protection.
2676
+ *
2677
+ * @param address - Wallet address
2678
+ */
2679
+ async getNonce(address) {
2680
+ try {
2681
+ return await this.readContract.read.nonces([address]);
2682
+ } catch (err) {
2683
+ throw wrapError(err, this.contractAddress);
2684
+ }
2685
+ }
2686
+ };
2687
+ function wrapError2(err, contractAddress) {
2688
+ if (err instanceof FiatsendError) return err;
2689
+ const message = err instanceof Error ? err.message : String(err);
2690
+ if (message.includes("TokenNotSupported")) {
2691
+ return new FiatsendError("Token is not supported by the gateway", FiatsendErrorCode.TOKEN_NOT_SUPPORTED, { contractAddress });
2692
+ }
2693
+ if (message.includes("NoMobileNFT")) {
2694
+ return new FiatsendError("User does not have a MobileNumber NFT \u2014 please register first", FiatsendErrorCode.NO_NFT, { contractAddress });
2695
+ }
2696
+ if (message.includes("KYCRequired")) {
2697
+ return new FiatsendError("KYC verification is required for amounts above the threshold", FiatsendErrorCode.KYC_REQUIRED, { contractAddress });
2698
+ }
2699
+ if (message.includes("BelowMinimum")) {
2700
+ return new FiatsendError("Amount is below the minimum withdrawal amount", FiatsendErrorCode.BELOW_MINIMUM, { contractAddress });
2701
+ }
2702
+ if (message.includes("DailyLimitExceeded")) {
2703
+ return new FiatsendError("Daily withdrawal limit exceeded", FiatsendErrorCode.DAILY_LIMIT_EXCEEDED, { contractAddress });
2704
+ }
2705
+ if (message.includes("Paused") || message.includes("EnforcedPause")) {
2706
+ return new FiatsendError("Gateway is currently paused", FiatsendErrorCode.CONTRACT_PAUSED, { contractAddress });
2707
+ }
2708
+ return new FiatsendError(message, FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress, ...err instanceof Error && { cause: err } });
2709
+ }
2710
+ var GatewayResource = class {
2711
+ publicClient;
2712
+ walletClient;
2713
+ contractAddress;
2714
+ constructor(params) {
2715
+ this.publicClient = params.publicClient;
2716
+ this.walletClient = params.walletClient;
2717
+ this.contractAddress = params.contractAddress;
2718
+ }
2719
+ get readContract() {
2720
+ return getContract({
2721
+ address: this.contractAddress,
2722
+ abi: FiatsendGatewayABI,
2723
+ client: this.publicClient
2724
+ });
2725
+ }
2726
+ requireWallet() {
2727
+ if (!this.walletClient) {
2728
+ throw new FiatsendError(
2729
+ "A walletClient is required for write operations.",
2730
+ FiatsendErrorCode.UNAUTHORIZED
2731
+ );
2732
+ }
2733
+ return this.walletClient;
2734
+ }
2735
+ /**
2736
+ * Initiates an offramp: converts a supported stablecoin to a mobile money payout.
2737
+ *
2738
+ * The user must:
2739
+ * 1. Have a MobileNumber NFT
2740
+ * 2. Pass KYC (if amount >= threshold)
2741
+ * 3. Have approved the gateway to spend `params.amount` of `params.token`
2742
+ *
2743
+ * @param params - Token, amount, and destination phone number
2744
+ * @returns Offramp result including the withdrawal ID and fees
2745
+ */
2746
+ async offramp(params) {
2747
+ validateOfframpParams(params);
2748
+ try {
2749
+ const [feeRate, minWithdraw] = await Promise.all([
2750
+ this.readContract.read.protocolFeeRate(),
2751
+ this.readContract.read.minWithdrawAmount()
2752
+ ]);
2753
+ if (params.amount < minWithdraw) {
2754
+ throw new FiatsendError(
2755
+ `Amount ${params.amount} is below the minimum withdrawal amount of ${minWithdraw}`,
2756
+ FiatsendErrorCode.BELOW_MINIMUM,
2757
+ { contractAddress: this.contractAddress }
2758
+ );
2759
+ }
2760
+ const fee = params.amount * feeRate / 10000n;
2761
+ const netAmount = params.amount - fee;
2762
+ const wallet = this.requireWallet();
2763
+ const hash = await wallet.writeContract({
2764
+ address: this.contractAddress,
2765
+ abi: FiatsendGatewayABI,
2766
+ functionName: "offramp",
2767
+ args: [params.token, params.amount, params.phoneNumber],
2768
+ account: wallet.account,
2769
+ chain: wallet.chain ?? null
2770
+ });
2771
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
2772
+ let withdrawalId = 0n;
2773
+ for (const log of receipt.logs) {
2774
+ if (log.topics.length >= 2) {
2775
+ const possibleId = BigInt(log.topics[1] ?? "0x0");
2776
+ if (possibleId > 0n) {
2777
+ withdrawalId = possibleId;
2778
+ break;
2779
+ }
2780
+ }
2781
+ }
2782
+ return {
2783
+ withdrawalId,
2784
+ amount: params.amount,
2785
+ fee,
2786
+ netAmount,
2787
+ hash
2788
+ };
2789
+ } catch (err) {
2790
+ if (err instanceof FiatsendError) throw err;
2791
+ throw wrapError2(err, this.contractAddress);
2792
+ }
2793
+ }
2794
+ /**
2795
+ * Returns the conversion rate for a supported token.
2796
+ *
2797
+ * @param token - Token address
2798
+ * @returns Scaled conversion rate as stored in the contract
2799
+ */
2800
+ async getConversionRate(token) {
2801
+ try {
2802
+ return await this.readContract.read.getConversionRate([token]);
2803
+ } catch (err) {
2804
+ throw wrapError2(err, this.contractAddress);
2805
+ }
2806
+ }
2807
+ /**
2808
+ * Checks whether a token is supported by the gateway.
2809
+ *
2810
+ * @param token - Token address
2811
+ */
2812
+ async isTokenSupported(token) {
2813
+ try {
2814
+ return await this.readContract.read.isTokenSupported([token]);
2815
+ } catch (err) {
2816
+ throw wrapError2(err, this.contractAddress);
2817
+ }
2818
+ }
2819
+ /**
2820
+ * Checks whether a user has passed KYC verification.
2821
+ *
2822
+ * @param user - User address
2823
+ */
2824
+ async isKYCPassed(user) {
2825
+ try {
2826
+ return await this.readContract.read.isKYCPassed([user]);
2827
+ } catch (err) {
2828
+ throw wrapError2(err, this.contractAddress);
2829
+ }
2830
+ }
2831
+ /**
2832
+ * Returns the gateway's full configuration snapshot.
2833
+ */
2834
+ async getConfig() {
2835
+ try {
2836
+ const contract = this.readContract;
2837
+ const [protocolFeeRate, minWithdrawAmount, dailyLimit, treasury] = await Promise.all([
2838
+ contract.read.protocolFeeRate(),
2839
+ contract.read.minWithdrawAmount(),
2840
+ contract.read.dailyLimit(),
2841
+ contract.read.protocolTreasury()
2842
+ ]);
2843
+ return {
2844
+ protocolFeeRate,
2845
+ minWithdrawAmount,
2846
+ dailyLimit,
2847
+ treasury
2848
+ };
2849
+ } catch (err) {
2850
+ throw wrapError2(err, this.contractAddress);
2851
+ }
2852
+ }
2853
+ /**
2854
+ * Returns the daily volume used by a user today.
2855
+ *
2856
+ * @param user - User address
2857
+ */
2858
+ async getDailyVolume(user) {
2859
+ try {
2860
+ return await this.readContract.read.getDailyVolume([user]);
2861
+ } catch (err) {
2862
+ throw wrapError2(err, this.contractAddress);
2863
+ }
2864
+ }
2865
+ /**
2866
+ * Returns the remaining daily allowance for a user.
2867
+ *
2868
+ * @param user - User address
2869
+ */
2870
+ async getDailyRemaining(user) {
2871
+ try {
2872
+ const contract = this.readContract;
2873
+ const [limit, used] = await Promise.all([
2874
+ contract.read.dailyLimit(),
2875
+ contract.read.getDailyVolume([user])
2876
+ ]);
2877
+ return limit > used ? limit - used : 0n;
2878
+ } catch (err) {
2879
+ throw wrapError2(err, this.contractAddress);
2880
+ }
2881
+ }
2882
+ /**
2883
+ * Mints GHSFIAT for a user. Requires the caller to be an authorized onramper.
2884
+ *
2885
+ * @param user - Recipient address
2886
+ * @param amount - Amount to mint
2887
+ * @returns Transaction result
2888
+ */
2889
+ async onramp(user, amount) {
2890
+ try {
2891
+ const wallet = this.requireWallet();
2892
+ const hash = await wallet.writeContract({
2893
+ address: this.contractAddress,
2894
+ abi: FiatsendGatewayABI,
2895
+ functionName: "onramp",
2896
+ args: [user, amount],
2897
+ account: wallet.account,
2898
+ chain: wallet.chain ?? null
2899
+ });
2900
+ return {
2901
+ hash,
2902
+ wait: async () => {
2903
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
2904
+ return {
2905
+ hash: receipt.transactionHash,
2906
+ status: receipt.status,
2907
+ blockNumber: receipt.blockNumber,
2908
+ gasUsed: receipt.gasUsed
2909
+ };
2910
+ }
2911
+ };
2912
+ } catch (err) {
2913
+ throw wrapError2(err, this.contractAddress);
2914
+ }
2915
+ }
2916
+ };
2917
+ function mapStatus(status) {
2918
+ if (status === 0) return "pending";
2919
+ if (status === 1) return "paid";
2920
+ return "cancelled";
2921
+ }
2922
+ function wrapError3(err, contractAddress) {
2923
+ if (err instanceof FiatsendError) return err;
2924
+ const message = err instanceof Error ? err.message : String(err);
2925
+ if (message.includes("PhoneNotRegistered")) {
2926
+ return new FiatsendError("Phone number is not registered to any address", FiatsendErrorCode.NO_NFT, { contractAddress });
2927
+ }
2928
+ if (message.includes("SelfPayment")) {
2929
+ return new FiatsendError("Cannot send payment to yourself", FiatsendErrorCode.UNAUTHORIZED, { contractAddress });
2930
+ }
2931
+ if (message.includes("RequestNotFound")) {
2932
+ return new FiatsendError("Payment request not found", FiatsendErrorCode.UNAUTHORIZED, { contractAddress });
2933
+ }
2934
+ if (message.includes("RequestNotPending")) {
2935
+ return new FiatsendError("Payment request is no longer pending", FiatsendErrorCode.UNAUTHORIZED, { contractAddress });
2936
+ }
2937
+ if (message.includes("NotRequestOwner")) {
2938
+ return new FiatsendError("Only the request creator can cancel it", FiatsendErrorCode.UNAUTHORIZED, { contractAddress });
2939
+ }
2940
+ if (message.includes("NotRequestRecipient")) {
2941
+ return new FiatsendError("Only the intended payer can pay this request", FiatsendErrorCode.UNAUTHORIZED, { contractAddress });
2942
+ }
2943
+ return new FiatsendError(message, FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress, ...err instanceof Error && { cause: err } });
2944
+ }
2945
+ var PaymentsResource = class {
2946
+ publicClient;
2947
+ walletClient;
2948
+ contractAddress;
2949
+ constructor(params) {
2950
+ this.publicClient = params.publicClient;
2951
+ this.walletClient = params.walletClient;
2952
+ this.contractAddress = params.contractAddress;
2953
+ }
2954
+ get readContract() {
2955
+ return getContract({
2956
+ address: this.contractAddress,
2957
+ abi: PaymentRouterABI,
2958
+ client: this.publicClient
2959
+ });
2960
+ }
2961
+ requireWallet() {
2962
+ if (!this.walletClient) {
2963
+ throw new FiatsendError(
2964
+ "A walletClient is required for write operations.",
2965
+ FiatsendErrorCode.UNAUTHORIZED
2966
+ );
2967
+ }
2968
+ return this.walletClient;
2969
+ }
2970
+ /**
2971
+ * Sends tokens directly to an address.
2972
+ *
2973
+ * The caller must have approved `params.amount` of `params.token` to the PaymentRouter.
2974
+ *
2975
+ * @param params - Token, recipient address, amount, and optional memo
2976
+ * @returns Transaction result
2977
+ */
2978
+ async send(params) {
2979
+ try {
2980
+ const wallet = this.requireWallet();
2981
+ const hash = await wallet.writeContract({
2982
+ address: this.contractAddress,
2983
+ abi: PaymentRouterABI,
2984
+ functionName: "send",
2985
+ args: [params.token, params.to, params.amount, params.memo ?? ""],
2986
+ account: wallet.account,
2987
+ chain: wallet.chain ?? null
2988
+ });
2989
+ return {
2990
+ hash,
2991
+ wait: async () => {
2992
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
2993
+ return { hash: receipt.transactionHash, status: receipt.status, blockNumber: receipt.blockNumber, gasUsed: receipt.gasUsed };
2994
+ }
2995
+ };
2996
+ } catch (err) {
2997
+ throw wrapError3(err, this.contractAddress);
2998
+ }
2999
+ }
3000
+ /**
3001
+ * Resolves an encrypted phone hash to an address via MobileNumberNFT and sends tokens.
3002
+ *
3003
+ * @param params - Token, encrypted phone, amount, and optional memo
3004
+ * @returns Transaction result
3005
+ */
3006
+ async sendToPhone(params) {
3007
+ try {
3008
+ const wallet = this.requireWallet();
3009
+ const hash = await wallet.writeContract({
3010
+ address: this.contractAddress,
3011
+ abi: PaymentRouterABI,
3012
+ functionName: "sendToPhone",
3013
+ args: [params.token, params.encryptedPhone, params.amount, params.memo ?? ""],
3014
+ account: wallet.account,
3015
+ chain: wallet.chain ?? null
3016
+ });
3017
+ return {
3018
+ hash,
3019
+ wait: async () => {
3020
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
3021
+ return { hash: receipt.transactionHash, status: receipt.status, blockNumber: receipt.blockNumber, gasUsed: receipt.gasUsed };
3022
+ }
3023
+ };
3024
+ } catch (err) {
3025
+ throw wrapError3(err, this.contractAddress);
3026
+ }
3027
+ }
3028
+ /**
3029
+ * Creates a payment request — asks another address to pay you.
3030
+ *
3031
+ * @param params - Token, payer address, amount, and optional memo
3032
+ * @returns The created request ID and transaction hash
3033
+ */
3034
+ async createRequest(params) {
3035
+ try {
3036
+ const wallet = this.requireWallet();
3037
+ const hash = await wallet.writeContract({
3038
+ address: this.contractAddress,
3039
+ abi: PaymentRouterABI,
3040
+ functionName: "createPaymentRequest",
3041
+ args: [params.token, params.from, params.amount, params.memo ?? ""],
3042
+ account: wallet.account,
3043
+ chain: wallet.chain ?? null
3044
+ });
3045
+ return { requestId: 0n, hash };
3046
+ } catch (err) {
3047
+ throw wrapError3(err, this.contractAddress);
3048
+ }
3049
+ }
3050
+ /**
3051
+ * Pays a pending payment request.
3052
+ *
3053
+ * Only the `to` address on the request can call this.
3054
+ * The caller must approve `request.amount` of `request.token` to the PaymentRouter.
3055
+ *
3056
+ * @param requestId - The payment request ID to pay
3057
+ * @returns Transaction result
3058
+ */
3059
+ async payRequest(requestId) {
3060
+ try {
3061
+ const wallet = this.requireWallet();
3062
+ const hash = await wallet.writeContract({
3063
+ address: this.contractAddress,
3064
+ abi: PaymentRouterABI,
3065
+ functionName: "payRequest",
3066
+ args: [requestId],
3067
+ account: wallet.account,
3068
+ chain: wallet.chain ?? null
3069
+ });
3070
+ return {
3071
+ hash,
3072
+ wait: async () => {
3073
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
3074
+ return { hash: receipt.transactionHash, status: receipt.status, blockNumber: receipt.blockNumber, gasUsed: receipt.gasUsed };
3075
+ }
3076
+ };
3077
+ } catch (err) {
3078
+ throw wrapError3(err, this.contractAddress);
3079
+ }
3080
+ }
3081
+ /**
3082
+ * Cancels a pending payment request.
3083
+ *
3084
+ * Only the request creator (`from` address) can cancel.
3085
+ *
3086
+ * @param requestId - The payment request ID to cancel
3087
+ * @returns Transaction result
3088
+ */
3089
+ async cancelRequest(requestId) {
3090
+ try {
3091
+ const wallet = this.requireWallet();
3092
+ const hash = await wallet.writeContract({
3093
+ address: this.contractAddress,
3094
+ abi: PaymentRouterABI,
3095
+ functionName: "cancelRequest",
3096
+ args: [requestId],
3097
+ account: wallet.account,
3098
+ chain: wallet.chain ?? null
3099
+ });
3100
+ return {
3101
+ hash,
3102
+ wait: async () => {
3103
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
3104
+ return { hash: receipt.transactionHash, status: receipt.status, blockNumber: receipt.blockNumber, gasUsed: receipt.gasUsed };
3105
+ }
3106
+ };
3107
+ } catch (err) {
3108
+ throw wrapError3(err, this.contractAddress);
3109
+ }
3110
+ }
3111
+ /**
3112
+ * Fetches a payment request by ID.
3113
+ *
3114
+ * @param requestId - Payment request ID
3115
+ * @returns PaymentRequest data
3116
+ */
3117
+ async getRequest(requestId) {
3118
+ try {
3119
+ const req = await this.readContract.read.getPaymentRequest([requestId]);
3120
+ return {
3121
+ id: req.id,
3122
+ from: req.from,
3123
+ to: req.to,
3124
+ token: req.token,
3125
+ amount: req.amount,
3126
+ memo: req.memo,
3127
+ status: mapStatus(req.status),
3128
+ createdAt: req.createdAt
3129
+ };
3130
+ } catch (err) {
3131
+ throw wrapError3(err, this.contractAddress);
3132
+ }
3133
+ }
3134
+ /**
3135
+ * Returns the total number of payment requests created.
3136
+ */
3137
+ async getRequestCount() {
3138
+ try {
3139
+ return await this.readContract.read.paymentRequestCounter();
3140
+ } catch (err) {
3141
+ throw wrapError3(err, this.contractAddress);
3142
+ }
3143
+ }
3144
+ };
3145
+ function mapStatus2(status) {
3146
+ switch (status) {
3147
+ case 1:
3148
+ return "pending";
3149
+ case 2:
3150
+ return "processing";
3151
+ case 3:
3152
+ return "completed";
3153
+ case 4:
3154
+ return "failed";
3155
+ default:
3156
+ return "pending";
3157
+ }
3158
+ }
3159
+ function wrapError4(err, contractAddress) {
3160
+ if (err instanceof FiatsendError) return err;
3161
+ const message = err instanceof Error ? err.message : String(err);
3162
+ if (message.includes("WithdrawalNotFound")) {
3163
+ return new FiatsendError("Withdrawal record not found", FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress });
3164
+ }
3165
+ return new FiatsendError(message, FiatsendErrorCode.NETWORK_ERROR, { contractAddress, ...err instanceof Error && { cause: err } });
3166
+ }
3167
+ var WithdrawalsResource = class {
3168
+ publicClient;
3169
+ contractAddress;
3170
+ constructor(params) {
3171
+ this.publicClient = params.publicClient;
3172
+ this.contractAddress = params.contractAddress;
3173
+ }
3174
+ get contract() {
3175
+ return getContract({
3176
+ address: this.contractAddress,
3177
+ abi: WithdrawalsABI,
3178
+ client: this.publicClient
3179
+ });
3180
+ }
3181
+ /**
3182
+ * Returns a withdrawal record by ID.
3183
+ *
3184
+ * @param id - Withdrawal ID
3185
+ */
3186
+ async getWithdrawal(id) {
3187
+ try {
3188
+ const w = await this.contract.read.getWithdrawal([id]);
3189
+ return {
3190
+ id: w.id,
3191
+ user: w.user,
3192
+ token: w.token,
3193
+ amount: w.amount,
3194
+ fee: w.fee,
3195
+ status: mapStatus2(w.status),
3196
+ paymentMethod: w.paymentMethod,
3197
+ phoneNumber: w.phoneNumber,
3198
+ createdAt: w.createdAt,
3199
+ completedAt: w.completedAt
3200
+ };
3201
+ } catch (err) {
3202
+ throw wrapError4(err, this.contractAddress);
3203
+ }
3204
+ }
3205
+ /**
3206
+ * Returns all withdrawal records for a user, resolved from their IDs.
3207
+ *
3208
+ * @param user - User address
3209
+ */
3210
+ async getUserWithdrawals(user) {
3211
+ try {
3212
+ const ids = await this.contract.read.getUserWithdrawals([user]);
3213
+ const withdrawals = await Promise.all(ids.map((id) => this.getWithdrawal(id)));
3214
+ return withdrawals;
3215
+ } catch (err) {
3216
+ throw wrapError4(err, this.contractAddress);
3217
+ }
3218
+ }
3219
+ /**
3220
+ * Returns the total number of withdrawals ever created.
3221
+ */
3222
+ async getWithdrawalCount() {
3223
+ try {
3224
+ return await this.contract.read.withdrawalCounter();
3225
+ } catch (err) {
3226
+ throw wrapError4(err, this.contractAddress);
3227
+ }
3228
+ }
3229
+ };
3230
+ function wrapError5(err, contractAddress) {
3231
+ if (err instanceof FiatsendError) return err;
3232
+ const message = err instanceof Error ? err.message : String(err);
3233
+ if (message.includes("BelowMinDeposit")) {
3234
+ return new FiatsendError("Amount is below the minimum deposit for this pool", FiatsendErrorCode.BELOW_MINIMUM, { contractAddress });
3235
+ }
3236
+ if (message.includes("LockPeriodActive")) {
3237
+ return new FiatsendError("Cannot withdraw \u2014 lock period is still active", FiatsendErrorCode.LOCK_PERIOD_ACTIVE, { contractAddress });
3238
+ }
3239
+ if (message.includes("InsufficientBalance")) {
3240
+ return new FiatsendError("Insufficient deposited balance", FiatsendErrorCode.INSUFFICIENT_BALANCE, { contractAddress });
3241
+ }
3242
+ if (message.includes("ZeroAmount")) {
3243
+ return new FiatsendError("Amount must be greater than zero", FiatsendErrorCode.BELOW_MINIMUM, { contractAddress });
3244
+ }
3245
+ return new FiatsendError(message, FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress, ...err instanceof Error && { cause: err } });
3246
+ }
3247
+ var LiquidityResource = class {
3248
+ publicClient;
3249
+ walletClient;
3250
+ contractAddress;
3251
+ constructor(params) {
3252
+ this.publicClient = params.publicClient;
3253
+ this.walletClient = params.walletClient;
3254
+ this.contractAddress = params.contractAddress;
3255
+ }
3256
+ get readContract() {
3257
+ return getContract({
3258
+ address: this.contractAddress,
3259
+ abi: LiquidityPoolABI,
3260
+ client: this.publicClient
3261
+ });
3262
+ }
3263
+ requireWallet() {
3264
+ if (!this.walletClient) {
3265
+ throw new FiatsendError("A walletClient is required for write operations.", FiatsendErrorCode.UNAUTHORIZED);
3266
+ }
3267
+ return this.walletClient;
3268
+ }
3269
+ /**
3270
+ * Deposits stablecoins into the liquidity pool.
3271
+ *
3272
+ * The caller must approve `amount` of the pool's supported token to this contract.
3273
+ *
3274
+ * @param amount - Amount to deposit (must be >= pool minDeposit)
3275
+ * @returns Transaction result
3276
+ */
3277
+ async deposit(amount) {
3278
+ try {
3279
+ const wallet = this.requireWallet();
3280
+ const hash = await wallet.writeContract({
3281
+ address: this.contractAddress,
3282
+ abi: LiquidityPoolABI,
3283
+ functionName: "deposit",
3284
+ args: [amount],
3285
+ account: wallet.account,
3286
+ chain: wallet.chain ?? null
3287
+ });
3288
+ return {
3289
+ hash,
3290
+ wait: async () => {
3291
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
3292
+ return { hash: receipt.transactionHash, status: receipt.status, blockNumber: receipt.blockNumber, gasUsed: receipt.gasUsed };
3293
+ }
3294
+ };
3295
+ } catch (err) {
3296
+ throw wrapError5(err, this.contractAddress);
3297
+ }
3298
+ }
3299
+ /**
3300
+ * Withdraws stablecoins from the pool (after the lock period has elapsed).
3301
+ *
3302
+ * @param amount - Amount to withdraw
3303
+ * @returns Transaction result
3304
+ */
3305
+ async withdraw(amount) {
3306
+ try {
3307
+ const wallet = this.requireWallet();
3308
+ const hash = await wallet.writeContract({
3309
+ address: this.contractAddress,
3310
+ abi: LiquidityPoolABI,
3311
+ functionName: "withdraw",
3312
+ args: [amount],
3313
+ account: wallet.account,
3314
+ chain: wallet.chain ?? null
3315
+ });
3316
+ return {
3317
+ hash,
3318
+ wait: async () => {
3319
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
3320
+ return { hash: receipt.transactionHash, status: receipt.status, blockNumber: receipt.blockNumber, gasUsed: receipt.gasUsed };
3321
+ }
3322
+ };
3323
+ } catch (err) {
3324
+ throw wrapError5(err, this.contractAddress);
3325
+ }
3326
+ }
3327
+ /**
3328
+ * Claims all pending fee rewards for the caller.
3329
+ *
3330
+ * @returns Transaction result
3331
+ */
3332
+ async claimRewards() {
3333
+ try {
3334
+ const wallet = this.requireWallet();
3335
+ const hash = await wallet.writeContract({
3336
+ address: this.contractAddress,
3337
+ abi: LiquidityPoolABI,
3338
+ functionName: "claimRewards",
3339
+ args: [],
3340
+ account: wallet.account,
3341
+ chain: wallet.chain ?? null
3342
+ });
3343
+ return {
3344
+ hash,
3345
+ wait: async () => {
3346
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
3347
+ return { hash: receipt.transactionHash, status: receipt.status, blockNumber: receipt.blockNumber, gasUsed: receipt.gasUsed };
3348
+ }
3349
+ };
3350
+ } catch (err) {
3351
+ throw wrapError5(err, this.contractAddress);
3352
+ }
3353
+ }
3354
+ /**
3355
+ * Returns pool-level statistics.
3356
+ */
3357
+ async getPoolInfo() {
3358
+ try {
3359
+ const info = await this.readContract.read.getPoolInfo();
3360
+ return {
3361
+ token: info.supportedToken,
3362
+ totalDeposits: info.totalDeposits,
3363
+ rewardPerToken: info.rewardPerToken,
3364
+ minDeposit: info.minDeposit,
3365
+ lockPeriod: info.lockPeriod
3366
+ };
3367
+ } catch (err) {
3368
+ throw wrapError5(err, this.contractAddress);
3369
+ }
3370
+ }
3371
+ /**
3372
+ * Returns a user's LP position including deposited balance and pending rewards.
3373
+ *
3374
+ * @param user - User address
3375
+ */
3376
+ async getPosition(user) {
3377
+ try {
3378
+ const contract = this.readContract;
3379
+ const [deposited, pendingRewards] = await Promise.all([
3380
+ contract.read.getDeposit([user]),
3381
+ contract.read.getRewards([user])
3382
+ ]);
3383
+ return {
3384
+ deposited,
3385
+ pendingRewards,
3386
+ depositTimestamp: 0n,
3387
+ canWithdraw: true
3388
+ };
3389
+ } catch (err) {
3390
+ throw wrapError5(err, this.contractAddress);
3391
+ }
3392
+ }
3393
+ /**
3394
+ * Returns pending rewards for a user.
3395
+ *
3396
+ * @param user - User address
3397
+ */
3398
+ async getPendingRewards(user) {
3399
+ try {
3400
+ return await this.readContract.read.getRewards([user]);
3401
+ } catch (err) {
3402
+ throw wrapError5(err, this.contractAddress);
3403
+ }
3404
+ }
3405
+ };
3406
+ function wrapError6(err, contractAddress) {
3407
+ if (err instanceof FiatsendError) return err;
3408
+ const message = err instanceof Error ? err.message : String(err);
3409
+ if (message.includes("BelowMinDeposit")) {
3410
+ return new FiatsendError("Amount is below the minimum vault deposit", FiatsendErrorCode.BELOW_MINIMUM, { contractAddress });
3411
+ }
3412
+ if (message.includes("InsufficientBalance")) {
3413
+ return new FiatsendError("Insufficient vault balance", FiatsendErrorCode.INSUFFICIENT_BALANCE, { contractAddress });
3414
+ }
3415
+ if (message.includes("NoYieldAvailable")) {
3416
+ return new FiatsendError("No yield available to claim yet", FiatsendErrorCode.BELOW_MINIMUM, { contractAddress });
3417
+ }
3418
+ return new FiatsendError(message, FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress, ...err instanceof Error && { cause: err } });
3419
+ }
3420
+ var VaultsResource = class {
3421
+ publicClient;
3422
+ walletClient;
3423
+ contractAddress;
3424
+ supportedTokenAddress;
3425
+ constructor(params) {
3426
+ this.publicClient = params.publicClient;
3427
+ this.walletClient = params.walletClient;
3428
+ this.contractAddress = params.contractAddress;
3429
+ this.supportedTokenAddress = params.supportedTokenAddress;
3430
+ }
3431
+ get readContract() {
3432
+ return getContract({
3433
+ address: this.contractAddress,
3434
+ abi: VaultControllerABI,
3435
+ client: this.publicClient
3436
+ });
3437
+ }
3438
+ requireWallet() {
3439
+ if (!this.walletClient) {
3440
+ throw new FiatsendError("A walletClient is required for write operations.", FiatsendErrorCode.UNAUTHORIZED);
3441
+ }
3442
+ return this.walletClient;
3443
+ }
3444
+ /**
3445
+ * Deposits stablecoins into the vault.
3446
+ *
3447
+ * The caller must approve `amount` of the vault's supported token to this contract.
3448
+ *
3449
+ * @param amount - Amount to deposit (must be >= vault minDeposit)
3450
+ * @returns Transaction result
3451
+ */
3452
+ async deposit(amount) {
3453
+ try {
3454
+ const wallet = this.requireWallet();
3455
+ const hash = await wallet.writeContract({
3456
+ address: this.contractAddress,
3457
+ abi: VaultControllerABI,
3458
+ functionName: "deposit",
3459
+ args: [amount],
3460
+ account: wallet.account,
3461
+ chain: wallet.chain ?? null
3462
+ });
3463
+ return {
3464
+ hash,
3465
+ wait: async () => {
3466
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
3467
+ return { hash: receipt.transactionHash, status: receipt.status, blockNumber: receipt.blockNumber, gasUsed: receipt.gasUsed };
3468
+ }
3469
+ };
3470
+ } catch (err) {
3471
+ throw wrapError6(err, this.contractAddress);
3472
+ }
3473
+ }
3474
+ /**
3475
+ * Withdraws stablecoins from the vault. Accrued yield is claimed automatically.
3476
+ *
3477
+ * @param amount - Amount to withdraw
3478
+ * @returns Transaction result
3479
+ */
3480
+ async withdraw(amount) {
3481
+ try {
3482
+ const wallet = this.requireWallet();
3483
+ const hash = await wallet.writeContract({
3484
+ address: this.contractAddress,
3485
+ abi: VaultControllerABI,
3486
+ functionName: "withdraw",
3487
+ args: [amount],
3488
+ account: wallet.account,
3489
+ chain: wallet.chain ?? null
3490
+ });
3491
+ return {
3492
+ hash,
3493
+ wait: async () => {
3494
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
3495
+ return { hash: receipt.transactionHash, status: receipt.status, blockNumber: receipt.blockNumber, gasUsed: receipt.gasUsed };
3496
+ }
3497
+ };
3498
+ } catch (err) {
3499
+ throw wrapError6(err, this.contractAddress);
3500
+ }
3501
+ }
3502
+ /**
3503
+ * Claims accrued yield without withdrawing principal.
3504
+ *
3505
+ * @returns Transaction result
3506
+ */
3507
+ async claimYield() {
3508
+ try {
3509
+ const wallet = this.requireWallet();
3510
+ const hash = await wallet.writeContract({
3511
+ address: this.contractAddress,
3512
+ abi: VaultControllerABI,
3513
+ functionName: "claimYield",
3514
+ args: [],
3515
+ account: wallet.account,
3516
+ chain: wallet.chain ?? null
3517
+ });
3518
+ return {
3519
+ hash,
3520
+ wait: async () => {
3521
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
3522
+ return { hash: receipt.transactionHash, status: receipt.status, blockNumber: receipt.blockNumber, gasUsed: receipt.gasUsed };
3523
+ }
3524
+ };
3525
+ } catch (err) {
3526
+ throw wrapError6(err, this.contractAddress);
3527
+ }
3528
+ }
3529
+ /**
3530
+ * Returns vault-level configuration.
3531
+ */
3532
+ async getVaultInfo() {
3533
+ try {
3534
+ const contract = this.readContract;
3535
+ const [annualYieldRate, minDeposit, totalDeposited] = await Promise.all([
3536
+ contract.read.annualYieldRate(),
3537
+ contract.read.minDeposit(),
3538
+ contract.read.totalDeposited()
3539
+ ]);
3540
+ return {
3541
+ token: this.supportedTokenAddress,
3542
+ totalDeposited,
3543
+ annualYieldRate,
3544
+ minDeposit
3545
+ };
3546
+ } catch (err) {
3547
+ throw wrapError6(err, this.contractAddress);
3548
+ }
3549
+ }
3550
+ /**
3551
+ * Returns a user's vault position.
3552
+ *
3553
+ * @param user - User address
3554
+ */
3555
+ async getPosition(user) {
3556
+ try {
3557
+ const contract = this.readContract;
3558
+ const [vaultData, pendingYield] = await Promise.all([
3559
+ contract.read.getVault([user]),
3560
+ contract.read.calculateYield([user])
3561
+ ]);
3562
+ return {
3563
+ balance: vaultData.balance,
3564
+ pendingYield,
3565
+ depositedAt: vaultData.depositedAt,
3566
+ lastYieldClaim: vaultData.lastYieldClaim
3567
+ };
3568
+ } catch (err) {
3569
+ throw wrapError6(err, this.contractAddress);
3570
+ }
3571
+ }
3572
+ /**
3573
+ * Returns the pending yield for a user.
3574
+ *
3575
+ * @param user - User address
3576
+ */
3577
+ async getPendingYield(user) {
3578
+ try {
3579
+ return await this.readContract.read.calculateYield([user]);
3580
+ } catch (err) {
3581
+ throw wrapError6(err, this.contractAddress);
3582
+ }
3583
+ }
3584
+ };
3585
+ function mapPayoutStatus(status) {
3586
+ switch (status) {
3587
+ case 0:
3588
+ return "pending";
3589
+ case 1:
3590
+ return "claimed";
3591
+ case 2:
3592
+ return "refunded";
3593
+ case 3:
3594
+ return "expired";
3595
+ default:
3596
+ return "pending";
3597
+ }
3598
+ }
3599
+ function mapPayout(raw) {
3600
+ return {
3601
+ id: raw.id,
3602
+ sender: raw.sender,
3603
+ recipient: raw.recipient,
3604
+ token: raw.token,
3605
+ amount: raw.amount,
3606
+ phoneHash: raw.phoneHash,
3607
+ status: mapPayoutStatus(raw.status),
3608
+ expiresAt: raw.expiresAt,
3609
+ createdAt: raw.createdAt,
3610
+ claimedAt: raw.claimedAt
3611
+ };
3612
+ }
3613
+ function wrapError7(err, contractAddress) {
3614
+ if (err instanceof FiatsendError) return err;
3615
+ const message = err instanceof Error ? err.message : String(err);
3616
+ if (message.includes("PayoutAlreadyExists")) {
3617
+ return new FiatsendError("A payout with this ID already exists", FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress });
3618
+ }
3619
+ if (message.includes("PayoutNotFound")) {
3620
+ return new FiatsendError("Payout not found", FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress });
3621
+ }
3622
+ if (message.includes("NotAuthorizedSender")) {
3623
+ return new FiatsendError("Caller is not an authorized sender", FiatsendErrorCode.UNAUTHORIZED, { contractAddress });
3624
+ }
3625
+ if (message.includes("NotPending")) {
3626
+ return new FiatsendError("Payout is not in pending status", FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress });
3627
+ }
3628
+ if (message.includes("NotExpiredYet")) {
3629
+ return new FiatsendError("Payout has not expired yet \u2014 cannot refund", FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress });
3630
+ }
3631
+ if (message.includes("NotRefundEligible")) {
3632
+ return new FiatsendError("Only the original sender or owner may refund this payout", FiatsendErrorCode.UNAUTHORIZED, { contractAddress });
3633
+ }
3634
+ if (message.includes("PhoneHashMismatch")) {
3635
+ return new FiatsendError("Your phone hash does not match this payout", FiatsendErrorCode.UNAUTHORIZED, { contractAddress });
3636
+ }
3637
+ if (message.includes("NoMobileNFT")) {
3638
+ return new FiatsendError("You do not have a MobileNumber NFT \u2014 please register first", FiatsendErrorCode.NO_NFT, { contractAddress });
3639
+ }
3640
+ if (message.includes("ZeroAmount")) {
3641
+ return new FiatsendError("Amount must be greater than zero", FiatsendErrorCode.BELOW_MINIMUM, { contractAddress });
3642
+ }
3643
+ if (message.includes("GatewayNotSet")) {
3644
+ return new FiatsendError("Gateway address has not been configured on PayoutEscrow", FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress });
3645
+ }
3646
+ if (message.includes("TokenNotSupportedByGateway")) {
3647
+ return new FiatsendError("This token is not supported by the gateway", FiatsendErrorCode.TOKEN_NOT_SUPPORTED, { contractAddress });
3648
+ }
3649
+ if (message.includes("ArrayLengthMismatch")) {
3650
+ return new FiatsendError("Batch payout arrays must all be the same length", FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress });
3651
+ }
3652
+ if (message.includes("InvalidExpiry")) {
3653
+ return new FiatsendError("Expiry timestamp must be in the future", FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress });
3654
+ }
3655
+ if (message.includes("Paused") || message.includes("EnforcedPause")) {
3656
+ return new FiatsendError("PayoutEscrow is currently paused", FiatsendErrorCode.CONTRACT_PAUSED, { contractAddress });
3657
+ }
3658
+ return new FiatsendError(message, FiatsendErrorCode.TRANSACTION_FAILED, {
3659
+ contractAddress,
3660
+ ...err instanceof Error && { cause: err }
3661
+ });
3662
+ }
3663
+ var PayoutsResource = class {
3664
+ publicClient;
3665
+ walletClient;
3666
+ contractAddress;
3667
+ constructor(params) {
3668
+ this.publicClient = params.publicClient;
3669
+ this.walletClient = params.walletClient;
3670
+ this.contractAddress = params.contractAddress;
3671
+ }
3672
+ get readContract() {
3673
+ return getContract({
3674
+ address: this.contractAddress,
3675
+ abi: PayoutEscrowABI,
3676
+ client: this.publicClient
3677
+ });
3678
+ }
3679
+ requireWallet() {
3680
+ if (!this.walletClient) {
3681
+ throw new FiatsendError(
3682
+ "A walletClient is required for write operations.",
3683
+ FiatsendErrorCode.UNAUTHORIZED
3684
+ );
3685
+ }
3686
+ return this.walletClient;
3687
+ }
3688
+ buildTxResult(hash) {
3689
+ return {
3690
+ hash,
3691
+ wait: async () => {
3692
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
3693
+ return {
3694
+ hash: receipt.transactionHash,
3695
+ status: receipt.status,
3696
+ blockNumber: receipt.blockNumber,
3697
+ gasUsed: receipt.gasUsed
3698
+ };
3699
+ }
3700
+ };
3701
+ }
3702
+ // ─── Write: Business payout creation ────────────────────────────────────
3703
+ /**
3704
+ * Creates a single payout in the escrow.
3705
+ *
3706
+ * The caller must be an authorized sender (set by the contract owner) and must
3707
+ * have approved `amount` of `token` to the PayoutEscrow contract first.
3708
+ *
3709
+ * @param params - Payout parameters including token, amount, phone hash, and optional expiry
3710
+ * @returns Transaction result
3711
+ */
3712
+ async createPayout(params) {
3713
+ try {
3714
+ const wallet = this.requireWallet();
3715
+ const hash = await wallet.writeContract({
3716
+ address: this.contractAddress,
3717
+ abi: PayoutEscrowABI,
3718
+ functionName: "createPayout",
3719
+ args: [
3720
+ params.payoutId,
3721
+ params.token,
3722
+ params.amount,
3723
+ params.phoneHash,
3724
+ params.expiresAt ?? 0n
3725
+ ],
3726
+ account: wallet.account,
3727
+ chain: wallet.chain ?? null
3728
+ });
3729
+ return this.buildTxResult(hash);
3730
+ } catch (err) {
3731
+ throw wrapError7(err, this.contractAddress);
3732
+ }
3733
+ }
3734
+ /**
3735
+ * Creates multiple payouts in a single transaction (single token approval).
3736
+ *
3737
+ * The caller must be an authorized sender and must have approved the total sum
3738
+ * of all amounts to the PayoutEscrow contract.
3739
+ *
3740
+ * @param params - Batch payout parameters
3741
+ * @returns Transaction result
3742
+ */
3743
+ async createBatchPayout(params) {
3744
+ try {
3745
+ const wallet = this.requireWallet();
3746
+ const hash = await wallet.writeContract({
3747
+ address: this.contractAddress,
3748
+ abi: PayoutEscrowABI,
3749
+ functionName: "createBatchPayout",
3750
+ args: [
3751
+ params.payoutIds,
3752
+ params.token,
3753
+ params.amounts,
3754
+ params.phoneHashes,
3755
+ params.expiresAt ?? 0n
3756
+ ],
3757
+ account: wallet.account,
3758
+ chain: wallet.chain ?? null
3759
+ });
3760
+ return this.buildTxResult(hash);
3761
+ } catch (err) {
3762
+ throw wrapError7(err, this.contractAddress);
3763
+ }
3764
+ }
3765
+ // ─── Write: Recipient claim ──────────────────────────────────────────────
3766
+ /**
3767
+ * Claims a payout to the caller's wallet.
3768
+ *
3769
+ * The caller must hold a MobileNumberNFT whose phone hash matches the payout.
3770
+ *
3771
+ * @param payoutId - ID of the payout to claim
3772
+ * @returns Transaction result
3773
+ */
3774
+ async claim(payoutId) {
3775
+ try {
3776
+ const wallet = this.requireWallet();
3777
+ const hash = await wallet.writeContract({
3778
+ address: this.contractAddress,
3779
+ abi: PayoutEscrowABI,
3780
+ functionName: "claim",
3781
+ args: [payoutId],
3782
+ account: wallet.account,
3783
+ chain: wallet.chain ?? null
3784
+ });
3785
+ return this.buildTxResult(hash);
3786
+ } catch (err) {
3787
+ throw wrapError7(err, this.contractAddress);
3788
+ }
3789
+ }
3790
+ /**
3791
+ * Claims a payout and immediately routes funds through the gateway to mobile money.
3792
+ *
3793
+ * Requires the gateway to be set on the PayoutEscrow and the token to be supported.
3794
+ * The caller must hold a MobileNumberNFT whose phone hash matches the payout.
3795
+ *
3796
+ * @param payoutId - ID of the payout to claim
3797
+ * @param phoneNumber - Destination MoMo phone number (e.g., "+233241234567")
3798
+ * @returns Transaction result
3799
+ */
3800
+ async claimToMoMo(payoutId, phoneNumber) {
3801
+ try {
3802
+ const wallet = this.requireWallet();
3803
+ const hash = await wallet.writeContract({
3804
+ address: this.contractAddress,
3805
+ abi: PayoutEscrowABI,
3806
+ functionName: "claimToMoMo",
3807
+ args: [payoutId, phoneNumber],
3808
+ account: wallet.account,
3809
+ chain: wallet.chain ?? null
3810
+ });
3811
+ return this.buildTxResult(hash);
3812
+ } catch (err) {
3813
+ throw wrapError7(err, this.contractAddress);
3814
+ }
3815
+ }
3816
+ // ─── Write: Business refund ──────────────────────────────────────────────
3817
+ /**
3818
+ * Refunds an expired pending payout back to the original sender.
3819
+ *
3820
+ * Only the original sender or contract owner may call this. The payout must
3821
+ * be past its expiry timestamp.
3822
+ *
3823
+ * @param payoutId - ID of the expired payout to refund
3824
+ * @returns Transaction result
3825
+ */
3826
+ async refund(payoutId) {
3827
+ try {
3828
+ const wallet = this.requireWallet();
3829
+ const hash = await wallet.writeContract({
3830
+ address: this.contractAddress,
3831
+ abi: PayoutEscrowABI,
3832
+ functionName: "refund",
3833
+ args: [payoutId],
3834
+ account: wallet.account,
3835
+ chain: wallet.chain ?? null
3836
+ });
3837
+ return this.buildTxResult(hash);
3838
+ } catch (err) {
3839
+ throw wrapError7(err, this.contractAddress);
3840
+ }
3841
+ }
3842
+ // ─── Read operations ──────────────────────────────────────────────────────
3843
+ /**
3844
+ * Returns the full payout struct for a given ID.
3845
+ *
3846
+ * @param payoutId - ID of the payout to look up
3847
+ * @returns Full Payout object with TypeScript-mapped status
3848
+ */
3849
+ async getPayout(payoutId) {
3850
+ try {
3851
+ const raw = await this.readContract.read.getPayout([payoutId]);
3852
+ return mapPayout(raw);
3853
+ } catch (err) {
3854
+ throw wrapError7(err, this.contractAddress);
3855
+ }
3856
+ }
3857
+ /**
3858
+ * Returns all payout IDs associated with a phone hash.
3859
+ *
3860
+ * @param phoneHash - keccak256 of the recipient's encrypted phone bytes
3861
+ * @returns Array of payout IDs (as bytes32 hashes)
3862
+ */
3863
+ async getPayoutsForPhone(phoneHash) {
3864
+ try {
3865
+ const ids = await this.readContract.read.getPayoutsForPhone([phoneHash]);
3866
+ return ids;
3867
+ } catch (err) {
3868
+ throw wrapError7(err, this.contractAddress);
3869
+ }
3870
+ }
3871
+ /**
3872
+ * Returns full payout objects that are still pending for a given phone hash.
3873
+ *
3874
+ * Convenience wrapper around `getPayoutsForPhone` + `getPayout` — fetches all
3875
+ * payout IDs for the phone and filters to those with status 'pending'.
3876
+ *
3877
+ * @param phoneHash - keccak256 of the recipient's encrypted phone bytes
3878
+ * @returns Array of pending Payout objects
3879
+ */
3880
+ async getPendingPayouts(phoneHash) {
3881
+ try {
3882
+ const ids = await this.readContract.read.getPayoutsByStatus([phoneHash, 0]);
3883
+ if (ids.length === 0) return [];
3884
+ const payouts = await Promise.all(
3885
+ ids.map((id) => this.getPayout(id))
3886
+ );
3887
+ return payouts;
3888
+ } catch (err) {
3889
+ throw wrapError7(err, this.contractAddress);
3890
+ }
3891
+ }
3892
+ /**
3893
+ * Returns all payouts claimable by a user based on their MobileNumberNFT phone hash.
3894
+ *
3895
+ * This is a convenience method: it reads the user's NFT phone hash on-chain (if
3896
+ * the NFT contract is accessible via the escrow's `mobileNumberNFT` reference),
3897
+ * then returns all pending payouts for that phone hash.
3898
+ *
3899
+ * Note: This requires the MobileNumberNFT to be queryable. If the NFT contract
3900
+ * is not set, this will throw. Use `getPendingPayouts(phoneHash)` if you already
3901
+ * know the phone hash.
3902
+ *
3903
+ * @param userAddress - Wallet address of the potential recipient
3904
+ * @returns Array of pending Payout objects claimable by this user
3905
+ */
3906
+ async getClaimablePayouts(userAddress) {
3907
+ try {
3908
+ const nftAddress = await this.readContract.read.mobileNumberNFT();
3909
+ const tokenId = await this.publicClient.readContract({
3910
+ address: nftAddress,
3911
+ abi: [
3912
+ {
3913
+ type: "function",
3914
+ name: "getTokenId",
3915
+ inputs: [{ name: "user", type: "address", internalType: "address" }],
3916
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
3917
+ stateMutability: "view"
3918
+ }
3919
+ ],
3920
+ functionName: "getTokenId",
3921
+ args: [userAddress]
3922
+ });
3923
+ if (tokenId === 0n) return [];
3924
+ const encryptedPhone = await this.publicClient.readContract({
3925
+ address: nftAddress,
3926
+ abi: [
3927
+ {
3928
+ type: "function",
3929
+ name: "getEncryptedPhone",
3930
+ inputs: [{ name: "tokenId", type: "uint256", internalType: "uint256" }],
3931
+ outputs: [{ name: "", type: "bytes", internalType: "bytes" }],
3932
+ stateMutability: "view"
3933
+ }
3934
+ ],
3935
+ functionName: "getEncryptedPhone",
3936
+ args: [tokenId]
3937
+ });
3938
+ const { keccak256 } = await import('viem');
3939
+ const phoneHash = keccak256(encryptedPhone);
3940
+ return this.getPendingPayouts(phoneHash);
3941
+ } catch (err) {
3942
+ throw wrapError7(err, this.contractAddress);
3943
+ }
3944
+ }
3945
+ };
3946
+ function mapOrderStatus(status) {
3947
+ switch (status) {
3948
+ case 0:
3949
+ return "open";
3950
+ case 1:
3951
+ return "locked";
3952
+ case 2:
3953
+ return "completed";
3954
+ case 3:
3955
+ return "cancelled";
3956
+ case 4:
3957
+ return "disputed";
3958
+ default:
3959
+ return "open";
3960
+ }
3961
+ }
3962
+ function mapOrder(raw) {
3963
+ return {
3964
+ id: raw.id,
3965
+ maker: raw.maker,
3966
+ taker: raw.taker,
3967
+ token: raw.token,
3968
+ amount: raw.amount,
3969
+ paymentReference: raw.paymentReference,
3970
+ exchangePlatform: raw.exchangePlatform,
3971
+ status: mapOrderStatus(raw.status),
3972
+ createdAt: raw.createdAt,
3973
+ lockedAt: raw.lockedAt,
3974
+ completedAt: raw.completedAt,
3975
+ expiryDuration: raw.expiryDuration
3976
+ };
3977
+ }
3978
+ function wrapError8(err, contractAddress) {
3979
+ if (err instanceof FiatsendError) return err;
3980
+ const message = err instanceof Error ? err.message : String(err);
3981
+ if (message.includes("OrderAlreadyExists")) {
3982
+ return new FiatsendError("An order with this ID already exists", FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress });
3983
+ }
3984
+ if (message.includes("OrderNotFound")) {
3985
+ return new FiatsendError("Order not found", FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress });
3986
+ }
3987
+ if (message.includes("NotMaker")) {
3988
+ return new FiatsendError("Only the order maker can perform this action", FiatsendErrorCode.UNAUTHORIZED, { contractAddress });
3989
+ }
3990
+ if (message.includes("NotParty")) {
3991
+ return new FiatsendError("Only the maker or taker can dispute an order", FiatsendErrorCode.UNAUTHORIZED, { contractAddress });
3992
+ }
3993
+ if (message.includes("NotDisputeResolver")) {
3994
+ return new FiatsendError("Only the designated dispute resolver can resolve disputes", FiatsendErrorCode.UNAUTHORIZED, { contractAddress });
3995
+ }
3996
+ if (message.includes("OrderNotOpen")) {
3997
+ return new FiatsendError("Order is not open \u2014 it may have already been taken or cancelled", FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress });
3998
+ }
3999
+ if (message.includes("OrderNotLocked")) {
4000
+ return new FiatsendError("Order is not locked \u2014 it must be taken before payment can be confirmed", FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress });
4001
+ }
4002
+ if (message.includes("OrderNotDisputed")) {
4003
+ return new FiatsendError("Order is not in disputed status", FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress });
4004
+ }
4005
+ if (message.includes("SelfTake")) {
4006
+ return new FiatsendError("Maker cannot take their own order", FiatsendErrorCode.UNAUTHORIZED, { contractAddress });
4007
+ }
4008
+ if (message.includes("ZeroAmount")) {
4009
+ return new FiatsendError("Amount must be greater than zero", FiatsendErrorCode.BELOW_MINIMUM, { contractAddress });
4010
+ }
4011
+ if (message.includes("ZeroExpiryDuration")) {
4012
+ return new FiatsendError("Expiry duration must be greater than zero", FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress });
4013
+ }
4014
+ if (message.includes("InvalidWinner")) {
4015
+ return new FiatsendError("Winner must be either the maker or the taker", FiatsendErrorCode.TRANSACTION_FAILED, { contractAddress });
4016
+ }
4017
+ if (message.includes("Paused") || message.includes("EnforcedPause")) {
4018
+ return new FiatsendError("P2PExchange is currently paused", FiatsendErrorCode.CONTRACT_PAUSED, { contractAddress });
4019
+ }
4020
+ return new FiatsendError(message, FiatsendErrorCode.TRANSACTION_FAILED, {
4021
+ contractAddress,
4022
+ ...err instanceof Error && { cause: err }
4023
+ });
4024
+ }
4025
+ var P2PResource = class {
4026
+ publicClient;
4027
+ walletClient;
4028
+ contractAddress;
4029
+ constructor(params) {
4030
+ this.publicClient = params.publicClient;
4031
+ this.walletClient = params.walletClient;
4032
+ this.contractAddress = params.contractAddress;
4033
+ }
4034
+ get readContract() {
4035
+ return getContract({
4036
+ address: this.contractAddress,
4037
+ abi: P2PExchangeABI,
4038
+ client: this.publicClient
4039
+ });
4040
+ }
4041
+ requireWallet() {
4042
+ if (!this.walletClient) {
4043
+ throw new FiatsendError(
4044
+ "A walletClient is required for write operations.",
4045
+ FiatsendErrorCode.UNAUTHORIZED
4046
+ );
4047
+ }
4048
+ return this.walletClient;
4049
+ }
4050
+ buildTxResult(hash) {
4051
+ return {
4052
+ hash,
4053
+ wait: async () => {
4054
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
4055
+ return {
4056
+ hash: receipt.transactionHash,
4057
+ status: receipt.status,
4058
+ blockNumber: receipt.blockNumber,
4059
+ gasUsed: receipt.gasUsed
4060
+ };
4061
+ }
4062
+ };
4063
+ }
4064
+ // ─── Write operations ─────────────────────────────────────────────────────
4065
+ /**
4066
+ * Creates a new P2P order and escrows tokens from the maker.
4067
+ *
4068
+ * The caller must have approved `amount` of `token` to the P2PExchange contract.
4069
+ *
4070
+ * @param params - Order parameters
4071
+ * @returns Transaction result
4072
+ */
4073
+ async createOrder(params) {
4074
+ try {
4075
+ const wallet = this.requireWallet();
4076
+ const hash = await wallet.writeContract({
4077
+ address: this.contractAddress,
4078
+ abi: P2PExchangeABI,
4079
+ functionName: "createOrder",
4080
+ args: [
4081
+ params.orderId,
4082
+ params.token,
4083
+ params.amount,
4084
+ params.paymentReference,
4085
+ params.exchangePlatform,
4086
+ params.expiryDuration
4087
+ ],
4088
+ account: wallet.account,
4089
+ chain: wallet.chain ?? null
4090
+ });
4091
+ return this.buildTxResult(hash);
4092
+ } catch (err) {
4093
+ throw wrapError8(err, this.contractAddress);
4094
+ }
4095
+ }
4096
+ /**
4097
+ * Locks an open order. Taker commits to pay via the exchange using the payment reference.
4098
+ *
4099
+ * Once taken, the taker must complete the off-chain payment using the exact reference
4100
+ * string from the order. The maker then calls `confirmPayment` to release funds.
4101
+ *
4102
+ * @param orderId - ID of the order to take
4103
+ * @returns Transaction result
4104
+ */
4105
+ async takeOrder(orderId) {
4106
+ try {
4107
+ const wallet = this.requireWallet();
4108
+ const hash = await wallet.writeContract({
4109
+ address: this.contractAddress,
4110
+ abi: P2PExchangeABI,
4111
+ functionName: "takeOrder",
4112
+ args: [orderId],
4113
+ account: wallet.account,
4114
+ chain: wallet.chain ?? null
4115
+ });
4116
+ return this.buildTxResult(hash);
4117
+ } catch (err) {
4118
+ throw wrapError8(err, this.contractAddress);
4119
+ }
4120
+ }
4121
+ /**
4122
+ * Confirms payment received on the exchange and releases tokens to the taker.
4123
+ *
4124
+ * Only the maker can call this. After confirmation, the escrowed tokens are
4125
+ * transferred to the taker's wallet.
4126
+ *
4127
+ * @param orderId - ID of the locked order to confirm
4128
+ * @returns Transaction result
4129
+ */
4130
+ async confirmPayment(orderId) {
4131
+ try {
4132
+ const wallet = this.requireWallet();
4133
+ const hash = await wallet.writeContract({
4134
+ address: this.contractAddress,
4135
+ abi: P2PExchangeABI,
4136
+ functionName: "confirmPayment",
4137
+ args: [orderId],
4138
+ account: wallet.account,
4139
+ chain: wallet.chain ?? null
4140
+ });
4141
+ return this.buildTxResult(hash);
4142
+ } catch (err) {
4143
+ throw wrapError8(err, this.contractAddress);
4144
+ }
4145
+ }
4146
+ /**
4147
+ * Cancels an open (not yet taken) order and returns tokens to the maker.
4148
+ *
4149
+ * Only the maker can cancel, and only while the order is still open.
4150
+ *
4151
+ * @param orderId - ID of the open order to cancel
4152
+ * @returns Transaction result
4153
+ */
4154
+ async cancelOrder(orderId) {
4155
+ try {
4156
+ const wallet = this.requireWallet();
4157
+ const hash = await wallet.writeContract({
4158
+ address: this.contractAddress,
4159
+ abi: P2PExchangeABI,
4160
+ functionName: "cancelOrder",
4161
+ args: [orderId],
4162
+ account: wallet.account,
4163
+ chain: wallet.chain ?? null
4164
+ });
4165
+ return this.buildTxResult(hash);
4166
+ } catch (err) {
4167
+ throw wrapError8(err, this.contractAddress);
4168
+ }
4169
+ }
4170
+ /**
4171
+ * Raises a dispute on a locked order.
4172
+ *
4173
+ * Either the maker or taker can dispute. Once disputed, the order is frozen
4174
+ * until the designated dispute resolver calls `resolveDispute`.
4175
+ *
4176
+ * @param orderId - ID of the locked order to dispute
4177
+ * @returns Transaction result
4178
+ */
4179
+ async disputeOrder(orderId) {
4180
+ try {
4181
+ const wallet = this.requireWallet();
4182
+ const hash = await wallet.writeContract({
4183
+ address: this.contractAddress,
4184
+ abi: P2PExchangeABI,
4185
+ functionName: "disputeOrder",
4186
+ args: [orderId],
4187
+ account: wallet.account,
4188
+ chain: wallet.chain ?? null
4189
+ });
4190
+ return this.buildTxResult(hash);
4191
+ } catch (err) {
4192
+ throw wrapError8(err, this.contractAddress);
4193
+ }
4194
+ }
4195
+ // ─── Read operations ──────────────────────────────────────────────────────
4196
+ /**
4197
+ * Returns the full order struct for a given ID.
4198
+ *
4199
+ * @param orderId - ID of the order to look up
4200
+ * @returns Full P2POrder object with TypeScript-mapped status
4201
+ */
4202
+ async getOrder(orderId) {
4203
+ try {
4204
+ const raw = await this.readContract.read.getOrder([orderId]);
4205
+ return mapOrder(raw);
4206
+ } catch (err) {
4207
+ throw wrapError8(err, this.contractAddress);
4208
+ }
4209
+ }
4210
+ /**
4211
+ * Returns all order IDs created by a user.
4212
+ *
4213
+ * @param user - Wallet address of the maker
4214
+ * @returns Array of order IDs (as bytes32 hashes)
4215
+ */
4216
+ async getUserOrders(user) {
4217
+ try {
4218
+ const ids = await this.readContract.read.getUserOrders([user]);
4219
+ return ids;
4220
+ } catch (err) {
4221
+ throw wrapError8(err, this.contractAddress);
4222
+ }
4223
+ }
4224
+ /**
4225
+ * Returns open order IDs available for taking.
4226
+ *
4227
+ * @param limit - Maximum number of order IDs to return (0 = all)
4228
+ * @returns Array of open order IDs
4229
+ */
4230
+ async getOpenOrders(limit = 0) {
4231
+ try {
4232
+ const ids = await this.readContract.read.getOpenOrders([BigInt(limit)]);
4233
+ return ids;
4234
+ } catch (err) {
4235
+ throw wrapError8(err, this.contractAddress);
4236
+ }
4237
+ }
4238
+ /**
4239
+ * Returns full order objects for all currently open orders.
4240
+ *
4241
+ * Convenience wrapper around `getOpenOrders` + `getOrder` — fetches all
4242
+ * open order IDs and resolves each to a full P2POrder.
4243
+ *
4244
+ * @param limit - Maximum number of orders to fetch (0 = all)
4245
+ * @returns Array of full P2POrder objects
4246
+ */
4247
+ async getOpenOrdersDetailed(limit = 0) {
4248
+ try {
4249
+ const ids = await this.getOpenOrders(limit);
4250
+ if (ids.length === 0) return [];
4251
+ return Promise.all(ids.map((id) => this.getOrder(id)));
4252
+ } catch (err) {
4253
+ throw wrapError8(err, this.contractAddress);
4254
+ }
4255
+ }
4256
+ };
4257
+
4258
+ // src/client.ts
4259
+ var FiatsendClient = class _FiatsendClient {
4260
+ /** Chain configuration used by this client */
4261
+ chainConfig;
4262
+ /** viem PublicClient used for all read operations */
4263
+ publicClient;
4264
+ /** viem WalletClient (optional) used for write operations */
4265
+ walletClient;
4266
+ /** Resolved contract addresses */
4267
+ addresses;
4268
+ // ─── Resources ────────────────────────────────────────────────────────────
4269
+ /** MobileNumberNFT interactions — register, resolve, KYC */
4270
+ identity;
4271
+ /** FiatsendGateway interactions — offramp, onramp, configuration */
4272
+ gateway;
4273
+ /** PaymentRouter interactions — send, sendToPhone, payment requests */
4274
+ payments;
4275
+ /** Withdrawals contract — read-only withdrawal tracking */
4276
+ withdrawals;
4277
+ /** LiquidityPool interactions — deposit, withdraw, claim rewards */
4278
+ liquidity;
4279
+ /** VaultController interactions — deposit, withdraw, claim yield */
4280
+ vaults;
4281
+ /**
4282
+ * PayoutEscrow interactions — core B2B payout claim flow.
4283
+ *
4284
+ * Businesses create payouts; recipients claim via their MobileNumberNFT identity.
4285
+ * Supports single-tx `claimToMoMo` for immediate mobile money delivery.
4286
+ */
4287
+ payouts;
4288
+ /**
4289
+ * P2PExchange interactions — peer-to-peer exchange with payment references.
4290
+ *
4291
+ * Makers escrow tokens on-chain; takers pay via exchange platforms (Binance P2P,
4292
+ * Paxful, Noones) using the exact payment reference; makers confirm receipt.
4293
+ */
4294
+ p2p;
4295
+ constructor(config) {
4296
+ this.chainConfig = getChainConfig(config.chain);
4297
+ this.addresses = {
4298
+ ...this.chainConfig.contracts,
4299
+ ...config.contractAddresses
4300
+ };
4301
+ this.publicClient = config.publicClient ?? createPublicClient({
4302
+ transport: http(config.rpcUrl ?? this.chainConfig.rpcUrl)
4303
+ });
4304
+ this.walletClient = config.walletClient;
4305
+ const walletOpt = this.walletClient !== void 0 ? { walletClient: this.walletClient } : {};
4306
+ this.identity = new IdentityResource({
4307
+ publicClient: this.publicClient,
4308
+ ...walletOpt,
4309
+ contractAddress: this.addresses.mobileNumberNFT
4310
+ });
4311
+ this.gateway = new GatewayResource({
4312
+ publicClient: this.publicClient,
4313
+ ...walletOpt,
4314
+ contractAddress: this.addresses.gateway
4315
+ });
4316
+ this.payments = new PaymentsResource({
4317
+ publicClient: this.publicClient,
4318
+ ...walletOpt,
4319
+ contractAddress: this.addresses.paymentRouter
4320
+ });
4321
+ this.withdrawals = new WithdrawalsResource({
4322
+ publicClient: this.publicClient,
4323
+ contractAddress: this.addresses.withdrawals
4324
+ });
4325
+ this.liquidity = new LiquidityResource({
4326
+ publicClient: this.publicClient,
4327
+ ...walletOpt,
4328
+ contractAddress: this.addresses.liquidityPool
4329
+ });
4330
+ this.vaults = new VaultsResource({
4331
+ publicClient: this.publicClient,
4332
+ ...walletOpt,
4333
+ contractAddress: this.addresses.vaultController,
4334
+ supportedTokenAddress: this.addresses.ghsFiat
4335
+ });
4336
+ this.payouts = new PayoutsResource({
4337
+ publicClient: this.publicClient,
4338
+ ...walletOpt,
4339
+ contractAddress: this.addresses.payoutEscrow
4340
+ });
4341
+ this.p2p = new P2PResource({
4342
+ publicClient: this.publicClient,
4343
+ ...walletOpt,
4344
+ contractAddress: this.addresses.p2pExchange
4345
+ });
4346
+ }
4347
+ /**
4348
+ * Convenience: returns a copy of this client with a new walletClient attached.
4349
+ *
4350
+ * Useful when the wallet connects after the client is created.
4351
+ *
4352
+ * @param walletClient - The viem WalletClient to attach
4353
+ */
4354
+ withWallet(walletClient) {
4355
+ return new _FiatsendClient({
4356
+ chain: this.chainConfig.chainId,
4357
+ publicClient: this.publicClient,
4358
+ walletClient,
4359
+ contractAddresses: this.addresses
4360
+ });
4361
+ }
4362
+ };
4363
+
4364
+ export { CHAINS, FiatsendClient, FiatsendGatewayABI, GHSFIATABI, GatewayResource, IdentityResource, LiquidityPoolABI, LiquidityResource, MobileNumberNFTABI, P2PExchangeABI, P2PResource, PaymentRouterABI, PaymentsResource, PayoutEscrowABI, PayoutsResource, VaultControllerABI, VaultsResource, WithdrawalsABI, WithdrawalsResource, getChainConfig };
4365
+ //# sourceMappingURL=index.mjs.map
4366
+ //# sourceMappingURL=index.mjs.map