@metamask-previews/sentinel-api-service 2.1.0-preview-e80304db4 → 2.1.0-preview-e92ccc12d
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 +13 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/sentinel-api-service-method-action-types.d.ts +48 -1
- package/dist/sentinel-api-service-method-action-types.d.ts.map +1 -1
- package/dist/sentinel-api-service-method-action-types.js.map +1 -1
- package/dist/sentinel-api-service.d.ts +44 -1
- package/dist/sentinel-api-service.d.ts.map +1 -1
- package/dist/sentinel-api-service.js +209 -1
- package/dist/sentinel-api-service.js.map +1 -1
- package/dist/structs.d.ts +104 -0
- package/dist/structs.d.ts.map +1 -1
- package/dist/structs.js +60 -0
- package/dist/structs.js.map +1 -1
- package/dist/types.d.ts +240 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +69 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentinel-api-service.js","sourceRoot":"","sources":["../src/sentinel-api-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,2BAA2B,EAC3B,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,kCAAkC,EAClC,8BAA8B,EAC9B,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAC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KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CACrC,yCAAyC,CAC1C,CAAC;YACF,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,CAAC,aAAa,GAAG,UAAU,KAAK,EAAE,CAAC;YAC5C,CAAC;QACH,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,iDAAiD;YACjD,GAAG,CACD,YAAY,EACZ,oDAAoD,EACpD,KAAK,CACN,CAAC;QACJ,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,WAAW,CACf,OAAY,EACZ,UAAiD;QAEjD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAEtD,IAAI,CAAC,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,8BAA8B,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAChE,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,iBAAiB,CAAC,OAAY;QAClC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QAC1C,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACpD,OAAO,QAAQ,CAAC,cAAc,CAAC,CAAC;IAClC,CAAC;IAED;;;;;;OAMG;IACH,SAAS,CAAC,SAAiB;QACzB,OAAO,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,OAAO,CACxD,KAAK,EACL,IAAI,CAAC,kBAAkB,CACxB,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { BaseDataService } from '@metamask/base-data-service';\nimport { handleWhen, HttpError } from '@metamask/controller-utils';\nimport { validate } from '@metamask/superstruct';\nimport type { Hex, Json } from '@metamask/utils';\n\nimport {\n BASE_URL_TEMPLATE,\n DEFAULT_ENVIRONMENT,\n ENDPOINT_NETWORK,\n ENDPOINT_NETWORKS,\n ENDPOINT_SMART_TRANSACTIONS,\n ENVIRONMENT_DOMAIN,\n NETWORK_STALE_TIME_MS,\n NETWORKS_STALE_TIME_MS,\n NETWORKS_SUBDOMAIN,\n RPC_METHOD_SEND_RELAY,\n RPC_METHOD_SIMULATE,\n serviceName,\n} from './constants.js';\nimport {\n SentinelApiResponseValidationError,\n SentinelChainNotSupportedError,\n SentinelJsonRpcError,\n} from './errors.js';\nimport { projectLogger, createModuleLogger } from './logger.js';\nimport {\n SentinelSmartTransactionResponseStruct,\n SentinelNetworkRegistryStruct,\n SentinelNetworkStruct,\n SentinelRelaySubmitResponseStruct,\n SentinelSimulationResponseStruct,\n} from './structs.js';\nimport type {\n SentinelApiServiceMessenger,\n SentinelApiServiceOptions,\n SentinelNetwork,\n SentinelNetworkRegistry,\n SentinelRelaySubmitRequest,\n SentinelRelaySubmitResponse,\n SentinelSimulationRequest,\n SentinelSimulationResponse,\n SentinelSmartTransactionRequest,\n SentinelSmartTransactionResponse,\n} from './types.js';\n\nconst log = createModuleLogger(projectLogger, serviceName);\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'getNetwork',\n 'getNetworks',\n 'simulateTransactions',\n 'submitRelayTransaction',\n 'getSmartTransaction',\n] as const;\n\n/**\n * Data service that centralises all interactions with the MetaMask Sentinel\n * API (`tx-sentinel-<network>.api.cx.metamask.io`).\n *\n * It exposes one method per Sentinel endpoint:\n * - {@link SentinelApiService.getNetwork} — the configuration of a single\n * network (`/network`), cached since it is stable.\n * - {@link SentinelApiService.getNetworks} — the supported-network registry\n * (`/networks`), cached since it is stable and identical across subdomains.\n * - {@link SentinelApiService.simulateTransactions} — transaction simulation\n * (`infura_simulateTransactions`), used by `@metamask/transaction-controller`\n * and `@metamask/transaction-pay-controller`.\n * - {@link SentinelApiService.submitRelayTransaction} — gas station relay\n * submission (`eth_sendRelayTransaction`), used by the extension and mobile.\n * - {@link SentinelApiService.getSmartTransaction} — smart-transaction status\n * lookup (`/smart-transactions/{uuid}`).\n *\n * Consumers derive higher-level concerns (whether a chain supports simulation\n * or relay, polling loops, etc.) from the raw endpoint responses.\n */\nexport class SentinelApiService extends BaseDataService<\n typeof serviceName,\n SentinelApiServiceMessenger\n> {\n readonly #fetch: typeof fetch;\n\n readonly #clientId?: string;\n\n readonly #clientVersion?: string;\n\n readonly #environmentDomain: string;\n\n /**\n * Constructs a new SentinelApiService.\n *\n * @param options - The constructor options. See\n * {@link SentinelApiServiceOptions}.\n * @param options.messenger - The messenger suited for this service.\n * @param options.fetch - The `fetch` function to use for requests. Defaults\n * to the global `fetch`.\n * @param options.environment - The Sentinel API environment to target\n * (`dev`, `uat`, or `prod`). Defaults to `prod`.\n * @param options.clientId - Identifier for the calling client (for example\n * `extension` or `mobile`), sent as the `X-Client-Id` header.\n * @param options.clientVersion - Version of the calling client, sent as the\n * `X-Client-Version` header when provided.\n * @param options.queryClientConfig - Configuration for the underlying\n * TanStack Query client.\n * @param options.policyOptions - Options to pass to `createServicePolicy`.\n * Retries are disabled by default (`maxRetries: 0`) to preserve the\n * single-attempt behaviour of the clients this service replaces; pass\n * `maxRetries` here to opt in.\n */\n constructor({\n messenger,\n fetch: fetchFunction = globalThis.fetch,\n environment = DEFAULT_ENVIRONMENT,\n clientId,\n clientVersion,\n queryClientConfig = {},\n policyOptions = {},\n }: SentinelApiServiceOptions) {\n super({\n name: serviceName,\n messenger,\n queryClientConfig,\n policyOptions: {\n // Disable retries by default so the service is behaviourally\n // backwards-compatible with the single-request clients it replaces.\n // Callers can override via `policyOptions.maxRetries`.\n maxRetries: 0,\n retryFilterPolicy: handleWhen(\n (error) =>\n !(error instanceof SentinelApiResponseValidationError) &&\n !(error instanceof SentinelChainNotSupportedError) &&\n !(error instanceof SentinelJsonRpcError),\n ),\n ...policyOptions,\n },\n });\n\n this.#fetch = fetchFunction;\n this.#environmentDomain = ENVIRONMENT_DOMAIN[environment];\n this.#clientId = clientId;\n this.#clientVersion = clientVersion;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n log('Initialized');\n }\n\n /**\n * Fetches the configuration of a single network from the `/network`\n * endpoint of that network's subdomain. The subdomain is resolved from the\n * supported-network registry. The result is cached, as the configuration is\n * stable.\n *\n * @param chainId - The chain ID of the network.\n * @returns The network configuration.\n */\n async getNetwork(chainId: Hex): Promise<SentinelNetwork> {\n const registryEntry = await this.#getRegistryEntry(chainId);\n\n if (!registryEntry) {\n throw new SentinelChainNotSupportedError(chainId);\n }\n\n const url = `${this.#buildUrl(registryEntry.network)}${ENDPOINT_NETWORK}`;\n\n const result = await this.fetchQuery({\n queryKey: [`${this.name}:getNetwork`, chainId],\n staleTime: NETWORK_STALE_TIME_MS,\n queryFn: async (): Promise<Json> => {\n const headers = await this.#getHeaders();\n\n log('getNetwork', 'Request', url);\n\n const response = await this.#fetch(url, { headers });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Sentinel API: Network request failed with status '${response.status}'`,\n );\n }\n\n const json = (await response.json()) as Json;\n\n const [error] = validate(json, SentinelNetworkStruct);\n if (error) {\n throw new SentinelApiResponseValidationError(\n `Sentinel API: Malformed response from network endpoint: ${error.message}`,\n );\n }\n\n log('getNetwork', 'Response', json);\n\n return json;\n },\n });\n\n return result as unknown as SentinelNetwork;\n }\n\n /**\n * Fetches the Sentinel supported-network registry. The result is cached, as\n * the registry is stable and identical across network subdomains.\n *\n * @returns The network registry, keyed by decimal chain ID.\n */\n async getNetworks(): Promise<SentinelNetworkRegistry> {\n const url = `${this.#buildUrl(NETWORKS_SUBDOMAIN)}${ENDPOINT_NETWORKS}`;\n\n const result = await this.fetchQuery({\n queryKey: [`${this.name}:getNetworks`],\n staleTime: NETWORKS_STALE_TIME_MS,\n queryFn: async (): Promise<Json> => {\n const headers = await this.#getHeaders();\n\n log('getNetworks', 'Request', url);\n\n const response = await this.#fetch(url, { headers });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Sentinel API: Networks request failed with status '${response.status}'`,\n );\n }\n\n const json: Json = await response.json();\n\n const [error] = validate(json, SentinelNetworkRegistryStruct);\n if (error) {\n throw new SentinelApiResponseValidationError(\n `Sentinel API: Malformed response from networks endpoint: ${error.message}`,\n );\n }\n\n log('getNetworks', 'Response', json);\n\n return json;\n },\n });\n\n return result as unknown as SentinelNetworkRegistry;\n }\n\n /**\n * Simulates transactions against the Sentinel API via\n * `infura_simulateTransactions`. Not cached, since each request body is\n * unique and stale simulations must not be reused.\n *\n * @param chainId - The chain ID to simulate on.\n * @param request - The simulation request.\n * @param options - Additional options.\n * @param options.getUrl - Optional callback that receives the default\n * Sentinel URL resolved for the chain and returns the URL to use instead.\n * Lets consumers rewrite the request URL (for example to route through the\n * MetaMask Shield proxy) without the service knowing about those concerns.\n * @returns The simulation response.\n */\n async simulateTransactions(\n chainId: Hex,\n request: SentinelSimulationRequest,\n options: { getUrl?: (defaultUrl: string) => string | Promise<string> } = {},\n ): Promise<SentinelSimulationResponse> {\n const defaultUrl = await this.#resolveUrl(chainId, 'confirmations');\n const url = options.getUrl ? await options.getUrl(defaultUrl) : defaultUrl;\n\n const result = await this.fetchQuery({\n queryKey: [`${this.name}:simulateTransactions`, chainId, request, url],\n staleTime: 0,\n queryFn: async (): Promise<Json> => {\n log('simulateTransactions', 'Request', url, request);\n\n const rpcResult = await this.#jsonRpc(url, RPC_METHOD_SIMULATE, [\n request,\n ]);\n\n const [error] = validate(rpcResult, SentinelSimulationResponseStruct);\n if (error) {\n throw new SentinelApiResponseValidationError(\n `Sentinel API: Malformed response from simulation endpoint: ${error.message}`,\n );\n }\n\n log('simulateTransactions', 'Response', rpcResult);\n\n return rpcResult;\n },\n });\n\n return result as unknown as SentinelSimulationResponse;\n }\n\n /**\n * Submits a signed relay (gas station) transaction to the Sentinel API via\n * `eth_sendRelayTransaction`. Not cached.\n *\n * @param request - The relay submit request.\n * @returns The relay submit response containing the tracking UUID.\n */\n async submitRelayTransaction(\n request: SentinelRelaySubmitRequest,\n ): Promise<SentinelRelaySubmitResponse> {\n const url = await this.#resolveUrl(request.chainId, 'relayTransactions');\n\n const result = await this.fetchQuery({\n queryKey: [`${this.name}:submitRelayTransaction`, request],\n staleTime: 0,\n queryFn: async (): Promise<Json> => {\n log('submitRelayTransaction', 'Request', url, request);\n\n const rpcResult = await this.#jsonRpc(url, RPC_METHOD_SEND_RELAY, [\n request,\n ]);\n\n const [error] = validate(rpcResult, SentinelRelaySubmitResponseStruct);\n if (error) {\n throw new SentinelApiResponseValidationError(\n `Sentinel API: Malformed response from relay submit endpoint: ${error.message}`,\n );\n }\n\n log('submitRelayTransaction', 'Response', rpcResult);\n\n return rpcResult;\n },\n });\n\n return result as unknown as SentinelRelaySubmitResponse;\n }\n\n /**\n * Looks up the state of a submitted smart transaction by UUID against the\n * `/smart-transactions/{uuid}` endpoint. Performs a single request; callers\n * own any polling loop. Not cached.\n *\n * @param request - The smart-transaction lookup request.\n * @returns The response envelope containing the smart transaction(s)\n * associated with the requested UUID.\n */\n async getSmartTransaction(\n request: SentinelSmartTransactionRequest,\n ): Promise<SentinelSmartTransactionResponse> {\n const { chainId, uuid } = request;\n const baseUrl = await this.#resolveUrl(chainId, 'relayTransactions');\n const url = `${baseUrl}${ENDPOINT_SMART_TRANSACTIONS}/${uuid}`;\n\n const result = await this.fetchQuery({\n queryKey: [`${this.name}:getSmartTransaction`, chainId, uuid],\n staleTime: 0,\n queryFn: async (): Promise<Json> => {\n const headers = await this.#getHeaders();\n\n log('getSmartTransaction', 'Request', url);\n\n const response = await this.#fetch(url, { headers });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Sentinel API: Smart-transaction request failed with status '${response.status}'`,\n );\n }\n\n const json: Json = await response.json();\n\n const [error] = validate(json, SentinelSmartTransactionResponseStruct);\n if (error) {\n throw new SentinelApiResponseValidationError(\n `Sentinel API: Malformed response from smart-transactions endpoint: ${error.message}`,\n );\n }\n\n log('getSmartTransaction', 'Response', json);\n\n return json;\n },\n });\n\n return result as unknown as SentinelSmartTransactionResponse;\n }\n\n /**\n * Performs a JSON-RPC POST to the Sentinel API and returns the `result`.\n *\n * @param url - The URL to post to.\n * @param method - The JSON-RPC method name.\n * @param params - The JSON-RPC params.\n * @returns The `result` field of the JSON-RPC response.\n */\n async #jsonRpc(url: string, method: string, params: Json[]): Promise<Json> {\n const headers = await this.#getHeaders();\n\n const response = await this.#fetch(url, {\n method: 'POST',\n headers: {\n ...headers,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n id: '1',\n jsonrpc: '2.0',\n method,\n params,\n }),\n });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Sentinel API: JSON-RPC request '${method}' failed with status '${response.status}'`,\n );\n }\n\n const responseJson = (await response.json()) as {\n error?: { code?: number; message?: string };\n result?: Json;\n };\n\n if (responseJson.error) {\n const { code, message } = responseJson.error;\n throw new SentinelJsonRpcError(\n `Sentinel API: JSON-RPC error: ${message}`,\n code,\n );\n }\n\n if (responseJson.result === undefined) {\n throw new SentinelJsonRpcError(\n 'Sentinel API: JSON-RPC response missing result',\n -32603,\n );\n }\n\n return responseJson.result;\n }\n\n /**\n * Builds the outbound headers for a Sentinel request: the client identity\n * headers plus a best-effort `Authorization` bearer token. Token retrieval\n * failures are swallowed so unauthenticated requests still proceed.\n *\n * @returns The headers to attach to the request.\n */\n async #getHeaders(): Promise<Record<string, string>> {\n const headers: Record<string, string> = {};\n\n if (this.#clientId !== undefined) {\n headers['X-Client-Id'] = this.#clientId;\n }\n\n if (this.#clientVersion !== undefined) {\n headers['X-Client-Version'] = this.#clientVersion;\n }\n\n try {\n const token = await this.messenger.call(\n 'AuthenticationController:getBearerToken',\n );\n if (token) {\n headers.Authorization = `Bearer ${token}`;\n }\n } catch (error: unknown) {\n // Proceed without auth if token retrieval fails.\n log(\n 'getHeaders',\n 'Auth token unavailable, proceeding unauthenticated',\n error,\n );\n }\n\n return headers;\n }\n\n /**\n * Resolves the Sentinel URL for a chain, asserting the required capability.\n *\n * @param chainId - The chain ID to resolve a URL for.\n * @param capability - The capability flag that must be enabled.\n * @returns The resolved base URL.\n */\n async #resolveUrl(\n chainId: Hex,\n capability: 'confirmations' | 'relayTransactions',\n ): Promise<string> {\n const network = await this.#getRegistryEntry(chainId);\n\n if (!network?.[capability]) {\n throw new SentinelChainNotSupportedError(chainId, capability);\n }\n\n return this.#buildUrl(network.network);\n }\n\n /**\n * Looks up a single network entry from the registry by chain ID.\n *\n * @param chainId - The chain ID to look up.\n * @returns The network entry, or undefined if not present.\n */\n async #getRegistryEntry(chainId: Hex): Promise<SentinelNetwork | undefined> {\n const registry = await this.getNetworks();\n const chainIdDecimal = BigInt(chainId).toString(10);\n return registry[chainIdDecimal];\n }\n\n /**\n * Builds a Sentinel base URL for the given network subdomain, targeting the\n * environment this service was constructed with.\n *\n * @param subdomain - The network subdomain (for example `ethereum-mainnet`).\n * @returns The full base URL.\n */\n #buildUrl(subdomain: string): string {\n return BASE_URL_TEMPLATE.replace('{0}', subdomain).replace(\n '{1}',\n this.#environmentDomain,\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sentinel-api-service.js","sourceRoot":"","sources":["../src/sentinel-api-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,2BAA2B,EAC3B,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,kCAAkC,EAClC,8BAA8B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C;QACH,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAS,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["import { BaseDataService } from '@metamask/base-data-service';\nimport { handleWhen, HttpError } from '@metamask/controller-utils';\nimport { validate } from '@metamask/superstruct';\nimport type { Hex, Json } from '@metamask/utils';\n\nimport {\n BASE_URL_TEMPLATE,\n DEFAULT_ENVIRONMENT,\n ENDPOINT_NETWORK,\n ENDPOINT_NETWORKS,\n ENDPOINT_SMART_TRANSACTIONS,\n ENVIRONMENT_DOMAIN,\n NETWORK_STALE_TIME_MS,\n NETWORKS_STALE_TIME_MS,\n NETWORKS_SUBDOMAIN,\n RPC_METHOD_SEND_RELAY,\n RPC_METHOD_SIMULATE,\n serviceName,\n} from './constants.js';\nimport {\n SentinelApiResponseValidationError,\n SentinelChainNotSupportedError,\n SentinelJsonRpcError,\n} from './errors.js';\nimport { projectLogger, createModuleLogger } from './logger.js';\nimport {\n SentinelSmartTransactionResponseStruct,\n SentinelBatchStatusResponseStruct,\n SentinelNetworkRegistryStruct,\n SentinelNetworkStruct,\n SentinelCancelResponseStruct,\n SentinelGetFeesResponseStruct,\n SentinelRelaySubmitResponseStruct,\n SentinelSimulationResponseStruct,\n SentinelSubmitTransactionsResponseStruct,\n} from './structs.js';\nimport type {\n SentinelApiServiceMessenger,\n SentinelApiServiceOptions,\n SentinelBatchStatusRequest,\n SentinelBatchStatusResponse,\n SentinelCancelRequest,\n SentinelCancelResponse,\n SentinelGetFeesRequest,\n SentinelGetFeesResponse,\n SentinelNetwork,\n SentinelNetworkRegistry,\n SentinelRelaySubmitRequest,\n SentinelRelaySubmitResponse,\n SentinelSimulationRequest,\n SentinelSimulationResponse,\n SentinelSmartTransactionRequest,\n SentinelSmartTransactionResponse,\n SentinelSubmitTransactionsRequest,\n SentinelSubmitTransactionsResponse,\n} from './types.js';\n\nconst log = createModuleLogger(projectLogger, serviceName);\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'cancel',\n 'getBatchStatus',\n 'getFees',\n 'getNetwork',\n 'getNetworks',\n 'simulateTransactions',\n 'submitRelayTransaction',\n 'submitTransactions',\n 'getSmartTransaction',\n] as const;\n\n/**\n * Data service that centralises all interactions with the MetaMask Sentinel\n * API (`tx-sentinel-<network>.api.cx.metamask.io`).\n *\n * It exposes one method per Sentinel endpoint:\n * - {@link SentinelApiService.getNetwork} — the configuration of a single\n * network (`/network`), cached since it is stable.\n * - {@link SentinelApiService.getNetworks} — the supported-network registry\n * (`/networks`), cached since it is stable and identical across subdomains.\n * - {@link SentinelApiService.simulateTransactions} — transaction simulation\n * (`infura_simulateTransactions`), used by `@metamask/transaction-controller`\n * and `@metamask/transaction-pay-controller`.\n * - {@link SentinelApiService.submitRelayTransaction} — gas station relay\n * submission (`eth_sendRelayTransaction`), used by the extension and mobile.\n * - {@link SentinelApiService.getSmartTransaction} — smart-transaction status\n * lookup (`/smart-transactions/{uuid}`).\n * - {@link SentinelApiService.getFees} — smart-transaction fee quotes\n * (`POST /v1/networks/{chainId}/getFees`). Not cached.\n * - {@link SentinelApiService.submitTransactions} — signed smart-transaction\n * submission (`POST /v1/networks/{chainId}/submitTransactions`). Not cached.\n * - {@link SentinelApiService.cancel} — smart-transaction cancellation\n * (`POST /v1/networks/{chainId}/cancel`). Not cached.\n * - {@link SentinelApiService.getBatchStatus} — smart-transaction status lookup\n * for several UUIDs (`GET /v1/networks/{chainId}/batchStatus`). Not cached.\n *\n * Consumers derive higher-level concerns (whether a chain supports simulation\n * or relay, polling loops, etc.) from the raw endpoint responses.\n */\nexport class SentinelApiService extends BaseDataService<\n typeof serviceName,\n SentinelApiServiceMessenger\n> {\n readonly #fetch: typeof fetch;\n\n readonly #clientId?: string;\n\n readonly #clientVersion?: string;\n\n readonly #environmentDomain: string;\n\n /**\n * Constructs a new SentinelApiService.\n *\n * @param options - The constructor options. See\n * {@link SentinelApiServiceOptions}.\n * @param options.messenger - The messenger suited for this service.\n * @param options.fetch - The `fetch` function to use for requests. Defaults\n * to the global `fetch`.\n * @param options.environment - The Sentinel API environment to target\n * (`dev`, `uat`, or `prod`). Defaults to `prod`.\n * @param options.clientId - Identifier for the calling client (for example\n * `extension` or `mobile`), sent as the `X-Client-Id` header.\n * @param options.clientVersion - Version of the calling client, sent as the\n * `X-Client-Version` header when provided.\n * @param options.queryClientConfig - Configuration for the underlying\n * TanStack Query client.\n * @param options.policyOptions - Options to pass to `createServicePolicy`.\n * Retries are disabled by default (`maxRetries: 0`) to preserve the\n * single-attempt behaviour of the clients this service replaces; pass\n * `maxRetries` here to opt in.\n */\n constructor({\n messenger,\n fetch: fetchFunction = globalThis.fetch,\n environment = DEFAULT_ENVIRONMENT,\n clientId,\n clientVersion,\n queryClientConfig = {},\n policyOptions = {},\n }: SentinelApiServiceOptions) {\n super({\n name: serviceName,\n messenger,\n queryClientConfig,\n policyOptions: {\n // Disable retries by default so the service is behaviourally\n // backwards-compatible with the single-request clients it replaces.\n // Callers can override via `policyOptions.maxRetries`.\n maxRetries: 0,\n retryFilterPolicy: handleWhen(\n (error) =>\n !(error instanceof SentinelApiResponseValidationError) &&\n !(error instanceof SentinelChainNotSupportedError) &&\n !(error instanceof SentinelJsonRpcError),\n ),\n ...policyOptions,\n },\n });\n\n this.#fetch = fetchFunction;\n this.#environmentDomain = ENVIRONMENT_DOMAIN[environment];\n this.#clientId = clientId;\n this.#clientVersion = clientVersion;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n log('Initialized');\n }\n\n /**\n * Fetches the configuration of a single network from the `/network`\n * endpoint of that network's subdomain. The subdomain is resolved from the\n * supported-network registry. The result is cached, as the configuration is\n * stable.\n *\n * @param chainId - The chain ID of the network.\n * @returns The network configuration.\n */\n async getNetwork(chainId: Hex): Promise<SentinelNetwork> {\n const registryEntry = await this.#getRegistryEntry(chainId);\n\n if (!registryEntry) {\n throw new SentinelChainNotSupportedError(chainId);\n }\n\n const url = `${this.#buildUrl(registryEntry.network)}${ENDPOINT_NETWORK}`;\n\n const result = await this.fetchQuery({\n queryKey: [`${this.name}:getNetwork`, chainId],\n staleTime: NETWORK_STALE_TIME_MS,\n queryFn: async (): Promise<Json> => {\n const headers = await this.#getHeaders();\n\n log('getNetwork', 'Request', url);\n\n const response = await this.#fetch(url, { headers });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Sentinel API: Network request failed with status '${response.status}'`,\n );\n }\n\n const json = (await response.json()) as Json;\n\n const [error] = validate(json, SentinelNetworkStruct);\n if (error) {\n throw new SentinelApiResponseValidationError(\n `Sentinel API: Malformed response from network endpoint: ${error.message}`,\n );\n }\n\n log('getNetwork', 'Response', json);\n\n return json;\n },\n });\n\n return result as unknown as SentinelNetwork;\n }\n\n /**\n * Fetches the Sentinel supported-network registry. The result is cached, as\n * the registry is stable and identical across network subdomains.\n *\n * @returns The network registry, keyed by decimal chain ID.\n */\n async getNetworks(): Promise<SentinelNetworkRegistry> {\n const url = `${this.#buildUrl(NETWORKS_SUBDOMAIN)}${ENDPOINT_NETWORKS}`;\n\n const result = await this.fetchQuery({\n queryKey: [`${this.name}:getNetworks`],\n staleTime: NETWORKS_STALE_TIME_MS,\n queryFn: async (): Promise<Json> => {\n const headers = await this.#getHeaders();\n\n log('getNetworks', 'Request', url);\n\n const response = await this.#fetch(url, { headers });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Sentinel API: Networks request failed with status '${response.status}'`,\n );\n }\n\n const json: Json = await response.json();\n\n const [error] = validate(json, SentinelNetworkRegistryStruct);\n if (error) {\n throw new SentinelApiResponseValidationError(\n `Sentinel API: Malformed response from networks endpoint: ${error.message}`,\n );\n }\n\n log('getNetworks', 'Response', json);\n\n return json;\n },\n });\n\n return result as unknown as SentinelNetworkRegistry;\n }\n\n /**\n * Simulates transactions against the Sentinel API via\n * `infura_simulateTransactions`. Not cached, since each request body is\n * unique and stale simulations must not be reused.\n *\n * @param chainId - The chain ID to simulate on.\n * @param request - The simulation request.\n * @param options - Additional options.\n * @param options.getUrl - Optional callback that receives the default\n * Sentinel URL resolved for the chain and returns the URL to use instead.\n * Lets consumers rewrite the request URL (for example to route through the\n * MetaMask Shield proxy) without the service knowing about those concerns.\n * @returns The simulation response.\n */\n async simulateTransactions(\n chainId: Hex,\n request: SentinelSimulationRequest,\n options: { getUrl?: (defaultUrl: string) => string | Promise<string> } = {},\n ): Promise<SentinelSimulationResponse> {\n const defaultUrl = await this.#resolveUrl(chainId, 'confirmations');\n const url = options.getUrl ? await options.getUrl(defaultUrl) : defaultUrl;\n\n const result = await this.fetchQuery({\n queryKey: [`${this.name}:simulateTransactions`, chainId, request, url],\n staleTime: 0,\n queryFn: async (): Promise<Json> => {\n log('simulateTransactions', 'Request', url, request);\n\n const rpcResult = await this.#jsonRpc(url, RPC_METHOD_SIMULATE, [\n request,\n ]);\n\n const [error] = validate(rpcResult, SentinelSimulationResponseStruct);\n if (error) {\n throw new SentinelApiResponseValidationError(\n `Sentinel API: Malformed response from simulation endpoint: ${error.message}`,\n );\n }\n\n log('simulateTransactions', 'Response', rpcResult);\n\n return rpcResult;\n },\n });\n\n return result as unknown as SentinelSimulationResponse;\n }\n\n /**\n * Submits a signed relay (gas station) transaction to the Sentinel API via\n * `eth_sendRelayTransaction`. Not cached.\n *\n * @param request - The relay submit request.\n * @returns The relay submit response containing the tracking UUID.\n */\n async submitRelayTransaction(\n request: SentinelRelaySubmitRequest,\n ): Promise<SentinelRelaySubmitResponse> {\n const url = await this.#resolveUrl(request.chainId, 'relayTransactions');\n\n const result = await this.fetchQuery({\n queryKey: [`${this.name}:submitRelayTransaction`, request],\n staleTime: 0,\n queryFn: async (): Promise<Json> => {\n log('submitRelayTransaction', 'Request', url, request);\n\n const rpcResult = await this.#jsonRpc(url, RPC_METHOD_SEND_RELAY, [\n request,\n ]);\n\n const [error] = validate(rpcResult, SentinelRelaySubmitResponseStruct);\n if (error) {\n throw new SentinelApiResponseValidationError(\n `Sentinel API: Malformed response from relay submit endpoint: ${error.message}`,\n );\n }\n\n log('submitRelayTransaction', 'Response', rpcResult);\n\n return rpcResult;\n },\n });\n\n return result as unknown as SentinelRelaySubmitResponse;\n }\n\n /**\n * Looks up the state of a submitted smart transaction by UUID against the\n * `/smart-transactions/{uuid}` endpoint. Performs a single request; callers\n * own any polling loop. Not cached.\n *\n * @param request - The smart-transaction lookup request.\n * @returns The response envelope containing the smart transaction(s)\n * associated with the requested UUID.\n */\n async getSmartTransaction(\n request: SentinelSmartTransactionRequest,\n ): Promise<SentinelSmartTransactionResponse> {\n const { chainId, uuid } = request;\n const baseUrl = await this.#resolveUrl(chainId, 'relayTransactions');\n const url = `${baseUrl}${ENDPOINT_SMART_TRANSACTIONS}/${uuid}`;\n\n const result = await this.fetchQuery({\n queryKey: [`${this.name}:getSmartTransaction`, chainId, uuid],\n staleTime: 0,\n queryFn: async (): Promise<Json> => {\n const headers = await this.#getHeaders();\n\n log('getSmartTransaction', 'Request', url);\n\n const response = await this.#fetch(url, { headers });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Sentinel API: Smart-transaction request failed with status '${response.status}'`,\n );\n }\n\n const json: Json = await response.json();\n\n const [error] = validate(json, SentinelSmartTransactionResponseStruct);\n if (error) {\n throw new SentinelApiResponseValidationError(\n `Sentinel API: Malformed response from smart-transactions endpoint: ${error.message}`,\n );\n }\n\n log('getSmartTransaction', 'Response', json);\n\n return json;\n },\n });\n\n return result as unknown as SentinelSmartTransactionResponse;\n }\n\n /**\n * Quotes gas fees for unsigned smart transactions via\n * `POST /v1/networks/{chainId}/getFees`. Not cached, since a quote goes\n * stale immediately.\n *\n * @param request - The fee quote request.\n * @returns The fee quote response. One entry in `txs` per transaction, in\n * request order.\n */\n async getFees(\n request: SentinelGetFeesRequest,\n ): Promise<SentinelGetFeesResponse> {\n const { chainId, transactions } = request;\n const baseUrl = await this.#resolveUrl(chainId, 'confirmations');\n const chainIdDecimal = BigInt(chainId).toString(10);\n const url = `${baseUrl}v1/networks/${chainIdDecimal}/getFees`;\n\n const result = await this.fetchQuery({\n queryKey: [`${this.name}:getFees`, request],\n staleTime: 0,\n queryFn: async (): Promise<Json> => {\n const headers = await this.#getHeaders();\n\n log('getFees', 'Request', url, request);\n\n const response = await this.#fetch(url, {\n method: 'POST',\n headers: {\n ...headers,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ txs: transactions }),\n });\n\n if (!response.ok) {\n const data = await readJsonBody(response);\n const error = new HttpError(\n response.status,\n `Sentinel API: getFees request failed with status '${response.status}'`,\n );\n if (data !== undefined) {\n Object.assign(error, { data });\n }\n throw error;\n }\n\n const json = (await response.json()) as Json;\n\n const [error] = validate(json, SentinelGetFeesResponseStruct);\n if (error) {\n throw new SentinelApiResponseValidationError(\n `Sentinel API: Malformed response from /getFees endpoint: ${error.message}`,\n );\n }\n\n log('getFees', 'Response', json);\n\n return json;\n },\n });\n\n return result as unknown as SentinelGetFeesResponse;\n }\n\n /**\n * Submits signed smart transactions via\n * `POST /v1/networks/{chainId}/submitTransactions`. Not cached.\n *\n * @param request - The submit request.\n * @returns The UUID assigned to the submitted batch.\n */\n async submitTransactions(\n request: SentinelSubmitTransactionsRequest,\n ): Promise<SentinelSubmitTransactionsResponse> {\n const { chainId, rawTxs, rawCancelTxs, rawTxsWithMetadata } = request;\n const baseUrl = await this.#resolveUrl(chainId, 'confirmations');\n const chainIdDecimal = BigInt(chainId).toString(10);\n const url = `${baseUrl}v1/networks/${chainIdDecimal}/submitTransactions`;\n\n const result = await this.fetchQuery({\n queryKey: [`${this.name}:submitTransactions`, request],\n staleTime: 0,\n queryFn: async (): Promise<Json> => {\n const headers = await this.#getHeaders();\n\n log('submitTransactions', 'Request', url, request);\n\n const response = await this.#fetch(url, {\n method: 'POST',\n headers: {\n ...headers,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n rawTxs,\n ...(rawCancelTxs === undefined ? {} : { rawCancelTxs }),\n ...(rawTxsWithMetadata === undefined ? {} : { rawTxsWithMetadata }),\n }),\n });\n\n if (!response.ok) {\n const data = await readJsonBody(response);\n const error = new HttpError(\n response.status,\n `Sentinel API: submitTransactions request failed with status '${response.status}'`,\n );\n if (data !== undefined) {\n Object.assign(error, { data });\n }\n throw error;\n }\n\n const json = (await response.json()) as Json;\n\n const [error] = validate(\n json,\n SentinelSubmitTransactionsResponseStruct,\n );\n if (error) {\n throw new SentinelApiResponseValidationError(\n `Sentinel API: Malformed response from /submitTransactions endpoint: ${error.message}`,\n );\n }\n\n log('submitTransactions', 'Response', json);\n\n return json;\n },\n });\n\n return result as unknown as SentinelSubmitTransactionsResponse;\n }\n\n /**\n * Cancels a smart transaction via `POST /v1/networks/{chainId}/cancel`.\n * Not cached.\n *\n * @param request - The cancel request.\n * @returns The cancel result. `cancelled` is `true` on success.\n */\n async cancel(\n request: SentinelCancelRequest,\n ): Promise<SentinelCancelResponse> {\n const { chainId, uuid } = request;\n const baseUrl = await this.#resolveUrl(chainId, 'confirmations');\n const chainIdDecimal = BigInt(chainId).toString(10);\n const url = `${baseUrl}v1/networks/${chainIdDecimal}/cancel`;\n\n const result = await this.fetchQuery({\n queryKey: [`${this.name}:cancel`, request],\n staleTime: 0,\n queryFn: async (): Promise<Json> => {\n const headers = await this.#getHeaders();\n\n log('cancel', 'Request', url, request);\n\n const response = await this.#fetch(url, {\n method: 'POST',\n headers: {\n ...headers,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ uuid }),\n });\n\n if (!response.ok) {\n const data = await readJsonBody(response);\n const error = new HttpError(\n response.status,\n `Sentinel API: Cancel request failed with status '${response.status}'`,\n );\n if (data !== undefined) {\n Object.assign(error, { data });\n }\n throw error;\n }\n\n const json = (await response.json()) as Json;\n\n const [error] = validate(json, SentinelCancelResponseStruct);\n if (error) {\n throw new SentinelApiResponseValidationError(\n `Sentinel API: Malformed response from /cancel endpoint: ${error.message}`,\n );\n }\n\n log('cancel', 'Response', json);\n\n return json;\n },\n });\n\n return result as unknown as SentinelCancelResponse;\n }\n\n /**\n * Looks up the statuses of several smart transactions via\n * `GET /v1/networks/{chainId}/batchStatus`. Not cached, since statuses change\n * while transactions are pending.\n *\n * @param request - The batch status request.\n * @returns The status of each requested transaction, keyed by UUID.\n */\n async getBatchStatus(\n request: SentinelBatchStatusRequest,\n ): Promise<SentinelBatchStatusResponse> {\n const { chainId, uuids } = request;\n const baseUrl = await this.#resolveUrl(chainId, 'confirmations');\n const chainIdDecimal = BigInt(chainId).toString(10);\n const query = new URLSearchParams({ uuids: uuids.join(',') });\n const url = `${baseUrl}v1/networks/${chainIdDecimal}/batchStatus?${query.toString()}`;\n\n const result = await this.fetchQuery({\n queryKey: [`${this.name}:getBatchStatus`, request],\n staleTime: 0,\n queryFn: async (): Promise<Json> => {\n const headers = await this.#getHeaders();\n\n log('getBatchStatus', 'Request', url, request);\n\n const response = await this.#fetch(url, { headers });\n\n if (!response.ok) {\n const data = await readJsonBody(response);\n const error = new HttpError(\n response.status,\n `Sentinel API: Batch status request failed with status '${response.status}'`,\n );\n if (data !== undefined) {\n Object.assign(error, { data });\n }\n throw error;\n }\n\n const json = (await response.json()) as Json;\n\n const [error] = validate(json, SentinelBatchStatusResponseStruct);\n if (error) {\n throw new SentinelApiResponseValidationError(\n `Sentinel API: Malformed response from /batchStatus endpoint: ${error.message}`,\n );\n }\n\n log('getBatchStatus', 'Response', json);\n\n return json;\n },\n });\n\n return result as unknown as SentinelBatchStatusResponse;\n }\n\n /**\n * Performs a JSON-RPC POST to the Sentinel API and returns the `result`.\n *\n * @param url - The URL to post to.\n * @param method - The JSON-RPC method name.\n * @param params - The JSON-RPC params.\n * @returns The `result` field of the JSON-RPC response.\n */\n async #jsonRpc(url: string, method: string, params: Json[]): Promise<Json> {\n const headers = await this.#getHeaders();\n\n const response = await this.#fetch(url, {\n method: 'POST',\n headers: {\n ...headers,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n id: '1',\n jsonrpc: '2.0',\n method,\n params,\n }),\n });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Sentinel API: JSON-RPC request '${method}' failed with status '${response.status}'`,\n );\n }\n\n const responseJson = (await response.json()) as {\n error?: { code?: number; message?: string };\n result?: Json;\n };\n\n if (responseJson.error) {\n const { code, message } = responseJson.error;\n throw new SentinelJsonRpcError(\n `Sentinel API: JSON-RPC error: ${message}`,\n code,\n );\n }\n\n if (responseJson.result === undefined) {\n throw new SentinelJsonRpcError(\n 'Sentinel API: JSON-RPC response missing result',\n -32603,\n );\n }\n\n return responseJson.result;\n }\n\n /**\n * Builds the outbound headers for a Sentinel request: the client identity\n * headers plus a best-effort `Authorization` bearer token. Token retrieval\n * failures are swallowed so unauthenticated requests still proceed.\n *\n * @returns The headers to attach to the request.\n */\n async #getHeaders(): Promise<Record<string, string>> {\n const headers: Record<string, string> = {};\n\n if (this.#clientId !== undefined) {\n headers['X-Client-Id'] = this.#clientId;\n }\n\n if (this.#clientVersion !== undefined) {\n headers['X-Client-Version'] = this.#clientVersion;\n }\n\n try {\n const token = await this.messenger.call(\n 'AuthenticationController:getBearerToken',\n );\n if (token) {\n headers.Authorization = `Bearer ${token}`;\n }\n } catch (error: unknown) {\n // Proceed without auth if token retrieval fails.\n log(\n 'getHeaders',\n 'Auth token unavailable, proceeding unauthenticated',\n error,\n );\n }\n\n return headers;\n }\n\n /**\n * Resolves the Sentinel URL for a chain, asserting the required capability.\n *\n * @param chainId - The chain ID to resolve a URL for.\n * @param capability - The capability flag that must be enabled.\n * @returns The resolved base URL.\n */\n async #resolveUrl(\n chainId: Hex,\n capability: 'confirmations' | 'relayTransactions',\n ): Promise<string> {\n const network = await this.#getRegistryEntry(chainId);\n\n if (!network?.[capability]) {\n throw new SentinelChainNotSupportedError(chainId, capability);\n }\n\n return this.#buildUrl(network.network);\n }\n\n /**\n * Looks up a single network entry from the registry by chain ID.\n *\n * @param chainId - The chain ID to look up.\n * @returns The network entry, or undefined if not present.\n */\n async #getRegistryEntry(chainId: Hex): Promise<SentinelNetwork | undefined> {\n const registry = await this.getNetworks();\n const chainIdDecimal = BigInt(chainId).toString(10);\n return registry[chainIdDecimal];\n }\n\n /**\n * Builds a Sentinel base URL for the given network subdomain, targeting the\n * environment this service was constructed with.\n *\n * @param subdomain - The network subdomain (for example `ethereum-mainnet`).\n * @returns The full base URL.\n */\n #buildUrl(subdomain: string): string {\n return BASE_URL_TEMPLATE.replace('{0}', subdomain).replace(\n '{1}',\n this.#environmentDomain,\n );\n }\n}\n\n/**\n * Reads a response body as JSON. Returns undefined when the body is empty or\n * not JSON, so a failed request can still surface its HTTP status.\n *\n * @param response - The response to read.\n * @returns The parsed JSON body, or undefined.\n */\nasync function readJsonBody(response: Response): Promise<Json | undefined> {\n try {\n return (await response.json()) as Json;\n } catch {\n return undefined;\n }\n}\n"]}
|
package/dist/structs.d.ts
CHANGED
|
@@ -87,4 +87,108 @@ export declare const SentinelSmartTransactionResponseStruct: import("@metamask/s
|
|
|
87
87
|
errorReason: import("@metamask/superstruct").Struct<string | null | undefined, null>;
|
|
88
88
|
}>>;
|
|
89
89
|
}>;
|
|
90
|
+
/**
|
|
91
|
+
* Validates the `/getFees` response body.
|
|
92
|
+
*/
|
|
93
|
+
export declare const SentinelGetFeesResponseStruct: import("@metamask/superstruct").Struct<{
|
|
94
|
+
txs: {
|
|
95
|
+
cancelFees: {
|
|
96
|
+
maxFeePerGas: number;
|
|
97
|
+
maxPriorityFeePerGas: number;
|
|
98
|
+
}[];
|
|
99
|
+
feeEstimate: number;
|
|
100
|
+
fees: {
|
|
101
|
+
maxFeePerGas: number;
|
|
102
|
+
maxPriorityFeePerGas: number;
|
|
103
|
+
}[];
|
|
104
|
+
gasLimit: number;
|
|
105
|
+
gasUsed: number;
|
|
106
|
+
}[];
|
|
107
|
+
}, {
|
|
108
|
+
txs: import("@metamask/superstruct").Struct<{
|
|
109
|
+
cancelFees: {
|
|
110
|
+
maxFeePerGas: number;
|
|
111
|
+
maxPriorityFeePerGas: number;
|
|
112
|
+
}[];
|
|
113
|
+
feeEstimate: number;
|
|
114
|
+
fees: {
|
|
115
|
+
maxFeePerGas: number;
|
|
116
|
+
maxPriorityFeePerGas: number;
|
|
117
|
+
}[];
|
|
118
|
+
gasLimit: number;
|
|
119
|
+
gasUsed: number;
|
|
120
|
+
}[], import("@metamask/superstruct").Struct<{
|
|
121
|
+
cancelFees: {
|
|
122
|
+
maxFeePerGas: number;
|
|
123
|
+
maxPriorityFeePerGas: number;
|
|
124
|
+
}[];
|
|
125
|
+
feeEstimate: number;
|
|
126
|
+
fees: {
|
|
127
|
+
maxFeePerGas: number;
|
|
128
|
+
maxPriorityFeePerGas: number;
|
|
129
|
+
}[];
|
|
130
|
+
gasLimit: number;
|
|
131
|
+
gasUsed: number;
|
|
132
|
+
}, {
|
|
133
|
+
cancelFees: import("@metamask/superstruct").Struct<{
|
|
134
|
+
maxFeePerGas: number;
|
|
135
|
+
maxPriorityFeePerGas: number;
|
|
136
|
+
}[], import("@metamask/superstruct").Struct<{
|
|
137
|
+
maxFeePerGas: number;
|
|
138
|
+
maxPriorityFeePerGas: number;
|
|
139
|
+
}, {
|
|
140
|
+
maxFeePerGas: import("@metamask/superstruct").Struct<number, null>;
|
|
141
|
+
maxPriorityFeePerGas: import("@metamask/superstruct").Struct<number, null>;
|
|
142
|
+
}>>;
|
|
143
|
+
feeEstimate: import("@metamask/superstruct").Struct<number, null>;
|
|
144
|
+
fees: import("@metamask/superstruct").Struct<{
|
|
145
|
+
maxFeePerGas: number;
|
|
146
|
+
maxPriorityFeePerGas: number;
|
|
147
|
+
}[], import("@metamask/superstruct").Struct<{
|
|
148
|
+
maxFeePerGas: number;
|
|
149
|
+
maxPriorityFeePerGas: number;
|
|
150
|
+
}, {
|
|
151
|
+
maxFeePerGas: import("@metamask/superstruct").Struct<number, null>;
|
|
152
|
+
maxPriorityFeePerGas: import("@metamask/superstruct").Struct<number, null>;
|
|
153
|
+
}>>;
|
|
154
|
+
gasLimit: import("@metamask/superstruct").Struct<number, null>;
|
|
155
|
+
gasUsed: import("@metamask/superstruct").Struct<number, null>;
|
|
156
|
+
}>>;
|
|
157
|
+
}>;
|
|
158
|
+
/**
|
|
159
|
+
* Validates the `/submitTransactions` response body.
|
|
160
|
+
*/
|
|
161
|
+
export declare const SentinelSubmitTransactionsResponseStruct: import("@metamask/superstruct").Struct<{
|
|
162
|
+
uuid: string;
|
|
163
|
+
}, {
|
|
164
|
+
uuid: import("@metamask/superstruct").Struct<string, null>;
|
|
165
|
+
}>;
|
|
166
|
+
/**
|
|
167
|
+
* Validates the `/cancel` response body.
|
|
168
|
+
*/
|
|
169
|
+
export declare const SentinelCancelResponseStruct: import("@metamask/superstruct").Struct<{
|
|
170
|
+
affected: number;
|
|
171
|
+
cancelled: boolean;
|
|
172
|
+
uuid: string;
|
|
173
|
+
}, {
|
|
174
|
+
affected: import("@metamask/superstruct").Struct<number, null>;
|
|
175
|
+
cancelled: import("@metamask/superstruct").Struct<boolean, null>;
|
|
176
|
+
uuid: import("@metamask/superstruct").Struct<string, null>;
|
|
177
|
+
}>;
|
|
178
|
+
/**
|
|
179
|
+
* Validates the `/batchStatus` response body (a map keyed by UUID).
|
|
180
|
+
*/
|
|
181
|
+
export declare const SentinelBatchStatusResponseStruct: import("@metamask/superstruct").Struct<Record<string, {
|
|
182
|
+
cancellationFeeWei: number;
|
|
183
|
+
cancellationReason: string;
|
|
184
|
+
deadlineRatio: number;
|
|
185
|
+
duplicated: boolean;
|
|
186
|
+
isSettled: boolean;
|
|
187
|
+
minedHash: string;
|
|
188
|
+
minedTx: string;
|
|
189
|
+
originalTransactionStatus: string;
|
|
190
|
+
proxied: boolean;
|
|
191
|
+
timedOut: boolean;
|
|
192
|
+
wouldRevertMessage: string;
|
|
193
|
+
}>, null>;
|
|
90
194
|
//# sourceMappingURL=structs.d.ts.map
|
package/dist/structs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structs.d.ts","sourceRoot":"","sources":["../src/structs.ts"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;EAShC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;SAGzC,CAAC;AAUF;;;GAGG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;EAE3C,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,iCAAiC;;;;EAE5C,CAAC;AAWH;;;GAGG;AACH,eAAO,MAAM,sCAAsC;;;;;;;;;;;;;;;;;;;;EAEjD,CAAC"}
|
|
1
|
+
{"version":3,"file":"structs.d.ts","sourceRoot":"","sources":["../src/structs.ts"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;EAShC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;SAGzC,CAAC;AAUF;;;GAGG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;EAE3C,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,iCAAiC;;;;EAE5C,CAAC;AAWH;;;GAGG;AACH,eAAO,MAAM,sCAAsC;;;;;;;;;;;;;;;;;;;;EAEjD,CAAC;AAsBH;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAExC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,wCAAwC;;;;EAEnD,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;EAIvC,CAAC;AAqBH;;GAEG;AACH,eAAO,MAAM,iCAAiC;;;;;;;;;;;;SAG7C,CAAC"}
|
package/dist/structs.js
CHANGED
|
@@ -56,4 +56,64 @@ const SentinelSmartTransactionStruct = type({
|
|
|
56
56
|
export const SentinelSmartTransactionResponseStruct = type({
|
|
57
57
|
transactions: array(SentinelSmartTransactionStruct),
|
|
58
58
|
});
|
|
59
|
+
/**
|
|
60
|
+
* Validates one fee level from the `/getFees` endpoint.
|
|
61
|
+
*/
|
|
62
|
+
const SentinelSmartTransactionFeeStruct = type({
|
|
63
|
+
maxFeePerGas: number(),
|
|
64
|
+
maxPriorityFeePerGas: number(),
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
67
|
+
* Validates the fee quote for a single transaction. Loose so additional
|
|
68
|
+
* fields returned by the API are ignored.
|
|
69
|
+
*/
|
|
70
|
+
const SentinelSmartTransactionFeesStruct = type({
|
|
71
|
+
cancelFees: array(SentinelSmartTransactionFeeStruct),
|
|
72
|
+
feeEstimate: number(),
|
|
73
|
+
fees: array(SentinelSmartTransactionFeeStruct),
|
|
74
|
+
gasLimit: number(),
|
|
75
|
+
gasUsed: number(),
|
|
76
|
+
});
|
|
77
|
+
/**
|
|
78
|
+
* Validates the `/getFees` response body.
|
|
79
|
+
*/
|
|
80
|
+
export const SentinelGetFeesResponseStruct = type({
|
|
81
|
+
txs: array(SentinelSmartTransactionFeesStruct),
|
|
82
|
+
});
|
|
83
|
+
/**
|
|
84
|
+
* Validates the `/submitTransactions` response body.
|
|
85
|
+
*/
|
|
86
|
+
export const SentinelSubmitTransactionsResponseStruct = type({
|
|
87
|
+
uuid: string(),
|
|
88
|
+
});
|
|
89
|
+
/**
|
|
90
|
+
* Validates the `/cancel` response body.
|
|
91
|
+
*/
|
|
92
|
+
export const SentinelCancelResponseStruct = type({
|
|
93
|
+
affected: number(),
|
|
94
|
+
cancelled: boolean(),
|
|
95
|
+
uuid: string(),
|
|
96
|
+
});
|
|
97
|
+
/**
|
|
98
|
+
* Validates one UUID's entry in the `/batchStatus` response. The closed-set
|
|
99
|
+
* fields are checked as strings, matching the loose validation used for other
|
|
100
|
+
* Sentinel status fields.
|
|
101
|
+
*/
|
|
102
|
+
const SentinelBatchedTransactionStatusStruct = type({
|
|
103
|
+
cancellationFeeWei: number(),
|
|
104
|
+
cancellationReason: string(),
|
|
105
|
+
deadlineRatio: number(),
|
|
106
|
+
duplicated: boolean(),
|
|
107
|
+
isSettled: boolean(),
|
|
108
|
+
minedHash: string(),
|
|
109
|
+
minedTx: string(),
|
|
110
|
+
originalTransactionStatus: string(),
|
|
111
|
+
proxied: boolean(),
|
|
112
|
+
timedOut: boolean(),
|
|
113
|
+
wouldRevertMessage: string(),
|
|
114
|
+
});
|
|
115
|
+
/**
|
|
116
|
+
* Validates the `/batchStatus` response body (a map keyed by UUID).
|
|
117
|
+
*/
|
|
118
|
+
export const SentinelBatchStatusResponseStruct = record(string(), SentinelBatchedTransactionStatusStruct);
|
|
59
119
|
//# sourceMappingURL=structs.js.map
|
package/dist/structs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structs.js","sourceRoot":"","sources":["../src/structs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,IAAI,GACL,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;IACxC,OAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IAClC,aAAa,EAAE,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAC/C,OAAO,EAAE,MAAM,EAAE;IACjB,iBAAiB,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IACtC,UAAU,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC/B,qBAAqB,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC1C,iBAAiB,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;CACvC,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CACjD,MAAM,EAAE,EACR,qBAAqB,CACtB,CAAC;AAEF;;;GAGG;AACH,MAAM,2CAA2C,GAAG,IAAI,CAAC;IACvD,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;CAC1B,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,IAAI,CAAC;IACnD,YAAY,EAAE,KAAK,CAAC,2CAA2C,CAAC;CACjE,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,IAAI,CAAC;IACpD,IAAI,EAAE,MAAM,EAAE;CACf,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,8BAA8B,GAAG,IAAI,CAAC;IAC1C,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE;IAChB,WAAW,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;CAC1C,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,IAAI,CAAC;IACzD,YAAY,EAAE,KAAK,CAAC,8BAA8B,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import {\n array,\n boolean,\n nullable,\n number,\n optional,\n record,\n string,\n type,\n} from '@metamask/superstruct';\nimport { StrictHexStruct } from '@metamask/utils';\n\n/**\n * Validates a single network entry from the `/networks` registry, or the\n * single network configuration from the `/network` endpoint. Uses `type`\n * (loose) validation so that additional fields returned by the API do not\n * cause rejection; only the fields we depend on are asserted.\n */\nexport const SentinelNetworkStruct = type({\n chainID: optional(number()),\n confirmations: optional(boolean()),\n cubistSigners: optional(array(StrictHexStruct)),\n network: string(),\n relayTransactions: optional(boolean()),\n sendBundle: optional(boolean()),\n simulationIncludeFees: optional(boolean()),\n smartTransactions: optional(boolean()),\n});\n\n/**\n * Validates the `/networks` registry response (a map keyed by decimal chain\n * ID).\n */\nexport const SentinelNetworkRegistryStruct = record(\n string(),\n SentinelNetworkStruct,\n);\n\n/**\n * Validates a simulated-transaction result. Loose to tolerate the many\n * optional fields the API may return.\n */\nconst SentinelSimulationResponseTransactionStruct = type({\n error: optional(string()),\n});\n\n/**\n * Validates the top-level simulation response. Only the `transactions` array\n * is required by consumers.\n */\nexport const SentinelSimulationResponseStruct = type({\n transactions: array(SentinelSimulationResponseTransactionStruct),\n});\n\n/**\n * Validates the response from submitting a relay transaction.\n */\nexport const SentinelRelaySubmitResponseStruct = type({\n uuid: string(),\n});\n\n/**\n * Validates a single entry in the smart-transactions endpoint response.\n */\nconst SentinelSmartTransactionStruct = type({\n hash: optional(string()),\n status: string(),\n errorReason: optional(nullable(string())),\n});\n\n/**\n * Validates the smart-transactions endpoint response body (a list of\n * transactions).\n */\nexport const SentinelSmartTransactionResponseStruct = type({\n transactions: array(SentinelSmartTransactionStruct),\n});\n"]}
|
|
1
|
+
{"version":3,"file":"structs.js","sourceRoot":"","sources":["../src/structs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,IAAI,GACL,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;IACxC,OAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IAClC,aAAa,EAAE,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAC/C,OAAO,EAAE,MAAM,EAAE;IACjB,iBAAiB,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IACtC,UAAU,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC/B,qBAAqB,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC1C,iBAAiB,EAAE,QAAQ,CAAC,O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AEG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,CAAC;IAChD,GAAG,EAAE,KAAK,CAAC,kCAAkC,CAAC;CAC/C,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,wCAAwC,GAAG,IAAI,CAAC;IAC3D,IAAI,EAAE,MAAM,EAAE;CACf,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,CAAC;IAC/C,QAAQ,EAAE,MAAM,EAAE;IAClB,SAAS,EAAE,OAAO,EAAE;IACpB,IAAI,EAAE,MAAM,EAAE;CACf,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,sCAAsC,GAAG,IAAI,CAAC;IAClD,kBAAkB,EAAE,MAAM,EAAE;IAC5B,kBAAkB,EAAE,MAAM,EAAE;IAC5B,aAAa,EAAE,MAAM,EAAE;IACvB,UAAU,EAAE,OAAO,EAAE;IACrB,SAAS,EAAE,OAAO,EAAE;IACpB,SAAS,EAAE,MAAM,EAAE;IACnB,OAAO,EAAE,MAAM,EAAE;IACjB,yBAAyB,EAAE,MAAM,EAAE;IACnC,OAAO,EAAE,OAAO,EAAE;IAClB,QAAQ,EAAE,OAAO,EAAE;IACnB,kBAAkB,EAAE,MAAM,EAAE;CAC7B,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,MAAM,CACrD,MAAM,EAAE,EACR,sCAAsC,CACvC,CAAC","sourcesContent":["import {\n array,\n boolean,\n nullable,\n number,\n optional,\n record,\n string,\n type,\n} from '@metamask/superstruct';\nimport { StrictHexStruct } from '@metamask/utils';\n\n/**\n * Validates a single network entry from the `/networks` registry, or the\n * single network configuration from the `/network` endpoint. Uses `type`\n * (loose) validation so that additional fields returned by the API do not\n * cause rejection; only the fields we depend on are asserted.\n */\nexport const SentinelNetworkStruct = type({\n chainID: optional(number()),\n confirmations: optional(boolean()),\n cubistSigners: optional(array(StrictHexStruct)),\n network: string(),\n relayTransactions: optional(boolean()),\n sendBundle: optional(boolean()),\n simulationIncludeFees: optional(boolean()),\n smartTransactions: optional(boolean()),\n});\n\n/**\n * Validates the `/networks` registry response (a map keyed by decimal chain\n * ID).\n */\nexport const SentinelNetworkRegistryStruct = record(\n string(),\n SentinelNetworkStruct,\n);\n\n/**\n * Validates a simulated-transaction result. Loose to tolerate the many\n * optional fields the API may return.\n */\nconst SentinelSimulationResponseTransactionStruct = type({\n error: optional(string()),\n});\n\n/**\n * Validates the top-level simulation response. Only the `transactions` array\n * is required by consumers.\n */\nexport const SentinelSimulationResponseStruct = type({\n transactions: array(SentinelSimulationResponseTransactionStruct),\n});\n\n/**\n * Validates the response from submitting a relay transaction.\n */\nexport const SentinelRelaySubmitResponseStruct = type({\n uuid: string(),\n});\n\n/**\n * Validates a single entry in the smart-transactions endpoint response.\n */\nconst SentinelSmartTransactionStruct = type({\n hash: optional(string()),\n status: string(),\n errorReason: optional(nullable(string())),\n});\n\n/**\n * Validates the smart-transactions endpoint response body (a list of\n * transactions).\n */\nexport const SentinelSmartTransactionResponseStruct = type({\n transactions: array(SentinelSmartTransactionStruct),\n});\n\n/**\n * Validates one fee level from the `/getFees` endpoint.\n */\nconst SentinelSmartTransactionFeeStruct = type({\n maxFeePerGas: number(),\n maxPriorityFeePerGas: number(),\n});\n\n/**\n * Validates the fee quote for a single transaction. Loose so additional\n * fields returned by the API are ignored.\n */\nconst SentinelSmartTransactionFeesStruct = type({\n cancelFees: array(SentinelSmartTransactionFeeStruct),\n feeEstimate: number(),\n fees: array(SentinelSmartTransactionFeeStruct),\n gasLimit: number(),\n gasUsed: number(),\n});\n\n/**\n * Validates the `/getFees` response body.\n */\nexport const SentinelGetFeesResponseStruct = type({\n txs: array(SentinelSmartTransactionFeesStruct),\n});\n\n/**\n * Validates the `/submitTransactions` response body.\n */\nexport const SentinelSubmitTransactionsResponseStruct = type({\n uuid: string(),\n});\n\n/**\n * Validates the `/cancel` response body.\n */\nexport const SentinelCancelResponseStruct = type({\n affected: number(),\n cancelled: boolean(),\n uuid: string(),\n});\n\n/**\n * Validates one UUID's entry in the `/batchStatus` response. The closed-set\n * fields are checked as strings, matching the loose validation used for other\n * Sentinel status fields.\n */\nconst SentinelBatchedTransactionStatusStruct = type({\n cancellationFeeWei: number(),\n cancellationReason: string(),\n deadlineRatio: number(),\n duplicated: boolean(),\n isSettled: boolean(),\n minedHash: string(),\n minedTx: string(),\n originalTransactionStatus: string(),\n proxied: boolean(),\n timedOut: boolean(),\n wouldRevertMessage: string(),\n});\n\n/**\n * Validates the `/batchStatus` response body (a map keyed by UUID).\n */\nexport const SentinelBatchStatusResponseStruct = record(\n string(),\n SentinelBatchedTransactionStatusStruct,\n);\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -90,6 +90,9 @@ export declare enum SentinelFeature {
|
|
|
90
90
|
/**
|
|
91
91
|
* The kind of relay (gas station) submission. Redefined here so that this
|
|
92
92
|
* package does not depend on `@metamask/smart-transactions-controller`.
|
|
93
|
+
*
|
|
94
|
+
* @deprecated Sentinel no longer takes a `kind` in its metadata. This enum
|
|
95
|
+
* will be removed in a future major version.
|
|
93
96
|
*/
|
|
94
97
|
export declare enum SentinelKind {
|
|
95
98
|
Bundle = "bundle",
|
|
@@ -97,6 +100,17 @@ export declare enum SentinelKind {
|
|
|
97
100
|
GaslessEIP7702 = "gaslessEIP7702",
|
|
98
101
|
GaslessSendBundle = "gaslessSendBundle"
|
|
99
102
|
}
|
|
103
|
+
export declare enum SentinelProductFeature {
|
|
104
|
+
Bridge = "Bridge",
|
|
105
|
+
Card = "Card",
|
|
106
|
+
dAppTransaction = "dAppTransaction",
|
|
107
|
+
Earn = "Earn",
|
|
108
|
+
Perp = "Perp",
|
|
109
|
+
Prediction = "Prediction",
|
|
110
|
+
Ramp = "Ramp",
|
|
111
|
+
Staking = "Staking",
|
|
112
|
+
Swap = "Swap"
|
|
113
|
+
}
|
|
100
114
|
/**
|
|
101
115
|
* Optional metadata forwarded with a relay submission for observability. All
|
|
102
116
|
* fields are optional and passed through verbatim to the Sentinel API.
|
|
@@ -104,11 +118,20 @@ export declare enum SentinelKind {
|
|
|
104
118
|
export type SentinelMeta = {
|
|
105
119
|
client?: string;
|
|
106
120
|
clientVersion?: string;
|
|
107
|
-
feature?: SentinelFeature;
|
|
121
|
+
feature?: SentinelFeature | SentinelProductFeature;
|
|
122
|
+
/**
|
|
123
|
+
* @deprecated Sentinel no longer takes a `kind` in its metadata. This field
|
|
124
|
+
* will be removed in a future major version.
|
|
125
|
+
*/
|
|
108
126
|
kind?: SentinelKind;
|
|
109
127
|
origin?: string;
|
|
110
128
|
txType?: string;
|
|
129
|
+
/**
|
|
130
|
+
* @deprecated Sentinel no longer takes a `wallet` in its metadata. This field
|
|
131
|
+
* will be removed in a future major version.
|
|
132
|
+
*/
|
|
111
133
|
wallet?: string;
|
|
134
|
+
accountHardwareType?: string;
|
|
112
135
|
};
|
|
113
136
|
/**
|
|
114
137
|
* An EIP-7702 authorization entry, as accepted by the Sentinel simulation API.
|
|
@@ -231,6 +254,72 @@ export type SentinelSmartTransactionRequest = {
|
|
|
231
254
|
/** The UUID returned by {@link SentinelRelaySubmitResponse}. */
|
|
232
255
|
uuid: string;
|
|
233
256
|
};
|
|
257
|
+
/**
|
|
258
|
+
* A request to quote gas fees for unsigned smart transactions via
|
|
259
|
+
* `POST /v1/networks/{chainId}/getFees`.
|
|
260
|
+
*/
|
|
261
|
+
export type SentinelGetFeesRequest = {
|
|
262
|
+
/** The chain to quote fees on. */
|
|
263
|
+
chainId: Hex;
|
|
264
|
+
/**
|
|
265
|
+
* Transactions to quote, in the order the fees should be returned. Each
|
|
266
|
+
* entry is a {@link SentinelSimulationTransaction}. The handler forwards
|
|
267
|
+
* them as the `txs` array.
|
|
268
|
+
*/
|
|
269
|
+
transactions: SentinelSimulationTransaction[];
|
|
270
|
+
};
|
|
271
|
+
/**
|
|
272
|
+
* A raw signed smart transaction and the metadata stored with it.
|
|
273
|
+
*/
|
|
274
|
+
export type SentinelSubmitTransactionWithMetadata = {
|
|
275
|
+
/** Raw signed transaction. */
|
|
276
|
+
tx: Hex;
|
|
277
|
+
/** Observability metadata stored with the transaction. */
|
|
278
|
+
metadata?: SentinelMeta;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* A request to submit signed smart transactions via
|
|
282
|
+
* `POST /v1/networks/{chainId}/submitTransactions`.
|
|
283
|
+
*/
|
|
284
|
+
export type SentinelSubmitTransactionsRequest = {
|
|
285
|
+
/** The chain to submit the transactions on. */
|
|
286
|
+
chainId: Hex;
|
|
287
|
+
/**
|
|
288
|
+
* Raw signed transactions. Used when `rawTxsWithMetadata` is omitted or
|
|
289
|
+
* empty.
|
|
290
|
+
*/
|
|
291
|
+
rawTxs: Hex[];
|
|
292
|
+
/** Raw signed transactions that cancel the submitted batch. */
|
|
293
|
+
rawCancelTxs?: Hex[];
|
|
294
|
+
/**
|
|
295
|
+
* Raw signed transactions with metadata. When non-empty, the API submits
|
|
296
|
+
* these instead of `rawTxs`.
|
|
297
|
+
*/
|
|
298
|
+
rawTxsWithMetadata?: SentinelSubmitTransactionWithMetadata[];
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* A request to cancel a smart transaction via
|
|
302
|
+
* `POST /v1/networks/{chainId}/cancel`.
|
|
303
|
+
*/
|
|
304
|
+
export type SentinelCancelRequest = {
|
|
305
|
+
/** The chain to cancel the transaction on. */
|
|
306
|
+
chainId: Hex;
|
|
307
|
+
/** UUID of the smart transaction to cancel. */
|
|
308
|
+
uuid: string;
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* A request to look up smart-transaction statuses via
|
|
312
|
+
* `GET /v1/networks/{chainId}/batchStatus`.
|
|
313
|
+
*/
|
|
314
|
+
export type SentinelBatchStatusRequest = {
|
|
315
|
+
/** The chain to look up statuses on. */
|
|
316
|
+
chainId: Hex;
|
|
317
|
+
/**
|
|
318
|
+
* UUIDs to look up. Sent as the comma-separated `uuids` query parameter.
|
|
319
|
+
* The handler rejects a list longer than 128.
|
|
320
|
+
*/
|
|
321
|
+
uuids: string[];
|
|
322
|
+
};
|
|
234
323
|
/**
|
|
235
324
|
* A single network entry from the Sentinel `/networks` registry, or the
|
|
236
325
|
* configuration of a single network from the `/network` endpoint.
|
|
@@ -430,5 +519,155 @@ export type SentinelSmartTransaction = {
|
|
|
430
519
|
export type SentinelSmartTransactionResponse = {
|
|
431
520
|
transactions: SentinelSmartTransaction[];
|
|
432
521
|
};
|
|
522
|
+
/**
|
|
523
|
+
* One gas-fee level returned by the smart-transactions `/getFees` endpoint.
|
|
524
|
+
* Amounts are decimal numbers, in wei.
|
|
525
|
+
*/
|
|
526
|
+
export type SentinelSmartTransactionFee = {
|
|
527
|
+
/** Maximum fee per gas, in wei. */
|
|
528
|
+
maxFeePerGas: number;
|
|
529
|
+
/** Maximum priority fee per gas, in wei. */
|
|
530
|
+
maxPriorityFeePerGas: number;
|
|
531
|
+
};
|
|
532
|
+
/**
|
|
533
|
+
* Fee quote for a single transaction from the `/getFees` endpoint.
|
|
534
|
+
*/
|
|
535
|
+
export type SentinelSmartTransactionFees = {
|
|
536
|
+
/** Candidate fees for submitting the transaction. */
|
|
537
|
+
fees: SentinelSmartTransactionFee[];
|
|
538
|
+
/** Candidate fees for cancelling the transaction. */
|
|
539
|
+
cancelFees: SentinelSmartTransactionFee[];
|
|
540
|
+
/** Estimated total fee, in wei. */
|
|
541
|
+
feeEstimate: number;
|
|
542
|
+
/** Gas limit used for the quote. */
|
|
543
|
+
gasLimit: number;
|
|
544
|
+
/** Gas used by the quote. */
|
|
545
|
+
gasUsed: number;
|
|
546
|
+
};
|
|
547
|
+
/**
|
|
548
|
+
* The response from `POST /v1/networks/{chainId}/getFees`. One entry in `txs`
|
|
549
|
+
* per transaction in the request, in the same order.
|
|
550
|
+
*/
|
|
551
|
+
export type SentinelGetFeesResponse = {
|
|
552
|
+
txs: SentinelSmartTransactionFees[];
|
|
553
|
+
};
|
|
554
|
+
/**
|
|
555
|
+
* The response from `POST /v1/networks/{chainId}/submitTransactions`.
|
|
556
|
+
*/
|
|
557
|
+
export type SentinelSubmitTransactionsResponse = {
|
|
558
|
+
/** UUID assigned to the submitted batch. */
|
|
559
|
+
uuid: string;
|
|
560
|
+
};
|
|
561
|
+
/**
|
|
562
|
+
* The response from `POST /v1/networks/{chainId}/cancel`.
|
|
563
|
+
*/
|
|
564
|
+
export type SentinelCancelResponse = {
|
|
565
|
+
/** UUID of the cancelled smart transaction. */
|
|
566
|
+
uuid: string;
|
|
567
|
+
/** Number of pending transactions the cancel updated. */
|
|
568
|
+
affected: number;
|
|
569
|
+
/**
|
|
570
|
+
* Always `true` on a 200 response. The handler sets this itself; the RPC
|
|
571
|
+
* result only carries `uuid` and `affected`.
|
|
572
|
+
*/
|
|
573
|
+
cancelled: boolean;
|
|
574
|
+
};
|
|
575
|
+
/**
|
|
576
|
+
* Values of `cancellationReason` on a batch-status entry.
|
|
577
|
+
* Compliant with the Transaction API (SCP).
|
|
578
|
+
*/
|
|
579
|
+
export declare enum SentinelCancellationReason {
|
|
580
|
+
DeadlineMissed = "deadline_missed",
|
|
581
|
+
InvalidNonce = "invalid_nonce",
|
|
582
|
+
NotCancelled = "not_cancelled",
|
|
583
|
+
TooCheap = "too_cheap",
|
|
584
|
+
UserCancelled = "user_cancelled",
|
|
585
|
+
WouldRevert = "would_revert"
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Values of `minedTx` on a batch-status entry.
|
|
589
|
+
* Compliant with the Transaction API (SCP).
|
|
590
|
+
*/
|
|
591
|
+
export declare enum SentinelMinedTxStatus {
|
|
592
|
+
Cancelled = "cancelled",
|
|
593
|
+
NotMined = "not_mined",
|
|
594
|
+
Reverted = "reverted",
|
|
595
|
+
Success = "success"
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Values of `originalTransactionStatus` on a batch-status entry.
|
|
599
|
+
* `UNKNOWN_STATUS` is the Go `String()` fallback and is not produced for a
|
|
600
|
+
* status loaded from the database.
|
|
601
|
+
*/
|
|
602
|
+
export declare enum SentinelOriginalTransactionStatus {
|
|
603
|
+
Cancelled = "CANCELLED",
|
|
604
|
+
CancelledLeakedReverted = "CANCELLED_LEAKED_REVERTED",
|
|
605
|
+
CancelledLeakedValidated = "CANCELLED_LEAKED_VALIDATED",
|
|
606
|
+
Failed = "FAILED",
|
|
607
|
+
FailedAuth = "FAILED_AUTH",
|
|
608
|
+
FailedGaslessConfig = "FAILED_GASLESS_CONFIG",
|
|
609
|
+
FailedGasTooLow = "FAILED_GAS_TOO_LOW",
|
|
610
|
+
FailedInsufficientFee = "FAILED_INSUFFICIENT_FEE",
|
|
611
|
+
FailedInsufficientFunds = "FAILED_INSUFFICIENT_FUNDS",
|
|
612
|
+
FailedNonceTooHigh = "FAILED_NONCE_TOO_HIGH",
|
|
613
|
+
FailedSpam = "FAILED_SPAM",
|
|
614
|
+
FailedSponsorshipRule = "FAILED_SPONSORSHIP_RULE",
|
|
615
|
+
FailedTimeout = "FAILED_TIMEOUT",
|
|
616
|
+
FailedUnknown = "FAILED_UNKNOWN",
|
|
617
|
+
FailedWouldRevert = "FAILED_WOULD_REVERT",
|
|
618
|
+
LeakedReverted = "LEAKED_REVERTED",
|
|
619
|
+
LeakedValidated = "LEAKED_VALIDATED",
|
|
620
|
+
NonceTooLow = "NONCE_TOO_LOW",
|
|
621
|
+
Pending = "PENDING",
|
|
622
|
+
PendingCancelled = "PENDING_CANCELLED",
|
|
623
|
+
Reverted = "REVERTED",
|
|
624
|
+
Validated = "VALIDATED"
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* One UUID's status from `GET /v1/networks/{chainId}/batchStatus`.
|
|
628
|
+
*/
|
|
629
|
+
export type SentinelBatchedTransactionStatus = {
|
|
630
|
+
/**
|
|
631
|
+
* Cancellation fee in wei. The handler always sends `0`.
|
|
632
|
+
*/
|
|
633
|
+
cancellationFeeWei: number;
|
|
634
|
+
/** Why the transaction was cancelled, or `not_cancelled`. */
|
|
635
|
+
cancellationReason: SentinelCancellationReason;
|
|
636
|
+
/**
|
|
637
|
+
* Deadline ratio. The handler always sends `0`.
|
|
638
|
+
*/
|
|
639
|
+
deadlineRatio: number;
|
|
640
|
+
/**
|
|
641
|
+
* Whether the transaction has left `PENDING`. `PENDING_CANCELLED` is
|
|
642
|
+
* settled.
|
|
643
|
+
*/
|
|
644
|
+
isSettled: boolean;
|
|
645
|
+
/**
|
|
646
|
+
* Hash of the mined submission. Empty when the aggregate status is not a
|
|
647
|
+
* mined status, or when no submission hash matches that status.
|
|
648
|
+
*/
|
|
649
|
+
minedHash: string;
|
|
650
|
+
/** Mining outcome of the smart transaction. */
|
|
651
|
+
minedTx: SentinelMinedTxStatus;
|
|
652
|
+
/**
|
|
653
|
+
* Failure message. Empty unless the aggregate status is
|
|
654
|
+
* `FAILED_WOULD_REVERT`, `FAILED_SPONSORSHIP_RULE`,
|
|
655
|
+
* `FAILED_INSUFFICIENT_FUNDS`, or `FAILED_INSUFFICIENT_FEE`.
|
|
656
|
+
*/
|
|
657
|
+
wouldRevertMessage: string;
|
|
658
|
+
/** Whether Sentinel treated the submission as a duplicate. */
|
|
659
|
+
duplicated: boolean;
|
|
660
|
+
/** Whether the submission was proxied. */
|
|
661
|
+
proxied: boolean;
|
|
662
|
+
/** Whether the submission timed out. */
|
|
663
|
+
timedOut: boolean;
|
|
664
|
+
/** Aggregate smart-transaction status. */
|
|
665
|
+
originalTransactionStatus: SentinelOriginalTransactionStatus;
|
|
666
|
+
};
|
|
667
|
+
/**
|
|
668
|
+
* The response from `GET /v1/networks/{chainId}/batchStatus`.
|
|
669
|
+
* Keys are the smart-transaction UUIDs from the request.
|
|
670
|
+
*/
|
|
671
|
+
export type SentinelBatchStatusResponse = Record<string, SentinelBatchedTransactionStatus>;
|
|
433
672
|
export {};
|
|
434
673
|
//# sourceMappingURL=types.d.ts.map
|