Skip to content

Commit

Permalink
Merge pull request #527 from deltaDAO/development
Browse files Browse the repository at this point in the history
fix: add checks if edit state tx was successful (#526)
  • Loading branch information
moritzkirstein authored Mar 25, 2024
2 parents ddab483 + d94a363 commit e54272c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
1 change: 1 addition & 0 deletions content/pages/editMetadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
44 changes: 27 additions & 17 deletions src/components/Asset/Edit/EditMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit e54272c

Please sign in to comment.