diff --git a/Assembly-CSharp.csproj b/Assembly-CSharp.csproj index 8b8ecbe..0d7eac6 100644 --- a/Assembly-CSharp.csproj +++ b/Assembly-CSharp.csproj @@ -115,8 +115,8 @@ - + diff --git a/Assets/ParticleNetwork/Mobile/Demo/ParticleNetworkSDKDemo.cs b/Assets/ParticleNetwork/Mobile/Demo/ParticleNetworkSDKDemo.cs index d795a21..c55ff20 100644 --- a/Assets/ParticleNetwork/Mobile/Demo/ParticleNetworkSDKDemo.cs +++ b/Assets/ParticleNetwork/Mobile/Demo/ParticleNetworkSDKDemo.cs @@ -4,6 +4,7 @@ using Network.Particle.Scripts.Core; using Network.Particle.Scripts.Model; using Network.Particle.Scripts.Test; +using Newtonsoft.Json.Linq; using UnityEngine; public class ParticleNetworkSDKDemo : MonoBehaviour @@ -29,5 +30,4 @@ private void Init() // control how to show set master password and payment password. // ParticleNetwork.SetSecurityAccountConfig(new SecurityAccountConfig(0, 0)); } - -} +} \ No newline at end of file diff --git a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/ErrorException.cs b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/ErrorException.cs deleted file mode 100644 index 3a600b6..0000000 --- a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/ErrorException.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -namespace Plugins.WebGL.ParticleAuthWebGL.Share -{ - public class ErrorException : Exception - { - public int Code { get; } - - public ErrorException(int code, string message) : base(message) - { - Code = code; - } - - public ErrorException(int code, string message, Exception innerException) : base(message, innerException) - { - Code = code; - } - } -} \ No newline at end of file diff --git a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/ErrorException.cs.meta b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/ErrorException.cs.meta deleted file mode 100644 index 4cd86b2..0000000 --- a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/ErrorException.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: f1622bd3c1e64e80b2b36a7521f102c4 -timeCreated: 1725966911 \ No newline at end of file diff --git a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/InitConfig.cs b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/InitConfig.cs index ce73594..e74f5a3 100644 --- a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/InitConfig.cs +++ b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/InitConfig.cs @@ -152,4 +152,19 @@ public LoginConfig(string preferredAuthType, string account, bool? hideLoading, this.socialLoginPrompt = socialLoginPrompt; this.authorization = authorization; } +} + +public class ErrorException : Exception +{ + public int Code { get; } + + public ErrorException(int code, string message) : base(message) + { + Code = code; + } + + public ErrorException(int code, string message, Exception innerException) : base(message, innerException) + { + Code = code; + } } \ No newline at end of file diff --git a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/ParticleAuth.cs b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/ParticleAuth.cs index 86e8b8b..fddf9ef 100644 --- a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/ParticleAuth.cs +++ b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/ParticleAuth.cs @@ -9,7 +9,6 @@ using Network.Particle.Scripts.Model; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using Plugins.WebGL.ParticleAuthWebGL.Share; public class ParticleAuth : MonoBehaviour @@ -81,13 +80,13 @@ public class ParticleAuth : MonoBehaviour private static extern void ParticleSolanaSignAndSendTransaction(string transaction); [DllImport("__Internal")] - private static extern void ParticleSolanasSignMessage(string message); + private static extern void ParticleSolanaSignMessage(string message); [DllImport("__Internal")] - private static extern void ParticleSolanasSignTransaction(string transaction); + private static extern void ParticleSolanaSignTransaction(string transaction); [DllImport("__Internal")] - private static extern void ParticleSolanasSignAllTransactions(string[] transaction); + private static extern void ParticleSolanaSignAllTransactions(string json); public static ParticleAuth Instance; @@ -102,9 +101,9 @@ public class ParticleAuth : MonoBehaviour private TaskCompletionSource evmSignTypedDataTask; private TaskCompletionSource evmSignTypedDataUniqTask; private TaskCompletionSource solanaSignAndSendTransactionTask; - private TaskCompletionSource solanasSignMessageTask; - private TaskCompletionSource solanasSignTransactionTask; - private TaskCompletionSource> solanasSignAllTransactionsTask; + private TaskCompletionSource solanaSignMessageTask; + private TaskCompletionSource solanaSignTransactionTask; + private TaskCompletionSource> solanaSignAllTransactionsTask; void Awake() @@ -137,9 +136,9 @@ public void InitWithJsonString(string json) var chainName = (string)JObject.Parse(json)["chainName"]; var chainId = (long)JObject.Parse(json)["chainId"]; var chainInfo = ChainInfo.GetChain(chainId, chainName); - var projectId = (string)JObject.Parse(json)["projectId"]; - var clientKey = (string)JObject.Parse(json)["clientKey"]; - var appId = (string)JObject.Parse(json)["appId"]; + var projectId = (string)JObject.Parse(json)["projectId"]; + var clientKey = (string)JObject.Parse(json)["clientKey"]; + var appId = (string)JObject.Parse(json)["appId"]; SetInnerConfig(projectId, clientKey, appId, chainInfo); InitParticleAuth(json); } @@ -150,6 +149,7 @@ private void SetInnerConfig(string projectId, string clientKey, string appId, Ch { throw new ErrorException(0, "Init config is wrong"); } + ParticleUnityRpc.projectId = projectId; ParticleUnityRpc.appId = appId; ParticleUnityRpc.clientKey = clientKey; @@ -406,40 +406,41 @@ public void OnSolanaSignAndSendTransaction(string json) HandleSignResult(json, solanaSignAndSendTransactionTask); } - public Task SolanasSignMessage(string transaction) + public Task SolanaSignMessage(string transaction) { - solanasSignMessageTask = new TaskCompletionSource(); - ParticleSolanasSignMessage(transaction); - return solanasSignMessageTask.Task; + solanaSignMessageTask = new TaskCompletionSource(); + ParticleSolanaSignMessage(transaction); + return solanaSignMessageTask.Task; } - public void OnSolanasSignMessage(string json) + public void OnSolanaSignMessage(string json) { - HandleSignResult(json, solanasSignMessageTask); + HandleSignResult(json, solanaSignMessageTask); } - public Task SolanasSignTransaction(string transaction) + public Task SolanaSignTransaction(string transaction) { - solanasSignTransactionTask = new TaskCompletionSource(); - ParticleSolanasSignTransaction(transaction); - return solanasSignTransactionTask.Task; + solanaSignTransactionTask = new TaskCompletionSource(); + ParticleSolanaSignTransaction(transaction); + return solanaSignTransactionTask.Task; } - public void OnSolanasSignTransaction(string json) + public void OnSolanaSignTransaction(string json) { - HandleSignResult(json, solanasSignTransactionTask); + HandleSignResult(json, solanaSignTransactionTask); } - public Task> SolanasSignAllTransactions(string[] transactions) + public Task> SolanaSignAllTransactions(string[] transactions) { - solanasSignAllTransactionsTask = new TaskCompletionSource>(); - ParticleSolanasSignAllTransactions(transactions); - return solanasSignAllTransactionsTask.Task; + solanaSignAllTransactionsTask = new TaskCompletionSource>(); + var json = JsonConvert.SerializeObject(transactions); + ParticleSolanaSignAllTransactions(json); + return solanaSignAllTransactionsTask.Task; } - public void OnSolanasSignAllTransactions(string json) + public void OnSolanaSignAllTransactions(string json) { - HandleSignResult(json, solanasSignAllTransactionsTask); + HandleSignResult(json, solanaSignAllTransactionsTask); } private void HandleSignResult(string json, TaskCompletionSource task) diff --git a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Model/TestAccount.cs b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Helper/TestAccount.cs similarity index 100% rename from ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Model/TestAccount.cs rename to ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Helper/TestAccount.cs diff --git a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Model/TestAccount.cs.meta b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Helper/TestAccount.cs.meta similarity index 100% rename from ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Model/TestAccount.cs.meta rename to ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Helper/TestAccount.cs.meta diff --git a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Model/ChainInfo.cs b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Model/ChainInfo.cs index fc0bfed..321ba5b 100644 --- a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Model/ChainInfo.cs +++ b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Model/ChainInfo.cs @@ -116,7 +116,7 @@ public ChainInfo(long id, string name, string chainType, string icon, string ful "https://static.particle.network/token-list/elastos/native.png", "Elastos Mainnet", "Mainnet", - "http://elastos.org", + "https://elastos.org", new NativeCurrency("ELA", "ELA", 18), "https://api.elastos.io/esc", "https://esc.elastos.io", @@ -413,24 +413,6 @@ public ChainInfo(long id, string name, string chainType, string icon, string ful ); - public static ChainInfo Heco => _heco; - - private static ChainInfo _heco = new ChainInfo( - 128, - "Heco", - "evm", - "https://static.particle.network/token-list/heco/native.png", - "Heco Mainnet", - "Mainnet", - "https://www.hecochain.com", - new NativeCurrency("HT", "HT", 18), - "https://http-mainnet.hecochain.com", - "https://hecoinfo.com", - new List() { new Feature("EIP1559")}, - null - ); - - public static ChainInfo Polygon => _polygon; private static ChainInfo _polygon = new ChainInfo( @@ -989,6 +971,42 @@ public ChainInfo(long id, string name, string chainType, string icon, string ful ); + public static ChainInfo StoryNetworkTestnet => _storynetworktestnet; + + private static ChainInfo _storynetworktestnet = new ChainInfo( + 1513, + "StoryNetwork", + "evm", + "https://static.particle.network/token-list/storynetwork/native.png", + "Story Network Testnet", + "Testnet", + "https://explorer.testnet.storyprotocol.net", + new NativeCurrency("IP", "IP", 18), + "https://rpc.partner.testnet.storyprotocol.net", + "https://explorer.testnet.storyprotocol.net", + new List() { new Feature("EIP1559")}, + null + ); + + + public static ChainInfo GravityAlpha => _gravityalpha; + + private static ChainInfo _gravityalpha = new ChainInfo( + 1625, + "Gravity", + "evm", + "https://static.particle.network/token-list/gravity/native.png", + "Gravity Alpha Mainnet", + "Mainnet", + "https://gravity.xyz", + new NativeCurrency("G", "G", 18), + "https://rpc.gravity.xyz", + "https://gscan.xyz", + new List() { new Feature("EIP1559")}, + null + ); + + public static ChainInfo ComboTestnet => _combotestnet; private static ChainInfo _combotestnet = new ChainInfo( @@ -1007,6 +1025,24 @@ public ChainInfo(long id, string name, string chainType, string icon, string ful ); + public static ChainInfo SoneiumMinatoTestnet => _soneiumminatotestnet; + + private static ChainInfo _soneiumminatotestnet = new ChainInfo( + 1946, + "Soneium", + "evm", + "https://static.particle.network/token-list/soneium/native.png", + "Soneium Minato Testnet", + "Testnet", + "https://soneium.org", + new NativeCurrency("ETH", "ETH", 18), + "https://rpc.minato.soneium.org", + "https://explorer-testnet.soneium.org", + new List() { new Feature("EIP1559")}, + null + ); + + public static ChainInfo KavaTestnet => _kavatestnet; private static ChainInfo _kavatestnet = new ChainInfo( @@ -1019,7 +1055,7 @@ public ChainInfo(long id, string name, string chainType, string icon, string ful "https://www.kava.io", new NativeCurrency("KAVA", "KAVA", 18), "https://evm.testnet.kava.io", - "http://testnet.kavascan.com", + "https://testnet.kavascan.com", null, "https://faucet.kava.io" ); @@ -1195,7 +1231,7 @@ public ChainInfo(long id, string name, string chainType, string icon, string ful "evm", "https://static.particle.network/token-list/astarzkevm/native.png", "Astar zkEVM Mainet", - "Mainet", + "Mainnet", "https://astar.network", new NativeCurrency("Sepolia Ether", "ETH", 18), "https://rpc.startale.com/astar-zkevm", @@ -1601,6 +1637,24 @@ public ChainInfo(long id, string name, string chainType, string icon, string ful ); + public static ChainInfo GravityAlphaTestnet => _gravityalphatestnet; + + private static ChainInfo _gravityalphatestnet = new ChainInfo( + 13505, + "Gravity", + "evm", + "https://static.particle.network/token-list/gravity/native.png", + "Gravity Alpha Testnet", + "Testnet", + "https://gravity.xyz", + new NativeCurrency("G", "G", 18), + "https://rpc-sepolia.gravity.xyz", + " https://explorer-sepolia.gravity.xyz", + new List() { new Feature("EIP1559")}, + null + ); + + public static ChainInfo EOSEVMTestnet => _eosevmtestnet; private static ChainInfo _eosevmtestnet = new ChainInfo( @@ -1901,12 +1955,30 @@ public ChainInfo(long id, string name, string chainType, string icon, string ful "https://www.zircuit.com", new NativeCurrency("Ether", "ETH", 18), "https://zircuit1.p2pify.com", - "https://explorer.zircuit.com", + "https://explorer.testnet.zircuit.com", new List() { new Feature("ERC4337")}, null ); + public static ChainInfo DODOChainTestnet => _dodochaintestnet; + + private static ChainInfo _dodochaintestnet = new ChainInfo( + 53457, + "DODOChain", + "evm", + "https://static.particle.network/token-list/dodochain/native.png", + "DODOChain Testnet", + "Testnet", + "https://www.dodochain.com", + new NativeCurrency("DODO", "DODO", 18), + "https://dodochain-testnet.alt.technology", + "https://testnet-scan.dodochain.com", + new List() { new Feature("EIP1559")}, + null + ); + + public static ChainInfo ZerooneTestnet => _zeroonetestnet; private static ChainInfo _zeroonetestnet = new ChainInfo( @@ -2177,6 +2249,24 @@ public ChainInfo(long id, string name, string chainType, string icon, string ful ); + public static ChainInfo DuckchainTestnet => _duckchaintestnet; + + private static ChainInfo _duckchaintestnet = new ChainInfo( + 202105, + "Duckchain", + "evm", + "https://static.particle.network/token-list/duckchain/native.png", + "Duckchain Testnet", + "Testnet", + "https://testnet-scan.duckchain.io", + new NativeCurrency("TON", "TON", 18), + "https://testnet-rpc.duckchain.io", + "https://testnet-scan.duckchain.io", + new List() { new Feature("EIP1559")}, + null + ); + + public static ChainInfo PlatON => _platon; private static ChainInfo _platon = new ChainInfo( @@ -2483,6 +2573,24 @@ public ChainInfo(long id, string name, string chainType, string icon, string ful ); + public static ChainInfo PlumeTestnet => _plumetestnet; + + private static ChainInfo _plumetestnet = new ChainInfo( + 161221135, + "Plume", + "evm", + "https://static.particle.network/token-list/plume/native.png", + "Plume Testnet", + "Testnet", + "https://testnet-explorer.plumenetwork.xyz", + new NativeCurrency("ETH", "ETH", 18), + "https://testnet-rpc.plumenetwork.xyz/http", + "https://testnet-explorer.plumenetwork.xyz", + new List() { new Feature("EIP1559")}, + null + ); + + public static ChainInfo BlastSepolia => _blastsepolia; private static ChainInfo _blastsepolia = new ChainInfo( @@ -2681,24 +2789,6 @@ public ChainInfo(long id, string name, string chainType, string icon, string ful ); - public static ChainInfo GMNetworkTestnet => _gmnetworktestnet; - - private static ChainInfo _gmnetworktestnet = new ChainInfo( - 202402181627, - "GMNetwork", - "evm", - "https://static.particle.network/token-list/gmnetwork/native.png", - "GM Network Testnet", - "Testnet", - "https://gmnetwork.ai", - new NativeCurrency("Ether", "ETH", 18), - "https://gmnetwork-testnet.alt.technology", - "https://gmnetwork-testnet-explorer.alt.technology", - new List() { new Feature("EIP1559")}, - null - ); - - private static Dictionary < string, ChainInfo > ParticleChains = new Dictionary () { @@ -2742,8 +2832,6 @@ public ChainInfo(long id, string name, string chainType, string icon, string ful {"fuse-123" , FuseTestnet }, - {"heco-128" , Heco }, - {"polygon-137" , Polygon }, {"manta-169" , Manta }, @@ -2806,8 +2894,14 @@ public ChainInfo(long id, string name, string chainType, string icon, string ful {"bevm-1502" , BEVMCanaryTestnet }, + {"storynetwork-1513" , StoryNetworkTestnet }, + + {"gravity-1625" , GravityAlpha }, + {"combo-1715" , ComboTestnet }, + {"soneium-1946" , SoneiumMinatoTestnet }, + {"kava-2221" , KavaTestnet }, {"kava-2222" , Kava }, @@ -2874,6 +2968,8 @@ public ChainInfo(long id, string name, string chainType, string icon, string ful {"immutable-13473" , ImmutablezkEVMTestnet }, + {"gravity-13505" , GravityAlphaTestnet }, + {"eosevm-15557" , EOSEVMTestnet }, {"ethereum-17000" , EthereumHolesky }, @@ -2908,6 +3004,8 @@ public ChainInfo(long id, string name, string chainType, string icon, string ful {"zircuit-48899" , ZircuitTestnet }, + {"dodochain-53457" , DODOChainTestnet }, + {"zeroone-56400" , ZerooneTestnet }, {"linea-59141" , LineaSepolia }, @@ -2938,6 +3036,8 @@ public ChainInfo(long id, string name, string chainType, string icon, string ful {"bitlayer-200901" , Bitlayer }, + {"duckchain-202105" , DuckchainTestnet }, + {"platon-210425" , PlatON }, {"arbitrum-421614" , ArbitrumSepolia }, @@ -2972,6 +3072,8 @@ public ChainInfo(long id, string name, string chainType, string icon, string ful {"cyber-111557560" , CyberTestnet }, + {"plume-161221135" , PlumeTestnet }, + {"blast-168587773" , BlastSepolia }, {"tron-728126428" , Tron }, @@ -2993,8 +3095,6 @@ public ChainInfo(long id, string name, string chainType, string icon, string ful {"tron-2494104990" , TronShasta }, {"tron-3448148188" , TronNile }, - - {"gmnetwork-202402181627" , GMNetworkTestnet }, }; // template code end [CanBeNull] public static ChainInfo GetChain(long chainId, string chainName) diff --git a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/UnityRpc/UnityInnerChainInfo.cs b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/UnityRpc/UnityInnerChainInfo.cs index 70f9e8d..8f90867 100644 --- a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/UnityRpc/UnityInnerChainInfo.cs +++ b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/UnityRpc/UnityInnerChainInfo.cs @@ -1,8 +1,4 @@ -using Network.Particle.Scripts.Core.Utils; using Network.Particle.Scripts.Model; -using Newtonsoft.Json.Linq; -using UnityEngine; -using UnityEngine.Assertions; namespace Network.Particle.Scripts.Core { @@ -12,28 +8,7 @@ public static class UnityInnerChainInfo public static ChainInfo GetChainInfo() { - var resultJson = ""; - -#if UNITY_ANDROID && !UNITY_EDITOR - Assert.IsNotNull(currChainInfo, "currChainInfo is null, you must call ParticleNetwork.Init() first"); - resultJson = ParticleNetwork.GetUnityBridgeClass().CallStatic("getChainInfo"); - - Debug.Log($"GetChainInfo json: {resultJson}"); - var data = JObject.Parse(resultJson); - var chainInfo = ChainUtils.FindChain(data["chain_name"].ToString(), (int)data["chain_id"]); - return chainInfo; -#elif UNITY_IOS && !UNITY_EDITOR - Assert.IsNotNull(currChainInfo, "currChainInfo is null, you must call ParticleNetwork.Init() first"); - resultJson = ParticleNetworkIOSBridge.getChainInfo(); - - Debug.Log($"GetChainInfo json: {resultJson}"); - var data = JObject.Parse(resultJson); - var chainInfo = ChainUtils.FindChain(data["chain_name"].ToString(), (int)data["chain_id"]); - return chainInfo; -#else - return currChainInfo; -#endif } public static void SetChainInfo(ChainInfo chainInfo) diff --git a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Utils.meta b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Utils.meta deleted file mode 100644 index 65bfc33..0000000 --- a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Utils.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: e942d1cc1fd145339b41ff1a49b069db -timeCreated: 1662540462 \ No newline at end of file diff --git a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Utils/ChainUtils.cs b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Utils/ChainUtils.cs deleted file mode 100644 index 706bfdb..0000000 --- a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Utils/ChainUtils.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Network.Particle.Scripts.Model; - -namespace Network.Particle.Scripts.Core.Utils -{ - public class ChainUtils - { - public static ChainInfo FindChain(string chainNameString, long chainId) - { - var chainInfo = ChainInfo.GetEvmChain(chainId); - if (chainInfo != null) - { - return chainInfo; - } - - chainInfo = ChainInfo.GetSolanaChain(chainId); - - if (chainInfo != null) - { - return chainInfo; - } - - return ChainInfo.Ethereum; - } - } -} \ No newline at end of file diff --git a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Utils/ChainUtils.cs.meta b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Utils/ChainUtils.cs.meta deleted file mode 100644 index d093b0d..0000000 --- a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Utils/ChainUtils.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: d2c79090463d4b70934345a86833852a -timeCreated: 1662540469 \ No newline at end of file diff --git a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Utils/HexTool.cs b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Utils/HexTool.cs deleted file mode 100644 index 88d99eb..0000000 --- a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Utils/HexTool.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Text; -using System.Text.RegularExpressions; - -public class HexUtils -{ - public static bool IsHexadecimal(string value) - { - return Regex.IsMatch(value, @"\A\b0x[0-9a-fA-F]+\b\Z"); - } - - public static string ConvertHex(string message) - { - var serialized = BitConverter.ToString(Encoding.Default.GetBytes(message)); - serialized = serialized.Replace("-", ""); - return "0x" + serialized; - } -} \ No newline at end of file diff --git a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Utils/HexTool.cs.meta b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Utils/HexTool.cs.meta deleted file mode 100644 index a3a383f..0000000 --- a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/Share/Utils/HexTool.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 4f77f31a617d41e1977e789d99eaf1c5 -timeCreated: 1690965708 \ No newline at end of file diff --git a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/particleAuth.jslib b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/particleAuth.jslib index f3f673a..533fd4b 100644 --- a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/particleAuth.jslib +++ b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/particleAuth.jslib @@ -169,33 +169,37 @@ mergeInto(LibraryManager.library, { } }, - ParticleSolanasSignMessage: async function (options) { + ParticleSolanaSignMessage: async function (options) { const message = UTF8ToString(options); try { const signature = (await window.particle.solana.signMessage(message)).toString('base64'); - SendMessage('ParticleAuth', 'OnSolanasSignMessage', JSON.stringify({ signature })); + SendMessage('ParticleAuth', 'OnSolanaSignMessage', JSON.stringify({ signature })); } catch (error) { - SendMessage('ParticleAuth', 'OnSolanasSignMessage', JSON.stringify({ error })); + SendMessage('ParticleAuth', 'OnSolanaSignMessage', JSON.stringify({ error })); } }, - ParticleSolanasSignTransaction: async function (options) { + ParticleSolanaSignTransaction: async function (options) { const message = UTF8ToString(options); try { const signature = (await window.particle.solana.signTransaction(message)).toString('base64'); - SendMessage('ParticleAuth', 'OnSolanasSignTransaction', JSON.stringify({ signature })); + SendMessage('ParticleAuth', 'OnSolanaSignTransaction', JSON.stringify({ signature })); } catch (error) { - SendMessage('ParticleAuth', 'OnSolanasSignTransaction', JSON.stringify({ error })); + SendMessage('ParticleAuth', 'OnSolanaSignTransaction', JSON.stringify({ error })); } }, - ParticleSolanasSignAllTransactions: async function (options) { + ParticleSolanaSignAllTransactions: async function (options) { const message = UTF8ToString(options); try { - const signature = (await window.particle.solana.signAllTransactions(message)).toString('base64'); - SendMessage('ParticleAuth', 'OnSolanasSignAllTransactions', JSON.stringify({ signature })); + let signature = (await window.particle.solana.signAllTransactions(JSON.parse(message))); + signature = signature.map(signature => { + return signature.toString('base64') + }); + + SendMessage('ParticleAuth', 'OnSolanaSignAllTransactions', JSON.stringify({ signature })); } catch (error) { - SendMessage('ParticleAuth', 'OnSolanasSignAllTransactions', JSON.stringify({ error })); + SendMessage('ParticleAuth', 'OnSolanaSignAllTransactions', JSON.stringify({ error })); } }, }); diff --git a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Scenes/SampleScene.unity b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Scenes/SampleScene.unity index 6ee28f1..f5d848c 100644 --- a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Scenes/SampleScene.unity +++ b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Scenes/SampleScene.unity @@ -1500,63 +1500,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 458089296} m_CullTransparentMesh: 1 ---- !u!1001 &487161588 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 8070970354961720260, guid: d8d5883ca91354cacbeee698e897354e, type: 3} - propertyPath: m_Name - value: ParticleUnityRpc - objectReference: {fileID: 0} - - target: {fileID: 8070970354961720267, guid: d8d5883ca91354cacbeee698e897354e, type: 3} - propertyPath: m_RootOrder - value: 5 - objectReference: {fileID: 0} - - target: {fileID: 8070970354961720267, guid: d8d5883ca91354cacbeee698e897354e, type: 3} - propertyPath: m_LocalPosition.x - value: 866.7024 - objectReference: {fileID: 0} - - target: {fileID: 8070970354961720267, guid: d8d5883ca91354cacbeee698e897354e, type: 3} - propertyPath: m_LocalPosition.y - value: 1232.0088 - objectReference: {fileID: 0} - - target: {fileID: 8070970354961720267, guid: d8d5883ca91354cacbeee698e897354e, type: 3} - propertyPath: m_LocalPosition.z - value: -293.3122 - objectReference: {fileID: 0} - - target: {fileID: 8070970354961720267, guid: d8d5883ca91354cacbeee698e897354e, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 8070970354961720267, guid: d8d5883ca91354cacbeee698e897354e, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 8070970354961720267, guid: d8d5883ca91354cacbeee698e897354e, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 8070970354961720267, guid: d8d5883ca91354cacbeee698e897354e, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 8070970354961720267, guid: d8d5883ca91354cacbeee698e897354e, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 8070970354961720267, guid: d8d5883ca91354cacbeee698e897354e, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 8070970354961720267, guid: d8d5883ca91354cacbeee698e897354e, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: d8d5883ca91354cacbeee698e897354e, type: 3} --- !u!1 &528326213 GameObject: m_ObjectHideFlags: 0 diff --git a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Scripts/Demo.cs b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Scripts/Demo.cs index 9c30151..261b7b7 100644 --- a/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Scripts/Demo.cs +++ b/ParticleWebGLDemo/ParticleWebGLDemo/Assets/Scripts/Demo.cs @@ -39,10 +39,10 @@ public void Init() defaultWalletEntryPosition = new WalletEntryPosition { x = 0.0f, y = 0.0f }, supportChains = new List { - ChainInfo.EthereumSepolia + ChainInfo.SolanaDevnet } }; - var config = new InitConfig(projectId, clientKey, appId, ChainInfo.EthereumSepolia, securityAccount, + var config = new InitConfig(projectId, clientKey, appId, ChainInfo.SolanaDevnet, securityAccount, wallet); ParticleAuth.Instance.Init(config); @@ -186,7 +186,7 @@ public async void SolanaSignMessage() { // "hello world" convert to base58 string, var message = "StV1DL6CwTryKyV"; - var signature = await ParticleAuth.Instance.SolanasSignMessage(message); + var signature = await ParticleAuth.Instance.SolanaSignMessage(message); Debug.Log($"signature {signature}"); } catch (Exception e) @@ -202,7 +202,7 @@ public async void SolanaSignTransaction() { // "hello world" convert to base58 string, var transaction = await TransactionHelper.GetSolanaTransacion(_solanaAddress); - var signature = await ParticleAuth.Instance.SolanasSignTransaction(transaction); + var signature = await ParticleAuth.Instance.SolanaSignTransaction(transaction); Debug.Log($"signature {signature}"); } catch (Exception e) @@ -220,8 +220,8 @@ public async void SolanaSignAllTransactions() var transaction1 = await TransactionHelper.GetSolanaTransacion(_solanaAddress); var transaction2 = await TransactionHelper.GetSolanaTransacion(_solanaAddress); var signatures = - await ParticleAuth.Instance.SolanasSignAllTransactions(new[] { transaction1, transaction2 }); - Debug.Log($"signature {signatures}"); + await ParticleAuth.Instance.SolanaSignAllTransactions(new[] { transaction1, transaction2 }); + Debug.Log($"signatures: {string.Join(", ", signatures)}"); } catch (Exception e) {