-
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_getUncleCountByBlockHash
(#787)
* Add EthGetUncleCountByBlockHash * Fix error handler * Add hasCommitById * Add block check * Slice block id * style: resolve style guide violations --------- Co-authored-by: sebastijankuzner <[email protected]>
- Loading branch information
1 parent
c616cfa
commit 7f6c7d0
Showing
7 changed files
with
43 additions
and
3 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
27 changes: 27 additions & 0 deletions
27
packages/api-evm/source/actions/eth-get-uncle-count-by-block-hash.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,27 @@ | ||
import { inject, injectable } from "@mainsail/container"; | ||
import { Contracts, Exceptions, Identifiers } from "@mainsail/contracts"; | ||
|
||
@injectable() | ||
export class EthGetUncleCountByBlockHash implements Contracts.Api.RPC.Action { | ||
@inject(Identifiers.Database.Service) | ||
private readonly databaseService!: Contracts.Database.DatabaseService; | ||
|
||
public readonly name: string = "eth_getUncleCountByBlockHash"; | ||
|
||
public readonly schema = { | ||
$id: `jsonRpc_${this.name}`, | ||
maxItems: 1, | ||
minItems: 1, | ||
|
||
prefixItems: [{ $ref: "prefixedHex" }], // TODO: Replace prefixedHex with prefixedBlockId | ||
type: "array", | ||
}; | ||
|
||
public async handle(parameters: [string]): Promise<string> { | ||
if (!this.databaseService.hasCommitById(parameters[0].slice(2))) { | ||
throw new Exceptions.RpcError("Block not found"); | ||
} | ||
|
||
return `0x0`; | ||
} | ||
} |
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