Skip to content

Commit f2d6762

Browse files
committed
webgl performance dll
1 parent 36266fa commit f2d6762

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

Assets/Thirdweb/Examples/Scripts/EcosystemWalletManager.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using System.IO;
3+
using System.Linq;
34
using TMPro;
45
using UnityEngine;
56

@@ -17,7 +18,7 @@ public class EcosystemWalletManager : MonoBehaviour
1718
public TMP_Text LogText;
1819

1920
private ThirdwebClient _client;
20-
private EcosystemWallet _ecosystemWallet;
21+
private IThirdwebWallet _ecosystemWallet;
2122

2223
private void Awake()
2324
{
@@ -96,15 +97,16 @@ public async void Login()
9697
}
9798

9899
string address;
99-
if (await _ecosystemWallet.IsConnected())
100+
if (!await _ecosystemWallet.IsConnected() && _ecosystemWallet is EcosystemWallet)
100101
{
101-
address = await _ecosystemWallet.GetAddress();
102-
Log($"Connected with address: {address}");
103-
return;
102+
_ = await (_ecosystemWallet as EcosystemWallet).SendOTP();
103+
_ecosystemWallet = await EcosystemWalletModal.LoginWithOtp(_ecosystemWallet as EcosystemWallet);
104104
}
105105

106-
_ = await _ecosystemWallet.SendOTP();
107-
_ecosystemWallet = await EcosystemWalletModal.LoginWithOtp(_ecosystemWallet);
106+
if (_ecosystemWallet is not SmartWallet)
107+
{
108+
_ecosystemWallet = await SmartWallet.Create(_ecosystemWallet, 421614, gasless: true);
109+
}
108110

109111
address = await _ecosystemWallet.GetAddress();
110112
Log($"Connected with address: {address}");
@@ -132,10 +134,9 @@ public async void SignTransaction()
132134
}
133135

134136
var address = await _ecosystemWallet.GetAddress();
135-
var nonce = await _ecosystemWallet.GetTransactionCount(chainId: 421614, blocktag: "pending");
136-
var tx = new ThirdwebTransactionInput(chainId: 421614, from: address, to: address, nonce: nonce, gas: 100000, gasPrice: 200000000, value: 0, data: "0x");
137-
var signature = await _ecosystemWallet.SignTransaction(tx);
138-
Log($"Transaction Signed: {signature}");
137+
var contract = await ThirdwebContract.Create(_client, "0xEBB8a39D865465F289fa349A67B3391d8f910da9", 421614);
138+
var receipt = await contract.DropERC20_Claim(_ecosystemWallet, address, "1");
139+
Log($"Hash: {receipt.TransactionHash}");
139140
}
140141

141142
private void Log(string message)
11 KB
Binary file not shown.

Assets/Thirdweb/Runtime/Unity/ThirdwebUnityHttpClient.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ public async Task<ThirdwebHttpResponseMessage> GetAsync(string requestUri, Cance
5757

5858
public async Task<ThirdwebHttpResponseMessage> PostAsync(string requestUri, HttpContent content, CancellationToken cancellationToken = default)
5959
{
60+
var contentBytes = await content.ReadAsByteArrayAsync().ConfigureAwait(false);
61+
6062
return await SendRequestAsync(
6163
() =>
6264
{
6365
var webRequest = new UnityWebRequest(requestUri, UnityWebRequest.kHttpVerbPOST)
6466
{
65-
uploadHandler = new UploadHandlerRaw(content.ReadAsByteArrayAsync().Result) { contentType = content.Headers.ContentType.ToString() },
67+
uploadHandler = new UploadHandlerRaw(contentBytes) { contentType = content.Headers.ContentType.ToString() },
6668
downloadHandler = new DownloadHandlerBuffer()
6769
};
6870
return webRequest;

0 commit comments

Comments
 (0)