Skip to content

Commit

Permalink
feat: add optional CBOR representation to GET_TRANSACTION
Browse files Browse the repository at this point in the history
  • Loading branch information
iccicci committed Nov 29, 2024
1 parent 7259cf4 commit 36b7266
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ Payload contains [protocol parameters](https://docs.blockfrost.io/#tag/cardano--

### GET_TRANSACTION

Returns information about a specified transaction.
Returns information about a specified transaction, optionally with CBOR representation.

Input message:

Expand All @@ -645,6 +645,7 @@ Input message:
"command": "GET_TRANSACTION";
"params": {
"txId": string; // transaction id
"cbor":? boolean;
}
}
```
Expand Down Expand Up @@ -686,6 +687,7 @@ Payload contains [transaction data](https://docs.blockfrost.io/#tag/cardano--tra
asset_mint_or_burn_count: number;
redeemer_count: number;
valid_contract: boolean;
cbor?: string;
};
}
```
Expand Down
8 changes: 2 additions & 6 deletions src/methods/get-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@ import { prepareMessage } from '../utils/message.js';
import { fetchTransactionData } from '../utils/transaction.js';
import { MessageId } from '../types/message.js';

export default async (id: MessageId, clientId: string, txId: string): Promise<string> => {
const data = await fetchTransactionData(txId);
const message = prepareMessage({ id, clientId, data });

return message;
};
export default async (id: MessageId, clientId: string, txId: string, cbor?: boolean) =>
prepareMessage({ id, clientId, data: await fetchTransactionData(txId, cbor) });
2 changes: 1 addition & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ wss.on('connection', async (ws: Server.Ws) => {

case 'GET_TRANSACTION': {
validators.GET_TRANSACTION(params);
response = await getTransaction(id, clientId, params.txId);
response = await getTransaction(id, clientId, params.txId, params.cbor);

break;
}
Expand Down
1 change: 1 addition & 0 deletions src/types/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export type Messages = BaseMessage &
command: 'GET_TRANSACTION';
params: {
txId: string;
cbor?: boolean;
};
}
| {
Expand Down
1 change: 1 addition & 0 deletions src/utils/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const schemas: { [k in Validators]: { properties: unknown; required?: string[] }
GET_TRANSACTION: {
properties: {
txId: { type: 'string' },
cbor: { type: 'boolean' },
},
required: ['txId'],
},
Expand Down

0 comments on commit 36b7266

Please sign in to comment.