verze-app / solana-php-sdk

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

Borsh Implementation #13

Closed exzachlyvv closed 2 years ago

exzachlyvv commented 2 years ago

Known limitation:

  1. Large numbers unsupported (anything over a long (64 bits)).
  2. Enums - Don't really exist yet in PHP.

Todo in the future:

  1. Support more datatypes: a. Maps (Associative arrays) b. Much more
mattstauffer commented 2 years ago

I love the idea of a separate repo. Do you want to make it Tighten as well, same reason you answered it for this one?

exzachlyvv commented 2 years ago

Yeah that sounds like a great idea to me, let's house it under Tighten. The typical naming convention of the other borsh implementations is borsh-{$language}. So let's use borsh-php.

exzachlyvv commented 2 years ago

@mattstauffer this is now ready for review and merging. I can move this to an isolated repository whenever that is ready.

Do you know of a real-world example I could use to verify in a unit test?

neverything commented 2 years ago

@exzachlyvv here is an example I have been working with:

array:2 [▼
  "context" => array:1 [▶]
  "value" => array:5 [▼
    "data" => array:2 [▼
      0 => "BIcWwV2E66FeoVKsjwmsBS9m/7at6DThr7bqkd00fgolgBxluIzeDkDdQE+sVaYh9cprZWqk51KFpY8WDbHI5dUgAAAAUG93ZXIgUGxhbnQAAAAAAAAAAAAAAAAAAAAAAAAAAAAKAAAATVNQUDEAAAAAAMgAAABodHRwczovL2dhbGF4eS5zdGFyYXRsYXMuY29tL25mdHMvOWQ2SlFTV3JYVkVqeEJOcmVqN2VmQ1VkYzdaQ1JwYUhzZE4yQ0g2c0Vhd24AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAf8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== ◀"
      1 => "base64"
    ]
    "executable" => false
    "lamports" => 5616720
    "owner" => "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"
    "rentEpoch" => 232
  ]
]

Fetched using:

$account = $client->call('getAccountInfo', ['DSQiKA3zxbvXwJMT8kjUCVPRn9WbEnps18BoQPyRhxQp', ["encoding" => "base64"]]);
mattstauffer commented 2 years ago

@exzachlyvv Great, thanks! Just added you as an admin on https://github.com/tighten/borsh-php.

mattstauffer commented 2 years ago

@exzachlyvv I'm ready to merge as soon as you feel comfortable with it. You can either merge it or add a unit test and merge. Thanks!!

neverything commented 2 years ago

Let me know if I can test something regarding that. Glad if I can be of any help.

exzachlyvv commented 2 years ago

Let's merge this in. We can move the borsh functionality over for the borsh-php repo in a separate PR.