diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 91c61401f6..1819430016 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -40,6 +40,7 @@ ## Earn Team /packages/earn-controller @MetaMask/earn /packages/money-account-balance-service @MetaMask/earn +/packages/chomp-api-service @MetaMask/earn @MetaMask/delegation ## Social AI Team /packages/ai-controllers @MetaMask/social-ai @@ -229,3 +230,5 @@ /packages/social-controllers/CHANGELOG.md @MetaMask/social-ai @MetaMask/core-platform /packages/money-account-controller/package.json @MetaMask/accounts-engineers @MetaMask/core-platform /packages/money-account-controller/CHANGELOG.md @MetaMask/accounts-engineers @MetaMask/core-platform +/packages/chomp-api-service/package.json @MetaMask/earn @MetaMask/delegation @MetaMask/core-platform +/packages/chomp-api-service/CHANGELOG.md @MetaMask/earn @MetaMask/delegation @MetaMask/core-platform diff --git a/README.md b/README.md index 83f276c0a0..98c5599b03 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ Each package in this repository has its own README where you can find installati - [`@metamask/bridge-status-controller`](packages/bridge-status-controller) - [`@metamask/build-utils`](packages/build-utils) - [`@metamask/chain-agnostic-permission`](packages/chain-agnostic-permission) +- [`@metamask/chomp-api-service`](packages/chomp-api-service) - [`@metamask/claims-controller`](packages/claims-controller) - [`@metamask/client-controller`](packages/client-controller) - [`@metamask/compliance-controller`](packages/compliance-controller) @@ -124,6 +125,7 @@ linkStyle default opacity:0.5 bridge_status_controller(["@metamask/bridge-status-controller"]); build_utils(["@metamask/build-utils"]); chain_agnostic_permission(["@metamask/chain-agnostic-permission"]); + chomp_api_service(["@metamask/chomp-api-service"]); claims_controller(["@metamask/claims-controller"]); client_controller(["@metamask/client-controller"]); compliance_controller(["@metamask/compliance-controller"]); @@ -277,6 +279,9 @@ linkStyle default opacity:0.5 bridge_status_controller --> transaction_controller; chain_agnostic_permission --> controller_utils; chain_agnostic_permission --> permission_controller; + chomp_api_service --> base_data_service; + chomp_api_service --> controller_utils; + chomp_api_service --> messenger; claims_controller --> base_controller; claims_controller --> controller_utils; claims_controller --> keyring_controller; diff --git a/packages/chomp-api-service/CHANGELOG.md b/packages/chomp-api-service/CHANGELOG.md new file mode 100644 index 0000000000..77f2d8816a --- /dev/null +++ b/packages/chomp-api-service/CHANGELOG.md @@ -0,0 +1,14 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- Add `ChompApiService` ([#8413](https://github.com/MetaMask/core/pull/8413)) + +[Unreleased]: https://github.com/MetaMask/core/ diff --git a/packages/chomp-api-service/LICENSE b/packages/chomp-api-service/LICENSE new file mode 100644 index 0000000000..c8a0ff6be3 --- /dev/null +++ b/packages/chomp-api-service/LICENSE @@ -0,0 +1,20 @@ +MIT License + +Copyright (c) 2026 MetaMask + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE diff --git a/packages/chomp-api-service/README.md b/packages/chomp-api-service/README.md new file mode 100644 index 0000000000..d1b2943f48 --- /dev/null +++ b/packages/chomp-api-service/README.md @@ -0,0 +1,15 @@ +# `@metamask/chomp-api-service` + +Chomp API data service. + +## Installation + +`yarn add @metamask/chomp-api-service` + +or + +`npm install @metamask/chomp-api-service` + +## Contributing + +This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme). diff --git a/packages/chomp-api-service/jest.config.js b/packages/chomp-api-service/jest.config.js new file mode 100644 index 0000000000..ca08413339 --- /dev/null +++ b/packages/chomp-api-service/jest.config.js @@ -0,0 +1,26 @@ +/* + * For a detailed explanation regarding each configuration property and type check, visit: + * https://jestjs.io/docs/configuration + */ + +const merge = require('deepmerge'); +const path = require('path'); + +const baseConfig = require('../../jest.config.packages'); + +const displayName = path.basename(__dirname); + +module.exports = merge(baseConfig, { + // The display name when running multiple projects + displayName, + + // An object that configures minimum threshold enforcement for coverage results + coverageThreshold: { + global: { + branches: 100, + functions: 100, + lines: 100, + statements: 100, + }, + }, +}); diff --git a/packages/chomp-api-service/package.json b/packages/chomp-api-service/package.json new file mode 100644 index 0000000000..ccb790bb81 --- /dev/null +++ b/packages/chomp-api-service/package.json @@ -0,0 +1,76 @@ +{ + "name": "@metamask/chomp-api-service", + "version": "0.0.0", + "description": "Data service for the Chomp API", + "keywords": [ + "Ethereum", + "MetaMask" + ], + "homepage": "https://github.com/MetaMask/core/tree/main/packages/chomp-api-service#readme", + "bugs": { + "url": "https://github.com/MetaMask/core/issues" + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/MetaMask/core.git" + }, + "files": [ + "dist/" + ], + "sideEffects": false, + "main": "./dist/index.cjs", + "types": "./dist/index.d.cts", + "exports": { + ".": { + "import": { + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" + }, + "require": { + "types": "./dist/index.d.cts", + "default": "./dist/index.cjs" + } + }, + "./package.json": "./package.json" + }, + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + }, + "scripts": { + "build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references", + "build:all": "ts-bridge --project tsconfig.build.json --verbose --clean", + "build:docs": "typedoc", + "changelog:update": "../../scripts/update-changelog.sh @metamask/chomp-api-service", + "changelog:validate": "../../scripts/validate-changelog.sh @metamask/chomp-api-service", + "since-latest-release": "../../scripts/since-latest-release.sh", + "test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter", + "test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache", + "test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose", + "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch" + }, + "dependencies": { + "@metamask/base-data-service": "^0.1.1", + "@metamask/controller-utils": "^11.20.0", + "@metamask/messenger": "^1.1.1", + "@metamask/superstruct": "^3.1.0", + "@metamask/utils": "^11.9.0", + "@tanstack/query-core": "^4.43.0" + }, + "devDependencies": { + "@metamask/auto-changelog": "^6.1.0", + "@ts-bridge/cli": "^0.6.4", + "@types/jest": "^29.5.14", + "deepmerge": "^4.2.2", + "jest": "^29.7.0", + "nock": "^13.3.1", + "ts-jest": "^29.2.5", + "typedoc": "^0.25.13", + "typedoc-plugin-missing-exports": "^2.0.0", + "typescript": "~5.3.3" + }, + "engines": { + "node": "^18.18 || >=20" + } +} diff --git a/packages/chomp-api-service/src/chomp-api-service-method-action-types.ts b/packages/chomp-api-service/src/chomp-api-service-method-action-types.ts new file mode 100644 index 0000000000..7b878bd16a --- /dev/null +++ b/packages/chomp-api-service/src/chomp-api-service-method-action-types.ts @@ -0,0 +1,83 @@ +/** + * This file is auto generated. + * Do not edit manually. + */ + +import type { ChompApiService } from './chomp-api-service'; + +/** + * Associates an address with a CHOMP profile via POST /v1/auth/address. + */ +export type ChompApiServiceAssociateAddressAction = { + type: `ChompApiService:associateAddress`; + handler: ChompApiService['associateAddress']; +}; + +/** + * Creates an account upgrade via POST /v1/account-upgrade. + */ +export type ChompApiServiceCreateUpgradeAction = { + type: `ChompApiService:createUpgrade`; + handler: ChompApiService['createUpgrade']; +}; + +/** + * Fetches the upgrade record for an address via GET /v1/account-upgrade/:address. + */ +export type ChompApiServiceGetUpgradeAction = { + type: `ChompApiService:getUpgrade`; + handler: ChompApiService['getUpgrade']; +}; + +/** + * Verifies a delegation via POST /v1/intent/verify-delegation. + */ +export type ChompApiServiceVerifyDelegationAction = { + type: `ChompApiService:verifyDelegation`; + handler: ChompApiService['verifyDelegation']; +}; + +/** + * Submits intents via POST /v1/intent. + */ +export type ChompApiServiceCreateIntentsAction = { + type: `ChompApiService:createIntents`; + handler: ChompApiService['createIntents']; +}; + +/** + * Fetches intents by address via GET /v1/intent/account/:address. + */ +export type ChompApiServiceGetIntentsByAddressAction = { + type: `ChompApiService:getIntentsByAddress`; + handler: ChompApiService['getIntentsByAddress']; +}; + +/** + * Submits a withdrawal request via POST /v1/withdrawal + */ +export type ChompApiServiceCreateWithdrawalAction = { + type: `ChompApiService:createWithdrawal`; + handler: ChompApiService['createWithdrawal']; +}; + +/** + * Retrieves service details via GET /v1/chomp. + */ +export type ChompApiServiceGetServiceDetailsAction = { + type: `ChompApiService:getServiceDetails`; + handler: ChompApiService['getServiceDetails']; +}; + +/** + * Union of all ChompApiService action types. + */ +export type ChompApiServiceMethodActions = + | ChompApiServiceAssociateAddressAction + | ChompApiServiceCreateUpgradeAction + | ChompApiServiceGetUpgradeAction + | ChompApiServiceVerifyDelegationAction + | ChompApiServiceCreateIntentsAction + | ChompApiServiceGetIntentsByAddressAction + | ChompApiServiceCreateWithdrawalAction + | ChompApiServiceGetServiceDetailsAction; diff --git a/packages/chomp-api-service/src/chomp-api-service.test.ts b/packages/chomp-api-service/src/chomp-api-service.test.ts new file mode 100644 index 0000000000..6b538ef480 --- /dev/null +++ b/packages/chomp-api-service/src/chomp-api-service.test.ts @@ -0,0 +1,598 @@ +import { DEFAULT_MAX_RETRIES } from '@metamask/controller-utils'; +import { Messenger, MOCK_ANY_NAMESPACE } from '@metamask/messenger'; +import type { + MockAnyNamespace, + MessengerActions, + MessengerEvents, +} from '@metamask/messenger'; +import nock from 'nock'; + +import type { ChompApiServiceMessenger } from './chomp-api-service'; +import { ChompApiService } from './chomp-api-service'; + +const BASE_URL = 'https://api.chomp.example.com'; +const MOCK_TOKEN = 'mock-jwt-token'; + +describe('ChompApiService', () => { + describe('associateAddress', () => { + const associateParams = { + signature: '0x123' as const, + timestamp: '2026-01-01T00:00:00Z', + address: '0xabc' as const, + }; + + it('sends a POST with auth headers and returns the response on 201', async () => { + nock(BASE_URL) + .post('/v1/auth/address', associateParams) + .matchHeader('Authorization', `Bearer ${MOCK_TOKEN}`) + .matchHeader('Content-Type', 'application/json') + .reply(201, { + profileId: 'p1', + address: '0xabc', + status: 'created', + }); + const { rootMessenger } = createService(); + + const result = await rootMessenger.call( + 'ChompApiService:associateAddress', + associateParams, + ); + + expect(result).toStrictEqual({ + profileId: 'p1', + address: '0xabc', + status: 'created', + }); + }); + + it('returns the response on 409 without throwing', async () => { + nock(BASE_URL).post('/v1/auth/address').reply(409, { + profileId: 'p1', + address: '0xabc', + status: 'already_associated', + }); + const { service } = createService(); + + const result = await service.associateAddress(associateParams); + + expect(result).toStrictEqual({ + profileId: 'p1', + address: '0xabc', + status: 'already_associated', + }); + }); + + it('throws on non-201/409 status', async () => { + nock(BASE_URL) + .post('/v1/auth/address') + .times(DEFAULT_MAX_RETRIES + 1) + .reply(500); + const { service } = createService(); + + await expect(service.associateAddress(associateParams)).rejects.toThrow( + "POST /v1/auth/address failed with status '500'", + ); + }); + + it('throws on malformed response', async () => { + nock(BASE_URL) + .post('/v1/auth/address') + .reply(201, JSON.stringify({ missing: 'fields' })); + const { service } = createService(); + + await expect(service.associateAddress(associateParams)).rejects.toThrow( + 'At path: profileId -- Expected a string', + ); + }); + }); + + describe('createUpgrade', () => { + const upgradeParams = { + r: '0x1' as const, + s: '0x2' as const, + v: 27, + yParity: 0, + address: '0xabc' as const, + chainId: '1', + nonce: '0', + }; + + const upgradeResponse = { + signerAddress: '0xdef', + status: 'pending', + createdAt: '2026-01-01T00:00:00Z', + }; + + it('sends a POST with auth headers and returns the response', async () => { + nock(BASE_URL) + .post('/v1/account-upgrade', upgradeParams) + .matchHeader('Authorization', `Bearer ${MOCK_TOKEN}`) + .reply(200, upgradeResponse); + const { rootMessenger } = createService(); + + const result = await rootMessenger.call( + 'ChompApiService:createUpgrade', + upgradeParams, + ); + + expect(result).toStrictEqual(upgradeResponse); + }); + + it('throws on non-OK status', async () => { + nock(BASE_URL) + .post('/v1/account-upgrade') + .times(DEFAULT_MAX_RETRIES + 1) + .reply(500); + const { service } = createService(); + + await expect(service.createUpgrade(upgradeParams)).rejects.toThrow( + "POST /v1/account-upgrade failed with status '500'", + ); + }); + + it('throws on malformed response', async () => { + nock(BASE_URL) + .post('/v1/account-upgrade') + .reply(200, JSON.stringify({ bad: 'data' })); + const { service } = createService(); + + await expect(service.createUpgrade(upgradeParams)).rejects.toThrow( + 'At path: signerAddress -- Expected a string', + ); + }); + }); + + describe('getUpgrade', () => { + const upgradeRecord = { + signerAddress: '0xdef', + status: 'pending', + createdAt: '2026-01-01T00:00:00Z', + }; + + it('sends a GET with auth headers and returns the upgrade record', async () => { + nock(BASE_URL) + .get('/v1/account-upgrade/0xabc') + .matchHeader('Authorization', `Bearer ${MOCK_TOKEN}`) + .reply(200, upgradeRecord); + const { rootMessenger } = createService(); + + const result = await rootMessenger.call( + 'ChompApiService:getUpgrade', + '0xabc', + ); + + expect(result).toStrictEqual(upgradeRecord); + }); + + it('returns null on 404', async () => { + nock(BASE_URL).get('/v1/account-upgrade/0xabc').reply(404); + const { service } = createService(); + + const result = await service.getUpgrade('0xabc'); + + expect(result).toBeNull(); + }); + + it('throws on non-OK/non-404 status', async () => { + nock(BASE_URL) + .get('/v1/account-upgrade/0xabc') + .times(DEFAULT_MAX_RETRIES + 1) + .reply(500); + const { service } = createService(); + + await expect(service.getUpgrade('0xabc')).rejects.toThrow( + "Get upgrade request failed with status '500'", + ); + }); + + it('throws on malformed response', async () => { + nock(BASE_URL) + .get('/v1/account-upgrade/0xabc') + .reply(200, JSON.stringify({ bad: 'data' })); + const { service } = createService(); + + await expect(service.getUpgrade('0xabc')).rejects.toThrow( + 'At path: signerAddress -- Expected a string', + ); + }); + }); + + describe('verifyDelegation', () => { + const delegationParams = { + signedDelegation: { + delegate: '0x1' as const, + delegator: '0x2' as const, + authority: '0x3' as const, + caveats: [], + salt: '0x4' as const, + signature: '0x5' as const, + }, + chainId: '0x1' as const, + }; + + it('sends a POST with auth headers and returns the response', async () => { + nock(BASE_URL) + .post('/v1/intent/verify-delegation', delegationParams) + .matchHeader('Authorization', `Bearer ${MOCK_TOKEN}`) + .reply(200, { valid: true, delegationHash: '0xabc123' }); + const { rootMessenger } = createService(); + + const result = await rootMessenger.call( + 'ChompApiService:verifyDelegation', + delegationParams, + ); + + expect(result).toStrictEqual({ + valid: true, + delegationHash: '0xabc123', + }); + }); + + it('returns errors when delegation is invalid', async () => { + nock(BASE_URL) + .post('/v1/intent/verify-delegation') + .reply(200, { valid: false, errors: ['bad signature'] }); + const { service } = createService(); + + const result = await service.verifyDelegation(delegationParams); + + expect(result).toStrictEqual({ + valid: false, + errors: ['bad signature'], + }); + }); + + it('throws on non-OK status', async () => { + nock(BASE_URL) + .post('/v1/intent/verify-delegation') + .times(DEFAULT_MAX_RETRIES + 1) + .reply(400); + const { service } = createService(); + + await expect(service.verifyDelegation(delegationParams)).rejects.toThrow( + "POST /v1/intent/verify-delegation failed with status '400'", + ); + }); + + it('throws on malformed response', async () => { + nock(BASE_URL) + .post('/v1/intent/verify-delegation') + .reply(200, JSON.stringify({ bad: 'data' })); + const { service } = createService(); + + await expect(service.verifyDelegation(delegationParams)).rejects.toThrow( + 'At path: valid -- Expected a value of type `boolean`', + ); + }); + }); + + describe('createIntents', () => { + const intentParams = [ + { + account: '0xabc' as const, + delegationHash: '0xdef' as const, + chainId: '0x1' as const, + metadata: { + allowance: '0xff' as const, + tokenSymbol: 'USDC', + tokenAddress: '0x123' as const, + type: 'cash-deposit' as const, + }, + }, + ]; + + const intentResponse = [ + { + delegationHash: '0xdef', + metadata: { + allowance: '0xff', + tokenSymbol: 'USDC', + tokenAddress: '0x123', + type: 'cash-deposit', + }, + createdAt: '2026-01-01T00:00:00Z', + }, + ]; + + it('sends a POST with auth headers and returns the response array', async () => { + nock(BASE_URL) + .post('/v1/intent', intentParams) + .matchHeader('Authorization', `Bearer ${MOCK_TOKEN}`) + .reply(201, intentResponse); + const { rootMessenger } = createService(); + + const result = await rootMessenger.call( + 'ChompApiService:createIntents', + intentParams, + ); + + expect(result).toStrictEqual(intentResponse); + }); + + it('throws on non-OK status', async () => { + nock(BASE_URL) + .post('/v1/intent') + .times(DEFAULT_MAX_RETRIES + 1) + .reply(409); + const { service } = createService(); + + await expect(service.createIntents(intentParams)).rejects.toThrow( + "POST /v1/intent failed with status '409'", + ); + }); + + it('throws on malformed response', async () => { + nock(BASE_URL) + .post('/v1/intent') + .reply(201, JSON.stringify([{ bad: 'data' }])); + const { service } = createService(); + + await expect(service.createIntents(intentParams)).rejects.toThrow( + 'At path: 0.delegationHash -- Expected a string', + ); + }); + }); + + describe('getIntentsByAddress', () => { + const intentsResponse = [ + { + account: '0xabc', + delegationHash: '0xdef', + chainId: '0x1', + status: 'active', + metadata: { + allowance: '0xff', + tokenAddress: '0x123', + tokenSymbol: 'USDC', + type: 'deposit', + }, + }, + ]; + + it('sends a GET with auth headers and returns the intents array', async () => { + nock(BASE_URL) + .get('/v1/intent/account/0xabc') + .matchHeader('Authorization', `Bearer ${MOCK_TOKEN}`) + .reply(200, intentsResponse); + const { rootMessenger } = createService(); + + const result = await rootMessenger.call( + 'ChompApiService:getIntentsByAddress', + '0xabc', + ); + + expect(result).toStrictEqual(intentsResponse); + }); + + it('returns an empty array when no intents exist', async () => { + nock(BASE_URL).get('/v1/intent/account/0xabc').reply(200, []); + const { service } = createService(); + + const result = await service.getIntentsByAddress('0xabc'); + + expect(result).toStrictEqual([]); + }); + + it('throws on non-OK status', async () => { + nock(BASE_URL) + .get('/v1/intent/account/0xabc') + .times(DEFAULT_MAX_RETRIES + 1) + .reply(500); + const { service } = createService(); + + await expect(service.getIntentsByAddress('0xabc')).rejects.toThrow( + "Get intents request failed with status '500'", + ); + }); + + it('throws on malformed response', async () => { + nock(BASE_URL) + .get('/v1/intent/account/0xabc') + .reply(200, JSON.stringify([{ bad: 'data' }])); + const { service } = createService(); + + await expect(service.getIntentsByAddress('0xabc')).rejects.toThrow( + 'At path: 0.account -- Expected a string, but received: undefined', + ); + }); + }); + + describe('createWithdrawal', () => { + const withdrawalParams = { + chainId: '0x1' as const, + amount: '1000000', + account: '0xabc' as const, + }; + + it('sends a POST with auth headers and returns the response', async () => { + nock(BASE_URL) + .post('/v1/withdrawal', withdrawalParams) + .matchHeader('Authorization', `Bearer ${MOCK_TOKEN}`) + .reply(200, { success: true }); + const { rootMessenger } = createService(); + + const result = await rootMessenger.call( + 'ChompApiService:createWithdrawal', + withdrawalParams, + ); + + expect(result).toStrictEqual({ success: true }); + }); + + it('throws on non-OK status', async () => { + nock(BASE_URL) + .post('/v1/withdrawal') + .times(DEFAULT_MAX_RETRIES + 1) + .reply(400); + const { service } = createService(); + + await expect(service.createWithdrawal(withdrawalParams)).rejects.toThrow( + "POST /v1/withdrawal failed with status '400'", + ); + }); + + it('throws on malformed response', async () => { + nock(BASE_URL) + .post('/v1/withdrawal') + .reply(200, JSON.stringify({ success: false })); + const { service } = createService(); + + await expect(service.createWithdrawal(withdrawalParams)).rejects.toThrow( + 'At path: success -- Expected the literal `true`', + ); + }); + }); + + describe('getServiceDetails', () => { + const serviceDetailsResponse = { + auth: { + message: 'CHOMP Authentication ', + }, + chains: { + '0xa4b1': { + autoDepositDelegate: '0xb4827a2a066cd2ef88560efdf063dd05c6c41cc7', + protocol: { + vedaProtocol: { + supportedTokens: [ + { + tokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', + tokenDecimals: 6, + }, + ], + adapterAddress: '0x4839b1BA117BdFFA986FCfA4E5fE6b9027b8f8B1', + intentTypes: ['cash-deposit', 'cash-withdrawal'], + }, + }, + }, + }, + }; + + it('sends a GET with auth headers and chainId query param and returns the response', async () => { + nock(BASE_URL) + .get('/v1/chomp') + .query({ chainId: '0xa4b1' }) + .matchHeader('Authorization', `Bearer ${MOCK_TOKEN}`) + .reply(200, serviceDetailsResponse); + const { rootMessenger } = createService(); + + const result = await rootMessenger.call( + 'ChompApiService:getServiceDetails', + ['0xa4b1'], + ); + + expect(result).toStrictEqual(serviceDetailsResponse); + }); + + it('supports multiple chain IDs as a comma-separated query param', async () => { + nock(BASE_URL) + .get('/v1/chomp') + .query({ chainId: '0xa4b1,0x1' }) + .matchHeader('Authorization', `Bearer ${MOCK_TOKEN}`) + .reply(200, serviceDetailsResponse); + const { service } = createService(); + + const result = await service.getServiceDetails(['0xa4b1', '0x1']); + + expect(result).toStrictEqual(serviceDetailsResponse); + }); + + it('throws on non-OK status', async () => { + nock(BASE_URL) + .get('/v1/chomp') + .query({ chainId: '0xa4b1' }) + .times(DEFAULT_MAX_RETRIES + 1) + .reply(400); + const { service } = createService(); + + await expect(service.getServiceDetails(['0xa4b1'])).rejects.toThrow( + "GET /v1/chomp failed with status '400'", + ); + }); + + it('throws on malformed response', async () => { + nock(BASE_URL) + .get('/v1/chomp') + .query({ chainId: '0xa4b1' }) + .reply(200, JSON.stringify({ bad: 'data' })); + const { service } = createService(); + + await expect(service.getServiceDetails(['0xa4b1'])).rejects.toThrow( + 'At path: auth -- Expected an object', + ); + }); + }); +}); + +/** + * The type of the messenger populated with all external actions and events + * required by the service under test. + */ +type RootMessenger = Messenger< + MockAnyNamespace, + MessengerActions, + MessengerEvents +>; + +/** + * Constructs the messenger populated with all external actions and events + * required by the service under test. + * + * @returns The root messenger. + */ +function createRootMessenger(): RootMessenger { + return new Messenger({ namespace: MOCK_ANY_NAMESPACE }); +} + +/** + * Constructs the messenger for the service under test. + * + * @param rootMessenger - The root messenger, with all external actions and + * events required by the controller's messenger. + * @returns The service-specific messenger. + */ +function createServiceMessenger( + rootMessenger: RootMessenger, +): ChompApiServiceMessenger { + return new Messenger({ + namespace: 'ChompApiService', + parent: rootMessenger, + }); +} + +/** + * Constructs the service under test. + * + * @param args - The arguments to this function. + * @param args.options - The options that the service constructor takes. All are + * optional and will be filled in with defaults as needed (including + * `messenger`). + * @returns The new service, root messenger, and service messenger. + */ +function createService({ + options = {}, +}: { + options?: Partial[0]>; +} = {}): { + service: ChompApiService; + rootMessenger: RootMessenger; + messenger: ChompApiServiceMessenger; +} { + const rootMessenger = createRootMessenger(); + rootMessenger.registerActionHandler( + 'AuthenticationController:getBearerToken', + async () => MOCK_TOKEN, + ); + const messenger = createServiceMessenger(rootMessenger); + rootMessenger.delegate({ + messenger, + actions: ['AuthenticationController:getBearerToken'], + events: [], + }); + const service = new ChompApiService({ + baseUrl: BASE_URL, + messenger, + ...options, + }); + + return { service, rootMessenger, messenger }; +} diff --git a/packages/chomp-api-service/src/chomp-api-service.ts b/packages/chomp-api-service/src/chomp-api-service.ts new file mode 100644 index 0000000000..082e7c74f1 --- /dev/null +++ b/packages/chomp-api-service/src/chomp-api-service.ts @@ -0,0 +1,558 @@ +import { BaseDataService } from '@metamask/base-data-service'; +import type { + DataServiceCacheUpdatedEvent, + DataServiceGranularCacheUpdatedEvent, + DataServiceInvalidateQueriesAction, +} from '@metamask/base-data-service'; +import type { CreateServicePolicyOptions } from '@metamask/controller-utils'; +import { HttpError } from '@metamask/controller-utils'; +import type { Messenger } from '@metamask/messenger'; +import { + array, + boolean, + create, + enums, + literal, + number, + optional, + record, + string, + type, +} from '@metamask/superstruct'; +import type { Hex } from '@metamask/utils'; +import { StrictHexStruct } from '@metamask/utils'; +import type { QueryClientConfig } from '@tanstack/query-core'; + +import type { ChompApiServiceMethodActions } from './chomp-api-service-method-action-types'; +import type { + AssociateAddressParams, + AssociateAddressResponse, + CreateUpgradeParams, + UpgradeResponse, + CreateWithdrawalParams, + CreateWithdrawalResponse, + IntentEntry, + SendIntentParams, + SendIntentResponse, + ServiceDetailsResponse, + VerifyDelegationParams, + VerifyDelegationResponse, +} from './types'; + +// === GENERAL === + +/** + * The name of the {@link ChompApiService}, used to namespace the service's + * actions and events. + */ +export const serviceName = 'ChompApiService'; + +// === MESSENGER === + +/** + * All of the methods within {@link ChompApiService} that are exposed via the + * messenger. + */ +const MESSENGER_EXPOSED_METHODS = [ + 'associateAddress', + 'createUpgrade', + 'getUpgrade', + 'verifyDelegation', + 'createIntents', + 'getIntentsByAddress', + 'createWithdrawal', + 'getServiceDetails', +] as const; + +/** + * Invalidates cached queries for {@link ChompApiService}. + */ +export type ChompApiServiceInvalidateQueriesAction = + DataServiceInvalidateQueriesAction; + +/** + * Actions that {@link ChompApiService} exposes to other consumers. + */ +export type ChompApiServiceActions = + | ChompApiServiceMethodActions + | ChompApiServiceInvalidateQueriesAction; + +/** + * Actions from other messengers that {@link ChompApiService} calls. + */ +type AllowedActions = { + type: 'AuthenticationController:getBearerToken'; + handler: (entropySourceId?: string) => Promise; +}; + +/** + * Published when {@link ChompApiService}'s cache is updated. + */ +export type ChompApiServiceCacheUpdatedEvent = DataServiceCacheUpdatedEvent< + typeof serviceName +>; + +/** + * Published when a key within {@link ChompApiService}'s cache is updated. + */ +export type ChompApiServiceGranularCacheUpdatedEvent = + DataServiceGranularCacheUpdatedEvent; + +/** + * Events that {@link ChompApiService} exposes to other consumers. + */ +export type ChompApiServiceEvents = + | ChompApiServiceCacheUpdatedEvent + | ChompApiServiceGranularCacheUpdatedEvent; + +/** + * Events from other messengers that {@link ChompApiService} subscribes to. + */ +type AllowedEvents = never; + +/** + * The messenger which is restricted to actions and events accessed by + * {@link ChompApiService}. + */ +export type ChompApiServiceMessenger = Messenger< + typeof serviceName, + ChompApiServiceActions | AllowedActions, + ChompApiServiceEvents | AllowedEvents +>; + +// === RESPONSE VALIDATION === + +const AssociateAddressResponseStruct = type({ + profileId: string(), + address: StrictHexStruct, + status: string(), +}); + +const UpgradeResponseStruct = type({ + signerAddress: StrictHexStruct, + status: string(), + createdAt: string(), +}); + +const VerifyDelegationResponseStruct = type({ + valid: boolean(), + delegationHash: optional(StrictHexStruct), + errors: optional(array(string())), +}); + +const SendIntentResponseArrayStruct = array( + type({ + delegationHash: StrictHexStruct, + metadata: type({ + allowance: StrictHexStruct, + tokenSymbol: string(), + tokenAddress: StrictHexStruct, + type: enums(['cash-deposit', 'cash-withdrawal']), + }), + createdAt: string(), + }), +); + +const IntentEntryArrayStruct = array( + type({ + account: StrictHexStruct, + delegationHash: StrictHexStruct, + chainId: StrictHexStruct, + status: enums(['active', 'revoked']), + metadata: type({ + allowance: StrictHexStruct, + tokenAddress: StrictHexStruct, + tokenSymbol: string(), + type: enums(['deposit', 'withdraw']), + }), + }), +); + +const CreateWithdrawalResponseStruct = type({ + success: literal(true), +}); + +const ServiceDetailsProtocolStruct = type({ + supportedTokens: array( + type({ + tokenAddress: StrictHexStruct, + tokenDecimals: number(), + }), + ), + adapterAddress: StrictHexStruct, + intentTypes: array(enums(['cash-deposit', 'cash-withdrawal'])), +}); + +const ServiceDetailsResponseStruct = type({ + auth: type({ + message: string(), + }), + chains: record( + StrictHexStruct, + type({ + autoDepositDelegate: StrictHexStruct, + protocol: record(string(), ServiceDetailsProtocolStruct), + }), + ), +}); + +// === SERVICE DEFINITION === + +/** + * This service is responsible for communicating with the CHOMP API. + * + * All requests are authenticated via JWT Bearer tokens obtained from the + * `AuthenticationController:getBearerToken` messenger action. + */ +export class ChompApiService extends BaseDataService< + typeof serviceName, + ChompApiServiceMessenger +> { + readonly #baseUrl: string; + + /** + * Constructs a new ChompApiService. + * + * @param args - The constructor arguments. + * @param args.messenger - The messenger suited for this service. + * @param args.baseUrl - The base URL of the CHOMP API. + * @param args.queryClientConfig - Configuration for the underlying TanStack + * Query client. + * @param args.policyOptions - Options to pass to `createServicePolicy`. + */ + constructor({ + messenger, + baseUrl, + queryClientConfig = {}, + policyOptions = {}, + }: { + messenger: ChompApiServiceMessenger; + baseUrl: string; + queryClientConfig?: QueryClientConfig; + policyOptions?: CreateServicePolicyOptions; + }) { + super({ + name: serviceName, + messenger, + queryClientConfig, + policyOptions, + }); + + this.#baseUrl = baseUrl; + + this.messenger.registerMethodActionHandlers( + this, + MESSENGER_EXPOSED_METHODS, + ); + } + + /** + * Builds the standard headers for an authenticated CHOMP API request. + * + * @returns Headers including Authorization and Content-Type. + */ + async #authHeaders(): Promise> { + const token = await this.messenger.call( + 'AuthenticationController:getBearerToken', + ); + return { + Authorization: `Bearer ${token}`, + 'Content-Type': 'application/json', + }; + } + + /** + * Associates an address with a CHOMP profile. + * + * POST /v1/auth/address + * + * @param params - The association params containing signature, timestamp, + * and address. + * @returns The profile association result. Returns on both 201 and 409. + */ + async associateAddress( + params: AssociateAddressParams, + ): Promise { + const jsonResponse = await this.fetchQuery({ + queryKey: [`${this.name}:associateAddress`, params], + staleTime: 0, + queryFn: async () => { + const headers = await this.#authHeaders(); + const response = await fetch( + new URL('/v1/auth/address', this.#baseUrl), + { + method: 'POST', + headers, + body: JSON.stringify(params), + }, + ); + + if (!response.ok && response.status !== 409) { + throw new HttpError( + response.status, + `POST /v1/auth/address failed with status '${response.status}'`, + ); + } + + return response.json(); + }, + }); + + return create(jsonResponse, AssociateAddressResponseStruct); + } + + /** + * Creates an account upgrade request. + * + * POST /v1/account-upgrade + * + * @param params - The upgrade params containing signature components and + * chain details. + * @returns The upgrade result. + */ + async createUpgrade(params: CreateUpgradeParams): Promise { + const jsonResponse = await this.fetchQuery({ + queryKey: [`${this.name}:createUpgrade`, params], + staleTime: 0, + queryFn: async () => { + const headers = await this.#authHeaders(); + const response = await fetch( + new URL('/v1/account-upgrade', this.#baseUrl), + { + method: 'POST', + headers, + body: JSON.stringify(params), + }, + ); + + if (!response.ok) { + throw new HttpError( + response.status, + `POST /v1/account-upgrade failed with status '${response.status}'`, + ); + } + + return response.json(); + }, + }); + + return create(jsonResponse, UpgradeResponseStruct); + } + + /** + * Fetches the upgrade record for a given address. + * + * GET /v1/account-upgrade/:address + * + * @param address - The address to look up. + * @returns The upgrade record, or null if not found. + */ + async getUpgrade(address: Hex): Promise { + const jsonResponse = await this.fetchQuery({ + queryKey: [`${this.name}:getUpgrade`, address], + queryFn: async () => { + const headers = await this.#authHeaders(); + const response = await fetch( + new URL(`/v1/account-upgrade/${address}`, this.#baseUrl), + { headers }, + ); + + if (response.status === 404) { + return null; + } + + if (!response.ok) { + throw new HttpError( + response.status, + `Get upgrade request failed with status '${response.status}'`, + ); + } + + return response.json(); + }, + }); + + if (jsonResponse === null) { + return null; + } + + return create(jsonResponse, UpgradeResponseStruct); + } + + /** + * Verifies a delegation signature. + * + * POST /v1/intent/verify-delegation + * + * @param params - The delegation verification params. + * @returns The verification result including validity and optional errors. + */ + async verifyDelegation( + params: VerifyDelegationParams, + ): Promise { + const jsonResponse = await this.fetchQuery({ + queryKey: [`${this.name}:verifyDelegation`, params], + staleTime: 0, + queryFn: async () => { + const headers = await this.#authHeaders(); + const response = await fetch( + new URL('/v1/intent/verify-delegation', this.#baseUrl), + { + method: 'POST', + headers, + body: JSON.stringify(params), + }, + ); + + if (!response.ok) { + throw new HttpError( + response.status, + `POST /v1/intent/verify-delegation failed with status '${response.status}'`, + ); + } + + return response.json(); + }, + }); + + return create(jsonResponse, VerifyDelegationResponseStruct); + } + + /** + * Submits one or more intents to the CHOMP API. + * + * POST /v1/intent + * + * @param intents - The array of intents to submit. + * @returns The array of intent responses. + */ + async createIntents( + intents: SendIntentParams[], + ): Promise { + const jsonResponse = await this.fetchQuery({ + queryKey: [`${this.name}:createIntents`, intents], + staleTime: 0, + queryFn: async () => { + const headers = await this.#authHeaders(); + const response = await fetch(new URL('/v1/intent', this.#baseUrl), { + method: 'POST', + headers, + body: JSON.stringify(intents), + }); + + if (!response.ok) { + throw new HttpError( + response.status, + `POST /v1/intent failed with status '${response.status}'`, + ); + } + + return response.json(); + }, + }); + + return create(jsonResponse, SendIntentResponseArrayStruct); + } + + /** + * Fetches intents associated with a given address. + * + * GET /v1/intent/account/:address + * + * @param address - The address to look up intents for. + * @returns The array of intents for the address. + */ + async getIntentsByAddress(address: Hex): Promise { + const jsonResponse = await this.fetchQuery({ + queryKey: [`${this.name}:getIntentsByAddress`, address], + queryFn: async () => { + const headers = await this.#authHeaders(); + const response = await fetch( + new URL(`/v1/intent/account/${address}`, this.#baseUrl), + { headers }, + ); + + if (!response.ok) { + throw new HttpError( + response.status, + `Get intents request failed with status '${response.status}'`, + ); + } + + return response.json(); + }, + }); + + return create(jsonResponse, IntentEntryArrayStruct); + } + + /** + * Creates a withdrawal for card spend flows. + * + * POST /v1/withdrawal + * + * @param params - The withdrawal params containing chainId, amount + * (decimal or hex string), and account address. + * @returns The withdrawal result. + */ + async createWithdrawal( + params: CreateWithdrawalParams, + ): Promise { + const jsonResponse = await this.fetchQuery({ + queryKey: [`${this.name}:createWithdrawal`, params], + staleTime: 0, + queryFn: async () => { + const headers = await this.#authHeaders(); + const response = await fetch(new URL('/v1/withdrawal', this.#baseUrl), { + method: 'POST', + headers, + body: JSON.stringify(params), + }); + + if (!response.ok) { + throw new HttpError( + response.status, + `POST /v1/withdrawal failed with status '${response.status}'`, + ); + } + + return response.json(); + }, + }); + + return create(jsonResponse, CreateWithdrawalResponseStruct); + } + + /** + * Retrieves service details including delegation redeemer addresses and DeFi + * contract details for signing delegations for auto-deposit functionality. + * + * GET /v1/chomp + * + * @param chainIds - Array of chain IDs (0x-prefixed hex strings) to retrieve + * details for. + * @returns The service details for the requested chains. + */ + async getServiceDetails(chainIds: Hex[]): Promise { + const jsonResponse = await this.fetchQuery({ + queryKey: [`${this.name}:getServiceDetails`, chainIds], + queryFn: async () => { + const headers = await this.#authHeaders(); + const url = new URL('/v1/chomp', this.#baseUrl); + url.searchParams.set('chainId', chainIds.join(',')); + const response = await fetch(url, { headers }); + + if (!response.ok) { + throw new HttpError( + response.status, + `GET /v1/chomp failed with status '${response.status}'`, + ); + } + + return response.json(); + }, + }); + + return create(jsonResponse, ServiceDetailsResponseStruct); + } +} diff --git a/packages/chomp-api-service/src/index.ts b/packages/chomp-api-service/src/index.ts new file mode 100644 index 0000000000..74f087f17f --- /dev/null +++ b/packages/chomp-api-service/src/index.ts @@ -0,0 +1,40 @@ +export { ChompApiService } from './chomp-api-service'; +export type { + ChompApiServiceMessenger, + ChompApiServiceActions, + ChompApiServiceEvents, + ChompApiServiceInvalidateQueriesAction, + ChompApiServiceCacheUpdatedEvent, + ChompApiServiceGranularCacheUpdatedEvent, +} from './chomp-api-service'; +export type { + ChompApiServiceAssociateAddressAction, + ChompApiServiceCreateUpgradeAction, + ChompApiServiceGetUpgradeAction, + ChompApiServiceVerifyDelegationAction, + ChompApiServiceCreateIntentsAction, + ChompApiServiceGetIntentsByAddressAction, + ChompApiServiceCreateWithdrawalAction, + ChompApiServiceGetServiceDetailsAction, +} from './chomp-api-service-method-action-types'; +export type { + AssociateAddressParams, + AssociateAddressResponse, + CreateUpgradeParams, + CreateWithdrawalParams, + CreateWithdrawalResponse, + DelegationCaveat, + UpgradeResponse, + IntentEntry, + IntentMetadataParams, + IntentMetadataResponse, + SendIntentParams, + SendIntentResponse, + ServiceDetailsChain, + ServiceDetailsProtocol, + ServiceDetailsResponse, + ServiceDetailsSupportedToken, + SignedDelegation, + VerifyDelegationParams, + VerifyDelegationResponse, +} from './types'; diff --git a/packages/chomp-api-service/src/types.ts b/packages/chomp-api-service/src/types.ts new file mode 100644 index 0000000000..56f47e1931 --- /dev/null +++ b/packages/chomp-api-service/src/types.ts @@ -0,0 +1,143 @@ +import type { Hex } from '@metamask/utils'; + +// === COMMON TYPES === + +export type DelegationCaveat = { + enforcer: Hex; + terms: Hex; + args: Hex; +}; + +export type SignedDelegation = { + delegate: Hex; + delegator: Hex; + authority: Hex; + caveats: DelegationCaveat[]; + salt: Hex; + signature: Hex; +}; + +// === PARAMS TYPES === + +export type AssociateAddressParams = { + signature: Hex; + timestamp: string; + address: Hex; +}; + +export type CreateUpgradeParams = { + r: Hex; + s: Hex; + v: number; + yParity: number; + address: Hex; + chainId: string; + nonce: string; +}; + +export type VerifyDelegationParams = { + signedDelegation: SignedDelegation; + chainId: Hex; +}; + +export type IntentMetadataParams = { + allowance: Hex; + tokenSymbol: string; + tokenAddress: Hex; + type: 'cash-deposit' | 'cash-withdrawal'; +}; + +export type SendIntentParams = { + account: Hex; + delegationHash: Hex; + chainId: Hex; + metadata: IntentMetadataParams; +}; + +export type CreateWithdrawalParams = { + chainId: Hex; + /** Decimal integer or 0x-prefixed hex string representing the amount. */ + amount: string; + account: Hex; +}; + +// === RESPONSE TYPES === + +export type AssociateAddressResponse = { + profileId: string; + address: Hex; + status: string; +}; + +export type UpgradeResponse = { + signerAddress: Hex; + status: string; + createdAt: string; +}; + +export type VerifyDelegationResponse = { + valid: boolean; + delegationHash?: Hex; + errors?: string[]; +}; + +export type IntentMetadataResponse = { + allowance: Hex; + tokenSymbol: string; + tokenAddress: Hex; + type: 'cash-deposit' | 'cash-withdrawal'; +}; + +export type SendIntentResponse = { + delegationHash: Hex; + metadata: IntentMetadataResponse; + createdAt: string; +}; + +/** + * The shape returned by GET /v1/intent/account/:address for each intent. + * + * Note: the metadata `type` uses 'deposit' | 'withdraw' here, whereas the + * create-intent endpoint uses 'cash-deposit' | 'cash-withdrawal'. + */ +export type IntentEntry = { + account: Hex; + delegationHash: Hex; + chainId: Hex; + status: 'active' | 'revoked'; + metadata: { + allowance: Hex; + tokenAddress: Hex; + tokenSymbol: string; + type: 'deposit' | 'withdraw'; + }; +}; + +export type CreateWithdrawalResponse = { + success: true; +}; + +// === SERVICE DETAILS TYPES === + +export type ServiceDetailsSupportedToken = { + tokenAddress: Hex; + tokenDecimals: number; +}; + +export type ServiceDetailsProtocol = { + supportedTokens: ServiceDetailsSupportedToken[]; + adapterAddress: Hex; + intentTypes: ('cash-deposit' | 'cash-withdrawal')[]; +}; + +export type ServiceDetailsChain = { + autoDepositDelegate: Hex; + protocol: Record; +}; + +export type ServiceDetailsResponse = { + auth: { + message: string; + }; + chains: Record; +}; diff --git a/packages/chomp-api-service/tsconfig.build.json b/packages/chomp-api-service/tsconfig.build.json new file mode 100644 index 0000000000..c468e8dd1f --- /dev/null +++ b/packages/chomp-api-service/tsconfig.build.json @@ -0,0 +1,14 @@ +{ + "extends": "../../tsconfig.packages.build.json", + "compilerOptions": { + "baseUrl": "./", + "outDir": "./dist", + "rootDir": "./src" + }, + "references": [ + { "path": "../messenger/tsconfig.build.json" }, + { "path": "../controller-utils/tsconfig.build.json" }, + { "path": "../base-data-service/tsconfig.build.json" } + ], + "include": ["../../types", "./src"] +} diff --git a/packages/chomp-api-service/tsconfig.json b/packages/chomp-api-service/tsconfig.json new file mode 100644 index 0000000000..203994e1c3 --- /dev/null +++ b/packages/chomp-api-service/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.packages.json", + "compilerOptions": { + "baseUrl": "./" + }, + "references": [ + { "path": "../messenger" }, + { "path": "../controller-utils" }, + { "path": "../base-data-service" } + ], + "include": ["../../types", "./src"] +} diff --git a/packages/chomp-api-service/typedoc.json b/packages/chomp-api-service/typedoc.json new file mode 100644 index 0000000000..c9da015dbf --- /dev/null +++ b/packages/chomp-api-service/typedoc.json @@ -0,0 +1,7 @@ +{ + "entryPoints": ["./src/index.ts"], + "excludePrivate": true, + "hideGenerator": true, + "out": "docs", + "tsconfig": "./tsconfig.build.json" +} diff --git a/teams.json b/teams.json index 775e450198..7ea11e2eab 100644 --- a/teams.json +++ b/teams.json @@ -34,6 +34,7 @@ "metamask/app-metadata-controller": "team-mobile-platform", "metamask/delegation-controller": "team-delegation", "metamask/chain-agnostic-permission": "team-wallet-integrations", + "metamask/chomp-api-service": "team-earn", "metamask/eip1193-permission-middleware": "team-wallet-integrations", "metamask/multichain-api-middleware": "team-wallet-integrations", "metamask/selected-network-controller": "team-wallet-integrations", diff --git a/tsconfig.build.json b/tsconfig.build.json index d741e37726..0abc4163fb 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -58,6 +58,9 @@ { "path": "./packages/chain-agnostic-permission/tsconfig.build.json" }, + { + "path": "./packages/chomp-api-service/tsconfig.build.json" + }, { "path": "./packages/claims-controller/tsconfig.build.json" }, diff --git a/tsconfig.json b/tsconfig.json index 74762bc7b6..9311cfcfeb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -59,6 +59,9 @@ { "path": "./packages/chain-agnostic-permission" }, + { + "path": "./packages/chomp-api-service" + }, { "path": "./packages/claims-controller" }, diff --git a/yarn.lock b/yarn.lock index 1d50842898..6e0e6c4cd8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3119,6 +3119,29 @@ __metadata: languageName: unknown linkType: soft +"@metamask/chomp-api-service@workspace:packages/chomp-api-service": + version: 0.0.0-use.local + resolution: "@metamask/chomp-api-service@workspace:packages/chomp-api-service" + dependencies: + "@metamask/auto-changelog": "npm:^6.1.0" + "@metamask/base-data-service": "npm:^0.1.1" + "@metamask/controller-utils": "npm:^11.20.0" + "@metamask/messenger": "npm:^1.1.1" + "@metamask/superstruct": "npm:^3.1.0" + "@metamask/utils": "npm:^11.9.0" + "@tanstack/query-core": "npm:^4.43.0" + "@ts-bridge/cli": "npm:^0.6.4" + "@types/jest": "npm:^29.5.14" + deepmerge: "npm:^4.2.2" + jest: "npm:^29.7.0" + nock: "npm:^13.3.1" + ts-jest: "npm:^29.2.5" + typedoc: "npm:^0.25.13" + typedoc-plugin-missing-exports: "npm:^2.0.0" + typescript: "npm:~5.3.3" + languageName: unknown + linkType: soft + "@metamask/claims-controller@workspace:packages/claims-controller": version: 0.0.0-use.local resolution: "@metamask/claims-controller@workspace:packages/claims-controller"