Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
destream-blockchain
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DeStream-public
destream-blockchain
Commits
2486507a
Commit
2486507a
authored
6 years ago
by
Sergei Zubov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix smart contracts project
parent
07f6c5ca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
0 deletions
+87
-0
Builder.cs
Sources/Stratis.SmartContracts.Tools.Sct/Builder/Builder.cs
+87
-0
No files found.
Sources/Stratis.SmartContracts.Tools.Sct/Builder/Builder.cs
0 → 100644
View file @
2486507a
using
System.ComponentModel.DataAnnotations
;
using
System.IO
;
using
McMaster.Extensions.CommandLineUtils
;
namespace
Stratis.SmartContracts.Tools.Sct.Build
{
[
Command
(
Description
=
"Builds a smart contract and outputs a dll. For testing purposes."
)]
[
HelpOption
]
class
Builder
{
[
Argument
(
0
,
Description
=
"The file containing the source code of the smart contract to deploy"
,
Name
=
"<File>"
)]
[
Required
]
[
FileExists
]
public
string
InputFile
{
get
;
}
[
Argument
(
1
,
Description
=
"The destination path"
,
Name
=
"<Path>"
)]
[
Required
]
public
string
OutputPath
{
get
;
}
[
Option
(
"-params|--params"
,
CommandOptionType
.
MultipleValue
,
Description
=
"Params to be passed to the constructor when instantiating the contract"
)]
public
string
[]
Params
{
get
;
}
public
int
OnExecute
(
CommandLineApplication
app
,
IConsole
console
)
{
console
.
WriteLine
();
console
.
WriteLine
(
"Smart Contract Deployer"
);
console
.
WriteLine
();
if
(!
File
.
Exists
(
this
.
InputFile
))
{
console
.
WriteLine
(
$"
{
this
.
InputFile
}
does not exist"
);
return
1
;
}
if
(
File
.
Exists
(
this
.
OutputPath
))
{
console
.
WriteLine
(
$"Output file already exists!"
);
return
1
;
}
console
.
WriteLine
(
$"Reading
{
this
.
InputFile
}
..."
);
string
source
;
using
(
var
sr
=
new
StreamReader
(
File
.
OpenRead
(
this
.
InputFile
)))
{
source
=
sr
.
ReadToEnd
();
}
console
.
WriteLine
(
$"Read
{
this
.
InputFile
}
OK!"
);
console
.
WriteLine
();
if
(
string
.
IsNullOrWhiteSpace
(
source
))
{
console
.
WriteLine
(
$"Empty file at
{
this
.
InputFile
}
"
);
return
1
;
}
ValidationServiceResult
validationResult
=
new
ValidatorService
().
Validate
(
this
.
InputFile
,
source
,
console
,
this
.
Params
);
if
(!
validationResult
.
Success
)
return
1
;
else
console
.
WriteLine
(
"Validation passed!"
);
this
.
WriteDll
(
validationResult
.
CompilationResult
.
Compilation
);
console
.
WriteLine
(
$"File
{
this
.
OutputPath
}
written."
);
return
1
;
}
private
void
WriteDll
(
byte
[]
compilation
)
{
using
(
FileStream
sw
=
File
.
OpenWrite
(
this
.
OutputPath
))
{
sw
.
Write
(
compilation
,
0
,
compilation
.
Length
);
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment