Skip to content

Commit 33e12b6

Browse files
committed
Add option not to deploy smart wallets on sign message/typeddata
1 parent c6b5a3c commit 33e12b6

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

Assets/Thirdweb/Core/Scripts/ThirdwebManager.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using UnityEngine;
2-
using Thirdweb;
32
using System.Collections.Generic;
43
using System.Numerics;
54

@@ -100,6 +99,9 @@ public class ThirdwebManager : MonoBehaviour
10099
[Tooltip("Whether it should use a paymaster for gasless transactions or not")]
101100
public bool gasless;
102101

102+
[Tooltip("Indicates whether to deploy the smart wallet upon signing any type of message.")]
103+
public bool doNotDeployOnSignMessage;
104+
103105
[Tooltip("Optional - If you want to use a custom relayer, you can provide the URL here")]
104106
public string bundlerUrl;
105107

@@ -282,6 +284,7 @@ public void Initialize(string chainIdentifier)
282284
{
283285
factoryAddress = factoryAddress,
284286
gasless = gasless,
287+
doNotDeployOnSignMessage = doNotDeployOnSignMessage,
285288
bundlerUrl = string.IsNullOrEmpty(bundlerUrl) ? $"https://{activeChainId}.bundler.thirdweb.com" : bundlerUrl,
286289
paymasterUrl = string.IsNullOrEmpty(paymasterUrl) ? $"https://{activeChainId}.bundler.thirdweb.com" : paymasterUrl,
287290
entryPointAddress = string.IsNullOrEmpty(entryPointAddress) ? Thirdweb.AccountAbstraction.Constants.DEFAULT_ENTRYPOINT_ADDRESS : entryPointAddress,

Assets/Thirdweb/Core/Scripts/ThirdwebSDK.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ public struct SmartWalletConfig
112112
/// </summary>
113113
public bool gasless;
114114

115+
/// <summary>
116+
/// Indicates whether to deploy the smart wallet upon signing any type of message.
117+
/// </summary>
118+
public bool doNotDeployOnSignMessage;
119+
115120
/// <summary>
116121
/// The URL of the bundler service.
117122
/// </summary>

Assets/Thirdweb/Core/Scripts/Wallet.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,10 @@ public async Task<string> Sign(string message)
389389
}
390390
else
391391
{
392-
if (ThirdwebManager.Instance.SDK.session.ActiveWallet.GetProvider() == WalletProvider.SmartWallet)
392+
if (
393+
ThirdwebManager.Instance.SDK.session.ActiveWallet.GetProvider() == WalletProvider.SmartWallet
394+
&& !ThirdwebManager.Instance.SDK.session.Options.smartWalletConfig.Value.doNotDeployOnSignMessage
395+
)
393396
{
394397
var sw = ThirdwebManager.Instance.SDK.session.ActiveWallet as Wallets.ThirdwebSmartWallet;
395398
if (!sw.SmartWallet.IsDeployed && !sw.SmartWallet.IsDeploying)
@@ -417,7 +420,10 @@ public async Task<string> SignTypedDataV4<T, TDomain>(T data, TypedData<TDomain>
417420
if (!await IsConnected())
418421
throw new Exception("No account connected!");
419422

420-
if (ThirdwebManager.Instance.SDK.session.ActiveWallet.GetProvider() == WalletProvider.SmartWallet)
423+
if (
424+
ThirdwebManager.Instance.SDK.session.ActiveWallet.GetProvider() == WalletProvider.SmartWallet
425+
&& !ThirdwebManager.Instance.SDK.session.Options.smartWalletConfig.Value.doNotDeployOnSignMessage
426+
)
421427
{
422428
var sw = ThirdwebManager.Instance.SDK.session.ActiveWallet as Wallets.ThirdwebSmartWallet;
423429
if (!sw.SmartWallet.IsDeployed && !sw.SmartWallet.IsDeploying)

Assets/Thirdweb/Editor/ThirdwebManagerEditor.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class ThirdwebManagerEditor : Editor
2727
private SerializedProperty walletConnectExplorerRecommendedWalletIdsProperty;
2828
private SerializedProperty factoryAddressProperty;
2929
private SerializedProperty gaslessProperty;
30+
private SerializedProperty doNotDeployOnSignMessageProperty;
3031
private SerializedProperty bundlerUrlProperty;
3132
private SerializedProperty paymasterUrlProperty;
3233
private SerializedProperty entryPointAddressProperty;
@@ -67,6 +68,7 @@ private void OnEnable()
6768
walletConnectExplorerRecommendedWalletIdsProperty = serializedObject.FindProperty("walletConnectExplorerRecommendedWalletIds");
6869
factoryAddressProperty = serializedObject.FindProperty("factoryAddress");
6970
gaslessProperty = serializedObject.FindProperty("gasless");
71+
doNotDeployOnSignMessageProperty = serializedObject.FindProperty("doNotDeployOnSignMessage");
7072
bundlerUrlProperty = serializedObject.FindProperty("bundlerUrl");
7173
paymasterUrlProperty = serializedObject.FindProperty("paymasterUrl");
7274
entryPointAddressProperty = serializedObject.FindProperty("entryPointAddress");
@@ -304,6 +306,7 @@ public override void OnInspectorGUI()
304306

305307
if (showSmartWalletOptionalFields)
306308
{
309+
EditorGUILayout.PropertyField(doNotDeployOnSignMessageProperty);
307310
EditorGUILayout.PropertyField(bundlerUrlProperty);
308311
EditorGUILayout.PropertyField(paymasterUrlProperty);
309312
EditorGUILayout.PropertyField(entryPointAddressProperty);

0 commit comments

Comments
 (0)