Skip to content

Commit

Permalink
Remove beacon API call, superceeded by head call. Use proper version …
Browse files Browse the repository at this point in the history
…enpoints of BridgeAPI.
  • Loading branch information
luka-ethernal committed Aug 26, 2024
1 parent 01dc84b commit 7ffed76
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
15 changes: 4 additions & 11 deletions src/services/bridge-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,28 @@ export default class BridgeApi {
async getAvailLatestHeadOnEthereum(): Promise<AxiosResponse<any>> {
return await axios({
method: "get",
url: `${this.url}/avl/head`,
url: `${this.url}/v1/avl/head`,
});
}

async getEthLatestHeadOnAvail(): Promise<AxiosResponse<any>> {
return await axios({
method: "get",
url: `${this.url}/eth/head`,
});
}

async getBlockNumberBySlot(slot: number): Promise<AxiosResponse<any>> {
return await axios({
method: "get",
url: `${this.url}/beacon/slot/${slot}`,
url: `${this.url}/v1/eth/head`,
});
}

async getProofToSubmitOnEthereum(blockHash: string, transactionIndex: string): Promise<AxiosResponse<any>> {
return await axios({
method: "get",
url: `${this.url}/eth/proof/${blockHash}?index=${transactionIndex}`,
url: `${this.url}/v1/eth/proof/${blockHash}?index=${transactionIndex}`,
});
}

async getProofToSubmitOnAvail(blockHash: string, messageId: string): Promise<AxiosResponse<any>> {
return await axios({
method: "get",
url: `${this.url}/avl/proof/${blockHash}/${messageId}`,
url: `${this.url}/v1/avl/proof/${blockHash}/${messageId}`,
});
}

Expand Down
10 changes: 3 additions & 7 deletions src/services/transaction-cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,21 +266,17 @@ export default class TransactionCron {
try {
let response = await this.bridgeApi.getEthLatestHeadOnAvail();

if (response && response.data && response.data.slot) {
let block = await this.bridgeApi.getBlockNumberBySlot(
response.data.slot
);
if (block && block.data && block.data.blockNumber) {
if (response && response.data && response.data.blockNumber) {
let blockNumber = response.data.blockNumber
await prisma.ethereumsends.updateMany({
where: {
status: "BRIDGED",
sourceBlockNumber: { lte: block.data.blockNumber },
sourceBlockNumber: { lte: blockNumber },
},
data: {
status: "READY_TO_CLAIM",
},
});
}
}
} catch (error) {
logger.error(
Expand Down

0 comments on commit 7ffed76

Please sign in to comment.