@metamask-previews/chomp-api-service 0.0.0-preview-9fac52d → 1.0.0-preview-42c8fd288

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.
@@ -12,8 +12,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
12
12
  var _ChompApiService_instances, _ChompApiService_baseUrl, _ChompApiService_authHeaders;
13
13
  import { BaseDataService } from "@metamask/base-data-service";
14
14
  import { HttpError } from "@metamask/controller-utils";
15
- import { array, boolean, create, define, enums, literal, number, optional, record, string, type } from "@metamask/superstruct";
16
- import { isStrictHexString } from "@metamask/utils";
15
+ import { array, boolean, create, enums, literal, number, optional, record, string, type } from "@metamask/superstruct";
16
+ import { StrictHexStruct } from "@metamask/utils";
17
17
  // === GENERAL ===
18
18
  /**
19
19
  * The name of the {@link ChompApiService}, used to namespace the service's
@@ -36,40 +36,39 @@ const MESSENGER_EXPOSED_METHODS = [
36
36
  'getServiceDetails',
37
37
  ];
38
38
  // === RESPONSE VALIDATION ===
39
- const HexStringStruct = define('Hex string', (value) => isStrictHexString(value));
40
39
  const AssociateAddressResponseStruct = type({
41
40
  profileId: string(),
42
- address: string(),
41
+ address: StrictHexStruct,
43
42
  status: string(),
44
43
  });
45
44
  const UpgradeResponseStruct = type({
46
- signerAddress: string(),
45
+ signerAddress: StrictHexStruct,
47
46
  status: string(),
48
47
  createdAt: string(),
49
48
  });
50
49
  const VerifyDelegationResponseStruct = type({
51
50
  valid: boolean(),
52
- delegationHash: optional(string()),
51
+ delegationHash: optional(StrictHexStruct),
53
52
  errors: optional(array(string())),
54
53
  });
55
54
  const SendIntentResponseArrayStruct = array(type({
56
- delegationHash: string(),
55
+ delegationHash: StrictHexStruct,
57
56
  metadata: type({
58
- allowance: HexStringStruct,
57
+ allowance: StrictHexStruct,
59
58
  tokenSymbol: string(),
60
- tokenAddress: HexStringStruct,
59
+ tokenAddress: StrictHexStruct,
61
60
  type: enums(['cash-deposit', 'cash-withdrawal']),
62
61
  }),
63
62
  createdAt: string(),
64
63
  }));
65
64
  const IntentEntryArrayStruct = array(type({
66
- account: HexStringStruct,
67
- delegationHash: HexStringStruct,
68
- chainId: HexStringStruct,
65
+ account: StrictHexStruct,
66
+ delegationHash: StrictHexStruct,
67
+ chainId: StrictHexStruct,
69
68
  status: enums(['active', 'revoked']),
70
69
  metadata: type({
71
- allowance: HexStringStruct,
72
- tokenAddress: HexStringStruct,
70
+ allowance: StrictHexStruct,
71
+ tokenAddress: StrictHexStruct,
73
72
  tokenSymbol: string(),
74
73
  type: enums(['deposit', 'withdraw']),
75
74
  }),
@@ -79,18 +78,18 @@ const CreateWithdrawalResponseStruct = type({
79
78
  });
80
79
  const ServiceDetailsProtocolStruct = type({
81
80
  supportedTokens: array(type({
82
- tokenAddress: string(),
81
+ tokenAddress: StrictHexStruct,
83
82
  tokenDecimals: number(),
84
83
  })),
85
- adapterAddress: string(),
84
+ adapterAddress: StrictHexStruct,
86
85
  intentTypes: array(enums(['cash-deposit', 'cash-withdrawal'])),
87
86
  });
88
87
  const ServiceDetailsResponseStruct = type({
89
88
  auth: type({
90
89
  message: string(),
91
90
  }),
92
- chains: record(string(), type({
93
- autoDepositDelegate: string(),
91
+ chains: record(StrictHexStruct, type({
92
+ autoDepositDelegate: StrictHexStruct,
94
93
  protocol: record(string(), ServiceDetailsProtocolStruct),
95
94
  })),
96
95
  });
@@ -129,20 +128,20 @@ export class ChompApiService extends BaseDataService {
129
128
  *
130
129
  * POST /v1/auth/address
131
130
  *
132
- * @param request - The association request containing signature, timestamp,
131
+ * @param params - The association params containing signature, timestamp,
133
132
  * and address.
134
133
  * @returns The profile association result. Returns on both 201 and 409.
135
134
  */
136
- async associateAddress(request) {
135
+ async associateAddress(params) {
137
136
  const jsonResponse = await this.fetchQuery({
138
- queryKey: [`${this.name}:associateAddress`, request],
137
+ queryKey: [`${this.name}:associateAddress`, params],
139
138
  staleTime: 0,
140
139
  queryFn: async () => {
141
140
  const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
142
141
  const response = await fetch(new URL('/v1/auth/address', __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), {
143
142
  method: 'POST',
144
143
  headers,
145
- body: JSON.stringify(request),
144
+ body: JSON.stringify(params),
146
145
  });
147
146
  if (!response.ok && response.status !== 409) {
148
147
  throw new HttpError(response.status, `POST /v1/auth/address failed with status '${response.status}'`);
@@ -157,20 +156,20 @@ export class ChompApiService extends BaseDataService {
157
156
  *
158
157
  * POST /v1/account-upgrade
159
158
  *
160
- * @param request - The upgrade request containing signature components and
159
+ * @param params - The upgrade params containing signature components and
161
160
  * chain details.
162
161
  * @returns The upgrade result.
163
162
  */
164
- async createUpgrade(request) {
163
+ async createUpgrade(params) {
165
164
  const jsonResponse = await this.fetchQuery({
166
- queryKey: [`${this.name}:createUpgrade`, request],
165
+ queryKey: [`${this.name}:createUpgrade`, params],
167
166
  staleTime: 0,
168
167
  queryFn: async () => {
169
168
  const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
170
169
  const response = await fetch(new URL('/v1/account-upgrade', __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), {
171
170
  method: 'POST',
172
171
  headers,
173
- body: JSON.stringify(request),
172
+ body: JSON.stringify(params),
174
173
  });
175
174
  if (!response.ok) {
176
175
  throw new HttpError(response.status, `POST /v1/account-upgrade failed with status '${response.status}'`);
@@ -213,19 +212,19 @@ export class ChompApiService extends BaseDataService {
213
212
  *
214
213
  * POST /v1/intent/verify-delegation
215
214
  *
216
- * @param request - The delegation verification request.
215
+ * @param params - The delegation verification params.
217
216
  * @returns The verification result including validity and optional errors.
218
217
  */
219
- async verifyDelegation(request) {
218
+ async verifyDelegation(params) {
220
219
  const jsonResponse = await this.fetchQuery({
221
- queryKey: [`${this.name}:verifyDelegation`, request],
220
+ queryKey: [`${this.name}:verifyDelegation`, params],
222
221
  staleTime: 0,
223
222
  queryFn: async () => {
224
223
  const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
225
224
  const response = await fetch(new URL('/v1/intent/verify-delegation', __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), {
226
225
  method: 'POST',
227
226
  headers,
228
- body: JSON.stringify(request),
227
+ body: JSON.stringify(params),
229
228
  });
230
229
  if (!response.ok) {
231
230
  throw new HttpError(response.status, `POST /v1/intent/verify-delegation failed with status '${response.status}'`);
@@ -289,20 +288,20 @@ export class ChompApiService extends BaseDataService {
289
288
  *
290
289
  * POST /v1/withdrawal
291
290
  *
292
- * @param request - The withdrawal request containing chainId, amount
291
+ * @param params - The withdrawal params containing chainId, amount
293
292
  * (decimal or hex string), and account address.
294
293
  * @returns The withdrawal result.
295
294
  */
296
- async createWithdrawal(request) {
295
+ async createWithdrawal(params) {
297
296
  const jsonResponse = await this.fetchQuery({
298
- queryKey: [`${this.name}:createWithdrawal`, request],
297
+ queryKey: [`${this.name}:createWithdrawal`, params],
299
298
  staleTime: 0,
300
299
  queryFn: async () => {
301
300
  const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
302
301
  const response = await fetch(new URL('/v1/withdrawal', __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), {
303
302
  method: 'POST',
304
303
  headers,
305
- body: JSON.stringify(request),
304
+ body: JSON.stringify(params),
306
305
  });
307
306
  if (!response.ok) {
308
307
  throw new HttpError(response.status, `POST /v1/withdrawal failed with status '${response.status}'`);
@@ -323,11 +322,6 @@ export class ChompApiService extends BaseDataService {
323
322
  * @returns The service details for the requested chains.
324
323
  */
325
324
  async getServiceDetails(chainIds) {
326
- for (const chainId of chainIds) {
327
- if (!isStrictHexString(chainId)) {
328
- throw new Error(`Invalid chainId: expected a 0x-prefixed hex string, got '${chainId}'`);
329
- }
330
- }
331
325
  const jsonResponse = await this.fetchQuery({
332
326
  queryKey: [`${this.name}:getServiceDetails`, chainIds],
333
327
  queryFn: async () => {
@@ -1 +1 @@
1
- {"version":3,"file":"chomp-api-service.mjs","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAO9D,OAAO,EAAE,SAAS,EAAE,mCAAmC;AAEvD,OAAO,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,MAAM,EACN,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,IAAI,EACL,8BAA8B;AAC/B,OAAO,EAAE,iBAAiB,EAAE,wBAAwB;AAmBpD,kBAAkB;AAElB;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAE7C,oBAAoB;AAEpB;;;GAGG;AACH,MAAM,yBAAyB,GAAG;IAChC,kBAAkB;IAClB,eAAe;IACf,YAAY;IACZ,kBAAkB;IAClB,eAAe;IACf,qBAAqB;IACrB,kBAAkB;IAClB,mBAAmB;CACX,CAAC;AA0DX,8BAA8B;AAE9B,MAAM,eAAe,GAAG,MAAM,CAAS,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAC7D,iBAAiB,CAAC,KAAK,CAAC,CACzB,CAAC;AAEF,MAAM,8BAA8B,GAAG,IAAI,CAAC;IAC1C,SAAS,EAAE,MAAM,EAAE;IACnB,OAAO,EAAE,MAAM,EAAE;IACjB,MAAM,EAAE,MAAM,EAAE;CACjB,CAAC,CAAC;AAEH,MAAM,qBAAqB,GAAG,IAAI,CAAC;IACjC,aAAa,EAAE,MAAM,EAAE;IACvB,MAAM,EAAE,MAAM,EAAE;IAChB,SAAS,EAAE,MAAM,EAAE;CACpB,CAAC,CAAC;AAEH,MAAM,8BAA8B,GAAG,IAAI,CAAC;IAC1C,KAAK,EAAE,OAAO,EAAE;IAChB,cAAc,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAClC,MAAM,EAAE,QAAQ,CAAC,K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G,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;gBAE/C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACjB,MAAM,IAAI,SAAS,CACjB,QAAQ,CAAC,MAAM,EACf,qCAAqC,QAAQ,CAAC,MAAM,GAAG,CACxD,CAAC;gBACJ,CAAC;gBAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;YACzB,CAAC;SACF,CAAC,CAAC;QAEH,OAAO,MAAM,CACX,YAAY,EACZ,4BAA4B,CACH,CAAC;IAC9B,CAAC;CACF;;AAnUC;;;;GAIG;AACH,KAAK;IACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CACrC,yCAAyC,CAC1C,CAAC;IACF,OAAO;QACL,aAAa,EAAE,UAAU,KAAK,EAAE;QAChC,cAAc,EAAE,kBAAkB;KACnC,CAAC;AACJ,CAAC","sourcesContent":["import { BaseDataService } from '@metamask/base-data-service';\nimport type {\n DataServiceCacheUpdatedEvent,\n DataServiceGranularCacheUpdatedEvent,\n DataServiceInvalidateQueriesAction,\n} from '@metamask/base-data-service';\nimport type { CreateServicePolicyOptions } from '@metamask/controller-utils';\nimport { HttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport {\n array,\n boolean,\n create,\n define,\n enums,\n literal,\n number,\n optional,\n record,\n string,\n type,\n} from '@metamask/superstruct';\nimport { isStrictHexString } from '@metamask/utils';\nimport type { QueryClientConfig } from '@tanstack/query-core';\n\nimport type { ChompApiServiceMethodActions } from './chomp-api-service-method-action-types';\nimport type {\n AssociateAddressRequest,\n AssociateAddressResponse,\n CreateUpgradeRequest,\n UpgradeResponse,\n CreateWithdrawalRequest,\n CreateWithdrawalResponse,\n IntentEntry,\n SendIntentRequest,\n SendIntentResponse,\n ServiceDetailsResponse,\n VerifyDelegationRequest,\n VerifyDelegationResponse,\n} from './types';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link ChompApiService}, used to namespace the service's\n * actions and events.\n */\nexport const serviceName = 'ChompApiService';\n\n// === MESSENGER ===\n\n/**\n * All of the methods within {@link ChompApiService} that are exposed via the\n * messenger.\n */\nconst MESSENGER_EXPOSED_METHODS = [\n 'associateAddress',\n 'createUpgrade',\n 'getUpgrade',\n 'verifyDelegation',\n 'createIntents',\n 'getIntentsByAddress',\n 'createWithdrawal',\n 'getServiceDetails',\n] as const;\n\n/**\n * Invalidates cached queries for {@link ChompApiService}.\n */\nexport type ChompApiServiceInvalidateQueriesAction =\n DataServiceInvalidateQueriesAction<typeof serviceName>;\n\n/**\n * Actions that {@link ChompApiService} exposes to other consumers.\n */\nexport type ChompApiServiceActions =\n | ChompApiServiceMethodActions\n | ChompApiServiceInvalidateQueriesAction;\n\n/**\n * Actions from other messengers that {@link ChompApiService} calls.\n */\ntype AllowedActions = {\n type: 'AuthenticationController:getBearerToken';\n handler: (entropySourceId?: string) => Promise<string>;\n};\n\n/**\n * Published when {@link ChompApiService}'s cache is updated.\n */\nexport type ChompApiServiceCacheUpdatedEvent = DataServiceCacheUpdatedEvent<\n typeof serviceName\n>;\n\n/**\n * Published when a key within {@link ChompApiService}'s cache is updated.\n */\nexport type ChompApiServiceGranularCacheUpdatedEvent =\n DataServiceGranularCacheUpdatedEvent<typeof serviceName>;\n\n/**\n * Events that {@link ChompApiService} exposes to other consumers.\n */\nexport type ChompApiServiceEvents =\n | ChompApiServiceCacheUpdatedEvent\n | ChompApiServiceGranularCacheUpdatedEvent;\n\n/**\n * Events from other messengers that {@link ChompApiService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link ChompApiService}.\n */\nexport type ChompApiServiceMessenger = Messenger<\n typeof serviceName,\n ChompApiServiceActions | AllowedActions,\n ChompApiServiceEvents | AllowedEvents\n>;\n\n// === RESPONSE VALIDATION ===\n\nconst HexStringStruct = define<string>('Hex string', (value) =>\n isStrictHexString(value),\n);\n\nconst AssociateAddressResponseStruct = type({\n profileId: string(),\n address: string(),\n status: string(),\n});\n\nconst UpgradeResponseStruct = type({\n signerAddress: string(),\n status: string(),\n createdAt: string(),\n});\n\nconst VerifyDelegationResponseStruct = type({\n valid: boolean(),\n delegationHash: optional(string()),\n errors: optional(array(string())),\n});\n\nconst SendIntentResponseArrayStruct = array(\n type({\n delegationHash: string(),\n metadata: type({\n allowance: HexStringStruct,\n tokenSymbol: string(),\n tokenAddress: HexStringStruct,\n type: enums(['cash-deposit', 'cash-withdrawal']),\n }),\n createdAt: string(),\n }),\n);\n\nconst IntentEntryArrayStruct = array(\n type({\n account: HexStringStruct,\n delegationHash: HexStringStruct,\n chainId: HexStringStruct,\n status: enums(['active', 'revoked']),\n metadata: type({\n allowance: HexStringStruct,\n tokenAddress: HexStringStruct,\n tokenSymbol: string(),\n type: enums(['deposit', 'withdraw']),\n }),\n }),\n);\n\nconst CreateWithdrawalResponseStruct = type({\n success: literal(true),\n});\n\nconst ServiceDetailsProtocolStruct = type({\n supportedTokens: array(\n type({\n tokenAddress: string(),\n tokenDecimals: number(),\n }),\n ),\n adapterAddress: string(),\n intentTypes: array(enums(['cash-deposit', 'cash-withdrawal'])),\n});\n\nconst ServiceDetailsResponseStruct = type({\n auth: type({\n message: string(),\n }),\n chains: record(\n string(),\n type({\n autoDepositDelegate: string(),\n protocol: record(string(), ServiceDetailsProtocolStruct),\n }),\n ),\n});\n\n// === SERVICE DEFINITION ===\n\n/**\n * This service is responsible for communicating with the CHOMP API.\n *\n * All requests are authenticated via JWT Bearer tokens obtained from the\n * `AuthenticationController:getBearerToken` messenger action.\n */\nexport class ChompApiService extends BaseDataService<\n typeof serviceName,\n ChompApiServiceMessenger\n> {\n readonly #baseUrl: string;\n\n /**\n * Constructs a new ChompApiService.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n * @param args.baseUrl - The base URL of the CHOMP API.\n * @param args.queryClientConfig - Configuration for the underlying TanStack\n * Query client.\n * @param args.policyOptions - Options to pass to `createServicePolicy`.\n */\n constructor({\n messenger,\n baseUrl,\n queryClientConfig = {},\n policyOptions = {},\n }: {\n messenger: ChompApiServiceMessenger;\n baseUrl: string;\n queryClientConfig?: QueryClientConfig;\n policyOptions?: CreateServicePolicyOptions;\n }) {\n super({\n name: serviceName,\n messenger,\n queryClientConfig,\n policyOptions,\n });\n\n this.#baseUrl = baseUrl;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Builds the standard headers for an authenticated CHOMP API request.\n *\n * @returns Headers including Authorization and Content-Type.\n */\n async #authHeaders(): Promise<Record<string, string>> {\n const token = await this.messenger.call(\n 'AuthenticationController:getBearerToken',\n );\n return {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n };\n }\n\n /**\n * Associates an address with a CHOMP profile.\n *\n * POST /v1/auth/address\n *\n * @param request - The association request containing signature, timestamp,\n * and address.\n * @returns The profile association result. Returns on both 201 and 409.\n */\n async associateAddress(\n request: AssociateAddressRequest,\n ): Promise<AssociateAddressResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:associateAddress`, request],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL('/v1/auth/address', this.#baseUrl),\n {\n method: 'POST',\n headers,\n body: JSON.stringify(request),\n },\n );\n\n if (!response.ok && response.status !== 409) {\n throw new HttpError(\n response.status,\n `POST /v1/auth/address failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, AssociateAddressResponseStruct);\n }\n\n /**\n * Creates an account upgrade request.\n *\n * POST /v1/account-upgrade\n *\n * @param request - The upgrade request containing signature components and\n * chain details.\n * @returns The upgrade result.\n */\n async createUpgrade(request: CreateUpgradeRequest): Promise<UpgradeResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createUpgrade`, request],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL('/v1/account-upgrade', this.#baseUrl),\n {\n method: 'POST',\n headers,\n body: JSON.stringify(request),\n },\n );\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `POST /v1/account-upgrade failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, UpgradeResponseStruct);\n }\n\n /**\n * Fetches the upgrade record for a given address.\n *\n * GET /v1/account-upgrade/:address\n *\n * @param address - The address to look up.\n * @returns The upgrade record, or null if not found.\n */\n async getUpgrade(address: string): Promise<UpgradeResponse | null> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getUpgrade`, address],\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL(`/v1/account-upgrade/${address}`, this.#baseUrl),\n { headers },\n );\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Get upgrade request failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n if (jsonResponse === null) {\n return null;\n }\n\n return create(jsonResponse, UpgradeResponseStruct);\n }\n\n /**\n * Verifies a delegation signature.\n *\n * POST /v1/intent/verify-delegation\n *\n * @param request - The delegation verification request.\n * @returns The verification result including validity and optional errors.\n */\n async verifyDelegation(\n request: VerifyDelegationRequest,\n ): Promise<VerifyDelegationResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:verifyDelegation`, request],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL('/v1/intent/verify-delegation', this.#baseUrl),\n {\n method: 'POST',\n headers,\n body: JSON.stringify(request),\n },\n );\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `POST /v1/intent/verify-delegation failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, VerifyDelegationResponseStruct);\n }\n\n /**\n * Submits one or more intents to the CHOMP API.\n *\n * POST /v1/intent\n *\n * @param intents - The array of intents to submit.\n * @returns The array of intent responses.\n */\n async createIntents(\n intents: SendIntentRequest[],\n ): Promise<SendIntentResponse[]> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createIntents`, intents],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(new URL('/v1/intent', this.#baseUrl), {\n method: 'POST',\n headers,\n body: JSON.stringify(intents),\n });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `POST /v1/intent failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(\n jsonResponse,\n SendIntentResponseArrayStruct,\n ) as SendIntentResponse[];\n }\n\n /**\n * Fetches intents associated with a given address.\n *\n * GET /v1/intent/account/:address\n *\n * @param address - The address to look up intents for.\n * @returns The array of intents for the address.\n */\n async getIntentsByAddress(address: string): Promise<IntentEntry[]> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getIntentsByAddress`, address],\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL(`/v1/intent/account/${address}`, this.#baseUrl),\n { headers },\n );\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Get intents request failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, IntentEntryArrayStruct) as IntentEntry[];\n }\n\n /**\n * Creates a withdrawal for card spend flows.\n *\n * POST /v1/withdrawal\n *\n * @param request - The withdrawal request containing chainId, amount\n * (decimal or hex string), and account address.\n * @returns The withdrawal result.\n */\n async createWithdrawal(\n request: CreateWithdrawalRequest,\n ): Promise<CreateWithdrawalResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createWithdrawal`, request],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(new URL('/v1/withdrawal', this.#baseUrl), {\n method: 'POST',\n headers,\n body: JSON.stringify(request),\n });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `POST /v1/withdrawal failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, CreateWithdrawalResponseStruct);\n }\n\n /**\n * Retrieves service details including delegation redeemer addresses and DeFi\n * contract details for signing delegations for auto-deposit functionality.\n *\n * GET /v1/chomp\n *\n * @param chainIds - Array of chain IDs (0x-prefixed hex strings) to retrieve\n * details for.\n * @returns The service details for the requested chains.\n */\n async getServiceDetails(chainIds: string[]): Promise<ServiceDetailsResponse> {\n for (const chainId of chainIds) {\n if (!isStrictHexString(chainId)) {\n throw new Error(\n `Invalid chainId: expected a 0x-prefixed hex string, got '${chainId}'`,\n );\n }\n }\n\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getServiceDetails`, chainIds],\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const url = new URL('/v1/chomp', this.#baseUrl);\n url.searchParams.set('chainId', chainIds.join(','));\n const response = await fetch(url, { headers });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `GET /v1/chomp failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(\n jsonResponse,\n ServiceDetailsResponseStruct,\n ) as ServiceDetailsResponse;\n }\n}\n"]}
1
+ {"version":3,"file":"chomp-api-service.mjs","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAO9D,OAAO,EAAE,SAAS,EAAE,mCAAmC;AAEvD,OAAO,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,IAAI,EACL,8BAA8B;AAE/B,OAAO,EAAE,eAAe,EAAE,wBAAwB;AAmBlD,kBAAkB;AAElB;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAE7C,oBAAoB;AAEpB;;;GAGG;AACH,MAAM,yBAAyB,GAAG;IAChC,kBAAkB;IAClB,eAAe;IACf,YAAY;IACZ,kBAAkB;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AAM,uBAAA,IAAI,gEAAa,MAAjB,IAAI,CAAe,CAAC;gBAC1C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,EAAE,uBAAA,IAAI,gCAAS,CAAC,CAAC;gBAChD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;gBACpD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;gBAE/C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACjB,MAAM,IAAI,SAAS,CACjB,QAAQ,CAAC,MAAM,EACf,qCAAqC,QAAQ,CAAC,MAAM,GAAG,CACxD,CAAC;gBACJ,CAAC;gBAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;YACzB,CAAC;SACF,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC,YAAY,EAAE,4BAA4B,CAAC,CAAC;IAC5D,CAAC;CACF;;AArTC;;;;GAIG;AACH,KAAK;IACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CACrC,yCAAyC,CAC1C,CAAC;IACF,OAAO;QACL,aAAa,EAAE,UAAU,KAAK,EAAE;QAChC,cAAc,EAAE,kBAAkB;KACnC,CAAC;AACJ,CAAC","sourcesContent":["import { BaseDataService } from '@metamask/base-data-service';\nimport type {\n DataServiceCacheUpdatedEvent,\n DataServiceGranularCacheUpdatedEvent,\n DataServiceInvalidateQueriesAction,\n} from '@metamask/base-data-service';\nimport type { CreateServicePolicyOptions } from '@metamask/controller-utils';\nimport { HttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport {\n array,\n boolean,\n create,\n enums,\n literal,\n number,\n optional,\n record,\n string,\n type,\n} from '@metamask/superstruct';\nimport type { Hex } from '@metamask/utils';\nimport { StrictHexStruct } from '@metamask/utils';\nimport type { QueryClientConfig } from '@tanstack/query-core';\n\nimport type { ChompApiServiceMethodActions } from './chomp-api-service-method-action-types';\nimport type {\n AssociateAddressParams,\n AssociateAddressResponse,\n CreateUpgradeParams,\n UpgradeResponse,\n CreateWithdrawalParams,\n CreateWithdrawalResponse,\n IntentEntry,\n SendIntentParams,\n SendIntentResponse,\n ServiceDetailsResponse,\n VerifyDelegationParams,\n VerifyDelegationResponse,\n} from './types';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link ChompApiService}, used to namespace the service's\n * actions and events.\n */\nexport const serviceName = 'ChompApiService';\n\n// === MESSENGER ===\n\n/**\n * All of the methods within {@link ChompApiService} that are exposed via the\n * messenger.\n */\nconst MESSENGER_EXPOSED_METHODS = [\n 'associateAddress',\n 'createUpgrade',\n 'getUpgrade',\n 'verifyDelegation',\n 'createIntents',\n 'getIntentsByAddress',\n 'createWithdrawal',\n 'getServiceDetails',\n] as const;\n\n/**\n * Invalidates cached queries for {@link ChompApiService}.\n */\nexport type ChompApiServiceInvalidateQueriesAction =\n DataServiceInvalidateQueriesAction<typeof serviceName>;\n\n/**\n * Actions that {@link ChompApiService} exposes to other consumers.\n */\nexport type ChompApiServiceActions =\n | ChompApiServiceMethodActions\n | ChompApiServiceInvalidateQueriesAction;\n\n/**\n * Actions from other messengers that {@link ChompApiService} calls.\n */\ntype AllowedActions = {\n type: 'AuthenticationController:getBearerToken';\n handler: (entropySourceId?: string) => Promise<string>;\n};\n\n/**\n * Published when {@link ChompApiService}'s cache is updated.\n */\nexport type ChompApiServiceCacheUpdatedEvent = DataServiceCacheUpdatedEvent<\n typeof serviceName\n>;\n\n/**\n * Published when a key within {@link ChompApiService}'s cache is updated.\n */\nexport type ChompApiServiceGranularCacheUpdatedEvent =\n DataServiceGranularCacheUpdatedEvent<typeof serviceName>;\n\n/**\n * Events that {@link ChompApiService} exposes to other consumers.\n */\nexport type ChompApiServiceEvents =\n | ChompApiServiceCacheUpdatedEvent\n | ChompApiServiceGranularCacheUpdatedEvent;\n\n/**\n * Events from other messengers that {@link ChompApiService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link ChompApiService}.\n */\nexport type ChompApiServiceMessenger = Messenger<\n typeof serviceName,\n ChompApiServiceActions | AllowedActions,\n ChompApiServiceEvents | AllowedEvents\n>;\n\n// === RESPONSE VALIDATION ===\n\nconst AssociateAddressResponseStruct = type({\n profileId: string(),\n address: StrictHexStruct,\n status: string(),\n});\n\nconst UpgradeResponseStruct = type({\n signerAddress: StrictHexStruct,\n status: string(),\n createdAt: string(),\n});\n\nconst VerifyDelegationResponseStruct = type({\n valid: boolean(),\n delegationHash: optional(StrictHexStruct),\n errors: optional(array(string())),\n});\n\nconst SendIntentResponseArrayStruct = array(\n type({\n delegationHash: StrictHexStruct,\n metadata: type({\n allowance: StrictHexStruct,\n tokenSymbol: string(),\n tokenAddress: StrictHexStruct,\n type: enums(['cash-deposit', 'cash-withdrawal']),\n }),\n createdAt: string(),\n }),\n);\n\nconst IntentEntryArrayStruct = array(\n type({\n account: StrictHexStruct,\n delegationHash: StrictHexStruct,\n chainId: StrictHexStruct,\n status: enums(['active', 'revoked']),\n metadata: type({\n allowance: StrictHexStruct,\n tokenAddress: StrictHexStruct,\n tokenSymbol: string(),\n type: enums(['deposit', 'withdraw']),\n }),\n }),\n);\n\nconst CreateWithdrawalResponseStruct = type({\n success: literal(true),\n});\n\nconst ServiceDetailsProtocolStruct = type({\n supportedTokens: array(\n type({\n tokenAddress: StrictHexStruct,\n tokenDecimals: number(),\n }),\n ),\n adapterAddress: StrictHexStruct,\n intentTypes: array(enums(['cash-deposit', 'cash-withdrawal'])),\n});\n\nconst ServiceDetailsResponseStruct = type({\n auth: type({\n message: string(),\n }),\n chains: record(\n StrictHexStruct,\n type({\n autoDepositDelegate: StrictHexStruct,\n protocol: record(string(), ServiceDetailsProtocolStruct),\n }),\n ),\n});\n\n// === SERVICE DEFINITION ===\n\n/**\n * This service is responsible for communicating with the CHOMP API.\n *\n * All requests are authenticated via JWT Bearer tokens obtained from the\n * `AuthenticationController:getBearerToken` messenger action.\n */\nexport class ChompApiService extends BaseDataService<\n typeof serviceName,\n ChompApiServiceMessenger\n> {\n readonly #baseUrl: string;\n\n /**\n * Constructs a new ChompApiService.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n * @param args.baseUrl - The base URL of the CHOMP API.\n * @param args.queryClientConfig - Configuration for the underlying TanStack\n * Query client.\n * @param args.policyOptions - Options to pass to `createServicePolicy`.\n */\n constructor({\n messenger,\n baseUrl,\n queryClientConfig = {},\n policyOptions = {},\n }: {\n messenger: ChompApiServiceMessenger;\n baseUrl: string;\n queryClientConfig?: QueryClientConfig;\n policyOptions?: CreateServicePolicyOptions;\n }) {\n super({\n name: serviceName,\n messenger,\n queryClientConfig,\n policyOptions,\n });\n\n this.#baseUrl = baseUrl;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Builds the standard headers for an authenticated CHOMP API request.\n *\n * @returns Headers including Authorization and Content-Type.\n */\n async #authHeaders(): Promise<Record<string, string>> {\n const token = await this.messenger.call(\n 'AuthenticationController:getBearerToken',\n );\n return {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n };\n }\n\n /**\n * Associates an address with a CHOMP profile.\n *\n * POST /v1/auth/address\n *\n * @param params - The association params containing signature, timestamp,\n * and address.\n * @returns The profile association result. Returns on both 201 and 409.\n */\n async associateAddress(\n params: AssociateAddressParams,\n ): Promise<AssociateAddressResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:associateAddress`, params],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL('/v1/auth/address', this.#baseUrl),\n {\n method: 'POST',\n headers,\n body: JSON.stringify(params),\n },\n );\n\n if (!response.ok && response.status !== 409) {\n throw new HttpError(\n response.status,\n `POST /v1/auth/address failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, AssociateAddressResponseStruct);\n }\n\n /**\n * Creates an account upgrade request.\n *\n * POST /v1/account-upgrade\n *\n * @param params - The upgrade params containing signature components and\n * chain details.\n * @returns The upgrade result.\n */\n async createUpgrade(params: CreateUpgradeParams): Promise<UpgradeResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createUpgrade`, params],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL('/v1/account-upgrade', this.#baseUrl),\n {\n method: 'POST',\n headers,\n body: JSON.stringify(params),\n },\n );\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `POST /v1/account-upgrade failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, UpgradeResponseStruct);\n }\n\n /**\n * Fetches the upgrade record for a given address.\n *\n * GET /v1/account-upgrade/:address\n *\n * @param address - The address to look up.\n * @returns The upgrade record, or null if not found.\n */\n async getUpgrade(address: Hex): Promise<UpgradeResponse | null> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getUpgrade`, address],\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL(`/v1/account-upgrade/${address}`, this.#baseUrl),\n { headers },\n );\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Get upgrade request failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n if (jsonResponse === null) {\n return null;\n }\n\n return create(jsonResponse, UpgradeResponseStruct);\n }\n\n /**\n * Verifies a delegation signature.\n *\n * POST /v1/intent/verify-delegation\n *\n * @param params - The delegation verification params.\n * @returns The verification result including validity and optional errors.\n */\n async verifyDelegation(\n params: VerifyDelegationParams,\n ): Promise<VerifyDelegationResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:verifyDelegation`, params],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL('/v1/intent/verify-delegation', this.#baseUrl),\n {\n method: 'POST',\n headers,\n body: JSON.stringify(params),\n },\n );\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `POST /v1/intent/verify-delegation failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, VerifyDelegationResponseStruct);\n }\n\n /**\n * Submits one or more intents to the CHOMP API.\n *\n * POST /v1/intent\n *\n * @param intents - The array of intents to submit.\n * @returns The array of intent responses.\n */\n async createIntents(\n intents: SendIntentParams[],\n ): Promise<SendIntentResponse[]> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createIntents`, intents],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(new URL('/v1/intent', this.#baseUrl), {\n method: 'POST',\n headers,\n body: JSON.stringify(intents),\n });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `POST /v1/intent failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, SendIntentResponseArrayStruct);\n }\n\n /**\n * Fetches intents associated with a given address.\n *\n * GET /v1/intent/account/:address\n *\n * @param address - The address to look up intents for.\n * @returns The array of intents for the address.\n */\n async getIntentsByAddress(address: Hex): Promise<IntentEntry[]> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getIntentsByAddress`, address],\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL(`/v1/intent/account/${address}`, this.#baseUrl),\n { headers },\n );\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Get intents request failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, IntentEntryArrayStruct);\n }\n\n /**\n * Creates a withdrawal for card spend flows.\n *\n * POST /v1/withdrawal\n *\n * @param params - The withdrawal params containing chainId, amount\n * (decimal or hex string), and account address.\n * @returns The withdrawal result.\n */\n async createWithdrawal(\n params: CreateWithdrawalParams,\n ): Promise<CreateWithdrawalResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createWithdrawal`, params],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(new URL('/v1/withdrawal', this.#baseUrl), {\n method: 'POST',\n headers,\n body: JSON.stringify(params),\n });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `POST /v1/withdrawal failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, CreateWithdrawalResponseStruct);\n }\n\n /**\n * Retrieves service details including delegation redeemer addresses and DeFi\n * contract details for signing delegations for auto-deposit functionality.\n *\n * GET /v1/chomp\n *\n * @param chainIds - Array of chain IDs (0x-prefixed hex strings) to retrieve\n * details for.\n * @returns The service details for the requested chains.\n */\n async getServiceDetails(chainIds: Hex[]): Promise<ServiceDetailsResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getServiceDetails`, chainIds],\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const url = new URL('/v1/chomp', this.#baseUrl);\n url.searchParams.set('chainId', chainIds.join(','));\n const response = await fetch(url, { headers });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `GET /v1/chomp failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, ServiceDetailsResponseStruct);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAAsD;AAA7C,oHAAA,eAAe,OAAA","sourcesContent":["export { ChompApiService } from './chomp-api-service';\nexport type {\n ChompApiServiceMessenger,\n ChompApiServiceActions,\n ChompApiServiceEvents,\n ChompApiServiceInvalidateQueriesAction,\n ChompApiServiceCacheUpdatedEvent,\n ChompApiServiceGranularCacheUpdatedEvent,\n} from './chomp-api-service';\nexport type {\n ChompApiServiceAssociateAddressAction,\n ChompApiServiceCreateUpgradeAction,\n ChompApiServiceGetUpgradeAction,\n ChompApiServiceVerifyDelegationAction,\n ChompApiServiceCreateIntentsAction,\n ChompApiServiceGetIntentsByAddressAction,\n ChompApiServiceCreateWithdrawalAction,\n ChompApiServiceGetServiceDetailsAction,\n} from './chomp-api-service-method-action-types';\nexport type {\n AssociateAddressRequest,\n AssociateAddressResponse,\n CreateUpgradeRequest,\n CreateWithdrawalRequest,\n CreateWithdrawalResponse,\n DelegationCaveat,\n UpgradeResponse,\n IntentEntry,\n IntentMetadataRequest,\n IntentMetadataResponse,\n SendIntentRequest,\n SendIntentResponse,\n ServiceDetailsChain,\n ServiceDetailsProtocol,\n ServiceDetailsResponse,\n ServiceDetailsSupportedToken,\n SignedDelegation,\n VerifyDelegationRequest,\n VerifyDelegationResponse,\n} from './types';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAAsD;AAA7C,oHAAA,eAAe,OAAA","sourcesContent":["export { ChompApiService } from './chomp-api-service';\nexport type {\n ChompApiServiceMessenger,\n ChompApiServiceActions,\n ChompApiServiceEvents,\n ChompApiServiceInvalidateQueriesAction,\n ChompApiServiceCacheUpdatedEvent,\n ChompApiServiceGranularCacheUpdatedEvent,\n} from './chomp-api-service';\nexport type {\n ChompApiServiceAssociateAddressAction,\n ChompApiServiceCreateUpgradeAction,\n ChompApiServiceGetUpgradeAction,\n ChompApiServiceVerifyDelegationAction,\n ChompApiServiceCreateIntentsAction,\n ChompApiServiceGetIntentsByAddressAction,\n ChompApiServiceCreateWithdrawalAction,\n ChompApiServiceGetServiceDetailsAction,\n} from './chomp-api-service-method-action-types';\nexport type {\n AssociateAddressParams,\n AssociateAddressResponse,\n CreateUpgradeParams,\n CreateWithdrawalParams,\n CreateWithdrawalResponse,\n DelegationCaveat,\n UpgradeResponse,\n IntentEntry,\n IntentMetadataParams,\n IntentMetadataResponse,\n SendIntentParams,\n SendIntentResponse,\n ServiceDetailsChain,\n ServiceDetailsProtocol,\n ServiceDetailsResponse,\n ServiceDetailsSupportedToken,\n SignedDelegation,\n VerifyDelegationParams,\n VerifyDelegationResponse,\n} from './types';\n"]}
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { ChompApiService } from "./chomp-api-service.cjs";
2
2
  export type { ChompApiServiceMessenger, ChompApiServiceActions, ChompApiServiceEvents, ChompApiServiceInvalidateQueriesAction, ChompApiServiceCacheUpdatedEvent, ChompApiServiceGranularCacheUpdatedEvent, } from "./chomp-api-service.cjs";
3
3
  export type { ChompApiServiceAssociateAddressAction, ChompApiServiceCreateUpgradeAction, ChompApiServiceGetUpgradeAction, ChompApiServiceVerifyDelegationAction, ChompApiServiceCreateIntentsAction, ChompApiServiceGetIntentsByAddressAction, ChompApiServiceCreateWithdrawalAction, ChompApiServiceGetServiceDetailsAction, } from "./chomp-api-service-method-action-types.cjs";
4
- export type { AssociateAddressRequest, AssociateAddressResponse, CreateUpgradeRequest, CreateWithdrawalRequest, CreateWithdrawalResponse, DelegationCaveat, UpgradeResponse, IntentEntry, IntentMetadataRequest, IntentMetadataResponse, SendIntentRequest, SendIntentResponse, ServiceDetailsChain, ServiceDetailsProtocol, ServiceDetailsResponse, ServiceDetailsSupportedToken, SignedDelegation, VerifyDelegationRequest, VerifyDelegationResponse, } from "./types.cjs";
4
+ export type { AssociateAddressParams, AssociateAddressResponse, CreateUpgradeParams, CreateWithdrawalParams, CreateWithdrawalResponse, DelegationCaveat, UpgradeResponse, IntentEntry, IntentMetadataParams, IntentMetadataResponse, SendIntentParams, SendIntentResponse, ServiceDetailsChain, ServiceDetailsProtocol, ServiceDetailsResponse, ServiceDetailsSupportedToken, SignedDelegation, VerifyDelegationParams, VerifyDelegationResponse, } from "./types.cjs";
5
5
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gCAA4B;AACtD,YAAY,EACV,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,sCAAsC,EACtC,gCAAgC,EAChC,wCAAwC,GACzC,gCAA4B;AAC7B,YAAY,EACV,qCAAqC,EACrC,kCAAkC,EAClC,+BAA+B,EAC/B,qCAAqC,EACrC,kCAAkC,EAClC,wCAAwC,EACxC,qCAAqC,EACrC,sCAAsC,GACvC,oDAAgD;AACjD,YAAY,EACV,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,GACzB,oBAAgB"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gCAA4B;AACtD,YAAY,EACV,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,sCAAsC,EACtC,gCAAgC,EAChC,wCAAwC,GACzC,gCAA4B;AAC7B,YAAY,EACV,qCAAqC,EACrC,kCAAkC,EAClC,+BAA+B,EAC/B,qCAAqC,EACrC,kCAAkC,EAClC,wCAAwC,EACxC,qCAAqC,EACrC,sCAAsC,GACvC,oDAAgD;AACjD,YAAY,EACV,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,GACzB,oBAAgB"}
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { ChompApiService } from "./chomp-api-service.mjs";
2
2
  export type { ChompApiServiceMessenger, ChompApiServiceActions, ChompApiServiceEvents, ChompApiServiceInvalidateQueriesAction, ChompApiServiceCacheUpdatedEvent, ChompApiServiceGranularCacheUpdatedEvent, } from "./chomp-api-service.mjs";
3
3
  export type { ChompApiServiceAssociateAddressAction, ChompApiServiceCreateUpgradeAction, ChompApiServiceGetUpgradeAction, ChompApiServiceVerifyDelegationAction, ChompApiServiceCreateIntentsAction, ChompApiServiceGetIntentsByAddressAction, ChompApiServiceCreateWithdrawalAction, ChompApiServiceGetServiceDetailsAction, } from "./chomp-api-service-method-action-types.mjs";
4
- export type { AssociateAddressRequest, AssociateAddressResponse, CreateUpgradeRequest, CreateWithdrawalRequest, CreateWithdrawalResponse, DelegationCaveat, UpgradeResponse, IntentEntry, IntentMetadataRequest, IntentMetadataResponse, SendIntentRequest, SendIntentResponse, ServiceDetailsChain, ServiceDetailsProtocol, ServiceDetailsResponse, ServiceDetailsSupportedToken, SignedDelegation, VerifyDelegationRequest, VerifyDelegationResponse, } from "./types.mjs";
4
+ export type { AssociateAddressParams, AssociateAddressResponse, CreateUpgradeParams, CreateWithdrawalParams, CreateWithdrawalResponse, DelegationCaveat, UpgradeResponse, IntentEntry, IntentMetadataParams, IntentMetadataResponse, SendIntentParams, SendIntentResponse, ServiceDetailsChain, ServiceDetailsProtocol, ServiceDetailsResponse, ServiceDetailsSupportedToken, SignedDelegation, VerifyDelegationParams, VerifyDelegationResponse, } from "./types.mjs";
5
5
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gCAA4B;AACtD,YAAY,EACV,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,sCAAsC,EACtC,gCAAgC,EAChC,wCAAwC,GACzC,gCAA4B;AAC7B,YAAY,EACV,qCAAqC,EACrC,kCAAkC,EAClC,+BAA+B,EAC/B,qCAAqC,EACrC,kCAAkC,EAClC,wCAAwC,EACxC,qCAAqC,EACrC,sCAAsC,GACvC,oDAAgD;AACjD,YAAY,EACV,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,GACzB,oBAAgB"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gCAA4B;AACtD,YAAY,EACV,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,sCAAsC,EACtC,gCAAgC,EAChC,wCAAwC,GACzC,gCAA4B;AAC7B,YAAY,EACV,qCAAqC,EACrC,kCAAkC,EAClC,+BAA+B,EAC/B,qCAAqC,EACrC,kCAAkC,EAClC,wCAAwC,EACxC,qCAAqC,EACrC,sCAAsC,GACvC,oDAAgD;AACjD,YAAY,EACV,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,GACzB,oBAAgB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gCAA4B","sourcesContent":["export { ChompApiService } from './chomp-api-service';\nexport type {\n ChompApiServiceMessenger,\n ChompApiServiceActions,\n ChompApiServiceEvents,\n ChompApiServiceInvalidateQueriesAction,\n ChompApiServiceCacheUpdatedEvent,\n ChompApiServiceGranularCacheUpdatedEvent,\n} from './chomp-api-service';\nexport type {\n ChompApiServiceAssociateAddressAction,\n ChompApiServiceCreateUpgradeAction,\n ChompApiServiceGetUpgradeAction,\n ChompApiServiceVerifyDelegationAction,\n ChompApiServiceCreateIntentsAction,\n ChompApiServiceGetIntentsByAddressAction,\n ChompApiServiceCreateWithdrawalAction,\n ChompApiServiceGetServiceDetailsAction,\n} from './chomp-api-service-method-action-types';\nexport type {\n AssociateAddressRequest,\n AssociateAddressResponse,\n CreateUpgradeRequest,\n CreateWithdrawalRequest,\n CreateWithdrawalResponse,\n DelegationCaveat,\n UpgradeResponse,\n IntentEntry,\n IntentMetadataRequest,\n IntentMetadataResponse,\n SendIntentRequest,\n SendIntentResponse,\n ServiceDetailsChain,\n ServiceDetailsProtocol,\n ServiceDetailsResponse,\n ServiceDetailsSupportedToken,\n SignedDelegation,\n VerifyDelegationRequest,\n VerifyDelegationResponse,\n} from './types';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gCAA4B","sourcesContent":["export { ChompApiService } from './chomp-api-service';\nexport type {\n ChompApiServiceMessenger,\n ChompApiServiceActions,\n ChompApiServiceEvents,\n ChompApiServiceInvalidateQueriesAction,\n ChompApiServiceCacheUpdatedEvent,\n ChompApiServiceGranularCacheUpdatedEvent,\n} from './chomp-api-service';\nexport type {\n ChompApiServiceAssociateAddressAction,\n ChompApiServiceCreateUpgradeAction,\n ChompApiServiceGetUpgradeAction,\n ChompApiServiceVerifyDelegationAction,\n ChompApiServiceCreateIntentsAction,\n ChompApiServiceGetIntentsByAddressAction,\n ChompApiServiceCreateWithdrawalAction,\n ChompApiServiceGetServiceDetailsAction,\n} from './chomp-api-service-method-action-types';\nexport type {\n AssociateAddressParams,\n AssociateAddressResponse,\n CreateUpgradeParams,\n CreateWithdrawalParams,\n CreateWithdrawalResponse,\n DelegationCaveat,\n UpgradeResponse,\n IntentEntry,\n IntentMetadataParams,\n IntentMetadataResponse,\n SendIntentParams,\n SendIntentResponse,\n ServiceDetailsChain,\n ServiceDetailsProtocol,\n ServiceDetailsResponse,\n ServiceDetailsSupportedToken,\n SignedDelegation,\n VerifyDelegationParams,\n VerifyDelegationResponse,\n} from './types';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n// === COMMON TYPES ===\n\nexport type DelegationCaveat = {\n enforcer: Hex;\n terms: Hex;\n args: Hex;\n};\n\nexport type SignedDelegation = {\n delegate: Hex;\n delegator: Hex;\n authority: Hex;\n caveats: DelegationCaveat[];\n salt: Hex;\n signature: Hex;\n};\n\n// === REQUEST TYPES ===\n\nexport type AssociateAddressRequest = {\n signature: string;\n timestamp: string;\n address: string;\n};\n\nexport type CreateUpgradeRequest = {\n r: string;\n s: string;\n v: number;\n yParity: number;\n address: string;\n chainId: string;\n nonce: string;\n};\n\nexport type VerifyDelegationRequest = {\n signedDelegation: SignedDelegation;\n chainId: Hex;\n};\n\nexport type IntentMetadataRequest = {\n allowance: Hex;\n tokenSymbol: string;\n tokenAddress: Hex;\n type: 'cash-deposit' | 'cash-withdrawal';\n};\n\nexport type SendIntentRequest = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n metadata: IntentMetadataRequest;\n};\n\nexport type CreateWithdrawalRequest = {\n chainId: Hex;\n /** Decimal integer or 0x-prefixed hex string representing the amount. */\n amount: string;\n account: Hex;\n};\n\n// === RESPONSE TYPES ===\n\nexport type AssociateAddressResponse = {\n profileId: string;\n address: string;\n status: string;\n};\n\nexport type UpgradeResponse = {\n signerAddress: string;\n status: string;\n createdAt: string;\n};\n\nexport type VerifyDelegationResponse = {\n valid: boolean;\n delegationHash?: string;\n errors?: string[];\n};\n\nexport type IntentMetadataResponse = {\n allowance: Hex;\n tokenSymbol: string;\n tokenAddress: Hex;\n type: 'cash-deposit' | 'cash-withdrawal';\n};\n\nexport type SendIntentResponse = {\n delegationHash: string;\n metadata: IntentMetadataResponse;\n createdAt: string;\n};\n\n/**\n * The shape returned by GET /v1/intent/account/:address for each intent.\n *\n * Note: the metadata `type` uses 'deposit' | 'withdraw' here, whereas the\n * create-intent endpoint uses 'cash-deposit' | 'cash-withdrawal'.\n */\nexport type IntentEntry = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n status: 'active' | 'revoked';\n metadata: {\n allowance: Hex;\n tokenAddress: Hex;\n tokenSymbol: string;\n type: 'deposit' | 'withdraw';\n };\n};\n\nexport type CreateWithdrawalResponse = {\n success: true;\n};\n\n// === SERVICE DETAILS TYPES ===\n\nexport type ServiceDetailsSupportedToken = {\n tokenAddress: string;\n tokenDecimals: number;\n};\n\nexport type ServiceDetailsProtocol = {\n supportedTokens: ServiceDetailsSupportedToken[];\n adapterAddress: string;\n intentTypes: ('cash-deposit' | 'cash-withdrawal')[];\n};\n\nexport type ServiceDetailsChain = {\n autoDepositDelegate: string;\n protocol: Record<string, ServiceDetailsProtocol>;\n};\n\nexport type ServiceDetailsResponse = {\n auth: {\n message: string;\n };\n chains: Record<string, ServiceDetailsChain>;\n};\n"]}
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n// === COMMON TYPES ===\n\nexport type DelegationCaveat = {\n enforcer: Hex;\n terms: Hex;\n args: Hex;\n};\n\nexport type SignedDelegation = {\n delegate: Hex;\n delegator: Hex;\n authority: Hex;\n caveats: DelegationCaveat[];\n salt: Hex;\n signature: Hex;\n};\n\n// === PARAMS TYPES ===\n\nexport type AssociateAddressParams = {\n signature: Hex;\n timestamp: string;\n address: Hex;\n};\n\nexport type CreateUpgradeParams = {\n r: Hex;\n s: Hex;\n v: number;\n yParity: number;\n address: Hex;\n chainId: string;\n nonce: string;\n};\n\nexport type VerifyDelegationParams = {\n signedDelegation: SignedDelegation;\n chainId: Hex;\n};\n\nexport type IntentMetadataParams = {\n allowance: Hex;\n tokenSymbol: string;\n tokenAddress: Hex;\n type: 'cash-deposit' | 'cash-withdrawal';\n};\n\nexport type SendIntentParams = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n metadata: IntentMetadataParams;\n};\n\nexport type CreateWithdrawalParams = {\n chainId: Hex;\n /** Decimal integer or 0x-prefixed hex string representing the amount. */\n amount: string;\n account: Hex;\n};\n\n// === RESPONSE TYPES ===\n\nexport type AssociateAddressResponse = {\n profileId: string;\n address: Hex;\n status: string;\n};\n\nexport type UpgradeResponse = {\n signerAddress: Hex;\n status: string;\n createdAt: string;\n};\n\nexport type VerifyDelegationResponse = {\n valid: boolean;\n delegationHash?: Hex;\n errors?: string[];\n};\n\nexport type IntentMetadataResponse = {\n allowance: Hex;\n tokenSymbol: string;\n tokenAddress: Hex;\n type: 'cash-deposit' | 'cash-withdrawal';\n};\n\nexport type SendIntentResponse = {\n delegationHash: Hex;\n metadata: IntentMetadataResponse;\n createdAt: string;\n};\n\n/**\n * The shape returned by GET /v1/intent/account/:address for each intent.\n *\n * Note: the metadata `type` uses 'deposit' | 'withdraw' here, whereas the\n * create-intent endpoint uses 'cash-deposit' | 'cash-withdrawal'.\n */\nexport type IntentEntry = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n status: 'active' | 'revoked';\n metadata: {\n allowance: Hex;\n tokenAddress: Hex;\n tokenSymbol: string;\n type: 'deposit' | 'withdraw';\n };\n};\n\nexport type CreateWithdrawalResponse = {\n success: true;\n};\n\n// === SERVICE DETAILS TYPES ===\n\nexport type ServiceDetailsSupportedToken = {\n tokenAddress: Hex;\n tokenDecimals: number;\n};\n\nexport type ServiceDetailsProtocol = {\n supportedTokens: ServiceDetailsSupportedToken[];\n adapterAddress: Hex;\n intentTypes: ('cash-deposit' | 'cash-withdrawal')[];\n};\n\nexport type ServiceDetailsChain = {\n autoDepositDelegate: Hex;\n protocol: Record<string, ServiceDetailsProtocol>;\n};\n\nexport type ServiceDetailsResponse = {\n auth: {\n message: string;\n };\n chains: Record<Hex, ServiceDetailsChain>;\n};\n"]}
package/dist/types.d.cts CHANGED
@@ -12,37 +12,37 @@ export type SignedDelegation = {
12
12
  salt: Hex;
13
13
  signature: Hex;
14
14
  };
15
- export type AssociateAddressRequest = {
16
- signature: string;
15
+ export type AssociateAddressParams = {
16
+ signature: Hex;
17
17
  timestamp: string;
18
- address: string;
18
+ address: Hex;
19
19
  };
20
- export type CreateUpgradeRequest = {
21
- r: string;
22
- s: string;
20
+ export type CreateUpgradeParams = {
21
+ r: Hex;
22
+ s: Hex;
23
23
  v: number;
24
24
  yParity: number;
25
- address: string;
25
+ address: Hex;
26
26
  chainId: string;
27
27
  nonce: string;
28
28
  };
29
- export type VerifyDelegationRequest = {
29
+ export type VerifyDelegationParams = {
30
30
  signedDelegation: SignedDelegation;
31
31
  chainId: Hex;
32
32
  };
33
- export type IntentMetadataRequest = {
33
+ export type IntentMetadataParams = {
34
34
  allowance: Hex;
35
35
  tokenSymbol: string;
36
36
  tokenAddress: Hex;
37
37
  type: 'cash-deposit' | 'cash-withdrawal';
38
38
  };
39
- export type SendIntentRequest = {
39
+ export type SendIntentParams = {
40
40
  account: Hex;
41
41
  delegationHash: Hex;
42
42
  chainId: Hex;
43
- metadata: IntentMetadataRequest;
43
+ metadata: IntentMetadataParams;
44
44
  };
45
- export type CreateWithdrawalRequest = {
45
+ export type CreateWithdrawalParams = {
46
46
  chainId: Hex;
47
47
  /** Decimal integer or 0x-prefixed hex string representing the amount. */
48
48
  amount: string;
@@ -50,17 +50,17 @@ export type CreateWithdrawalRequest = {
50
50
  };
51
51
  export type AssociateAddressResponse = {
52
52
  profileId: string;
53
- address: string;
53
+ address: Hex;
54
54
  status: string;
55
55
  };
56
56
  export type UpgradeResponse = {
57
- signerAddress: string;
57
+ signerAddress: Hex;
58
58
  status: string;
59
59
  createdAt: string;
60
60
  };
61
61
  export type VerifyDelegationResponse = {
62
62
  valid: boolean;
63
- delegationHash?: string;
63
+ delegationHash?: Hex;
64
64
  errors?: string[];
65
65
  };
66
66
  export type IntentMetadataResponse = {
@@ -70,7 +70,7 @@ export type IntentMetadataResponse = {
70
70
  type: 'cash-deposit' | 'cash-withdrawal';
71
71
  };
72
72
  export type SendIntentResponse = {
73
- delegationHash: string;
73
+ delegationHash: Hex;
74
74
  metadata: IntentMetadataResponse;
75
75
  createdAt: string;
76
76
  };
@@ -96,22 +96,22 @@ export type CreateWithdrawalResponse = {
96
96
  success: true;
97
97
  };
98
98
  export type ServiceDetailsSupportedToken = {
99
- tokenAddress: string;
99
+ tokenAddress: Hex;
100
100
  tokenDecimals: number;
101
101
  };
102
102
  export type ServiceDetailsProtocol = {
103
103
  supportedTokens: ServiceDetailsSupportedToken[];
104
- adapterAddress: string;
104
+ adapterAddress: Hex;
105
105
  intentTypes: ('cash-deposit' | 'cash-withdrawal')[];
106
106
  };
107
107
  export type ServiceDetailsChain = {
108
- autoDepositDelegate: string;
108
+ autoDepositDelegate: Hex;
109
109
  protocol: Record<string, ServiceDetailsProtocol>;
110
110
  };
111
111
  export type ServiceDetailsResponse = {
112
112
  auth: {
113
113
  message: string;
114
114
  };
115
- chains: Record<string, ServiceDetailsChain>;
115
+ chains: Record<Hex, ServiceDetailsChain>;
116
116
  };
117
117
  //# sourceMappingURL=types.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAI3C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,GAAG,CAAC;IACd,KAAK,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,gBAAgB,G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types.d.mts CHANGED
@@ -12,37 +12,37 @@ export type SignedDelegation = {
12
12
  salt: Hex;
13
13
  signature: Hex;
14
14
  };
15
- export type AssociateAddressRequest = {
16
- signature: string;
15
+ export type AssociateAddressParams = {
16
+ signature: Hex;
17
17
  timestamp: string;
18
- address: string;
18
+ address: Hex;
19
19
  };
20
- export type CreateUpgradeRequest = {
21
- r: string;
22
- s: string;
20
+ export type CreateUpgradeParams = {
21
+ r: Hex;
22
+ s: Hex;
23
23
  v: number;
24
24
  yParity: number;
25
- address: string;
25
+ address: Hex;
26
26
  chainId: string;
27
27
  nonce: string;
28
28
  };
29
- export type VerifyDelegationRequest = {
29
+ export type VerifyDelegationParams = {
30
30
  signedDelegation: SignedDelegation;
31
31
  chainId: Hex;
32
32
  };
33
- export type IntentMetadataRequest = {
33
+ export type IntentMetadataParams = {
34
34
  allowance: Hex;
35
35
  tokenSymbol: string;
36
36
  tokenAddress: Hex;
37
37
  type: 'cash-deposit' | 'cash-withdrawal';
38
38
  };
39
- export type SendIntentRequest = {
39
+ export type SendIntentParams = {
40
40
  account: Hex;
41
41
  delegationHash: Hex;
42
42
  chainId: Hex;
43
- metadata: IntentMetadataRequest;
43
+ metadata: IntentMetadataParams;
44
44
  };
45
- export type CreateWithdrawalRequest = {
45
+ export type CreateWithdrawalParams = {
46
46
  chainId: Hex;
47
47
  /** Decimal integer or 0x-prefixed hex string representing the amount. */
48
48
  amount: string;
@@ -50,17 +50,17 @@ export type CreateWithdrawalRequest = {
50
50
  };
51
51
  export type AssociateAddressResponse = {
52
52
  profileId: string;
53
- address: string;
53
+ address: Hex;
54
54
  status: string;
55
55
  };
56
56
  export type UpgradeResponse = {
57
- signerAddress: string;
57
+ signerAddress: Hex;
58
58
  status: string;
59
59
  createdAt: string;
60
60
  };
61
61
  export type VerifyDelegationResponse = {
62
62
  valid: boolean;
63
- delegationHash?: string;
63
+ delegationHash?: Hex;
64
64
  errors?: string[];
65
65
  };
66
66
  export type IntentMetadataResponse = {
@@ -70,7 +70,7 @@ export type IntentMetadataResponse = {
70
70
  type: 'cash-deposit' | 'cash-withdrawal';
71
71
  };
72
72
  export type SendIntentResponse = {
73
- delegationHash: string;
73
+ delegationHash: Hex;
74
74
  metadata: IntentMetadataResponse;
75
75
  createdAt: string;
76
76
  };
@@ -96,22 +96,22 @@ export type CreateWithdrawalResponse = {
96
96
  success: true;
97
97
  };
98
98
  export type ServiceDetailsSupportedToken = {
99
- tokenAddress: string;
99
+ tokenAddress: Hex;
100
100
  tokenDecimals: number;
101
101
  };
102
102
  export type ServiceDetailsProtocol = {
103
103
  supportedTokens: ServiceDetailsSupportedToken[];
104
- adapterAddress: string;
104
+ adapterAddress: Hex;
105
105
  intentTypes: ('cash-deposit' | 'cash-withdrawal')[];
106
106
  };
107
107
  export type ServiceDetailsChain = {
108
- autoDepositDelegate: string;
108
+ autoDepositDelegate: Hex;
109
109
  protocol: Record<string, ServiceDetailsProtocol>;
110
110
  };
111
111
  export type ServiceDetailsResponse = {
112
112
  auth: {
113
113
  message: string;
114
114
  };
115
- chains: Record<string, ServiceDetailsChain>;
115
+ chains: Record<Hex, ServiceDetailsChain>;
116
116
  };
117
117
  //# sourceMappingURL=types.d.mts.map