Skip to content

Conversation

@Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Oct 23, 2025

Summary

  • expose missing Policy governance setters/getters and role designation helpers to smart contracts
  • add managed transaction attribute wrappers so contracts can inspect native attributes
  • update testing harness artifacts and unit tests to cover the new governance APIs

Testing

  • dotnet test tests/Neo.SmartContract.Framework.UnitTests/Neo.SmartContract.Framework.UnitTests.csproj --filter NativeTest

@Jim8y Jim8y changed the base branch from master to dev October 23, 2025 14:25
@Jim8y Jim8y requested a review from shargon October 23, 2025 14:30
@shargon shargon requested a review from ajara87 October 23, 2025 20:00

try
{
if (path != null && File.Exists(path))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method are duplicated, and it's better to use !string.IsNullOrEmpty

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's possible to simplify the method.

    private static string? TryGetSourceSnippet(string fileName, int startZeroBasedLineNumber, int endZeroBasedLineNumber)
    {
        if (string.IsNullOrWhiteSpace(fileName)) return null;
        var path = Path.IsPathRooted(fileName) ? fileName : Path.Combine(Environment.CurrentDirectory, fileName);

        try
        {
            if (!File.Exists(path))
                return null;

             string[] lines = File.ReadAllLines(path);
             int start = Math.Max(0, startZeroBasedLineNumber);
             int end = Math.Min(lines.Length - 1, Math.Max(startZeroBasedLineNumber, endZeroBasedLineNumber));
             if (start > end) return null;
             return string.Join(Environment.NewLine, lines[start..(end + 1)]).Trim();
        }
        catch { }
        return null;
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer needed, this pr now focus on only one task

{
static class OptimizedScriptBuilder
{
private static readonly IReadOnlyDictionary<OpCode, (OpCode LongOp, int SizeDelta)> ShortToLongJumpMap =
Copy link
Contributor

@Wi1l-B0t Wi1l-B0t Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a part of 'Expose policy governance APIs' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed, this pr focus on only exposing poliocy govergance API now

@Jim8y
Copy link
Contributor Author

Jim8y commented Oct 24, 2025

Rebased on the latest dev, resolved conflicts, and trimmed the branch so it now only exposes the policy/role governance APIs. Added native Policy setters/getters, RoleManagement.DesignateAsRole, TransactionAttribute wrappers, and refreshed the unit tests. NativeTest suite passes (dotnet test ... --filter NativeTest).

@Jim8y Jim8y changed the title Expose policy governance APIs and strengthen analyzer UX Expose policy governance APIs Oct 24, 2025
@erikzhang
Copy link
Member

Why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants