public Task <RpcInvokeResult> InvokeAsync(Neo.VM.Script script) { try { if (disposedValue) { return(Task.FromException <RpcInvokeResult>(new ObjectDisposedException(nameof(OfflineNode)))); } using ApplicationEngine engine = script.Invoke(neoSystem.Settings, neoSystem.StoreView); return(Task.FromResult(new RpcInvokeResult() { State = engine.State, Exception = engine.FaultException?.GetBaseException().Message ?? string.Empty, GasConsumed = engine.GasConsumed, Stack = engine.ResultStack.ToArray(), Script = string.Empty, Tx = string.Empty })); } catch (Exception ex) { return(Task.FromException <RpcInvokeResult>(ex)); } }
public static ApplicationEngine Invoke(this Neo.VM.Script script, ProtocolSettings settings, DataCache snapshot) => ApplicationEngine.Run( script: script, snapshot: snapshot, settings: settings);
public static ApplicationEngine Invoke(this Neo.VM.Script script, ProtocolSettings settings, DataCache snapshot, IVerifiable?container = null) => ApplicationEngine.Run( script: script, snapshot: snapshot, settings: settings, container: container);
public async Task <UInt256> ExecuteAsync(Wallet wallet, UInt160 accountHash, WitnessScope witnessScope, Neo.VM.Script script, decimal additionalGas = 0) { if (disposedValue) { throw new ObjectDisposedException(nameof(OfflineNode)); } var signer = new Signer() { Account = accountHash, Scopes = witnessScope }; var tx = wallet.MakeTransaction(neoSystem.StoreView, script, accountHash, new[] { signer }); if (additionalGas > 0.0m) { tx.SystemFee += (long)additionalGas.ToBigInteger(NativeContract.GAS.Decimals); } var context = new ContractParametersContext(neoSystem.StoreView, tx, ProtocolSettings.Network); var account = wallet.GetAccount(accountHash) ?? throw new Exception(); if (account.IsMultiSigContract()) { var multiSigWallets = chain.GetMultiSigWallets(neoSystem.Settings, accountHash); for (int i = 0; i < multiSigWallets.Count; i++) { multiSigWallets[i].Sign(context); if (context.Completed) { break; } } } else { wallet.Sign(context); } if (!context.Completed) { throw new Exception(); } tx.Witnesses = context.GetWitnesses(); return(await SubmitTransactionAsync(tx).ConfigureAwait(false)); }