Skip to content

Sync Calls in an Async World #43

Answered by gagdiez
gagdiez asked this question in Q&A
May 19, 2022 · 1 comments · 5 replies
Discussion options

You must be logged in to vote

@ailisp answered: Yes
Your contract will like this:

@call
your_method() {
  let ret1 = near.jsvmCall('DEX-1', 'method1', args1)
// ^ will throw errors if failed, lead to tx failed, and nothing will be saved to state
  if (ret1 != 'blablabla') {
    throw new Error('call in DEX-1 not   giving expect result, abort')
// ^ also lead to tx failed, and nothing will be saved to state
  }
  let ret2 = near.jsvmCall('DEX-2', 'method2', args2)
  // do something of your logic
}

@ailisp I have a follow up question: If near.jsvmCall('DEX-2', 'method2', args2) fails, then the first one is rolled back and nothing gets saved to state, right?

Replies: 1 comment 5 replies

Comment options

gagdiez
May 19, 2022
Collaborator Author

You must be logged in to vote
5 replies
@ailisp
Comment options

@gagdiez
Comment options

gagdiez May 20, 2022
Collaborator Author

@think-in-universe
Comment options

@ailisp
Comment options

@ailisp
Comment options

Answer selected by volovyks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants