-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement request-submitted handler
- Loading branch information
1 parent
4ca2aa6
commit 9171572
Showing
8 changed files
with
193 additions
and
19 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
export default () => async () => { | ||
// TODO: Add to request o watchlist. | ||
import { ethers } from "ethers" | ||
import { BigNumber } from "ethers/utils" | ||
|
||
export default (db: Level, tcr: ethers.Contract) => async ( | ||
_itemID: string, | ||
_requestIndex: BigNumber, | ||
_requestType: number | ||
) => { | ||
const challengePeriodDuration = await tcr.challengePeriodDuration() | ||
const { submissionTime } = await tcr.getRequestInfo(_itemID, _requestIndex) | ||
|
||
await db.put(tcr.address, { | ||
...(await db.get(tcr.address)), | ||
[_itemID]: submissionTime.add(challengePeriodDuration).toString() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
declare module 'level' | ||
|
||
interface BlockInterval { | ||
fromBlock: number | ||
toBlock: number | ||
} | ||
|
||
interface Level { | ||
get: Function | ||
put: Function | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Wrap level.get and level.put to parse and stringify JSON values. | ||
export default function wrapLevel(db: Level) { | ||
return ({ | ||
get: async (key: string) => JSON.parse(await db.get(key)), | ||
put: async (key: string, value: object) => db.put(key, JSON.stringify(value)) | ||
}) | ||
} |
Oops, something went wrong.