@metamask-previews/ramps-controller 20.2.0-preview-e12b5ece6 → 20.2.0-preview-e0510042f

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 (108) hide show
  1. package/CHANGELOG.md +4 -3
  2. package/dist/RampsController-method-action-types.cjs.map +1 -1
  3. package/dist/RampsController-method-action-types.d.cts +8 -91
  4. package/dist/RampsController-method-action-types.d.cts.map +1 -1
  5. package/dist/RampsController-method-action-types.d.mts +8 -91
  6. package/dist/RampsController-method-action-types.d.mts.map +1 -1
  7. package/dist/RampsController-method-action-types.mjs.map +1 -1
  8. package/dist/RampsController.cjs +20 -375
  9. package/dist/RampsController.cjs.map +1 -1
  10. package/dist/RampsController.d.cts +14 -153
  11. package/dist/RampsController.d.cts.map +1 -1
  12. package/dist/RampsController.d.mts +14 -153
  13. package/dist/RampsController.d.mts.map +1 -1
  14. package/dist/RampsController.mjs +19 -374
  15. package/dist/RampsController.mjs.map +1 -1
  16. package/dist/RampsService-method-action-types.cjs.map +1 -1
  17. package/dist/RampsService-method-action-types.d.cts +1 -0
  18. package/dist/RampsService-method-action-types.d.cts.map +1 -1
  19. package/dist/RampsService-method-action-types.d.mts +1 -0
  20. package/dist/RampsService-method-action-types.d.mts.map +1 -1
  21. package/dist/RampsService-method-action-types.mjs.map +1 -1
  22. package/dist/RampsService.cjs +4 -0
  23. package/dist/RampsService.cjs.map +1 -1
  24. package/dist/RampsService.d.cts +23 -0
  25. package/dist/RampsService.d.cts.map +1 -1
  26. package/dist/RampsService.d.mts +23 -0
  27. package/dist/RampsService.d.mts.map +1 -1
  28. package/dist/RampsService.mjs +4 -0
  29. package/dist/RampsService.mjs.map +1 -1
  30. package/dist/TransakService-method-action-types.cjs.map +1 -1
  31. package/dist/TransakService-method-action-types.d.cts +10 -2
  32. package/dist/TransakService-method-action-types.d.cts.map +1 -1
  33. package/dist/TransakService-method-action-types.d.mts +10 -2
  34. package/dist/TransakService-method-action-types.d.mts.map +1 -1
  35. package/dist/TransakService-method-action-types.mjs.map +1 -1
  36. package/dist/TransakService.cjs +45 -5
  37. package/dist/TransakService.cjs.map +1 -1
  38. package/dist/TransakService.d.cts +15 -3
  39. package/dist/TransakService.d.cts.map +1 -1
  40. package/dist/TransakService.d.mts +15 -3
  41. package/dist/TransakService.d.mts.map +1 -1
  42. package/dist/TransakService.mjs +45 -5
  43. package/dist/TransakService.mjs.map +1 -1
  44. package/dist/index.cjs +1 -20
  45. package/dist/index.cjs.map +1 -1
  46. package/dist/index.d.cts +4 -13
  47. package/dist/index.d.cts.map +1 -1
  48. package/dist/index.d.mts +4 -13
  49. package/dist/index.d.mts.map +1 -1
  50. package/dist/index.mjs +1 -5
  51. package/dist/index.mjs.map +1 -1
  52. package/package.json +1 -1
  53. package/dist/NeoBankService-method-action-types.cjs +0 -7
  54. package/dist/NeoBankService-method-action-types.cjs.map +0 -1
  55. package/dist/NeoBankService-method-action-types.d.cts +0 -126
  56. package/dist/NeoBankService-method-action-types.d.cts.map +0 -1
  57. package/dist/NeoBankService-method-action-types.d.mts +0 -126
  58. package/dist/NeoBankService-method-action-types.d.mts.map +0 -1
  59. package/dist/NeoBankService-method-action-types.mjs +0 -6
  60. package/dist/NeoBankService-method-action-types.mjs.map +0 -1
  61. package/dist/NeoBankService.cjs +0 -387
  62. package/dist/NeoBankService.cjs.map +0 -1
  63. package/dist/NeoBankService.d.cts +0 -191
  64. package/dist/NeoBankService.d.cts.map +0 -1
  65. package/dist/NeoBankService.d.mts +0 -191
  66. package/dist/NeoBankService.d.mts.map +0 -1
  67. package/dist/NeoBankService.mjs +0 -379
  68. package/dist/NeoBankService.mjs.map +0 -1
  69. package/dist/autoramp-types.cjs +0 -3
  70. package/dist/autoramp-types.cjs.map +0 -1
  71. package/dist/autoramp-types.d.cts +0 -22
  72. package/dist/autoramp-types.d.cts.map +0 -1
  73. package/dist/autoramp-types.d.mts +0 -22
  74. package/dist/autoramp-types.d.mts.map +0 -1
  75. package/dist/autoramp-types.mjs +0 -2
  76. package/dist/autoramp-types.mjs.map +0 -1
  77. package/dist/autorampAccount.cjs +0 -155
  78. package/dist/autorampAccount.cjs.map +0 -1
  79. package/dist/autorampAccount.d.cts +0 -126
  80. package/dist/autorampAccount.d.cts.map +0 -1
  81. package/dist/autorampAccount.d.mts +0 -126
  82. package/dist/autorampAccount.d.mts.map +0 -1
  83. package/dist/autorampAccount.mjs +0 -147
  84. package/dist/autorampAccount.mjs.map +0 -1
  85. package/dist/ownership-message.cjs +0 -26
  86. package/dist/ownership-message.cjs.map +0 -1
  87. package/dist/ownership-message.d.cts +0 -22
  88. package/dist/ownership-message.d.cts.map +0 -1
  89. package/dist/ownership-message.d.mts +0 -22
  90. package/dist/ownership-message.d.mts.map +0 -1
  91. package/dist/ownership-message.mjs +0 -22
  92. package/dist/ownership-message.mjs.map +0 -1
  93. package/dist/wallet-registration-machine.cjs +0 -144
  94. package/dist/wallet-registration-machine.cjs.map +0 -1
  95. package/dist/wallet-registration-machine.d.cts +0 -81
  96. package/dist/wallet-registration-machine.d.cts.map +0 -1
  97. package/dist/wallet-registration-machine.d.mts +0 -81
  98. package/dist/wallet-registration-machine.d.mts.map +0 -1
  99. package/dist/wallet-registration-machine.mjs +0 -139
  100. package/dist/wallet-registration-machine.mjs.map +0 -1
  101. package/dist/wallet-registration-service.cjs +0 -351
  102. package/dist/wallet-registration-service.cjs.map +0 -1
  103. package/dist/wallet-registration-service.d.cts +0 -144
  104. package/dist/wallet-registration-service.d.cts.map +0 -1
  105. package/dist/wallet-registration-service.d.mts +0 -144
  106. package/dist/wallet-registration-service.d.mts.map +0 -1
  107. package/dist/wallet-registration-service.mjs +0 -344
  108. package/dist/wallet-registration-service.mjs.map +0 -1
@@ -10,22 +10,18 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
11
11
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
12
  };
13
- var _RampsController_instances, _RampsController_requestCacheTTL, _RampsController_requestCacheMaxSize, _RampsController_pendingRequests, _RampsController_pendingResourceCount, _RampsController_pendingResourceGeneration, _RampsController_orderPollingMeta, _RampsController_orderPollingTimer, _RampsController_isPolling, _RampsController_initPromise, _RampsController_clearPendingResourceCountForDependentResources, _RampsController_abortDependentRequests, _RampsController_resolveAllProvidersFlag, _RampsController_mutateRequests, _RampsController_removeRequestState, _RampsController_cleanupState, _RampsController_requireRegion, _RampsController_isRegionCurrent, _RampsController_isTokenCurrent, _RampsController_isProviderCurrent, _RampsController_updateResourceField, _RampsController_setResourceLoading, _RampsController_setResourceError, _RampsController_updateRequestState, _RampsController_runInit, _RampsController_syncUserRegionFromCountriesCatalog, _RampsController_pickWidenedQuote, _RampsController_getSupportingProvidersForRegion, _RampsController_filterProviderIdsBySupport, _RampsController_resolveProviderIdsForQuote, _RampsController_resolveProviderIdsForPaymentMethods, _RampsController_getPreferredProviderIdsFromOrders, _RampsController_applyAutorampRemoteSnapshot, _RampsController_refreshOrder, _RampsController_pollPendingOrders, _RampsController_syncTransakAuthOnError, _RampsController_getNormalizedTransakError;
13
+ var _RampsController_instances, _RampsController_requestCacheTTL, _RampsController_requestCacheMaxSize, _RampsController_pendingRequests, _RampsController_pendingResourceCount, _RampsController_pendingResourceGeneration, _RampsController_orderPollingMeta, _RampsController_orderPollingTimer, _RampsController_isPolling, _RampsController_initPromise, _RampsController_clearPendingResourceCountForDependentResources, _RampsController_abortDependentRequests, _RampsController_resolveAllProvidersFlag, _RampsController_mutateRequests, _RampsController_removeRequestState, _RampsController_cleanupState, _RampsController_requireRegion, _RampsController_isRegionCurrent, _RampsController_isTokenCurrent, _RampsController_isProviderCurrent, _RampsController_updateResourceField, _RampsController_setResourceLoading, _RampsController_setResourceError, _RampsController_updateRequestState, _RampsController_runInit, _RampsController_syncUserRegionFromCountriesCatalog, _RampsController_pickWidenedQuote, _RampsController_getSupportingProvidersForRegion, _RampsController_filterProviderIdsBySupport, _RampsController_resolveProviderIdsForQuote, _RampsController_resolveProviderIdsForPaymentMethods, _RampsController_getPreferredProviderIdsFromOrders, _RampsController_refreshOrder, _RampsController_pollPendingOrders, _RampsController_syncTransakAuthOnError, _RampsController_getNormalizedTransakError;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.RampsController = exports.getInternalOrderCode = exports.getDefaultRampsControllerState = exports.RAMPS_CONTROLLER_REQUIRED_CONTROLLER_ACTIONS = exports.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = exports.controllerName = void 0;
15
+ exports.RampsController = exports.getInternalOrderCode = exports.getDefaultRampsControllerState = exports.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = exports.controllerName = void 0;
16
16
  const base_controller_1 = require("@metamask/base-controller");
17
17
  const controller_utils_1 = require("@metamask/controller-utils");
18
- const autorampAccount_js_1 = require("./autorampAccount.cjs");
19
18
  const featureFlags_js_1 = require("./featureFlags.cjs");
20
19
  const orderStatus_js_1 = require("./orderStatus.cjs");
21
- const ownership_message_js_1 = require("./ownership-message.cjs");
22
20
  const paymentMethodMerge_js_1 = require("./paymentMethodMerge.cjs");
23
21
  const providerAvailability_js_1 = require("./providerAvailability.cjs");
24
22
  const rampsErrorCodes_js_1 = require("./rampsErrorCodes.cjs");
25
23
  const RampsService_js_1 = require("./RampsService.cjs");
26
24
  const RequestCache_js_1 = require("./RequestCache.cjs");
27
- const wallet_registration_machine_js_1 = require("./wallet-registration-machine.cjs");
28
- const wallet_registration_service_js_1 = require("./wallet-registration-service.cjs");
29
25
  // === GENERAL ===
30
26
  /**
31
27
  * The name of the {@link RampsController}, used to namespace the
@@ -74,36 +70,7 @@ exports.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = [
74
70
  'TransakService:cancelOrder',
75
71
  'TransakService:cancelAllActiveOrders',
76
72
  'TransakService:getActiveOrders',
77
- 'NeoBankService:getAutoramp',
78
- 'NeoBankService:createAutoramp',
79
- 'NeoBankService:getCustomerByExternalId',
80
- 'NeoBankService:getWalletRegistrationStatus',
81
- 'NeoBankService:registerSelfHostedWallet',
82
73
  ];
83
- /**
84
- * Every external controller action RampsController calls via the messenger,
85
- * which hosts must delegate from the root messenger.
86
- * `AuthenticationController:getSessionProfile` resolves the vendor customer
87
- * identity from Profile Sync, and `KeyringController:signPersonalMessage` signs
88
- * the EIP-191 ownership proof for Money Account self-hosted wallet
89
- * registration; both are only exercised by the autoramp paths.
90
- */
91
- exports.RAMPS_CONTROLLER_REQUIRED_CONTROLLER_ACTIONS = [
92
- 'AuthenticationController:getSessionProfile',
93
- 'KeyringController:signPersonalMessage',
94
- 'RemoteFeatureFlagController:getState',
95
- ];
96
- /**
97
- * Distinguishes an already-materialized {@link AutorampAccount} from the
98
- * create-fields shape accepted by {@link RampsController.addAutoramp}.
99
- *
100
- * @param value - Full account or create fields.
101
- * @returns Whether the value already carries the derived account fields.
102
- */
103
- function isFullAutorampAccount(value) {
104
- return (typeof value.updatedAt === 'number' &&
105
- value.lastSeenStatus !== undefined);
106
- }
107
74
  /**
108
75
  * Default TTL for quotes requests (15 seconds).
109
76
  * Quotes are time-sensitive and should have a shorter cache duration.
@@ -215,12 +182,6 @@ const rampsControllerMetadata = {
215
182
  includeInStateLogs: true,
216
183
  usedInUi: true,
217
184
  },
218
- autoramps: {
219
- persist: true,
220
- includeInDebugSnapshot: true,
221
- includeInStateLogs: true,
222
- usedInUi: true,
223
- },
224
185
  providerAutoSelected: {
225
186
  persist: true,
226
187
  includeInDebugSnapshot: true,
@@ -270,7 +231,6 @@ function getDefaultRampsControllerState() {
270
231
  },
271
232
  },
272
233
  orders: [],
273
- autoramps: [],
274
234
  providerAutoSelected: false,
275
235
  };
276
236
  }
@@ -418,14 +378,6 @@ const MESSENGER_EXPOSED_METHODS = [
418
378
  'getQuotes',
419
379
  'addOrder',
420
380
  'removeOrder',
421
- 'addAutoramp',
422
- 'createAutoramp',
423
- 'removeAutoramp',
424
- 'registerMoneyAccountWallet',
425
- 'markAutorampAsNotified',
426
- 'applyAutorampStatusFromPush',
427
- 'refreshAutoramp',
428
- 'refreshAutoramps',
429
381
  'startOrderPolling',
430
382
  'stopOrderPolling',
431
383
  'getBuyWidgetData',
@@ -1227,6 +1179,12 @@ class RampsController extends base_controller_1.BaseController {
1227
1179
  * @param options.action - The ramp action type. Defaults to 'buy'.
1228
1180
  * @param options.forceRefresh - Whether to bypass cache.
1229
1181
  * @param options.ttl - Custom TTL for this request.
1182
+ * @param options.isFeeExcludedFromFiat - When true, requests quotes whose
1183
+ * fees are charged on top of `amount` rather than taken out of it, so
1184
+ * `amountOut` is what `amount` buys before fees. The ramps API honours it
1185
+ * only when the request names exactly one provider, because a fee-on-top
1186
+ * `amountOut` cannot be ranked against fee-inclusive ones. Defaults to the
1187
+ * existing fee-inclusive behaviour.
1230
1188
  * @returns The quotes response containing success, sorted, error, and customActions.
1231
1189
  */
1232
1190
  async getQuotes(options) {
@@ -1257,7 +1215,12 @@ class RampsController extends base_controller_1.BaseController {
1257
1215
  const { enabled: allProvidersEnabled, allowlist: providerAllowlist } = wantsAutoSelection
1258
1216
  ? __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_resolveAllProvidersFlag).call(this)
1259
1217
  : { enabled: false, allowlist: undefined };
1260
- const widenToAllProviders = wantsAutoSelection && allProvidersEnabled;
1218
+ // Fee-on-top quotes cannot be ranked against fee-inclusive quotes because
1219
+ // their amountOut values have different meanings. Keep this request on the
1220
+ // single-provider resolver even when all-provider widening is enabled.
1221
+ const widenToAllProviders = wantsAutoSelection &&
1222
+ allProvidersEnabled &&
1223
+ options.isFeeExcludedFromFiat !== true;
1261
1224
  let providersToUse;
1262
1225
  let widenedProviderCatalog = this.state.providers.data;
1263
1226
  if (options.providers) {
@@ -1333,6 +1296,7 @@ class RampsController extends base_controller_1.BaseController {
1333
1296
  (widenToAllProviders
1334
1297
  ? this.messenger.call('RampsService:getDefaultRedirectCallbackUrl')
1335
1298
  : undefined);
1299
+ const isFeeExcludedFromFiat = options.isFeeExcludedFromFiat === true;
1336
1300
  const cacheKey = (0, RequestCache_js_1.createCacheKey)('getQuotes', [
1337
1301
  normalizedRegion,
1338
1302
  normalizedFiat,
@@ -1343,6 +1307,7 @@ class RampsController extends base_controller_1.BaseController {
1343
1307
  [...providersToUse].sort().join(','),
1344
1308
  effectiveRedirectUrl,
1345
1309
  action,
1310
+ isFeeExcludedFromFiat,
1346
1311
  ]);
1347
1312
  const params = {
1348
1313
  region: normalizedRegion,
@@ -1354,6 +1319,7 @@ class RampsController extends base_controller_1.BaseController {
1354
1319
  providers: providersToUse,
1355
1320
  redirectUrl: effectiveRedirectUrl,
1356
1321
  action,
1322
+ isFeeExcludedFromFiat,
1357
1323
  };
1358
1324
  const response = await this.executeRequest(cacheKey, async () => {
1359
1325
  return this.messenger.call('RampsService:getQuotes', params);
@@ -1431,304 +1397,6 @@ class RampsController extends base_controller_1.BaseController {
1431
1397
  });
1432
1398
  __classPrivateFieldGet(this, _RampsController_orderPollingMeta, "f").delete(providerOrderId);
1433
1399
  }
1434
- /**
1435
- * Adds or updates a local autoramp last-seen cursor (e.g. after create).
1436
- *
1437
- * @param accountOrInput - Full account or create fields.
1438
- * @returns The upserted {@link AutorampAccount}.
1439
- */
1440
- addAutoramp(accountOrInput) {
1441
- const account = isFullAutorampAccount(accountOrInput)
1442
- ? accountOrInput
1443
- : (0, autorampAccount_js_1.createAutorampAccount)(accountOrInput);
1444
- this.update((state) => {
1445
- const idx = state.autoramps.findIndex((existing) => existing.id === account.id);
1446
- if (idx === -1) {
1447
- state.autoramps.push(account);
1448
- }
1449
- else {
1450
- state.autoramps[idx] = {
1451
- ...state.autoramps[idx],
1452
- ...account,
1453
- };
1454
- }
1455
- });
1456
- return (this.state.autoramps.find((existing) => existing.id === account.id) ??
1457
- account);
1458
- }
1459
- /**
1460
- * Creates an autoramp via the neo-bank proxy and applies the returned
1461
- * snapshot as the local last-seen cursor.
1462
- *
1463
- * The vendor `customer_id` is resolved via
1464
- * {@link RampsController.resolveAutorampCustomerId} and injected into the
1465
- * request (any caller-supplied `customer_id` is overwritten).
1466
- *
1467
- * @param request - CreateAutoramp payload.
1468
- * @param options - Optional idempotency key forwarded to the proxy.
1469
- * @param options.idempotencyKey - Value sent as `Idempotency-Key`.
1470
- * @returns The created/updated local {@link AutorampAccount}.
1471
- */
1472
- async createAutoramp(request, options = {}) {
1473
- const customerId = await this.resolveAutorampCustomerId();
1474
- const body = { ...request, customer_id: customerId };
1475
- const remote = await this.messenger.call('NeoBankService:createAutoramp', body, options);
1476
- return __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_applyAutorampRemoteSnapshot).call(this, remote);
1477
- }
1478
- /**
1479
- * Resolves the vendor `customer_id` for autoramp / Money Account operations.
1480
- *
1481
- * Maps the wallet's Profile Sync id (the partner `external_id`) to the
1482
- * vendor customer via `GET /neobank/customers/{external_id}/external`.
1483
- *
1484
- * @returns The vendor customer id.
1485
- */
1486
- async resolveAutorampCustomerId() {
1487
- const profile = await this.messenger.call('AuthenticationController:getSessionProfile');
1488
- const canonical = profile?.canonicalProfileId;
1489
- const externalId = typeof canonical === 'string' && canonical.length > 0
1490
- ? canonical
1491
- : profile?.profileId;
1492
- if (typeof externalId !== 'string' || externalId.length === 0) {
1493
- throw new Error('Cannot resolve MoonPay customer id: wallet is not signed in to Profile Sync.');
1494
- }
1495
- const customer = await this.messenger.call('NeoBankService:getCustomerByExternalId', externalId);
1496
- const customerId = customer &&
1497
- typeof customer === 'object' &&
1498
- typeof customer.id === 'string'
1499
- ? customer.id
1500
- : null;
1501
- if (!customerId) {
1502
- throw new Error(`Cannot resolve MoonPay customer id: no MoonPay customer is mapped to external id "${externalId}".`);
1503
- }
1504
- return customerId;
1505
- }
1506
- /**
1507
- * Registers a Money Account wallet with MoonPay Iron via neobank-proxy.
1508
- *
1509
- * @param params - Money Account wallet registration parameters.
1510
- * @param params.address - Monad Money Account address.
1511
- * @returns The registration state, or `{ type: 'lookupUnavailable' }` when
1512
- * the address-list lookup fails (never treated as unregistered).
1513
- */
1514
- async registerMoneyAccountWallet({ address, }) {
1515
- let machine = (0, wallet_registration_machine_js_1.transition)((0, wallet_registration_machine_js_1.createInitialState)(), { type: 'START' });
1516
- const toExistingResult = (status) => {
1517
- if (status.type === 'active') {
1518
- return { type: 'alreadyRegistered', registration: status.registration };
1519
- }
1520
- if (status.type === 'disabled') {
1521
- return {
1522
- type: 'registeredDisabled',
1523
- registration: status.registration,
1524
- };
1525
- }
1526
- return undefined;
1527
- };
1528
- const customerId = await this.resolveAutorampCustomerId();
1529
- const toLookupUnavailableResult = (error) => {
1530
- machine = (0, wallet_registration_machine_js_1.transition)(machine, {
1531
- type: 'LOOKUP_FAILED',
1532
- });
1533
- return {
1534
- type: 'lookupUnavailable',
1535
- error: error instanceof wallet_registration_service_js_1.WalletRegistrationError
1536
- ? error
1537
- : new wallet_registration_service_js_1.WalletRegistrationError('lookupUnavailable', {
1538
- message: 'self-hosted address lookup failed',
1539
- body: error instanceof Error ? error.message : undefined,
1540
- }),
1541
- };
1542
- };
1543
- const lookup = async () => {
1544
- try {
1545
- return await this.messenger.call('NeoBankService:getWalletRegistrationStatus', { customerId, address });
1546
- }
1547
- catch (error) {
1548
- return toLookupUnavailableResult(error);
1549
- }
1550
- };
1551
- const applyLookup = (status) => {
1552
- let eventType = 'LOOKUP_ABSENT';
1553
- if (status.type === 'active') {
1554
- eventType = 'LOOKUP_ACTIVE';
1555
- }
1556
- else if (status.type === 'disabled') {
1557
- eventType = 'LOOKUP_DISABLED';
1558
- }
1559
- machine = (0, wallet_registration_machine_js_1.transition)(machine, {
1560
- type: eventType,
1561
- });
1562
- return toExistingResult(status);
1563
- };
1564
- const resolveLookup = async () => {
1565
- const status = await lookup();
1566
- if (status.type === 'lookupUnavailable') {
1567
- return status;
1568
- }
1569
- return applyLookup(status);
1570
- };
1571
- const existingResult = await resolveLookup();
1572
- if (existingResult) {
1573
- return existingResult;
1574
- }
1575
- let idempotencyKey = (0, wallet_registration_service_js_1.createIdempotencyKey)();
1576
- let lastMessage;
1577
- while (true) {
1578
- const message = (0, ownership_message_js_1.buildOwnershipMessage)({
1579
- address,
1580
- customerId,
1581
- now: new Date(),
1582
- });
1583
- if (lastMessage !== undefined && message !== lastMessage) {
1584
- idempotencyKey = (0, wallet_registration_service_js_1.createIdempotencyKey)();
1585
- }
1586
- lastMessage = message;
1587
- let signature;
1588
- try {
1589
- signature = await this.messenger.call('KeyringController:signPersonalMessage', { data: message, from: address });
1590
- machine = (0, wallet_registration_machine_js_1.transition)(machine, { type: 'SIGN_OK' });
1591
- }
1592
- catch (error) {
1593
- machine = (0, wallet_registration_machine_js_1.transition)(machine, {
1594
- type: 'SIGN_FAILED',
1595
- retryable: false,
1596
- });
1597
- throw error;
1598
- }
1599
- try {
1600
- const result = await this.messenger.call('NeoBankService:registerSelfHostedWallet', {
1601
- address,
1602
- customerId,
1603
- message,
1604
- signature,
1605
- idempotencyKey,
1606
- });
1607
- machine = (0, wallet_registration_machine_js_1.transition)(machine, { type: 'SUBMIT_OK' });
1608
- return result;
1609
- }
1610
- catch (error) {
1611
- if (!(error instanceof wallet_registration_service_js_1.WalletRegistrationError)) {
1612
- machine = (0, wallet_registration_machine_js_1.transition)(machine, {
1613
- type: 'SUBMIT_TERMINAL',
1614
- });
1615
- throw error;
1616
- }
1617
- if (error.kind === 'conflict') {
1618
- machine = (0, wallet_registration_machine_js_1.transition)(machine, {
1619
- type: 'SUBMIT_CONFLICT',
1620
- });
1621
- }
1622
- else if (error.kind === 'transient') {
1623
- machine = (0, wallet_registration_machine_js_1.transition)(machine, {
1624
- type: 'SUBMIT_TRANSIENT',
1625
- });
1626
- }
1627
- else if (error.kind === 'validation') {
1628
- machine = (0, wallet_registration_machine_js_1.transition)(machine, {
1629
- type: 'SUBMIT_VALIDATION',
1630
- utcRollover: (0, ownership_message_js_1.buildOwnershipMessage)({
1631
- address,
1632
- customerId,
1633
- now: new Date(),
1634
- }) !== message,
1635
- });
1636
- }
1637
- else if (error.kind === 'rateLimited') {
1638
- machine = (0, wallet_registration_machine_js_1.transition)(machine, {
1639
- type: 'SUBMIT_RATE_LIMITED',
1640
- });
1641
- }
1642
- else {
1643
- machine = (0, wallet_registration_machine_js_1.transition)(machine, {
1644
- type: 'SUBMIT_TERMINAL',
1645
- });
1646
- }
1647
- if (machine.status === 'disambiguate409' ||
1648
- machine.status === 'checkThenRetry') {
1649
- const reconciledResult = await resolveLookup();
1650
- if (reconciledResult) {
1651
- return reconciledResult;
1652
- }
1653
- }
1654
- if (machine.status !== 'signing') {
1655
- throw error;
1656
- }
1657
- }
1658
- }
1659
- }
1660
- /**
1661
- * Removes a local autoramp last-seen cursor by id.
1662
- *
1663
- * @param autorampId - MoonPay autoramp id.
1664
- */
1665
- removeAutoramp(autorampId) {
1666
- this.update((state) => {
1667
- state.autoramps = state.autoramps.filter((autoramp) => autoramp.id !== autorampId);
1668
- });
1669
- }
1670
- /**
1671
- * Marks that the UI has already notified for the autoramp's current status.
1672
- *
1673
- * @param autorampId - MoonPay autoramp id.
1674
- */
1675
- markAutorampAsNotified(autorampId) {
1676
- const existing = this.state.autoramps.find((autoramp) => autoramp.id === autorampId);
1677
- if (!existing) {
1678
- return;
1679
- }
1680
- const notified = (0, autorampAccount_js_1.markAutorampNotified)(existing);
1681
- this.update((state) => {
1682
- const idx = state.autoramps.findIndex((autoramp) => autoramp.id === autorampId);
1683
- if (idx !== -1) {
1684
- state.autoramps[idx] = notified;
1685
- }
1686
- });
1687
- }
1688
- /**
1689
- * Applies a remote autoramp snapshot from a websocket / webhook push.
1690
- *
1691
- * @param remote - Remote autoramp snapshot.
1692
- * @returns The updated local account.
1693
- */
1694
- applyAutorampStatusFromPush(remote) {
1695
- return __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_applyAutorampRemoteSnapshot).call(this, remote);
1696
- }
1697
- /**
1698
- * Fetches one autoramp from the neo-bank proxy and applies it to the
1699
- * last-seen cursor. Does not recreate a cursor that was removed while the
1700
- * request was in flight.
1701
- *
1702
- * @param autorampId - MoonPay autoramp id.
1703
- * @returns The updated local account, or an unpersisted snapshot if the
1704
- * cursor was removed during the fetch.
1705
- */
1706
- async refreshAutoramp(autorampId) {
1707
- const remote = await this.messenger.call('NeoBankService:getAutoramp', autorampId);
1708
- return __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_applyAutorampRemoteSnapshot).call(this, remote, { allowInsert: false });
1709
- }
1710
- /**
1711
- * Refreshes all known local autoramps from MoonPay.
1712
- * Intended for app resume / unlock catch-up when webhooks were missed.
1713
- *
1714
- * @returns Updated autoramp accounts (failed fetches are skipped).
1715
- */
1716
- async refreshAutoramps() {
1717
- const ids = this.state.autoramps.map((autoramp) => autoramp.id);
1718
- const updated = [];
1719
- for (const id of ids) {
1720
- try {
1721
- const account = await this.refreshAutoramp(id);
1722
- if (this.state.autoramps.some((autoramp) => autoramp.id === account.id)) {
1723
- updated.push(account);
1724
- }
1725
- }
1726
- catch {
1727
- // Keep local cursor for this id; continue remaining refreshes.
1728
- }
1729
- }
1730
- return updated;
1731
- }
1732
1400
  /**
1733
1401
  * Starts polling all pending V2 orders at a fixed interval.
1734
1402
  * Each poll cycle iterates orders with non-terminal statuses,
@@ -2018,16 +1686,17 @@ class RampsController extends base_controller_1.BaseController {
2018
1686
  * @param network - The blockchain network identifier.
2019
1687
  * @param paymentMethod - The payment method identifier.
2020
1688
  * @param fiatAmount - The fiat amount as a string.
1689
+ * @param isFeeExcludedFromFiat - Whether Transak charges fees on top.
2021
1690
  * @returns The buy quote with pricing and fee details.
2022
1691
  */
2023
- async transakGetBuyQuote(fiatCurrency, cryptoCurrency, network, paymentMethod, fiatAmount) {
1692
+ async transakGetBuyQuote(fiatCurrency, cryptoCurrency, network, paymentMethod, fiatAmount, isFeeExcludedFromFiat = false) {
2024
1693
  this.update((state) => {
2025
1694
  state.nativeProviders.transak.buyQuote.isLoading = true;
2026
1695
  state.nativeProviders.transak.buyQuote.error = null;
2027
1696
  delete state.nativeProviders.transak.buyQuote.errorKey;
2028
1697
  });
2029
1698
  try {
2030
- const quote = await this.messenger.call('TransakService:getBuyQuote', fiatCurrency, cryptoCurrency, network, paymentMethod, fiatAmount);
1699
+ const quote = await this.messenger.call('TransakService:getBuyQuote', fiatCurrency, cryptoCurrency, network, paymentMethod, fiatAmount, isFeeExcludedFromFiat);
2031
1700
  this.update((state) => {
2032
1701
  state.nativeProviders.transak.buyQuote.data = quote;
2033
1702
  state.nativeProviders.transak.buyQuote.isLoading = false;
@@ -2688,30 +2357,6 @@ async function _RampsController_resolveProviderIdsForPaymentMethods({ assetId, r
2688
2357
  }
2689
2358
  }
2690
2359
  return orderedIds;
2691
- }, _RampsController_applyAutorampRemoteSnapshot = function _RampsController_applyAutorampRemoteSnapshot(remote, { allowInsert = true } = {}) {
2692
- const local = this.state.autoramps.find((autoramp) => autoramp.id === remote.id) ??
2693
- null;
2694
- if (local === null && !allowInsert) {
2695
- return (0, autorampAccount_js_1.applyAutorampRemoteStatus)(null, remote).account;
2696
- }
2697
- const result = (0, autorampAccount_js_1.applyAutorampRemoteStatus)(local, remote);
2698
- this.update((state) => {
2699
- const idx = state.autoramps.findIndex((autoramp) => autoramp.id === result.account.id);
2700
- if (idx === -1) {
2701
- state.autoramps.push(result.account);
2702
- }
2703
- else {
2704
- state.autoramps[idx] = result.account;
2705
- }
2706
- });
2707
- if (result.statusChanged) {
2708
- this.messenger.publish('RampsController:autorampStatusChanged', {
2709
- autoramp: result.account,
2710
- previousStatus: result.previousStatus,
2711
- shouldNotify: result.shouldNotify,
2712
- });
2713
- }
2714
- return (this.state.autoramps.find((autoramp) => autoramp.id === result.account.id) ?? result.account);
2715
2360
  }, _RampsController_refreshOrder =
2716
2361
  /**
2717
2362
  * Refreshes a single order via the V2 API and updates it in state.