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

EPIC: Refactor contract interactions #6973

Open
just-mitch opened this issue Jun 7, 2024 · 0 comments
Open

EPIC: Refactor contract interactions #6973

just-mitch opened this issue Jun 7, 2024 · 0 comments
Assignees
Labels

Comments

@just-mitch
Copy link
Contributor

just-mitch commented Jun 7, 2024

We have a mess in terms of the base API we expose to users. This is epitomized in:

  public async estimateGas(
    opts?: Omit<SendMethodOptions, 'estimateGas' | 'skipPublicSimulation'>,
  ): Promise<Pick<GasSettings, 'gasLimits' | 'teardownGasLimits'>> {
    // REFACTOR: both `this.txRequest = undefined` below are horrible, we should not be caching stuff that doesn't need to be.
    // This also hints at a weird interface for create/request/estimate/send etc.

    // Ensure we don't accidentally use a version of tx request that has estimateGas set to true, leading to an infinite loop.
    this.txRequest = undefined;
    const txRequest = await this.create({ ...opts, estimateGas: false });
    // Ensure we don't accidentally cache a version of tx request that has estimateGas forcefully set to false.
    this.txRequest = undefined;
    
    const simulationResult = await this.wallet.simulateTx(txRequest, true);
    const { totalGas: gasLimits, teardownGas: teardownGasLimits } = getGasLimits(
      simulationResult,
      (opts?.fee?.gasSettings ?? GasSettings.default()).teardownGasLimits,
    );
    return { gasLimits, teardownGasLimits };
}

We need to clean this up so developers have a much simpler interface when performing basic interactions like:

  1. creating a transaction request
  2. estimating the gas needed to perform a TX
  3. simulating a transaction request
  4. proving a transaction request
  5. sending a proven transaction to the network

Candidate design in progress is here

@just-mitch just-mitch self-assigned this Jun 7, 2024
@github-project-automation github-project-automation bot moved this to Todo in A3 Jun 7, 2024
@just-mitch just-mitch changed the title Refactor base contract interactions Refactor contract interactions Jun 13, 2024
@just-mitch just-mitch assigned nventuro and unassigned just-mitch Jul 3, 2024
@rahul-kothari rahul-kothari changed the title Refactor contract interactions EPIC: Refactor contract interactions Oct 11, 2024
@rahul-kothari rahul-kothari added this to the TestNet milestone Oct 11, 2024
@rahul-kothari rahul-kothari added the team-fairies Nico's team label Oct 11, 2024
@rahul-kothari rahul-kothari removed this from the TestNet milestone Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

3 participants