Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK: track older FastBridge transactions #2332

Open
ChiTimesChi opened this issue Mar 21, 2024 · 2 comments
Open

SDK: track older FastBridge transactions #2332

ChiTimesChi opened this issue Mar 21, 2024 · 2 comments

Comments

@ChiTimesChi
Copy link
Collaborator

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.

@ChiTimesChi ChiTimesChi changed the title SDK: track older FastBridge tramsactions SDK: track older FastBridge transactions Mar 21, 2024
@trajan0x trajan0x added the small label Jun 24, 2024
@trajan0x trajan0x reopened this Jun 24, 2024
@trajan0x trajan0x removed the small label Jun 24, 2024
Copy link

greptile-apps bot commented Jun 24, 2024

To support historical FastBridge deployments in the SDK methods getSynapseTxId and getBridgeTxStatus, follow these steps:

  1. Update getSynapseTxId method in fastBridgeRouter.ts:

    • Modify the method to iterate through all historical FastBridge contract addresses.
    • Example:
    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');
    }
  2. Update getBridgeTxStatus method in fastBridgeRouter.ts:

    • Modify the method to check the status across all historical FastBridge contract addresses.
    • Example:
    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;
    }
  3. Implement getAllFastBridgeContracts method in fastBridgeRouter.ts:

    • This method should return an array of all FastBridge contract instances.
    • Example:
    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);
    }

References

/packages/sdk-router/src/rfq/fastBridgeRouter.ts
/packages/contracts-rfq/contracts/FastBridge.sol
/packages/contracts-rfq/deployments/optimism/FastBridge.json

Ask Greptile

@OladeleSeyi
Copy link

Hi @trajan0x is this taken or stale ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants