From 1f4d61722bcbd22fcc8e78cf43229a4615ac5df0 Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Thu, 13 Jun 2024 11:50:03 +0300 Subject: [PATCH 1/8] Thirdweb Pay --- Thirdweb/Thirdweb.Pay/Constants.cs | 17 ++ .../Thirdweb.Pay/ThirdwebPay.BuyWithCrypto.cs | 38 ++++ .../Thirdweb.Pay/ThirdwebPay.BuyWithFiat.cs | 20 ++ .../Thirdweb.Pay/ThirdwebPay.GetBuyHistory.cs | 56 +++++ .../ThirdwebPay.GetBuyWithCryptoQuote.cs | 62 ++++++ .../ThirdwebPay.GetBuyWithCryptoStatus.cs | 54 +++++ .../ThirdwebPay.GetBuyWithFiatCurrencies.cs | 46 ++++ .../ThirdwebPay.GetBuyWithFiatQuote.cs | 61 ++++++ .../ThirdwebPay.GetBuyWithFiatStatus.cs | 54 +++++ Thirdweb/Thirdweb.Pay/Types.GetBuyHistory.cs | 34 +++ .../Types.GetBuyWithCryptoQuote.cs | 200 ++++++++++++++++++ .../Types.GetBuyWithCryptoStatus.cs | 119 +++++++++++ .../Types.GetBuyWithFiatCurrencies.cs | 16 ++ .../Thirdweb.Pay/Types.GetBuyWithFiatQuote.cs | 140 ++++++++++++ .../Types.GetBuyWithFiatStatus.cs | 83 ++++++++ Thirdweb/Thirdweb.Pay/Types.Shared.cs | 96 +++++++++ 16 files changed, 1096 insertions(+) create mode 100644 Thirdweb/Thirdweb.Pay/Constants.cs create mode 100644 Thirdweb/Thirdweb.Pay/ThirdwebPay.BuyWithCrypto.cs create mode 100644 Thirdweb/Thirdweb.Pay/ThirdwebPay.BuyWithFiat.cs create mode 100644 Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyHistory.cs create mode 100644 Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithCryptoQuote.cs create mode 100644 Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithCryptoStatus.cs create mode 100644 Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatCurrencies.cs create mode 100644 Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatQuote.cs create mode 100644 Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatStatus.cs create mode 100644 Thirdweb/Thirdweb.Pay/Types.GetBuyHistory.cs create mode 100644 Thirdweb/Thirdweb.Pay/Types.GetBuyWithCryptoQuote.cs create mode 100644 Thirdweb/Thirdweb.Pay/Types.GetBuyWithCryptoStatus.cs create mode 100644 Thirdweb/Thirdweb.Pay/Types.GetBuyWithFiatCurrencies.cs create mode 100644 Thirdweb/Thirdweb.Pay/Types.GetBuyWithFiatQuote.cs create mode 100644 Thirdweb/Thirdweb.Pay/Types.GetBuyWithFiatStatus.cs create mode 100644 Thirdweb/Thirdweb.Pay/Types.Shared.cs diff --git a/Thirdweb/Thirdweb.Pay/Constants.cs b/Thirdweb/Thirdweb.Pay/Constants.cs new file mode 100644 index 0000000..3990ea3 --- /dev/null +++ b/Thirdweb/Thirdweb.Pay/Constants.cs @@ -0,0 +1,17 @@ +namespace Thirdweb.Pay +{ + public static class Constants + { + public const string THIRDWEB_PAY_BASE_URL = "https://pay.thirdweb.com"; + + public const string THIRDWEB_PAY_CRYPTO_QUOTE_ENDPOINT = THIRDWEB_PAY_BASE_URL + "/buy-with-crypto/quote/v1"; + public const string THIRDWEB_PAY_CRYPTO_STATUS_ENDPOINT = THIRDWEB_PAY_BASE_URL + "/buy-with-crypto/status/v1"; + + public const string THIRDWEB_PAY_FIAT_QUOTE_ENDPOINT = THIRDWEB_PAY_BASE_URL + "/buy-with-fiat/quote/v1"; + public const string THIRDWEB_PAY_FIAT_STATUS_ENDPOINT = THIRDWEB_PAY_BASE_URL + "/buy-with-fiat/status/v1"; + + public const string THIRDWEB_PAY_FIAT_CURRENCIES_ENDPOINT = THIRDWEB_PAY_BASE_URL + "/buy-with-fiat/currency/v1"; + + public const string THIRDWEB_PAY_HISTORY_ENDPOINT = THIRDWEB_PAY_BASE_URL + "/wallet/history/v1"; + } +} diff --git a/Thirdweb/Thirdweb.Pay/ThirdwebPay.BuyWithCrypto.cs b/Thirdweb/Thirdweb.Pay/ThirdwebPay.BuyWithCrypto.cs new file mode 100644 index 0000000..c1d8cd8 --- /dev/null +++ b/Thirdweb/Thirdweb.Pay/ThirdwebPay.BuyWithCrypto.cs @@ -0,0 +1,38 @@ +using System.Numerics; +using System.Threading.Tasks; +using Nethereum.Hex.HexTypes; + +namespace Thirdweb.Pay +{ + public partial class ThirdwebPay + { + public static async Task BuyWithCrypto(ThirdwebClient client, IThirdwebWallet wallet, BuyWithCryptoQuoteResult buyWithCryptoQuote) + { + if (buyWithCryptoQuote.Approval != null) + { + var erc20ToApprove = await ThirdwebContract.Create(client, buyWithCryptoQuote.Approval.TokenAddress, buyWithCryptoQuote.Approval.ChainId); + var currentAllowance = await erc20ToApprove.ERC20_Allowance(await wallet.GetAddress(), buyWithCryptoQuote.Approval.SpenderAddress); + if (currentAllowance < BigInteger.Parse(buyWithCryptoQuote.Approval.AmountWei)) + { + _ = await erc20ToApprove.ERC20_Approve(wallet, buyWithCryptoQuote.Approval.SpenderAddress, BigInteger.Parse(buyWithCryptoQuote.Approval.AmountWei)); + } + } + + var txInput = new ThirdwebTransactionInput() + { + From = buyWithCryptoQuote.TransactionRequest.From, + To = buyWithCryptoQuote.TransactionRequest.To, + Data = buyWithCryptoQuote.TransactionRequest.Data, + Value = new HexBigInteger(buyWithCryptoQuote.TransactionRequest.Value), + Gas = new HexBigInteger(buyWithCryptoQuote.TransactionRequest.GasLimit), + GasPrice = new HexBigInteger(buyWithCryptoQuote.TransactionRequest.GasPrice), + }; + + var tx = await ThirdwebTransaction.Create(client, wallet, txInput, buyWithCryptoQuote.TransactionRequest.ChainId); + + var hash = await ThirdwebTransaction.Send(tx); + + return hash; + } + } +} diff --git a/Thirdweb/Thirdweb.Pay/ThirdwebPay.BuyWithFiat.cs b/Thirdweb/Thirdweb.Pay/ThirdwebPay.BuyWithFiat.cs new file mode 100644 index 0000000..b400bfd --- /dev/null +++ b/Thirdweb/Thirdweb.Pay/ThirdwebPay.BuyWithFiat.cs @@ -0,0 +1,20 @@ +using System; +using System.Threading.Tasks; + +namespace Thirdweb.Pay +{ + public partial class ThirdwebPay + { + public static string BuyWithFiat(BuyWithFiatQuoteResult buyWithFiatQuote) + { + if (string.IsNullOrEmpty(buyWithFiatQuote.OnRampLink)) + { + throw new ArgumentException("On-ramp link cannot be null or empty."); + } + + var onRampLink = buyWithFiatQuote.OnRampLink; + + return onRampLink; + } + } +} diff --git a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyHistory.cs b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyHistory.cs new file mode 100644 index 0000000..4079ace --- /dev/null +++ b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyHistory.cs @@ -0,0 +1,56 @@ +using Newtonsoft.Json; + +namespace Thirdweb.Pay +{ + public partial class ThirdwebPay + { + public static async Task GetBuyHistory(ThirdwebClient client, string walletAddress, int start, int count, string cursor = null, int? pageSize = null) + { + var queryString = new Dictionary + { + { "walletAddress", walletAddress }, + { "start", start.ToString() }, + { "count", count.ToString() }, + { "cursor", cursor }, + { "pageSize", pageSize?.ToString() } + }; + + var queryStringFormatted = string.Join("&", queryString.Where(kv => kv.Value != null).Select(kv => $"{Uri.EscapeDataString(kv.Key)}={Uri.EscapeDataString(kv.Value)}")); + var url = $"{Constants.THIRDWEB_PAY_HISTORY_ENDPOINT}?{queryStringFormatted}"; + + var getResponse = await client.HttpClient.GetAsync(url); + + var content = await getResponse.Content.ReadAsStringAsync(); + + if (!getResponse.IsSuccessStatusCode) + { + ErrorResponse error; + try + { + error = JsonConvert.DeserializeObject(content); + } + catch + { + error = new ErrorResponse + { + Error = new ErrorDetails + { + Message = "Unknown error", + Reason = "Unknown", + Code = "Unknown", + Stack = "Unknown", + 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}" + ); + } + + var data = JsonConvert.DeserializeObject(content); + return data.Result; + } + } +} diff --git a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithCryptoQuote.cs b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithCryptoQuote.cs new file mode 100644 index 0000000..399738d --- /dev/null +++ b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithCryptoQuote.cs @@ -0,0 +1,62 @@ +using Newtonsoft.Json; + +namespace Thirdweb.Pay +{ + public partial class ThirdwebPay + { + public static async Task GetBuyWithCryptoQuote(ThirdwebClient client, BuyWithCryptoQuoteParams buyWithCryptoParams) + { + var queryString = new Dictionary + { + { "fromAddress", buyWithCryptoParams.FromAddress }, + { "fromChainId", buyWithCryptoParams.FromChainId?.ToString() }, + { "fromTokenAddress", buyWithCryptoParams.FromTokenAddress }, + { "fromAmount", buyWithCryptoParams.FromAmount }, + { "fromAmountWei", buyWithCryptoParams.FromAmountWei }, + { "toChainId", buyWithCryptoParams.ToChainId?.ToString() }, + { "toTokenAddress", buyWithCryptoParams.ToTokenAddress }, + { "toAmount", buyWithCryptoParams.ToAmount }, + { "toAmountWei", buyWithCryptoParams.ToAmountWei }, + { "maxSlippageBPS", buyWithCryptoParams.MaxSlippageBPS?.ToString() }, + { "intentId", buyWithCryptoParams.IntentId } + }; + + var queryStringFormatted = string.Join("&", queryString.Where(kv => kv.Value != null).Select(kv => $"{Uri.EscapeDataString(kv.Key)}={Uri.EscapeDataString(kv.Value)}")); + var url = $"{Constants.THIRDWEB_PAY_CRYPTO_QUOTE_ENDPOINT}?{queryStringFormatted}"; + + var getResponse = await client.HttpClient.GetAsync(url); + + var content = await getResponse.Content.ReadAsStringAsync(); + + if (!getResponse.IsSuccessStatusCode) + { + ErrorResponse error; + try + { + error = JsonConvert.DeserializeObject(content); + } + catch + { + error = new ErrorResponse + { + Error = new ErrorDetails + { + Message = "Unknown error", + Reason = "Unknown", + Code = "Unknown", + Stack = "Unknown", + 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}" + ); + } + + var data = JsonConvert.DeserializeObject(content); + return data.Result; + } + } +} diff --git a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithCryptoStatus.cs b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithCryptoStatus.cs new file mode 100644 index 0000000..3d4c0ca --- /dev/null +++ b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithCryptoStatus.cs @@ -0,0 +1,54 @@ +using Newtonsoft.Json; + +namespace Thirdweb.Pay +{ + public partial class ThirdwebPay + { + public static async Task GetBuyWithCryptoStatus(ThirdwebClient client, string transactionHash) + { + if (string.IsNullOrEmpty(transactionHash)) + { + throw new ArgumentException(nameof(transactionHash), "Transaction hash cannot be null or empty."); + } + + var queryString = new Dictionary { { "transactionHash", transactionHash } }; + + var queryStringFormatted = string.Join("&", queryString.Where(kv => kv.Value != null).Select(kv => $"{Uri.EscapeDataString(kv.Key)}={Uri.EscapeDataString(kv.Value)}")); + var url = $"{Constants.THIRDWEB_PAY_CRYPTO_STATUS_ENDPOINT}?{queryStringFormatted}"; + + var getResponse = await client.HttpClient.GetAsync(url); + + var content = await getResponse.Content.ReadAsStringAsync(); + + if (!getResponse.IsSuccessStatusCode) + { + ErrorResponse error; + try + { + error = JsonConvert.DeserializeObject(content); + } + catch + { + error = new ErrorResponse + { + Error = new ErrorDetails + { + Message = "Unknown error", + Reason = "Unknown", + Code = "Unknown", + Stack = "Unknown", + 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}" + ); + } + + var data = JsonConvert.DeserializeObject(content); + return data.Result; + } + } +} diff --git a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatCurrencies.cs b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatCurrencies.cs new file mode 100644 index 0000000..eb3a442 --- /dev/null +++ b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatCurrencies.cs @@ -0,0 +1,46 @@ +using Newtonsoft.Json; + +namespace Thirdweb.Pay +{ + public partial class ThirdwebPay + { + public async Task> GetBuyWithFiatCurrencies(ThirdwebClient client) + { + var url = $"{Constants.THIRDWEB_PAY_FIAT_CURRENCIES_ENDPOINT}"; + + var getResponse = await client.HttpClient.GetAsync(url); + + var content = await getResponse.Content.ReadAsStringAsync(); + + if (!getResponse.IsSuccessStatusCode) + { + ErrorResponse error; + try + { + error = JsonConvert.DeserializeObject(content); + } + catch + { + error = new ErrorResponse + { + Error = new ErrorDetails + { + Message = "Unknown error", + Reason = "Unknown", + Code = "Unknown", + Stack = "Unknown", + 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}" + ); + } + + var data = JsonConvert.DeserializeObject(content); + return data.Result.FiatCurrencies; + } + } +} diff --git a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatQuote.cs b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatQuote.cs new file mode 100644 index 0000000..71ed24a --- /dev/null +++ b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatQuote.cs @@ -0,0 +1,61 @@ +using Newtonsoft.Json; + +namespace Thirdweb.Pay +{ + public partial class ThirdwebPay + { + public static async Task GetBuyWithFiatQuote(ThirdwebClient client, BuyWithFiatQuoteParams buyWithFiatParams) + { + var queryString = new Dictionary + { + { "fromCurrencySymbol", buyWithFiatParams.FromCurrencySymbol }, + { "fromAmount", buyWithFiatParams.FromAmount }, + { "fromAmountUnits", buyWithFiatParams.FromAmountUnits }, + { "toAddress", buyWithFiatParams.ToAddress }, + { "toChainId", buyWithFiatParams.ToChainId }, + { "toTokenAddress", buyWithFiatParams.ToTokenAddress }, + { "toAmount", buyWithFiatParams.ToAmount }, + { "toAmountWei", buyWithFiatParams.ToAmountWei }, + { "maxSlippageBPS", buyWithFiatParams.MaxSlippageBPS?.ToString() } + }; + + var queryStringFormatted = string.Join("&", queryString.Where(kv => kv.Value != null).Select(kv => $"{Uri.EscapeDataString(kv.Key)}={Uri.EscapeDataString(kv.Value)}")); + var url = $"{Constants.THIRDWEB_PAY_FIAT_QUOTE_ENDPOINT}?{queryStringFormatted}"; + url += buyWithFiatParams.IsTestMode ? "&isTestMode=true" : "&isTestMode=false"; + + var getResponse = await client.HttpClient.GetAsync(url); + + var content = await getResponse.Content.ReadAsStringAsync(); + + if (!getResponse.IsSuccessStatusCode) + { + ErrorResponse error; + try + { + error = JsonConvert.DeserializeObject(content); + } + catch + { + error = new ErrorResponse + { + Error = new ErrorDetails + { + Message = "Unknown error", + Reason = "Unknown", + Code = "Unknown", + Stack = "Unknown", + 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}" + ); + } + + var data = JsonConvert.DeserializeObject(content); + return data.Result; + } + } +} diff --git a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatStatus.cs b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatStatus.cs new file mode 100644 index 0000000..d35356c --- /dev/null +++ b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatStatus.cs @@ -0,0 +1,54 @@ +using Newtonsoft.Json; + +namespace Thirdweb.Pay +{ + public partial class ThirdwebPay + { + public async Task GetBuyWithFiatStatus(ThirdwebClient client, string intentId) + { + if (string.IsNullOrEmpty(intentId)) + { + throw new ArgumentException(nameof(intentId), "Intent ID cannot be null or empty."); + } + + var queryString = new Dictionary { { "intentId", intentId } }; + + var queryStringFormatted = string.Join("&", queryString.Where(kv => kv.Value != null).Select(kv => $"{Uri.EscapeDataString(kv.Key)}={Uri.EscapeDataString(kv.Value)}")); + var url = $"{Constants.THIRDWEB_PAY_FIAT_STATUS_ENDPOINT}?{queryStringFormatted}"; + + var getResponse = await client.HttpClient.GetAsync(url); + + var content = await getResponse.Content.ReadAsStringAsync(); + + if (!getResponse.IsSuccessStatusCode) + { + ErrorResponse error; + try + { + error = JsonConvert.DeserializeObject(content); + } + catch + { + error = new ErrorResponse + { + Error = new ErrorDetails + { + Message = "Unknown error", + Reason = "Unknown", + Code = "Unknown", + Stack = "Unknown", + 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}" + ); + } + + var data = JsonConvert.DeserializeObject(content); + return data.Result; + } + } +} diff --git a/Thirdweb/Thirdweb.Pay/Types.GetBuyHistory.cs b/Thirdweb/Thirdweb.Pay/Types.GetBuyHistory.cs new file mode 100644 index 0000000..d3fd01b --- /dev/null +++ b/Thirdweb/Thirdweb.Pay/Types.GetBuyHistory.cs @@ -0,0 +1,34 @@ +using Newtonsoft.Json; + +namespace Thirdweb.Pay +{ + public class BuyHistoryResponse + { + [JsonProperty("result")] + public BuyHistoryResult Result { get; set; } + } + + public class BuyHistoryResult + { + [JsonProperty("walletAddress")] + public string WalletAddress { get; set; } + + [JsonProperty("page")] + public List Page { get; set; } + + [JsonProperty("nextCursor")] + public string NextCursor { get; set; } + + [JsonProperty("pageSize")] + public int PageSize { get; set; } + } + + public class HistoryPage + { + [JsonProperty("buyWithCryptoStatus")] + public BuyWithCryptoStatusResult BuyWithCryptoStatus; + + [JsonProperty("buyWithFiatStatus")] + public BuyWithFiatStatusResult BuyWithFiatStatus; + } +} diff --git a/Thirdweb/Thirdweb.Pay/Types.GetBuyWithCryptoQuote.cs b/Thirdweb/Thirdweb.Pay/Types.GetBuyWithCryptoQuote.cs new file mode 100644 index 0000000..bb0876c --- /dev/null +++ b/Thirdweb/Thirdweb.Pay/Types.GetBuyWithCryptoQuote.cs @@ -0,0 +1,200 @@ +using System.Numerics; +using Newtonsoft.Json; + +namespace Thirdweb.Pay +{ + public class BuyWithCryptoQuoteParams + { + [JsonProperty("fromAddress")] + public string FromAddress { get; set; } + + [JsonProperty("fromChainId")] + public BigInteger? FromChainId { get; set; } + + [JsonProperty("fromTokenAddress")] + public string FromTokenAddress { get; set; } + + [JsonProperty("fromAmount")] + public string FromAmount { get; set; } + + [JsonProperty("fromAmountWei")] + public string FromAmountWei { get; set; } + + [JsonProperty("toChainId")] + public BigInteger? ToChainId { get; set; } + + [JsonProperty("toTokenAddress")] + public string ToTokenAddress { get; set; } + + [JsonProperty("toAmount")] + public string ToAmount { get; set; } + + [JsonProperty("toAmountWei")] + public string ToAmountWei { get; set; } + + [JsonProperty("maxSlippageBPS")] + public double? MaxSlippageBPS { get; set; } + + [JsonProperty("intentId")] + public string IntentId { get; set; } + + public BuyWithCryptoQuoteParams( + string fromAddress, + BigInteger? fromChainId, + string fromTokenAddress, + string toTokenAddress, + string fromAmount = null, + string fromAmountWei = null, + BigInteger? toChainId = null, + string toAmount = null, + string toAmountWei = null, + double? maxSlippageBPS = null, + string intentId = null + ) + { + FromAddress = fromAddress; + FromChainId = fromChainId; + FromTokenAddress = fromTokenAddress; + FromAmount = fromAmount; + FromAmountWei = fromAmountWei; + ToChainId = toChainId; + ToTokenAddress = toTokenAddress; + ToAmount = toAmount; + ToAmountWei = toAmountWei; + MaxSlippageBPS = maxSlippageBPS; + IntentId = intentId; + } + } + + public class TransactionRequest + { + [JsonProperty("data")] + public string Data { get; set; } + + [JsonProperty("to")] + public string To { get; set; } + + [JsonProperty("value")] + public string Value { get; set; } + + [JsonProperty("from")] + public string From { get; set; } + + [JsonProperty("chainId")] + public BigInteger ChainId { get; set; } + + [JsonProperty("gasPrice")] + public string GasPrice { get; set; } + + [JsonProperty("gasLimit")] + public string GasLimit { get; set; } + } + + public class Approval + { + [JsonProperty("chainId")] + public BigInteger ChainId { get; set; } + + [JsonProperty("tokenAddress")] + public string TokenAddress { get; set; } + + [JsonProperty("spenderAddress")] + public string SpenderAddress { get; set; } + + [JsonProperty("amountWei")] + public string AmountWei { get; set; } + } + + public class PaymentToken + { + [JsonProperty("token")] + public Token Token { get; set; } + + [JsonProperty("amountWei")] + public string AmountWei { get; set; } + + [JsonProperty("amount")] + public string Amount { get; set; } + + [JsonProperty("amountUSDCents")] + public double AmountUSDCents { get; set; } + } + + public class ProcessingFee + { + [JsonProperty("token")] + public Token Token { get; set; } + + [JsonProperty("amountWei")] + public string AmountWei { get; set; } + + [JsonProperty("amount")] + public string Amount { get; set; } + + [JsonProperty("amountUSDCents")] + public double AmountUSDCents { get; set; } + } + + public class BuyWithCryptoQuoteResult + { + [JsonProperty("quoteId")] + public string QuoteId { get; set; } + + [JsonProperty("transactionRequest")] + public TransactionRequest TransactionRequest { get; set; } + + [JsonProperty("approval")] + public Approval Approval { get; set; } + + [JsonProperty("fromAddress")] + public string FromAddress { get; set; } + + [JsonProperty("toAddress")] + public string ToAddress { get; set; } + + [JsonProperty("fromToken")] + public Token FromToken { get; set; } + + [JsonProperty("toToken")] + public Token ToToken { get; set; } + + [JsonProperty("fromAmountWei")] + public string FromAmountWei { get; set; } + + [JsonProperty("fromAmount")] + public string FromAmount { get; set; } + + [JsonProperty("toAmountMinWei")] + public string ToAmountMinWei { get; set; } + + [JsonProperty("toAmountMin")] + public string ToAmountMin { get; set; } + + [JsonProperty("toAmountWei")] + public string ToAmountWei { get; set; } + + [JsonProperty("toAmount")] + public string ToAmount { get; set; } + + [JsonProperty("paymentTokens")] + public List PaymentTokens { get; set; } + + [JsonProperty("processingFees")] + public List ProcessingFees { get; set; } + + [JsonProperty("estimated")] + public Estimated Estimated { get; set; } + + [JsonProperty("maxSlippageBPS")] + public double MaxSlippageBPS { get; set; } + + [JsonProperty("bridge")] + public string Bridge { get; set; } + } + + public class GetSwapQuoteResponse + { + [JsonProperty("result")] + public BuyWithCryptoQuoteResult Result { get; set; } + } +} diff --git a/Thirdweb/Thirdweb.Pay/Types.GetBuyWithCryptoStatus.cs b/Thirdweb/Thirdweb.Pay/Types.GetBuyWithCryptoStatus.cs new file mode 100644 index 0000000..b0421f7 --- /dev/null +++ b/Thirdweb/Thirdweb.Pay/Types.GetBuyWithCryptoStatus.cs @@ -0,0 +1,119 @@ +using Newtonsoft.Json; + +namespace Thirdweb.Pay +{ + public class SwapStatusResponse + { + [JsonProperty("result")] + public BuyWithCryptoStatusResult Result { get; set; } + } + + public class BuyWithCryptoStatusResult + { + [JsonProperty("quote")] + public SwapQuote Quote { get; set; } + + [JsonProperty("swapType")] + public string SwapType { get; set; } + + [JsonProperty("source")] + public TransactionDetails Source { get; set; } + + [JsonProperty("destination")] + public TransactionDetails Destination { get; set; } + + [JsonProperty("status")] + public string Status { get; set; } + + [JsonProperty("subStatus")] + public string SubStatus { get; set; } + + [JsonProperty("fromAddress")] + public string FromAddress { get; set; } + + [JsonProperty("toAddress")] + public string ToAddress { get; set; } + + [JsonProperty("failureMessage")] + public string FailureMessage { get; set; } + + [JsonProperty("bridge")] + public string Bridge { get; set; } + } + + public class TransactionDetails + { + [JsonProperty("transactionHash")] + public string TransactionHash { get; set; } + + [JsonProperty("token")] + public Token Token { get; set; } + + [JsonProperty("amount")] + public string Amount { get; set; } + + [JsonProperty("amountWei")] + public string AmountWei { get; set; } + + [JsonProperty("amountUSDCents")] + public double AmountUSDCents { get; set; } + + [JsonProperty("completedAt")] + public DateTime CompletedAt { get; set; } + + [JsonProperty("explorerLink")] + public string ExplorerLink { get; set; } + } + + public class SwapQuote + { + [JsonProperty("fromToken")] + public Token FromToken { get; set; } + + [JsonProperty("toToken")] + public Token ToToken { get; set; } + + [JsonProperty("fromAmountWei")] + public string FromAmountWei { get; set; } + + [JsonProperty("fromAmount")] + public string FromAmount { get; set; } + + [JsonProperty("toAmountWei")] + public string ToAmountWei { get; set; } + + [JsonProperty("toAmount")] + public string ToAmount { get; set; } + + [JsonProperty("toAmountMin")] + public string ToAmountMin { get; set; } + + [JsonProperty("toAmountMinWei")] + public string ToAmountMinWei { get; set; } + + [JsonProperty("estimated")] + public Estimated Estimated { get; set; } + + [JsonProperty("createdAt")] + public DateTime CreatedAt { get; set; } + } + + public enum SwapStatus + { + NOT_FOUND, + NONE, + PENDING, + FAILED, + COMPLETED + } + + public enum SwapSubStatus + { + NONE, + WAITING_BRIDGE, + REVERTED_ON_CHAIN, + SUCCESS, + PARTIAL_SUCCESS, + UNKNOWN_ERROR + } +} diff --git a/Thirdweb/Thirdweb.Pay/Types.GetBuyWithFiatCurrencies.cs b/Thirdweb/Thirdweb.Pay/Types.GetBuyWithFiatCurrencies.cs new file mode 100644 index 0000000..8b242ec --- /dev/null +++ b/Thirdweb/Thirdweb.Pay/Types.GetBuyWithFiatCurrencies.cs @@ -0,0 +1,16 @@ +using Newtonsoft.Json; + +namespace Thirdweb.Pay +{ + public class FiatCurrenciesResponse + { + [JsonProperty("result")] + public FiatCurrenciesResult Result { get; set; } + } + + public class FiatCurrenciesResult + { + [JsonProperty("fiatCurrencies")] + public List FiatCurrencies { get; set; } + } +} diff --git a/Thirdweb/Thirdweb.Pay/Types.GetBuyWithFiatQuote.cs b/Thirdweb/Thirdweb.Pay/Types.GetBuyWithFiatQuote.cs new file mode 100644 index 0000000..d64ed08 --- /dev/null +++ b/Thirdweb/Thirdweb.Pay/Types.GetBuyWithFiatQuote.cs @@ -0,0 +1,140 @@ +using Newtonsoft.Json; + +namespace Thirdweb.Pay +{ + public class BuyWithFiatQuoteParams + { + [JsonProperty("fromCurrencySymbol")] + public string FromCurrencySymbol { get; set; } + + [JsonProperty("fromAmount")] + public string FromAmount { get; set; } + + [JsonProperty("fromAmountUnits")] + public string FromAmountUnits { get; set; } + + [JsonProperty("toAddress")] + public string ToAddress { get; set; } + + [JsonProperty("toChainId")] + public string ToChainId { get; set; } + + [JsonProperty("toTokenAddress")] + public string ToTokenAddress { get; set; } + + [JsonProperty("toAmount")] + public string ToAmount { get; set; } + + [JsonProperty("toAmountWei")] + public string ToAmountWei { get; set; } + + [JsonProperty("maxSlippageBPS")] + public double? MaxSlippageBPS { get; set; } + + [JsonProperty("isTestMode")] + public bool IsTestMode { get; set; } + + public BuyWithFiatQuoteParams( + string fromCurrencySymbol, + string toAddress, + string toChainId, + string toTokenAddress, + string fromAmount = null, + string fromAmountUnits = null, + string toAmount = null, + string toAmountWei = null, + double? maxSlippageBPS = null, + bool isTestMode = false + ) + { + FromCurrencySymbol = fromCurrencySymbol; + FromAmount = fromAmount; + FromAmountUnits = fromAmountUnits; + ToAddress = toAddress; + ToChainId = toChainId; + ToTokenAddress = toTokenAddress; + ToAmount = toAmount; + ToAmountWei = toAmountWei; + MaxSlippageBPS = maxSlippageBPS; + IsTestMode = isTestMode; + } + } + + public class BuyWithFiatQuoteResult + { + [JsonProperty("intentId")] + public string IntentId { get; set; } + + [JsonProperty("toAddress")] + public string ToAddress { get; set; } + + [JsonProperty("fromCurrency")] + public OnRampCurrency FromCurrency { get; set; } + + [JsonProperty("fromCurrencyWithFees")] + public OnRampCurrency FromCurrencyWithFees { get; set; } + + [JsonProperty("onRampToken")] + public OnRampToken OnRampToken { get; set; } + + [JsonProperty("toToken")] + public Token ToToken { get; set; } + + [JsonProperty("estimatedToAmountMinWei")] + public string EstimatedToAmountMinWei { get; set; } + + [JsonProperty("estimatedToAmountMin")] + public string EstimatedToAmountMin { get; set; } + + [JsonProperty("processingFees")] + public List ProcessingFees { get; set; } + + [JsonProperty("estimatedDurationSeconds")] + public string EstimatedDurationSeconds { get; set; } + + [JsonProperty("maxSlippageBPS")] + public double MaxSlippageBPS { get; set; } + + [JsonProperty("onRampLink")] + public string OnRampLink { get; set; } + } + + public class OnRampToken + { + [JsonProperty("token")] + public Token Token { get; set; } + + [JsonProperty("amountWei")] + public string AmountWei { get; set; } + + [JsonProperty("amount")] + public string Amount { get; set; } + + [JsonProperty("amountUSDCents")] + public double AmountUSDCents { get; set; } + } + + public class OnRampFees + { + [JsonProperty("amount")] + public string Amount { get; set; } + + [JsonProperty("amountUnits")] + public string AmountUnits { get; set; } + + [JsonProperty("decimals")] + public int Decimals { get; set; } + + [JsonProperty("currencySymbol")] + public string CurrencySymbol { get; set; } + + [JsonProperty("feeType")] + public string FeeType { get; set; } + } + + public class GetFiatQuoteResponse + { + [JsonProperty("result")] + public BuyWithFiatQuoteResult Result { get; set; } + } +} diff --git a/Thirdweb/Thirdweb.Pay/Types.GetBuyWithFiatStatus.cs b/Thirdweb/Thirdweb.Pay/Types.GetBuyWithFiatStatus.cs new file mode 100644 index 0000000..b6c1733 --- /dev/null +++ b/Thirdweb/Thirdweb.Pay/Types.GetBuyWithFiatStatus.cs @@ -0,0 +1,83 @@ +using Newtonsoft.Json; + +namespace Thirdweb.Pay +{ + public class OnRampStatusResponse + { + [JsonProperty("result")] + public BuyWithFiatStatusResult Result { get; set; } + } + + public class BuyWithFiatStatusResult + { + [JsonProperty("intentId")] + public string IntentId { get; set; } + + [JsonProperty("status")] + public string Status { get; set; } + + [JsonProperty("toAddress")] + public string ToAddress { get; set; } + + [JsonProperty("quote")] + public OnRampQuote Quote { get; set; } + + [JsonProperty("source")] + public TransactionDetails Source { get; set; } + + [JsonProperty("destination")] + public TransactionDetails Destination { get; set; } + + [JsonProperty("failureMessage")] + public string FailureMessage { get; set; } + } + + public class OnRampQuote + { + [JsonProperty("createdAt")] + public string CreatedAt { get; set; } + + [JsonProperty("estimatedOnRampAmountWei")] + public string EstimatedOnRampAmountWei { get; set; } + + [JsonProperty("estimatedOnRampAmount")] + public string EstimatedOnRampAmount { get; set; } + + [JsonProperty("estimatedToTokenAmount")] + public string EstimatedToTokenAmount { get; set; } + + [JsonProperty("estimatedToTokenAmountWei")] + public string EstimatedToTokenAmountWei { get; set; } + + [JsonProperty("fromCurrency")] + public OnRampCurrency FromCurrency { get; set; } + + [JsonProperty("fromCurrencyWithFees")] + public OnRampCurrency FromCurrencyWithFees { get; set; } + + [JsonProperty("onRampToken")] + public Token OnRampToken { get; set; } + + [JsonProperty("toToken")] + public Token ToToken { get; set; } + + [JsonProperty("estimatedDurationSeconds")] + public long EstimatedDurationSeconds { get; set; } + } + + public enum OnRampStatus + { + NONE, + PENDING_PAYMENT, + PAYMENT_FAILED, + PENDING_ON_RAMP_TRANSFER, + ON_RAMP_TRANSFER_IN_PROGRESS, + ON_RAMP_TRANSFER_COMPLETED, + ON_RAMP_TRANSFER_FAILED, + CRYPTO_SWAP_REQUIRED, + CRYPTO_SWAP_COMPLETED, + CRYPTO_SWAP_FALLBACK, + CRYPTO_SWAP_IN_PROGRESS, + CRYPTO_SWAP_FAILED, + } +} diff --git a/Thirdweb/Thirdweb.Pay/Types.Shared.cs b/Thirdweb/Thirdweb.Pay/Types.Shared.cs new file mode 100644 index 0000000..de204d9 --- /dev/null +++ b/Thirdweb/Thirdweb.Pay/Types.Shared.cs @@ -0,0 +1,96 @@ +using System.Numerics; +using Newtonsoft.Json; + +namespace Thirdweb.Pay +{ + public class ErrorResponse + { + [JsonProperty("error")] + public ErrorDetails Error { get; set; } + } + + public class ErrorDetails + { + [JsonProperty("message")] + public string Message { get; set; } + + [JsonProperty("reason")] + public string Reason { get; set; } + + [JsonProperty("code")] + public string Code { get; set; } + + [JsonProperty("stack")] + public string Stack { get; set; } + + [JsonProperty("statusCode")] + public int StatusCode { get; set; } + } + + public class Token + { + [JsonProperty("chainId")] + public BigInteger ChainId { get; set; } + + [JsonProperty("tokenAddress")] + public string TokenAddress { get; set; } + + [JsonProperty("decimals")] + public int Decimals { get; set; } + + [JsonProperty("priceUSDCents")] + public int PriceUSDCents { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("symbol")] + public string Symbol { get; set; } + } + + public class Estimated + { + [JsonProperty("fromAmountUSDCents")] + public double FromAmountUSDCents { get; set; } + + [JsonProperty("toAmountMinUSDCents")] + public double ToAmountMinUSDCents { get; set; } + + [JsonProperty("toAmountUSDCents")] + public double ToAmountUSDCents { get; set; } + + [JsonProperty("slippageBPS")] + public int SlippageBPS { get; set; } + + [JsonProperty("feesUSDCents")] + public double FeesUSDCents { get; set; } + + [JsonProperty("gasCostUSDCents")] + public double GasCostUSDCents { get; set; } + + [JsonProperty("durationSeconds")] + public int DurationSeconds { get; set; } + } + + public class OnRampCurrency + { + [JsonProperty("amount")] + public string Amount { get; set; } + + [JsonProperty("amountUnits")] + public string AmountUnits { get; set; } + + [JsonProperty("decimals")] + public int Decimals { get; set; } + + [JsonProperty("currencySymbol")] + public string CurrencySymbol { get; set; } + } + + public enum SwapType + { + SAME_CHAIN, + CROSS_CHAIN, + ON_RAMP + } +} From e90884e57c7d357c14d399ec3a065813fbba6bff Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Fri, 14 Jun 2024 00:56:01 +0300 Subject: [PATCH 2/8] checksum util --- Thirdweb.Tests/Thirdweb.Utils.Tests.cs | 8 ++++++++ Thirdweb/Thirdweb.Utils/Utils.cs | 5 +++++ .../Thirdweb.Wallets/PrivateKeyWallet/PrivateKeyWallet.cs | 2 +- Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Thirdweb.Tests/Thirdweb.Utils.Tests.cs b/Thirdweb.Tests/Thirdweb.Utils.Tests.cs index b2ac60d..61e4ba1 100644 --- a/Thirdweb.Tests/Thirdweb.Utils.Tests.cs +++ b/Thirdweb.Tests/Thirdweb.Utils.Tests.cs @@ -386,4 +386,12 @@ public void GenerateSIWE_ThrowsOnNullIssuedAt() }; _ = Assert.Throws(() => Utils.GenerateSIWE(loginPayloadData)); } + + [Fact] + public void ToChecksumAddress_ReturnsCorrectValue() + { + var address = "0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed".ToLower(); + var checksumAddress = Utils.ToChecksumAddress(address); + Assert.Equal("0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed", checksumAddress); + } } diff --git a/Thirdweb/Thirdweb.Utils/Utils.cs b/Thirdweb/Thirdweb.Utils/Utils.cs index aa06160..1d5335a 100644 --- a/Thirdweb/Thirdweb.Utils/Utils.cs +++ b/Thirdweb/Thirdweb.Utils/Utils.cs @@ -173,5 +173,10 @@ public static bool IsZkSync(BigInteger chainId) { return chainId.Equals(324) || chainId.Equals(300) || chainId.Equals(302); } + + public static string ToChecksumAddress(this string address) + { + return new AddressUtil().ConvertToChecksumAddress(address); + } } } diff --git a/Thirdweb/Thirdweb.Wallets/PrivateKeyWallet/PrivateKeyWallet.cs b/Thirdweb/Thirdweb.Wallets/PrivateKeyWallet/PrivateKeyWallet.cs index 817ca20..9f75f91 100644 --- a/Thirdweb/Thirdweb.Wallets/PrivateKeyWallet/PrivateKeyWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/PrivateKeyWallet/PrivateKeyWallet.cs @@ -39,7 +39,7 @@ public static Task Generate(ThirdwebClient client) public virtual Task GetAddress() { - return Task.FromResult(_ecKey.GetPublicAddress()); + return Task.FromResult(_ecKey.GetPublicAddress().ToChecksumAddress()); } public virtual Task EthSign(byte[] rawMessage) diff --git a/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs b/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs index fd829e3..164f5ec 100644 --- a/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs @@ -352,7 +352,7 @@ public Task GetPersonalAccount() public async Task GetAddress() { - return Utils.IsZkSync(_chainId) ? await _personalAccount.GetAddress() : _accountContract.Address; + return Utils.IsZkSync(_chainId) ? await _personalAccount.GetAddress() : _accountContract.Address.ToChecksumAddress(); } public Task EthSign(byte[] rawMessage) From 275297cf65853a766b179ad175e7b98cd85f9d2a Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Fri, 14 Jun 2024 01:15:21 +0300 Subject: [PATCH 3/8] hex str -> bigint -> hexbigint --- Thirdweb/Thirdweb.Pay/ThirdwebPay.BuyWithCrypto.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Thirdweb/Thirdweb.Pay/ThirdwebPay.BuyWithCrypto.cs b/Thirdweb/Thirdweb.Pay/ThirdwebPay.BuyWithCrypto.cs index c1d8cd8..0f8d04a 100644 --- a/Thirdweb/Thirdweb.Pay/ThirdwebPay.BuyWithCrypto.cs +++ b/Thirdweb/Thirdweb.Pay/ThirdwebPay.BuyWithCrypto.cs @@ -23,9 +23,9 @@ public static async Task BuyWithCrypto(ThirdwebClient client, IThirdwebW From = buyWithCryptoQuote.TransactionRequest.From, To = buyWithCryptoQuote.TransactionRequest.To, Data = buyWithCryptoQuote.TransactionRequest.Data, - Value = new HexBigInteger(buyWithCryptoQuote.TransactionRequest.Value), - Gas = new HexBigInteger(buyWithCryptoQuote.TransactionRequest.GasLimit), - GasPrice = new HexBigInteger(buyWithCryptoQuote.TransactionRequest.GasPrice), + Value = new HexBigInteger(BigInteger.Parse(buyWithCryptoQuote.TransactionRequest.Value)), + Gas = new HexBigInteger(BigInteger.Parse(buyWithCryptoQuote.TransactionRequest.GasLimit)), + GasPrice = new HexBigInteger(BigInteger.Parse(buyWithCryptoQuote.TransactionRequest.GasPrice)), }; var tx = await ThirdwebTransaction.Create(client, wallet, txInput, buyWithCryptoQuote.TransactionRequest.ChainId); From 61e07423e2c392d8fccb76e7d8e0a85c1ed03981 Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Fri, 14 Jun 2024 01:53:27 +0300 Subject: [PATCH 4/8] static --- Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatCurrencies.cs | 2 +- Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatStatus.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatCurrencies.cs b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatCurrencies.cs index eb3a442..7336ead 100644 --- a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatCurrencies.cs +++ b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatCurrencies.cs @@ -4,7 +4,7 @@ namespace Thirdweb.Pay { public partial class ThirdwebPay { - public async Task> GetBuyWithFiatCurrencies(ThirdwebClient client) + public static async Task> GetBuyWithFiatCurrencies(ThirdwebClient client) { var url = $"{Constants.THIRDWEB_PAY_FIAT_CURRENCIES_ENDPOINT}"; diff --git a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatStatus.cs b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatStatus.cs index d35356c..1103a37 100644 --- a/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatStatus.cs +++ b/Thirdweb/Thirdweb.Pay/ThirdwebPay.GetBuyWithFiatStatus.cs @@ -4,7 +4,7 @@ namespace Thirdweb.Pay { public partial class ThirdwebPay { - public async Task GetBuyWithFiatStatus(ThirdwebClient client, string intentId) + public static async Task GetBuyWithFiatStatus(ThirdwebClient client, string intentId) { if (string.IsNullOrEmpty(intentId)) { From fa281847f1e4b3c917a33df83869dcf1d9f1098a Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Fri, 14 Jun 2024 02:02:27 +0300 Subject: [PATCH 5/8] Update codecov.yml --- codecov.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/codecov.yml b/codecov.yml index 68f4592..8968aaa 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,2 +1,3 @@ ignore: - "Thirdweb/Thirdweb.Wallets/InAppWallet" + - "Thirdweb/Thirdweb.Pay From d16f286be88bb0f3597dc5b69778f273da2af1dd Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Fri, 14 Jun 2024 02:06:44 +0300 Subject: [PATCH 6/8] min gas per pub 10k --- Thirdweb/Thirdweb.Transactions/ThirdwebTransaction.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Thirdweb/Thirdweb.Transactions/ThirdwebTransaction.cs b/Thirdweb/Thirdweb.Transactions/ThirdwebTransaction.cs index a9df6a7..465f6c5 100644 --- a/Thirdweb/Thirdweb.Transactions/ThirdwebTransaction.cs +++ b/Thirdweb/Thirdweb.Transactions/ThirdwebTransaction.cs @@ -237,7 +237,8 @@ private static async Task GetGasPerPubData(ThirdwebTransaction trans { var rpc = ThirdwebRPC.GetRpcInstance(transaction._client, transaction.Input.ChainId.Value); var hex = (await rpc.SendRequestAsync("zks_estimateFee", transaction.Input, "latest"))["gas_per_pubdata_limit"].ToString(); - return new HexBigInteger(hex).Value * 10 / 5; + var finalGasPerPubData = new HexBigInteger(hex).Value * 10 / 5; + return finalGasPerPubData < 10000 ? 10000 : finalGasPerPubData; } public static async Task Sign(ThirdwebTransaction transaction) From 67c4bb2063f2992b8151e98b9ab6cbc9b24cb42e Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Fri, 14 Jun 2024 02:08:38 +0300 Subject: [PATCH 7/8] Update codecov.yml --- codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codecov.yml b/codecov.yml index 8968aaa..92a0a54 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,3 +1,3 @@ ignore: - "Thirdweb/Thirdweb.Wallets/InAppWallet" - - "Thirdweb/Thirdweb.Pay + - "Thirdweb/Thirdweb.Pay \ No newline at end of file From 9aad74e7471083bd60217d38dbe15253e5fc234c Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Fri, 14 Jun 2024 02:10:24 +0300 Subject: [PATCH 8/8] Update codecov.yml --- codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codecov.yml b/codecov.yml index 92a0a54..bd2adf1 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,3 +1,3 @@ ignore: - "Thirdweb/Thirdweb.Wallets/InAppWallet" - - "Thirdweb/Thirdweb.Pay \ No newline at end of file + - "Thirdweb/Thirdweb.Pay" \ No newline at end of file