From a3e8ed91c9fadf068891b9d835c814613b0f179a Mon Sep 17 00:00:00 2001 From: William Chong Date: Wed, 11 Dec 2024 00:07:16 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Support=20signing=20author=20as=20a?= =?UTF-8?q?n=20object?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/IscnRegisterForm.vue | 7 ++++--- utils/cosmos/iscn/iscn.type.ts | 1 + utils/cosmos/iscn/sign.ts | 10 ++++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/components/IscnRegisterForm.vue b/components/IscnRegisterForm.vue index dbab3546..cdc986a3 100644 --- a/components/IscnRegisterForm.vue +++ b/components/IscnRegisterForm.vue @@ -1043,12 +1043,13 @@ export default class IscnRegisterForm extends Vue { numbersProtocolAssetId: [...this.numbersProtocolAssetIds.values()], fileSHA256: this.fileRecords.map((file) => file.fileSHA256), author: this.author.name, + authorDescription: this.author.authorDescription, authorNames: this.authorNames, + authorDescriptions: this.authorDescriptions, authorUrls: this.authorUrls, authorWallets: this.authorWalletAddresses, likerIds: this.likerIds, likerIdsAddresses: this.likerIdsAddresses, - authorDescriptions: this.authorDescriptions, contentFingerprints: this.contentFingerprintLinks, inLanguage: this.language, thumbnailUrl: this.thumbnailUrl, @@ -1157,7 +1158,7 @@ export default class IscnRegisterForm extends Vue { this.name = this.epubMetadata.title || '' this.description = this.extractText(this.epubMetadata.description) this.author.name = this.epubMetadata.author || '' - this.author.authorDescription = 'Author' + this.author.authorDescription = '' this.tags = this.epubMetadata.tags || [] this.thumbnailUrl = this.formatArweave( this.epubMetadata.thumbnailArweaveId, @@ -1191,7 +1192,7 @@ export default class IscnRegisterForm extends Vue { wallet: [{ content: address, id: 1, type: 'like', isOpenOptions: false }], url: [], likerId: userData?.user || '', - authorDescription: userData?.description || 'Publisher', + authorDescription: userData?.description || '', } } diff --git a/utils/cosmos/iscn/iscn.type.ts b/utils/cosmos/iscn/iscn.type.ts index cbeb32db..798c9e3d 100644 --- a/utils/cosmos/iscn/iscn.type.ts +++ b/utils/cosmos/iscn/iscn.type.ts @@ -14,6 +14,7 @@ export interface ISCNRegisterPayload { type: string; publisher?: string, author: string; + authorDescription?: string; authorNames: string[]; authorUrls: string[][]; authorWallets: any[][]; diff --git a/utils/cosmos/iscn/sign.ts b/utils/cosmos/iscn/sign.ts index 1c81a027..39464112 100644 --- a/utils/cosmos/iscn/sign.ts +++ b/utils/cosmos/iscn/sign.ts @@ -37,12 +37,13 @@ export function formatISCNTxPayload(payload: ISCNRegisterPayload): ISCNSignPaylo arweaveId, fileSHA256, author, + authorDescription, authorNames, + authorDescriptions, authorUrls, authorWallets, likerIds, likerIdsAddresses, - authorDescriptions, numbersProtocolAssetId, contentFingerprints: contentFingerprintsInput = [], stakeholders: stakeholdersInput = [], @@ -135,10 +136,15 @@ export function formatISCNTxPayload(payload: ISCNRegisterPayload): ISCNSignPaylo } } + const authorEntity = (author && authorDescription) ? { + name: author, + description: authorDescription, + } : author + return { ...data, publisher: publisherInput, - author, + author: authorEntity, keywords: tagsString.split(','), usageInfo: license, contentFingerprints: [...new Set(contentFingerprints)],