-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(evm-api): implement
eth_getUncleByBlockHashAndIndex
(#789)
* Add eth_getUncleByBlockHashAndIndex * Register handler * Fix schema
- Loading branch information
1 parent
954ccf3
commit 47ab48b
Showing
3 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
packages/api-evm/source/actions/eth-get-uncle-by-block-hash-and-index.ts
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,28 @@ | ||
import { inject, injectable } from "@mainsail/container"; | ||
import { Contracts, Exceptions, Identifiers } from "@mainsail/contracts"; | ||
|
||
@injectable() | ||
export class EthGetUncleByBlockHashAndIndex implements Contracts.Api.RPC.Action { | ||
@inject(Identifiers.Database.Service) | ||
private readonly databaseService!: Contracts.Database.DatabaseService; | ||
|
||
public readonly name: string = "eth_getUncleByBlockHashAndIndex"; | ||
|
||
public readonly schema = { | ||
$id: `jsonRpc_${this.name}`, | ||
maxItems: 2, | ||
minItems: 2, | ||
|
||
prefixItems: [{ $ref: "prefixedHex" }, { $ref: "prefixedHex" }], // TODO: Replace prefixedHex with prefixedBlockId | ||
type: "array", | ||
}; | ||
|
||
public async handle(parameters: [string]): Promise<null> { | ||
if (!this.databaseService.hasCommitById(parameters[0].slice(2))) { | ||
throw new Exceptions.RpcError("Block not found"); | ||
} | ||
|
||
// eslint-disable-next-line unicorn/no-null | ||
return null; | ||
} | ||
} |
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