May
22
14 hours ago
started
started time in 1 hour ago
Activity icon
issue

JayWelsh issue TrueFiEng/useDApp

JayWelsh
JayWelsh

How to handle errors in useContractFunction?

There seems to be no way to extract an error message while using useContractFunction, it seems that one can only refer to state to check if it is equal to "Exception", but in most cases, I'd want to handle the error thrown by the smart contract in order to show it to the user. At the moment, the error does get logged in my console but I have no idea how I can extract it or use it in order to show a specific error message to the user.

Example of what I see logged:

Screenshot 2022-05-22 at 14 47 11

Is there any way I can handle this error or access the error.message within my code whilst using useContractFunction?

Activity icon
issue

JayWelsh issue comment TrueFiEng/useDApp

JayWelsh
JayWelsh

send should return ethers transaction instead of void

const { send } = useContractFunction('erc20', "transfer");

currently send promise resolves to the void, but I think it would be more useful on having it on resolving to the ethers transaction response (like state.transaction). So it could be used instantly after tx is broadcasted. Would be able to use .transaction.wait() for example so I could trigger some action after tx is mined

JayWelsh
JayWelsh

I think you can use this to check if the tx is successful:

const { send, state } = useContractFunction('erc20', "transfer");

Then you can refer to the value of state.status to check if it is equal to 'Success'

But I do agree that it might be better for send to return something, or at least there should be a way to extract an error if an error is thrown during send.

Activity icon
issue

JayWelsh issue comment TrueFiEng/useDApp

JayWelsh
JayWelsh

Return trasnaction response/error on awaiting

Hello

Example:

I have a function, that should sequentially execute some transactions.

const { send: buyMarketItem, state: buyMarketItemState } = useContractFunction(marketContract, "buyMarketItem"); const { send: applyResult, state: applyResultState } = useContractFunction(marketContract, "applyResult");

My button handler looks like:

const handleClick = () => { await buyMarketItem(); await applyResult(); };

I would like to stop executing second transaction if the first one is failed by throwing error or returning some error object/value; How could i achieve this? Actually i can give you a PR to fix this issue in my case.

JayWelsh
JayWelsh

You can probably use buyMarketItemState?.status to check if it is equal to 'Success'

started
started time in 10 hours ago
May
21
1 day ago
Activity icon
issue

Entity54 issue comment TrueFiEng/useDApp

Entity54
Entity54

Failed to parse source map from ... Error: ENOENT: no such file or directory, open ...

The issue #521 still reappears after the 0.11 update, but this time without >100 warnings.

Compiled with warnings.

Failed to parse source map from '/Users/mac/Desktop/react-django-nft-marketplace/react_django_nft_marketplace/frontend/frontend/node_modules/@metamask/detect-provider/src/index.ts' file: Error: ENOENT: no such file or directory, open '/Users/mac/Desktop/react-django-nft-marketplace/react_django_nft_marketplace/frontend/frontend/node_modules/@metamask/detect-provider/src/index.ts'

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

assets by path static/js/*.js 2.92 MiB
  asset static/js/bundle.js 2.92 MiB [emitted] (name: main) 1 related asset
  asset static/js/node_modules_web-vitals_dist_web-vitals_js.chunk.js 6.92 KiB [emitted] 1 related asset
asset index.html 1.67 KiB [emitted]
asset asset-manifest.json 458 bytes [emitted]
cached modules 4.26 MiB (javascript) 31.5 KiB (runtime) [cached] 1227 modules

WARNING in ./node_modules/@metamask/detect-provider/dist/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/mac/Desktop/react-django-nft-marketplace/react_django_nft_marketplace/frontend/frontend/node_modules/@metamask/detect-provider/src/index.ts' file: Error: ENOENT: no such file or directory, open '/Users/mac/Desktop/react-django-nft-marketplace/react_django_nft_marketplace/frontend/frontend/node_modules/@metamask/detect-provider/src/index.ts'
 @ ./node_modules/@usedapp/core/dist/esm/src/helpers/injectedProvider.js 2:0-63 4:33-55
 @ ./node_modules/@usedapp/core/dist/esm/src/providers/injectedNetwork/provider.js 4:0-69 19:4-23
 @ ./node_modules/@usedapp/core/dist/esm/src/providers/injectedNetwork/index.js 2:0-27 2:0-27
 @ ./node_modules/@usedapp/core/dist/esm/src/providers/index.js 6:0-34 6:0-34
 @ ./node_modules/@usedapp/core/dist/esm/src/index.js 2:0-28 2:0-28
 @ ./src/App.tsx 6:0-54 9:30-42 11:24-37 11:39-54
 @ ./src/index.tsx 7:0-24 11:33-36

1 warning has detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

webpack 5.68.0 compiled with 1 warning in 2753 ms
Files successfully emitted, waiting for typecheck results...
Issues checking in progress...
No issues found.
^C
(env) mbp:src mac$ 
Entity54
Entity54

Hi All, We have the same issue with our create-react-app. When running in localhost we get the following "Failed to parse source map from node_modules/@metamask/detect-provider/src/index.ts' file: Error: ENOENT: no such file or directory ..." but the Dapp runs perfectly fine

However when trying to deploy to Vercel (or similar) it becomes impossible because of this message

started
started time in 1 day ago
Activity icon
commit_comment

TrueFiEng/useDApp

May
20
2 days ago
Activity icon
issue

noodesonmars issue comment TrueFiEng/useDApp

noodesonmars
noodesonmars

export 'dnsEncode' (reexported as 'dnsEncode') was not found in '@ethersproject/hash' (possible exports: _TypedDataEncoder, hashMessage, id, isValidName, messagePrefix, namehash)

Using "@usedapp/core": "^1.0.2"

export 'dnsEncode' (reexported as 'dnsEncode') was not found in '@ethersproject/hash' (possible exports: _TypedDataEncoder, hashMessage, id, isValidName, messagePrefix, namehash)

Does not appear in console when running yarn build, but appears in Netlify during production build.

I added this from the troubleshooting page on the website but it changed nothing:

  "resolutions": {
    "@ethersproject/abi": "5.2.0",
    "@ethersproject/contracts": "^5.6.0"
  },
noodesonmars
noodesonmars

Downgraded to "@usedapp/core": "^0.11.0" and it built on Netlify and it worked

started
started time in 1 day ago
Previous