Skip to content

Commit 548725b

Browse files
added update budget and payout schedule events
1 parent 940cc16 commit 548725b

File tree

2 files changed

+76
-2
lines changed

2 files changed

+76
-2
lines changed

src/eventGenerator.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const DEPOSIT_REFUNDED = "DepositRefunded(bytes32,string,address,string,uint256,
44
const BOUNTY_CLOSED = "BountyClosed(string,address,string,address,uint256,uint256,bytes,uint256)"
55
const TOKEN_BALANCE_CLAIMED = "TokenBalanceClaimed(string,address,string,address,uint256,address,uint256,uint256,bytes,uint256)"
66
const SUPPORTING_DOCUMENTS_COMPLETE_SET = "SupportingDocumentsCompleteSet(address,uint256,bytes,uint256)";
7+
const PAYOUT_SCHEDULE_UPDATED = "PayoutScheduleUpdated(string,address,string,address,uint256,uint256,bytes,uint256)";
8+
const FUNDING_GOAL_SET = "FundingGoalSet(string,address,string,address,uint256,uint256,bytes,uint256)";
79

810
require('dotenv').config()
911

@@ -29,6 +31,11 @@ const eventGenerator = (eventType: string, params: any) => {
2931
case "SupportingDocumentsCompleteSet":
3032
signature = SUPPORTING_DOCUMENTS_COMPLETE_SET
3133
break;
34+
case "PayoutScheduleUpdated":
35+
signature = PAYOUT_SCHEDULE_UPDATED
36+
break;
37+
case "FundingGoalSet":
38+
signature = FUNDING_GOAL_SET
3239
default:
3340
throw new Error()
3441
}

src/index.ts

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ const claimManager = new ethers.Contract(
3838
) as ClaimManagerV1;
3939

4040
const BountyCreatedFilter = openQ.filters.BountyCreated();
41-
41+
const PayoutScheduleUpdatedFilter = openQ.filters.PayoutScheduleSet();
42+
const FundingGoalSetFilter = openQ.filters.FundingGoalSet();
4243
const SupportingDocumentsCompleteSetFilter =
4344
openQ.filters.SupportingDocumentsCompleteSet();
4445
const TokenDepositReceivedFilter =
@@ -90,6 +91,72 @@ async function main() {
9091
}
9192
}
9293
);
94+
openQ.on(
95+
FundingGoalSetFilter,
96+
async (
97+
bountyAddress,
98+
fundingGoalTokenAddress,
99+
fundingGoalVolume,
100+
bountyType,
101+
data,
102+
version
103+
) => {
104+
const headers = {
105+
Authorization: process.env.OPENQ_API_SECRET,
106+
};
107+
108+
try {
109+
const result = await axios.post(
110+
`${process.env.OPENQ_BOUNTY_ACTIONS_AUTOTASK_URL}`,
111+
112+
eventGenerator("FundingGoalSet", {
113+
bountyAddress,
114+
fundingGoalTokenAddress,
115+
fundingGoalVolume,
116+
bountyType,
117+
data,
118+
version
119+
}),
120+
{ headers: headers as AxiosRequestHeaders }
121+
);
122+
} catch (error: any) {
123+
console.error(error.response);
124+
}
125+
}
126+
);
127+
openQ.on(
128+
PayoutScheduleUpdatedFilter,
129+
async (
130+
bountyAddress,
131+
payoutTokenAddress,
132+
payoutSchedule,
133+
bountyType,
134+
data,
135+
version
136+
) => {
137+
const headers = {
138+
Authorization: process.env.OPENQ_API_SECRET,
139+
};
140+
141+
try {
142+
const result = await axios.post(
143+
`${process.env.OPENQ_BOUNTY_ACTIONS_AUTOTASK_URL}`,
144+
145+
eventGenerator("PayoutScheduleUpdated", {
146+
bountyAddress,
147+
payoutTokenAddress,
148+
payoutSchedule,
149+
bountyType,
150+
data,
151+
version,
152+
}),
153+
{ headers: headers as AxiosRequestHeaders }
154+
);
155+
} catch (error: any) {
156+
console.error(error.response);
157+
}
158+
}
159+
);
93160
openQ.on(
94161
SupportingDocumentsCompleteSetFilter,
95162
async (bountyAddress, bountyType, data, version) => {
@@ -110,7 +177,7 @@ async function main() {
110177
{ headers: headers as AxiosRequestHeaders }
111178
);
112179
} catch (error: any) {
113-
console.log(error, "early")
180+
console.log(error, "early");
114181
console.error(error.response);
115182
}
116183
}

0 commit comments

Comments
 (0)