-
Notifications
You must be signed in to change notification settings - Fork 102
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
[Framwork Add]Add examples #931
Changes from all commits
21f7419
2c0da4e
6f13c68
c75cff8
e1af5f8
40ea594
1b9d962
24555e2
09f2785
27e671a
b6b6e94
b6d6c1e
725a783
d61e4ff
28c829d
5954bee
c0f5006
8fe9173
7a4d438
38aad3c
be6cdbf
f0c1d6e
79f01a3
528d263
6dc7e12
39d28f9
c3fd99b
862a2a0
0aaa6dc
c1db8c8
ae15f04
a0fd5c1
933d6fa
330ff6a
4a7ba49
af5f866
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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> |
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; | ||
Check warning on line 29 in examples/Example.SmartContract.ContractCall/ContractCall.cs GitHub Actions / Test
|
||
|
||
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); | ||
} | ||
} |
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> |
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; | ||
Check warning on line 29 in examples/Example.SmartContract.Event/Event.cs GitHub Actions / Test
|
||
|
||
public static event Action<byte[], BigInteger> event2; | ||
Check warning on line 31 in examples/Example.SmartContract.Event/Event.cs GitHub Actions / Test
|
||
|
||
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; | ||
} | ||
} |
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> |
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> |
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?
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