From 52ccfe69b015602af6f3636b61fef44d8e8727a6 Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Wed, 11 Oct 2023 12:03:06 +0300 Subject: [PATCH 1/3] error handling updates --- src/@utils/accessDetailsAndPricing.ts | 2 +- src/@utils/compute.ts | 4 ++-- src/@utils/nft.ts | 4 ++-- src/@utils/order.ts | 2 +- src/@utils/provider.ts | 23 ++++++++++--------- .../FormInput/InputElement/Provider/index.tsx | 2 +- .../Asset/AssetActions/Compute/index.tsx | 2 +- src/components/Asset/AssetActions/index.tsx | 1 + .../Profile/History/ComputeJobs/Results.tsx | 2 +- src/components/Publish/index.tsx | 2 +- 10 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/@utils/accessDetailsAndPricing.ts b/src/@utils/accessDetailsAndPricing.ts index 3e6e2eedd..ad9294041 100644 --- a/src/@utils/accessDetailsAndPricing.ts +++ b/src/@utils/accessDetailsAndPricing.ts @@ -193,7 +193,7 @@ export async function getOrderPriceAndFees( customProviderUrl || asset?.services[0].serviceEndpoint )) } catch (error) { - const message = getErrorMessage(JSON.parse(error.message)) + const message = getErrorMessage(error.message) LoggerInstance.error('[Initialize Provider] Error:', message) toast.error(message) } diff --git a/src/@utils/compute.ts b/src/@utils/compute.ts index d6ddfaa16..eb31cdf91 100644 --- a/src/@utils/compute.ts +++ b/src/@utils/compute.ts @@ -148,7 +148,7 @@ export async function getComputeEnviroment( if (!computeEnvs[asset.chainId][0]) return null return computeEnvs[asset.chainId][0] } catch (e) { - const message = getErrorMessage(JSON.parse(e.message)) + const message = getErrorMessage(e.message) LoggerInstance.error( '[Compute to Data] Fetch compute environment:', message @@ -261,7 +261,7 @@ async function getJobs( }) } } catch (err) { - const message = getErrorMessage(JSON.parse(err.message)) + const message = getErrorMessage(err.message) LoggerInstance.error('[Compute to Data] Error:', message) toast.error(message) } diff --git a/src/@utils/nft.ts b/src/@utils/nft.ts index 4b89a632b..84e3eb455 100644 --- a/src/@utils/nft.ts +++ b/src/@utils/nft.ts @@ -113,7 +113,7 @@ export async function setNftMetadata( signal ) } catch (err) { - const message = getErrorMessage(JSON.parse(err.message)) + const message = getErrorMessage(err.message) LoggerInstance.error('[Encrypt Data] Error:', message) toast.error(message) } @@ -155,7 +155,7 @@ export async function setNFTMetadataAndTokenURI( signal ) } catch (err) { - const message = getErrorMessage(JSON.parse(err.message)) + const message = getErrorMessage(err.message) LoggerInstance.error('[Encrypt Data] Error:', message) toast.error(message) } diff --git a/src/@utils/order.ts b/src/@utils/order.ts index 8a8cdcc4b..08cd1d781 100644 --- a/src/@utils/order.ts +++ b/src/@utils/order.ts @@ -40,7 +40,7 @@ async function initializeProvider( ) return provider } catch (error) { - const message = getErrorMessage(JSON.parse(error.message)) + const message = getErrorMessage(error.message) LoggerInstance.log('[Initialize Provider] Error:', message) toast.error(message) } diff --git a/src/@utils/provider.ts b/src/@utils/provider.ts index c16cc85a5..f96212ae6 100644 --- a/src/@utils/provider.ts +++ b/src/@utils/provider.ts @@ -57,7 +57,7 @@ export async function initializeProviderForCompute( accountId ) } catch (error) { - const message = getErrorMessage(JSON.parse(error.message)) + const message = getErrorMessage(error.message) LoggerInstance.error('[Initialize Provider] Error:', message) toast.error(message) return null @@ -79,7 +79,7 @@ export async function getEncryptedFiles( ) return response } catch (error) { - const message = getErrorMessage(JSON.parse(error.message)) + const message = getErrorMessage(error.message) LoggerInstance.error('[Provider Encrypt] Error:', message) toast.error(message) } @@ -100,9 +100,10 @@ export async function getFileDidInfo( ) return response } catch (error) { - const message = getErrorMessage(JSON.parse(error.message)) + const message = getErrorMessage(error.message) LoggerInstance.error('[Initialize check file did] Error:', message) - toast.error(message) + toast.error(`[Initialize check file did] Error: ${message}`) + throw new Error(`[Initialize check file did] Error: ${message}`) } } @@ -137,7 +138,7 @@ export async function getFileInfo( customProviderUrl || providerUrl ) } catch (error) { - const message = getErrorMessage(JSON.parse(error.message)) + const message = getErrorMessage(error.message) LoggerInstance.error('[Provider Get File info] Error:', message) toast.error(message) } @@ -154,7 +155,7 @@ export async function getFileInfo( customProviderUrl || providerUrl ) } catch (error) { - const message = getErrorMessage(JSON.parse(error.message)) + const message = getErrorMessage(error.message) LoggerInstance.error('[Provider Get File info] Error:', message) toast.error(message) } @@ -173,7 +174,7 @@ export async function getFileInfo( customProviderUrl || providerUrl ) } catch (error) { - const message = getErrorMessage(JSON.parse(error.message)) + const message = getErrorMessage(error.message) LoggerInstance.error('[Provider Get File info] Error:', message) toast.error(message) } @@ -193,7 +194,7 @@ export async function getFileInfo( customProviderUrl || providerUrl ) } catch (error) { - const message = getErrorMessage(JSON.parse(error.message)) + const message = getErrorMessage(error.message) LoggerInstance.error('[Provider Get File info] Error:', message) toast.error(message) } @@ -213,7 +214,7 @@ export async function getFileInfo( customProviderUrl || providerUrl ) } catch (error) { - const message = getErrorMessage(JSON.parse(error.message)) + const message = getErrorMessage(error.message) LoggerInstance.error('[Provider Get File info] Error:', message) toast.error(message) } @@ -242,7 +243,7 @@ export async function downloadFile( userCustomParameters ) } catch (error) { - const message = getErrorMessage(JSON.parse(error.message)) + const message = getErrorMessage(error.message) LoggerInstance.error('[Provider Get download url] Error:', message) toast.error(message) } @@ -256,7 +257,7 @@ export async function checkValidProvider( const response = await ProviderInstance.isValidProvider(providerUrl) return response } catch (error) { - const message = getErrorMessage(JSON.parse(error.message)) + const message = getErrorMessage(error.message) LoggerInstance.error('[Provider Check] Error:', message) toast.error(message) } diff --git a/src/components/@shared/FormInput/InputElement/Provider/index.tsx b/src/components/@shared/FormInput/InputElement/Provider/index.tsx index d36808753..78c844c57 100644 --- a/src/components/@shared/FormInput/InputElement/Provider/index.tsx +++ b/src/components/@shared/FormInput/InputElement/Provider/index.tsx @@ -76,7 +76,7 @@ export default function CustomProvider(props: InputProps): ReactElement { // if all good, add provider to formik state helpers.setValue({ url: field.value.url, valid: isValid, custom: true }) } catch (error) { - const message = getErrorMessage(JSON.parse(error.message)) + const message = getErrorMessage(error.message) setFieldError(`${field.name}.url`, message) LoggerInstance.error('[Custom Provider]:', message) } finally { diff --git a/src/components/Asset/AssetActions/Compute/index.tsx b/src/components/Asset/AssetActions/Compute/index.tsx index e4731583e..8549ed91d 100644 --- a/src/components/Asset/AssetActions/Compute/index.tsx +++ b/src/components/Asset/AssetActions/Compute/index.tsx @@ -439,7 +439,7 @@ export default function Compute({ setRefetchJobs(!refetchJobs) initPriceAndFees() } catch (error) { - const message = getErrorMessage(JSON.parse(error.message)) + const message = getErrorMessage(error.message) LoggerInstance.error('[Compute] Error:', message) setError(message) setRetry(true) diff --git a/src/components/Asset/AssetActions/index.tsx b/src/components/Asset/AssetActions/index.tsx index 9b02acb1d..6087c3a64 100644 --- a/src/components/Asset/AssetActions/index.tsx +++ b/src/components/Asset/AssetActions/index.tsx @@ -95,6 +95,7 @@ export default function AssetActions({ setFileIsLoading(false) } catch (error) { + setFileIsLoading(false) LoggerInstance.error(error.message) } } diff --git a/src/components/Profile/History/ComputeJobs/Results.tsx b/src/components/Profile/History/ComputeJobs/Results.tsx index a4a564bae..750c0e871 100644 --- a/src/components/Profile/History/ComputeJobs/Results.tsx +++ b/src/components/Profile/History/ComputeJobs/Results.tsx @@ -72,7 +72,7 @@ export default function Results({ ) await downloadFileBrowser(jobResult) } catch (error) { - const message = getErrorMessage(JSON.parse(error.message)) + const message = getErrorMessage(error.message) LoggerInstance.error('[Provider Get c2d results url] Error:', message) toast.error(message) } diff --git a/src/components/Publish/index.tsx b/src/components/Publish/index.tsx index effde8695..674b55274 100644 --- a/src/components/Publish/index.tsx +++ b/src/components/Publish/index.tsx @@ -149,7 +149,7 @@ export default function PublishPage({ newAbortController() ) } catch (error) { - const message = getErrorMessage(JSON.parse(error.message)) + const message = getErrorMessage(error.message) LoggerInstance.error('[Provider Encrypt] Error:', message) } From 6bf2e36467f6a491251f9a72598889df28f0af4c Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Wed, 11 Oct 2023 12:15:54 +0300 Subject: [PATCH 2/3] use ocean.js pre release 3.1.3-next.1 --- package-lock.json | 101 +++++++++++++++++++++++++++++++++++++++++----- package.json | 2 +- 2 files changed, 93 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0afd8546a..69bf90cd4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "@coingecko/cryptoformat": "^0.5.4", "@loadable/component": "^5.15.2", "@oceanprotocol/art": "^3.2.0", - "@oceanprotocol/lib": "^3.0.4", + "@oceanprotocol/lib": "^3.1.3-next.1", "@oceanprotocol/typographies": "^0.1.0", "@oceanprotocol/use-dark-mode": "^2.4.3", "@orbisclub/orbis-sdk": "^0.4.40", @@ -6077,12 +6077,12 @@ "integrity": "sha512-PJih7C6LHaWHHj1qgxZsSkEqKphhJrL3G7WuMOxl4N1daDrF6sooDDU+9dZkcHSVPc7cMjkFqLc5fP58NSAobw==" }, "node_modules/@oceanprotocol/lib": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-3.0.4.tgz", - "integrity": "sha512-HG187KtiT6LV8N5RbupcdKMR+6qsYLEmf43H5gnrIjDflachSayc1R629M7FPC29M8RMgqhfCwKLJJN64U+pmw==", + "version": "3.1.3-next.1", + "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-3.1.3-next.1.tgz", + "integrity": "sha512-x8Jau6kJEeg7GY7lGk1iFepDwPFbJ+hfsokg+SZInVBaqbAry17ykmdWK6w3bBJsXSBi+QnSyfu/EAyMb3Z22w==", "dependencies": { "@oceanprotocol/contracts": "^1.1.14", - "cross-fetch": "^3.1.5", + "cross-fetch": "^4.0.0", "crypto-js": "^4.1.1", "decimal.js": "^10.4.1", "ethers": "^5.7.2" @@ -6091,6 +6091,52 @@ "web3": "^1.8.0" } }, + "node_modules/@oceanprotocol/lib/node_modules/cross-fetch": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz", + "integrity": "sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==", + "dependencies": { + "node-fetch": "^2.6.12" + } + }, + "node_modules/@oceanprotocol/lib/node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/@oceanprotocol/lib/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/@oceanprotocol/lib/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/@oceanprotocol/lib/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/@oceanprotocol/typographies": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/@oceanprotocol/typographies/-/typographies-0.1.0.tgz", @@ -58441,15 +58487,52 @@ "integrity": "sha512-PJih7C6LHaWHHj1qgxZsSkEqKphhJrL3G7WuMOxl4N1daDrF6sooDDU+9dZkcHSVPc7cMjkFqLc5fP58NSAobw==" }, "@oceanprotocol/lib": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-3.0.4.tgz", - "integrity": "sha512-HG187KtiT6LV8N5RbupcdKMR+6qsYLEmf43H5gnrIjDflachSayc1R629M7FPC29M8RMgqhfCwKLJJN64U+pmw==", + "version": "3.1.3-next.1", + "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-3.1.3-next.1.tgz", + "integrity": "sha512-x8Jau6kJEeg7GY7lGk1iFepDwPFbJ+hfsokg+SZInVBaqbAry17ykmdWK6w3bBJsXSBi+QnSyfu/EAyMb3Z22w==", "requires": { "@oceanprotocol/contracts": "^1.1.14", - "cross-fetch": "^3.1.5", + "cross-fetch": "^4.0.0", "crypto-js": "^4.1.1", "decimal.js": "^10.4.1", "ethers": "^5.7.2" + }, + "dependencies": { + "cross-fetch": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz", + "integrity": "sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==", + "requires": { + "node-fetch": "^2.6.12" + } + }, + "node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "requires": { + "whatwg-url": "^5.0.0" + } + }, + "tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "requires": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + } } }, "@oceanprotocol/typographies": { diff --git a/package.json b/package.json index f9eae5374..9f6583558 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "@coingecko/cryptoformat": "^0.5.4", "@loadable/component": "^5.15.2", "@oceanprotocol/art": "^3.2.0", - "@oceanprotocol/lib": "^3.0.4", + "@oceanprotocol/lib": "^3.1.3-next.1", "@oceanprotocol/typographies": "^0.1.0", "@oceanprotocol/use-dark-mode": "^2.4.3", "@orbisclub/orbis-sdk": "^0.4.40", From 277ccb5134b9b2d10ac91aa4d26865e96a9a488c Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Mon, 16 Oct 2023 23:44:08 +0300 Subject: [PATCH 3/3] bump oceanlib --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 69bf90cd4..debfacddc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "@coingecko/cryptoformat": "^0.5.4", "@loadable/component": "^5.15.2", "@oceanprotocol/art": "^3.2.0", - "@oceanprotocol/lib": "^3.1.3-next.1", + "@oceanprotocol/lib": "^3.1.3", "@oceanprotocol/typographies": "^0.1.0", "@oceanprotocol/use-dark-mode": "^2.4.3", "@orbisclub/orbis-sdk": "^0.4.40", @@ -6077,9 +6077,9 @@ "integrity": "sha512-PJih7C6LHaWHHj1qgxZsSkEqKphhJrL3G7WuMOxl4N1daDrF6sooDDU+9dZkcHSVPc7cMjkFqLc5fP58NSAobw==" }, "node_modules/@oceanprotocol/lib": { - "version": "3.1.3-next.1", - "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-3.1.3-next.1.tgz", - "integrity": "sha512-x8Jau6kJEeg7GY7lGk1iFepDwPFbJ+hfsokg+SZInVBaqbAry17ykmdWK6w3bBJsXSBi+QnSyfu/EAyMb3Z22w==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-3.1.3.tgz", + "integrity": "sha512-A7LStVhJILhDlaxMQM71cLco3+tyrE6croPG4UTX58lSb7IRuikOgWq0uH78p3sC4si1RBXVsfLprcx0HiZ9Gg==", "dependencies": { "@oceanprotocol/contracts": "^1.1.14", "cross-fetch": "^4.0.0", @@ -58487,9 +58487,9 @@ "integrity": "sha512-PJih7C6LHaWHHj1qgxZsSkEqKphhJrL3G7WuMOxl4N1daDrF6sooDDU+9dZkcHSVPc7cMjkFqLc5fP58NSAobw==" }, "@oceanprotocol/lib": { - "version": "3.1.3-next.1", - "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-3.1.3-next.1.tgz", - "integrity": "sha512-x8Jau6kJEeg7GY7lGk1iFepDwPFbJ+hfsokg+SZInVBaqbAry17ykmdWK6w3bBJsXSBi+QnSyfu/EAyMb3Z22w==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-3.1.3.tgz", + "integrity": "sha512-A7LStVhJILhDlaxMQM71cLco3+tyrE6croPG4UTX58lSb7IRuikOgWq0uH78p3sC4si1RBXVsfLprcx0HiZ9Gg==", "requires": { "@oceanprotocol/contracts": "^1.1.14", "cross-fetch": "^4.0.0", diff --git a/package.json b/package.json index 9f6583558..3ccece29d 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "@coingecko/cryptoformat": "^0.5.4", "@loadable/component": "^5.15.2", "@oceanprotocol/art": "^3.2.0", - "@oceanprotocol/lib": "^3.1.3-next.1", + "@oceanprotocol/lib": "^3.1.3", "@oceanprotocol/typographies": "^0.1.0", "@oceanprotocol/use-dark-mode": "^2.4.3", "@orbisclub/orbis-sdk": "^0.4.40",