diff --git a/Uniton Connect/Configs/Jettons Storage/Jettons/Jetton_DOGS.asset b/Uniton Connect/Configs/Jettons Storage/Jettons/Jetton_DOGS.asset index 02b9331..5ca1343 100644 --- a/Uniton Connect/Configs/Jettons Storage/Jettons/Jetton_DOGS.asset +++ b/Uniton Connect/Configs/Jettons Storage/Jettons/Jetton_DOGS.asset @@ -13,5 +13,6 @@ MonoBehaviour: m_Name: Jetton_DOGS m_EditorClassIdentifier: k__BackingField: 2 + k__BackingField: DOGS k__BackingField: 0:afc49cb8786f21c87045b19ede78fc6b46c51048513f8e9a6d44060199c1bf0c k__BackingField: https://cache.tonapi.io/imgproxy/6Pb0sBFy_AzW6l39EIHGs-Iz4eLbbZUh8AYY_Xq-rcg/rs:fill:200:200:1/g:no/aHR0cHM6Ly9jZG4uZG9ncy5kZXYvZG9ncy5wbmc.webp diff --git a/Uniton Connect/Configs/Jettons Storage/Jettons/Jetton_GRAM.asset b/Uniton Connect/Configs/Jettons Storage/Jettons/Jetton_GRAM.asset index ce53f6c..9108c27 100644 --- a/Uniton Connect/Configs/Jettons Storage/Jettons/Jetton_GRAM.asset +++ b/Uniton Connect/Configs/Jettons Storage/Jettons/Jetton_GRAM.asset @@ -13,5 +13,6 @@ MonoBehaviour: m_Name: Jetton_GRAM m_EditorClassIdentifier: k__BackingField: 0 + k__BackingField: GRAM k__BackingField: 0:b8ef4f77a17e5785bd31ba4da50abd91852f2b8febee97ad6ee16d941f939198 k__BackingField: https://cache.tonapi.io/imgproxy/lNoY3YdNeBug53ixjK6hxT6XIX3_xoIYNqv-ykIQ1Aw/rs:fill:200:200:1/g:no/aHR0cHM6Ly9ncmFtY29pbi5vcmcvaW1nL2ljb24ucG5n.webp diff --git a/Uniton Connect/Configs/Jettons Storage/Jettons/Jetton_NOT.asset b/Uniton Connect/Configs/Jettons Storage/Jettons/Jetton_NOT.asset index d60370c..72dfff2 100644 --- a/Uniton Connect/Configs/Jettons Storage/Jettons/Jetton_NOT.asset +++ b/Uniton Connect/Configs/Jettons Storage/Jettons/Jetton_NOT.asset @@ -13,5 +13,6 @@ MonoBehaviour: m_Name: Jetton_NOT m_EditorClassIdentifier: k__BackingField: 1 + k__BackingField: NOT k__BackingField: 0:2f956143c461769579baef2e32cc2d7bc18283f40d20bb03e432cd603ac33ffc k__BackingField: https://cache.tonapi.io/imgproxy/4KCMNm34jZLXt0rqeFm4rH-BK4FoK76EVX9r0cCIGDg/rs:fill:200:200:1/g:no/aHR0cHM6Ly9jZG4uam9pbmNvbW11bml0eS54eXovY2xpY2tlci9ub3RfbG9nby5wbmc.webp diff --git a/Uniton Connect/Configs/Jettons Storage/Jettons/Jetton_USDT.asset b/Uniton Connect/Configs/Jettons Storage/Jettons/Jetton_USDT.asset index 0adc5ab..2ecf184 100644 --- a/Uniton Connect/Configs/Jettons Storage/Jettons/Jetton_USDT.asset +++ b/Uniton Connect/Configs/Jettons Storage/Jettons/Jetton_USDT.asset @@ -13,5 +13,6 @@ MonoBehaviour: m_Name: Jetton_USDT m_EditorClassIdentifier: k__BackingField: 3 + k__BackingField: "USD\u20AE" k__BackingField: 0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe k__BackingField: https://cache.tonapi.io/imgproxy/T3PB4s7oprNVaJkwqbGg54nexKE0zzKhcrPv8jcWYzU/rs:fill:200:200:1/g:no/aHR0cHM6Ly90ZXRoZXIudG8vaW1hZ2VzL2xvZ29DaXJjbGUucG5n.webp diff --git a/Uniton Connect/Runtime/Common/JettonTypes.cs b/Uniton Connect/Runtime/Common/JettonTypes.cs index 72a1a9d..511ddc5 100644 --- a/Uniton Connect/Runtime/Common/JettonTypes.cs +++ b/Uniton Connect/Runtime/Common/JettonTypes.cs @@ -5,6 +5,7 @@ public enum JettonTypes GRAM, NOT, DOGS, - USDT + USDT, + Custom } } \ No newline at end of file diff --git a/Uniton Connect/Runtime/Common/TransactionTypes.cs b/Uniton Connect/Runtime/Common/TransactionTypes.cs new file mode 100644 index 0000000..ddd2ca6 --- /dev/null +++ b/Uniton Connect/Runtime/Common/TransactionTypes.cs @@ -0,0 +1,8 @@ +namespace UnitonConnect.Core.Common +{ + public enum TransactionTypes + { + Sent, + Received + } +} \ No newline at end of file diff --git a/Uniton Connect/Runtime/Consts/ClassicJettonNames.cs b/Uniton Connect/Runtime/Consts/ClassicJettonNames.cs new file mode 100644 index 0000000..108c6d1 --- /dev/null +++ b/Uniton Connect/Runtime/Consts/ClassicJettonNames.cs @@ -0,0 +1,10 @@ +namespace UnitonConnect.Core.Common +{ + public static class ClassicJettonNames + { + public const string USDT_NAME = "Tether USD"; + public const string GRAM_NAME = "Gram"; + public const string NOT_NAME = "Notcoin"; + public const string DOGS_NAME = "Dogs"; + } +} \ No newline at end of file diff --git a/Uniton Connect/Runtime/Core/Base/Transactions/IUnitonConnectJettonCallbacks.cs b/Uniton Connect/Runtime/Core/Base/Transactions/IUnitonConnectJettonCallbacks.cs index 0129a81..2033e02 100644 --- a/Uniton Connect/Runtime/Core/Base/Transactions/IUnitonConnectJettonCallbacks.cs +++ b/Uniton Connect/Runtime/Core/Base/Transactions/IUnitonConnectJettonCallbacks.cs @@ -1,18 +1,28 @@ +using System.Collections.Generic; using UnitonConnect.Core.Data; namespace UnitonConnect.Core.Common { public interface IUnitonConnectJettonCallbacks { + delegate void OnJettonBalanceLoaded(decimal balance, + string jettonName, string masterAddress); + delegate void OnJettonAddressParsed(string jettonAddress); + delegate void OnLastJettonTransactionsLoaded(TransactionTypes type, + List transactions); + delegate void OnJettonTransactionSend(string masterAddress, SuccessTransactionData transactionData); delegate void OnJettonTransactionSendFail(string masterAddress, string errorMessage); + event OnJettonBalanceLoaded OnBalanceLoaded; event OnJettonAddressParsed OnAddressParsed; + event OnLastJettonTransactionsLoaded OnLastTransactionsLoaded; + event OnJettonTransactionSend OnTransactionSended; event OnJettonTransactionSendFail OnTransactionSendFailed; } diff --git a/Uniton Connect/Runtime/Core/Bridges/TonApiBridge.cs b/Uniton Connect/Runtime/Core/Bridges/TonApiBridge.cs index ea5bfea..5c9e9f8 100644 --- a/Uniton Connect/Runtime/Core/Bridges/TonApiBridge.cs +++ b/Uniton Connect/Runtime/Core/Bridges/TonApiBridge.cs @@ -73,16 +73,6 @@ internal static IEnumerator GetAssetIcon( internal static IEnumerator GetBalance(Action walletBalanceClaimed) { - if (!UNITON_CONNECT.IsWalletConnected) - { - UnitonConnectLogger.LogWarning("Failed to request the balance," + - " connect the wallet and repeat the operation later"); - - walletBalanceClaimed?.Invoke(0); - - yield break; - } - var userEncodedAddress = ConvertAddressToEncodeURL(_walletAddress); var targetUrl = GetUserWalletUrl(userEncodedAddress); @@ -173,14 +163,6 @@ internal static IEnumerator GetTransactionPayload(decimal amount, internal static IEnumerator GetTransactionData(string transactionHash, float awaitDelay, Action dataClaimed, Action fetchDataFailed) { - if (!UNITON_CONNECT.IsWalletConnected) - { - UnitonConnectLogger.LogWarning("Failed to request the balance," + - " connect the wallet and repeat the operation later"); - - yield break; - } - yield return new WaitForSeconds(awaitDelay); var encodedTransactionHash = EscapeQueryParam(transactionHash); @@ -250,14 +232,6 @@ internal static class NFT internal static IEnumerator GetCollections(string apiURL, Action collectionsClaimed) { - if (!UNITON_CONNECT.IsWalletConnected) - { - UnitonConnectLogger.LogWarning("Failed to load user nft" + - " collections, wallet is not connected."); - - yield break; - } - using (UnityWebRequest request = UnityWebRequest.Get(apiURL)) { yield return request.SendWebRequest(); @@ -300,7 +274,42 @@ internal static string GetAllCollectionsUrl( internal sealed class Jetton { + internal static IEnumerator GetBalance(string tonAddress, + string masterJettonAddress, Action jettonBalanceLoaded) + { + var targetUrl = GetBalanceUrl(tonAddress, masterJettonAddress); + using (UnityWebRequest request = UnityWebRequest.Get(targetUrl)) + { + yield return request.SendWebRequest(); + + var responseJson = request.downloadHandler.text; + + if (request.result != WebRequestUtils.SUCCESS) + { + UnitonConnectLogger.LogError($"Failed to fetch jetton balance, reason: {responseJson}"); + + jettonBalanceLoaded?.Invoke(null); + + yield break; + } + + var responseData = JsonConvert.DeserializeObject(responseJson); + + jettonBalanceLoaded?.Invoke(responseData); + + UnitonConnectLogger.Log($"Loaded jetton {responseData.Configuration.Name} " + + $"with balance in nano: {responseData.BalanceInNano}"); + + yield break; + } + } + + internal static string GetBalanceUrl(string tonAddress, + string masterJettonAddress) + { + return $"https://tonapi.io/v2/accounts/{tonAddress}/jettons/{masterJettonAddress}"; + } } } } \ No newline at end of file diff --git a/Uniton Connect/Runtime/Core/Bridges/TonCenterApiBridge.cs b/Uniton Connect/Runtime/Core/Bridges/TonCenterApiBridge.cs index 692fe5d..5acd007 100644 --- a/Uniton Connect/Runtime/Core/Bridges/TonCenterApiBridge.cs +++ b/Uniton Connect/Runtime/Core/Bridges/TonCenterApiBridge.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Collections.Generic; using UnityEngine.Networking; using Newtonsoft.Json; using UnitonConnect.Core; @@ -71,11 +72,59 @@ internal static IEnumerator GetJettonWalletByOwner(string tonAddress, } } + internal static IEnumerator GetLastTransactions(string ownerAddress, + string directionTag, int limit, Action> transactionsLoaded) + { + var targetUrl = GetLastJettonTransactionsUrl(ownerAddress, directionTag, limit); + + using (UnityWebRequest request = UnityWebRequest.Get(targetUrl)) + { + yield return request.SendWebRequest(); + + var responseResult = request.downloadHandler.text; + + UnitonConnectLogger.Log($"Parsed response for loading " + + $"last jetton transactions: {responseResult}"); + + if (request.result == WebRequestUtils.SUCCESS) + { + var loadedTransactionsList = JsonConvert.DeserializeObject(responseResult); + + if (loadedTransactionsList.Transfers == null || + loadedTransactionsList.Transfers.Count == 0) + { + UnitonConnectLogger.Log($"Jetton transactions is not detected at wallet: {ownerAddress}"); + + transactionsLoaded?.Invoke(null); + + yield break; + } + + transactionsLoaded?.Invoke(loadedTransactionsList.Transfers); + + yield break; + } + + var errorData = JsonConvert.DeserializeObject(responseResult); + + UnitonConnectLogger.LogError($"Failed to load last jetton transactions, reason: {errorData.Message}"); + + transactionsLoaded?.Invoke(null); + } + } + internal static string GetJettonWalletUlr(string tonAddress, string jettonMaster) { return $"https://toncenter.com/api/v3/jetton/wallets?owner_address={tonAddress}&" + $"jetton_address={jettonMaster}&exclude_zero_balance=false&limit=50&offset=0"; } + + internal static string GetLastJettonTransactionsUrl(string ownerAddress, + string directionTag, int limit) + { + return $"https://toncenter.com/api/v3/jetton/transfers?owner_address={ownerAddress}" + + $"&direction={directionTag}&limit={limit}&offset=0"; + } } } } \ No newline at end of file diff --git a/Uniton Connect/Runtime/Core/Modules/UserAssets.cs b/Uniton Connect/Runtime/Core/Modules/UserAssets.cs index 3d3a6ed..12f78dd 100644 --- a/Uniton Connect/Runtime/Core/Modules/UserAssets.cs +++ b/Uniton Connect/Runtime/Core/Modules/UserAssets.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Collections; +using System.Collections.Generic; using UnityEngine; using UnitonConnect.Core; using UnitonConnect.Core.Data; @@ -9,6 +10,7 @@ using UnitonConnect.Core.Utils.Debugging; using UnitonConnect.Runtime.Data; using UnitonConnect.ThirdParty; +using UnitonConnect.Editor.Data; namespace UnitonConnect.DeFi { @@ -137,11 +139,21 @@ public Jetton(MonoBehaviour mono, _sdk = sdk; } + /// + /// Callback to get the jetton balance for a specific master address with its configuration + /// + public event IUnitonConnectJettonCallbacks.OnJettonBalanceLoaded OnBalanceLoaded; + /// /// Callback to get the wallet address of a specific token, if it exists in the connected account /// public event IUnitonConnectJettonCallbacks.OnJettonAddressParsed OnAddressParsed; + /// + /// Callback to retrieve a list of successful owner's Jetton transactions (received or sent) + /// + public event IUnitonConnectJettonCallbacks.OnLastJettonTransactionsLoaded OnLastTransactionsLoaded; + /// /// Callback to retrieve transaction information from the blockchain after a successful submission /// @@ -157,16 +169,24 @@ public Jetton(MonoBehaviour mono, /// if it was previously created on the connected wallet /// /// Master address of the target jetton contract - public void ParseAddress(string masterAddress) + public void GetAddress(string masterAddress) { if (!IsWalletConnected()) { + return; + } + + if (string.IsNullOrEmpty(masterAddress)) + { + UnitonConnectLogger.LogWarning("The master address is " + + "required to load the jetton wallet address!"); + return; } var currentAddress = _sdk.Wallet.ToHex(); - ParseAddress(masterAddress, currentAddress, (walletConfig) => + GetAddress(masterAddress, currentAddress, (walletConfig) => { if (walletConfig == null) { @@ -187,28 +207,102 @@ public void ParseAddress(string masterAddress) /// Loading the balance of the classic token on the connected wallet /// /// - public void LoadBalance(JettonTypes type) + public void GetBalance(JettonTypes type) { if (!IsWalletConnected()) { return; } + var targetJetton = GetConfigByType(type); + if (targetJetton == null) + { + return; + } + + var masterAddress = targetJetton.MasterAddress; + + GetBalance(masterAddress); } /// /// Loading the balance of a custom token on the connected wallet by its master address /// - /// - public void LoadBalance(string masterAddress) + /// Jetton master address for loading + public void GetBalance(string masterAddress) { if (!IsWalletConnected()) { return; } + if (string.IsNullOrEmpty(masterAddress)) + { + UnitonConnectLogger.LogWarning("The master address is " + + "required to load the jetton balance!"); + + return; + } + + var currentAddress = _sdk.Wallet.ToHex(); + _mono.StartCoroutine(TonApiBridge.Jetton.GetBalance( + currentAddress, masterAddress, (loadedJettonConfig) => + { + if (loadedJettonConfig == null) + { + UnitonConnectLogger.LogWarning($"Target jetton " + + $"{masterAddress} not found at connected wallet"); + + OnBalanceLoaded?.Invoke(0, "NOT_FOUND", masterAddress); + + return; + } + + var balanceInNano = long.Parse(loadedJettonConfig.BalanceInNano); + decimal balance = UserAssetsUtils.FromNanoton(balanceInNano); + + var tokenName = loadedJettonConfig.Configuration.Name; + + if (tokenName == ClassicJettonNames.USDT_NAME) + { + balance = (decimal)UserAssetsUtils.FromUSDtNanoton(balanceInNano); + } + + OnBalanceLoaded?.Invoke(balance, tokenName, masterAddress); + })); + } + + /// + /// Getting the latest successful transactions by 'sent/received' type + /// + /// + /// + public void GetLastTransactions(TransactionTypes type, int limit) + { + if (!IsWalletConnected()) + { + return; + } + + var transactionTag = type == TransactionTypes.Received ? "in" : "out"; + var connectedAddress = _sdk.Wallet.ToHex(); + + _mono.StartCoroutine(TonCenterApiBridge.Jetton.GetLastTransactions( + connectedAddress, transactionTag, limit, (loadedTransactions) => + { + if (loadedTransactions == null) + { + OnLastTransactionsLoaded?.Invoke(type, new List()); + + return; + } + + UnitonConnectLogger.Log($"Loaded the last {limit} jetton transactions"); + + OnLastTransactionsLoaded?.Invoke(type, loadedTransactions); + })); } /// @@ -226,14 +320,18 @@ public void SendTransaction(JettonTypes type, string recipientAddress, return; } - var targetJetton = _sdk.JettonStorage.Jettons - .FirstOrDefault(jetton => jetton.Type == type); + if (string.IsNullOrEmpty(recipientAddress)) + { + UnitonConnectLogger.LogWarning("Recipient address " + + "is required, transaction cancelled"); + + return; + } + + var targetJetton = GetConfigByType(type); if (targetJetton == null) { - UnitonConnectLogger.LogError($"Jetton {type} not found " + - $"in the storage of available jettons for sending"); - return; } @@ -254,14 +352,25 @@ public void SendTransaction(JettonTypes type, string recipientAddress, public void SendTransaction(string masterAddress, string recipientAddress, decimal amount, decimal gasFee, string message = null) { + if (!IsWalletConnected()) + { + return; + } + if (string.IsNullOrEmpty(LatestJettonWalletAddress)) { UnitonConnectLogger.LogWarning("The jetton wallet has not been loaded, start parsing..."); } var ownerAddress = _sdk.Wallet.ToHex(); + var recipientToHex = WalletConnectUtils.GetHEXAddress(recipientAddress); - ParseAddress(masterAddress, ownerAddress, (walletConfig) => + if (WalletConnectUtils.IsAddressesMatch(recipientAddress)) + { + return; + } + + GetAddress(masterAddress, ownerAddress, (walletConfig) => { if (walletConfig == null) { @@ -278,7 +387,7 @@ public void SendTransaction(string masterAddress, string recipientAddress, }); } - private void ParseAddress(string masterAddress, string tonAddress, + private void GetAddress(string masterAddress, string tonAddress, Action walletParsed) { _mono.StartCoroutine(UserAssetsUtils.GetJettonWalletByAddress( @@ -356,6 +465,8 @@ private IEnumerator LoadTransactionStatus(string transactionHash) { isFailed = true; + _mono.StartCoroutine(LoadTransactionStatus(transactionHash)); + return; } @@ -363,6 +474,22 @@ private IEnumerator LoadTransactionStatus(string transactionHash) }); } + private JettonConfig GetConfigByType(JettonTypes type) + { + var targetJetton = _sdk.JettonStorage.Jettons + .FirstOrDefault(jetton => jetton.Type == type); + + if (targetJetton == null) + { + UnitonConnectLogger.LogError($"Jetton {type} not found " + + $"in the storage of available jettons for sending"); + + return null; + } + + return targetJetton; + } + private bool IsWalletConnected() { if (!_sdk.IsWalletConnected) diff --git a/Uniton Connect/Runtime/Core/UnitonConnectSDK.cs b/Uniton Connect/Runtime/Core/UnitonConnectSDK.cs index 4077273..693587c 100644 --- a/Uniton Connect/Runtime/Core/UnitonConnectSDK.cs +++ b/Uniton Connect/Runtime/Core/UnitonConnectSDK.cs @@ -206,6 +206,10 @@ public void Initialize() OnInitialize, OnConnect, OnConnectFail, OnConnectRestore); } + else + { + OnInitialize(true); + } UnitonConnectLogger.Log("Native SDK successfully initialized"); @@ -311,7 +315,9 @@ public void SendTransaction(string recipientAddress, return; } - if (WalletConnectUtils.IsAddressesMatch(recipientAddress)) + var recipientToHex = WalletConnectUtils.GetHEXAddress(recipientAddress); + + if (WalletConnectUtils.IsAddressesMatch(recipientToHex)) { UnitonConnectLogger.LogWarning("Transaction canceled because the recipient and sender addresses match"); @@ -356,7 +362,7 @@ private IEnumerator ConfirmTonTransaction(string transactionHash) yield return new WaitForSeconds(5f); } - StartCoroutine(TonApiBridge.GetTransactionData(transactionHash, + yield return TonApiBridge.GetTransactionData(transactionHash, _confirmTransactionDelay, (transactionData) => { var fee = UserAssetsUtils.FromNanoton(transactionData.TotalFees).ToString(); @@ -378,11 +384,13 @@ private IEnumerator ConfirmTonTransaction(string transactionHash) { isFailed = true; + StartCoroutine(ConfirmTonTransaction(transactionHash)); + return; } OnSendingTonConfirm(null); - })); + }); } private bool IsSupporedPlatform() diff --git a/Uniton Connect/Runtime/Data/Jettons/JettonBalanceData.cs b/Uniton Connect/Runtime/Data/Jettons/JettonBalanceData.cs new file mode 100644 index 0000000..364c9e3 --- /dev/null +++ b/Uniton Connect/Runtime/Data/Jettons/JettonBalanceData.cs @@ -0,0 +1,16 @@ +using Newtonsoft.Json; + +namespace UnitonConnect.Core.Data +{ + public sealed class JettonBalanceData + { + [JsonProperty("balance")] + public string BalanceInNano { get; set; } + + [JsonProperty("wallet_address")] + public WalletAccountData Account { get; set; } + + [JsonProperty("jetton")] + public JettonData Configuration { get; set; } + } +} \ No newline at end of file diff --git a/Uniton Connect/Runtime/Data/Jettons/JettonData.cs b/Uniton Connect/Runtime/Data/Jettons/JettonData.cs new file mode 100644 index 0000000..532e4bf --- /dev/null +++ b/Uniton Connect/Runtime/Data/Jettons/JettonData.cs @@ -0,0 +1,25 @@ +using Newtonsoft.Json; + +namespace UnitonConnect.Core.Data +{ + public sealed class JettonData + { + [JsonProperty("address")] + public string MasterAddress { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("symbol")] + public string TokenSymbol { get; set; } + + [JsonProperty("decimals")] + public decimal DecimalsInNano { get; set; } + + [JsonProperty("image")] + public string IconUrl { get; set; } + + [JsonProperty("verification")] + public string VerificationStatus { get; set; } + } +} \ No newline at end of file diff --git a/Uniton Connect/Runtime/Data/Transaction/Jettons/JettonTransactionData.cs b/Uniton Connect/Runtime/Data/Transaction/Jettons/JettonTransactionData.cs new file mode 100644 index 0000000..ad5d45d --- /dev/null +++ b/Uniton Connect/Runtime/Data/Transaction/Jettons/JettonTransactionData.cs @@ -0,0 +1,52 @@ +using Newtonsoft.Json; + +namespace UnitonConnect.Core.Data +{ + public sealed class JettonTransactionData + { + [JsonProperty("query_id")] + public string QueryId { get; set; } + + [JsonProperty("source")] + public string SenderAddress { get; set; } + + [JsonProperty("destination")] + public string RecipientAddress { get; set; } + + [JsonProperty("amount")] + public string AmountInNano { get; set; } + + [JsonProperty("source_wallet")] + public string SourceWallet { get; set; } + + [JsonProperty("jetton_master")] + public string JettonMasterAddress { get; set; } + + [JsonProperty("transaction_hash")] + public string TransactionHash { get; set; } + + [JsonProperty("transaction_lt")] + public string TransactionLt { get; set; } + + [JsonProperty("transaction_now")] + public long TransactionNow { get; set; } + + [JsonProperty("transaction_aborted")] + public bool IsAborted { get; set; } + + [JsonProperty("response_destination")] + public string ResponseDestination { get; set; } + + [JsonProperty("custom_payload")] + public object CustomPayload { get; set; } + + [JsonProperty("forward_ton_amount")] + public string ForwardTonAmount { get; set; } + + [JsonProperty("forward_payload")] + public object ForwardPayload { get; set; } + + [JsonProperty("trace_id")] + public string TraceId { get; set; } + } +} \ No newline at end of file diff --git a/Uniton Connect/Runtime/Data/Transaction/Jettons/JettonTransactionsListData.cs b/Uniton Connect/Runtime/Data/Transaction/Jettons/JettonTransactionsListData.cs new file mode 100644 index 0000000..8b7fc93 --- /dev/null +++ b/Uniton Connect/Runtime/Data/Transaction/Jettons/JettonTransactionsListData.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace UnitonConnect.Core.Data +{ + public sealed class JettonTransactionsListData + { + [JsonProperty("jetton_transfers")] + public List Transfers { get; set; } + + [JsonProperty("address_book")] + public Dictionary AddressBook { get; set; } + } +} \ No newline at end of file diff --git a/Uniton Connect/Runtime/Data/Wallets/Jetton/SO/JettonConfig.cs b/Uniton Connect/Runtime/Data/Wallets/Jetton/SO/JettonConfig.cs index 80878a4..f261a40 100644 --- a/Uniton Connect/Runtime/Data/Wallets/Jetton/SO/JettonConfig.cs +++ b/Uniton Connect/Runtime/Data/Wallets/Jetton/SO/JettonConfig.cs @@ -9,6 +9,7 @@ namespace UnitonConnect.Editor.Data public sealed class JettonConfig : ScriptableObject { [field: SerializeField, Space] public JettonTypes Type { get; private set; } + [field: SerializeField, Space] public string Name { get; private set; } [field: SerializeField, Space] public string MasterAddress { get; private set; } [field: SerializeField, Space] public string IconUrl { get; private set; } diff --git a/Uniton Connect/Runtime/Utils/Wallet/WalletConnectUtils.cs b/Uniton Connect/Runtime/Utils/Wallet/WalletConnectUtils.cs index 55f0f83..8602c93 100644 --- a/Uniton Connect/Runtime/Utils/Wallet/WalletConnectUtils.cs +++ b/Uniton Connect/Runtime/Utils/Wallet/WalletConnectUtils.cs @@ -9,7 +9,7 @@ public static class WalletConnectUtils internal static bool IsAddressesMatch(string recipientAddress) { - var authorizedWalletAddress = _unitonConnect.Wallet.ToString(); + var authorizedWalletAddress = _unitonConnect.Wallet.ToHex(); if (authorizedWalletAddress == recipientAddress) { diff --git a/Uniton Connect/Samples/Scripts/TestWalletInterfaceAdapter.cs b/Uniton Connect/Samples/Scripts/TestWalletInterfaceAdapter.cs index 2550650..d733cd1 100644 --- a/Uniton Connect/Samples/Scripts/TestWalletInterfaceAdapter.cs +++ b/Uniton Connect/Samples/Scripts/TestWalletInterfaceAdapter.cs @@ -3,7 +3,6 @@ using TMPro; using UnitonConnect.Core.Data; using UnitonConnect.Core.Utils; -using UnitonConnect.Core.Utils.View; using UnitonConnect.Runtime.Data; using UnitonConnect.DeFi; @@ -25,9 +24,11 @@ public sealed class TestWalletInterfaceAdapter : MonoBehaviour private UnitonConnectSDK _unitonSDK; private UserAssets.NFT _nftModule => _unitonSDK.Assets.Nft; + private UserAssets.Jetton _jettonModule => _unitonSDK.Assets.Jettons; public UnitonConnectSDK UnitonSDK => _unitonSDK; public UserAssets.NFT NftStorage => _nftModule; + public UserAssets.Jetton JettonModule => _jettonModule; private void Awake() { @@ -104,7 +105,7 @@ private void WalletConnectionFinished(NewWalletConfig wallet) $"full account address: {userAddress}, \n" + $"Public Key: {wallet.PublicKey}"; - var shortWalletAddress = WalletVisualUtils.ProcessWalletAddress(userAddress, 6); + var shortWalletAddress = _unitonSDK.Wallet.ToShort(8); _debugMessage.text = successConnectMessage; _shortWalletAddress.text = shortWalletAddress; diff --git a/package.json b/package.json index d520b0a..d1e441a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.veittech.uniton.connect", - "version": "0.2.9", + "version": "0.3.0", "displayName": "Uniton Connect", "description": "A library for working with the Ton Connect ecosystem in Unity. Authorization through TON wallets via deeplink or QR code to your dApps, making transactions and more.", "unity": "2020.3",