Skip to content

Commit

Permalink
subgraph backend working
Browse files Browse the repository at this point in the history
  • Loading branch information
fala13 committed Jun 1, 2024
1 parent 4634ae0 commit d25a17d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 21 deletions.
12 changes: 6 additions & 6 deletions packages/hardhat/contracts/Think2Earn.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ contract Think2Earn is Think2EarnBountyFactoryV1, ReentrancyGuard {
mapping(uint256 => Bounty) public bounties;
uint256 public bountyCount = 0; // Start counting bounties from 0

event EEGDataSubmitted(uint256 bountyId, uint256 submissionId, bytes32 eegDataHash);
event EEGDataSubmitted(uint256 bountyId, uint256 submissionId, address submitter, bytes32 eegDataHash);
event EtherDeposited(address sender, uint256 amount);
event PaymentMade(uint256 bountyId, uint256 submissionId, uint256 amount);
event BountyCreated(uint256 bountyId, string name, string description, uint256 reward, uint256 duration, uint256 judgeTime, uint256 maxProgress, address creator);
event BountyCreated(uint256 bountyId, string name, string description, string mediaURI, uint256 reward, uint256 duration, uint256 judgeTime, uint256 maxProgress, address creator);
event BountyCompleted(uint256 bountyId, uint256 numAcceptedSubmissions);

receive() external payable {
Expand All @@ -88,15 +88,15 @@ contract Think2Earn is Think2EarnBountyFactoryV1, ReentrancyGuard {
}));
submissionId = bounties[_bountyId].submissions.length;

emit EEGDataSubmitted(_bountyId, submissionId, _eegDataHash);
emit EEGDataSubmitted(_bountyId, submissionId, msg.sender, _eegDataHash);

return submissionId;
}

function createBounty(
string calldata _name,
string calldata _description,
string calldata _mediaURIHash, // Hash of the media URI
string calldata _mediaURI, // Hash of the media URI
uint256 _duration,
uint256 _judgeTime,
uint256 _maxProgress
Expand All @@ -108,7 +108,7 @@ contract Think2Earn is Think2EarnBountyFactoryV1, ReentrancyGuard {
Bounty storage newBounty = bounties[bountyCount];
newBounty.name = _name;
newBounty.description = _description;
newBounty.mediaURIHash = _mediaURIHash;
newBounty.mediaURIHash = _mediaURI;
newBounty.reward = msg.value;
newBounty.duration = _duration;
newBounty.judgeTime = _judgeTime;
Expand All @@ -117,7 +117,7 @@ contract Think2Earn is Think2EarnBountyFactoryV1, ReentrancyGuard {
newBounty.creator = msg.sender;
newBounty.isActive = true;

emit BountyCreated(bountyCount, _name, _description, msg.value, _duration, _judgeTime, _maxProgress, msg.sender);
emit BountyCreated(bountyCount, _name, _description, _mediaURI, msg.value, _duration, _judgeTime, _maxProgress, msg.sender);

activeBountyIds.push(bountyCount);
bountyCount++;
Expand Down
12 changes: 6 additions & 6 deletions packages/hardhat/contracts/YourContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ contract YourContract is Think2EarnBountyFactoryV1, ReentrancyGuard {
mapping(uint256 => Bounty) public bounties;
uint256 public bountyCount = 0; // Start counting bounties from 0

event EEGDataSubmitted(uint256 bountyId, uint256 submissionId, bytes32 eegDataHash);
event EEGDataSubmitted(uint256 bountyId, uint256 submissionId, address submitter, bytes32 eegDataHash);
event EtherDeposited(address sender, uint256 amount);
event PaymentMade(uint256 bountyId, uint256 submissionId, uint256 amount);
event BountyCreated(uint256 bountyId, string name, string description, uint256 reward, uint256 duration, uint256 judgeTime, uint256 maxProgress, address creator);
event BountyCreated(uint256 bountyId, string name, string description, string mediaURI, uint256 reward, uint256 duration, uint256 judgeTime, uint256 maxProgress, address creator);
event BountyCompleted(uint256 bountyId, uint256 numAcceptedSubmissions);

receive() external payable {
Expand All @@ -88,15 +88,15 @@ contract YourContract is Think2EarnBountyFactoryV1, ReentrancyGuard {
}));
submissionId = bounties[_bountyId].submissions.length;

emit EEGDataSubmitted(_bountyId, submissionId, _eegDataHash);
emit EEGDataSubmitted(_bountyId, submissionId, msg.sender, _eegDataHash);

return submissionId;
}

function createBounty(
string calldata _name,
string calldata _description,
string calldata _mediaURIHash, // Hash of the media URI
string calldata _mediaURI, // Hash of the media URI
uint256 _duration,
uint256 _judgeTime,
uint256 _maxProgress
Expand All @@ -108,7 +108,7 @@ contract YourContract is Think2EarnBountyFactoryV1, ReentrancyGuard {
Bounty storage newBounty = bounties[bountyCount];
newBounty.name = _name;
newBounty.description = _description;
newBounty.mediaURIHash = _mediaURIHash;
newBounty.mediaURIHash = _mediaURI;
newBounty.reward = msg.value;
newBounty.duration = _duration;
newBounty.judgeTime = _judgeTime;
Expand All @@ -117,7 +117,7 @@ contract YourContract is Think2EarnBountyFactoryV1, ReentrancyGuard {
newBounty.creator = msg.sender;
newBounty.isActive = true;

emit BountyCreated(bountyCount, _name, _description, msg.value, _duration, _judgeTime, _maxProgress, msg.sender);
emit BountyCreated(bountyCount, _name, _description, _mediaURI, msg.value, _duration, _judgeTime, _maxProgress, msg.sender);

activeBountyIds.push(bountyCount);
bountyCount++;
Expand Down
14 changes: 13 additions & 1 deletion packages/subgraph/abis/localhost_Think2Earn.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
"name": "description",
"type": "string"
},
{
"indexed": false,
"internalType": "string",
"name": "mediaURI",
"type": "string"
},
{
"indexed": false,
"internalType": "uint256",
Expand Down Expand Up @@ -88,6 +94,12 @@
"name": "submissionId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "submitter",
"type": "address"
},
{
"indexed": false,
"internalType": "bytes32",
Expand Down Expand Up @@ -270,7 +282,7 @@
},
{
"internalType": "string",
"name": "_mediaURIHash",
"name": "_mediaURI",
"type": "string"
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/subgraph/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"address": "0x5FbDB2315678afecb367f032d93F642f64180aa3"
},
"Think2Earn": {
"address": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707"
"address": "0x610178dA211FEF7D417bC0e6FeD39F05609AD788"
}
}
}
11 changes: 4 additions & 7 deletions packages/subgraph/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dataSources:
network: localhost
source:
abi: Think2Earn
address: "0x5FbDB2315678afecb367f032d93F642f64180aa3"
address: "0x610178dA211FEF7D417bC0e6FeD39F05609AD788"
mapping:
kind: ethereum/events
apiVersion: 0.0.6
Expand All @@ -23,18 +23,15 @@ dataSources:
abis:
- name: Think2Earn
file: abis/localhost_Think2Earn.json
# file: Think2Earn/abis/localhost_Think2Earn.json
eventHandlers:
- event: BountyCreated(uint256,string,string,uint256,uint256,uint256,uint256,address)
- event: BountyCreated(uint256,string,string,string,uint256,uint256,uint256,uint256,address)
handler: handleBountyCreated
- event: EEGDataSubmitted(uint256,uint256,bytes32)
- event: EEGDataSubmitted(uint256,uint256,address,bytes32)
handler: handleEEGDataSubmitted
- event: BountyCompleted(uint256,uint256)
handler: handleBountyCompleted
- event: EtherDeposited(address,uint256)
handler: handleEtherDeposited
- event: PaymentMade(uint256,uint256,uint256)
handler: handlePaymentMade
file: build/YourContract/YourContract.wasm
# file: Think2Earn/Think2Earn.wasm

file: src/mapping.ts

0 comments on commit d25a17d

Please sign in to comment.