@funkit/api-base 1.5.4 → 1.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/index.js +192 -210
  3. package/dist/index.js.map +2 -2
  4. package/dist/src/consts/request.d.ts +12 -3
  5. package/dist/src/services/assets/endpoints.d.ts +10 -10
  6. package/dist/src/services/assets/types.d.ts +1 -4
  7. package/dist/src/services/checkout/endpoints.d.ts +11 -18
  8. package/dist/src/services/checkout/types.d.ts +17 -18
  9. package/dist/src/services/faucet/endpoints.d.ts +1 -1
  10. package/dist/src/services/faucet/types.d.ts +2 -2
  11. package/dist/src/services/fw-access/endpoints.d.ts +2 -2
  12. package/dist/src/services/fw-access/types.d.ts +3 -4
  13. package/dist/src/services/fw-group/endpoints.d.ts +1 -1
  14. package/dist/src/services/fw-group/types.d.ts +2 -2
  15. package/dist/src/services/fw-info/endpoints.d.ts +2 -2
  16. package/dist/src/services/fw-info/types.d.ts +3 -4
  17. package/dist/src/services/fw-operation/endpoints.d.ts +10 -10
  18. package/dist/src/services/fw-operation/types.d.ts +9 -16
  19. package/dist/src/services/fw-paymaster/endpoints.d.ts +1 -1
  20. package/dist/src/services/fw-paymaster/types.d.ts +2 -2
  21. package/dist/src/services/fw-user/endpoints.d.ts +5 -5
  22. package/dist/src/services/fw-user/types.d.ts +6 -10
  23. package/dist/src/services/mesh/endpoints.d.ts +13 -14
  24. package/dist/src/services/mesh/types.d.ts +7 -11
  25. package/dist/src/services/moonpay/endpoints.d.ts +2 -2
  26. package/dist/src/services/moonpay/types.d.ts +3 -4
  27. package/dist/src/services/stripe/endpoints.d.ts +4 -4
  28. package/dist/src/services/stripe/types.d.ts +2 -2
  29. package/dist/src/services/support/endpoints.d.ts +1 -1
  30. package/dist/src/services/support/types.d.ts +2 -2
  31. package/dist/src/utils/request.d.ts +5 -5
  32. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -78,27 +78,47 @@ async function sendRequest({
78
78
  method,
79
79
  apiKey,
80
80
  body = {},
81
+ logger,
81
82
  retryOptions = {},
82
83
  signal
83
84
  }) {
85
+ const headers = {
86
+ "Content-Type": "application/json",
87
+ ...apiKey ? { "X-Api-Key": apiKey } : {}
88
+ };
84
89
  try {
85
- const headers = {
86
- "Content-Type": "application/json",
87
- ...apiKey ? { "X-Api-Key": apiKey } : {}
88
- };
89
90
  const finalRetryOptions = {
90
91
  ...DEFAULT_RETRY_OPTIONS,
91
- ...retryOptions || {}
92
+ ...retryOptions
92
93
  };
93
- return retry(async () => {
94
- const response = await fetch(uri, {
94
+ return retry(async (context) => {
95
+ const startTimeMs = Date.now();
96
+ const fetchParams = {
95
97
  method,
96
98
  headers,
97
99
  redirect: "follow",
98
100
  signal,
99
101
  body: method !== "GET" ? stringifyWithBigIntSanitization(body) : void 0
102
+ };
103
+ logger?.info("api-base:sendRequest_before", {
104
+ uri,
105
+ fetchParams,
106
+ startTimeMs
100
107
  });
108
+ const response = await fetch(uri, fetchParams);
101
109
  const json = await response.json();
110
+ const endTimeMs = Date.now();
111
+ logger?.info("api-base:sendRequest_after", {
112
+ url: uri,
113
+ fetchParams,
114
+ endTimeMs,
115
+ response: {
116
+ body: json,
117
+ status: response.status
118
+ },
119
+ durationMs: endTimeMs - startTimeMs,
120
+ retries: context.attemptNum
121
+ });
102
122
  if (response.ok) {
103
123
  return json;
104
124
  }
@@ -187,6 +207,15 @@ async function sendRequest({
187
207
  return {};
188
208
  }, finalRetryOptions);
189
209
  } catch (err) {
210
+ logger?.error("api-base:fetch_error", {
211
+ url: uri,
212
+ method,
213
+ request: {
214
+ body,
215
+ headers
216
+ },
217
+ error: err
218
+ });
190
219
  throw new InternalFailureError(
191
220
  ErrorCode.ServerConnectionError,
192
221
  `Cannot connect to Fun API Service ${err}`,
@@ -197,171 +226,119 @@ async function sendRequest({
197
226
  );
198
227
  }
199
228
  }
200
- async function sendGetRequest({
201
- uri,
202
- apiKey,
203
- retryOptions,
204
- signal
205
- }) {
206
- return await sendRequest({
207
- uri,
208
- apiKey,
209
- retryOptions,
210
- signal,
211
- method: "GET"
212
- });
229
+ async function sendGetRequest(options) {
230
+ return await sendRequest({ ...options, method: "GET" });
213
231
  }
214
- async function sendPostRequest({
215
- uri,
216
- body,
217
- apiKey,
218
- retryOptions,
219
- signal
220
- }) {
221
- return await sendRequest({
222
- uri,
223
- apiKey,
224
- body,
225
- retryOptions,
226
- signal,
227
- method: "POST"
228
- });
232
+ async function sendPostRequest(options) {
233
+ return await sendRequest({ ...options, method: "POST" });
229
234
  }
230
- async function sendDeleteRequest({
231
- uri,
232
- apiKey,
233
- retryOptions,
234
- signal
235
- }) {
236
- await sendRequest({
237
- uri,
238
- method: "DELETE",
239
- apiKey,
240
- retryOptions,
241
- signal
242
- });
235
+ async function sendPutRequest(options) {
236
+ return await sendRequest({ ...options, method: "PUT" });
243
237
  }
244
- async function sendPutRequest({
245
- uri,
246
- body,
247
- apiKey,
248
- retryOptions,
249
- signal
250
- }) {
251
- return await sendRequest({
252
- uri,
253
- apiKey,
254
- body,
255
- retryOptions,
256
- signal,
257
- method: "PUT"
258
- });
238
+ async function sendDeleteRequest(options) {
239
+ await sendRequest({ ...options, method: "DELETE" });
259
240
  }
260
241
 
261
242
  // src/services/assets/endpoints.ts
262
243
  async function getAssetPriceInfo({
263
244
  chainId,
264
245
  assetTokenAddress,
265
- apiKey
246
+ ...options
266
247
  }) {
267
248
  const priceInfo = await sendGetRequest({
268
249
  uri: `${API_BASE_URL}/asset/erc20/price/${chainId}/${assetTokenAddress}`,
269
- apiKey,
270
- retryOptions: { maxAttempts: 2 }
250
+ retryOptions: { maxAttempts: 2 },
251
+ ...options
271
252
  });
272
253
  return priceInfo;
273
254
  }
274
255
  async function getAssetErc20ByChainAndSymbol({
275
256
  chainId,
276
257
  symbol,
277
- apiKey
258
+ ...options
278
259
  }) {
279
260
  return await sendGetRequest({
280
261
  uri: `${API_BASE_URL}/asset/erc20/${chainId}/${symbol}`,
281
- apiKey,
282
- retryOptions: { maxAttempts: 2 }
262
+ retryOptions: { maxAttempts: 2 },
263
+ ...options
283
264
  });
284
265
  }
285
266
  async function getAllWalletTokens({
286
267
  walletAddress,
287
268
  onlyVerifiedTokens,
288
- apiKey,
289
- signal
269
+ ...options
290
270
  }) {
291
271
  return await sendGetRequest({
292
272
  uri: `${API_BASE_URL}/assets/erc20s/${walletAddress}?onlyVerifiedTokens=${onlyVerifiedTokens}`,
293
- apiKey,
294
- signal,
295
- retryOptions: { maxAttempts: 2 }
273
+ retryOptions: { maxAttempts: 2 },
274
+ ...options
296
275
  });
297
276
  }
298
277
  async function getAllWalletTokensByChainId({
299
278
  chainId,
300
279
  walletAddress,
301
280
  onlyVerifiedTokens,
302
- apiKey
281
+ ...options
303
282
  }) {
304
283
  return await sendGetRequest({
305
284
  uri: `${API_BASE_URL}/assets/erc20s/${walletAddress}/${chainId}?onlyVerifiedTokens=${onlyVerifiedTokens}`,
306
- apiKey,
307
- retryOptions: { maxAttempts: 2 }
285
+ retryOptions: { maxAttempts: 2 },
286
+ ...options
308
287
  });
309
288
  }
310
- async function getAllowedAssets({
311
- apiKey
312
- }) {
289
+ async function getAllowedAssets(options) {
313
290
  return await sendGetRequest({
314
291
  uri: `${API_BASE_URL}/assets/allow`,
315
- apiKey,
316
- retryOptions: { maxAttempts: 2 }
292
+ retryOptions: { maxAttempts: 2 },
293
+ ...options
317
294
  });
318
295
  }
319
296
  async function getAllWalletNFTs({
320
297
  walletAddress,
321
- apiKey
298
+ ...options
322
299
  }) {
323
300
  return await sendGetRequest({
324
301
  uri: `${API_BASE_URL}/assets/nfts/${walletAddress}`,
325
- apiKey
302
+ ...options
326
303
  });
327
304
  }
328
305
  async function getAllWalletNFTsByChainId({
329
306
  chainId,
330
307
  walletAddress,
331
- apiKey
308
+ ...options
332
309
  }) {
333
310
  return await sendGetRequest({
334
311
  uri: `${API_BASE_URL}/assets/nfts/${walletAddress}/${chainId}`,
335
- apiKey
312
+ ...options
336
313
  });
337
314
  }
338
315
  async function getWalletLidoWithdrawalsByChainId({
339
316
  chainId,
340
317
  walletAddress,
341
- apiKey
318
+ ...options
342
319
  }) {
343
320
  return await sendGetRequest({
344
321
  uri: `${API_BASE_URL}/assets/lido-withdrawals/${walletAddress}/${chainId}`,
345
- apiKey
322
+ ...options
346
323
  });
347
324
  }
348
325
  async function getNftName({
349
326
  chainId,
350
327
  nftAddress,
351
- apiKey
328
+ ...options
352
329
  }) {
353
330
  return await sendGetRequest({
354
331
  uri: `${API_BASE_URL}/asset/nft/${chainId}/${nftAddress}`,
355
- apiKey
332
+ ...options
356
333
  });
357
334
  }
358
335
  async function getNftAddress({
359
336
  name,
360
- apiKey
337
+ ...options
361
338
  }) {
362
339
  return await sendGetRequest({
363
340
  uri: `${API_BASE_URL}/asset/nft?name=${name}`,
364
- apiKey
341
+ ...options
365
342
  });
366
343
  }
367
344
 
@@ -400,8 +377,7 @@ async function getCheckoutQuote({
400
377
  recipientAddr,
401
378
  needsRefuel,
402
379
  userId,
403
- apiKey,
404
- signal
380
+ ...options
405
381
  }) {
406
382
  try {
407
383
  const toMultipler = 10 ** toTokenDecimals;
@@ -428,8 +404,7 @@ async function getCheckoutQuote({
428
404
  const searchParams = new URLSearchParams(queryParams);
429
405
  const quoteRes = await sendGetRequest({
430
406
  uri: `${API_BASE_URL}/checkout/quote?${searchParams}`,
431
- apiKey,
432
- signal
407
+ ...options
433
408
  });
434
409
  const fromMultipler = 10 ** fromTokenDecimals;
435
410
  return {
@@ -460,8 +435,8 @@ async function initializeCheckout({
460
435
  userOp,
461
436
  quoteId,
462
437
  sourceOfFund,
463
- apiKey,
464
- clientMetadata
438
+ clientMetadata,
439
+ ...options
465
440
  }) {
466
441
  const body = {
467
442
  ...userOp ? { userOp } : {},
@@ -473,7 +448,7 @@ async function initializeCheckout({
473
448
  const res = await sendPostRequest({
474
449
  uri: `${API_BASE_URL}/checkout`,
475
450
  body,
476
- apiKey
451
+ ...options
477
452
  });
478
453
  if (!res?.depositAddr) {
479
454
  throw new ResourceNotFoundError3(
@@ -489,7 +464,7 @@ async function initializeCheckout({
489
464
  }
490
465
  async function deactivateCheckout({
491
466
  depositAddress,
492
- apiKey
467
+ ...options
493
468
  }) {
494
469
  try {
495
470
  await sendPostRequest({
@@ -498,7 +473,7 @@ async function deactivateCheckout({
498
473
  // Fixed state to cancel the checkout
499
474
  state: "CANCELLED" /* CANCELLED */
500
475
  },
501
- apiKey
476
+ ...options
502
477
  });
503
478
  return true;
504
479
  } catch (_err) {
@@ -507,14 +482,12 @@ async function deactivateCheckout({
507
482
  }
508
483
  async function getCheckoutByDepositAddress({
509
484
  depositAddress,
510
- apiKey,
511
- signal
485
+ ...options
512
486
  }) {
513
487
  try {
514
488
  return await sendGetRequest({
515
489
  uri: `${API_BASE_URL}/checkout/${depositAddress}`,
516
- apiKey,
517
- signal
490
+ ...options
518
491
  });
519
492
  } catch (err) {
520
493
  if (err instanceof ResourceNotFoundError3) {
@@ -525,44 +498,38 @@ async function getCheckoutByDepositAddress({
525
498
  }
526
499
  async function getCheckoutsByFunWalletAddress({
527
500
  funWalletAddress,
528
- apiKey,
529
- signal
501
+ ...options
530
502
  }) {
531
503
  const res = await sendGetRequest({
532
504
  uri: `${API_BASE_URL}/checkout/fun-wallet/${funWalletAddress}`,
533
- apiKey,
534
- signal
505
+ ...options
535
506
  });
536
507
  return res || [];
537
508
  }
538
509
  async function getCheckoutsByRecipientAddress({
539
510
  recipientAddress,
540
- apiKey,
541
- signal
511
+ ...options
542
512
  }) {
543
513
  const res = await sendGetRequest({
544
514
  uri: `${API_BASE_URL}/checkout/recipient/${recipientAddress}`,
545
- apiKey,
546
- signal
515
+ ...options
547
516
  });
548
517
  return res || [];
549
518
  }
550
519
  async function getCheckoutsByUserId({
551
520
  userId,
552
- apiKey,
553
- signal
521
+ ...options
554
522
  }) {
555
523
  const res = await sendGetRequest({
556
524
  uri: `${API_BASE_URL}/checkout/userId/${userId}`,
557
- apiKey,
558
- signal
525
+ ...options
559
526
  });
560
527
  return res || [];
561
528
  }
562
529
  async function getPaymasterDataForCheckoutSponsoredTransfer({
563
530
  depositAddress,
564
531
  transferUserOp,
565
- apiKey
532
+ ...options
566
533
  }) {
567
534
  const body = {
568
535
  depositAddress,
@@ -571,7 +538,7 @@ async function getPaymasterDataForCheckoutSponsoredTransfer({
571
538
  const res = await sendPostRequest({
572
539
  uri: `${API_BASE_URL}/checkout/sponsor-transfer`,
573
540
  body,
574
- apiKey
541
+ ...options
575
542
  });
576
543
  if (!res) {
577
544
  throw new Error("Unable to get sponsorship information");
@@ -580,22 +547,26 @@ async function getPaymasterDataForCheckoutSponsoredTransfer({
580
547
  }
581
548
  async function getRiskAssessmentForAddress({
582
549
  address,
583
- apiKey
550
+ ...options
584
551
  }) {
585
552
  const response = await sendGetRequest({
586
553
  uri: `${API_BASE_URL}/checkout/risk-assessment?address=${address}`,
587
- apiKey
554
+ ...options
588
555
  });
589
556
  return response;
590
557
  }
591
558
  async function initializeCheckoutTokenTransferAddress({
592
559
  apiKey,
560
+ logger,
561
+ signal,
593
562
  ...body
594
563
  }) {
595
564
  const res = await sendPostRequest({
596
565
  uri: `${API_BASE_URL}/eoa`,
597
566
  body,
598
- apiKey
567
+ apiKey,
568
+ logger,
569
+ signal
599
570
  });
600
571
  if (!res?.depositAddr) {
601
572
  throw new ResourceNotFoundError3(
@@ -615,11 +586,11 @@ async function getAssetFromFaucet({
615
586
  token,
616
587
  chain,
617
588
  walletAddress,
618
- apiKey
589
+ ...options
619
590
  }) {
620
591
  return await sendGetRequest({
621
592
  uri: `${FUN_FAUCET_URL}/get-faucet?token=${token}&testnet=${chain}&addr=${walletAddress}`,
622
- apiKey
593
+ ...options
623
594
  });
624
595
  }
625
596
 
@@ -627,21 +598,21 @@ async function getAssetFromFaucet({
627
598
  async function initializeWalletAccess({
628
599
  walletAddr,
629
600
  creatorAddr,
630
- apiKey
601
+ ...options
631
602
  }) {
632
603
  await sendPostRequest({
633
604
  uri: `${API_BASE_URL}/access/wallet`,
634
605
  body: { walletAddr, creatorAddr },
635
- apiKey
606
+ ...options
636
607
  });
637
608
  }
638
609
  async function checkWalletAccessInitialization({
639
610
  walletAddr,
640
- apiKey
611
+ ...options
641
612
  }) {
642
613
  return (await sendGetRequest({
643
614
  uri: `${API_BASE_URL}/access/wallet/${walletAddr}`,
644
- apiKey
615
+ ...options
645
616
  })).initialized;
646
617
  }
647
618
 
@@ -649,23 +620,23 @@ async function checkWalletAccessInitialization({
649
620
  async function getGroups({
650
621
  groupIds,
651
622
  chainId,
652
- apiKey
623
+ ...options
653
624
  }) {
654
625
  return (await sendPostRequest({
655
626
  uri: `${API_BASE_URL}/group/get-groups`,
656
627
  body: { groupIds, chainId },
657
- apiKey
628
+ ...options
658
629
  })).groups;
659
630
  }
660
631
 
661
632
  // src/services/fw-info/endpoints.ts
662
633
  async function getChainFromId({
663
634
  chainId,
664
- apiKey
635
+ ...options
665
636
  }) {
666
637
  const res = await sendGetRequest({
667
638
  uri: `${API_BASE_URL}/chain-info/${chainId}`,
668
- apiKey
639
+ ...options
669
640
  });
670
641
  if (!res) {
671
642
  throw new Error(JSON.stringify(res));
@@ -674,11 +645,11 @@ async function getChainFromId({
674
645
  }
675
646
  async function getChainFromName({
676
647
  name,
677
- apiKey
648
+ ...options
678
649
  }) {
679
650
  const res = await sendGetRequest({
680
651
  uri: `${API_BASE_URL}/chain-info?name=${name}`,
681
- apiKey
652
+ ...options
682
653
  });
683
654
  if (!res) {
684
655
  throw new Error(JSON.stringify(res));
@@ -689,27 +660,27 @@ async function getChainFromName({
689
660
  // src/services/fw-operation/endpoints.ts
690
661
  async function createOp({
691
662
  op,
692
- apiKey
663
+ ...options
693
664
  }) {
694
665
  return (await sendPostRequest({
695
666
  uri: `${API_BASE_URL}/operation`,
696
667
  body: { ...op },
697
- apiKey
668
+ ...options
698
669
  })).opId;
699
670
  }
700
671
  async function getOpsOfWallet({
701
672
  walletAddr,
702
673
  chainId,
703
- apiKey,
704
- status
674
+ status,
675
+ ...options
705
676
  }) {
706
677
  const endpoint = status ? `${API_BASE_URL}/operation/wallet/${walletAddr}/chain/${chainId}?status=${status}` : `${API_BASE_URL}/operation/wallet/${walletAddr}/chain/${chainId}`;
707
- return (await sendGetRequest({ uri: endpoint, apiKey })).operations;
678
+ return (await sendGetRequest({ uri: endpoint, ...options })).operations;
708
679
  }
709
680
  async function getOps({
710
681
  opIds,
711
682
  chainId,
712
- apiKey
683
+ ...options
713
684
  }) {
714
685
  return (await sendPostRequest({
715
686
  uri: `${API_BASE_URL}/operation/get-operations`,
@@ -717,17 +688,17 @@ async function getOps({
717
688
  opIds,
718
689
  chainId
719
690
  },
720
- apiKey
691
+ ...options
721
692
  })).operations;
722
693
  }
723
694
  async function deleteOp({
724
695
  opId,
725
696
  chainId,
726
- apiKey
697
+ ...options
727
698
  }) {
728
699
  await sendDeleteRequest({
729
700
  uri: `${API_BASE_URL}/operation/${opId}/chain/${chainId}`,
730
- apiKey
701
+ ...options
731
702
  });
732
703
  }
733
704
  async function signOp({
@@ -735,8 +706,8 @@ async function signOp({
735
706
  chainId,
736
707
  signature,
737
708
  signedBy,
738
- apiKey,
739
- threshold
709
+ threshold,
710
+ ...options
740
711
  }) {
741
712
  await sendPostRequest({
742
713
  uri: `${API_BASE_URL}/operation/sign`,
@@ -747,44 +718,44 @@ async function signOp({
747
718
  signedBy,
748
719
  threshold
749
720
  },
750
- apiKey
721
+ ...options
751
722
  });
752
723
  }
753
724
  async function executeOp({
754
725
  input,
755
- apiKey
726
+ ...options
756
727
  }) {
757
728
  return await sendPostRequest({
758
729
  uri: `${API_BASE_URL}/operation/execute`,
759
730
  body: input,
760
- apiKey
731
+ ...options
761
732
  });
762
733
  }
763
734
  async function estimateOp({
764
- apiKey,
765
- input
735
+ input,
736
+ ...options
766
737
  }) {
767
738
  return await sendPostRequest({
768
739
  uri: `${API_BASE_URL}/operation/estimate`,
769
740
  body: input,
770
- apiKey
741
+ ...options
771
742
  });
772
743
  }
773
744
  async function scheduleOp({
774
745
  input,
775
- apiKey
746
+ ...options
776
747
  }) {
777
748
  await sendPostRequest({
778
749
  uri: `${API_BASE_URL}/operation/schedule`,
779
750
  body: input,
780
- apiKey
751
+ ...options
781
752
  });
782
753
  }
783
754
  var getFullReceipt = async ({
784
755
  opId,
785
756
  chainId,
786
757
  userOpHash,
787
- apiKey
758
+ ...options
788
759
  }) => {
789
760
  const retries = 20;
790
761
  let result = {
@@ -794,7 +765,7 @@ var getFullReceipt = async ({
794
765
  try {
795
766
  result = await sendGetRequest({
796
767
  uri: `${API_BASE_URL}/operation/${opId}/chain/${chainId}/receipt?userOpHash=${userOpHash}`,
797
- apiKey
768
+ ...options
798
769
  });
799
770
  if (result.status === "included") {
800
771
  break;
@@ -819,11 +790,11 @@ var getFullReceipt = async ({
819
790
  };
820
791
  var getUserOpGasPrice = async ({
821
792
  chainId,
822
- apiKey
793
+ ...options
823
794
  }) => {
824
795
  return await sendGetRequest({
825
796
  uri: `${API_BASE_URL}/operation/chain/${chainId}/gas-price`,
826
- apiKey
797
+ ...options
827
798
  });
828
799
  };
829
800
 
@@ -858,7 +829,7 @@ async function addTransaction({
858
829
  transaction,
859
830
  paymasterType,
860
831
  sponsorAddress,
861
- apiKey
832
+ ...options
862
833
  }) {
863
834
  try {
864
835
  return await sendPostRequest({
@@ -871,7 +842,7 @@ async function addTransaction({
871
842
  transaction,
872
843
  txid
873
844
  },
874
- apiKey
845
+ ...options
875
846
  });
876
847
  } catch (_err) {
877
848
  }
@@ -894,7 +865,7 @@ async function createUser({
894
865
  addr,
895
866
  method,
896
867
  userUniqueId,
897
- apiKey
868
+ ...options
898
869
  }) {
899
870
  await sendPostRequest({
900
871
  uri: `${API_BASE_URL}/user`,
@@ -904,17 +875,17 @@ async function createUser({
904
875
  method,
905
876
  userUniqueId
906
877
  },
907
- apiKey
878
+ ...options
908
879
  });
909
880
  }
910
881
  async function getUserUniqueId({
911
882
  authId,
912
- apiKey
883
+ ...options
913
884
  }) {
914
885
  try {
915
886
  return (await sendGetRequest({
916
887
  uri: `${API_BASE_URL}/user/auth/${authId}/unique-id`,
917
- apiKey
888
+ ...options
918
889
  })).userUniqueId;
919
890
  } catch (err) {
920
891
  if (err instanceof ResourceNotFoundError4) {
@@ -925,25 +896,25 @@ async function getUserUniqueId({
925
896
  }
926
897
  async function getUserWalletsByAddr({
927
898
  addr,
928
- apiKey,
929
- chainId
899
+ chainId,
900
+ ...options
930
901
  }) {
931
902
  const endpoint = chainId ? `${API_BASE_URL}/user/addr/${addr}/wallets?chainId=${chainId}` : `${API_BASE_URL}/user/addr/${addr}/wallets`;
932
- return (await sendGetRequest({ uri: endpoint, apiKey })).wallets;
903
+ return (await sendGetRequest({ uri: endpoint, ...options })).wallets;
933
904
  }
934
905
  async function addUserToWallet({
935
906
  authId,
936
907
  chainId,
937
908
  walletAddr,
938
909
  userIds,
939
- apiKey,
940
- walletUniqueId
910
+ walletUniqueId,
911
+ ...options
941
912
  }) {
942
913
  try {
943
914
  await sendPostRequest({
944
915
  uri: `${API_BASE_URL}/user/auth/${authId}/chain/${chainId}/wallet`,
945
916
  body: { walletAddr, userIds, walletUniqueId },
946
- apiKey
917
+ ...options
947
918
  });
948
919
  } catch (err) {
949
920
  if (err instanceof InvalidParameterError3) {
@@ -956,11 +927,11 @@ async function getUserWalletIdentities({
956
927
  authId,
957
928
  chainId,
958
929
  walletAddr,
959
- apiKey
930
+ ...options
960
931
  }) {
961
932
  return (await sendGetRequest({
962
933
  uri: `${API_BASE_URL}/user/auth/${authId}/chain/${chainId}/wallet/${walletAddr}/identities`,
963
- apiKey
934
+ ...options
964
935
  })).ids ?? [];
965
936
  }
966
937
 
@@ -968,30 +939,29 @@ async function getUserWalletIdentities({
968
939
  async function meshGetCryptocurrencyHoldings({
969
940
  authToken,
970
941
  type,
971
- apiKey
942
+ ...options
972
943
  }) {
973
944
  return sendPostRequest({
974
945
  uri: `${API_BASE_URL}/mesh/holdings/get`,
975
946
  body: { authToken, type },
976
- apiKey
947
+ ...options
977
948
  });
978
949
  }
979
950
  async function meshGetCryptocurrencyHoldingsProxy({
980
- apiKey,
981
- ...props
951
+ brokerType,
952
+ deviceId,
953
+ ...options
982
954
  }) {
983
955
  return sendPostRequest({
984
956
  uri: `${MESH_API_BASE_URL}/mesh/holdings/get`,
985
- body: { ...props },
986
- apiKey
957
+ body: { brokerType, deviceId },
958
+ ...options
987
959
  });
988
960
  }
989
- async function meshGetTransferIntegrations({
990
- apiKey
991
- }) {
961
+ async function meshGetTransferIntegrations(options) {
992
962
  return sendGetRequest({
993
963
  uri: `${API_BASE_URL}/mesh/transfers/managed/integrations`,
994
- apiKey
964
+ ...options
995
965
  });
996
966
  }
997
967
  async function meshGetLinkToken({
@@ -999,7 +969,7 @@ async function meshGetLinkToken({
999
969
  integrationId,
1000
970
  restrictMultipleAccounts,
1001
971
  transferOptions,
1002
- apiKey
972
+ ...options
1003
973
  }) {
1004
974
  const body = {
1005
975
  userId,
@@ -1010,7 +980,7 @@ async function meshGetLinkToken({
1010
980
  return sendPostRequest({
1011
981
  uri: `${API_BASE_URL}/mesh/linktoken`,
1012
982
  body,
1013
- apiKey
983
+ ...options
1014
984
  });
1015
985
  }
1016
986
  async function meshPreviewTransfer({
@@ -1024,7 +994,7 @@ async function meshPreviewTransfer({
1024
994
  amount,
1025
995
  amountInFiat,
1026
996
  fiatCurrency,
1027
- apiKey
997
+ ...options
1028
998
  }) {
1029
999
  const body = {
1030
1000
  fromAuthToken,
@@ -1041,12 +1011,14 @@ async function meshPreviewTransfer({
1041
1011
  return sendPostRequest({
1042
1012
  uri: `${API_BASE_URL}/mesh/transfers/managed/preview`,
1043
1013
  body,
1044
- apiKey,
1045
- retryOptions: { maxAttempts: 1 }
1014
+ retryOptions: { maxAttempts: 1 },
1015
+ ...options
1046
1016
  });
1047
1017
  }
1048
1018
  async function meshPreviewTransferProxy({
1049
1019
  apiKey,
1020
+ logger,
1021
+ signal,
1050
1022
  ...props
1051
1023
  }) {
1052
1024
  const body = { ...props };
@@ -1054,7 +1026,9 @@ async function meshPreviewTransferProxy({
1054
1026
  uri: `${MESH_API_BASE_URL}/mesh/transfers/managed/preview`,
1055
1027
  body,
1056
1028
  apiKey,
1057
- retryOptions: { maxAttempts: 1 }
1029
+ logger,
1030
+ retryOptions: { maxAttempts: 1 },
1031
+ signal
1058
1032
  });
1059
1033
  }
1060
1034
  async function meshExecuteTransfer({
@@ -1062,7 +1036,7 @@ async function meshExecuteTransfer({
1062
1036
  fromType,
1063
1037
  previewId,
1064
1038
  mfaCode,
1065
- apiKey
1039
+ ...options
1066
1040
  }) {
1067
1041
  const body = {
1068
1042
  fromAuthToken,
@@ -1073,39 +1047,47 @@ async function meshExecuteTransfer({
1073
1047
  return sendPostRequest({
1074
1048
  uri: `${API_BASE_URL}/mesh/transfers/managed/execute`,
1075
1049
  body,
1076
- apiKey
1050
+ ...options
1077
1051
  });
1078
1052
  }
1079
1053
  async function meshExecuteTransferProxy({
1080
1054
  apiKey,
1055
+ logger,
1056
+ signal,
1081
1057
  ...props
1082
1058
  }) {
1083
1059
  const body = { ...props };
1084
1060
  return sendPostRequest({
1085
1061
  uri: `${MESH_API_BASE_URL}/mesh/transfers/managed/execute`,
1086
1062
  body,
1087
- apiKey
1063
+ apiKey,
1064
+ logger,
1065
+ signal
1088
1066
  });
1089
1067
  }
1090
1068
  async function saveTokensToMeshProxy({
1091
1069
  apiKey,
1070
+ logger,
1071
+ signal,
1092
1072
  ...props
1093
1073
  }) {
1094
1074
  const body = { ...props };
1095
1075
  return sendPostRequest({
1096
1076
  uri: `${MESH_API_BASE_URL}/api/tokens`,
1097
1077
  body,
1098
- apiKey
1078
+ apiKey,
1079
+ logger,
1080
+ signal
1099
1081
  });
1100
1082
  }
1101
1083
  async function removeTokensFromMeshProxy({
1102
- apiKey,
1103
- ...props
1084
+ deviceId,
1085
+ brokerType,
1086
+ ...options
1104
1087
  }) {
1105
- const body = { ...props };
1106
1088
  return await sendDeleteRequest({
1107
- uri: `${MESH_API_BASE_URL}/api/tokens?deviceId=${body.deviceId}&brokerType=${body.brokerType}`,
1108
- apiKey
1089
+ uri: `${MESH_API_BASE_URL}/api/tokens?deviceId=${deviceId}&brokerType=${brokerType}`,
1090
+ ...options
1109
1091
  });
1110
1092
  }
1111
1093
 
@@ -1138,12 +1120,12 @@ import { ErrorCode as ErrorCode3, InternalFailureError as InternalFailureError2
1138
1120
  async function getMoonpayUrlSignature({
1139
1121
  url,
1140
1122
  isSandbox,
1141
- apiKey
1123
+ ...options
1142
1124
  }) {
1143
1125
  const signature = await sendPostRequest({
1144
1126
  uri: `${API_BASE_URL}/on-ramp/moonpay-signature/`,
1145
1127
  body: { url, isSandbox },
1146
- apiKey
1128
+ ...options
1147
1129
  });
1148
1130
  if (!signature || !signature?.url) {
1149
1131
  throw new InternalFailureError2(
@@ -1164,7 +1146,7 @@ async function getMoonpayBuyQuoteForCreditCard({
1164
1146
  baseCurrencyAmount,
1165
1147
  extraFeePercentage,
1166
1148
  areFeesIncluded,
1167
- apiKey
1149
+ ...options
1168
1150
  }) {
1169
1151
  const params = new URLSearchParams({
1170
1152
  currencyCode,
@@ -1177,8 +1159,8 @@ async function getMoonpayBuyQuoteForCreditCard({
1177
1159
  }).toString();
1178
1160
  return sendGetRequest({
1179
1161
  uri: `${API_BASE_URL}/on-ramp/moonpay-buy-quote?${params}`,
1180
- apiKey,
1181
- retryOptions: { maxAttempts: 1 }
1162
+ retryOptions: { maxAttempts: 1 },
1163
+ ...options
1182
1164
  });
1183
1165
  }
1184
1166
 
@@ -1189,7 +1171,7 @@ async function getStripeBuyQuote({
1189
1171
  destinationCurrency,
1190
1172
  destinationNetwork,
1191
1173
  isSandbox,
1192
- apiKey
1174
+ ...options
1193
1175
  }) {
1194
1176
  const params = new URLSearchParams({
1195
1177
  isSandbox: isSandbox.toString(),
@@ -1203,7 +1185,7 @@ async function getStripeBuyQuote({
1203
1185
  const buyQuoteResp = await sendGetRequest({
1204
1186
  uri: `${API_BASE_URL}/on-ramp/stripe-buy-quote?${params}`,
1205
1187
  retryOptions: { maxAttempts: 1 },
1206
- apiKey
1188
+ ...options
1207
1189
  });
1208
1190
  return buyQuoteResp;
1209
1191
  }
@@ -1215,7 +1197,7 @@ async function createStripeBuySession({
1215
1197
  walletAddress,
1216
1198
  customerIpAddress,
1217
1199
  isSandbox,
1218
- apiKey
1200
+ ...options
1219
1201
  }) {
1220
1202
  const body = {
1221
1203
  isSandbox: isSandbox.toString(),
@@ -1237,18 +1219,18 @@ async function createStripeBuySession({
1237
1219
  uri: `${API_BASE_URL}/on-ramp/stripe-checkout`,
1238
1220
  body,
1239
1221
  retryOptions: { maxAttempts: 1 },
1240
- apiKey
1222
+ ...options
1241
1223
  });
1242
1224
  return newBuySessionResp;
1243
1225
  }
1244
1226
  async function getStripeBuySession({
1245
1227
  sessionId,
1246
- apiKey
1228
+ ...options
1247
1229
  }) {
1248
1230
  const buySessionResp = await sendGetRequest({
1249
1231
  uri: `${API_BASE_URL}/on-ramp/stripe-checkout-session/${sessionId}`,
1250
1232
  retryOptions: { maxAttempts: 1 },
1251
- apiKey
1233
+ ...options
1252
1234
  });
1253
1235
  return buySessionResp;
1254
1236
  }
@@ -1258,14 +1240,14 @@ async function sendSupportMessage({
1258
1240
  title,
1259
1241
  description,
1260
1242
  userEmail,
1261
- apiKey
1243
+ ...options
1262
1244
  }) {
1263
1245
  try {
1264
1246
  await sendPostRequest({
1265
1247
  uri: `${API_BASE_URL}/support/send-message`,
1266
1248
  body: { title, description, userEmail },
1267
- apiKey,
1268
- retryOptions: { maxAttempts: 1 }
1249
+ retryOptions: { maxAttempts: 1 },
1250
+ ...options
1269
1251
  });
1270
1252
  return true;
1271
1253
  } catch (_err) {