From 33f03a415938ae4c838a0e4efa0cfc364b2947a8 Mon Sep 17 00:00:00 2001 From: Motokoder Date: Sat, 7 Oct 2023 00:00:46 -0600 Subject: [PATCH] ENG-1981 fix error when uploading first library file --- src/methods/nft/nft.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/methods/nft/nft.ts b/src/methods/nft/nft.ts index 660aaa6..75e4677 100644 --- a/src/methods/nft/nft.ts +++ b/src/methods/nft/nft.ts @@ -328,15 +328,17 @@ const buildLibraryMetadata = async ( // get highest sort value let maxSort = 0n; - for (const library of nftLibraries) { - const sortAttrib = getAttribute(library, 'sort'); - if (sortAttrib) { - const sort = (sortAttrib.value as NatValue)?.Nat || 0n; - maxSort = sort > maxSort ? sort : maxSort; + if (nftLibraries?.length) { + for (const library of nftLibraries) { + const sortAttrib = getAttribute(library, 'sort'); + if (sortAttrib) { + const sort = (sortAttrib.value as NatValue)?.Nat || 0n; + maxSort = sort > maxSort ? sort : maxSort; + } + } + if (maxSort < nftLibraries.length + 1) { + maxSort = BigInt(nftLibraries.length + 1); } - } - if (maxSort < nftLibraries.length + 1) { - maxSort = BigInt(nftLibraries.length + 1); } const attribs: PropertyShared[] = [];