diff --git a/content/pages/editMetadata.json b/content/pages/editMetadata.json index 921571f2b..6b3f3deb5 100644 --- a/content/pages/editMetadata.json +++ b/content/pages/editMetadata.json @@ -2,6 +2,7 @@ "form": { "success": "🎉 Successfully updated. 🎉\n\nUpdates might not show up right away on your asset. In this case, wait some seconds and reload your asset details page in your browser.", "error": "Updating DDO failed.", + "stateError": "Updating asset state failed.", "data": [ { "name": "name", diff --git a/src/components/Asset/Edit/EditMetadata.tsx b/src/components/Asset/Edit/EditMetadata.tsx index 22e860fbc..c78cb97ee 100644 --- a/src/components/Asset/Edit/EditMetadata.tsx +++ b/src/components/Asset/Edit/EditMetadata.tsx @@ -212,35 +212,45 @@ export default function Edit({ // newAbortController() // ) - console.log({ state: values.assetState, assetState }) + if (!setMetadataTx) { + setError(content.form.error) + LoggerInstance.error(content.form.error) + return + } + await setMetadataTx.wait() + + LoggerInstance.log('[edit] asset states', { + state: values.assetState, + assetState + }) if (values.assetState !== assetState) { const nft = new Nft(signer) - await nft.setMetadataState( + const setMetadataStateTx = await nft.setMetadataState( asset?.nftAddress, accountId, assetStateToNumber(values.assetState) ) + if (!setMetadataStateTx) { + setError(content.form.stateError) + LoggerInstance.error(content.form.stateError) + return + } + await setMetadataStateTx.wait() } LoggerInstance.log('[edit] setMetadata result', setMetadataTx) - if (!setMetadataTx) { - setError(content.form.error) - LoggerInstance.error(content.form.error) - return - } else { - await setMetadataTx.wait() - if (asset.accessDetails.type === 'free') { - const tx = await setMinterToDispenser( - signer, - asset?.accessDetails?.datatoken?.address, - accountId, - setError - ) - if (!tx) return - } + if (asset.accessDetails.type === 'free') { + const tx = await setMinterToDispenser( + signer, + asset?.accessDetails?.datatoken?.address, + accountId, + setError + ) + if (!tx) return } + // Edit succeeded setSuccess(content.form.success) resetForm()