Skip to content

Commit

Permalink
Error handling for comunication with the blockchain (#138)
Browse files Browse the repository at this point in the history

---------

Co-authored-by: Filip Lelek <[email protected]>
  • Loading branch information
Filip-L and filip-neti authored Sep 27, 2024
1 parent 873896c commit 495f960
Show file tree
Hide file tree
Showing 8 changed files with 433 additions and 5 deletions.
321 changes: 321 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"encoding": "^0.1.13",
"eslint-config-next": "^12.3.4",
"filecoin-verifier-tools": "^2.3.0",
"filecoin-verifier-tools-temporary": "^2.3.0",
"fuse.js": "^6.6.2",
"lucide-react": "^0.260.0",
"next": "13.5.6",
Expand Down
12 changes: 11 additions & 1 deletion src/hooks/useApplicationActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
useQueryClient,
type UseMutationResult,
} from 'react-query'
import { getStateWaitMsg } from '@/lib/glifApi'

interface ApplicationActions {
application: Application
Expand Down Expand Up @@ -444,7 +445,16 @@ const useApplicationActions = (
'Error sending proposal. Please try again or contact support.',
)
}

const response = await getStateWaitMsg(messageCID)
if (
typeof response.data === 'object' &&
response.data.ReturnDec.Applied &&
response.data.ReturnDec.Code !== 0
) {
throw new Error(
`Error sending transaction. Please try again or contact support. Error code: ${response.data.ReturnDec.Code}`,
)
}
return await postApplicationProposal(
initialApplication.ID,
requestId,
Expand Down
1 change: 0 additions & 1 deletion src/hooks/useWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ const useWallet = (): WalletState => {
contractAddress,
calldata,
activeAccountIndex,
wallet,
)
},
[wallet, multisigAddress, activeAccountIndex],
Expand Down
Loading

0 comments on commit 495f960

Please sign in to comment.