From 8803063ec0eca4bf2caa2c7b48128dba09ecaf19 Mon Sep 17 00:00:00 2001
From: sneakzttv <57473220+sneakzttv@users.noreply.github.com>
Date: Tue, 25 Jun 2024 20:33:39 +0800
Subject: [PATCH 1/3] block explorer url, custom token display & auto tx fixes
---
.../WalletGUI/Scripts/Web3AuthWalletGUITokenManager.cs | 4 ++--
.../WalletGUI/Scripts/Web3AuthWalletGUITxManager.cs | 10 ++++++++--
.../io.chainsafe.web3-unity/Editor/ServerSettings.cs | 2 +-
.../Runtime/Scripts/Model/ChainInfoModel.cs | 9 ++++++++-
4 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/Packages/io.chainsafe.web3-unity.web3auth/Runtime/WalletGUI/Scripts/Web3AuthWalletGUITokenManager.cs b/Packages/io.chainsafe.web3-unity.web3auth/Runtime/WalletGUI/Scripts/Web3AuthWalletGUITokenManager.cs
index 201dad0a8..10409751a 100644
--- a/Packages/io.chainsafe.web3-unity.web3auth/Runtime/WalletGUI/Scripts/Web3AuthWalletGUITokenManager.cs
+++ b/Packages/io.chainsafe.web3-unity.web3auth/Runtime/WalletGUI/Scripts/Web3AuthWalletGUITokenManager.cs
@@ -74,8 +74,8 @@ private async void SetTokens()
customTokenContract = data[0];
customTokenSymbolText.text = data[1].ToUpper();
var balance = await Web3Accessor.Web3.Erc20.GetBalanceOf(customTokenContract, Web3Accessor.Web3.Signer.PublicAddress);
- var customTokenValue = balance / BigInteger.Pow(10, 18);
- customTokenAmountText.text = customTokenValue.ToString();
+ var customTokenValue = (decimal)balance / (decimal)BigInteger.Pow(10, 18);
+ customTokenAmountText.text = customTokenValue.ToString("N18");
customTokenDisplay.SetActive(true);
}
else
diff --git a/Packages/io.chainsafe.web3-unity.web3auth/Runtime/WalletGUI/Scripts/Web3AuthWalletGUITxManager.cs b/Packages/io.chainsafe.web3-unity.web3auth/Runtime/WalletGUI/Scripts/Web3AuthWalletGUITxManager.cs
index 4b31b413f..d82b6de16 100644
--- a/Packages/io.chainsafe.web3-unity.web3auth/Runtime/WalletGUI/Scripts/Web3AuthWalletGUITxManager.cs
+++ b/Packages/io.chainsafe.web3-unity.web3auth/Runtime/WalletGUI/Scripts/Web3AuthWalletGUITxManager.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Threading.Tasks;
using ChainSafe.Gaming.Evm.Transactions;
using ChainSafe.Gaming.UnityPackage;
using ChainSafe.GamingSdk.Web3Auth;
@@ -78,8 +79,11 @@ private void OnTransactionRequested(TransactionRequested transactionRequested)
PromptTransactionRequest();
}
-
- private void PromptTransactionRequest()
+
+ ///
+ /// Prompts transaction request display.
+ ///
+ private async void PromptTransactionRequest()
{
TransactionRequested transactionRequested = _transactionQueue.Peek();
@@ -87,6 +91,8 @@ private void PromptTransactionRequest()
if (AutoConfirmTransactions)
{
+ await Task.Delay(1000);
+
AcceptRequest();
return;
diff --git a/Packages/io.chainsafe.web3-unity/Editor/ServerSettings.cs b/Packages/io.chainsafe.web3-unity/Editor/ServerSettings.cs
index 9c3242ddf..9da8f8350 100644
--- a/Packages/io.chainsafe.web3-unity/Editor/ServerSettings.cs
+++ b/Packages/io.chainsafe.web3-unity/Editor/ServerSettings.cs
@@ -102,7 +102,7 @@ public void UpdateServerMenuInfo()
selectedRpcIndex = Mathf.Clamp(selectedRpcIndex, 0, chainList[selectedChainIndex].rpc.Count - 1);
// Set the rpc
rpc = chainList[selectedChainIndex].rpc[selectedRpcIndex];
- blockExplorerUrl = chainList[selectedChainIndex].blockExplorerUrl;
+ blockExplorerUrl = chainList[selectedChainIndex].explorers[0].url;
}
else
{
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Model/ChainInfoModel.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Model/ChainInfoModel.cs
index b4fceb731..018262fc1 100644
--- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Model/ChainInfoModel.cs
+++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Model/ChainInfoModel.cs
@@ -6,6 +6,13 @@ public struct NativeCurrency
{
public string symbol { get; set; }
}
+
+ public struct Explorer
+ {
+ public string name { get; set; }
+ public string url { get; set; }
+ public string standard { get; set; }
+ }
public struct Root
{
@@ -14,6 +21,6 @@ public struct Root
public List rpc { get; set; }
public NativeCurrency nativeCurrency { get; set; }
public object chainId { get; set; }
- public string blockExplorerUrl { get; set; }
+ public List explorers { get; set; }
}
}
\ No newline at end of file
From 19bff78b005be9168a81e07812627f719273156e Mon Sep 17 00:00:00 2001
From: sneakzttv <57473220+sneakzttv@users.noreply.github.com>
Date: Tue, 25 Jun 2024 21:33:02 +0800
Subject: [PATCH 2/3] Update Web3AuthWalletGUI.prefab
---
.../Runtime/WalletGUI/Prefabs/Web3AuthWalletGUI.prefab | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Packages/io.chainsafe.web3-unity.web3auth/Runtime/WalletGUI/Prefabs/Web3AuthWalletGUI.prefab b/Packages/io.chainsafe.web3-unity.web3auth/Runtime/WalletGUI/Prefabs/Web3AuthWalletGUI.prefab
index eefcb83b6..9f3261658 100644
--- a/Packages/io.chainsafe.web3-unity.web3auth/Runtime/WalletGUI/Prefabs/Web3AuthWalletGUI.prefab
+++ b/Packages/io.chainsafe.web3-unity.web3auth/Runtime/WalletGUI/Prefabs/Web3AuthWalletGUI.prefab
@@ -5014,6 +5014,7 @@ MonoBehaviour:
- {fileID: 1253856405580558448}
- {fileID: 6789953013710888595}
- {fileID: 8115748193872107302}
+ - {fileID: 1136090464794109220}
displayLineObjects:
- {fileID: 3146313566770778794}
- {fileID: 3922797289987004089}
@@ -11112,8 +11113,8 @@ MonoBehaviour:
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
- rgba: 4286381996
- m_fontColor: {r: 0.6745098, g: 1, b: 0.4862745, a: 1}
+ rgba: 4294967295
+ m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
From 4fbad0226e219de674933be12302bdc926b95816 Mon Sep 17 00:00:00 2001
From: sneakzttv <57473220+sneakzttv@users.noreply.github.com>
Date: Tue, 25 Jun 2024 22:02:31 +0800
Subject: [PATCH 3/3] requested changes
requested changes
---
.../Runtime/WalletGUI/Scripts/Web3AuthWalletGUITxManager.cs | 5 +----
.../Runtime/Web3AuthWallet.cs | 4 ++--
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/Packages/io.chainsafe.web3-unity.web3auth/Runtime/WalletGUI/Scripts/Web3AuthWalletGUITxManager.cs b/Packages/io.chainsafe.web3-unity.web3auth/Runtime/WalletGUI/Scripts/Web3AuthWalletGUITxManager.cs
index d82b6de16..2920cdfa0 100644
--- a/Packages/io.chainsafe.web3-unity.web3auth/Runtime/WalletGUI/Scripts/Web3AuthWalletGUITxManager.cs
+++ b/Packages/io.chainsafe.web3-unity.web3auth/Runtime/WalletGUI/Scripts/Web3AuthWalletGUITxManager.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Threading.Tasks;
using ChainSafe.Gaming.Evm.Transactions;
using ChainSafe.Gaming.UnityPackage;
using ChainSafe.GamingSdk.Web3Auth;
@@ -83,7 +82,7 @@ private void OnTransactionRequested(TransactionRequested transactionRequested)
///
/// Prompts transaction request display.
///
- private async void PromptTransactionRequest()
+ private void PromptTransactionRequest()
{
TransactionRequested transactionRequested = _transactionQueue.Peek();
@@ -91,8 +90,6 @@ private async void PromptTransactionRequest()
if (AutoConfirmTransactions)
{
- await Task.Delay(1000);
-
AcceptRequest();
return;
diff --git a/Packages/io.chainsafe.web3-unity.web3auth/Runtime/Web3AuthWallet.cs b/Packages/io.chainsafe.web3-unity.web3auth/Runtime/Web3AuthWallet.cs
index aa3e9a27d..de7a770a8 100644
--- a/Packages/io.chainsafe.web3-unity.web3auth/Runtime/Web3AuthWallet.cs
+++ b/Packages/io.chainsafe.web3-unity.web3auth/Runtime/Web3AuthWallet.cs
@@ -151,12 +151,12 @@ public Task SendTransaction(TransactionRequest transaction)
var request = new TransactionRequested(id, transaction);
- transactionHandler.RequestTransaction(request);
-
var tcs = new TaskCompletionSource();
_transactionPool.Add(request, tcs);
+ transactionHandler.RequestTransaction(request);
+
return tcs.Task;
}