From 95673ad0b3e7d47ef1393857d40430909713de45 Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Tue, 17 Dec 2024 13:18:35 +0700 Subject: [PATCH] drop the enum, match type from GetLinkedAccounts --- Thirdweb.Console/Program.cs | 12 ++-------- Thirdweb/Thirdweb.Wallets/IThirdwebWallet.cs | 4 ++-- .../EcosystemWallet/EcosystemWallet.cs | 3 +-- .../InAppWallet/InAppWallet.Types.cs | 22 ------------------- .../PrivateKeyWallet/PrivateKeyWallet.cs | 2 +- .../SmartWallet/SmartWallet.cs | 4 ++-- 6 files changed, 8 insertions(+), 39 deletions(-) diff --git a/Thirdweb.Console/Program.cs b/Thirdweb.Console/Program.cs index d65ea60..b6b9eef 100644 --- a/Thirdweb.Console/Program.cs +++ b/Thirdweb.Console/Program.cs @@ -260,24 +260,16 @@ // var oldLinkedAccounts = await inAppWalletMain.GetLinkedAccounts(); // Console.WriteLine($"Old linked accounts: {JsonConvert.SerializeObject(oldLinkedAccounts, Formatting.Indented)}"); -// External wallet variant +// // External wallet variant // var externalWallet = await PrivateKeyWallet.Generate(client: client); // var externalWalletAddress = await externalWallet.GetAddress(); // var inAppWalletToLink = await InAppWallet.Create(client: client, authProvider: AuthProvider.Siwe, siweSigner: externalWallet); // _ = await inAppWalletMain.LinkAccount(walletToLink: inAppWalletToLink, chainId: 421614); -// Email variant -// var linkedEmail = "firekeeper+unlinkingtest@thirdweb.com"; -// var inAppWalletToLink = await InAppWallet.Create(client: client, email: linkedEmail); -// await inAppWalletToLink.SendOTP(); -// Console.WriteLine("Enter OTP:"); -// var otp = Console.ReadLine(); -// _ = await inAppWalletMain.LinkAccount(walletToLink: inAppWalletToLink, otp: otp); - // var linkedAccounts = await inAppWalletMain.GetLinkedAccounts(); // Console.WriteLine($"Linked accounts: {JsonConvert.SerializeObject(linkedAccounts, Formatting.Indented)}"); -// var unlinkingResult = await inAppWalletMain.UnlinkAccount(authProviderToUnlink: UnlinkingType.email, email: linkedEmail); +// var unlinkingResult = await inAppWalletMain.UnlinkAccount(linkedType: "siwe", address: externalWalletAddress); // Console.WriteLine($"Unlinking result: {JsonConvert.SerializeObject(unlinkingResult, Formatting.Indented)}"); #endregion diff --git a/Thirdweb/Thirdweb.Wallets/IThirdwebWallet.cs b/Thirdweb/Thirdweb.Wallets/IThirdwebWallet.cs index 0f87f20..16f62fb 100644 --- a/Thirdweb/Thirdweb.Wallets/IThirdwebWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/IThirdwebWallet.cs @@ -158,12 +158,12 @@ Task> LinkAccount( /// /// Unlinks an account (auth method) from the current wallet. Must pass corresponding parameter to unlink. /// - /// The auth provider to unlink. + /// The auth provider to unlink, use the type you get from GetLinkedAccounts. /// The related wallet address to unlink (if applicable). /// The related email to unlink (if applicable). /// The related phone number to unlink (if applicable). /// The related user ID to unlink (if applicable). - Task> UnlinkAccount(UnlinkingType authProviderToUnlink, string address = null, string email = null, string phone = null, string id = null); + Task> UnlinkAccount(string linkedType, string address = null, string email = null, string phone = null, string id = null); /// /// Returns a list of linked accounts to the current wallet. diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/EcosystemWallet/EcosystemWallet.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/EcosystemWallet/EcosystemWallet.cs index 666f831..5b9c73e 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/EcosystemWallet/EcosystemWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/EcosystemWallet/EcosystemWallet.cs @@ -332,7 +332,7 @@ public string GenerateExternalLoginLink(string redirectUrl) #region Account Linking - public async Task> UnlinkAccount(UnlinkingType authProviderToUnlink, string address = null, string email = null, string phone = null, string id = null) + public async Task> UnlinkAccount(string linkedType, string address = null, string email = null, string phone = null, string id = null) { if (!await this.IsConnected().ConfigureAwait(false)) { @@ -340,7 +340,6 @@ public async Task> UnlinkAccount(UnlinkingType authProviderT } var currentAccountToken = this.EmbeddedWallet.GetSessionData()?.AuthToken; - var linkedType = authProviderToUnlink.ToString(); var linkedDetails = new { address, diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.Types.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.Types.cs index 2079c04..ca02287 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.Types.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.Types.cs @@ -26,28 +26,6 @@ public enum AuthProvider Steam } -public enum UnlinkingType -{ - apple, - coinbase, - discord, - email, - facebook, - farcaster, - github, - google, - guest, - line, - passkey, - phone, - siwe, - steam, - telegram, - twitch, - x, - wallet -} - /// /// Represents a linked account. /// diff --git a/Thirdweb/Thirdweb.Wallets/PrivateKeyWallet/PrivateKeyWallet.cs b/Thirdweb/Thirdweb.Wallets/PrivateKeyWallet/PrivateKeyWallet.cs index c916147..b274665 100644 --- a/Thirdweb/Thirdweb.Wallets/PrivateKeyWallet/PrivateKeyWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/PrivateKeyWallet/PrivateKeyWallet.cs @@ -380,7 +380,7 @@ public virtual Task> GetLinkedAccounts() throw new InvalidOperationException("GetLinkedAccounts is not supported for private key wallets."); } - public Task> UnlinkAccount(UnlinkingType authProviderToUnlink, string address = null, string email = null, string phone = null, string id = null) + public Task> UnlinkAccount(string linkedType, string address = null, string email = null, string phone = null, string id = null) { throw new InvalidOperationException("UnlinkAccount is not supported for private key wallets."); } diff --git a/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs b/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs index f2b4990..44feb3c 100644 --- a/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs @@ -1167,14 +1167,14 @@ public Task Disconnect() return Task.CompletedTask; } - public async Task> UnlinkAccount(UnlinkingType authProviderToUnlink, string address = null, string email = null, string phone = null, string id = null) + public async Task> UnlinkAccount(string linkedType, string address = null, string email = null, string phone = null, string id = null) { var personalWallet = await this.GetPersonalWallet().ConfigureAwait(false); if (personalWallet is not InAppWallet and not EcosystemWallet) { throw new Exception("SmartWallet.UnlinkAccount is only supported if the signer is an InAppWallet or EcosystemWallet"); } - return await personalWallet.UnlinkAccount(authProviderToUnlink, address, email, phone, id).ConfigureAwait(false); + return await personalWallet.UnlinkAccount(linkedType, address, email, phone, id).ConfigureAwait(false); } public async Task> LinkAccount(