When I use payable method, the page redirects to the wallet to approve the amount, but after the redirection, it returns to the old page, and the code below after the redirection is not run.
Here is the rust contract function:
#[payable]
pub fn add_liquidity(&mut self, tokens: u128, account_id: AccountId) -> u128 {
let amount = env::attached_deposit();
}
Here, the reactjs code:
onSubmit={async (values, actions) => {
try {
const data = await nearvar.contract.add_liquidity({"tokens": values.buy.toString(), "account_id": "amiyarust.testnet"}, 95000000000000, 500)
// Page redirects here. Code below is not run.
actions.setSubmitting(false)
history.push(`/hello`)
} catch (e) {
console.error(e)
}
I want to run history.push(`/hello`) after redirection.
But it refreshes the page, and the form is rendered again.
How to do solve it?