verze-app / solana-php-sdk

Simple PHP SDK for Solana JSON RPC endpoints
MIT License
88 stars 45 forks source link

Does anyone have successfully used Borsh::serialize()? #35

Open mindell opened 2 years ago

mindell commented 2 years ago

When i tried Borsh::serialize() i got this error..

Call to undefined method Tighten\\SolanaPhpSdk\\Borsh\\BinaryWriter::writeTighten\\SolanaPhpSdk\\Accounts\\Creator()
neverything commented 2 years ago

According to the tests is seems to be working: https://github.com/tighten/solana-php-sdk/blob/main/tests/Unit/BorshTest.php

mindell commented 2 years ago

Yes, but deserializing NFT and then serializing it again is not working. Anyway, I already use ts-node on that part.

neverything commented 2 years ago

@mindell this does indeed seem like a bug currently. Feel free to write a pull request for it or I'll get to it eventually in the future.

chongkan commented 4 months ago

@neverything , this is NOT a bug.

The class doesn't contain the method @mindell was trying to call.

See: https://github.com/verze-app/solana-php-sdk/blob/main/src/Borsh/BinaryWriter.php

For both the serializer and deserializer to work, one needs to use a valid STRUCT and the struct needs to include the definition of any other custom structs it might be using.

See: https://github.com/verze-app/solana-php-sdk/blob/main/src/Accounts/Metadata.php

FYI, I just made a pull request. https://github.com/verze-app/solana-php-sdk/pull/53