From 54cf20fed1b513ee1104f1d9694074aad36462ef Mon Sep 17 00:00:00 2001 From: AuroraHuang22 Date: Thu, 15 Feb 2024 17:11:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=9A=B8=20Add=20default=20value=20to?= =?UTF-8?q?=20stakeholders?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/IscnRegisterForm.vue | 69 +++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/components/IscnRegisterForm.vue b/components/IscnRegisterForm.vue index 58d5b9d6..cac1cb04 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,48 @@ 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.thumbnailUrl) 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.thumbnailUrl) as string + if (this.author.name) { + this.authors.push(this.author) + } } - } - 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, - }], - url: [], - likerId: '', - authorDescription: 'ISCN owner', + + if (this.address) { + try { + const { data } = await this.$axios.get( + getUserInfoMinByAddress(this.address), + ) + const iscnOwner = { + name: data?.displayName || this.address, + wallet: [{ + content: this.address, + id: 1, + type: 'like', + isOpenOptions: false, + }], + url: [], + likerId: data?.user || '', + authorDescription: data?.description || 'Publisher', + } + this.authors.push(iscnOwner) + } catch (error) { + // eslint-disable-next-line no-console + console.error(error) + } } - this.authors.push(iscnOwner) + // ISCN Fee needs Arweave fee to calculate + await this.calculateISCNFee() + this.uploadStatus = '' } - this.uploadStatus = 'loading' - // ISCN Fee needs Arweave fee to calculate - await this.calculateISCNFee() - this.uploadStatus = '' -} addContentFingerprint() { this.customContentFingerprints.push(this.contentFingerprintInput) From 1f52588176c140fb6d65b6939d6182a5ea3228d0 Mon Sep 17 00:00:00 2001 From: AuroraHuang22 Date: Fri, 16 Feb 2024 10:37:23 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=8E=A8=20Use=20default=20info=20when?= =?UTF-8?q?=20likerid=20not=20found?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/IscnRegisterForm.vue | 46 ++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/components/IscnRegisterForm.vue b/components/IscnRegisterForm.vue index cac1cb04..dbdef66a 100644 --- a/components/IscnRegisterForm.vue +++ b/components/IscnRegisterForm.vue @@ -1131,33 +1131,37 @@ export default class IscnRegisterForm extends Vue { } if (this.address) { - try { - const { data } = await this.$axios.get( - getUserInfoMinByAddress(this.address), - ) - const iscnOwner = { - name: data?.displayName || this.address, - wallet: [{ - content: this.address, - id: 1, - type: 'like', - isOpenOptions: false, - }], - url: [], - likerId: data?.user || '', - authorDescription: data?.description || 'Publisher', - } - this.authors.push(iscnOwner) - } catch (error) { - // eslint-disable-next-line no-console - console.error(error) - } + const iscnOwner = await this.fetchUserInfoByAddress(this.address) + this.authors.push(iscnOwner) } // ISCN Fee needs Arweave fee to calculate await this.calculateISCNFee() this.uploadStatus = '' } + async fetchUserInfoByAddress(address: any) { + try { + const { data } = await this.$axios.get(getUserInfoMinByAddress(address)) + return { + name: data?.displayName || address, + wallet: [{ content: address, id: 1, type: 'like', isOpenOptions: false }], + url: [], + likerId: data?.user || '', + authorDescription: data?.description || 'Publisher', + } + } catch (error) { + // eslint-disable-next-line no-console + console.error(error) + return { + name: address, + wallet: [{ content: address, id: 1, type: 'like', isOpenOptions: false }], + url: [], + likerId: '', + authorDescription: 'Publisher', + } + } + } + addContentFingerprint() { this.customContentFingerprints.push(this.contentFingerprintInput) this.contentFingerprintInput = '' From 4474a883bc8b1d79c1d50380cd17c25a05fdfcfa Mon Sep 17 00:00:00 2001 From: AuroraHuang22 Date: Fri, 16 Feb 2024 19:50:00 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=8E=A8=20Handle=20default=20info=20wh?= =?UTF-8?q?en=20user=20data=20is=20unavailable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/IscnRegisterForm.vue | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/components/IscnRegisterForm.vue b/components/IscnRegisterForm.vue index dbdef66a..dd80d0ce 100644 --- a/components/IscnRegisterForm.vue +++ b/components/IscnRegisterForm.vue @@ -1140,25 +1140,19 @@ export default class IscnRegisterForm extends Vue { } async fetchUserInfoByAddress(address: any) { + let userData: any = null; try { - const { data } = await this.$axios.get(getUserInfoMinByAddress(address)) - return { - name: data?.displayName || address, - wallet: [{ content: address, id: 1, type: 'like', isOpenOptions: false }], - url: [], - likerId: data?.user || '', - authorDescription: data?.description || 'Publisher', - } + ({ data: userData } = await this.$axios.get(getUserInfoMinByAddress(address))) } catch (error) { // eslint-disable-next-line no-console console.error(error) - return { - name: address, - wallet: [{ content: address, id: 1, type: 'like', isOpenOptions: false }], - url: [], - likerId: '', - authorDescription: 'Publisher', - } + } + return { + name: userData?.displayName || address, + wallet: [{ content: address, id: 1, type: 'like', isOpenOptions: false }], + url: [], + likerId: userData?.user || '', + authorDescription: userData?.description || 'Publisher', } }