Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 158 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results

[Dd]ebug/
[Rr]elease/
x64/
[Bb]in/
[Oo]bj/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.svclog
*.scc

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml
*.pubxml
*.azurePubxml

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
packages/
## TODO: If the tool you use requires repositories.config, also uncomment the next line
!packages/repositories.config

# Windows Azure Build Output
csx/
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
![Ss]tyle[Cc]op.targets
~$*
*~
*.dbmdl
*.[Pp]ublish.xml

*.publishsettings

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf

# =========================
# Windows detritus
# =========================

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Mac desktop service store files
.DS_Store

_NCrunch*

# =================================
# Common IntelliJ Platform excludes
# =================================

# User specific
**/.idea/**/workspace.xml
**/.idea/**/tasks.xml
**/.idea/shelf/*
**/.idea/dictionaries
**/.idea/httpRequests/

# Sensitive or high-churn files
**/.idea/**/dataSources/
**/.idea/**/dataSources.ids
**/.idea/**/dataSources.xml
**/.idea/**/dataSources.local.xml
**/.idea/**/sqlDataSources.xml
**/.idea/**/dynamic.xml

# Rider
# Rider auto-generates .iml files, and contentModel.xml
**/.idea/**/*.iml
**/.idea/**/contentModel.xml
**/.idea/**/modules.xml
23 changes: 23 additions & 0 deletions basics/hello-world/src/AElf.Contracts.HelloWorld.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>AElf.Contracts.HelloWorld</RootNamespace>
<IsContract>true</IsContract>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AElf.Sdk.CSharp" Version="1.3.0" />
<PackageReference Include="AElf.Tools" Version="1.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>

34 changes: 34 additions & 0 deletions basics/hello-world/src/HelloWorld.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using AElf.Sdk.CSharp;
using Google.Protobuf.WellKnownTypes;

namespace AElf.Contracts.HelloWorld
{
public partial class HelloWorld : HelloWorldContainer.HelloWorldBase
{
// Method to update the message value.
public override Empty Update(StringValue input)
{
// Set the message value in the contract state
State.Message.Value = input.Value;
// Trigger an event to notify listeners about the message update
Context.Fire(new UpdatedMessage
{
Value = input.Value
});
// Return an empty response
return new Empty();
}

// Method to read the current message value
public override StringValue Read(Empty input)
{
// Create a new StringValue object to hold the message value
StringValue value = new StringValue();
// Set the value from the contract state
value.Value = State.Message.Value;
// Return the StringValue object
return value;
}
}

}
9 changes: 9 additions & 0 deletions basics/hello-world/src/HelloWorldState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using AElf.Sdk.CSharp.State;

namespace AElf.Contracts.HelloWorld
{
public partial class HelloWorldState : ContractState
{
public StringState Message { get; set; }
}
}
53 changes: 53 additions & 0 deletions basics/hello-world/src/Protobuf/base/acs1.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* AElf Standards ACS1(Transaction Fee Standard)
*
* Used to manage the transaction fee.
*/
syntax = "proto3";

package acs1;

import public "aelf/options.proto";
import public "google/protobuf/empty.proto";
import public "google/protobuf/wrappers.proto";
import "aelf/core.proto";
import "Protobuf/message/authority_info.proto";

option (aelf.identity) = "acs1";
option csharp_namespace = "AElf.Standards.ACS1";

service MethodFeeProviderContract {

// Set the method fees for the specified method. Note that this will override all fees of the method.
rpc SetMethodFee (MethodFees) returns (google.protobuf.Empty) {
}

// Change the method fee controller, the default is parliament and default organization.
rpc ChangeMethodFeeController (AuthorityInfo) returns (google.protobuf.Empty) {
}

// Query method fee information by method name.
rpc GetMethodFee (google.protobuf.StringValue) returns (MethodFees) {
option (aelf.is_view) = true;
}

// Query the method fee controller.
rpc GetMethodFeeController (google.protobuf.Empty) returns (AuthorityInfo) {
option (aelf.is_view) = true;
}
}

message MethodFees {
// The name of the method to be charged.
string method_name = 1;
// List of fees to be charged.
repeated MethodFee fees = 2;
bool is_size_fee_free = 3;// Optional based on the implementation of SetMethodFee method.
}

message MethodFee {
// The token symbol of the method fee.
string symbol = 1;
// The amount of fees to be charged.
int64 basic_fee = 2;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Need to fix class name.
Fixed in the next commit.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
syntax = "proto3";

import "aelf/core.proto";
import "aelf/options.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";

option csharp_namespace = "AElf.Contracts.HelloWorld";

service HelloWorld {
option (aelf.csharp_state) = "AElf.Contracts.HelloWorld.HelloWorldState";

// Actions
rpc Update (google.protobuf.StringValue) returns (google.protobuf.Empty) {
}

// Views
rpc Read (google.protobuf.Empty) returns (google.protobuf.StringValue) {
option (aelf.is_view) = true;
}
}

message UpdatedMessage {
option (aelf.is_event) = true;
string value = 1;
}
10 changes: 10 additions & 0 deletions basics/hello-world/src/Protobuf/message/authority_info.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
syntax = "proto3";

import "aelf/core.proto";

option csharp_namespace = "AElf.Contracts.HelloWorld";

message AuthorityInfo {
aelf.Address contract_address = 1;
aelf.Address owner_address = 2;
}
33 changes: 33 additions & 0 deletions basics/hello-world/test/AElf.Contracts.HelloWorld.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>AElf.Contracts.HelloWorld</RootNamespace>
</PropertyGroup>

<PropertyGroup>
<NoWarn>0436</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AElf.Testing.TestBase" Version="1.0.0" />
<PackageReference Include="AElf.EconomicSystem" Version="1.3.0" />
<PackageReference Include="AElf.GovernmentSystem" Version="1.3.0" />
<PackageReference Include="coverlet.msbuild" Version="2.5.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.console" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="AElf.ContractTestKit" Version="1.3.0" />
<PackageReference Include="AElf.Tools" Version="1.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\src\AElf.Contracts.HelloWorld.csproj" />
</ItemGroup>

</Project>
Loading