-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
I'm trying to use the CardanoWatchClient to watch for transactions involving a policyId. However, whenever I get a transaction from WatchService/WatchTx, I end up with this error:
~/projects/lobsvr/indexer-testing/node_modules/.pnpm/@utxorpc+sdk@0.8.0_@bufbuild+protobuf@1.10.1/node_modules/@utxorpc/sdk/src/cardano.ts:63
throw new Error(`Unexpected block chain response (expected "cardano", saw "${response.action.value.block?.chain?.case ?? "<none>"}")`);
^
Error: Unexpected block chain response (expected "cardano", saw "<none>")
at toTxEvent (~/projects/lobsvr/indexer-testing/node_modules/.pnpm/@utxorpc+sdk@0.8.0_@bufbuild+protobuf@1.10.1/node_modules/@utxorpc/sdk/src/cardano.ts:63:15)
at WatchClient.watchTxByPredicate (~/projects/lobsvr/indexer-testing/node_modules/.pnpm/@utxorpc+sdk@0.8.0_@bufbuild+protobuf@1.10.1/node_modules/@utxorpc/sdk/src/cardano.ts:487:13)
at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
at async WatchClient.watchTxByMatch (~/projects/lobsvr/indexer-testing/node_modules/.pnpm/@utxorpc+sdk@0.8.0_@bufbuild+protobuf@1.10.1/node_modules/@utxorpc/sdk/src/cardano.ts:496:5)
at async WatchClient.watchTxForAsset (~/projects/lobsvr/indexer-testing/node_modules/.pnpm/@utxorpc+sdk@0.8.0_@bufbuild+protobuf@1.10.1/node_modules/@utxorpc/sdk/src/cardano.ts:534:5)
at async <anonymous> (~/projects/lobsvr/indexer-testing/src/utxorpc.ts:56:18)
It looks like the toTxEvent function in src/cardano.ts is checking for a Block, but we only ever get a Transaction from the service.
function toTxEvent(response: watch.WatchTxResponse): TxEvent {
switch (response.action.case) {
case "apply":
case "undo":
if (response.action.value.chain.case !== "cardano") {
throw new Error(`Unexpected tx chain response (expected "cardano", saw "${response.action.value.chain.case}")`);
}
if (response.action.value.block?.chain?.case !== "cardano") {
// This code always triggers, because this is a Transaction Event, not a Block Event
throw new Error(`Unexpected block chain response (expected "cardano", saw "${response.action.value.block?.chain?.case ?? "<none>"}")`);
}
return {
action: response.action.case,
Tx: response.action.value.chain.value,
Block: response.action.value.block.chain.value,
}Can we just get rid of the check for a Block here, and then only return the action and Tx? It seems like we don't need the Block if we're just dealing with a Transation Event.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels