diff --git a/Assets/Phantasma.SDK/WebClient.cs b/Assets/Phantasma.SDK/WebClient.cs index cda2e41e..05637ed7 100644 --- a/Assets/Phantasma.SDK/WebClient.cs +++ b/Assets/Phantasma.SDK/WebClient.cs @@ -104,11 +104,27 @@ public static IEnumerator RPCRequest(string url, string method, int timeout, int try { var stringResponse = request.downloadHandler.text; - if (method.ToUpper() == "GETNFT" && parameters.Length > 0 && ((string)parameters[0]).ToUpper() == "GAME") + + try + { + root = JSONReader.ReadFromString(stringResponse); + } + catch { - // TODO remove later: Temporary HACK for binary data inside JSON - var cutFrom = stringResponse.IndexOf(",{\"Key\" : \"OriginalMetadata\""); - stringResponse = stringResponse.Substring(0, cutFrom) + "]}"; + if (method.ToUpper() == "GETNFT" && parameters.Length > 0 && ((string)parameters[0]).ToUpper() == "GAME") + { + Log.Write($"RPC response [{requestNumber}]\nurl: {url}\nFailed to parse GAME NFT, trying workaround. JSON: " + stringResponse, Log.Level.Logic); + // TODO remove later: Temporary HACK for binary data inside JSON + var cutFrom = stringResponse.IndexOf(",{\"Key\":\"OriginalMetadata\"", StringComparison.InvariantCultureIgnoreCase); + if (cutFrom > 0) + { + stringResponse = stringResponse.Substring(0, cutFrom) + "]}"; + } + } + else + { + throw; + } } root = JSONReader.ReadFromString(stringResponse); diff --git a/Assets/Phantasma/Phantasma.Business/src/VM/Utils/DisasmUtils.cs b/Assets/Phantasma/Phantasma.Business/src/VM/Utils/DisasmUtils.cs index bc06a07d..c2adf4c1 100644 --- a/Assets/Phantasma/Phantasma.Business/src/VM/Utils/DisasmUtils.cs +++ b/Assets/Phantasma/Phantasma.Business/src/VM/Utils/DisasmUtils.cs @@ -12,15 +12,19 @@ public struct DisasmMethodCall public VMObject[] Arguments; - public override string ToString() + public string ToString(bool useNewlines) { var sb = new StringBuilder(); sb.Append($"{ContractName}.{MethodName}("); - for (int i=0; i 0) { sb.Append(','); + if(useNewlines) + { + sb.Append('\n'); + } } var arg = Arguments[i]; @@ -29,6 +33,11 @@ public override string ToString() sb.Append(")"); return sb.ToString(); } + + public override string ToString() + { + return ToString(true); + } } public static class DisasmUtils diff --git a/Assets/Phantasma/Phantasma.Core/src/Domain/WalletLink.cs b/Assets/Phantasma/Phantasma.Core/src/Domain/WalletLink.cs index d76cf1e2..01cc8dc4 100644 --- a/Assets/Phantasma/Phantasma.Core/src/Domain/WalletLink.cs +++ b/Assets/Phantasma/Phantasma.Core/src/Domain/WalletLink.cs @@ -4,6 +4,7 @@ using LunarLabs.Parser; using Phantasma.Core.Cryptography; using Phantasma.Core.Numerics; +using UnityEngine; namespace Phantasma.Core.Domain { @@ -115,7 +116,7 @@ public Connection(string token, int version) } } - private Random rnd = new Random(); + private System.Random rnd = new System.Random(); private Dictionary _connections = new Dictionary(); @@ -481,7 +482,7 @@ private void HandleSignTx(string[] args, Connection connection, int id, Action= 2 ? args[2].ToLower() : "phantasma"; var transaction = Phantasma.Core.Domain.Transaction.Unserialize(data); - + if (transaction.NexusName != this.Nexus) + { + answer = APIUtils.FromAPIResult(new Error() { message = $"signData: Expected nexus {this.Nexus}, instead got {transaction.NexusName}. Wrong network selected, please check Dapp or Wallet settings" }); + callback(id, answer, false); + _isPendingRequest = false; + return; + } + SignTransactionSignature(transaction, platform, signatureKind, (signature, txError) => { if (signature != null) { @@ -848,6 +860,7 @@ public void Execute(string cmd, Action callback) { answer = APIUtils.FromAPIResult(new Error() { message = "Invalid or missing API token" }); callback(id, answer, false); + _isPendingRequest = false; return; } diff --git a/Assets/Resources/Tokens/RAA.png b/Assets/Resources/Tokens/RAA.png new file mode 100644 index 00000000..debd84b3 Binary files /dev/null and b/Assets/Resources/Tokens/RAA.png differ diff --git a/Assets/Resources/Tokens/RAA.png.meta b/Assets/Resources/Tokens/RAA.png.meta new file mode 100644 index 00000000..96669241 --- /dev/null +++ b/Assets/Resources/Tokens/RAA.png.meta @@ -0,0 +1,140 @@ +fileFormatVersion: 2 +guid: f1e16df8263a5254985763f53baf0c9c +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: iPhone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/pgl_logo.png b/Assets/Resources/pgl_logo.png index 32153579..ae4ac371 100644 Binary files a/Assets/Resources/pgl_logo.png and b/Assets/Resources/pgl_logo.png differ diff --git a/Assets/Scripts/Updater/UpdateChecker.cs b/Assets/Scripts/Updater/UpdateChecker.cs index c5c90d20..ab4cf4d8 100644 --- a/Assets/Scripts/Updater/UpdateChecker.cs +++ b/Assets/Scripts/Updater/UpdateChecker.cs @@ -1,10 +1,6 @@ -using System; using System.Collections; -using System.Collections.Generic; -using System.Security.Policy; using System.Text.RegularExpressions; using Poltergeist; -using TMPro; using UnityEngine; using UnityEngine.Networking; @@ -12,7 +8,7 @@ public class UpdateChecker : MonoBehaviour { public string githubOwner = "phantasma-io"; // Your GitHub username public string githubRepo = "PoltergeistLite"; // Your repository name - public string currentVersion = "1.0.5"; // Current version of your game + public string currentVersion = "1.1.0"; // Current version of your game private const string GITHUB_RELEASES_URL = "https://github.com/"; private static string URL = ""; diff --git a/Assets/Scripts/Wallet/DescriptionUtils.cs b/Assets/Scripts/Wallet/DescriptionUtils.cs index 3a9d1ee9..5d4dc794 100644 --- a/Assets/Scripts/Wallet/DescriptionUtils.cs +++ b/Assets/Scripts/Wallet/DescriptionUtils.cs @@ -109,12 +109,9 @@ private static string ShortenTokenId(string tokenId) return tokenId.Substring(0, 5) + "..." + tokenId.Substring(tokenId.Length - 5); } - public static IEnumerator GetDescription(byte[] script, Action callback) + public static IEnumerator GetDescription(byte[] script, bool devMode, Action callback) { - foreach (var entry in methodTable.Keys) - { - Debug.Log("disam method: " + entry); - } + Debug.Log("disam methods: " + string.Join(", ", methodTable.Keys)); if(knownContracts == null) { @@ -217,7 +214,13 @@ public static IEnumerator GetDescription(byte[] script, Action c } // Put it to log so that developer can easily check what PG is receiving. - Log.Write("GetDescription(): Contract's description: " + entry.ToString()); + var unprocessedMethodCall = "Unprocessed method call: " + entry.ToString(); + Log.Write(unprocessedMethodCall); + if(devMode) + { + sb.AppendLine(unprocessedMethodCall); + sb.AppendLine(); + } switch (GetCallFullName(entry)) { @@ -371,6 +374,12 @@ public static IEnumerator GetDescription(byte[] script, Action c if (typeAuction == 0) { sb.AppendLine($"\u2605 List {tokenSymbol} NFT #{ShortenTokenId(nftNumber)} for a Fixed Auction with a price of {price} {priceSymbol}."); + if (devMode) + { + sb.AppendLine($"Start date: {startDate} [unix seconds: {startDate.Value}]."); + sb.AppendLine($"End date: {untilDate} [unix seconds: {untilDate.Value}]."); + sb.AppendLine($"Extension period: {extensionPeriod}."); + } break; } else if (typeAuction == 1) diff --git a/Assets/Scripts/Wallet/Settings.cs b/Assets/Scripts/Wallet/Settings.cs index 20f85ec1..1ceb12d4 100644 --- a/Assets/Scripts/Wallet/Settings.cs +++ b/Assets/Scripts/Wallet/Settings.cs @@ -102,6 +102,8 @@ public class Settings public const string PasswordModeTag = "password.mode"; + public const string DevModeTag = "developer.mode"; + public string phantasmaRPCURL; public string phantasmaExplorer; public string phantasmaNftExplorer; @@ -121,6 +123,7 @@ public class Settings public MnemonicPhraseLength mnemonicPhraseLength; public MnemonicPhraseVerificationMode mnemonicPhraseVerificationMode; public PasswordMode passwordMode; + public bool devMode; public override string ToString() { @@ -141,7 +144,8 @@ public override string ToString() "NFT sort direction: " + this.nftSortDirection + "\n" + "Mnemonic phrase length: " + this.mnemonicPhraseLength + "\n" + "Mnemonic phrase verification mode: " + this.mnemonicPhraseVerificationMode + "\n" + - "Password mode: " + this.passwordMode; + "Password mode: " + this.passwordMode + "\n" + + "Developer mode: " + this.devMode; } public void LoadLogSettings() @@ -227,6 +231,8 @@ public void Load() this.passwordMode = PasswordMode.Ask_Always; } + this.devMode = PlayerPrefs.GetInt(DevModeTag, 0) != 0; + Log.Write("Settings: Load: " + ToString()); } @@ -357,6 +363,7 @@ public void Save() PlayerPrefs.SetString(MnemonicPhraseLengthTag, this.mnemonicPhraseLength.ToString()); PlayerPrefs.SetString(MnemonicPhraseVerificationModeTag, this.mnemonicPhraseVerificationMode.ToString()); PlayerPrefs.SetString(PasswordModeTag, this.passwordMode.ToString()); + PlayerPrefs.SetInt(DevModeTag, this.devMode ? 1 : 0); PlayerPrefs.Save(); Log.Write("Settings: Save: " + ToString()); diff --git a/Assets/Scripts/Wallet/WalletGUIFolder/WalletGUI.ModalPrompts.cs b/Assets/Scripts/Wallet/WalletGUIFolder/WalletGUI.ModalPrompts.cs index 7f22099a..830a4aba 100644 --- a/Assets/Scripts/Wallet/WalletGUIFolder/WalletGUI.ModalPrompts.cs +++ b/Assets/Scripts/Wallet/WalletGUIFolder/WalletGUI.ModalPrompts.cs @@ -11,7 +11,10 @@ public partial class WalletGUI : MonoBehaviour #region MODAL PROMPTS private string[] ModalNone = new string[] { }; private string[] ModalOk = new string[] { "Ok" }; + // ModalOkCopy automatically processes "Copy" button press private string[] ModalOkCopy = new string[] { "Ok", "Copy to clipboard" }; + // ModalOkCopy_NoAutoCopy requires "Copy" button press callback to be implemented + private string[] ModalOkCopy_NoAutoCopy = new string[] { "Ok", "Copy to clipboard" }; private string[] ModalOkView = new string[] { "Ok", "View" }; private string[] ModalConfirmCancel = new string[] { "Confirm", "Cancel" }; private string[] ModalSendCancel = new string[] { "Send", "Cancel" }; diff --git a/Assets/Scripts/Wallet/WalletGUIFolder/WalletGUI.Settings.cs b/Assets/Scripts/Wallet/WalletGUIFolder/WalletGUI.Settings.cs index a85cf596..c7ab56bb 100644 --- a/Assets/Scripts/Wallet/WalletGUIFolder/WalletGUI.Settings.cs +++ b/Assets/Scripts/Wallet/WalletGUIFolder/WalletGUI.Settings.cs @@ -263,6 +263,10 @@ private void DoSettingsScreen() curY += Units(3); + settings.devMode = GUI.Toggle(new Rect(posX, curY, Units(2), Units(2)), settings.devMode, ""); + GUI.Label(new Rect(posX + Units(2), curY, Units(9), labelHeight), "Developer mode"); + curY += Units(3); + DoButton(true, new Rect(posX, curY, Units(16), Units(2)), "Phantasma staking info", () => { byte[] scriptMasterClaimDate; @@ -385,6 +389,49 @@ private void DoSettingsScreen() }); curY += Units(3); + DoButton(true, new Rect(posX, curY, Units(16), Units(2)), "Get tx description from script", () => + { + ShowModal("Transaction script", "Enter transaction script in Base16 encoding", ModalState.Input, 2, -1, ModalConfirmCancel, 4, (result, input) => + { + if (result == PromptResult.Success) + { + var script = Base16.Decode(input, false); + if (script == null) + { + ShowModal("Script description", $"Cannot parse script '{input}'", + ModalState.Message, 0, 0, ModalOkCopy, 0, (_, input) => { }); + } + else + { + try + { + WalletGUI.Instance.StartCoroutine(DescriptionUtils.GetDescription(script, true, (description, error) => + { + string message; + if (description == null) + { + message = "Error during script parsing.\nDetails: " + error; + } + else + { + message = description; + } + + ShowModal("Script description", message, + ModalState.Message, 0, 0, ModalOkCopy, 0, (_, input) => { }); + })); + } + catch (Exception e) + { + WalletGUI.Instance.MessageBox(MessageKind.Error, "Error during script parsing.\nDetails: " + e.Message); + return; + } + } + } + }); + }); + curY += Units(3); + curY += Units(1); DoButton(true, new Rect(posX, curY, Units(16), Units(2)), "Clear cache", () => { diff --git a/Assets/Scripts/Wallet/WalletGUIFolder/WalletGUI.cs b/Assets/Scripts/Wallet/WalletGUIFolder/WalletGUI.cs index 1eb495db..e9461584 100644 --- a/Assets/Scripts/Wallet/WalletGUIFolder/WalletGUI.cs +++ b/Assets/Scripts/Wallet/WalletGUIFolder/WalletGUI.cs @@ -1289,7 +1289,13 @@ private void DoWalletsScreen() } else { - MessageBox(MessageKind.Error, "Invalid input format."); + MessageBox(MessageKind.Error, "Seed phrase or private key that you entered is incorrect." + +"\nPlease check your spelling carefully, and try again." + +"\n" + +"\nEnsure that:" + +"\n* If copy / pasting - That you've selected the entire set of characters." + +"\n* If copy / pasting - That the characters have been copied into your clipboard correctly." + +"\n* If typing it -Take care to check that you're using English keyboard layout and the correct case for each letter."); } } }); @@ -2134,16 +2140,12 @@ private void DoBalanceScreen() return; } - int curY = Units(12); - - decimal feeBalance = state.GetAvailableAmount("KCAL"); - if (state.balances == null) { DrawCenteredText($"No assets found in this {accountManager.CurrentPlatform} account."); return; } - + var balanceCount = DoScrollArea(ref balanceScroll, startY, endY, VerticalLayout ? Units(7) : Units(6), state.balances.Where(x => x.Total >= 0.001m), DoBalanceEntry); @@ -2694,6 +2696,7 @@ private void DoNftEntry(string entryId, int index, int curY, Rect rect) { var accountManager = AccountManager.Instance; + string imageUrl = ""; string nftName; string nftDescription; string infusionDescription = ""; @@ -2704,13 +2707,7 @@ private void DoNftEntry(string entryId, int index, int curY, Rect rect) if (!String.IsNullOrEmpty(item.NameEnglish)) { - var image = NftImages.GetImage(item.Img); - - if (!String.IsNullOrEmpty(image.Url)) - { - var textureDisplayedHeight = VerticalLayout ? Units(3) : Units(3) - 8; - GUI.DrawTexture(new Rect(Units(2), VerticalLayout ? curY + Units(1) : curY + 12, (float)textureDisplayedHeight * ((float)image.Texture.width / (float)image.Texture.height), textureDisplayedHeight), image.Texture); - } + imageUrl = item.Img; } string rarity; @@ -2762,58 +2759,18 @@ private void DoNftEntry(string entryId, int index, int curY, Rect rect) if (!String.IsNullOrEmpty(item.name_english)) { - var image = NftImages.GetImage(item.img_url); - - if (!String.IsNullOrEmpty(image.Url)) - { - var textureDisplayedHeight = VerticalLayout ? Units(3) : Units(3) - 8; - GUI.DrawTexture(new Rect(Units(2), VerticalLayout ? curY + Units(1) : curY + 12, (float)textureDisplayedHeight * ((float)image.Texture.width / (float)image.Texture.height), textureDisplayedHeight), image.Texture); - } + imageUrl = item.img_url; } nftName = item.name_english; - nftDescription = item.mint == 0 ? "" : (VerticalLayout ? "#" : "Mint #") + item.mint + " " + (VerticalLayout ? item.timestampDT.ToString("dd.MM.yy") : item.timestampDT.ToString("dd.MM.yyyy HH:mm:ss")) + (VerticalLayout ? " " : " / " + item.description_english); + nftDescription = item.mint == 0 ? "" : (VerticalLayout ? "#" : "Mint #") + item.mint + " " + (VerticalLayout ? item.timestampDT.ToString("dd.MM.yy") : item.timestampDT.ToString("dd.MM.yyyy HH:mm:ss")) + (VerticalLayout ? " " : " / ") + item.description_english; } else { var item = accountManager.GetNft(entryId); - var image = NftImages.GetImage(item.GetPropertyValue("ImageURL")); - - if (!String.IsNullOrEmpty(image.Url)) - { - var textureDisplayedWidth = VerticalLayout ? Units(7) - Units(3) : Units(6) - Units(3) + 8; - var textureDisplayedHeight = VerticalLayout ? Units(3) : Units(3) - 8; - - if (image.Url.StartsWith("ipfs-audio://")) - GUI.DrawTexture(new Rect(Units(2), VerticalLayout ? curY + Units(1) : curY + 12, (float)textureDisplayedHeight * ((float)ResourceManager.Instance.NftAudioPlaceholder.width / (float)ResourceManager.Instance.NftAudioPlaceholder.height), textureDisplayedHeight), ResourceManager.Instance.NftAudioPlaceholder); - else if (image.Url.StartsWith("ipfs-video://")) - GUI.DrawTexture(new Rect(Units(2), VerticalLayout ? curY + Units(1) : curY + 12, (float)textureDisplayedHeight * ((float)ResourceManager.Instance.NftVideoPlaceholder.width / (float)ResourceManager.Instance.NftVideoPlaceholder.height), textureDisplayedHeight), ResourceManager.Instance.NftVideoPlaceholder); - else if (image.Texture == null) - GUI.DrawTexture(new Rect(Units(2), VerticalLayout ? curY + Units(1) : curY + 12, (float)textureDisplayedHeight * ((float)ResourceManager.Instance.NftPhotoPlaceholder.width / (float)ResourceManager.Instance.NftPhotoPlaceholder.height), textureDisplayedHeight), ResourceManager.Instance.NftPhotoPlaceholder); - else - { - var width = (float)textureDisplayedHeight * ((float)image.Texture.width / (float)image.Texture.height); - var height = (float)textureDisplayedHeight; - if(width > textureDisplayedWidth) - { - var correction = textureDisplayedWidth / width; - width = textureDisplayedWidth; - height = height * correction; - } - - // Following code helps to center images in the image area. - var x = Units(2); - if (width < textureDisplayedWidth) - x += (int)((textureDisplayedWidth - width) / 2); - var y = VerticalLayout ? curY + Units(1) : curY + 12; - if (height < textureDisplayedHeight) - y += (int)((textureDisplayedHeight - height) / 2); - - GUI.DrawTexture(new Rect(x, y, width, height), image.Texture); - } - } + imageUrl = item.GetPropertyValue("ImageURL"); DateTime nftDate = new DateTime(); if (item.parsedRom != null) @@ -2823,24 +2780,15 @@ private void DoNftEntry(string entryId, int index, int curY, Rect rect) nftName = item.GetPropertyValue("Name"); nftDescription = item.GetPropertyValue("Description"); - if(VerticalLayout) - { - if (nftDescription.Length > 15) - nftDescription = nftDescription.Substring(0, 12) + "..."; - } - else - { - if (nftDescription.Length > 60) - nftDescription = nftDescription.Substring(0, 57) + "..."; - } nftDescription = item.mint == 0 ? "" : (VerticalLayout ? "#" : "Mint #") + item.mint + " " + (nftDate == DateTime.MinValue ? "" : (VerticalLayout ? nftDate.ToString("dd.MM.yy") : nftDate.ToString("dd.MM.yyyy HH:mm:ss"))) + (String.IsNullOrEmpty(nftDescription) ? "" : ((VerticalLayout ? " " : " / ") + nftDescription)); - infusionDescription = VerticalLayout ? "" : "Infusions: "; - if (item.infusion != null) + if (item.infusion != null && item.infusion.Length > 0) { + infusionDescription = VerticalLayout ? "" : "Infusions: "; + var fungibleInfusions = new Dictionary(); var nftInfusions = new Dictionary(); for (var i = 0; i < item.infusion.Length; i++) @@ -2879,9 +2827,47 @@ private void DoNftEntry(string entryId, int index, int curY, Rect rect) } } } - else + } + + // Fixing CROWNs image url + imageUrl = imageUrl.Replace("phantasma.io", "phantasma.info"); + + if (!String.IsNullOrEmpty(imageUrl)) + { + var image = NftImages.GetImage(imageUrl); + + if (!String.IsNullOrEmpty(image.Url)) { - infusionDescription += "None"; + var textureDisplayedWidth = VerticalLayout ? Units(7) - Units(3) : Units(6) - Units(3) + 8; + var textureDisplayedHeight = VerticalLayout ? Units(3) : Units(3) - 8; + + if (image.Url.StartsWith("ipfs-audio://")) + GUI.DrawTexture(new Rect(Units(2), VerticalLayout ? curY + Units(1) : curY + 12, (float)textureDisplayedHeight * ((float)ResourceManager.Instance.NftAudioPlaceholder.width / (float)ResourceManager.Instance.NftAudioPlaceholder.height), textureDisplayedHeight), ResourceManager.Instance.NftAudioPlaceholder); + else if (image.Url.StartsWith("ipfs-video://")) + GUI.DrawTexture(new Rect(Units(2), VerticalLayout ? curY + Units(1) : curY + 12, (float)textureDisplayedHeight * ((float)ResourceManager.Instance.NftVideoPlaceholder.width / (float)ResourceManager.Instance.NftVideoPlaceholder.height), textureDisplayedHeight), ResourceManager.Instance.NftVideoPlaceholder); + else if (image.Texture == null) + GUI.DrawTexture(new Rect(Units(2), VerticalLayout ? curY + Units(1) : curY + 12, (float)textureDisplayedHeight * ((float)ResourceManager.Instance.NftPhotoPlaceholder.width / (float)ResourceManager.Instance.NftPhotoPlaceholder.height), textureDisplayedHeight), ResourceManager.Instance.NftPhotoPlaceholder); + else + { + var width = (float)textureDisplayedHeight * ((float)image.Texture.width / (float)image.Texture.height); + var height = (float)textureDisplayedHeight; + if (width > textureDisplayedWidth) + { + var correction = textureDisplayedWidth / width; + width = textureDisplayedWidth; + height = height * correction; + } + + // Following code helps to center images in the image area. + var x = Units(2); + if (width < textureDisplayedWidth) + x += (int)((textureDisplayedWidth - width) / 2); + var y = VerticalLayout ? curY + Units(1) : curY + 12; + if (height < textureDisplayedHeight) + y += (int)((textureDisplayedHeight - height) / 2); + + GUI.DrawTexture(new Rect(x, y, width, height), image.Texture); + } } } @@ -2890,42 +2876,49 @@ private void DoNftEntry(string entryId, int index, int curY, Rect rect) if (VerticalLayout && nftName.Length > 18) nftName = nftName.Substring(0, 15) + "..."; - else if (nftName.Length > 50) - nftName = nftName.Substring(0, 47) + "..."; + else if (nftName.Length > 103) + nftName = nftName.Substring(0, 100) + "..."; - if (transferSymbol == "TTRS" || transferSymbol == "GAME") + float nameYPosition = curY; + float descYPosition = curY; + if (!String.IsNullOrEmpty(infusionDescription)) { - // Old drawing mode for TTRS - - GUI.Label(new Rect(VerticalLayout ? Units(7) : Units(6) + 8, VerticalLayout ? curY + 4 : curY, rect.width - Units(6), Units(2) + 4), nftName); - - if (!String.IsNullOrEmpty(nftDescription)) - { - var style = GUI.skin.label; - style.fontSize -= VerticalLayout ? 2 : 4; - GUI.Label(new Rect(VerticalLayout ? Units(7) : Units(6) + 8, VerticalLayout ? curY + Units(2) + 4 : curY + Units(1) + 8, rect.width - Units(6), Units(2)), nftDescription); - style.fontSize += VerticalLayout ? 2 : 4; - } + nameYPosition += VerticalLayout ? - 2 : - 8; + descYPosition += VerticalLayout ? Units(1) + 6 : Units(1) - 2; } else { - GUI.Label(new Rect(VerticalLayout ? Units(7) : Units(6) + 8, VerticalLayout ? curY - 2 : curY - 8, rect.width - Units(6), Units(2) + 4), nftName); + nameYPosition += VerticalLayout ? 4 : 0; + descYPosition += VerticalLayout ? Units(2) + 4 : Units(1) + 8; + } + + GUI.Label(new Rect(VerticalLayout ? Units(7) : Units(6) + 8, nameYPosition, rect.width - Units(6), Units(2) + 4), nftName); - if (!String.IsNullOrEmpty(nftDescription)) + if (!String.IsNullOrEmpty(nftDescription)) + { + if (VerticalLayout) { - var style = GUI.skin.label; - style.fontSize -= VerticalLayout ? 2 : 4; - GUI.Label(new Rect(VerticalLayout ? Units(7) : Units(6) + 8, VerticalLayout ? curY + Units(1) + 6 : curY + Units(1) - 2, rect.width - Units(6), Units(2)), nftDescription); - style.fontSize += VerticalLayout ? 2 : 4; + if (nftDescription.Length > 25) + nftDescription = nftDescription.Substring(0, 22) + "..."; } - - if (!String.IsNullOrEmpty(infusionDescription)) + else { - var style = GUI.skin.label; - style.fontSize -= VerticalLayout ? 2 : 4; - GUI.Label(new Rect(VerticalLayout ? Units(7) : Units(6) + 8, VerticalLayout ? curY + Units(2) + 10 : curY + Units(2), rect.width - Units(6), Units(2)), infusionDescription); - style.fontSize += VerticalLayout ? 2 : 4; + if (nftDescription.Length > 100) + nftDescription = nftDescription.Substring(0, 97) + "..."; } + + var style = GUI.skin.label; + style.fontSize -= VerticalLayout ? 2 : 4; + GUI.Label(new Rect(VerticalLayout ? Units(7) : Units(6) + 8, descYPosition, rect.width - Units(6), Units(2)), nftDescription); + style.fontSize += VerticalLayout ? 2 : 4; + } + + if (!String.IsNullOrEmpty(infusionDescription)) + { + var style = GUI.skin.label; + style.fontSize -= VerticalLayout ? 2 : 4; + GUI.Label(new Rect(VerticalLayout ? Units(7) : Units(6) + 8, VerticalLayout ? curY + Units(2) + 10 : curY + Units(2), rect.width - Units(6), Units(2)), infusionDescription); + style.fontSize += VerticalLayout ? 2 : 4; } Rect btnRectToggle; @@ -3116,6 +3109,37 @@ private void DoAccountScreen() DoBottomMenu(); } + private List StringSplit(string input, int splitBy) + { + List result = new(); + var parts = (int)Math.Ceiling((decimal)input.Length / splitBy); + for (var i = 0; i < parts; i++) + { + if (i == parts - 1) + { + result.Add(input.Substring(i * splitBy, input.Length - i * splitBy)); + } + else + { + result.Add(input.Substring(i * splitBy, splitBy)); + } + } + + return result; + } + + private string KeyPrepareForMessageBox(string key) + { + if (VerticalLayout) + { + return string.Join('\n', StringSplit(key, 24).Select(x => string.Join(' ', StringSplit(x, 8)))); + } + else + { + return string.Join(' ', StringSplit(key, 8)); + } + } + private void DoAccountManagementMenu(int btnOffset) { var accountManager = AccountManager.Instance; @@ -3151,13 +3175,11 @@ private void DoAccountManagementMenu(int btnOffset) { case 0: { - ShowModal("Private key export", $"Copy private key in Wallet Import Format (WIF) or in HEX format to the clipboard" + - "\n\nWIF format is supported by most of Phantasma blockchain wallets." + - "\nWIF format example (52 symbols):" + - "\nKz9xQgW1U49x8d6yijwLaBgN9x5zEdZaqkjLaS88ZnagcmBjckNE" + - "\n\nHEX format example (64 symbols):" + - "\n5794a280d6d69c676855d6ffb63b40b20fde3c79d557cd058c95cd608a933fc3" + - "\n\nNEVER SHARE YOUR PRIVATE KEY WITH ANYONE, INCLUDING TEAM, SUPPORT OR COMMUNITY ADMINS", + ShowModal("Private key export", $"Show private key in WIF format (recommended) or in HEX format." + + "\n\nNEVER SHARE YOUR PRIVATE KEY with ANYONE, including TEAM, SUPPORT or COMMUNITY ADMINS." + + "\n\nFollowing screen will reveal your private key. It provides full access to your wallet and funds." + + " Press 'WIF format' or 'HEX format' buttons to expose private key in corresponding format." + + "\n\nMake sure NO ONE IS LOOKING AT YOUR SCREEN.", ModalState.Message, 0, 0, ModalHexWifCancel, 0, (result, input) => { if (result == PromptResult.Custom_1) @@ -3167,8 +3189,18 @@ private void DoAccountManagementMenu(int btnOffset) if (auth == PromptResult.Success) { var keys = EthereumKey.FromWIF(accountManager.CurrentWif); - GUIUtility.systemCopyBuffer = Poltergeist.PhantasmaLegacy.Ethereum.Hex.HexConvertors.Extensions.HexByteConvertorExtensions.ToHex(keys.PrivateKey); - MessageBox(MessageKind.Default, "Private key (HEX format) copied to the clipboard."); + var hexKey = PhantasmaLegacy.Ethereum.Hex.HexConvertors.Extensions.HexByteConvertorExtensions.ToHex(keys.PrivateKey); + + ShowModal("Your private key (HEX)", + KeyPrepareForMessageBox(hexKey), + ModalState.Message, 0, 0, ModalOkCopy_NoAutoCopy, 1, (result1, _) => + { + if (result1 != PromptResult.Success) // Means "Copy to clipboard" button was pressed + { + GUIUtility.systemCopyBuffer = hexKey; + MessageBox(MessageKind.Default, "Your private key was copied to the clipboard."); + } + }); } }, ignoreStoredPassword: true); @@ -3179,12 +3211,17 @@ private void DoAccountManagementMenu(int btnOffset) { if (auth == PromptResult.Success) { - GUIUtility.systemCopyBuffer = accountManager.CurrentWif; - MessageBox(MessageKind.Default, "Private key (WIF format) copied to the clipboard."); + ShowModal("Your private key (WIF)", KeyPrepareForMessageBox(accountManager.CurrentWif), ModalState.Message, 0, 0, ModalOkCopy_NoAutoCopy, 1, (result1, _) => + { + if (result1 != PromptResult.Success) // Means "Copy to clipboard" button was pressed + { + GUIUtility.systemCopyBuffer = accountManager.CurrentWif; + MessageBox(MessageKind.Default, "Your private key was copied to the clipboard."); + } + }); } }, ignoreStoredPassword: true); - } }); break; diff --git a/Assets/Scripts/Wallet/WalletLink/WalletConnector.cs b/Assets/Scripts/Wallet/WalletLink/WalletConnector.cs index 47dfaf5a..b1e20c88 100644 --- a/Assets/Scripts/Wallet/WalletLink/WalletConnector.cs +++ b/Assets/Scripts/Wallet/WalletLink/WalletConnector.cs @@ -429,13 +429,17 @@ protected override void SignTransaction(string platform, SignatureKind kind, str { try { - WalletGUI.Instance.StartCoroutine(DescriptionUtils.GetDescription(script, (description, error) => { + WalletGUI.Instance.StartCoroutine(DescriptionUtils.GetDescription(script, accountManager.Settings.devMode, (description, error) => { if (description == null) { Log.Write("Error during description parsing.\nDetails: " + error); //description = "Could not decode transaction contents. (Not an error)"; } + else + { + Log.Write("Script description: " + description); + } WalletGUI.Instance.Prompt("Allow dapp to send a transaction on your behalf?\n" + description, (success) => { diff --git a/ProjectSettings/AudioManager.asset b/ProjectSettings/AudioManager.asset index 4f31e744..556b1085 100644 --- a/ProjectSettings/AudioManager.asset +++ b/ProjectSettings/AudioManager.asset @@ -3,6 +3,7 @@ --- !u!11 &1 AudioManager: m_ObjectHideFlags: 0 + serializedVersion: 2 m_Volume: 1 Rolloff Scale: 1 Doppler Factor: 1 @@ -11,7 +12,9 @@ AudioManager: m_DSPBufferSize: 1024 m_VirtualVoiceCount: 512 m_RealVoiceCount: 32 + m_EnableOutputSuspension: 1 m_SpatializerPlugin: m_AmbisonicDecoderPlugin: - m_DisableAudio: 0 + m_DisableAudio: 1 m_VirtualizeEffects: 1 + m_RequestedDSPBufferSize: 1024 diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 5f2b511b..d3ab8b6a 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -139,7 +139,7 @@ PlayerSettings: loadStoreDebugModeEnabled: 0 visionOSBundleVersion: 1.0 tvOSBundleVersion: 1.0 - bundleVersion: 1.0.5 + bundleVersion: 1.1.0 preloadedAssets: [] metroInputSource: 0 wsaTransparentSwapchain: 0 @@ -852,7 +852,7 @@ PlayerSettings: gcWBarrierValidation: 0 apiCompatibilityLevelPerPlatform: Android: 3 - Standalone: 3 + Standalone: 6 iPhone: 3 m_RenderingPath: 1 m_MobileRenderingPath: 1 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 9f9a5338..9b596327 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2022.3.26f1 -m_EditorVersionWithRevision: 2022.3.26f1 (ec6cd8118806) +m_EditorVersion: 2022.3.34f1 +m_EditorVersionWithRevision: 2022.3.34f1 (4886f5360533)