diff --git a/packages/protobuf/package.json b/packages/protobuf/package.json index 05d520912..6afda46c3 100644 --- a/packages/protobuf/package.json +++ b/packages/protobuf/package.json @@ -16,7 +16,7 @@ "gen:ibc": "buf generate buf.build/cosmos/ibc:7ab44ae956a0488ea04e04511efa5f70", "gen:ics23": "buf generate buf.build/cosmos/ics23:55085f7c710a45f58fa09947208eb70b", "gen:noble": "buf generate buf.build/noble-assets/forwarding:5a8609a6772d417584a9c60cd8b80881", - "gen:penumbra": "buf generate buf.build/penumbra-zone/penumbra:ae2300bce202a7d429727f1340e7412d3b9f810c", + "gen:penumbra": "buf generate buf.build/penumbra-zone/penumbra:f6682d4ef839bb06e2da4fae487eb9d565ea04d6", "lint": "eslint src", "lint:fix": "eslint src --fix", "lint:strict": "tsc --noEmit && eslint src --max-warnings 0", diff --git a/packages/services/src/view-service/transaction-info.ts b/packages/services/src/view-service/transaction-info.ts index a8c007272..3fbae2cf0 100644 --- a/packages/services/src/view-service/transaction-info.ts +++ b/packages/services/src/view-service/transaction-info.ts @@ -8,6 +8,7 @@ import { import { fvkCtx } from '../ctx/full-viewing-key.js'; import { TransactionPerspective, + TransactionSummary, TransactionView, } from '@penumbra-zone/protobuf/penumbra/core/transaction/v1/transaction_pb'; @@ -27,11 +28,13 @@ export const transactionInfo: Impl['transactionInfo'] = async function* (_req, c const tx_info = await indexedDb.getTransactionInfo(txRecord.id); let perspective: TransactionPerspective; let view: TransactionView; + let summary: TransactionSummary; - // If TxP + TxV already exist in database, then simply yield them. - if (tx_info) { + // If TxP + TxV + summary already exist in database, then simply yield them. + if (tx_info && tx_info.summary) { perspective = tx_info.perspective; view = tx_info.view; + summary = tx_info.summary; // Otherwise, generate the TxP + TxV from the transaction in wasm // and store them. } else { @@ -41,10 +44,10 @@ export const transactionInfo: Impl['transactionInfo'] = async function* (_req, c indexedDb.constants(), ); - let tx_summary = await generateTransactionSummary(txv); - console.log('tx_summary: ', tx_summary); + // Generate and save transaction info summary from the TxV. + summary = await generateTransactionSummary(txv); + await indexedDb.saveTransactionInfo(txRecord.id, txp, txv, summary); - await indexedDb.saveTransactionInfo(txRecord.id, txp, txv); perspective = txp; view = txv; } @@ -56,6 +59,7 @@ export const transactionInfo: Impl['transactionInfo'] = async function* (_req, c transaction: txRecord.transaction, perspective, view, + summary, }), }; } diff --git a/packages/storage/src/indexed-db/index.ts b/packages/storage/src/indexed-db/index.ts index 23fac4b4a..71303a7d5 100644 --- a/packages/storage/src/indexed-db/index.ts +++ b/packages/storage/src/indexed-db/index.ts @@ -37,6 +37,7 @@ import { ValidatorInfo } from '@penumbra-zone/protobuf/penumbra/core/component/s import { Transaction, TransactionPerspective, + TransactionSummary, TransactionView, } from '@penumbra-zone/protobuf/penumbra/core/transaction/v1/transaction_pb'; import { bech32mAssetId } from '@penumbra-zone/bech32m/passet'; @@ -369,7 +370,13 @@ export class IndexedDb implements IndexedDbInterface { async getTransactionInfo( id: TransactionId, ): Promise< - { id: TransactionId; perspective: TransactionPerspective; view: TransactionView } | undefined + | { + id: TransactionId; + perspective: TransactionPerspective; + view: TransactionView; + summary: TransactionSummary | undefined; + } + | undefined > { const existingData = await this.db.get('TRANSACTION_INFO', uint8ArrayToBase64(id.inner)); if (existingData) { @@ -377,6 +384,9 @@ export class IndexedDb implements IndexedDbInterface { id: TransactionId.fromJson(existingData.id, { typeRegistry }), perspective: TransactionPerspective.fromJson(existingData.perspective, { typeRegistry }), view: TransactionView.fromJson(existingData.view, { typeRegistry }), + summary: existingData.summary + ? TransactionSummary.fromJson(existingData.summary, { typeRegistry }) + : undefined, }; } else { return undefined; @@ -387,12 +397,14 @@ export class IndexedDb implements IndexedDbInterface { id: TransactionId, txp: TransactionPerspective, txv: TransactionView, + summary: TransactionSummary, ): Promise { assertTransactionId(id); const value = { id: id.toJson({ typeRegistry }) as Jsonified, perspective: txp.toJson({ typeRegistry }) as Jsonified, view: txv.toJson({ typeRegistry }) as Jsonified, + summary: summary.toJson({ typeRegistry }) as Jsonified, }; await this.u.update({ table: 'TRANSACTION_INFO', diff --git a/packages/types/src/indexed-db.ts b/packages/types/src/indexed-db.ts index f56135306..abfa53c7b 100644 --- a/packages/types/src/indexed-db.ts +++ b/packages/types/src/indexed-db.ts @@ -36,6 +36,7 @@ import { AddressIndex, IdentityKey } from '@penumbra-zone/protobuf/penumbra/core import { Transaction, TransactionPerspective, + TransactionSummary, TransactionView, } from '@penumbra-zone/protobuf/penumbra/core/transaction/v1/transaction_pb'; import { TransactionId } from '@penumbra-zone/protobuf/penumbra/core/txhash/v1/txhash_pb'; @@ -168,12 +169,19 @@ export interface IndexedDbInterface { id: TransactionId, txp: TransactionPerspective, txv: TransactionView, + summary: TransactionSummary, ): Promise; getTransactionInfo( id: TransactionId, ): Promise< - { id: TransactionId; perspective: TransactionPerspective; view: TransactionView } | undefined + | { + id: TransactionId; + perspective: TransactionPerspective; + view: TransactionView; + summary: TransactionSummary | undefined; + } + | undefined >; getPosition(positionId: PositionId): Promise; @@ -241,6 +249,7 @@ export interface PenumbraDb extends DBSchema { id: Jsonified; perspective: Jsonified; view: Jsonified; + summary: Jsonified; }; }; REGISTRY_VERSION: {