@metamask-previews/chomp-api-service 4.0.1-preview-3866c0ff1 → 4.0.1-preview-e3275932a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +0 -1
  2. package/dist/chomp-api-service-method-action-types.cjs +7 -0
  3. package/dist/chomp-api-service-method-action-types.cjs.map +1 -0
  4. package/dist/{chomp-api-service-method-action-types.d.ts → chomp-api-service-method-action-types.d.cts} +2 -2
  5. package/dist/chomp-api-service-method-action-types.d.cts.map +1 -0
  6. package/dist/chomp-api-service-method-action-types.d.mts +133 -0
  7. package/dist/chomp-api-service-method-action-types.d.mts.map +1 -0
  8. package/dist/{chomp-api-service-method-action-types.js → chomp-api-service-method-action-types.mjs} +1 -1
  9. package/dist/chomp-api-service-method-action-types.mjs.map +1 -0
  10. package/dist/chomp-api-service.cjs +451 -0
  11. package/dist/chomp-api-service.cjs.map +1 -0
  12. package/dist/{chomp-api-service.d.ts → chomp-api-service.d.cts} +9 -9
  13. package/dist/chomp-api-service.d.cts.map +1 -0
  14. package/dist/chomp-api-service.d.mts +175 -0
  15. package/dist/chomp-api-service.d.mts.map +1 -0
  16. package/dist/{chomp-api-service.js → chomp-api-service.mjs} +52 -46
  17. package/dist/chomp-api-service.mjs.map +1 -0
  18. package/dist/index.cjs +6 -0
  19. package/dist/index.cjs.map +1 -0
  20. package/dist/{index.d.ts → index.d.cts} +5 -5
  21. package/dist/index.d.cts.map +1 -0
  22. package/dist/index.d.mts +5 -0
  23. package/dist/index.d.mts.map +1 -0
  24. package/dist/index.mjs +2 -0
  25. package/dist/index.mjs.map +1 -0
  26. package/dist/types.cjs +3 -0
  27. package/dist/types.cjs.map +1 -0
  28. package/dist/{types.d.ts → types.d.cts} +2 -2
  29. package/dist/types.d.cts.map +1 -0
  30. package/dist/types.d.mts +162 -0
  31. package/dist/types.d.mts.map +1 -0
  32. package/dist/types.mjs +2 -0
  33. package/dist/types.mjs.map +1 -0
  34. package/package.json +16 -12
  35. package/dist/chomp-api-service-method-action-types.d.ts.map +0 -1
  36. package/dist/chomp-api-service-method-action-types.js.map +0 -1
  37. package/dist/chomp-api-service.d.ts.map +0 -1
  38. package/dist/chomp-api-service.js.map +0 -1
  39. package/dist/index.d.ts.map +0 -1
  40. package/dist/index.js +0 -2
  41. package/dist/index.js.map +0 -1
  42. package/dist/types.d.ts.map +0 -1
  43. package/dist/types.js +0 -2
  44. package/dist/types.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -26,7 +26,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
26
26
 
27
27
  ### Changed
28
28
 
29
- - **BREAKING:** Bump minimum Node.js version to 22 ([#9168](https://github.com/MetaMask/core/pull/9168))
30
29
  - **BREAKING:** `associateAddress` now throws an `HttpError` on a 409 response instead of returning the parsed body ([#9387](https://github.com/MetaMask/core/pull/9387))
31
30
  - A 409 from `POST /v1/auth/address` indicates the address is associated with a _different_ profile; the previous handling attempted to parse the error body as an association result and failed with a confusing validation error. An address already associated with the authenticated profile is reported via a 201 response with `status: 'active'`, which is unchanged.
32
31
  - Bump `@metamask/utils` from `^11.9.0` to `^11.11.0` ([#9074](https://github.com/MetaMask/core/pull/9074))
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * This file is auto generated.
4
+ * Do not edit manually.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=chomp-api-service-method-action-types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chomp-api-service-method-action-types.cjs","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ChompApiService } from './chomp-api-service.js';\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: `status: 'created'` for a new\n * association, `status: 'active'` when the address was already associated\n * with the authenticated profile. Throws on 409, which indicates the\n * address is associated with a different profile.\n */\nexport type ChompApiServiceAssociateAddressAction = {\n type: `ChompApiService:associateAddress`;\n handler: ChompApiService['associateAddress'];\n};\n\n/**\n * Fetches the addresses associated with the authenticated profile.\n *\n * GET /v1/auth/address\n *\n * The result is scoped to the authenticated profile and consumers use it to\n * decide whether an association already exists, so it is always fetched\n * fresh (`staleTime: 0`, `cacheTime: 0`) and the query key is scoped to the\n * profile via a digest of the bearer token — concurrent calls only share a\n * request when they are for the same profile.\n *\n * @returns The active address associations; empty array if none exist.\n * Addresses are lowercased.\n */\nexport type ChompApiServiceGetAssociatedAddressesAction = {\n type: `ChompApiService:getAssociatedAddresses`;\n handler: ChompApiService['getAssociatedAddresses'];\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 */\nexport type ChompApiServiceCreateUpgradeAction = {\n type: `ChompApiService:createUpgrade`;\n handler: ChompApiService['createUpgrade'];\n};\n\n/**\n * Fetches all EIP-7702 upgrade authorizations for a given address (one per\n * chain).\n *\n * GET /v1/account-upgrade/:address\n *\n * @param address - The address to look up.\n * @returns The upgrade entries; empty array if none exist.\n */\nexport type ChompApiServiceGetUpgradesAction = {\n type: `ChompApiService:getUpgrades`;\n handler: ChompApiService['getUpgrades'];\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 */\nexport type ChompApiServiceVerifyDelegationAction = {\n type: `ChompApiService:verifyDelegation`;\n handler: ChompApiService['verifyDelegation'];\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 */\nexport type ChompApiServiceCreateIntentsAction = {\n type: `ChompApiService:createIntents`;\n handler: ChompApiService['createIntents'];\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 */\nexport type ChompApiServiceGetIntentsByAddressAction = {\n type: `ChompApiService:getIntentsByAddress`;\n handler: ChompApiService['getIntentsByAddress'];\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 */\nexport type ChompApiServiceCreateWithdrawalAction = {\n type: `ChompApiService:createWithdrawal`;\n handler: ChompApiService['createWithdrawal'];\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 */\nexport type ChompApiServiceGetServiceDetailsAction = {\n type: `ChompApiService:getServiceDetails`;\n handler: ChompApiService['getServiceDetails'];\n};\n\n/**\n * Union of all ChompApiService action types.\n */\nexport type ChompApiServiceMethodActions =\n | ChompApiServiceAssociateAddressAction\n | ChompApiServiceGetAssociatedAddressesAction\n | ChompApiServiceCreateUpgradeAction\n | ChompApiServiceGetUpgradesAction\n | ChompApiServiceVerifyDelegationAction\n | ChompApiServiceCreateIntentsAction\n | ChompApiServiceGetIntentsByAddressAction\n | ChompApiServiceCreateWithdrawalAction\n | ChompApiServiceGetServiceDetailsAction;\n"]}
@@ -2,7 +2,7 @@
2
2
  * This file is auto generated.
3
3
  * Do not edit manually.
4
4
  */
5
- import type { ChompApiService } from './chomp-api-service.js';
5
+ import type { ChompApiService } from "./chomp-api-service.cjs";
6
6
  /**
7
7
  * Associates an address with a CHOMP profile.
8
8
  *
@@ -130,4 +130,4 @@ export type ChompApiServiceGetServiceDetailsAction = {
130
130
  * Union of all ChompApiService action types.
131
131
  */
132
132
  export type ChompApiServiceMethodActions = ChompApiServiceAssociateAddressAction | ChompApiServiceGetAssociatedAddressesAction | ChompApiServiceCreateUpgradeAction | ChompApiServiceGetUpgradesAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceGetIntentsByAddressAction | ChompApiServiceCreateWithdrawalAction | ChompApiServiceGetServiceDetailsAction;
133
- //# sourceMappingURL=chomp-api-service-method-action-types.d.ts.map
133
+ //# sourceMappingURL=chomp-api-service-method-action-types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chomp-api-service-method-action-types.d.cts","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,gCAA+B;AAE9D;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,eAAe,CAAC,wBAAwB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;CACzC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,eAAe,CAAC,mBAAmB,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACpC,qCAAqC,GACrC,2CAA2C,GAC3C,kCAAkC,GAClC,gCAAgC,GAChC,qCAAqC,GACrC,kCAAkC,GAClC,wCAAwC,GACxC,qCAAqC,GACrC,sCAAsC,CAAC"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * This file is auto generated.
3
+ * Do not edit manually.
4
+ */
5
+ import type { ChompApiService } from "./chomp-api-service.mjs";
6
+ /**
7
+ * Associates an address with a CHOMP profile.
8
+ *
9
+ * POST /v1/auth/address
10
+ *
11
+ * @param params - The association params containing signature, timestamp,
12
+ * and address.
13
+ * @returns The profile association result: `status: 'created'` for a new
14
+ * association, `status: 'active'` when the address was already associated
15
+ * with the authenticated profile. Throws on 409, which indicates the
16
+ * address is associated with a different profile.
17
+ */
18
+ export type ChompApiServiceAssociateAddressAction = {
19
+ type: `ChompApiService:associateAddress`;
20
+ handler: ChompApiService['associateAddress'];
21
+ };
22
+ /**
23
+ * Fetches the addresses associated with the authenticated profile.
24
+ *
25
+ * GET /v1/auth/address
26
+ *
27
+ * The result is scoped to the authenticated profile and consumers use it to
28
+ * decide whether an association already exists, so it is always fetched
29
+ * fresh (`staleTime: 0`, `cacheTime: 0`) and the query key is scoped to the
30
+ * profile via a digest of the bearer token — concurrent calls only share a
31
+ * request when they are for the same profile.
32
+ *
33
+ * @returns The active address associations; empty array if none exist.
34
+ * Addresses are lowercased.
35
+ */
36
+ export type ChompApiServiceGetAssociatedAddressesAction = {
37
+ type: `ChompApiService:getAssociatedAddresses`;
38
+ handler: ChompApiService['getAssociatedAddresses'];
39
+ };
40
+ /**
41
+ * Creates an account upgrade request.
42
+ *
43
+ * POST /v1/account-upgrade
44
+ *
45
+ * @param params - The upgrade params containing signature components and
46
+ * chain details.
47
+ * @returns The upgrade result.
48
+ */
49
+ export type ChompApiServiceCreateUpgradeAction = {
50
+ type: `ChompApiService:createUpgrade`;
51
+ handler: ChompApiService['createUpgrade'];
52
+ };
53
+ /**
54
+ * Fetches all EIP-7702 upgrade authorizations for a given address (one per
55
+ * chain).
56
+ *
57
+ * GET /v1/account-upgrade/:address
58
+ *
59
+ * @param address - The address to look up.
60
+ * @returns The upgrade entries; empty array if none exist.
61
+ */
62
+ export type ChompApiServiceGetUpgradesAction = {
63
+ type: `ChompApiService:getUpgrades`;
64
+ handler: ChompApiService['getUpgrades'];
65
+ };
66
+ /**
67
+ * Verifies a delegation signature.
68
+ *
69
+ * POST /v1/intent/verify-delegation
70
+ *
71
+ * @param params - The delegation verification params.
72
+ * @returns The verification result including validity and optional errors.
73
+ */
74
+ export type ChompApiServiceVerifyDelegationAction = {
75
+ type: `ChompApiService:verifyDelegation`;
76
+ handler: ChompApiService['verifyDelegation'];
77
+ };
78
+ /**
79
+ * Submits one or more intents to the CHOMP API.
80
+ *
81
+ * POST /v1/intent
82
+ *
83
+ * @param intents - The array of intents to submit.
84
+ * @returns The array of intent responses.
85
+ */
86
+ export type ChompApiServiceCreateIntentsAction = {
87
+ type: `ChompApiService:createIntents`;
88
+ handler: ChompApiService['createIntents'];
89
+ };
90
+ /**
91
+ * Fetches intents associated with a given address.
92
+ *
93
+ * GET /v1/intent/account/:address
94
+ *
95
+ * @param address - The address to look up intents for.
96
+ * @returns The array of intents for the address.
97
+ */
98
+ export type ChompApiServiceGetIntentsByAddressAction = {
99
+ type: `ChompApiService:getIntentsByAddress`;
100
+ handler: ChompApiService['getIntentsByAddress'];
101
+ };
102
+ /**
103
+ * Creates a withdrawal for card spend flows.
104
+ *
105
+ * POST /v1/withdrawal
106
+ *
107
+ * @param params - The withdrawal params containing chainId, amount
108
+ * (decimal or hex string), and account address.
109
+ * @returns The withdrawal result.
110
+ */
111
+ export type ChompApiServiceCreateWithdrawalAction = {
112
+ type: `ChompApiService:createWithdrawal`;
113
+ handler: ChompApiService['createWithdrawal'];
114
+ };
115
+ /**
116
+ * Retrieves service details including delegation redeemer addresses and DeFi
117
+ * contract details for signing delegations for auto-deposit functionality.
118
+ *
119
+ * GET /v1/chomp
120
+ *
121
+ * @param chainIds - Array of chain IDs (0x-prefixed hex strings) to retrieve
122
+ * details for.
123
+ * @returns The service details for the requested chains.
124
+ */
125
+ export type ChompApiServiceGetServiceDetailsAction = {
126
+ type: `ChompApiService:getServiceDetails`;
127
+ handler: ChompApiService['getServiceDetails'];
128
+ };
129
+ /**
130
+ * Union of all ChompApiService action types.
131
+ */
132
+ export type ChompApiServiceMethodActions = ChompApiServiceAssociateAddressAction | ChompApiServiceGetAssociatedAddressesAction | ChompApiServiceCreateUpgradeAction | ChompApiServiceGetUpgradesAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceGetIntentsByAddressAction | ChompApiServiceCreateWithdrawalAction | ChompApiServiceGetServiceDetailsAction;
133
+ //# sourceMappingURL=chomp-api-service-method-action-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chomp-api-service-method-action-types.d.mts","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,gCAA+B;AAE9D;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,eAAe,CAAC,wBAAwB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;CACzC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,eAAe,CAAC,mBAAmB,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACpC,qCAAqC,GACrC,2CAA2C,GAC3C,kCAAkC,GAClC,gCAAgC,GAChC,qCAAqC,GACrC,kCAAkC,GAClC,wCAAwC,GACxC,qCAAqC,GACrC,sCAAsC,CAAC"}
@@ -3,4 +3,4 @@
3
3
  * Do not edit manually.
4
4
  */
5
5
  export {};
6
- //# sourceMappingURL=chomp-api-service-method-action-types.js.map
6
+ //# sourceMappingURL=chomp-api-service-method-action-types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chomp-api-service-method-action-types.mjs","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ChompApiService } from './chomp-api-service.js';\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: `status: 'created'` for a new\n * association, `status: 'active'` when the address was already associated\n * with the authenticated profile. Throws on 409, which indicates the\n * address is associated with a different profile.\n */\nexport type ChompApiServiceAssociateAddressAction = {\n type: `ChompApiService:associateAddress`;\n handler: ChompApiService['associateAddress'];\n};\n\n/**\n * Fetches the addresses associated with the authenticated profile.\n *\n * GET /v1/auth/address\n *\n * The result is scoped to the authenticated profile and consumers use it to\n * decide whether an association already exists, so it is always fetched\n * fresh (`staleTime: 0`, `cacheTime: 0`) and the query key is scoped to the\n * profile via a digest of the bearer token — concurrent calls only share a\n * request when they are for the same profile.\n *\n * @returns The active address associations; empty array if none exist.\n * Addresses are lowercased.\n */\nexport type ChompApiServiceGetAssociatedAddressesAction = {\n type: `ChompApiService:getAssociatedAddresses`;\n handler: ChompApiService['getAssociatedAddresses'];\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 */\nexport type ChompApiServiceCreateUpgradeAction = {\n type: `ChompApiService:createUpgrade`;\n handler: ChompApiService['createUpgrade'];\n};\n\n/**\n * Fetches all EIP-7702 upgrade authorizations for a given address (one per\n * chain).\n *\n * GET /v1/account-upgrade/:address\n *\n * @param address - The address to look up.\n * @returns The upgrade entries; empty array if none exist.\n */\nexport type ChompApiServiceGetUpgradesAction = {\n type: `ChompApiService:getUpgrades`;\n handler: ChompApiService['getUpgrades'];\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 */\nexport type ChompApiServiceVerifyDelegationAction = {\n type: `ChompApiService:verifyDelegation`;\n handler: ChompApiService['verifyDelegation'];\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 */\nexport type ChompApiServiceCreateIntentsAction = {\n type: `ChompApiService:createIntents`;\n handler: ChompApiService['createIntents'];\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 */\nexport type ChompApiServiceGetIntentsByAddressAction = {\n type: `ChompApiService:getIntentsByAddress`;\n handler: ChompApiService['getIntentsByAddress'];\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 */\nexport type ChompApiServiceCreateWithdrawalAction = {\n type: `ChompApiService:createWithdrawal`;\n handler: ChompApiService['createWithdrawal'];\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 */\nexport type ChompApiServiceGetServiceDetailsAction = {\n type: `ChompApiService:getServiceDetails`;\n handler: ChompApiService['getServiceDetails'];\n};\n\n/**\n * Union of all ChompApiService action types.\n */\nexport type ChompApiServiceMethodActions =\n | ChompApiServiceAssociateAddressAction\n | ChompApiServiceGetAssociatedAddressesAction\n | ChompApiServiceCreateUpgradeAction\n | ChompApiServiceGetUpgradesAction\n | ChompApiServiceVerifyDelegationAction\n | ChompApiServiceCreateIntentsAction\n | ChompApiServiceGetIntentsByAddressAction\n | ChompApiServiceCreateWithdrawalAction\n | ChompApiServiceGetServiceDetailsAction;\n"]}
@@ -0,0 +1,451 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _ChompApiService_instances, _ChompApiService_baseUrl, _ChompApiService_headersForToken, _ChompApiService_authHeaders;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ChompApiService = exports.serviceName = void 0;
16
+ const base_data_service_1 = require("@metamask/base-data-service");
17
+ const controller_utils_1 = require("@metamask/controller-utils");
18
+ const superstruct_1 = require("@metamask/superstruct");
19
+ const utils_1 = require("@metamask/utils");
20
+ // === GENERAL ===
21
+ /**
22
+ * The name of the {@link ChompApiService}, used to namespace the service's
23
+ * actions and events.
24
+ */
25
+ exports.serviceName = 'ChompApiService';
26
+ // === MESSENGER ===
27
+ /**
28
+ * All of the methods within {@link ChompApiService} that are exposed via the
29
+ * messenger.
30
+ */
31
+ const MESSENGER_EXPOSED_METHODS = [
32
+ 'associateAddress',
33
+ 'getAssociatedAddresses',
34
+ 'createUpgrade',
35
+ 'getUpgrades',
36
+ 'verifyDelegation',
37
+ 'createIntents',
38
+ 'getIntentsByAddress',
39
+ 'createWithdrawal',
40
+ 'getServiceDetails',
41
+ ];
42
+ // === RESPONSE VALIDATION ===
43
+ const AssociateAddressResponseStruct = (0, superstruct_1.type)({
44
+ profileId: (0, superstruct_1.optional)((0, superstruct_1.string)()),
45
+ address: utils_1.StrictHexStruct,
46
+ status: (0, superstruct_1.enums)(['active', 'created']),
47
+ });
48
+ /**
49
+ * Parses addresses into canonical lowercase form. CHOMP stores and returns
50
+ * addresses lowercased, but `StrictHexStruct` alone accepts any casing, so
51
+ * this makes the canonical form a guarantee of the parsed data rather than a
52
+ * convention consumers must each remember.
53
+ */
54
+ const LowercaseHexAddressStruct = (0, superstruct_1.coerce)(utils_1.StrictHexStruct, (0, superstruct_1.string)(), (value) => value.toLowerCase());
55
+ const ProfileAddressEntryArrayStruct = (0, superstruct_1.array)((0, superstruct_1.type)({
56
+ profileId: (0, superstruct_1.string)(),
57
+ address: LowercaseHexAddressStruct,
58
+ status: (0, superstruct_1.enums)(['active']),
59
+ }));
60
+ const AccountUpgradeStatusStruct = (0, superstruct_1.enums)(['pending', 'upgraded']);
61
+ const AuthorizationDataStruct = (0, superstruct_1.type)({
62
+ r: utils_1.StrictHexStruct,
63
+ s: utils_1.StrictHexStruct,
64
+ v: (0, superstruct_1.number)(),
65
+ yParity: (0, superstruct_1.number)(),
66
+ address: utils_1.StrictHexStruct,
67
+ chainId: utils_1.StrictHexStruct,
68
+ nonce: utils_1.StrictHexStruct,
69
+ });
70
+ const CreateUpgradeResponseStruct = (0, superstruct_1.type)({
71
+ signerAddress: utils_1.StrictHexStruct,
72
+ address: utils_1.StrictHexStruct,
73
+ chainId: utils_1.StrictHexStruct,
74
+ nonce: utils_1.StrictHexStruct,
75
+ status: AccountUpgradeStatusStruct,
76
+ createdAt: (0, superstruct_1.string)(),
77
+ });
78
+ const UpgradeEntryArrayStruct = (0, superstruct_1.array)((0, superstruct_1.type)({
79
+ signerAddress: utils_1.StrictHexStruct,
80
+ chainId: utils_1.StrictHexStruct,
81
+ nonce: utils_1.StrictHexStruct,
82
+ authorization: AuthorizationDataStruct,
83
+ status: AccountUpgradeStatusStruct,
84
+ createdAt: (0, superstruct_1.string)(),
85
+ }));
86
+ const VerifyDelegationResponseStruct = (0, superstruct_1.type)({
87
+ valid: (0, superstruct_1.boolean)(),
88
+ delegationHash: (0, superstruct_1.optional)(utils_1.StrictHexStruct),
89
+ errors: (0, superstruct_1.optional)((0, superstruct_1.array)((0, superstruct_1.string)())),
90
+ });
91
+ const SendIntentResponseArrayStruct = (0, superstruct_1.array)((0, superstruct_1.type)({
92
+ delegationHash: utils_1.StrictHexStruct,
93
+ metadata: (0, superstruct_1.type)({
94
+ allowance: utils_1.StrictHexStruct,
95
+ tokenSymbol: (0, superstruct_1.string)(),
96
+ tokenAddress: utils_1.StrictHexStruct,
97
+ type: (0, superstruct_1.enums)(['cash-deposit', 'cash-withdrawal']),
98
+ }),
99
+ createdAt: (0, superstruct_1.string)(),
100
+ }));
101
+ const IntentEntryArrayStruct = (0, superstruct_1.array)((0, superstruct_1.type)({
102
+ account: utils_1.StrictHexStruct,
103
+ delegationHash: utils_1.StrictHexStruct,
104
+ chainId: utils_1.StrictHexStruct,
105
+ status: (0, superstruct_1.enums)(['active', 'revoked']),
106
+ metadata: (0, superstruct_1.type)({
107
+ allowance: utils_1.StrictHexStruct,
108
+ tokenAddress: utils_1.StrictHexStruct,
109
+ tokenSymbol: (0, superstruct_1.string)(),
110
+ type: (0, superstruct_1.enums)(['cash-deposit', 'cash-withdrawal']),
111
+ }),
112
+ }));
113
+ const CreateWithdrawalResponseStruct = (0, superstruct_1.type)({
114
+ success: (0, superstruct_1.literal)(true),
115
+ });
116
+ const ServiceDetailsProtocolStruct = (0, superstruct_1.type)({
117
+ supportedTokens: (0, superstruct_1.array)((0, superstruct_1.type)({
118
+ tokenAddress: utils_1.StrictHexStruct,
119
+ tokenDecimals: (0, superstruct_1.number)(),
120
+ })),
121
+ adapterAddress: utils_1.StrictHexStruct,
122
+ intentTypes: (0, superstruct_1.array)((0, superstruct_1.enums)(['cash-deposit', 'cash-withdrawal'])),
123
+ });
124
+ const ServiceDetailsResponseStruct = (0, superstruct_1.type)({
125
+ auth: (0, superstruct_1.type)({
126
+ message: (0, superstruct_1.string)(),
127
+ }),
128
+ chains: (0, superstruct_1.record)(utils_1.StrictHexStruct, (0, superstruct_1.type)({
129
+ autoDepositDelegate: utils_1.StrictHexStruct,
130
+ protocol: (0, superstruct_1.record)((0, superstruct_1.string)(), ServiceDetailsProtocolStruct),
131
+ })),
132
+ });
133
+ // === RETRY POLICY ===
134
+ /**
135
+ * Determines whether an error from a CHOMP API call is worth retrying.
136
+ *
137
+ * 4xx responses (e.g. 409 "already exists", 400 validation, 401/403 auth) are
138
+ * caused by the request itself and will not be resolved by re-issuing the same
139
+ * request, so they bypass the retry loop. 429 is treated as transient and
140
+ * retried alongside 5xx server errors. Non-HTTP errors (network/timeout) fall
141
+ * through to the default "retry" behaviour.
142
+ *
143
+ * @param error - The error thrown by the query function.
144
+ * @returns `true` when the error is worth retrying.
145
+ */
146
+ function isRetryableError(error) {
147
+ if (error instanceof controller_utils_1.HttpError) {
148
+ if (error.httpStatus === 429) {
149
+ return true;
150
+ }
151
+ return error.httpStatus < 400 || error.httpStatus >= 500;
152
+ }
153
+ return true;
154
+ }
155
+ const DEFAULT_POLICY_OPTIONS = {
156
+ retryFilterPolicy: (0, controller_utils_1.handleWhen)(isRetryableError),
157
+ };
158
+ // === SERVICE DEFINITION ===
159
+ /**
160
+ * This service is responsible for communicating with the CHOMP API.
161
+ *
162
+ * All requests are authenticated via JWT Bearer tokens obtained from the
163
+ * `AuthenticationController:getBearerToken` messenger action.
164
+ */
165
+ class ChompApiService extends base_data_service_1.BaseDataService {
166
+ /**
167
+ * Constructs a new ChompApiService.
168
+ *
169
+ * @param args - The constructor arguments.
170
+ * @param args.messenger - The messenger suited for this service.
171
+ * @param args.baseUrl - The base URL of the CHOMP API.
172
+ * @param args.queryClientConfig - Configuration for the underlying TanStack
173
+ * Query client.
174
+ * @param args.policyOptions - Options to pass to `createServicePolicy`.
175
+ */
176
+ constructor({ messenger, baseUrl, queryClientConfig = {}, policyOptions = {}, }) {
177
+ super({
178
+ name: exports.serviceName,
179
+ messenger,
180
+ queryClientConfig,
181
+ policyOptions: { ...DEFAULT_POLICY_OPTIONS, ...policyOptions },
182
+ });
183
+ _ChompApiService_instances.add(this);
184
+ _ChompApiService_baseUrl.set(this, void 0);
185
+ __classPrivateFieldSet(this, _ChompApiService_baseUrl, baseUrl, "f");
186
+ this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
187
+ }
188
+ /**
189
+ * Associates an address with a CHOMP profile.
190
+ *
191
+ * POST /v1/auth/address
192
+ *
193
+ * @param params - The association params containing signature, timestamp,
194
+ * and address.
195
+ * @returns The profile association result: `status: 'created'` for a new
196
+ * association, `status: 'active'` when the address was already associated
197
+ * with the authenticated profile. Throws on 409, which indicates the
198
+ * address is associated with a different profile.
199
+ */
200
+ async associateAddress(params) {
201
+ const jsonResponse = await this.fetchQuery({
202
+ queryKey: [`${this.name}:associateAddress`, params],
203
+ staleTime: 0,
204
+ queryFn: async () => {
205
+ const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
206
+ const response = await fetch(new URL('/v1/auth/address', __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), {
207
+ method: 'POST',
208
+ headers,
209
+ body: JSON.stringify(params),
210
+ });
211
+ if (!response.ok) {
212
+ throw new controller_utils_1.HttpError(response.status, `POST /v1/auth/address failed with status '${response.status}'`);
213
+ }
214
+ return response.json();
215
+ },
216
+ });
217
+ return (0, superstruct_1.create)(jsonResponse, AssociateAddressResponseStruct);
218
+ }
219
+ /**
220
+ * Fetches the addresses associated with the authenticated profile.
221
+ *
222
+ * GET /v1/auth/address
223
+ *
224
+ * The result is scoped to the authenticated profile and consumers use it
225
+ * to decide whether an association already exists, so it is always fetched
226
+ * fresh (`staleTime: 0`) and evicted as soon as the call settles
227
+ * (`gcTime: 0`). The query key carries a SHA-256 digest of the bearer
228
+ * token — the same token the request is made with — so concurrent calls
229
+ * only share an in-flight request when they are for the same profile. The
230
+ * digest, not the token, is used because query keys leave the service via
231
+ * the `cacheUpdated` messenger events.
232
+ *
233
+ * @returns The active address associations; empty array if none exist.
234
+ * Addresses are lowercased.
235
+ */
236
+ async getAssociatedAddresses() {
237
+ const token = await this.messenger.call('AuthenticationController:getBearerToken');
238
+ const profileKey = (0, utils_1.bytesToHex)(await (0, utils_1.sha256)((0, utils_1.stringToBytes)(token)));
239
+ const jsonResponse = await this.fetchQuery({
240
+ queryKey: [`${this.name}:getAssociatedAddresses`, profileKey],
241
+ staleTime: 0,
242
+ gcTime: 0,
243
+ queryFn: async () => {
244
+ const response = await fetch(new URL('/v1/auth/address', __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), { headers: __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_headersForToken).call(this, token) });
245
+ if (!response.ok) {
246
+ throw new controller_utils_1.HttpError(response.status, `GET /v1/auth/address failed with status '${response.status}'`);
247
+ }
248
+ return response.json();
249
+ },
250
+ });
251
+ return (0, superstruct_1.create)(jsonResponse, ProfileAddressEntryArrayStruct);
252
+ }
253
+ /**
254
+ * Creates an account upgrade request.
255
+ *
256
+ * POST /v1/account-upgrade
257
+ *
258
+ * @param params - The upgrade params containing signature components and
259
+ * chain details.
260
+ * @returns The upgrade result.
261
+ */
262
+ async createUpgrade(params) {
263
+ const jsonResponse = await this.fetchQuery({
264
+ queryKey: [`${this.name}:createUpgrade`, params],
265
+ staleTime: 0,
266
+ queryFn: async () => {
267
+ const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
268
+ const response = await fetch(new URL('/v1/account-upgrade', __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), {
269
+ method: 'POST',
270
+ headers,
271
+ body: JSON.stringify(params),
272
+ });
273
+ if (!response.ok) {
274
+ throw new controller_utils_1.HttpError(response.status, `POST /v1/account-upgrade failed with status '${response.status}'`);
275
+ }
276
+ return response.json();
277
+ },
278
+ });
279
+ return (0, superstruct_1.create)(jsonResponse, CreateUpgradeResponseStruct);
280
+ }
281
+ /**
282
+ * Fetches all EIP-7702 upgrade authorizations for a given address (one per
283
+ * chain).
284
+ *
285
+ * GET /v1/account-upgrade/:address
286
+ *
287
+ * @param address - The address to look up.
288
+ * @returns The upgrade entries; empty array if none exist.
289
+ */
290
+ async getUpgrades(address) {
291
+ const jsonResponse = await this.fetchQuery({
292
+ queryKey: [`${this.name}:getUpgrades`, address],
293
+ queryFn: async () => {
294
+ const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
295
+ const response = await fetch(new URL(`/v1/account-upgrade/${address}`, __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), { headers });
296
+ if (!response.ok) {
297
+ throw new controller_utils_1.HttpError(response.status, `Get upgrades request failed with status '${response.status}'`);
298
+ }
299
+ return response.json();
300
+ },
301
+ });
302
+ return (0, superstruct_1.create)(jsonResponse, UpgradeEntryArrayStruct);
303
+ }
304
+ /**
305
+ * Verifies a delegation signature.
306
+ *
307
+ * POST /v1/intent/verify-delegation
308
+ *
309
+ * @param params - The delegation verification params.
310
+ * @returns The verification result including validity and optional errors.
311
+ */
312
+ async verifyDelegation(params) {
313
+ const jsonResponse = await this.fetchQuery({
314
+ queryKey: [`${this.name}:verifyDelegation`, params],
315
+ staleTime: 0,
316
+ queryFn: async () => {
317
+ const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
318
+ const response = await fetch(new URL('/v1/intent/verify-delegation', __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), {
319
+ method: 'POST',
320
+ headers,
321
+ body: JSON.stringify(params),
322
+ });
323
+ if (!response.ok) {
324
+ throw new controller_utils_1.HttpError(response.status, `POST /v1/intent/verify-delegation failed with status '${response.status}'`);
325
+ }
326
+ return response.json();
327
+ },
328
+ });
329
+ return (0, superstruct_1.create)(jsonResponse, VerifyDelegationResponseStruct);
330
+ }
331
+ /**
332
+ * Submits one or more intents to the CHOMP API.
333
+ *
334
+ * POST /v1/intent
335
+ *
336
+ * @param intents - The array of intents to submit.
337
+ * @returns The array of intent responses.
338
+ */
339
+ async createIntents(intents) {
340
+ const jsonResponse = await this.fetchQuery({
341
+ queryKey: [`${this.name}:createIntents`, intents],
342
+ staleTime: 0,
343
+ queryFn: async () => {
344
+ const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
345
+ const response = await fetch(new URL('/v1/intent', __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), {
346
+ method: 'POST',
347
+ headers,
348
+ body: JSON.stringify(intents),
349
+ });
350
+ if (!response.ok) {
351
+ throw new controller_utils_1.HttpError(response.status, `POST /v1/intent failed with status '${response.status}'`);
352
+ }
353
+ return response.json();
354
+ },
355
+ });
356
+ return (0, superstruct_1.create)(jsonResponse, SendIntentResponseArrayStruct);
357
+ }
358
+ /**
359
+ * Fetches intents associated with a given address.
360
+ *
361
+ * GET /v1/intent/account/:address
362
+ *
363
+ * @param address - The address to look up intents for.
364
+ * @returns The array of intents for the address.
365
+ */
366
+ async getIntentsByAddress(address) {
367
+ const jsonResponse = await this.fetchQuery({
368
+ queryKey: [`${this.name}:getIntentsByAddress`, address],
369
+ queryFn: async () => {
370
+ const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
371
+ const response = await fetch(new URL(`/v1/intent/account/${address}`, __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), { headers });
372
+ if (!response.ok) {
373
+ throw new controller_utils_1.HttpError(response.status, `Get intents request failed with status '${response.status}'`);
374
+ }
375
+ return response.json();
376
+ },
377
+ });
378
+ return (0, superstruct_1.create)(jsonResponse, IntentEntryArrayStruct);
379
+ }
380
+ /**
381
+ * Creates a withdrawal for card spend flows.
382
+ *
383
+ * POST /v1/withdrawal
384
+ *
385
+ * @param params - The withdrawal params containing chainId, amount
386
+ * (decimal or hex string), and account address.
387
+ * @returns The withdrawal result.
388
+ */
389
+ async createWithdrawal(params) {
390
+ const jsonResponse = await this.fetchQuery({
391
+ queryKey: [`${this.name}:createWithdrawal`, params],
392
+ staleTime: 0,
393
+ queryFn: async () => {
394
+ const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
395
+ const response = await fetch(new URL('/v1/withdrawal', __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), {
396
+ method: 'POST',
397
+ headers,
398
+ body: JSON.stringify(params),
399
+ });
400
+ if (!response.ok) {
401
+ throw new controller_utils_1.HttpError(response.status, `POST /v1/withdrawal failed with status '${response.status}'`);
402
+ }
403
+ return response.json();
404
+ },
405
+ });
406
+ return (0, superstruct_1.create)(jsonResponse, CreateWithdrawalResponseStruct);
407
+ }
408
+ /**
409
+ * Retrieves service details including delegation redeemer addresses and DeFi
410
+ * contract details for signing delegations for auto-deposit functionality.
411
+ *
412
+ * GET /v1/chomp
413
+ *
414
+ * @param chainIds - Array of chain IDs (0x-prefixed hex strings) to retrieve
415
+ * details for.
416
+ * @returns The service details for the requested chains.
417
+ */
418
+ async getServiceDetails(chainIds) {
419
+ const jsonResponse = await this.fetchQuery({
420
+ queryKey: [`${this.name}:getServiceDetails`, chainIds],
421
+ queryFn: async () => {
422
+ const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
423
+ const url = new URL('/v1/chomp', __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f"));
424
+ url.searchParams.set('chainId', chainIds.join(','));
425
+ const response = await fetch(url, { headers });
426
+ if (!response.ok) {
427
+ throw new controller_utils_1.HttpError(response.status, `GET /v1/chomp failed with status '${response.status}'`);
428
+ }
429
+ return response.json();
430
+ },
431
+ });
432
+ return (0, superstruct_1.create)(jsonResponse, ServiceDetailsResponseStruct);
433
+ }
434
+ }
435
+ exports.ChompApiService = ChompApiService;
436
+ _ChompApiService_baseUrl = new WeakMap(), _ChompApiService_instances = new WeakSet(), _ChompApiService_headersForToken = function _ChompApiService_headersForToken(token) {
437
+ return {
438
+ Authorization: `Bearer ${token}`,
439
+ 'Content-Type': 'application/json',
440
+ };
441
+ }, _ChompApiService_authHeaders =
442
+ /**
443
+ * Builds the standard headers for an authenticated CHOMP API request.
444
+ *
445
+ * @returns Headers including Authorization and Content-Type.
446
+ */
447
+ async function _ChompApiService_authHeaders() {
448
+ const token = await this.messenger.call('AuthenticationController:getBearerToken');
449
+ return __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_headersForToken).call(this, token);
450
+ };
451
+ //# sourceMappingURL=chomp-api-service.cjs.map