Skip to content

Conversation

@Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Oct 30, 2025

Summary

  • add feature-based template generation combining Basic/NEP17/NEP11/Ownable/Oracle
  • streamline CLI/docs/scripts to advertise new feature flags
  • update artifacts and tests to cover combinations and ensure generated projects compile

@shargon shargon mentioned this pull request Oct 30, 2025
Comment on lines +17 to +24
contract_name="$1"
shift

template="Basic"
features=()

if [[ $# -gt 0 ]]; then
template="$1"
Copy link
Member

Choose a reason for hiding this comment

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

The arguments should be sanitized because it goes to the command line

# Sanitize: allow only alphanumeric, underscore, and dash
if [[ ! "$contract_name" =~ ^[a-zA-Z0-9_-]+$ ]]; then
  echo "Error: Invalid contract name. Only letters, numbers, '_' and '-' are allowed."
  exit 1
fi

UInt160 previous = GetOwner();
Storage.Put(new[] { Prefix_Owner }, newOwner);
Storage.Put(Storage.CurrentContext, OwnerKey, newOwner);
Copy link
Member

Choose a reason for hiding this comment

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

We can use Local, it's cheaper (no context required), safer and easier

public void TestGenerateFeaturesNep11Ownable()
{
string projectName = "FeatureNep11Ownable";
_templateManager.GenerateContractFromFeatures(new[] { "NEP11", "Ownable" }, projectName, _testOutputPath);
Copy link
Member

Choose a reason for hiding this comment

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

Should be good if we compile the template results, otherwise it will be hard to detect if we make something wrong, only users who use it will know it

Copy link

Copilot AI commented Oct 30, 2025

@shargon I've opened a new pull request, #1418, to work on those changes. Once the pull request is ready, I'll request review from you.

@Wi1l-B0t
Copy link
Contributor

Wi1l-B0t commented Nov 1, 2025

Can this be like 'dotnet new console', even without extra scripts?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants