Skip to content

Commit

Permalink
fix: avoid /extended/v1/tx/<txid> request that must follow redirects (
Browse files Browse the repository at this point in the history
  • Loading branch information
zone117x authored Mar 27, 2023
1 parent fdf8f5e commit 54a52c4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
uses: cycjimmy/semantic-release-action@v3
id: semantic
# Only run on non-PR events or only PRs that aren't from forks
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
Expand Down
11 changes: 9 additions & 2 deletions src/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,17 @@ export async function checkTransactions(
if (!tx.blockHeight || tx.blockHeight <= 0) {
// const txInfo = await bskConfig.network.getTransactionInfo(tx.txHash)
const url = new URL(
bskConfig.network.coreApiUrl + `/extended/v1/tx/${tx.txHash}`
bskConfig.network.coreApiUrl + `/extended/v1/tx/0x${tx.txHash}`
);
const httpRequest = await fetch(url);
const txInfo = await httpRequest.json();
const reqText = await httpRequest.text();
let txInfo;
try {
txInfo = JSON.parse(reqText);
} catch (error) {
logger.error(`Error parsing JSON from ${url.toString()} ${error}, received: ${reqText}`);
throw error;
}

if (!txInfo.block_height) {
logger.info("Could not get block_height, probably unconfirmed.", {
Expand Down
2 changes: 1 addition & 1 deletion tests/src/unitTestOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export function unitTestOperations() {

txs.forEach(x => nock('https://stacks-node-api.mainnet.stacks.co')
.persist()
.get(`/extended/v1/tx/${x.txHash}`)
.get(`/extended/v1/tx/0x${x.txHash}`)
.reply(200, { block_height: x.blockheight }))

// nock('https://stacks-node-api.mainnet.stacks.co')
Expand Down
2 changes: 1 addition & 1 deletion tests/src/unitTestServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ export function testSubdomainServer() {

nock('https://stacks-node-api.mainnet.stacks.co')
.persist()
.get(`/extended/v1/tx/${expected_tx}`)
.get(`/extended/v1/tx/0x${expected_tx}`)
.reply(200, { block_height: 300 })

await s.checkZonefiles() //todo
Expand Down

0 comments on commit 54a52c4

Please sign in to comment.