Closed 852Kerfunkle closed 5 months ago
Hey there! Are you looking for support with the store()
function? We were hoping that with the storeBlob
and storeCar
methods for uploading generic content, folks could hand-roll creating their own metadata if it's not ERC-1155, but it's true that you have to write your own validation of the metadata. Just want to make sure I'm understanding your request!
Hello! Yes, with the store()
function.
Here's what I'm doing to be able to use the store function, I liked the store function.
// extend NFTStorage to allow us to supply our own validation while keeping
// the simplicity of the store() function.
class NFTStorageTZip extends NFTStorage {
static override async encodeNFT(input: any) {
validateTZip12(input)
return Token.Token.encode(input)
}
static override async store(service: Service, metadata: any) {
const { token, car } = await NFTStorageTZip.encodeNFT(metadata)
await NFTStorageTZip.storeCar(service, car)
return token
}
override store(token: any) {
return NFTStorageTZip.store(this, token)
}
static override async storeBlob(service: Service, blob: Blob) {
const { cid, car } = await NFTStorageTZip.encodeBlob(blob)
await NFTStorageTZip.storeCar(service, car)
return cid.toString()
}
}
I'm perfectly happy to keep using it this way, it would just be nice to be able to supply my validation function to NFTStorage.
edit: in terms of not having to make sure this code keeps working as intended.
Makes sense! I think we probably won't give support to many different contract standards for the store()
method unless there's a ton of demand for supporting certain standards in store()
specifically (given that it's pretty simple to use the other methods to store what metadata you need to!). I think it's a cool idea so will keep the ticket open, but just being transparent that at the moment we probably won't be able to get to it unless we hear more from folks!
No worries, thank you for the feedback!
Would be nice to have. Currently working around the validation by overloading some functions and providing my own.
Could be an option in the interface.
For example, TZIP-12, a token standard on: Tezos https://tzip.tezosagora.org/proposal/tzip-12/#token-metadata
As trival as it is, here's the code: