Skip to content

Commit

Permalink
upgrade element bridge to use falafel's new REST API (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
spypsy committed Nov 21, 2022
1 parent c2b4904 commit e6cf987
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aztec/bridge-clients",
"version": "0.1.73",
"version": "0.1.74",
"description": "This repo contains the solidity files and typescript helper class for all of the Aztec Connect Bridge Contracts",
"repository": "git@github.com:AztecProtocol/aztec-connect-bridges.git",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/client/element/element-bridge-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ describe("element bridge data", () => {
EthAddress.ZERO,
EthAddress.ZERO,
EthAddress.ZERO,
"https://api.aztec.network/aztec-connect-prod/falafel/graphql",
"https://api.aztec.network/aztec-connect-prod/falafel",
); // can pass in dummy values here as the above factories do all of the work
};

Expand Down
23 changes: 6 additions & 17 deletions src/client/element/element-bridge-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,21 @@ export class ElementBridgeData implements BridgeDataFieldGetters {
private elementBridgeContract: ElementBridge,
private balancerContract: IVault,
private rollupContract: RollupProcessor,
private falafelGraphQlEndpoint: string,
private falafelEndpoint: string,
) {}

static create(
provider: EthereumProvider,
elementBridgeAddress: EthAddress,
balancerAddress: EthAddress,
rollupContractAddress: EthAddress,
falafelGraphQlEndpoint: string,
falafelEndpoint: string,
) {
const ethersProvider = createWeb3Provider(provider);
const elementBridgeContract = ElementBridge__factory.connect(elementBridgeAddress.toString(), ethersProvider);
const rollupContract = RollupProcessor__factory.connect(rollupContractAddress.toString(), ethersProvider);
const vaultContract = IVault__factory.connect(balancerAddress.toString(), ethersProvider);
return new ElementBridgeData(elementBridgeContract, vaultContract, rollupContract, falafelGraphQlEndpoint);
return new ElementBridgeData(elementBridgeContract, vaultContract, rollupContract, falafelEndpoint);
}

private async storeEventBlocks(events: AsyncDefiBridgeProcessedEvent[]) {
Expand Down Expand Up @@ -117,25 +117,14 @@ export class ElementBridgeData implements BridgeDataFieldGetters {

private async getBlockNumber(interactionNonce: number) {
const id = Math.floor(interactionNonce / 32);
const query = `query Block($id: Int!) {
block: rollup(id: $id) {
ethTxHash
}
}`;

const response = await fetch(this.falafelGraphQlEndpoint, {
const response = await fetch(`${this.falafelEndpoint}/rollup/${id}`, {
headers: { "Content-Type": "application/json" },
method: "POST",
body: JSON.stringify({
query,
operationName: "Block",
variables: { id },
}),
method: "GET",
});

const data = await response.json();
const txhash = `0x${data["data"]["block"]["ethTxHash"]}`;
const tx = await this.elementBridgeContract.provider.getTransactionReceipt(txhash);
const tx = await this.elementBridgeContract.provider.getTransactionReceipt(data["ethTxHash"]);
return tx.blockNumber;
}

Expand Down

0 comments on commit e6cf987

Please sign in to comment.