Skip to content

Commit

Permalink
drop the enum, match type from GetLinkedAccounts
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFirekeeper committed Dec 17, 2024
1 parent d8d1432 commit 95673ad
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 39 deletions.
12 changes: 2 additions & 10 deletions Thirdweb.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]";
// 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
Expand Down
4 changes: 2 additions & 2 deletions Thirdweb/Thirdweb.Wallets/IThirdwebWallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ Task<List<LinkedAccount>> LinkAccount(
/// <summary>
/// Unlinks an account (auth method) from the current wallet. Must pass corresponding parameter to unlink.
/// </summary>
/// <param name="authProviderToUnlink">The auth provider to unlink.</param>
/// <param name="linkedType">The auth provider to unlink, use the type you get from GetLinkedAccounts.</param>
/// <param name="address">The related wallet address to unlink (if applicable).</param>
/// <param name="email">The related email to unlink (if applicable).</param>
/// <param name="phone">The related phone number to unlink (if applicable).</param>
/// <param name="id">The related user ID to unlink (if applicable).</param>
Task<List<LinkedAccount>> UnlinkAccount(UnlinkingType authProviderToUnlink, string address = null, string email = null, string phone = null, string id = null);
Task<List<LinkedAccount>> UnlinkAccount(string linkedType, string address = null, string email = null, string phone = null, string id = null);

/// <summary>
/// Returns a list of linked accounts to the current wallet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,14 @@ public string GenerateExternalLoginLink(string redirectUrl)

#region Account Linking

public async Task<List<LinkedAccount>> UnlinkAccount(UnlinkingType authProviderToUnlink, string address = null, string email = null, string phone = null, string id = null)
public async Task<List<LinkedAccount>> UnlinkAccount(string linkedType, string address = null, string email = null, string phone = null, string id = null)
{
if (!await this.IsConnected().ConfigureAwait(false))
{
throw new InvalidOperationException("Cannot unlink account with a wallet that is not connected. Please login to the wallet before unlinking other wallets.");
}

var currentAccountToken = this.EmbeddedWallet.GetSessionData()?.AuthToken;
var linkedType = authProviderToUnlink.ToString();
var linkedDetails = new
{
address,
Expand Down
22 changes: 0 additions & 22 deletions Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/// <summary>
/// Represents a linked account.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public virtual Task<List<LinkedAccount>> GetLinkedAccounts()
throw new InvalidOperationException("GetLinkedAccounts is not supported for private key wallets.");
}

public Task<List<LinkedAccount>> UnlinkAccount(UnlinkingType authProviderToUnlink, string address = null, string email = null, string phone = null, string id = null)
public Task<List<LinkedAccount>> 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.");
}
Expand Down
4 changes: 2 additions & 2 deletions Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1167,14 +1167,14 @@ public Task Disconnect()
return Task.CompletedTask;
}

public async Task<List<LinkedAccount>> UnlinkAccount(UnlinkingType authProviderToUnlink, string address = null, string email = null, string phone = null, string id = null)
public async Task<List<LinkedAccount>> 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<List<LinkedAccount>> LinkAccount(
Expand Down

0 comments on commit 95673ad

Please sign in to comment.