Git Product home page Git Product logo

Comments (5)

omarkilani avatar omarkilani commented on July 19, 2024 1

FWIW, this is an example of the metadata serialised into JSON to see the null bytes

{"Key":4,"UpdateAuthority":"AumNBDNhvvknpcK9Zg6YeX9FrEoXtDE1f4rhK4qfVoyp","Mint":"2FREdEicgDaV4qixzuoSaJGY49SM5u4S8oRDK2MWVw8r","Data":{"Name":"Trippy Bunny #669\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000","Symbol":"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000","Uri":"https://arweave.net/SfdF4FtlF6C8Ex_6V_D6JiF227jF0xCqMDa52lKN-UM\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000","SellerFeeBasisPoints":420,"Creators":[{"Address":"BVpxLszd8FLUd7N8trW2Ykq47PNHEojMpEu2qqy9KX1S","Verified":true,"Share":0},{"Address":"GRUZBgdF7vHj52bca5wpUBaJ4VtC3v6iyHLyJ5SKE4mD","Verified":false,"Share":25},{"Address":"2rwAUSFw9ZffXra6uJenBbMmKKsowzkgkhaVaQAPTDEH","Verified":false,"Share":25},{"Address":"A1PYqVforDNbobBJw4MY4jcPWnKFzCA5XpJTNhMdVyy8","Verified":false,"Share":25},{"Address":"4xjqkXXh4FcirWZuFFJZypKy5TU36SFwrF6UFXos2Lii","Verified":false,"Share":25}]},"PrimarySaleHappened":true,"IsMutable":true,"EditionNonce":249}

from solana-go-sdk.

yihau avatar yihau commented on July 19, 2024

Actually, all the bytes (including null) are the original data on chain.
I want to preserve them in the underlayer function.
WDYT?

from solana-go-sdk.

omarkilani avatar omarkilani commented on July 19, 2024

Thanks for your response!

It's very confusing because the metadata Uri, when used with net/http, will always return an error due to null padding.

If the metadata name is passed to some formatting function then it will end up including the null bytes that you can't see.

IMHO, if the code is returning a string, it should be as expected by Go, i.e. excluding nulls.

If it was returning []byte then I think keeping the data like what's on the chain makes sense.

Right now, any time I'm working with metadata I need to use something like this:

func ByteSliceToString(s []byte) string {
        if i := bytes.IndexByte(s, 0); i != -1 {
                s = s[:i]
        }
        return string(s)
}

func CleanString(x string) string {
        return ByteSliceToString([]byte(x))
}

Which makes it cumbersome to work with the API, IMHO.

from solana-go-sdk.

yihau avatar yihau commented on July 19, 2024

yup. I agree with you.
Absolutely it is cumbersome to do the CleanString
Thank for the bug report. I will try to figure out a solution.

from solana-go-sdk.

yihau avatar yihau commented on July 19, 2024

I've released a new version, v1.8.1
I trim null bytes in the string.
Feel free to open another issue for any bugs!

from solana-go-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.