protected override void SignTransaction(string platform, SignatureKind kind, string chain, byte[] script, byte[] payload, int id, Action <Hash, string> callback) { var accountManager = AccountManager.Instance; var targetPlatform = RequestPlatform(platform); if (targetPlatform == PlatformKind.None) { callback(Hash.Null, "Unsupported platform: " + platform); return; } var state = AccountManager.Instance.CurrentState; if (state == null) { callback(Hash.Null, "not logged in"); return; } var nexus = AccountManager.Instance.Settings.nexusName; var account = AccountManager.Instance.CurrentAccount; WalletGUI.Instance.CallOnUIThread(() => { try { WalletGUI.Instance.StartCoroutine(DescriptionUtils.GetDescription(script, (description, error) => { if (description == null) { WalletGUI.Instance.MessageBox(MessageKind.Error, "Error during description parsing.\nContact the developers.\nDetails: " + error); callback(Hash.Null, "description parsing error"); return; } WalletGUI.Instance.Prompt("Allow dapp to send a transaction on your behalf?\n" + description, (success) => { if (success) { WalletGUI.Instance.SendTransaction(description, script, payload, chain, ProofOfWork.None, (hash) => { AppFocus.Instance.EndFocus(); if (hash != Hash.Null) { callback(hash, null); } else { callback(Hash.Null, "something bad happend while sending"); } }); } else { AppFocus.Instance.EndFocus(); callback(Hash.Null, "user rejected"); } }); })); } catch (Exception e) { WalletGUI.Instance.MessageBox(MessageKind.Error, "Error during description parsing.\nContact the developers.\nDetails: " + e.Message); callback(Hash.Null, "description parsing error"); return; } }); }
protected override void SignTransaction(string nexus, string chain, byte[] script, byte[] payload, int id, Action <Hash, string> callback) { var state = AccountManager.Instance.CurrentState; if (state == null) { callback(Hash.Null, "not logged in"); return; } var expectedNexus = AccountManager.Instance.Settings.nexusName; if (nexus != expectedNexus) { callback(Hash.Null, "nexus mismatch, expected: " + expectedNexus); return; } var account = AccountManager.Instance.CurrentAccount; if (account.platforms.HasFlag(PlatformKind.Phantasma)) { WalletGUI.Instance.CallOnUIThread(() => { string description; try { description = DescriptionUtils.GetDescription(script); } catch (Exception e) { WalletGUI.Instance.MessageBox(MessageKind.Error, "Error during description parsing.\nContact the developers.\nDetails: " + e.Message); callback(Hash.Null, "description parsing error"); return; } WalletGUI.Instance.Prompt("Allow dapp to send a transaction on your behalf?\n" + description, (success) => { if (success) { // TODO show description of transfer :^) WalletGUI.Instance.SendTransaction(description, script, payload, chain, (hash) => { if (hash != Hash.Null) { callback(hash, null); } else { callback(Hash.Null, "something bad happend while sending"); } }); } else { callback(Hash.Null, "user rejected"); } }); }); } else { callback(Hash.Null, "current account does not support Phantasma platform"); } }