Code Monkey home page Code Monkey logo

solana.unity-sdk's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

solana.unity-sdk's Issues

[Erro create transaction with multi singature]

Describe the bug
when add more than one signature in transaction don't open Phanton and have error : ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.

#Code

       var blockHash = await Web3.Instance.Wallet.ActiveRpcClient.GetRecentBlockHashAsync();
        Debug.Log($"{blockHash.Result.Value.Blockhash}");

        Account mintAccount = Web3.Instance.Wallet.Account;
        Debug.Log($"MintAccount: {mintAccount}");
        Account ownerAccount = new Account("", "9nQUWBRcxLH8d3UDD2e9vaRJcdGgR7rdZXGugZ9ES7FV");
        Debug.Log($"OwnerAccount: {ownerAccount}");
        Account initialAccount = new Account("", "87L945pDtH7LDP2fFugpDkQu8YdN2xXRLi5GxdQEnfqT");
        Debug.Log($"InitialAccount: {initialAccount}");

        var txBuilder = new TransactionBuilder()
            .SetRecentBlockHash(blockHash.Result.Value.Blockhash)
            .SetFeePayer(mintAccount)
            .AddInstruction(MemoProgram.NewMemo(mintAccount.PublicKey, "Hello Mehrdad :)"))
            .Build(new List<Account>() {mintAccount, ownerAccount, initialAccount});

        var sign = await Web3.Instance.Wallet.SignTransaction(Transaction.Deserialize(txBuilder));

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS:[android]
  • Browser [e.g. chrome, safari]
  • Version Solana [ 0.1]

image

Separate metadata and texture loading in NFT loader

Is your feature request related to a problem? Please describe.
Using NFT loader takes unnecessarily long time, since it loads metadata and texture of every NFT. In my app, I am only interested in loading textures only of specific NFTs.

Describe the solution you'd like
In the NFT loader function, have an optional variable of "metadataOnly". If its true, only fetch metadata on the object, leaving texture as null. Additionally, a new function is needed called LoadTextures() which takes in an array of objects with their metadata parsed and loads textures onto them

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)

Can't create a Transaction from a instruction buffer

The SDK has a few instructions to create a Transaction, but it's not clear what format to use as the parameters.

I have the int[] with the instructions. ("buffer instruction")
image

This is how it's expected to be used:

Message m = Message.Deserialize(instructions);
Transaction t = Transaction.Populate(m);

But, what is the format of the instructions? In my case I have an array of integers. Should I turn it into byte[] ? I tried and it don't reconstruct anything.

This is my code:
image

This is the byte[]:
image

But no instructions are read:
image

Transacion not constructed:
image

What is the format osf this parameter?
Message.Deserialize(????)

Thansk in advanced.

Namespace Not found

I followed the installation step given in README.md but still getting this error. I'm using 2021.3.6f1 or even tried with latest one 2022, but the issue still persists.

image

Update the example user interface

Problem description

The current UI could be simplified, making it more pleasant and responsive on different types of screens (mobile / desktop)

Describe the solution you'd like

Modify the example scene to make it more pleasant and responsive

Backpack sign message implementation

Is your feature request related to a problem? Please describe.
I want to sign messages with backpack, because when I build my project with xNFT, I'm not able to sign in users.

Describe the solution you'd like
Implement _SignTransaction function inside XNFTWallet.cs

Describe alternatives you've considered
The only alternative to this function is to use signTransaction and make user sign memo transaction and don't send it, use it for validation only, which is not the best solution, it's already used by Ledger users but not convenient one, since backpack supports sign message.

Additional context
I've written implementation for it, but problem is, that Phantom.jslib uses window.phantom.solana.request function, which returns signature as a string, but other wallet adapters does not return string, return UInt8Array. For consistency, we must return Uint8Array from phantom wallet adapter as well.

If you have any other ideas how we can implement it, I can do it for sure.

Build failure

Problem:
Library\PackageCache\com.solana.unity_sdk@73c9e46\Runtime\Plugins\HideIf\Editor\HideIfAttributeDrawer.cs(144,2): error CS0246: The type or namespace name 'CustomPropertyDrawerAttribute' could not be found (are you missing a using directive or an assembly reference?)

Build fails with 21 errors

To Reproduce

  1. Add SDK to project from git link
  2. Build project for WebGL

Unity version: 2021.3.1f1

Expected behavior
Project compiles and build succeeds.

Issue1

Add retry mechanism to SignAndSendTransaction

Is your feature request related to a problem? Please describe.
In case of transaction failure, the WalletBase could retry to send the transaction to the network

Describe the solution you'd like
Add an int retry parameter to SignAndSendTransaction

[Bug] GetTokenAccountsByOwnerAsync request isn't successfully handled

Describe the bug

Within the Unity Editor, I am calling

TokenAccount[] tokens = await Web3.Base.GetTokenAccounts(new Wallet.PublicKey(tokenMintAddress), new Wallet.PublicKey(applicationData.tokenProgramID));

but the result is not successful and the following data is returned:

WasHttpRequestSuccessful: true
WasRequestSuccessfullyHandled: False
ServerErrorCode: -32602
ErrorData: Null
Reason: Invalid params: invalid value: map, expected map with a single key.
RawRpcRequest: {"method":"getTokenAccountsByOwner","params":["A2FNZ6EZgppKvrSSfDZJrHFNkEh6cxB3dQwvxmxmyYX7",{"mint":"E6UU5M1z4CvSAAF99d9wRoXsasWMEXsvHrz3JQRXtm2X","programId":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{"encoding":"jsonParsed"}],"jsonrpc":"2.0","id":1}
RawRpcResponse: {"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params: invalid value: map, expected map with a single key."},"id":1}

It seems the Token Mint Address param string for the method getTokenAccountsByOwner has "mint:" as a prefix to the Token Mint Address string that I passed into the GetTokenAccounts function.

To Reproduce

Steps to reproduce the behavior:

(1) Call

TokenAccount[] tokens = await Web3.Base.GetTokenAccounts(new Wallet.PublicKey(tokenMintAddress), new Wallet.PublicKey(.tokenProgramID));

(2) Wait for the response data.

Expected behavior

I expected the token data associated with the Token Mint Address and the User's Public Address to be returned within the result as a TokenAccount object.

[Bug] Cannot sign transaction with new extension version

Describe the bug
After update extension of phantom wallet on web. My wallet cannot be sign transaction which was build on Back-end.

To Reproduce

  1. Back-end build transaction and return buffer.
  2. Convert Transaction by "Transaction.Deserialize"
  3. Call function Web3.Base.SignAndSendTransaction(trans)
  4. Phatomwallet show popup Sign Transaction
  5. Return value: {"jsonrpc":"2.0","error":{"code":-32003,"message":"Transaction signature verification failure"},"id":3}

Screenshots
image
image

Desktop (please complete the following information):

  • OS: Window 10
  • Browser: Chrome
  • Version: 23.4.0

Additional context
We use devnet. On both back end and unity

Old version of extension still work.

Error when calling dex.GetSwapQuoteFromWhirpool()

My code is:

                    WalletBase wallet = new SolanaWalletAdapterWebGL(options, RpcCluster.MainNet, "https://api.metaplex.solana.com/", null, true);
                    await wallet.Login();
                    dex = new OrcaDex(wallet.Account, wallet.ActiveRpcClient, commitment: Commitment.Finalized);

                    // GET ORCA SWAP PRICE
                    TokenData tokenA = await dex.GetTokenBySymbol("USDC");
                    TokenData tokenB = await dex.GetTokenByMint(item.Account.Data.Parsed.Info.Mint);
                    Pool whirlpool;
                    if (tokenA != null && tokenB != null)
                    {
                        whirlpool = await dex.FindWhirlpoolAddress(tokenA.MintAddress, tokenB.MintAddress);

                        if(whirlpool != null)
                        {
                            Debug.Log("whirlpool FOUND FOR " + item.Account.Data.Parsed.Info.Mint);
                            Debug.Log("DECIMALS IS " + tokenA.Decimals);
                            var value = float.Parse("1");
                            Debug.Log("CONVERTED TO LONG");

                         ->   SwapQuote swapQuote = await dex.GetSwapQuoteFromWhirlpool(
                                whirlpool.Address,
                                DecimalUtil.ToUlong(value, tokenA.Decimals),
                                tokenA.MintAddress,
                                slippageTolerance: 0.1
                            );

                            if(swapQuote != null)
                            {
                                Debug.Log("QUOTE found for " + item.Account.Data.Parsed.Info.Mint);
                                var quote = DecimalUtil.FromBigInteger(swapQuote.EstimatedAmountOut, tokenB.Decimals);
                                Debug.Log("PRICE OF " + item.Account.Data.Parsed.Info.Mint);
                                Debug.Log(quote);
                            }
                        }
                    }

But it fails in the marked line with this errors:

website.framework.js:3 InvalidOperationException: Sequence contains no matching element
  at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) [0x00000] in <00000000000000000000000000000000>:0 
--- End of stack trace from previous location where exception was thrown ---

PercentageException: Conversion not possible
  at Solana.Unity.Dex.Math.Percentage.FromDouble (System.Double dValue) [0x00000] in <00000000000000000000000000000000>:0 
--- End of stack trace from previous location where exception was thrown ---

[Bug] Error: Please install phantom browser extension

Describe the bug

At demo site, it ask me to install Phantom browser extension, despite I've it already installed.

To Reproduce
Steps to reproduce the behavior:

  1. https://magicblock-labs.github.io/Solana.Unity-SDK/
  2. Click on wallet, then 'Sign in with Phantom'.

Expected behavior
It should connect to Phantom extension.

Desktop (please complete the following information):

  • OS: macOS
  • Browser: Chrome
  • Version: 113.0.5651.0

Additional context
Add any other context about the problem here.

[Bug] when sign and send transaction has a error .

Describe the bug
when sign and send transaction with network dev and main get signature but search in Solscan "Search not found"

Desktop (please complete the following information):

  • OS: [WEB]
  • Version SDK [0.1]

[Bug] Error on transfer

Describe the bug
A clear and concise description of what the bug is.

I am trying to transfer sol to another wallet I am able to accept the transaction but it doesn't get send to the solana blockchain due to a signature error (see screenshot)

To Reproduce
Steps to reproduce the behavior:

Import the package Solana Unity to any project

Expected behavior
A clear and concise description of what you expected to happen.

It should send the transaction to the solana blockchain but instead it throws an error of the RPC endpoint

Screenshots
If applicable, add screenshots to help explain your problem.

Captura de Pantalla 2023-02-13 a las 21 04 43

Desktop (please complete the following information):

  • OS: [e.g. iOS] MacOS
  • Browser [e.g. chrome, safari] Chrome
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Automatic code generation to interact with any Anchor program

Problem description

Currently, to interact with a new Anchor program (or Solana program), it is necessary to write the C # code to serialize, deserialize and call the program's methods.

Anchor can be used to generate C# code using the IDL definition, but the generated code requires changes to make it compatible with standard dotnet 2.0 and Unity

Describe the solution you'd like

Fork https://github.com/bmresearch/Solnet.Anchor/ as a starting point, and modify it to generate code compatible with Unity and dotnet standard 2.0

Additional context

Anchor: https://github.com/coral-xyz

[Bug] "Unsupported JSON-RPC protocol version" error appears after login into the wallet in the demo scene

Bug description
Solana and NFTs are not displayed on the user's balance, in the demo scene, after logging into the wallet. In dev tools user receives message: "Unsupported JSON-RPC protocol version". This error appears for Dev net, Test net and Main net as well login both via Phantom or creating a new wallet

  • MacOS - Ventura 13.0
  • Browser - Chrome 111
  • Unity3d - 2021.3.21f1
  • Solana.Unity-SDK - v0.0.8

Steps To Reproduce

  1. Open the wallet_scene and build it for WebGL without any changes in the project
  2. Start WebGL build on localhost
  3. Sign in with Phantom
    Neither solana balance nor NFTs are displayed on the wallet and the error presents in dev tools

1

Payload request
{method: "getTokenAccountsByOwner", id: 1} id : 1 method : "getTokenAccountsByOwner"

Main net case:
2

Failed Encoding of Creator Address String utf-8

Describe the bug
nftData.metaplexData.data.creators[0].address is not returning valid utf-8 string

To Reproduce
Steps to reproduce the behavior:

Expected behavior
nftData.metaplexData.data.creators[0].address is returning valid utf-8 string

Screenshots
image

image

Auto connect wallet on page reload

Is your feature request related to a problem? Please describe.
When reloading the page, the wallet adapter prompt again for wallet selection/connection

Describe the solution you'd like
The connection could be automatically reopened, similarly to the react wallet adapter

Error when trying to connect to Phantom (webGL) [Bug]

Works on the editor but throws an error when trying to connect to Phantom or creating a new wallet on WebGL:

An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was:
RuntimeError: index out of bounds
InterfaceFuncInvoker1<WebRequest_t89050438AE9A5AA9221ECAE223584127F7C1294B
, Uri_t1500A52B5F71A04F5D05C0852D0F2A0941842A0E
>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, Uri_t1500A52B5F71A04F5D05C0852D0F2A0941842A0E*)@http://localhost:55818/Build/Build.wasm:wasm-function[3555]:0x11cdd0
WebSocketWrapper_SendAsync_m3BD5E210A83C3723DBB217694EA8FE4409A89027@http://localhost:55818/Build/Build.wasm:wasm-function[30944]:0x7f9cce**

Steps to reproduce the behavior:
Create new WebGL project, install the SDK, change RPC (alchemy in my case), build and then try to login via Phantom or new wallet

sdk v0.0.7
Unity v2021.3.21f
Alchemy rpc
tested on Firefox and Chrome

Add WebGL support for Web3Auth Adapter

Is your feature request related to a problem? Please describe.

Web3Auth Adapter currently only works on mobiles, editor and desktop

Describe the solution you'd like
Similarly to Phantom, it's possibly to extend the current adapter and rely on the official Javascript SDK to Login/Sing transaction

[Bug] When I install Photon lib with Solana Unity SDK there is a WebSocketSharp duplicity error

Describe the bug
When I install Photon lib with Solana Unity SDK there is a WebSocketSharp duplicity error being triggered:

Assets\SolanaSDK\Runtime\codebase\SolanaMobileWalletAdapter.cs(92,28): error CS0121: The call is ambiguous between the following methods or properties: 'WebSocketSharp.Ext.IsNullOrEmpty(string)' and 'WebSocketSharp.Ext.IsNullOrEmpty(string)'

Happens that Photon has the same library being distributed with.
If I try to remove the duplicate dll from Solana folder...
image
... the Solana Unity SDK don't work, and shows follow error:
Assets\SolanaSDK\Runtime\codebase\SolanaMobileStack\MobileWalletAdapterWebSocket.cs(2,7): error CS0246: The type or namespace name 'NativeWebSocket' could not be found (are you missing a using directive or an assembly reference?)

To Reproduce

  • Install the Solana Unity SDK from the zip file downloaded from github.
  • Install Photon Quantum plugin from zip file downloaded from Photom website.
  • The lib duplicity error will be triggered.
  • Remove the NativeWebSocket.dll from Solana folder.
  • Now the "Type namespáce error" is triggered.

Expected behavior
I expect to remove the NativeWebSocket lib distributed with Solana SDK and use any generic NativeWebSocket lib already present in the project.

Screenshots
image

Desktop (please complete the following information):

  • Unity 2-21.3.12

[Bug] Exception in InGameWallet when EncryptedKeystoreKey not initialised

Describe the bug
When there was no account for InGameWallet yet the login throws an exception instead of returning null.

To Reproduce
Create a new InGameWallet when there was never saved a EncryptedKeystoreKey before.

Expected behavior
Nothing beaks

Additional context
To fix replace the InGameWallet:35
catch (DecryptException)
in line to:
catch (Exception)

[Bug] In the example project, LoginXNFT from ModelH class don't work.

Describe the bug
The example project always fails to login when the user created/loaded a wallet already .

To Reproduce
1 - Run the example project and click in the wallet icon in the center of the screen;
2 - Load/Create a Wallet;
3 - Leave the wallet screen and go to the main screen where the wallet button is.
4 - Hit the wallet button again and expect to go direct to the wallet screen;

Expected behavior
A internal logind should be done and the user should be led to the WEallet screen.
But it always fails, the example project should be able to do login but it fails and always shows the login screen;

Screenshots
The screenshot below shows the part of the code inside LoginScreen.cs. This part of the code is responsible for testing the login (line 92), and if success, lead the user to the Wallet screen(line 103).
bug

Unity Editor :

  • Version [2021.3.18f1]
  • OS: Windows 10

Additional context
The problem happens in the line 92 (see image above). The LoginXNFT from WalletH is not working and the entire flow is interrupted.
The LoginXNFT method from WalletH creates a XNFTWallet object and the Login method from this class is probably the source of the problem.

[Bug] WebSocketShard DLL exists twice, 1.0.0 and 1.0.2

Describe the bug
When trying to compile with 0.0.3 i get the following error:
Assets/SolPlay/WebSockets/SolPlaySharpWebSockets.cs(15,32): error CS0433: The type 'WebSocket' exists in both 'websocket-sharp-core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' and 'websocket-sharp-latest, Version=1.0.2.0, Culture=neutral, PublicKeyToken=5660b08a1845a91e'

[websocket-sharp-core.1.0.0.dll]
[websocket-sharp-latest.dll]

To Reproduce
Add https://github.com/garbles-labs/Solana.Unity-SDK.git to packages and try to compile.

Expected behavior
No errors

Desktop (please complete the following information):
Plattform is WebGL

Probably would be safe to delete the version 1.0.0?

Error occurred while transfer sol

An error occureed when I was trying to transfer sol to another pub address using the wallet simple.
1

the error said this is null
transferError

but I checked it is not.
accountIsNotNull

[Bug] Some problems with the demo scene in unity editor

  1. The logout button throws an Error

image

NullReferenceException: Object reference not set to an instance of an object
ReceiveScreen.CheckAndToggleAirdrop () (at Assets/Samples/Solana SDK/0.0.9/Simple Wallet/Solana Wallet/Scripts/example/screens/ReceiveScreen.cs:50)
Solana.Unity.SDK.Web3.set_Wallet (Solana.Unity.SDK.WalletBase value) (at /Users/jonasmac2/Documents/GitHub/Solana.Unity-SDK/Runtime/codebase/Web3.cs:48)
Solana.Unity.SDK.Web3.Logout () (at /Users/jonasmac2/Documents/GitHub/Solana.Unity-SDK/Runtime/codebase/Web3.cs:164)
Solana.Unity.SDK.Example.WalletScreen.b__14_3 () (at Assets/Samples/Solana SDK/0.0.9/Simple Wallet/Solana Wallet/Scripts/example/screens/WalletScreen.cs:68)
UnityEngine.Events.InvokableCall.Invoke () (at /Users/bokken/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent.cs:178)
UnityEngine.Events.UnityEvent.Invoke () (at /Users/bokken/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent/UnityEvent_0.cs:58)
UnityEngine.UI.Button.Press () (at Library/PackageCache/[email protected]/Runtime/UI/Core/Button.cs:70)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/[email protected]/Runtime/UI/Core/Button.cs:114)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/[email protected]/Runtime/EventSystem/ExecuteEvents.cs:57)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at Library/PackageCache/[email protected]/Runtime/EventSystem/ExecuteEvents.cs:272)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/[email protected]/Runtime/EventSystem/EventSystem.cs:501)

Null pointer in wallet screen:
NullReferenceException: Object reference not set to an instance of an object
Solana.Unity.Wallet.PrivateKey.op_Implicit (Solana.Unity.Wallet.PrivateKey privateKey) (at <5e5d3c5645854f6095878615ec04f331>:0)
Solana.Unity.SDK.Example.WalletScreen.OnEnable () (at Assets/Samples/Solana SDK/0.0.9/Simple Wallet/Solana Wallet/Scripts/example/screens/WalletScreen.cs:110)
UnityEngine.GameObject:SetActive(GameObject, Boolean)
WalletHolder:b__4_0() (at Assets/Samples/Solana SDK/0.0.9/Simple Wallet/Solana Wallet/Scripts/example/simple_screen_manager/WalletHolder.cs:17)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/[email protected]/Runtime/EventSystem/EventSystem.cs:501)

image

Swap screen does not update the value on the right side and there is no feedback when clicking the button or an error message.

Null pointer when clicking the copy address button the recieve screen:
NullReferenceException: Object reference not set to an instance of an object
ReceiveScreen.CopyPublicKeyToClipboard () (at Assets/Samples/Solana SDK/0.0.9/Simple Wallet/Solana Wallet/Scripts/example/screens/ReceiveScreen.cs:83)
UnityEngine.Events.InvokableCall.Invoke () (at /Users/bokken/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent.cs:178)
UnityEngine.Events.UnityEvent.Invoke () (at /Users/bokken/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent/UnityEvent_0.cs:58)
UnityEngine.UI.Button.Press () (at Library/PackageCache/[email protected]/Runtime/UI/Core/Button.cs:70)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/[email protected]/Runtime/UI/Core/Button.cs:114)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/[email protected]/Runtime/EventSystem/ExecuteEvents.cs:57)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at Library/PackageCache/[email protected]/Runtime/EventSystem/ExecuteEvents.cs:272)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/[email protected]/Runtime/EventSystem/EventSystem.cs:501)

Connect to devnet, get an airdrop, click copy private key:
NullReferenceException: Object reference not set to an instance of an object
Solana.Unity.SDK.Example.WalletScreen.SavePrivateKeyOnClick () (at Assets/Samples/Solana SDK/0.0.9/Simple Wallet/Solana Wallet/Scripts/example/screens/WalletScreen.cs:119)
UnityEngine.Events.InvokableCall.Invoke () (at /Users/bokken/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent.cs:178)
UnityEngine.Events.UnityEvent.Invoke () (at /Users/bokken/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent/UnityEvent_0.cs:58)
UnityEngine.UI.Button.Press () (at Library/PackageCache/[email protected]/Runtime/UI/Core/Button.cs:70)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/[email protected]/Runtime/UI/Core/Button.cs:114)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/[email protected]/Runtime/EventSystem/ExecuteEvents.cs:57)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at Library/PackageCache/[email protected]/Runtime/EventSystem/ExecuteEvents.cs:272)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/[email protected]/Runtime/EventSystem/EventSystem.cs:501)

image

Every click on sign in with phantom creates a new websocket dispatcher. (I know it doesnt work in editor, but still dont need these probably :D )

Clicking on connect with twitter created a new game web 3 auth game object which points to mainnet but the config in the wallet controller sais testnet
image

After logout the dropdown for networks does not work anymore.

Wallet constructor with private key as param.

Would be nice to have a way to login in my game using the priovate key, not the mnemonics.

The solution is a new constructor for the Wallet classlike below:
Wallet(string privatekey)
or
Wallet(byte[] privatekeyByteArray)

[Bug] Failed to find entry points: System.Exception:

Describe the bug
When I install the package I get a compiler error in unity that says "Failed to find entry points"

To Reproduce
Create a new empty 2D Core unity project using Unity 2022.2.8f1. Install the solana_unity package using github link (v0.0.6).
You will see the error and you cant play any scenes in your project.

Expected behavior
I should not see any compilation errors in the Unity editor as I haven't written any scripts yet or created any objects. Just installing the package breaks the projects

Desktop (please complete the following information):

  • MAC OS Monterey version 12.6

** Full Error code **

Failed to find entry-points:
System.Exception: Unexpected exception while collecting types in assembly Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly:
'Solana.Unity.Rpc, Version=2.6.0.11, Culture=neutral, PublicKeyToken=null'
at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00105] in :0
at zzzUnity.Burst.CodeGen.AssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00039] in :0
at Burst.Compiler.IL.AssemblyLoader.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00079] in :0
at Mono.Cecil.MetadataResolver.Resolve (Mono.Cecil.TypeReference type) [0x00038] in :0
at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference type) [0x00006] in :0
at Mono.Cecil.TypeReference.Resolve () [0x00006] in :0
at Burst.Compiler.IL.Server.EntryPointMethodFinder.CollectGenericTypeInstances (Mono.Cecil.TypeReference type, System.Collections.Generic.List1[T] types, System.Collections.Generic.HashSet1[T] visited) [0x0002f] in :0
at Burst.Compiler.IL.Server.EntryPointMethodFinder.CollectGenericTypeInstances (Mono.Cecil.AssemblyDefinition assembly, System.Collections.Generic.List1[T] types, System.Collections.Generic.HashSet1[T] visited) [0x00057] in :0
at Burst.Compiler.IL.Server.EntryPointMethodFinder.FindEntryPoints (System.String[] rootAssemblyNames, Burst.Compiler.IL.Hashing.CacheRuntime.HashCacheAssemblyStore assemblyStore, Burst.Compiler.IL.AssemblyLoader assemblyLoader, Burst.Compiler.IL.NativeCompilerOptions options, Burst.Compiler.IL.Server.ProfileDelegate profileCallback, System.Boolean includeRootAssemblyReferences, System.Boolean splitTargets, Burst.Compiler.IL.Helpers.DebugLogWriter debugWriter) [0x0019d] in :0
--- End of inner exception stack trace ---
at Burst.Compiler.IL.Server.EntryPointMethodFinder.FindEntryPoints (System.String[] rootAssemblyNames, Burst.Compiler.IL.Hashing.CacheRuntime.HashCacheAssemblyStore assemblyStore, Burst.Compiler.IL.AssemblyLoader assemblyLoader, Burst.Compiler.IL.NativeCompilerOptions options, Burst.Compiler.IL.Server.ProfileDelegate profileCallback, System.Boolean includeRootAssemblyReferences, System.Boolean splitTargets, Burst.Compiler.IL.Helpers.DebugLogWriter debugWriter) [0x001d9] in :0
at Burst.Compiler.IL.Server.FindMethodsJob.Execute (Burst.Compiler.IL.Server.CompilerServerJobExecutionContext context) [0x00133] in :0

While compiling job:

Errors when calling Nft.TryGetNftData() method

I log in with the wallet, the tokens get correctly with GetTokenAccounts(), but when i try to:

Solana.Unity.SDK.Nft.Nft.TryGetNftData() it fails.

Unity version: 2021.3.11f1

public async UniTask GetNftFromWallet()
{
    WalletBase wallet = new SolanaWalletAdapterWebGL(options, RpcCluster.MainNet, "https://api.metaplex.solana.com/", null, true);
    await wallet.Login();

    // Get Tokens of wallet
    Solana.Unity.Rpc.Models.TokenAccount[] tokens = await wallet.GetTokenAccounts(Commitment.Confirmed);

    // Sort tokens in descending 
    var tokenAccounts = tokens.OrderByDescending(tk => tk.Account.Data.Parsed.Info.TokenAmount.AmountUlong);

    foreach (var item in tokenAccounts)
    {
        Solana.Unity.SDK.Nft.Nft.TryGetNftData(item.Account.Data.Parsed.Info.Mint, Web3.Instance.Wallet.ActiveRpcClient).AsUniTask().ContinueWith(nftData =>
        {

        }).Forget();
    }
}

The errors are:

Not implemented: Class::FromIl2CppType

MethodAccessException: Attempt to access method 'Solana.Unity.Rpc.IRpcClient.GetAccountInfoAsync' on type '' failed.
Rethrow as AggregateException: One or more errors occurred. (Attempt to access method 'Solana.Unity.Rpc.IRpcClient.GetAccountInfoAsync' on type '' failed.)
  at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00000] in <00000000000000000000000000000000>:0 
--- End of stack trace from previous location where exception was thrown ---

My gues is the error is from Packages/Solana Sdk/Runtime/codebase/nft/CandyMachineV2.cs in this line of code:

        public async Task<AccountResultWrapper<CandyMachine>> GetCandyMachineAsync(string accountAddress, Commitment commitment = Commitment.Finalized)
        {
      ->  var res = await RpcClient.GetAccountInfoAsync(accountAddress, commitment);
            if (!res.WasSuccessful)
                return new AccountResultWrapper<CandyMachine>(res);
            var resultingAccount = CandyMachine.Deserialize(Convert.FromBase64String(res.Result.Value.Data[0]));
            return new AccountResultWrapper<CandyMachine>(res, resultingAccount);
        }

But i do not know.

Login method from InGameWallet freezes the unity before to return the Account

Is your feature request related to a problem? Please describe.
The method Login does 2 things, first it unlocks the keystore using the provided password from the user. Second, it gets the account for the user. looks like the second task (GetAccount) freezes the unity and it's not possible to use in an async way.

Describe the solution you'd like
In order to avoid the freezing event and havingf a better feedbac kfor the user it's important to split the current Login method into to separate methods, one for the login and another just for the returning account. In this way the Logfijn would be a simple sync method. The GetAccount can be a async method and the developer can put it into a async workinglow avoind the problems with the unity API;.

Add phantom wallet adapter

Feature

  • Add support for login & transaction signature with Phantom wallet

  • Phantom integration through DeepLink. on mobile and js connection on WebGl

Additional context
Initial implementation in #9

[Bug] Deeplinks on IOS are not working any more

Describe the bug
Signing transactions via deeplink on IOS stopped working.
The error:
"Expected Signature Length to be equal to the number of required signatures".
On Android everything works fine.

To Reproduce
Create and transaction and try to sign it via deeplink phantom wallet on IOS.

Expected behavior
There is no error like on android

I asked in the phantom discord if there are any known problems for IOS. No answer so far.

I can not connect phantom from ingame[Bug]

This is the error I am receiving:

NotImplementedException: The method or operation is not implemented.
Solana.Unity.SDK.PhantomWallet._Login (System.String password) (at Library/PackageCache/com.solana.unity_sdk@40c9b4bd19/Runtime/codebase/PhantomWallet.cs:51)
Solana.Unity.SDK.WalletBase.Login (System.String password) (at Library/PackageCache/com.solana.unity_sdk@40c9b4bd19/Runtime/codebase/WalletBase.cs:76)
Solana.Unity.SDK.Web3.LoginPhantom () (at Library/PackageCache/com.solana.unity_sdk@40c9b4bd19/Runtime/codebase/Web3.cs:77)
Solana.Unity.SDK.Example.LoginScreen.LoginCheckerPhantom () (at Assets/Samples/Solana SDK/0.0.7/Simple Wallet/Solana

[Bug] MetaPlexData is missing animation_url

Describe the bug
When loading NFT meta data the animation url is not parsed because its not a field in the json data

Expected behavior
Animation url is parsed when it is set in the NFT meta data

I will create a pr for this

[Bug] WebGL Adapters do not return

Describe the bug
I think this is more enhancement than bug, but in jslib files, in catch block, or else block, there is not returning anything, which is not best pattern to do so. For example in this function:

if (Web3.Instance == null) return;
var account = await Web3.Instance.LoginXNFT();
if (account != null)
{
    accountManager.SetActive(true);
} else
{
    walletManager.gameObject.SetActive(true);
}

It never goes to the if block, because LoginXNFT does not return anything and it should return null if login is not possible.

To Reproduce
Just run above function and try to log in with webgl without xnft wallet. It will never go to the line after await.

Expected behavior
Expected behavior would be to return null instead of wait endlessly.

WebGL (please complete the following information):
It only happens on webGL, because in other platforms it returns null.

P.S.: I've seen how you handle it in demo project, but still think it's not the best solution.

[Bug] Cannot build with WebGL master version

Describe the bug
A clear and concise description of what the bug is.

Getting a build error trying your master version

To Reproduce
Steps to reproduce the behavior:

Steps to reproduce it in MacOS Monterey version.
Unity hub 3.4.1 and version 2021.3.16f1.

Create project
3D Core
Window > Package manager > import using GIT
Import solana using https://github.com/garbles-labs/Solana.Unity-SDK.git
Samples > Simple Wallet Import
Open wallet_scene
TMP importer pop up > Import TMP essentials
File > Build settings > Add open scenes
Webgl > Switch platform
Player settings > Uncheck Auto Graphics API (because it tells you cannot use Color space Linear with Webgl1)
Close player settings
Build and run.

Expected behavior
A clear and concise description of what you expected to happen.

Have the built project

Screenshots
If applicable, add screenshots to help explain your problem.

Screenshot

Desktop (please complete the following information):

  • OS: [e.g. iOS] MacOS
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Compile a cross-platform websockets library

Describe the solution you'd like
For SMS, Account/Transaction subscription, fixing the Streaming RPC client we need a websocket that works cross-platform.

  • Built a single assembly (e.g.: websocket-sharp-unity.dll) that contains an interface for use and hide cross-platform complexity.

Describe alternatives you've considered
Combination of websocket-sharp for NoWebGL and NativeWebSocket for WebGL seems to work on all the platform.

See #32 for additional context.

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.