Created
October 23, 2018 17:42
-
-
Save stefanbemelmans/a6f26777211c34c98576ee303e5c8a3d to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=true&gist=
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Copyright (c) 2018 HERC SEZC | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, | |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
See the License for the specific language governing permissions and | |
limitations under the License. | |
*/ | |
// I had difficulty importing the Herc777 contract(s), I believe the functionality I need can be found in Token.sol | |
pragma solidity ^0.4.23; | |
import "./Ownable.sol"; | |
import "./SafeMath.sol"; | |
import "./Token.sol"; | |
contract AssetCoreFunction is Ownable, Token { | |
using SafeMath for uint256; | |
address public hercContract = 0xC443f11CfA23C1b5a098a46ceFb76cc998089a46; //will be herc Contract Address | |
address public user = msg.sender; | |
uint newAssetFee = 1000; | |
uint viewerFee = 0x20; | |
// uint transactionFee; | |
event NewAssetRegistered(string _organizationName, uint _hercId); | |
event TransactionOriginated(string _organizationName, string _originator, uint _hercId); | |
event ReceivedTransaction(string _recipOrgName, string _receiving, string _origOrgName, uint _hercId); | |
event ValidTransaction(string _validated, string _origOrgName, string _recipOrgName, uint _hercId); | |
// When a new asset is registered a mapping of | |
// msg.sender to new the Asset occurs | |
// Asset mappings | |
mapping (address => NewAsset) assetAddresses; // assets mapped to user addresses | |
address[] public assetAccounts; // Array of address with assets | |
struct NewAsset { | |
string orgName; | |
uint fctHash; | |
uint hercId; | |
} | |
// Asset Functions | |
function registerNewAsset(string _orgName, address _address, uint _hercId, uint _fctHash) public payable { | |
NewAsset storage asset = assetAddresses[_address]; | |
asset.orgName = _orgName; | |
asset.hercId =_hercId; | |
asset.fctHash =_fctHash; | |
assetAccounts.push(_address); | |
transfer(hercContract, newAssetFee); | |
emit NewAssetRegistered(_orgName, _hercId); | |
} | |
function getAssets() view public returns(address[]){ | |
return assetAccounts; | |
} | |
function getAsset(address _address) view public returns(uint) { | |
return assetAddresses[_address].hercId; | |
} | |
function countAssets() view public returns (uint) { | |
return assetAccounts.length; | |
} | |
// Originator transactions mappings | |
mapping (address => OrigTrans) origTransAdresses; | |
address[] public origTransAccounts; | |
// originator transaction | |
struct OrigTrans { | |
string orgName; | |
uint hercId; | |
string originator; | |
} | |
function newOrigTrans(address _address, uint _transCost, string _orgName, uint _hercId, string _originator) public payable { | |
OrigTrans storage origTrans = origTransAdresses[_address]; | |
origTrans.orgName = _orgName; | |
origTrans.hercId = _hercId; | |
origTrans.originator = _originator; | |
origTransAccounts.push(_address); | |
transfer(hercContract, _transCost); | |
emit TransactionOriginated(_orgName, "Originated", _hercId); | |
} | |
// recipient transaction | |
struct RecipTrans { | |
address recipAddress; | |
string origOrgName; | |
string recipOrgName; | |
uint hercId; | |
uint origTransFctHash; | |
uint recipTransFctHash; | |
} | |
mapping (address => RecipTrans) recipTransAdresses; | |
address[] public recipTransAccounts; | |
function newRecipTrans( | |
address _address, | |
string _origOrgName, | |
string _recipOrgName, | |
uint _hercId, | |
uint _origTransFctHash, | |
uint _recipTransFctHash, | |
uint _transCost | |
) onlyOwner public payable { | |
RecipTrans storage recipTrans = recipTransAdresses[_address]; | |
recipTrans.origOrgName = _origOrgName; | |
recipTrans.recipOrgName = _recipOrgName; | |
recipTrans.hercId = _hercId; | |
recipTrans.origTransFctHash = _origTransFctHash; | |
recipTrans.recipTransFctHash = _recipTransFctHash; | |
// recipTransAdresses[_address] = recipTrans; | |
recipTransAccounts.push(_address); | |
transfer(hercContract, _transCost); | |
emit ReceivedTransaction( _recipOrgName,"ReceivedTransaction", _origOrgName, _hercId); | |
} | |
// need something to attach the orig transactions to the recip trans, probably need to discuss further | |
function getAllOriginTrans() view public returns(address[]){ | |
return origTransAccounts; | |
} | |
function getSingleOriginTrans(address _address) view public returns (uint) { | |
return origTransAdresses[_address].hercId; | |
} | |
function countOriginTrans() view public returns (uint) { | |
return origTransAccounts.length; | |
} | |
// Recipient Transactions | |
function getAllRecipientTrans() view public returns(address[]){ | |
return recipTransAccounts; | |
} | |
function getSingleRecipientTrans(address _address) view public returns (uint) { | |
return recipTransAdresses[_address].hercId; | |
} | |
function countRecipientTrans() view public returns (uint) { | |
return recipTransAccounts.length; | |
} | |
// Function structs and mappings for getting the validated transactions from the HIPR smart Contracts | |
struct ValidatedTransaction { | |
// address recipAddress; | |
string origOrgName; | |
string recipOrgName; | |
uint hercId; | |
uint origTransFctHash; | |
uint recipTransFctHash; | |
} | |
mapping (address => ValidatedTransaction) validatedTransAdresses; | |
address[] public validatedTransAccounts; | |
function addValidatedTransaction ( | |
address _address, | |
string _origOrgName, | |
string _recipOrgName, | |
uint _hercId, | |
uint _origTransFctHash, | |
uint _recipTransFctHash | |
) public | |
{ | |
ValidatedTransaction storage validatedTransaction = validatedTransAdresses[_address]; | |
validatedTransaction.origOrgName = _origOrgName; | |
validatedTransaction.recipOrgName = _recipOrgName; | |
validatedTransaction.hercId = _hercId; | |
validatedTransaction.origTransFctHash = _origTransFctHash; | |
validatedTransaction.recipTransFctHash = _recipTransFctHash; | |
// validatedTransactionAdresses[_address] = validatedTransaction; | |
validatedTransAccounts.push(_address); | |
// transfer(hercContract, _transCost); | |
emit ValidTransaction("Validated", _origOrgName, _recipOrgName, _hercId); | |
} | |
function getAllValidatedTrans() view public returns(address[]){ | |
return validatedTransAccounts; | |
} | |
function getSingleValidatedTrans(address _address) view public returns (uint) { | |
return recipTransAdresses[_address].hercId; | |
} | |
function countValidatedTrans() view public returns (uint) { | |
return recipTransAccounts.length; | |
} | |
// FOR CHANGES | |
// function setTo(address _hercContract) public { | |
// hercContract = _hercContract; | |
// } | |
// FOR CHANGES | |
// function setChainFee(uint _chainFee) public { | |
// newAssetFee = _chainFee; | |
// } | |
// FOR CHANGES | |
// function setViewerFee(uint _viewerFee) public { | |
// viewerFee = _viewerFee; | |
// } | |
// function transfer(uint _value) | |
// public | |
// returns (bool) { | |
// return transfer(hercContract, _value); | |
// } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @title Ownable | |
* @dev The Ownable contract has an owner address, and provides basic authorization control | |
* functions, this simplifies the implementation of "user permissions". | |
*/ | |
pragma solidity ^0.4.19; | |
contract Ownable { | |
address public owner; | |
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); | |
/** | |
* @dev The Ownable constructor sets the original `owner` of the contract to the sender | |
* account. | |
*/ | |
constructor() public { | |
owner = msg.sender; | |
} | |
/** | |
* @dev Throws if called by any account other than the owner. | |
*/ | |
modifier onlyOwner() { | |
require(msg.sender == owner); | |
_; | |
} | |
/** | |
* @dev Allows the current owner to transfer control of the contract to a newOwner. | |
* @param newOwner The address to transfer ownership to. | |
*/ | |
function transferOwnership(address newOwner) public onlyOwner { | |
require(newOwner != address(0)); | |
emit OwnershipTransferred(owner, newOwner); | |
owner = newOwner; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.18; | |
/* | |
Copyright (c) 2018 HERC SEZC | |
Permission is hereby granted, free of charge, to any person obtaining | |
a copy of this software and associated documentation files (the | |
"Software"), to deal in the Software without restriction, including | |
without limitation the rights to use, copy, modify, merge, publish, | |
distribute, sublicense, and/or sell copies of the Software, and to | |
permit persons to whom the Software is furnished to do so, subject to | |
the following conditions: | |
The above copyright notice and this permission notice shall be included | |
in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | |
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | |
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | |
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
*/ | |
/** | |
* @title SafeMath | |
* @dev Math operations with safety checks that throw on error | |
*/ | |
library SafeMath { | |
function mul(uint256 a, uint256 b) internal pure returns (uint256) { | |
if (a == 0) { | |
return 0; | |
} | |
uint256 c = a * b; | |
assert(c / a == b); | |
return c; | |
} | |
function div(uint256 a, uint256 b) internal pure returns (uint256) { | |
// assert(b > 0); // Solidity automatically throws when dividing by 0 | |
uint256 c = a / b; | |
// assert(a == b * c + a % b); // There is no case in which this doesn't hold | |
return c; | |
} | |
function sub(uint256 a, uint256 b) internal pure returns (uint256) { | |
assert(b <= a); | |
return a - b; | |
} | |
function add(uint256 a, uint256 b) internal pure returns (uint256) { | |
uint256 c = a + b; | |
assert(c >= a); | |
return c; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.11; | |
/* | |
Copyright 2017 HERC SEZC | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, | |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
See the License for the specific language governing permissions and | |
limitations under the License. | |
*/ | |
contract Token { | |
function totalSupply() view returns (uint supply) {} | |
function balanceOf(address _owner) view returns (uint balance) {} | |
function transfer(address _to, uint _value) returns (bool success) {} | |
function transferFrom(address _from, address _to, uint _value) returns (bool success) {} | |
function approve(address _spender, uint _value) returns (bool success) {} | |
function allowance(address _owner, address _spender) view returns (uint remaining) {} | |
event Transfer(address indexed _from, address indexed _to, uint _value); | |
event Approval(address indexed _owner, address indexed _spender, uint _value); | |
} | |
// pragma soidity 0.4.11; | |
/* | |
Copyright 2017 HERC SEZC | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, | |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
See the License for the specific language governing permissions and | |
limitations under the License. | |
*/ | |
// contract Token { | |
// function totalSupply() public constant returns (uint supply) {} | |
// function balanceOf(address _owner) constant returns (uint balance) {} | |
// function transfer(address _to, uint _value) returns (bool success) {} | |
// function transferFrom(address _from, address _to, uint _value) returns (bool success) {} | |
// function approve(address _spender, uint _value) returns (bool success) {} | |
// function allowance(address _owner, address _spender) constant returns (uint remaining) {} | |
// event Transfer(address indexed _from, address indexed _to, uint _value); | |
// event Approval(address indexed _owner, address indexed _spender, uint _value); | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment