-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle ProposeDisputed event (#21)
# 🤖 Linear Closes GRT-83 ## Description Handles the `ResposeDisputed` event.
- Loading branch information
Showing
9 changed files
with
418 additions
and
120 deletions.
There are no files selected for viewing
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
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
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,79 @@ | ||
import { BlockNumberService } from "@ebo-agent/blocknumber"; | ||
import { Caip2ChainId } from "@ebo-agent/blocknumber/dist/types"; | ||
import { ILogger } from "@ebo-agent/shared"; | ||
|
||
import { EboActor } from "../../../src/eboActor"; | ||
import { EboMemoryRegistry } from "../../../src/eboMemoryRegistry"; | ||
import { ProtocolProvider } from "../../../src/protocolProvider"; | ||
import { Request, Response } from "../../../src/types/prophet"; | ||
import { DEFAULT_MOCKED_PROTOCOL_CONTRACTS } from "../fixtures"; | ||
|
||
/** | ||
* Builds a base `EboActor` scaffolded with all its dependencies. | ||
* | ||
* @param request a `Request` to populate the `EboActor` with | ||
* @param logger logger | ||
* @returns | ||
*/ | ||
function buildEboActor(request: Request, logger: ILogger) { | ||
const { id, chainId, epoch, epochTimestamp } = request; | ||
|
||
const protocolProviderRpcUrls = ["http://localhost:8538"]; | ||
const protocolProvider = new ProtocolProvider( | ||
protocolProviderRpcUrls, | ||
DEFAULT_MOCKED_PROTOCOL_CONTRACTS, | ||
); | ||
|
||
const blockNumberRpcUrls = new Map<Caip2ChainId, string[]>([ | ||
[chainId, ["http://localhost:8539"]], | ||
]); | ||
const blockNumberService = new BlockNumberService(blockNumberRpcUrls, logger); | ||
|
||
const registry = new EboMemoryRegistry(); | ||
|
||
const actor = new EboActor( | ||
{ id, epoch, epochTimestamp }, | ||
protocolProvider, | ||
blockNumberService, | ||
registry, | ||
logger, | ||
); | ||
|
||
return { | ||
actor, | ||
protocolProvider, | ||
blockNumberService, | ||
registry, | ||
logger, | ||
}; | ||
} | ||
|
||
/** | ||
* Helper function to build a response based on a request. | ||
* | ||
* @param request the `Request` to base the response on | ||
* @param attributes custom attributes to set into the response to build | ||
* @returns a `Response` | ||
*/ | ||
function buildResponse(request: Request, attributes: Partial<Response> = {}): Response { | ||
const baseResponse: Response = { | ||
id: "0x01", | ||
wasDisputed: false, | ||
prophetData: { | ||
proposer: "0x01", | ||
requestId: request.id, | ||
response: { | ||
chainId: request.chainId, | ||
block: 1n, | ||
epoch: request.epoch, | ||
}, | ||
}, | ||
}; | ||
|
||
return { | ||
...baseResponse, | ||
...attributes, | ||
}; | ||
} | ||
|
||
export default { buildEboActor, buildResponse }; |
Oops, something went wrong.