Skip to content

Commit 30c3d7f

Browse files
⚡ Add Wallet Adapter wrapper & improvements (#101)
Add Wallet Adapter wrapper (Mobile/WebGL) & Improvements
1 parent d9a5600 commit 30c3d7f

File tree

10 files changed

+248
-72
lines changed

10 files changed

+248
-72
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!1 &5903901361556689692
4+
GameObject:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
serializedVersion: 6
10+
m_Component:
11+
- component: {fileID: 5903901361556689694}
12+
- component: {fileID: 42048107343790436}
13+
- component: {fileID: 5903901361556689688}
14+
m_Layer: 0
15+
m_Name: '[WalletController]'
16+
m_TagString: Untagged
17+
m_Icon: {fileID: 0}
18+
m_NavMeshLayer: 0
19+
m_StaticEditorFlags: 0
20+
m_IsActive: 1
21+
--- !u!4 &5903901361556689694
22+
Transform:
23+
m_ObjectHideFlags: 0
24+
m_CorrespondingSourceObject: {fileID: 0}
25+
m_PrefabInstance: {fileID: 0}
26+
m_PrefabAsset: {fileID: 0}
27+
m_GameObject: {fileID: 5903901361556689692}
28+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
29+
m_LocalPosition: {x: 523.5468, y: 236.58032, z: -101.23384}
30+
m_LocalScale: {x: 1, y: 1, z: 1}
31+
m_ConstrainProportionsScale: 0
32+
m_Children: []
33+
m_Father: {fileID: 0}
34+
m_RootOrder: 0
35+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
36+
--- !u!114 &42048107343790436
37+
MonoBehaviour:
38+
m_ObjectHideFlags: 0
39+
m_CorrespondingSourceObject: {fileID: 0}
40+
m_PrefabInstance: {fileID: 0}
41+
m_PrefabAsset: {fileID: 0}
42+
m_GameObject: {fileID: 5903901361556689692}
43+
m_Enabled: 1
44+
m_EditorHideFlags: 0
45+
m_Script: {fileID: 11500000, guid: fbd7daddfbeaa44729a122a269ac8fb5, type: 3}
46+
m_Name:
47+
m_EditorClassIdentifier:
48+
--- !u!114 &5903901361556689688
49+
MonoBehaviour:
50+
m_ObjectHideFlags: 0
51+
m_CorrespondingSourceObject: {fileID: 0}
52+
m_PrefabInstance: {fileID: 0}
53+
m_PrefabAsset: {fileID: 0}
54+
m_GameObject: {fileID: 5903901361556689692}
55+
m_Enabled: 1
56+
m_EditorHideFlags: 0
57+
m_Script: {fileID: 11500000, guid: b75a4e92c14884ea6bf3e46d07a33eb0, type: 3}
58+
m_Name:
59+
m_EditorClassIdentifier:
60+
rpcCluster: 0
61+
customRpc: https://red-boldest-uranium.solana-mainnet.quiknode.pro/190d71a30ba3170f66df5e49c8c88870737cd5ce/
62+
autoConnectOnStartup: 1
63+
webSocketsRpc:
64+
web3AuthWalletOptions:
65+
appName: Solana Unity SDK
66+
logoLight:
67+
logoDark:
68+
defaultLanguage: en
69+
dark: 1
70+
themeName: primary
71+
themeColor: '#123456'
72+
redirectUrl: torusapp://com.torus.Web3AuthUnity/auth
73+
clientId: BO4zGEzyV6DT1vHU46b6GEngOcg2jl5Pmd9Boi8dLdBpBZnS351ulHDz2k7XJ1dEm-DcvyyARivGCZDXrbZng-0
74+
network: 0
75+
phantomWalletOptions:
76+
phantomApiVersion: v1
77+
appMetaDataUrl: https://github.com/garbles-labs/Solana.Unity-SDK
78+
deeplinkUrlScheme: unitydl
79+
solanaWalletAdapterOptions:
80+
solanaMobileWalletAdapterOptions:
81+
identityUri: https://solana.unity-sdk.gg/
82+
iconUri: /favicon.ico
83+
name: Solana.Unity-SDK
84+
keepConnectionAlive: 1
85+
solanaWalletAdapterWebGLOptions:
86+
walletAdapterButtonPrefab: {fileID: 0}
87+
walletAdapterUIPrefab: {fileID: 0}
88+
phantomWalletOptions:
89+
phantomApiVersion: v1
90+
appMetaDataUrl: https://github.com/garbles-labs/Solana.Unity-SDK
91+
deeplinkUrlScheme: unitydl

Runtime/codebase/Prefabs/[WalletController].prefab.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/codebase/SolanaMobileWalletAdapter.cs renamed to Runtime/codebase/SolanaMobileStack/SolanaMobileWalletAdapter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class SolanaMobileWalletAdapterOptions
2121
}
2222

2323

24+
[Obsolete("Use SolanaWalletAdapter class instead, which is the cross platform wrapper.")]
2425
public class SolanaMobileWalletAdapter : WalletBase
2526
{
2627
private readonly SolanaMobileWalletAdapterOptions _walletOptions;
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using Solana.Unity.Rpc.Models;
4+
using Solana.Unity.Wallet;
5+
6+
// ReSharper disable once CheckNamespace
7+
8+
namespace Solana.Unity.SDK
9+
{
10+
11+
[Serializable]
12+
public class SolanaWalletAdapterOptions
13+
{
14+
public SolanaMobileWalletAdapterOptions solanaMobileWalletAdapterOptions;
15+
public SolanaWalletAdapterWebGLOptions solanaWalletAdapterWebGLOptions;
16+
public PhantomWalletOptions phantomWalletOptions;
17+
}
18+
19+
public class SolanaWalletAdapter: WalletBase
20+
{
21+
private readonly WalletBase _internalWallet;
22+
23+
public SolanaWalletAdapter(SolanaWalletAdapterOptions options, RpcCluster rpcCluster = RpcCluster.DevNet, string customRpcUri = null, string customStreamingRpcUri = null, bool autoConnectOnStartup = false) : base(rpcCluster, customRpcUri, customStreamingRpcUri, autoConnectOnStartup)
24+
{
25+
#if UNITY_ANDROID
26+
#pragma warning disable CS0618
27+
_internalWallet = new SolanaMobileWalletAdapter(options.solanaMobileWalletAdapterOptions, rpcCluster, customRpcUri, customStreamingRpcUri, autoConnectOnStartup);
28+
#elif UNITY_WEBGL
29+
#pragma warning disable CS0618
30+
_internalWallet = new SolanaWalletAdapterWebGL(options.solanaWalletAdapterWebGLOptions, rpcCluster, customRpcUri, customStreamingRpcUri, autoConnectOnStartup);
31+
#elif UNITY_IOS
32+
#pragma warning disable CS0618
33+
_internalWallet = new PhantomDeepLink(options.phantomWalletOptions, rpcCluster, customRpcUri, customStreamingRpcUri, autoConnectOnStartup);
34+
#else
35+
#endif
36+
}
37+
38+
protected override Task<Account> _Login(string password = null)
39+
{
40+
if (_internalWallet != null)
41+
return _internalWallet.Login(password);
42+
throw new NotImplementedException();
43+
}
44+
45+
protected override Task<Transaction> _SignTransaction(Transaction transaction)
46+
{
47+
if (_internalWallet != null)
48+
return _internalWallet.SignTransaction(transaction);
49+
throw new NotImplementedException();
50+
}
51+
52+
protected override Task<Transaction[]> _SignAllTransactions(Transaction[] transactions)
53+
{
54+
if (_internalWallet != null)
55+
return _internalWallet.SignAllTransactions(transactions);
56+
throw new NotImplementedException();
57+
}
58+
59+
public override Task<byte[]> SignMessage(byte[] message)
60+
{
61+
if (_internalWallet != null)
62+
return _internalWallet.SignMessage(message);
63+
throw new NotImplementedException();
64+
}
65+
66+
protected override Task<Account> _CreateAccount(string mnemonic = null, string password = null)
67+
{
68+
throw new NotImplementedException();
69+
}
70+
}
71+
}

Runtime/codebase/SolanaWalletAdapter.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/codebase/SolanaWalletAdapterWebGL/SolanaWalletAdapterWebGL.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public class WalletSpecsObject
5555
private static WalletSpecs _currentWallet;
5656

5757

58+
[Obsolete("Use SolanaWalletAdapter class instead, which is the cross platform wrapper.")]
5859
public SolanaWalletAdapterWebGL(
5960
SolanaWalletAdapterWebGLOptions solanaWalletOptions,
6061
RpcCluster rpcCluster = RpcCluster.DevNet,

0 commit comments

Comments
 (0)