-
Notifications
You must be signed in to change notification settings - Fork 105
[Framwork Add]Add examples #931
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
Merged
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
21f7419
add examples and ease contract implementation
Jim8y 2c0da4e
optimize the code
Jim8y 6f13c68
Merge branch 'master' into add-examples
Jim8y c75cff8
Merge branch 'master' into add-examples
Jim8y e1af5f8
Merge branch 'master' into add-examples
Jim8y 40ea594
Merge branch 'add-examples' of github.com:Jim8y/neo-devpack-dotnet in…
Jim8y 1b9d962
Merge branch 'master' into add-examples
Jim8y 24555e2
Delete src/Neo.SmartContract.Template/templates/neocontract/Contract1.cs
shargon 09f2785
Merge branch 'master' into add-examples
Jim8y 27e671a
Merge branch 'add-examples' of github.com:Jim8y/neo-devpack-dotnet in…
Jim8y b6b6e94
Merge branch 'master' into add-examples
Jim8y b6d6c1e
fix coverage issue
Jim8y 725a783
Merge branch 'master' into add-examples
Jim8y d61e4ff
Update tests/Neo.SmartContract.Framework.TestContracts/Contract_Suppo…
shargon 28c829d
remove conflict
Jim8y 5954bee
Merge branch 'master' into add-examples
Jim8y c0f5006
Merge branch 'master' into add-examples
Jim8y 8fe9173
Merge branch 'master' into add-examples
Jim8y 7a4d438
Merge branch 'master' into add-examples
Jim8y 38aad3c
Merge branch 'add-examples'
Jim8y be6cdbf
Merge branch 'master' into add-examples
Jim8y f0c1d6e
Update tests/Neo.SmartContract.Template.UnitTests/templates/neocontra…
shargon 79f01a3
Update src/Neo.SmartContract.Framework/Interfaces/INEP11Payment.cs
Jim8y 528d263
fix url
Jim8y 6dc7e12
Merge branch 'add-examples' of github.com:Jim8y/neo-devpack-dotnet in…
Jim8y 39d28f9
fix name
Jim8y c3fd99b
remove extra file
Jim8y 862a2a0
revert
Jim8y 0aaa6dc
Merge branch 'master' into add-examples
Jim8y c1db8c8
Merge branch 'master' into add-examples
shargon ae15f04
Update TransferContract.cs
shargon a0fd5c1
Some fixes & clean code
shargon 933d6fa
clean
shargon 330ff6a
Clean and comment
shargon 4a7ba49
clean
shargon af5f866
Remove todo
shargon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
|
||
<PropertyGroup> | ||
<Copyright>2024 The SharpNeo Examples Project</Copyright> | ||
<VersionPrefix>3.6.2</VersionPrefix> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<Authors>The SharpNeo Project</Authors> | ||
<PackageIcon>neo.png</PackageIcon> | ||
<PackageProjectUrl>https://github.com/neo-project/neo-devpack-dotnet/examples</PackageProjectUrl> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<PackageReadmeFile>README.md</PackageReadmeFile> | ||
<RepositoryType>git</RepositoryType> | ||
<RepositoryUrl>https://github.com/neo-project/neo-devpack-dotnet.git</RepositoryUrl> | ||
<IncludeSymbols>true</IncludeSymbols> | ||
<SymbolPackageFormat>snupkg</SymbolPackageFormat> | ||
<Company>The Neo N3 Contract Examples Project</Company> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<Nullable>enable</Nullable> | ||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Neo.SmartContract.Framework\Neo.SmartContract.Framework.csproj" /> | ||
</ItemGroup> | ||
|
||
<!-- <Target Name="PostBuild" AfterTargets="PostBuildEvent">--> | ||
<!-- <Exec Command="dotnet nccs "$(MSBuildProjectFile)"" />--> | ||
<!-- </Target>--> | ||
</Project> |
39 changes: 39 additions & 0 deletions
39
examples/Example.SmartContract.ContractCall/ContractCall.cs
This file contains hidden or 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,39 @@ | ||
// Copyright (C) 2015-2024 The Neo Project. | ||
// | ||
// ContractCall.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.SmartContract.Framework; | ||
using Neo.SmartContract.Framework.Attributes; | ||
using Neo.SmartContract.Framework.Services; | ||
using System.ComponentModel; | ||
using System.Numerics; | ||
|
||
namespace ContractCall; | ||
|
||
[DisplayName("SampleContractCall")] | ||
[ContractAuthor("core-dev")] | ||
[ContractEmail("[email protected]")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think its example. should be fine. |
||
[ContractVersion("0.0.1")] | ||
[ContractDescription("A sample contract to demonstrate how to call a contract")] | ||
[ContractSourceCode("https://github.com/neo-project/neo-devpack-dotnet/tree/master/examples/")] | ||
public class SampleContractCall : SmartContract | ||
{ | ||
[Hash160("0x13a83e059c2eedd5157b766d3357bc826810905e")] | ||
private static readonly UInt160 DummyTarget; | ||
|
||
public static void onNEP17Payment(UInt160 from, BigInteger amount, BigInteger data) | ||
{ | ||
if (!data.Equals(123)) return; | ||
UInt160 @this = Runtime.ExecutingScriptHash; | ||
UInt160 tokenHash = Runtime.CallingScriptHash; | ||
BigInteger balanceOf = (BigInteger)Contract.Call(tokenHash, "balanceOf", CallFlags.All, @this); | ||
Contract.Call(DummyTarget, "dummyMethod", CallFlags.All, @this, tokenHash, balanceOf); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
examples/Example.SmartContract.ContractCall/Example.SmartContract.ContractCall.csproj
This file contains hidden or 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,7 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<RootNamespace>ContractCall</RootNamespace> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains hidden or 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,40 @@ | ||
// Copyright (C) 2015-2024 The Neo Project. | ||
// | ||
// Event.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.SmartContract.Framework; | ||
using Neo.SmartContract.Framework.Attributes; | ||
using System; | ||
using System.ComponentModel; | ||
using System.Numerics; | ||
|
||
namespace Event; | ||
|
||
[DisplayName("SampleEvent")] | ||
[ContractAuthor("code-dev", "[email protected]")] | ||
[ContractDescription("A sample contract that demonstrates how to use Events")] | ||
[ContractVersion("0.0.1")] | ||
[ContractSourceCode("https://github.com/neo-project/neo-devpack-dotnet/tree/master/examples/")] | ||
[ContractPermission(Permission.WildCard, Method.WildCard)] | ||
public class SampleEvent : SmartContract | ||
{ | ||
[DisplayName("new_event_name")] | ||
public static event Action<byte[], string, BigInteger> event_name; | ||
|
||
public static event Action<byte[], BigInteger> event2; | ||
|
||
public static bool Main() | ||
{ | ||
byte[] ba = new byte[] { 0x01, 0x02, 0x03 }; | ||
event_name(ba, "oi", 10); // will Example.SmartContract.Runtime.Notify: 'new_event_name', '\x01\x02\x03', 'oi', 10 | ||
event2(ba, 50); // will Example.SmartContract.Runtime.Notify: 'event2', '\x01\x02\x03', '\x32' | ||
return false; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
examples/Example.SmartContract.Event/Example.SmartContract.Event.csproj
This file contains hidden or 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,7 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<RootNamespace>Event</RootNamespace> | ||
</PropertyGroup> | ||
|
||
</Project> |
7 changes: 7 additions & 0 deletions
7
examples/Example.SmartContract.Exception/Example.SmartContract.Exception.csproj
This file contains hidden or 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,7 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<RootNamespace>Exception</RootNamespace> | ||
</PropertyGroup> | ||
|
||
</Project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This works with the current compiler?
Uh oh!
There was an error while loading. Please reload this page.
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.
Not compiled, just syntax. Compile the example everytime is meaningless.
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.
I mean, in
public Compilation GetCompilation(string csproj)
we don't read the Directory.Build.props, maybe we should do it, (not related to this pr)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.
emmmm, to be honest, i never thought we will run into this situation