Skip to content

Commit 150d53d

Browse files
committed
Smart Wallets WebGL
1 parent fe070c4 commit 150d53d

File tree

9 files changed

+315608
-226
lines changed

9 files changed

+315608
-226
lines changed

Assets/Thirdweb/Core/Scripts/ThirdwebManager.cs

+39-3
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,31 @@ public class ThirdwebManager : MonoBehaviour
6767
public string forwaderVersionOverride = null;
6868

6969
[Header("MAGIC LINK OPTIONS")]
70+
[Tooltip("Magic Link API Key (https://dashboard.magic.link)")]
7071
public string magicLinkApiKey = null;
7172

73+
[Header("SMART WALLET OPTIONS")]
74+
[Tooltip("Factory Contract Address")]
75+
public string factoryAddress;
76+
77+
[Tooltip("Thirdweb API Key (https://thirdweb.com/dashboard/api-keys)")]
78+
public string thirdwebApiKey;
79+
80+
[Tooltip("Whether it should use a paymaster for gasless transactions or not")]
81+
public bool gasless;
82+
83+
[Tooltip("Optional - If you want to use a custom relayer, you can provide the URL here")]
84+
public string bundlerUrl;
85+
86+
[Tooltip("Optional - If you want to use a custom paymaster, you can provide the URL here")]
87+
public string paymasterUrl;
88+
89+
[Tooltip("Optional - If you want to use a custom paymaster, you can provide the API key here")]
90+
public string paymasterAPI;
91+
92+
[Tooltip("Optional - If you want to use a custom entry point, you can provide the contract address here")]
93+
public string entryPointAddress;
94+
7295
[Header("NATIVE PREFABS (DANGER ZONE)")]
7396
[Tooltip("Instantiates the WalletConnect SDK for Native platforms.")]
7497
public GameObject WalletConnectPrefab;
@@ -157,17 +180,30 @@ private void Awake()
157180
};
158181
}
159182

160-
// Set up app metadata
161-
183+
// Set up wallet data
162184
options.wallet = new ThirdwebSDK.WalletOptions()
163185
{
164186
appName = string.IsNullOrEmpty(appName) ? "Thirdweb Game" : appName,
165187
appDescription = string.IsNullOrEmpty(appDescription) ? "Thirdweb Game Demo" : appDescription,
166188
appIcons = appIcons.Length == 0 ? new string[] { "https://thirdweb.com/favicon.ico" } : appIcons,
167189
appUrl = string.IsNullOrEmpty(appUrl) ? "https://thirdweb.com" : appUrl,
168-
magicLinkApiKey = string.IsNullOrEmpty(magicLinkApiKey) ? null : magicLinkApiKey
190+
magicLinkApiKey = string.IsNullOrEmpty(magicLinkApiKey) ? null : magicLinkApiKey,
169191
};
170192

193+
options.smartWalletConfig =
194+
string.IsNullOrEmpty(factoryAddress) || string.IsNullOrEmpty(thirdwebApiKey)
195+
? null
196+
: new ThirdwebSDK.SmartWalletConfig()
197+
{
198+
factoryAddress = factoryAddress,
199+
thirdwebApiKey = thirdwebApiKey,
200+
gasless = gasless,
201+
bundlerUrl = bundlerUrl,
202+
paymasterUrl = paymasterUrl,
203+
paymasterAPI = paymasterAPI,
204+
entryPointAddress = entryPointAddress
205+
};
206+
171207
SDK = new ThirdwebSDK(chainOrRPC, chainId, options);
172208
}
173209

Assets/Thirdweb/Core/Scripts/ThirdwebSDK.cs

+13
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public struct Options
2323
public GaslessOptions? gasless;
2424
public StorageOptions? storage;
2525
public WalletOptions? wallet;
26+
public SmartWalletConfig? smartWalletConfig;
2627
}
2728

2829
/// <summary>
@@ -39,6 +40,18 @@ public struct WalletOptions
3940
public Dictionary<string, object> extras; // extra data to pass to the wallet provider
4041
}
4142

43+
[System.Serializable]
44+
public struct SmartWalletConfig
45+
{
46+
public string factoryAddress;
47+
public string thirdwebApiKey;
48+
public bool gasless;
49+
public string bundlerUrl;
50+
public string paymasterUrl;
51+
public string paymasterAPI;
52+
public string entryPointAddress;
53+
}
54+
4255
/// <summary>
4356
/// Storage configuration options.
4457
/// </summary>

Assets/Thirdweb/Core/Scripts/Wallet.cs

+1
Original file line numberDiff line numberDiff line change
@@ -603,5 +603,6 @@ public enum WalletProvider
603603
Injected,
604604
MagicLink,
605605
LocalWallet,
606+
SmartWallet
606607
}
607608
}

0 commit comments

Comments
 (0)