Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid character in catalog's dictionary key leads to broken scripts #107

Open
nvdtf opened this issue Jan 2, 2023 · 1 comment
Open

Comments

@nvdtf
Copy link
Member

nvdtf commented Jan 2, 2023

Most catalog scripts rely on temporary linking to return data (like this):

let tempPathStr = "catalog".concat(key)
let tempPublicPath = PublicPath(identifier: tempPathStr)!
account.link<&{MetadataViews.ResolverCollection}>(
            tempPublicPath,
            target: value.collectionData.storagePath
        )

This leads to errors if the key contains characters like '. This is now true on mainnet catalog.

As a workaround we can hash the key instead, but the downside is more computation:

pub fun cleanStringForPath(_ input: String): String {
  return "catalog".concat(String.encodeHex(HashAlgorithm.SHA3_256.hash(input.utf8)))
}


let tempPublicPath = PublicPath(identifier: cleanStringForPath(key))!
@nvdtf nvdtf changed the title Invalid character in dictionary key leads to broken scripts Invalid character in catalog's main dictionary keys leads to broken scripts Jan 2, 2023
@nvdtf nvdtf changed the title Invalid character in catalog's main dictionary keys leads to broken scripts Invalid character in catalog's dictionary key leads to broken scripts Jan 2, 2023
@bshahid331
Copy link
Contributor

I like this! Something we can implement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants