Skip to content

Commit

Permalink
🔀 Merge #1857 into deploy/rinkeby
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Oct 3, 2024
2 parents ac6e422 + bfeaafd commit 4cfa318
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/pages/nft/claim/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ import {
getNFTClassCollectionType,
nftClassCollectionType,
parseNFTMetadataURL,
parseAutoMemo,
} from '~/util/nft';
import { ellipsis } from '~/util/ui';
import { NFT_BOOK_PLATFORM_LIKER_LAND } from '~/constant';
Expand Down Expand Up @@ -844,7 +845,7 @@ export default {
this.giftInfo = giftInfo;
this.isPhysicalOnly = isPhysicalOnly;
this.isAutoDeliver = isAutoDeliver;
this.creatorMessage = autoMemo;
this.creatorMessage = parseAutoMemo(autoMemo);
this.status = status;
this.quantity = quantity;
} catch (err) {
Expand All @@ -859,7 +860,7 @@ export default {
const { isPhysicalOnly, autoMemo, isAutoDeliver } = data;
this.isPhysicalOnly = isPhysicalOnly;
this.isAutoDeliver = isAutoDeliver;
this.creatorMessage = autoMemo;
this.creatorMessage = parseAutoMemo(autoMemo);
}
try {
Expand Down
12 changes: 8 additions & 4 deletions src/util/nft.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,22 @@ export function checkIsNFTBook(classMetadata) {
);
}

export function formatEventMemo(event) {
const { memo } = event;
export function parseAutoMemo(memo, index = 0) {
if (!memo) return memo;
try {
const payload = JSON.parse(event.memo);
const payload = JSON.parse(memo.replaceAll('\\"', '"'));
if (Array.isArray(payload)) {
return payload[event.msg_index || 0] || memo;
return payload[index] || memo;
}
} catch (error) {}
return memo;
}

export function formatEventMemo(event) {
const { memo } = event;
return parseAutoMemo(memo, event.msg_index || 0);
}

export function formatNFTEvent(event) {
const {
class_id: classId,
Expand Down

0 comments on commit 4cfa318

Please sign in to comment.