Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EmbeddedWallet -> InAppWallet - Scripts, Prefabs, Files #175

Merged
merged 4 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Assets/Thirdweb/Core/Prefabs/ThirdwebManager.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,19 @@ MonoBehaviour:
forwarderDomainOverride:
forwaderVersionOverride:
walletConnectProjectId:
walletConnectEnableExplorer: 0
walletConnectExplorerRecommendedWalletIds: []
walletConnectWalletImages: []
walletConnectDesktopWallets: []
walletConnectMobileWallets: []
walletConnectThemeMode:
factoryAddress:
gasless: 0
deployOnSign: 0
erc20PaymasterAddress:
erc20TokenAddress:
bundlerUrl:
paymasterUrl:
entryPointAddress:
WalletConnectPrefab: {fileID: 3202619366221042887, guid: c8c0099339b6ef54f87b1f049c5eb74f, type: 3}
MetamaskPrefab: {fileID: 3503421935870801903, guid: f09c6d17b08bed346bec9906a7f17092, type: 3}
EmbeddedWalletPrefab: {fileID: 3202619366221042887, guid: bef3cf6334b95f14883fb1b8095a0960, type: 3}
InAppWalletPrefab: {fileID: 3202619366221042887, guid: bef3cf6334b95f14883fb1b8095a0960, type: 3}
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ GameObject:
- component: {fileID: 5}
- component: {fileID: 6}
m_Layer: 5
m_Name: Canvas_EWS
m_Name: Canvas_InAppWallet
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand Down Expand Up @@ -1605,7 +1605,7 @@ GameObject:
- component: {fileID: 3202619366221042882}
- component: {fileID: 7585343039585244319}
m_Layer: 0
m_Name: WalletProvider_EmbeddedWallet
m_Name: WalletProvider_InAppWallet
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand Down Expand Up @@ -1640,14 +1640,14 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e763a7f1e5865f44a89d3aa169a46691, type: 3}
m_Name:
m_EditorClassIdentifier:
EmbeddedWalletCanvas: {fileID: 3040857394524813045}
InAppWalletCanvas: {fileID: 3040857394524813045}
OTPInput: {fileID: 8918216154903914298}
RecoveryInput: {fileID: 1061075594562819070}
SubmitButton: {fileID: 1670754136118778672}
RecoveryCodesCanvas: {fileID: 3065337689055971296}
RecoveryCodesText: {fileID: 4840930599477263590}
RecoveryCodesCopy: {fileID: 7908066674043299061}
OnEmailOTPVerificationFailed:
OnOTPVerificationFailed:
m_PersistentCalls:
m_Calls: []
--- !u!1 &3462065987877024667
Expand Down
8 changes: 4 additions & 4 deletions Assets/Thirdweb/Core/Scripts/ThirdwebInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public override async Task<object> InterceptSendRequestAsync<T>(Func<RpcRequest,
var personalSign = new PersonalSign(msg, acc);
return await WalletConnect.Instance.RequestAsync<PersonalSign, string>(personalSign);
case WalletProvider.LocalWallet:
case WalletProvider.EmbeddedWallet:
case WalletProvider.InAppWallet:
var message = request.RawParameters[0].ToString();
return new EthereumMessageSigner().EncodeUTF8AndSign(message, new EthECKey(_thirdwebWallet.GetLocalAccount().PrivateKey));
case WalletProvider.SmartWallet:
Expand All @@ -74,7 +74,7 @@ public override async Task<object> InterceptSendRequestAsync<T>(Func<RpcRequest,
var ethSignTypedDataV4 = new EthSignTypedDataV4(account, data);
return await WalletConnect.Instance.RequestAsync<EthSignTypedDataV4, string>(ethSignTypedDataV4);
case WalletProvider.LocalWallet:
case WalletProvider.EmbeddedWallet:
case WalletProvider.InAppWallet:
throw new Exception("Please use Wallet.SignTypedDataV4 instead.");
case WalletProvider.SmartWallet:
return await signerWeb3.Client.SendRequestAsync<T>("eth_signTypedData_v4", null, request.RawParameters);
Expand Down Expand Up @@ -146,7 +146,7 @@ params object[] paramList
var personalSign = new PersonalSign(msg, acc);
return await WalletConnect.Instance.RequestAsync<PersonalSign, string>(personalSign);
case WalletProvider.LocalWallet:
case WalletProvider.EmbeddedWallet:
case WalletProvider.InAppWallet:
var message = paramList[0].ToString();
return new EthereumMessageSigner().EncodeUTF8AndSign(message, new EthECKey(_thirdwebWallet.GetLocalAccount().PrivateKey));
case WalletProvider.SmartWallet:
Expand All @@ -167,7 +167,7 @@ params object[] paramList
var ethSignTypedDataV4 = new EthSignTypedDataV4(acc, msg);
return await WalletConnect.Instance.RequestAsync<EthSignTypedDataV4, string>(ethSignTypedDataV4);
case WalletProvider.LocalWallet:
case WalletProvider.EmbeddedWallet:
case WalletProvider.InAppWallet:
throw new Exception("Please use Wallet.SignTypedDataV4 instead.");
case WalletProvider.SmartWallet:
return await signerWeb3.Client.SendRequestAsync<T>("eth_signTypedData_v4", null, paramList);
Expand Down
4 changes: 2 additions & 2 deletions Assets/Thirdweb/Core/Scripts/ThirdwebManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ public class ThirdwebManager : MonoBehaviour
[Tooltip("Instantiates the Metamask SDK for Native platforms.")]
public GameObject MetamaskPrefab;

[Tooltip("Instantiates the EmbeddedWallet SDK for Native platforms.")]
public GameObject EmbeddedWalletPrefab;
[Tooltip("Instantiates the InAppWallet SDK for Native platforms.")]
public GameObject InAppWalletPrefab;

public ThirdwebSDK SDK;

Expand Down
6 changes: 3 additions & 3 deletions Assets/Thirdweb/Core/Scripts/ThirdwebSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ await Connect(
case WalletProvider.Hyperplay:
ActiveWallet = new ThirdwebHyperplay(ChainId.ToString());
break;
case WalletProvider.EmbeddedWallet:
case WalletProvider.InAppWallet:
if (string.IsNullOrEmpty(Options.clientId))
throw new UnityException("thirdweb client id is required for EmbeddedWallet connection method!");
ActiveWallet = new ThirdwebEmbeddedWallet(Options.clientId, Options.bundleId);
throw new UnityException("thirdweb client id is required for InAppWallet connection method!");
ActiveWallet = new ThirdwebInAppWallet(Options.clientId, Options.bundleId);
break;
default:
throw new UnityException("This wallet connection method is not supported on this platform!");
Expand Down
10 changes: 5 additions & 5 deletions Assets/Thirdweb/Core/Scripts/Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public async Task<string> GetAddress()
}

/// <summary>
/// Gets the connected embedded wallet email if any.
/// Gets the connected In App Wallet email if any.
/// </summary>
public async Task<string> GetEmail()
{
Expand Down Expand Up @@ -985,7 +985,7 @@ public class WalletConnection
/// <param name="password">Optional wallet encryption password</param>
/// <param name="email">The email to login with if using email based providers.</param>
/// <param name="personalWallet">The personal wallet provider if using smart wallets.</param>
/// <param name="authOptions">The authentication options if using embedded wallets.</param>
/// <param name="authOptions">The authentication options if using in app wallets.</param>
/// <param name="smartWalletAccountOverride">Optionally choose to connect to a smart account the personal wallet is not an admin of.</param>
/// <returns>A new instance of the <see cref="WalletConnection"/> class.</returns>
public WalletConnection(
Expand All @@ -1011,7 +1011,7 @@ public WalletConnection(
}

/// <summary>
/// Embedded Wallet Authentication Options.
/// In App Wallet Authentication Options.
/// </summary>
[System.Serializable]
public class AuthOptions
Expand Down Expand Up @@ -1048,11 +1048,11 @@ public enum WalletProvider
LocalWallet,
SmartWallet,
Hyperplay,
EmbeddedWallet
InAppWallet
}

/// <summary>
/// Represents the available auth providers for Embedded Wallet.
/// Represents the available auth providers for In App Wallet.
/// </summary>
[System.Serializable]
public enum AuthProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Thirdweb.Wallets
{
public class ThirdwebEmbeddedWallet : IThirdwebWallet
public class ThirdwebInAppWallet : IThirdwebWallet
{
private Web3 _web3;
private readonly WalletProvider _provider;
Expand All @@ -16,10 +16,10 @@ public class ThirdwebEmbeddedWallet : IThirdwebWallet
private Account _account;
private string _email;

public ThirdwebEmbeddedWallet(string clientId, string bundleId)
public ThirdwebInAppWallet(string clientId, string bundleId)
{
_web3 = null;
_provider = WalletProvider.EmbeddedWallet;
_provider = WalletProvider.InAppWallet;
_signerProvider = WalletProvider.LocalWallet;
_embeddedWallet = new EmbeddedWallet(clientId, bundleId, "unity", ThirdwebSDK.version);
}
Expand All @@ -28,12 +28,12 @@ public async Task<string> Connect(WalletConnection walletConnection, string rpc)
{
await _embeddedWallet.VerifyThirdwebClientIdAsync("");

if (EmbeddedWalletUI.Instance == null)
if (InAppWalletUI.Instance == null)
{
GameObject.Instantiate(ThirdwebManager.Instance.EmbeddedWalletPrefab);
GameObject.Instantiate(ThirdwebManager.Instance.InAppWalletPrefab);
}

var user = await EmbeddedWalletUI.Instance.Connect(_embeddedWallet, walletConnection.email, walletConnection.phoneNumber, walletConnection.authOptions);
var user = await InAppWalletUI.Instance.Connect(_embeddedWallet, walletConnection.email, walletConnection.phoneNumber, walletConnection.authOptions);
_account = user.Account;
_email = user.EmailAddress;
_web3 = new Web3(_account, rpc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

namespace Thirdweb.Wallets
{
public class EmbeddedWalletUI : MonoBehaviour
public class InAppWalletUI : MonoBehaviour
{
#region Variables

public GameObject EmbeddedWalletCanvas;
public GameObject InAppWalletCanvas;
public TMP_InputField OTPInput;
public TMP_InputField RecoveryInput;
public Button SubmitButton;
Expand All @@ -42,7 +42,7 @@ public class EmbeddedWalletUI : MonoBehaviour

#region Initialization

public static EmbeddedWalletUI Instance { get; private set; }
public static InAppWalletUI Instance { get; private set; }

private void Awake()
{
Expand Down Expand Up @@ -78,7 +78,7 @@ public virtual async Task<User> Connect(EmbeddedWallet embeddedWallet, string em
RecoveryInput.gameObject.SetActive(false);
SubmitButton.onClick.RemoveAllListeners();
RecoveryCodesCopy.onClick.RemoveAllListeners();
EmbeddedWalletCanvas.SetActive(false);
InAppWalletCanvas.SetActive(false);
RecoveryCodesCanvas.SetActive(false);

try
Expand Down Expand Up @@ -135,7 +135,7 @@ public virtual async Task<User> Connect(EmbeddedWallet embeddedWallet, string em
}

await new WaitUntil(() => _user != null || _exception != null);
EmbeddedWalletCanvas.SetActive(false);
InAppWalletCanvas.SetActive(false);
if (_exception != null)
throw _exception;
return _user;
Expand All @@ -157,7 +157,7 @@ public virtual async Task LoginWithOTP()

SubmitButton.onClick.AddListener(OnSubmitOTP);
await OnSendOTP();
EmbeddedWalletCanvas.SetActive(true);
InAppWalletCanvas.SetActive(true);
}

public virtual async Task OnSendOTP()
Expand Down Expand Up @@ -220,7 +220,7 @@ public virtual async Task LoginWithPhoneNumber()

SubmitButton.onClick.AddListener(OnSubmitPhoneOTP);
await OnSendPhoneOTP();
EmbeddedWalletCanvas.SetActive(true);
InAppWalletCanvas.SetActive(true);
}

public virtual async Task OnSendPhoneOTP()
Expand Down Expand Up @@ -385,7 +385,7 @@ public virtual void DisplayRecoveryInput(bool hideOtpInput)
if (hideOtpInput)
OTPInput.gameObject.SetActive(false);
RecoveryInput.gameObject.SetActive(true);
EmbeddedWalletCanvas.SetActive(true);
InAppWalletCanvas.SetActive(true);
}

public virtual void ShowRecoveryCodes(EmbeddedWallet.VerifyResult res)
Expand Down
6 changes: 3 additions & 3 deletions Assets/Thirdweb/Editor/ThirdwebManagerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class ThirdwebManagerEditor : Editor
private SerializedProperty entryPointAddressProperty;
private SerializedProperty WalletConnectPrefabProperty;
private SerializedProperty MetamaskPrefabProperty;
private SerializedProperty EmbeddedWalletPrefabProperty;
private SerializedProperty InAppWalletPrefabProperty;

private ReorderableList supportedChainsList;
private bool[] sectionExpanded;
Expand Down Expand Up @@ -87,7 +87,7 @@ private void OnEnable()
entryPointAddressProperty = serializedObject.FindProperty("entryPointAddress");
WalletConnectPrefabProperty = serializedObject.FindProperty("WalletConnectPrefab");
MetamaskPrefabProperty = serializedObject.FindProperty("MetamaskPrefab");
EmbeddedWalletPrefabProperty = serializedObject.FindProperty("EmbeddedWalletPrefab");
InAppWalletPrefabProperty = serializedObject.FindProperty("InAppWalletPrefab");

supportedChainsList = new ReorderableList(serializedObject, supportedChainsProperty, true, true, true, true);
supportedChainsList.drawHeaderCallback = rect =>
Expand Down Expand Up @@ -374,7 +374,7 @@ public override void OnInspectorGUI()
{
EditorGUILayout.PropertyField(WalletConnectPrefabProperty);
EditorGUILayout.PropertyField(MetamaskPrefabProperty);
EditorGUILayout.PropertyField(EmbeddedWalletPrefabProperty);
EditorGUILayout.PropertyField(InAppWalletPrefabProperty);
}

EditorGUILayout.EndVertical();
Expand Down
14 changes: 7 additions & 7 deletions Assets/Thirdweb/Examples/Scripts/Prefabs/Prefab_ConnectWallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class WalletIcon
public class WalletProviderUIDictionary : SerializableDictionaryBase<WalletProvider, GameObject> { }

[Header("Enabled Wallet Providers. Press Play to see changes.")]
public List<WalletProvider> enabledWalletProviders = new List<WalletProvider> { WalletProvider.LocalWallet, WalletProvider.EmbeddedWallet, WalletProvider.SmartWallet };
public List<WalletProvider> enabledWalletProviders = new List<WalletProvider> { WalletProvider.LocalWallet, WalletProvider.InAppWallet, WalletProvider.SmartWallet };

[Header("Use ERC-4337 (Account Abstraction) compatible smart wallets.\nEnabling this will connect user to the associated smart wallet as per your ThirwebManager settings.")]
public bool useSmartWallets = false;
Expand Down Expand Up @@ -96,10 +96,10 @@ public void ConnectOauth(string authProviderStr)
provider: WalletProvider.SmartWallet,
chainId: BigInteger.Parse(_currentChainData.chainId),
authOptions: new AuthOptions(Enum.Parse<AuthProvider>(authProviderStr)),
personalWallet: WalletProvider.EmbeddedWallet
personalWallet: WalletProvider.InAppWallet
)
: new WalletConnection(
provider: WalletProvider.EmbeddedWallet,
provider: WalletProvider.InAppWallet,
chainId: BigInteger.Parse(_currentChainData.chainId),
authOptions: new AuthOptions(Enum.Parse<AuthProvider>(authProviderStr))
);
Expand All @@ -120,10 +120,10 @@ public void ConnectEmail()
chainId: BigInteger.Parse(_currentChainData.chainId),
email: emailInput.text,
authOptions: new AuthOptions(AuthProvider.EmailOTP),
personalWallet: WalletProvider.EmbeddedWallet
personalWallet: WalletProvider.InAppWallet
)
: new WalletConnection(
provider: WalletProvider.EmbeddedWallet,
provider: WalletProvider.InAppWallet,
chainId: BigInteger.Parse(_currentChainData.chainId),
email: emailInput.text,
authOptions: new AuthOptions(AuthProvider.EmailOTP)
Expand All @@ -137,10 +137,10 @@ public void ConnectEmail()
chainId: BigInteger.Parse(_currentChainData.chainId),
phoneNumber: input,
authOptions: new AuthOptions(AuthProvider.PhoneOTP),
personalWallet: WalletProvider.EmbeddedWallet
personalWallet: WalletProvider.InAppWallet
)
: new WalletConnection(
provider: WalletProvider.EmbeddedWallet,
provider: WalletProvider.InAppWallet,
chainId: BigInteger.Parse(_currentChainData.chainId),
phoneNumber: input,
authOptions: new AuthOptions(AuthProvider.PhoneOTP)
Expand Down
357,156 changes: 356,907 additions & 249 deletions Assets/WebGLTemplates/Thirdweb/lib/thirdweb-unity-bridge.js

Large diffs are not rendered by default.

Loading