diff --git a/packages/api-evm/source/actions/eth-get-uncle-by-block-hash-and-index.ts b/packages/api-evm/source/actions/eth-get-uncle-by-block-hash-and-index.ts new file mode 100644 index 000000000..672f67255 --- /dev/null +++ b/packages/api-evm/source/actions/eth-get-uncle-by-block-hash-and-index.ts @@ -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 { + if (!this.databaseService.hasCommitById(parameters[0].slice(2))) { + throw new Exceptions.RpcError("Block not found"); + } + + // eslint-disable-next-line unicorn/no-null + return null; + } +} diff --git a/packages/api-evm/source/actions/index.ts b/packages/api-evm/source/actions/index.ts index 4578f8bb0..b96fd1d10 100644 --- a/packages/api-evm/source/actions/index.ts +++ b/packages/api-evm/source/actions/index.ts @@ -6,6 +6,7 @@ export * from "./eth-get-block-by-number.js"; export * from "./eth-get-code.js"; export * from "./eth-get-storage-at.js"; export * from "./eth-get-transaction-count.js"; +export * from "./eth-get-uncle-by-block-hash-and-index.js"; export * from "./eth-get-uncle-count-by-block-hash.js"; export * from "./eth-get-uncle-count-by-block-number.js"; export * from "./net-listening.js"; diff --git a/packages/api-evm/source/service-provider.ts b/packages/api-evm/source/service-provider.ts index c225fef7a..40b0b871c 100644 --- a/packages/api-evm/source/service-provider.ts +++ b/packages/api-evm/source/service-provider.ts @@ -11,6 +11,7 @@ import { EthGetCodeAction, EthGetStorageAtAction, EthGetTransactionCount, + EthGetUncleByBlockHashAndIndex, EthGetUncleCountByBlockHash, EthGetUncleCountByBlockNumber, NetListeningAction, @@ -74,6 +75,7 @@ export class ServiceProvider extends AbstractServiceProvider { this.app.resolve(EthGetCodeAction), this.app.resolve(EthGetStorageAtAction), this.app.resolve(EthGetTransactionCount), + this.app.resolve(EthGetUncleByBlockHashAndIndex), this.app.resolve(EthGetUncleCountByBlockHash), this.app.resolve(EthGetUncleCountByBlockNumber), this.app.resolve(NetListeningAction),