Skip to content

chore: adds digestId to client responses#8283

Merged
zone-live merged 11 commits intomainfrom
TSA-add-digestId-to-client-response
Mar 25, 2026
Merged

chore: adds digestId to client responses#8283
zone-live merged 11 commits intomainfrom
TSA-add-digestId-to-client-response

Conversation

@zone-live
Copy link
Copy Markdown
Contributor

@zone-live zone-live commented Mar 24, 2026

Explanation

The /asset-summary and /market-overview API endpoints always return responses wrapped in an { id, digest } / { id, report } envelope where id is a unique UUID identifying the digest. This PR updates AiDigestService to require that envelope shape (removing the bare-response fallback path), extracts id and exposes it as digestId on both MarketInsightsReport and MarketOverview, and makes digestId a required field on both types. This enables downstream consumers like MM app to include a digest_id property in analytics events.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Introduces a breaking response-shape/type change by no longer accepting bare /asset-summary payloads and making digestId required, which can break downstream consumers and tests that still expect the old shape.

Overview
AI digest client responses now surface the API-provided digest UUID. AiDigestService.searchDigest now only accepts the { id, digest } envelope for /asset-summary, validates id, and returns the digest with id exposed as a required digestId.

Tests are updated to mock enveloped responses and assert digestId is present, and the ai-controllers changelog documents the new required field and the removal of the bare-response fallback.

Written by Cursor Bugbot for commit c0f3977. This will update automatically on new commits. Configure here.

@zone-live zone-live requested review from a team as code owners March 24, 2026 14:19
Comment thread packages/ai-controllers/src/AiDigestService.ts Outdated
Copy link
Copy Markdown
Contributor

@joaosantos15 joaosantos15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MarketOverviewReport doesn't currently include an ID. We can add it, but it's not there atm.

REQ: https://digest.dev-api.cx.metamask.io/api/v1/market-overview

RES:

{
    "report": {
        "trends": [
            {
                "title": "Trump postpones Iran strikes",
                "impact": "positive",
                "articles": [
                    {
                        "url": "https://www.coindesk.com/markets/2026/03/23/bitcoin-surges-above-usd71-000-as-trump-postpones-iran-strikes-for-five-days",
                        "date": "2026-03-23",
                        "title": "Bitcoin price news: BTC surges 5% to $71,000 as Trump ...",
                        "source": "coindesk.com"
                    }
                ],
                "category": "geopolitical",
                "description": "President Trump delays US attacks on Iran's infrastructure, sparking a 5% surge in Bitcoin to $71,000 and gains in major cryptocurrencies. This eases short-term geopolitical tensions boosting risk assets.",
                "relatedAssets": [
                    {
                        "name": "Bitcoin",
                        "caip19": [
                            "bip122:000000000019d6689c085ae165831e93/slip44:0",
                            "eip155:1/erc20:0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
                            "eip155:43114/erc20:0x0555E30da8f98308EdB960aa94C0Db47230d2B9c",
                            "eip155:56/erc20:0x0555E30da8f98308EdB960aa94C0Db47230d2B9c",
                            "tron:728126428/trc20:TYhWwKpw43ENFWBTGpzLHn3882f2au7SMi",
                            "tron:mainnet/trc20:TYhWwKpw43ENFWBTGpzLHn3882f2au7SMi",
                            "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/spl:5XZw2LKTyrfvfiskJ78AMpackRjPcyCif1WhUsPDuVqQ",
                            "eip155:8453/erc20:0x1ceA84203673764244E05693e42E6Ace62bE9BA5",
                            "eip155:10/erc20:0x68f180fcCe6836688e9084f035309E29Bf0A2095",
                            "eip155:1/erc20:0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
                            "eip155:8453/erc20:0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
                            "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/spl:cbbtcf3aa214zXHbiAZQwf4122FBYbraNdFqgw4iMij",
                            "eip155:42161/erc20:0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
                            "eip155:42161/erc20:0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
                            "eip155:137/erc20:0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6",
                            "eip155:43114/erc20:0x50b7545627a5162F82A992c33b87aDc75187B218",
                            "eip155:56/erc20:0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c"
                        ],
                        "symbol": "BTC",
                        "hlPerpsMarket": "BTC",
                        "sourceAssetId": "bitcoin"
                    }
                ]
            },
            {
                "title": "US crypto legislation stalls",
                "impact": "negative",
                "articles": [
                    {
                        "url": "https://www.reuters.com/business/finance/citigroup-cuts-12-month-bitcoin-ether-targets-us-crypto-legislation-stalls-2026-03-17",
                        "date": "2026-03-17",
                        "title": "Citigroup cuts 12-month bitcoin, ether targets as US crypto ...",
                        "source": "reuters.com"
                    }
                ],
                "category": "regulatory",
                "description": "US crypto regulatory bills stall in Congress, leading Citigroup to cut its 12-month Bitcoin price target to $112,000 and Ether to $3,175. Ongoing uncertainty hampers bullish forecasts.",
                "relatedAssets": [
                    {
                        "name": "Bitcoin",
                        "caip19": [
                            "bip122:000000000019d6689c085ae165831e93/slip44:0",
                            "eip155:1/erc20:0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
                            "eip155:43114/erc20:0x0555E30da8f98308EdB960aa94C0Db47230d2B9c",
                            "eip155:56/erc20:0x0555E30da8f98308EdB960aa94C0Db47230d2B9c",
                            "tron:728126428/trc20:TYhWwKpw43ENFWBTGpzLHn3882f2au7SMi",
                            "tron:mainnet/trc20:TYhWwKpw43ENFWBTGpzLHn3882f2au7SMi",
                            "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/spl:5XZw2LKTyrfvfiskJ78AMpackRjPcyCif1WhUsPDuVqQ",
                            "eip155:8453/erc20:0x1ceA84203673764244E05693e42E6Ace62bE9BA5",
                            "eip155:10/erc20:0x68f180fcCe6836688e9084f035309E29Bf0A2095",
                            "eip155:1/erc20:0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
                            "eip155:8453/erc20:0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
                            "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/spl:cbbtcf3aa214zXHbiAZQwf4122FBYbraNdFqgw4iMij",
                            "eip155:42161/erc20:0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
                            "eip155:42161/erc20:0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
                            "eip155:137/erc20:0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6",
                            "eip155:43114/erc20:0x50b7545627a5162F82A992c33b87aDc75187B218",
                            "eip155:56/erc20:0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c"
                        ],
                        "symbol": "BTC",
                        "hlPerpsMarket": "BTC",
                        "sourceAssetId": "bitcoin"
                    },
                    {
                        "name": "Ethereum",
                        "caip19": [
                            "eip155:1/slip44:60",
                            "eip155:1/erc20:0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
                            "tron:728126428/trc20:THb4CqiFdwNHsWsQCs4JhzwjMWys4aqCbF",
                            "tron:mainnet/trc20:THb4CqiFdwNHsWsQCs4JhzwjMWys4aqCbF",
                            "eip155:42161/slip44:60",
                            "eip155:42161/erc20:0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
                            "eip155:10/slip44:60",
                            "eip155:10/erc20:0x4200000000000000000000000000000000000006",
                            "eip155:8453/slip44:60",
                            "eip155:8453/erc20:0x4200000000000000000000000000000000000006",
                            "eip155:59144/slip44:60",
                            "eip155:59144/erc20:0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f",
                            "eip155:324/slip44:60",
                            "eip155:324/erc20:0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91",
                            "eip155:534352/slip44:60",
                            "eip155:534352/erc20:0x5300000000000000000000000000000000000004",
                            "eip155:81457/slip44:60",
                            "eip155:81457/erc20:0x4300000000000000000000000000000000000004",
                            "eip155:1101/slip44:60",
                            "eip155:1101/erc20:0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9",
                            "eip155:137/erc20:0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
                            "eip155:43114/erc20:0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",
                            "eip155:56/erc20:0x2170Ed0880ac9A755fd29B2688956BD959F933F8",
                            "eip155:42220/erc20:0xD221812de1BD094f35587EE8E174B07B6167D9Af",
                            "eip155:100/erc20:0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1",
                            "eip155:314/erc20:0x522B61755b5FF8176B2931DA7bF1a5F9414Eb710"
                        ],
                        "symbol": "ETH",
                        "hlPerpsMarket": "ETH",
                        "sourceAssetId": "ethereum"
                    }
                ]
            },
            {
                "title": "Institutions adopt DeFi and Solana tools",
                "impact": "positive",
                "articles": [
                    {
                        "url": "https://www.coindesk.com/business/2026/03/24/crypto-finance-is-beginning-to-look-at-lot-more-traditional-aave-and-ethena-founders-say",
                        "date": "2026-03-24",
                        "title": "Crypto finance is beginning to look at lot more traditional, Aave and ...",
                        "source": "coindesk.com"
                    },
                    {
                        "url": "https://www.theblock.co/post/394756/mastercard-western-union-tap-solana-foundations-new-enterprise-developer-toolbox",
                        "date": "2026-03-24",
                        "title": "Mastercard, Western Union tap Solana Foundation's new enterprise ...",
                        "source": "theblock.co"
                    },
                    {
                        "url": "https://www.coindesk.com/opinion/2026/03/21/how-defi-is-quietly-rebuilding-the-fixed-income-stack-for-institutional-capital",
                        "date": "2026-03-21",
                        "title": "How DeFi is quietly rebuilding the fixed-income stack for institutional ...",
                        "source": "coindesk.com"
                    }
                ],
                "category": "macro",
                "description": "DeFi protocols gain traction with traditional firms as Aave and Ethena draw interest, and Mastercard plus Western Union use Solana's enterprise developer toolbox. This bridges institutional capital to crypto ecosystems.",
                "relatedAssets": [
                    {
                        "name": "Ethereum",
                        "caip19": [
                            "eip155:1/slip44:60",
                            "eip155:1/erc20:0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
                            "tron:728126428/trc20:THb4CqiFdwNHsWsQCs4JhzwjMWys4aqCbF",
                            "tron:mainnet/trc20:THb4CqiFdwNHsWsQCs4JhzwjMWys4aqCbF",
                            "eip155:42161/slip44:60",
                            "eip155:42161/erc20:0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
                            "eip155:10/slip44:60",
                            "eip155:10/erc20:0x4200000000000000000000000000000000000006",
                            "eip155:8453/slip44:60",
                            "eip155:8453/erc20:0x4200000000000000000000000000000000000006",
                            "eip155:59144/slip44:60",
                            "eip155:59144/erc20:0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f",
                            "eip155:324/slip44:60",
                            "eip155:324/erc20:0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91",
                            "eip155:534352/slip44:60",
                            "eip155:534352/erc20:0x5300000000000000000000000000000000000004",
                            "eip155:81457/slip44:60",
                            "eip155:81457/erc20:0x4300000000000000000000000000000000000004",
                            "eip155:1101/slip44:60",
                            "eip155:1101/erc20:0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9",
                            "eip155:137/erc20:0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
                            "eip155:43114/erc20:0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",
                            "eip155:56/erc20:0x2170Ed0880ac9A755fd29B2688956BD959F933F8",
                            "eip155:42220/erc20:0xD221812de1BD094f35587EE8E174B07B6167D9Af",
                            "eip155:100/erc20:0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1",
                            "eip155:314/erc20:0x522B61755b5FF8176B2931DA7bF1a5F9414Eb710"
                        ],
                        "symbol": "ETH",
                        "hlPerpsMarket": "ETH",
                        "sourceAssetId": "ethereum"
                    },
                    {
                        "name": "Solana",
                        "caip19": [
                            "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501",
                            "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/spl:So11111111111111111111111111111111111111112"
                        ],
                        "symbol": "SOL",
                        "hlPerpsMarket": "SOL",
                        "sourceAssetId": "solana"
                    }
                ]
            }
        ],
        "version": "1.0",
        "metadata": [
            {
                "provider": "xAI"
            }
        ],
        "generatedAt": "2026-03-25T08:00:39.704Z"
    },
    "generatedAt": "2026-03-25T08:00:39.808Z",
    "processingTime": 35589,
    "success": true,
    "error": null,
    "createdAt": "2026-03-25T08:00:39.815Z",
    "updatedAt": "2026-03-25T08:00:39.815Z"
}

@zone-live zone-live requested a review from joaosantos15 March 25, 2026 09:56
@zone-live zone-live enabled auto-merge March 25, 2026 10:07
@zone-live zone-live added this pull request to the merge queue Mar 25, 2026
Merged via the queue into main with commit 94c4791 Mar 25, 2026
326 checks passed
@zone-live zone-live deleted the TSA-add-digestId-to-client-response branch March 25, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants