Skip to content

Commit 4ab18d6

Browse files
author
Zhichao Link
committed
update webgl
1 parent 05bf1d6 commit 4ab18d6

File tree

3 files changed

+94
-210
lines changed

3 files changed

+94
-210
lines changed

ParticleWebGLDemo/ParticleWebGLDemo/Assets/Plugins/WebGL/ParticleAuthWebGL/ParticleAuth.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ private void HandleResult<T>(string json, TaskCompletionSource<T> task, string k
545545
}
546546
}
547547

548-
private string HexToString(string hex)
548+
public string HexToString(string hex)
549549
{
550550
if (hex.StartsWith("0x"))
551551
{

ParticleWebGLDemo/ParticleWebGLDemo/Assets/Scripts/Demo.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Numerics;
5+
using System.Runtime.InteropServices.ComTypes;
56
using Network.Particle.Scripts.Core;
67
using Network.Particle.Scripts.Model;
78
using Network.Particle.Scripts.Test;
@@ -39,10 +40,10 @@ public void Init()
3940
defaultWalletEntryPosition = new WalletEntryPosition { x = 0.0f, y = 0.0f },
4041
supportChains = new List<ChainInfo>
4142
{
42-
ChainInfo.Sei
43+
ChainInfo.EthereumSepolia
4344
}
4445
};
45-
var config = new InitConfig(projectId, clientKey, appId, ChainInfo.Sei, securityAccount,
46+
var config = new InitConfig(projectId, clientKey, appId, ChainInfo.EthereumSepolia, securityAccount,
4647
wallet);
4748

4849
ParticleAuth.Instance.Init(config);
@@ -185,6 +186,9 @@ public async void EVMSendTransaction()
185186
try
186187
{
187188
var transaction = await TransactionHelper.GetEVMTransacion(_evmAddress);
189+
var simplifyTransaction = GetSimplifyTransactionFrom(transaction);
190+
Debug.Log($"simplifyTransaction to {simplifyTransaction.to}, data {simplifyTransaction.data}, value {simplifyTransaction.value}");
191+
188192
var signature = await ParticleAuth.Instance.EVMSendTransaction(transaction);
189193
Debug.Log($"signature {signature}");
190194
}
@@ -610,5 +614,16 @@ public async void SendSessionUserOp()
610614
Debug.LogError($"An error occurred: {e.Message}");
611615
}
612616
}
617+
618+
// convert the transaction hex string to a SimplifyTransaction object
619+
public SimplifyTransaction GetSimplifyTransactionFrom(string transaction)
620+
{
621+
var jsonString = ParticleAuth.Instance.HexToString(transaction);
622+
var jobject = JObject.Parse(jsonString);
623+
var to = jobject["to"].ToString();
624+
var data = jobject["data"].ToString();
625+
var value = jobject["value"].ToString();
626+
return new SimplifyTransaction(to, data, value);
627+
}
613628
}
614629
}

0 commit comments

Comments
 (0)