Skip to content

Commit 54e4d41

Browse files
committed
GetClientId Util
1 parent 2b5c3b4 commit 54e4d41

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ private static async Task<RpcResponseMessage> BundlerRequest(string url, string
6565
httpRequestMessage.Headers.Add("x-sdk-os", Utils.GetRuntimePlatform());
6666
httpRequestMessage.Headers.Add("x-sdk-platform", "unity");
6767
httpRequestMessage.Headers.Add("x-sdk-version", ThirdwebSDK.version);
68-
httpRequestMessage.Headers.Add("x-client-id", ThirdwebManager.Instance.SDK.session.Options.clientId);
68+
httpRequestMessage.Headers.Add("x-client-id", Utils.GetClientId());
6969
if (!Utils.IsWebGLBuild())
70-
httpRequestMessage.Headers.Add("x-bundle-id", ThirdwebManager.Instance.SDK.session.Options.bundleId);
70+
httpRequestMessage.Headers.Add("x-bundle-id", Utils.GetBundleId());
7171
}
7272

7373
var httpResponse = await client.SendAsync(httpRequestMessage);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ internal async Task<RpcResponseMessage> Request(RpcRequestMessage requestMessage
196196
{
197197
requestId ??= SmartWalletClient.GenerateRpcId();
198198

199-
string apiKey = ThirdwebManager.Instance.SDK.session.Options.clientId;
199+
string apiKey = Utils.GetClientId();
200200

201201
// Create the user operation and its safe (hexified) version
202202

@@ -262,7 +262,7 @@ private async Task<RpcResponseMessage> CreateUserOpAndSend(RpcRequestMessage req
262262
_deploying = true;
263263
}
264264

265-
string apiKey = ThirdwebManager.Instance.SDK.session.Options.clientId;
265+
string apiKey = Utils.GetClientId();
266266

267267
// Deserialize the transaction input from the request message
268268

Assets/Thirdweb/Core/Scripts/Utils.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,11 @@ public static string ToChecksumAddress(this string address)
415415
return Nethereum.Util.AddressUtil.Current.ConvertToChecksumAddress(address);
416416
}
417417

418+
public static string GetClientId()
419+
{
420+
return ThirdwebManager.Instance.SDK?.session?.Options.clientId ?? (string.IsNullOrEmpty(ThirdwebManager.Instance.clientId) ? null : ThirdwebManager.Instance.clientId);
421+
}
422+
418423
public static string GetBundleId()
419424
{
420425
return ThirdwebManager.Instance.SDK?.session?.Options.bundleId

Assets/Thirdweb/Core/Scripts/Wallet.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,7 @@ public async Task<string> Connect(WalletConnection walletConnection)
3939
else
4040
{
4141
address = await ThirdwebManager.Instance.SDK.session.Connect(walletConnection);
42-
Utils.TrackWalletAnalytics(
43-
ThirdwebManager.Instance.SDK.session.Options.clientId,
44-
"connectWallet",
45-
"connect",
46-
walletConnection.provider.ToString()[..1].ToLower() + walletConnection.provider.ToString()[1..],
47-
address
48-
);
42+
Utils.TrackWalletAnalytics(Utils.GetClientId(), "connectWallet", "connect", walletConnection.provider.ToString()[..1].ToLower() + walletConnection.provider.ToString()[1..], address);
4943
return address;
5044
}
5145

Assets/Thirdweb/Core/Scripts/WalletsUI/EmbeddedWalletUI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public virtual async Task<string> GetLoginLink(string authProvider)
271271
string loginUrl = await _embeddedWallet.FetchHeadlessOauthLoginLinkAsync(authProvider);
272272
string platform = "unity";
273273
string redirectUrl = UnityWebRequest.EscapeURL(Application.isMobilePlatform ? _customScheme : "http://localhost:8789/");
274-
string developerClientId = UnityWebRequest.EscapeURL(ThirdwebManager.Instance.SDK.session.Options.clientId);
274+
string developerClientId = UnityWebRequest.EscapeURL(Utils.GetClientId());
275275
return $"{loginUrl}?platform={platform}&redirectUrl={redirectUrl}&developerClientId={developerClientId}&authOption={authProvider}";
276276
}
277277

0 commit comments

Comments
 (0)