diff --git a/contracts/components/Claims.sol b/contracts/components/Claims.sol index cc83582..9f96e66 100644 --- a/contracts/components/Claims.sol +++ b/contracts/components/Claims.sol @@ -133,14 +133,13 @@ contract Claims { event Dispute( IArbitrator indexed _arbitrator, uint256 indexed _disputeID, - uint256 _metaEvidenceID, - uint256 _evidenceGroupID + uint256 _metaEvidenceID ); event CreateClaim( - address indexed createdBy, string indexed safeId, - uint256 indexed id + uint256 indexed id, + uint256 timeStamp ); /** @@ -181,8 +180,7 @@ contract Claims { emit Dispute( data.arbitrator, disputeID, - data.metaEvidenceId, - evidenceGroupID + data.metaEvidenceId ); claims[disputeID] = Types.Claim({ @@ -195,9 +193,7 @@ contract Claims { }); claimsCount += 1; - - emit CreateClaim(msg.sender, _safeId, disputeID); - + emit CreateClaim(_safeId,disputeID, block.timestamp); if (bytes(_evidence).length != 0) { _submitEvidence(disputeID, _evidence, data.arbitrator); } @@ -225,7 +221,7 @@ contract Claims { status: Types.ClaimStatus.Active }); - emit CreateClaim(msg.sender, _safeId, claimsCount); + emit CreateClaim(_safeId, claimsCount, block.timestamp); } /** @@ -259,7 +255,7 @@ contract Claims { }); } - emit CreateClaim(msg.sender, _safeId, claimsCount); + emit CreateClaim(_safeId,claimsCount, block.timestamp); } /** diff --git a/package-lock.json b/package-lock.json index 60e7f96..0d3ccfb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,18 @@ { "name": "@safient/contracts", - "version": "0.1.11-alpha", + "version": "0.1.13-alpha", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@safient/contracts", - "version": "0.1.11-alpha", + "version": "0.1.13-alpha", "dependencies": { "@ethersproject/address": "^5.2.0", "@ethersproject/bignumber": "^5.2.0", "@ethersproject/contracts": "^5.0.5", "@ethersproject/logger": "^5.2.0", - "@ethersproject/providers": "^5.2.0", + "@ethersproject/providers": "^5.4.4", "@ethersproject/units": "^5.2.0", "@nomiclabs/hardhat-ethers": "^2.0.2", "@nomiclabs/hardhat-waffle": "^2.0.1", diff --git a/package.json b/package.json index 6b79a62..7c95d89 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@safient/contracts", - "version": "0.1.13-alpha", + "version": "0.1.14-alpha", "description": "JavaScript SDK to manage and interact with the safe claims on Safient protocol.", "keywords": [ "Web3", diff --git a/src/abis/SafientMain.json b/src/abis/SafientMain.json index 9fc0838..697d638 100644 --- a/src/abis/SafientMain.json +++ b/src/abis/SafientMain.json @@ -1 +1 @@ -{"abi":[{"inputs":[{"internalType":"contract IArbitrator","name":"_arbitrator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"createdBy","type":"address"},{"indexed":true,"internalType":"string","name":"safeId","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"CreateClaim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"createdBy","type":"address"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":true,"internalType":"uint256","name":"metaEvidenceId","type":"uint256"}],"name":"CreateSafe","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IArbitrator","name":"_arbitrator","type":"address"},{"indexed":true,"internalType":"uint256","name":"_disputeID","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_metaEvidenceID","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_evidenceGroupID","type":"uint256"}],"name":"Dispute","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IArbitrator","name":"_arbitrator","type":"address"},{"indexed":true,"internalType":"uint256","name":"_evidenceGroupID","type":"uint256"},{"indexed":true,"internalType":"address","name":"_party","type":"address"},{"indexed":false,"internalType":"string","name":"_evidence","type":"string"}],"name":"Evidence","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_metaEvidenceID","type":"uint256"},{"indexed":false,"internalType":"string","name":"_evidence","type":"string"}],"name":"MetaEvidence","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IArbitrator","name":"_arbitrator","type":"address"},{"indexed":true,"internalType":"uint256","name":"_disputeID","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_ruling","type":"uint256"}],"name":"Ruling","type":"event"},{"inputs":[],"name":"arbitrator","outputs":[{"internalType":"contract IArbitrator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_funds","type":"uint256"}],"name":"claimRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"claims","outputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address","name":"claimedBy","type":"address"},{"internalType":"enum Types.ClaimType","name":"claimType","type":"uint8"},{"internalType":"uint256","name":"metaEvidenceId","type":"uint256"},{"internalType":"uint256","name":"evidenceGroupId","type":"uint256"},{"internalType":"enum Types.ClaimStatus","name":"status","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimsCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_safeId","type":"string"},{"internalType":"string","name":"_evidence","type":"string"}],"name":"createClaim","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_beneficiary","type":"address"},{"internalType":"string","name":"_safeId","type":"string"},{"internalType":"enum Types.ClaimType","name":"_claimType","type":"uint8"},{"internalType":"uint256","name":"_signalingPeriod","type":"uint256"},{"internalType":"uint256","name":"_DDay","type":"uint256"},{"internalType":"string","name":"_metaEvidence","type":"string"}],"name":"createSafe","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"_safeId","type":"string"}],"name":"depositFunds","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"evidenceGroupID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_safeId","type":"string"},{"internalType":"uint256","name":"_claimId","type":"uint256"}],"name":"getClaimStatus","outputs":[{"internalType":"enum Types.ClaimStatus","name":"status","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_message","type":"string"},{"internalType":"bytes","name":"_signature","type":"bytes"},{"components":[{"internalType":"bytes32","name":"secretHash","type":"bytes32"},{"internalType":"address","name":"guardianAddress","type":"address"}],"internalType":"struct Types.RecoveryProof[]","name":"_guardianproof","type":"tuple[]"},{"internalType":"string[]","name":"_secrets","type":"string[]"},{"internalType":"string","name":"_safeId","type":"string"}],"name":"guardianProof","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"guardianRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"metaEvidenceID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_disputeID","type":"uint256"},{"internalType":"uint256","name":"_ruling","type":"uint256"}],"name":"rule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rulingOptions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"safes","outputs":[{"internalType":"string","name":"id","type":"string"},{"internalType":"address","name":"createdBy","type":"address"},{"internalType":"address","name":"currentOwner","type":"address"},{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"uint256","name":"signalingPeriod","type":"uint256"},{"internalType":"uint256","name":"endSignalTime","type":"uint256"},{"internalType":"uint256","name":"latestSignalTime","type":"uint256"},{"internalType":"uint256","name":"dDay","type":"uint256"},{"internalType":"enum Types.ClaimType","name":"claimType","type":"uint8"},{"internalType":"uint256","name":"metaEvidenceId","type":"uint256"},{"internalType":"uint256","name":"claimsCount","type":"uint256"},{"internalType":"uint256","name":"funds","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"safesCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_safeId","type":"string"}],"name":"sendSignal","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_disputeID","type":"uint256"},{"internalType":"string","name":"_evidence","type":"string"}],"name":"submitEvidence","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_creator","type":"address"},{"internalType":"string","name":"_safeId","type":"string"},{"internalType":"enum Types.ClaimType","name":"_claimType","type":"uint8"},{"internalType":"uint256","name":"_signalingPeriod","type":"uint256"},{"internalType":"uint256","name":"_DDay","type":"uint256"},{"internalType":"string","name":"_metaEvidence","type":"string"}],"name":"syncSafe","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"_safeId","type":"string"},{"internalType":"uint256","name":"_DDay","type":"uint256"}],"name":"updateDDay","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_safeId","type":"string"}],"name":"withdrawFunds","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]} \ No newline at end of file +{"abi":[{"inputs":[{"internalType":"contract IArbitrator","name":"_arbitrator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"safeId","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timeStamp","type":"uint256"}],"name":"CreateClaim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"createdBy","type":"address"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":true,"internalType":"uint256","name":"metaEvidenceId","type":"uint256"}],"name":"CreateSafe","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IArbitrator","name":"_arbitrator","type":"address"},{"indexed":true,"internalType":"uint256","name":"_disputeID","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_metaEvidenceID","type":"uint256"}],"name":"Dispute","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IArbitrator","name":"_arbitrator","type":"address"},{"indexed":true,"internalType":"uint256","name":"_evidenceGroupID","type":"uint256"},{"indexed":true,"internalType":"address","name":"_party","type":"address"},{"indexed":false,"internalType":"string","name":"_evidence","type":"string"}],"name":"Evidence","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_metaEvidenceID","type":"uint256"},{"indexed":false,"internalType":"string","name":"_evidence","type":"string"}],"name":"MetaEvidence","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IArbitrator","name":"_arbitrator","type":"address"},{"indexed":true,"internalType":"uint256","name":"_disputeID","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_ruling","type":"uint256"}],"name":"Ruling","type":"event"},{"inputs":[],"name":"arbitrator","outputs":[{"internalType":"contract IArbitrator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_funds","type":"uint256"}],"name":"claimRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"claims","outputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address","name":"claimedBy","type":"address"},{"internalType":"enum Types.ClaimType","name":"claimType","type":"uint8"},{"internalType":"uint256","name":"metaEvidenceId","type":"uint256"},{"internalType":"uint256","name":"evidenceGroupId","type":"uint256"},{"internalType":"enum Types.ClaimStatus","name":"status","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimsCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_safeId","type":"string"},{"internalType":"string","name":"_evidence","type":"string"}],"name":"createClaim","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_beneficiary","type":"address"},{"internalType":"string","name":"_safeId","type":"string"},{"internalType":"enum Types.ClaimType","name":"_claimType","type":"uint8"},{"internalType":"uint256","name":"_signalingPeriod","type":"uint256"},{"internalType":"uint256","name":"_DDay","type":"uint256"},{"internalType":"string","name":"_metaEvidence","type":"string"}],"name":"createSafe","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"_safeId","type":"string"}],"name":"depositFunds","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"evidenceGroupID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_safeId","type":"string"},{"internalType":"uint256","name":"_claimId","type":"uint256"}],"name":"getClaimStatus","outputs":[{"internalType":"enum Types.ClaimStatus","name":"status","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_message","type":"string"},{"internalType":"bytes","name":"_signature","type":"bytes"},{"components":[{"internalType":"bytes32","name":"secretHash","type":"bytes32"},{"internalType":"address","name":"guardianAddress","type":"address"}],"internalType":"struct Types.RecoveryProof[]","name":"_guardianproof","type":"tuple[]"},{"internalType":"string[]","name":"_secrets","type":"string[]"},{"internalType":"string","name":"_safeId","type":"string"}],"name":"guardianProof","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"guardianRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"metaEvidenceID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_disputeID","type":"uint256"},{"internalType":"uint256","name":"_ruling","type":"uint256"}],"name":"rule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rulingOptions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"safes","outputs":[{"internalType":"string","name":"id","type":"string"},{"internalType":"address","name":"createdBy","type":"address"},{"internalType":"address","name":"currentOwner","type":"address"},{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"uint256","name":"signalingPeriod","type":"uint256"},{"internalType":"uint256","name":"endSignalTime","type":"uint256"},{"internalType":"uint256","name":"latestSignalTime","type":"uint256"},{"internalType":"uint256","name":"dDay","type":"uint256"},{"internalType":"enum Types.ClaimType","name":"claimType","type":"uint8"},{"internalType":"uint256","name":"metaEvidenceId","type":"uint256"},{"internalType":"uint256","name":"claimsCount","type":"uint256"},{"internalType":"uint256","name":"funds","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"safesCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_safeId","type":"string"}],"name":"sendSignal","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_disputeID","type":"uint256"},{"internalType":"string","name":"_evidence","type":"string"}],"name":"submitEvidence","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_creator","type":"address"},{"internalType":"string","name":"_safeId","type":"string"},{"internalType":"enum Types.ClaimType","name":"_claimType","type":"uint8"},{"internalType":"uint256","name":"_signalingPeriod","type":"uint256"},{"internalType":"uint256","name":"_DDay","type":"uint256"},{"internalType":"string","name":"_metaEvidence","type":"string"}],"name":"syncSafe","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"_safeId","type":"string"},{"internalType":"uint256","name":"_DDay","type":"uint256"}],"name":"updateDDay","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_safeId","type":"string"}],"name":"withdrawFunds","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]} \ No newline at end of file diff --git a/src/utils/networks.json b/src/utils/networks.json index 7549946..4c7b654 100644 --- a/src/utils/networks.json +++ b/src/utils/networks.json @@ -23,8 +23,8 @@ "kovan": { "chainId": 42, "addresses": { - "AutoAppealableArbitrator": "0x823E2b7623aD287819674548f43F8965F38B2626", - "SafientMain": "0x8C2FA3dE952f5A1c463af0Fb42a9A812D3Ffe9e3" + "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", + "SafientMain": "0xF88915c8762aB973b64086221cDFd20Ec104F732" } }, "ropsten": { diff --git a/test/claims.js b/test/claims.js index 281fdf6..40959c3 100644 --- a/test/claims.js +++ b/test/claims.js @@ -337,7 +337,7 @@ describe('SafientMain', async () => { // create a claim - before D-Day (claim should fail) const tx1 = await safientMain.connect(beneficiary).createClaim(safeId4, ''); const txReceipt1 = await tx1.wait(); - const claimId1 = txReceipt1.events[0].args[2]; + const claimId1 = txReceipt1.events[0].args[1]; const claimID1 = parseInt(claimId1._hex); // check claim status (DDayBased) @@ -355,7 +355,7 @@ describe('SafientMain', async () => { // create a claim - before D-Day (claim should pass) const tx2 = await safientMain.connect(beneficiary).createClaim(safeId4, ''); const txReceipt2 = await tx2.wait(); - const claimId2 = txReceipt2.events[0].args[2]; + const claimId2 = txReceipt2.events[0].args[1]; const claimID2 = parseInt(claimId2._hex); // check claim status (DDayBased) @@ -391,7 +391,7 @@ describe('SafientMain', async () => { // create a claim - before D-Day (6 seconds) (claim should fail) const tx1 = await safientMain.connect(beneficiary).createClaim(safeId5, ''); const txReceipt1 = await tx1.wait(); - const claimId1 = txReceipt1.events[0].args[2]; + const claimId1 = txReceipt1.events[0].args[1]; const claimID1 = parseInt(claimId1._hex); // check claim status (DDayBased) @@ -416,7 +416,7 @@ describe('SafientMain', async () => { // create a claim - before D-Day (12 seconds) (claim should fail) const tx2 = await safientMain.connect(beneficiary).createClaim(safeId5, ''); const txReceipt2 = await tx2.wait(); - const claimId2 = txReceipt2.events[0].args[2]; + const claimId2 = txReceipt2.events[0].args[1]; const claimID2 = parseInt(claimId2._hex); // check claim status (DDayBased) @@ -434,7 +434,7 @@ describe('SafientMain', async () => { // create a claim - after D-Day (10 + 2 = 12 seconds) (claim should pass) const tx3 = await safientMain.connect(beneficiary).createClaim(safeId5, ''); const txReceipt3 = await tx3.wait(); - const claimId3 = txReceipt3.events[0].args[2]; + const claimId3 = txReceipt3.events[0].args[1]; const claimID3 = parseInt(claimId3._hex); // check claim status (DDayBased)