Skip to content
Snippets Groups Projects
Commit 94f1bdb0 authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

Codigo inicial

parent 1a2deca9
No related branches found
No related tags found
No related merge requests found
// 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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment