Skip to content

Commit

Permalink
Allow overriding redirect html
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFirekeeper committed Sep 27, 2024
1 parent 4f53d12 commit 0d2fc3c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
Binary file modified Assets/Thirdweb/Runtime/NET/Thirdweb.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,25 @@ public class CrossPlatformUnityBrowser : IThirdwebBrowser
{
IThirdwebBrowser _unityBrowser;

public CrossPlatformUnityBrowser()
public CrossPlatformUnityBrowser(string htmlOverride = null)
{
if (string.IsNullOrEmpty(htmlOverride) || string.IsNullOrWhiteSpace(htmlOverride))
{
htmlOverride = null;
}

var go = new GameObject("WebGLInAppWalletBrowser");

#if UNITY_EDITOR
_unityBrowser = new InAppWalletBrowser();
_unityBrowser = new InAppWalletBrowser(htmlOverride);
#elif UNITY_WEBGL
_unityBrowser = go.AddComponent<WebGLInAppWalletBrowser>();
#elif UNITY_ANDROID
_unityBrowser = new AndroidBrowser();
#elif UNITY_IOS
_unityBrowser = new IOSBrowser();
#else
_unityBrowser = new InAppWalletBrowser();
_unityBrowser = new InAppWalletBrowser(htmlOverride);
#endif
}

Expand Down
20 changes: 16 additions & 4 deletions Assets/Thirdweb/Runtime/Unity/ThirdwebManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,26 +134,38 @@ public WalletOptions(
}
}

[HelpURL("http://portal.thirdweb.com/unity/v5/thirdwebmanager")]
public class ThirdwebManager : MonoBehaviour
{
[field: SerializeField, Header("Client Settings")]
[Tooltip("API key for your Thirdweb project. Get your API key from https://thirdweb.com/create-api-key")]
private string ClientId { get; set; }

[field: SerializeField]
[Tooltip("Bundle ID of your Unity project. Default is Application.identifier. If not set, it will be generated using Application.companyName and Application.productName.")]
private string BundleId { get; set; }

[field: SerializeField]
[Tooltip("Initialize ThirdwebManager on Awake. Default is true. Set to false if you want to initialize manually.")]
private bool InitializeOnAwake { get; set; } = true;

[field: SerializeField]
[Tooltip("Enable or disable debug logs. Default is true.")]
private bool ShowDebugLogs { get; set; } = true;

[field: SerializeField]
[Tooltip("Opt out of usage analytics. This will disable tracking of wallet connection events and affect your dashboard stats.")]
private bool OptOutUsageAnalytics { get; set; } = false;

[field: SerializeField, Header("WalletConnect Settings")]
[Tooltip("Chain IDs supported by WalletConnect Wallet.")]
private ulong[] SupportedChains { get; set; } = new ulong[] { 421614 };

[field: SerializeField, Header("Desktop OAuth Settings")]
[Tooltip("HTML content to be displayed when redirecting to the OAuth provider. Leave empty to use the default page.")]
[TextArea(3, 10)]
private string RedirectPageHtmlOverride;

public ThirdwebClient Client { get; private set; }

public IThirdwebWallet ActiveWallet { get; private set; }
Expand Down Expand Up @@ -355,7 +367,7 @@ public async Task<IThirdwebWallet> ConnectWallet(WalletOptions walletOptions)
isMobile: Application.isMobilePlatform,
browserOpenAction: (url) => Application.OpenURL(url),
mobileRedirectScheme: BundleId + "://",
browser: new CrossPlatformUnityBrowser()
browser: new CrossPlatformUnityBrowser(RedirectPageHtmlOverride)
);
}
}
Expand Down Expand Up @@ -393,7 +405,7 @@ public async Task<IThirdwebWallet> ConnectWallet(WalletOptions walletOptions)
isMobile: Application.isMobilePlatform,
browserOpenAction: (url) => Application.OpenURL(url),
mobileRedirectScheme: BundleId + "://",
browser: new CrossPlatformUnityBrowser()
browser: new CrossPlatformUnityBrowser(RedirectPageHtmlOverride)
);
}
}
Expand Down Expand Up @@ -470,7 +482,7 @@ public async Task<List<LinkedAccount>> LinkAccount(InAppWallet mainWallet, InApp
isMobile: Application.isMobilePlatform,
browserOpenAction: (url) => Application.OpenURL(url),
mobileRedirectScheme: BundleId + "://",
browser: new CrossPlatformUnityBrowser(),
browser: new CrossPlatformUnityBrowser(RedirectPageHtmlOverride),
chainId: chainId,
jwt: jwtOrPayload,
payload: jwtOrPayload
Expand All @@ -485,7 +497,7 @@ public async Task<List<LinkedAccount>> LinkAccount(EcosystemWallet mainWallet, E
isMobile: Application.isMobilePlatform,
browserOpenAction: (url) => Application.OpenURL(url),
mobileRedirectScheme: BundleId + "://",
browser: new CrossPlatformUnityBrowser(),
browser: new CrossPlatformUnityBrowser(RedirectPageHtmlOverride),
chainId: chainId,
jwt: jwtOrPayload,
payload: jwtOrPayload
Expand Down

0 comments on commit 0d2fc3c

Please sign in to comment.