Skip to content

Commit

Permalink
Smart Wallets WebGL
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFirekeeper committed May 24, 2023
1 parent fe070c4 commit 150d53d
Show file tree
Hide file tree
Showing 9 changed files with 315,608 additions and 226 deletions.
42 changes: 39 additions & 3 deletions Assets/Thirdweb/Core/Scripts/ThirdwebManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,31 @@ public class ThirdwebManager : MonoBehaviour
public string forwaderVersionOverride = null;

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

[Header("SMART WALLET OPTIONS")]
[Tooltip("Factory Contract Address")]
public string factoryAddress;

[Tooltip("Thirdweb API Key (https://thirdweb.com/dashboard/api-keys)")]
public string thirdwebApiKey;

[Tooltip("Whether it should use a paymaster for gasless transactions or not")]
public bool gasless;

[Tooltip("Optional - If you want to use a custom relayer, you can provide the URL here")]
public string bundlerUrl;

[Tooltip("Optional - If you want to use a custom paymaster, you can provide the URL here")]
public string paymasterUrl;

[Tooltip("Optional - If you want to use a custom paymaster, you can provide the API key here")]
public string paymasterAPI;

[Tooltip("Optional - If you want to use a custom entry point, you can provide the contract address here")]
public string entryPointAddress;

[Header("NATIVE PREFABS (DANGER ZONE)")]
[Tooltip("Instantiates the WalletConnect SDK for Native platforms.")]
public GameObject WalletConnectPrefab;
Expand Down Expand Up @@ -157,17 +180,30 @@ private void Awake()
};
}

// Set up app metadata

// Set up wallet data
options.wallet = new ThirdwebSDK.WalletOptions()
{
appName = string.IsNullOrEmpty(appName) ? "Thirdweb Game" : appName,
appDescription = string.IsNullOrEmpty(appDescription) ? "Thirdweb Game Demo" : appDescription,
appIcons = appIcons.Length == 0 ? new string[] { "https://thirdweb.com/favicon.ico" } : appIcons,
appUrl = string.IsNullOrEmpty(appUrl) ? "https://thirdweb.com" : appUrl,
magicLinkApiKey = string.IsNullOrEmpty(magicLinkApiKey) ? null : magicLinkApiKey
magicLinkApiKey = string.IsNullOrEmpty(magicLinkApiKey) ? null : magicLinkApiKey,
};

options.smartWalletConfig =
string.IsNullOrEmpty(factoryAddress) || string.IsNullOrEmpty(thirdwebApiKey)
? null
: new ThirdwebSDK.SmartWalletConfig()
{
factoryAddress = factoryAddress,
thirdwebApiKey = thirdwebApiKey,
gasless = gasless,
bundlerUrl = bundlerUrl,
paymasterUrl = paymasterUrl,
paymasterAPI = paymasterAPI,
entryPointAddress = entryPointAddress
};

SDK = new ThirdwebSDK(chainOrRPC, chainId, options);
}

Expand Down
13 changes: 13 additions & 0 deletions Assets/Thirdweb/Core/Scripts/ThirdwebSDK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public struct Options
public GaslessOptions? gasless;
public StorageOptions? storage;
public WalletOptions? wallet;
public SmartWalletConfig? smartWalletConfig;
}

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

[System.Serializable]
public struct SmartWalletConfig
{
public string factoryAddress;
public string thirdwebApiKey;
public bool gasless;
public string bundlerUrl;
public string paymasterUrl;
public string paymasterAPI;
public string entryPointAddress;
}

/// <summary>
/// Storage configuration options.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions Assets/Thirdweb/Core/Scripts/Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -603,5 +603,6 @@ public enum WalletProvider
Injected,
MagicLink,
LocalWallet,
SmartWallet
}
}
Loading

0 comments on commit 150d53d

Please sign in to comment.