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

feat: outside execution: add estimate fees and simulate #1327

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

PhilippeR26
Copy link
Collaborator

Motivation and Resolution

Solves issue #1263 .
User are requesting to add functions for executors of SNIP-9 outside executions, allowing them to estimate the fees they will have to pay and to simulate a SNIP-9 transaction.

Usage related changes

Estimate fees for an outside execution:

On executor side, if you want to estimate how many fees you will pay:

const outsideExecutionCall: Call[] =
  outsideExecution.buildExecuteFromOutsideCall(outsideTransaction1);
const estimateFee = await executorAccount.estimateFee(outsideExecutionCall);

Simulate an outside execution:

On executor side, if you want to simulate the transaction:

const outsideExecutionCall: Call[] =
  outsideExecution.buildExecuteFromOutsideCall(outsideTransaction1);
const invocations: Invocations = [
  {
    type: TransactionType.INVOKE,
    payload: outsideExecutionCall,
  },
];
const responseSimulate = await executorAccount.simulateTransaction(invocations);

Development related changes

  • a function outsideExecution.buildExecuteFromOutsideCall() has been added to create a Call. Then this Call can be used in the standard functions for estimateFee and simulate.
  • this new function allows some refactors in code & tests.

Checklist:

  • Performed a self-review of the code
  • Rebased to the last commit of the target branch (or merged it into my branch)
  • Linked the issues which this PR resolves
  • Documented the changes in code (API docs will be generated automatically)
  • Updated the tests
  • All tests are passing

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

Successfully merging this pull request may close these issues.

1 participant