@metamask-previews/chomp-api-service 7.0.0-preview-40b7a961e → 7.0.0-preview-486391fb9

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 CHANGED
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+
12
+ - Add `createIntentsV2` method for `POST /v2/intent`, which accepts the Money Account migration intent types, and the `ChompMigrationIntentType`, `SendIntentV2Params` and `SendIntentV2Response` types, also exposed through the messenger ([#11369](https://github.com/MetaMask/core/pull/11369))
13
+ - Add optional `vaultMigrationHelperAddress` to `ServiceDetailsChain` ([#11369](https://github.com/MetaMask/core/pull/11369))
14
+ - Add `startFundsTransfer` method for `POST /v1/money-account/identities/address/:address/funds-transfer`, which starts moving the funds of a migrating Money Account to its successor, and the `FundsTransferStart` type, also exposed through the messenger ([#11369](https://github.com/MetaMask/core/pull/11369))
15
+
16
+ ### Changed
17
+
18
+ - `getDerivedIdentities` and `getDerivedIdentityByAddress` now omit migration steps they don't know instead of throwing ([#11369](https://github.com/MetaMask/core/pull/11369))
19
+
10
20
  ## [7.0.0]
11
21
 
12
22
  ### Added
@@ -131,6 +131,22 @@ export type ChompApiServiceCreateIntentsAction = {
131
131
  type: `ChompApiService:createIntents`;
132
132
  handler: ChompApiService['createIntents'];
133
133
  };
134
+ /**
135
+ * Submits one or more intents to the CHOMP API, including the Money Account
136
+ * migration intents that `POST /v1/intent` rejects.
137
+ *
138
+ * POST /v2/intent
139
+ *
140
+ * CHOMP accepts at most 10 intents per request. Their delegations must
141
+ * already be saved to the authenticated user storage.
142
+ *
143
+ * @param intents - The array of intents to submit.
144
+ * @returns The array of intent responses.
145
+ */
146
+ export type ChompApiServiceCreateIntentsV2Action = {
147
+ type: `ChompApiService:createIntentsV2`;
148
+ handler: ChompApiService['createIntentsV2'];
149
+ };
134
150
  /**
135
151
  * Fetches intents associated with a given address.
136
152
  *
@@ -209,8 +225,27 @@ export type ChompApiServiceGetDerivedIdentityByAddressAction = {
209
225
  type: `ChompApiService:getDerivedIdentityByAddress`;
210
226
  handler: ChompApiService['getDerivedIdentityByAddress'];
211
227
  };
228
+ /**
229
+ * Starts moving the funds of a migrating Money Account to its successor.
230
+ *
231
+ * POST /v1/money-account/identities/address/:address/funds-transfer
232
+ *
233
+ * CHOMP starts the transfer for the predecessor of the migrating identity
234
+ * that contains `address`, once every other migration step is complete,
235
+ * and rejects the request with `MIGRATION_STEPS_INCOMPLETE` otherwise. Once
236
+ * the transfer exists, the migration can no longer be cancelled. Repeating
237
+ * the request returns the existing transfer requests, so it is retried like
238
+ * a read.
239
+ *
240
+ * @param address - Any address of the migrating identity.
241
+ * @returns The funds-transfer requests. Addresses are lowercased.
242
+ */
243
+ export type ChompApiServiceStartFundsTransferAction = {
244
+ type: `ChompApiService:startFundsTransfer`;
245
+ handler: ChompApiService['startFundsTransfer'];
246
+ };
212
247
  /**
213
248
  * Union of all ChompApiService action types.
214
249
  */
215
- export type ChompApiServiceMethodActions = ChompApiServiceCreateAddressChallengeAction | ChompApiServiceAssociateAddressV2Action | ChompApiServiceDisassociateAddressAction | ChompApiServiceGetAssociatedAddressesAction | ChompApiServiceCreateUpgradeAction | ChompApiServiceGetUpgradesAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceGetIntentsByAddressAction | ChompApiServiceCreateWithdrawalAction | ChompApiServiceGetServiceDetailsAction | ChompApiServiceGetDerivedIdentitiesAction | ChompApiServiceGetDerivedIdentityByAddressAction;
250
+ export type ChompApiServiceMethodActions = ChompApiServiceCreateAddressChallengeAction | ChompApiServiceAssociateAddressV2Action | ChompApiServiceDisassociateAddressAction | ChompApiServiceGetAssociatedAddressesAction | ChompApiServiceCreateUpgradeAction | ChompApiServiceGetUpgradesAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceCreateIntentsV2Action | ChompApiServiceGetIntentsByAddressAction | ChompApiServiceCreateWithdrawalAction | ChompApiServiceGetServiceDetailsAction | ChompApiServiceGetDerivedIdentitiesAction | ChompApiServiceGetDerivedIdentityByAddressAction | ChompApiServiceStartFundsTransferAction;
216
251
  //# 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;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;CACjD,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,+BAA+B,CAAC;IACtC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EA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CAAkC,GAClC,gCAAgC,GAChC,qCAAqC,GACrC,kCAAkC,GAClC,wCAAwC,GACxC,qCAAqC,GACrC,sCAAsC,GACtC,yCAAyC,GACzC,gDAAgD,CAAC"}
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;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;CACjD,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,+BAA+B,CAAC;IACtC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;CACzC,CAAC;AAEF;;;;;;;GAO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uC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,eAAe,CAAC,oBAAoB,CAAC,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACpC,2CAA2C,GAC3C,uCAAuC,GACvC,wCAAwC,GACxC,2CAA2C,GAC3C,kCAAkC,GAClC,gCAAgC,GAChC,qCAAqC,GACrC,kCAAkC,GAClC,oCAAoC,GACpC,wCAAwC,GACxC,qCAAqC,GACrC,sCAAsC,GACtC,yCAAyC,GACzC,gDAAgD,GAChD,uCAAuC,CAAC"}
@@ -1 +1 @@
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 * Removes an address association from the authenticated profile.\n * When called with an addresses that is linked as successors it will only succeed\n * if the chomp migration has not yet created a funds-transfer request. Otherwise\n * CHOMP will reject the request with `LINK_COMPLETE`\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 */\nexport type ChompApiServiceDisassociateAddressAction = {\n type: `ChompApiService:disassociateAddress`;\n handler: ChompApiService['disassociateAddress'];\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 * Fetches the Money Account identities of the authenticated profile, including\n * status and migration steps information. Calling this will start migrations.\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 */\nexport type ChompApiServiceGetDerivedIdentitiesAction = {\n type: `ChompApiService:getDerivedIdentities`;\n handler: ChompApiService['getDerivedIdentities'];\n};\n\n/**\n * Fetches the identity containing an address, along with where the address\n * sits in it.\n *\n * GET /v1/money-account/identities/address/:address\n *\n * Always fetched fresh and keyed by a digest of the bearer token.\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`\n *\n * Addresses are lowercased.\n */\nexport type ChompApiServiceGetDerivedIdentityByAddressAction = {\n type: `ChompApiService:getDerivedIdentityByAddress`;\n handler: ChompApiService['getDerivedIdentityByAddress'];\n};\n\n/**\n * Union of all ChompApiService action types.\n */\nexport type ChompApiServiceMethodActions =\n | ChompApiServiceCreateAddressChallengeAction\n | ChompApiServiceAssociateAddressV2Action\n | ChompApiServiceDisassociateAddressAction\n | ChompApiServiceGetAssociatedAddressesAction\n | ChompApiServiceCreateUpgradeAction\n | ChompApiServiceGetUpgradesAction\n | ChompApiServiceVerifyDelegationAction\n | ChompApiServiceCreateIntentsAction\n | ChompApiServiceGetIntentsByAddressAction\n | ChompApiServiceCreateWithdrawalAction\n | ChompApiServiceGetServiceDetailsAction\n | ChompApiServiceGetDerivedIdentitiesAction\n | ChompApiServiceGetDerivedIdentityByAddressAction;\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 * Removes an address association from the authenticated profile.\n * When called with an addresses that is linked as successors it will only succeed\n * if the chomp migration has not yet created a funds-transfer request. Otherwise\n * CHOMP will reject the request with `LINK_COMPLETE`\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 */\nexport type ChompApiServiceDisassociateAddressAction = {\n type: `ChompApiService:disassociateAddress`;\n handler: ChompApiService['disassociateAddress'];\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 * Submits one or more intents to the CHOMP API, including the Money Account\n * migration intents that `POST /v1/intent` rejects.\n *\n * POST /v2/intent\n *\n * CHOMP accepts at most 10 intents per request. Their delegations must\n * already be saved to the authenticated user storage.\n *\n * @param intents - The array of intents to submit.\n * @returns The array of intent responses.\n */\nexport type ChompApiServiceCreateIntentsV2Action = {\n type: `ChompApiService:createIntentsV2`;\n handler: ChompApiService['createIntentsV2'];\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 * Fetches the Money Account identities of the authenticated profile, including\n * status and migration steps information. Calling this will start migrations.\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 */\nexport type ChompApiServiceGetDerivedIdentitiesAction = {\n type: `ChompApiService:getDerivedIdentities`;\n handler: ChompApiService['getDerivedIdentities'];\n};\n\n/**\n * Fetches the identity containing an address, along with where the address\n * sits in it.\n *\n * GET /v1/money-account/identities/address/:address\n *\n * Always fetched fresh and keyed by a digest of the bearer token.\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`\n *\n * Addresses are lowercased.\n */\nexport type ChompApiServiceGetDerivedIdentityByAddressAction = {\n type: `ChompApiService:getDerivedIdentityByAddress`;\n handler: ChompApiService['getDerivedIdentityByAddress'];\n};\n\n/**\n * Starts moving the funds of a migrating Money Account to its successor.\n *\n * POST /v1/money-account/identities/address/:address/funds-transfer\n *\n * CHOMP starts the transfer for the predecessor of the migrating identity\n * that contains `address`, once every other migration step is complete,\n * and rejects the request with `MIGRATION_STEPS_INCOMPLETE` otherwise. Once\n * the transfer exists, the migration can no longer be cancelled. Repeating\n * the request returns the existing transfer requests, so it is retried like\n * a read.\n *\n * @param address - Any address of the migrating identity.\n * @returns The funds-transfer requests. Addresses are lowercased.\n */\nexport type ChompApiServiceStartFundsTransferAction = {\n type: `ChompApiService:startFundsTransfer`;\n handler: ChompApiService['startFundsTransfer'];\n};\n\n/**\n * Union of all ChompApiService action types.\n */\nexport type ChompApiServiceMethodActions =\n | ChompApiServiceCreateAddressChallengeAction\n | ChompApiServiceAssociateAddressV2Action\n | ChompApiServiceDisassociateAddressAction\n | ChompApiServiceGetAssociatedAddressesAction\n | ChompApiServiceCreateUpgradeAction\n | ChompApiServiceGetUpgradesAction\n | ChompApiServiceVerifyDelegationAction\n | ChompApiServiceCreateIntentsAction\n | ChompApiServiceCreateIntentsV2Action\n | ChompApiServiceGetIntentsByAddressAction\n | ChompApiServiceCreateWithdrawalAction\n | ChompApiServiceGetServiceDetailsAction\n | ChompApiServiceGetDerivedIdentitiesAction\n | ChompApiServiceGetDerivedIdentityByAddressAction\n | ChompApiServiceStartFundsTransferAction;\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 { AddressIdentityResponse, AssociateAddressResponse, AssociateAddressV2Params, CreateAddressChallengeParams, CreateAddressChallengeResponse, ProfileAddressEntry, CreateUpgradeParams, CreateUpgradeResponse, UpgradeEntry, CreateWithdrawalParams, CreateWithdrawalResponse, DerivedIdentitiesResponse, IntentEntry, SendIntentParams, SendIntentResponse, ServiceDetailsResponse, VerifyDelegationParams, VerifyDelegationResponse } from './types.js';
9
+ import type { AddressIdentityResponse, AssociateAddressResponse, AssociateAddressV2Params, CreateAddressChallengeParams, CreateAddressChallengeResponse, ProfileAddressEntry, CreateUpgradeParams, CreateUpgradeResponse, UpgradeEntry, CreateWithdrawalParams, FundsTransferStart, CreateWithdrawalResponse, DerivedIdentitiesResponse, IntentEntry, SendIntentParams, SendIntentResponse, SendIntentV2Params, SendIntentV2Response, 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.
@@ -194,6 +194,19 @@ export declare class ChompApiService extends BaseDataService<typeof serviceName,
194
194
  * @returns The array of intent responses.
195
195
  */
196
196
  createIntents(intents: SendIntentParams[]): Promise<SendIntentResponse[]>;
197
+ /**
198
+ * Submits one or more intents to the CHOMP API, including the Money Account
199
+ * migration intents that `POST /v1/intent` rejects.
200
+ *
201
+ * POST /v2/intent
202
+ *
203
+ * CHOMP accepts at most 10 intents per request. Their delegations must
204
+ * already be saved to the authenticated user storage.
205
+ *
206
+ * @param intents - The array of intents to submit.
207
+ * @returns The array of intent responses.
208
+ */
209
+ createIntentsV2(intents: SendIntentV2Params[]): Promise<SendIntentV2Response[]>;
197
210
  /**
198
211
  * Fetches intents associated with a given address.
199
212
  *
@@ -257,6 +270,22 @@ export declare class ChompApiService extends BaseDataService<typeof serviceName,
257
270
  * Addresses are lowercased.
258
271
  */
259
272
  getDerivedIdentityByAddress(address: Hex): Promise<AddressIdentityResponse | null>;
273
+ /**
274
+ * Starts moving the funds of a migrating Money Account to its successor.
275
+ *
276
+ * POST /v1/money-account/identities/address/:address/funds-transfer
277
+ *
278
+ * CHOMP starts the transfer for the predecessor of the migrating identity
279
+ * that contains `address`, once every other migration step is complete,
280
+ * and rejects the request with `MIGRATION_STEPS_INCOMPLETE` otherwise. Once
281
+ * the transfer exists, the migration can no longer be cancelled. Repeating
282
+ * the request returns the existing transfer requests, so it is retried like
283
+ * a read.
284
+ *
285
+ * @param address - Any address of the migrating identity.
286
+ * @returns The funds-transfer requests. Addresses are lowercased.
287
+ */
288
+ startFundsTransfer(address: Hex): Promise<FundsTransferStart>;
260
289
  }
261
290
  export {};
262
291
  //# 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;AAerD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAS3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,EAC5B,8BAA8B,EAC9B,mBAAmB,EAEnB,mBAAmB,EACnB,qBAAqB,EACrB,YAAY,EACZ,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,EACzB,WAAW,EAEX,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AA4BpB;;;GAGG;AACH,eAAO,MAAM,WAAW,o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CAAC,sBAAsB,CAAC,CAqBxE;IAED;;;;;;;;;;;;OAYG;IACG,oBAAoB,IAAI,OAAO,CAAC,yBAAyB,CAAC,CAyB/D;IAED;;;;;;;;;;;;;OAaG;IACG,2BAA2B,CAC/B,OAAO,EAAE,GAAG,GACX,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAsCzC;IAED;;;;;;;;;;;;;;OAcG;IACG,kBAAkB,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA0BlE;CACF"}
@@ -9,6 +9,11 @@ const CHOMP_INTENT_TYPES = [
9
9
  'cash-withdrawal-premium',
10
10
  'cash-subscription',
11
11
  ];
12
+ const CHOMP_MIGRATION_INTENT_TYPES = [
13
+ 'cash-migration-root',
14
+ 'cash-migration-transfer',
15
+ 'cash-migration-premium-transfer',
16
+ ];
12
17
  const MIGRATION_STEPS = [
13
18
  'SUCCESSOR_DEPOSIT_INTENT',
14
19
  'SUCCESSOR_WITHDRAWAL_INTENT',
@@ -23,6 +28,9 @@ const MIGRATION_STEPS = [
23
28
  function isChompIntentType(value) {
24
29
  return CHOMP_INTENT_TYPES.includes(value);
25
30
  }
31
+ function isMigrationStep(value) {
32
+ return MIGRATION_STEPS.includes(value);
33
+ }
26
34
  // === GENERAL ===
27
35
  /**
28
36
  * The name of the {@link ChompApiService}, used to namespace the service's
@@ -81,11 +89,13 @@ const MESSENGER_EXPOSED_METHODS = [
81
89
  'getUpgrades',
82
90
  'verifyDelegation',
83
91
  'createIntents',
92
+ 'createIntentsV2',
84
93
  'getIntentsByAddress',
85
94
  'createWithdrawal',
86
95
  'getServiceDetails',
87
96
  'getDerivedIdentities',
88
97
  'getDerivedIdentityByAddress',
98
+ 'startFundsTransfer',
89
99
  ];
90
100
  // === RESPONSE VALIDATION ===
91
101
  const AssociateAddressResponseStruct = type({
@@ -121,10 +131,10 @@ const DerivedIdentityStruct = type({
121
131
  migration: nullable(type({
122
132
  from: LowercaseHexAddressStruct,
123
133
  to: LowercaseHexAddressStruct,
124
- steps: array(type({
134
+ steps: coerce(array(type({
125
135
  step: enums(MIGRATION_STEPS),
126
136
  completed: boolean(),
127
- })),
137
+ })), array(type({ step: string(), completed: boolean() })), (steps) => steps.filter(({ step }) => isMigrationStep(step))),
128
138
  transfer: MigrationTransferStruct,
129
139
  premiumTransfer: MigrationTransferStruct,
130
140
  })),
@@ -141,6 +151,12 @@ const AddressIdentityResponseStruct = type({
141
151
  successor: nullable(LowercaseHexAddressStruct),
142
152
  }),
143
153
  });
154
+ const FundsTransferStartStruct = type({
155
+ from: LowercaseHexAddressStruct,
156
+ to: LowercaseHexAddressStruct,
157
+ transfer: MigrationTransferStruct,
158
+ premiumTransfer: MigrationTransferStruct,
159
+ });
144
160
  const AccountUpgradeStatusStruct = enums(['pending', 'upgraded']);
145
161
  const AuthorizationDataStruct = type({
146
162
  r: StrictHexStruct,
@@ -182,6 +198,19 @@ const SendIntentResponseArrayStruct = array(type({
182
198
  }),
183
199
  createdAt: string(),
184
200
  }));
201
+ const SendIntentV2ResponseArrayStruct = array(type({
202
+ delegationHash: StrictHexStruct,
203
+ intent: type({
204
+ type: enums([...CHOMP_INTENT_TYPES, ...CHOMP_MIGRATION_INTENT_TYPES]),
205
+ data: type({
206
+ allowance: StrictHexStruct,
207
+ tokenSymbol: string(),
208
+ tokenAddress: StrictHexStruct,
209
+ userSignature: optional(StrictHexStruct),
210
+ }),
211
+ }),
212
+ createdAt: string(),
213
+ }));
185
214
  const IntentEntryArrayStruct = array(type({
186
215
  account: StrictHexStruct,
187
216
  delegationHash: StrictHexStruct,
@@ -211,6 +240,7 @@ const ServiceDetailsResponseStruct = type({
211
240
  }),
212
241
  chains: record(StrictHexStruct, type({
213
242
  autoDepositDelegate: StrictHexStruct,
243
+ vaultMigrationHelperAddress: optional(StrictHexStruct),
214
244
  protocol: type({
215
245
  vedaProtocol: ServiceDetailsProtocolStruct,
216
246
  vedaPremiumProtocol: optional(ServiceDetailsProtocolStruct),
@@ -548,6 +578,37 @@ export class ChompApiService extends BaseDataService {
548
578
  });
549
579
  return create(jsonResponse, SendIntentResponseArrayStruct);
550
580
  }
581
+ /**
582
+ * Submits one or more intents to the CHOMP API, including the Money Account
583
+ * migration intents that `POST /v1/intent` rejects.
584
+ *
585
+ * POST /v2/intent
586
+ *
587
+ * CHOMP accepts at most 10 intents per request. Their delegations must
588
+ * already be saved to the authenticated user storage.
589
+ *
590
+ * @param intents - The array of intents to submit.
591
+ * @returns The array of intent responses.
592
+ */
593
+ async createIntentsV2(intents) {
594
+ const jsonResponse = await this.fetchQuery({
595
+ queryKey: [`${this.name}:createIntentsV2`, intents],
596
+ staleTime: 0,
597
+ queryFn: async () => {
598
+ const headers = await this.#authHeaders();
599
+ const response = await fetch(new URL('/v2/intent', this.#baseUrl), {
600
+ method: 'POST',
601
+ headers,
602
+ body: JSON.stringify(intents),
603
+ });
604
+ if (!response.ok) {
605
+ throw await createChompApiError(response, `POST /v2/intent failed with status '${response.status}'`);
606
+ }
607
+ return response.json();
608
+ },
609
+ });
610
+ return create(jsonResponse, SendIntentV2ResponseArrayStruct);
611
+ }
551
612
  /**
552
613
  * Fetches intents associated with a given address.
553
614
  *
@@ -698,5 +759,40 @@ export class ChompApiService extends BaseDataService {
698
759
  ? null
699
760
  : create(jsonResponse, AddressIdentityResponseStruct);
700
761
  }
762
+ /**
763
+ * Starts moving the funds of a migrating Money Account to its successor.
764
+ *
765
+ * POST /v1/money-account/identities/address/:address/funds-transfer
766
+ *
767
+ * CHOMP starts the transfer for the predecessor of the migrating identity
768
+ * that contains `address`, once every other migration step is complete,
769
+ * and rejects the request with `MIGRATION_STEPS_INCOMPLETE` otherwise. Once
770
+ * the transfer exists, the migration can no longer be cancelled. Repeating
771
+ * the request returns the existing transfer requests, so it is retried like
772
+ * a read.
773
+ *
774
+ * @param address - Any address of the migrating identity.
775
+ * @returns The funds-transfer requests. Addresses are lowercased.
776
+ */
777
+ async startFundsTransfer(address) {
778
+ const { token, profileKey } = await this.#getProfileScopedToken();
779
+ const path = `/v1/money-account/identities/address/${address}/funds-transfer`;
780
+ const jsonResponse = await this.fetchQuery({
781
+ queryKey: [`${this.name}:startFundsTransfer`, profileKey, address],
782
+ staleTime: 0,
783
+ gcTime: 0,
784
+ queryFn: async () => {
785
+ const response = await fetch(new URL(path, this.#baseUrl), {
786
+ method: 'POST',
787
+ headers: this.#headersForToken(token),
788
+ });
789
+ if (!response.ok) {
790
+ throw await createChompApiError(response, `POST ${path} failed with status '${response.status}'`);
791
+ }
792
+ return response.json();
793
+ },
794
+ });
795
+ return create(jsonResponse, FundsTransferStartStruct);
796
+ }
701
797
  }
702
798
  //# sourceMappingURL=chomp-api-service.js.map
@@ -1 +1 @@
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,QAAQ,EACR,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;AA2BzB,MAAM,kBAAkB,GAAsB;IAC5C,cAAc;IACd,iBAAiB;IACjB,sBAAsB;IACtB,yBAAyB;IACzB,mBAAmB;CACpB,CAAC;AAEF,MAAM,eAAe,GAAoB;IACvC,0BAA0B;IAC1B,6BAA6B;IAC7B,+BAA+B;IAC/B,qBAAqB;IACrB,iBAAiB;IACjB,sBAAsB;IACtB,uBAAuB;IACvB,wBAAwB;IACxB,mBAAmB;CACpB,CAAC;AAEF,SAAS,iBAAiB,CAAC,KAAa;IACtC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,CACd,EACD,EAAE,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAC1C,CAAC;gBAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACjB,MAAM,KAAK,GAAG,MAAM,mBAAmB,CACrC,QAAQ,EACR,4CAA4C,OAAO,wBAAwB,QAAQ,CAAC,MAAM,GAAG,CAC9F,CAAC;oBACF,IAAI,KAAK,CAAC,IAAI,KAAK,wBAAwB,EAAE,CAAC;wBAC5C,OAAO,IAAI,CAAC;oBACd,CAAC;oBACD,MAAM,KAAK,CAAC;gBACd,CAAC;gBAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;YACzB,CAAC;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.\n * When called with an addresses that is linked as successors it will only succeed\n * if the chomp migration has not yet created a funds-transfer request. Otherwise\n * CHOMP will reject the request with `LINK_COMPLETE`\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, including\n * status and migration steps information. Calling this will start migrations.\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.\n *\n * GET /v1/money-account/identities/address/:address\n *\n * Always fetched fresh and keyed by a digest of the bearer token.\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`\n *\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,QAAQ,EACR,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;AA+BzB,MAAM,kBAAkB,GAAsB;IAC5C,cAAc;IACd,iBAAiB;IACjB,sBAAsB;IACtB,yBAAyB;IACzB,mBAAmB;CACpB,CAAC;AAEF,MAAM,4BAA4B,GAA+B;IAC/D,qBAAqB;IACrB,yB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ServiceGranularCacheUpdatedEvent,\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 ChompMigrationIntentType,\n CreateUpgradeParams,\n CreateUpgradeResponse,\n UpgradeEntry,\n CreateWithdrawalParams,\n FundsTransferStart,\n CreateWithdrawalResponse,\n DerivedIdentitiesResponse,\n IntentEntry,\n MigrationStep,\n SendIntentParams,\n SendIntentResponse,\n SendIntentV2Params,\n SendIntentV2Response,\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 CHOMP_MIGRATION_INTENT_TYPES: ChompMigrationIntentType[] = [\n 'cash-migration-root',\n 'cash-migration-transfer',\n 'cash-migration-premium-transfer',\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\nfunction isMigrationStep(value: string): value is MigrationStep {\n return (MIGRATION_STEPS 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 'createIntentsV2',\n 'getIntentsByAddress',\n 'createWithdrawal',\n 'getServiceDetails',\n 'getDerivedIdentities',\n 'getDerivedIdentityByAddress',\n 'startFundsTransfer',\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: coerce(\n array(\n type({\n step: enums(MIGRATION_STEPS),\n completed: boolean(),\n }),\n ),\n array(type({ step: string(), completed: boolean() })),\n (steps) => steps.filter(({ step }) => isMigrationStep(step)),\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 FundsTransferStartStruct = type({\n from: LowercaseHexAddressStruct,\n to: LowercaseHexAddressStruct,\n transfer: MigrationTransferStruct,\n premiumTransfer: MigrationTransferStruct,\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 SendIntentV2ResponseArrayStruct = array(\n type({\n delegationHash: StrictHexStruct,\n intent: type({\n type: enums([...CHOMP_INTENT_TYPES, ...CHOMP_MIGRATION_INTENT_TYPES]),\n data: type({\n allowance: StrictHexStruct,\n tokenSymbol: string(),\n tokenAddress: StrictHexStruct,\n userSignature: optional(StrictHexStruct),\n }),\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 vaultMigrationHelperAddress: optional(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.\n * When called with an addresses that is linked as successors it will only succeed\n * if the chomp migration has not yet created a funds-transfer request. Otherwise\n * CHOMP will reject the request with `LINK_COMPLETE`\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 * Submits one or more intents to the CHOMP API, including the Money Account\n * migration intents that `POST /v1/intent` rejects.\n *\n * POST /v2/intent\n *\n * CHOMP accepts at most 10 intents per request. Their delegations must\n * already be saved to the authenticated user storage.\n *\n * @param intents - The array of intents to submit.\n * @returns The array of intent responses.\n */\n async createIntentsV2(\n intents: SendIntentV2Params[],\n ): Promise<SendIntentV2Response[]> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createIntentsV2`, intents],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(new URL('/v2/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 /v2/intent failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, SendIntentV2ResponseArrayStruct);\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, including\n * status and migration steps information. Calling this will start migrations.\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.\n *\n * GET /v1/money-account/identities/address/:address\n *\n * Always fetched fresh and keyed by a digest of the bearer token.\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`\n *\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 /**\n * Starts moving the funds of a migrating Money Account to its successor.\n *\n * POST /v1/money-account/identities/address/:address/funds-transfer\n *\n * CHOMP starts the transfer for the predecessor of the migrating identity\n * that contains `address`, once every other migration step is complete,\n * and rejects the request with `MIGRATION_STEPS_INCOMPLETE` otherwise. Once\n * the transfer exists, the migration can no longer be cancelled. Repeating\n * the request returns the existing transfer requests, so it is retried like\n * a read.\n *\n * @param address - Any address of the migrating identity.\n * @returns The funds-transfer requests. Addresses are lowercased.\n */\n async startFundsTransfer(address: Hex): Promise<FundsTransferStart> {\n const { token, profileKey } = await this.#getProfileScopedToken();\n const path = `/v1/money-account/identities/address/${address}/funds-transfer`;\n\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:startFundsTransfer`, profileKey, address],\n staleTime: 0,\n gcTime: 0,\n queryFn: async () => {\n const response = await fetch(new URL(path, this.#baseUrl), {\n method: 'POST',\n headers: this.#headersForToken(token),\n });\n\n if (!response.ok) {\n throw await createChompApiError(\n response,\n `POST ${path} failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, FundsTransferStartStruct);\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, ChompApiServiceDisassociateAddressAction, ChompApiServiceGetAssociatedAddressesAction, ChompApiServiceCreateUpgradeAction, ChompApiServiceGetUpgradesAction, ChompApiServiceVerifyDelegationAction, ChompApiServiceCreateIntentsAction, ChompApiServiceGetIntentsByAddressAction, ChompApiServiceCreateWithdrawalAction, ChompApiServiceGetServiceDetailsAction, ChompApiServiceGetDerivedIdentitiesAction, ChompApiServiceGetDerivedIdentityByAddressAction, } from './chomp-api-service-method-action-types.js';
4
- export type { AccountUpgradeStatus, AddressIdentityResponse, AssociateAddressResponse, AssociateAddressV2Params, AssociationPurpose, AuthorizationData, ChompIntentType, CreateAddressChallengeParams, CreateAddressChallengeResponse, CreateUpgradeParams, CreateUpgradeResponse, CreateWithdrawalParams, CreateWithdrawalResponse, DelegationCaveat, DerivedIdentitiesResponse, DerivedIdentity, DerivedIdentityAddressRole, DerivedIdentityMigration, DerivedIdentityStatus, UpgradeEntry, IntentEntry, IntentMetadataParams, IntentMetadataResponse, MigrationStep, MigrationStepState, MigrationTransfer, ProfileAddressEntry, SendIntentParams, SendIntentResponse, ServiceDetailsChain, ServiceDetailsProtocol, ServiceDetailsResponse, ServiceDetailsSupportedToken, SignedDelegation, VerifyDelegationParams, VerifyDelegationResponse, } from './types.js';
3
+ export type { ChompApiServiceAssociateAddressV2Action, ChompApiServiceCreateAddressChallengeAction, ChompApiServiceDisassociateAddressAction, ChompApiServiceGetAssociatedAddressesAction, ChompApiServiceCreateUpgradeAction, ChompApiServiceGetUpgradesAction, ChompApiServiceVerifyDelegationAction, ChompApiServiceCreateIntentsAction, ChompApiServiceCreateIntentsV2Action, ChompApiServiceGetIntentsByAddressAction, ChompApiServiceCreateWithdrawalAction, ChompApiServiceGetServiceDetailsAction, ChompApiServiceGetDerivedIdentitiesAction, ChompApiServiceGetDerivedIdentityByAddressAction, ChompApiServiceStartFundsTransferAction, } from './chomp-api-service-method-action-types.js';
4
+ export type { AccountUpgradeStatus, AddressIdentityResponse, AssociateAddressResponse, AssociateAddressV2Params, AssociationPurpose, AuthorizationData, ChompIntentType, ChompMigrationIntentType, CreateAddressChallengeParams, CreateAddressChallengeResponse, CreateUpgradeParams, CreateUpgradeResponse, CreateWithdrawalParams, FundsTransferStart, CreateWithdrawalResponse, DelegationCaveat, DerivedIdentitiesResponse, DerivedIdentity, DerivedIdentityAddressRole, DerivedIdentityMigration, DerivedIdentityStatus, UpgradeEntry, IntentDataParams, IntentEntry, IntentMetadataParams, IntentMetadataResponse, MigrationStep, MigrationStepState, MigrationTransfer, ProfileAddressEntry, SendIntentParams, SendIntentResponse, SendIntentV2Params, SendIntentV2Response, ServiceDetailsChain, ServiceDetailsProtocol, ServiceDetailsResponse, ServiceDetailsSupportedToken, SignedDelegation, VerifyDelegationParams, VerifyDelegationResponse, } from './types.js';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -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,wCAAwC,EACxC,2CAA2C,EAC3C,kCAAkC,EAClC,gCAAgC,EAChC,qCAAqC,EACrC,kCAAkC,EAClC,wCAAwC,EACxC,qCAAqC,EACrC,sCAAsC,EACtC,yCAAyC,EACzC,gDAAgD,GACjD,MAAM,4CAA4C,CAAC;AACpD,YAAY,EACV,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,4BAA4B,EAC5B,8BAA8B,EAC9B,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,EACrB,YAAY,EACZ,WAAW,EACX,oBAAoB,EACpB,sBAAsB,EACtB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
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,wCAAwC,EACxC,2CAA2C,EAC3C,kCAAkC,EAClC,gCAAgC,EAChC,qCAAqC,EACrC,kCAAkC,EAClC,oCAAoC,EACpC,wCAAwC,EACxC,qCAAqC,EACrC,sCAAsC,EACtC,yCAAyC,EACzC,gDAAgD,EAChD,uCAAuC,GACxC,MAAM,4CAA4C,CAAC;AACpD,YAAY,EACV,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,4BAA4B,EAC5B,8BAA8B,EAC9B,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,EACrB,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,sBAAsB,EACtB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,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 ChompApiServiceDisassociateAddressAction,\n ChompApiServiceGetAssociatedAddressesAction,\n ChompApiServiceCreateUpgradeAction,\n ChompApiServiceGetUpgradesAction,\n ChompApiServiceVerifyDelegationAction,\n ChompApiServiceCreateIntentsAction,\n ChompApiServiceGetIntentsByAddressAction,\n ChompApiServiceCreateWithdrawalAction,\n ChompApiServiceGetServiceDetailsAction,\n ChompApiServiceGetDerivedIdentitiesAction,\n ChompApiServiceGetDerivedIdentityByAddressAction,\n} from './chomp-api-service-method-action-types.js';\nexport type {\n AccountUpgradeStatus,\n AddressIdentityResponse,\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 DerivedIdentitiesResponse,\n DerivedIdentity,\n DerivedIdentityAddressRole,\n DerivedIdentityMigration,\n DerivedIdentityStatus,\n UpgradeEntry,\n IntentEntry,\n IntentMetadataParams,\n IntentMetadataResponse,\n MigrationStep,\n MigrationStepState,\n MigrationTransfer,\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"]}
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 ChompApiServiceDisassociateAddressAction,\n ChompApiServiceGetAssociatedAddressesAction,\n ChompApiServiceCreateUpgradeAction,\n ChompApiServiceGetUpgradesAction,\n ChompApiServiceVerifyDelegationAction,\n ChompApiServiceCreateIntentsAction,\n ChompApiServiceCreateIntentsV2Action,\n ChompApiServiceGetIntentsByAddressAction,\n ChompApiServiceCreateWithdrawalAction,\n ChompApiServiceGetServiceDetailsAction,\n ChompApiServiceGetDerivedIdentitiesAction,\n ChompApiServiceGetDerivedIdentityByAddressAction,\n ChompApiServiceStartFundsTransferAction,\n} from './chomp-api-service-method-action-types.js';\nexport type {\n AccountUpgradeStatus,\n AddressIdentityResponse,\n AssociateAddressResponse,\n AssociateAddressV2Params,\n AssociationPurpose,\n AuthorizationData,\n ChompIntentType,\n ChompMigrationIntentType,\n CreateAddressChallengeParams,\n CreateAddressChallengeResponse,\n CreateUpgradeParams,\n CreateUpgradeResponse,\n CreateWithdrawalParams,\n FundsTransferStart,\n CreateWithdrawalResponse,\n DelegationCaveat,\n DerivedIdentitiesResponse,\n DerivedIdentity,\n DerivedIdentityAddressRole,\n DerivedIdentityMigration,\n DerivedIdentityStatus,\n UpgradeEntry,\n IntentDataParams,\n IntentEntry,\n IntentMetadataParams,\n IntentMetadataResponse,\n MigrationStep,\n MigrationStepState,\n MigrationTransfer,\n ProfileAddressEntry,\n SendIntentParams,\n SendIntentResponse,\n SendIntentV2Params,\n SendIntentV2Response,\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
@@ -6,6 +6,20 @@ import type { Hex } from '@metamask/utils';
6
6
  * subscription payment (`cash-subscription`).
7
7
  */
8
8
  export type ChompIntentType = 'cash-deposit' | 'cash-withdrawal' | 'cash-deposit-premium' | 'cash-withdrawal-premium' | 'cash-subscription';
9
+ /**
10
+ * The CHOMP intent types that complete the Money Account migration steps
11
+ * signed by the predecessor address. They can only be created through
12
+ * `POST /v2/intent`.
13
+ *
14
+ * - `cash-migration-root`: root delegation from the predecessor to the
15
+ * successor.
16
+ * - `cash-migration-transfer`: open delegation that lets any redeemer
17
+ * transfer one token (mUSD or vmUSD) from the predecessor only to the
18
+ * successor.
19
+ * - `cash-migration-premium-transfer`: delegation from the predecessor to
20
+ * CHOMP that moves the pvmUSD balance to the successor. Premium only.
21
+ */
22
+ export type ChompMigrationIntentType = 'cash-migration-root' | 'cash-migration-transfer' | 'cash-migration-premium-transfer';
9
23
  export type DelegationCaveat = {
10
24
  enforcer: Hex;
11
25
  terms: Hex;
@@ -70,6 +84,31 @@ export type SendIntentParams = {
70
84
  chainId: Hex;
71
85
  metadata: IntentMetadataParams;
72
86
  };
87
+ export type IntentDataParams = {
88
+ allowance: Hex;
89
+ tokenSymbol: string;
90
+ tokenAddress: Hex;
91
+ };
92
+ export type SendIntentV2Params = {
93
+ account: Hex;
94
+ delegationHash: Hex;
95
+ chainId: Hex;
96
+ intent: {
97
+ type: ChompIntentType | Exclude<ChompMigrationIntentType, 'cash-migration-premium-transfer'>;
98
+ data: IntentDataParams;
99
+ } | {
100
+ type: 'cash-migration-premium-transfer';
101
+ data: IntentDataParams & {
102
+ /**
103
+ * The predecessor's `personal_sign` signature of the raw digest
104
+ * `keccak256(abi.encode(vaultMigrationHelper, chainId, predecessor,
105
+ * successor, delegationHash))`, which binds the successor as the
106
+ * destination of this delegation.
107
+ */
108
+ userSignature: Hex;
109
+ };
110
+ };
111
+ };
73
112
  export type CreateWithdrawalParams = {
74
113
  chainId: Hex;
75
114
  /** Decimal integer or 0x-prefixed hex string representing the amount. */
@@ -165,6 +204,17 @@ export type SendIntentResponse = {
165
204
  metadata: IntentMetadataResponse;
166
205
  createdAt: string;
167
206
  };
207
+ export type SendIntentV2Response = {
208
+ delegationHash: Hex;
209
+ intent: {
210
+ type: ChompIntentType | ChompMigrationIntentType;
211
+ data: IntentDataParams & {
212
+ /** Only returned for `cash-migration-premium-transfer` intents. */
213
+ userSignature?: Hex;
214
+ };
215
+ };
216
+ createdAt: string;
217
+ };
168
218
  /**
169
219
  * The shape returned by GET /v1/intent/account/:address for each intent.
170
220
  */
@@ -250,6 +300,17 @@ export type AddressIdentityResponse = {
250
300
  successor: Hex | null;
251
301
  };
252
302
  };
303
+ /**
304
+ * Returned by POST /v1/money-account/identities/address/:address/funds-transfer.
305
+ * Addresses are lowercased.
306
+ */
307
+ export type FundsTransferStart = {
308
+ from: Hex;
309
+ to: Hex;
310
+ transfer: MigrationTransfer | null;
311
+ /** Stays `null` for a standard link, and until CHOMP creates it. */
312
+ premiumTransfer: MigrationTransfer | null;
313
+ };
253
314
  export type ServiceDetailsSupportedToken = {
254
315
  tokenAddress: Hex;
255
316
  tokenDecimals: number;
@@ -261,6 +322,11 @@ export type ServiceDetailsProtocol = {
261
322
  };
262
323
  export type ServiceDetailsChain = {
263
324
  autoDepositDelegate: Hex;
325
+ /**
326
+ * The VaultMigrationHelper contract, which redeems the premium migration
327
+ * transfer delegation. Not yet served on every environment.
328
+ */
329
+ vaultMigrationHelperAddress?: Hex;
264
330
  protocol: {
265
331
  vedaProtocol: ServiceDetailsProtocol;
266
332
  vedaPremiumProtocol?: ServiceDetailsProtocol;
@@ -1 +1 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;CACH,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,GAAG,CAAC;IACV,EAAE,EAAE,GAAG,CAAC;IACR,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACnC,oEAAoE;IACpE,eAAe,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAC3C,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;;;OAGG;IACH,2BAA2B,CAAC,EAAE,GAAG,CAAC;IAClC,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// === DERIVED IDENTITY TYPES ===\n\n/**\n * A step that must be completed before a migration link counts as complete.\n * `SUCCESSOR_SUBSCRIPTION_INTENT` and `TRANSFER_INTENT_PVMUSD` are only\n * required for premium subscribers.\n */\nexport type 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/**\n * The settlement status of a Money Account identity chain. `NONE` is never\n * returned as an entry: a profile with no Money Account has no identities.\n */\nexport type DerivedIdentityStatus = 'NONE' | 'MIGRATING' | 'DONE';\n\nexport type MigrationStepState = {\n step: MigrationStep;\n completed: boolean;\n};\n\n/**\n * A funds-transfer execution request that CHOMP creates once every other\n * migration step is complete.\n */\nexport type MigrationTransfer = {\n requestId: string;\n status: string;\n};\n\n/**\n * The latest link of an identity chain while it is migrating.\n */\nexport type DerivedIdentityMigration = {\n from: Hex;\n to: Hex;\n /** The steps required for the link's tier, in canonical order. */\n steps: MigrationStepState[];\n transfer: MigrationTransfer | null;\n /** Stays `null` for a standard link, which never needs one. */\n premiumTransfer: MigrationTransfer | null;\n};\n\n/**\n * One Money Account over time: a chain of addresses joined by links.\n * Addresses are lowercased.\n */\nexport type DerivedIdentity = {\n /** The tip of the chain. Stays on the old address while migrating. */\n currentAddress: Hex;\n /** Earlier addresses, from the immediate predecessor backwards. */\n previousAddresses: Hex[];\n status: DerivedIdentityStatus;\n migration: DerivedIdentityMigration | null;\n};\n\n/**\n * Returned by GET /v1/money-account/identities.\n */\nexport type DerivedIdentitiesResponse = {\n identities: DerivedIdentity[];\n};\n\nexport type DerivedIdentityAddressRole =\n | 'CURRENT'\n | 'PREVIOUS'\n | 'PENDING_SUCCESSOR';\n\n/**\n * Returned by GET /v1/money-account/identities/address/:address. Addresses\n * are lowercased.\n */\nexport type AddressIdentityResponse = {\n identity: DerivedIdentity;\n address: {\n address: Hex;\n role: DerivedIdentityAddressRole;\n predecessor: Hex | null;\n successor: Hex | null;\n };\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"]}
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\n/**\n * The CHOMP intent types that complete the Money Account migration steps\n * signed by the predecessor address. They can only be created through\n * `POST /v2/intent`.\n *\n * - `cash-migration-root`: root delegation from the predecessor to the\n * successor.\n * - `cash-migration-transfer`: open delegation that lets any redeemer\n * transfer one token (mUSD or vmUSD) from the predecessor only to the\n * successor.\n * - `cash-migration-premium-transfer`: delegation from the predecessor to\n * CHOMP that moves the pvmUSD balance to the successor. Premium only.\n */\nexport type ChompMigrationIntentType =\n | 'cash-migration-root'\n | 'cash-migration-transfer'\n | 'cash-migration-premium-transfer';\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 IntentDataParams = {\n allowance: Hex;\n tokenSymbol: string;\n tokenAddress: Hex;\n};\n\nexport type SendIntentV2Params = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n intent:\n | {\n type:\n | ChompIntentType\n | Exclude<\n ChompMigrationIntentType,\n 'cash-migration-premium-transfer'\n >;\n data: IntentDataParams;\n }\n | {\n type: 'cash-migration-premium-transfer';\n data: IntentDataParams & {\n /**\n * The predecessor's `personal_sign` signature of the raw digest\n * `keccak256(abi.encode(vaultMigrationHelper, chainId, predecessor,\n * successor, delegationHash))`, which binds the successor as the\n * destination of this delegation.\n */\n userSignature: Hex;\n };\n };\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\nexport type SendIntentV2Response = {\n delegationHash: Hex;\n intent: {\n type: ChompIntentType | ChompMigrationIntentType;\n data: IntentDataParams & {\n /** Only returned for `cash-migration-premium-transfer` intents. */\n userSignature?: Hex;\n };\n };\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// === DERIVED IDENTITY TYPES ===\n\n/**\n * A step that must be completed before a migration link counts as complete.\n * `SUCCESSOR_SUBSCRIPTION_INTENT` and `TRANSFER_INTENT_PVMUSD` are only\n * required for premium subscribers.\n */\nexport type 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/**\n * The settlement status of a Money Account identity chain. `NONE` is never\n * returned as an entry: a profile with no Money Account has no identities.\n */\nexport type DerivedIdentityStatus = 'NONE' | 'MIGRATING' | 'DONE';\n\nexport type MigrationStepState = {\n step: MigrationStep;\n completed: boolean;\n};\n\n/**\n * A funds-transfer execution request that CHOMP creates once every other\n * migration step is complete.\n */\nexport type MigrationTransfer = {\n requestId: string;\n status: string;\n};\n\n/**\n * The latest link of an identity chain while it is migrating.\n */\nexport type DerivedIdentityMigration = {\n from: Hex;\n to: Hex;\n /** The steps required for the link's tier, in canonical order. */\n steps: MigrationStepState[];\n transfer: MigrationTransfer | null;\n /** Stays `null` for a standard link, which never needs one. */\n premiumTransfer: MigrationTransfer | null;\n};\n\n/**\n * One Money Account over time: a chain of addresses joined by links.\n * Addresses are lowercased.\n */\nexport type DerivedIdentity = {\n /** The tip of the chain. Stays on the old address while migrating. */\n currentAddress: Hex;\n /** Earlier addresses, from the immediate predecessor backwards. */\n previousAddresses: Hex[];\n status: DerivedIdentityStatus;\n migration: DerivedIdentityMigration | null;\n};\n\n/**\n * Returned by GET /v1/money-account/identities.\n */\nexport type DerivedIdentitiesResponse = {\n identities: DerivedIdentity[];\n};\n\nexport type DerivedIdentityAddressRole =\n | 'CURRENT'\n | 'PREVIOUS'\n | 'PENDING_SUCCESSOR';\n\n/**\n * Returned by GET /v1/money-account/identities/address/:address. Addresses\n * are lowercased.\n */\nexport type AddressIdentityResponse = {\n identity: DerivedIdentity;\n address: {\n address: Hex;\n role: DerivedIdentityAddressRole;\n predecessor: Hex | null;\n successor: Hex | null;\n };\n};\n\n/**\n * Returned by POST /v1/money-account/identities/address/:address/funds-transfer.\n * Addresses are lowercased.\n */\nexport type FundsTransferStart = {\n from: Hex;\n to: Hex;\n transfer: MigrationTransfer | null;\n /** Stays `null` for a standard link, and until CHOMP creates it. */\n premiumTransfer: MigrationTransfer | null;\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 /**\n * The VaultMigrationHelper contract, which redeems the premium migration\n * transfer delegation. Not yet served on every environment.\n */\n vaultMigrationHelperAddress?: 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": "7.0.0-preview-40b7a961e",
3
+ "version": "7.0.0-preview-486391fb9",
4
4
  "description": "Data service for the Chomp API",
5
5
  "keywords": [
6
6
  "Ethereum",