Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmpa committed Aug 12, 2024
2 parents 7a9be4f + b5c0884 commit 5da1a37
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Assets/Scripts/Updater/UpdateChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,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.1.0"; // Current version of your game
public string currentVersion = "1.1.1"; // Current version of your game

private const string GITHUB_RELEASES_URL = "https://github.com/";
private static string URL = "";
Expand Down
7 changes: 5 additions & 2 deletions Assets/Scripts/Wallet/AccountManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,12 @@ public void SignAndSendTransaction(string chain, byte[] script, TransferRequest?
{
case PlatformKind.Phantasma:
{
StartCoroutine(phantasmaApi.SignAndSendTransactionWithPayload(PhantasmaKeys.FromWIF(CurrentWif), customKeys, Settings.nexusName, script, chain, phaGasPrice, phaGasLimit, payload, PoW, (hashText) =>
StartCoroutine(phantasmaApi.SignAndSendTransactionWithPayload(PhantasmaKeys.FromWIF(CurrentWif), customKeys, Settings.nexusName, script, chain, phaGasPrice, phaGasLimit, payload, PoW, (hashText, encodedTx) =>
{

if (Settings.devMode)
{
Log.Write($"SignAndSendTransactionWithPayload(): Encoded tx: {encodedTx}");
}
if ( !string.IsNullOrEmpty(hashText) )
{
try
Expand Down
68 changes: 64 additions & 4 deletions Assets/Scripts/Wallet/DescriptionUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public static IEnumerator GetDescription(byte[] script, bool devMode, Action<str
DisasmMethodCall? prevCall = null;
foreach (var call in disasm)
{
if (CheckIfCallShouldBeIgnored(call))
if (CheckIfCallShouldBeIgnored(call) && !devMode)
{
continue;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ public static IEnumerator GetDescription(byte[] script, bool devMode, Action<str
var sb = new StringBuilder();
foreach (var entry in disasm)
{
if (CheckIfCallShouldBeIgnored(entry))
if (CheckIfCallShouldBeIgnored(entry) && !devMode)
{
continue;
}
Expand All @@ -224,6 +224,50 @@ public static IEnumerator GetDescription(byte[] script, bool devMode, Action<str

switch (GetCallFullName(entry))
{
case "gas.AllowGas":
{
string from, to;
if (entry.Arguments[0].Type.ToString() == "Bytes")
{
from = Phantasma.Core.Domain.Serialization.Unserialize(GetByteArrayArg(entry, 0), typeof(Phantasma.Core.Cryptography.Address)).ToString();
}
else
{
from = GetStringArg(entry, 0);
}
if (entry.Arguments[1].Type.ToString() == "Bytes")
{
to = Phantasma.Core.Domain.Serialization.Unserialize(GetByteArrayArg(entry, 1), typeof(Phantasma.Core.Cryptography.Address)).ToString();
}
else
{
to = GetStringArg(entry, 1);
}
var gasPrice = GetNumberArg(entry, 2);
var gasLimit = GetNumberArg(entry, 3);

sb.AppendLine($"\u2605 AllowGas price: {gasPrice} limit: {gasLimit} from {from} to {to}.");

break;
}

case "gas.SpendGas":
{
string address;
if (entry.Arguments[0].Type.ToString() == "Bytes")
{
address = Phantasma.Core.Domain.Serialization.Unserialize(GetByteArrayArg(entry, 0), typeof(Phantasma.Core.Cryptography.Address)).ToString();
}
else
{
address = GetStringArg(entry, 0);
}

sb.AppendLine($"\u2605 SpendGas address {address}.");

break;
}

case "Runtime.TransferToken":
{
var src = GetStringArg(entry, 0);
Expand Down Expand Up @@ -262,8 +306,23 @@ public static IEnumerator GetDescription(byte[] script, bool devMode, Action<str
}
case "Runtime.TransferTokens":
{
var src = GetStringArg(entry, 0);
var dst = GetStringArg(entry, 1);
string src, dst;
if (entry.Arguments[0].Type.ToString() == "Bytes")
{
src = Phantasma.Core.Domain.Serialization.Unserialize(GetByteArrayArg(entry, 0), typeof(Phantasma.Core.Cryptography.Address)).ToString();
}
else
{
src = GetStringArg(entry, 0);
}
if (entry.Arguments[1].Type.ToString() == "Bytes")
{
dst = Phantasma.Core.Domain.Serialization.Unserialize(GetByteArrayArg(entry, 1), typeof(Phantasma.Core.Cryptography.Address)).ToString();
}
else
{
dst = GetStringArg(entry, 1);
}
var symbol = GetStringArg(entry, 2);
var amount = GetNumberArg(entry, 3);

Expand Down Expand Up @@ -595,6 +654,7 @@ public static IEnumerator GetDescription(byte[] script, bool devMode, Action<str
break;
}

sb.AppendLine();
}

if (sb.Length > 0)
Expand Down
6 changes: 3 additions & 3 deletions Assets/Scripts/Wallet/PhantasmaAPI.Unity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -872,12 +872,12 @@ public IEnumerator GetAllAddressTransactions(string addressText, Action<AccountT
}

//Allows to broadcast a signed operation on the network, but it&apos;s required to build it manually.
public IEnumerator SendRawTransaction(string txData, Action<string> callback, Action<EPHANTASMA_SDK_ERROR_TYPE, string> errorHandlingCallback = null)
public IEnumerator SendRawTransaction(string txData, Action<string, string> callback, Action<EPHANTASMA_SDK_ERROR_TYPE, string> errorHandlingCallback = null)
{
yield return WebClient.RPCRequest(Host, "sendRawTransaction", WebClient.NoTimeout, 0, errorHandlingCallback, (node) =>
{
var result = node.Value;
callback(result);
callback(result, txData);
}, txData);
}

Expand Down Expand Up @@ -963,7 +963,7 @@ public IEnumerator GetPlatforms(Action<Platform[]> callback, Action<EPHANTASMA_S
});
}

public IEnumerator SignAndSendTransactionWithPayload(PhantasmaKeys keys, IKeyPair otherKeys, string nexus, byte[] script, string chain, BigInteger gasPrice, BigInteger gasLimit, byte[] payload, ProofOfWork PoW, Action<string> callback, Action<EPHANTASMA_SDK_ERROR_TYPE, string> errorHandlingCallback = null, Func<byte[], byte[], byte[], byte[]> customSignFunction = null)
public IEnumerator SignAndSendTransactionWithPayload(PhantasmaKeys keys, IKeyPair otherKeys, string nexus, byte[] script, string chain, BigInteger gasPrice, BigInteger gasLimit, byte[] payload, ProofOfWork PoW, Action<string, string> callback, Action<EPHANTASMA_SDK_ERROR_TYPE, string> errorHandlingCallback = null, Func<byte[], byte[], byte[], byte[]> customSignFunction = null)
{
Log.Write("Sending transaction...");

Expand Down
63 changes: 63 additions & 0 deletions Assets/Scripts/Wallet/WalletGUIFolder/WalletGUI.Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,69 @@ private void DoSettingsScreen()
});
curY += Units(3);

DoButton(true, new Rect(posX, curY, Units(16), Units(2)), "Decode tx", () =>
{
ShowModal("Encoded transaction", "Enter transaction in Base16 encoding", ModalState.Input, 2, -1, ModalConfirmCancel, 4, (result, input) =>
{
if (result == PromptResult.Success)
{
var tx = Phantasma.Core.Domain.Transaction.Unserialize(Base16.Decode(input, false));

if (tx == null)
{
ShowModal("Tx description", $"Cannot parse transaction '{input}'",
ModalState.Message, 0, 0, ModalOkCopy, 0, (_, input) => { });
}
else
{
try
{
WalletGUI.Instance.StartCoroutine(DescriptionUtils.GetDescription(tx.Script, true, (description, error) =>
{
string message;
if (description == null)
{
message = "Error during script parsing.\nDetails: " + error;
}
else
{
message = description;
}

string signatures = "";
if (tx.HasSignatures)
{
foreach (var s in tx.Signatures)
{
signatures += s.ToString() + "\n";
}
}

message = "Nexus name: " + tx.NexusName + "\n" +
"Chain name: " + tx.ChainName + "\n" +
"Expiration: " + tx.Expiration + "\n" +
"Payload: " + System.Text.Encoding.UTF8.GetString(tx.Payload) + "\n" +
"Hash: " + tx.Hash + "\n" +
"Signatures count: " + (tx.HasSignatures ? tx.Signatures.Length : "0") + "\n" +
"Signatures: " + signatures + "\n" +
"\n" +
message;

ShowModal("Tx 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", () =>
{
Expand Down
2 changes: 1 addition & 1 deletion ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ PlayerSettings:
loadStoreDebugModeEnabled: 0
visionOSBundleVersion: 1.0
tvOSBundleVersion: 1.0
bundleVersion: 1.1.0
bundleVersion: 1.1.1
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
Expand Down
4 changes: 2 additions & 2 deletions ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 2022.3.34f1
m_EditorVersionWithRevision: 2022.3.34f1 (4886f5360533)
m_EditorVersion: 2022.3.37f1
m_EditorVersionWithRevision: 2022.3.37f1 (340ba89e4c23)

0 comments on commit 5da1a37

Please sign in to comment.