Skip to content

Commit 2a7d8b9

Browse files
committed
Fix arrays in signTypedData, add fallback for client chain id failing
1 parent 4f49a96 commit 2a7d8b9

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Assets/Thirdweb/Core/Scripts/AccountAbstraction/Core/SmartWallet.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,15 @@ internal async Task<RpcResponseMessage> Request(RpcRequestMessage requestMessage
149149
}
150150
else if (requestMessage.Method == "eth_chainId")
151151
{
152-
var chainId = await PersonalWeb3.Eth.ChainId.SendRequestAsync();
153-
return new RpcResponseMessage(requestMessage.Id, chainId.HexValue);
152+
try
153+
{
154+
var chainId = await PersonalWeb3.Eth.ChainId.SendRequestAsync();
155+
return new RpcResponseMessage(requestMessage.Id, chainId.HexValue);
156+
}
157+
catch
158+
{
159+
return new RpcResponseMessage(requestMessage.Id, ThirdwebManager.Instance.SDK.session.CurrentChainData.chainId);
160+
}
154161
}
155162
else if (requestMessage.Method == "eth_estimateGas")
156163
{

Assets/Thirdweb/Core/Scripts/Wallet.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,16 @@ public async Task<string> SignTypedDataV4<T, TDomain>(T data, TypedData<TDomain>
431431

432432
var messageObject = jsonObject.GetValue("message") as JObject;
433433
foreach (var property in messageObject.Properties())
434-
property.Value = property.Value.ToString();
434+
{
435+
if (property.Value.Type == JTokenType.Array)
436+
{
437+
continue;
438+
}
439+
else
440+
{
441+
property.Value = property.Value.ToString();
442+
}
443+
}
435444

436445
string safeJson = jsonObject.ToString();
437446
return await ThirdwebManager.Instance.SDK.session.Request<string>("eth_signTypedData_v4", await GetSignerAddress(), safeJson);

0 commit comments

Comments
 (0)