Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cauciones
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
blockchain
Cauciones
Commits
94f1bdb0
Commit
94f1bdb0
authored
6 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
Codigo inicial
parent
1a2deca9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SmartContract/cauciones.sol
+71
-0
71 additions, 0 deletions
SmartContract/cauciones.sol
with
71 additions
and
0 deletions
SmartContract/cauciones.sol
0 → 100644
+
71
−
0
View file @
94f1bdb0
// 20190513 Robert Martin-Legene <robert@nic.ar>
// vim:filetype=javascript
pragma
solidity
^
0.4
.
24
;
contract
Majority
{
function
isVoter
(
address
)
public
view
returns
(
bool
)
{
}
}
contract
cauciones
{
enum
EstadosDePolizas
{
PolizaNoExiste
,
PolizaVigente
,
PolizaCancelado
,
PolizaAnulado
}
// why a struct? because I think we'll see requirements for more info
struct
poliza
{
EstadosDePolizas
estado
;
}
mapping
(
uint256
=>
poliza
)
polizas
;
Majority
admins
;
event
estadoPoliza
(
uint256
objeto
,
EstadosDePolizas
estado
);
modifier
onlyAuthorized
()
{
require
(
admins
.
isVoter
(
msg
.
sender
));
_
;
}
// can't use the modifier before the admins variable has been initialized.
constructor
(
address
admincontractaddress
)
public
{
admins
=
Majority
(
admincontractaddress
);
require
(
admins
.
isVoter
(
msg
.
sender
),
"
Creator of this contract must be authorized voter in the Majority voting contract.
"
);
}
function
_set_estado
(
uint256
objeto
,
EstadosDePolizas
estado
)
private
{
polizas
[
objeto
].
estado
=
estado
;
emit
estadoPoliza
(
objeto
,
estado
);
}
function
crearPoliza
(
uint256
objeto
)
public
onlyAuthorized
{
// must not exist already
require
(
polizas
[
objeto
].
estado
==
EstadosDePolizas
.
PolizaNoExiste
);
_set_estado
(
objeto
,
EstadosDePolizas
.
PolizaVigente
);
}
function
anularPoliza
(
uint256
objeto
)
public
onlyAuthorized
{
// must exist already
require
(
polizas
[
objeto
].
estado
!=
EstadosDePolizas
.
PolizaNoExiste
);
_set_estado
(
objeto
,
EstadosDePolizas
.
PolizaAnulado
);
}
function
cancelarPoliza
(
uint256
objeto
)
public
onlyAuthorized
{
// must exist already
require
(
polizas
[
objeto
].
estado
!=
EstadosDePolizas
.
PolizaNoExiste
);
_set_estado
(
objeto
,
EstadosDePolizas
.
PolizaCancelado
);
}
function
mostrarEstado
(
uint256
objeto
)
public
view
returns
(
uint8
)
{
return
uint8
(
polizas
[
objeto
].
estado
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment