@metamask/ramps-controller 16.0.0 → 17.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.
Files changed (90) hide show
  1. package/CHANGELOG.md +34 -1
  2. package/dist/RampsController-method-action-types.cjs.map +1 -1
  3. package/dist/RampsController-method-action-types.d.cts +15 -1
  4. package/dist/RampsController-method-action-types.d.cts.map +1 -1
  5. package/dist/RampsController-method-action-types.d.mts +15 -1
  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 +90 -97
  9. package/dist/RampsController.cjs.map +1 -1
  10. package/dist/RampsController.d.cts +22 -28
  11. package/dist/RampsController.d.cts.map +1 -1
  12. package/dist/RampsController.d.mts +22 -28
  13. package/dist/RampsController.d.mts.map +1 -1
  14. package/dist/RampsController.mjs +63 -70
  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.map +1 -1
  18. package/dist/RampsService-method-action-types.d.mts.map +1 -1
  19. package/dist/RampsService-method-action-types.mjs.map +1 -1
  20. package/dist/RampsService.cjs.map +1 -1
  21. package/dist/RampsService.d.cts.map +1 -1
  22. package/dist/RampsService.d.mts.map +1 -1
  23. package/dist/RampsService.mjs.map +1 -1
  24. package/dist/RequestCache.cjs.map +1 -1
  25. package/dist/RequestCache.d.cts.map +1 -1
  26. package/dist/RequestCache.d.mts.map +1 -1
  27. package/dist/RequestCache.mjs.map +1 -1
  28. package/dist/TransakService-method-action-types.cjs.map +1 -1
  29. package/dist/TransakService-method-action-types.d.cts +35 -1
  30. package/dist/TransakService-method-action-types.d.cts.map +1 -1
  31. package/dist/TransakService-method-action-types.d.mts +35 -1
  32. package/dist/TransakService-method-action-types.d.mts.map +1 -1
  33. package/dist/TransakService-method-action-types.mjs.map +1 -1
  34. package/dist/TransakService.cjs +128 -12
  35. package/dist/TransakService.cjs.map +1 -1
  36. package/dist/TransakService.d.cts +41 -3
  37. package/dist/TransakService.d.cts.map +1 -1
  38. package/dist/TransakService.d.mts +41 -3
  39. package/dist/TransakService.d.mts.map +1 -1
  40. package/dist/TransakService.mjs +123 -10
  41. package/dist/TransakService.mjs.map +1 -1
  42. package/dist/errorNormalization.cjs +84 -0
  43. package/dist/errorNormalization.cjs.map +1 -0
  44. package/dist/errorNormalization.d.cts +56 -0
  45. package/dist/errorNormalization.d.cts.map +1 -0
  46. package/dist/errorNormalization.d.mts +56 -0
  47. package/dist/errorNormalization.d.mts.map +1 -0
  48. package/dist/errorNormalization.mjs +78 -0
  49. package/dist/errorNormalization.mjs.map +1 -0
  50. package/dist/featureFlags.cjs +39 -0
  51. package/dist/featureFlags.cjs.map +1 -0
  52. package/dist/featureFlags.d.cts +40 -0
  53. package/dist/featureFlags.d.cts.map +1 -0
  54. package/dist/featureFlags.d.mts +40 -0
  55. package/dist/featureFlags.d.mts.map +1 -0
  56. package/dist/featureFlags.mjs +35 -0
  57. package/dist/featureFlags.mjs.map +1 -0
  58. package/dist/index.cjs +49 -33
  59. package/dist/index.cjs.map +1 -1
  60. package/dist/index.d.cts +8 -2
  61. package/dist/index.d.cts.map +1 -1
  62. package/dist/index.d.mts +8 -2
  63. package/dist/index.d.mts.map +1 -1
  64. package/dist/index.mjs +4 -0
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/providerAvailability.cjs +103 -0
  67. package/dist/providerAvailability.cjs.map +1 -0
  68. package/dist/providerAvailability.d.cts +76 -0
  69. package/dist/providerAvailability.d.cts.map +1 -0
  70. package/dist/providerAvailability.d.mts +76 -0
  71. package/dist/providerAvailability.d.mts.map +1 -0
  72. package/dist/providerAvailability.mjs +96 -0
  73. package/dist/providerAvailability.mjs.map +1 -0
  74. package/dist/quoteClassification.cjs +44 -0
  75. package/dist/quoteClassification.cjs.map +1 -0
  76. package/dist/quoteClassification.d.cts +33 -0
  77. package/dist/quoteClassification.d.cts.map +1 -0
  78. package/dist/quoteClassification.d.mts +33 -0
  79. package/dist/quoteClassification.d.mts.map +1 -0
  80. package/dist/quoteClassification.mjs +38 -0
  81. package/dist/quoteClassification.mjs.map +1 -0
  82. package/dist/selectors.cjs +3 -3
  83. package/dist/selectors.cjs.map +1 -1
  84. package/dist/selectors.d.cts.map +1 -1
  85. package/dist/selectors.d.mts.map +1 -1
  86. package/dist/selectors.mjs.map +1 -1
  87. package/dist/transakApiErrorUtils.cjs +5 -5
  88. package/dist/transakApiErrorUtils.cjs.map +1 -1
  89. package/dist/transakApiErrorUtils.mjs.map +1 -1
  90. package/package.json +10 -7
@@ -0,0 +1,76 @@
1
+ import type { Provider } from "./RampsService.cjs";
2
+ /**
3
+ * Whether a provider serves the given deposit asset.
4
+ *
5
+ * Mirrors the region-provider matching the controller performs internally: a
6
+ * provider serves the asset when its `supportedCryptoCurrencies` map (keyed by
7
+ * CAIP-19 asset id) contains the asset id, compared case-insensitively on both
8
+ * sides. EVM CAIP-19 asset ids may arrive checksummed or lowercased and the
9
+ * providers API returns both forms, so only the lowercased forms are compared.
10
+ * A provider without a `supportedCryptoCurrencies` map is treated as not
11
+ * serving the asset.
12
+ *
13
+ * @param provider - The provider to test.
14
+ * @param assetId - CAIP-19 asset id of the deposit asset.
15
+ * @returns Whether the provider serves the asset.
16
+ */
17
+ export declare function providerServesAsset(provider: Provider, assetId: string): boolean;
18
+ /**
19
+ * Filters a provider list down to those serving the given deposit asset.
20
+ *
21
+ * @param providers - The providers to filter.
22
+ * @param assetId - CAIP-19 asset id of the deposit asset.
23
+ * @returns The subset of providers serving the asset.
24
+ */
25
+ export declare function getProvidersServingAsset(providers: Provider[], assetId: string): Provider[];
26
+ /**
27
+ * Whether a region offers a usable on-ramp provider that serves the given
28
+ * deposit asset, under the all-providers feature flag. This is the pure,
29
+ * asset-aware region gate shared between the controller and headless-buy
30
+ * consumers so the two never disagree about eligibility.
31
+ *
32
+ * With `allProvidersEnabled` false the gate is native-only: the region must
33
+ * offer a native provider (e.g. Transak Native) that serves the asset. With
34
+ * `allProvidersEnabled` true the region is supported when any provider
35
+ * (native or aggregator) serves the asset; the controller's flag-aware
36
+ * `getQuotes` performs the precise provider selection at quote time. Fails
37
+ * closed: an empty or missing `assetId` returns `false`.
38
+ *
39
+ * @param options - The options.
40
+ * @param options.providers - The region's providers (native and aggregator).
41
+ * @param options.assetId - CAIP-19 asset id of the deposit asset.
42
+ * @param options.allProvidersEnabled - Whether the all-providers feature flag
43
+ * is enabled (see `isHeadlessAllProvidersEnabled`).
44
+ * @returns Whether the region has a provider serving the asset.
45
+ */
46
+ export declare function regionHasProviderForAsset({ providers, assetId, allProvidersEnabled, }: {
47
+ providers: Provider[];
48
+ assetId: string;
49
+ allProvidersEnabled: boolean;
50
+ }): boolean;
51
+ /**
52
+ * Whether headless fiat deposit is available for the current region, under
53
+ * the all-providers feature flag. Flag-aware and independent of which single
54
+ * provider is currently selected once widened, so the availability gate
55
+ * cannot disagree with the controller's own flag-aware provider pick.
56
+ *
57
+ * With `allProvidersEnabled` false the check keeps the native-only behaviour:
58
+ * a native provider must be the currently selected (preferred) one, since the
59
+ * controller resolves the selected provider first and an aggregator preferred
60
+ * provider would otherwise run a non-native deposit. With
61
+ * `allProvidersEnabled` true the flow is available whenever the region has
62
+ * any provider.
63
+ *
64
+ * @param options - The options.
65
+ * @param options.providers - The region's providers.
66
+ * @param options.selectedProvider - The currently selected provider, if any.
67
+ * @param options.allProvidersEnabled - Whether the all-providers feature flag
68
+ * is enabled (see `isHeadlessAllProvidersEnabled`).
69
+ * @returns Whether headless fiat deposit is available.
70
+ */
71
+ export declare function isFiatDepositAvailable({ providers, selectedProvider, allProvidersEnabled, }: {
72
+ providers: Provider[];
73
+ selectedProvider?: Provider | null;
74
+ allProvidersEnabled: boolean;
75
+ }): boolean;
76
+ //# sourceMappingURL=providerAvailability.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providerAvailability.d.cts","sourceRoot":"","sources":["../src/providerAvailability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,2BAA0B;AAElD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAOT;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,QAAQ,EAAE,EACrB,OAAO,EAAE,MAAM,GACd,QAAQ,EAAE,CAEZ;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,SAAS,EACT,OAAO,EACP,mBAAmB,GACpB,EAAE;IACD,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,GAAG,OAAO,CAYV;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,SAAS,EACT,gBAAgB,EAChB,mBAAmB,GACpB,EAAE;IACD,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,gBAAgB,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IACnC,mBAAmB,EAAE,OAAO,CAAC;CAC9B,GAAG,OAAO,CAQV"}
@@ -0,0 +1,76 @@
1
+ import type { Provider } from "./RampsService.mjs";
2
+ /**
3
+ * Whether a provider serves the given deposit asset.
4
+ *
5
+ * Mirrors the region-provider matching the controller performs internally: a
6
+ * provider serves the asset when its `supportedCryptoCurrencies` map (keyed by
7
+ * CAIP-19 asset id) contains the asset id, compared case-insensitively on both
8
+ * sides. EVM CAIP-19 asset ids may arrive checksummed or lowercased and the
9
+ * providers API returns both forms, so only the lowercased forms are compared.
10
+ * A provider without a `supportedCryptoCurrencies` map is treated as not
11
+ * serving the asset.
12
+ *
13
+ * @param provider - The provider to test.
14
+ * @param assetId - CAIP-19 asset id of the deposit asset.
15
+ * @returns Whether the provider serves the asset.
16
+ */
17
+ export declare function providerServesAsset(provider: Provider, assetId: string): boolean;
18
+ /**
19
+ * Filters a provider list down to those serving the given deposit asset.
20
+ *
21
+ * @param providers - The providers to filter.
22
+ * @param assetId - CAIP-19 asset id of the deposit asset.
23
+ * @returns The subset of providers serving the asset.
24
+ */
25
+ export declare function getProvidersServingAsset(providers: Provider[], assetId: string): Provider[];
26
+ /**
27
+ * Whether a region offers a usable on-ramp provider that serves the given
28
+ * deposit asset, under the all-providers feature flag. This is the pure,
29
+ * asset-aware region gate shared between the controller and headless-buy
30
+ * consumers so the two never disagree about eligibility.
31
+ *
32
+ * With `allProvidersEnabled` false the gate is native-only: the region must
33
+ * offer a native provider (e.g. Transak Native) that serves the asset. With
34
+ * `allProvidersEnabled` true the region is supported when any provider
35
+ * (native or aggregator) serves the asset; the controller's flag-aware
36
+ * `getQuotes` performs the precise provider selection at quote time. Fails
37
+ * closed: an empty or missing `assetId` returns `false`.
38
+ *
39
+ * @param options - The options.
40
+ * @param options.providers - The region's providers (native and aggregator).
41
+ * @param options.assetId - CAIP-19 asset id of the deposit asset.
42
+ * @param options.allProvidersEnabled - Whether the all-providers feature flag
43
+ * is enabled (see `isHeadlessAllProvidersEnabled`).
44
+ * @returns Whether the region has a provider serving the asset.
45
+ */
46
+ export declare function regionHasProviderForAsset({ providers, assetId, allProvidersEnabled, }: {
47
+ providers: Provider[];
48
+ assetId: string;
49
+ allProvidersEnabled: boolean;
50
+ }): boolean;
51
+ /**
52
+ * Whether headless fiat deposit is available for the current region, under
53
+ * the all-providers feature flag. Flag-aware and independent of which single
54
+ * provider is currently selected once widened, so the availability gate
55
+ * cannot disagree with the controller's own flag-aware provider pick.
56
+ *
57
+ * With `allProvidersEnabled` false the check keeps the native-only behaviour:
58
+ * a native provider must be the currently selected (preferred) one, since the
59
+ * controller resolves the selected provider first and an aggregator preferred
60
+ * provider would otherwise run a non-native deposit. With
61
+ * `allProvidersEnabled` true the flow is available whenever the region has
62
+ * any provider.
63
+ *
64
+ * @param options - The options.
65
+ * @param options.providers - The region's providers.
66
+ * @param options.selectedProvider - The currently selected provider, if any.
67
+ * @param options.allProvidersEnabled - Whether the all-providers feature flag
68
+ * is enabled (see `isHeadlessAllProvidersEnabled`).
69
+ * @returns Whether headless fiat deposit is available.
70
+ */
71
+ export declare function isFiatDepositAvailable({ providers, selectedProvider, allProvidersEnabled, }: {
72
+ providers: Provider[];
73
+ selectedProvider?: Provider | null;
74
+ allProvidersEnabled: boolean;
75
+ }): boolean;
76
+ //# sourceMappingURL=providerAvailability.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providerAvailability.d.mts","sourceRoot":"","sources":["../src/providerAvailability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,2BAA0B;AAElD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAOT;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,QAAQ,EAAE,EACrB,OAAO,EAAE,MAAM,GACd,QAAQ,EAAE,CAEZ;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,SAAS,EACT,OAAO,EACP,mBAAmB,GACpB,EAAE;IACD,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,GAAG,OAAO,CAYV;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,SAAS,EACT,gBAAgB,EAChB,mBAAmB,GACpB,EAAE;IACD,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,gBAAgB,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IACnC,mBAAmB,EAAE,OAAO,CAAC;CAC9B,GAAG,OAAO,CAQV"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Whether a provider serves the given deposit asset.
3
+ *
4
+ * Mirrors the region-provider matching the controller performs internally: a
5
+ * provider serves the asset when its `supportedCryptoCurrencies` map (keyed by
6
+ * CAIP-19 asset id) contains the asset id, compared case-insensitively on both
7
+ * sides. EVM CAIP-19 asset ids may arrive checksummed or lowercased and the
8
+ * providers API returns both forms, so only the lowercased forms are compared.
9
+ * A provider without a `supportedCryptoCurrencies` map is treated as not
10
+ * serving the asset.
11
+ *
12
+ * @param provider - The provider to test.
13
+ * @param assetId - CAIP-19 asset id of the deposit asset.
14
+ * @returns Whether the provider serves the asset.
15
+ */
16
+ export function providerServesAsset(provider, assetId) {
17
+ const map = provider?.supportedCryptoCurrencies;
18
+ if (!map) {
19
+ return false;
20
+ }
21
+ const target = assetId.toLowerCase();
22
+ return Object.keys(map).some((key) => key.toLowerCase() === target);
23
+ }
24
+ /**
25
+ * Filters a provider list down to those serving the given deposit asset.
26
+ *
27
+ * @param providers - The providers to filter.
28
+ * @param assetId - CAIP-19 asset id of the deposit asset.
29
+ * @returns The subset of providers serving the asset.
30
+ */
31
+ export function getProvidersServingAsset(providers, assetId) {
32
+ return providers.filter((provider) => providerServesAsset(provider, assetId));
33
+ }
34
+ /**
35
+ * Whether a region offers a usable on-ramp provider that serves the given
36
+ * deposit asset, under the all-providers feature flag. This is the pure,
37
+ * asset-aware region gate shared between the controller and headless-buy
38
+ * consumers so the two never disagree about eligibility.
39
+ *
40
+ * With `allProvidersEnabled` false the gate is native-only: the region must
41
+ * offer a native provider (e.g. Transak Native) that serves the asset. With
42
+ * `allProvidersEnabled` true the region is supported when any provider
43
+ * (native or aggregator) serves the asset; the controller's flag-aware
44
+ * `getQuotes` performs the precise provider selection at quote time. Fails
45
+ * closed: an empty or missing `assetId` returns `false`.
46
+ *
47
+ * @param options - The options.
48
+ * @param options.providers - The region's providers (native and aggregator).
49
+ * @param options.assetId - CAIP-19 asset id of the deposit asset.
50
+ * @param options.allProvidersEnabled - Whether the all-providers feature flag
51
+ * is enabled (see `isHeadlessAllProvidersEnabled`).
52
+ * @returns Whether the region has a provider serving the asset.
53
+ */
54
+ export function regionHasProviderForAsset({ providers, assetId, allProvidersEnabled, }) {
55
+ if (!assetId) {
56
+ return false;
57
+ }
58
+ const serving = getProvidersServingAsset(providers, assetId);
59
+ if (serving.some((provider) => provider.type === 'native')) {
60
+ return true;
61
+ }
62
+ if (!allProvidersEnabled) {
63
+ return false;
64
+ }
65
+ return serving.length > 0;
66
+ }
67
+ /**
68
+ * Whether headless fiat deposit is available for the current region, under
69
+ * the all-providers feature flag. Flag-aware and independent of which single
70
+ * provider is currently selected once widened, so the availability gate
71
+ * cannot disagree with the controller's own flag-aware provider pick.
72
+ *
73
+ * With `allProvidersEnabled` false the check keeps the native-only behaviour:
74
+ * a native provider must be the currently selected (preferred) one, since the
75
+ * controller resolves the selected provider first and an aggregator preferred
76
+ * provider would otherwise run a non-native deposit. With
77
+ * `allProvidersEnabled` true the flow is available whenever the region has
78
+ * any provider.
79
+ *
80
+ * @param options - The options.
81
+ * @param options.providers - The region's providers.
82
+ * @param options.selectedProvider - The currently selected provider, if any.
83
+ * @param options.allProvidersEnabled - Whether the all-providers feature flag
84
+ * is enabled (see `isHeadlessAllProvidersEnabled`).
85
+ * @returns Whether headless fiat deposit is available.
86
+ */
87
+ export function isFiatDepositAvailable({ providers, selectedProvider, allProvidersEnabled, }) {
88
+ if (selectedProvider?.type === 'native') {
89
+ return true;
90
+ }
91
+ if (!allProvidersEnabled) {
92
+ return false;
93
+ }
94
+ return providers.length > 0;
95
+ }
96
+ //# sourceMappingURL=providerAvailability.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providerAvailability.mjs","sourceRoot":"","sources":["../src/providerAvailability.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAAkB,EAClB,OAAe;IAEf,MAAM,GAAG,GAAG,QAAQ,EAAE,yBAAyB,CAAC;IAChD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACrC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACtC,SAAqB,EACrB,OAAe;IAEf,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAChF,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,yBAAyB,CAAC,EACxC,SAAS,EACT,OAAO,EACP,mBAAmB,GAKpB;IACC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,OAAO,GAAG,wBAAwB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC7D,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,EAAE,CAAC;QAC3D,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,sBAAsB,CAAC,EACrC,SAAS,EACT,gBAAgB,EAChB,mBAAmB,GAKpB;IACC,IAAI,gBAAgB,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import type { Provider } from './RampsService.js';\n\n/**\n * Whether a provider serves the given deposit asset.\n *\n * Mirrors the region-provider matching the controller performs internally: a\n * provider serves the asset when its `supportedCryptoCurrencies` map (keyed by\n * CAIP-19 asset id) contains the asset id, compared case-insensitively on both\n * sides. EVM CAIP-19 asset ids may arrive checksummed or lowercased and the\n * providers API returns both forms, so only the lowercased forms are compared.\n * A provider without a `supportedCryptoCurrencies` map is treated as not\n * serving the asset.\n *\n * @param provider - The provider to test.\n * @param assetId - CAIP-19 asset id of the deposit asset.\n * @returns Whether the provider serves the asset.\n */\nexport function providerServesAsset(\n provider: Provider,\n assetId: string,\n): boolean {\n const map = provider?.supportedCryptoCurrencies;\n if (!map) {\n return false;\n }\n const target = assetId.toLowerCase();\n return Object.keys(map).some((key) => key.toLowerCase() === target);\n}\n\n/**\n * Filters a provider list down to those serving the given deposit asset.\n *\n * @param providers - The providers to filter.\n * @param assetId - CAIP-19 asset id of the deposit asset.\n * @returns The subset of providers serving the asset.\n */\nexport function getProvidersServingAsset(\n providers: Provider[],\n assetId: string,\n): Provider[] {\n return providers.filter((provider) => providerServesAsset(provider, assetId));\n}\n\n/**\n * Whether a region offers a usable on-ramp provider that serves the given\n * deposit asset, under the all-providers feature flag. This is the pure,\n * asset-aware region gate shared between the controller and headless-buy\n * consumers so the two never disagree about eligibility.\n *\n * With `allProvidersEnabled` false the gate is native-only: the region must\n * offer a native provider (e.g. Transak Native) that serves the asset. With\n * `allProvidersEnabled` true the region is supported when any provider\n * (native or aggregator) serves the asset; the controller's flag-aware\n * `getQuotes` performs the precise provider selection at quote time. Fails\n * closed: an empty or missing `assetId` returns `false`.\n *\n * @param options - The options.\n * @param options.providers - The region's providers (native and aggregator).\n * @param options.assetId - CAIP-19 asset id of the deposit asset.\n * @param options.allProvidersEnabled - Whether the all-providers feature flag\n * is enabled (see `isHeadlessAllProvidersEnabled`).\n * @returns Whether the region has a provider serving the asset.\n */\nexport function regionHasProviderForAsset({\n providers,\n assetId,\n allProvidersEnabled,\n}: {\n providers: Provider[];\n assetId: string;\n allProvidersEnabled: boolean;\n}): boolean {\n if (!assetId) {\n return false;\n }\n const serving = getProvidersServingAsset(providers, assetId);\n if (serving.some((provider) => provider.type === 'native')) {\n return true;\n }\n if (!allProvidersEnabled) {\n return false;\n }\n return serving.length > 0;\n}\n\n/**\n * Whether headless fiat deposit is available for the current region, under\n * the all-providers feature flag. Flag-aware and independent of which single\n * provider is currently selected once widened, so the availability gate\n * cannot disagree with the controller's own flag-aware provider pick.\n *\n * With `allProvidersEnabled` false the check keeps the native-only behaviour:\n * a native provider must be the currently selected (preferred) one, since the\n * controller resolves the selected provider first and an aggregator preferred\n * provider would otherwise run a non-native deposit. With\n * `allProvidersEnabled` true the flow is available whenever the region has\n * any provider.\n *\n * @param options - The options.\n * @param options.providers - The region's providers.\n * @param options.selectedProvider - The currently selected provider, if any.\n * @param options.allProvidersEnabled - Whether the all-providers feature flag\n * is enabled (see `isHeadlessAllProvidersEnabled`).\n * @returns Whether headless fiat deposit is available.\n */\nexport function isFiatDepositAvailable({\n providers,\n selectedProvider,\n allProvidersEnabled,\n}: {\n providers: Provider[];\n selectedProvider?: Provider | null;\n allProvidersEnabled: boolean;\n}): boolean {\n if (selectedProvider?.type === 'native') {\n return true;\n }\n if (!allProvidersEnabled) {\n return false;\n }\n return providers.length > 0;\n}\n"]}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isInAppOnlyQuote = exports.isCustomActionQuote = exports.isExternalBrowserQuote = void 0;
4
+ /**
5
+ * Whether a quote's checkout runs in an external / system browser rather than
6
+ * an in-app WebView. Decided by the per-quote `buyWidget.browser` hint from the
7
+ * quotes API. When the hint is absent the quote is treated as in-app (the
8
+ * caller is responsible for the in-app WebView fail-safe).
9
+ *
10
+ * This is the pure classification only: it deliberately knows nothing about
11
+ * host redirect URLs or deeplink schemes, which stay in the consuming client.
12
+ *
13
+ * @param quote - The quote to classify.
14
+ * @returns Whether the quote uses an external browser.
15
+ */
16
+ function isExternalBrowserQuote(quote) {
17
+ return quote.quote?.buyWidget?.browser === 'IN_APP_OS_BROWSER';
18
+ }
19
+ exports.isExternalBrowserQuote = isExternalBrowserQuote;
20
+ /**
21
+ * Whether a quote is a custom-action ("checkout outside of MetaMask") quote,
22
+ * e.g. PayPal or Robinhood. Reads the inline `isCustomAction` flag, which the
23
+ * wire may carry even though it is absent from the published `Quote` type.
24
+ *
25
+ * @param quote - The quote to classify.
26
+ * @returns Whether the quote is a custom-action quote.
27
+ */
28
+ function isCustomActionQuote(quote) {
29
+ return quote.quote?.isCustomAction === true;
30
+ }
31
+ exports.isCustomActionQuote = isCustomActionQuote;
32
+ /**
33
+ * Whether a quote continues inside an in-app WebView, i.e. it is neither a
34
+ * custom-action quote nor an external-browser quote. This is the Phase 1
35
+ * in-app-only inclusion test.
36
+ *
37
+ * @param quote - The quote to classify.
38
+ * @returns Whether the quote is an in-app WebView quote.
39
+ */
40
+ function isInAppOnlyQuote(quote) {
41
+ return !isCustomActionQuote(quote) && !isExternalBrowserQuote(quote);
42
+ }
43
+ exports.isInAppOnlyQuote = isInAppOnlyQuote;
44
+ //# sourceMappingURL=quoteClassification.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quoteClassification.cjs","sourceRoot":"","sources":["../src/quoteClassification.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;GAWG;AACH,SAAgB,sBAAsB,CAAC,KAAY;IACjD,OAAO,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,KAAK,mBAAmB,CAAC;AACjE,CAAC;AAFD,wDAEC;AAED;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAAC,KAAY;IAC9C,OAAQ,KAAK,CAAC,KAAsC,EAAE,cAAc,KAAK,IAAI,CAAC;AAChF,CAAC;AAFD,kDAEC;AAED;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAAC,KAAY;IAC3C,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC;AAFD,4CAEC","sourcesContent":["import type { Quote } from './RampsService.js';\n\n/**\n * Whether a quote's checkout runs in an external / system browser rather than\n * an in-app WebView. Decided by the per-quote `buyWidget.browser` hint from the\n * quotes API. When the hint is absent the quote is treated as in-app (the\n * caller is responsible for the in-app WebView fail-safe).\n *\n * This is the pure classification only: it deliberately knows nothing about\n * host redirect URLs or deeplink schemes, which stay in the consuming client.\n *\n * @param quote - The quote to classify.\n * @returns Whether the quote uses an external browser.\n */\nexport function isExternalBrowserQuote(quote: Quote): boolean {\n return quote.quote?.buyWidget?.browser === 'IN_APP_OS_BROWSER';\n}\n\n/**\n * Whether a quote is a custom-action (\"checkout outside of MetaMask\") quote,\n * e.g. PayPal or Robinhood. Reads the inline `isCustomAction` flag, which the\n * wire may carry even though it is absent from the published `Quote` type.\n *\n * @param quote - The quote to classify.\n * @returns Whether the quote is a custom-action quote.\n */\nexport function isCustomActionQuote(quote: Quote): boolean {\n return (quote.quote as { isCustomAction?: boolean })?.isCustomAction === true;\n}\n\n/**\n * Whether a quote continues inside an in-app WebView, i.e. it is neither a\n * custom-action quote nor an external-browser quote. This is the Phase 1\n * in-app-only inclusion test.\n *\n * @param quote - The quote to classify.\n * @returns Whether the quote is an in-app WebView quote.\n */\nexport function isInAppOnlyQuote(quote: Quote): boolean {\n return !isCustomActionQuote(quote) && !isExternalBrowserQuote(quote);\n}\n"]}
@@ -0,0 +1,33 @@
1
+ import type { Quote } from "./RampsService.cjs";
2
+ /**
3
+ * Whether a quote's checkout runs in an external / system browser rather than
4
+ * an in-app WebView. Decided by the per-quote `buyWidget.browser` hint from the
5
+ * quotes API. When the hint is absent the quote is treated as in-app (the
6
+ * caller is responsible for the in-app WebView fail-safe).
7
+ *
8
+ * This is the pure classification only: it deliberately knows nothing about
9
+ * host redirect URLs or deeplink schemes, which stay in the consuming client.
10
+ *
11
+ * @param quote - The quote to classify.
12
+ * @returns Whether the quote uses an external browser.
13
+ */
14
+ export declare function isExternalBrowserQuote(quote: Quote): boolean;
15
+ /**
16
+ * Whether a quote is a custom-action ("checkout outside of MetaMask") quote,
17
+ * e.g. PayPal or Robinhood. Reads the inline `isCustomAction` flag, which the
18
+ * wire may carry even though it is absent from the published `Quote` type.
19
+ *
20
+ * @param quote - The quote to classify.
21
+ * @returns Whether the quote is a custom-action quote.
22
+ */
23
+ export declare function isCustomActionQuote(quote: Quote): boolean;
24
+ /**
25
+ * Whether a quote continues inside an in-app WebView, i.e. it is neither a
26
+ * custom-action quote nor an external-browser quote. This is the Phase 1
27
+ * in-app-only inclusion test.
28
+ *
29
+ * @param quote - The quote to classify.
30
+ * @returns Whether the quote is an in-app WebView quote.
31
+ */
32
+ export declare function isInAppOnlyQuote(quote: Quote): boolean;
33
+ //# sourceMappingURL=quoteClassification.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quoteClassification.d.cts","sourceRoot":"","sources":["../src/quoteClassification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,2BAA0B;AAE/C;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAE5D;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAEzD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAEtD"}
@@ -0,0 +1,33 @@
1
+ import type { Quote } from "./RampsService.mjs";
2
+ /**
3
+ * Whether a quote's checkout runs in an external / system browser rather than
4
+ * an in-app WebView. Decided by the per-quote `buyWidget.browser` hint from the
5
+ * quotes API. When the hint is absent the quote is treated as in-app (the
6
+ * caller is responsible for the in-app WebView fail-safe).
7
+ *
8
+ * This is the pure classification only: it deliberately knows nothing about
9
+ * host redirect URLs or deeplink schemes, which stay in the consuming client.
10
+ *
11
+ * @param quote - The quote to classify.
12
+ * @returns Whether the quote uses an external browser.
13
+ */
14
+ export declare function isExternalBrowserQuote(quote: Quote): boolean;
15
+ /**
16
+ * Whether a quote is a custom-action ("checkout outside of MetaMask") quote,
17
+ * e.g. PayPal or Robinhood. Reads the inline `isCustomAction` flag, which the
18
+ * wire may carry even though it is absent from the published `Quote` type.
19
+ *
20
+ * @param quote - The quote to classify.
21
+ * @returns Whether the quote is a custom-action quote.
22
+ */
23
+ export declare function isCustomActionQuote(quote: Quote): boolean;
24
+ /**
25
+ * Whether a quote continues inside an in-app WebView, i.e. it is neither a
26
+ * custom-action quote nor an external-browser quote. This is the Phase 1
27
+ * in-app-only inclusion test.
28
+ *
29
+ * @param quote - The quote to classify.
30
+ * @returns Whether the quote is an in-app WebView quote.
31
+ */
32
+ export declare function isInAppOnlyQuote(quote: Quote): boolean;
33
+ //# sourceMappingURL=quoteClassification.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quoteClassification.d.mts","sourceRoot":"","sources":["../src/quoteClassification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,2BAA0B;AAE/C;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAE5D;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAEzD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAEtD"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Whether a quote's checkout runs in an external / system browser rather than
3
+ * an in-app WebView. Decided by the per-quote `buyWidget.browser` hint from the
4
+ * quotes API. When the hint is absent the quote is treated as in-app (the
5
+ * caller is responsible for the in-app WebView fail-safe).
6
+ *
7
+ * This is the pure classification only: it deliberately knows nothing about
8
+ * host redirect URLs or deeplink schemes, which stay in the consuming client.
9
+ *
10
+ * @param quote - The quote to classify.
11
+ * @returns Whether the quote uses an external browser.
12
+ */
13
+ export function isExternalBrowserQuote(quote) {
14
+ return quote.quote?.buyWidget?.browser === 'IN_APP_OS_BROWSER';
15
+ }
16
+ /**
17
+ * Whether a quote is a custom-action ("checkout outside of MetaMask") quote,
18
+ * e.g. PayPal or Robinhood. Reads the inline `isCustomAction` flag, which the
19
+ * wire may carry even though it is absent from the published `Quote` type.
20
+ *
21
+ * @param quote - The quote to classify.
22
+ * @returns Whether the quote is a custom-action quote.
23
+ */
24
+ export function isCustomActionQuote(quote) {
25
+ return quote.quote?.isCustomAction === true;
26
+ }
27
+ /**
28
+ * Whether a quote continues inside an in-app WebView, i.e. it is neither a
29
+ * custom-action quote nor an external-browser quote. This is the Phase 1
30
+ * in-app-only inclusion test.
31
+ *
32
+ * @param quote - The quote to classify.
33
+ * @returns Whether the quote is an in-app WebView quote.
34
+ */
35
+ export function isInAppOnlyQuote(quote) {
36
+ return !isCustomActionQuote(quote) && !isExternalBrowserQuote(quote);
37
+ }
38
+ //# sourceMappingURL=quoteClassification.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quoteClassification.mjs","sourceRoot":"","sources":["../src/quoteClassification.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAY;IACjD,OAAO,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,KAAK,mBAAmB,CAAC;AACjE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAY;IAC9C,OAAQ,KAAK,CAAC,KAAsC,EAAE,cAAc,KAAK,IAAI,CAAC;AAChF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAY;IAC3C,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import type { Quote } from './RampsService.js';\n\n/**\n * Whether a quote's checkout runs in an external / system browser rather than\n * an in-app WebView. Decided by the per-quote `buyWidget.browser` hint from the\n * quotes API. When the hint is absent the quote is treated as in-app (the\n * caller is responsible for the in-app WebView fail-safe).\n *\n * This is the pure classification only: it deliberately knows nothing about\n * host redirect URLs or deeplink schemes, which stay in the consuming client.\n *\n * @param quote - The quote to classify.\n * @returns Whether the quote uses an external browser.\n */\nexport function isExternalBrowserQuote(quote: Quote): boolean {\n return quote.quote?.buyWidget?.browser === 'IN_APP_OS_BROWSER';\n}\n\n/**\n * Whether a quote is a custom-action (\"checkout outside of MetaMask\") quote,\n * e.g. PayPal or Robinhood. Reads the inline `isCustomAction` flag, which the\n * wire may carry even though it is absent from the published `Quote` type.\n *\n * @param quote - The quote to classify.\n * @returns Whether the quote is a custom-action quote.\n */\nexport function isCustomActionQuote(quote: Quote): boolean {\n return (quote.quote as { isCustomAction?: boolean })?.isCustomAction === true;\n}\n\n/**\n * Whether a quote continues inside an in-app WebView, i.e. it is neither a\n * custom-action quote nor an external-browser quote. This is the Phase 1\n * in-app-only inclusion test.\n *\n * @param quote - The quote to classify.\n * @returns Whether the quote is an in-app WebView quote.\n */\nexport function isInAppOnlyQuote(quote: Quote): boolean {\n return !isCustomActionQuote(quote) && !isExternalBrowserQuote(quote);\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createRequestSelector = void 0;
4
- const RequestCache_1 = require("./RequestCache.cjs");
4
+ const RequestCache_js_1 = require("./RequestCache.cjs");
5
5
  /**
6
6
  * Creates a memoized selector for a controller method's request state.
7
7
  *
@@ -60,7 +60,7 @@ const RequestCache_1 = require("./RequestCache.cjs");
60
60
  * ```
61
61
  */
62
62
  function createRequestSelector(getState, method, params) {
63
- const cacheKey = (0, RequestCache_1.createCacheKey)(method, params);
63
+ const cacheKey = (0, RequestCache_js_1.createCacheKey)(method, params);
64
64
  let lastRequest;
65
65
  let lastResult = null;
66
66
  return (state) => {
@@ -71,7 +71,7 @@ function createRequestSelector(getState, method, params) {
71
71
  lastRequest = request;
72
72
  const nextResult = {
73
73
  data: request?.data ?? null,
74
- isFetching: request?.status === RequestCache_1.RequestStatus.LOADING,
74
+ isFetching: request?.status === RequestCache_js_1.RequestStatus.LOADING,
75
75
  error: request?.error ?? null,
76
76
  };
77
77
  if (request?.errorKey) {
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.cjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":";;;AAGA,qDAA+D;AAoB/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,SAAgB,qBAAqB,CACnC,QAAqE,EACrE,MAAc,EACd,MAAiB;IAEjB,MAAM,QAAQ,GAAG,IAAA,6BAAc,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhD,IAAI,WAAqC,CAAC;IAC1C,IAAI,UAAU,GAAwC,IAAI,CAAC;IAE3D,OAAO,CAAC,KAAiB,EAAgC,EAAE;QACzD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC;QAEtD,IAAI,OAAO,KAAK,WAAW,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YACnD,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,WAAW,GAAG,OAAO,CAAC;QACtB,MAAM,UAAU,GAAiC;YAC/C,IAAI,EAAG,OAAO,EAAE,IAAc,IAAI,IAAI;YACtC,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,4BAAa,CAAC,OAAO;YACrD,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI;SAC9B,CAAC;QAEF,IAAI,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,UAAU,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACzC,CAAC;QAED,UAAU,GAAG,UAAU,CAAC;QAExB,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAhCD,sDAgCC","sourcesContent":["import type { RampsControllerState } from './RampsController';\nimport type { RampsErrorCode } from './rampsErrorCodes';\nimport type { RequestState } from './RequestCache';\nimport { RequestStatus, createCacheKey } from './RequestCache';\n\n/**\n * Result shape returned by request selectors.\n *\n * This object is memoized - the same reference is returned when the underlying\n * request state hasn't changed, making it safe to use with React Redux's\n * `useSelector` without `shallowEqual`.\n */\nexport type RequestSelectorResult<TData> = {\n /** The data returned by the request, or null if not yet loaded or on error. */\n data: TData | null;\n /** Whether the request is currently in progress. */\n isFetching: boolean;\n /** Error message if the request failed, or null if successful or not yet attempted. */\n error: string | null;\n /** Stable error key for client-side localization, if available. */\n errorKey?: RampsErrorCode | null;\n};\n\n/**\n * Creates a memoized selector for a controller method's request state.\n *\n * This selector tracks the loading, error, and data state for a specific\n * controller method call. It's optimized for use with React Redux's `useSelector`\n * hook - the selector returns the same object reference when the underlying\n * request state hasn't changed, so no `shallowEqual` is needed.\n *\n * The selector uses reference equality on the request object itself, so it\n * works correctly with arrays and objects without expensive deep equality checks.\n *\n * @param getState - Function that extracts RampsControllerState from the root state.\n * Typically a reselect selector like `selectRampsControllerState`.\n * @param method - The controller method name (e.g., 'updateUserRegion').\n * @param params - The parameters passed to the method, used to generate the cache key.\n * Must match the params used when calling the controller method.\n * @returns A selector function that returns `{ data, isFetching, error }`.\n *\n * @example\n * ```ts\n * // In selectors file - create once at module level\n * import { createRequestSelector } from '@metamask/ramps-controller';\n * import { createSelector } from 'reselect';\n *\n * const selectRampsControllerState = createSelector(\n * (state: RootState) => state.engine.backgroundState.RampsController,\n * (rampsControllerState) => rampsControllerState,\n * );\n *\n * export const selectUserRegionRequest = createRequestSelector<\n * RootState,\n * string\n * >(selectRampsControllerState, 'updateUserRegion', []);\n *\n * // In hook - use directly with useSelector, no shallowEqual needed\n * export function useRampsUserRegion() {\n * const { isFetching, error } = useSelector(selectUserRegionRequest);\n * // ... rest of hook\n * }\n * ```\n *\n * @example\n * ```ts\n * // For methods with parameters\n * export const selectCryptoCurrenciesRequest = (region: string) =>\n * createRequestSelector<RootState, CryptoCurrency[]>(\n * selectRampsControllerState,\n * 'getCryptoCurrencies',\n * [region],\n * );\n *\n * // In component\n * const { data, isFetching, error } = useSelector(\n * selectCryptoCurrenciesRequest('US')\n * );\n * ```\n */\nexport function createRequestSelector<TRootState, TData>(\n getState: (rootState: TRootState) => RampsControllerState | undefined,\n method: string,\n params: unknown[],\n): (state: TRootState) => RequestSelectorResult<TData> {\n const cacheKey = createCacheKey(method, params);\n\n let lastRequest: RequestState | undefined;\n let lastResult: RequestSelectorResult<TData> | null = null;\n\n return (state: TRootState): RequestSelectorResult<TData> => {\n const request = getState(state)?.requests?.[cacheKey];\n\n if (request === lastRequest && lastResult !== null) {\n return lastResult;\n }\n\n lastRequest = request;\n const nextResult: RequestSelectorResult<TData> = {\n data: (request?.data as TData) ?? null,\n isFetching: request?.status === RequestStatus.LOADING,\n error: request?.error ?? null,\n };\n\n if (request?.errorKey) {\n nextResult.errorKey = request.errorKey;\n }\n\n lastResult = nextResult;\n\n return lastResult;\n };\n}\n"]}
1
+ {"version":3,"file":"selectors.cjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":";;;AAGA,wDAAkE;AAoBlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,SAAgB,qBAAqB,CACnC,QAAqE,EACrE,MAAc,EACd,MAAiB;IAEjB,MAAM,QAAQ,GAAG,IAAA,gCAAc,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhD,IAAI,WAAqC,CAAC;IAC1C,IAAI,UAAU,GAAwC,IAAI,CAAC;IAE3D,OAAO,CAAC,KAAiB,EAAgC,EAAE;QACzD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC;QAEtD,IAAI,OAAO,KAAK,WAAW,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YACnD,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,WAAW,GAAG,OAAO,CAAC;QACtB,MAAM,UAAU,GAAiC;YAC/C,IAAI,EAAG,OAAO,EAAE,IAAc,IAAI,IAAI;YACtC,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,+BAAa,CAAC,OAAO;YACrD,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI;SAC9B,CAAC;QAEF,IAAI,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,UAAU,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACzC,CAAC;QAED,UAAU,GAAG,UAAU,CAAC;QAExB,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAhCD,sDAgCC","sourcesContent":["import type { RampsControllerState } from './RampsController.js';\nimport type { RampsErrorCode } from './rampsErrorCodes.js';\nimport type { RequestState } from './RequestCache.js';\nimport { RequestStatus, createCacheKey } from './RequestCache.js';\n\n/**\n * Result shape returned by request selectors.\n *\n * This object is memoized - the same reference is returned when the underlying\n * request state hasn't changed, making it safe to use with React Redux's\n * `useSelector` without `shallowEqual`.\n */\nexport type RequestSelectorResult<TData> = {\n /** The data returned by the request, or null if not yet loaded or on error. */\n data: TData | null;\n /** Whether the request is currently in progress. */\n isFetching: boolean;\n /** Error message if the request failed, or null if successful or not yet attempted. */\n error: string | null;\n /** Stable error key for client-side localization, if available. */\n errorKey?: RampsErrorCode | null;\n};\n\n/**\n * Creates a memoized selector for a controller method's request state.\n *\n * This selector tracks the loading, error, and data state for a specific\n * controller method call. It's optimized for use with React Redux's `useSelector`\n * hook - the selector returns the same object reference when the underlying\n * request state hasn't changed, so no `shallowEqual` is needed.\n *\n * The selector uses reference equality on the request object itself, so it\n * works correctly with arrays and objects without expensive deep equality checks.\n *\n * @param getState - Function that extracts RampsControllerState from the root state.\n * Typically a reselect selector like `selectRampsControllerState`.\n * @param method - The controller method name (e.g., 'updateUserRegion').\n * @param params - The parameters passed to the method, used to generate the cache key.\n * Must match the params used when calling the controller method.\n * @returns A selector function that returns `{ data, isFetching, error }`.\n *\n * @example\n * ```ts\n * // In selectors file - create once at module level\n * import { createRequestSelector } from '@metamask/ramps-controller';\n * import { createSelector } from 'reselect';\n *\n * const selectRampsControllerState = createSelector(\n * (state: RootState) => state.engine.backgroundState.RampsController,\n * (rampsControllerState) => rampsControllerState,\n * );\n *\n * export const selectUserRegionRequest = createRequestSelector<\n * RootState,\n * string\n * >(selectRampsControllerState, 'updateUserRegion', []);\n *\n * // In hook - use directly with useSelector, no shallowEqual needed\n * export function useRampsUserRegion() {\n * const { isFetching, error } = useSelector(selectUserRegionRequest);\n * // ... rest of hook\n * }\n * ```\n *\n * @example\n * ```ts\n * // For methods with parameters\n * export const selectCryptoCurrenciesRequest = (region: string) =>\n * createRequestSelector<RootState, CryptoCurrency[]>(\n * selectRampsControllerState,\n * 'getCryptoCurrencies',\n * [region],\n * );\n *\n * // In component\n * const { data, isFetching, error } = useSelector(\n * selectCryptoCurrenciesRequest('US')\n * );\n * ```\n */\nexport function createRequestSelector<TRootState, TData>(\n getState: (rootState: TRootState) => RampsControllerState | undefined,\n method: string,\n params: unknown[],\n): (state: TRootState) => RequestSelectorResult<TData> {\n const cacheKey = createCacheKey(method, params);\n\n let lastRequest: RequestState | undefined;\n let lastResult: RequestSelectorResult<TData> | null = null;\n\n return (state: TRootState): RequestSelectorResult<TData> => {\n const request = getState(state)?.requests?.[cacheKey];\n\n if (request === lastRequest && lastResult !== null) {\n return lastResult;\n }\n\n lastRequest = request;\n const nextResult: RequestSelectorResult<TData> = {\n data: (request?.data as TData) ?? null,\n isFetching: request?.status === RequestStatus.LOADING,\n error: request?.error ?? null,\n };\n\n if (request?.errorKey) {\n nextResult.errorKey = request.errorKey;\n }\n\n lastResult = nextResult;\n\n return lastResult;\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.d.cts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,8BAA0B;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA0B;AAIxD;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,CAAC,KAAK,IAAI;IACzC,+EAA+E;IAC/E,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IACnB,oDAAoD;IACpD,UAAU,EAAE,OAAO,CAAC;IACpB,uFAAuF;IACvF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,KAAK,EACrD,QAAQ,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,oBAAoB,GAAG,SAAS,EACrE,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,EAAE,GAChB,CAAC,KAAK,EAAE,UAAU,KAAK,qBAAqB,CAAC,KAAK,CAAC,CA4BrD"}
1
+ {"version":3,"file":"selectors.d.cts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,8BAA6B;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA6B;AAI3D;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,CAAC,KAAK,IAAI;IACzC,+EAA+E;IAC/E,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IACnB,oDAAoD;IACpD,UAAU,EAAE,OAAO,CAAC;IACpB,uFAAuF;IACvF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,KAAK,EACrD,QAAQ,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,oBAAoB,GAAG,SAAS,EACrE,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,EAAE,GAChB,CAAC,KAAK,EAAE,UAAU,KAAK,qBAAqB,CAAC,KAAK,CAAC,CA4BrD"}
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.d.mts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,8BAA0B;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA0B;AAIxD;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,CAAC,KAAK,IAAI;IACzC,+EAA+E;IAC/E,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IACnB,oDAAoD;IACpD,UAAU,EAAE,OAAO,CAAC;IACpB,uFAAuF;IACvF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,KAAK,EACrD,QAAQ,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,oBAAoB,GAAG,SAAS,EACrE,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,EAAE,GAChB,CAAC,KAAK,EAAE,UAAU,KAAK,qBAAqB,CAAC,KAAK,CAAC,CA4BrD"}
1
+ {"version":3,"file":"selectors.d.mts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,8BAA6B;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA6B;AAI3D;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,CAAC,KAAK,IAAI;IACzC,+EAA+E;IAC/E,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IACnB,oDAAoD;IACpD,UAAU,EAAE,OAAO,CAAC;IACpB,uFAAuF;IACvF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,KAAK,EACrD,QAAQ,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,oBAAoB,GAAG,SAAS,EACrE,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,EAAE,GAChB,CAAC,KAAK,EAAE,UAAU,KAAK,qBAAqB,CAAC,KAAK,CAAC,CA4BrD"}
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.mjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,2BAAuB;AAoB/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAqE,EACrE,MAAc,EACd,MAAiB;IAEjB,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhD,IAAI,WAAqC,CAAC;IAC1C,IAAI,UAAU,GAAwC,IAAI,CAAC;IAE3D,OAAO,CAAC,KAAiB,EAAgC,EAAE;QACzD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC;QAEtD,IAAI,OAAO,KAAK,WAAW,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YACnD,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,WAAW,GAAG,OAAO,CAAC;QACtB,MAAM,UAAU,GAAiC;YAC/C,IAAI,EAAG,OAAO,EAAE,IAAc,IAAI,IAAI;YACtC,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,aAAa,CAAC,OAAO;YACrD,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI;SAC9B,CAAC;QAEF,IAAI,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,UAAU,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACzC,CAAC;QAED,UAAU,GAAG,UAAU,CAAC;QAExB,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { RampsControllerState } from './RampsController';\nimport type { RampsErrorCode } from './rampsErrorCodes';\nimport type { RequestState } from './RequestCache';\nimport { RequestStatus, createCacheKey } from './RequestCache';\n\n/**\n * Result shape returned by request selectors.\n *\n * This object is memoized - the same reference is returned when the underlying\n * request state hasn't changed, making it safe to use with React Redux's\n * `useSelector` without `shallowEqual`.\n */\nexport type RequestSelectorResult<TData> = {\n /** The data returned by the request, or null if not yet loaded or on error. */\n data: TData | null;\n /** Whether the request is currently in progress. */\n isFetching: boolean;\n /** Error message if the request failed, or null if successful or not yet attempted. */\n error: string | null;\n /** Stable error key for client-side localization, if available. */\n errorKey?: RampsErrorCode | null;\n};\n\n/**\n * Creates a memoized selector for a controller method's request state.\n *\n * This selector tracks the loading, error, and data state for a specific\n * controller method call. It's optimized for use with React Redux's `useSelector`\n * hook - the selector returns the same object reference when the underlying\n * request state hasn't changed, so no `shallowEqual` is needed.\n *\n * The selector uses reference equality on the request object itself, so it\n * works correctly with arrays and objects without expensive deep equality checks.\n *\n * @param getState - Function that extracts RampsControllerState from the root state.\n * Typically a reselect selector like `selectRampsControllerState`.\n * @param method - The controller method name (e.g., 'updateUserRegion').\n * @param params - The parameters passed to the method, used to generate the cache key.\n * Must match the params used when calling the controller method.\n * @returns A selector function that returns `{ data, isFetching, error }`.\n *\n * @example\n * ```ts\n * // In selectors file - create once at module level\n * import { createRequestSelector } from '@metamask/ramps-controller';\n * import { createSelector } from 'reselect';\n *\n * const selectRampsControllerState = createSelector(\n * (state: RootState) => state.engine.backgroundState.RampsController,\n * (rampsControllerState) => rampsControllerState,\n * );\n *\n * export const selectUserRegionRequest = createRequestSelector<\n * RootState,\n * string\n * >(selectRampsControllerState, 'updateUserRegion', []);\n *\n * // In hook - use directly with useSelector, no shallowEqual needed\n * export function useRampsUserRegion() {\n * const { isFetching, error } = useSelector(selectUserRegionRequest);\n * // ... rest of hook\n * }\n * ```\n *\n * @example\n * ```ts\n * // For methods with parameters\n * export const selectCryptoCurrenciesRequest = (region: string) =>\n * createRequestSelector<RootState, CryptoCurrency[]>(\n * selectRampsControllerState,\n * 'getCryptoCurrencies',\n * [region],\n * );\n *\n * // In component\n * const { data, isFetching, error } = useSelector(\n * selectCryptoCurrenciesRequest('US')\n * );\n * ```\n */\nexport function createRequestSelector<TRootState, TData>(\n getState: (rootState: TRootState) => RampsControllerState | undefined,\n method: string,\n params: unknown[],\n): (state: TRootState) => RequestSelectorResult<TData> {\n const cacheKey = createCacheKey(method, params);\n\n let lastRequest: RequestState | undefined;\n let lastResult: RequestSelectorResult<TData> | null = null;\n\n return (state: TRootState): RequestSelectorResult<TData> => {\n const request = getState(state)?.requests?.[cacheKey];\n\n if (request === lastRequest && lastResult !== null) {\n return lastResult;\n }\n\n lastRequest = request;\n const nextResult: RequestSelectorResult<TData> = {\n data: (request?.data as TData) ?? null,\n isFetching: request?.status === RequestStatus.LOADING,\n error: request?.error ?? null,\n };\n\n if (request?.errorKey) {\n nextResult.errorKey = request.errorKey;\n }\n\n lastResult = nextResult;\n\n return lastResult;\n };\n}\n"]}
1
+ {"version":3,"file":"selectors.mjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,2BAA0B;AAoBlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAqE,EACrE,MAAc,EACd,MAAiB;IAEjB,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhD,IAAI,WAAqC,CAAC;IAC1C,IAAI,UAAU,GAAwC,IAAI,CAAC;IAE3D,OAAO,CAAC,KAAiB,EAAgC,EAAE;QACzD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC;QAEtD,IAAI,OAAO,KAAK,WAAW,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YACnD,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,WAAW,GAAG,OAAO,CAAC;QACtB,MAAM,UAAU,GAAiC;YAC/C,IAAI,EAAG,OAAO,EAAE,IAAc,IAAI,IAAI;YACtC,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,aAAa,CAAC,OAAO;YACrD,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI;SAC9B,CAAC;QAEF,IAAI,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,UAAU,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACzC,CAAC;QAED,UAAU,GAAG,UAAU,CAAC;QAExB,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { RampsControllerState } from './RampsController.js';\nimport type { RampsErrorCode } from './rampsErrorCodes.js';\nimport type { RequestState } from './RequestCache.js';\nimport { RequestStatus, createCacheKey } from './RequestCache.js';\n\n/**\n * Result shape returned by request selectors.\n *\n * This object is memoized - the same reference is returned when the underlying\n * request state hasn't changed, making it safe to use with React Redux's\n * `useSelector` without `shallowEqual`.\n */\nexport type RequestSelectorResult<TData> = {\n /** The data returned by the request, or null if not yet loaded or on error. */\n data: TData | null;\n /** Whether the request is currently in progress. */\n isFetching: boolean;\n /** Error message if the request failed, or null if successful or not yet attempted. */\n error: string | null;\n /** Stable error key for client-side localization, if available. */\n errorKey?: RampsErrorCode | null;\n};\n\n/**\n * Creates a memoized selector for a controller method's request state.\n *\n * This selector tracks the loading, error, and data state for a specific\n * controller method call. It's optimized for use with React Redux's `useSelector`\n * hook - the selector returns the same object reference when the underlying\n * request state hasn't changed, so no `shallowEqual` is needed.\n *\n * The selector uses reference equality on the request object itself, so it\n * works correctly with arrays and objects without expensive deep equality checks.\n *\n * @param getState - Function that extracts RampsControllerState from the root state.\n * Typically a reselect selector like `selectRampsControllerState`.\n * @param method - The controller method name (e.g., 'updateUserRegion').\n * @param params - The parameters passed to the method, used to generate the cache key.\n * Must match the params used when calling the controller method.\n * @returns A selector function that returns `{ data, isFetching, error }`.\n *\n * @example\n * ```ts\n * // In selectors file - create once at module level\n * import { createRequestSelector } from '@metamask/ramps-controller';\n * import { createSelector } from 'reselect';\n *\n * const selectRampsControllerState = createSelector(\n * (state: RootState) => state.engine.backgroundState.RampsController,\n * (rampsControllerState) => rampsControllerState,\n * );\n *\n * export const selectUserRegionRequest = createRequestSelector<\n * RootState,\n * string\n * >(selectRampsControllerState, 'updateUserRegion', []);\n *\n * // In hook - use directly with useSelector, no shallowEqual needed\n * export function useRampsUserRegion() {\n * const { isFetching, error } = useSelector(selectUserRegionRequest);\n * // ... rest of hook\n * }\n * ```\n *\n * @example\n * ```ts\n * // For methods with parameters\n * export const selectCryptoCurrenciesRequest = (region: string) =>\n * createRequestSelector<RootState, CryptoCurrency[]>(\n * selectRampsControllerState,\n * 'getCryptoCurrencies',\n * [region],\n * );\n *\n * // In component\n * const { data, isFetching, error } = useSelector(\n * selectCryptoCurrenciesRequest('US')\n * );\n * ```\n */\nexport function createRequestSelector<TRootState, TData>(\n getState: (rootState: TRootState) => RampsControllerState | undefined,\n method: string,\n params: unknown[],\n): (state: TRootState) => RequestSelectorResult<TData> {\n const cacheKey = createCacheKey(method, params);\n\n let lastRequest: RequestState | undefined;\n let lastResult: RequestSelectorResult<TData> | null = null;\n\n return (state: TRootState): RequestSelectorResult<TData> => {\n const request = getState(state)?.requests?.[cacheKey];\n\n if (request === lastRequest && lastResult !== null) {\n return lastResult;\n }\n\n lastRequest = request;\n const nextResult: RequestSelectorResult<TData> = {\n data: (request?.data as TData) ?? null,\n isFetching: request?.status === RequestStatus.LOADING,\n error: request?.error ?? null,\n };\n\n if (request?.errorKey) {\n nextResult.errorKey = request.errorKey;\n }\n\n lastResult = nextResult;\n\n return lastResult;\n };\n}\n"]}
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isTransakPhoneRegisteredError = exports.getTransakApiMessage = void 0;
4
- const transakErrorCodes_1 = require("./transakErrorCodes.cjs");
5
- const TransakService_1 = require("./TransakService.cjs");
4
+ const transakErrorCodes_js_1 = require("./transakErrorCodes.cjs");
5
+ const TransakService_js_1 = require("./TransakService.cjs");
6
6
  function getTransakApiMessage(error) {
7
- return error instanceof TransakService_1.TransakApiError ? error.apiMessage : undefined;
7
+ return error instanceof TransakService_js_1.TransakApiError ? error.apiMessage : undefined;
8
8
  }
9
9
  exports.getTransakApiMessage = getTransakApiMessage;
10
10
  function isTransakPhoneRegisteredError(error) {
11
- return (error instanceof TransakService_1.TransakApiError &&
12
- error.errorCode === transakErrorCodes_1.TRANSAK_ERROR_CODES.PHONE_ALREADY_REGISTERED);
11
+ return (error instanceof TransakService_js_1.TransakApiError &&
12
+ error.errorCode === transakErrorCodes_js_1.TRANSAK_ERROR_CODES.PHONE_ALREADY_REGISTERED);
13
13
  }
14
14
  exports.isTransakPhoneRegisteredError = isTransakPhoneRegisteredError;
15
15
  //# sourceMappingURL=transakApiErrorUtils.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"transakApiErrorUtils.cjs","sourceRoot":"","sources":["../src/transakApiErrorUtils.ts"],"names":[],"mappings":";;;AAAA,+DAA0D;AAC1D,yDAAmD;AAEnD,SAAgB,oBAAoB,CAAC,KAAc;IACjD,OAAO,KAAK,YAAY,gCAAe,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;AACzE,CAAC;AAFD,oDAEC;AAED,SAAgB,6BAA6B,CAAC,KAAc;IAC1D,OAAO,CACL,KAAK,YAAY,gCAAe;QAChC,KAAK,CAAC,SAAS,KAAK,uCAAmB,CAAC,wBAAwB,CACjE,CAAC;AACJ,CAAC;AALD,sEAKC","sourcesContent":["import { TRANSAK_ERROR_CODES } from './transakErrorCodes';\nimport { TransakApiError } from './TransakService';\n\nexport function getTransakApiMessage(error: unknown): string | undefined {\n return error instanceof TransakApiError ? error.apiMessage : undefined;\n}\n\nexport function isTransakPhoneRegisteredError(error: unknown): boolean {\n return (\n error instanceof TransakApiError &&\n error.errorCode === TRANSAK_ERROR_CODES.PHONE_ALREADY_REGISTERED\n );\n}\n"]}
1
+ {"version":3,"file":"transakApiErrorUtils.cjs","sourceRoot":"","sources":["../src/transakApiErrorUtils.ts"],"names":[],"mappings":";;;AAAA,kEAA6D;AAC7D,4DAAsD;AAEtD,SAAgB,oBAAoB,CAAC,KAAc;IACjD,OAAO,KAAK,YAAY,mCAAe,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;AACzE,CAAC;AAFD,oDAEC;AAED,SAAgB,6BAA6B,CAAC,KAAc;IAC1D,OAAO,CACL,KAAK,YAAY,mCAAe;QAChC,KAAK,CAAC,SAAS,KAAK,0CAAmB,CAAC,wBAAwB,CACjE,CAAC;AACJ,CAAC;AALD,sEAKC","sourcesContent":["import { TRANSAK_ERROR_CODES } from './transakErrorCodes.js';\nimport { TransakApiError } from './TransakService.js';\n\nexport function getTransakApiMessage(error: unknown): string | undefined {\n return error instanceof TransakApiError ? error.apiMessage : undefined;\n}\n\nexport function isTransakPhoneRegisteredError(error: unknown): boolean {\n return (\n error instanceof TransakApiError &&\n error.errorCode === TRANSAK_ERROR_CODES.PHONE_ALREADY_REGISTERED\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"transakApiErrorUtils.mjs","sourceRoot":"","sources":["../src/transakApiErrorUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,gCAA4B;AAC1D,OAAO,EAAE,eAAe,EAAE,6BAAyB;AAEnD,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,KAAK,YAAY,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,KAAc;IAC1D,OAAO,CACL,KAAK,YAAY,eAAe;QAChC,KAAK,CAAC,SAAS,KAAK,mBAAmB,CAAC,wBAAwB,CACjE,CAAC;AACJ,CAAC","sourcesContent":["import { TRANSAK_ERROR_CODES } from './transakErrorCodes';\nimport { TransakApiError } from './TransakService';\n\nexport function getTransakApiMessage(error: unknown): string | undefined {\n return error instanceof TransakApiError ? error.apiMessage : undefined;\n}\n\nexport function isTransakPhoneRegisteredError(error: unknown): boolean {\n return (\n error instanceof TransakApiError &&\n error.errorCode === TRANSAK_ERROR_CODES.PHONE_ALREADY_REGISTERED\n );\n}\n"]}
1
+ {"version":3,"file":"transakApiErrorUtils.mjs","sourceRoot":"","sources":["../src/transakApiErrorUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,gCAA+B;AAC7D,OAAO,EAAE,eAAe,EAAE,6BAA4B;AAEtD,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,KAAK,YAAY,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,KAAc;IAC1D,OAAO,CACL,KAAK,YAAY,eAAe;QAChC,KAAK,CAAC,SAAS,KAAK,mBAAmB,CAAC,wBAAwB,CACjE,CAAC;AACJ,CAAC","sourcesContent":["import { TRANSAK_ERROR_CODES } from './transakErrorCodes.js';\nimport { TransakApiError } from './TransakService.js';\n\nexport function getTransakApiMessage(error: unknown): string | undefined {\n return error instanceof TransakApiError ? error.apiMessage : undefined;\n}\n\nexport function isTransakPhoneRegisteredError(error: unknown): boolean {\n return (\n error instanceof TransakApiError &&\n error.errorCode === TRANSAK_ERROR_CODES.PHONE_ALREADY_REGISTERED\n );\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/ramps-controller",
3
- "version": "16.0.0",
3
+ "version": "17.1.0",
4
4
  "description": "A controller for managing cryptocurrency on/off ramps functionality",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -45,8 +45,10 @@
45
45
  "changelog:update": "../../scripts/update-changelog.sh @metamask/ramps-controller",
46
46
  "changelog:validate": "../../scripts/validate-changelog.sh @metamask/ramps-controller",
47
47
  "dev": "node dev-watch.js",
48
- "messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --check",
49
- "messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --generate",
48
+ "lint:tsconfigs": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts",
49
+ "lint:tsconfigs:fix": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts --fix",
50
+ "messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --esm --check",
51
+ "messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --esm --generate",
50
52
  "since-latest-release": "../../scripts/since-latest-release.sh",
51
53
  "test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
52
54
  "test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
@@ -57,16 +59,17 @@
57
59
  "@metamask/base-controller": "^9.1.0",
58
60
  "@metamask/controller-utils": "^12.3.0",
59
61
  "@metamask/messenger": "^2.0.0",
60
- "@metamask/profile-sync-controller": "^28.3.0"
62
+ "@metamask/profile-sync-controller": "^28.3.0",
63
+ "@metamask/remote-feature-flag-controller": "^4.2.2"
61
64
  },
62
65
  "devDependencies": {
63
66
  "@metamask/auto-changelog": "^6.1.0",
64
67
  "@ts-bridge/cli": "^0.6.4",
65
- "@types/jest": "^29.5.14",
68
+ "@types/jest": "^30.0.0",
66
69
  "deepmerge": "^4.2.2",
67
- "jest": "^29.7.0",
70
+ "jest": "^30.4.2",
68
71
  "nock": "^13.3.1",
69
- "ts-jest": "^29.2.5",
72
+ "ts-jest": "^29.4.11",
70
73
  "tsx": "^4.20.5",
71
74
  "typedoc": "^0.25.13",
72
75
  "typedoc-plugin-missing-exports": "^2.0.0",