From 1ccdc073ebeae7cb6b2bc6cc60a1d03355fb8613 Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Fri, 8 Aug 2025 06:50:50 +0700 Subject: [PATCH 1/4] Add TikTok as AuthProvider Introduces TikTok as a new AuthProvider across InAppWallet and EcosystemWallet, updating relevant enums, switch statements, and OAuth login link generation. Also refactors some code for consistency, fixes minor formatting, and ensures TikTok is handled in provider mappings and UI logic. --- Thirdweb.Console/Program.cs | 2 +- .../Thirdweb.Utils/Thirdweb.Utils.Tests.cs | 18 +-- Thirdweb/Thirdweb.RPC/ThirdwebRPC.cs | 2 +- Thirdweb/Thirdweb.Utils/Utils.cs | 8 +- .../EcosystemWallet/EcosystemWallet.cs | 69 ++++++----- .../EmbeddedWallet.Authentication/Server.cs | 21 ++-- .../InAppWallet/InAppWallet.Types.cs | 1 + .../SmartWallet/SmartWallet.cs | 109 +++++++++--------- 8 files changed, 113 insertions(+), 117 deletions(-) diff --git a/Thirdweb.Console/Program.cs b/Thirdweb.Console/Program.cs index a796ffc4..1598b895 100644 --- a/Thirdweb.Console/Program.cs +++ b/Thirdweb.Console/Program.cs @@ -742,7 +742,7 @@ #region InAppWallet - OAuth -// var inAppWalletOAuth = await InAppWallet.Create(client: client, authProvider: AuthProvider.Github); +// var inAppWalletOAuth = await InAppWallet.Create(client: client, authProvider: AuthProvider.TikTok); // if (!await inAppWalletOAuth.IsConnected()) // { // _ = await inAppWalletOAuth.LoginWithOauth( diff --git a/Thirdweb.Tests/Thirdweb.Utils/Thirdweb.Utils.Tests.cs b/Thirdweb.Tests/Thirdweb.Utils/Thirdweb.Utils.Tests.cs index f1802b95..e151052a 100644 --- a/Thirdweb.Tests/Thirdweb.Utils/Thirdweb.Utils.Tests.cs +++ b/Thirdweb.Tests/Thirdweb.Utils/Thirdweb.Utils.Tests.cs @@ -229,7 +229,7 @@ public void GenerateSIWE_ReturnsCorrectValue() Domain = "thirdweb.com", IssuedAt = "0", ExpirationTime = "0", - InvalidBefore = "0" + InvalidBefore = "0", }; var expectedSIWE = "thirdweb.com wants you to sign in with your Ethereum account:\n0x0000000000000000000000000000000000000000\n\n\nVersion: 1\nChain ID: 421614\nNonce: 0\nIssued At: 0\nExpiration Time: 0\nNot Before: 0"; @@ -252,7 +252,7 @@ public void GenerateSIWE_WithAllOptional_ReturnsCorrectValue() InvalidBefore = "0", Statement = "This is a statement", Uri = "https://thirdweb.com", - Resources = new List() { "resource1", "resource2" } + Resources = new List() { "resource1", "resource2" }, }; var expectedSIWE = "thirdweb.com wants you to sign in with your Ethereum account:\n0x0000000000000000000000000000000000000000\n\nThis is a statement\n\nURI: https://thirdweb.com\nVersion: 1\nChain ID: 421614\nNonce: 0\nIssued At: 0\nExpiration Time: 0\nNot Before: 0\nResources:\n- resource1\n- resource2"; @@ -273,7 +273,7 @@ public void GenerateSIWE_WithResources_ReturnsCorrectValue() IssuedAt = "0", ExpirationTime = "0", InvalidBefore = "0", - Resources = new List() { "resource1", "resource2" } + Resources = new List() { "resource1", "resource2" }, }; var expectedSIWE = "thirdweb.com wants you to sign in with your Ethereum account:\n0x0000000000000000000000000000000000000000\n\n\nVersion: 1\nChain ID: 421614\nNonce: 0\nIssued At: 0\nExpiration Time: 0\nNot Before: 0\nResources:\n- resource1\n- resource2"; @@ -300,7 +300,7 @@ public void GenerateSIWE_ThrowsOnNullDomain() Domain = null!, IssuedAt = "0", ExpirationTime = "0", - InvalidBefore = "0" + InvalidBefore = "0", }; _ = Assert.Throws(() => Utils.GenerateSIWE(loginPayloadData)); } @@ -317,7 +317,7 @@ public void GenerateSIWE_ThrowsOnNullAddress() Domain = "thirdweb.com", IssuedAt = "0", ExpirationTime = "0", - InvalidBefore = "0" + InvalidBefore = "0", }; _ = Assert.Throws(() => Utils.GenerateSIWE(loginPayloadData)); } @@ -334,7 +334,7 @@ public void GenerateSIWE_ThrowsOnNullVersion() Domain = "thirdweb.com", IssuedAt = "0", ExpirationTime = "0", - InvalidBefore = "0" + InvalidBefore = "0", }; _ = Assert.Throws(() => Utils.GenerateSIWE(loginPayloadData)); } @@ -351,7 +351,7 @@ public void GenerateSIWE_ThrowsOnNullChainId() Domain = "thirdweb.com", IssuedAt = "0", ExpirationTime = "0", - InvalidBefore = "0" + InvalidBefore = "0", }; _ = Assert.Throws(() => Utils.GenerateSIWE(loginPayloadData)); } @@ -368,7 +368,7 @@ public void GenerateSIWE_ThrowsOnNullNonce() Domain = "thirdweb.com", IssuedAt = "0", ExpirationTime = "0", - InvalidBefore = "0" + InvalidBefore = "0", }; _ = Assert.Throws(() => Utils.GenerateSIWE(loginPayloadData)); } @@ -385,7 +385,7 @@ public void GenerateSIWE_ThrowsOnNullIssuedAt() Domain = "thirdweb.com", IssuedAt = null!, ExpirationTime = "0", - InvalidBefore = "0" + InvalidBefore = "0", }; _ = Assert.Throws(() => Utils.GenerateSIWE(loginPayloadData)); } diff --git a/Thirdweb/Thirdweb.RPC/ThirdwebRPC.cs b/Thirdweb/Thirdweb.RPC/ThirdwebRPC.cs index 88884a74..a3449566 100644 --- a/Thirdweb/Thirdweb.RPC/ThirdwebRPC.cs +++ b/Thirdweb/Thirdweb.RPC/ThirdwebRPC.cs @@ -117,7 +117,7 @@ public async Task SendRequestAsync(string method, params o { Method = method, Params = parameters, - Id = requestId + Id = requestId, }; lock (this._responseLock) diff --git a/Thirdweb/Thirdweb.Utils/Utils.cs b/Thirdweb/Thirdweb.Utils/Utils.cs index efd33154..cec2c9ef 100644 --- a/Thirdweb/Thirdweb.Utils/Utils.cs +++ b/Thirdweb/Thirdweb.Utils/Utils.cs @@ -712,7 +712,7 @@ public static async Task IsEip155Enforced(ThirdwebClient client, BigIntege "chainid no support", "chainid (0)", "chainid(0)", - "invalid sender" + "invalid sender", }; if (errorSubstrings.Any(errorMsg.Contains)) @@ -1156,7 +1156,7 @@ public static (ThirdwebTransactionInput transactionInput, string signature) Deco maxPriorityFeePerGas: maxPriorityFeePerGas ) { - AuthorizationList = authorizations + AuthorizationList = authorizations, }, signature.CreateStringSignature() ); @@ -1186,7 +1186,7 @@ public static List DecodeAutorizationList(byte[] authoriza Nonce = new HexBigInteger(decodedItem[2].RLPData.ToBigIntegerFromRLPDecoded()).HexValue, YParity = signature.V.BytesToHex(), R = signature.R.BytesToHex(), - S = signature.S.BytesToHex() + S = signature.S.BytesToHex(), }; authorizationLists.Add(authorizationListItem); } @@ -1221,7 +1221,7 @@ public static async void TrackTransaction(ThirdwebTransaction transaction, strin walletAddress = await wallet.GetAddress().ConfigureAwait(false), walletType = wallet.WalletId, contractAddress = transaction.Input.To, - gasPrice = transaction.Input.GasPrice?.Value ?? transaction.Input.MaxFeePerGas?.Value + gasPrice = transaction.Input.GasPrice?.Value ?? transaction.Input.MaxFeePerGas?.Value, } ), Encoding.UTF8, diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/EcosystemWallet/EcosystemWallet.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/EcosystemWallet/EcosystemWallet.cs index 53c5ae59..e83153dd 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/EcosystemWallet/EcosystemWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/EcosystemWallet/EcosystemWallet.cs @@ -16,7 +16,7 @@ public enum ExecutionMode { EOA, EIP7702, - EIP7702Sponsored + EIP7702Sponsored, } /// @@ -137,6 +137,7 @@ public static async Task Create( Thirdweb.AuthProvider.Line => "Line", Thirdweb.AuthProvider.Guest => "Guest", Thirdweb.AuthProvider.X => "X", + Thirdweb.AuthProvider.TikTok => "TikTok", Thirdweb.AuthProvider.Coinbase => "Coinbase", Thirdweb.AuthProvider.Github => "Github", Thirdweb.AuthProvider.Twitch => "Twitch", @@ -195,7 +196,7 @@ public static async Task Create( executionMode ) { - Address = userAddress + Address = userAddress, }; } catch @@ -216,7 +217,7 @@ public static async Task Create( executionMode ) { - Address = null + Address = null, }; } } @@ -316,8 +317,8 @@ private async Task PostAuth(Server.VerifyResult result) private async Task MigrateShardToEnclave(Server.VerifyResult authResult) { - var (address, encryptedPrivateKeyB64, ivB64, kmsCiphertextB64) = await this.EmbeddedWallet - .GenerateEncryptionDataAsync(authResult.AuthToken, this.LegacyEncryptionKey ?? authResult.RecoveryCode) + var (address, encryptedPrivateKeyB64, ivB64, kmsCiphertextB64) = await this + .EmbeddedWallet.GenerateEncryptionDataAsync(authResult.AuthToken, this.LegacyEncryptionKey ?? authResult.RecoveryCode) .ConfigureAwait(false); var url = $"{ENCLAVE_PATH}/migrate"; @@ -326,7 +327,7 @@ private async Task MigrateShardToEnclave(Server.VerifyResult authResult) address, encryptedPrivateKeyB64, ivB64, - kmsCiphertextB64 + kmsCiphertextB64, }; var requestContent = new StringContent(JsonConvert.SerializeObject(payload), Encoding.UTF8, "application/json"); @@ -492,7 +493,7 @@ public async Task CreateSessionKey( ExpiresAt = Utils.GetUnixTimeStampNow() + durationInSeconds, CallPolicies = callPolicies ?? new List(), TransferPolicies = transferPolicies ?? new List(), - Uid = uid ?? Guid.NewGuid().ToByteArray() + Uid = uid ?? Guid.NewGuid().ToByteArray(), }; var userWalletAddress = await this.GetAddress(); @@ -643,8 +644,8 @@ public async Task> UnlinkAccount(LinkedAccount accountToUnli Email = linkedAccount.Details?.Email, Address = linkedAccount.Details?.Address, Phone = linkedAccount.Details?.Phone, - Id = linkedAccount.Details?.Id - } + Id = linkedAccount.Details?.Id, + }, } ); } @@ -744,6 +745,7 @@ public async Task> LinkAccount( case "Telegram": case "Line": case "X": + case "TikTok": case "Coinbase": case "Github": case "Twitch": @@ -770,8 +772,8 @@ public async Task> LinkAccount( Email = linkedAccount.Details?.Email, Address = linkedAccount.Details?.Address, Phone = linkedAccount.Details?.Phone, - Id = linkedAccount.Details?.Id - } + Id = linkedAccount.Details?.Id, + }, } ); } @@ -794,8 +796,8 @@ public async Task> GetLinkedAccounts() Email = linkedAccount.Details?.Email, Address = linkedAccount.Details?.Address, Phone = linkedAccount.Details?.Phone, - Id = linkedAccount.Details?.Id - } + Id = linkedAccount.Details?.Id, + }, } ); } @@ -838,11 +840,9 @@ public async Task SendOTP() } var serverRes = - string.IsNullOrEmpty(this.Email) && string.IsNullOrEmpty(this.PhoneNumber) - ? throw new Exception("Email or Phone Number is required for OTP login") - : this.Email == null - ? await this.EmbeddedWallet.VerifyPhoneOtpAsync(this.PhoneNumber, otp).ConfigureAwait(false) - : await this.EmbeddedWallet.VerifyEmailOtpAsync(this.Email, otp).ConfigureAwait(false); + string.IsNullOrEmpty(this.Email) && string.IsNullOrEmpty(this.PhoneNumber) ? throw new Exception("Email or Phone Number is required for OTP login") + : this.Email == null ? await this.EmbeddedWallet.VerifyPhoneOtpAsync(this.PhoneNumber, otp).ConfigureAwait(false) + : await this.EmbeddedWallet.VerifyEmailOtpAsync(this.Email, otp).ConfigureAwait(false); return serverRes; } @@ -1258,22 +1258,19 @@ public async Task SignTransaction(ThirdwebTransactionInput transaction) maxPriorityFeePerGas = transaction.MaxPriorityFeePerGas, chainId = transaction.ChainId, authorizationList = transaction.AuthorizationList != null && transaction.AuthorizationList.Count > 0 - ? transaction.AuthorizationList - .Select( - authorization => - new - { - chainId = authorization.ChainId.HexToNumber(), - address = authorization.Address, - nonce = authorization.Nonce.HexToNumber().ToString(), - yParity = authorization.YParity.HexToNumber(), - r = authorization.R.HexToNumber().ToString(), - s = authorization.S.HexToNumber().ToString() - } - ) + ? transaction + .AuthorizationList.Select(authorization => new + { + chainId = authorization.ChainId.HexToNumber(), + address = authorization.Address, + nonce = authorization.Nonce.HexToNumber().ToString(), + yParity = authorization.YParity.HexToNumber(), + r = authorization.R.HexToNumber().ToString(), + s = authorization.S.HexToNumber().ToString(), + }) .ToArray() - : null - } + : null, + }, }; var url = $"{ENCLAVE_PATH}/sign-transaction"; @@ -1308,8 +1305,8 @@ public async Task SendTransaction(ThirdwebTransactionInput transaction) { Target = transaction.To, Value = transaction.Value?.Value ?? BigInteger.Zero, - Data = transaction.Data.HexToBytes() - } + Data = transaction.Data.HexToBytes(), + }, }; switch (this.ExecutionMode) @@ -1441,7 +1438,7 @@ public async Task SignAuthorization(BigInteger chainId, st { address = contractAddress, chainId, - nonce + nonce, }; var requestContent = new StringContent(JsonConvert.SerializeObject(payload), Encoding.UTF8, "application/json"); diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/Server.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/Server.cs index 8c750ca1..6669fcf4 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/Server.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/Server.cs @@ -108,13 +108,12 @@ internal override async Task FetchAuthShareAsync(string authToken) // embedded-wallet/embedded-wallet-shares GET private async Task FetchRemoteSharesAsync(string authToken, bool wantsRecoveryShare) { - Dictionary queryParams = - new() - { - { "getEncryptedAuthShare", "true" }, - { "getEncryptedRecoveryShare", wantsRecoveryShare ? "true" : "false" }, - { "useSealedSecret", "false" } - }; + Dictionary queryParams = new() + { + { "getEncryptedAuthShare", "true" }, + { "getEncryptedRecoveryShare", wantsRecoveryShare ? "true" : "false" }, + { "useSealedSecret", "false" }, + }; var uri = MakeUri2023("/embedded-wallet/embedded-wallet-shares", queryParams); var response = await this.SendHttpWithAuthAsync(uri, authToken).ConfigureAwait(false); await CheckStatusCodeAsync(response).ConfigureAwait(false); @@ -201,7 +200,7 @@ internal override async Task VerifyGuestAsync(string sessionId) // login/oauthprovider internal override Task FetchHeadlessOauthLoginLinkAsync(string authProvider, string platform) { - return Task.FromResult(MakeUri2024($"/login/{authProvider}", new Dictionary { { "clientId", this._clientId }, { "platform", platform } }).ToString()); + return Task.FromResult(MakeUri2024($"/login/{authProvider.ToLower()}", new Dictionary { { "clientId", this._clientId }, { "platform", platform } }).ToString()); } // login/email @@ -389,7 +388,7 @@ private static async Task DeserializeAsync(ThirdwebHttpResponseMessage res private static Uri MakeUri2024(string path, IDictionary parameters = null) { - UriBuilder b = new(ROOT_URL) { Path = API_ROOT_PATH_2024 + path, }; + UriBuilder b = new(ROOT_URL) { Path = API_ROOT_PATH_2024 + path }; if (parameters != null && parameters.Any()) { var queryString = string.Join('&', parameters.Select((p) => $"{p.Key}={Uri.EscapeDataString(p.Value)}")); @@ -400,7 +399,7 @@ private static Uri MakeUri2024(string path, IDictionary paramete private static Uri MakeUri2023(string path, IDictionary parameters = null) { - UriBuilder b = new(ROOT_URL) { Path = API_ROOT_PATH_2023 + path, }; + UriBuilder b = new(ROOT_URL) { Path = API_ROOT_PATH_2023 + path }; if (parameters != null && parameters.Any()) { var queryString = string.Join('&', parameters.Select((p) => $"{p.Key}={Uri.EscapeDataString(p.Value)}")); @@ -418,7 +417,7 @@ private static StringContent MakeHttpContent(object data) private static string Serialize(object data) { - JsonSerializer jsonSerializer = new() { NullValueHandling = NullValueHandling.Ignore, }; + JsonSerializer jsonSerializer = new() { NullValueHandling = NullValueHandling.Ignore }; StringWriter stringWriter = new(); jsonSerializer.Serialize(stringWriter, data); var rv = stringWriter.ToString(); diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.Types.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.Types.cs index f4a78123..7d41e57b 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.Types.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.Types.cs @@ -20,6 +20,7 @@ public enum AuthProvider Line, Guest, X, + TikTok, Coinbase, Github, Twitch, diff --git a/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs b/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs index 8f36b9b4..717952df 100644 --- a/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs @@ -16,7 +16,7 @@ public enum TokenPaymaster NONE, BASE_USDC, CELO_CUSD, - LISK_LSK + LISK_LSK, } public class SmartWallet : IThirdwebWallet @@ -53,50 +53,49 @@ private struct TokenPaymasterConfig public BigInteger BalanceStorageSlot; } - private static readonly Dictionary _tokenPaymasterConfig = - new() + private static readonly Dictionary _tokenPaymasterConfig = new() + { { + TokenPaymaster.NONE, + new TokenPaymasterConfig() { - TokenPaymaster.NONE, - new TokenPaymasterConfig() - { - ChainId = 0, - PaymasterAddress = null, - TokenAddress = null, - BalanceStorageSlot = 0 - } - }, + ChainId = 0, + PaymasterAddress = null, + TokenAddress = null, + BalanceStorageSlot = 0, + } + }, + { + TokenPaymaster.BASE_USDC, + new TokenPaymasterConfig() { - TokenPaymaster.BASE_USDC, - new TokenPaymasterConfig() - { - ChainId = 8453, - PaymasterAddress = "0x2222f2738BE6bB7aA0Bfe4AEeAf2908172CF5539", - TokenAddress = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", - BalanceStorageSlot = 9 - } - }, + ChainId = 8453, + PaymasterAddress = "0x2222f2738BE6bB7aA0Bfe4AEeAf2908172CF5539", + TokenAddress = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", + BalanceStorageSlot = 9, + } + }, + { + TokenPaymaster.CELO_CUSD, + new TokenPaymasterConfig() { - TokenPaymaster.CELO_CUSD, - new TokenPaymasterConfig() - { - ChainId = 42220, - PaymasterAddress = "0x3feA3c5744D715ff46e91C4e5C9a94426DfF2aF9", - TokenAddress = "0x765DE816845861e75A25fCA122bb6898B8B1282a", - BalanceStorageSlot = 9 - } - }, + ChainId = 42220, + PaymasterAddress = "0x3feA3c5744D715ff46e91C4e5C9a94426DfF2aF9", + TokenAddress = "0x765DE816845861e75A25fCA122bb6898B8B1282a", + BalanceStorageSlot = 9, + } + }, + { + TokenPaymaster.LISK_LSK, + new TokenPaymasterConfig() { - TokenPaymaster.LISK_LSK, - new TokenPaymasterConfig() - { - ChainId = 1135, - PaymasterAddress = "0x9eb8cf7fBa5ed9EeDCC97a0d52254cc0e9B1AC25", - TokenAddress = "0xac485391EB2d7D88253a7F1eF18C37f4242D1A24", - BalanceStorageSlot = 9 - } + ChainId = 1135, + PaymasterAddress = "0x9eb8cf7fBa5ed9EeDCC97a0d52254cc0e9B1AC25", + TokenAddress = "0xac485391EB2d7D88253a7F1eF18C37f4242D1A24", + BalanceStorageSlot = 9, } - }; + }, + }; private bool UseERC20Paymaster => !string.IsNullOrEmpty(this._erc20PaymasterAddress) && !string.IsNullOrEmpty(this._erc20PaymasterToken); @@ -286,7 +285,7 @@ public async Task ForceDeploy() { Data = "0x", To = this._accountContract.Address, - Value = new HexBigInteger(0) + Value = new HexBigInteger(0), }; var txHash = await this.SendTransaction(input).ConfigureAwait(false); _ = await ThirdwebTransaction.WaitForTransactionReceipt(this.Client, this.ActiveChainId, txHash).ConfigureAwait(false); @@ -321,15 +320,15 @@ public async Task IsValidSignature(string message, string signature) { Target = erc6492Sig.Create2Factory, AllowFailure = true, - CallData = erc6492Sig.FactoryCalldata + CallData = erc6492Sig.FactoryCalldata, }, new() { Target = this._accountContract.Address, AllowFailure = true, - CallData = this._accountContract.CreateCallData("isValidSignature", message.HashPrefixedMessage().HexToBytes(), erc6492Sig.SigToValidate).HexToBytes() - } - } + CallData = this._accountContract.CreateCallData("isValidSignature", message.HashPrefixedMessage().HexToBytes(), erc6492Sig.SigToValidate).HexToBytes(), + }, + }, } ) .ConfigureAwait(false); @@ -433,7 +432,7 @@ string reqValidityEndTimestamp PermissionEndTimestamp = BigInteger.Parse(permissionEndTimestamp), ReqValidityStartTimestamp = BigInteger.Parse(reqValidityStartTimestamp), ReqValidityEndTimestamp = BigInteger.Parse(reqValidityEndTimestamp), - Uid = Guid.NewGuid().ToByteArray() + Uid = Guid.NewGuid().ToByteArray(), }; var signature = await EIP712 @@ -445,7 +444,7 @@ string reqValidityEndTimestamp { To = this._accountContract.Address, Value = new HexBigInteger(0), - Data = data + Data = data, }; var txHash = await this.SendTransaction(txInput).ConfigureAwait(false); return await ThirdwebTransaction.WaitForTransactionReceipt(this.Client, this.ActiveChainId, txHash).ConfigureAwait(false); @@ -485,7 +484,7 @@ public async Task AddAdmin(string admin) PermissionEndTimestamp = Utils.GetUnixTimeStampIn10Years(), ReqValidityStartTimestamp = Utils.GetUnixTimeStampNow() - 3600, ReqValidityEndTimestamp = Utils.GetUnixTimeStampIn10Years(), - Uid = Guid.NewGuid().ToByteArray() + Uid = Guid.NewGuid().ToByteArray(), }; var signature = await EIP712.GenerateSignature_SmartAccount("Account", "1", this.ActiveChainId, await this.GetAddress(), request, this._personalAccount).ConfigureAwait(false); @@ -494,7 +493,7 @@ public async Task AddAdmin(string admin) { To = this._accountContract.Address, Value = new HexBigInteger(0), - Data = data + Data = data, }; var txHash = await this.SendTransaction(txInput).ConfigureAwait(false); return await ThirdwebTransaction.WaitForTransactionReceipt(this.Client, this.ActiveChainId, txHash).ConfigureAwait(false); @@ -522,7 +521,7 @@ public async Task RemoveAdmin(string admin) PermissionEndTimestamp = Utils.GetUnixTimeStampIn10Years(), ReqValidityStartTimestamp = Utils.GetUnixTimeStampNow() - 3600, ReqValidityEndTimestamp = Utils.GetUnixTimeStampIn10Years(), - Uid = Guid.NewGuid().ToByteArray() + Uid = Guid.NewGuid().ToByteArray(), }; var signature = await EIP712 @@ -533,7 +532,7 @@ public async Task RemoveAdmin(string admin) { To = this._accountContract.Address, Value = new HexBigInteger(0), - Data = data + Data = data, }; var txHash = await this.SendTransaction(txInput).ConfigureAwait(false); return await ThirdwebTransaction.WaitForTransactionReceipt(this.Client, this.ActiveChainId, txHash).ConfigureAwait(false); @@ -914,7 +913,7 @@ private async Task HashAndSignUserOp(UserOperationV7 userOp, ThirdwebCon PreVerificationGas = userOp.PreVerificationGas, GasFees = gasFeesBuffer, PaymasterAndData = Array.Empty(), - Signature = userOp.Signature + Signature = userOp.Signature, }; } else @@ -939,7 +938,7 @@ private async Task HashAndSignUserOp(UserOperationV7 userOp, ThirdwebCon PreVerificationGas = userOp.PreVerificationGas, GasFees = gasFeesBuffer, PaymasterAndData = paymasterAndDataBuffer, - Signature = userOp.Signature + Signature = userOp.Signature, }; } @@ -967,7 +966,7 @@ private static UserOperationHexifiedV6 EncodeUserOperation(UserOperationV6 userO MaxFeePerGas = userOperation.MaxFeePerGas.ToHexBigInteger().HexValue, MaxPriorityFeePerGas = userOperation.MaxPriorityFeePerGas.ToHexBigInteger().HexValue, PaymasterAndData = userOperation.PaymasterAndData.BytesToHex(), - Signature = userOperation.Signature.BytesToHex() + Signature = userOperation.Signature.BytesToHex(), }; } @@ -989,7 +988,7 @@ private static UserOperationHexifiedV7 EncodeUserOperation(UserOperationV7 userO PaymasterVerificationGasLimit = userOperation.PaymasterVerificationGasLimit.ToHexBigInteger().HexValue, PaymasterPostOpGasLimit = userOperation.PaymasterPostOpGasLimit.ToHexBigInteger().HexValue, PaymasterData = userOperation.PaymasterData.BytesToHex(), - Signature = userOperation.Signature.BytesToHex() + Signature = userOperation.Signature.BytesToHex(), }; } @@ -1035,7 +1034,7 @@ public async Task SendTransaction(ThirdwebTransactionInput transactionIn maxPriorityFeePerGas = zkTx.MaxPriorityFeePerGas.ToString(), chainId = this.ActiveChainId.ToString(), signedTransaction = zkTxSigned, - paymaster + paymaster, } ) .ConfigureAwait(false); From b16be3f60ca0b7e895192bab4b5b30a3003016c3 Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Fri, 8 Aug 2025 20:06:48 +0700 Subject: [PATCH 2/4] Add Arachnid contract deployment check to EIP-155 detection Updated the EIP-155 detection logic to first check if the Arachnid contract is deployed before sending a pre-155 transaction. Also added missing trailing commas in several object initializations for consistency. --- Thirdweb/Thirdweb.Utils/Utils.cs | 68 +++++++++++++++++--------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/Thirdweb/Thirdweb.Utils/Utils.cs b/Thirdweb/Thirdweb.Utils/Utils.cs index cec2c9ef..9e840592 100644 --- a/Thirdweb/Thirdweb.Utils/Utils.cs +++ b/Thirdweb/Thirdweb.Utils/Utils.cs @@ -686,43 +686,47 @@ public static async Task IsEip155Enforced(ThirdwebClient client, BigIntege } var result = false; - var rpc = ThirdwebRPC.GetRpcInstance(client, chainId); - try + var isArachnidDeployed = await IsDeployed(client, chainId, "0x4e59b44847b379578588920ca78fbf26c0b4956c").ConfigureAwait(false); + if (!isArachnidDeployed) { - // Pre-155 tx that will fail - var rawTransaction = - "0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222"; - _ = await rpc.SendRequestAsync("eth_sendRawTransaction", rawTransaction); - } - catch (Exception e) - { - var errorMsg = e.Message.ToLower(); - - var errorSubstrings = new List - { - "eip-155", - "eip155", - "protected", - "invalid chain id for signer", - "chain id none", - "chain_id mismatch", - "recovered sender mismatch", - "transaction hash mismatch", - "chainid no support", - "chainid (0)", - "chainid(0)", - "invalid sender", - }; - - if (errorSubstrings.Any(errorMsg.Contains)) + try { - result = true; + // Pre-155 tx that will fail + var rpc = ThirdwebRPC.GetRpcInstance(client, chainId); + var rawTransaction = + "0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222"; + _ = await rpc.SendRequestAsync("eth_sendRawTransaction", rawTransaction).ConfigureAwait(false); } - else + catch (Exception e) { - // Check if all substrings in any of the composite substrings are present - result = _errorSubstringsComposite.Any(arr => arr.All(substring => errorMsg.Contains(substring))); + var errorMsg = e.Message.ToLower(); + + var errorSubstrings = new List + { + "eip-155", + "eip155", + "protected", + "invalid chain id for signer", + "chain id none", + "chain_id mismatch", + "recovered sender mismatch", + "transaction hash mismatch", + "chainid no support", + "chainid (0)", + "chainid(0)", + "invalid sender", + }; + + if (errorSubstrings.Any(errorMsg.Contains)) + { + result = true; + } + else + { + // Check if all substrings in any of the composite substrings are present + result = _errorSubstringsComposite.Any(arr => arr.All(substring => errorMsg.Contains(substring))); + } } } From 7abd38feabfb2ef4220f88287f21bfeedd9a1a6b Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Fri, 8 Aug 2025 20:18:21 +0700 Subject: [PATCH 3/4] use editorconfig for csharpier --- .csharpierrc | 10 ---- .editorconfig | 14 ++++- Directory.Build.props | 4 +- Directory.Packages.props | 2 +- Thirdweb.Console/Thirdweb.Console.csproj | 8 +-- .../Thirdweb.Contracts.Tests.cs | 8 +-- .../Thirdweb.Extensions.Tests.cs | 56 +++++++++---------- .../Thirdweb.MarketplaceExtensions.Tests.cs | 8 +-- .../Thirdweb.Http/Thirdweb.Http.Tests.cs | 6 +- Thirdweb.Tests/Thirdweb.Tests.csproj | 8 +-- .../Thirdweb.Transactions.Tests.cs | 8 +-- .../Thirdweb.ZkSmartWallet.Tests.cs | 25 ++++----- .../Thirdweb.PrivateKeyWallet.Tests.cs | 4 +- .../Thirdweb.SmartWallet.Tests.cs | 14 ++--- .../Thirdweb.Wallets.Tests.cs | 10 ++-- Thirdweb/Thirdweb.AI/ThirdwebNebula.cs | 6 +- .../Thirdweb.Bridge/ThirdwebBridge.Types.cs | 8 +-- Thirdweb/Thirdweb.Bridge/ThirdwebBridge.cs | 12 ++-- .../ThirdwebExtensions.Types.cs | 2 +- .../Thirdweb.Extensions/ThirdwebExtensions.cs | 24 ++++---- .../ThirdwebMarketplaceExtensions.Types.cs | 4 +- .../ThirdwebInsight.Extensions.cs | 4 +- Thirdweb/Thirdweb.Indexer/ThirdwebInsight.cs | 4 +- .../Thirdweb.Pay/ThirdwebPay.GetBuyHistory.cs | 11 ++-- .../ThirdwebPay.GetBuyWithCryptoQuote.cs | 4 +- .../ThirdwebPay.GetBuyWithCryptoStatus.cs | 8 +-- .../ThirdwebPay.GetBuyWithFiatCurrencies.cs | 8 +-- .../ThirdwebPay.GetBuyWithFiatQuote.cs | 4 +- .../ThirdwebPay.GetBuyWithFiatStatus.cs | 8 +-- .../Types.GetBuyWithCryptoQuote.cs | 2 +- .../Types.GetBuyWithCryptoStatus.cs | 4 +- .../Thirdweb.Pay/Types.GetBuyWithFiatQuote.cs | 2 +- Thirdweb/Thirdweb.Pay/Types.Shared.cs | 2 +- .../ThirdwebTransaction.cs | 11 ++-- Thirdweb/Thirdweb.Utils/Utils.Types.cs | 4 +- Thirdweb/Thirdweb.Wallets/EIP712.cs | 2 +- Thirdweb/Thirdweb.Wallets/EIP712Encoder.cs | 12 ++-- .../EngineWallet/EngineWallet.cs | 27 ++++----- Thirdweb/Thirdweb.Wallets/IThirdwebWallet.cs | 2 +- .../EmbeddedWallet.Authentication/AWS.cs | 2 +- .../EmbeddedWallet.Cryptography.cs | 18 +++--- .../EmbeddedWallet.Encryption/Secrets.cs | 12 ++-- .../VerificationException.cs | 3 +- .../EmbeddedWallet.AccountLinking.cs | 4 +- .../PrivateKeyWallet/PrivateKeyWallet.cs | 4 +- .../Thirdweb.AccountAbstraction/AATypes.cs | 2 +- .../BundlerClient.cs | 2 +- Thirdweb/Thirdweb.csproj | 7 +-- 48 files changed, 187 insertions(+), 227 deletions(-) delete mode 100644 .csharpierrc diff --git a/.csharpierrc b/.csharpierrc deleted file mode 100644 index 74f82b53..00000000 --- a/.csharpierrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "printWidth": 200, - "useTabs": false, - "tabWidth": 4, - "preprocessorSymbolSets": [ - "", - "DEBUG", - "RELEASE" - ] -} diff --git a/.editorconfig b/.editorconfig index 06d538c5..b397fcdc 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,11 +1,21 @@ ############################### -# Core EditorConfig Options # +# Core EditorConfig Options # ############################### root = true ############################### -# .NET Coding Conventions # +# Configurable behaviors # +############################### + +[*.{cs,csx}] +end_of_line = crlf +indent_style = space +indent_size = 4 +max_line_length = 200 + +############################### +# .NET Coding Conventions # ############################### [*.{cs,vb}] diff --git a/Directory.Build.props b/Directory.Build.props index 0c6e3424..cc4faf70 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,16 +4,14 @@ 2.24.0 netstandard2.1;net6.0;net7.0;net8.0 - latest true enable - $(DefaultVersion) $(DefaultVersion) $(DefaultVersion) - \ No newline at end of file + diff --git a/Directory.Packages.props b/Directory.Packages.props index c1be8cd6..15ff8543 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -23,4 +23,4 @@ - \ No newline at end of file + diff --git a/Thirdweb.Console/Thirdweb.Console.csproj b/Thirdweb.Console/Thirdweb.Console.csproj index 2acaa4b5..64200b0c 100644 --- a/Thirdweb.Console/Thirdweb.Console.csproj +++ b/Thirdweb.Console/Thirdweb.Console.csproj @@ -1,6 +1,4 @@ - - Exe net8.0 @@ -8,19 +6,15 @@ enable false - - - PreserveNewest - - \ No newline at end of file + diff --git a/Thirdweb.Tests/Thirdweb.Contracts/Thirdweb.Contracts.Tests.cs b/Thirdweb.Tests/Thirdweb.Contracts/Thirdweb.Contracts.Tests.cs index e8a8314d..844a4b77 100644 --- a/Thirdweb.Tests/Thirdweb.Contracts/Thirdweb.Contracts.Tests.cs +++ b/Thirdweb.Tests/Thirdweb.Contracts/Thirdweb.Contracts.Tests.cs @@ -228,7 +228,7 @@ public async Task SignatureMint_Generate() Value = BigInteger.Zero, Gas = BigInteger.Zero, Nonce = BigInteger.Zero, - Data = "0x" + Data = "0x", }; var signature = await EIP712.GenerateSignature_MinimalForwarder(randomDomain, randomVersion, randomChainId, randomContractAddress, forwardRequest, signer); Assert.NotNull(signature); @@ -243,7 +243,7 @@ public async Task SignatureMint_Generate() Currency = Constants.ADDRESS_ZERO, ValidityEndTimestamp = 0, ValidityStartTimestamp = Utils.GetUnixTimeStampIn10Years(), - Uid = new byte[] { 0x01 } + Uid = new byte[] { 0x01 }, }; var signature20 = await EIP712.GenerateSignature_TokenERC20(randomDomain, randomVersion, randomChainId, randomContractAddress, mintRequest20, signer); Assert.NotNull(signature20); @@ -261,7 +261,7 @@ public async Task SignatureMint_Generate() Currency = Constants.ADDRESS_ZERO, ValidityEndTimestamp = 0, ValidityStartTimestamp = Utils.GetUnixTimeStampIn10Years(), - Uid = new byte[] { 0x01 } + Uid = new byte[] { 0x01 }, }; var signature721 = await EIP712.GenerateSignature_TokenERC721(randomDomain, randomVersion, randomChainId, randomContractAddress, mintRequest721, signer); Assert.NotNull(signature721); @@ -281,7 +281,7 @@ public async Task SignatureMint_Generate() Currency = Constants.ADDRESS_ZERO, ValidityEndTimestamp = 0, ValidityStartTimestamp = Utils.GetUnixTimeStampIn10Years(), - Uid = new byte[] { 0x01 } + Uid = new byte[] { 0x01 }, }; var signature1155 = await EIP712.GenerateSignature_TokenERC1155(randomDomain, randomVersion, randomChainId, randomContractAddress, mintRequest1155, signer); Assert.NotNull(signature1155); diff --git a/Thirdweb.Tests/Thirdweb.Extensions/Thirdweb.Extensions.Tests.cs b/Thirdweb.Tests/Thirdweb.Extensions/Thirdweb.Extensions.Tests.cs index a5c7d8e9..43447cc4 100644 --- a/Thirdweb.Tests/Thirdweb.Extensions/Thirdweb.Extensions.Tests.cs +++ b/Thirdweb.Tests/Thirdweb.Extensions/Thirdweb.Extensions.Tests.cs @@ -716,26 +716,26 @@ public async Task ERC1155_NullChecks() _ = await Assert.ThrowsAsync(async () => await contract.ERC1155_SafeTransferFrom(wallet, validAddress, validAddress, BigInteger.MinusOne, validAmount, validData)); // ERC1155_SafeBatchTransferFrom - _ = await Assert.ThrowsAsync( - async () => await contract.ERC1155_SafeBatchTransferFrom(null, null, null, new BigInteger[] { validTokenId }, new BigInteger[] { validAmount }, validData) + _ = await Assert.ThrowsAsync(async () => + await contract.ERC1155_SafeBatchTransferFrom(null, null, null, new BigInteger[] { validTokenId }, new BigInteger[] { validAmount }, validData) ); - _ = await Assert.ThrowsAsync( - async () => await contract.ERC1155_SafeBatchTransferFrom(wallet, null, null, new BigInteger[] { validTokenId }, new BigInteger[] { validAmount }, validData) + _ = await Assert.ThrowsAsync(async () => + await contract.ERC1155_SafeBatchTransferFrom(wallet, null, null, new BigInteger[] { validTokenId }, new BigInteger[] { validAmount }, validData) ); - _ = await Assert.ThrowsAsync( - async () => await contract.ERC1155_SafeBatchTransferFrom(wallet, string.Empty, null, new BigInteger[] { validTokenId }, new BigInteger[] { validAmount }, validData) + _ = await Assert.ThrowsAsync(async () => + await contract.ERC1155_SafeBatchTransferFrom(wallet, string.Empty, null, new BigInteger[] { validTokenId }, new BigInteger[] { validAmount }, validData) ); - _ = await Assert.ThrowsAsync( - async () => await contract.ERC1155_SafeBatchTransferFrom(wallet, validAddress, null, new BigInteger[] { validTokenId }, new BigInteger[] { validAmount }, validData) + _ = await Assert.ThrowsAsync(async () => + await contract.ERC1155_SafeBatchTransferFrom(wallet, validAddress, null, new BigInteger[] { validTokenId }, new BigInteger[] { validAmount }, validData) ); - _ = await Assert.ThrowsAsync( - async () => await contract.ERC1155_SafeBatchTransferFrom(wallet, validAddress, string.Empty, new BigInteger[] { validTokenId }, new BigInteger[] { validAmount }, validData) + _ = await Assert.ThrowsAsync(async () => + await contract.ERC1155_SafeBatchTransferFrom(wallet, validAddress, string.Empty, new BigInteger[] { validTokenId }, new BigInteger[] { validAmount }, validData) ); - _ = await Assert.ThrowsAsync( - async () => await contract.ERC1155_SafeBatchTransferFrom(wallet, validAddress, validAddress, null, new BigInteger[] { validAmount }, validData) + _ = await Assert.ThrowsAsync(async () => + await contract.ERC1155_SafeBatchTransferFrom(wallet, validAddress, validAddress, null, new BigInteger[] { validAmount }, validData) ); - _ = await Assert.ThrowsAsync( - async () => await contract.ERC1155_SafeBatchTransferFrom(wallet, validAddress, validAddress, new BigInteger[] { validTokenId }, null, validData) + _ = await Assert.ThrowsAsync(async () => + await contract.ERC1155_SafeBatchTransferFrom(wallet, validAddress, validAddress, new BigInteger[] { validTokenId }, null, validData) ); // ERC1155_URI @@ -749,8 +749,8 @@ public async Task ERC1155_NullChecks() _ = await Assert.ThrowsAsync(async () => await contract.ERC1155_SetApprovalForAll(wallet, validAddress, false)); _ = await Assert.ThrowsAsync(async () => await contract.ERC1155_SafeTransferFrom(wallet, validAddress, validAddress, validTokenId, validAmount, validData)); - _ = await Assert.ThrowsAsync( - async () => await contract.ERC1155_SafeBatchTransferFrom(wallet, validAddress, validAddress, new BigInteger[] { validTokenId }, new BigInteger[] { validAmount }, validData) + _ = await Assert.ThrowsAsync(async () => + await contract.ERC1155_SafeBatchTransferFrom(wallet, validAddress, validAddress, new BigInteger[] { validTokenId }, new BigInteger[] { validAmount }, validData) ); // Null contract checks @@ -761,8 +761,8 @@ public async Task ERC1155_NullChecks() _ = await Assert.ThrowsAsync(async () => await contract.ERC1155_SetApprovalForAll(wallet, validAddress, false)); _ = await Assert.ThrowsAsync(async () => await contract.ERC1155_IsApprovedForAll(validAddress, validAddress)); _ = await Assert.ThrowsAsync(async () => await contract.ERC1155_SafeTransferFrom(wallet, validAddress, validAddress, validTokenId, validAmount, validData)); - _ = await Assert.ThrowsAsync( - async () => await contract.ERC1155_SafeBatchTransferFrom(wallet, validAddress, validAddress, new BigInteger[] { validTokenId }, new BigInteger[] { validAmount }, validData) + _ = await Assert.ThrowsAsync(async () => + await contract.ERC1155_SafeBatchTransferFrom(wallet, validAddress, validAddress, new BigInteger[] { validTokenId }, new BigInteger[] { validAmount }, validData) ); _ = await Assert.ThrowsAsync(async () => await contract.ERC1155_URI(validTokenId)); _ = await Assert.ThrowsAsync(async () => await contract.ERC1155_TotalSupply(validTokenId)); @@ -1375,7 +1375,7 @@ public async Task TokenERC20_NullChecks() Currency = Constants.NATIVE_TOKEN_ADDRESS, ValidityStartTimestamp = 0, ValidityEndTimestamp = 0, - Uid = Guid.NewGuid().ToByteArray().PadTo32Bytes() + Uid = Guid.NewGuid().ToByteArray().PadTo32Bytes(), }; // TokenERC20_MintTo null checks @@ -1422,7 +1422,7 @@ public async Task TokenERC20_GenerateMintSignature_WithVerify() var contract = await this.GetTokenERC20Contract(); var fakeAuthorizedSigner = await PrivateKeyWallet.Generate(this.Client); var randomReceiver = await PrivateKeyWallet.Generate(this.Client); - var mintRequest = new TokenERC20_MintRequest { To = await randomReceiver.GetAddress(), Quantity = BigInteger.Parse("1.5".ToWei()), }; + var mintRequest = new TokenERC20_MintRequest { To = await randomReceiver.GetAddress(), Quantity = BigInteger.Parse("1.5".ToWei()) }; (var payload, var signature) = await contract.TokenERC20_GenerateMintSignature(fakeAuthorizedSigner, mintRequest); @@ -1477,7 +1477,7 @@ public async Task TokenERC721_NullChecks() Currency = Constants.NATIVE_TOKEN_ADDRESS, ValidityStartTimestamp = 0, ValidityEndTimestamp = 0, - Uid = Guid.NewGuid().ToByteArray().PadTo32Bytes() + Uid = Guid.NewGuid().ToByteArray().PadTo32Bytes(), }; // TokenERC721_MintTo (with URI) null checks @@ -1530,7 +1530,7 @@ public async Task TokenERC721_GenerateMintSignature_WithUri_WithVerify() var contract = await this.GetTokenERC721Contract(); var fakeAuthorizedSigner = await PrivateKeyWallet.Generate(this.Client); var randomReceiver = await PrivateKeyWallet.Generate(this.Client); - var mintRequest = new TokenERC721_MintRequest { To = await randomReceiver.GetAddress(), Uri = "", }; + var mintRequest = new TokenERC721_MintRequest { To = await randomReceiver.GetAddress(), Uri = "" }; (var payload, var signature) = await contract.TokenERC721_GenerateMintSignature(fakeAuthorizedSigner, mintRequest); @@ -1637,7 +1637,7 @@ public async Task TokenERC1155_NullChecks() Currency = Constants.NATIVE_TOKEN_ADDRESS, ValidityStartTimestamp = 0, ValidityEndTimestamp = 0, - Uid = Guid.NewGuid().ToByteArray().PadTo32Bytes() + Uid = Guid.NewGuid().ToByteArray().PadTo32Bytes(), }; // TokenERC1155_MintTo (with URI) null checks @@ -1654,11 +1654,11 @@ public async Task TokenERC1155_NullChecks() _ = await Assert.ThrowsAsync(async () => await ThirdwebExtensions.TokenERC1155_MintTo(contract, null, validAddress, validTokenId, validQuantity, new NFTMetadata())); _ = await Assert.ThrowsAsync(async () => await ThirdwebExtensions.TokenERC1155_MintTo(contract, wallet, null, validTokenId, validQuantity, new NFTMetadata())); _ = await Assert.ThrowsAsync(async () => await ThirdwebExtensions.TokenERC1155_MintTo(contract, wallet, string.Empty, validTokenId, validQuantity, new NFTMetadata())); - _ = await Assert.ThrowsAsync( - async () => await ThirdwebExtensions.TokenERC1155_MintTo(contract, wallet, validAddress, invalidTokenId, validQuantity, new NFTMetadata()) + _ = await Assert.ThrowsAsync(async () => + await ThirdwebExtensions.TokenERC1155_MintTo(contract, wallet, validAddress, invalidTokenId, validQuantity, new NFTMetadata()) ); - _ = await Assert.ThrowsAsync( - async () => await ThirdwebExtensions.TokenERC1155_MintTo(contract, wallet, validAddress, validTokenId, invalidQuantity, new NFTMetadata()) + _ = await Assert.ThrowsAsync(async () => + await ThirdwebExtensions.TokenERC1155_MintTo(contract, wallet, validAddress, validTokenId, invalidQuantity, new NFTMetadata()) ); // TokenERC1155_MintWithSignature null checks @@ -1698,7 +1698,7 @@ public async Task TokenERC1155_GenerateMintSignature_WithUri_WithVerify() var contract = await this.GetTokenERC1155Contract(); var fakeAuthorizedSigner = await PrivateKeyWallet.Generate(this.Client); var randomReceiver = await PrivateKeyWallet.Generate(this.Client); - var mintRequest = new TokenERC1155_MintRequest { To = await randomReceiver.GetAddress(), Uri = "", }; + var mintRequest = new TokenERC1155_MintRequest { To = await randomReceiver.GetAddress(), Uri = "" }; (var payload, var signature) = await contract.TokenERC1155_GenerateMintSignature(fakeAuthorizedSigner, mintRequest); diff --git a/Thirdweb.Tests/Thirdweb.Extensions/Thirdweb.MarketplaceExtensions.Tests.cs b/Thirdweb.Tests/Thirdweb.Extensions/Thirdweb.MarketplaceExtensions.Tests.cs index e30f63b5..c13f62ab 100644 --- a/Thirdweb.Tests/Thirdweb.Extensions/Thirdweb.MarketplaceExtensions.Tests.cs +++ b/Thirdweb.Tests/Thirdweb.Extensions/Thirdweb.MarketplaceExtensions.Tests.cs @@ -49,7 +49,7 @@ public async Task Marketplace_DirectListings_CreateListing_Success() PricePerToken = 1, StartTimestamp = Utils.GetUnixTimeStampNow(), EndTimestamp = Utils.GetUnixTimeStampNow() + 3600, - Reserved = false + Reserved = false, }; var receipt = await contract.Marketplace_DirectListings_CreateListing(wallet, listingParams, true); @@ -92,7 +92,7 @@ public async Task Marketplace_DirectListings_UpdateListing_Success() PricePerToken = 1, StartTimestamp = Utils.GetUnixTimeStampNow() + 1800, EndTimestamp = Utils.GetUnixTimeStampNow() + 3600, - Reserved = false + Reserved = false, }; var receipt = await contract.Marketplace_DirectListings_CreateListing(wallet, originalListing, true); @@ -130,7 +130,7 @@ public async Task Marketplace_DirectListings_CancelListing_Success() PricePerToken = 1, StartTimestamp = Utils.GetUnixTimeStampNow() + 1800, EndTimestamp = Utils.GetUnixTimeStampNow() + 3600, - Reserved = false + Reserved = false, }; var receipt = await contract.Marketplace_DirectListings_CreateListing(wallet, originalListing, true); @@ -159,7 +159,7 @@ public async Task Marketplace_DirectListings_ApproveBuyerForListing() PricePerToken = 1, StartTimestamp = Utils.GetUnixTimeStampNow(), EndTimestamp = Utils.GetUnixTimeStampNow() + 3600, - Reserved = true + Reserved = true, }; var receipt = await contract.Marketplace_DirectListings_CreateListing(wallet, reservedListing, true); diff --git a/Thirdweb.Tests/Thirdweb.Http/Thirdweb.Http.Tests.cs b/Thirdweb.Tests/Thirdweb.Http/Thirdweb.Http.Tests.cs index 9f27e597..d0ed13d6 100644 --- a/Thirdweb.Tests/Thirdweb.Http/Thirdweb.Http.Tests.cs +++ b/Thirdweb.Tests/Thirdweb.Http/Thirdweb.Http.Tests.cs @@ -324,7 +324,7 @@ public void StatusCode_ShouldSetAndGet() var responseMessage = new ThirdwebHttpResponseMessage(200, new ThirdwebHttpContent("Test Content"), true) { // Act - StatusCode = 404 + StatusCode = 404, }; // Assert @@ -340,7 +340,7 @@ public void Content_ShouldSetAndGet() var responseMessage = new ThirdwebHttpResponseMessage(200, initialContent, true) { // Act - Content = newContent + Content = newContent, }; // Assert @@ -354,7 +354,7 @@ public void IsSuccessStatusCode_ShouldSetAndGet() var responseMessage = new ThirdwebHttpResponseMessage(200, new ThirdwebHttpContent("Test Content"), true) { // Act - IsSuccessStatusCode = false + IsSuccessStatusCode = false, }; // Assert diff --git a/Thirdweb.Tests/Thirdweb.Tests.csproj b/Thirdweb.Tests/Thirdweb.Tests.csproj index 5ad03d1c..02711904 100644 --- a/Thirdweb.Tests/Thirdweb.Tests.csproj +++ b/Thirdweb.Tests/Thirdweb.Tests.csproj @@ -1,5 +1,4 @@ - net8.0 enable @@ -7,7 +6,6 @@ false true - all @@ -23,21 +21,17 @@ - - PreserveNewest - PreserveNewest - - \ No newline at end of file + diff --git a/Thirdweb.Tests/Thirdweb.Transactions/Thirdweb.Transactions.Tests.cs b/Thirdweb.Tests/Thirdweb.Transactions/Thirdweb.Transactions.Tests.cs index 83895fe7..3d3bce7a 100644 --- a/Thirdweb.Tests/Thirdweb.Transactions/Thirdweb.Transactions.Tests.cs +++ b/Thirdweb.Tests/Thirdweb.Transactions/Thirdweb.Transactions.Tests.cs @@ -11,7 +11,7 @@ public TransactionTests(ITestOutputHelper output) private async Task CreateSampleTransaction() { var wallet = await PrivateKeyWallet.Generate(this.Client); - var transaction = await ThirdwebTransaction.Create(wallet, new ThirdwebTransactionInput(421614) { To = await wallet.GetAddress(), }); + var transaction = await ThirdwebTransaction.Create(wallet, new ThirdwebTransactionInput(421614) { To = await wallet.GetAddress() }); return transaction; } @@ -164,7 +164,7 @@ public async Task Sign_SmartWallet_SignsTransaction() var client = this.Client; var privateKeyAccount = await PrivateKeyWallet.Generate(client); var smartAccount = await SmartWallet.Create(personalWallet: privateKeyAccount, factoryAddress: "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052", gasless: true, chainId: 421614); - var transaction = await ThirdwebTransaction.Create(smartAccount, new ThirdwebTransactionInput(421614) { To = Constants.ADDRESS_ZERO, }); + var transaction = await ThirdwebTransaction.Create(smartAccount, new ThirdwebTransactionInput(421614) { To = Constants.ADDRESS_ZERO }); var signed = await ThirdwebTransaction.Sign(transaction); Assert.NotNull(signed); } @@ -329,7 +329,7 @@ public async Task EstimateTotalCosts_HigherThanGasCostsByValue() [Fact(Timeout = 120000)] public async Task EstimateGasFees_ReturnsCorrectly() { - var transaction = await ThirdwebTransaction.Create(await PrivateKeyWallet.Generate(this.Client), new ThirdwebTransactionInput(250) { To = Constants.ADDRESS_ZERO, }); + var transaction = await ThirdwebTransaction.Create(await PrivateKeyWallet.Generate(this.Client), new ThirdwebTransactionInput(250) { To = Constants.ADDRESS_ZERO }); (var maxFee, var maxPrio) = await ThirdwebTransaction.EstimateGasFees(transaction); @@ -365,7 +365,7 @@ public async Task Simulate_ReturnsDataOrThrowsIntrinsic() var client = this.Client; var privateKeyAccount = await PrivateKeyWallet.Generate(client); var smartAccount = await SmartWallet.Create(personalWallet: privateKeyAccount, factoryAddress: "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052", gasless: true, chainId: 421614); - var transaction = await ThirdwebTransaction.Create(smartAccount, new ThirdwebTransactionInput(421614) { To = Constants.ADDRESS_ZERO, Gas = new HexBigInteger(250000), }); + var transaction = await ThirdwebTransaction.Create(smartAccount, new ThirdwebTransactionInput(421614) { To = Constants.ADDRESS_ZERO, Gas = new HexBigInteger(250000) }); try { diff --git a/Thirdweb.Tests/Thirdweb.Transactions/Thirdweb.ZkSmartWallet.Tests.cs b/Thirdweb.Tests/Thirdweb.Transactions/Thirdweb.ZkSmartWallet.Tests.cs index 3bc6452c..5aad82db 100644 --- a/Thirdweb.Tests/Thirdweb.Transactions/Thirdweb.ZkSmartWallet.Tests.cs +++ b/Thirdweb.Tests/Thirdweb.Transactions/Thirdweb.ZkSmartWallet.Tests.cs @@ -33,17 +33,16 @@ public async Task PersonalSign_Success() public async Task CreateSessionKey_Throws() { var account = await this.GetSmartAccount(); - _ = await Assert.ThrowsAsync( - async () => - await account.CreateSessionKey( - signerAddress: await account.GetAddress(), - approvedTargets: new List() { Constants.ADDRESS_ZERO }, - nativeTokenLimitPerTransactionInWei: "0", - permissionStartTimestamp: "0", - permissionEndTimestamp: (Utils.GetUnixTimeStampNow() + 86400).ToString(), - reqValidityStartTimestamp: "0", - reqValidityEndTimestamp: Utils.GetUnixTimeStampIn10Years().ToString() - ) + _ = await Assert.ThrowsAsync(async () => + await account.CreateSessionKey( + signerAddress: await account.GetAddress(), + approvedTargets: new List() { Constants.ADDRESS_ZERO }, + nativeTokenLimitPerTransactionInWei: "0", + permissionStartTimestamp: "0", + permissionEndTimestamp: (Utils.GetUnixTimeStampNow() + 86400).ToString(), + reqValidityStartTimestamp: "0", + reqValidityEndTimestamp: Utils.GetUnixTimeStampIn10Years().ToString() + ) ); } @@ -78,7 +77,7 @@ public async Task SendGaslessZkTx_Success() From = await account.GetAddress(), To = await account.GetAddress(), Value = new Nethereum.Hex.HexTypes.HexBigInteger(0), - Data = "0x" + Data = "0x", } ); Assert.NotNull(hash); @@ -146,7 +145,7 @@ public async Task ZkSync_Switch() From = await account.GetAddress(), To = await account.GetAddress(), Value = new Nethereum.Hex.HexTypes.HexBigInteger(0), - Data = "0x" + Data = "0x", } ); } diff --git a/Thirdweb.Tests/Thirdweb.Wallets/Thirdweb.PrivateKeyWallet.Tests.cs b/Thirdweb.Tests/Thirdweb.Wallets/Thirdweb.PrivateKeyWallet.Tests.cs index 145c6c7a..fe33ed02 100644 --- a/Thirdweb.Tests/Thirdweb.Wallets/Thirdweb.PrivateKeyWallet.Tests.cs +++ b/Thirdweb.Tests/Thirdweb.Wallets/Thirdweb.PrivateKeyWallet.Tests.cs @@ -270,7 +270,7 @@ public async Task SignTransaction_NoNonce() To = Constants.ADDRESS_ZERO, Value = new HexBigInteger(0), Gas = new HexBigInteger(21000), - Data = "0x" + Data = "0x", }; var ex = await Assert.ThrowsAsync(() => account.SignTransaction(transaction)); Assert.Equal("Transaction nonce has not been set (Parameter 'transaction')", ex.Message); @@ -288,7 +288,7 @@ public async Task SignTransaction_NoGasPrice() Gas = new HexBigInteger(21000), Data = "0x", Nonce = new HexBigInteger(99999999999), - ChainId = new HexBigInteger(421614) + ChainId = new HexBigInteger(421614), }; var ex = await Assert.ThrowsAsync(() => account.SignTransaction(transaction)); Assert.Equal("Transaction MaxPriorityFeePerGas and MaxFeePerGas must be set for EIP-1559 transactions", ex.Message); diff --git a/Thirdweb.Tests/Thirdweb.Wallets/Thirdweb.SmartWallet.Tests.cs b/Thirdweb.Tests/Thirdweb.Wallets/Thirdweb.SmartWallet.Tests.cs index c6c10816..ce299687 100644 --- a/Thirdweb.Tests/Thirdweb.Wallets/Thirdweb.SmartWallet.Tests.cs +++ b/Thirdweb.Tests/Thirdweb.Wallets/Thirdweb.SmartWallet.Tests.cs @@ -34,8 +34,8 @@ public async Task Initialization_Fail() var client = this.Client; var privateKeyAccount = await PrivateKeyWallet.Generate(client); await privateKeyAccount.Disconnect(); - var ex = await Assert.ThrowsAsync( - async () => await SmartWallet.Create(personalWallet: privateKeyAccount, factoryAddress: "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052", gasless: true, chainId: 421614) + var ex = await Assert.ThrowsAsync(async () => + await SmartWallet.Create(personalWallet: privateKeyAccount, factoryAddress: "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052", gasless: true, chainId: 421614) ); Assert.Equal("SmartAccount.Connect: Personal account must be connected.", ex.Message); } @@ -85,7 +85,7 @@ public async Task ExecuteTransaction_Success() public async Task SendTransaction_Success() { var account = await this.GetSmartAccount(); - var tx = await account.SendTransaction(new ThirdwebTransactionInput(421614) { To = await account.GetAddress(), }); + var tx = await account.SendTransaction(new ThirdwebTransactionInput(421614) { To = await account.GetAddress() }); Assert.NotNull(tx); } @@ -95,7 +95,7 @@ public async Task SendTransaction_ClientBundleId_Success() var client = ThirdwebClient.Create(clientId: this.ClientIdBundleIdOnly, bundleId: this.BundleIdBundleIdOnly); var privateKeyAccount = await PrivateKeyWallet.Generate(client); var smartAccount = await SmartWallet.Create(personalWallet: privateKeyAccount, factoryAddress: "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052", gasless: true, chainId: 421614); - var tx = await smartAccount.SendTransaction(new ThirdwebTransactionInput(421614) { To = await smartAccount.GetAddress(), }); + var tx = await smartAccount.SendTransaction(new ThirdwebTransactionInput(421614) { To = await smartAccount.GetAddress() }); Assert.NotNull(tx); } @@ -289,7 +289,7 @@ public async Task SendTransaction_07_Success() entryPoint: Constants.ENTRYPOINT_ADDRESS_V07 ); - var hash07 = await smartWallet07.SendTransaction(new ThirdwebTransactionInput(11155111) { To = await smartWallet07.GetAddress(), }); + var hash07 = await smartWallet07.SendTransaction(new ThirdwebTransactionInput(11155111) { To = await smartWallet07.GetAddress() }); Assert.NotNull(hash07); Assert.True(hash07.Length == 66); @@ -306,8 +306,8 @@ public async Task ExecuteTransaction_07_WhenAll_Success() entryPoint: Constants.ENTRYPOINT_ADDRESS_V07 ); - var hash07 = smartWallet07.ExecuteTransaction(new ThirdwebTransactionInput(11155111) { To = await smartWallet07.GetAddress(), }); - var hash07_2 = smartWallet07.ExecuteTransaction(new ThirdwebTransactionInput(11155111) { To = await smartWallet07.GetAddress(), }); + var hash07 = smartWallet07.ExecuteTransaction(new ThirdwebTransactionInput(11155111) { To = await smartWallet07.GetAddress() }); + var hash07_2 = smartWallet07.ExecuteTransaction(new ThirdwebTransactionInput(11155111) { To = await smartWallet07.GetAddress() }); var hashes = await Task.WhenAll(hash07, hash07_2); diff --git a/Thirdweb.Tests/Thirdweb.Wallets/Thirdweb.Wallets.Tests.cs b/Thirdweb.Tests/Thirdweb.Wallets/Thirdweb.Wallets.Tests.cs index 517c11e9..cbe822a8 100644 --- a/Thirdweb.Tests/Thirdweb.Wallets/Thirdweb.Wallets.Tests.cs +++ b/Thirdweb.Tests/Thirdweb.Wallets/Thirdweb.Wallets.Tests.cs @@ -102,7 +102,7 @@ await wallet.GetAddress(), PermissionStartTimestamp = 0, ReqValidityStartTimestamp = 0, PermissionEndTimestamp = 0, - Uid = new byte[32] + Uid = new byte[32], }; var typedData2 = EIP712.GetTypedDefinition_SmartAccount("Account", "1", 421614, await wallet.GetAddress()); @@ -221,12 +221,12 @@ public async Task RecoverAddress_AllVariants_NullTests() var nullData = null as AccountAbstraction.SignerPermissionRequest; var nullTypedData = null as Nethereum.ABI.EIP712.TypedData; var nullSig = null as string; - _ = await Assert.ThrowsAsync( - async () => await wallet.RecoverAddressFromTypedDataV4(nullData, nullTypedData, nullSig) + _ = await Assert.ThrowsAsync(async () => + await wallet.RecoverAddressFromTypedDataV4(nullData, nullTypedData, nullSig) ); _ = await Assert.ThrowsAsync(async () => await wallet.RecoverAddressFromTypedDataV4(new AccountAbstraction.SignerPermissionRequest(), nullTypedData, nullSig)); - _ = await Assert.ThrowsAsync( - async () => await wallet.RecoverAddressFromTypedDataV4(new AccountAbstraction.SignerPermissionRequest(), new Nethereum.ABI.EIP712.TypedData(), nullSig) + _ = await Assert.ThrowsAsync(async () => + await wallet.RecoverAddressFromTypedDataV4(new AccountAbstraction.SignerPermissionRequest(), new Nethereum.ABI.EIP712.TypedData(), nullSig) ); #nullable restore } diff --git a/Thirdweb/Thirdweb.AI/ThirdwebNebula.cs b/Thirdweb/Thirdweb.AI/ThirdwebNebula.cs index 86b1c199..c30f6538 100644 --- a/Thirdweb/Thirdweb.AI/ThirdwebNebula.cs +++ b/Thirdweb/Thirdweb.AI/ThirdwebNebula.cs @@ -6,7 +6,7 @@ namespace Thirdweb.AI; public enum NebulaChatRole { User, - Assistant + Assistant, } public class NebulaChatMessage @@ -82,7 +82,7 @@ public static async Task Create(ThirdwebClient client, string se { ModelName = model, Title = $"Thirdweb .NET SDK (v{Constants.VERSION}) | Nebula {model} Session | Client ID: {client.ClientId}", - IsPublic = false + IsPublic = false, } ); nebula.SessionId = session.Id; @@ -225,7 +225,7 @@ private async Task PrepareContextFilter(IThirdwebWallet walle { SessionId = this.SessionId, ChainIds = context?.ChainIds?.Select(id => id).ToList(), - WalletAddress = context?.WalletAddress + WalletAddress = context?.WalletAddress, }; } diff --git a/Thirdweb/Thirdweb.Bridge/ThirdwebBridge.Types.cs b/Thirdweb/Thirdweb.Bridge/ThirdwebBridge.Types.cs index 368bef60..9bfeb4da 100644 --- a/Thirdweb/Thirdweb.Bridge/ThirdwebBridge.Types.cs +++ b/Thirdweb/Thirdweb.Bridge/ThirdwebBridge.Types.cs @@ -381,7 +381,7 @@ public enum StatusType NOT_FOUND, PROCESSING, CREATED, - UNKNOWN + UNKNOWN, } /// @@ -400,7 +400,7 @@ public class StatusData "PENDING" => StatusType.PENDING, "COMPLETED" => StatusType.COMPLETED, "NOT_FOUND" => StatusType.NOT_FOUND, - _ => StatusType.UNKNOWN + _ => StatusType.UNKNOWN, }; /// @@ -496,7 +496,7 @@ public enum OnrampProvider { Stripe, Coinbase, - Transak + Transak, } /// @@ -585,7 +585,7 @@ public class OnrampStatusData "COMPLETED" => StatusType.COMPLETED, "PROCESSING" => StatusType.PROCESSING, "CREATED" => StatusType.CREATED, - _ => StatusType.UNKNOWN + _ => StatusType.UNKNOWN, }; [JsonProperty("status")] diff --git a/Thirdweb/Thirdweb.Bridge/ThirdwebBridge.cs b/Thirdweb/Thirdweb.Bridge/ThirdwebBridge.cs index 733cbc61..00960be2 100644 --- a/Thirdweb/Thirdweb.Bridge/ThirdwebBridge.cs +++ b/Thirdweb/Thirdweb.Bridge/ThirdwebBridge.cs @@ -73,7 +73,7 @@ public async Task Buy_Quote( { "destinationChainId", destinationChainId.ToString() }, { "destinationTokenAddress", destinationTokenAddress }, { "buyAmountWei", buyAmountWei.ToString() }, - { "maxSteps", maxSteps.ToString() } + { "maxSteps", maxSteps.ToString() }, }; url = AppendQueryParams(url, queryParams); @@ -150,7 +150,7 @@ public async Task Buy_Prepare( sender, receiver, maxSteps, - purchaseData + purchaseData, }; var url = $"{Constants.BRIDGE_API_URL}/v1/buy/prepare"; @@ -219,7 +219,7 @@ public async Task Sell_Quote( { "destinationChainId", destinationChainId.ToString() }, { "destinationTokenAddress", destinationTokenAddress }, { "sellAmountWei", sellAmountWei.ToString() }, - { "maxSteps", maxSteps.ToString() } + { "maxSteps", maxSteps.ToString() }, }; url = AppendQueryParams(url, queryParams); @@ -296,7 +296,7 @@ public async Task Sell_Prepare( sender, receiver, maxSteps, - purchaseData + purchaseData, }; var url = $"{Constants.BRIDGE_API_URL}/v1/sell/prepare"; @@ -372,7 +372,7 @@ public async Task Transfer_Prepare( sender, receiver, feePayer, - purchaseData + purchaseData, }; var url = $"{Constants.BRIDGE_API_URL}/v1/transfer/prepare"; @@ -439,7 +439,7 @@ public async Task Onramp_Prepare( currency, maxSteps, excludeChainIds = excludeChainIds != null && excludeChainIds.Count > 0 ? excludeChainIds.Select(id => id.ToString()).ToList() : null, - purchaseData + purchaseData, }; var url = $"{Constants.BRIDGE_API_URL}/v1/onramp/prepare"; diff --git a/Thirdweb/Thirdweb.Extensions/ThirdwebExtensions.Types.cs b/Thirdweb/Thirdweb.Extensions/ThirdwebExtensions.Types.cs index 0fedf798..197cf08c 100644 --- a/Thirdweb/Thirdweb.Extensions/ThirdwebExtensions.Types.cs +++ b/Thirdweb/Thirdweb.Extensions/ThirdwebExtensions.Types.cs @@ -142,7 +142,7 @@ public class Forwarder_ForwardRequest public enum NFTType { ERC721, - ERC1155 + ERC1155, } /// diff --git a/Thirdweb/Thirdweb.Extensions/ThirdwebExtensions.cs b/Thirdweb/Thirdweb.Extensions/ThirdwebExtensions.cs index 4324e1f0..c706ef13 100644 --- a/Thirdweb/Thirdweb.Extensions/ThirdwebExtensions.cs +++ b/Thirdweb/Thirdweb.Extensions/ThirdwebExtensions.cs @@ -107,11 +107,9 @@ public static async Task GetMetadata(this ThirdwebContract con /// Thrown when the client is null. public static async Task GetNFTImageBytes(this NFT nft, ThirdwebClient client) { - return client == null - ? throw new ArgumentNullException(nameof(client)) - : string.IsNullOrEmpty(nft.Metadata.Image) - ? Array.Empty() - : await ThirdwebStorage.Download(client, nft.Metadata.Image).ConfigureAwait(false); + return client == null ? throw new ArgumentNullException(nameof(client)) + : string.IsNullOrEmpty(nft.Metadata.Image) ? Array.Empty() + : await ThirdwebStorage.Download(client, nft.Metadata.Image).ConfigureAwait(false); } /// @@ -1238,7 +1236,7 @@ public static async Task ERC721_GetNFT(this ThirdwebContract contract, BigI Owner = Constants.ADDRESS_ZERO, Type = NFTType.ERC721, Supply = 1, - QuantityOwned = 1 + QuantityOwned = 1, }; if (fillOwner) @@ -1272,7 +1270,7 @@ public static async Task ERC721_GetNFT(this ThirdwebContract contract, BigI return nft with { - Metadata = nftMetadata + Metadata = nftMetadata, }; } @@ -1594,7 +1592,7 @@ public static async Task DropERC20_Claim(this Thirdw activeClaimCondition.Currency, // currency activeClaimCondition.PricePerToken, // pricePerToken allowlistProof, // allowlistProof - Array.Empty() // data + Array.Empty(), // data }; return await ThirdwebContract.Write(wallet, contract, "claim", payableAmount, fnArgs); @@ -1732,7 +1730,7 @@ public static async Task DropERC721_Claim(this Third activeClaimCondition.Currency, // currency activeClaimCondition.PricePerToken, // pricePerToken allowlistProof, // allowlistProof - Array.Empty() // data + Array.Empty(), // data }; return await ThirdwebContract.Write(wallet, contract, "claim", payableAmount, fnArgs); @@ -1896,7 +1894,7 @@ public static async Task DropERC1155_Claim(this Thir activeClaimCondition.Currency, // currency activeClaimCondition.PricePerToken, // pricePerToken allowlistProof, // allowlistProof - Array.Empty() // data + Array.Empty(), // data }; return await ThirdwebContract.Write(wallet, contract, "claim", payableAmount, fnArgs); @@ -2088,7 +2086,7 @@ public static async Task TokenERC20_MintWithSignatur Currency = mintRequest.Currency ?? Constants.NATIVE_TOKEN_ADDRESS, ValidityStartTimestamp = mintRequest.ValidityStartTimestamp, ValidityEndTimestamp = mintRequest.ValidityEndTimestamp > 0 ? mintRequest.ValidityEndTimestamp : Utils.GetUnixTimeStampIn10Years(), - Uid = mintRequest.Uid ?? Guid.NewGuid().ToByteArray().PadTo32Bytes() + Uid = mintRequest.Uid ?? Guid.NewGuid().ToByteArray().PadTo32Bytes(), }; var contractMetadata = await contract.GetMetadata(); @@ -2335,7 +2333,7 @@ public static async Task TokenERC721_MintWithSignatu Currency = mintRequest.Currency ?? Constants.NATIVE_TOKEN_ADDRESS, ValidityStartTimestamp = mintRequest.ValidityStartTimestamp, ValidityEndTimestamp = mintRequest.ValidityEndTimestamp > 0 ? mintRequest.ValidityEndTimestamp : Utils.GetUnixTimeStampIn10Years(), - Uid = mintRequest.Uid ?? Guid.NewGuid().ToByteArray().PadTo32Bytes() + Uid = mintRequest.Uid ?? Guid.NewGuid().ToByteArray().PadTo32Bytes(), }; var signature = await EIP712.GenerateSignature_TokenERC721( @@ -2682,7 +2680,7 @@ public static async Task TokenERC1155_MintWithSignat Currency = mintRequest.Currency ?? Constants.NATIVE_TOKEN_ADDRESS, ValidityStartTimestamp = mintRequest.ValidityStartTimestamp, ValidityEndTimestamp = mintRequest.ValidityEndTimestamp > 0 ? mintRequest.ValidityEndTimestamp : Utils.GetUnixTimeStampIn10Years(), - Uid = mintRequest.Uid ?? Guid.NewGuid().ToByteArray().PadTo32Bytes() + Uid = mintRequest.Uid ?? Guid.NewGuid().ToByteArray().PadTo32Bytes(), }; var signature = await EIP712.GenerateSignature_TokenERC1155( diff --git a/Thirdweb/Thirdweb.Extensions/ThirdwebMarketplaceExtensions.Types.cs b/Thirdweb/Thirdweb.Extensions/ThirdwebMarketplaceExtensions.Types.cs index 01ccf9c9..453590da 100644 --- a/Thirdweb/Thirdweb.Extensions/ThirdwebMarketplaceExtensions.Types.cs +++ b/Thirdweb/Thirdweb.Extensions/ThirdwebMarketplaceExtensions.Types.cs @@ -23,7 +23,7 @@ public enum TokenType : byte /// /// Represents an ERC20 token. /// - ERC20 = 2 + ERC20 = 2, } /// @@ -49,7 +49,7 @@ public enum Status : byte /// /// The entity is cancelled. /// - CANCELLED = 3 + CANCELLED = 3, } #endregion diff --git a/Thirdweb/Thirdweb.Indexer/ThirdwebInsight.Extensions.cs b/Thirdweb/Thirdweb.Indexer/ThirdwebInsight.Extensions.cs index 127d0d65..5d20d3fc 100644 --- a/Thirdweb/Thirdweb.Indexer/ThirdwebInsight.Extensions.cs +++ b/Thirdweb/Thirdweb.Indexer/ThirdwebInsight.Extensions.cs @@ -17,7 +17,7 @@ public static NFT ToNFT(this Token_NFT token) "ERC1155" => NFTType.ERC1155, "erc721" => NFTType.ERC721, "erc1155" => NFTType.ERC1155, - _ => throw new Exception($"Unknown NFT type: {token.Contract.Type}") + _ => throw new Exception($"Unknown NFT type: {token.Contract.Type}"), }, Metadata = new NFTMetadata() { @@ -31,7 +31,7 @@ public static NFT ToNFT(this Token_NFT token) BackgroundColor = token.BackgroundColor, Attributes = token.ExtraMetadata?.Attributes, Properties = token.ExtraMetadata?.Properties, - } + }, }; } diff --git a/Thirdweb/Thirdweb.Indexer/ThirdwebInsight.cs b/Thirdweb/Thirdweb.Indexer/ThirdwebInsight.cs index a49ea1ec..b232cca5 100644 --- a/Thirdweb/Thirdweb.Indexer/ThirdwebInsight.cs +++ b/Thirdweb/Thirdweb.Indexer/ThirdwebInsight.cs @@ -292,7 +292,7 @@ public async Task GetEvents( _ = response.EnsureSuccessStatusCode(); var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false); var result = JsonConvert.DeserializeObject>(responseContent); - return new InsightEvents { Events = result.Data, Meta = result.Meta, }; + return new InsightEvents { Events = result.Data, Meta = result.Meta }; } /// @@ -378,7 +378,7 @@ public async Task GetTransactions( _ = response.EnsureSuccessStatusCode(); var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false); var result = JsonConvert.DeserializeObject>(responseContent); - return new InsightTransactions { Transactions = result.Data, Meta = result.Meta, }; + return new InsightTransactions { Transactions = result.Data, Meta = result.Meta }; } private static string AppendChains(string url, BigInteger[] chainIds) diff --git a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyHistory.cs b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyHistory.cs index 75cb1fe1..a2db51dc 100644 --- a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyHistory.cs +++ b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyHistory.cs @@ -26,7 +26,7 @@ public static async Task GetBuyHistory(ThirdwebClient client, { "start", start.ToString() }, { "count", count.ToString() }, { "cursor", cursor }, - { "pageSize", pageSize?.ToString() } + { "pageSize", pageSize?.ToString() }, }; var queryStringFormatted = string.Join("&", queryString.Where(kv => kv.Value != null).Select(kv => $"{Uri.EscapeDataString(kv.Key)}={Uri.EscapeDataString(kv.Value)}")); @@ -41,7 +41,6 @@ public static async Task GetBuyHistory(ThirdwebClient client, ErrorResponse error; try - { error = JsonConvert.DeserializeObject(content); } @@ -55,14 +54,12 @@ public static async Task GetBuyHistory(ThirdwebClient client, Reason = "Unknown", Code = "Unknown", Stack = "Unknown", - StatusCode = (int)getResponse.StatusCode - } + StatusCode = (int)getResponse.StatusCode, + }, }; } - throw new Exception( - $"HTTP error! Code: {error.Error.Code} Message: {error.Error.Message} Reason: {error.Error.Reason} StatusCode: {error.Error.StatusCode} Stack: {error.Error.Stack}" - ); + throw new Exception($"HTTP error! Code: {error.Error.Code} Message: {error.Error.Message} Reason: {error.Error.Reason} StatusCode: {error.Error.StatusCode} Stack: {error.Error.Stack}"); } var data = JsonConvert.DeserializeObject(content); diff --git a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithCryptoQuote.cs b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithCryptoQuote.cs index 2db716fe..544b5763 100644 --- a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithCryptoQuote.cs +++ b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithCryptoQuote.cs @@ -44,8 +44,8 @@ public static async Task GetBuyWithCryptoQuote(Thirdwe Reason = "Unknown", Code = "Unknown", Stack = "Unknown", - StatusCode = (int)response.StatusCode - } + StatusCode = (int)response.StatusCode, + }, }; } diff --git a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithCryptoStatus.cs b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithCryptoStatus.cs index eab0331c..f8123241 100644 --- a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithCryptoStatus.cs +++ b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithCryptoStatus.cs @@ -48,14 +48,12 @@ public static async Task GetBuyWithCryptoStatus(Third Reason = "Unknown", Code = "Unknown", Stack = "Unknown", - StatusCode = (int)getResponse.StatusCode - } + StatusCode = (int)getResponse.StatusCode, + }, }; } - throw new Exception( - $"HTTP error! Code: {error.Error.Code} Message: {error.Error.Message} Reason: {error.Error.Reason} StatusCode: {error.Error.StatusCode} Stack: {error.Error.Stack}" - ); + throw new Exception($"HTTP error! Code: {error.Error.Code} Message: {error.Error.Message} Reason: {error.Error.Reason} StatusCode: {error.Error.StatusCode} Stack: {error.Error.Stack}"); } var data = JsonConvert.DeserializeObject(content); diff --git a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatCurrencies.cs b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatCurrencies.cs index 6acfcd39..a2865d7b 100644 --- a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatCurrencies.cs +++ b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatCurrencies.cs @@ -38,14 +38,12 @@ public static async Task> GetBuyWithFiatCurrencies(ThirdwebClient c Reason = "Unknown", Code = "Unknown", Stack = "Unknown", - StatusCode = (int)getResponse.StatusCode - } + StatusCode = (int)getResponse.StatusCode, + }, }; } - throw new Exception( - $"HTTP error! Code: {error.Error.Code} Message: {error.Error.Message} Reason: {error.Error.Reason} StatusCode: {error.Error.StatusCode} Stack: {error.Error.Stack}" - ); + throw new Exception($"HTTP error! Code: {error.Error.Code} Message: {error.Error.Message} Reason: {error.Error.Reason} StatusCode: {error.Error.StatusCode} Stack: {error.Error.Stack}"); } var data = JsonConvert.DeserializeObject(content); diff --git a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatQuote.cs b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatQuote.cs index 57bb2075..ae0ff05b 100644 --- a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatQuote.cs +++ b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatQuote.cs @@ -44,8 +44,8 @@ public static async Task GetBuyWithFiatQuote(ThirdwebCli Reason = "Unknown", Code = "Unknown", Stack = "Unknown", - StatusCode = (int)response.StatusCode - } + StatusCode = (int)response.StatusCode, + }, }; } diff --git a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatStatus.cs b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatStatus.cs index 14cbd01c..00fbbf27 100644 --- a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatStatus.cs +++ b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatStatus.cs @@ -48,14 +48,12 @@ public static async Task GetBuyWithFiatStatus(ThirdwebC Reason = "Unknown", Code = "Unknown", Stack = "Unknown", - StatusCode = (int)getResponse.StatusCode - } + StatusCode = (int)getResponse.StatusCode, + }, }; } - throw new Exception( - $"HTTP error! Code: {error.Error.Code} Message: {error.Error.Message} Reason: {error.Error.Reason} StatusCode: {error.Error.StatusCode} Stack: {error.Error.Stack}" - ); + throw new Exception($"HTTP error! Code: {error.Error.Code} Message: {error.Error.Message} Reason: {error.Error.Reason} StatusCode: {error.Error.StatusCode} Stack: {error.Error.Stack}"); } var data = JsonConvert.DeserializeObject(content); diff --git a/Thirdweb/Thirdweb.Pay/Types.GetBuyWithCryptoQuote.cs b/Thirdweb/Thirdweb.Pay/Types.GetBuyWithCryptoQuote.cs index 31800907..1cb75f21 100644 --- a/Thirdweb/Thirdweb.Pay/Types.GetBuyWithCryptoQuote.cs +++ b/Thirdweb/Thirdweb.Pay/Types.GetBuyWithCryptoQuote.cs @@ -23,7 +23,7 @@ public class BuyWithCryptoQuoteParams( double? maxSlippageBPS = null, string intentId = null, object purchaseData = null - ) +) { /// /// The address from which the payment is made. diff --git a/Thirdweb/Thirdweb.Pay/Types.GetBuyWithCryptoStatus.cs b/Thirdweb/Thirdweb.Pay/Types.GetBuyWithCryptoStatus.cs index 10a1c2f9..5778cc44 100644 --- a/Thirdweb/Thirdweb.Pay/Types.GetBuyWithCryptoStatus.cs +++ b/Thirdweb/Thirdweb.Pay/Types.GetBuyWithCryptoStatus.cs @@ -228,7 +228,7 @@ public enum SwapStatus /// /// Status when the swap is completed. /// - COMPLETED + COMPLETED, } /// @@ -264,5 +264,5 @@ public enum SwapSubStatus /// /// Sub-status when there is an unknown error. /// - UNKNOWN_ERROR + UNKNOWN_ERROR, } diff --git a/Thirdweb/Thirdweb.Pay/Types.GetBuyWithFiatQuote.cs b/Thirdweb/Thirdweb.Pay/Types.GetBuyWithFiatQuote.cs index 2b07e2d2..8d3f343e 100644 --- a/Thirdweb/Thirdweb.Pay/Types.GetBuyWithFiatQuote.cs +++ b/Thirdweb/Thirdweb.Pay/Types.GetBuyWithFiatQuote.cs @@ -21,7 +21,7 @@ public class BuyWithFiatQuoteParams( bool isTestMode = false, string preferredProvider = null, object purchaseData = null - ) +) { /// /// The symbol of the currency to be used for the purchase. diff --git a/Thirdweb/Thirdweb.Pay/Types.Shared.cs b/Thirdweb/Thirdweb.Pay/Types.Shared.cs index 7d0a9ed9..43310b96 100644 --- a/Thirdweb/Thirdweb.Pay/Types.Shared.cs +++ b/Thirdweb/Thirdweb.Pay/Types.Shared.cs @@ -189,5 +189,5 @@ public enum SwapType /// /// On-ramp swap. /// - ON_RAMP + ON_RAMP, } diff --git a/Thirdweb/Thirdweb.Transactions/ThirdwebTransaction.cs b/Thirdweb/Thirdweb.Transactions/ThirdwebTransaction.cs index 17f0a1a0..9871d476 100644 --- a/Thirdweb/Thirdweb.Transactions/ThirdwebTransaction.cs +++ b/Thirdweb/Thirdweb.Transactions/ThirdwebTransaction.cs @@ -262,11 +262,10 @@ public static async Task EstimateGasLimit(ThirdwebTransaction transa { var rpc = ThirdwebRPC.GetRpcInstance(transaction.Wallet.Client, transaction.Input.ChainId.Value); var isZkSync = await Utils.IsZkSync(transaction.Wallet.Client, transaction.Input.ChainId.Value).ConfigureAwait(false); - BigInteger divider = isZkSync - ? 7 - : transaction.Input.AuthorizationList == null - ? 5 - : 3; + BigInteger divider = + isZkSync ? 7 + : transaction.Input.AuthorizationList == null ? 5 + : 3; BigInteger baseGas; if (isZkSync) { @@ -491,7 +490,7 @@ public static async Task WaitForTransactionReceipt(T Value = transaction.Input.Value?.Value ?? 0, Data = transaction.Input.Data?.HexToByteArray() ?? Array.Empty(), FactoryDeps = transaction.Input.ZkSync.Value.FactoryDeps, - PaymasterInput = transaction.Input.ZkSync.Value.PaymasterInput + PaymasterInput = transaction.Input.ZkSync.Value.PaymasterInput, }; } } diff --git a/Thirdweb/Thirdweb.Utils/Utils.Types.cs b/Thirdweb/Thirdweb.Utils/Utils.Types.cs index 6933018e..817dda06 100644 --- a/Thirdweb/Thirdweb.Utils/Utils.Types.cs +++ b/Thirdweb/Thirdweb.Utils/Utils.Types.cs @@ -1,5 +1,5 @@ -using Newtonsoft.Json; -using System.Numerics; +using System.Numerics; +using Newtonsoft.Json; namespace Thirdweb; diff --git a/Thirdweb/Thirdweb.Wallets/EIP712.cs b/Thirdweb/Thirdweb.Wallets/EIP712.cs index 8588ecc9..0867bd43 100644 --- a/Thirdweb/Thirdweb.Wallets/EIP712.cs +++ b/Thirdweb/Thirdweb.Wallets/EIP712.cs @@ -487,7 +487,7 @@ private static string SerializeEip712(AccountAbstraction.ZkSyncAATransaction tra // add array of rlp encoded paymaster/paymasterinput transaction.Paymaster != 0 ? RLP.EncodeElement(transaction.Paymaster.ToByteArray(isUnsigned: true, isBigEndian: true)).Concat(RLP.EncodeElement(transaction.PaymasterInput)).ToArray() - : new byte[] { 0xc0 } + : new byte[] { 0xc0 }, }; return "0x71" + RLP.EncodeDataItemsAsElementOrListAndCombineAsList(fields.ToArray(), _indexOfListDataItems).ToHex(); diff --git a/Thirdweb/Thirdweb.Wallets/EIP712Encoder.cs b/Thirdweb/Thirdweb.Wallets/EIP712Encoder.cs index c9520d58..c9b04059 100644 --- a/Thirdweb/Thirdweb.Wallets/EIP712Encoder.cs +++ b/Thirdweb/Thirdweb.Wallets/EIP712Encoder.cs @@ -1,11 +1,11 @@ +using System.Collections; +using System.Numerics; using System.Text; -using Nethereum.Hex.HexConvertors.Extensions; using Nethereum.ABI; +using Nethereum.ABI.EIP712; using Nethereum.ABI.FunctionEncoding; +using Nethereum.Hex.HexConvertors.Extensions; using Nethereum.Util; -using System.Collections; -using System.Numerics; -using Nethereum.ABI.EIP712; namespace Thirdweb; @@ -268,10 +268,10 @@ public TypedData GenerateTypedData(T data, TDomain domain, Types = new Dictionary { [primaryTypeName] = typeMembers.ToArray(), - ["EIP712Domain"] = MemberDescriptionFactory.GetTypesMemberDescription(typeof(TDomain))["EIP712Domain"] + ["EIP712Domain"] = MemberDescriptionFactory.GetTypesMemberDescription(typeof(TDomain))["EIP712Domain"], }, Message = typeValues.ToArray(), - Domain = domain + Domain = domain, }; return result; diff --git a/Thirdweb/Thirdweb.Wallets/EngineWallet/EngineWallet.cs b/Thirdweb/Thirdweb.Wallets/EngineWallet/EngineWallet.cs index 1de38e59..5d7b6b4e 100644 --- a/Thirdweb/Thirdweb.Wallets/EngineWallet/EngineWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/EngineWallet/EngineWallet.cs @@ -72,7 +72,7 @@ public static EngineWallet Create(ThirdwebClient client, string engineUrl, strin walletAddress = walletAddress.ToChecksumAddress(); - var engineClient = Utils.ReconstructHttpClient(client.HttpClient, new Dictionary { { "Authorization", $"Bearer {authToken}" }, }); + var engineClient = Utils.ReconstructHttpClient(client.HttpClient, new Dictionary { { "Authorization", $"Bearer {authToken}" } }); engineClient.AddHeader("X-Backend-Wallet-Address", walletAddress); if (additionalHeaders != null) { @@ -125,19 +125,16 @@ private object ToEngineTransaction(ThirdwebTransactionInput transaction) data = transaction.Data, value = transaction.Value?.HexValue ?? "0x00", authorizationList = transaction.AuthorizationList != null && transaction.AuthorizationList.Count > 0 - ? transaction.AuthorizationList - .Select( - authorization => - new - { - chainId = authorization.ChainId.HexToNumber(), - address = authorization.Address, - nonce = authorization.Nonce.HexToNumber(), - yParity = authorization.YParity.HexToNumber(), - r = authorization.R, - s = authorization.S - } - ) + ? transaction + .AuthorizationList.Select(authorization => new + { + chainId = authorization.ChainId.HexToNumber(), + address = authorization.Address, + nonce = authorization.Nonce.HexToNumber(), + yParity = authorization.YParity.HexToNumber(), + r = authorization.R, + s = authorization.S, + }) .ToArray() : null, txOverrides = this._timeoutSeconds != null || transaction.Gas != null || transaction.GasPrice != null || transaction.MaxFeePerGas != null || transaction.MaxPriorityFeePerGas != null @@ -271,7 +268,7 @@ public async Task SignTransaction(ThirdwebTransactionInput transaction) throw new ArgumentNullException(nameof(transaction)); } - object payload = new { transaction = this.ToEngineTransaction(transaction), }; + object payload = new { transaction = this.ToEngineTransaction(transaction) }; var url = $"{this._engineUrl}/backend-wallet/sign-transaction"; diff --git a/Thirdweb/Thirdweb.Wallets/IThirdwebWallet.cs b/Thirdweb/Thirdweb.Wallets/IThirdwebWallet.cs index 78cfdd52..44663513 100644 --- a/Thirdweb/Thirdweb.Wallets/IThirdwebWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/IThirdwebWallet.cs @@ -200,7 +200,7 @@ public enum ThirdwebAccountType { PrivateKeyAccount, SmartAccount, - ExternalAccount + ExternalAccount, } /// diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/AWS.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/AWS.cs index 6444660e..5662f71b 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/AWS.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/AWS.cs @@ -49,7 +49,7 @@ private static async Task GetTemporaryCredentialsAsync(string id { AccessKeyId = credentialsResponse.Credentials.AccessKeyId, SecretAccessKey = credentialsResponse.Credentials.SecretKey, - SessionToken = credentialsResponse.Credentials.SessionToken + SessionToken = credentialsResponse.Credentials.SessionToken, }; } diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Encryption/EmbeddedWallet.Cryptography.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Encryption/EmbeddedWallet.Cryptography.cs index b90fbb84..075d9ae4 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Encryption/EmbeddedWallet.Cryptography.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Encryption/EmbeddedWallet.Cryptography.cs @@ -107,13 +107,13 @@ private static (string deviceShare, string recoveryShare, string authShare) Crea private static async Task GetEncryptionKeyAsync(string password, byte[] salt, int iterationCount) { return await Task.Run(() => - { - var generator = new Pkcs5S2ParametersGenerator(new Sha256Digest()); - var keyLength = KEY_SIZE * 8; // will be redivided by 8 internally - generator.Init(Encoding.UTF8.GetBytes(password), salt, iterationCount); - var keyParam = (KeyParameter)generator.GenerateDerivedMacParameters(keyLength); - return keyParam.GetKey(); - }) + { + var generator = new Pkcs5S2ParametersGenerator(new Sha256Digest()); + var keyLength = KEY_SIZE * 8; // will be redivided by 8 internally + generator.Init(Encoding.UTF8.GetBytes(password), salt, iterationCount); + var keyParam = (KeyParameter)generator.GenerateDerivedMacParameters(keyLength); + return keyParam.GetKey(); + }) .ConfigureAwait(false); } @@ -123,8 +123,6 @@ private static Account MakeAccountFromShares(params string[] shares) var encodedSecret = secrets.Combine(shares); var secret = Encoding.ASCII.GetString(Secrets.GetBytes(encodedSecret)); - return !secret.StartsWith(WALLET_PRIVATE_KEY_PREFIX) - ? throw new InvalidOperationException($"Corrupted share encountered {secret}") - : new Account(secret.Split(WALLET_PRIVATE_KEY_PREFIX)[1]); + return !secret.StartsWith(WALLET_PRIVATE_KEY_PREFIX) ? throw new InvalidOperationException($"Corrupted share encountered {secret}") : new Account(secret.Split(WALLET_PRIVATE_KEY_PREFIX)[1]); } } diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Encryption/Secrets.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Encryption/Secrets.cs index 8fc0d55c..a55c0868 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Encryption/Secrets.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Encryption/Secrets.cs @@ -11,7 +11,7 @@ internal class Secrets private const int NHexDigitBits = 4; private readonly Func _getRandomInt32 = (nBits) => RandomNumberGenerator.GetInt32(1, 1 << nBits); private static readonly string _padding = string.Join("", Enumerable.Repeat("0", Defaults.MaxPaddingMultiple)); - private static readonly string[] _nybbles = { "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111", }; + private static readonly string[] _nybbles = { "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111" }; /// /// Reconsitute a secret from . @@ -305,11 +305,9 @@ private static ShareComponents ExtractShareComponents(string share) private static int GetLargeBaseValue(char ch) { var rv = - ch >= 'a' - ? ch - 'a' + 10 - : ch >= 'A' - ? ch - 'A' + 10 - : ch - '0'; + ch >= 'a' ? ch - 'a' + 10 + : ch >= 'A' ? ch - 'A' + 10 + : ch - '0'; return rv; } @@ -453,7 +451,7 @@ private class Defaults // These are primitive polynomial coefficients for Galois Fields GF(2^n) for 2 <= n <= 20. The index of each term in the // array corresponds to the n for that polynomial. - internal static readonly int[] PrimitivePolynomialCoefficients = { -1, -1, 1, 3, 3, 5, 3, 3, 29, 17, 9, 5, 83, 27, 43, 3, 45, 9, 39, 39, 9, }; + internal static readonly int[] PrimitivePolynomialCoefficients = { -1, -1, 1, 3, 3, 5, 3, 3, 29, 17, 9, 5, 83, 27, 43, 3, 45, 9, 39, 39, 9 }; } private class ShareComponents diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Exceptions/VerificationException.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Exceptions/VerificationException.cs index ccbb7cbc..4aee8932 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Exceptions/VerificationException.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Exceptions/VerificationException.cs @@ -1,7 +1,6 @@ namespace Thirdweb.EWS; -internal class VerificationException -(bool canRetry) : Exception +internal class VerificationException(bool canRetry) : Exception { internal bool CanRetry { get; } = canRetry; } diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet/EmbeddedWallet.AccountLinking.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet/EmbeddedWallet.AccountLinking.cs index 0e1335aa..4cf9917c 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet/EmbeddedWallet.AccountLinking.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet/EmbeddedWallet.AccountLinking.cs @@ -12,8 +12,8 @@ internal partial class EmbeddedWallet Email = linkedAccount.Details.Email, Address = linkedAccount.Details.Address, Phone = linkedAccount.Details.Phone, - Id = linkedAccount.Details.Id - } + Id = linkedAccount.Details.Id, + }, }; return await this._server.UnlinkAccountAsync(currentAccountToken, serverLinkedAccount).ConfigureAwait(false); } diff --git a/Thirdweb/Thirdweb.Wallets/PrivateKeyWallet/PrivateKeyWallet.cs b/Thirdweb/Thirdweb.Wallets/PrivateKeyWallet/PrivateKeyWallet.cs index 1529d492..d249044d 100644 --- a/Thirdweb/Thirdweb.Wallets/PrivateKeyWallet/PrivateKeyWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/PrivateKeyWallet/PrivateKeyWallet.cs @@ -358,7 +358,7 @@ public virtual Task SignTransaction(ThirdwebTransactionInput transaction RLP.EncodeElement(authorizationList.Nonce.HexToNumber().ToByteArrayForRLPEncoding()), RLP.EncodeElement(authorizationList.YParity is "0x00" or "0x0" or "0x" ? Array.Empty() : authorizationList.YParity.HexToBytes()), RLP.EncodeElement(authorizationList.R.HexToBytes().TrimZeroes()), - RLP.EncodeElement(authorizationList.S.HexToBytes().TrimZeroes()) + RLP.EncodeElement(authorizationList.S.HexToBytes().TrimZeroes()), }; encodedAuthorizationList.Add(RLP.EncodeList(encodedItem.ToArray())); } @@ -467,7 +467,7 @@ public async Task SignAuthorization(BigInteger chainId, st { RLP.EncodeElement(chainId.ToByteArrayForRLPEncoding()), RLP.EncodeElement(contractAddress.HexToBytes()), - RLP.EncodeElement(nonce.ToByteArrayForRLPEncoding()) + RLP.EncodeElement(nonce.ToByteArrayForRLPEncoding()), }; var encodedBytes = RLP.EncodeList(encodedData.ToArray()); var returnElements = new byte[encodedBytes.Length + 1]; diff --git a/Thirdweb/Thirdweb.Wallets/SmartWallet/Thirdweb.AccountAbstraction/AATypes.cs b/Thirdweb/Thirdweb.Wallets/SmartWallet/Thirdweb.AccountAbstraction/AATypes.cs index 748d4b2e..c7cdc037 100644 --- a/Thirdweb/Thirdweb.Wallets/SmartWallet/Thirdweb.AccountAbstraction/AATypes.cs +++ b/Thirdweb/Thirdweb.Wallets/SmartWallet/Thirdweb.AccountAbstraction/AATypes.cs @@ -625,7 +625,7 @@ public object EncodeForHttp() { target = this.Target, value = this.Value, - data = this.Data != null ? this.Data.BytesToHex() : "0x" + data = this.Data != null ? this.Data.BytesToHex() : "0x", }; } } diff --git a/Thirdweb/Thirdweb.Wallets/SmartWallet/Thirdweb.AccountAbstraction/BundlerClient.cs b/Thirdweb/Thirdweb.Wallets/SmartWallet/Thirdweb.AccountAbstraction/BundlerClient.cs index eb58d9f5..d8ab8c74 100644 --- a/Thirdweb/Thirdweb.Wallets/SmartWallet/Thirdweb.AccountAbstraction/BundlerClient.cs +++ b/Thirdweb/Thirdweb.Wallets/SmartWallet/Thirdweb.AccountAbstraction/BundlerClient.cs @@ -33,7 +33,7 @@ public static async Task TwExecute( nonce = authorization?.Nonce.HexToNumber().ToString(), yParity = authorization?.YParity.HexToNumber(), r = authorization?.R.HexToNumber().ToString(), - s = authorization?.S.HexToNumber().ToString() + s = authorization?.S.HexToNumber().ToString(), } ) .ConfigureAwait(false); diff --git a/Thirdweb/Thirdweb.csproj b/Thirdweb/Thirdweb.csproj index 20461857..1d6f695d 100644 --- a/Thirdweb/Thirdweb.csproj +++ b/Thirdweb/Thirdweb.csproj @@ -1,5 +1,4 @@ - $(DefaultTargetFrameworks) $(DefaultVersion) @@ -18,13 +17,11 @@ true Apache-2.0 - README.md true $(NoWarn);1591 - @@ -35,10 +32,8 @@ - - - \ No newline at end of file + From f0555f2bc5c65ff098c04e6020f940e86f79afab Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Tue, 26 Aug 2025 20:38:46 +0700 Subject: [PATCH 4/4] Fix OAuth login URL to use lowercase auth provider Updated the OAuth login URL construction in EcosystemWallet to use the lowercase value of AuthProvider. Also uncommented private key wallet generation in the console program for testing. --- Thirdweb.Console/Program.cs | 6 ++++-- .../InAppWallet/EcosystemWallet/EcosystemWallet.cs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Thirdweb.Console/Program.cs b/Thirdweb.Console/Program.cs index e9cab223..8c4f6da5 100644 --- a/Thirdweb.Console/Program.cs +++ b/Thirdweb.Console/Program.cs @@ -1,7 +1,9 @@ #pragma warning disable IDE0005 #pragma warning disable IDE0059 +using System.Diagnostics; using dotenv.net; +using Newtonsoft.Json; using Thirdweb; DotEnv.Load(); @@ -14,8 +16,8 @@ #region Basic Wallet Interaction -// // Create a private key wallet -// var privateKeyWallet = await PrivateKeyWallet.Generate(client); +// Create a private key wallet +var privateKeyWallet = await PrivateKeyWallet.Generate(client); // var walletAddress = await privateKeyWallet.GetAddress(); // Console.WriteLine($"PK Wallet address: {walletAddress}"); diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/EcosystemWallet/EcosystemWallet.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/EcosystemWallet/EcosystemWallet.cs index e83153dd..1037983d 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/EcosystemWallet/EcosystemWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/EcosystemWallet/EcosystemWallet.cs @@ -873,7 +873,7 @@ public async Task LoginWithOtp(string otp) var platform = this.HttpClient?.Headers?["x-sdk-name"] == "UnitySDK_WebGL" ? "web" : "dotnet"; var redirectUrl = isMobile ? mobileRedirectScheme : "http://localhost:8789/"; var loginUrl = await this.EmbeddedWallet.FetchHeadlessOauthLoginLinkAsync(this.AuthProvider, platform).ConfigureAwait(false); - loginUrl = platform == "web" ? loginUrl : $"{loginUrl}&redirectUrl={redirectUrl}&developerClientId={this.Client.ClientId}&authOption={this.AuthProvider}"; + loginUrl = platform == "web" ? loginUrl : $"{loginUrl}&redirectUrl={redirectUrl}&developerClientId={this.Client.ClientId}&authOption={this.AuthProvider.ToLower()}"; if (!string.IsNullOrEmpty(this._ecosystemId)) { loginUrl = $"{loginUrl}&ecosystemId={this._ecosystemId}";