Skip to content

Commit

Permalink
✨ Support signing author as an object (#501)
Browse files Browse the repository at this point in the history
* 🚸 Add min description length check

* ✨ Support signing author as an object
  • Loading branch information
williamchong committed Dec 17, 2024
1 parent aaa076a commit e4d55dd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
15 changes: 9 additions & 6 deletions components/IscnRegisterForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
v-model="description"
:is-textarea="true"
:error-message="
validateField(description, charactersLimit.description, true)
validateField(description, charactersLimit.descriptionMax, true, charactersLimit.descriptionMin)
"
:placeholder="$t('IscnRegisterForm.placeholder.description')"
/>
Expand Down Expand Up @@ -698,7 +698,8 @@ const walletModule = namespace('wallet')
export enum CharactersLimit {
name = 100,
description = 1600,
descriptionMax = 1600,
descriptionMin = 10,
tagContent = 35,
tagNumber = 10,
authorName = 100,
Expand Down Expand Up @@ -1042,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,
Expand Down Expand Up @@ -1107,7 +1109,8 @@ export default class IscnRegisterForm extends Vue {
this.name &&
this.description &&
this.name.length <= CharactersLimit.name &&
this.description.length <= CharactersLimit.description
this.description.length <= CharactersLimit.descriptionMax &&
this.description.length >= CharactersLimit.descriptionMin
)
}
Expand Down Expand Up @@ -1155,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,
Expand Down Expand Up @@ -1189,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 || '',
}
}
Expand Down
1 change: 1 addition & 0 deletions utils/cosmos/iscn/iscn.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface ISCNRegisterPayload {
type: string;
publisher?: string,
author: string;
authorDescription?: string;
authorNames: string[];
authorUrls: string[][];
authorWallets: any[][];
Expand Down
10 changes: 8 additions & 2 deletions utils/cosmos/iscn/sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [],
Expand Down Expand Up @@ -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)],
Expand Down

0 comments on commit e4d55dd

Please sign in to comment.