Skip to content

Commit

Permalink
Merge pull request #299 from blockfrost/feat/txs-cbor
Browse files Browse the repository at this point in the history
feat: /txs/:hash/cbor
  • Loading branch information
vladimirvolek authored Oct 3, 2024
2 parents e8a15d0 + 3783f5c commit 6cc02f4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- added the `gotOptions` property to the `BlockFrostAPI` class. This property can be passed during the initialization of the `BlockFrostAPI` object. For more details, refer to the [Got Options documentation](https://github.com/sindresorhus/got/blob/main/documentation/2-options.md).
- `txsRequiredSigners` for retrieving required signers (extra transaction witnesses)
- `networkEras` method for querying [blockchain eras](https://docs.blockfrost.io/#tag/Cardano-Network/paths/~1network~1eras/get)
- `txsCbor` for retrieving transaction CBOR

## [5.5.0] - 2023-12-20

Expand Down
2 changes: 2 additions & 0 deletions src/BlockFrostAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ import {
txsMetadata,
txsRedeemers,
txsRequiredSigners,
txsCbor,
txSubmit,
} from './endpoints/api/txs';
import {
Expand Down Expand Up @@ -331,6 +332,7 @@ class BlockFrostAPI {
txsMetadata = txsMetadata;
txsRedeemers = txsRedeemers;
txsRequiredSigners = txsRequiredSigners;
txsCbor = txsCbor;
txSubmit = txSubmit;

network = network;
Expand Down
22 changes: 22 additions & 0 deletions src/endpoints/api/txs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,28 @@ export async function txsRequiredSigners(
}
}

/**
* Obtains Obtain the CBOR serialized transaction.
* @see {@link https://docs.blockfrost.io/#tag/Cardano-Transactions/paths/~1txs~1%7Bhash%7D~cbor/get | API docs for Transaction CBOR}
*
* @param hash - Transaction hash
* @returns Transaction CBOR
*
*/
export async function txsCbor(
this: BlockFrostAPI,
hash: string,
): Promise<components['schemas']['tx_content_cbor']> {
try {
const res = await this.instance<components['schemas']['tx_content_cbor']>(
`txs/${hash}/cbor`,
);
return res.body;
} catch (error) {
throw handleError(error);
}
}

/**
* Submits a transaction to the network.
* @see {@link https://docs.blockfrost.io/#tag/Cardano-Transactions/paths/~1tx~1submit/post | API docs for Transaction submit}
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,17 @@ export default [
endpointMock: [],
response: [],
},
{
command: (SDK: BlockFrostAPI) =>
SDK.txsCbor(
'e641005803337a553a03cf3c11a1819491a629bd7d0a3c39e4866a01b5dac36d',
),
path: mainnetUrl(
'/txs/e641005803337a553a03cf3c11a1819491a629bd7d0a3c39e4866a01b5dac36d/cbor',
),
endpointMock: { cbor: 'deadbeef' },
response: { cbor: 'deadbeef' },
},
{
command: (SDK: BlockFrostAPI) => SDK.scripts(),
path: mainnetUrl('/scripts'),
Expand Down

0 comments on commit 6cc02f4

Please sign in to comment.