Skip to content

Commit

Permalink
Remit Contract Update
Browse files Browse the repository at this point in the history
  • Loading branch information
sirmikecarter committed Aug 22, 2017
1 parent 22384cd commit b827026
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 85 deletions.
60 changes: 59 additions & 1 deletion build/contracts/Campaign.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,66 @@
"links": {},
"address": "0x6522665e30789b6fd072f9c78f016a1309f9327e",
"updated_at": 1503347291307
},
"1503418741944": {
"events": {
"0x370510fa7e8c74204b8d2fd52b7a0837e535ea0c1491fd4e13730ce825e40524": {
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "sender",
"type": "address"
},
{
"indexed": false,
"name": "amount",
"type": "uint256"
}
],
"name": "LogContribution",
"type": "event"
},
"0xdd896e09a507baf21c108627cf41469f315fb779fe323f5e1c6154fd5d869e69": {
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "funder",
"type": "address"
},
{
"indexed": false,
"name": "amount",
"type": "uint256"
}
],
"name": "LogRefundSent",
"type": "event"
},
"0xb4214c8c54fc7442f36d3682f59aebaf09358a4431835b30efb29d52cf9e1e91": {
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "beneficiary",
"type": "address"
},
{
"indexed": false,
"name": "amount",
"type": "uint256"
}
],
"name": "LogWithdrawal",
"type": "event"
}
},
"links": {},
"address": "0x2d029514246335ac1aef6064be0faf913e3cdc05",
"updated_at": 1503418769895
}
},
"schema_version": "0.0.5",
"updated_at": 1503347291307
"updated_at": 1503418769895
}
8 changes: 7 additions & 1 deletion build/contracts/Migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,14 @@
"links": {},
"address": "0x8545ac0a4062e531aca3c34af7b0e9c552d2aa69",
"updated_at": 1503347291328
},
"1503418741944": {
"events": {},
"links": {},
"address": "0xe0980c8068f22925f37a239a983708966ff52437",
"updated_at": 1503418769917
}
},
"schema_version": "0.0.5",
"updated_at": 1503347291328
"updated_at": 1503418769917
}
107 changes: 48 additions & 59 deletions build/contracts/Remittance.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,6 @@
"payable": false,
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "inputHash1",
"type": "bytes32"
},
{
"name": "inputHash2",
"type": "bytes32"
}
],
"name": "enterHashCodes",
"outputs": [
{
"name": "success",
"type": "bool"
}
],
"payable": false,
"type": "function"
},
{
"constant": true,
"inputs": [],
Expand All @@ -57,28 +35,6 @@
"payable": false,
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "duration",
"type": "uint256"
},
{
"name": "recieverAdd",
"type": "address"
}
],
"name": "exchangeShop",
"outputs": [
{
"name": "success",
"type": "bool"
}
],
"payable": true,
"type": "function"
},
{
"constant": false,
"inputs": [
Expand Down Expand Up @@ -119,29 +75,33 @@
"type": "function"
},
{
"constant": true,
"constant": false,
"inputs": [
{
"name": "",
"type": "address"
}
],
"name": "exchangeShopDetails",
"outputs": [
"name": "inputHash1",
"type": "bytes32"
},
{
"name": "recieverAddress",
"type": "address"
"name": "inputHash2",
"type": "bytes32"
},
{
"name": "recieverAmount",
"name": "duration",
"type": "uint256"
},
{
"name": "deadline",
"type": "uint256"
"name": "recieverAdd",
"type": "address"
}
],
"payable": false,
"name": "exchangeShop",
"outputs": [
{
"name": "success",
"type": "bool"
}
],
"payable": true,
"type": "function"
},
{
Expand Down Expand Up @@ -185,7 +145,7 @@
"type": "event"
}
],
"unlinked_binary": "0x6060604052341561000f57600080fd5b5b60008054600160a060020a03338116600160a060020a0319928316179092556501176592e0006003556001805430909316929091169190911790555b5b6105228061005c6000396000f3006060604052361561007d5763ffffffff60e060020a60003504166329dcb0cf81146100825780634844efaf146100a75780638da5cb5b146100d4578063b603cd8014610103578063cb6f6f1a14610118578063d4a0601214610143578063ddca3f431461017c578063ec666944146101a1578063f6b4dfb4146101f6575b600080fd5b341561008d57600080fd5b610095610225565b60405190815260200160405180910390f35b34156100b257600080fd5b6100c060043560243561022b565b604051901515815260200160405180910390f35b34156100df57600080fd5b6100e7610286565b604051600160a060020a03909116815260200160405180910390f35b341561010e57600080fd5b610116610295565b005b6100c0600435600160a060020a03602435166102bd565b604051901515815260200160405180910390f35b341561014e57600080fd5b6100c0600435602435600160a060020a0360443516610389565b604051901515815260200160405180910390f35b341561018757600080fd5b610095610459565b60405190815260200160405180910390f35b34156101ac57600080fd5b6101c0600160a060020a036004351661045f565b6040518084600160a060020a0316600160a060020a03168152602001838152602001828152602001935050505060405180910390f35b341561020157600080fd5b6100e761048a565b604051600160a060020a03909116815260200160405180910390f35b60025481565b6000610235610499565b83836040519182526020820152604090810190519081900390208152600480546001810161026383826104ab565b916000526020600020900160005b508290815190555060019250505b5092915050565b600054600160a060020a031681565b60005433600160a060020a039081169116146102ad57fe5b600054600160a060020a0316ff5b565b60003415156102cb57600080fd5b33600160a060020a0390811660009081526005602052604090208054600160a060020a0319169184169190911790556002345b33600160a060020a038116600090815260056020526040908190209390920460018401554386016002909301929092557fbc2674b1c231352f5fe99c10d8db7182a2c0c857f496f1157968bdcbdb52bf3d91908490349051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a15060015b92915050565b600083836040519182526020820152604090810190519081900390206004805460009081106103b457fe5b906000526020600020900160005b5054146103ce57600080fd5b600160a060020a0380831660009081526005602052604090819020805460019091015492169180156108fc029151600060405180830381858888f19350505050151561041957600080fd5b81600160a060020a03166108fc6003549081150290604051600060405180830381858888f19350505050151561044e57600080fd5b5060015b9392505050565b60035481565b600560205260009081526040902080546001820154600290920154600160a060020a03909116919083565b600154600160a060020a031681565b60206040519081016040526000815290565b8154818355818115116104cf576000838152602090206104cf9181019083016104d5565b5b505050565b6104f391905b808211156104ef57600081556001016104db565b5090565b905600a165627a7a723058206f4f8a8cfb441f8df103ead89f1550d76f0e6174f58d8ff82d0cc483d2628d740029",
"unlinked_binary": "0x6060604052341561000f57600080fd5b5b60008054600160a060020a03338116600160a060020a0319928316179092556501176592e0006003556001805430909316929091169190911790555b5b6104838061005c6000396000f300606060405236156100675763ffffffff60e060020a60003504166329dcb0cf811461006c5780638da5cb5b14610091578063b603cd80146100c0578063d4a06012146100d5578063ddca3f431461010e578063edd79b5a14610133578063f6b4dfb414610164575b600080fd5b341561007757600080fd5b61007f610193565b60405190815260200160405180910390f35b341561009c57600080fd5b6100a4610199565b604051600160a060020a03909116815260200160405180910390f35b34156100cb57600080fd5b6100d36101a8565b005b34156100e057600080fd5b6100fa600435602435600160a060020a03604435166101d0565b604051901515815260200160405180910390f35b341561011957600080fd5b61007f6102f0565b60405190815260200160405180910390f35b6100fa600435602435604435600160a060020a03606435166102f6565b604051901515815260200160405180910390f35b341561016f57600080fd5b6100a4610421565b604051600160a060020a03909116815260200160405180910390f35b60025481565b600054600160a060020a031681565b60005433600160a060020a039081169116146101c057fe5b600054600160a060020a0316ff5b565b60006101da610430565b600460008686604051918252602082015260409081019051809103902060001916600019168152602001908152602001600020608060405190810160409081528254600160a060020a0390811683526001840154166020830152600283015490820190815260039092015460608201529150600090511161025a57600080fd5b8051600160a060020a0384811691161461027357600080fd5b8060200151600160a060020a03166108fc82604001519081150290604051600060405180830381858888f1935050505015156102ae57600080fd5b82600160a060020a03166108fc6003549081150290604051600060405180830381858888f1935050505015156102e357600080fd5b600191505b509392505050565b60035481565b6000610300610430565b34151561030c57600080fd5b600160a060020a033381168252831660208201526002345b04816040018181525050834301816060018181525050806004600088886040519182526020820152604090810190519081900390208152602081019190915260400160002081518154600160a060020a031916600160a060020a03919091161781556020820151600182018054600160a060020a031916600160a060020a0392909216919091179055604082015181600201556060820151600390910155507fbc2674b1c231352f5fe99c10d8db7182a2c0c857f496f1157968bdcbdb52bf3d338434604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a1600191505b50949350505050565b600154600160a060020a031681565b608060405190810160409081526000808352602083018190529082018190526060820152905600a165627a7a723058206f727ece0947169f97ea0739004c05da804c2589663b59aa63a00ef4141eabc90029",
"networks": {
"1503280387528": {
"events": {
Expand Down Expand Up @@ -273,8 +233,37 @@
"links": {},
"address": "0x454fa13df71f88349ea40ab34b6b4004d5ed79b0",
"updated_at": 1503347291296
},
"1503418741944": {
"events": {
"0xbc2674b1c231352f5fe99c10d8db7182a2c0c857f496f1157968bdcbdb52bf3d": {
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "msgSender",
"type": "address"
},
{
"indexed": false,
"name": "recieverAddress",
"type": "address"
},
{
"indexed": false,
"name": "contractAmount",
"type": "uint256"
}
],
"name": "LogExchange",
"type": "event"
}
},
"links": {},
"address": "0x1a4cafbe88f7473eb4491901f1e143369abfd01a",
"updated_at": 1503418769885
}
},
"schema_version": "0.0.5",
"updated_at": 1503347291296
"updated_at": 1503418769885
}
36 changes: 35 additions & 1 deletion build/contracts/Splitter.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,42 @@
"links": {},
"address": "0xcb2264f68370542c501975cd9a2f6dc556d3b354",
"updated_at": 1503347291306
},
"1503418741944": {
"events": {
"0x06db731693593acc083dff79ce1fcec079345d6a9523bc1b715f844092cb0d57": {
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "amount",
"type": "uint256"
},
{
"indexed": false,
"name": "sender",
"type": "address"
},
{
"indexed": false,
"name": "receiver1",
"type": "address"
},
{
"indexed": false,
"name": "receiver2",
"type": "address"
}
],
"name": "LogSplitAmount",
"type": "event"
}
},
"links": {},
"address": "0x0878baad4f0f053031b60fad74d478fe447c3e41",
"updated_at": 1503418769891
}
},
"schema_version": "0.0.5",
"updated_at": 1503347291306
"updated_at": 1503418769891
}
38 changes: 15 additions & 23 deletions contracts/Remittance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,31 @@ contract Remittance {
event LogExchange(address msgSender, address recieverAddress, uint contractAmount);

struct ExchangeShopDetails {
address creatorAddress;
address recieverAddress;
uint recieverAmount;
uint deadline;
}

struct HashCodes {
bytes32 theHash;
}

HashCodes[] private hashCodes;

mapping(address=>ExchangeShopDetails) public exchangeShopDetails;

mapping(bytes32=>ExchangeShopDetails) private exchangeShopDetails;

function Remittance(){
owner = msg.sender;
fee = 300000 * 4000000 ; //Fee (gas*gasPrice)
contractAddress = this;

}

function enterHashCodes(bytes32 inputHash1,bytes32 inputHash2) public returns (bool success) {

HashCodes memory newCodes;
newCodes.theHash = keccak256(inputHash1,inputHash2);
hashCodes.push(newCodes);
return true;
}

function exchangeShop(uint duration, address recieverAdd) public payable returns (bool success) {
function exchangeShop(bytes32 inputHash1,bytes32 inputHash2, uint duration, address recieverAdd) public payable returns (bool success) {

if(msg.value== 0) revert();

exchangeShopDetails[msg.sender].recieverAddress = recieverAdd;
exchangeShopDetails[msg.sender].recieverAmount = msg.value/2; //Local Currency
exchangeShopDetails[msg.sender].deadline = block.number+duration;

ExchangeShopDetails memory newTransfer;
newTransfer.creatorAddress = msg.sender;
newTransfer.recieverAddress = recieverAdd;
newTransfer.recieverAmount = msg.value/2; //Local Currency

This comment has been minimized.

Copy link
@xavierlepretre

xavierlepretre Aug 27, 2017

Where are the remaining msg.value - msg.value / 2 accounted?

This comment has been minimized.

Copy link
@xavierlepretre

xavierlepretre Aug 27, 2017

And why / 2 in the first place?

newTransfer.deadline = block.number+duration;
exchangeShopDetails[keccak256(inputHash1,inputHash2)] = newTransfer;

LogExchange(msg.sender, recieverAdd, msg.value );

Expand All @@ -52,8 +42,10 @@ contract Remittance {

function verifyFunds(bytes32 verifyhash1, bytes32 verifyhash2, address contractOwner) public returns (bool success) {

require(hashCodes[0].theHash == keccak256(verifyhash1,verifyhash2));
exchangeShopDetails[contractOwner].recieverAddress.transfer(exchangeShopDetails[contractOwner].recieverAmount);
ExchangeShopDetails memory toVerify = exchangeShopDetails[keccak256(verifyhash1,verifyhash2)];
require(toVerify.recieverAmount > 0);
require(contractOwner == toVerify.creatorAddress);

This comment has been minimized.

Copy link
@xavierlepretre

xavierlepretre Aug 27, 2017

What is the point of asking the caller to pass contractOwner if the contract has saved it all along?

This comment has been minimized.

Copy link
@xavierlepretre

xavierlepretre Aug 27, 2017

No deadline check?

toVerify.recieverAddress.transfer(toVerify.recieverAmount);

This comment has been minimized.

Copy link
@xavierlepretre

xavierlepretre Aug 27, 2017

Once I have passed these inputs, I can just pass them again and be paid again? And again until the contract is empty?

contractOwner.transfer(fee);

This comment has been minimized.

Copy link
@xavierlepretre

xavierlepretre Aug 27, 2017

Two transfers in a single transaction. Bad pattern.

return true;
}
Expand Down

0 comments on commit b827026

Please sign in to comment.