I’m working on a project where user has to send token_A
to a canister and then canister mints token_B
to the user.
This is oversimplified piece of the code:
private func deposit(loanUUID : T.UUID) : async Result.Result<T.UUID, T.TransferError> {
let transferResult = await tokenTransfer({...});
// update state based on outcome of transfer operation
let mintResult = await tokenTransfer({...});
// update state based on outcome of mint operation
};
And this is the state I’m holding in case some operation fails:
public type State = {
depositTransfer: Bool;
depositMint : Bool;
withdrawTransfer : Bool;
withdrawBurn : Bool;
inProgress : Bool;
};
So, my question is simple - what is the best approach for retry mechanism in case some of the inter canister call fail (for example: transfer is successful but mint fails so user is stuck with half done deposit flow)?
Should I use period task that automatically retries the deposit procedure or provide the user with retry method?