Coder Social home page Coder Social logo

magicblock-labs / solana.unity-core Goto Github PK

View Code? Open in Web Editor NEW
42.0 1.0 13.0 4.11 MB

Solana's Unity SDK and integration library.

Home Page: https://solana.unity-sdk.gg

License: MIT License

C# 99.98% PowerShell 0.01% Shell 0.01%
rpc solana solana-client unity unity3d

solana.unity-core's Issues

SendTransactionAsync does not add a 'commitment' parameter before sending the transaction

Note that SendTransactionAsync in SolanaRpcClient (Solana.Unity.Rpc/SolanaRpcClient.cs, line 985) doesn't add a "commitment" parameter to the outgoing request; it only adds the "preflightCommitment", which is a different parameter.

From the Solana docs: "For preflight checks and transaction processing," .... "The commitment parameter should be included as the last element in the params array"
https://docs.solana.com/developing/clients/jsonrpc-api

There is a HandleCommitment method (non-public) which conditionally adds a 'commitment' parameter with value to the Parameters collection. It isn't called in SendTransactionAsync, but it's called in similar methods.

Note that the only Commitment argument accepted by SendTransactionAsync is called "preflightCommitment", and it's used to set the preflightCommitment value. It might do to change that parameter to "commitment", and use it for both preflight commitment and commitment. Or else, add a second parameter for commitment.

I'm creating a pull request with the former (one parameter used for both preflight commitment and commitment)

Integrate changes from latest version of Solnet & Investigate automated pull request

Problem description

  • Solnet has integrated new features that are not present in our ported latest version.
  • This situation is recurring, investigate if it is possible to open a pull request automatically every time there are new commits in the main branch of Solnet repo, so that the changes can be integrated progressively

Describe the solution you'd like

  • Integrate the changes and update the Solana.Unity Core
  • Use a Github action to check daily if there are changes in main. If there are, it opens a pull request with the files that should be updated.

Additional context
Solnet: https://github.com/bmresearch/Solnet

[Bug]Unity stucks

Describe the bug
I wrote some simple code as the doc saids.

  1. create a wallet with Mnemonic
  2. try to get balance
  3. Unity sutcks and I heve to kill it

here is the code:

        Mnemonic newMnemonic = new Mnemonic(WordList.English, WordCount.Twelve);
        // generate a wallet
        Wallet wallet = new Wallet(newMnemonic);
        CurrentWallet = wallet;
        Debug.Log("words:" + wallet.Mnemonic);
        Debug.Log("pubkey:" + wallet.Account.PublicKey);
        Debug.Log("privatekey:" + wallet.Account.PrivateKey);
        // It's ok to get here ↑↑↑
        //try to get balance
        IRpcClient rpcClient = ClientFactory.GetClient(Cluster.DevNet);
        var balance = rpcClient.GetBalance(wallet.Account.PublicKey);
        //unity get stuck here ↑↑↑
        Debug.Log($"Balance: {balance.Result.Value}");

[Bug] PriceMath.TickIndexToPrice and PriceMath.SqrtPriceX64ToPrice Wrong price calculations

Describe the bug
Wrong price calculations

To Reproduce

Console.WriteLine(PriceMath.TickIndexToPrice(1, 9, 9));
Console.WriteLine(PriceMath.TickIndexToPrice(100, 9, 9));
10.00150003749937502188359611493754442728685383249508961171928583303106051744175749673006360257982567683817469619873
10.15112303331957826695058866288058596662162812280744838892230990557699568227283140711413108281156799322006970554316890624

Expected behavior

1.0001
1.0100496620928754

[Bug] Endless loop when logging public or private key with null value

Describe the bug
When you call toString on a public or private key which _key or _keyBytes are null there is an endless loop from the properties calling each other.

To Reproduce
PublicKey pubKey = new PublicKey("");
pubKey.Key = null;
Debug.Log(pubKey);

Expected behavior
There is no endless loop but instead returned null.

Additional context
Ill make a pr for a fix

[Bug] Solana.Unity.Rpc.SolanaRpcClient.SendTransactionAsync doesn't block until the required completion status

Describe the bug
Regarding class Solana.Unity.Rpc.SolanaRpcClient, which is an implementation of IRpcClient: Its SendTransactionAsync method takes in a parameter of type Commitment. It may be expected that, if the transaction is successfully sent, the method will block the task's thread until the transaction's status has reached the specified commitment level.

Example:
SendTransactionAsync(buffer, true, Commitment.Finalized)

In the call above, it may be reasonably expected that by the time the method returns, the transaction (if it was successfully sent and not reverted) is Finalized.

However, no blocking occurs.

To Reproduce

  • use the method Solana.Unity.Rpc.SolanaRpcClient.SendTransactionAsync to send a transaction. Specify the Commitment.Finalized value for the "commitment" parameter.
  • inspect the transaction immediately after execution completes.
  • note that the transaction is (probably) not finalized until a few seconds later.

Expected behavior
My understanding is that the expected behavior is for the SendTransactionAsync method to block its task thread until the transaction's status has reached the specified commitment level.

Desktop (please complete the following information):

  • OS: Ubuntu
  • Version 20.04

Add configurable default commitment for RPC calls

Is your feature request related to a problem? Please describe.
Finalized is not always desirable as default commitment

Describe the solution you'd like
Add configurable default commitment for RPC calls

[Bug]rentEpoc > ulong.MaxValue

Describe the bug
I encountered an overflow error when converting the result from JSON using the rpc.GetTokenAccountsByOwnerAsync method, specifically when the rentEpoch value exceeds ulong.MaxValue. This issue arises when processing rentEpoch values larger than what ulong can represent.

To Reproduce
Steps to reproduce the behavior:

  1. Call the rpc.GetTokenAccountsByOwnerAsync method to retrieve information about token accounts associated with an owner.
  2. Identify a scenario where the rentEpoch value in the returned JSON data exceeds ulong.MaxValue.
  3. Observe an overflow error during the conversion of JSON to .NET objects when encountering large rentEpoch values.

Expected behavior
I expected the library to either handle rentEpoch values of any size properly or provide a clear error message indicating that the value exceeds the supported range. Ideally, measures such as using a different data type or implementing a validation mechanism should be taken to accommodate scenarios where rentEpoch could surpass ulong limits.

Additional context
Error json excerpt

{"id":1,"jsonrpc":"2.0","result":{"context":{"apiVersion":"1.17.18","slot":246405854},"value":[{"account":{"data":{"parsed":{"info":{"isNative":false,"mint":"4wjPQJ6PrkC4dHhYghwJzGBVP78DkBzA2U3kHoFNBuhj","owner":"xxxxxxxxxxxxxxxxxx","state":"initialized","tokenAmount":{"amount":"100754","decimals":6,"uiAmount":0.100754,"uiAmountString":"0.100754"}},"type":"account"},"program":"spl-token","space":165},"executable":false,"lamports":2039280,"owner":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","rentEpoch":18446744073709552000,"space":165},"pubkey":"RVM2fCzme8o13BcyuZ2Ja1U7e6bHkf43Fze3iQNgJ1e"}....

Note: This issue report was created with the assistance of ChatGPT.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.