Skip to content

Commit

Permalink
introducing LOCIregister
Browse files Browse the repository at this point in the history
  • Loading branch information
emmonspired committed Mar 15, 2018
1 parent 00128e6 commit 5fef99f
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
70 changes: 70 additions & 0 deletions contracts/LOCIregister.sol
@@ -0,0 +1,70 @@
pragma solidity ^0.4.18;

import 'zeppelin-solidity/contracts/math/SafeMath.sol';
import 'zeppelin-solidity/contracts/ownership/Ownable.sol';
import 'zeppelin-solidity/contracts/ownership/Contactable.sol';
import 'zeppelin-solidity/contracts/token/StandardToken.sol';

contract LOCIregister is Ownable, Contactable {
using SafeMath for uint256;

// this is the already deployed coin from the token sale
StandardToken token;

// Register every withdrawal we make from a linked LOCIsearch payment
event RegisterWithdrawal(address indexed register, /* address the customer sent payment to */
address indexed beneficiary, /* recipent of funds after withdrawal */
address indexed linked, /* original linked customer address */
uint256 amount, /* amount of wei to transfer */
uint reason); /* 0=refund, 1=payment, 2=stake, 3=bid */

// After this contract is deployed, we will grant access to this contract
// by calling methods on the LOCIcoin since we are using the same owner
// and granting the distribution of tokens to this contract
function LOCIregister( address _token, string _contactInformation ) public {
require(_token != 0x0);

token = StandardToken(_token);
contactInformation = _contactInformation;
}

function withdrawFrom( address _register, address _beneficiary, address _linked, uint256 _amount, uint _reason ) onlyOwner public {
require(_register != 0x0);
require(_beneficiary != 0x0 );
require(_beneficiary != address(token));

token.transferFrom( _register, _beneficiary, _amount );
RegisterWithdrawal( _register, _beneficiary, _linked, _amount, _reason );
}

function withdrawFromAll( address[] _register, address[] _beneficiary, address[] _linked, uint256[] _amount, uint[] _reason ) onlyOwner public {
require( _register.length == _beneficiary.length && _beneficiary.length == _amount.length && _amount.length == _reason.length );

for (uint i = 0; i < _register.length; i += 1) {
token.transferFrom( _register[i], _beneficiary[i], _amount[i] );
RegisterWithdrawal( _register[i], _beneficiary[i], _linked[i], _amount[i], _reason[i] );
}
}

// in the event ether is accidentally sent to our contract, we can retrieve it
function ownerTransferWei(address _beneficiary, uint256 _value) external onlyOwner {
require(_beneficiary != 0x0);
require(_beneficiary != address(token));

// if zero requested, send the entire amount, otherwise the amount requested
uint256 _amount = _value > 0 ? _value : this.balance;

_beneficiary.transfer(_amount);
}

// after we distribute the bonus tokens, we will send them back to the coin itself
function ownerRecoverTokens(address _beneficiary) external onlyOwner {
require(_beneficiary != 0x0);
require(_beneficiary != address(token));

uint256 _tokensRemaining = token.balanceOf(address(this));
if (_tokensRemaining > 0) {
token.transfer(_beneficiary, _tokensRemaining);
}
}
}
34 changes: 34 additions & 0 deletions migrations/4_deploy_LOCIregister.js
@@ -0,0 +1,34 @@
const SafeMath = artifacts.require('zeppelin-solidity/contracts/math/SafeMath.sol');
const Ownable = artifacts.require('zeppelin-solidity/contracts/ownership/Ownable.sol');
const Contactable = artifacts.require('zeppelin-solidity/contracts/ownership/Contactable.sol');
const LOCIcoin = artifacts.require("./LOCIcoin.sol");
const LOCIregister = artifacts.require("./LOCIregister.sol");

const BigNumber = require('bignumber.js');

module.exports = (deployer, network, accounts) => {

let deployAddress = accounts[0]; // by convention

console.log('Preparing for deployment of LOCIregister...');

if( network == "live" ) {
console.log("Using LOCIcoin at:" + LOCIcoin.address);
throw "Halt. Sanity check. Not ready for deployment to live network. Manually remove this throw and try again.";
}

console.log('deploying from:' + deployAddress);
console.log('deploying SafeMath Ownable Contactable');
//deployer.deploy(SafeMath, {from: deployAddress});
//deployer.deploy(Ownable, {from: deployAddress});
//deployer.deploy(Contactable, {from: deployAddress});

console.log('linking Ownable SafeMath Contactable');
deployer.link(Ownable, [LOCIregister], {from: deployAddress});
deployer.link(SafeMath, [LOCIregister], {from: deployAddress});
deployer.link(Contactable, [LOCIregister], {from: deployAddress});

console.log('deploying LOCIregister');
deployer.deploy(LOCIregister, LOCIcoin.address, 'LOCIpro.com', {from: deployAddress});

};

0 comments on commit 5fef99f

Please sign in to comment.