Closed gabrielkoerich closed 2 years ago
This looks great to me, and thank you for your hard work! But I'm also not super experienced with how this should look.
@exzachlyvv do you have time to review?
Looks solid to me, I say go for it :D
Glad to see the Borsh serialize and deserialize are working for you. It has unit tests with it for the basics but is not very well battle-tested.
Thank you @gabrielkoerich, I got stuck with implementing it, but this looks solid. Will give it a spin in a project I'm working on right now.
Hey @gabrielkoerich tested it on my pet project and it works like a charm. Thank you so much.
Example I used:
$buffer = Tighten\SolanaPhpSdk\Util\Buffer::from(base64_decode("BLUfopsd28JkHxD508khOVqJs0QEtJil6YnQx6TnsfjCvqlhQ8ZBiq6HQQAmaAGcnOT8OZqx345k6w7TwXNMEgkgAAAARGVnZW4gQXBlICM2MDcwAAAAAAAAAAAAAAAAAAAAAAAKAAAAREFQRQAAAAAAAMgAAABodHRwczovL2Fyd2VhdmUubmV0LzYtTlRNQ3V2U1RoenhVa1hGMEJCQnNkMlVkUndleGJQZ1Y3ZURlNnZxWlEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKQBAQUAAAB5gjzbbOUIc9s/iV4kP5TYIguYOHAu+Xu662lw3SOU/wAnepeo3YmSVXuxd1YIGA0Fx/NBhlrdkN7wihlp80ABbNYAGfMttjlO90iXaxTs+8J22sQvCBdhYhhLS9qYAwYgbdVKABlc/UqP7sYeQijwKGxdKwBRDSYVJjog7Vg/GdoRJ0TtEAAKtR+imx3bwmQfEPnTySE5WomzRAS0mKXpidDHpOex+MIBAQEAAf8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="));
$metadata = Tighten\SolanaPhpSdk\Accounts\Metadata::fromBuffer($buffer->toArray());
Results in:
=> Tighten\SolanaPhpSdk\Accounts\Metadata {#1352
+"key": 4,
+"updateAuthority": "DC2mkgwhy56w3viNtHDjJQmc7SGu2QX785bS4aexojwX",
+"mint": "DqGGFuiWRiJ6Mim1qafLWn6FZzBGGcSTyFFSJ8RpuqE8",
+"data": Tighten\SolanaPhpSdk\Accounts\MetadataData {#1351
+"name": "Degen Ape #6070",
+"symbol": "DAPE",
+"uri": "https://arweave.net/6-NTMCuvSThzxUkXF0BBBsd2UdRwexbPgV7eDe6vqZQ",
+"sellerFeeBasisPoints": 420,
+"creators": [
Tighten\SolanaPhpSdk\Accounts\Creator {#1349
+"address": "9BKWqDHfHZh9j39xakYVMdr6hXmCLHH5VfCpeq2idU9L",
+"verified": 0,
+"share": 39,
},
Tighten\SolanaPhpSdk\Accounts\Creator {#1348
+"address": "9FYsKrNuEweb55Wa2jaj8wTKYDBvuCG3huhakEj96iN9",
+"verified": 0,
+"share": 25,
},
Tighten\SolanaPhpSdk\Accounts\Creator {#1345
+"address": "HNGVuL5kqjDehw7KR63w9gxow32sX6xzRNgLb8GkbwCM",
+"verified": 0,
+"share": 25,
},
Tighten\SolanaPhpSdk\Accounts\Creator {#1344
+"address": "7FzXBBPjzrNJbm9MrZKZcyvP3ojVeYPUG2XkBPVZvuBu",
+"verified": 0,
+"share": 10,
},
Tighten\SolanaPhpSdk\Accounts\Creator {#1347
+"address": "DC2mkgwhy56w3viNtHDjJQmc7SGu2QX785bS4aexojwX",
+"verified": 1,
+"share": 1,
},
],
},
+"primarySaleHappened": 1,
+"isMutable": 0,
}
@neverything awesome to see it helped!
@exzachlyvv yeah, this wouldn't be possible without your work, thanks!
Fantastic--thanks so much for your work @gabrielkoerich! Tagging now.
Hi guys!
This PR creates 3 accounts:
It uses the same schema Metaplex uses to deserialize objects from the buffer array.
I also created a test to show how it works, but basically would be something like this:
So we finally can deserialize them on PHP! 🚀