From ac2ba71c133d0d7f7d8699304f7643bbcc9f856c Mon Sep 17 00:00:00 2001 From: AuroraHuang22 <75730405+AuroraHuang22@users.noreply.github.com> Date: Fri, 16 Feb 2024 21:44:02 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Add=20default=20value=20to=20sta?= =?UTF-8?q?keholders=20(#440)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🚸 Add default value to stakeholders * 🎨 Use default info when likerid not found * 🎨 Handle default info when user data is unavailable --------- Co-authored-by: William Chong <6198816+williamchong@users.noreply.github.com> --- components/IscnRegisterForm.vue | 63 +++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/components/IscnRegisterForm.vue b/components/IscnRegisterForm.vue index 3c106de1..49f2d75c 100644 --- a/components/IscnRegisterForm.vue +++ b/components/IscnRegisterForm.vue @@ -722,6 +722,7 @@ import { estimateISCNTxGasAndFee, formatISCNTxPayload } from '~/utils/cosmos/isc import { ISCN_GAS_MULTIPLIER } from '~/constant'; import { getLikerIdMinApi, + getUserInfoMinByAddress, API_POST_NUMBERS_PROTOCOL_ASSETS, } from '~/constant/api'; import { getAccountBalance } from '~/utils/cosmos' @@ -1114,38 +1115,46 @@ export default class IscnRegisterForm extends Vue { } async mounted() { - if (this.epubMetadata) { - this.name = this.epubMetadata.title; - this.description = this.extractText(this.epubMetadata.description); - this.author.name = this.epubMetadata.author; - this.author.authorDescription = 'Author' - this.language = this.epubMetadata.language - this.tags = this.epubMetadata.tags - this.thumbnailUrl = this.formatArweave(this.epubMetadata.thumbnailArweaveId) as string - if (this.author.name) { - this.authors.push(this.author) + this.uploadStatus = 'loading' + + if (this.epubMetadata) { + this.name = this.epubMetadata.title; + this.description = this.extractText(this.epubMetadata.description); + this.author.name = this.epubMetadata.author; + this.author.authorDescription = 'Author' + this.language = this.epubMetadata.language + this.tags = this.epubMetadata.tags + this.thumbnailUrl = this.formatArweave(this.epubMetadata.thumbnailArweaveId) as string + if (this.author.name) { + this.authors.push(this.author) + } + } + + if (this.address) { + const iscnOwner = await this.fetchUserInfoByAddress(this.address) + this.authors.push(iscnOwner) } + // ISCN Fee needs Arweave fee to calculate + await this.calculateISCNFee() + this.uploadStatus = '' } - if (this.address) { - const iscnOwner = { - name: this.$t('iscn.meta.stakeholders.name.placeholder') as string, - wallet: [{ - content: this.address, - id: 1, - type: 'like', - isOpenOptions: false, - }], + + async fetchUserInfoByAddress(address: any) { + let userData: any = null; + try { + ({ data: userData } = await this.$axios.get(getUserInfoMinByAddress(address))) + } catch (error) { + // eslint-disable-next-line no-console + console.error(error) + } + return { + name: userData?.displayName || address, + wallet: [{ content: address, id: 1, type: 'like', isOpenOptions: false }], url: [], - likerId: '', - authorDescription: 'ISCN owner', + likerId: userData?.user || '', + authorDescription: userData?.description || 'Publisher', } - this.authors.push(iscnOwner) } - this.uploadStatus = 'loading' - // ISCN Fee needs Arweave fee to calculate - await this.calculateISCNFee() - this.uploadStatus = '' -} addContentFingerprint() { this.customContentFingerprints.push(this.contentFingerprintInput)