Skip to content

Commit

Permalink
Merge pull request #587 from cardano-foundation/feat/add-support-for-…
Browse files Browse the repository at this point in the history
…blockfrost-submit-api

feat(vote-commitment): added blockfrost auth header for submit api
  • Loading branch information
rcmorano authored Sep 22, 2024
2 parents 4af759d + 624ed2f commit f26badf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ public BlockchainTransactionSubmissionService backendServiceTransactionSubmissio
@Bean
@Profile( value = { "prod", "dev--preprod" } )
public BlockchainTransactionSubmissionService cardanoSummitTransactionSubmissionService(HttpClient httpClient,
@Value("${cardano.tx.submit.api.url}") String cardanoSubmitApiUrl) {
return new CardanoSubmitApiBlockchainTransactionSubmissionService(cardanoSubmitApiUrl, httpClient);
@Value("${cardano.tx.submit.api.url}") String cardanoSubmitApiUrl,
@Value("${blockfrost.api.key}") String blockfrostApiKey) {
return new CardanoSubmitApiBlockchainTransactionSubmissionService(cardanoSubmitApiUrl, httpClient, blockfrostApiKey);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ public class CardanoSubmitApiBlockchainTransactionSubmissionService implements B

private final HttpClient httpClient;

private final String blockfrostApiKey;

@Override
@SneakyThrows
public String submitTransaction(byte[] txData) {
var txTransactionSubmitPostRequest = HttpRequest.newBuilder()
.uri(URI.create(cardanoSubmitApiUrl))
.POST(HttpRequest.BodyPublishers.ofByteArray(txData))
.header("Content-Type", "application/cbor")
.header("project_id", blockfrostApiKey)
.build();

var r = httpClient.send(txTransactionSubmitPostRequest, HttpResponse.BodyHandlers.ofString());
Expand Down

0 comments on commit f26badf

Please sign in to comment.