solana-php-sdk icon indicating copy to clipboard operation
solana-php-sdk copied to clipboard

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

Open mindell opened this issue 4 years ago • 4 comments

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

Call to undefined method Tighten\\SolanaPhpSdk\\Borsh\\BinaryWriter::writeTighten\\SolanaPhpSdk\\Accounts\\Creator()

mindell avatar Apr 08 '22 12:04 mindell

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

neverything avatar Apr 11 '22 11:04 neverything

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

mindell avatar Apr 11 '22 16:04 mindell

@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.

neverything avatar Apr 22 '22 14:04 neverything

@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

chongkan avatar Apr 23 '24 13:04 chongkan