verze-app / solana-php-sdk

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

Begin work to allow for finding program address via JavaScript #8

Closed mattstauffer closed 2 years ago

mattstauffer commented 2 years ago

Trying to extract the work out of mes/javascript-find-program that is actually useful so I can merge it sooner than later.

I actually think this is functional now. Testing on a project via composer.

Tag @exzachlyvv

mattstauffer commented 2 years ago

My local Valet install can't find Node when I pull it in via Composer; seems it has a different $PATH.

I may have to find a different way to run this Javascript, like running v8 or whatever.

exzachlyvv commented 2 years ago

I'm curious, what is the goal of the Javascript portion of this package?

It seems that most Solana dapps so far have separated the frontend js code from whatever backend it uses. I am imagining this package will re-implement the solana-web3 package in PHP code.

Are you trying to interface Php to javascript so we don't need to re-implement the solana-web3 logic in PHP? Brilliant idea, have you done things like that before with success? I would be skeptical of the production readiness that would bring to this package.

exzachlyvv commented 2 years ago

From looking at the other Solana SDK's out there, Python/go/Java, they are all basically a port of the 1st party @solana/web3.js

mattstauffer commented 2 years ago

Are you trying to interface Php to javascript so we don't need to re-implement the solana-web3 logic in PHP? Brilliant idea, have you done things like that before with success? I would be skeptical of the production readiness that would bring to this package.

Yup. As you can see in my other branch, reproducing all of the Nacl/etc. code in PHP was tough, so I just wanted to port that work out to JavaScript either permanently or at least for right now. ... If it's possible. It works locally with no problem, and I have some ideas for how to define the path--even if it requires some manual steps.

mattstauffer commented 2 years ago

FWIW, the goal of this is also to be relatively port-ish of web3.js. I'd rather not rely on JS if possible.

exzachlyvv commented 2 years ago

Got ya, I love that idea.

I've had pretty good success with PHP's sodium encryption library for all things cryptography. Public keys, secrets, onCurve all seem to work very well in my unit tests.

exzachlyvv commented 2 years ago

PR for fork coming in the next few days: https://github.com/exzachlyvv/solana-php-sdk/blob/main/src/PublicKey.php#L161 👀

mattstauffer commented 2 years ago

@exzachlyvv Great! I knew Sodium was going to be the solution but hadn't had time to figure out which sodium method mapped to which method in web3.js. So glad you've put in this work!

And good news, this means all this JS stuff won't be needed, so I'll jsut keep it in this branch for me to work with until we get your stuff merged