@keetanetwork/anchor 0.0.81 → 0.0.83
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/lib/anchor-metadata-server.js +1 -1
- package/lib/anchor-metadata-server.js.map +1 -1
- package/lib/anchor-status.d.ts +32 -1
- package/lib/anchor-status.d.ts.map +1 -1
- package/lib/anchor-status.js +62 -1
- package/lib/anchor-status.js.map +1 -1
- package/lib/asset.d.ts +3 -0
- package/lib/asset.d.ts.map +1 -1
- package/lib/asset.js +25 -1
- package/lib/asset.js.map +1 -1
- package/lib/chaining.d.ts +13 -1
- package/lib/chaining.d.ts.map +1 -1
- package/lib/chaining.js +58 -17
- package/lib/chaining.js.map +1 -1
- package/lib/encrypted-container.d.ts.map +1 -1
- package/lib/encrypted-container.js +22 -7
- package/lib/encrypted-container.js.map +1 -1
- package/lib/history.d.ts +77 -21
- package/lib/history.d.ts.map +1 -1
- package/lib/history.js +951 -70
- package/lib/history.js.map +1 -1
- package/lib/http-server/index.d.ts.map +1 -1
- package/lib/http-server/index.js +20 -1
- package/lib/http-server/index.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/resolver.d.ts.map +1 -1
- package/lib/resolver.js +18 -2
- package/lib/resolver.js.map +1 -1
- package/lib/sensitive-attribute.d.ts.map +1 -1
- package/lib/sensitive-attribute.js +24 -2
- package/lib/sensitive-attribute.js.map +1 -1
- package/npm-shrinkwrap.json +18 -6
- package/package.json +2 -1
- package/services/fx/client.d.ts +18 -4
- package/services/fx/client.d.ts.map +1 -1
- package/services/fx/client.js +52 -6
- package/services/fx/client.js.map +1 -1
- package/services/fx/common.d.ts +35 -0
- package/services/fx/common.d.ts.map +1 -1
- package/services/fx/common.js +5 -5
- package/services/fx/common.js.map +1 -1
- package/services/fx/server.d.ts +17 -1
- package/services/fx/server.d.ts.map +1 -1
- package/services/fx/server.js +236 -18
- package/services/fx/server.js.map +1 -1
- package/services/fx/status-source.d.ts +34 -0
- package/services/fx/status-source.d.ts.map +1 -0
- package/services/fx/status-source.js +99 -0
- package/services/fx/status-source.js.map +1 -0
package/lib/history.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/lib/history.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAYnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,kCAAkC,EAAE,eAAe,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAInJ,MAAM,aAAa,GAAG,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC;AAwXtD;;;GAGG;AACH,SAAS,OAAO,CAAC,KAAa;IAC7B,IAAI,CAAC;QACJ,OAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACR,OAAM,CAAC,EAAE,CAAC,CAAC;IACZ,CAAC;AACF,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,QAAgB,EAAE,SAAmB;IAC7D,IAAI,MAAM,CAAC;IACX,IAAI,CAAC;QACJ,MAAM,GAAG,yBAAyB,CAAC,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACR,OAAM,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAED,OAAM,CAAC,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAAuC;IAC9E,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACnE,MAAM,OAAO,GAAG,eAAe,CAAC,QAAQ,CAAC,EAAE,CA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U,CAAC,MAA8D,EAAE,YAAoB,EAAE,WAAoF;QAC1L,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAC7C,IAAI,MAAM,KAAK,SAAS,IAAI,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;YAC3D,OAAM,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC;QACxB,CAAC;QAED,IAAI,MAAkE,CAAC;QACvE,IAAI,CAAC;YACJ,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;YACrE,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,wBAAwB,EAAE,0BAA0B,YAAY,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC1G,MAAM,GAAG,IAAI,CAAC;QACf,CAAC;QAED,WAAW,CAAC,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QACtC,OAAM,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;CACD;AAED,eAAe,WAAW,CAAC","sourcesContent":["import type { GenericAccount } from '@keetanetwork/keetanet-client/lib/account.js';\nimport type { Block } from '@keetanetwork/keetanet-client/lib/block/index.js';\nimport type { BlockOperations } from '@keetanetwork/keetanet-client/lib/block/operations.js';\nimport { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';\n\nimport type { KeetaNetAccount } from './asset.js';\nimport type { Logger } from './log/index.js';\nimport type { KeetaAssetMovementTransaction } from '../services/asset-movement/common.js';\nimport type {\n\tAnchorExternalTransactionStatusOptions,\n\tAnchorGetTransactionStatusOptions,\n\tAnchorTransactionStatus,\n\tAnchorTransactionStatusResult,\n\tAnchorTransferReader\n} from './anchor-status.js';\nimport { isCompletedTransferStatus } from './anchor-status.js';\nimport { convertAssetSearchInputToCanonical, isChainLocation, toAssetLocationFromString, toAssetPair } from '../services/asset-movement/common.js';\n\ntype Account = InstanceType<typeof KeetaNetLib.Account>;\n\nconst OperationType = KeetaNetLib.Block.OperationType;\n\n/**\n * Wallet-facing logical category of a transaction.\n */\nexport type LogicalTransactionType = 'send' | 'receive' | 'swap' | 'deposit' | 'withdraw' | 'bridge' | 'other';\n\n/**\n * Standardized lifecycle state. Only `complete` is asserted from a settled\n * block or a `COMPLETE` anchor status.\n */\nexport type LogicalTransactionStatus = 'pending' | 'complete' | 'failed';\n\n/**\n * Flow of value relative to the queried account.\n */\nexport type LogicalDirection = 'in' | 'out' | 'self';\n\n/**\n * A token (or anchor asset) and its quantity in smallest units.\n */\nexport type LogicalAmount = {\n\t/**\n\t * Token public key for on-chain legs, or the anchor asset rendered as a\n\t * string for anchor legs.\n\t */\n\ttoken: string;\n\t/**\n\t * Quantity in the asset's smallest unit.\n\t */\n\tamount: bigint;\n};\n\n/**\n * The other party to a logical transaction.\n */\nexport type LogicalCounterparty = {\n\t/**\n\t * What the counterparty represents.\n\t */\n\tkind: 'account' | 'anchor' | 'liquidity';\n\t/**\n\t * Account public key (or anchor id) of the counterparty.\n\t */\n\tid: string;\n\t/**\n\t * Optional display name resolved for the counterparty.\n\t */\n\tname?: string;\n};\n\n/**\n * One constituent part of a logical transaction: either a single on-chain\n * operation or a transfer tracked at an anchor.\n */\nexport type LogicalLeg =\n\t| {\n\t\t/**\n\t\t * On-chain operation leg.\n\t\t */\n\t\tkind: 'onchain';\n\t\t/**\n\t\t * Hash of the block carrying the operation.\n\t\t */\n\t\tblockHash: string;\n\t\t/**\n\t\t * Index of the operation within its block.\n\t\t */\n\t\toperationIndex: number;\n\t\t/**\n\t\t * Whether the operation sent or received value.\n\t\t */\n\t\topType: 'send' | 'receive';\n\t\t/**\n\t\t * Account on the other side of the operation.\n\t\t */\n\t\tcounterparty: string;\n\t\t/**\n\t\t * Value moved by the operation.\n\t\t */\n\t\tamount: LogicalAmount;\n\t}\n\t| {\n\t\t/**\n\t\t * Anchor-tracked transfer leg.\n\t\t */\n\t\tkind: 'anchor';\n\t\t/**\n\t\t * Anchor account the transfer was filed under.\n\t\t */\n\t\tanchorID: string;\n\t\t/**\n\t\t * Anchor-scoped transaction id.\n\t\t */\n\t\ttransactionID: string;\n\t\t/**\n\t\t * Related chain transaction ids reported by the anchor.\n\t\t */\n\t\tsubTransactions: string[];\n\t};\n\n/**\n * A single condensed, wallet-displayable transaction folded from one or more\n * on-chain operations and any anchor transfer that backs them.\n */\nexport type LogicalTransaction = {\n\t/**\n\t * Stable id: the block hash, or `blockHash:operationIndex` when a block\n\t * yields more than one logical transaction.\n\t */\n\tid: string;\n\t/**\n\t * Logical category.\n\t */\n\ttype: LogicalTransactionType;\n\t/**\n\t * Standardized status.\n\t */\n\tstatus: LogicalTransactionStatus;\n\t/**\n\t * Raw provider status string, present when an anchor transfer backs the\n\t * transaction. The wallet interprets non-standardized states.\n\t */\n\tproviderStatus?: string;\n\t/**\n\t * Flow of value relative to the queried account.\n\t */\n\tdirection: LogicalDirection;\n\t/**\n\t * ISO-8601 timestamp from the vote staple the block settled in.\n\t */\n\ttimestamp: string;\n\t/**\n\t * Value the account sent, when applicable.\n\t */\n\tsend?: LogicalAmount;\n\t/**\n\t * Value the account received, when applicable.\n\t */\n\treceive?: LogicalAmount;\n\t/**\n\t * Fee paid, when applicable.\n\t */\n\tfee?: LogicalAmount;\n\t/**\n\t * The other party, when one applies.\n\t */\n\tcounterparty?: LogicalCounterparty;\n\t/**\n\t * Constituent legs.\n\t */\n\tlegs: LogicalLeg[];\n\t/**\n\t * Source references for drill-down.\n\t */\n\trefs: {\n\t\t/**\n\t\t * Block hashes contributing to this logical transaction.\n\t\t */\n\t\tblockHashes: string[];\n\t\t/**\n\t\t * Anchor-scoped transaction ids contributing to this logical transaction.\n\t\t */\n\t\tanchorTxIDs: string[];\n\t\t/**\n\t\t * Raw `external` strings observed, when present.\n\t\t */\n\t\texternal?: string[];\n\t};\n\t/**\n\t * Raw source the transaction was folded from. Present only when\n\t * {@link UserHistoryListOptions.includeSource} is set.\n\t */\n\tsource?: LogicalTransactionSource;\n};\n\n/**\n * Raw source backing a {@link LogicalTransaction}, for callers that need to\n * drill down into the underlying on-chain data without re-fetching.\n */\nexport type LogicalTransactionSource = {\n\t/**\n\t * Vote staple that settled the source block.\n\t */\n\tstaple: HistoryStaple;\n\t/**\n\t * The enriched source block the transaction was classified from.\n\t */\n\tenriched: EnrichedBlock;\n};\n\n/**\n * One on-chain operation enriched with the anchor transfer it resolved to,\n * if any. The classify input unit.\n */\nexport type EnrichedOperation = {\n\t/**\n\t * The decoded on-chain operation.\n\t */\n\toperation: BlockOperations;\n\t/**\n\t * Index of the operation within its block.\n\t */\n\tindex: number;\n\t/**\n\t * Anchor transfer the operation resolved to, if enrichment found one.\n\t */\n\ttransfer?: KeetaAssetMovementTransaction;\n\t/**\n\t * Anchor account the transfer resolved under, when enrichment found one.\n\t * Authoritative over operation counterparties: for anchor-issued payout\n\t * blocks the operation counterparty is the user, not the anchor.\n\t */\n\tanchorID?: string;\n};\n\n/**\n * A block with each of its operations enriched. The classifier operates on\n * this and has no I/O of its own.\n */\nexport type EnrichedBlock = {\n\t/**\n\t * Hash of the block.\n\t */\n\tblockHash: string;\n\t/**\n\t * Issuing account of the block.\n\t * Note: Do NOT narrow to `AccountPublicKeyString`.\n\t */\n\taccount: string;\n\t/**\n\t * Account whose history is being folded.\n\t * Note: Do NOT narrow to `AccountPublicKeyString`.\n\t */\n\tperspective?: string;\n\t/**\n\t * ISO-8601 timestamp from the block's vote staple.\n\t */\n\ttimestamp: string;\n\t/**\n\t * The block's enriched operations.\n\t */\n\toperations: EnrichedOperation[];\n};\n\n/**\n * A classifier that maps an enriched block to zero or more logical\n * transactions. Returns `null` when it does not apply.\n */\nexport interface LogicalClassifier {\n\tclassify(block: EnrichedBlock): LogicalTransaction[] | null;\n}\n\n/**\n * A history page entry as produced by a node client's history call.\n */\nexport interface HistoryEntry {\n\t/**\n\t * The vote staple settling one or more blocks.\n\t */\n\tvoteStaple: HistoryStaple;\n}\n\n/**\n * The minimal vote-staple surface consumed when folding history.\n */\nexport interface HistoryStaple {\n\t/**\n\t * Settlement time of the staple.\n\t */\n\ttimestamp(): Date;\n\t/**\n\t * Blocks settled by the staple.\n\t */\n\tblocks: readonly Block[];\n\t/**\n\t * Cursor for the next page.\n\t */\n\tblocksHash: { toString(): string };\n}\n\n/**\n * Per-page query passed to a {@link HistorySource}.\n */\nexport type HistoryQuery = {\n\t/**\n\t * Number of vote staples to walk back per page.\n\t */\n\tdepth?: number;\n\t/**\n\t * Cursor returned by a previous page.\n\t */\n\tstartBlocksHash?: string;\n\t/**\n\t * Page size hint.\n\t */\n\tpageSize?: number;\n};\n\n/**\n * Account a history is read for: an account instance, its public-key\n * string, or `null` for the network-wide perspective.\n */\nexport type HistoryAccount = GenericAccount | string | null;\n\n/**\n * Inverted source of on-chain history pages, newest-first.\n */\nexport interface HistorySource {\n\tgetHistory(account: HistoryAccount, query?: HistoryQuery): Promise<HistoryEntry[]>;\n}\n\n/**\n * Construction inputs for {@link UserHistory}.\n */\nexport type UserHistoryConfig = {\n\t/**\n\t * Source of on-chain history pages. Any object exposing\n\t * {@link HistorySource.getHistory} is accepted, including a node client.\n\t */\n\thistory: HistorySource;\n\t/**\n\t * Anchor status reader used to enrich operations.\n\t */\n\tstatus?: AnchorTransactionStatus<KeetaAssetMovementTransaction>;\n\t/**\n\t * Ordered classifiers, specific-first.\n\t * Defaults to {@link defaultClassifiers}.\n\t */\n\tclassifiers?: readonly LogicalClassifier[];\n\t/**\n\t * Logger for diagnostics.\n\t */\n\tlogger?: Logger;\n};\n\n/**\n * Per-call options for {@link UserHistory.list}.\n */\nexport type UserHistoryListOptions = {\n\t/**\n\t * Vote staples to walk back per page.\n\t */\n\tdepth?: number;\n\t/**\n\t * Page size hint.\n\t */\n\tpageSize?: number;\n\t/**\n\t * Maximum number of logical transactions to return.\n\t */\n\tlimit?: number;\n\t/**\n\t * Cursor to resume paging from.\n\t */\n\tcursor?: string;\n\t/**\n\t * Enable anchor enrichment.\n\t * Defaults to `true` when a status source is set.\n\t */\n\tenrich?: boolean;\n\t/**\n\t * Keys tried against encrypted external slices.\n\t */\n\tdecryptionKeys?: Account[];\n\t/**\n\t * Account used to authenticate anchor status reads.\n\t */\n\trequesterAccount?: KeetaNetAccount;\n\t/**\n\t * Attach {@link LogicalTransaction.source} to each returned transaction.\n\t * Defaults to `false` to keep results lean.\n\t */\n\tincludeSource?: boolean;\n};\n\n/**\n * Parse a value string into smallest-unit units, defaulting to zero on a\n * value that is not a whole-number string.\n */\nfunction toUnits(value: string): bigint {\n\ttry {\n\t\treturn(BigInt(value));\n\t} catch {\n\t\treturn(0n);\n\t}\n}\n\n/**\n * Whether a location string denotes a chain (optionally a specific one).\n */\nfunction locationIsChain(location: string, chainType?: 'keeta'): boolean {\n\tlet parsed;\n\ttry {\n\t\tparsed = toAssetLocationFromString(location);\n\t} catch {\n\t\treturn(false);\n\t}\n\n\treturn(isChainLocation(parsed, chainType));\n}\n\n/**\n * Derive the logical type of an anchor transfer from its endpoints.\n */\nexport function logicalTypeFromTransfer(transfer: KeetaAssetMovementTransaction): LogicalTransactionType {\n\tconst fromKeeta = locationIsChain(transfer.from.location, 'keeta');\n\tconst toKeeta = locationIsChain(transfer.to.location, 'keeta');\n\tif (fromKeeta && toKeeta) {\n\t\treturn('swap');\n\t}\n\n\tconst fromChain = locationIsChain(transfer.from.location);\n\tconst toChain = locationIsChain(transfer.to.location);\n\tif ((fromKeeta && toChain) || (toKeeta && fromChain)) {\n\t\treturn('bridge');\n\t}\n\n\tif (fromKeeta) {\n\t\treturn('withdraw');\n\t}\n\n\tif (toKeeta) {\n\t\treturn('deposit');\n\t}\n\n\treturn('other');\n}\n\n/**\n * Map an anchor transfer's raw status onto the standardized status, carrying\n * the raw provider string for the wallet to interpret.\n */\nexport function statusFromTransfer(transfer: KeetaAssetMovementTransaction): { status: LogicalTransactionStatus; providerStatus: string } {\n\tif (isCompletedTransferStatus(transfer.status)) {\n\t\treturn({ status: 'complete', providerStatus: transfer.status });\n\t}\n\n\treturn({ status: 'pending', providerStatus: transfer.status });\n}\n\n/**\n * Derive value flow for an anchor transfer type.\n */\nfunction directionFromTransfer(type: LogicalTransactionType, fromKeeta: boolean): LogicalDirection {\n\tif (type === 'deposit') {\n\t\treturn('in');\n\t}\n\n\tif (type === 'withdraw') {\n\t\treturn('out');\n\t}\n\n\tif (type === 'bridge') {\n\t\tif (fromKeeta) {\n\t\t\treturn('out');\n\t\t}\n\n\t\treturn('in');\n\t}\n\n\treturn('self');\n}\n\n/**\n * Collect the chain transaction ids an anchor transfer references.\n */\nfunction collectAnchorSubTransactions(transfer: KeetaAssetMovementTransaction): string[] {\n\tconst ids: string[] = [];\n\tconst groups = [ transfer.from.transactions, transfer.to.transactions ];\n\tfor (const group of groups) {\n\t\tfor (const value of Object.values(group)) {\n\t\t\tif (value !== null && value !== undefined) {\n\t\t\t\tids.push(value.id);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn(ids);\n}\n\n/**\n * A SEND/RECEIVE operation reduced to its logical shape.\n */\ntype OperationView = {\n\topType: 'send' | 'receive';\n\tcounterparty: string;\n\tamount: LogicalAmount;\n};\n\n/**\n * Reduce a block operation to its logical view, or `null` for non-transfer\n * operations.\n */\nfunction operationView(operation: BlockOperations): OperationView | null {\n\tif (operation.type === OperationType.SEND) {\n\t\treturn({\n\t\t\topType: 'send',\n\t\t\tcounterparty: operation.to.publicKeyString.get(),\n\t\t\tamount: { token: operation.token.publicKeyString.get(), amount: operation.amount }\n\t\t});\n\t}\n\tif (operation.type === OperationType.RECEIVE) {\n\t\treturn({\n\t\t\topType: 'receive',\n\t\t\tcounterparty: operation.from.publicKeyString.get(),\n\t\t\tamount: { token: operation.token.publicKeyString.get(), amount: operation.amount }\n\t\t});\n\t}\n\n\treturn(null);\n}\n\n/**\n * Reduce an operation to its logical view relative to the block's\n * perspective account.\n */\nfunction viewOf(block: EnrichedBlock, operation: BlockOperations): OperationView | null {\n\tconst native = operationView(operation);\n\tif (native === null) {\n\t\treturn(null);\n\t}\n\n\tif (block.perspective === undefined || block.perspective === block.account) {\n\t\treturn(native);\n\t}\n\n\tif (native.opType === 'send' && native.counterparty === block.perspective) {\n\t\treturn({ opType: 'receive', counterparty: block.account, amount: native.amount });\n\t}\n\n\treturn(null);\n}\n\n/**\n * The account on the other side of a transfer operation, if any.\n */\nfunction counterpartyID(operation: BlockOperations): string | undefined {\n\tif (operation.type === OperationType.SEND) {\n\t\treturn(operation.to.publicKeyString.get());\n\t}\n\tif (operation.type === OperationType.RECEIVE) {\n\t\treturn(operation.from.publicKeyString.get());\n\t}\n\n\treturn(undefined);\n}\n\n/**\n * An operation view paired with its block-relative index.\n */\ntype IndexedView = OperationView & { index: number };\n\n/**\n * Partition a block's operations into send/receive views.\n */\nfunction viewsOf(block: EnrichedBlock): { sends: IndexedView[]; receives: IndexedView[]; otherCount: number } {\n\tconst sends: IndexedView[] = [];\n\tconst receives: IndexedView[] = [];\n\tlet otherCount = 0;\n\tfor (const enriched of block.operations) {\n\t\tconst view = viewOf(block, enriched.operation);\n\t\tif (view === null) {\n\t\t\totherCount++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst indexed: IndexedView = { ...view, index: enriched.index };\n\t\tif (indexed.opType === 'send') {\n\t\t\tsends.push(indexed);\n\t\t} else {\n\t\t\treceives.push(indexed);\n\t\t}\n\t}\n\n\treturn({ sends, receives, otherCount });\n}\n\n/**\n * The shared counterparty across views, or `undefined` when they differ.\n */\nfunction uniformCounterparty(views: readonly IndexedView[]): string | undefined {\n\tconst first = views[0];\n\tif (first === undefined) {\n\t\treturn(undefined);\n\t}\n\n\tfor (const view of views) {\n\t\tif (view.counterparty !== first.counterparty) {\n\t\t\treturn(undefined);\n\t\t}\n\t}\n\n\treturn(first.counterparty);\n}\n\n/**\n * Build on-chain legs for every transfer operation in a block.\n */\nfunction onchainLegs(block: EnrichedBlock): LogicalLeg[] {\n\tconst legs: LogicalLeg[] = [];\n\tfor (const enriched of block.operations) {\n\t\tconst view = viewOf(block, enriched.operation);\n\t\tif (view === null) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tlegs.push({\n\t\t\tkind: 'onchain',\n\t\t\tblockHash: block.blockHash,\n\t\t\toperationIndex: enriched.index,\n\t\t\topType: view.opType,\n\t\t\tcounterparty: view.counterparty,\n\t\t\tamount: view.amount\n\t\t});\n\t}\n\n\treturn(legs);\n}\n\n/**\n * Collect raw `external` strings carried by a block's SEND operations.\n */\nfunction blockExternals(block: EnrichedBlock): string[] {\n\tconst externals: string[] = [];\n\tfor (const enriched of block.operations) {\n\t\tconst operation = enriched.operation;\n\t\tif (operation.type === OperationType.SEND && operation.external !== undefined) {\n\t\t\texternals.push(operation.external);\n\t\t}\n\t}\n\n\treturn(externals);\n}\n\n/**\n * Build the refs block for a logical transaction.\n */\nfunction buildRefs(block: EnrichedBlock, anchorTxIDs: string[]): LogicalTransaction['refs'] {\n\tconst refs: LogicalTransaction['refs'] = { blockHashes: [ block.blockHash ], anchorTxIDs };\n\tconst externals = blockExternals(block);\n\tif (externals.length > 0) {\n\t\trefs.external = externals;\n\t}\n\n\treturn(refs);\n}\n\n// #endregion Operation views\n\n// #region Classifiers\n\n/**\n * Build the logical transaction backing one enriched anchor operation.\n */\nfunction buildAnchorTransaction(block: EnrichedBlock, enriched: EnrichedOperation, transfer: KeetaAssetMovementTransaction): LogicalTransaction {\n\tconst type = logicalTypeFromTransfer(transfer);\n\tconst fromKeeta = locationIsChain(transfer.from.location, 'keeta');\n\tconst direction = directionFromTransfer(type, fromKeeta);\n\tconst settled = statusFromTransfer(transfer);\n\tconst assets = toAssetPair(transfer.asset);\n\tconst view = viewOf(block, enriched.operation);\n\n\tconst legs: LogicalLeg[] = [];\n\tif (view !== null) {\n\t\tlegs.push({\n\t\t\tkind: 'onchain',\n\t\t\tblockHash: block.blockHash,\n\t\t\toperationIndex: enriched.index,\n\t\t\topType: view.opType,\n\t\t\tcounterparty: view.counterparty,\n\t\t\tamount: view.amount\n\t\t});\n\t}\n\n\tconst anchorID = enriched.anchorID ?? view?.counterparty ?? transfer.id;\n\tlegs.push({\n\t\tkind: 'anchor',\n\t\tanchorID,\n\t\ttransactionID: transfer.id,\n\t\tsubTransactions: collectAnchorSubTransactions(transfer)\n\t});\n\n\tconst refs: LogicalTransaction['refs'] = { blockHashes: [ block.blockHash ], anchorTxIDs: [ transfer.id ] };\n\tconst externals = blockExternals(block);\n\tif (externals.length > 0) {\n\t\trefs.external = externals;\n\t}\n\n\tconst transaction: LogicalTransaction = {\n\t\tid: `${block.blockHash}:${enriched.index}`,\n\t\ttype,\n\t\tstatus: settled.status,\n\t\tproviderStatus: settled.providerStatus,\n\t\tdirection,\n\t\ttimestamp: block.timestamp,\n\t\tsend: { token: convertAssetSearchInputToCanonical(assets.from), amount: toUnits(transfer.from.value) },\n\t\treceive: { token: convertAssetSearchInputToCanonical(assets.to), amount: toUnits(transfer.to.value) },\n\t\tlegs,\n\t\trefs\n\t};\n\n\ttransaction.counterparty = { kind: 'anchor', id: anchorID };\n\n\tif (transfer.fee !== null) {\n\t\ttransaction.fee = { token: convertAssetSearchInputToCanonical(transfer.fee.asset), amount: toUnits(transfer.fee.value) };\n\t}\n\n\treturn(transaction);\n}\n\n/**\n * Emits one logical transaction per operation that resolved to an anchor\n * transfer; the logical type comes from the transfer, not block shape.\n */\nconst anchorTransferClassifier: LogicalClassifier = {\n\tclassify(block) {\n\t\tconst transactions: LogicalTransaction[] = [];\n\t\tfor (const enriched of block.operations) {\n\t\t\tconst transfer = enriched.transfer;\n\t\t\tif (transfer === undefined) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\ttransactions.push(buildAnchorTransaction(block, enriched, transfer));\n\t\t}\n\n\t\tif (transactions.length === 0) {\n\t\t\treturn(null);\n\t\t}\n\n\t\treturn(transactions);\n\t}\n};\n\n/**\n * Classifies an on-chain atomic swap: SEND(s) and RECEIVE(s) against a single\n * counterparty with differing send/receive tokens.\n */\nconst atomicSwapClassifier: LogicalClassifier = {\n\tclassify(block) {\n\t\tconst { sends, receives, otherCount } = viewsOf(block);\n\t\tif (otherCount !== 0 || sends.length === 0 || receives.length === 0) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst counterparty = uniformCounterparty([ ...sends, ...receives ]);\n\t\tif (counterparty === undefined) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst received = receives[0];\n\t\tif (received === undefined) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst principal = sends.find(send => send.amount.token !== received.amount.token);\n\t\tif (principal === undefined) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst fee = sends.find(send => send.index !== principal.index);\n\n\t\tconst transaction: LogicalTransaction = {\n\t\t\tid: block.blockHash,\n\t\t\ttype: 'swap',\n\t\t\tstatus: 'complete',\n\t\t\tdirection: 'self',\n\t\t\ttimestamp: block.timestamp,\n\t\t\tsend: principal.amount,\n\t\t\treceive: received.amount,\n\t\t\tcounterparty: { kind: 'liquidity', id: counterparty },\n\t\t\tlegs: onchainLegs(block),\n\t\t\trefs: buildRefs(block, [])\n\t\t};\n\n\t\tif (fee !== undefined) {\n\t\t\ttransaction.fee = fee.amount;\n\t\t}\n\n\t\treturn([ transaction ]);\n\t}\n};\n\n/**\n * Classifies a SEND-only block as a plain send.\n */\nconst sendClassifier: LogicalClassifier = {\n\tclassify(block) {\n\t\tconst { sends, receives, otherCount } = viewsOf(block);\n\t\tif (otherCount !== 0 || receives.length !== 0 || sends.length === 0) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst primary = sends[0];\n\t\tif (primary === undefined) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst transaction: LogicalTransaction = {\n\t\t\tid: block.blockHash,\n\t\t\ttype: 'send',\n\t\t\tstatus: 'complete',\n\t\t\tdirection: 'out',\n\t\t\ttimestamp: block.timestamp,\n\t\t\tsend: primary.amount,\n\t\t\tlegs: onchainLegs(block),\n\t\t\trefs: buildRefs(block, [])\n\t\t};\n\n\t\tconst counterparty = uniformCounterparty(sends);\n\t\tif (counterparty !== undefined) {\n\t\t\ttransaction.counterparty = { kind: 'account', id: counterparty };\n\t\t}\n\n\t\treturn([ transaction ]);\n\t}\n};\n\n/**\n * Classifies a RECEIVE-only block as a plain receive.\n */\nconst receiveClassifier: LogicalClassifier = {\n\tclassify(block) {\n\t\tconst { sends, receives, otherCount } = viewsOf(block);\n\t\tif (otherCount !== 0 || sends.length !== 0 || receives.length === 0) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst primary = receives[0];\n\t\tif (primary === undefined) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst transaction: LogicalTransaction = {\n\t\t\tid: block.blockHash,\n\t\t\ttype: 'receive',\n\t\t\tstatus: 'complete',\n\t\t\tdirection: 'in',\n\t\t\ttimestamp: block.timestamp,\n\t\t\treceive: primary.amount,\n\t\t\tlegs: onchainLegs(block),\n\t\t\trefs: buildRefs(block, [])\n\t\t};\n\n\t\tconst counterparty = uniformCounterparty(receives);\n\t\tif (counterparty !== undefined) {\n\t\t\ttransaction.counterparty = { kind: 'account', id: counterparty };\n\t\t}\n\n\t\treturn([ transaction ]);\n\t}\n};\n\n/**\n * Fallback that emits a single `other` transaction for any unmatched block.\n */\nconst otherClassifier: LogicalClassifier = {\n\tclassify(block) {\n\t\tconst transaction: LogicalTransaction = {\n\t\t\tid: block.blockHash,\n\t\t\ttype: 'other',\n\t\t\tstatus: 'complete',\n\t\t\tdirection: 'self',\n\t\t\ttimestamp: block.timestamp,\n\t\t\tlegs: onchainLegs(block),\n\t\t\trefs: buildRefs(block, [])\n\t\t};\n\n\t\treturn([ transaction ]);\n\t}\n};\n\n/**\n * Default ordered classifier list, specific-first.\n */\nexport const defaultClassifiers: readonly LogicalClassifier[] = [\n\tanchorTransferClassifier,\n\tatomicSwapClassifier,\n\tsendClassifier,\n\treceiveClassifier,\n\totherClassifier\n];\n\n/**\n * Fold enriched blocks into logical transactions by running the ordered\n * classifiers; the first classifier that applies to a block wins.\n */\nexport function foldHistory(blocks: readonly EnrichedBlock[], classifiers: readonly LogicalClassifier[]): LogicalTransaction[] {\n\tconst results: LogicalTransaction[] = [];\n\tfor (const block of blocks) {\n\t\tfor (const classifier of classifiers) {\n\t\t\tconst classified = classifier.classify(block);\n\t\t\tif (classified !== null) {\n\t\t\t\tresults.push(...classified);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn(results);\n}\n\n/**\n * A transfer paired with the anchor account it resolved under.\n */\ntype ResolvedTransfer = {\n\tanchorID: string;\n\ttransfer: KeetaAssetMovementTransaction;\n};\n\n/**\n * The first transfer reported as a status across an external's anchors.\n */\nfunction firstResolvedTransfer(results: { [anchorID: string]: AnchorTransactionStatusResult<KeetaAssetMovementTransaction> }): ResolvedTransfer | undefined {\n\tfor (const [ anchorID, result ] of Object.entries(results)) {\n\t\tif (result.kind === 'status') {\n\t\t\treturn({ anchorID, transfer: result.status.transaction });\n\t\t}\n\t}\n\n\treturn(undefined);\n}\n\n/**\n * Build decode + status options for an external resolution.\n */\nfunction buildExternalOptions(options?: UserHistoryListOptions): AnchorExternalTransactionStatusOptions {\n\tconst built: AnchorExternalTransactionStatusOptions = {};\n\tif (options?.decryptionKeys !== undefined) {\n\t\tbuilt.decryptionKeys = options.decryptionKeys;\n\t}\n\n\tif (options?.requesterAccount !== undefined) {\n\t\tbuilt.requesterAccount = options.requesterAccount;\n\t}\n\n\treturn(built);\n}\n\n/**\n * Attach raw sources to folded transactions by their source block hash.\n *\n * A transaction id is its block hash, or `blockHash:operationIndex` when a\n * block yields more than one logical transaction.\n */\nfunction attachSources(transactions: readonly LogicalTransaction[], sources: ReadonlyMap<string, LogicalTransactionSource>): void {\n\tfor (const transaction of transactions) {\n\t\tconst [ blockHash ] = transaction.id.split(':');\n\t\tif (blockHash === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst source = sources.get(blockHash);\n\t\tif (source !== undefined) {\n\t\t\ttransaction.source = source;\n\t\t}\n\t}\n}\n\n/**\n * Normalize the queried account to its public key string.\n */\nfunction perspectiveOf(account: HistoryAccount): string | undefined {\n\tif (account === null) {\n\t\treturn(undefined);\n\t}\n\n\tif (typeof account === 'string') {\n\t\treturn(account);\n\t}\n\n\treturn(account.publicKeyString.get());\n}\n\n/**\n * Build status options for a reverse-lookup.\n */\nfunction buildStatusOptions(options?: UserHistoryListOptions): AnchorGetTransactionStatusOptions {\n\tconst built: AnchorGetTransactionStatusOptions = {};\n\tif (options?.requesterAccount !== undefined) {\n\t\tbuilt.requesterAccount = options.requesterAccount;\n\t}\n\n\treturn(built);\n}\n\n/**\n * Folds a user's on-chain history and anchor transfer data into a condensed\n * list of {@link LogicalTransaction}.\n */\nexport class UserHistory {\n\treadonly #history: HistorySource;\n\treadonly #status?: AnchorTransactionStatus<KeetaAssetMovementTransaction>;\n\treadonly #classifiers: readonly LogicalClassifier[];\n\treadonly #logger?: Logger;\n\n\tconstructor(config: UserHistoryConfig) {\n\t\tthis.#history = config.history;\n\t\tif (config.status !== undefined) {\n\t\t\tthis.#status = config.status;\n\t\t}\n\n\t\tif (config.logger !== undefined) {\n\t\t\tthis.#logger = config.logger;\n\t\t}\n\n\t\tthis.#classifiers = config.classifiers ?? defaultClassifiers;\n\t}\n\n\t/**\n\t * Fetch, enrich and fold a user's history into logical transactions.\n\t */\n\tasync list(account: HistoryAccount, options?: UserHistoryListOptions): Promise<LogicalTransaction[]> {\n\t\tconst transactions: LogicalTransaction[] = [];\n\t\tfor await (const transaction of this.iterate(account, options)) {\n\t\t\ttransactions.push(transaction);\n\t\t}\n\n\t\treturn(transactions);\n\t}\n\n\t/**\n\t * Stream logical transactions page by page instead of buffering the full\n\t * result set in memory.\n\t */\n\tasync *iterate(account: HistoryAccount, options?: UserHistoryListOptions): AsyncGenerator<LogicalTransaction> {\n\t\tconst externalCache = new Map<string, ResolvedTransfer | undefined>();\n\t\tconst readerCache = new Map<string, AnchorTransferReader<KeetaAssetMovementTransaction> | null>();\n\t\tconst perspective = perspectiveOf(account);\n\n\t\tlet cursor = options?.cursor;\n\t\tlet yielded = 0;\n\t\twhile (true) {\n\t\t\tconst page = await this.#fetchPage(account, cursor, options);\n\t\t\tif (page.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfor (const entry of page) {\n\t\t\t\tconst timestamp = entry.voteStaple.timestamp().toISOString();\n\t\t\t\tconst blocks: EnrichedBlock[] = [];\n\t\t\t\tconst sources = new Map<string, LogicalTransactionSource>();\n\t\t\t\tfor (const block of entry.voteStaple.blocks) {\n\t\t\t\t\tconst enriched = await this.#enrichBlock(block, timestamp, perspective, options, externalCache, readerCache);\n\t\t\t\t\tblocks.push(enriched);\n\n\t\t\t\t\tif (options?.includeSource === true) {\n\t\t\t\t\t\tsources.set(enriched.blockHash, { staple: entry.voteStaple, enriched });\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst logical = foldHistory(blocks, this.#classifiers);\n\t\t\t\tattachSources(logical, sources);\n\n\t\t\t\tfor (const transaction of logical) {\n\t\t\t\t\tyield transaction;\n\t\t\t\t\tyielded += 1;\n\n\t\t\t\t\tif (options?.limit !== undefined && yielded >= options.limit) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst last = page.at(-1);\n\t\t\tif (last === undefined) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = last.voteStaple.blocksHash.toString();\n\t\t\tif (options?.limit === undefined) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Fetch one page of on-chain history.\n\t */\n\tasync #fetchPage(account: HistoryAccount, cursor: string | undefined, options?: UserHistoryListOptions): Promise<HistoryEntry[]> {\n\t\tconst query: HistoryQuery = {};\n\t\tif (options?.depth !== undefined) {\n\t\t\tquery.depth = options.depth;\n\t\t}\n\t\tif (options?.pageSize !== undefined) {\n\t\t\tquery.pageSize = options.pageSize;\n\t\t}\n\t\tif (cursor !== undefined) {\n\t\t\tquery.startBlocksHash = cursor;\n\t\t}\n\n\t\tconst result = await this.#history.getHistory(account, query);\n\t\treturn(result);\n\t}\n\n\t/**\n\t * Enrich each operation of a block with its anchor transfer, if resolvable.\n\t */\n\tasync #enrichBlock(block: Block, timestamp: string, perspective: string | undefined, options: UserHistoryListOptions | undefined, externalCache: Map<string, ResolvedTransfer | undefined>, readerCache: Map<string, AnchorTransferReader<KeetaAssetMovementTransaction> | null>): Promise<EnrichedBlock> {\n\t\tconst blockHash = block.hash.toString();\n\t\tconst account = block.account.publicKeyString.get();\n\t\tconst enrichEnabled = options?.enrich !== false && this.#status !== undefined;\n\n\t\tconst operations: EnrichedOperation[] = [];\n\t\tfor (let index = 0; index < block.operations.length; index++) {\n\t\t\tconst operation = block.operations[index];\n\t\t\tif (operation === undefined) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst enriched: EnrichedOperation = { operation, index };\n\t\t\tif (enrichEnabled) {\n\t\t\t\tconst resolved = await this.#resolveTransfer(block, operation, index, perspective, options, externalCache, readerCache);\n\t\t\t\tif (resolved !== undefined) {\n\t\t\t\t\tenriched.transfer = resolved.transfer;\n\t\t\t\t\tenriched.anchorID = resolved.anchorID;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\toperations.push(enriched);\n\t\t}\n\n\t\tconst result: EnrichedBlock = { blockHash, account, timestamp, operations };\n\t\tif (perspective !== undefined) {\n\t\t\tresult.perspective = perspective;\n\t\t}\n\n\t\treturn(result);\n\t}\n\n\t/**\n\t * Resolve one operation to its anchor transfer, preferring the SEND's own\n\t * `external` and falling back to a reverse-lookup by on-chain coordinates.\n\t */\n\tasync #resolveTransfer(block: Block, operation: BlockOperations, index: number, perspective: string | undefined, options: UserHistoryListOptions | undefined, externalCache: Map<string, ResolvedTransfer | undefined>, readerCache: Map<string, AnchorTransferReader<KeetaAssetMovementTransaction> | null>): Promise<ResolvedTransfer | undefined> {\n\t\tconst status = this.#status;\n\t\tif (status === undefined) {\n\t\t\treturn(undefined);\n\t\t}\n\n\t\tif (operation.type === OperationType.SEND && operation.external !== undefined) {\n\t\t\tconst fromExternal = await this.#resolveFromExternal(status, operation.external, options, externalCache);\n\t\t\tif (fromExternal !== undefined) {\n\t\t\t\treturn(fromExternal);\n\t\t\t}\n\t\t}\n\n\t\tconst issuer = block.account.publicKeyString.get();\n\t\tlet candidateAnchor: string | undefined;\n\t\tif (perspective !== undefined && issuer !== perspective) {\n\t\t\tcandidateAnchor = issuer;\n\t\t} else {\n\t\t\tcandidateAnchor = counterpartyID(operation);\n\t\t}\n\n\t\tif (candidateAnchor === undefined) {\n\t\t\treturn(undefined);\n\t\t}\n\n\t\tconst fromOnChain = await this.#resolveByOnChain(status, candidateAnchor, block.network, block.hash.toString(), index, options, readerCache);\n\t\treturn(fromOnChain);\n\t}\n\n\t/**\n\t * Resolve a transfer from a SEND's `external` envelope, deduped per blob.\n\t */\n\tasync #resolveFromExternal(status: AnchorTransactionStatus<KeetaAssetMovementTransaction>, external: string, options: UserHistoryListOptions | undefined, externalCache: Map<string, ResolvedTransfer | undefined>): Promise<ResolvedTransfer | undefined> {\n\t\tconst cached = externalCache.get(external);\n\t\tif (cached !== undefined || externalCache.has(external)) {\n\t\t\treturn(cached);\n\t\t}\n\n\t\tlet resolved: ResolvedTransfer | undefined;\n\t\ttry {\n\t\t\tconst results = await status.getStatusesFromExternal(external, buildExternalOptions(options));\n\t\t\tresolved = firstResolvedTransfer(results);\n\t\t} catch (error) {\n\t\t\tthis.#logger?.debug('UserHistory::resolveFromExternal', `External did not resolve to a transfer, degrading to block-shape classification: ${String(error)}`);\n\t\t\tresolved = undefined;\n\t\t}\n\n\t\texternalCache.set(external, resolved);\n\t\treturn(resolved);\n\t}\n\n\t/**\n\t * Reverse-lookup a transfer by on-chain coordinates through the anchor the\n\t * counterparty resolves to.\n\t */\n\tasync #resolveByOnChain(status: AnchorTransactionStatus<KeetaAssetMovementTransaction>, counterparty: string, networkID: bigint, blockHash: string, operationIndex: number, options: UserHistoryListOptions | undefined, readerCache: Map<string, AnchorTransferReader<KeetaAssetMovementTransaction> | null>): Promise<ResolvedTransfer | undefined> {\n\t\tconst reader = await this.#getReader(status, counterparty, readerCache);\n\t\tif (reader?.findByOnChain === undefined) {\n\t\t\treturn(undefined);\n\t\t}\n\n\t\ttry {\n\t\t\tconst result = await reader.findByOnChain({ keetaNetworkID: networkID, blockHash, operationIndex }, buildStatusOptions(options));\n\t\t\tif (result === null) {\n\t\t\t\treturn(undefined);\n\t\t\t}\n\n\t\t\treturn({ anchorID: counterparty, transfer: result.transaction });\n\t\t} catch (error) {\n\t\t\tthis.#logger?.debug('UserHistory::resolveByOnChain', `Reverse-lookup at ${counterparty} for ${blockHash}:${operationIndex} failed: ${String(error)}`);\n\t\t\treturn(undefined);\n\t\t}\n\t}\n\n\t/**\n\t * Resolve and cache the reader for an anchor counterparty.\n\t */\n\tasync #getReader(status: AnchorTransactionStatus<KeetaAssetMovementTransaction>, counterparty: string, readerCache: Map<string, AnchorTransferReader<KeetaAssetMovementTransaction> | null>): Promise<AnchorTransferReader<KeetaAssetMovementTransaction> | null> {\n\t\tconst cached = readerCache.get(counterparty);\n\t\tif (cached !== undefined || readerCache.has(counterparty)) {\n\t\t\treturn(cached ?? null);\n\t\t}\n\n\t\tlet reader: AnchorTransferReader<KeetaAssetMovementTransaction> | null;\n\t\ttry {\n\t\t\tconst anchor = KeetaNetLib.Account.fromPublicKeyString(counterparty);\n\t\t\treader = await status.getReader(anchor);\n\t\t} catch (error) {\n\t\t\tthis.#logger?.debug('UserHistory::getReader', `No reader resolved for ${counterparty}: ${String(error)}`);\n\t\t\treader = null;\n\t\t}\n\n\t\treaderCache.set(counterparty, reader);\n\t\treturn(reader);\n\t}\n}\n\nexport default UserHistory;\n"]}
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/lib/history.ts"],"names":[],"mappings":"AAGA,O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AAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;YAC3D,OAAM,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC;QACxB,CAAC;QAED,IAAI,MAAkE,CAAC;QACvE,IAAI,CAAC;YACJ,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;YACrE,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,wBAAwB,EAAE,0BAA0B,YAAY,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC1G,MAAM,GAAG,IAAI,CAAC;QACf,CAAC;QAED,WAAW,CAAC,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QACtC,OAAM,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;CACD;AAED,eAAe,WAAW,CAAC","sourcesContent":["import type { GenericAccount } from '@keetanetwork/keetanet-client/lib/account.js';\nimport type { Block } from '@keetanetwork/keetanet-client/lib/block/index.js';\nimport type { BlockOperations } from '@keetanetwork/keetanet-client/lib/block/operations.js';\nimport { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';\n\nimport type { KeetaNetAccount } from './asset.js';\nimport type { Logger } from './log/index.js';\nimport type { KeetaAssetMovementTransaction } from '../services/asset-movement/common.js';\nimport type {\n\tAnchorExternalTransactionStatusOptions,\n\tAnchorGetTransactionStatusOptions,\n\tAnchorTransactionStatus,\n\tAnchorTransactionStatusResult,\n\tAnchorTransferReader\n} from './anchor-status.js';\nimport type { AnchorExternalInput } from './anchor-external.js';\nimport type { VerifiableAccount } from './utils/signing.js';\nimport { isCompletedTransferStatus } from './anchor-status.js';\nimport { AnchorExternal } from './anchor-external.js';\nimport { convertAssetSearchInputToCanonical, isChainLocation, toAssetLocationFromString, toAssetPair } from '../services/asset-movement/common.js';\n\ntype Account = InstanceType<typeof KeetaNetLib.Account>;\n\nconst OperationType = KeetaNetLib.Block.OperationType;\n\n/**\n * Wallet-facing logical category of a transaction.\n */\nexport type LogicalTransactionType = 'send' | 'receive' | 'swap' | 'deposit' | 'withdraw' | 'bridge' | 'other';\n\n/**\n * Standardized lifecycle state. Only `complete` is asserted from a settled\n * block or a `COMPLETE` anchor status.\n */\nexport type LogicalTransactionStatus = 'pending' | 'complete' | 'failed';\n\n/**\n * Flow of value relative to the queried account.\n */\nexport type LogicalDirection = 'in' | 'out' | 'self';\n\n/**\n * A token (or anchor asset) and its quantity in smallest units.\n */\nexport type LogicalAmount = {\n\t/**\n\t * Token public key for on-chain legs, or the anchor asset rendered as a\n\t * string for anchor legs.\n\t */\n\ttoken: string;\n\t/**\n\t * Quantity in the asset's smallest unit.\n\t */\n\tamount: bigint;\n};\n\n/**\n * The other party to a logical transaction.\n */\nexport type LogicalCounterparty = {\n\t/**\n\t * What the counterparty represents.\n\t */\n\tkind: 'account' | 'anchor' | 'liquidity';\n\t/**\n\t * Account public key (or anchor id) of the counterparty.\n\t */\n\tid: string;\n\t/**\n\t * Optional display name resolved for the counterparty.\n\t */\n\tname?: string;\n};\n\n/**\n * One constituent part of a logical transaction: either a single on-chain\n * operation or a transfer tracked at an anchor.\n */\nexport type LogicalLeg =\n\t| {\n\t\t/**\n\t\t * On-chain operation leg.\n\t\t */\n\t\tkind: 'onchain';\n\t\t/**\n\t\t * Hash of the block carrying the operation.\n\t\t */\n\t\tblockHash: string;\n\t\t/**\n\t\t * Index of the operation within its block.\n\t\t */\n\t\toperationIndex: number;\n\t\t/**\n\t\t * Whether the operation sent or received value.\n\t\t */\n\t\topType: 'send' | 'receive';\n\t\t/**\n\t\t * Account on the other side of the operation.\n\t\t */\n\t\tcounterparty: string;\n\t\t/**\n\t\t * Value moved by the operation.\n\t\t */\n\t\tamount: LogicalAmount;\n\t}\n\t| {\n\t\t/**\n\t\t * Anchor-tracked transfer leg.\n\t\t */\n\t\tkind: 'anchor';\n\t\t/**\n\t\t * Anchor account the transfer was filed under.\n\t\t */\n\t\tanchorID: string;\n\t\t/**\n\t\t * Anchor-scoped transaction id.\n\t\t */\n\t\ttransactionID: string;\n\t\t/**\n\t\t * Related chain transaction ids reported by the anchor.\n\t\t */\n\t\tsubTransactions: string[];\n\t};\n\n/**\n * A single condensed, wallet-displayable transaction folded from one or more\n * on-chain operations and any anchor transfer that backs them.\n */\nexport type LogicalTransaction = {\n\t/**\n\t * Stable id: the block hash, or `blockHash:operationIndex` when a block\n\t * yields more than one logical transaction.\n\t */\n\tid: string;\n\t/**\n\t * Logical category.\n\t */\n\ttype: LogicalTransactionType;\n\t/**\n\t * Standardized status.\n\t */\n\tstatus: LogicalTransactionStatus;\n\t/**\n\t * Raw provider status string, present when an anchor transfer backs the\n\t * transaction. The wallet interprets non-standardized states.\n\t */\n\tproviderStatus?: string;\n\t/**\n\t * Set when `type` and `counterparty` were inferred locally from the block's\n\t * anchor `external` without enrichment, so the wallet can render a tentative\n\t * label and enrich on demand. Cleared once the transfer resolves.\n\t */\n\tprovisional?: boolean;\n\t/**\n\t * Flow of value relative to the queried account.\n\t */\n\tdirection: LogicalDirection;\n\t/**\n\t * ISO-8601 timestamp from the vote staple the block settled in.\n\t */\n\ttimestamp: string;\n\t/**\n\t * Value the account sent, when applicable.\n\t */\n\tsend?: LogicalAmount;\n\t/**\n\t * Value the account received, when applicable.\n\t */\n\treceive?: LogicalAmount;\n\t/**\n\t * Fee paid, when applicable.\n\t */\n\tfee?: LogicalAmount;\n\t/**\n\t * The other party, when one applies.\n\t */\n\tcounterparty?: LogicalCounterparty;\n\t/**\n\t * Constituent legs.\n\t */\n\tlegs: LogicalLeg[];\n\t/**\n\t * Source references for drill-down.\n\t */\n\trefs: {\n\t\t/**\n\t\t * Block hashes contributing to this logical transaction.\n\t\t */\n\t\tblockHashes: string[];\n\t\t/**\n\t\t * Anchor-scoped transaction ids contributing to this logical transaction.\n\t\t */\n\t\tanchorTxIDs: string[];\n\t\t/**\n\t\t * Raw `external` strings observed, when present.\n\t\t */\n\t\texternal?: string[];\n\t\t/**\n\t\t * On-chain operations this transaction declared as its inputs, decoded\n\t\t * from the `external` envelope.\n\t\t */\n\t\tinputs?: AnchorExternalInput[];\n\t\t/**\n\t\t * Anchor transfer ids declared locally by the block's SEND `external`\n\t\t * envelopes, available without enrichment. Superseded by `anchorTxIDs`\n\t\t * once the transfer is resolved.\n\t\t */\n\t\tdeclaredAnchorTxIDs?: string[];\n\t};\n\t/**\n\t * Raw source the transaction was folded from. Present only when\n\t * {@link UserHistoryListOptions.includeSource} is set.\n\t */\n\tsource?: LogicalTransactionSource;\n};\n\n/**\n * Raw source backing a {@link LogicalTransaction}, for callers that need to\n * drill down into the underlying on-chain data without re-fetching.\n */\nexport type LogicalTransactionSource = {\n\t/**\n\t * Vote staple that settled the source block.\n\t */\n\tstaple: HistoryStaple;\n\t/**\n\t * The enriched source block the transaction was classified from.\n\t */\n\tenriched: EnrichedBlock;\n};\n\n/**\n * One on-chain operation enriched with the anchor transfer it resolved to,\n * if any. The classify input unit.\n */\nexport type EnrichedOperation = {\n\t/**\n\t * The decoded on-chain operation.\n\t */\n\toperation: BlockOperations;\n\t/**\n\t * Index of the operation within its block.\n\t */\n\tindex: number;\n\t/**\n\t * Anchor transfer the operation resolved to, if enrichment found one.\n\t */\n\ttransfer?: KeetaAssetMovementTransaction;\n\t/**\n\t * Anchor account the transfer resolved under, when enrichment found one.\n\t * Authoritative over operation counterparties: for anchor-issued payout\n\t * blocks the operation counterparty is the user, not the anchor.\n\t */\n\tanchorID?: string;\n};\n\n/**\n * A block with each of its operations enriched. The classifier operates on\n * this and has no I/O of its own.\n */\nexport type EnrichedBlock = {\n\t/**\n\t * Hash of the block.\n\t */\n\tblockHash: string;\n\t/**\n\t * Issuing account of the block.\n\t * Note: Do NOT narrow to `AccountPublicKeyString`.\n\t */\n\taccount: string;\n\t/**\n\t * Account whose history is being folded.\n\t * Note: Do NOT narrow to `AccountPublicKeyString`.\n\t */\n\tperspective?: string;\n\t/**\n\t * ISO-8601 timestamp from the block's vote staple.\n\t */\n\ttimestamp: string;\n\t/**\n\t * The block's enriched operations.\n\t */\n\toperations: EnrichedOperation[];\n\t/**\n\t * On-chain inputs decoded from the block's SEND `external` envelopes, in\n\t * the order observed. Captured locally during enrichment, independent of\n\t * anchor status resolution. Present only when non-empty.\n\t */\n\tinputs?: AnchorExternalInput[];\n\t/**\n\t * Anchor transfer references decoded locally from the block's SEND\n\t * `external` envelopes and trusted (block-owned by the perspective or\n\t * anchor-signed). Present only when non-empty.\n\t */\n\tdeclaredAnchors?: DeclaredAnchorRef[];\n};\n\n/**\n * An anchor transfer reference decoded locally from a block's SEND `external`\n * envelope. `signed` is true when the envelope was signed by `anchorID`, which\n * makes the reference trustworthy even for a block the perspective does not own.\n */\nexport type DeclaredAnchorRef = {\n\t/**\n\t * Anchor public key string the entry is filed under.\n\t */\n\tanchorID: string;\n\t/**\n\t * Anchor-scoped transaction id declared for this transfer. Matches the\n\t * resolved transfer's id later carried in `refs.anchorTxIDs`.\n\t */\n\ttransactionID: string;\n\t/**\n\t * Whether the declaring `external` was signed by `anchorID`.\n\t */\n\tsigned: boolean;\n};\n\n/**\n * A classifier that maps an enriched block to zero or more logical\n * transactions. Returns `null` when it does not apply.\n */\nexport interface LogicalClassifier {\n\tclassify(block: EnrichedBlock): LogicalTransaction[] | null;\n}\n\n/**\n * A history page entry as produced by a node client's history call.\n */\nexport interface HistoryEntry {\n\t/**\n\t * The vote staple settling one or more blocks.\n\t */\n\tvoteStaple: HistoryStaple;\n}\n\n/**\n * The minimal vote-staple surface consumed when folding history.\n */\nexport interface HistoryStaple {\n\t/**\n\t * Settlement time of the staple.\n\t */\n\ttimestamp(): Date;\n\t/**\n\t * Blocks settled by the staple.\n\t */\n\tblocks: readonly Block[];\n\t/**\n\t * Cursor for the next page.\n\t */\n\tblocksHash: { toString(): string };\n}\n\n/**\n * Per-page query passed to a {@link HistorySource}.\n */\nexport type HistoryQuery = {\n\t/**\n\t * Number of vote staples to walk back per page.\n\t */\n\tdepth?: number;\n\t/**\n\t * Cursor returned by a previous page.\n\t */\n\tstartBlocksHash?: string;\n\t/**\n\t * Page size hint.\n\t */\n\tpageSize?: number;\n};\n\n/**\n * Account a history is read for: an account instance, its public-key\n * string, or `null` for the network-wide perspective.\n */\nexport type HistoryAccount = GenericAccount | string | null;\n\n/**\n * Inverted source of on-chain history pages, newest-first.\n */\nexport interface HistorySource {\n\tgetHistory(account: HistoryAccount, query?: HistoryQuery): Promise<HistoryEntry[]>;\n\t/**\n\t * Fetch the vote staple settling `blockHash`, or `null`/`undefined` when it\n\t * cannot be resolved. Optional: when present, {@link UserHistory.iterate}\n\t * folds linked multi-hop swap chains incrementally (resolving each\n\t * referenced predecessor by hash) instead of buffering the whole account.\n\t */\n\tgetVoteStaple?(blockHash: string): Promise<HistoryStaple | null | undefined>;\n}\n\n/**\n * Construction inputs for {@link UserHistory}.\n */\nexport type UserHistoryConfig = {\n\t/**\n\t * Source of on-chain history pages. Any object exposing\n\t * {@link HistorySource.getHistory} is accepted, including a node client.\n\t */\n\thistory: HistorySource;\n\t/**\n\t * Anchor status reader used to enrich operations.\n\t */\n\tstatus?: AnchorTransactionStatus<KeetaAssetMovementTransaction>;\n\t/**\n\t * Ordered classifiers, specific-first.\n\t * Defaults to {@link defaultClassifiers}.\n\t */\n\tclassifiers?: readonly LogicalClassifier[];\n\t/**\n\t * Logger for diagnostics.\n\t */\n\tlogger?: Logger;\n};\n\n/**\n * Per-call options for {@link UserHistory.list}.\n */\nexport type UserHistoryListOptions = {\n\t/**\n\t * Vote staples to walk back per page.\n\t */\n\tdepth?: number;\n\t/**\n\t * Page size hint.\n\t */\n\tpageSize?: number;\n\t/**\n\t * Maximum number of logical transactions to return. When unset, every page\n\t * of history is walked until exhausted.\n\t */\n\tlimit?: number;\n\t/**\n\t * Cursor to resume paging from.\n\t */\n\tcursor?: string;\n\t/**\n\t * Enable anchor enrichment, which resolves each operation to its anchor\n\t * transfer over HTTP.\n\t * Defaults to `false`.\n\t */\n\tenrich?: boolean;\n\t/**\n\t * Keys tried against encrypted external slices.\n\t */\n\tdecryptionKeys?: Account[];\n\t/**\n\t * Account used to authenticate anchor status reads.\n\t */\n\trequesterAccount?: KeetaNetAccount;\n\t/**\n\t * Attach {@link LogicalTransaction.source} to each returned transaction.\n\t * Defaults to `false` to keep results lean.\n\t */\n\tincludeSource?: boolean;\n};\n\n/**\n * Parse a value string into smallest-unit units, defaulting to zero on a\n * value that is not a whole-number string.\n */\nfunction toUnits(value: string): bigint {\n\ttry {\n\t\treturn(BigInt(value));\n\t} catch {\n\t\treturn(0n);\n\t}\n}\n\n/**\n * Whether a location string denotes a chain (optionally a specific one).\n */\nfunction locationIsChain(location: string, chainType?: 'keeta'): boolean {\n\tlet parsed;\n\ttry {\n\t\tparsed = toAssetLocationFromString(location);\n\t} catch {\n\t\treturn(false);\n\t}\n\n\treturn(isChainLocation(parsed, chainType));\n}\n\n/**\n * Derive the logical type of an anchor transfer from its endpoints.\n */\nfunction logicalTypeFromTransfer(transfer: KeetaAssetMovementTransaction): LogicalTransactionType {\n\tconst fromKeeta = locationIsChain(transfer.from.location, 'keeta');\n\tconst toKeeta = locationIsChain(transfer.to.location, 'keeta');\n\tif (fromKeeta && toKeeta) {\n\t\treturn('swap');\n\t}\n\n\tconst fromChain = locationIsChain(transfer.from.location);\n\tconst toChain = locationIsChain(transfer.to.location);\n\tif ((fromKeeta && toChain) || (toKeeta && fromChain)) {\n\t\treturn('bridge');\n\t}\n\n\tif (fromKeeta) {\n\t\treturn('withdraw');\n\t}\n\n\tif (toKeeta) {\n\t\treturn('deposit');\n\t}\n\n\treturn('other');\n}\n\n/**\n * Map an anchor transfer's raw status onto the standardized status, carrying\n * the raw provider string for the wallet to interpret.\n */\nfunction statusFromTransfer(transfer: KeetaAssetMovementTransaction): { status: LogicalTransactionStatus; providerStatus: string } {\n\tif (isCompletedTransferStatus(transfer.status)) {\n\t\treturn({ status: 'complete', providerStatus: transfer.status });\n\t}\n\n\treturn({ status: 'pending', providerStatus: transfer.status });\n}\n\n/**\n * Derive value flow for an anchor transfer type.\n */\nfunction directionFromTransfer(type: LogicalTransactionType, fromKeeta: boolean): LogicalDirection {\n\tif (type === 'deposit') {\n\t\treturn('in');\n\t}\n\n\tif (type === 'withdraw') {\n\t\treturn('out');\n\t}\n\n\tif (type === 'bridge') {\n\t\tif (fromKeeta) {\n\t\t\treturn('out');\n\t\t}\n\n\t\treturn('in');\n\t}\n\n\treturn('self');\n}\n\n/**\n * Collect the chain transaction ids an anchor transfer references.\n */\nfunction collectAnchorSubTransactions(transfer: KeetaAssetMovementTransaction): string[] {\n\tconst ids: string[] = [];\n\tconst groups = [ transfer.from.transactions, transfer.to.transactions ];\n\tfor (const group of groups) {\n\t\tfor (const value of Object.values(group)) {\n\t\t\tif (value !== null && value !== undefined) {\n\t\t\t\tids.push(value.id);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn(ids);\n}\n\n/**\n * A SEND/RECEIVE operation reduced to its logical shape.\n */\ntype OperationView = {\n\topType: 'send' | 'receive';\n\tcounterparty: string;\n\tamount: LogicalAmount;\n};\n\n/**\n * Reduce a block operation to its logical view, or `null` for non-transfer\n * operations.\n */\nfunction operationView(operation: BlockOperations): OperationView | null {\n\tif (operation.type === OperationType.SEND) {\n\t\treturn({\n\t\t\topType: 'send',\n\t\t\tcounterparty: operation.to.publicKeyString.get(),\n\t\t\tamount: { token: operation.token.publicKeyString.get(), amount: operation.amount }\n\t\t});\n\t}\n\tif (operation.type === OperationType.RECEIVE) {\n\t\treturn({\n\t\t\topType: 'receive',\n\t\t\tcounterparty: operation.from.publicKeyString.get(),\n\t\t\tamount: { token: operation.token.publicKeyString.get(), amount: operation.amount }\n\t\t});\n\t}\n\n\treturn(null);\n}\n\n/**\n * Reduce an operation to its logical view relative to the block's\n * perspective account.\n */\nfunction viewOf(block: EnrichedBlock, operation: BlockOperations): OperationView | null {\n\tconst native = operationView(operation);\n\tif (native === null) {\n\t\treturn(null);\n\t}\n\n\tif (block.perspective === undefined || block.perspective === block.account) {\n\t\treturn(native);\n\t}\n\n\tif (native.opType === 'send' && native.counterparty === block.perspective) {\n\t\treturn({ opType: 'receive', counterparty: block.account, amount: native.amount });\n\t}\n\n\treturn(null);\n}\n\n/**\n * The account on the other side of a transfer operation, if any.\n */\nfunction counterpartyID(operation: BlockOperations): string | undefined {\n\tif (operation.type === OperationType.SEND) {\n\t\treturn(operation.to.publicKeyString.get());\n\t}\n\tif (operation.type === OperationType.RECEIVE) {\n\t\treturn(operation.from.publicKeyString.get());\n\t}\n\n\treturn(undefined);\n}\n\n/**\n * An operation view paired with its block-relative index.\n */\ntype IndexedView = OperationView & { index: number };\n\n/**\n * Partition a block's operations into send/receive views.\n */\nfunction viewsOf(block: EnrichedBlock): { sends: IndexedView[]; receives: IndexedView[]; otherCount: number } {\n\tconst sends: IndexedView[] = [];\n\tconst receives: IndexedView[] = [];\n\tlet otherCount = 0;\n\tfor (const enriched of block.operations) {\n\t\tconst view = viewOf(block, enriched.operation);\n\t\tif (view === null) {\n\t\t\totherCount++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst indexed: IndexedView = { ...view, index: enriched.index };\n\t\tif (indexed.opType === 'send') {\n\t\t\tsends.push(indexed);\n\t\t} else {\n\t\t\treceives.push(indexed);\n\t\t}\n\t}\n\n\treturn({ sends, receives, otherCount });\n}\n\n/**\n * The shared counterparty across views, or `undefined` when they differ.\n */\nfunction uniformCounterparty(views: readonly IndexedView[]): string | undefined {\n\tconst first = views[0];\n\tif (first === undefined) {\n\t\treturn(undefined);\n\t}\n\n\tfor (const view of views) {\n\t\tif (view.counterparty !== first.counterparty) {\n\t\t\treturn(undefined);\n\t\t}\n\t}\n\n\treturn(first.counterparty);\n}\n\n/**\n * Build on-chain legs for every transfer operation in a block.\n */\nfunction onchainLegs(block: EnrichedBlock): LogicalLeg[] {\n\tconst legs: LogicalLeg[] = [];\n\tfor (const enriched of block.operations) {\n\t\tconst view = viewOf(block, enriched.operation);\n\t\tif (view === null) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tlegs.push({\n\t\t\tkind: 'onchain',\n\t\t\tblockHash: block.blockHash,\n\t\t\toperationIndex: enriched.index,\n\t\t\topType: view.opType,\n\t\t\tcounterparty: view.counterparty,\n\t\t\tamount: view.amount\n\t\t});\n\t}\n\n\treturn(legs);\n}\n\n/**\n * Collect raw `external` strings carried by a block's SEND operations.\n */\nfunction blockExternals(block: EnrichedBlock): string[] {\n\tconst externals: string[] = [];\n\tfor (const enriched of block.operations) {\n\t\tconst operation = enriched.operation;\n\t\tif (operation.type === OperationType.SEND && operation.external !== undefined) {\n\t\t\texternals.push(operation.external);\n\t\t}\n\t}\n\n\treturn(externals);\n}\n\n/**\n * Decode a block's SEND `external` envelopes into the on-chain `inputs` they\n * declare and the anchor transfers they name. Both are captured locally,\n * independent of anchor status resolution; undecodable envelopes are skipped.\n */\nasync function decodeExternalEnvelopes(externals: readonly string[], decryptionKeys: VerifiableAccount[] | undefined): Promise<{ inputs: AnchorExternalInput[]; declaredAnchors: DeclaredAnchorRef[] }> {\n\tconst inputs: AnchorExternalInput[] = [];\n\tconst declaredAnchors: DeclaredAnchorRef[] = [];\n\tfor (const external of externals) {\n\t\tlet decoded: AnchorExternal;\n\t\ttry {\n\t\t\tconst decodeOptions: { decryptionKeys?: VerifiableAccount[] } = {};\n\t\t\tif (decryptionKeys !== undefined) {\n\t\t\t\tdecodeOptions.decryptionKeys = decryptionKeys;\n\t\t\t}\n\n\t\t\tdecoded = await AnchorExternal.fromExternal(external, decodeOptions);\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst envelopeInputs = decoded.envelope.inputs;\n\t\tif (envelopeInputs !== undefined) {\n\t\t\tfor (const inputReference of envelopeInputs) {\n\t\t\t\tinputs.push(inputReference);\n\t\t\t}\n\t\t}\n\n\t\tconst signerID = decoded.signed?.signer.publicKeyString.get();\n\t\tfor (const [ anchorID, entry ] of Object.entries(decoded.envelope.anchors)) {\n\t\t\tif (!('transactionId' in entry)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tdeclaredAnchors.push({ anchorID, transactionID: entry.transactionId, signed: signerID === anchorID });\n\t\t}\n\t}\n\n\treturn({ inputs, declaredAnchors });\n}\n\n/**\n * The single anchor a block's trusted declarations name, or `undefined` when\n * there are none or they disagree.\n */\nfunction declaredAnchorID(block: EnrichedBlock): string | undefined {\n\tconst refs = block.declaredAnchors ?? [];\n\tconst first = refs[0];\n\tif (first === undefined) {\n\t\treturn(undefined);\n\t}\n\n\tfor (const ref of refs) {\n\t\tif (ref.anchorID !== first.anchorID) {\n\t\t\treturn(undefined);\n\t\t}\n\t}\n\n\treturn(first.anchorID);\n}\n\n/**\n * The distinct anchor transfer ids a block declares locally, in order.\n */\nfunction declaredAnchorTxIDsOf(block: EnrichedBlock): string[] {\n\tconst ids: string[] = [];\n\tfor (const ref of block.declaredAnchors ?? []) {\n\t\tif (!ids.includes(ref.transactionID)) {\n\t\t\tids.push(ref.transactionID);\n\t\t}\n\t}\n\n\treturn(ids);\n}\n\n/**\n * Build the refs block for a logical transaction.\n */\nfunction buildRefs(block: EnrichedBlock, anchorTxIDs: string[]): LogicalTransaction['refs'] {\n\tconst refs: LogicalTransaction['refs'] = { blockHashes: [ block.blockHash ], anchorTxIDs };\n\tconst externals = blockExternals(block);\n\tif (externals.length > 0) {\n\t\trefs.external = externals;\n\t}\n\n\tif (block.inputs !== undefined && block.inputs.length > 0) {\n\t\trefs.inputs = block.inputs;\n\t}\n\n\tconst declaredAnchorTxIDs = declaredAnchorTxIDsOf(block);\n\tif (declaredAnchorTxIDs.length > 0) {\n\t\trefs.declaredAnchorTxIDs = declaredAnchorTxIDs;\n\t}\n\n\treturn(refs);\n}\n\n// #endregion Operation views\n\n// #region Classifiers\n\n/**\n * Build the logical transaction backing one enriched anchor operation.\n */\nfunction buildAnchorTransaction(block: EnrichedBlock, enriched: EnrichedOperation, transfer: KeetaAssetMovementTransaction, indexed: boolean): LogicalTransaction {\n\tconst type = logicalTypeFromTransfer(transfer);\n\tconst fromKeeta = locationIsChain(transfer.from.location, 'keeta');\n\tconst direction = directionFromTransfer(type, fromKeeta);\n\tconst settled = statusFromTransfer(transfer);\n\tconst assets = toAssetPair(transfer.asset);\n\tconst view = viewOf(block, enriched.operation);\n\n\tconst legs: LogicalLeg[] = [];\n\tif (view !== null) {\n\t\tlegs.push({\n\t\t\tkind: 'onchain',\n\t\t\tblockHash: block.blockHash,\n\t\t\toperationIndex: enriched.index,\n\t\t\topType: view.opType,\n\t\t\tcounterparty: view.counterparty,\n\t\t\tamount: view.amount\n\t\t});\n\t}\n\n\tconst anchorID = enriched.anchorID ?? view?.counterparty ?? transfer.id;\n\tlegs.push({\n\t\tkind: 'anchor',\n\t\tanchorID,\n\t\ttransactionID: transfer.id,\n\t\tsubTransactions: collectAnchorSubTransactions(transfer)\n\t});\n\n\tconst refs = buildRefs(block, [ transfer.id ]);\n\tconst transaction: LogicalTransaction = {\n\t\tid: indexed ? `${block.blockHash}:${enriched.index}` : block.blockHash,\n\t\ttype,\n\t\tstatus: settled.status,\n\t\tproviderStatus: settled.providerStatus,\n\t\tdirection,\n\t\ttimestamp: block.timestamp,\n\t\tsend: { token: convertAssetSearchInputToCanonical(assets.from), amount: toUnits(transfer.from.value) },\n\t\treceive: { token: convertAssetSearchInputToCanonical(assets.to), amount: toUnits(transfer.to.value) },\n\t\tlegs,\n\t\trefs\n\t};\n\n\ttransaction.counterparty = { kind: 'anchor', id: anchorID };\n\n\tif (transfer.fee !== null) {\n\t\ttransaction.fee = { token: convertAssetSearchInputToCanonical(transfer.fee.asset), amount: toUnits(transfer.fee.value) };\n\t}\n\n\treturn(transaction);\n}\n\n/**\n * Emits one logical transaction per operation that resolved to an anchor\n * transfer; the logical type comes from the transfer, not block shape.\n */\nconst anchorTransferClassifier: LogicalClassifier = {\n\tclassify(block) {\n\t\tconst resolved: { enriched: EnrichedOperation; transfer: KeetaAssetMovementTransaction }[] = [];\n\t\tfor (const enriched of block.operations) {\n\t\t\tconst transfer = enriched.transfer;\n\t\t\tif (transfer !== undefined) {\n\t\t\t\tresolved.push({ enriched, transfer });\n\t\t\t}\n\t\t}\n\n\t\tif (resolved.length === 0) {\n\t\t\treturn(null);\n\t\t}\n\n\t\t/*\n\t\t * Suffix the id with the operation index only when the block settles more\n\t\t * than one transfer; a single-transfer block keeps the bare block hash so\n\t\t * its id matches the shape-classified (unenriched) row for the same block.\n\t\t */\n\t\tconst indexed = resolved.length > 1;\n\t\treturn(resolved.map(entry => buildAnchorTransaction(block, entry.enriched, entry.transfer, indexed)));\n\t}\n};\n\n/**\n * Pick the swap principal: the largest send whose token differs from the\n * received token.\n */\nfunction principalSend(sends: readonly IndexedView[], receivedToken: string): IndexedView | undefined {\n\tlet principal: IndexedView | undefined;\n\tfor (const send of sends) {\n\t\tif (send.amount.token === receivedToken) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (principal === undefined || send.amount.amount > principal.amount.amount) {\n\t\t\tprincipal = send;\n\t\t}\n\t}\n\n\treturn(principal);\n}\n\n/**\n * Sum amounts into one total, or `undefined` when there are none or they use\n * more than one token.\n */\nfunction combineFees(fees: readonly LogicalAmount[]): LogicalAmount | undefined {\n\tconst first = fees.at(0);\n\tif (first === undefined) {\n\t\treturn(undefined);\n\t}\n\n\tlet total = 0n;\n\tfor (const fee of fees) {\n\t\tif (fee.token !== first.token) {\n\t\t\treturn(undefined);\n\t\t}\n\n\t\ttotal += fee.amount;\n\t}\n\n\treturn({ token: first.token, amount: total });\n}\n\n/**\n * Aggregate the non-principal sends into a single fee amount, or `undefined`\n * when there are none or they use more than one token.\n */\nfunction aggregateFee(feeSends: readonly IndexedView[]): LogicalAmount | undefined {\n\treturn(combineFees(feeSends.map(send => send.amount)));\n}\n\n/**\n * Build a `self`-directed swap from its principal and received legs. Shared by\n * the single-block classifier and the cross-block accepted-swap fold.\n */\nfunction swapTransaction(input: {\n\tid: string;\n\ttimestamp: string;\n\tsend: LogicalAmount;\n\treceive: LogicalAmount;\n\tcounterparty: NonNullable<LogicalTransaction['counterparty']>;\n\tlegs: LogicalLeg[];\n\trefs: LogicalTransaction['refs'];\n\tfee?: LogicalAmount;\n}): LogicalTransaction {\n\tconst transaction: LogicalTransaction = {\n\t\tid: input.id,\n\t\ttype: 'swap',\n\t\tstatus: 'complete',\n\t\tdirection: 'self',\n\t\ttimestamp: input.timestamp,\n\t\tsend: input.send,\n\t\treceive: input.receive,\n\t\tcounterparty: input.counterparty,\n\t\tlegs: input.legs,\n\t\trefs: input.refs\n\t};\n\n\tif (input.fee !== undefined) {\n\t\ttransaction.fee = input.fee;\n\t}\n\n\treturn(transaction);\n}\n\n/**\n * Classifies an on-chain atomic swap: SEND(s) and RECEIVE(s) against a single\n * counterparty with differing send/receive tokens.\n */\nconst atomicSwapClassifier: LogicalClassifier = {\n\tclassify(block) {\n\t\tconst { sends, receives, otherCount } = viewsOf(block);\n\t\tif (otherCount !== 0 || sends.length === 0 || receives.length === 0) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst counterparty = uniformCounterparty([ ...sends, ...receives ]);\n\t\tif (counterparty === undefined) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst received = receives[0];\n\t\tif (received === undefined) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst principal = principalSend(sends, received.amount.token);\n\t\tif (principal === undefined) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst fee = aggregateFee(sends.filter(send => send.index !== principal.index));\n\n\t\treturn([ swapTransaction({\n\t\t\tid: block.blockHash,\n\t\t\ttimestamp: block.timestamp,\n\t\t\tsend: principal.amount,\n\t\t\treceive: received.amount,\n\t\t\tcounterparty: { kind: 'liquidity', id: counterparty },\n\t\t\tlegs: onchainLegs(block),\n\t\t\trefs: buildRefs(block, []),\n\t\t\t...(fee !== undefined ? { fee } : {})\n\t\t}) ]);\n\t}\n};\n\n/**\n * Classifies a SEND-only block as a plain send.\n */\nconst sendClassifier: LogicalClassifier = {\n\tclassify(block) {\n\t\tconst { sends, receives, otherCount } = viewsOf(block);\n\t\tif (otherCount !== 0 || receives.length !== 0 || sends.length === 0) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst primary = sends[0];\n\t\tif (primary === undefined) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst transaction: LogicalTransaction = {\n\t\t\tid: block.blockHash,\n\t\t\ttype: 'send',\n\t\t\tstatus: 'complete',\n\t\t\tdirection: 'out',\n\t\t\ttimestamp: block.timestamp,\n\t\t\tsend: primary.amount,\n\t\t\tlegs: onchainLegs(block),\n\t\t\trefs: buildRefs(block, [])\n\t\t};\n\n\t\tconst anchorID = declaredAnchorID(block);\n\t\tif (anchorID !== undefined) {\n\t\t\ttransaction.counterparty = { kind: 'anchor', id: anchorID };\n\t\t} else {\n\t\t\tconst counterparty = uniformCounterparty(sends);\n\t\t\tif (counterparty !== undefined) {\n\t\t\t\ttransaction.counterparty = { kind: 'account', id: counterparty };\n\t\t\t}\n\t\t}\n\n\t\treturn([ transaction ]);\n\t}\n};\n\n/**\n * Classifies a RECEIVE-only block as a plain receive.\n */\nconst receiveClassifier: LogicalClassifier = {\n\tclassify(block) {\n\t\tconst { sends, receives, otherCount } = viewsOf(block);\n\t\tif (otherCount !== 0 || sends.length !== 0 || receives.length === 0) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst primary = receives[0];\n\t\tif (primary === undefined) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst transaction: LogicalTransaction = {\n\t\t\tid: block.blockHash,\n\t\t\ttype: 'receive',\n\t\t\tstatus: 'complete',\n\t\t\tdirection: 'in',\n\t\t\ttimestamp: block.timestamp,\n\t\t\treceive: primary.amount,\n\t\t\tlegs: onchainLegs(block),\n\t\t\trefs: buildRefs(block, [])\n\t\t};\n\n\t\tconst anchorID = declaredAnchorID(block);\n\t\tif (anchorID !== undefined) {\n\t\t\ttransaction.counterparty = { kind: 'anchor', id: anchorID };\n\t\t} else {\n\t\t\tconst counterparty = uniformCounterparty(receives);\n\t\t\tif (counterparty !== undefined) {\n\t\t\t\ttransaction.counterparty = { kind: 'account', id: counterparty };\n\t\t\t}\n\t\t}\n\n\t\treturn([ transaction ]);\n\t}\n};\n\n/**\n * Fallback that emits a single `other` transaction for any unmatched block.\n */\nconst otherClassifier: LogicalClassifier = {\n\tclassify(block) {\n\t\tconst transaction: LogicalTransaction = {\n\t\t\tid: block.blockHash,\n\t\t\ttype: 'other',\n\t\t\tstatus: 'complete',\n\t\t\tdirection: 'self',\n\t\t\ttimestamp: block.timestamp,\n\t\t\tlegs: onchainLegs(block),\n\t\t\trefs: buildRefs(block, [])\n\t\t};\n\n\t\treturn([ transaction ]);\n\t}\n};\n\n/**\n * Default ordered classifier list, specific-first.\n */\nexport const defaultClassifiers: readonly LogicalClassifier[] = [\n\tanchorTransferClassifier,\n\tatomicSwapClassifier,\n\tsendClassifier,\n\treceiveClassifier,\n\totherClassifier\n];\n\n/**\n * Within a settled staple, drop foreign counterpart blocks whose settlement is\n * already represented by a perspective-owned block.\n */\nfunction suppressCoveredForeignBlocks(blocks: readonly EnrichedBlock[]): readonly EnrichedBlock[] {\n\tconst perspective = blocks.find(block => block.perspective !== undefined)?.perspective;\n\tif (perspective === undefined) {\n\t\treturn(blocks);\n\t}\n\n\tconst owned = blocks.filter(block => block.account === perspective);\n\tif (owned.length === 0) {\n\t\treturn(blocks);\n\t}\n\n\tconst covered = new Set<string>();\n\tfor (const block of owned) {\n\t\tfor (const enriched of block.operations) {\n\t\t\tconst counterparty = counterpartyID(enriched.operation);\n\t\t\tif (counterparty !== undefined) {\n\t\t\t\tcovered.add(counterparty);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst result = blocks.filter(block => block.account === perspective || !covered.has(block.account));\n\treturn(result);\n}\n\n/**\n * Find a block authored by `counterparty` within the staple that exactly\n * consumes `principal` (a RECEIVE from the perspective for the same token and\n * amount) and pays a different token back to the perspective, returning the\n * received amount and that block. This is the counterpart leg of an accepted\n * P2P swap, whose receive leg the perspective never signs itself.\n */\nfunction matchSwapCounterpart(blocks: readonly EnrichedBlock[], perspective: string, counterparty: string, principal: LogicalAmount, consumed: ReadonlySet<string>): { block: EnrichedBlock; receive: LogicalAmount } | undefined {\n\tfor (const block of blocks) {\n\t\tif (block.account !== counterparty || consumed.has(block.blockHash)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet consumesPrincipal = false;\n\t\tlet payout: LogicalAmount | undefined;\n\t\tfor (const enriched of block.operations) {\n\t\t\tconst view = operationView(enriched.operation);\n\t\t\tif (view === null || view.counterparty !== perspective) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (view.opType === 'receive' && view.amount.token === principal.token && view.amount.amount === principal.amount) {\n\t\t\t\tconsumesPrincipal = true;\n\t\t\t} else if (view.opType === 'send' && view.amount.token !== principal.token) {\n\t\t\t\tpayout = view.amount;\n\t\t\t}\n\t\t}\n\n\t\tif (consumesPrincipal && payout !== undefined) {\n\t\t\treturn({ block, receive: payout });\n\t\t}\n\t}\n\n\treturn(undefined);\n}\n\n/**\n * Fold accepted P2P swaps whose legs span two blocks of one staple: the\n * perspective signs only a SEND (the token it gives) while its RECEIVE lives\n * in the counterparty's block.\n */\nfunction crossBlockSwaps(blocks: readonly EnrichedBlock[]): { transactions: LogicalTransaction[]; consumed: Set<string> } {\n\tconst consumed = new Set<string>();\n\tconst transactions: LogicalTransaction[] = [];\n\tconst perspective = blocks.find(block => block.perspective !== undefined)?.perspective;\n\tif (perspective === undefined) {\n\t\treturn({ transactions, consumed });\n\t}\n\n\tfor (const owned of blocks) {\n\t\tif (owned.account !== perspective || consumed.has(owned.blockHash)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst { sends, receives, otherCount } = viewsOf(owned);\n\t\tconst principal = sends[0];\n\t\tif (otherCount !== 0 || receives.length !== 0 || sends.length !== 1 || principal === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst matched = matchSwapCounterpart(blocks, perspective, principal.counterparty, principal.amount, consumed);\n\t\tif (matched === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst refs = buildRefs(owned, []);\n\t\trefs.blockHashes = [ ...refs.blockHashes, matched.block.blockHash ];\n\t\ttransactions.push(swapTransaction({\n\t\t\tid: owned.blockHash,\n\t\t\ttimestamp: owned.timestamp,\n\t\t\tsend: principal.amount,\n\t\t\treceive: matched.receive,\n\t\t\tcounterparty: { kind: 'account', id: principal.counterparty },\n\t\t\tlegs: [ ...onchainLegs(owned), ...onchainLegs(matched.block) ],\n\t\t\trefs\n\t\t}));\n\t\tconsumed.add(owned.blockHash);\n\t\tconsumed.add(matched.block.blockHash);\n\t}\n\n\treturn({ transactions, consumed });\n}\n\n/**\n * Fold enriched blocks into logical transactions. Cross-block accepted swaps\n * are paired first so neither leg is later dropped or split, then the ordered\n * classifiers run per block; the first classifier that applies to a block wins.\n */\nfunction foldHistory(blocks: readonly EnrichedBlock[], classifiers: readonly LogicalClassifier[]): LogicalTransaction[] {\n\tconst { transactions: swaps, consumed } = crossBlockSwaps(blocks);\n\tconst results: LogicalTransaction[] = [ ...swaps ];\n\tconst remaining = blocks.filter(block => !consumed.has(block.blockHash));\n\tfor (const block of suppressCoveredForeignBlocks(remaining)) {\n\t\tfor (const classifier of classifiers) {\n\t\t\tconst classified = classifier.classify(block);\n\t\t\tif (classified !== null) {\n\t\t\t\tresults.push(...classified);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn(results);\n}\n\n/**\n * Append `value` to `target` only when it is not already present.\n */\nfunction pushUnique<T>(target: T[], value: T): void {\n\tif (!target.includes(value)) {\n\t\ttarget.push(value);\n\t}\n}\n\n/**\n * Whether `transaction` declares an on-chain input that points at one of the\n * blocks contributing to `candidate`.\n */\nfunction inputsReference(transaction: LogicalTransaction, candidate: LogicalTransaction): boolean {\n\tconst inputs = transaction.refs.inputs;\n\tif (inputs === undefined) {\n\t\treturn(false);\n\t}\n\n\tconst blockHashes = new Set(candidate.refs.blockHashes);\n\tfor (const input of inputs) {\n\t\tif (blockHashes.has(input.blockHash)) {\n\t\t\treturn(true);\n\t\t}\n\t}\n\n\treturn(false);\n}\n\n/**\n * The counterparty shared by every hop, or `undefined` when the hops disagree.\n */\nfunction sharedCounterparty(hops: readonly LogicalTransaction[]): LogicalCounterparty | undefined {\n\tlet shared: LogicalCounterparty | undefined;\n\tfor (const hop of hops) {\n\t\tif (hop.counterparty === undefined) {\n\t\t\treturn(undefined);\n\t\t}\n\n\t\tif (shared === undefined) {\n\t\t\tshared = hop.counterparty;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (shared.kind !== hop.counterparty.kind || shared.id !== hop.counterparty.id) {\n\t\t\treturn(undefined);\n\t\t}\n\t}\n\n\treturn(shared);\n}\n\n/**\n * Reduce a linked chain of swap hops (head -> ... -> tail) into one logical\n * conversion: the head's send into the tail's receive, with intermediate\n * hops' legs suppressed and every hop's `refs` merged for drill-down.\n */\ntype MergedHopRefs = {\n\tblockHashes: string[];\n\tanchorTxIDs: string[];\n\texternals: string[];\n\tinputs: AnchorExternalInput[];\n\tdeclaredAnchorTxIDs: string[];\n};\n\n/**\n * Merge every hop's `refs`, de-duplicating block hashes, anchor transfer ids\n * and externals while preserving the ordered on-chain inputs.\n */\nfunction accumulateHopRefs(hops: readonly LogicalTransaction[]): MergedHopRefs {\n\tconst merged: MergedHopRefs = { blockHashes: [], anchorTxIDs: [], externals: [], inputs: [], declaredAnchorTxIDs: [] };\n\tfor (const hop of hops) {\n\t\tfor (const blockHash of hop.refs.blockHashes) {\n\t\t\tpushUnique(merged.blockHashes, blockHash);\n\t\t}\n\t\tfor (const anchorTxID of hop.refs.anchorTxIDs) {\n\t\t\tpushUnique(merged.anchorTxIDs, anchorTxID);\n\t\t}\n\t\tfor (const external of hop.refs.external ?? []) {\n\t\t\tpushUnique(merged.externals, external);\n\t\t}\n\t\tfor (const input of hop.refs.inputs ?? []) {\n\t\t\tmerged.inputs.push(input);\n\t\t}\n\t\tfor (const declaredAnchorTxID of hop.refs.declaredAnchorTxIDs ?? []) {\n\t\t\tpushUnique(merged.declaredAnchorTxIDs, declaredAnchorTxID);\n\t\t}\n\t}\n\n\treturn(merged);\n}\n\n/**\n * Combine hop statuses with failed taking precedence over pending over\n * complete.\n */\nfunction aggregateHopStatus(hops: readonly LogicalTransaction[]): LogicalTransactionStatus {\n\tlet pending = false;\n\tfor (const hop of hops) {\n\t\tif (hop.status === 'failed') {\n\t\t\treturn('failed');\n\t\t}\n\n\t\tif (hop.status === 'pending') {\n\t\t\tpending = true;\n\t\t}\n\t}\n\n\treturn(pending ? 'pending' : 'complete');\n}\n\n/**\n * The earliest timestamp across the hops, never later than `fallback`.\n */\nfunction earliestHopTimestamp(hops: readonly LogicalTransaction[], fallback: string): string {\n\tlet earliest = fallback;\n\tfor (const hop of hops) {\n\t\tif (Date.parse(hop.timestamp) < Date.parse(earliest)) {\n\t\t\tearliest = hop.timestamp;\n\t\t}\n\t}\n\n\treturn(earliest);\n}\n\n/**\n * The fees declared by the hops, in chain order.\n */\nfunction collectHopFees(hops: readonly LogicalTransaction[]): LogicalAmount[] {\n\tconst fees: LogicalAmount[] = [];\n\tfor (const hop of hops) {\n\t\tif (hop.fee !== undefined) {\n\t\t\tfees.push(hop.fee);\n\t\t}\n\t}\n\n\treturn(fees);\n}\n\n/**\n * The provider status of the latest hop that carries one, so a folded\n * conversion still reports the anchor's settlement status.\n */\nfunction latestHopProviderStatus(hops: readonly LogicalTransaction[]): string | undefined {\n\tlet providerStatus: string | undefined;\n\tfor (const hop of hops) {\n\t\tif (hop.providerStatus !== undefined) {\n\t\t\tproviderStatus = hop.providerStatus;\n\t\t}\n\t}\n\n\treturn(providerStatus);\n}\n\n/**\n * The head's legs followed by the tail's, suppressing intermediate hops and\n * avoiding a duplicate when head and tail are the same transaction.\n */\nfunction mergeHopLegs(head: LogicalTransaction, tail: LogicalTransaction): LogicalLeg[] {\n\tconst legs: LogicalLeg[] = [ ...head.legs ];\n\tif (tail.id !== head.id) {\n\t\tlegs.push(...tail.legs);\n\t}\n\n\treturn(legs);\n}\n\n/**\n * The display shape of a folded conversion.\n */\nfunction conversionShape(head: LogicalTransaction, tail: LogicalTransaction, hops: readonly LogicalTransaction[]): { type: LogicalTransaction['type']; direction: LogicalTransaction['direction']; counterparty: LogicalTransaction['counterparty'] } {\n\tif (head.type === 'send' && tail.type === 'receive') {\n\t\treturn({ type: 'swap', direction: 'self', counterparty: head.counterparty ?? tail.counterparty });\n\t}\n\n\tconst counterparty = tail.type === 'swap' ? sharedCounterparty(hops) : tail.counterparty;\n\treturn({ type: tail.type, direction: tail.direction, counterparty });\n}\n\nfunction mergeChainHops(head: LogicalTransaction, tail: LogicalTransaction, hops: readonly LogicalTransaction[]): LogicalTransaction {\n\tconst { blockHashes, anchorTxIDs, externals, inputs, declaredAnchorTxIDs } = accumulateHopRefs(hops);\n\n\tconst refs: LogicalTransaction['refs'] = { blockHashes, anchorTxIDs };\n\tif (externals.length > 0) {\n\t\trefs.external = externals;\n\t}\n\n\tif (inputs.length > 0) {\n\t\trefs.inputs = inputs;\n\t}\n\n\tif (declaredAnchorTxIDs.length > 0) {\n\t\trefs.declaredAnchorTxIDs = declaredAnchorTxIDs;\n\t}\n\n\tconst shape = conversionShape(head, tail, hops);\n\tconst merged: LogicalTransaction = {\n\t\tid: head.id,\n\t\ttype: shape.type,\n\t\tstatus: aggregateHopStatus(hops),\n\t\tdirection: shape.direction,\n\t\ttimestamp: earliestHopTimestamp(hops, head.timestamp),\n\t\tlegs: mergeHopLegs(head, tail),\n\t\trefs\n\t};\n\n\tif (head.send !== undefined) {\n\t\tmerged.send = head.send;\n\t}\n\n\tif (tail.receive !== undefined) {\n\t\tmerged.receive = tail.receive;\n\t}\n\n\tconst fee = combineFees(collectHopFees(hops));\n\tif (fee !== undefined) {\n\t\tmerged.fee = fee;\n\t}\n\n\tif (shape.counterparty !== undefined) {\n\t\tmerged.counterparty = shape.counterparty;\n\t}\n\n\tconst providerStatus = latestHopProviderStatus(hops);\n\tif (providerStatus !== undefined) {\n\t\tmerged.providerStatus = providerStatus;\n\t}\n\n\treturn(merged);\n}\n\n/**\n * An ordered chain of two or more linked hops.\n */\ntype FoldChain = {\n\tid: string;\n\thead: LogicalTransaction;\n\ttail: LogicalTransaction;\n\thops: LogicalTransaction[];\n};\n\n/**\n * An unenriched leg attributed to an anchor purely from its locally decoded\n * `external` (a declared transfer id, no authoritative `anchorTxIDs` yet, and\n * an anchor counterparty). These are the hops of an anchor conversion before\n * enrichment resolves their true swap/bridge types, so they chain along their\n * `inputs` edges the way resolved swaps do.\n */\nfunction isLocalAnchorHop(transaction: LogicalTransaction): boolean {\n\treturn(transaction.refs.anchorTxIDs.length === 0\n\t\t&& (transaction.refs.declaredAnchorTxIDs?.length ?? 0) > 0\n\t\t&& transaction.counterparty?.kind === 'anchor');\n}\n\n/**\n * Whether `head` may fold into `successor` along their\n * `refs.inputs` <-> `refs.blockHashes` link: swaps chain into further swaps or\n * a capping bridge, and a pay-in `send` caps into its delivery `receive`. The\n * single source of truth for edge validity, shared by the pure\n * {@link foldChains} pass and the incremental by-hash resolution.\n */\nfunction canLink(head: LogicalTransaction, successor: LogicalTransaction): boolean {\n\t/*\n\t * Unenriched anchor hops chain to one another along their inputs edges the\n\t * way resolved swaps do, so a multi-hop anchor conversion folds into one row\n\t * without enrichment. The inputs edge itself is always separately required\n\t * by the caller.\n\t */\n\tif (isLocalAnchorHop(head) && isLocalAnchorHop(successor)) {\n\t\treturn(true);\n\t}\n\n\tif (head.type === 'swap') {\n\t\treturn(successor.type === 'swap' || successor.type === 'bridge');\n\t}\n\n\tif (head.type === 'send') {\n\t\treturn(successor.type === 'receive');\n\t}\n\n\treturn(false);\n}\n\n/**\n * The forward/backward links between each head and the successor it funds,\n * established through their `refs.inputs` <-> `refs.blockHashes` edges. Each\n * head keeps at most one successor (its first match).\n */\ntype FoldLinks = {\n\tsuccessorOf: Map<string, LogicalTransaction>;\n\tpredecessorOf: Map<string, LogicalTransaction>;\n};\n\nfunction linkChainSuccessors(heads: readonly LogicalTransaction[], successors: readonly LogicalTransaction[]): FoldLinks {\n\tconst successorOf = new Map<string, LogicalTransaction>();\n\tconst predecessorOf = new Map<string, LogicalTransaction>();\n\tfor (const head of heads) {\n\t\tfor (const other of successors) {\n\t\t\tif (other.id === head.id || successorOf.has(head.id)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (canLink(head, other) && inputsReference(other, head)) {\n\t\t\t\tsuccessorOf.set(head.id, other);\n\t\t\t\tpredecessorOf.set(other.id, head);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn({ successorOf, predecessorOf });\n}\n\n/**\n * Walk the successor links from `head` to its tail, returning the hops in\n * order and stopping on a cycle.\n */\nfunction walkChainFrom(head: LogicalTransaction, successorOf: ReadonlyMap<string, LogicalTransaction>): LogicalTransaction[] {\n\tconst hops: LogicalTransaction[] = [ head ];\n\tconst visited = new Set<string>([ head.id ]);\n\tlet current = head;\n\twhile (true) {\n\t\tconst next = successorOf.get(current.id);\n\t\tif (next === undefined || visited.has(next.id)) {\n\t\t\tbreak;\n\t\t}\n\n\t\thops.push(next);\n\t\tvisited.add(next.id);\n\t\tcurrent = next;\n\t}\n\n\treturn(hops);\n}\n\nfunction buildChains(transactions: readonly LogicalTransaction[]): Map<string, FoldChain> {\n\tconst heads = transactions.filter(transaction => transaction.type === 'swap' || transaction.type === 'send' || isLocalAnchorHop(transaction));\n\tconst successors = transactions.filter(transaction => transaction.type === 'swap' || transaction.type === 'bridge' || transaction.type === 'receive' || isLocalAnchorHop(transaction));\n\tconst { successorOf, predecessorOf } = linkChainSuccessors(heads, successors);\n\n\tconst chainByMemberId = new Map<string, FoldChain>();\n\tfor (const head of heads) {\n\t\tif (predecessorOf.has(head.id)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst hops = walkChainFrom(head, successorOf);\n\t\tconst tail = hops.at(-1);\n\t\tif (hops.length < 2 || tail === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst chain: FoldChain = { id: head.id, head, tail, hops };\n\t\tfor (const hop of hops) {\n\t\t\tchainByMemberId.set(hop.id, chain);\n\t\t}\n\t}\n\n\treturn(chainByMemberId);\n}\n\n/**\n * Fold linked chains into single conversions for display: multi-hop swaps, a\n * swap that funds an outbound bridge, and a pay-in send capped by its delivery\n * receive (a non-atomic anchor swap seen leanly).\n */\nexport function foldChains(transactions: readonly LogicalTransaction[]): LogicalTransaction[] {\n\tconst chainByMemberId = buildChains(transactions);\n\tif (chainByMemberId.size === 0) {\n\t\treturn([ ...transactions ]);\n\t}\n\n\tconst emittedChains = new Set<string>();\n\tconst result: LogicalTransaction[] = [];\n\tfor (const transaction of transactions) {\n\t\tconst chain = chainByMemberId.get(transaction.id);\n\t\tif (chain === undefined) {\n\t\t\tresult.push(transaction);\n\t\t\tcontinue;\n\t\t}\n\t\tif (emittedChains.has(chain.id)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\temittedChains.add(chain.id);\n\t\tresult.push(mergeChainHops(chain.head, chain.tail, chain.hops));\n\t}\n\n\treturn(result);\n}\n\n/**\n * The anchor transfer ids a transaction settles: the authoritative\n * `anchorTxIDs` once enriched, otherwise the ids declared locally by the\n * block's `external` so an unenriched list de-duplicates a transfer's several\n * legs the same way. The empty-`anchorTxIDs` gate keeps enriched suppression\n * identical to before.\n */\nfunction settlementIDs(transaction: LogicalTransaction): readonly string[] {\n\tconst refs = transaction.refs;\n\tif (refs.anchorTxIDs.length > 0) {\n\t\treturn(refs.anchorTxIDs);\n\t}\n\n\treturn(refs.declaredAnchorTxIDs ?? []);\n}\n\n/**\n * Whether every anchor transfer a logical transaction settles has already been\n * emitted, marking it a duplicate settlement leg.\n */\nfunction isSettledDuplicate(transaction: LogicalTransaction, emitted: ReadonlySet<string>): boolean {\n\tconst ids = settlementIDs(transaction);\n\tif (ids.length === 0) {\n\t\treturn(false);\n\t}\n\n\treturn(ids.every(id => emitted.has(id)));\n}\n\n/**\n * Record the anchor transfers a logical transaction settles.\n */\nfunction markEmittedTransfers(transaction: LogicalTransaction, emitted: Set<string>): void {\n\tfor (const id of settlementIDs(transaction)) {\n\t\temitted.add(id);\n\t}\n}\n\n/**\n * Whether a transaction is a settlement leg already accounted for by an\n * earlier (newest-first) conversion.\n */\nfunction isSettledLeg(transaction: LogicalTransaction, emittedBlocks: ReadonlySet<string>): boolean {\n\tif (transaction.type !== 'receive') {\n\t\treturn(false);\n\t}\n\n\tconst inputs = transaction.refs.inputs;\n\tif (inputs === undefined || inputs.length === 0) {\n\t\treturn(false);\n\t}\n\n\treturn(inputs.every(input => emittedBlocks.has(input.blockHash)));\n}\n\n/**\n * Record the on-chain blocks a logical transaction (or folded conversion)\n * already accounts for.\n */\nfunction markEmittedBlocks(transaction: LogicalTransaction, emitted: Set<string>): void {\n\tfor (const blockHash of transaction.refs.blockHashes) {\n\t\temitted.add(blockHash);\n\t}\n}\n\n/**\n * Drop logical transactions whose every settled transfer was already emitted by\n * an earlier (newest-first) entry, collapsing a transfer's multiple on-chain\n * legs into the single conversion that represents it.\n */\nfunction suppressSettledDuplicates(transactions: readonly LogicalTransaction[]): LogicalTransaction[] {\n\tconst emitted = new Set<string>();\n\tconst emittedBlocks = new Set<string>();\n\tconst result: LogicalTransaction[] = [];\n\tfor (const transaction of transactions) {\n\t\tif (isSettledDuplicate(transaction, emitted) || isSettledLeg(transaction, emittedBlocks)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tmarkEmittedTransfers(transaction, emitted);\n\t\tmarkEmittedBlocks(transaction, emittedBlocks);\n\t\tresult.push(transaction);\n\t}\n\n\treturn(result);\n}\n\n/**\n * Relabel a lone unenriched anchor leg to its provisional withdraw/deposit\n * shape for display. A no-op once enriched (the row then carries authoritative\n * `anchorTxIDs`), for folded swaps, and for rows with no trusted anchor\n * declaration. Must run AFTER settlement suppression, since it rewrites `type`\n * and would otherwise defeat the `type === 'receive'` gate in `isSettledLeg`.\n */\nfunction normalizeProvisional(transaction: LogicalTransaction): LogicalTransaction {\n\tconst refs = transaction.refs;\n\tif (refs.anchorTxIDs.length > 0) {\n\t\treturn(transaction);\n\t}\n\n\tif (refs.declaredAnchorTxIDs === undefined || refs.declaredAnchorTxIDs.length === 0) {\n\t\treturn(transaction);\n\t}\n\n\tif (transaction.counterparty?.kind !== 'anchor') {\n\t\treturn(transaction);\n\t}\n\n\tif (transaction.type !== 'send' && transaction.type !== 'receive') {\n\t\treturn(transaction);\n\t}\n\n\treturn({ ...transaction, type: transaction.type === 'send' ? 'withdraw' : 'deposit', provisional: true });\n}\n\n/**\n * Re-attach a caller's `source` to a conversion that lost it. A folded\n * multi-hop conversion is built fresh by {@link mergeChainHops} and carries no\n * `source`, so an `includeSource` enrichment would otherwise drop the\n * perspective a detail view needs. Mirrors how {@link UserHistory.iterate}\n * carries source into a folded conversion in its `#foldForward` pass.\n */\nfunction attachConversionSource(transaction: LogicalTransaction, source: LogicalTransactionSource | undefined, includeSource: boolean): LogicalTransaction {\n\tif (!includeSource || transaction.source !== undefined || source === undefined) {\n\t\treturn(transaction);\n\t}\n\n\treturn({ ...transaction, source });\n}\n\n/**\n * A transfer paired with the anchor account it resolved under.\n */\ntype ResolvedTransfer = {\n\tanchorID: string;\n\ttransfer: KeetaAssetMovementTransaction;\n};\n\n/**\n * The per-stream state threaded through {@link UserHistory.iterate}: the\n * resolved query, whether the source can fold chains, and the dedupe sets and\n * caches shared across pages.\n */\ntype IterationContext = {\n\tperspective: string | undefined;\n\toptions: UserHistoryListOptions | undefined;\n\t/**\n\t * Fold-capable sources resolve each linked predecessor by block hash, so a\n\t * chain whose tail is seen first (newest-first paging) is folded on the\n\t * spot and its older hops are skipped when they later page in.\n\t */\n\tfoldCapable: boolean;\n\t/**\n\t * Hop ids already folded into an emitted conversion.\n\t */\n\tconsumed: Set<string>;\n\t/**\n\t * Anchor transfer ids already emitted.\n\t */\n\temittedTransfers: Set<string>;\n\t/**\n\t * On-chain blocks already represented by an emitted conversion.\n\t */\n\temittedBlocks: Set<string>;\n\texternalCache: Map<string, ResolvedTransfer | undefined>;\n\treaderCache: Map<string, AnchorTransferReader<KeetaAssetMovementTransaction> | null>;\n};\n\n/**\n * The first transfer reported as a status across an external's anchors.\n */\nfunction firstResolvedTransfer(results: { [anchorID: string]: AnchorTransactionStatusResult<KeetaAssetMovementTransaction> }): ResolvedTransfer | undefined {\n\tfor (const [ anchorID, result ] of Object.entries(results)) {\n\t\tif (result.kind === 'status') {\n\t\t\treturn({ anchorID, transfer: result.status.transaction });\n\t\t}\n\t}\n\n\treturn(undefined);\n}\n\n/**\n * Build decode + status options for an external resolution.\n */\nfunction buildExternalOptions(options?: UserHistoryListOptions): AnchorExternalTransactionStatusOptions {\n\tconst built: AnchorExternalTransactionStatusOptions = {};\n\tif (options?.decryptionKeys !== undefined) {\n\t\tbuilt.decryptionKeys = options.decryptionKeys;\n\t}\n\n\tif (options?.requesterAccount !== undefined) {\n\t\tbuilt.requesterAccount = options.requesterAccount;\n\t}\n\n\treturn(built);\n}\n\n/**\n * Attach raw sources to folded transactions by their source block hash.\n *\n * A transaction id is its block hash, or `blockHash:operationIndex` when a\n * block yields more than one logical transaction.\n */\nfunction attachSources(transactions: readonly LogicalTransaction[], sources: ReadonlyMap<string, LogicalTransactionSource>): void {\n\tfor (const transaction of transactions) {\n\t\tconst [ blockHash ] = transaction.id.split(':');\n\t\tif (blockHash === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst source = sources.get(blockHash);\n\t\tif (source !== undefined) {\n\t\t\ttransaction.source = source;\n\t\t}\n\t}\n}\n\n/**\n * Normalize the queried account to its public key string.\n */\nfunction perspectiveOf(account: HistoryAccount): string | undefined {\n\tif (account === null) {\n\t\treturn(undefined);\n\t}\n\n\tif (typeof account === 'string') {\n\t\treturn(account);\n\t}\n\n\treturn(account.publicKeyString.get());\n}\n\n/**\n * Build status options for a reverse-lookup.\n */\nfunction buildStatusOptions(options?: UserHistoryListOptions): AnchorGetTransactionStatusOptions {\n\tconst built: AnchorGetTransactionStatusOptions = {};\n\tif (options?.requesterAccount !== undefined) {\n\t\tbuilt.requesterAccount = options.requesterAccount;\n\t}\n\n\treturn(built);\n}\n\n/**\n * Folds a user's on-chain history and anchor transfer data into a condensed\n * list of {@link LogicalTransaction}.\n */\nexport class UserHistory {\n\treadonly #history: HistorySource;\n\treadonly #status?: AnchorTransactionStatus<KeetaAssetMovementTransaction>;\n\treadonly #classifiers: readonly LogicalClassifier[];\n\treadonly #logger?: Logger;\n\n\tconstructor(config: UserHistoryConfig) {\n\t\tthis.#history = config.history;\n\t\tif (config.status !== undefined) {\n\t\t\tthis.#status = config.status;\n\t\t}\n\n\t\tif (config.logger !== undefined) {\n\t\t\tthis.#logger = config.logger;\n\t\t}\n\n\t\tthis.#classifiers = config.classifiers ?? defaultClassifiers;\n\t}\n\n\t/**\n\t * Fetch, enrich and fold a user's history into logical transactions,\n\t * grouping linked multi-hop chains into single conversions.\n\t */\n\tasync list(account: HistoryAccount, options?: UserHistoryListOptions): Promise<LogicalTransaction[]> {\n\t\tconst transactions: LogicalTransaction[] = [];\n\n\t\t/*\n\t\t * When the source can resolve staples by block hash, iterate() already\n\t\t * folds linked chains incrementally and honors `limit` by short-circuit,\n\t\t * so a bounded `limit` no longer walks the whole account.\n\t\t */\n\t\tif (typeof this.#history.getVoteStaple === 'function') {\n\t\t\tfor await (const transaction of this.iterate(account, options)) {\n\t\t\t\ttransactions.push(transaction);\n\t\t\t}\n\n\t\t\treturn(transactions);\n\t\t}\n\n\t\t/*\n\t\t * Fallback for sources without by-hash resolution: drain fully and fold\n\t\t * across the whole set so cross-page chains still group.\n\t\t */\n\t\tconst { limit, ...collectOptions } = options ?? {};\n\t\tfor await (const transaction of this.iterate(account, collectOptions)) {\n\t\t\ttransactions.push(transaction);\n\t\t}\n\n\t\tconst folded = suppressSettledDuplicates(foldChains(transactions)).map(normalizeProvisional);\n\t\tif (limit !== undefined) {\n\t\t\treturn(folded.slice(0, limit));\n\t\t}\n\n\t\treturn(folded);\n\t}\n\n\t/**\n\t * Enrich a single transaction on demand by resolving the anchor transfers\n\t * for only its contributing blocks.\n\t */\n\tasync enrichTransaction(transaction: LogicalTransaction, account: HistoryAccount, options?: UserHistoryListOptions): Promise<LogicalTransaction> {\n\t\tconst source = this.#history;\n\t\tif (typeof source.getVoteStaple !== 'function') {\n\t\t\treturn(transaction);\n\t\t}\n\n\t\tconst perspective = perspectiveOf(account);\n\t\tconst resolved = this.#withDefaultDecryptionKeys(account, { ...options, enrich: true });\n\t\tconst externalCache = new Map<string, ResolvedTransfer | undefined>();\n\t\tconst readerCache = new Map<string, AnchorTransferReader<KeetaAssetMovementTransaction> | null>();\n\n\t\tconst logical: LogicalTransaction[] = [];\n\t\tconst visited = new Set<string>();\n\t\tfor (const blockHash of transaction.refs.blockHashes) {\n\t\t\tif (visited.has(blockHash)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tvisited.add(blockHash);\n\t\t\tconst staple = await source.getVoteStaple(blockHash);\n\t\t\tif (staple === null || staple === undefined) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfor (const candidate of await this.#foldStaple(staple, perspective, resolved, externalCache, readerCache)) {\n\t\t\t\tlogical.push(candidate);\n\t\t\t}\n\t\t}\n\n\t\tconst blockHashes = new Set(transaction.refs.blockHashes);\n\t\tconst folded = foldChains(logical);\n\t\tconst includeSource = resolved?.includeSource === true;\n\n\t\tconst matchByID = folded.find(function(candidate) {\n\t\t\treturn(candidate.id === transaction.id);\n\t\t});\n\t\tif (matchByID !== undefined) {\n\t\t\treturn(attachConversionSource(normalizeProvisional(matchByID), transaction.source, includeSource));\n\t\t}\n\n\t\tconst matchByBlock = folded.find(function(candidate) {\n\t\t\treturn(candidate.refs.blockHashes.some(hash => blockHashes.has(hash)));\n\t\t});\n\n\t\treturn(attachConversionSource(normalizeProvisional(matchByBlock ?? transaction), transaction.source, includeSource));\n\t}\n\n\t/**\n\t * Stream logical transactions newest-first, paging through history one page\n\t * at a time instead of buffering the full result set. Walks every page until\n\t * history is exhausted, or until {@link UserHistoryListOptions.limit} logical\n\t * transactions have been yielded.\n\t */\n\tasync *iterate(account: HistoryAccount, options?: UserHistoryListOptions): AsyncGenerator<LogicalTransaction> {\n\t\tconst resolved = this.#withDefaultDecryptionKeys(account, options);\n\t\tconst context: IterationContext = {\n\t\t\tperspective: perspectiveOf(account),\n\t\t\toptions: resolved,\n\t\t\tfoldCapable: typeof this.#history.getVoteStaple === 'function',\n\t\t\tconsumed: new Set<string>(),\n\t\t\temittedTransfers: new Set<string>(),\n\t\t\temittedBlocks: new Set<string>(),\n\t\t\texternalCache: new Map<string, ResolvedTransfer | undefined>(),\n\t\t\treaderCache: new Map<string, AnchorTransferReader<KeetaAssetMovementTransaction> | null>()\n\t\t};\n\n\t\tlet cursor = resolved?.cursor;\n\t\tlet yielded = 0;\n\t\twhile (true) {\n\t\t\tconst page = await this.#fetchPage(account, cursor, resolved);\n\t\t\tif (page.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfor (const entry of page) {\n\t\t\t\tfor (const transaction of await this.#stapleEmissions(entry.voteStaple, context)) {\n\t\t\t\t\tconst out = await this.#nextEmission(transaction, context);\n\t\t\t\t\tif (out === undefined) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tyield out;\n\t\t\t\t\tyielded += 1;\n\n\t\t\t\t\tif (resolved?.limit !== undefined && yielded >= resolved.limit) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst last = page.at(-1);\n\t\t\tif (last === undefined) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = last.voteStaple.blocksHash.toString();\n\t\t}\n\t}\n\n\t/**\n\t * Classify a staple into the logical transactions to consider, folding\n\t * chains up front when the source supports it.\n\t */\n\tasync #stapleEmissions(staple: HistoryStaple, context: IterationContext): Promise<LogicalTransaction[]> {\n\t\tconst logical = await this.#foldStaple(staple, context.perspective, context.options, context.externalCache, context.readerCache);\n\t\treturn(context.foldCapable ? foldChains(logical) : logical);\n\t}\n\n\t/**\n\t * Resolve a candidate to the transaction that should be emitted, or\n\t * `undefined` when it is an already-consumed hop or a duplicate settlement\n\t * leg. Folds the candidate forward and records what it settles.\n\t */\n\tasync #nextEmission(transaction: LogicalTransaction, context: IterationContext): Promise<LogicalTransaction | undefined> {\n\t\tif (context.consumed.has(transaction.id)) {\n\t\t\treturn(undefined);\n\t\t}\n\n\t\tlet out = transaction;\n\t\tif (context.foldCapable) {\n\t\t\tout = await this.#foldForward(transaction, context.consumed, context.perspective, context.options, context.externalCache, context.readerCache);\n\t\t}\n\n\t\tif (isSettledDuplicate(out, context.emittedTransfers) || isSettledLeg(out, context.emittedBlocks)) {\n\t\t\treturn(undefined);\n\t\t}\n\n\t\tmarkEmittedTransfers(out, context.emittedTransfers);\n\t\tmarkEmittedBlocks(out, context.emittedBlocks);\n\t\treturn(context.foldCapable ? normalizeProvisional(out) : out);\n\t}\n\n\t/**\n\t * Default {@link UserHistoryListOptions.decryptionKeys} to the queried\n\t * account, the recipient of any anchor-delivered slice and so the natural\n\t * key for the externals encrypted to it. An explicit `decryptionKeys` (or a\n\t * string/null perspective that cannot decrypt) is left untouched.\n\t */\n\t#withDefaultDecryptionKeys(account: HistoryAccount, options?: UserHistoryListOptions): UserHistoryListOptions | undefined {\n\t\tif (options?.decryptionKeys !== undefined || account === null || typeof account === 'string') {\n\t\t\treturn(options);\n\t\t}\n\n\t\treturn({ ...options, decryptionKeys: [ account ] });\n\t}\n\n\t/**\n\t * Enrich and classify a single vote staple's blocks into logical\n\t * transactions, attaching raw sources when requested. Shared by the paging\n\t * loop and the by-hash predecessor resolution used to fold chains.\n\t */\n\tasync #foldStaple(staple: HistoryStaple, perspective: string | undefined, options: UserHistoryListOptions | undefined, externalCache: Map<string, ResolvedTransfer | undefined>, readerCache: Map<string, AnchorTransferReader<KeetaAssetMovementTransaction> | null>): Promise<LogicalTransaction[]> {\n\t\tconst timestamp = staple.timestamp().toISOString();\n\t\tconst blocks: EnrichedBlock[] = [];\n\t\tconst sources = new Map<string, LogicalTransactionSource>();\n\t\tfor (const block of staple.blocks) {\n\t\t\tconst enriched = await this.#enrichBlock(block, timestamp, perspective, options, externalCache, readerCache);\n\t\t\tblocks.push(enriched);\n\n\t\t\tif (options?.includeSource === true) {\n\t\t\t\tsources.set(enriched.blockHash, { staple, enriched });\n\t\t\t}\n\t\t}\n\n\t\tconst logical = foldHistory(blocks, this.#classifiers);\n\t\tattachSources(logical, sources);\n\t\treturn(logical);\n\t}\n\n\t/**\n\t * Fold a tail that declares on-chain inputs into the full conversion it\n\t * caps, resolving every linked predecessor by hash and marking each hop\n\t * `consumed` so it is skipped when it later pages in.\n\t */\n\tasync #foldForward(transaction: LogicalTransaction, consumed: Set<string>, perspective: string | undefined, options: UserHistoryListOptions | undefined, externalCache: Map<string, ResolvedTransfer | undefined>, readerCache: Map<string, AnchorTransferReader<KeetaAssetMovementTransaction> | null>): Promise<LogicalTransaction> {\n\t\tconst foldable = transaction.type === 'swap' || transaction.type === 'bridge' || transaction.type === 'receive' || isLocalAnchorHop(transaction);\n\t\tif (!foldable || transaction.refs.inputs === undefined || transaction.refs.inputs.length === 0) {\n\t\t\treturn(transaction);\n\t\t}\n\n\t\tconst hops = await this.#resolveChainBackward(transaction, perspective, options, externalCache, readerCache);\n\t\tconst head = hops.at(0);\n\t\tconst tail = hops.at(-1);\n\t\tif (hops.length < 2 || head === undefined || tail === undefined) {\n\t\t\treturn(transaction);\n\t\t}\n\n\t\tfor (const hop of hops) {\n\t\t\tconsumed.add(hop.id);\n\t\t}\n\n\t\tconst merged = mergeChainHops(head, tail, hops);\n\t\tif (options?.includeSource === true && transaction.source !== undefined) {\n\t\t\tmerged.source = transaction.source;\n\t\t}\n\n\t\treturn(merged);\n\t}\n\n\t/**\n\t * Walk a chain backward from its tail, following each hop's on-chain input\n\t * to the predecessor it references, until the head (a hop with no\n\t * resolvable input) is reached. Returns the hops oldest-first.\n\t */\n\tasync #resolveChainBackward(tail: LogicalTransaction, perspective: string | undefined, options: UserHistoryListOptions | undefined, externalCache: Map<string, ResolvedTransfer | undefined>, readerCache: Map<string, AnchorTransferReader<KeetaAssetMovementTransaction> | null>): Promise<LogicalTransaction[]> {\n\t\tconst hops: LogicalTransaction[] = [ tail ];\n\t\tconst seenIds = new Set<string>([ tail.id ]);\n\t\tconst triedHashes = new Set<string>();\n\t\tlet current = tail;\n\t\twhile (true) {\n\t\t\tconst predecessor = await this.#walkToPredecessor(current, triedHashes, seenIds, perspective, options, externalCache, readerCache);\n\t\t\tif (predecessor === undefined) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\thops.unshift(predecessor);\n\t\t\tseenIds.add(predecessor.id);\n\t\t\tcurrent = predecessor;\n\t\t}\n\n\t\treturn(hops);\n\t}\n\n\t/**\n\t * Resolve the first not-yet-tried input of `current` to the predecessor it\n\t * references, or `undefined` when none resolve to a new, linkable hop.\n\t */\n\tasync #walkToPredecessor(current: LogicalTransaction, triedHashes: Set<string>, seenIds: Set<string>, perspective: string | undefined, options: UserHistoryListOptions | undefined, externalCache: Map<string, ResolvedTransfer | undefined>, readerCache: Map<string, AnchorTransferReader<KeetaAssetMovementTransaction> | null>): Promise<LogicalTransaction | undefined> {\n\t\tfor (const input of current.refs.inputs ?? []) {\n\t\t\tif (triedHashes.has(input.blockHash)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\ttriedHashes.add(input.blockHash);\n\n\t\t\tconst predecessor = await this.#resolveContributing(input.blockHash, current, perspective, options, externalCache, readerCache);\n\t\t\tif (predecessor !== undefined && !seenIds.has(predecessor.id)) {\n\t\t\t\treturn(predecessor);\n\t\t\t}\n\t\t}\n\n\t\treturn(undefined);\n\t}\n\n\t/**\n\t * Fetch the staple settling `blockHash` and return the logical transaction\n\t * it contributes that may fold into `successor` (per {@link canLink}), or\n\t * `undefined` when none can be resolved.\n\t */\n\tasync #resolveContributing(blockHash: string, successor: LogicalTransaction, perspective: string | undefined, options: UserHistoryListOptions | undefined, externalCache: Map<string, ResolvedTransfer | undefined>, readerCache: Map<string, AnchorTransferReader<KeetaAssetMovementTransaction> | null>): Promise<LogicalTransaction | undefined> {\n\t\tconst source = this.#history;\n\t\tif (typeof source.getVoteStaple !== 'function') {\n\t\t\treturn(undefined);\n\t\t}\n\n\t\tconst staple = await source.getVoteStaple(blockHash);\n\t\tif (staple === null || staple === undefined) {\n\t\t\treturn(undefined);\n\t\t}\n\n\t\tconst logical = foldChains(await this.#foldStaple(staple, perspective, options, externalCache, readerCache));\n\t\treturn(logical.find(transaction => transaction.refs.blockHashes.includes(blockHash) && canLink(transaction, successor)));\n\t}\n\n\t/**\n\t * Fetch one page of on-chain history.\n\t */\n\tasync #fetchPage(account: HistoryAccount, cursor: string | undefined, options?: UserHistoryListOptions): Promise<HistoryEntry[]> {\n\t\tconst query: HistoryQuery = {};\n\t\tif (options?.depth !== undefined) {\n\t\t\tquery.depth = options.depth;\n\t\t}\n\t\tif (options?.pageSize !== undefined) {\n\t\t\tquery.pageSize = options.pageSize;\n\t\t}\n\t\tif (cursor !== undefined) {\n\t\t\tquery.startBlocksHash = cursor;\n\t\t}\n\n\t\tconst result = await this.#history.getHistory(account, query);\n\t\treturn(result);\n\t}\n\n\t/**\n\t * Enrich each operation of a block with its anchor transfer, if resolvable.\n\t */\n\tasync #enrichBlock(block: Block, timestamp: string, perspective: string | undefined, options: UserHistoryListOptions | undefined, externalCache: Map<string, ResolvedTransfer | undefined>, readerCache: Map<string, AnchorTransferReader<KeetaAssetMovementTransaction> | null>): Promise<EnrichedBlock> {\n\t\tconst blockHash = block.hash.toString();\n\t\tconst account = block.account.publicKeyString.get();\n\t\tconst enrichEnabled = options?.enrich === true && this.#status !== undefined;\n\n\t\t/*\n\t\t * A single anchor transfer (an FX swap, say) can be settled by several\n\t\t * operations in one block.\n\t\t */\n\t\tconst attachedTransferIDs = new Set<string>();\n\t\tconst operations: EnrichedOperation[] = [];\n\t\tfor (let index = 0; index < block.operations.length; index++) {\n\t\t\tconst operation = block.operations[index];\n\t\t\tif (operation === undefined) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst enriched: EnrichedOperation = { operation, index };\n\t\t\tif (enrichEnabled) {\n\t\t\t\tconst resolved = await this.#resolveTransfer(block, operation, index, perspective, options, externalCache, readerCache);\n\t\t\t\tif (resolved !== undefined && !attachedTransferIDs.has(resolved.transfer.id)) {\n\t\t\t\t\tattachedTransferIDs.add(resolved.transfer.id);\n\t\t\t\t\tenriched.transfer = resolved.transfer;\n\t\t\t\t\tenriched.anchorID = resolved.anchorID;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\toperations.push(enriched);\n\t\t}\n\n\t\tconst result: EnrichedBlock = { blockHash, account, timestamp, operations };\n\t\tif (perspective !== undefined) {\n\t\t\tresult.perspective = perspective;\n\t\t}\n\n\t\tconst decoded = await decodeExternalEnvelopes(blockExternals(result), options?.decryptionKeys);\n\t\tif (decoded.inputs.length > 0) {\n\t\t\tresult.inputs = decoded.inputs;\n\t\t}\n\n\t\t/*\n\t\t * Only trust a declared anchor reference when the block is issued by the\n\t\t * perspective (its own history) or the entry was signed by the anchor.\n\t\t * An unsigned foreign block could otherwise assert a transfer id it does\n\t\t * not own and corrupt grouping.\n\t\t */\n\t\tconst owned = perspective !== undefined && account === perspective;\n\t\tconst trustedAnchors = decoded.declaredAnchors.filter(ref => owned || ref.signed);\n\t\tif (trustedAnchors.length > 0) {\n\t\t\tresult.declaredAnchors = trustedAnchors;\n\t\t}\n\n\t\treturn(result);\n\t}\n\n\t/**\n\t * Resolve one operation to its anchor transfer, preferring the SEND's own\n\t * `external` and falling back to a reverse-lookup by on-chain coordinates.\n\t */\n\tasync #resolveTransfer(block: Block, operation: BlockOperations, index: number, perspective: string | undefined, options: UserHistoryListOptions | undefined, externalCache: Map<string, ResolvedTransfer | undefined>, readerCache: Map<string, AnchorTransferReader<KeetaAssetMovementTransaction> | null>): Promise<ResolvedTransfer | undefined> {\n\t\tconst status = this.#status;\n\t\tif (status === undefined) {\n\t\t\treturn(undefined);\n\t\t}\n\n\t\tif (operation.type === OperationType.SEND && operation.external !== undefined) {\n\t\t\tconst fromExternal = await this.#resolveFromExternal(status, operation.external, options, externalCache);\n\t\t\tif (fromExternal !== undefined) {\n\t\t\t\treturn(fromExternal);\n\t\t\t}\n\t\t}\n\n\t\tconst issuer = block.account.publicKeyString.get();\n\t\tlet candidateAnchor: string | undefined;\n\t\tif (perspective !== undefined && issuer !== perspective) {\n\t\t\tcandidateAnchor = issuer;\n\t\t} else {\n\t\t\tcandidateAnchor = counterpartyID(operation);\n\t\t}\n\n\t\tif (candidateAnchor === undefined) {\n\t\t\treturn(undefined);\n\t\t}\n\n\t\tconst fromOnChain = await this.#resolveByOnChain(status, candidateAnchor, block.network, block.hash.toString(), index, options, readerCache);\n\t\treturn(fromOnChain);\n\t}\n\n\t/**\n\t * Resolve a transfer from a SEND's `external` envelope, deduped per blob.\n\t */\n\tasync #resolveFromExternal(status: AnchorTransactionStatus<KeetaAssetMovementTransaction>, external: string, options: UserHistoryListOptions | undefined, externalCache: Map<string, ResolvedTransfer | undefined>): Promise<ResolvedTransfer | undefined> {\n\t\tconst cached = externalCache.get(external);\n\t\tif (cached !== undefined || externalCache.has(external)) {\n\t\t\treturn(cached);\n\t\t}\n\n\t\tlet resolved: ResolvedTransfer | undefined;\n\t\ttry {\n\t\t\tconst results = await status.getStatusesFromExternal(external, buildExternalOptions(options));\n\t\t\tresolved = firstResolvedTransfer(results);\n\t\t} catch (error) {\n\t\t\tthis.#logger?.debug('UserHistory::resolveFromExternal', `External did not resolve to a transfer, degrading to block-shape classification: ${String(error)}`);\n\t\t\tresolved = undefined;\n\t\t}\n\n\t\texternalCache.set(external, resolved);\n\t\treturn(resolved);\n\t}\n\n\t/**\n\t * Reverse-lookup a transfer by on-chain coordinates through the anchor the\n\t * counterparty resolves to.\n\t */\n\tasync #resolveByOnChain(status: AnchorTransactionStatus<KeetaAssetMovementTransaction>, counterparty: string, networkID: bigint, blockHash: string, operationIndex: number, options: UserHistoryListOptions | undefined, readerCache: Map<string, AnchorTransferReader<KeetaAssetMovementTransaction> | null>): Promise<ResolvedTransfer | undefined> {\n\t\tconst reader = await this.#getReader(status, counterparty, readerCache);\n\t\tif (reader?.findByOnChain === undefined) {\n\t\t\treturn(undefined);\n\t\t}\n\n\t\ttry {\n\t\t\tconst result = await reader.findByOnChain({ keetaNetworkID: networkID, blockHash, operationIndex }, buildStatusOptions(options));\n\t\t\tif (result === null) {\n\t\t\t\treturn(undefined);\n\t\t\t}\n\n\t\t\treturn({ anchorID: counterparty, transfer: result.transaction });\n\t\t} catch (error) {\n\t\t\tthis.#logger?.debug('UserHistory::resolveByOnChain', `Reverse-lookup at ${counterparty} for ${blockHash}:${operationIndex} failed: ${String(error)}`);\n\t\t\treturn(undefined);\n\t\t}\n\t}\n\n\t/**\n\t * Resolve and cache the reader for an anchor counterparty.\n\t */\n\tasync #getReader(status: AnchorTransactionStatus<KeetaAssetMovementTransaction>, counterparty: string, readerCache: Map<string, AnchorTransferReader<KeetaAssetMovementTransaction> | null>): Promise<AnchorTransferReader<KeetaAssetMovementTransaction> | null> {\n\t\tconst cached = readerCache.get(counterparty);\n\t\tif (cached !== undefined || readerCache.has(counterparty)) {\n\t\t\treturn(cached ?? null);\n\t\t}\n\n\t\tlet reader: AnchorTransferReader<KeetaAssetMovementTransaction> | null;\n\t\ttry {\n\t\t\tconst anchor = KeetaNetLib.Account.fromPublicKeyString(counterparty);\n\t\t\treader = await status.getReader(anchor);\n\t\t} catch (error) {\n\t\t\tthis.#logger?.debug('UserHistory::getReader', `No reader resolved for ${counterparty}: ${String(error)}`);\n\t\t\treader = null;\n\t\t}\n\n\t\treaderCache.set(counterparty, reader);\n\t\treturn(reader);\n\t}\n}\n\nexport default UserHistory;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-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ACH,IAAI,GAAG,IAAI,MAAM,CAoChB;IAED,IAAI,GAAG,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,MAAM,EAAE,IAAI,KAAK,MAAM,CAAC,EAGnE;IAED,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAGtC"}
|
package/lib/http-server/index.js
CHANGED
|
@@ -318,12 +318,31 @@ export class KeetaNetAnchorHTTPServer {
|
|
|
318
318
|
...(await this.initRoutes(this.#config))
|
|
319
319
|
});
|
|
320
320
|
const server = new http.Server(async (request, response) => {
|
|
321
|
+
const forwardedProtoHeader = request.headers['x-forwarded-proto'];
|
|
322
|
+
let forwardedProto;
|
|
323
|
+
if (Array.isArray(forwardedProtoHeader)) {
|
|
324
|
+
forwardedProto = forwardedProtoHeader[0];
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
forwardedProto = forwardedProtoHeader;
|
|
328
|
+
}
|
|
329
|
+
forwardedProto = forwardedProto?.split(',')[0]?.trim();
|
|
330
|
+
let protocol;
|
|
331
|
+
if (forwardedProto !== undefined && forwardedProto !== '') {
|
|
332
|
+
protocol = forwardedProto;
|
|
333
|
+
}
|
|
334
|
+
else if ('encrypted' in request.socket && request.socket.encrypted === true) {
|
|
335
|
+
protocol = 'https';
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
protocol = 'http';
|
|
339
|
+
}
|
|
321
340
|
/*
|
|
322
341
|
* Get the Base URL from the request Host header (if
|
|
323
342
|
* available) or default to localhost. This is used
|
|
324
343
|
* to construct the full URL for routing.
|
|
325
344
|
*/
|
|
326
|
-
const inputURLBaseRaw = new URL(
|
|
345
|
+
const inputURLBaseRaw = new URL(`${protocol}://${request.headers.host ?? 'localhost'}`);
|
|
327
346
|
const inputURLBase = inputURLBaseRaw.protocol + '//' + inputURLBaseRaw.host;
|
|
328
347
|
/*
|
|
329
348
|
* Normalize the input URL by stripping leading slashes and
|