Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
cleanup event logs
Browse files Browse the repository at this point in the history
  • Loading branch information
clbrge committed Aug 25, 2018
1 parent 6cb17ae commit 8a98c1c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
13 changes: 5 additions & 8 deletions contracts/RougeFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ import "./RougeRegistry.sol";

contract RougeFactory is RougeRegistry {

string public version = '0.12.0';
string public version = '0.13.0';

// The Rouge Token contract address
RGETokenInterface public rge;
uint256 public tare;

address owner;

mapping (address => uint256) public deposit; // per campaign ...

constructor() public {
owner = msg.sender;
}
Expand All @@ -33,15 +31,15 @@ contract RougeFactory is RougeRegistry {
_;
}

event NewRougeFactory(address factory, uint256 _tare);
event SetFactory(address indexed _rge, uint256 _tare);

function setParams (address _rge, uint256 _tare) onlyBy(owner) public {
rge = RGETokenInterface(_rge);
tare = _tare;
emit NewRougeFactory(this, tare);
emit SetFactory(_rge, tare);
}

event NewCampaign(address issuer, address campaign, uint32 issuance);
event NewCampaign(address indexed issuer, address indexed campaign, uint32 issuance);

function createCampaign(address _issuer, uint32 _issuance, uint256 _tokens) public {

Expand All @@ -53,13 +51,12 @@ contract RougeFactory is RougeRegistry {
SimpleRougeCampaign c = new SimpleRougeCampaign(_issuer, _issuance, rge, tare, this);

// TODO XXX check front running
rge.transfer(c, _tokens); // transfer tokens to the campaign contract ...
require(rge.transfer(c, _tokens)); // transfer tokens to the campaign contract ...

emit NewCampaign(_issuer, c, _issuance);

// XXX beta sugar getters / not stricly necessary with good explorer/indexes...

deposit[c] = _tokens;
add_campaign(_issuer, c);

}
Expand Down
2 changes: 1 addition & 1 deletion contracts/SimpleRougeCampaign.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import "./RougeFactoryInterface.sol";

contract SimpleRougeCampaign {

string public version = '0.12.0';
string public version = '0.13.0';

// The Rouge Token contract address
RGETokenInterface public rge;
Expand Down
10 changes: 4 additions & 6 deletions test/RougeFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ contract('RougeFactory', function(accounts) {
const event_NewCampaign_sign = web3.sha3('NewCampaign(address,address,uint32)')
// const event_Transfer_sign = web3.sha3('Transfer(address,address,uint256)')
result.receipt.logs.forEach( function(e) {
// console.log(e)
if (e.topics[0] === event_NewCampaign_sign) {

assert.equal(e.data.slice(2 + 24, 66), issuer.substr(2), "issuer first data of NewCampaign event");
assert.equal(e.data.slice(66 + 24, 130), campaign_address.substr(2), "campaign address 2nd data of NewCampaign event");
assert.equal(web3.toDecimal( '0x' + e.data.slice(130, 194)), issuance, "issuance 3nd data of NewCampaign event");

// console.log(e)
assert.equal(e.topics[1].slice(26, 66), issuer.substr(2), "issuer first data of NewCampaign event");
assert.equal(e.topics[2].slice(26, 66), campaign_address.substr(2), "campaign address 2nd data of NewCampaign event");
assert.equal(web3.toDecimal(e.data), issuance, "issuance 3nd data of NewCampaign event");
}
})

Expand Down
10 changes: 5 additions & 5 deletions truffle.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ module.exports = {
// port: 8545,
// network_id: "*" // Match any network id
// },
sokol: {
host: " https://sokol-trace.poa.network", //https://sokol.poa.network",
port: 443,
network_id: "*" // Match any network id
}
// sokol: {
// host: " https://sokol-trace.poa.network", //https://sokol.poa.network",
// port: 443,
// network_id: "*" // Match any network id
// }
}
};

0 comments on commit 8a98c1c

Please sign in to comment.