Skip to content

Commit f9bf06b

Browse files
committed
feat: add random number generation contract
1 parent 56b88ae commit f9bf06b

18 files changed

+2747
-0
lines changed

.gitignore

Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.suo
6+
*.user
7+
*.userosscache
8+
*.sln.docstates
9+
10+
# User-specific files (MonoDevelop/Xamarin Studio)
11+
*.userprefs
12+
13+
# Build results
14+
[Dd]ebug/
15+
[Dd]ebugPublic/
16+
[Rr]elease/
17+
[Rr]eleases/
18+
x64/
19+
x86/
20+
bld/
21+
[Bb]in/
22+
[Oo]bj/
23+
[Ll]og/
24+
[Ll]ogs/
25+
.dotnet
26+
27+
# Visual Studio 2015 cache/options directory
28+
.vs/
29+
# Uncomment if you have tasks that create the project's static files in wwwroot
30+
#wwwroot/
31+
32+
# MSTest test Results
33+
[Tt]est[Rr]esult*/
34+
[Bb]uild[Ll]og.*
35+
36+
# NUNIT
37+
*.VisualState.xml
38+
TestResult.xml
39+
40+
# Build Results of an ATL Project
41+
[Dd]ebugPS/
42+
[Rr]eleasePS/
43+
dlldata.c
44+
45+
# DNX
46+
project.lock.json
47+
artifacts/
48+
49+
*_i.c
50+
*_p.c
51+
*_i.h
52+
*.ilk
53+
*.meta
54+
*.obj
55+
*.pch
56+
*.pdb
57+
*.pgc
58+
*.pgd
59+
*.rsp
60+
*.sbr
61+
*.tlb
62+
*.tli
63+
*.tlh
64+
*.tmp
65+
*.tmp_proj
66+
*.log
67+
*.vspscc
68+
*.vssscc
69+
.builds
70+
*.pidb
71+
*.svclog
72+
*.scc
73+
74+
# Chutzpah Test files
75+
_Chutzpah*
76+
77+
# Visual C++ cache files
78+
ipch/
79+
*.aps
80+
*.ncb
81+
*.opendb
82+
*.opensdf
83+
*.sdf
84+
*.cachefile
85+
*.VC.db
86+
*.VC.VC.opendb
87+
88+
# Visual Studio profiler
89+
*.psess
90+
*.vsp
91+
*.vspx
92+
*.sap
93+
94+
# TFS 2012 Local Workspace
95+
$tf/
96+
97+
# Guidance Automation Toolkit
98+
*.gpState
99+
100+
# ReSharper is a .NET coding add-in
101+
_ReSharper*/
102+
*.[Rr]e[Ss]harper
103+
*.DotSettings.user
104+
105+
# JustCode is a .NET coding add-in
106+
.JustCode
107+
108+
# TeamCity is a build add-in
109+
_TeamCity*
110+
111+
# DotCover is a Code Coverage Tool
112+
*.dotCover
113+
114+
# NCrunch
115+
_NCrunch_*
116+
.*crunch*.local.xml
117+
nCrunchTemp_*
118+
119+
# MightyMoose
120+
*.mm.*
121+
AutoTest.Net/
122+
123+
# Web workbench (sass)
124+
.sass-cache/
125+
126+
# Installshield output folder
127+
[Ee]xpress/
128+
129+
# DocProject is a documentation generator add-in
130+
DocProject/buildhelp/
131+
DocProject/Help/*.HxT
132+
DocProject/Help/*.HxC
133+
DocProject/Help/*.hhc
134+
DocProject/Help/*.hhk
135+
DocProject/Help/*.hhp
136+
DocProject/Help/Html2
137+
DocProject/Help/html
138+
139+
# Click-Once directory
140+
publish/
141+
142+
# Publish Web Output
143+
*.[Pp]ublish.xml
144+
*.azurePubxml
145+
# TODO: Comment the next line if you want to checkin your web deploy settings
146+
# but database connection strings (with potential passwords) will be unencrypted
147+
*.pubxml
148+
*.publishproj
149+
150+
# Microsoft Azure Web App publish settings. Comment the next line if you want to
151+
# checkin your Azure Web App publish settings, but sensitive information contained
152+
# in these scripts will be unencrypted
153+
PublishScripts/
154+
155+
# NuGet Packages
156+
*.nupkg
157+
# The packages folder can be ignored because of Package Restore
158+
**/packages/*
159+
# except build/, which is used as an MSBuild target.
160+
!**/packages/build/
161+
# Uncomment if necessary however generally it will be regenerated when needed
162+
#!**/packages/repositories.config
163+
# NuGet v3's project.json files produces more ignoreable files
164+
*.nuget.props
165+
*.nuget.targets
166+
167+
# Microsoft Azure Build Output
168+
csx/
169+
*.build.csdef
170+
171+
# Microsoft Azure Emulator
172+
ecf/
173+
rcf/
174+
175+
# Windows Store app package directories and files
176+
AppPackages/
177+
BundleArtifacts/
178+
Package.StoreAssociation.xml
179+
_pkginfo.txt
180+
181+
# Visual Studio cache files
182+
# files ending in .cache can be ignored
183+
*.[Cc]ache
184+
# but keep track of directories ending in .cache
185+
!*.[Cc]ache/
186+
187+
# Others
188+
ClientBin/
189+
~$*
190+
*~
191+
*.dbmdl
192+
*.dbproj.schemaview
193+
*.pfx
194+
*.publishsettings
195+
node_modules/
196+
orleans.codegen.cs
197+
198+
# Since there are multiple workflows, uncomment next line to ignore bower_components
199+
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
200+
#bower_components/
201+
202+
# RIA/Silverlight projects
203+
Generated_Code/
204+
205+
# Backup & report files from converting an old project file
206+
# to a newer Visual Studio version. Backup files are not needed,
207+
# because we have git ;-)
208+
_UpgradeReport_Files/
209+
Backup*/
210+
UpgradeLog*.XML
211+
UpgradeLog*.htm
212+
213+
# SQL Server files
214+
*.mdf
215+
*.ldf
216+
217+
# Business Intelligence projects
218+
*.rdl.data
219+
*.bim.layout
220+
*.bim_*.settings
221+
222+
# Microsoft Fakes
223+
FakesAssemblies/
224+
225+
# GhostDoc plugin setting file
226+
*.GhostDoc.xml
227+
228+
# Node.js Tools for Visual Studio
229+
.ntvs_analysis.dat
230+
231+
# Visual Studio 6 build log
232+
*.plg
233+
234+
# Visual Studio 6 workspace options file
235+
*.opt
236+
237+
# Visual Studio LightSwitch build output
238+
**/*.HTMLClient/GeneratedArtifacts
239+
**/*.DesktopClient/GeneratedArtifacts
240+
**/*.DesktopClient/ModelManifest.xml
241+
**/*.Server/GeneratedArtifacts
242+
**/*.Server/ModelManifest.xml
243+
_Pvt_Extensions
244+
245+
# Paket dependency manager
246+
.paket/paket.exe
247+
paket-files/
248+
249+
# FAKE - F# Make
250+
.fake/
251+
252+
# JetBrains Rider
253+
.idea/
254+
*.sln.iml
255+
256+
#Codecov
257+
CodeCoverage
258+
259+
*.dll

src/ContractReferences.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using AElf.Contracts.Consensus.AEDPoS;
2+
using AElf.Standards.ACS0;
3+
4+
namespace AElf.Contracts.RandomContract;
5+
6+
public partial class RandomContractState
7+
{
8+
internal ACS0Container.ACS0ReferenceState GenesisContract { get; set; }
9+
internal AEDPoSContractContainer.AEDPoSContractReferenceState ConsensusContract { get; set; }
10+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
syntax = "proto3";
2+
import "aelf/options.proto";
3+
import "aelf/core.proto";
4+
import "google/protobuf/empty.proto";
5+
import "google/protobuf/wrappers.proto";
6+
import "Protobuf/reference/acs12.proto";
7+
option csharp_namespace = "AElf.Contracts.RandomContract";
8+
service RandomContract {
9+
option (aelf.csharp_state) = "AElf.Contracts.RandomContract.RandomContractState";
10+
option (aelf.base) = "Protobuf/reference/acs12.proto";
11+
12+
rpc Initialize (InitializeInput) returns (google.protobuf.Empty) {
13+
}
14+
rpc SetAdmin (aelf.Address) returns (google.protobuf.Empty) {
15+
}
16+
rpc SetMaxValueLimit (google.protobuf.Int32Value) returns (google.protobuf.Empty) {
17+
}
18+
rpc SetMaxRandomNumberCount (google.protobuf.Int32Value) returns (google.protobuf.Empty) {
19+
}
20+
rpc GenerateRandomNumber (GenerateRandomNumberInput) returns (google.protobuf.Empty) {
21+
}
22+
rpc GetAdmin (google.protobuf.Empty) returns (aelf.Address) {
23+
option (aelf.is_view) = true;
24+
}
25+
rpc GetMaxValueLimit (google.protobuf.Empty) returns (google.protobuf.Int32Value) {
26+
option (aelf.is_view) = true;
27+
}
28+
rpc GetMaxRandomNumberCount (google.protobuf.Empty) returns (google.protobuf.Int32Value) {
29+
option (aelf.is_view) = true;
30+
}
31+
rpc GetRandomNumber (GetRandomNumberInput) returns (RandomNumberList) {
32+
option (aelf.is_view) = true;
33+
}
34+
}
35+
36+
message InitializeInput {
37+
int32 max_value_limit = 1;
38+
int32 max_random_number_count = 2;
39+
}
40+
41+
message GenerateRandomNumberInput {
42+
string hash = 1;
43+
int32 max_value = 2;
44+
int32 random_number_count = 3;
45+
}
46+
47+
message GetRandomNumberInput {
48+
string hash = 1;
49+
}
50+
51+
message RandomNumberList {
52+
repeated int32 value = 1;
53+
}
54+
55+
message RandomNumberGenerated {
56+
option (aelf.is_event) = true;
57+
RandomNumberList random_numbers = 1;
58+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
syntax = "proto3";
2+
3+
import "aelf/core.proto";
4+
5+
option csharp_namespace = "AElf.Contracts.RandomContract";
6+
7+
message AuthorityInfo {
8+
aelf.Address contract_address = 1;
9+
aelf.Address owner_address = 2;
10+
}

0 commit comments

Comments
 (0)