Skip to content

Commit

Permalink
update webgl
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhichao Link committed Oct 10, 2024
1 parent 05bf1d6 commit 4ab18d6
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 210 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ private void HandleResult<T>(string json, TaskCompletionSource<T> task, string k
}
}

private string HexToString(string hex)
public string HexToString(string hex)
{
if (hex.StartsWith("0x"))
{
Expand Down
19 changes: 17 additions & 2 deletions ParticleWebGLDemo/ParticleWebGLDemo/Assets/Scripts/Demo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using Network.Particle.Scripts.Core;
using Network.Particle.Scripts.Model;
using Network.Particle.Scripts.Test;
Expand Down Expand Up @@ -39,10 +40,10 @@ public void Init()
defaultWalletEntryPosition = new WalletEntryPosition { x = 0.0f, y = 0.0f },
supportChains = new List<ChainInfo>
{
ChainInfo.Sei
ChainInfo.EthereumSepolia
}
};
var config = new InitConfig(projectId, clientKey, appId, ChainInfo.Sei, securityAccount,
var config = new InitConfig(projectId, clientKey, appId, ChainInfo.EthereumSepolia, securityAccount,
wallet);

ParticleAuth.Instance.Init(config);
Expand Down Expand Up @@ -185,6 +186,9 @@ public async void EVMSendTransaction()
try
{
var transaction = await TransactionHelper.GetEVMTransacion(_evmAddress);
var simplifyTransaction = GetSimplifyTransactionFrom(transaction);
Debug.Log($"simplifyTransaction to {simplifyTransaction.to}, data {simplifyTransaction.data}, value {simplifyTransaction.value}");

var signature = await ParticleAuth.Instance.EVMSendTransaction(transaction);
Debug.Log($"signature {signature}");
}
Expand Down Expand Up @@ -610,5 +614,16 @@ public async void SendSessionUserOp()
Debug.LogError($"An error occurred: {e.Message}");
}
}

// convert the transaction hex string to a SimplifyTransaction object
public SimplifyTransaction GetSimplifyTransactionFrom(string transaction)
{
var jsonString = ParticleAuth.Instance.HexToString(transaction);
var jobject = JObject.Parse(jsonString);
var to = jobject["to"].ToString();
var data = jobject["data"].ToString();
var value = jobject["value"].ToString();
return new SimplifyTransaction(to, data, value);
}
}
}
Loading

0 comments on commit 4ab18d6

Please sign in to comment.