Open ChiTimesChi opened 5 months ago
To support historical FastBridge
deployments in the SDK methods getSynapseTxId
and getBridgeTxStatus
, follow these steps:
Update getSynapseTxId
method in fastBridgeRouter.ts
:
FastBridge
contract addresses.public async getSynapseTxId(txHash: string): Promise<string> {
const fastBridgeContracts = await this.getAllFastBridgeContracts();
for (const fastBridgeContract of fastBridgeContracts) {
try {
const fastBridgeLog = await getMatchingTxLog(
this.provider,
txHash,
fastBridgeContract,
this.originEvents
);
const parsedLog = fastBridgeContract.interface.parseLog(fastBridgeLog);
return parsedLog.args.transactionId;
} catch (e) {
// Continue to next contract if no matching log is found
}
}
throw new Error('Transaction ID not found');
}
Update getBridgeTxStatus
method in fastBridgeRouter.ts
:
FastBridge
contract addresses.public async getBridgeTxStatus(synapseTxId: string): Promise<boolean> {
const fastBridgeContracts = await this.getAllFastBridgeContracts();
for (const fastBridgeContract of fastBridgeContracts) {
try {
const status = await fastBridgeContract.bridgeRelays(synapseTxId);
if (status) return true;
} catch (e) {
// Continue to next contract if status is not found
}
}
return false;
}
Implement getAllFastBridgeContracts
method in fastBridgeRouter.ts
:
FastBridge
contract instances.private async getAllFastBridgeContracts(): Promise<FastBridgeContract[]> {
const addresses = [
'0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E', // Add all historical addresses here
// ... other addresses
];
return addresses.map(address => new Contract(
address,
FastBridgeRouter.fastBridgeInterface,
this.provider
) as FastBridgeContract);
}
/packages/sdk-router/src/rfq/fastBridgeRouter.ts /packages/contracts-rfq/contracts/FastBridge.sol /packages/contracts-rfq/deployments/optimism/FastBridge.json
Hi @trajan0x is this taken or stale ?
In the current implementation, only the txs done through the latest
FastBridge
contracts are trackable using the exposed SDK methods:getSynapseTxId()
getBridgeTxStatus()
This should be fixed to support all historical
FastBridge
deployments for backwards compatibility.