Skip to content

Commit

Permalink
fix(PoEModal): Aborting requests on error and showing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesGuesnon committed Nov 21, 2023
1 parent 0a3c22a commit 3b5e65f
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions components/PoeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ const PoeModal = () => {
const transactionCb = async (message: OperationRequestOutput) => {
setCurrentMetadata([message.id, message.appMetadata]);

if (message.operationDetails.length === 0) {
await state.p2pClient?.abortRequest(message.id);
setTransactionError("Operations were empty");
return;
}

setTransfers(
(
await Promise.all(
Expand All @@ -111,7 +117,7 @@ const PoeModal = () => {
]
);

const value = contract.methods[
const value = contract.methodsObject[
detail.parameters.entrypoint
](
methodSchema.Execute(detail.parameters.value)
Expand Down Expand Up @@ -148,8 +154,12 @@ const PoeModal = () => {
},
};
} catch (e) {
console.log("Error while converting contract call", e);
setTransactionError(
"Failed to convert the contract call to TzSafe format"
);
console.log("Error while converting contract call: ", e);

state.p2pClient?.abortRequest(message.id);
return undefined;
}
} else
Expand Down Expand Up @@ -191,9 +201,9 @@ const PoeModal = () => {
const signPayloadCb = async (message: SignPayloadRequest) => {
console.log("Sign:", message);
try {
//@ts-expect-error For a reason I don't know I can't access client like in taquito documentation
// See: https://tezostaquito.io/docs/signing/#generating-a-signature-with-beacon-sdk
const signed =
//@ts-expect-error For a reason I don't know I can't access client like in taquito documentation
// See: https://tezostaquito.io/docs/signing/#generating-a-signature-with-beacon-sdk
await state.connection.wallet.walletProvider.client.requestSignPayload(
{
signingType: message.signingType,
Expand Down

0 comments on commit 3b5e65f

Please sign in to comment.