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

💡 [REQUEST] - Migrate ticker from connex #1703

Open
freemanzMrojo opened this issue Jan 15, 2025 · 2 comments
Open

💡 [REQUEST] - Migrate ticker from connex #1703

freemanzMrojo opened this issue Jan 15, 2025 · 2 comments

Comments

@freemanzMrojo
Copy link
Member

freemanzMrojo commented Jan 15, 2025

Summary

There is a very useful feature in connex to wait for the blocks to be processed instead of using a timer, called ticker.

Basic Example

This would be a sample usage:

public async deployAndGetTxReceipt(
    bytecode: string,
    constructorEncoded?: string,
  ) {
    const clause = {
      value: '0',
      data: bytecode + (constructorEncoded ?? ''),
      to: null,
    };
    const gas = await this.connex.getGasEstimate([clause]);
    const signedTx = this.connex.signTransaction([clause], gas);
    const contract = await signedTx.request();

    let txReceipt: Connex.Thor.Transaction.Receipt | null = null;
    //Timeout after 3 blocks
    for (let i = 0; i < 3; i++) {
      txReceipt = await this.connex.thor
        .transaction(contract.txid)
        .getReceipt();
      if (txReceipt) {
        break;
      }
      await this.connex.thor.ticker().next();
    }

    return txReceipt;
  }
@victhorbi
Copy link
Collaborator

Hey @freemanzMrojo , are there other use-cases other than waiting the one in the example that can only be handled with the ticker?
How urgent this is?

@freemanzMrojo
Copy link
Member Author

hi @victhorbi , it is not urgent, this feature just came up in a conversation with @claytonneal last week, so I logged it 👍

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

No branches or pull requests

2 participants