-
Notifications
You must be signed in to change notification settings - Fork 106
Add composable contract templates #1416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
| contract_name="$1" | ||
| shift | ||
|
|
||
| template="Basic" | ||
| features=() | ||
|
|
||
| if [[ $# -gt 0 ]]; then | ||
| template="$1" |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
tests/Neo.Compiler.CSharp.UnitTests/UnitTest_TemplateManager.cs
Outdated
Show resolved
Hide resolved
| public void TestGenerateFeaturesNep11Ownable() | ||
| { | ||
| string projectName = "FeatureNep11Ownable"; | ||
| _templateManager.GenerateContractFromFeatures(new[] { "NEP11", "Ownable" }, projectName, _testOutputPath); |
There was a problem hiding this comment.
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
|
Can this be like 'dotnet new console', even without extra scripts? |
Summary