-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4fdf143
commit 5e5fb53
Showing
8 changed files
with
207 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
<template> | ||
<div class="modal fade" id="changeDescriptionModal" tabindex="-1" aria-labelledby="changeDescriptionModalLabel" aria-hidden="true"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h1 class="modal-title fs-5" id="changeDescriptionModalLabel">Change description</h1> | ||
<button :id="'closeModal-'+componentId" type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | ||
</div> | ||
|
||
<div class="modal-body"> | ||
<p>Change your collection description.</p> | ||
|
||
<div class="mt-4"> | ||
<label :for="'input-'+componentId" class="form-label"> | ||
<strong> | ||
Enter new description: | ||
</strong> | ||
</label> | ||
|
||
<input v-model="editDescription" type="text" class="form-control" :id="'input-'+componentId"> | ||
</div> | ||
|
||
</div> | ||
|
||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> | ||
|
||
<button @click="update" type="button" class="btn btn-primary" :disabled="!editDescription || waiting"> | ||
<span v-if="waiting" class="spinner-border spinner-border-sm mx-1" role="status" aria-hidden="true"></span> | ||
Submit | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { ethers } from 'ethers'; | ||
import { useEthers } from 'vue-dapp'; | ||
import { useToast } from "vue-toastification/dist/index.mjs"; | ||
import WaitingToast from "~/components/WaitingToast"; | ||
export default { | ||
name: 'ChangeDescriptionModal', | ||
props: ["cAddress", "cDescription", "mdAddress"], | ||
emits: ["saveCollection"], | ||
data() { | ||
return { | ||
componentId: null, | ||
editDescription: null, | ||
waiting: false | ||
} | ||
}, | ||
mounted() { | ||
this.componentId = this.$.uid; | ||
this.editDescription = this.cDescription; | ||
}, | ||
methods: { | ||
async update() { | ||
this.waiting = true; | ||
const metadataInterface = new ethers.utils.Interface([ | ||
"function setDescription(address nftAddress_, string memory description_) external" | ||
]); | ||
const metadataContract = new ethers.Contract(this.mdAddress, metadataInterface, this.signer); | ||
try { | ||
const tx = await metadataContract.setDescription(this.cAddress, this.editDescription); | ||
const toastWait = this.toast( | ||
{ | ||
component: WaitingToast, | ||
props: { | ||
text: "Please wait for your transaction to confirm. Click on this notification to see transaction in the block explorer." | ||
} | ||
}, | ||
{ | ||
type: "info", | ||
onClick: () => window.open(this.$config.blockExplorerBaseUrl+"/tx/"+tx.hash, '_blank').focus() | ||
} | ||
); | ||
const receipt = await tx.wait(); | ||
if (receipt.status === 1) { | ||
this.toast.dismiss(toastWait); | ||
this.toast("You have updated the NFT description.", { | ||
type: "success", | ||
onClick: () => window.open(this.$config.blockExplorerBaseUrl+"/tx/"+tx.hash, '_blank').focus() | ||
}); | ||
this.$emit("saveCollection", { | ||
description: this.editDescription | ||
}); | ||
this.editDescription = null; | ||
// close the modal | ||
document.getElementById('closeModal-'+this.componentId).click(); | ||
this.waiting = false; | ||
} else { | ||
this.toast.dismiss(toastWait); | ||
this.waiting = false; | ||
this.toast("Transaction has failed.", { | ||
type: "error", | ||
onClick: () => window.open(this.$config.blockExplorerBaseUrl+"/tx/"+tx.hash, '_blank').focus() | ||
}); | ||
console.log(receipt); | ||
} | ||
} catch (e) { | ||
console.error(e); | ||
try { | ||
let extractMessage = e.message.split("reason=")[1]; | ||
extractMessage = extractMessage.split(", method=")[0]; | ||
extractMessage = extractMessage.replace('"', ""); | ||
extractMessage = extractMessage.replace('"', ""); | ||
extractMessage = extractMessage.replace('execution reverted:', "Error:"); | ||
console.log(extractMessage); | ||
this.toast(extractMessage, {type: "error"}); | ||
} catch (e) { | ||
this.toast("Transaction has failed.", {type: "error"}); | ||
} | ||
this.waiting = false; | ||
} | ||
}, | ||
}, | ||
setup() { | ||
const { signer } = useEthers(); | ||
const toast = useToast(); | ||
return { signer, toast }; | ||
}, | ||
watch: { | ||
cDescription() { | ||
this.editDescription = this.cDescription; | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
5e5fb53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
iggy-social-frontend – ./
demo2.iggy.social
iggy-social-frontend.vercel.app
iggy-social-frontend-git-main-punk-domains.vercel.app
iggy-social-frontend-punk-domains.vercel.app