-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into add/plugins/rest-server
- Loading branch information
Showing
43 changed files
with
575 additions
and
443 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (C) 2015-2024 The Neo Project. | ||
// | ||
// UInt160Extensions.cs file belongs to the neo project and is free | ||
// software distributed under the MIT software license, see the | ||
// accompanying file LICENSE in the main directory of the | ||
// repository or http://www.opensource.org/licenses/mit-license.php | ||
// for more details. | ||
// | ||
// Redistribution and use in source and binary forms with or without | ||
// modifications are permitted. | ||
|
||
using Neo.VM; | ||
|
||
namespace Neo.Extensions | ||
{ | ||
public static class UInt160Extensions | ||
{ | ||
/// <summary> | ||
/// Generates the script for calling a contract dynamically. | ||
/// </summary> | ||
/// <param name="scriptHash">The hash of the contract to be called.</param> | ||
/// <param name="method">The method to be called in the contract.</param> | ||
/// <param name="args">The arguments for calling the contract.</param> | ||
/// <returns>The generated script.</returns> | ||
public static byte[] MakeScript(this UInt160 scriptHash, string method, params object[] args) | ||
{ | ||
using ScriptBuilder sb = new(); | ||
sb.EmitDynamicCall(scriptHash, method, args); | ||
return sb.ToArray(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (C) 2015-2024 The Neo Project. | ||
// | ||
// EvaluationStackExtensions.cs file belongs to the neo project and is free | ||
// software distributed under the MIT software license, see the | ||
// accompanying file LICENSE in the main directory of the | ||
// repository or http://www.opensource.org/licenses/mit-license.php | ||
// for more details. | ||
// | ||
// Redistribution and use in source and binary forms with or without | ||
// modifications are permitted. | ||
|
||
using Neo.Json; | ||
using Neo.VM; | ||
using System; | ||
|
||
namespace Neo.Extensions | ||
{ | ||
public static class EvaluationStackExtensions | ||
{ | ||
/// <summary> | ||
/// Converts the <see cref="EvaluationStack"/> to a JSON object. | ||
/// </summary> | ||
/// <param name="stack">The <see cref="EvaluationStack"/> to convert.</param> | ||
/// <param name="maxSize">The maximum size in bytes of the result.</param> | ||
/// <returns>The <see cref="EvaluationStack"/> represented by a JSON object.</returns> | ||
public static JArray ToJson(this EvaluationStack stack, int maxSize = int.MaxValue) | ||
{ | ||
if (maxSize <= 0) throw new ArgumentOutOfRangeException(nameof(maxSize)); | ||
maxSize -= 2/*[]*/+ Math.Max(0, (stack.Count - 1))/*,*/; | ||
JArray result = []; | ||
foreach (var item in stack) | ||
result.Add(item.ToJson(null, ref maxSize)); | ||
if (maxSize < 0) throw new InvalidOperationException("Max size reached."); | ||
return result; | ||
} | ||
} | ||
} |
Oops, something went wrong.