@metamask-previews/chomp-api-service 6.0.1-preview-601bac5ab → 6.0.1-preview-5990812f2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -6
- package/dist/chomp-api-service-method-action-types.d.ts +1 -59
- package/dist/chomp-api-service-method-action-types.d.ts.map +1 -1
- package/dist/chomp-api-service-method-action-types.js.map +1 -1
- package/dist/chomp-api-service.d.ts +1 -50
- package/dist/chomp-api-service.d.ts.map +1 -1
- package/dist/chomp-api-service.js +3 -167
- package/dist/chomp-api-service.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +0 -67
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -9,12 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
-
- Add `getDerivedIdentities` method, also expose it through the messenger as `ChompApiService:getDerivedIdentities` ([#10695](https://github.com/MetaMask/core/pull/10695))
|
|
13
|
-
- Add `getDerivedIdentityByAddress` method, and expose it through the messenger as `ChompApiService:getDerivedIdentityByAddress` ([#10695](https://github.com/MetaMask/core/pull/10695))
|
|
14
|
-
- Add `disassociateAddress` method for `DELETE /v1/auth/address`, and expose it through the messenger as `ChompApiService:disassociateAddress` ([#10695](https://github.com/MetaMask/core/pull/10695))
|
|
15
|
-
- For an address linked as a successor, this cancels the Money Account migration and unfreezes its predecessor. CHOMP rejects this with `LINK_COMPLETE` once a funds-transfer request exists for the migration.
|
|
16
|
-
- The request is never retried.
|
|
17
|
-
- Add `AddressIdentityResponse`, `DerivedIdentitiesResponse`, `DerivedIdentity`, `DerivedIdentityAddressRole`, `DerivedIdentityMigration`, `DerivedIdentityStatus`, `MigrationStep`, `MigrationStepState`, `MigrationTransfer`, `ChompApiServiceDisassociateAddressAction`, `ChompApiServiceGetDerivedIdentitiesAction`, and `ChompApiServiceGetDerivedIdentityByAddressAction` types ([#10695](https://github.com/MetaMask/core/pull/10695))
|
|
18
12
|
- Add `createAddressChallenge` method for `POST /v2/auth/address/challenge`, and expose it through the messenger as `ChompApiService:createAddressChallenge` ([#10687](https://github.com/MetaMask/core/pull/10687))
|
|
19
13
|
- Returns a single-use SIWE message bound to the profile, chain, purpose and address. The `ASSOCIATE_SUCCESSOR` purpose takes a `predecessorAddress` to link the address as the successor of an existing Money Account.
|
|
20
14
|
- Add `associateAddressV2` method for `POST /v2/auth/address`, and expose it through the messenger as `ChompApiService:associateAddressV2` ([#10687](https://github.com/MetaMask/core/pull/10687))
|
|
@@ -23,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
23
17
|
- Add `AssociationPurpose`, `CreateAddressChallengeParams`, `CreateAddressChallengeResponse`, `AssociateAddressV2Params`, `ChompApiServiceCreateAddressChallengeAction`, and `ChompApiServiceAssociateAddressV2Action` types ([#10687](https://github.com/MetaMask/core/pull/10687))
|
|
24
18
|
- Add support for Node.js 26 ([#10981](https://github.com/MetaMask/core/pull/10981))
|
|
25
19
|
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Bump `@metamask/utils` from `^12.0.0` to `^12.0.1` ([#11107](https://github.com/MetaMask/core/pull/11107))
|
|
23
|
+
|
|
26
24
|
### Removed
|
|
27
25
|
|
|
28
26
|
- **BREAKING:** Remove the `associateAddress` method and `ChompApiService:associateAddress` messenger action (`POST /v1/auth/address`), along with the `AssociateAddressParams` and `ChompApiServiceAssociateAddressAction` types ([#10687](https://github.com/MetaMask/core/pull/10687))
|
|
@@ -43,24 +43,6 @@ export type ChompApiServiceAssociateAddressV2Action = {
|
|
|
43
43
|
type: `ChompApiService:associateAddressV2`;
|
|
44
44
|
handler: ChompApiService['associateAddressV2'];
|
|
45
45
|
};
|
|
46
|
-
/**
|
|
47
|
-
* Removes an address association from the authenticated profile. For an
|
|
48
|
-
* address linked as a successor, this cancels the migration and unfreezes
|
|
49
|
-
* its predecessor. CHOMP rejects the cancellation with `LINK_COMPLETE` once
|
|
50
|
-
* a funds-transfer request exists for the link, which can happen before
|
|
51
|
-
* the migration is `DONE`.
|
|
52
|
-
*
|
|
53
|
-
* DELETE /v1/auth/address
|
|
54
|
-
*
|
|
55
|
-
* Executed as a mutation so it is never retried: a retry after a lost
|
|
56
|
-
* response would hit an already-removed address and fail with a 404.
|
|
57
|
-
*
|
|
58
|
-
* @param address - The address to disassociate.
|
|
59
|
-
*/
|
|
60
|
-
export type ChompApiServiceDisassociateAddressAction = {
|
|
61
|
-
type: `ChompApiService:disassociateAddress`;
|
|
62
|
-
handler: ChompApiService['disassociateAddress'];
|
|
63
|
-
};
|
|
64
46
|
/**
|
|
65
47
|
* Fetches the addresses associated with the authenticated profile.
|
|
66
48
|
*
|
|
@@ -175,48 +157,8 @@ export type ChompApiServiceGetServiceDetailsAction = {
|
|
|
175
157
|
type: `ChompApiService:getServiceDetails`;
|
|
176
158
|
handler: ChompApiService['getServiceDetails'];
|
|
177
159
|
};
|
|
178
|
-
/**
|
|
179
|
-
* Fetches the Money Account identities of the authenticated profile, with
|
|
180
|
-
* the status and migration steps CHOMP derives on every read. When funds
|
|
181
|
-
* transfer is the only missing step, CHOMP creates the transfer request as
|
|
182
|
-
* part of the read, after which the migration can no longer be cancelled.
|
|
183
|
-
*
|
|
184
|
-
* GET /v1/money-account/identities
|
|
185
|
-
*
|
|
186
|
-
* Profile-scoped and used to drive migrations, so it is always fetched
|
|
187
|
-
* fresh and keyed by a digest of the bearer token, like
|
|
188
|
-
* {@link ChompApiService.getAssociatedAddresses}.
|
|
189
|
-
*
|
|
190
|
-
* @returns The identities; empty when the profile has no Money Account.
|
|
191
|
-
* Addresses are lowercased.
|
|
192
|
-
*/
|
|
193
|
-
export type ChompApiServiceGetDerivedIdentitiesAction = {
|
|
194
|
-
type: `ChompApiService:getDerivedIdentities`;
|
|
195
|
-
handler: ChompApiService['getDerivedIdentities'];
|
|
196
|
-
};
|
|
197
|
-
/**
|
|
198
|
-
* Fetches the identity containing an address, along with where the address
|
|
199
|
-
* sits in it. The identity's `status` describes the whole chain. Like
|
|
200
|
-
* {@link ChompApiService.getDerivedIdentities}, this read can create the
|
|
201
|
-
* migration's funds-transfer request.
|
|
202
|
-
*
|
|
203
|
-
* GET /v1/money-account/identities/address/:address
|
|
204
|
-
*
|
|
205
|
-
* Always fetched fresh and keyed by a digest of the bearer token, like
|
|
206
|
-
* {@link ChompApiService.getDerivedIdentities}.
|
|
207
|
-
*
|
|
208
|
-
* @param address - The address to look up.
|
|
209
|
-
* @returns The identity and address details, or `null` when CHOMP responds
|
|
210
|
-
* with `ADDRESS_NOT_ASSOCIATED`: the address is not associated with the
|
|
211
|
-
* authenticated profile, or it is but belongs to no Money Account.
|
|
212
|
-
* Addresses are lowercased.
|
|
213
|
-
*/
|
|
214
|
-
export type ChompApiServiceGetDerivedIdentityByAddressAction = {
|
|
215
|
-
type: `ChompApiService:getDerivedIdentityByAddress`;
|
|
216
|
-
handler: ChompApiService['getDerivedIdentityByAddress'];
|
|
217
|
-
};
|
|
218
160
|
/**
|
|
219
161
|
* Union of all ChompApiService action types.
|
|
220
162
|
*/
|
|
221
|
-
export type ChompApiServiceMethodActions = ChompApiServiceCreateAddressChallengeAction | ChompApiServiceAssociateAddressV2Action |
|
|
163
|
+
export type ChompApiServiceMethodActions = ChompApiServiceCreateAddressChallengeAction | ChompApiServiceAssociateAddressV2Action | ChompApiServiceGetAssociatedAddressesAction | ChompApiServiceCreateUpgradeAction | ChompApiServiceGetUpgradesAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceGetIntentsByAddressAction | ChompApiServiceCreateWithdrawalAction | ChompApiServiceGetServiceDetailsAction;
|
|
222
164
|
//# sourceMappingURL=chomp-api-service-method-action-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chomp-api-service-method-action-types.d.ts","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,eAAe,CAAC,wBAAwB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,eAAe,CAAC,oBAAoB,CAAC,CAAC;CAChD,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"chomp-api-service-method-action-types.d.ts","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,eAAe,CAAC,wBAAwB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,eAAe,CAAC,oBAAoB,CAAC,CAAC;CAChD,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;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,+BA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["../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 * Requests a single-use challenge for associating an address through the v2\n * flow. Sign the returned `message` exactly as received, using\n * `personal_sign` with the address being associated, then submit it with\n * {@link ChompApiService.associateAddressV2} before `expiresAt`. Requesting\n * a new challenge for the same address replaces the previous one.\n *\n * POST /v2/auth/address/challenge\n *\n * Each call issues a new challenge, so the result is never cached.\n *\n * @param params - The address to associate and the association purpose.\n * `ASSOCIATE_SUCCESSOR` also requires the predecessor address.\n * @returns The challenge ID, the message to sign, and when it expires.\n */\nexport type ChompApiServiceCreateAddressChallengeAction = {\n type: `ChompApiService:createAddressChallenge`;\n handler: ChompApiService['createAddressChallenge'];\n};\n\n/**\n * Associates an address with a CHOMP profile by submitting the signature of\n * a challenge from {@link ChompApiService.createAddressChallenge}. The\n * address, purpose and predecessor come from the challenge. For\n * `ASSOCIATE_SUCCESSOR`, the association and the link to the predecessor\n * are written atomically.\n *\n * POST /v2/auth/address\n *\n * @param params - The challenge ID and its signature.\n * @returns The profile association result: `status: 'created'` when the\n * association or link was written, `status: 'active'` when the address was\n * already associated with the authenticated profile. Throws on 400\n * `CHALLENGE_INVALID_OR_EXPIRED` (request a new challenge), on 409 when the\n * address is associated with a different profile, and on link validation\n * errors.\n */\nexport type ChompApiServiceAssociateAddressV2Action = {\n type: `ChompApiService:associateAddressV2`;\n handler: ChompApiService['associateAddressV2'];\n};\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"chomp-api-service-method-action-types.js","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 * Requests a single-use challenge for associating an address through the v2\n * flow. Sign the returned `message` exactly as received, using\n * `personal_sign` with the address being associated, then submit it with\n * {@link ChompApiService.associateAddressV2} before `expiresAt`. Requesting\n * a new challenge for the same address replaces the previous one.\n *\n * POST /v2/auth/address/challenge\n *\n * Each call issues a new challenge, so the result is never cached.\n *\n * @param params - The address to associate and the association purpose.\n * `ASSOCIATE_SUCCESSOR` also requires the predecessor address.\n * @returns The challenge ID, the message to sign, and when it expires.\n */\nexport type ChompApiServiceCreateAddressChallengeAction = {\n type: `ChompApiService:createAddressChallenge`;\n handler: ChompApiService['createAddressChallenge'];\n};\n\n/**\n * Associates an address with a CHOMP profile by submitting the signature of\n * a challenge from {@link ChompApiService.createAddressChallenge}. The\n * address, purpose and predecessor come from the challenge. For\n * `ASSOCIATE_SUCCESSOR`, the association and the link to the predecessor\n * are written atomically.\n *\n * POST /v2/auth/address\n *\n * @param params - The challenge ID and its signature.\n * @returns The profile association result: `status: 'created'` when the\n * association or link was written, `status: 'active'` when the address was\n * already associated with the authenticated profile. Throws on 400\n * `CHALLENGE_INVALID_OR_EXPIRED` (request a new challenge), on 409 when the\n * address is associated with a different profile, and on link validation\n * errors.\n */\nexport type ChompApiServiceAssociateAddressV2Action = {\n type: `ChompApiService:associateAddressV2`;\n handler: ChompApiService['associateAddressV2'];\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\n * to decide whether an association already exists, so it is always fetched\n * fresh (`staleTime: 0`) and evicted as soon as the call settles\n * (`gcTime: 0`). The query key carries a SHA-256 digest of the bearer\n * token — the same token the request is made with — so concurrent calls\n * only share an in-flight request when they are for the same profile. The\n * digest, not the token, is used because query keys leave the service via\n * the `cacheUpdated` messenger events.\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 * Callers use the result to decide whether an intent already exists, so it\n * is always fetched fresh (`staleTime: 0`).\n *\n * @param address - The address to look up intents for.\n * @returns The array of intents for the address, omitting any with an\n * intent type this service does not recognise.\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 | ChompApiServiceCreateAddressChallengeAction\n | ChompApiServiceAssociateAddressV2Action\n | ChompApiServiceGetAssociatedAddressesAction\n | ChompApiServiceCreateUpgradeAction\n | ChompApiServiceGetUpgradesAction\n | ChompApiServiceVerifyDelegationAction\n | ChompApiServiceCreateIntentsAction\n | ChompApiServiceGetIntentsByAddressAction\n | ChompApiServiceCreateWithdrawalAction\n | ChompApiServiceGetServiceDetailsAction;\n"]}
|
|
@@ -6,7 +6,7 @@ import type { Messenger } from '@metamask/messenger';
|
|
|
6
6
|
import type { Hex } from '@metamask/utils';
|
|
7
7
|
import type { QueryClientConfig } from '@tanstack/query-core';
|
|
8
8
|
import type { ChompApiServiceMethodActions } from './chomp-api-service-method-action-types.js';
|
|
9
|
-
import type {
|
|
9
|
+
import type { AssociateAddressResponse, AssociateAddressV2Params, CreateAddressChallengeParams, CreateAddressChallengeResponse, ProfileAddressEntry, CreateUpgradeParams, CreateUpgradeResponse, UpgradeEntry, CreateWithdrawalParams, CreateWithdrawalResponse, IntentEntry, SendIntentParams, SendIntentResponse, ServiceDetailsResponse, VerifyDelegationParams, VerifyDelegationResponse } from './types.js';
|
|
10
10
|
/**
|
|
11
11
|
* The name of the {@link ChompApiService}, used to namespace the service's
|
|
12
12
|
* actions and events.
|
|
@@ -124,21 +124,6 @@ export declare class ChompApiService extends BaseDataService<typeof serviceName,
|
|
|
124
124
|
* errors.
|
|
125
125
|
*/
|
|
126
126
|
associateAddressV2(params: AssociateAddressV2Params): Promise<AssociateAddressResponse>;
|
|
127
|
-
/**
|
|
128
|
-
* Removes an address association from the authenticated profile. For an
|
|
129
|
-
* address linked as a successor, this cancels the migration and unfreezes
|
|
130
|
-
* its predecessor. CHOMP rejects the cancellation with `LINK_COMPLETE` once
|
|
131
|
-
* a funds-transfer request exists for the link, which can happen before
|
|
132
|
-
* the migration is `DONE`.
|
|
133
|
-
*
|
|
134
|
-
* DELETE /v1/auth/address
|
|
135
|
-
*
|
|
136
|
-
* Executed as a mutation so it is never retried: a retry after a lost
|
|
137
|
-
* response would hit an already-removed address and fail with a 404.
|
|
138
|
-
*
|
|
139
|
-
* @param address - The address to disassociate.
|
|
140
|
-
*/
|
|
141
|
-
disassociateAddress(address: Hex): Promise<void>;
|
|
142
127
|
/**
|
|
143
128
|
* Fetches the addresses associated with the authenticated profile.
|
|
144
129
|
*
|
|
@@ -229,40 +214,6 @@ export declare class ChompApiService extends BaseDataService<typeof serviceName,
|
|
|
229
214
|
* @returns The service details for the requested chains.
|
|
230
215
|
*/
|
|
231
216
|
getServiceDetails(chainIds: Hex[]): Promise<ServiceDetailsResponse>;
|
|
232
|
-
/**
|
|
233
|
-
* Fetches the Money Account identities of the authenticated profile, with
|
|
234
|
-
* the status and migration steps CHOMP derives on every read. When funds
|
|
235
|
-
* transfer is the only missing step, CHOMP creates the transfer request as
|
|
236
|
-
* part of the read, after which the migration can no longer be cancelled.
|
|
237
|
-
*
|
|
238
|
-
* GET /v1/money-account/identities
|
|
239
|
-
*
|
|
240
|
-
* Profile-scoped and used to drive migrations, so it is always fetched
|
|
241
|
-
* fresh and keyed by a digest of the bearer token, like
|
|
242
|
-
* {@link ChompApiService.getAssociatedAddresses}.
|
|
243
|
-
*
|
|
244
|
-
* @returns The identities; empty when the profile has no Money Account.
|
|
245
|
-
* Addresses are lowercased.
|
|
246
|
-
*/
|
|
247
|
-
getDerivedIdentities(): Promise<DerivedIdentitiesResponse>;
|
|
248
|
-
/**
|
|
249
|
-
* Fetches the identity containing an address, along with where the address
|
|
250
|
-
* sits in it. The identity's `status` describes the whole chain. Like
|
|
251
|
-
* {@link ChompApiService.getDerivedIdentities}, this read can create the
|
|
252
|
-
* migration's funds-transfer request.
|
|
253
|
-
*
|
|
254
|
-
* GET /v1/money-account/identities/address/:address
|
|
255
|
-
*
|
|
256
|
-
* Always fetched fresh and keyed by a digest of the bearer token, like
|
|
257
|
-
* {@link ChompApiService.getDerivedIdentities}.
|
|
258
|
-
*
|
|
259
|
-
* @param address - The address to look up.
|
|
260
|
-
* @returns The identity and address details, or `null` when CHOMP responds
|
|
261
|
-
* with `ADDRESS_NOT_ASSOCIATED`: the address is not associated with the
|
|
262
|
-
* authenticated profile, or it is but belongs to no Money Account.
|
|
263
|
-
* Addresses are lowercased.
|
|
264
|
-
*/
|
|
265
|
-
getDerivedIdentityByAddress(address: Hex): Promise<AddressIdentityResponse | null>;
|
|
266
217
|
}
|
|
267
218
|
export {};
|
|
268
219
|
//# sourceMappingURL=chomp-api-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chomp-api-service.d.ts","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EACnC,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAc,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"chomp-api-service.d.ts","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EACnC,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;A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BAAgB,CACpB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,wBAAwB,CAAC,CA2BnC;IAED;;;;;;;OAOG;IACG,aAAa,CACjB,OAAO,EAAE,gBAAgB,EAAE,GAC1B,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAwB/B;IAED;;;;;;;;;;;OAWG;IACG,mBAAmB,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CA0B9D;IAED;;;;;;;;OAQG;IACG,gBAAgB,CACpB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,wBAAwB,CAAC,CAwBnC;IAED;;;;;;;;;OASG;IACG,iBAAiB,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAqBxE;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseDataService } from '@metamask/base-data-service';
|
|
2
2
|
import { handleWhen, HttpError } from '@metamask/controller-utils';
|
|
3
|
-
import { array, boolean, coerce, create, enums, literal,
|
|
3
|
+
import { array, boolean, coerce, create, enums, literal, number, optional, record, string, type, } from '@metamask/superstruct';
|
|
4
4
|
import { bytesToHex, hasProperty, isObject, sha256, stringToBytes, StrictHexStruct, } from '@metamask/utils';
|
|
5
5
|
const CHOMP_INTENT_TYPES = [
|
|
6
6
|
'cash-deposit',
|
|
@@ -9,17 +9,6 @@ const CHOMP_INTENT_TYPES = [
|
|
|
9
9
|
'cash-withdrawal-premium',
|
|
10
10
|
'cash-subscription',
|
|
11
11
|
];
|
|
12
|
-
const MIGRATION_STEPS = [
|
|
13
|
-
'SUCCESSOR_DEPOSIT_INTENT',
|
|
14
|
-
'SUCCESSOR_WITHDRAWAL_INTENT',
|
|
15
|
-
'SUCCESSOR_SUBSCRIPTION_INTENT',
|
|
16
|
-
'SUCCESSOR_MONITORED',
|
|
17
|
-
'ROOT_DELEGATION',
|
|
18
|
-
'TRANSFER_INTENT_MUSD',
|
|
19
|
-
'TRANSFER_INTENT_VMUSD',
|
|
20
|
-
'TRANSFER_INTENT_PVMUSD',
|
|
21
|
-
'FUNDS_TRANSFERRED',
|
|
22
|
-
];
|
|
23
12
|
function isChompIntentType(value) {
|
|
24
13
|
return CHOMP_INTENT_TYPES.includes(value);
|
|
25
14
|
}
|
|
@@ -75,7 +64,6 @@ async function createChompApiError(response, message) {
|
|
|
75
64
|
const MESSENGER_EXPOSED_METHODS = [
|
|
76
65
|
'createAddressChallenge',
|
|
77
66
|
'associateAddressV2',
|
|
78
|
-
'disassociateAddress',
|
|
79
67
|
'getAssociatedAddresses',
|
|
80
68
|
'createUpgrade',
|
|
81
69
|
'getUpgrades',
|
|
@@ -84,8 +72,6 @@ const MESSENGER_EXPOSED_METHODS = [
|
|
|
84
72
|
'getIntentsByAddress',
|
|
85
73
|
'createWithdrawal',
|
|
86
74
|
'getServiceDetails',
|
|
87
|
-
'getDerivedIdentities',
|
|
88
|
-
'getDerivedIdentityByAddress',
|
|
89
75
|
];
|
|
90
76
|
// === RESPONSE VALIDATION ===
|
|
91
77
|
const AssociateAddressResponseStruct = type({
|
|
@@ -110,37 +96,6 @@ const ProfileAddressEntryArrayStruct = array(type({
|
|
|
110
96
|
address: LowercaseHexAddressStruct,
|
|
111
97
|
status: enums(['active']),
|
|
112
98
|
}));
|
|
113
|
-
const MigrationTransferStruct = nullable(type({
|
|
114
|
-
requestId: string(),
|
|
115
|
-
status: string(),
|
|
116
|
-
}));
|
|
117
|
-
const DerivedIdentityStruct = type({
|
|
118
|
-
currentAddress: LowercaseHexAddressStruct,
|
|
119
|
-
previousAddresses: array(LowercaseHexAddressStruct),
|
|
120
|
-
status: enums(['NONE', 'MIGRATING', 'DONE']),
|
|
121
|
-
migration: nullable(type({
|
|
122
|
-
from: LowercaseHexAddressStruct,
|
|
123
|
-
to: LowercaseHexAddressStruct,
|
|
124
|
-
steps: array(type({
|
|
125
|
-
step: enums(MIGRATION_STEPS),
|
|
126
|
-
completed: boolean(),
|
|
127
|
-
})),
|
|
128
|
-
transfer: MigrationTransferStruct,
|
|
129
|
-
premiumTransfer: MigrationTransferStruct,
|
|
130
|
-
})),
|
|
131
|
-
});
|
|
132
|
-
const DerivedIdentitiesResponseStruct = type({
|
|
133
|
-
identities: array(DerivedIdentityStruct),
|
|
134
|
-
});
|
|
135
|
-
const AddressIdentityResponseStruct = type({
|
|
136
|
-
identity: DerivedIdentityStruct,
|
|
137
|
-
address: type({
|
|
138
|
-
address: LowercaseHexAddressStruct,
|
|
139
|
-
role: enums(['CURRENT', 'PREVIOUS', 'PENDING_SUCCESSOR']),
|
|
140
|
-
predecessor: nullable(LowercaseHexAddressStruct),
|
|
141
|
-
successor: nullable(LowercaseHexAddressStruct),
|
|
142
|
-
}),
|
|
143
|
-
});
|
|
144
99
|
const AccountUpgradeStatusStruct = enums(['pending', 'upgraded']);
|
|
145
100
|
const AuthorizationDataStruct = type({
|
|
146
101
|
r: StrictHexStruct,
|
|
@@ -284,21 +239,6 @@ export class ChompApiService extends BaseDataService {
|
|
|
284
239
|
'Content-Type': 'application/json',
|
|
285
240
|
};
|
|
286
241
|
}
|
|
287
|
-
/**
|
|
288
|
-
* Fetches the bearer token along with a SHA-256 digest of it, for query
|
|
289
|
-
* keys of profile-scoped requests. The digest, not the token, goes in the
|
|
290
|
-
* key because query keys leave the service via the `cacheUpdated`
|
|
291
|
-
* messenger events.
|
|
292
|
-
*
|
|
293
|
-
* @returns The bearer token and its digest.
|
|
294
|
-
*/
|
|
295
|
-
async #getProfileScopedToken() {
|
|
296
|
-
const token = await this.messenger.call('AuthenticationController:getBearerToken');
|
|
297
|
-
return {
|
|
298
|
-
token,
|
|
299
|
-
profileKey: bytesToHex(await sha256(stringToBytes(token))),
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
242
|
/**
|
|
303
243
|
* Builds the standard headers for an authenticated CHOMP API request.
|
|
304
244
|
*
|
|
@@ -380,37 +320,6 @@ export class ChompApiService extends BaseDataService {
|
|
|
380
320
|
});
|
|
381
321
|
return create(jsonResponse, AssociateAddressResponseStruct);
|
|
382
322
|
}
|
|
383
|
-
/**
|
|
384
|
-
* Removes an address association from the authenticated profile. For an
|
|
385
|
-
* address linked as a successor, this cancels the migration and unfreezes
|
|
386
|
-
* its predecessor. CHOMP rejects the cancellation with `LINK_COMPLETE` once
|
|
387
|
-
* a funds-transfer request exists for the link, which can happen before
|
|
388
|
-
* the migration is `DONE`.
|
|
389
|
-
*
|
|
390
|
-
* DELETE /v1/auth/address
|
|
391
|
-
*
|
|
392
|
-
* Executed as a mutation so it is never retried: a retry after a lost
|
|
393
|
-
* response would hit an already-removed address and fail with a 404.
|
|
394
|
-
*
|
|
395
|
-
* @param address - The address to disassociate.
|
|
396
|
-
*/
|
|
397
|
-
async disassociateAddress(address) {
|
|
398
|
-
await this.executeMutation({
|
|
399
|
-
mutationKey: [`${this.name}:disassociateAddress`],
|
|
400
|
-
mutationFn: async () => {
|
|
401
|
-
const headers = await this.#authHeaders();
|
|
402
|
-
const response = await fetch(new URL('/v1/auth/address', this.#baseUrl), {
|
|
403
|
-
method: 'DELETE',
|
|
404
|
-
headers,
|
|
405
|
-
body: JSON.stringify({ address }),
|
|
406
|
-
});
|
|
407
|
-
if (!response.ok) {
|
|
408
|
-
throw await createChompApiError(response, `DELETE /v1/auth/address failed with status '${response.status}'`);
|
|
409
|
-
}
|
|
410
|
-
return null;
|
|
411
|
-
},
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
323
|
/**
|
|
415
324
|
* Fetches the addresses associated with the authenticated profile.
|
|
416
325
|
*
|
|
@@ -429,7 +338,8 @@ export class ChompApiService extends BaseDataService {
|
|
|
429
338
|
* Addresses are lowercased.
|
|
430
339
|
*/
|
|
431
340
|
async getAssociatedAddresses() {
|
|
432
|
-
const
|
|
341
|
+
const token = await this.messenger.call('AuthenticationController:getBearerToken');
|
|
342
|
+
const profileKey = bytesToHex(await sha256(stringToBytes(token)));
|
|
433
343
|
const jsonResponse = await this.fetchQuery({
|
|
434
344
|
queryKey: [`${this.name}:getAssociatedAddresses`, profileKey],
|
|
435
345
|
staleTime: 0,
|
|
@@ -630,79 +540,5 @@ export class ChompApiService extends BaseDataService {
|
|
|
630
540
|
});
|
|
631
541
|
return create(jsonResponse, ServiceDetailsResponseStruct);
|
|
632
542
|
}
|
|
633
|
-
/**
|
|
634
|
-
* Fetches the Money Account identities of the authenticated profile, with
|
|
635
|
-
* the status and migration steps CHOMP derives on every read. When funds
|
|
636
|
-
* transfer is the only missing step, CHOMP creates the transfer request as
|
|
637
|
-
* part of the read, after which the migration can no longer be cancelled.
|
|
638
|
-
*
|
|
639
|
-
* GET /v1/money-account/identities
|
|
640
|
-
*
|
|
641
|
-
* Profile-scoped and used to drive migrations, so it is always fetched
|
|
642
|
-
* fresh and keyed by a digest of the bearer token, like
|
|
643
|
-
* {@link ChompApiService.getAssociatedAddresses}.
|
|
644
|
-
*
|
|
645
|
-
* @returns The identities; empty when the profile has no Money Account.
|
|
646
|
-
* Addresses are lowercased.
|
|
647
|
-
*/
|
|
648
|
-
async getDerivedIdentities() {
|
|
649
|
-
const { token, profileKey } = await this.#getProfileScopedToken();
|
|
650
|
-
const jsonResponse = await this.fetchQuery({
|
|
651
|
-
queryKey: [`${this.name}:getDerivedIdentities`, profileKey],
|
|
652
|
-
staleTime: 0,
|
|
653
|
-
gcTime: 0,
|
|
654
|
-
queryFn: async () => {
|
|
655
|
-
const response = await fetch(new URL('/v1/money-account/identities', this.#baseUrl), { headers: this.#headersForToken(token) });
|
|
656
|
-
if (!response.ok) {
|
|
657
|
-
throw await createChompApiError(response, `GET /v1/money-account/identities failed with status '${response.status}'`);
|
|
658
|
-
}
|
|
659
|
-
return response.json();
|
|
660
|
-
},
|
|
661
|
-
});
|
|
662
|
-
return create(jsonResponse, DerivedIdentitiesResponseStruct);
|
|
663
|
-
}
|
|
664
|
-
/**
|
|
665
|
-
* Fetches the identity containing an address, along with where the address
|
|
666
|
-
* sits in it. The identity's `status` describes the whole chain. Like
|
|
667
|
-
* {@link ChompApiService.getDerivedIdentities}, this read can create the
|
|
668
|
-
* migration's funds-transfer request.
|
|
669
|
-
*
|
|
670
|
-
* GET /v1/money-account/identities/address/:address
|
|
671
|
-
*
|
|
672
|
-
* Always fetched fresh and keyed by a digest of the bearer token, like
|
|
673
|
-
* {@link ChompApiService.getDerivedIdentities}.
|
|
674
|
-
*
|
|
675
|
-
* @param address - The address to look up.
|
|
676
|
-
* @returns The identity and address details, or `null` when CHOMP responds
|
|
677
|
-
* with `ADDRESS_NOT_ASSOCIATED`: the address is not associated with the
|
|
678
|
-
* authenticated profile, or it is but belongs to no Money Account.
|
|
679
|
-
* Addresses are lowercased.
|
|
680
|
-
*/
|
|
681
|
-
async getDerivedIdentityByAddress(address) {
|
|
682
|
-
const { token, profileKey } = await this.#getProfileScopedToken();
|
|
683
|
-
const jsonResponse = await this.fetchQuery({
|
|
684
|
-
queryKey: [
|
|
685
|
-
`${this.name}:getDerivedIdentityByAddress`,
|
|
686
|
-
profileKey,
|
|
687
|
-
address,
|
|
688
|
-
],
|
|
689
|
-
staleTime: 0,
|
|
690
|
-
gcTime: 0,
|
|
691
|
-
queryFn: async () => {
|
|
692
|
-
const response = await fetch(new URL(`/v1/money-account/identities/address/${address}`, this.#baseUrl), { headers: this.#headersForToken(token) });
|
|
693
|
-
if (!response.ok) {
|
|
694
|
-
const error = await createChompApiError(response, `GET /v1/money-account/identities/address/${address} failed with status '${response.status}'`);
|
|
695
|
-
if (error.code === 'ADDRESS_NOT_ASSOCIATED') {
|
|
696
|
-
return null;
|
|
697
|
-
}
|
|
698
|
-
throw error;
|
|
699
|
-
}
|
|
700
|
-
return response.json();
|
|
701
|
-
},
|
|
702
|
-
});
|
|
703
|
-
return jsonResponse === null
|
|
704
|
-
? null
|
|
705
|
-
: create(jsonResponse, AddressIdentityResponseStruct);
|
|
706
|
-
}
|
|
707
543
|
}
|
|
708
544
|
//# sourceMappingURL=chomp-api-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-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C;SACF,CAAC,CAAC;QAEH,OAAO,YAAY,KAAK,IAAI;YAC1B,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,MAAM,CAAC,YAAY,EAAE,6BAA6B,CAAC,CAAC;IAC1D,CAAC;CACF","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 { handleWhen, HttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport {\n array,\n boolean,\n coerce,\n create,\n enums,\n literal,\n nullable,\n number,\n optional,\n record,\n string,\n type,\n} from '@metamask/superstruct';\nimport type { Hex } from '@metamask/utils';\nimport {\n bytesToHex,\n hasProperty,\n isObject,\n sha256,\n stringToBytes,\n StrictHexStruct,\n} from '@metamask/utils';\nimport type { QueryClientConfig } from '@tanstack/query-core';\n\nimport type { ChompApiServiceMethodActions } from './chomp-api-service-method-action-types.js';\nimport type {\n AddressIdentityResponse,\n AssociateAddressResponse,\n AssociateAddressV2Params,\n CreateAddressChallengeParams,\n CreateAddressChallengeResponse,\n ProfileAddressEntry,\n ChompIntentType,\n CreateUpgradeParams,\n CreateUpgradeResponse,\n UpgradeEntry,\n CreateWithdrawalParams,\n CreateWithdrawalResponse,\n DerivedIdentitiesResponse,\n IntentEntry,\n MigrationStep,\n SendIntentParams,\n SendIntentResponse,\n ServiceDetailsResponse,\n VerifyDelegationParams,\n VerifyDelegationResponse,\n} from './types.js';\n\nconst CHOMP_INTENT_TYPES: ChompIntentType[] = [\n 'cash-deposit',\n 'cash-withdrawal',\n 'cash-deposit-premium',\n 'cash-withdrawal-premium',\n 'cash-subscription',\n];\n\nconst MIGRATION_STEPS: MigrationStep[] = [\n 'SUCCESSOR_DEPOSIT_INTENT',\n 'SUCCESSOR_WITHDRAWAL_INTENT',\n 'SUCCESSOR_SUBSCRIPTION_INTENT',\n 'SUCCESSOR_MONITORED',\n 'ROOT_DELEGATION',\n 'TRANSFER_INTENT_MUSD',\n 'TRANSFER_INTENT_VMUSD',\n 'TRANSFER_INTENT_PVMUSD',\n 'FUNDS_TRANSFERRED',\n];\n\nfunction isChompIntentType(value: string): value is ChompIntentType {\n return (CHOMP_INTENT_TYPES as string[]).includes(value);\n}\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// === ERRORS ===\n\n/**\n * Thrown when the CHOMP API responds with a non-2xx status.\n */\nexport class ChompApiError extends HttpError {\n /**\n * The CHOMP error code from the response body (e.g.\n * `PREDECESSOR_HAS_OPEN_WITHDRAWALS`), if one was provided.\n */\n readonly code: string | undefined;\n\n /**\n * Construct a CHOMP API error.\n *\n * @param status - The HTTP response status.\n * @param message - The error message.\n * @param code - The CHOMP error code from the response body.\n */\n constructor(status: number, message: string, code?: string) {\n super(status, message);\n this.name = 'ChompApiError';\n this.code = code;\n }\n}\n\n/**\n * Builds a {@link ChompApiError} from a non-2xx response, reading the CHOMP\n * error code from the response body when there is one.\n *\n * @param response - The non-2xx response.\n * @param message - The error message.\n * @returns The error to throw.\n */\nasync function createChompApiError(\n response: Response,\n message: string,\n): Promise<ChompApiError> {\n const body: unknown = await response.json().catch(() => undefined);\n const code =\n isObject(body) && hasProperty(body, 'code') && typeof body.code === 'string'\n ? body.code\n : undefined;\n return new ChompApiError(response.status, message, code);\n}\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 'createAddressChallenge',\n 'associateAddressV2',\n 'disassociateAddress',\n 'getAssociatedAddresses',\n 'createUpgrade',\n 'getUpgrades',\n 'verifyDelegation',\n 'createIntents',\n 'getIntentsByAddress',\n 'createWithdrawal',\n 'getServiceDetails',\n 'getDerivedIdentities',\n 'getDerivedIdentityByAddress',\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: optional(string()),\n address: StrictHexStruct,\n status: enums(['active', 'created']),\n});\n\nconst CreateAddressChallengeResponseStruct = type({\n challengeId: string(),\n message: string(),\n expiresAt: string(),\n});\n\n/**\n * Parses addresses into canonical lowercase form. CHOMP stores and returns\n * addresses lowercased, but `StrictHexStruct` alone accepts any casing, so\n * this makes the canonical form a guarantee of the parsed data rather than a\n * convention consumers must each remember.\n */\nconst LowercaseHexAddressStruct = coerce(StrictHexStruct, string(), (value) =>\n value.toLowerCase(),\n);\n\nconst ProfileAddressEntryArrayStruct = array(\n type({\n profileId: string(),\n address: LowercaseHexAddressStruct,\n status: enums(['active']),\n }),\n);\n\nconst MigrationTransferStruct = nullable(\n type({\n requestId: string(),\n status: string(),\n }),\n);\n\nconst DerivedIdentityStruct = type({\n currentAddress: LowercaseHexAddressStruct,\n previousAddresses: array(LowercaseHexAddressStruct),\n status: enums(['NONE', 'MIGRATING', 'DONE']),\n migration: nullable(\n type({\n from: LowercaseHexAddressStruct,\n to: LowercaseHexAddressStruct,\n steps: array(\n type({\n step: enums(MIGRATION_STEPS),\n completed: boolean(),\n }),\n ),\n transfer: MigrationTransferStruct,\n premiumTransfer: MigrationTransferStruct,\n }),\n ),\n});\n\nconst DerivedIdentitiesResponseStruct = type({\n identities: array(DerivedIdentityStruct),\n});\n\nconst AddressIdentityResponseStruct = type({\n identity: DerivedIdentityStruct,\n address: type({\n address: LowercaseHexAddressStruct,\n role: enums(['CURRENT', 'PREVIOUS', 'PENDING_SUCCESSOR']),\n predecessor: nullable(LowercaseHexAddressStruct),\n successor: nullable(LowercaseHexAddressStruct),\n }),\n});\n\nconst AccountUpgradeStatusStruct = enums(['pending', 'upgraded']);\n\nconst AuthorizationDataStruct = type({\n r: StrictHexStruct,\n s: StrictHexStruct,\n v: number(),\n yParity: number(),\n address: StrictHexStruct,\n chainId: StrictHexStruct,\n nonce: StrictHexStruct,\n});\n\nconst CreateUpgradeResponseStruct = type({\n signerAddress: StrictHexStruct,\n address: StrictHexStruct,\n chainId: StrictHexStruct,\n nonce: StrictHexStruct,\n status: AccountUpgradeStatusStruct,\n createdAt: string(),\n});\n\nconst UpgradeEntryArrayStruct = array(\n type({\n signerAddress: StrictHexStruct,\n chainId: StrictHexStruct,\n nonce: StrictHexStruct,\n authorization: AuthorizationDataStruct,\n status: AccountUpgradeStatusStruct,\n createdAt: string(),\n }),\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(CHOMP_INTENT_TYPES),\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: string(),\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: coerce(\n array(enums(CHOMP_INTENT_TYPES)),\n array(string()),\n (intentTypes) => intentTypes.filter(isChompIntentType),\n ),\n});\n\nconst ServiceDetailsResponseStruct = type({\n auth: type({\n message: string(),\n }),\n chains: record(\n StrictHexStruct,\n type({\n autoDepositDelegate: StrictHexStruct,\n protocol: type({\n vedaProtocol: ServiceDetailsProtocolStruct,\n vedaPremiumProtocol: optional(ServiceDetailsProtocolStruct),\n }),\n }),\n ),\n});\n\n// === RETRY POLICY ===\n\n/**\n * Determines whether an error from a CHOMP API call is worth retrying.\n *\n * 4xx responses (e.g. 409 \"already exists\", 400 validation, 401/403 auth) are\n * caused by the request itself and will not be resolved by re-issuing the same\n * request, so they bypass the retry loop. 429 is treated as transient and\n * retried alongside 5xx server errors. Non-HTTP errors (network/timeout) fall\n * through to the default \"retry\" behaviour.\n *\n * @param error - The error thrown by the query function.\n * @returns `true` when the error is worth retrying.\n */\nfunction isRetryableError(error: unknown): boolean {\n if (error instanceof HttpError) {\n if (error.httpStatus === 429) {\n return true;\n }\n return error.httpStatus < 400 || error.httpStatus >= 500;\n }\n return true;\n}\n\nconst DEFAULT_POLICY_OPTIONS: CreateServicePolicyOptions = {\n retryFilterPolicy: handleWhen(isRetryableError),\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: { ...DEFAULT_POLICY_OPTIONS, ...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 a CHOMP API request authenticated with\n * the given bearer token.\n *\n * @param token - The bearer token to authenticate with.\n * @returns Headers including Authorization and Content-Type.\n */\n #headersForToken(token: string): Record<string, string> {\n return {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n };\n }\n\n /**\n * Fetches the bearer token along with a SHA-256 digest of it, for query\n * keys of profile-scoped requests. The digest, not the token, goes in the\n * key because query keys leave the service via the `cacheUpdated`\n * messenger events.\n *\n * @returns The bearer token and its digest.\n */\n async #getProfileScopedToken(): Promise<{\n token: string;\n profileKey: Hex;\n }> {\n const token = await this.messenger.call(\n 'AuthenticationController:getBearerToken',\n );\n return {\n token,\n profileKey: bytesToHex(await sha256(stringToBytes(token))),\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 this.#headersForToken(token);\n }\n\n /**\n * Requests a single-use challenge for associating an address through the v2\n * flow. Sign the returned `message` exactly as received, using\n * `personal_sign` with the address being associated, then submit it with\n * {@link ChompApiService.associateAddressV2} before `expiresAt`. Requesting\n * a new challenge for the same address replaces the previous one.\n *\n * POST /v2/auth/address/challenge\n *\n * Each call issues a new challenge, so the result is never cached.\n *\n * @param params - The address to associate and the association purpose.\n * `ASSOCIATE_SUCCESSOR` also requires the predecessor address.\n * @returns The challenge ID, the message to sign, and when it expires.\n */\n async createAddressChallenge(\n params: CreateAddressChallengeParams,\n ): Promise<CreateAddressChallengeResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createAddressChallenge`, params],\n staleTime: 0,\n gcTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL('/v2/auth/address/challenge', this.#baseUrl),\n {\n method: 'POST',\n headers,\n body: JSON.stringify(params),\n },\n );\n\n if (!response.ok) {\n throw await createChompApiError(\n response,\n `POST /v2/auth/address/challenge failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, CreateAddressChallengeResponseStruct);\n }\n\n /**\n * Associates an address with a CHOMP profile by submitting the signature of\n * a challenge from {@link ChompApiService.createAddressChallenge}. The\n * address, purpose and predecessor come from the challenge. For\n * `ASSOCIATE_SUCCESSOR`, the association and the link to the predecessor\n * are written atomically.\n *\n * POST /v2/auth/address\n *\n * @param params - The challenge ID and its signature.\n * @returns The profile association result: `status: 'created'` when the\n * association or link was written, `status: 'active'` when the address was\n * already associated with the authenticated profile. Throws on 400\n * `CHALLENGE_INVALID_OR_EXPIRED` (request a new challenge), on 409 when the\n * address is associated with a different profile, and on link validation\n * errors.\n */\n async associateAddressV2(\n params: AssociateAddressV2Params,\n ): Promise<AssociateAddressResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:associateAddressV2`, params],\n staleTime: 0,\n gcTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL('/v2/auth/address', this.#baseUrl),\n {\n method: 'POST',\n headers,\n body: JSON.stringify(params),\n },\n );\n\n if (!response.ok) {\n throw await createChompApiError(\n response,\n `POST /v2/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 * Removes an address association from the authenticated profile. For an\n * address linked as a successor, this cancels the migration and unfreezes\n * its predecessor. CHOMP rejects the cancellation with `LINK_COMPLETE` once\n * a funds-transfer request exists for the link, which can happen before\n * the migration is `DONE`.\n *\n * DELETE /v1/auth/address\n *\n * Executed as a mutation so it is never retried: a retry after a lost\n * response would hit an already-removed address and fail with a 404.\n *\n * @param address - The address to disassociate.\n */\n async disassociateAddress(address: Hex): Promise<void> {\n await this.executeMutation({\n mutationKey: [`${this.name}:disassociateAddress`],\n mutationFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL('/v1/auth/address', this.#baseUrl),\n {\n method: 'DELETE',\n headers,\n body: JSON.stringify({ address }),\n },\n );\n\n if (!response.ok) {\n throw await createChompApiError(\n response,\n `DELETE /v1/auth/address failed with status '${response.status}'`,\n );\n }\n\n return null;\n },\n });\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\n * to decide whether an association already exists, so it is always fetched\n * fresh (`staleTime: 0`) and evicted as soon as the call settles\n * (`gcTime: 0`). The query key carries a SHA-256 digest of the bearer\n * token — the same token the request is made with — so concurrent calls\n * only share an in-flight request when they are for the same profile. The\n * digest, not the token, is used because query keys leave the service via\n * the `cacheUpdated` messenger events.\n *\n * @returns The active address associations; empty array if none exist.\n * Addresses are lowercased.\n */\n async getAssociatedAddresses(): Promise<ProfileAddressEntry[]> {\n const { token, profileKey } = await this.#getProfileScopedToken();\n\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getAssociatedAddresses`, profileKey],\n staleTime: 0,\n gcTime: 0,\n queryFn: async () => {\n const response = await fetch(\n new URL('/v1/auth/address', this.#baseUrl),\n { headers: this.#headersForToken(token) },\n );\n\n if (!response.ok) {\n throw await createChompApiError(\n response,\n `GET /v1/auth/address failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, ProfileAddressEntryArrayStruct);\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(\n params: CreateUpgradeParams,\n ): Promise<CreateUpgradeResponse> {\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 await createChompApiError(\n response,\n `POST /v1/account-upgrade failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, CreateUpgradeResponseStruct);\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 */\n async getUpgrades(address: Hex): Promise<UpgradeEntry[]> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getUpgrades`, 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.ok) {\n throw await createChompApiError(\n response,\n `Get upgrades request failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, UpgradeEntryArrayStruct);\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 await createChompApiError(\n response,\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 await createChompApiError(\n response,\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 * Callers use the result to decide whether an intent already exists, so it\n * is always fetched fresh (`staleTime: 0`).\n *\n * @param address - The address to look up intents for.\n * @returns The array of intents for the address, omitting any with an\n * intent type this service does not recognise.\n */\n async getIntentsByAddress(address: Hex): Promise<IntentEntry[]> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getIntentsByAddress`, address],\n staleTime: 0,\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 await createChompApiError(\n response,\n `Get intents request failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, IntentEntryArrayStruct).filter(\n (intent): intent is IntentEntry =>\n isChompIntentType(intent.metadata.type),\n );\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 await createChompApiError(\n response,\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 await createChompApiError(\n response,\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 /**\n * Fetches the Money Account identities of the authenticated profile, with\n * the status and migration steps CHOMP derives on every read. When funds\n * transfer is the only missing step, CHOMP creates the transfer request as\n * part of the read, after which the migration can no longer be cancelled.\n *\n * GET /v1/money-account/identities\n *\n * Profile-scoped and used to drive migrations, so it is always fetched\n * fresh and keyed by a digest of the bearer token, like\n * {@link ChompApiService.getAssociatedAddresses}.\n *\n * @returns The identities; empty when the profile has no Money Account.\n * Addresses are lowercased.\n */\n async getDerivedIdentities(): Promise<DerivedIdentitiesResponse> {\n const { token, profileKey } = await this.#getProfileScopedToken();\n\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getDerivedIdentities`, profileKey],\n staleTime: 0,\n gcTime: 0,\n queryFn: async () => {\n const response = await fetch(\n new URL('/v1/money-account/identities', this.#baseUrl),\n { headers: this.#headersForToken(token) },\n );\n\n if (!response.ok) {\n throw await createChompApiError(\n response,\n `GET /v1/money-account/identities failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, DerivedIdentitiesResponseStruct);\n }\n\n /**\n * Fetches the identity containing an address, along with where the address\n * sits in it. The identity's `status` describes the whole chain. Like\n * {@link ChompApiService.getDerivedIdentities}, this read can create the\n * migration's funds-transfer request.\n *\n * GET /v1/money-account/identities/address/:address\n *\n * Always fetched fresh and keyed by a digest of the bearer token, like\n * {@link ChompApiService.getDerivedIdentities}.\n *\n * @param address - The address to look up.\n * @returns The identity and address details, or `null` when CHOMP responds\n * with `ADDRESS_NOT_ASSOCIATED`: the address is not associated with the\n * authenticated profile, or it is but belongs to no Money Account.\n * Addresses are lowercased.\n */\n async getDerivedIdentityByAddress(\n address: Hex,\n ): Promise<AddressIdentityResponse | null> {\n const { token, profileKey } = await this.#getProfileScopedToken();\n\n const jsonResponse = await this.fetchQuery({\n queryKey: [\n `${this.name}:getDerivedIdentityByAddress`,\n profileKey,\n address,\n ],\n staleTime: 0,\n gcTime: 0,\n queryFn: async () => {\n const response = await fetch(\n new URL(\n `/v1/money-account/identities/address/${address}`,\n this.#baseUrl,\n ),\n { headers: this.#headersForToken(token) },\n );\n\n if (!response.ok) {\n const error = await createChompApiError(\n response,\n `GET /v1/money-account/identities/address/${address} failed with status '${response.status}'`,\n );\n if (error.code === 'ADDRESS_NOT_ASSOCIATED') {\n return null;\n }\n throw error;\n }\n\n return response.json();\n },\n });\n\n return jsonResponse === null\n ? null\n : create(jsonResponse, AddressIdentityResponseStruct);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chomp-api-service.js","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAO9D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,MAAM,EACN,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,IAAI,GACL,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,UAAU,EACV,WAAW,EACX,QAAQ,EACR,MAAM,EACN,aAAa,EACb,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAwBzB,MAAM,kBAAkB,GAAsB;IAC5C,cAAc;IACd,iBAAiB;IACjB,sBAAsB;IACtB,yBAAyB;IACzB,mBAAmB;CACpB,CAAC;AAEF,SAAS,iBAAiB,CAAC,KAAa;IACtC,OAAQ,kBAA+B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED,kBAAkB;AAElB;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAE7C,iBAAiB;AAEjB;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C;;;OAGG;IACM,IAAI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ACJ,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","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 { handleWhen, HttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport {\n array,\n boolean,\n coerce,\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 {\n bytesToHex,\n hasProperty,\n isObject,\n sha256,\n stringToBytes,\n StrictHexStruct,\n} from '@metamask/utils';\nimport type { QueryClientConfig } from '@tanstack/query-core';\n\nimport type { ChompApiServiceMethodActions } from './chomp-api-service-method-action-types.js';\nimport type {\n AssociateAddressResponse,\n AssociateAddressV2Params,\n CreateAddressChallengeParams,\n CreateAddressChallengeResponse,\n ProfileAddressEntry,\n ChompIntentType,\n CreateUpgradeParams,\n CreateUpgradeResponse,\n UpgradeEntry,\n CreateWithdrawalParams,\n CreateWithdrawalResponse,\n IntentEntry,\n SendIntentParams,\n SendIntentResponse,\n ServiceDetailsResponse,\n VerifyDelegationParams,\n VerifyDelegationResponse,\n} from './types.js';\n\nconst CHOMP_INTENT_TYPES: ChompIntentType[] = [\n 'cash-deposit',\n 'cash-withdrawal',\n 'cash-deposit-premium',\n 'cash-withdrawal-premium',\n 'cash-subscription',\n];\n\nfunction isChompIntentType(value: string): value is ChompIntentType {\n return (CHOMP_INTENT_TYPES as string[]).includes(value);\n}\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// === ERRORS ===\n\n/**\n * Thrown when the CHOMP API responds with a non-2xx status.\n */\nexport class ChompApiError extends HttpError {\n /**\n * The CHOMP error code from the response body (e.g.\n * `PREDECESSOR_HAS_OPEN_WITHDRAWALS`), if one was provided.\n */\n readonly code: string | undefined;\n\n /**\n * Construct a CHOMP API error.\n *\n * @param status - The HTTP response status.\n * @param message - The error message.\n * @param code - The CHOMP error code from the response body.\n */\n constructor(status: number, message: string, code?: string) {\n super(status, message);\n this.name = 'ChompApiError';\n this.code = code;\n }\n}\n\n/**\n * Builds a {@link ChompApiError} from a non-2xx response, reading the CHOMP\n * error code from the response body when there is one.\n *\n * @param response - The non-2xx response.\n * @param message - The error message.\n * @returns The error to throw.\n */\nasync function createChompApiError(\n response: Response,\n message: string,\n): Promise<ChompApiError> {\n const body: unknown = await response.json().catch(() => undefined);\n const code =\n isObject(body) && hasProperty(body, 'code') && typeof body.code === 'string'\n ? body.code\n : undefined;\n return new ChompApiError(response.status, message, code);\n}\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 'createAddressChallenge',\n 'associateAddressV2',\n 'getAssociatedAddresses',\n 'createUpgrade',\n 'getUpgrades',\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: optional(string()),\n address: StrictHexStruct,\n status: enums(['active', 'created']),\n});\n\nconst CreateAddressChallengeResponseStruct = type({\n challengeId: string(),\n message: string(),\n expiresAt: string(),\n});\n\n/**\n * Parses addresses into canonical lowercase form. CHOMP stores and returns\n * addresses lowercased, but `StrictHexStruct` alone accepts any casing, so\n * this makes the canonical form a guarantee of the parsed data rather than a\n * convention consumers must each remember.\n */\nconst LowercaseHexAddressStruct = coerce(StrictHexStruct, string(), (value) =>\n value.toLowerCase(),\n);\n\nconst ProfileAddressEntryArrayStruct = array(\n type({\n profileId: string(),\n address: LowercaseHexAddressStruct,\n status: enums(['active']),\n }),\n);\n\nconst AccountUpgradeStatusStruct = enums(['pending', 'upgraded']);\n\nconst AuthorizationDataStruct = type({\n r: StrictHexStruct,\n s: StrictHexStruct,\n v: number(),\n yParity: number(),\n address: StrictHexStruct,\n chainId: StrictHexStruct,\n nonce: StrictHexStruct,\n});\n\nconst CreateUpgradeResponseStruct = type({\n signerAddress: StrictHexStruct,\n address: StrictHexStruct,\n chainId: StrictHexStruct,\n nonce: StrictHexStruct,\n status: AccountUpgradeStatusStruct,\n createdAt: string(),\n});\n\nconst UpgradeEntryArrayStruct = array(\n type({\n signerAddress: StrictHexStruct,\n chainId: StrictHexStruct,\n nonce: StrictHexStruct,\n authorization: AuthorizationDataStruct,\n status: AccountUpgradeStatusStruct,\n createdAt: string(),\n }),\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(CHOMP_INTENT_TYPES),\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: string(),\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: coerce(\n array(enums(CHOMP_INTENT_TYPES)),\n array(string()),\n (intentTypes) => intentTypes.filter(isChompIntentType),\n ),\n});\n\nconst ServiceDetailsResponseStruct = type({\n auth: type({\n message: string(),\n }),\n chains: record(\n StrictHexStruct,\n type({\n autoDepositDelegate: StrictHexStruct,\n protocol: type({\n vedaProtocol: ServiceDetailsProtocolStruct,\n vedaPremiumProtocol: optional(ServiceDetailsProtocolStruct),\n }),\n }),\n ),\n});\n\n// === RETRY POLICY ===\n\n/**\n * Determines whether an error from a CHOMP API call is worth retrying.\n *\n * 4xx responses (e.g. 409 \"already exists\", 400 validation, 401/403 auth) are\n * caused by the request itself and will not be resolved by re-issuing the same\n * request, so they bypass the retry loop. 429 is treated as transient and\n * retried alongside 5xx server errors. Non-HTTP errors (network/timeout) fall\n * through to the default \"retry\" behaviour.\n *\n * @param error - The error thrown by the query function.\n * @returns `true` when the error is worth retrying.\n */\nfunction isRetryableError(error: unknown): boolean {\n if (error instanceof HttpError) {\n if (error.httpStatus === 429) {\n return true;\n }\n return error.httpStatus < 400 || error.httpStatus >= 500;\n }\n return true;\n}\n\nconst DEFAULT_POLICY_OPTIONS: CreateServicePolicyOptions = {\n retryFilterPolicy: handleWhen(isRetryableError),\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: { ...DEFAULT_POLICY_OPTIONS, ...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 a CHOMP API request authenticated with\n * the given bearer token.\n *\n * @param token - The bearer token to authenticate with.\n * @returns Headers including Authorization and Content-Type.\n */\n #headersForToken(token: string): Record<string, string> {\n return {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\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 this.#headersForToken(token);\n }\n\n /**\n * Requests a single-use challenge for associating an address through the v2\n * flow. Sign the returned `message` exactly as received, using\n * `personal_sign` with the address being associated, then submit it with\n * {@link ChompApiService.associateAddressV2} before `expiresAt`. Requesting\n * a new challenge for the same address replaces the previous one.\n *\n * POST /v2/auth/address/challenge\n *\n * Each call issues a new challenge, so the result is never cached.\n *\n * @param params - The address to associate and the association purpose.\n * `ASSOCIATE_SUCCESSOR` also requires the predecessor address.\n * @returns The challenge ID, the message to sign, and when it expires.\n */\n async createAddressChallenge(\n params: CreateAddressChallengeParams,\n ): Promise<CreateAddressChallengeResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createAddressChallenge`, params],\n staleTime: 0,\n gcTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL('/v2/auth/address/challenge', this.#baseUrl),\n {\n method: 'POST',\n headers,\n body: JSON.stringify(params),\n },\n );\n\n if (!response.ok) {\n throw await createChompApiError(\n response,\n `POST /v2/auth/address/challenge failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, CreateAddressChallengeResponseStruct);\n }\n\n /**\n * Associates an address with a CHOMP profile by submitting the signature of\n * a challenge from {@link ChompApiService.createAddressChallenge}. The\n * address, purpose and predecessor come from the challenge. For\n * `ASSOCIATE_SUCCESSOR`, the association and the link to the predecessor\n * are written atomically.\n *\n * POST /v2/auth/address\n *\n * @param params - The challenge ID and its signature.\n * @returns The profile association result: `status: 'created'` when the\n * association or link was written, `status: 'active'` when the address was\n * already associated with the authenticated profile. Throws on 400\n * `CHALLENGE_INVALID_OR_EXPIRED` (request a new challenge), on 409 when the\n * address is associated with a different profile, and on link validation\n * errors.\n */\n async associateAddressV2(\n params: AssociateAddressV2Params,\n ): Promise<AssociateAddressResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:associateAddressV2`, params],\n staleTime: 0,\n gcTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL('/v2/auth/address', this.#baseUrl),\n {\n method: 'POST',\n headers,\n body: JSON.stringify(params),\n },\n );\n\n if (!response.ok) {\n throw await createChompApiError(\n response,\n `POST /v2/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 * 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\n * to decide whether an association already exists, so it is always fetched\n * fresh (`staleTime: 0`) and evicted as soon as the call settles\n * (`gcTime: 0`). The query key carries a SHA-256 digest of the bearer\n * token — the same token the request is made with — so concurrent calls\n * only share an in-flight request when they are for the same profile. The\n * digest, not the token, is used because query keys leave the service via\n * the `cacheUpdated` messenger events.\n *\n * @returns The active address associations; empty array if none exist.\n * Addresses are lowercased.\n */\n async getAssociatedAddresses(): Promise<ProfileAddressEntry[]> {\n const token = await this.messenger.call(\n 'AuthenticationController:getBearerToken',\n );\n const profileKey = bytesToHex(await sha256(stringToBytes(token)));\n\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getAssociatedAddresses`, profileKey],\n staleTime: 0,\n gcTime: 0,\n queryFn: async () => {\n const response = await fetch(\n new URL('/v1/auth/address', this.#baseUrl),\n { headers: this.#headersForToken(token) },\n );\n\n if (!response.ok) {\n throw await createChompApiError(\n response,\n `GET /v1/auth/address failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, ProfileAddressEntryArrayStruct);\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(\n params: CreateUpgradeParams,\n ): Promise<CreateUpgradeResponse> {\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 await createChompApiError(\n response,\n `POST /v1/account-upgrade failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, CreateUpgradeResponseStruct);\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 */\n async getUpgrades(address: Hex): Promise<UpgradeEntry[]> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getUpgrades`, 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.ok) {\n throw await createChompApiError(\n response,\n `Get upgrades request failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, UpgradeEntryArrayStruct);\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 await createChompApiError(\n response,\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 await createChompApiError(\n response,\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 * Callers use the result to decide whether an intent already exists, so it\n * is always fetched fresh (`staleTime: 0`).\n *\n * @param address - The address to look up intents for.\n * @returns The array of intents for the address, omitting any with an\n * intent type this service does not recognise.\n */\n async getIntentsByAddress(address: Hex): Promise<IntentEntry[]> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getIntentsByAddress`, address],\n staleTime: 0,\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 await createChompApiError(\n response,\n `Get intents request failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, IntentEntryArrayStruct).filter(\n (intent): intent is IntentEntry =>\n isChompIntentType(intent.metadata.type),\n );\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 await createChompApiError(\n response,\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 await createChompApiError(\n response,\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"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ChompApiError, ChompApiService } from './chomp-api-service.js';
|
|
2
2
|
export type { ChompApiServiceMessenger, ChompApiServiceActions, ChompApiServiceEvents, ChompApiServiceInvalidateQueriesAction, ChompApiServiceCacheUpdatedEvent, ChompApiServiceGranularCacheUpdatedEvent, } from './chomp-api-service.js';
|
|
3
|
-
export type { ChompApiServiceAssociateAddressV2Action, ChompApiServiceCreateAddressChallengeAction,
|
|
4
|
-
export type { AccountUpgradeStatus,
|
|
3
|
+
export type { ChompApiServiceAssociateAddressV2Action, ChompApiServiceCreateAddressChallengeAction, ChompApiServiceGetAssociatedAddressesAction, ChompApiServiceCreateUpgradeAction, ChompApiServiceGetUpgradesAction, ChompApiServiceVerifyDelegationAction, ChompApiServiceCreateIntentsAction, ChompApiServiceGetIntentsByAddressAction, ChompApiServiceCreateWithdrawalAction, ChompApiServiceGetServiceDetailsAction, } from './chomp-api-service-method-action-types.js';
|
|
4
|
+
export type { AccountUpgradeStatus, AssociateAddressResponse, AssociateAddressV2Params, AssociationPurpose, AuthorizationData, ChompIntentType, CreateAddressChallengeParams, CreateAddressChallengeResponse, CreateUpgradeParams, CreateUpgradeResponse, CreateWithdrawalParams, CreateWithdrawalResponse, DelegationCaveat, UpgradeEntry, IntentEntry, IntentMetadataParams, IntentMetadataResponse, ProfileAddressEntry, SendIntentParams, SendIntentResponse, ServiceDetailsChain, ServiceDetailsProtocol, ServiceDetailsResponse, ServiceDetailsSupportedToken, SignedDelegation, VerifyDelegationParams, VerifyDelegationResponse, } from './types.js';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACxE,YAAY,EACV,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,sCAAsC,EACtC,gCAAgC,EAChC,wCAAwC,GACzC,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,uCAAuC,EACvC,2CAA2C,EAC3C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACxE,YAAY,EACV,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,sCAAsC,EACtC,gCAAgC,EAChC,wCAAwC,GACzC,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,uCAAuC,EACvC,2CAA2C,EAC3C,2CAA2C,EAC3C,kCAAkC,EAClC,gCAAgC,EAChC,qCAAqC,EACrC,kCAAkC,EAClC,wCAAwC,EACxC,qCAAqC,EACrC,sCAAsC,GACvC,MAAM,4CAA4C,CAAC;AACpD,YAAY,EACV,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,4BAA4B,EAC5B,8BAA8B,EAC9B,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { ChompApiError, ChompApiService } from './chomp-api-service.js';\nexport type {\n ChompApiServiceMessenger,\n ChompApiServiceActions,\n ChompApiServiceEvents,\n ChompApiServiceInvalidateQueriesAction,\n ChompApiServiceCacheUpdatedEvent,\n ChompApiServiceGranularCacheUpdatedEvent,\n} from './chomp-api-service.js';\nexport type {\n ChompApiServiceAssociateAddressV2Action,\n ChompApiServiceCreateAddressChallengeAction,\n
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { ChompApiError, ChompApiService } from './chomp-api-service.js';\nexport type {\n ChompApiServiceMessenger,\n ChompApiServiceActions,\n ChompApiServiceEvents,\n ChompApiServiceInvalidateQueriesAction,\n ChompApiServiceCacheUpdatedEvent,\n ChompApiServiceGranularCacheUpdatedEvent,\n} from './chomp-api-service.js';\nexport type {\n ChompApiServiceAssociateAddressV2Action,\n ChompApiServiceCreateAddressChallengeAction,\n ChompApiServiceGetAssociatedAddressesAction,\n ChompApiServiceCreateUpgradeAction,\n ChompApiServiceGetUpgradesAction,\n ChompApiServiceVerifyDelegationAction,\n ChompApiServiceCreateIntentsAction,\n ChompApiServiceGetIntentsByAddressAction,\n ChompApiServiceCreateWithdrawalAction,\n ChompApiServiceGetServiceDetailsAction,\n} from './chomp-api-service-method-action-types.js';\nexport type {\n AccountUpgradeStatus,\n AssociateAddressResponse,\n AssociateAddressV2Params,\n AssociationPurpose,\n AuthorizationData,\n ChompIntentType,\n CreateAddressChallengeParams,\n CreateAddressChallengeResponse,\n CreateUpgradeParams,\n CreateUpgradeResponse,\n CreateWithdrawalParams,\n CreateWithdrawalResponse,\n DelegationCaveat,\n UpgradeEntry,\n IntentEntry,\n IntentMetadataParams,\n IntentMetadataResponse,\n ProfileAddressEntry,\n SendIntentParams,\n SendIntentResponse,\n ServiceDetailsChain,\n ServiceDetailsProtocol,\n ServiceDetailsResponse,\n ServiceDetailsSupportedToken,\n SignedDelegation,\n VerifyDelegationParams,\n VerifyDelegationResponse,\n} from './types.js';\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -183,73 +183,6 @@ export type IntentEntry = {
|
|
|
183
183
|
export type CreateWithdrawalResponse = {
|
|
184
184
|
success: true;
|
|
185
185
|
};
|
|
186
|
-
/**
|
|
187
|
-
* A step that must be completed before a migration link counts as complete.
|
|
188
|
-
* `SUCCESSOR_SUBSCRIPTION_INTENT` and `TRANSFER_INTENT_PVMUSD` are only
|
|
189
|
-
* required for premium subscribers.
|
|
190
|
-
*/
|
|
191
|
-
export type MigrationStep = 'SUCCESSOR_DEPOSIT_INTENT' | 'SUCCESSOR_WITHDRAWAL_INTENT' | 'SUCCESSOR_SUBSCRIPTION_INTENT' | 'SUCCESSOR_MONITORED' | 'ROOT_DELEGATION' | 'TRANSFER_INTENT_MUSD' | 'TRANSFER_INTENT_VMUSD' | 'TRANSFER_INTENT_PVMUSD' | 'FUNDS_TRANSFERRED';
|
|
192
|
-
/**
|
|
193
|
-
* The settlement status of a Money Account identity chain. `NONE` is never
|
|
194
|
-
* returned as an entry: a profile with no Money Account has no identities.
|
|
195
|
-
*/
|
|
196
|
-
export type DerivedIdentityStatus = 'NONE' | 'MIGRATING' | 'DONE';
|
|
197
|
-
export type MigrationStepState = {
|
|
198
|
-
step: MigrationStep;
|
|
199
|
-
completed: boolean;
|
|
200
|
-
};
|
|
201
|
-
/**
|
|
202
|
-
* A funds-transfer execution request that CHOMP creates once every other
|
|
203
|
-
* migration step is complete.
|
|
204
|
-
*/
|
|
205
|
-
export type MigrationTransfer = {
|
|
206
|
-
requestId: string;
|
|
207
|
-
status: string;
|
|
208
|
-
};
|
|
209
|
-
/**
|
|
210
|
-
* The latest link of an identity chain while it is migrating.
|
|
211
|
-
*/
|
|
212
|
-
export type DerivedIdentityMigration = {
|
|
213
|
-
from: Hex;
|
|
214
|
-
to: Hex;
|
|
215
|
-
/** The steps required for the link's tier, in canonical order. */
|
|
216
|
-
steps: MigrationStepState[];
|
|
217
|
-
transfer: MigrationTransfer | null;
|
|
218
|
-
/** Stays `null` for a standard link, which never needs one. */
|
|
219
|
-
premiumTransfer: MigrationTransfer | null;
|
|
220
|
-
};
|
|
221
|
-
/**
|
|
222
|
-
* One Money Account over time: a chain of addresses joined by links.
|
|
223
|
-
* Addresses are lowercased.
|
|
224
|
-
*/
|
|
225
|
-
export type DerivedIdentity = {
|
|
226
|
-
/** The tip of the chain. Stays on the old address while migrating. */
|
|
227
|
-
currentAddress: Hex;
|
|
228
|
-
/** Earlier addresses, from the immediate predecessor backwards. */
|
|
229
|
-
previousAddresses: Hex[];
|
|
230
|
-
status: DerivedIdentityStatus;
|
|
231
|
-
migration: DerivedIdentityMigration | null;
|
|
232
|
-
};
|
|
233
|
-
/**
|
|
234
|
-
* Returned by GET /v1/money-account/identities.
|
|
235
|
-
*/
|
|
236
|
-
export type DerivedIdentitiesResponse = {
|
|
237
|
-
identities: DerivedIdentity[];
|
|
238
|
-
};
|
|
239
|
-
export type DerivedIdentityAddressRole = 'CURRENT' | 'PREVIOUS' | 'PENDING_SUCCESSOR';
|
|
240
|
-
/**
|
|
241
|
-
* Returned by GET /v1/money-account/identities/address/:address. Addresses
|
|
242
|
-
* are lowercased.
|
|
243
|
-
*/
|
|
244
|
-
export type AddressIdentityResponse = {
|
|
245
|
-
identity: DerivedIdentity;
|
|
246
|
-
address: {
|
|
247
|
-
address: Hex;
|
|
248
|
-
role: DerivedIdentityAddressRole;
|
|
249
|
-
predecessor: Hex | null;
|
|
250
|
-
successor: Hex | null;
|
|
251
|
-
};
|
|
252
|
-
};
|
|
253
186
|
export type ServiceDetailsSupportedToken = {
|
|
254
187
|
tokenAddress: Hex;
|
|
255
188
|
tokenDecimals: number;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAI3C;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GACvB,cAAc,GACd,iBAAiB,GACjB,sBAAsB,GACtB,yBAAyB,GACzB,mBAAmB,CAAC;AAExB,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,GAAG;IAC7B,QAAQ,EAAE,GAAG,CAAC;IACd,SAAS,EAAE,GAAG,CAAC;IACf,SAAS,EAAE,GAAG,CAAC;IACf,OAAO,EAAE,gBAAgB,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C;CACH,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,IAAI,CAAC;CACf,CAAC;AAIF,MAAM,MAAM,4BAA4B,GAAG;IACzC,YAAY,EAAE,GAAG,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,eAAe,EAAE,4BAA4B,EAAE,CAAC;IAChD,cAAc,EAAE,GAAG,CAAC;IACpB,WAAW,EAAE,eAAe,EAAE,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,mBAAmB,EAAE,GAAG,CAAC;IACzB,QAAQ,EAAE;QACR,YAAY,EAAE,sBAAsB,CAAC;QACrC,mBAAmB,CAAC,EAAE,sBAAsB,CAAC;KAC9C,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;CAC1C,CAAC"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n// === COMMON TYPES ===\n\n/**\n * The CHOMP intent metadata `type` discriminator, covering the base vault\n * (`cash-deposit`, `cash-withdrawal`), the premium vault\n * (`cash-deposit-premium`, `cash-withdrawal-premium`), and the recurring\n * subscription payment (`cash-subscription`).\n */\nexport type ChompIntentType =\n | 'cash-deposit'\n | 'cash-withdrawal'\n | 'cash-deposit-premium'\n | 'cash-withdrawal-premium'\n | 'cash-subscription';\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\n/**\n * Why an address is being associated through the v2 flow. `ASSOCIATE` creates\n * a normal association, while `ASSOCIATE_SUCCESSOR` also links the address to\n * its predecessor as the next address in the Money Account identity chain.\n */\nexport type AssociationPurpose = 'ASSOCIATE' | 'ASSOCIATE_SUCCESSOR';\n\nexport type CreateAddressChallengeParams =\n | {\n address: Hex;\n purpose: 'ASSOCIATE';\n }\n | {\n address: Hex;\n purpose: 'ASSOCIATE_SUCCESSOR';\n /**\n * The current address of the Money Account that `address` succeeds.\n * Must be set before any intents exist on `address`.\n */\n predecessorAddress: Hex;\n };\n\nexport type AssociateAddressV2Params = {\n challengeId: string;\n /**\n * The `personal_sign` signature of the challenge `message`, signed exactly\n * as returned by CHOMP with the address being associated.\n */\n signature: 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: ChompIntentType;\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\n/**\n * Returned by POST /v2/auth/address.\n *\n * `profileId` is only included when the address was newly associated\n * (`status: 'created'`). When the address was already associated with the\n * authenticated profile (`status: 'active'`), only `address` is returned.\n * An address associated with a different profile responds with 409, which is\n * surfaced as an error.\n */\nexport type AssociateAddressResponse = {\n profileId?: string;\n address: Hex;\n status: 'active' | 'created';\n};\n\n/**\n * Returned by POST /v2/auth/address/challenge.\n */\nexport type CreateAddressChallengeResponse = {\n challengeId: string;\n /**\n * The EIP-4361 (Sign-In with Ethereum) message to sign, bound to the\n * profile, chain, purpose, address and predecessor.\n */\n message: string;\n /**\n * When the challenge expires, as an ISO 8601 timestamp.\n */\n expiresAt: string;\n};\n\n/**\n * One entry returned by GET /v1/auth/address. The endpoint returns an array\n * of these — the active address associations of the authenticated profile\n * (the API filters out soft-deleted associations, so `status` is always\n * `'active'`). Addresses are lowercased.\n */\nexport type ProfileAddressEntry = {\n profileId: string;\n address: Hex;\n status: 'active';\n};\n\nexport type AccountUpgradeStatus = 'pending' | 'upgraded';\n\nexport type AuthorizationData = {\n r: Hex;\n s: Hex;\n v: number;\n yParity: number;\n address: Hex;\n chainId: Hex;\n nonce: Hex;\n};\n\n/**\n * Returned by POST /v1/account-upgrade.\n */\nexport type CreateUpgradeResponse = {\n signerAddress: Hex;\n address: Hex;\n chainId: Hex;\n nonce: Hex;\n status: AccountUpgradeStatus;\n createdAt: string;\n};\n\n/**\n * One entry returned by GET /v1/account-upgrade/:address. The endpoint returns\n * an array of these (one per chain).\n */\nexport type UpgradeEntry = {\n signerAddress: Hex;\n chainId: Hex;\n nonce: Hex;\n authorization: AuthorizationData;\n status: AccountUpgradeStatus;\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: ChompIntentType;\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 */\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: ChompIntentType;\n };\n};\n\nexport type CreateWithdrawalResponse = {\n success: true;\n};\n\n// ===
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n// === COMMON TYPES ===\n\n/**\n * The CHOMP intent metadata `type` discriminator, covering the base vault\n * (`cash-deposit`, `cash-withdrawal`), the premium vault\n * (`cash-deposit-premium`, `cash-withdrawal-premium`), and the recurring\n * subscription payment (`cash-subscription`).\n */\nexport type ChompIntentType =\n | 'cash-deposit'\n | 'cash-withdrawal'\n | 'cash-deposit-premium'\n | 'cash-withdrawal-premium'\n | 'cash-subscription';\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\n/**\n * Why an address is being associated through the v2 flow. `ASSOCIATE` creates\n * a normal association, while `ASSOCIATE_SUCCESSOR` also links the address to\n * its predecessor as the next address in the Money Account identity chain.\n */\nexport type AssociationPurpose = 'ASSOCIATE' | 'ASSOCIATE_SUCCESSOR';\n\nexport type CreateAddressChallengeParams =\n | {\n address: Hex;\n purpose: 'ASSOCIATE';\n }\n | {\n address: Hex;\n purpose: 'ASSOCIATE_SUCCESSOR';\n /**\n * The current address of the Money Account that `address` succeeds.\n * Must be set before any intents exist on `address`.\n */\n predecessorAddress: Hex;\n };\n\nexport type AssociateAddressV2Params = {\n challengeId: string;\n /**\n * The `personal_sign` signature of the challenge `message`, signed exactly\n * as returned by CHOMP with the address being associated.\n */\n signature: 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: ChompIntentType;\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\n/**\n * Returned by POST /v2/auth/address.\n *\n * `profileId` is only included when the address was newly associated\n * (`status: 'created'`). When the address was already associated with the\n * authenticated profile (`status: 'active'`), only `address` is returned.\n * An address associated with a different profile responds with 409, which is\n * surfaced as an error.\n */\nexport type AssociateAddressResponse = {\n profileId?: string;\n address: Hex;\n status: 'active' | 'created';\n};\n\n/**\n * Returned by POST /v2/auth/address/challenge.\n */\nexport type CreateAddressChallengeResponse = {\n challengeId: string;\n /**\n * The EIP-4361 (Sign-In with Ethereum) message to sign, bound to the\n * profile, chain, purpose, address and predecessor.\n */\n message: string;\n /**\n * When the challenge expires, as an ISO 8601 timestamp.\n */\n expiresAt: string;\n};\n\n/**\n * One entry returned by GET /v1/auth/address. The endpoint returns an array\n * of these — the active address associations of the authenticated profile\n * (the API filters out soft-deleted associations, so `status` is always\n * `'active'`). Addresses are lowercased.\n */\nexport type ProfileAddressEntry = {\n profileId: string;\n address: Hex;\n status: 'active';\n};\n\nexport type AccountUpgradeStatus = 'pending' | 'upgraded';\n\nexport type AuthorizationData = {\n r: Hex;\n s: Hex;\n v: number;\n yParity: number;\n address: Hex;\n chainId: Hex;\n nonce: Hex;\n};\n\n/**\n * Returned by POST /v1/account-upgrade.\n */\nexport type CreateUpgradeResponse = {\n signerAddress: Hex;\n address: Hex;\n chainId: Hex;\n nonce: Hex;\n status: AccountUpgradeStatus;\n createdAt: string;\n};\n\n/**\n * One entry returned by GET /v1/account-upgrade/:address. The endpoint returns\n * an array of these (one per chain).\n */\nexport type UpgradeEntry = {\n signerAddress: Hex;\n chainId: Hex;\n nonce: Hex;\n authorization: AuthorizationData;\n status: AccountUpgradeStatus;\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: ChompIntentType;\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 */\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: ChompIntentType;\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: ChompIntentType[];\n};\n\nexport type ServiceDetailsChain = {\n autoDepositDelegate: Hex;\n protocol: {\n vedaProtocol: ServiceDetailsProtocol;\n vedaPremiumProtocol?: ServiceDetailsProtocol;\n };\n};\n\nexport type ServiceDetailsResponse = {\n auth: {\n message: string;\n };\n chains: Record<Hex, ServiceDetailsChain>;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/chomp-api-service",
|
|
3
|
-
"version": "6.0.1-preview-
|
|
3
|
+
"version": "6.0.1-preview-5990812f2",
|
|
4
4
|
"description": "Data service for the Chomp API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ethereum",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@metamask/controller-utils": "^13.0.0",
|
|
53
53
|
"@metamask/messenger": "^3.0.0",
|
|
54
54
|
"@metamask/superstruct": "^3.4.1",
|
|
55
|
-
"@metamask/utils": "^12.0.
|
|
55
|
+
"@metamask/utils": "^12.0.1",
|
|
56
56
|
"@tanstack/query-core": "^5.103.2"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|