@metamask-previews/ramps-controller 14.2.0-preview-e4b456ca8 → 14.2.0-preview-0bd5566
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/RampsController-method-action-types.cjs.map +1 -1
- package/dist/RampsController-method-action-types.d.cts +1 -1
- package/dist/RampsController-method-action-types.d.mts +1 -1
- package/dist/RampsController-method-action-types.mjs.map +1 -1
- package/dist/RampsController.cjs +38 -10
- package/dist/RampsController.cjs.map +1 -1
- package/dist/RampsController.d.cts +10 -1
- package/dist/RampsController.d.cts.map +1 -1
- package/dist/RampsController.d.mts +10 -1
- package/dist/RampsController.d.mts.map +1 -1
- package/dist/RampsController.mjs +36 -9
- package/dist/RampsController.mjs.map +1 -1
- package/dist/TransakService.cjs +2 -2
- package/dist/TransakService.cjs.map +1 -1
- package/dist/TransakService.d.cts.map +1 -1
- package/dist/TransakService.d.mts.map +1 -1
- package/dist/TransakService.mjs +2 -2
- package/dist/TransakService.mjs.map +1 -1
- package/dist/index.cjs +5 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/transakApiErrorUtils.cjs +15 -0
- package/dist/transakApiErrorUtils.cjs.map +1 -0
- package/dist/transakApiErrorUtils.d.cts +3 -0
- package/dist/transakApiErrorUtils.d.cts.map +1 -0
- package/dist/transakApiErrorUtils.d.mts +3 -0
- package/dist/transakApiErrorUtils.d.mts.map +1 -0
- package/dist/transakApiErrorUtils.mjs +10 -0
- package/dist/transakApiErrorUtils.mjs.map +1 -0
- package/dist/transakErrorCodes.cjs +14 -0
- package/dist/transakErrorCodes.cjs.map +1 -0
- package/dist/transakErrorCodes.d.cts +12 -0
- package/dist/transakErrorCodes.d.cts.map +1 -0
- package/dist/transakErrorCodes.d.mts +12 -0
- package/dist/transakErrorCodes.d.mts.map +1 -0
- package/dist/transakErrorCodes.mjs +11 -0
- package/dist/transakErrorCodes.mjs.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,10 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Export `getTransakApiMessage` and `isTransakPhoneRegisteredError` for consumers handling `TransakApiError`, and centralize known Transak API error codes in `transakErrorCodes.ts` ([#9135](https://github.com/MetaMask/core/pull/9135))
|
|
13
|
+
|
|
10
14
|
### Changed
|
|
11
15
|
|
|
12
16
|
- Bump `@metamask/profile-sync-controller` from `^28.1.1` to `^28.2.0` ([#9119](https://github.com/MetaMask/core/pull/9119))
|
|
13
17
|
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Compare internal order codes (from canonical order `id`) instead of provider-native `providerOrderId` when merging orders in `RampsController.addOrder` and `RampsController.getOrder` ([#9159](https://github.com/MetaMask/core/pull/9159))
|
|
21
|
+
|
|
14
22
|
## [14.2.0]
|
|
15
23
|
|
|
16
24
|
### Changed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RampsController-method-action-types.cjs","sourceRoot":"","sources":["../src/RampsController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { RampsController } from './RampsController';\n\n/**\n * Executes a request with caching, deduplication, and at most one in-flight\n * request per resource type.\n *\n * 1. **Same cache key in flight** – If a request with this cache key is\n * already pending, returns that promise (deduplication; no second request).\n *\n * 2. **Cache hit** – If valid, non-expired data exists in state.requests for\n * this key and forceRefresh is not set, returns that data without fetching.\n *\n * 3. **New request** – Creates an AbortController and fires the fetcher.\n * If options.resourceType is set, tags the pending request with that\n * resource type (so #abortDependentRequests can cancel it on region\n * change or cleanup) and ref-counts resource-level loading state.\n * On success or error, updates request state and resource error;\n * in finally, clears resource loading only if this request was not\n * aborted.\n *\n * @param cacheKey - Unique identifier for this request (e.g. from createCacheKey).\n * @param fetcher - Async function that performs the fetch. Receives an AbortSignal\n * that is aborted when this request is superseded by another for the same resource.\n * @param options - Optional forceRefresh, ttl, and resourceType for loading/error state.\n * @returns The result of the request (from cache, joined promise, or fetcher).\n */\nexport type RampsControllerExecuteRequestAction = {\n type: `RampsController:executeRequest`;\n handler: RampsController['executeRequest'];\n};\n\n/**\n * Aborts a pending request if one exists.\n *\n * @param cacheKey - The cache key of the request to abort.\n * @returns True if a request was aborted.\n */\nexport type RampsControllerAbortRequestAction = {\n type: `RampsController:abortRequest`;\n handler: RampsController['abortRequest'];\n};\n\n/**\n * Gets the state of a specific cached request.\n *\n * @param cacheKey - The cache key to look up.\n * @returns The request state, or undefined if not cached.\n */\nexport type RampsControllerGetRequestStateAction = {\n type: `RampsController:getRequestState`;\n handler: RampsController['getRequestState'];\n};\n\n/**\n * Sets the user's region manually (without fetching geolocation).\n * This allows users to override the detected region.\n *\n * @param region - The region code to set (e.g., \"US-CA\").\n * @param options - Options for cache behavior.\n * @returns The user region object.\n */\nexport type RampsControllerSetUserRegionAction = {\n type: `RampsController:setUserRegion`;\n handler: RampsController['setUserRegion'];\n};\n\n/**\n * Sets the user's selected provider.\n *\n * Accepts either a Provider object (stored directly) or a provider ID\n * string (looked up from state). The object form is preferred when the\n * caller already has the full data (e.g. from React Query cache).\n *\n * @param providerOrId - A Provider object, a provider ID string (e.g., \"/providers/moonpay\"), or null to clear.\n * @param options - Optional settings for the selection.\n * @param options.autoSelected - When true, marks the provider as system-guessed\n * (soft selection). The UI will silently auto-switch on token conflict instead\n * of showing the \"Token Not Available\" modal. Defaults to false.\n */\nexport type RampsControllerSetSelectedProviderAction = {\n type: `RampsController:setSelectedProvider`;\n handler: RampsController['setSelectedProvider'];\n};\n\n/**\n * Initializes the controller by fetching the user's region from geolocation.\n * This should be called once at app startup to set up the initial region.\n *\n * Idempotent: subsequent calls return the same promise unless forceRefresh is set.\n * Skips getCountries when countries are already loaded; skips geolocation when\n * userRegion already exists.\n *\n * @param options - Options for cache behavior. forceRefresh bypasses idempotency and re-runs the full flow.\n * @returns Promise that resolves when initialization is complete.\n */\nexport type RampsControllerInitAction = {\n type: `RampsController:init`;\n handler: RampsController['init'];\n};\n\n/**\n * Fetches the list of supported countries.\n * The API returns countries with support information for both buy and sell actions.\n * The countries are saved in the controller state once fetched.\n *\n * @param options - Options for cache behavior.\n * @returns An array of countries.\n */\nexport type RampsControllerGetCountriesAction = {\n type: `RampsController:getCountries`;\n handler: RampsController['getCountries'];\n};\n\n/**\n * Fetches the list of available tokens for a given region and action.\n * The tokens are saved in the controller state once fetched.\n *\n * @param region - The region code (e.g., \"us\", \"fr\", \"us-ny\"). If not provided, uses the user's region from controller state.\n * @param action - The ramp action type ('buy' or 'sell').\n * @param options - Options for cache behavior and query filters.\n * @param options.provider - Provider ID(s) to filter by.\n * @returns The tokens response containing topTokens and allTokens.\n */\nexport type RampsControllerGetTokensAction = {\n type: `RampsController:getTokens`;\n handler: RampsController['getTokens'];\n};\n\n/**\n * Sets the user's selected token by asset ID.\n * Looks up the token from the current tokens in state and automatically\n * fetches payment methods for that token.\n *\n * @param assetId - The asset identifier in CAIP-19 format (e.g., \"eip155:1/erc20:0x...\"), or undefined to clear.\n * @throws If region is not set, tokens are not loaded, or token is not found.\n */\nexport type RampsControllerSetSelectedTokenAction = {\n type: `RampsController:setSelectedToken`;\n handler: RampsController['setSelectedToken'];\n};\n\n/**\n * Fetches the list of providers for a given region.\n * The providers are saved in the controller state once fetched.\n *\n * @param region - The region code (e.g., \"us\", \"fr\", \"us-ny\"). If not provided, uses the user's region from controller state.\n * @param options - Options for cache behavior and query filters.\n * @param options.provider - Provider ID(s) to filter by.\n * @param options.crypto - Crypto currency ID(s) to filter by.\n * @param options.fiat - Fiat currency ID(s) to filter by.\n * @param options.payments - Payment method ID(s) to filter by.\n * @returns The providers response containing providers array.\n */\nexport type RampsControllerGetProvidersAction = {\n type: `RampsController:getProviders`;\n handler: RampsController['getProviders'];\n};\n\n/**\n * Fetches the list of payment methods for a given context.\n * The payment methods are saved in the controller state once fetched.\n *\n * @param region - User's region code (e.g. \"fr\", \"us-ny\").\n * @param options - Query parameters for filtering payment methods.\n * @param options.fiat - Fiat currency code (e.g., \"usd\"). If not provided, uses the user's region currency.\n * @param options.assetId - CAIP-19 cryptocurrency identifier.\n * @param options.provider - Provider ID path.\n * @returns The payment methods response containing payments array.\n */\nexport type RampsControllerGetPaymentMethodsAction = {\n type: `RampsController:getPaymentMethods`;\n handler: RampsController['getPaymentMethods'];\n};\n\n/**\n * Sets the user's selected payment method.\n *\n * Accepts either a payment method ID (looked up from state) or a full\n * PaymentMethod object (stored directly). The object form is preferred\n * when the caller already has the full data (e.g. from React Query cache),\n * as it avoids depending on controller state being populated.\n *\n * @param paymentMethodOrId - A PaymentMethod object, a payment method ID string, or undefined/null to clear.\n */\nexport type RampsControllerSetSelectedPaymentMethodAction = {\n type: `RampsController:setSelectedPaymentMethod`;\n handler: RampsController['setSelectedPaymentMethod'];\n};\n\n/**\n * Fetches quotes from all providers for a given set of parameters.\n * Uses the controller's request cache; callers manage the response in local state.\n *\n * @param options - The parameters for fetching quotes.\n * @param options.region - User's region code. If not provided, uses userRegion from state.\n * @param options.fiat - Fiat currency code. If not provided, uses userRegion currency.\n * @param options.assetId - CAIP-19 cryptocurrency identifier.\n * @param options.amount - The amount (in fiat for buy, crypto for sell).\n * @param options.walletAddress - The destination wallet address.\n * @param options.paymentMethods - Array of payment method IDs. If not provided, uses paymentMethods from state.\n * @param options.providers - Optional provider IDs to filter quotes.\n * @param options.autoSelectProvider - When true and `providers` is omitted,\n * resolves a provider that supports `assetId` for this request only (no\n * state mutation). Ignored when `providers` is passed.\n * @param options.preferredProviderIds - Optional provider IDs to prefer\n * during auto-selection, in priority order (e.g. derived by the caller\n * from completed-order history). Only used when `autoSelectProvider` is\n * true and `providers` is omitted.\n * @param options.restrictToKnownOrNativeProviders - Headless-buy v0 gating. When\n * true, auto-selection resolves only a native provider, and an explicitly\n * passed `providers` list is filtered to those supporting the region and\n * asset. If nothing qualifies, `getQuotes` returns an empty response\n * instead of quoting other providers.\n * @param options.redirectUrl - Optional redirect URL after order completion.\n * @param options.action - The ramp action type. Defaults to 'buy'.\n * @param options.forceRefresh - Whether to bypass cache.\n * @param options.ttl - Custom TTL for this request.\n * @returns The quotes response containing success, sorted, error, and customActions.\n */\nexport type RampsControllerGetQuotesAction = {\n type: `RampsController:getQuotes`;\n handler: RampsController['getQuotes'];\n};\n\n/**\n * Adds or updates a V2 order in controller state.\n * If an order with the same providerOrderId already exists, the incoming\n * fields are merged on top of the existing order so that fields not present\n * in the update (e.g. paymentDetails from the Transak API) are preserved.\n *\n * @param order - The RampsOrder to add or update.\n */\nexport type RampsControllerAddOrderAction = {\n type: `RampsController:addOrder`;\n handler: RampsController['addOrder'];\n};\n\n/**\n * Removes a V2 order from controller state by providerOrderId.\n *\n * @param providerOrderId - The provider order ID to remove.\n */\nexport type RampsControllerRemoveOrderAction = {\n type: `RampsController:removeOrder`;\n handler: RampsController['removeOrder'];\n};\n\n/**\n * Starts polling all pending V2 orders at a fixed interval.\n * Each poll cycle iterates orders with non-terminal statuses,\n * respects pollingSecondsMinimum and backoff from error count.\n */\nexport type RampsControllerStartOrderPollingAction = {\n type: `RampsController:startOrderPolling`;\n handler: RampsController['startOrderPolling'];\n};\n\n/**\n * Stops order polling and clears the interval.\n */\nexport type RampsControllerStopOrderPollingAction = {\n type: `RampsController:stopOrderPolling`;\n handler: RampsController['stopOrderPolling'];\n};\n\n/**\n * Fetches the widget data from a quote for redirect providers.\n * Makes a request to the buyURL endpoint via the RampsService to get the\n * actual provider widget URL and optional order ID for polling.\n *\n * @param quote - The quote to fetch the widget URL from.\n * @returns Promise resolving to the full BuyWidget (url, browser, orderId), or null if not available (missing buyURL or empty url in response).\n * @throws Rethrows errors from the RampsService (e.g. HttpError, network failures) so clients can react to fetch failures.\n */\nexport type RampsControllerGetBuyWidgetDataAction = {\n type: `RampsController:getBuyWidgetData`;\n handler: RampsController['getBuyWidgetData'];\n};\n\n/**\n * Registers an order ID for polling until the order is created or resolved.\n * Adds a minimal stub order to controller state; the existing order polling\n * will fetch the full order when the provider has created it.\n *\n * @param params - Object containing order identifiers and wallet info.\n * @param params.orderId - Full order ID (e.g. \"/providers/paypal/orders/abc123\") or order code.\n * @param params.providerCode - Provider code (e.g. \"paypal\", \"transak\"), with or without /providers/ prefix.\n * @param params.walletAddress - Wallet address for the order.\n * @param params.chainId - Optional chain ID for the order.\n */\nexport type RampsControllerAddPrecreatedOrderAction = {\n type: `RampsController:addPrecreatedOrder`;\n handler: RampsController['addPrecreatedOrder'];\n};\n\n/**\n * Fetches an order from the unified V2 API endpoint.\n * Returns a normalized RampsOrder for all provider types (aggregator and native).\n *\n * @param providerCode - The provider code (e.g., \"transak\", \"transak-native\", \"moonpay\").\n * @param orderCode - The order identifier.\n * @param wallet - The wallet address associated with the order.\n * @returns The unified order data.\n */\nexport type RampsControllerGetOrderAction = {\n type: `RampsController:getOrder`;\n handler: RampsController['getOrder'];\n};\n\n/**\n * Extracts an order from a provider callback URL.\n * Sends the callback URL to the V2 backend for provider-specific parsing,\n * then fetches the full order. This is the V2 equivalent of the aggregator\n * SDK's `getOrderFromCallback`.\n *\n * @param providerCode - The provider code (e.g., \"transak\", \"moonpay\").\n * @param callbackUrl - The full callback URL the provider redirected to.\n * @param wallet - The wallet address associated with the order.\n * @returns The unified order data.\n */\nexport type RampsControllerGetOrderFromCallbackAction = {\n type: `RampsController:getOrderFromCallback`;\n handler: RampsController['getOrderFromCallback'];\n};\n\n/**\n * Sets the Transak API key used for all Transak API requests.\n *\n * @param apiKey - The Transak API key.\n */\nexport type RampsControllerTransakSetApiKeyAction = {\n type: `RampsController:transakSetApiKey`;\n handler: RampsController['transakSetApiKey'];\n};\n\n/**\n * Sets the Transak access token and marks the user as authenticated.\n *\n * @param token - The access token received from Transak auth.\n */\nexport type RampsControllerTransakSetAccessTokenAction = {\n type: `RampsController:transakSetAccessToken`;\n handler: RampsController['transakSetAccessToken'];\n};\n\n/**\n * Clears the Transak access token and marks the user as unauthenticated.\n */\nexport type RampsControllerTransakClearAccessTokenAction = {\n type: `RampsController:transakClearAccessToken`;\n handler: RampsController['transakClearAccessToken'];\n};\n\n/**\n * Updates the Transak authentication flag in controller state.\n *\n * @param isAuthenticated - Whether the user is authenticated with Transak.\n */\nexport type RampsControllerTransakSetAuthenticatedAction = {\n type: `RampsController:transakSetAuthenticated`;\n handler: RampsController['transakSetAuthenticated'];\n};\n\n/**\n * Resets all Transak state back to defaults (unauthenticated, no data).\n */\nexport type RampsControllerTransakResetStateAction = {\n type: `RampsController:transakResetState`;\n handler: RampsController['transakResetState'];\n};\n\n/**\n * Sends a one-time password to the user's email for Transak authentication.\n *\n * @param email - The user's email address.\n * @returns The OTP response containing a state token for verification.\n */\nexport type RampsControllerTransakSendUserOtpAction = {\n type: `RampsController:transakSendUserOtp`;\n handler: RampsController['transakSendUserOtp'];\n};\n\n/**\n * Verifies a one-time password and authenticates the user with Transak.\n * Updates the controller's authentication state on success.\n *\n * @param email - The user's email address.\n * @param verificationCode - The OTP code entered by the user.\n * @param stateToken - The state token from the sendUserOtp response.\n * @returns The access token for subsequent authenticated requests.\n */\nexport type RampsControllerTransakVerifyUserOtpAction = {\n type: `RampsController:transakVerifyUserOtp`;\n handler: RampsController['transakVerifyUserOtp'];\n};\n\n/**\n * Logs the user out of Transak. Clears authentication state and user details\n * regardless of whether the API call succeeds or fails.\n *\n * @returns A message indicating the logout result.\n */\nexport type RampsControllerTransakLogoutAction = {\n type: `RampsController:transakLogout`;\n handler: RampsController['transakLogout'];\n};\n\n/**\n * Fetches the authenticated user's details from Transak.\n * Updates the userDetails resource state with loading/success/error states.\n *\n * @returns The user's profile and KYC details.\n */\nexport type RampsControllerTransakGetUserDetailsAction = {\n type: `RampsController:transakGetUserDetails`;\n handler: RampsController['transakGetUserDetails'];\n};\n\n/**\n * Fetches a buy quote from Transak for the given parameters.\n * Updates the buyQuote resource state with loading/success/error states.\n *\n * @param fiatCurrency - The fiat currency code (e.g., \"USD\").\n * @param cryptoCurrency - The cryptocurrency identifier.\n * @param network - The blockchain network identifier.\n * @param paymentMethod - The payment method identifier.\n * @param fiatAmount - The fiat amount as a string.\n * @returns The buy quote with pricing and fee details.\n */\nexport type RampsControllerTransakGetBuyQuoteAction = {\n type: `RampsController:transakGetBuyQuote`;\n handler: RampsController['transakGetBuyQuote'];\n};\n\n/**\n * Fetches the KYC requirement for a given quote.\n * Updates the kycRequirement resource state with loading/success/error states.\n *\n * @param quoteId - The quote ID to check KYC requirements for.\n * @returns The KYC requirement status and whether the user can place an order.\n */\nexport type RampsControllerTransakGetKycRequirementAction = {\n type: `RampsController:transakGetKycRequirement`;\n handler: RampsController['transakGetKycRequirement'];\n};\n\n/**\n * Fetches additional KYC requirements (e.g., ID proof, address proof) for a quote.\n *\n * @param quoteId - The quote ID to check additional requirements for.\n * @returns The list of additional forms required.\n */\nexport type RampsControllerTransakGetAdditionalRequirementsAction = {\n type: `RampsController:transakGetAdditionalRequirements`;\n handler: RampsController['transakGetAdditionalRequirements'];\n};\n\n/**\n * Creates a new order on Transak. If an existing order conflicts (HTTP 409),\n * active orders are cancelled and the creation is retried.\n *\n * @param quoteId - The quote ID to create an order from.\n * @param walletAddress - The destination wallet address.\n * @param paymentMethodId - The payment method to use.\n * @returns The created deposit order.\n */\nexport type RampsControllerTransakCreateOrderAction = {\n type: `RampsController:transakCreateOrder`;\n handler: RampsController['transakCreateOrder'];\n};\n\n/**\n * Fetches an existing order from Transak by order ID.\n *\n * @param orderId - The order ID (deposit format or raw Transak format).\n * @param wallet - The wallet address associated with the order.\n * @param paymentDetails - Optional payment details to attach to the order.\n * @returns The deposit order details.\n */\nexport type RampsControllerTransakGetOrderAction = {\n type: `RampsController:transakGetOrder`;\n handler: RampsController['transakGetOrder'];\n};\n\n/**\n * Fetches the user's spending limits for a given currency and payment method.\n *\n * @param fiatCurrency - The fiat currency code.\n * @param paymentMethod - The payment method identifier.\n * @param kycType - The KYC level type.\n * @returns The user's limits, spending, and remaining amounts.\n */\nexport type RampsControllerTransakGetUserLimitsAction = {\n type: `RampsController:transakGetUserLimits`;\n handler: RampsController['transakGetUserLimits'];\n};\n\n/**\n * Requests a one-time token (OTT) for the Transak payment widget.\n *\n * @returns The OTT response containing the token.\n */\nexport type RampsControllerTransakRequestOttAction = {\n type: `RampsController:transakRequestOtt`;\n handler: RampsController['transakRequestOtt'];\n};\n\n/**\n * Generates a URL for the Transak payment widget with pre-filled parameters.\n *\n * @param ottToken - The one-time token for widget authentication.\n * @param quote - The buy quote to pre-fill in the widget.\n * @param walletAddress - The destination wallet address.\n * @param extraParams - Optional additional URL parameters.\n * @returns The fully constructed widget URL string.\n */\nexport type RampsControllerTransakGeneratePaymentWidgetUrlAction = {\n type: `RampsController:transakGeneratePaymentWidgetUrl`;\n handler: RampsController['transakGeneratePaymentWidgetUrl'];\n};\n\n/**\n * Submits the user's purpose of usage form for KYC compliance.\n *\n * @param purpose - Array of purpose strings selected by the user.\n * @returns A promise that resolves when the form is submitted.\n */\nexport type RampsControllerTransakSubmitPurposeOfUsageFormAction = {\n type: `RampsController:transakSubmitPurposeOfUsageForm`;\n handler: RampsController['transakSubmitPurposeOfUsageForm'];\n};\n\n/**\n * Updates the user's personal or address details on Transak.\n *\n * @param data - The user data fields to update.\n * @returns The API response data.\n */\nexport type RampsControllerTransakPatchUserAction = {\n type: `RampsController:transakPatchUser`;\n handler: RampsController['transakPatchUser'];\n};\n\n/**\n * Submits the user's SSN for identity verification.\n *\n * @param ssn - The Social Security Number.\n * @param quoteId - The quote ID associated with the order requiring SSN.\n * @returns The API response data.\n */\nexport type RampsControllerTransakSubmitSsnDetailsAction = {\n type: `RampsController:transakSubmitSsnDetails`;\n handler: RampsController['transakSubmitSsnDetails'];\n};\n\n/**\n * Confirms payment for an order after the user has completed payment.\n *\n * @param orderId - The order ID to confirm payment for.\n * @param paymentMethodId - The payment method used.\n * @returns Whether the payment confirmation was successful.\n */\nexport type RampsControllerTransakConfirmPaymentAction = {\n type: `RampsController:transakConfirmPayment`;\n handler: RampsController['transakConfirmPayment'];\n};\n\n/**\n * Translates generic ramps identifiers to Transak-specific identifiers.\n *\n * @param request - The translation request with optional identifiers to translate.\n * @returns The translated Transak-specific identifiers.\n */\nexport type RampsControllerTransakGetTranslationAction = {\n type: `RampsController:transakGetTranslation`;\n handler: RampsController['transakGetTranslation'];\n};\n\n/**\n * Checks the status of an ID proof submission for KYC.\n *\n * @param workFlowRunId - The workflow run ID to check status for.\n * @returns The current ID proof status.\n */\nexport type RampsControllerTransakGetIdProofStatusAction = {\n type: `RampsController:transakGetIdProofStatus`;\n handler: RampsController['transakGetIdProofStatus'];\n};\n\n/**\n * Cancels a specific Transak order.\n *\n * @param depositOrderId - The deposit order ID to cancel.\n * @returns A promise that resolves when the order is cancelled.\n */\nexport type RampsControllerTransakCancelOrderAction = {\n type: `RampsController:transakCancelOrder`;\n handler: RampsController['transakCancelOrder'];\n};\n\n/**\n * Cancels all active Transak orders. Individual cancellation failures\n * are collected and returned rather than thrown.\n *\n * @returns An array of errors from any failed cancellations (empty if all succeeded).\n */\nexport type RampsControllerTransakCancelAllActiveOrdersAction = {\n type: `RampsController:transakCancelAllActiveOrders`;\n handler: RampsController['transakCancelAllActiveOrders'];\n};\n\n/**\n * Fetches all active Transak orders for the authenticated user.\n *\n * @returns The list of active orders.\n */\nexport type RampsControllerTransakGetActiveOrdersAction = {\n type: `RampsController:transakGetActiveOrders`;\n handler: RampsController['transakGetActiveOrders'];\n};\n\n/**\n * Union of all RampsController action types.\n */\nexport type RampsControllerMethodActions =\n | RampsControllerExecuteRequestAction\n | RampsControllerAbortRequestAction\n | RampsControllerGetRequestStateAction\n | RampsControllerSetUserRegionAction\n | RampsControllerSetSelectedProviderAction\n | RampsControllerInitAction\n | RampsControllerGetCountriesAction\n | RampsControllerGetTokensAction\n | RampsControllerSetSelectedTokenAction\n | RampsControllerGetProvidersAction\n | RampsControllerGetPaymentMethodsAction\n | RampsControllerSetSelectedPaymentMethodAction\n | RampsControllerGetQuotesAction\n | RampsControllerAddOrderAction\n | RampsControllerRemoveOrderAction\n | RampsControllerStartOrderPollingAction\n | RampsControllerStopOrderPollingAction\n | RampsControllerGetBuyWidgetDataAction\n | RampsControllerAddPrecreatedOrderAction\n | RampsControllerGetOrderAction\n | RampsControllerGetOrderFromCallbackAction\n | RampsControllerTransakSetApiKeyAction\n | RampsControllerTransakSetAccessTokenAction\n | RampsControllerTransakClearAccessTokenAction\n | RampsControllerTransakSetAuthenticatedAction\n | RampsControllerTransakResetStateAction\n | RampsControllerTransakSendUserOtpAction\n | RampsControllerTransakVerifyUserOtpAction\n | RampsControllerTransakLogoutAction\n | RampsControllerTransakGetUserDetailsAction\n | RampsControllerTransakGetBuyQuoteAction\n | RampsControllerTransakGetKycRequirementAction\n | RampsControllerTransakGetAdditionalRequirementsAction\n | RampsControllerTransakCreateOrderAction\n | RampsControllerTransakGetOrderAction\n | RampsControllerTransakGetUserLimitsAction\n | RampsControllerTransakRequestOttAction\n | RampsControllerTransakGeneratePaymentWidgetUrlAction\n | RampsControllerTransakSubmitPurposeOfUsageFormAction\n | RampsControllerTransakPatchUserAction\n | RampsControllerTransakSubmitSsnDetailsAction\n | RampsControllerTransakConfirmPaymentAction\n | RampsControllerTransakGetTranslationAction\n | RampsControllerTransakGetIdProofStatusAction\n | RampsControllerTransakCancelOrderAction\n | RampsControllerTransakCancelAllActiveOrdersAction\n | RampsControllerTransakGetActiveOrdersAction;\n"]}
|
|
1
|
+
{"version":3,"file":"RampsController-method-action-types.cjs","sourceRoot":"","sources":["../src/RampsController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { RampsController } from './RampsController';\n\n/**\n * Executes a request with caching, deduplication, and at most one in-flight\n * request per resource type.\n *\n * 1. **Same cache key in flight** – If a request with this cache key is\n * already pending, returns that promise (deduplication; no second request).\n *\n * 2. **Cache hit** – If valid, non-expired data exists in state.requests for\n * this key and forceRefresh is not set, returns that data without fetching.\n *\n * 3. **New request** – Creates an AbortController and fires the fetcher.\n * If options.resourceType is set, tags the pending request with that\n * resource type (so #abortDependentRequests can cancel it on region\n * change or cleanup) and ref-counts resource-level loading state.\n * On success or error, updates request state and resource error;\n * in finally, clears resource loading only if this request was not\n * aborted.\n *\n * @param cacheKey - Unique identifier for this request (e.g. from createCacheKey).\n * @param fetcher - Async function that performs the fetch. Receives an AbortSignal\n * that is aborted when this request is superseded by another for the same resource.\n * @param options - Optional forceRefresh, ttl, and resourceType for loading/error state.\n * @returns The result of the request (from cache, joined promise, or fetcher).\n */\nexport type RampsControllerExecuteRequestAction = {\n type: `RampsController:executeRequest`;\n handler: RampsController['executeRequest'];\n};\n\n/**\n * Aborts a pending request if one exists.\n *\n * @param cacheKey - The cache key of the request to abort.\n * @returns True if a request was aborted.\n */\nexport type RampsControllerAbortRequestAction = {\n type: `RampsController:abortRequest`;\n handler: RampsController['abortRequest'];\n};\n\n/**\n * Gets the state of a specific cached request.\n *\n * @param cacheKey - The cache key to look up.\n * @returns The request state, or undefined if not cached.\n */\nexport type RampsControllerGetRequestStateAction = {\n type: `RampsController:getRequestState`;\n handler: RampsController['getRequestState'];\n};\n\n/**\n * Sets the user's region manually (without fetching geolocation).\n * This allows users to override the detected region.\n *\n * @param region - The region code to set (e.g., \"US-CA\").\n * @param options - Options for cache behavior.\n * @returns The user region object.\n */\nexport type RampsControllerSetUserRegionAction = {\n type: `RampsController:setUserRegion`;\n handler: RampsController['setUserRegion'];\n};\n\n/**\n * Sets the user's selected provider.\n *\n * Accepts either a Provider object (stored directly) or a provider ID\n * string (looked up from state). The object form is preferred when the\n * caller already has the full data (e.g. from React Query cache).\n *\n * @param providerOrId - A Provider object, a provider ID string (e.g., \"/providers/moonpay\"), or null to clear.\n * @param options - Optional settings for the selection.\n * @param options.autoSelected - When true, marks the provider as system-guessed\n * (soft selection). The UI will silently auto-switch on token conflict instead\n * of showing the \"Token Not Available\" modal. Defaults to false.\n */\nexport type RampsControllerSetSelectedProviderAction = {\n type: `RampsController:setSelectedProvider`;\n handler: RampsController['setSelectedProvider'];\n};\n\n/**\n * Initializes the controller by fetching the user's region from geolocation.\n * This should be called once at app startup to set up the initial region.\n *\n * Idempotent: subsequent calls return the same promise unless forceRefresh is set.\n * Skips getCountries when countries are already loaded; skips geolocation when\n * userRegion already exists.\n *\n * @param options - Options for cache behavior. forceRefresh bypasses idempotency and re-runs the full flow.\n * @returns Promise that resolves when initialization is complete.\n */\nexport type RampsControllerInitAction = {\n type: `RampsController:init`;\n handler: RampsController['init'];\n};\n\n/**\n * Fetches the list of supported countries.\n * The API returns countries with support information for both buy and sell actions.\n * The countries are saved in the controller state once fetched.\n *\n * @param options - Options for cache behavior.\n * @returns An array of countries.\n */\nexport type RampsControllerGetCountriesAction = {\n type: `RampsController:getCountries`;\n handler: RampsController['getCountries'];\n};\n\n/**\n * Fetches the list of available tokens for a given region and action.\n * The tokens are saved in the controller state once fetched.\n *\n * @param region - The region code (e.g., \"us\", \"fr\", \"us-ny\"). If not provided, uses the user's region from controller state.\n * @param action - The ramp action type ('buy' or 'sell').\n * @param options - Options for cache behavior and query filters.\n * @param options.provider - Provider ID(s) to filter by.\n * @returns The tokens response containing topTokens and allTokens.\n */\nexport type RampsControllerGetTokensAction = {\n type: `RampsController:getTokens`;\n handler: RampsController['getTokens'];\n};\n\n/**\n * Sets the user's selected token by asset ID.\n * Looks up the token from the current tokens in state and automatically\n * fetches payment methods for that token.\n *\n * @param assetId - The asset identifier in CAIP-19 format (e.g., \"eip155:1/erc20:0x...\"), or undefined to clear.\n * @throws If region is not set, tokens are not loaded, or token is not found.\n */\nexport type RampsControllerSetSelectedTokenAction = {\n type: `RampsController:setSelectedToken`;\n handler: RampsController['setSelectedToken'];\n};\n\n/**\n * Fetches the list of providers for a given region.\n * The providers are saved in the controller state once fetched.\n *\n * @param region - The region code (e.g., \"us\", \"fr\", \"us-ny\"). If not provided, uses the user's region from controller state.\n * @param options - Options for cache behavior and query filters.\n * @param options.provider - Provider ID(s) to filter by.\n * @param options.crypto - Crypto currency ID(s) to filter by.\n * @param options.fiat - Fiat currency ID(s) to filter by.\n * @param options.payments - Payment method ID(s) to filter by.\n * @returns The providers response containing providers array.\n */\nexport type RampsControllerGetProvidersAction = {\n type: `RampsController:getProviders`;\n handler: RampsController['getProviders'];\n};\n\n/**\n * Fetches the list of payment methods for a given context.\n * The payment methods are saved in the controller state once fetched.\n *\n * @param region - User's region code (e.g. \"fr\", \"us-ny\").\n * @param options - Query parameters for filtering payment methods.\n * @param options.fiat - Fiat currency code (e.g., \"usd\"). If not provided, uses the user's region currency.\n * @param options.assetId - CAIP-19 cryptocurrency identifier.\n * @param options.provider - Provider ID path.\n * @returns The payment methods response containing payments array.\n */\nexport type RampsControllerGetPaymentMethodsAction = {\n type: `RampsController:getPaymentMethods`;\n handler: RampsController['getPaymentMethods'];\n};\n\n/**\n * Sets the user's selected payment method.\n *\n * Accepts either a payment method ID (looked up from state) or a full\n * PaymentMethod object (stored directly). The object form is preferred\n * when the caller already has the full data (e.g. from React Query cache),\n * as it avoids depending on controller state being populated.\n *\n * @param paymentMethodOrId - A PaymentMethod object, a payment method ID string, or undefined/null to clear.\n */\nexport type RampsControllerSetSelectedPaymentMethodAction = {\n type: `RampsController:setSelectedPaymentMethod`;\n handler: RampsController['setSelectedPaymentMethod'];\n};\n\n/**\n * Fetches quotes from all providers for a given set of parameters.\n * Uses the controller's request cache; callers manage the response in local state.\n *\n * @param options - The parameters for fetching quotes.\n * @param options.region - User's region code. If not provided, uses userRegion from state.\n * @param options.fiat - Fiat currency code. If not provided, uses userRegion currency.\n * @param options.assetId - CAIP-19 cryptocurrency identifier.\n * @param options.amount - The amount (in fiat for buy, crypto for sell).\n * @param options.walletAddress - The destination wallet address.\n * @param options.paymentMethods - Array of payment method IDs. If not provided, uses paymentMethods from state.\n * @param options.providers - Optional provider IDs to filter quotes.\n * @param options.autoSelectProvider - When true and `providers` is omitted,\n * resolves a provider that supports `assetId` for this request only (no\n * state mutation). Ignored when `providers` is passed.\n * @param options.preferredProviderIds - Optional provider IDs to prefer\n * during auto-selection, in priority order (e.g. derived by the caller\n * from completed-order history). Only used when `autoSelectProvider` is\n * true and `providers` is omitted.\n * @param options.restrictToKnownOrNativeProviders - Headless-buy v0 gating. When\n * true, auto-selection resolves only a native provider, and an explicitly\n * passed `providers` list is filtered to those supporting the region and\n * asset. If nothing qualifies, `getQuotes` returns an empty response\n * instead of quoting other providers.\n * @param options.redirectUrl - Optional redirect URL after order completion.\n * @param options.action - The ramp action type. Defaults to 'buy'.\n * @param options.forceRefresh - Whether to bypass cache.\n * @param options.ttl - Custom TTL for this request.\n * @returns The quotes response containing success, sorted, error, and customActions.\n */\nexport type RampsControllerGetQuotesAction = {\n type: `RampsController:getQuotes`;\n handler: RampsController['getQuotes'];\n};\n\n/**\n * Adds or updates a V2 order in controller state.\n * If an order with the same internal order code already exists, the incoming\n * fields are merged on top of the existing order so that fields not present\n * in the update (e.g. paymentDetails from the Transak API) are preserved.\n *\n * @param order - The RampsOrder to add or update.\n */\nexport type RampsControllerAddOrderAction = {\n type: `RampsController:addOrder`;\n handler: RampsController['addOrder'];\n};\n\n/**\n * Removes a V2 order from controller state by providerOrderId.\n *\n * @param providerOrderId - The provider order ID to remove.\n */\nexport type RampsControllerRemoveOrderAction = {\n type: `RampsController:removeOrder`;\n handler: RampsController['removeOrder'];\n};\n\n/**\n * Starts polling all pending V2 orders at a fixed interval.\n * Each poll cycle iterates orders with non-terminal statuses,\n * respects pollingSecondsMinimum and backoff from error count.\n */\nexport type RampsControllerStartOrderPollingAction = {\n type: `RampsController:startOrderPolling`;\n handler: RampsController['startOrderPolling'];\n};\n\n/**\n * Stops order polling and clears the interval.\n */\nexport type RampsControllerStopOrderPollingAction = {\n type: `RampsController:stopOrderPolling`;\n handler: RampsController['stopOrderPolling'];\n};\n\n/**\n * Fetches the widget data from a quote for redirect providers.\n * Makes a request to the buyURL endpoint via the RampsService to get the\n * actual provider widget URL and optional order ID for polling.\n *\n * @param quote - The quote to fetch the widget URL from.\n * @returns Promise resolving to the full BuyWidget (url, browser, orderId), or null if not available (missing buyURL or empty url in response).\n * @throws Rethrows errors from the RampsService (e.g. HttpError, network failures) so clients can react to fetch failures.\n */\nexport type RampsControllerGetBuyWidgetDataAction = {\n type: `RampsController:getBuyWidgetData`;\n handler: RampsController['getBuyWidgetData'];\n};\n\n/**\n * Registers an order ID for polling until the order is created or resolved.\n * Adds a minimal stub order to controller state; the existing order polling\n * will fetch the full order when the provider has created it.\n *\n * @param params - Object containing order identifiers and wallet info.\n * @param params.orderId - Full order ID (e.g. \"/providers/paypal/orders/abc123\") or order code.\n * @param params.providerCode - Provider code (e.g. \"paypal\", \"transak\"), with or without /providers/ prefix.\n * @param params.walletAddress - Wallet address for the order.\n * @param params.chainId - Optional chain ID for the order.\n */\nexport type RampsControllerAddPrecreatedOrderAction = {\n type: `RampsController:addPrecreatedOrder`;\n handler: RampsController['addPrecreatedOrder'];\n};\n\n/**\n * Fetches an order from the unified V2 API endpoint.\n * Returns a normalized RampsOrder for all provider types (aggregator and native).\n *\n * @param providerCode - The provider code (e.g., \"transak\", \"transak-native\", \"moonpay\").\n * @param orderCode - The order identifier.\n * @param wallet - The wallet address associated with the order.\n * @returns The unified order data.\n */\nexport type RampsControllerGetOrderAction = {\n type: `RampsController:getOrder`;\n handler: RampsController['getOrder'];\n};\n\n/**\n * Extracts an order from a provider callback URL.\n * Sends the callback URL to the V2 backend for provider-specific parsing,\n * then fetches the full order. This is the V2 equivalent of the aggregator\n * SDK's `getOrderFromCallback`.\n *\n * @param providerCode - The provider code (e.g., \"transak\", \"moonpay\").\n * @param callbackUrl - The full callback URL the provider redirected to.\n * @param wallet - The wallet address associated with the order.\n * @returns The unified order data.\n */\nexport type RampsControllerGetOrderFromCallbackAction = {\n type: `RampsController:getOrderFromCallback`;\n handler: RampsController['getOrderFromCallback'];\n};\n\n/**\n * Sets the Transak API key used for all Transak API requests.\n *\n * @param apiKey - The Transak API key.\n */\nexport type RampsControllerTransakSetApiKeyAction = {\n type: `RampsController:transakSetApiKey`;\n handler: RampsController['transakSetApiKey'];\n};\n\n/**\n * Sets the Transak access token and marks the user as authenticated.\n *\n * @param token - The access token received from Transak auth.\n */\nexport type RampsControllerTransakSetAccessTokenAction = {\n type: `RampsController:transakSetAccessToken`;\n handler: RampsController['transakSetAccessToken'];\n};\n\n/**\n * Clears the Transak access token and marks the user as unauthenticated.\n */\nexport type RampsControllerTransakClearAccessTokenAction = {\n type: `RampsController:transakClearAccessToken`;\n handler: RampsController['transakClearAccessToken'];\n};\n\n/**\n * Updates the Transak authentication flag in controller state.\n *\n * @param isAuthenticated - Whether the user is authenticated with Transak.\n */\nexport type RampsControllerTransakSetAuthenticatedAction = {\n type: `RampsController:transakSetAuthenticated`;\n handler: RampsController['transakSetAuthenticated'];\n};\n\n/**\n * Resets all Transak state back to defaults (unauthenticated, no data).\n */\nexport type RampsControllerTransakResetStateAction = {\n type: `RampsController:transakResetState`;\n handler: RampsController['transakResetState'];\n};\n\n/**\n * Sends a one-time password to the user's email for Transak authentication.\n *\n * @param email - The user's email address.\n * @returns The OTP response containing a state token for verification.\n */\nexport type RampsControllerTransakSendUserOtpAction = {\n type: `RampsController:transakSendUserOtp`;\n handler: RampsController['transakSendUserOtp'];\n};\n\n/**\n * Verifies a one-time password and authenticates the user with Transak.\n * Updates the controller's authentication state on success.\n *\n * @param email - The user's email address.\n * @param verificationCode - The OTP code entered by the user.\n * @param stateToken - The state token from the sendUserOtp response.\n * @returns The access token for subsequent authenticated requests.\n */\nexport type RampsControllerTransakVerifyUserOtpAction = {\n type: `RampsController:transakVerifyUserOtp`;\n handler: RampsController['transakVerifyUserOtp'];\n};\n\n/**\n * Logs the user out of Transak. Clears authentication state and user details\n * regardless of whether the API call succeeds or fails.\n *\n * @returns A message indicating the logout result.\n */\nexport type RampsControllerTransakLogoutAction = {\n type: `RampsController:transakLogout`;\n handler: RampsController['transakLogout'];\n};\n\n/**\n * Fetches the authenticated user's details from Transak.\n * Updates the userDetails resource state with loading/success/error states.\n *\n * @returns The user's profile and KYC details.\n */\nexport type RampsControllerTransakGetUserDetailsAction = {\n type: `RampsController:transakGetUserDetails`;\n handler: RampsController['transakGetUserDetails'];\n};\n\n/**\n * Fetches a buy quote from Transak for the given parameters.\n * Updates the buyQuote resource state with loading/success/error states.\n *\n * @param fiatCurrency - The fiat currency code (e.g., \"USD\").\n * @param cryptoCurrency - The cryptocurrency identifier.\n * @param network - The blockchain network identifier.\n * @param paymentMethod - The payment method identifier.\n * @param fiatAmount - The fiat amount as a string.\n * @returns The buy quote with pricing and fee details.\n */\nexport type RampsControllerTransakGetBuyQuoteAction = {\n type: `RampsController:transakGetBuyQuote`;\n handler: RampsController['transakGetBuyQuote'];\n};\n\n/**\n * Fetches the KYC requirement for a given quote.\n * Updates the kycRequirement resource state with loading/success/error states.\n *\n * @param quoteId - The quote ID to check KYC requirements for.\n * @returns The KYC requirement status and whether the user can place an order.\n */\nexport type RampsControllerTransakGetKycRequirementAction = {\n type: `RampsController:transakGetKycRequirement`;\n handler: RampsController['transakGetKycRequirement'];\n};\n\n/**\n * Fetches additional KYC requirements (e.g., ID proof, address proof) for a quote.\n *\n * @param quoteId - The quote ID to check additional requirements for.\n * @returns The list of additional forms required.\n */\nexport type RampsControllerTransakGetAdditionalRequirementsAction = {\n type: `RampsController:transakGetAdditionalRequirements`;\n handler: RampsController['transakGetAdditionalRequirements'];\n};\n\n/**\n * Creates a new order on Transak. If an existing order conflicts (HTTP 409),\n * active orders are cancelled and the creation is retried.\n *\n * @param quoteId - The quote ID to create an order from.\n * @param walletAddress - The destination wallet address.\n * @param paymentMethodId - The payment method to use.\n * @returns The created deposit order.\n */\nexport type RampsControllerTransakCreateOrderAction = {\n type: `RampsController:transakCreateOrder`;\n handler: RampsController['transakCreateOrder'];\n};\n\n/**\n * Fetches an existing order from Transak by order ID.\n *\n * @param orderId - The order ID (deposit format or raw Transak format).\n * @param wallet - The wallet address associated with the order.\n * @param paymentDetails - Optional payment details to attach to the order.\n * @returns The deposit order details.\n */\nexport type RampsControllerTransakGetOrderAction = {\n type: `RampsController:transakGetOrder`;\n handler: RampsController['transakGetOrder'];\n};\n\n/**\n * Fetches the user's spending limits for a given currency and payment method.\n *\n * @param fiatCurrency - The fiat currency code.\n * @param paymentMethod - The payment method identifier.\n * @param kycType - The KYC level type.\n * @returns The user's limits, spending, and remaining amounts.\n */\nexport type RampsControllerTransakGetUserLimitsAction = {\n type: `RampsController:transakGetUserLimits`;\n handler: RampsController['transakGetUserLimits'];\n};\n\n/**\n * Requests a one-time token (OTT) for the Transak payment widget.\n *\n * @returns The OTT response containing the token.\n */\nexport type RampsControllerTransakRequestOttAction = {\n type: `RampsController:transakRequestOtt`;\n handler: RampsController['transakRequestOtt'];\n};\n\n/**\n * Generates a URL for the Transak payment widget with pre-filled parameters.\n *\n * @param ottToken - The one-time token for widget authentication.\n * @param quote - The buy quote to pre-fill in the widget.\n * @param walletAddress - The destination wallet address.\n * @param extraParams - Optional additional URL parameters.\n * @returns The fully constructed widget URL string.\n */\nexport type RampsControllerTransakGeneratePaymentWidgetUrlAction = {\n type: `RampsController:transakGeneratePaymentWidgetUrl`;\n handler: RampsController['transakGeneratePaymentWidgetUrl'];\n};\n\n/**\n * Submits the user's purpose of usage form for KYC compliance.\n *\n * @param purpose - Array of purpose strings selected by the user.\n * @returns A promise that resolves when the form is submitted.\n */\nexport type RampsControllerTransakSubmitPurposeOfUsageFormAction = {\n type: `RampsController:transakSubmitPurposeOfUsageForm`;\n handler: RampsController['transakSubmitPurposeOfUsageForm'];\n};\n\n/**\n * Updates the user's personal or address details on Transak.\n *\n * @param data - The user data fields to update.\n * @returns The API response data.\n */\nexport type RampsControllerTransakPatchUserAction = {\n type: `RampsController:transakPatchUser`;\n handler: RampsController['transakPatchUser'];\n};\n\n/**\n * Submits the user's SSN for identity verification.\n *\n * @param ssn - The Social Security Number.\n * @param quoteId - The quote ID associated with the order requiring SSN.\n * @returns The API response data.\n */\nexport type RampsControllerTransakSubmitSsnDetailsAction = {\n type: `RampsController:transakSubmitSsnDetails`;\n handler: RampsController['transakSubmitSsnDetails'];\n};\n\n/**\n * Confirms payment for an order after the user has completed payment.\n *\n * @param orderId - The order ID to confirm payment for.\n * @param paymentMethodId - The payment method used.\n * @returns Whether the payment confirmation was successful.\n */\nexport type RampsControllerTransakConfirmPaymentAction = {\n type: `RampsController:transakConfirmPayment`;\n handler: RampsController['transakConfirmPayment'];\n};\n\n/**\n * Translates generic ramps identifiers to Transak-specific identifiers.\n *\n * @param request - The translation request with optional identifiers to translate.\n * @returns The translated Transak-specific identifiers.\n */\nexport type RampsControllerTransakGetTranslationAction = {\n type: `RampsController:transakGetTranslation`;\n handler: RampsController['transakGetTranslation'];\n};\n\n/**\n * Checks the status of an ID proof submission for KYC.\n *\n * @param workFlowRunId - The workflow run ID to check status for.\n * @returns The current ID proof status.\n */\nexport type RampsControllerTransakGetIdProofStatusAction = {\n type: `RampsController:transakGetIdProofStatus`;\n handler: RampsController['transakGetIdProofStatus'];\n};\n\n/**\n * Cancels a specific Transak order.\n *\n * @param depositOrderId - The deposit order ID to cancel.\n * @returns A promise that resolves when the order is cancelled.\n */\nexport type RampsControllerTransakCancelOrderAction = {\n type: `RampsController:transakCancelOrder`;\n handler: RampsController['transakCancelOrder'];\n};\n\n/**\n * Cancels all active Transak orders. Individual cancellation failures\n * are collected and returned rather than thrown.\n *\n * @returns An array of errors from any failed cancellations (empty if all succeeded).\n */\nexport type RampsControllerTransakCancelAllActiveOrdersAction = {\n type: `RampsController:transakCancelAllActiveOrders`;\n handler: RampsController['transakCancelAllActiveOrders'];\n};\n\n/**\n * Fetches all active Transak orders for the authenticated user.\n *\n * @returns The list of active orders.\n */\nexport type RampsControllerTransakGetActiveOrdersAction = {\n type: `RampsController:transakGetActiveOrders`;\n handler: RampsController['transakGetActiveOrders'];\n};\n\n/**\n * Union of all RampsController action types.\n */\nexport type RampsControllerMethodActions =\n | RampsControllerExecuteRequestAction\n | RampsControllerAbortRequestAction\n | RampsControllerGetRequestStateAction\n | RampsControllerSetUserRegionAction\n | RampsControllerSetSelectedProviderAction\n | RampsControllerInitAction\n | RampsControllerGetCountriesAction\n | RampsControllerGetTokensAction\n | RampsControllerSetSelectedTokenAction\n | RampsControllerGetProvidersAction\n | RampsControllerGetPaymentMethodsAction\n | RampsControllerSetSelectedPaymentMethodAction\n | RampsControllerGetQuotesAction\n | RampsControllerAddOrderAction\n | RampsControllerRemoveOrderAction\n | RampsControllerStartOrderPollingAction\n | RampsControllerStopOrderPollingAction\n | RampsControllerGetBuyWidgetDataAction\n | RampsControllerAddPrecreatedOrderAction\n | RampsControllerGetOrderAction\n | RampsControllerGetOrderFromCallbackAction\n | RampsControllerTransakSetApiKeyAction\n | RampsControllerTransakSetAccessTokenAction\n | RampsControllerTransakClearAccessTokenAction\n | RampsControllerTransakSetAuthenticatedAction\n | RampsControllerTransakResetStateAction\n | RampsControllerTransakSendUserOtpAction\n | RampsControllerTransakVerifyUserOtpAction\n | RampsControllerTransakLogoutAction\n | RampsControllerTransakGetUserDetailsAction\n | RampsControllerTransakGetBuyQuoteAction\n | RampsControllerTransakGetKycRequirementAction\n | RampsControllerTransakGetAdditionalRequirementsAction\n | RampsControllerTransakCreateOrderAction\n | RampsControllerTransakGetOrderAction\n | RampsControllerTransakGetUserLimitsAction\n | RampsControllerTransakRequestOttAction\n | RampsControllerTransakGeneratePaymentWidgetUrlAction\n | RampsControllerTransakSubmitPurposeOfUsageFormAction\n | RampsControllerTransakPatchUserAction\n | RampsControllerTransakSubmitSsnDetailsAction\n | RampsControllerTransakConfirmPaymentAction\n | RampsControllerTransakGetTranslationAction\n | RampsControllerTransakGetIdProofStatusAction\n | RampsControllerTransakCancelOrderAction\n | RampsControllerTransakCancelAllActiveOrdersAction\n | RampsControllerTransakGetActiveOrdersAction;\n"]}
|
|
@@ -214,7 +214,7 @@ export type RampsControllerGetQuotesAction = {
|
|
|
214
214
|
};
|
|
215
215
|
/**
|
|
216
216
|
* Adds or updates a V2 order in controller state.
|
|
217
|
-
* If an order with the same
|
|
217
|
+
* If an order with the same internal order code already exists, the incoming
|
|
218
218
|
* fields are merged on top of the existing order so that fields not present
|
|
219
219
|
* in the update (e.g. paymentDetails from the Transak API) are preserved.
|
|
220
220
|
*
|
|
@@ -214,7 +214,7 @@ export type RampsControllerGetQuotesAction = {
|
|
|
214
214
|
};
|
|
215
215
|
/**
|
|
216
216
|
* Adds or updates a V2 order in controller state.
|
|
217
|
-
* If an order with the same
|
|
217
|
+
* If an order with the same internal order code already exists, the incoming
|
|
218
218
|
* fields are merged on top of the existing order so that fields not present
|
|
219
219
|
* in the update (e.g. paymentDetails from the Transak API) are preserved.
|
|
220
220
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RampsController-method-action-types.mjs","sourceRoot":"","sources":["../src/RampsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { RampsController } from './RampsController';\n\n/**\n * Executes a request with caching, deduplication, and at most one in-flight\n * request per resource type.\n *\n * 1. **Same cache key in flight** – If a request with this cache key is\n * already pending, returns that promise (deduplication; no second request).\n *\n * 2. **Cache hit** – If valid, non-expired data exists in state.requests for\n * this key and forceRefresh is not set, returns that data without fetching.\n *\n * 3. **New request** – Creates an AbortController and fires the fetcher.\n * If options.resourceType is set, tags the pending request with that\n * resource type (so #abortDependentRequests can cancel it on region\n * change or cleanup) and ref-counts resource-level loading state.\n * On success or error, updates request state and resource error;\n * in finally, clears resource loading only if this request was not\n * aborted.\n *\n * @param cacheKey - Unique identifier for this request (e.g. from createCacheKey).\n * @param fetcher - Async function that performs the fetch. Receives an AbortSignal\n * that is aborted when this request is superseded by another for the same resource.\n * @param options - Optional forceRefresh, ttl, and resourceType for loading/error state.\n * @returns The result of the request (from cache, joined promise, or fetcher).\n */\nexport type RampsControllerExecuteRequestAction = {\n type: `RampsController:executeRequest`;\n handler: RampsController['executeRequest'];\n};\n\n/**\n * Aborts a pending request if one exists.\n *\n * @param cacheKey - The cache key of the request to abort.\n * @returns True if a request was aborted.\n */\nexport type RampsControllerAbortRequestAction = {\n type: `RampsController:abortRequest`;\n handler: RampsController['abortRequest'];\n};\n\n/**\n * Gets the state of a specific cached request.\n *\n * @param cacheKey - The cache key to look up.\n * @returns The request state, or undefined if not cached.\n */\nexport type RampsControllerGetRequestStateAction = {\n type: `RampsController:getRequestState`;\n handler: RampsController['getRequestState'];\n};\n\n/**\n * Sets the user's region manually (without fetching geolocation).\n * This allows users to override the detected region.\n *\n * @param region - The region code to set (e.g., \"US-CA\").\n * @param options - Options for cache behavior.\n * @returns The user region object.\n */\nexport type RampsControllerSetUserRegionAction = {\n type: `RampsController:setUserRegion`;\n handler: RampsController['setUserRegion'];\n};\n\n/**\n * Sets the user's selected provider.\n *\n * Accepts either a Provider object (stored directly) or a provider ID\n * string (looked up from state). The object form is preferred when the\n * caller already has the full data (e.g. from React Query cache).\n *\n * @param providerOrId - A Provider object, a provider ID string (e.g., \"/providers/moonpay\"), or null to clear.\n * @param options - Optional settings for the selection.\n * @param options.autoSelected - When true, marks the provider as system-guessed\n * (soft selection). The UI will silently auto-switch on token conflict instead\n * of showing the \"Token Not Available\" modal. Defaults to false.\n */\nexport type RampsControllerSetSelectedProviderAction = {\n type: `RampsController:setSelectedProvider`;\n handler: RampsController['setSelectedProvider'];\n};\n\n/**\n * Initializes the controller by fetching the user's region from geolocation.\n * This should be called once at app startup to set up the initial region.\n *\n * Idempotent: subsequent calls return the same promise unless forceRefresh is set.\n * Skips getCountries when countries are already loaded; skips geolocation when\n * userRegion already exists.\n *\n * @param options - Options for cache behavior. forceRefresh bypasses idempotency and re-runs the full flow.\n * @returns Promise that resolves when initialization is complete.\n */\nexport type RampsControllerInitAction = {\n type: `RampsController:init`;\n handler: RampsController['init'];\n};\n\n/**\n * Fetches the list of supported countries.\n * The API returns countries with support information for both buy and sell actions.\n * The countries are saved in the controller state once fetched.\n *\n * @param options - Options for cache behavior.\n * @returns An array of countries.\n */\nexport type RampsControllerGetCountriesAction = {\n type: `RampsController:getCountries`;\n handler: RampsController['getCountries'];\n};\n\n/**\n * Fetches the list of available tokens for a given region and action.\n * The tokens are saved in the controller state once fetched.\n *\n * @param region - The region code (e.g., \"us\", \"fr\", \"us-ny\"). If not provided, uses the user's region from controller state.\n * @param action - The ramp action type ('buy' or 'sell').\n * @param options - Options for cache behavior and query filters.\n * @param options.provider - Provider ID(s) to filter by.\n * @returns The tokens response containing topTokens and allTokens.\n */\nexport type RampsControllerGetTokensAction = {\n type: `RampsController:getTokens`;\n handler: RampsController['getTokens'];\n};\n\n/**\n * Sets the user's selected token by asset ID.\n * Looks up the token from the current tokens in state and automatically\n * fetches payment methods for that token.\n *\n * @param assetId - The asset identifier in CAIP-19 format (e.g., \"eip155:1/erc20:0x...\"), or undefined to clear.\n * @throws If region is not set, tokens are not loaded, or token is not found.\n */\nexport type RampsControllerSetSelectedTokenAction = {\n type: `RampsController:setSelectedToken`;\n handler: RampsController['setSelectedToken'];\n};\n\n/**\n * Fetches the list of providers for a given region.\n * The providers are saved in the controller state once fetched.\n *\n * @param region - The region code (e.g., \"us\", \"fr\", \"us-ny\"). If not provided, uses the user's region from controller state.\n * @param options - Options for cache behavior and query filters.\n * @param options.provider - Provider ID(s) to filter by.\n * @param options.crypto - Crypto currency ID(s) to filter by.\n * @param options.fiat - Fiat currency ID(s) to filter by.\n * @param options.payments - Payment method ID(s) to filter by.\n * @returns The providers response containing providers array.\n */\nexport type RampsControllerGetProvidersAction = {\n type: `RampsController:getProviders`;\n handler: RampsController['getProviders'];\n};\n\n/**\n * Fetches the list of payment methods for a given context.\n * The payment methods are saved in the controller state once fetched.\n *\n * @param region - User's region code (e.g. \"fr\", \"us-ny\").\n * @param options - Query parameters for filtering payment methods.\n * @param options.fiat - Fiat currency code (e.g., \"usd\"). If not provided, uses the user's region currency.\n * @param options.assetId - CAIP-19 cryptocurrency identifier.\n * @param options.provider - Provider ID path.\n * @returns The payment methods response containing payments array.\n */\nexport type RampsControllerGetPaymentMethodsAction = {\n type: `RampsController:getPaymentMethods`;\n handler: RampsController['getPaymentMethods'];\n};\n\n/**\n * Sets the user's selected payment method.\n *\n * Accepts either a payment method ID (looked up from state) or a full\n * PaymentMethod object (stored directly). The object form is preferred\n * when the caller already has the full data (e.g. from React Query cache),\n * as it avoids depending on controller state being populated.\n *\n * @param paymentMethodOrId - A PaymentMethod object, a payment method ID string, or undefined/null to clear.\n */\nexport type RampsControllerSetSelectedPaymentMethodAction = {\n type: `RampsController:setSelectedPaymentMethod`;\n handler: RampsController['setSelectedPaymentMethod'];\n};\n\n/**\n * Fetches quotes from all providers for a given set of parameters.\n * Uses the controller's request cache; callers manage the response in local state.\n *\n * @param options - The parameters for fetching quotes.\n * @param options.region - User's region code. If not provided, uses userRegion from state.\n * @param options.fiat - Fiat currency code. If not provided, uses userRegion currency.\n * @param options.assetId - CAIP-19 cryptocurrency identifier.\n * @param options.amount - The amount (in fiat for buy, crypto for sell).\n * @param options.walletAddress - The destination wallet address.\n * @param options.paymentMethods - Array of payment method IDs. If not provided, uses paymentMethods from state.\n * @param options.providers - Optional provider IDs to filter quotes.\n * @param options.autoSelectProvider - When true and `providers` is omitted,\n * resolves a provider that supports `assetId` for this request only (no\n * state mutation). Ignored when `providers` is passed.\n * @param options.preferredProviderIds - Optional provider IDs to prefer\n * during auto-selection, in priority order (e.g. derived by the caller\n * from completed-order history). Only used when `autoSelectProvider` is\n * true and `providers` is omitted.\n * @param options.restrictToKnownOrNativeProviders - Headless-buy v0 gating. When\n * true, auto-selection resolves only a native provider, and an explicitly\n * passed `providers` list is filtered to those supporting the region and\n * asset. If nothing qualifies, `getQuotes` returns an empty response\n * instead of quoting other providers.\n * @param options.redirectUrl - Optional redirect URL after order completion.\n * @param options.action - The ramp action type. Defaults to 'buy'.\n * @param options.forceRefresh - Whether to bypass cache.\n * @param options.ttl - Custom TTL for this request.\n * @returns The quotes response containing success, sorted, error, and customActions.\n */\nexport type RampsControllerGetQuotesAction = {\n type: `RampsController:getQuotes`;\n handler: RampsController['getQuotes'];\n};\n\n/**\n * Adds or updates a V2 order in controller state.\n * If an order with the same providerOrderId already exists, the incoming\n * fields are merged on top of the existing order so that fields not present\n * in the update (e.g. paymentDetails from the Transak API) are preserved.\n *\n * @param order - The RampsOrder to add or update.\n */\nexport type RampsControllerAddOrderAction = {\n type: `RampsController:addOrder`;\n handler: RampsController['addOrder'];\n};\n\n/**\n * Removes a V2 order from controller state by providerOrderId.\n *\n * @param providerOrderId - The provider order ID to remove.\n */\nexport type RampsControllerRemoveOrderAction = {\n type: `RampsController:removeOrder`;\n handler: RampsController['removeOrder'];\n};\n\n/**\n * Starts polling all pending V2 orders at a fixed interval.\n * Each poll cycle iterates orders with non-terminal statuses,\n * respects pollingSecondsMinimum and backoff from error count.\n */\nexport type RampsControllerStartOrderPollingAction = {\n type: `RampsController:startOrderPolling`;\n handler: RampsController['startOrderPolling'];\n};\n\n/**\n * Stops order polling and clears the interval.\n */\nexport type RampsControllerStopOrderPollingAction = {\n type: `RampsController:stopOrderPolling`;\n handler: RampsController['stopOrderPolling'];\n};\n\n/**\n * Fetches the widget data from a quote for redirect providers.\n * Makes a request to the buyURL endpoint via the RampsService to get the\n * actual provider widget URL and optional order ID for polling.\n *\n * @param quote - The quote to fetch the widget URL from.\n * @returns Promise resolving to the full BuyWidget (url, browser, orderId), or null if not available (missing buyURL or empty url in response).\n * @throws Rethrows errors from the RampsService (e.g. HttpError, network failures) so clients can react to fetch failures.\n */\nexport type RampsControllerGetBuyWidgetDataAction = {\n type: `RampsController:getBuyWidgetData`;\n handler: RampsController['getBuyWidgetData'];\n};\n\n/**\n * Registers an order ID for polling until the order is created or resolved.\n * Adds a minimal stub order to controller state; the existing order polling\n * will fetch the full order when the provider has created it.\n *\n * @param params - Object containing order identifiers and wallet info.\n * @param params.orderId - Full order ID (e.g. \"/providers/paypal/orders/abc123\") or order code.\n * @param params.providerCode - Provider code (e.g. \"paypal\", \"transak\"), with or without /providers/ prefix.\n * @param params.walletAddress - Wallet address for the order.\n * @param params.chainId - Optional chain ID for the order.\n */\nexport type RampsControllerAddPrecreatedOrderAction = {\n type: `RampsController:addPrecreatedOrder`;\n handler: RampsController['addPrecreatedOrder'];\n};\n\n/**\n * Fetches an order from the unified V2 API endpoint.\n * Returns a normalized RampsOrder for all provider types (aggregator and native).\n *\n * @param providerCode - The provider code (e.g., \"transak\", \"transak-native\", \"moonpay\").\n * @param orderCode - The order identifier.\n * @param wallet - The wallet address associated with the order.\n * @returns The unified order data.\n */\nexport type RampsControllerGetOrderAction = {\n type: `RampsController:getOrder`;\n handler: RampsController['getOrder'];\n};\n\n/**\n * Extracts an order from a provider callback URL.\n * Sends the callback URL to the V2 backend for provider-specific parsing,\n * then fetches the full order. This is the V2 equivalent of the aggregator\n * SDK's `getOrderFromCallback`.\n *\n * @param providerCode - The provider code (e.g., \"transak\", \"moonpay\").\n * @param callbackUrl - The full callback URL the provider redirected to.\n * @param wallet - The wallet address associated with the order.\n * @returns The unified order data.\n */\nexport type RampsControllerGetOrderFromCallbackAction = {\n type: `RampsController:getOrderFromCallback`;\n handler: RampsController['getOrderFromCallback'];\n};\n\n/**\n * Sets the Transak API key used for all Transak API requests.\n *\n * @param apiKey - The Transak API key.\n */\nexport type RampsControllerTransakSetApiKeyAction = {\n type: `RampsController:transakSetApiKey`;\n handler: RampsController['transakSetApiKey'];\n};\n\n/**\n * Sets the Transak access token and marks the user as authenticated.\n *\n * @param token - The access token received from Transak auth.\n */\nexport type RampsControllerTransakSetAccessTokenAction = {\n type: `RampsController:transakSetAccessToken`;\n handler: RampsController['transakSetAccessToken'];\n};\n\n/**\n * Clears the Transak access token and marks the user as unauthenticated.\n */\nexport type RampsControllerTransakClearAccessTokenAction = {\n type: `RampsController:transakClearAccessToken`;\n handler: RampsController['transakClearAccessToken'];\n};\n\n/**\n * Updates the Transak authentication flag in controller state.\n *\n * @param isAuthenticated - Whether the user is authenticated with Transak.\n */\nexport type RampsControllerTransakSetAuthenticatedAction = {\n type: `RampsController:transakSetAuthenticated`;\n handler: RampsController['transakSetAuthenticated'];\n};\n\n/**\n * Resets all Transak state back to defaults (unauthenticated, no data).\n */\nexport type RampsControllerTransakResetStateAction = {\n type: `RampsController:transakResetState`;\n handler: RampsController['transakResetState'];\n};\n\n/**\n * Sends a one-time password to the user's email for Transak authentication.\n *\n * @param email - The user's email address.\n * @returns The OTP response containing a state token for verification.\n */\nexport type RampsControllerTransakSendUserOtpAction = {\n type: `RampsController:transakSendUserOtp`;\n handler: RampsController['transakSendUserOtp'];\n};\n\n/**\n * Verifies a one-time password and authenticates the user with Transak.\n * Updates the controller's authentication state on success.\n *\n * @param email - The user's email address.\n * @param verificationCode - The OTP code entered by the user.\n * @param stateToken - The state token from the sendUserOtp response.\n * @returns The access token for subsequent authenticated requests.\n */\nexport type RampsControllerTransakVerifyUserOtpAction = {\n type: `RampsController:transakVerifyUserOtp`;\n handler: RampsController['transakVerifyUserOtp'];\n};\n\n/**\n * Logs the user out of Transak. Clears authentication state and user details\n * regardless of whether the API call succeeds or fails.\n *\n * @returns A message indicating the logout result.\n */\nexport type RampsControllerTransakLogoutAction = {\n type: `RampsController:transakLogout`;\n handler: RampsController['transakLogout'];\n};\n\n/**\n * Fetches the authenticated user's details from Transak.\n * Updates the userDetails resource state with loading/success/error states.\n *\n * @returns The user's profile and KYC details.\n */\nexport type RampsControllerTransakGetUserDetailsAction = {\n type: `RampsController:transakGetUserDetails`;\n handler: RampsController['transakGetUserDetails'];\n};\n\n/**\n * Fetches a buy quote from Transak for the given parameters.\n * Updates the buyQuote resource state with loading/success/error states.\n *\n * @param fiatCurrency - The fiat currency code (e.g., \"USD\").\n * @param cryptoCurrency - The cryptocurrency identifier.\n * @param network - The blockchain network identifier.\n * @param paymentMethod - The payment method identifier.\n * @param fiatAmount - The fiat amount as a string.\n * @returns The buy quote with pricing and fee details.\n */\nexport type RampsControllerTransakGetBuyQuoteAction = {\n type: `RampsController:transakGetBuyQuote`;\n handler: RampsController['transakGetBuyQuote'];\n};\n\n/**\n * Fetches the KYC requirement for a given quote.\n * Updates the kycRequirement resource state with loading/success/error states.\n *\n * @param quoteId - The quote ID to check KYC requirements for.\n * @returns The KYC requirement status and whether the user can place an order.\n */\nexport type RampsControllerTransakGetKycRequirementAction = {\n type: `RampsController:transakGetKycRequirement`;\n handler: RampsController['transakGetKycRequirement'];\n};\n\n/**\n * Fetches additional KYC requirements (e.g., ID proof, address proof) for a quote.\n *\n * @param quoteId - The quote ID to check additional requirements for.\n * @returns The list of additional forms required.\n */\nexport type RampsControllerTransakGetAdditionalRequirementsAction = {\n type: `RampsController:transakGetAdditionalRequirements`;\n handler: RampsController['transakGetAdditionalRequirements'];\n};\n\n/**\n * Creates a new order on Transak. If an existing order conflicts (HTTP 409),\n * active orders are cancelled and the creation is retried.\n *\n * @param quoteId - The quote ID to create an order from.\n * @param walletAddress - The destination wallet address.\n * @param paymentMethodId - The payment method to use.\n * @returns The created deposit order.\n */\nexport type RampsControllerTransakCreateOrderAction = {\n type: `RampsController:transakCreateOrder`;\n handler: RampsController['transakCreateOrder'];\n};\n\n/**\n * Fetches an existing order from Transak by order ID.\n *\n * @param orderId - The order ID (deposit format or raw Transak format).\n * @param wallet - The wallet address associated with the order.\n * @param paymentDetails - Optional payment details to attach to the order.\n * @returns The deposit order details.\n */\nexport type RampsControllerTransakGetOrderAction = {\n type: `RampsController:transakGetOrder`;\n handler: RampsController['transakGetOrder'];\n};\n\n/**\n * Fetches the user's spending limits for a given currency and payment method.\n *\n * @param fiatCurrency - The fiat currency code.\n * @param paymentMethod - The payment method identifier.\n * @param kycType - The KYC level type.\n * @returns The user's limits, spending, and remaining amounts.\n */\nexport type RampsControllerTransakGetUserLimitsAction = {\n type: `RampsController:transakGetUserLimits`;\n handler: RampsController['transakGetUserLimits'];\n};\n\n/**\n * Requests a one-time token (OTT) for the Transak payment widget.\n *\n * @returns The OTT response containing the token.\n */\nexport type RampsControllerTransakRequestOttAction = {\n type: `RampsController:transakRequestOtt`;\n handler: RampsController['transakRequestOtt'];\n};\n\n/**\n * Generates a URL for the Transak payment widget with pre-filled parameters.\n *\n * @param ottToken - The one-time token for widget authentication.\n * @param quote - The buy quote to pre-fill in the widget.\n * @param walletAddress - The destination wallet address.\n * @param extraParams - Optional additional URL parameters.\n * @returns The fully constructed widget URL string.\n */\nexport type RampsControllerTransakGeneratePaymentWidgetUrlAction = {\n type: `RampsController:transakGeneratePaymentWidgetUrl`;\n handler: RampsController['transakGeneratePaymentWidgetUrl'];\n};\n\n/**\n * Submits the user's purpose of usage form for KYC compliance.\n *\n * @param purpose - Array of purpose strings selected by the user.\n * @returns A promise that resolves when the form is submitted.\n */\nexport type RampsControllerTransakSubmitPurposeOfUsageFormAction = {\n type: `RampsController:transakSubmitPurposeOfUsageForm`;\n handler: RampsController['transakSubmitPurposeOfUsageForm'];\n};\n\n/**\n * Updates the user's personal or address details on Transak.\n *\n * @param data - The user data fields to update.\n * @returns The API response data.\n */\nexport type RampsControllerTransakPatchUserAction = {\n type: `RampsController:transakPatchUser`;\n handler: RampsController['transakPatchUser'];\n};\n\n/**\n * Submits the user's SSN for identity verification.\n *\n * @param ssn - The Social Security Number.\n * @param quoteId - The quote ID associated with the order requiring SSN.\n * @returns The API response data.\n */\nexport type RampsControllerTransakSubmitSsnDetailsAction = {\n type: `RampsController:transakSubmitSsnDetails`;\n handler: RampsController['transakSubmitSsnDetails'];\n};\n\n/**\n * Confirms payment for an order after the user has completed payment.\n *\n * @param orderId - The order ID to confirm payment for.\n * @param paymentMethodId - The payment method used.\n * @returns Whether the payment confirmation was successful.\n */\nexport type RampsControllerTransakConfirmPaymentAction = {\n type: `RampsController:transakConfirmPayment`;\n handler: RampsController['transakConfirmPayment'];\n};\n\n/**\n * Translates generic ramps identifiers to Transak-specific identifiers.\n *\n * @param request - The translation request with optional identifiers to translate.\n * @returns The translated Transak-specific identifiers.\n */\nexport type RampsControllerTransakGetTranslationAction = {\n type: `RampsController:transakGetTranslation`;\n handler: RampsController['transakGetTranslation'];\n};\n\n/**\n * Checks the status of an ID proof submission for KYC.\n *\n * @param workFlowRunId - The workflow run ID to check status for.\n * @returns The current ID proof status.\n */\nexport type RampsControllerTransakGetIdProofStatusAction = {\n type: `RampsController:transakGetIdProofStatus`;\n handler: RampsController['transakGetIdProofStatus'];\n};\n\n/**\n * Cancels a specific Transak order.\n *\n * @param depositOrderId - The deposit order ID to cancel.\n * @returns A promise that resolves when the order is cancelled.\n */\nexport type RampsControllerTransakCancelOrderAction = {\n type: `RampsController:transakCancelOrder`;\n handler: RampsController['transakCancelOrder'];\n};\n\n/**\n * Cancels all active Transak orders. Individual cancellation failures\n * are collected and returned rather than thrown.\n *\n * @returns An array of errors from any failed cancellations (empty if all succeeded).\n */\nexport type RampsControllerTransakCancelAllActiveOrdersAction = {\n type: `RampsController:transakCancelAllActiveOrders`;\n handler: RampsController['transakCancelAllActiveOrders'];\n};\n\n/**\n * Fetches all active Transak orders for the authenticated user.\n *\n * @returns The list of active orders.\n */\nexport type RampsControllerTransakGetActiveOrdersAction = {\n type: `RampsController:transakGetActiveOrders`;\n handler: RampsController['transakGetActiveOrders'];\n};\n\n/**\n * Union of all RampsController action types.\n */\nexport type RampsControllerMethodActions =\n | RampsControllerExecuteRequestAction\n | RampsControllerAbortRequestAction\n | RampsControllerGetRequestStateAction\n | RampsControllerSetUserRegionAction\n | RampsControllerSetSelectedProviderAction\n | RampsControllerInitAction\n | RampsControllerGetCountriesAction\n | RampsControllerGetTokensAction\n | RampsControllerSetSelectedTokenAction\n | RampsControllerGetProvidersAction\n | RampsControllerGetPaymentMethodsAction\n | RampsControllerSetSelectedPaymentMethodAction\n | RampsControllerGetQuotesAction\n | RampsControllerAddOrderAction\n | RampsControllerRemoveOrderAction\n | RampsControllerStartOrderPollingAction\n | RampsControllerStopOrderPollingAction\n | RampsControllerGetBuyWidgetDataAction\n | RampsControllerAddPrecreatedOrderAction\n | RampsControllerGetOrderAction\n | RampsControllerGetOrderFromCallbackAction\n | RampsControllerTransakSetApiKeyAction\n | RampsControllerTransakSetAccessTokenAction\n | RampsControllerTransakClearAccessTokenAction\n | RampsControllerTransakSetAuthenticatedAction\n | RampsControllerTransakResetStateAction\n | RampsControllerTransakSendUserOtpAction\n | RampsControllerTransakVerifyUserOtpAction\n | RampsControllerTransakLogoutAction\n | RampsControllerTransakGetUserDetailsAction\n | RampsControllerTransakGetBuyQuoteAction\n | RampsControllerTransakGetKycRequirementAction\n | RampsControllerTransakGetAdditionalRequirementsAction\n | RampsControllerTransakCreateOrderAction\n | RampsControllerTransakGetOrderAction\n | RampsControllerTransakGetUserLimitsAction\n | RampsControllerTransakRequestOttAction\n | RampsControllerTransakGeneratePaymentWidgetUrlAction\n | RampsControllerTransakSubmitPurposeOfUsageFormAction\n | RampsControllerTransakPatchUserAction\n | RampsControllerTransakSubmitSsnDetailsAction\n | RampsControllerTransakConfirmPaymentAction\n | RampsControllerTransakGetTranslationAction\n | RampsControllerTransakGetIdProofStatusAction\n | RampsControllerTransakCancelOrderAction\n | RampsControllerTransakCancelAllActiveOrdersAction\n | RampsControllerTransakGetActiveOrdersAction;\n"]}
|
|
1
|
+
{"version":3,"file":"RampsController-method-action-types.mjs","sourceRoot":"","sources":["../src/RampsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { RampsController } from './RampsController';\n\n/**\n * Executes a request with caching, deduplication, and at most one in-flight\n * request per resource type.\n *\n * 1. **Same cache key in flight** – If a request with this cache key is\n * already pending, returns that promise (deduplication; no second request).\n *\n * 2. **Cache hit** – If valid, non-expired data exists in state.requests for\n * this key and forceRefresh is not set, returns that data without fetching.\n *\n * 3. **New request** – Creates an AbortController and fires the fetcher.\n * If options.resourceType is set, tags the pending request with that\n * resource type (so #abortDependentRequests can cancel it on region\n * change or cleanup) and ref-counts resource-level loading state.\n * On success or error, updates request state and resource error;\n * in finally, clears resource loading only if this request was not\n * aborted.\n *\n * @param cacheKey - Unique identifier for this request (e.g. from createCacheKey).\n * @param fetcher - Async function that performs the fetch. Receives an AbortSignal\n * that is aborted when this request is superseded by another for the same resource.\n * @param options - Optional forceRefresh, ttl, and resourceType for loading/error state.\n * @returns The result of the request (from cache, joined promise, or fetcher).\n */\nexport type RampsControllerExecuteRequestAction = {\n type: `RampsController:executeRequest`;\n handler: RampsController['executeRequest'];\n};\n\n/**\n * Aborts a pending request if one exists.\n *\n * @param cacheKey - The cache key of the request to abort.\n * @returns True if a request was aborted.\n */\nexport type RampsControllerAbortRequestAction = {\n type: `RampsController:abortRequest`;\n handler: RampsController['abortRequest'];\n};\n\n/**\n * Gets the state of a specific cached request.\n *\n * @param cacheKey - The cache key to look up.\n * @returns The request state, or undefined if not cached.\n */\nexport type RampsControllerGetRequestStateAction = {\n type: `RampsController:getRequestState`;\n handler: RampsController['getRequestState'];\n};\n\n/**\n * Sets the user's region manually (without fetching geolocation).\n * This allows users to override the detected region.\n *\n * @param region - The region code to set (e.g., \"US-CA\").\n * @param options - Options for cache behavior.\n * @returns The user region object.\n */\nexport type RampsControllerSetUserRegionAction = {\n type: `RampsController:setUserRegion`;\n handler: RampsController['setUserRegion'];\n};\n\n/**\n * Sets the user's selected provider.\n *\n * Accepts either a Provider object (stored directly) or a provider ID\n * string (looked up from state). The object form is preferred when the\n * caller already has the full data (e.g. from React Query cache).\n *\n * @param providerOrId - A Provider object, a provider ID string (e.g., \"/providers/moonpay\"), or null to clear.\n * @param options - Optional settings for the selection.\n * @param options.autoSelected - When true, marks the provider as system-guessed\n * (soft selection). The UI will silently auto-switch on token conflict instead\n * of showing the \"Token Not Available\" modal. Defaults to false.\n */\nexport type RampsControllerSetSelectedProviderAction = {\n type: `RampsController:setSelectedProvider`;\n handler: RampsController['setSelectedProvider'];\n};\n\n/**\n * Initializes the controller by fetching the user's region from geolocation.\n * This should be called once at app startup to set up the initial region.\n *\n * Idempotent: subsequent calls return the same promise unless forceRefresh is set.\n * Skips getCountries when countries are already loaded; skips geolocation when\n * userRegion already exists.\n *\n * @param options - Options for cache behavior. forceRefresh bypasses idempotency and re-runs the full flow.\n * @returns Promise that resolves when initialization is complete.\n */\nexport type RampsControllerInitAction = {\n type: `RampsController:init`;\n handler: RampsController['init'];\n};\n\n/**\n * Fetches the list of supported countries.\n * The API returns countries with support information for both buy and sell actions.\n * The countries are saved in the controller state once fetched.\n *\n * @param options - Options for cache behavior.\n * @returns An array of countries.\n */\nexport type RampsControllerGetCountriesAction = {\n type: `RampsController:getCountries`;\n handler: RampsController['getCountries'];\n};\n\n/**\n * Fetches the list of available tokens for a given region and action.\n * The tokens are saved in the controller state once fetched.\n *\n * @param region - The region code (e.g., \"us\", \"fr\", \"us-ny\"). If not provided, uses the user's region from controller state.\n * @param action - The ramp action type ('buy' or 'sell').\n * @param options - Options for cache behavior and query filters.\n * @param options.provider - Provider ID(s) to filter by.\n * @returns The tokens response containing topTokens and allTokens.\n */\nexport type RampsControllerGetTokensAction = {\n type: `RampsController:getTokens`;\n handler: RampsController['getTokens'];\n};\n\n/**\n * Sets the user's selected token by asset ID.\n * Looks up the token from the current tokens in state and automatically\n * fetches payment methods for that token.\n *\n * @param assetId - The asset identifier in CAIP-19 format (e.g., \"eip155:1/erc20:0x...\"), or undefined to clear.\n * @throws If region is not set, tokens are not loaded, or token is not found.\n */\nexport type RampsControllerSetSelectedTokenAction = {\n type: `RampsController:setSelectedToken`;\n handler: RampsController['setSelectedToken'];\n};\n\n/**\n * Fetches the list of providers for a given region.\n * The providers are saved in the controller state once fetched.\n *\n * @param region - The region code (e.g., \"us\", \"fr\", \"us-ny\"). If not provided, uses the user's region from controller state.\n * @param options - Options for cache behavior and query filters.\n * @param options.provider - Provider ID(s) to filter by.\n * @param options.crypto - Crypto currency ID(s) to filter by.\n * @param options.fiat - Fiat currency ID(s) to filter by.\n * @param options.payments - Payment method ID(s) to filter by.\n * @returns The providers response containing providers array.\n */\nexport type RampsControllerGetProvidersAction = {\n type: `RampsController:getProviders`;\n handler: RampsController['getProviders'];\n};\n\n/**\n * Fetches the list of payment methods for a given context.\n * The payment methods are saved in the controller state once fetched.\n *\n * @param region - User's region code (e.g. \"fr\", \"us-ny\").\n * @param options - Query parameters for filtering payment methods.\n * @param options.fiat - Fiat currency code (e.g., \"usd\"). If not provided, uses the user's region currency.\n * @param options.assetId - CAIP-19 cryptocurrency identifier.\n * @param options.provider - Provider ID path.\n * @returns The payment methods response containing payments array.\n */\nexport type RampsControllerGetPaymentMethodsAction = {\n type: `RampsController:getPaymentMethods`;\n handler: RampsController['getPaymentMethods'];\n};\n\n/**\n * Sets the user's selected payment method.\n *\n * Accepts either a payment method ID (looked up from state) or a full\n * PaymentMethod object (stored directly). The object form is preferred\n * when the caller already has the full data (e.g. from React Query cache),\n * as it avoids depending on controller state being populated.\n *\n * @param paymentMethodOrId - A PaymentMethod object, a payment method ID string, or undefined/null to clear.\n */\nexport type RampsControllerSetSelectedPaymentMethodAction = {\n type: `RampsController:setSelectedPaymentMethod`;\n handler: RampsController['setSelectedPaymentMethod'];\n};\n\n/**\n * Fetches quotes from all providers for a given set of parameters.\n * Uses the controller's request cache; callers manage the response in local state.\n *\n * @param options - The parameters for fetching quotes.\n * @param options.region - User's region code. If not provided, uses userRegion from state.\n * @param options.fiat - Fiat currency code. If not provided, uses userRegion currency.\n * @param options.assetId - CAIP-19 cryptocurrency identifier.\n * @param options.amount - The amount (in fiat for buy, crypto for sell).\n * @param options.walletAddress - The destination wallet address.\n * @param options.paymentMethods - Array of payment method IDs. If not provided, uses paymentMethods from state.\n * @param options.providers - Optional provider IDs to filter quotes.\n * @param options.autoSelectProvider - When true and `providers` is omitted,\n * resolves a provider that supports `assetId` for this request only (no\n * state mutation). Ignored when `providers` is passed.\n * @param options.preferredProviderIds - Optional provider IDs to prefer\n * during auto-selection, in priority order (e.g. derived by the caller\n * from completed-order history). Only used when `autoSelectProvider` is\n * true and `providers` is omitted.\n * @param options.restrictToKnownOrNativeProviders - Headless-buy v0 gating. When\n * true, auto-selection resolves only a native provider, and an explicitly\n * passed `providers` list is filtered to those supporting the region and\n * asset. If nothing qualifies, `getQuotes` returns an empty response\n * instead of quoting other providers.\n * @param options.redirectUrl - Optional redirect URL after order completion.\n * @param options.action - The ramp action type. Defaults to 'buy'.\n * @param options.forceRefresh - Whether to bypass cache.\n * @param options.ttl - Custom TTL for this request.\n * @returns The quotes response containing success, sorted, error, and customActions.\n */\nexport type RampsControllerGetQuotesAction = {\n type: `RampsController:getQuotes`;\n handler: RampsController['getQuotes'];\n};\n\n/**\n * Adds or updates a V2 order in controller state.\n * If an order with the same internal order code already exists, the incoming\n * fields are merged on top of the existing order so that fields not present\n * in the update (e.g. paymentDetails from the Transak API) are preserved.\n *\n * @param order - The RampsOrder to add or update.\n */\nexport type RampsControllerAddOrderAction = {\n type: `RampsController:addOrder`;\n handler: RampsController['addOrder'];\n};\n\n/**\n * Removes a V2 order from controller state by providerOrderId.\n *\n * @param providerOrderId - The provider order ID to remove.\n */\nexport type RampsControllerRemoveOrderAction = {\n type: `RampsController:removeOrder`;\n handler: RampsController['removeOrder'];\n};\n\n/**\n * Starts polling all pending V2 orders at a fixed interval.\n * Each poll cycle iterates orders with non-terminal statuses,\n * respects pollingSecondsMinimum and backoff from error count.\n */\nexport type RampsControllerStartOrderPollingAction = {\n type: `RampsController:startOrderPolling`;\n handler: RampsController['startOrderPolling'];\n};\n\n/**\n * Stops order polling and clears the interval.\n */\nexport type RampsControllerStopOrderPollingAction = {\n type: `RampsController:stopOrderPolling`;\n handler: RampsController['stopOrderPolling'];\n};\n\n/**\n * Fetches the widget data from a quote for redirect providers.\n * Makes a request to the buyURL endpoint via the RampsService to get the\n * actual provider widget URL and optional order ID for polling.\n *\n * @param quote - The quote to fetch the widget URL from.\n * @returns Promise resolving to the full BuyWidget (url, browser, orderId), or null if not available (missing buyURL or empty url in response).\n * @throws Rethrows errors from the RampsService (e.g. HttpError, network failures) so clients can react to fetch failures.\n */\nexport type RampsControllerGetBuyWidgetDataAction = {\n type: `RampsController:getBuyWidgetData`;\n handler: RampsController['getBuyWidgetData'];\n};\n\n/**\n * Registers an order ID for polling until the order is created or resolved.\n * Adds a minimal stub order to controller state; the existing order polling\n * will fetch the full order when the provider has created it.\n *\n * @param params - Object containing order identifiers and wallet info.\n * @param params.orderId - Full order ID (e.g. \"/providers/paypal/orders/abc123\") or order code.\n * @param params.providerCode - Provider code (e.g. \"paypal\", \"transak\"), with or without /providers/ prefix.\n * @param params.walletAddress - Wallet address for the order.\n * @param params.chainId - Optional chain ID for the order.\n */\nexport type RampsControllerAddPrecreatedOrderAction = {\n type: `RampsController:addPrecreatedOrder`;\n handler: RampsController['addPrecreatedOrder'];\n};\n\n/**\n * Fetches an order from the unified V2 API endpoint.\n * Returns a normalized RampsOrder for all provider types (aggregator and native).\n *\n * @param providerCode - The provider code (e.g., \"transak\", \"transak-native\", \"moonpay\").\n * @param orderCode - The order identifier.\n * @param wallet - The wallet address associated with the order.\n * @returns The unified order data.\n */\nexport type RampsControllerGetOrderAction = {\n type: `RampsController:getOrder`;\n handler: RampsController['getOrder'];\n};\n\n/**\n * Extracts an order from a provider callback URL.\n * Sends the callback URL to the V2 backend for provider-specific parsing,\n * then fetches the full order. This is the V2 equivalent of the aggregator\n * SDK's `getOrderFromCallback`.\n *\n * @param providerCode - The provider code (e.g., \"transak\", \"moonpay\").\n * @param callbackUrl - The full callback URL the provider redirected to.\n * @param wallet - The wallet address associated with the order.\n * @returns The unified order data.\n */\nexport type RampsControllerGetOrderFromCallbackAction = {\n type: `RampsController:getOrderFromCallback`;\n handler: RampsController['getOrderFromCallback'];\n};\n\n/**\n * Sets the Transak API key used for all Transak API requests.\n *\n * @param apiKey - The Transak API key.\n */\nexport type RampsControllerTransakSetApiKeyAction = {\n type: `RampsController:transakSetApiKey`;\n handler: RampsController['transakSetApiKey'];\n};\n\n/**\n * Sets the Transak access token and marks the user as authenticated.\n *\n * @param token - The access token received from Transak auth.\n */\nexport type RampsControllerTransakSetAccessTokenAction = {\n type: `RampsController:transakSetAccessToken`;\n handler: RampsController['transakSetAccessToken'];\n};\n\n/**\n * Clears the Transak access token and marks the user as unauthenticated.\n */\nexport type RampsControllerTransakClearAccessTokenAction = {\n type: `RampsController:transakClearAccessToken`;\n handler: RampsController['transakClearAccessToken'];\n};\n\n/**\n * Updates the Transak authentication flag in controller state.\n *\n * @param isAuthenticated - Whether the user is authenticated with Transak.\n */\nexport type RampsControllerTransakSetAuthenticatedAction = {\n type: `RampsController:transakSetAuthenticated`;\n handler: RampsController['transakSetAuthenticated'];\n};\n\n/**\n * Resets all Transak state back to defaults (unauthenticated, no data).\n */\nexport type RampsControllerTransakResetStateAction = {\n type: `RampsController:transakResetState`;\n handler: RampsController['transakResetState'];\n};\n\n/**\n * Sends a one-time password to the user's email for Transak authentication.\n *\n * @param email - The user's email address.\n * @returns The OTP response containing a state token for verification.\n */\nexport type RampsControllerTransakSendUserOtpAction = {\n type: `RampsController:transakSendUserOtp`;\n handler: RampsController['transakSendUserOtp'];\n};\n\n/**\n * Verifies a one-time password and authenticates the user with Transak.\n * Updates the controller's authentication state on success.\n *\n * @param email - The user's email address.\n * @param verificationCode - The OTP code entered by the user.\n * @param stateToken - The state token from the sendUserOtp response.\n * @returns The access token for subsequent authenticated requests.\n */\nexport type RampsControllerTransakVerifyUserOtpAction = {\n type: `RampsController:transakVerifyUserOtp`;\n handler: RampsController['transakVerifyUserOtp'];\n};\n\n/**\n * Logs the user out of Transak. Clears authentication state and user details\n * regardless of whether the API call succeeds or fails.\n *\n * @returns A message indicating the logout result.\n */\nexport type RampsControllerTransakLogoutAction = {\n type: `RampsController:transakLogout`;\n handler: RampsController['transakLogout'];\n};\n\n/**\n * Fetches the authenticated user's details from Transak.\n * Updates the userDetails resource state with loading/success/error states.\n *\n * @returns The user's profile and KYC details.\n */\nexport type RampsControllerTransakGetUserDetailsAction = {\n type: `RampsController:transakGetUserDetails`;\n handler: RampsController['transakGetUserDetails'];\n};\n\n/**\n * Fetches a buy quote from Transak for the given parameters.\n * Updates the buyQuote resource state with loading/success/error states.\n *\n * @param fiatCurrency - The fiat currency code (e.g., \"USD\").\n * @param cryptoCurrency - The cryptocurrency identifier.\n * @param network - The blockchain network identifier.\n * @param paymentMethod - The payment method identifier.\n * @param fiatAmount - The fiat amount as a string.\n * @returns The buy quote with pricing and fee details.\n */\nexport type RampsControllerTransakGetBuyQuoteAction = {\n type: `RampsController:transakGetBuyQuote`;\n handler: RampsController['transakGetBuyQuote'];\n};\n\n/**\n * Fetches the KYC requirement for a given quote.\n * Updates the kycRequirement resource state with loading/success/error states.\n *\n * @param quoteId - The quote ID to check KYC requirements for.\n * @returns The KYC requirement status and whether the user can place an order.\n */\nexport type RampsControllerTransakGetKycRequirementAction = {\n type: `RampsController:transakGetKycRequirement`;\n handler: RampsController['transakGetKycRequirement'];\n};\n\n/**\n * Fetches additional KYC requirements (e.g., ID proof, address proof) for a quote.\n *\n * @param quoteId - The quote ID to check additional requirements for.\n * @returns The list of additional forms required.\n */\nexport type RampsControllerTransakGetAdditionalRequirementsAction = {\n type: `RampsController:transakGetAdditionalRequirements`;\n handler: RampsController['transakGetAdditionalRequirements'];\n};\n\n/**\n * Creates a new order on Transak. If an existing order conflicts (HTTP 409),\n * active orders are cancelled and the creation is retried.\n *\n * @param quoteId - The quote ID to create an order from.\n * @param walletAddress - The destination wallet address.\n * @param paymentMethodId - The payment method to use.\n * @returns The created deposit order.\n */\nexport type RampsControllerTransakCreateOrderAction = {\n type: `RampsController:transakCreateOrder`;\n handler: RampsController['transakCreateOrder'];\n};\n\n/**\n * Fetches an existing order from Transak by order ID.\n *\n * @param orderId - The order ID (deposit format or raw Transak format).\n * @param wallet - The wallet address associated with the order.\n * @param paymentDetails - Optional payment details to attach to the order.\n * @returns The deposit order details.\n */\nexport type RampsControllerTransakGetOrderAction = {\n type: `RampsController:transakGetOrder`;\n handler: RampsController['transakGetOrder'];\n};\n\n/**\n * Fetches the user's spending limits for a given currency and payment method.\n *\n * @param fiatCurrency - The fiat currency code.\n * @param paymentMethod - The payment method identifier.\n * @param kycType - The KYC level type.\n * @returns The user's limits, spending, and remaining amounts.\n */\nexport type RampsControllerTransakGetUserLimitsAction = {\n type: `RampsController:transakGetUserLimits`;\n handler: RampsController['transakGetUserLimits'];\n};\n\n/**\n * Requests a one-time token (OTT) for the Transak payment widget.\n *\n * @returns The OTT response containing the token.\n */\nexport type RampsControllerTransakRequestOttAction = {\n type: `RampsController:transakRequestOtt`;\n handler: RampsController['transakRequestOtt'];\n};\n\n/**\n * Generates a URL for the Transak payment widget with pre-filled parameters.\n *\n * @param ottToken - The one-time token for widget authentication.\n * @param quote - The buy quote to pre-fill in the widget.\n * @param walletAddress - The destination wallet address.\n * @param extraParams - Optional additional URL parameters.\n * @returns The fully constructed widget URL string.\n */\nexport type RampsControllerTransakGeneratePaymentWidgetUrlAction = {\n type: `RampsController:transakGeneratePaymentWidgetUrl`;\n handler: RampsController['transakGeneratePaymentWidgetUrl'];\n};\n\n/**\n * Submits the user's purpose of usage form for KYC compliance.\n *\n * @param purpose - Array of purpose strings selected by the user.\n * @returns A promise that resolves when the form is submitted.\n */\nexport type RampsControllerTransakSubmitPurposeOfUsageFormAction = {\n type: `RampsController:transakSubmitPurposeOfUsageForm`;\n handler: RampsController['transakSubmitPurposeOfUsageForm'];\n};\n\n/**\n * Updates the user's personal or address details on Transak.\n *\n * @param data - The user data fields to update.\n * @returns The API response data.\n */\nexport type RampsControllerTransakPatchUserAction = {\n type: `RampsController:transakPatchUser`;\n handler: RampsController['transakPatchUser'];\n};\n\n/**\n * Submits the user's SSN for identity verification.\n *\n * @param ssn - The Social Security Number.\n * @param quoteId - The quote ID associated with the order requiring SSN.\n * @returns The API response data.\n */\nexport type RampsControllerTransakSubmitSsnDetailsAction = {\n type: `RampsController:transakSubmitSsnDetails`;\n handler: RampsController['transakSubmitSsnDetails'];\n};\n\n/**\n * Confirms payment for an order after the user has completed payment.\n *\n * @param orderId - The order ID to confirm payment for.\n * @param paymentMethodId - The payment method used.\n * @returns Whether the payment confirmation was successful.\n */\nexport type RampsControllerTransakConfirmPaymentAction = {\n type: `RampsController:transakConfirmPayment`;\n handler: RampsController['transakConfirmPayment'];\n};\n\n/**\n * Translates generic ramps identifiers to Transak-specific identifiers.\n *\n * @param request - The translation request with optional identifiers to translate.\n * @returns The translated Transak-specific identifiers.\n */\nexport type RampsControllerTransakGetTranslationAction = {\n type: `RampsController:transakGetTranslation`;\n handler: RampsController['transakGetTranslation'];\n};\n\n/**\n * Checks the status of an ID proof submission for KYC.\n *\n * @param workFlowRunId - The workflow run ID to check status for.\n * @returns The current ID proof status.\n */\nexport type RampsControllerTransakGetIdProofStatusAction = {\n type: `RampsController:transakGetIdProofStatus`;\n handler: RampsController['transakGetIdProofStatus'];\n};\n\n/**\n * Cancels a specific Transak order.\n *\n * @param depositOrderId - The deposit order ID to cancel.\n * @returns A promise that resolves when the order is cancelled.\n */\nexport type RampsControllerTransakCancelOrderAction = {\n type: `RampsController:transakCancelOrder`;\n handler: RampsController['transakCancelOrder'];\n};\n\n/**\n * Cancels all active Transak orders. Individual cancellation failures\n * are collected and returned rather than thrown.\n *\n * @returns An array of errors from any failed cancellations (empty if all succeeded).\n */\nexport type RampsControllerTransakCancelAllActiveOrdersAction = {\n type: `RampsController:transakCancelAllActiveOrders`;\n handler: RampsController['transakCancelAllActiveOrders'];\n};\n\n/**\n * Fetches all active Transak orders for the authenticated user.\n *\n * @returns The list of active orders.\n */\nexport type RampsControllerTransakGetActiveOrdersAction = {\n type: `RampsController:transakGetActiveOrders`;\n handler: RampsController['transakGetActiveOrders'];\n};\n\n/**\n * Union of all RampsController action types.\n */\nexport type RampsControllerMethodActions =\n | RampsControllerExecuteRequestAction\n | RampsControllerAbortRequestAction\n | RampsControllerGetRequestStateAction\n | RampsControllerSetUserRegionAction\n | RampsControllerSetSelectedProviderAction\n | RampsControllerInitAction\n | RampsControllerGetCountriesAction\n | RampsControllerGetTokensAction\n | RampsControllerSetSelectedTokenAction\n | RampsControllerGetProvidersAction\n | RampsControllerGetPaymentMethodsAction\n | RampsControllerSetSelectedPaymentMethodAction\n | RampsControllerGetQuotesAction\n | RampsControllerAddOrderAction\n | RampsControllerRemoveOrderAction\n | RampsControllerStartOrderPollingAction\n | RampsControllerStopOrderPollingAction\n | RampsControllerGetBuyWidgetDataAction\n | RampsControllerAddPrecreatedOrderAction\n | RampsControllerGetOrderAction\n | RampsControllerGetOrderFromCallbackAction\n | RampsControllerTransakSetApiKeyAction\n | RampsControllerTransakSetAccessTokenAction\n | RampsControllerTransakClearAccessTokenAction\n | RampsControllerTransakSetAuthenticatedAction\n | RampsControllerTransakResetStateAction\n | RampsControllerTransakSendUserOtpAction\n | RampsControllerTransakVerifyUserOtpAction\n | RampsControllerTransakLogoutAction\n | RampsControllerTransakGetUserDetailsAction\n | RampsControllerTransakGetBuyQuoteAction\n | RampsControllerTransakGetKycRequirementAction\n | RampsControllerTransakGetAdditionalRequirementsAction\n | RampsControllerTransakCreateOrderAction\n | RampsControllerTransakGetOrderAction\n | RampsControllerTransakGetUserLimitsAction\n | RampsControllerTransakRequestOttAction\n | RampsControllerTransakGeneratePaymentWidgetUrlAction\n | RampsControllerTransakSubmitPurposeOfUsageFormAction\n | RampsControllerTransakPatchUserAction\n | RampsControllerTransakSubmitSsnDetailsAction\n | RampsControllerTransakConfirmPaymentAction\n | RampsControllerTransakGetTranslationAction\n | RampsControllerTransakGetIdProofStatusAction\n | RampsControllerTransakCancelOrderAction\n | RampsControllerTransakCancelAllActiveOrdersAction\n | RampsControllerTransakGetActiveOrdersAction;\n"]}
|
package/dist/RampsController.cjs
CHANGED
|
@@ -12,7 +12,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
12
12
|
};
|
|
13
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_mutateRequests, _RampsController_removeRequestState, _RampsController_cleanupState, _RampsController_requireRegion, _RampsController_isRegionCurrent, _RampsController_isTokenCurrent, _RampsController_isProviderCurrent, _RampsController_updateResourceField, _RampsController_setResourceLoading, _RampsController_setResourceError, _RampsController_updateRequestState, _RampsController_runInit, _RampsController_getSupportingProvidersForRegion, _RampsController_filterProviderIdsBySupport, _RampsController_resolveProviderIdsForQuote, _RampsController_getPreferredProviderIdsFromOrders, _RampsController_refreshOrder, _RampsController_pollPendingOrders, _RampsController_syncTransakAuthOnError, _RampsController_getNormalizedTransakError;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.RampsController = exports.normalizeProviderCode = exports.getDefaultRampsControllerState = exports.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = exports.controllerName = void 0;
|
|
15
|
+
exports.RampsController = exports.getInternalOrderCode = exports.normalizeProviderCode = 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
18
|
const rampsErrorCodes_1 = require("./rampsErrorCodes.cjs");
|
|
@@ -333,6 +333,27 @@ function normalizeProviderCode(providerCode) {
|
|
|
333
333
|
return providerCode.replace(/^\/providers\//u, '');
|
|
334
334
|
}
|
|
335
335
|
exports.normalizeProviderCode = normalizeProviderCode;
|
|
336
|
+
/**
|
|
337
|
+
* Returns the internal MetaMask order code used for state lookups and polling.
|
|
338
|
+
* Prefers the code embedded in the canonical order `id` path over `providerOrderId`,
|
|
339
|
+
* which may contain the provider's native order identifier.
|
|
340
|
+
*
|
|
341
|
+
* @param orderOrId - Order fields or a full order id / order code string.
|
|
342
|
+
* @returns The internal order code.
|
|
343
|
+
*/
|
|
344
|
+
function getInternalOrderCode(orderOrId) {
|
|
345
|
+
if (typeof orderOrId === 'string') {
|
|
346
|
+
return orderOrId.includes('/orders/')
|
|
347
|
+
? orderOrId.split('/orders/')[1]
|
|
348
|
+
: orderOrId;
|
|
349
|
+
}
|
|
350
|
+
const { id, providerOrderId } = orderOrId;
|
|
351
|
+
if (id?.includes('/orders/')) {
|
|
352
|
+
return id.split('/orders/')[1];
|
|
353
|
+
}
|
|
354
|
+
return providerOrderId;
|
|
355
|
+
}
|
|
356
|
+
exports.getInternalOrderCode = getInternalOrderCode;
|
|
336
357
|
// === ORDER POLLING CONSTANTS ===
|
|
337
358
|
const TERMINAL_ORDER_STATUSES = new Set([
|
|
338
359
|
RampsService_1.RampsOrderStatus.Completed,
|
|
@@ -1065,22 +1086,27 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1065
1086
|
// === ORDER MANAGEMENT ===
|
|
1066
1087
|
/**
|
|
1067
1088
|
* Adds or updates a V2 order in controller state.
|
|
1068
|
-
* If an order with the same
|
|
1089
|
+
* If an order with the same internal order code already exists, the incoming
|
|
1069
1090
|
* fields are merged on top of the existing order so that fields not present
|
|
1070
1091
|
* in the update (e.g. paymentDetails from the Transak API) are preserved.
|
|
1071
1092
|
*
|
|
1072
1093
|
* @param order - The RampsOrder to add or update.
|
|
1073
1094
|
*/
|
|
1074
1095
|
addOrder(order) {
|
|
1096
|
+
const internalOrderCode = getInternalOrderCode(order);
|
|
1097
|
+
const healedOrder = {
|
|
1098
|
+
...order,
|
|
1099
|
+
providerOrderId: internalOrderCode,
|
|
1100
|
+
};
|
|
1075
1101
|
this.update((state) => {
|
|
1076
|
-
const idx = state.orders.findIndex((existing) => existing
|
|
1102
|
+
const idx = state.orders.findIndex((existing) => getInternalOrderCode(existing) === internalOrderCode);
|
|
1077
1103
|
if (idx === -1) {
|
|
1078
|
-
state.orders.push(
|
|
1104
|
+
state.orders.push(healedOrder);
|
|
1079
1105
|
}
|
|
1080
1106
|
else {
|
|
1081
1107
|
state.orders[idx] = {
|
|
1082
1108
|
...state.orders[idx],
|
|
1083
|
-
...
|
|
1109
|
+
...healedOrder,
|
|
1084
1110
|
};
|
|
1085
1111
|
}
|
|
1086
1112
|
});
|
|
@@ -1160,9 +1186,7 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1160
1186
|
*/
|
|
1161
1187
|
addPrecreatedOrder(params) {
|
|
1162
1188
|
const { orderId, providerCode, walletAddress, chainId } = params;
|
|
1163
|
-
const orderCode = orderId
|
|
1164
|
-
? orderId.split('/orders/')[1]
|
|
1165
|
-
: orderId;
|
|
1189
|
+
const orderCode = getInternalOrderCode(orderId);
|
|
1166
1190
|
if (!orderCode?.trim()) {
|
|
1167
1191
|
return;
|
|
1168
1192
|
}
|
|
@@ -1209,13 +1233,17 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1209
1233
|
async getOrder(providerCode, orderCode, wallet) {
|
|
1210
1234
|
const order = await this.messenger.call('RampsService:getOrder', providerCode, orderCode, wallet);
|
|
1211
1235
|
const healedWalletAddress = order.walletAddress || wallet;
|
|
1236
|
+
const internalOrderCode = getInternalOrderCode({
|
|
1237
|
+
id: order.id,
|
|
1238
|
+
providerOrderId: orderCode,
|
|
1239
|
+
});
|
|
1212
1240
|
const healedOrder = {
|
|
1213
1241
|
...order,
|
|
1214
1242
|
walletAddress: healedWalletAddress,
|
|
1215
|
-
providerOrderId:
|
|
1243
|
+
providerOrderId: internalOrderCode,
|
|
1216
1244
|
};
|
|
1217
1245
|
this.update((state) => {
|
|
1218
|
-
const idx = state.orders.findIndex((existing) => existing
|
|
1246
|
+
const idx = state.orders.findIndex((existing) => getInternalOrderCode(existing) === internalOrderCode);
|
|
1219
1247
|
if (idx === -1) {
|
|
1220
1248
|
state.orders.push(healedOrder);
|
|
1221
1249
|
}
|