Skip to content

Commit a021fa1

Browse files
committed
.NET 1.5.0
1 parent 8ddedb6 commit a021fa1

File tree

5 files changed

+30
-23
lines changed

5 files changed

+30
-23
lines changed

Assets/Thirdweb/Examples/Scripts/PlaygroundManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private void Awake()
5353

5454
private async void Start()
5555
{
56-
_chainDetails = await Utils.FetchThirdwebChainDataAsync(client: ThirdwebManager.Instance.Client, chainId: ActiveChainId);
56+
_chainDetails = await Utils.GetChainMetadata(client: ThirdwebManager.Instance.Client, chainId: ActiveChainId);
5757
}
5858

5959
private void InitializePanels()
245 KB
Binary file not shown.

Assets/Thirdweb/Runtime/Unity/ThirdwebManager.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ public class SmartWalletOptions
5353
public string EntryPoint;
5454
public string BundlerUrl;
5555
public string PaymasterUrl;
56-
public string ERC20PaymasterAddress;
57-
public string ERC20PaymasterToken;
56+
public TokenPaymaster TokenPaymaster;
5857

5958
public SmartWalletOptions(
6059
bool sponsorGas,
@@ -63,8 +62,7 @@ public SmartWalletOptions(
6362
string entryPoint = null,
6463
string bundlerUrl = null,
6564
string paymasterUrl = null,
66-
string erc20PaymasterAddress = null,
67-
string erc20PaymasterToken = null
65+
TokenPaymaster tokenPaymaster = TokenPaymaster.NONE
6866
)
6967
{
7068
SponsorGas = sponsorGas;
@@ -73,8 +71,7 @@ public SmartWalletOptions(
7371
EntryPoint = entryPoint;
7472
BundlerUrl = bundlerUrl;
7573
PaymasterUrl = paymasterUrl;
76-
ERC20PaymasterAddress = erc20PaymasterAddress;
77-
ERC20PaymasterToken = erc20PaymasterToken;
74+
TokenPaymaster = tokenPaymaster;
7875
}
7976
}
8077

@@ -345,8 +342,7 @@ public async Task<SmartWallet> UpgradeToSmartWallet(IThirdwebWallet personalWall
345342
entryPoint: smartWalletOptions.EntryPoint,
346343
bundlerUrl: smartWalletOptions.BundlerUrl,
347344
paymasterUrl: smartWalletOptions.PaymasterUrl,
348-
erc20PaymasterAddress: smartWalletOptions.ERC20PaymasterAddress,
349-
erc20PaymasterToken: smartWalletOptions.ERC20PaymasterToken
345+
tokenPaymaster: smartWalletOptions.TokenPaymaster
350346
);
351347

352348
await AddWallet(wallet);

Assets/Thirdweb/Runtime/Unity/Wallets/Core/MetaMaskWallet.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ public async Task<string> PersonalSign(string message)
109109

110110
public async Task<string> SendTransaction(ThirdwebTransactionInput transaction)
111111
{
112-
await EnsureCorrectNetwork(transaction.ChainId);
113-
114112
var rpcRequest = new RpcRequest
115113
{
116114
Method = "eth_sendTransaction",
@@ -119,24 +117,30 @@ public async Task<string> SendTransaction(ThirdwebTransactionInput transaction)
119117
new TransactionInput()
120118
{
121119
Nonce = transaction.Nonce,
122-
From = transaction.From,
120+
From = await GetAddress(),
123121
To = transaction.To,
124122
Gas = transaction.Gas,
125123
GasPrice = transaction.GasPrice,
126124
Value = transaction.Value,
127125
Data = transaction.Data,
128126
MaxFeePerGas = transaction.MaxFeePerGas,
129127
MaxPriorityFeePerGas = transaction.MaxPriorityFeePerGas,
130-
ChainId = transaction.ChainId,
128+
ChainId = new HexBigInteger(WebGLMetaMask.Instance.GetActiveChainId()),
131129
}
132130
}
133131
};
134132
return await WebGLMetaMask.Instance.RequestAsync<string>(rpcRequest);
135133
}
136134

135+
public async Task<ThirdwebTransactionReceipt> ExecuteTransaction(ThirdwebTransactionInput transaction)
136+
{
137+
var hash = await SendTransaction(transaction);
138+
return await ThirdwebTransaction.WaitForTransactionReceipt(client: _client, chainId: WebGLMetaMask.Instance.GetActiveChainId(), txHash: hash);
139+
}
140+
137141
public Task<string> SignTransaction(ThirdwebTransactionInput transaction)
138142
{
139-
throw new NotImplementedException("Offline transaction signing is not supported by MetaMask.");
143+
throw new NotImplementedException("Raw transaction signing is not supported.");
140144
}
141145

142146
public async Task<string> SignTypedDataV4(string json)
@@ -191,9 +195,9 @@ public virtual async Task<string> Authenticate(
191195
var payloadString = await payloadResponse.Content.ReadAsStringAsync();
192196

193197
var loginBodyRaw = JsonConvert.DeserializeObject<LoginPayload>(payloadString);
194-
var payloadToSign = Utils.GenerateSIWE(loginBodyRaw.payload);
198+
var payloadToSign = Utils.GenerateSIWE(loginBodyRaw.Payload);
195199

196-
loginBodyRaw.signature = await PersonalSign(payloadToSign);
200+
loginBodyRaw.Signature = await PersonalSign(payloadToSign);
197201
var loginBody = JsonConvert.SerializeObject(new { payload = loginBodyRaw });
198202

199203
var loginContent = new StringContent(loginBody, Encoding.UTF8, "application/json");
@@ -254,7 +258,7 @@ private static async Task SwitchNetwork(BigInteger chainId)
254258
private static async Task AddNetwork(BigInteger chainId)
255259
{
256260
ThirdwebDebug.Log($"Fetching chain data for chainId {chainId}...");
257-
var twChainData = await Utils.FetchThirdwebChainDataAsync(_client, chainId) ?? throw new Exception($"Chain data for chainId {chainId} could not be fetched.");
261+
var twChainData = await Utils.GetChainMetadata(_client, chainId) ?? throw new Exception($"Chain data for chainId {chainId} could not be fetched.");
258262
ThirdwebDebug.Log($"Chain data fetched: {JsonConvert.SerializeObject(twChainData)}");
259263
var explorers = twChainData.Explorers?.Select(e => e?.Url).Where(url => url != null).ToList() ?? new List<string>();
260264
var iconUrl = twChainData.Icon?.Url ?? "ipfs://QmdwQDr6vmBtXmK2TmknkEuZNoaDqTasFdZdu3DRw8b2wt";

Assets/Thirdweb/Runtime/Unity/Wallets/Core/WalletConnectWallet.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public async static Task<WalletConnectWallet> Create(ThirdwebClient client, BigI
9494

9595
public async Task EnsureCorrectNetwork(BigInteger chainId)
9696
{
97-
var chainInfo = await Utils.FetchThirdwebChainDataAsync(_client, chainId);
97+
var chainInfo = await Utils.GetChainMetadata(_client, chainId);
9898
var wcChainInfo = new EthereumChain()
9999
{
100100
chainIdHex = new HexBigInteger(chainInfo.ChainId).HexValue,
@@ -190,30 +190,37 @@ public Task<string> SignTypedDataV4<T, TDomain>(T data, TypedData<TDomain> typed
190190

191191
public Task<string> SignTransaction(ThirdwebTransactionInput transaction)
192192
{
193-
throw new InvalidOperationException("Offline signing is not supported by external wallets.");
193+
throw new NotImplementedException("Raw transaction signing is not supported.");
194194
}
195195

196196
public async Task<string> SendTransaction(ThirdwebTransactionInput transaction)
197197
{
198+
Debug.Log("DEFAULT CHAIN ID: " + WalletConnect.Instance.SignClient.AddressProvider.DefaultChainId);
198199
var task = _walletConnectService.SendTransactionAsync(
199200
new TransactionInput()
200201
{
201202
Nonce = transaction.Nonce,
202-
From = transaction.From,
203+
From = await GetAddress(),
203204
To = transaction.To,
204205
Gas = transaction.Gas,
205206
GasPrice = transaction.GasPrice,
206207
Value = transaction.Value,
207208
Data = transaction.Data,
208209
MaxFeePerGas = transaction.MaxFeePerGas,
209210
MaxPriorityFeePerGas = transaction.MaxPriorityFeePerGas,
210-
ChainId = transaction.ChainId,
211+
ChainId = new HexBigInteger(WalletConnect.Instance.SignClient.AddressProvider.DefaultChainId),
211212
}
212213
);
213214
SessionRequestDeeplink();
214215
return await task as string;
215216
}
216217

218+
public async Task<ThirdwebTransactionReceipt> ExecuteTransaction(ThirdwebTransactionInput transaction)
219+
{
220+
var hash = await SendTransaction(transaction);
221+
return await ThirdwebTransaction.WaitForTransactionReceipt(client: _client, chainId: WebGLMetaMask.Instance.GetActiveChainId(), txHash: hash);
222+
}
223+
217224
public Task<bool> IsConnected()
218225
{
219226
return Task.FromResult(WalletConnect.Instance.IsConnected);
@@ -246,9 +253,9 @@ public virtual async Task<string> Authenticate(
246253
var payloadString = await payloadResponse.Content.ReadAsStringAsync();
247254

248255
var loginBodyRaw = JsonConvert.DeserializeObject<LoginPayload>(payloadString);
249-
var payloadToSign = Utils.GenerateSIWE(loginBodyRaw.payload);
256+
var payloadToSign = Utils.GenerateSIWE(loginBodyRaw.Payload);
250257

251-
loginBodyRaw.signature = await PersonalSign(payloadToSign);
258+
loginBodyRaw.Signature = await PersonalSign(payloadToSign);
252259
var loginBody = JsonConvert.SerializeObject(new { payload = loginBodyRaw });
253260

254261
var loginContent = new StringContent(loginBody, Encoding.UTF8, "application/json");

0 commit comments

Comments
 (0)