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

Add a getGasConfig helper on the Provider class #1260

Closed
Dhaiwat10 opened this issue Sep 15, 2023 · 0 comments · Fixed by #1181
Closed

Add a getGasConfig helper on the Provider class #1260

Dhaiwat10 opened this issue Sep 15, 2023 · 0 comments · Fixed by #1181
Assignees
Labels
feat Issue is a feature

Comments

@Dhaiwat10
Copy link
Member

Follow-up from #1181 and this comment:

Possible implementation:

getGasConfig() {
  // get cached info
  const chain = this.getChain();
  const nodeInfo = this.getNodeInfo();

  const { minGasPrice } = nodeInfo;
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte } = chain;

  // return relevant gas info
  return {
    minGasPrice, maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte
  }
}

Possible usage:

const provider = await Provider.create(url);
const gasConfig = provider.getGasConfig();

// now use correct config to create things with correct default gasConfig
const scriptRequest = new ScriptTransactionRequest({ gasPrice: gasConfig.minGasPrice, gasLimit: maxGasPerTx });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Issue is a feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants