-
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.
- Loading branch information
1 parent
cdb4d80
commit f19ea60
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
packages/api-evm/source/actions/eth-get-transaction-by-block-number-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,38 @@ | ||
import { inject, injectable } from "@mainsail/container"; | ||
import { Contracts, Identifiers } from "@mainsail/contracts"; | ||
|
||
import { TransactionResource } from "../resources/index.js"; | ||
|
||
@injectable() | ||
export class EthGetTransactionByBlockNumberAndIndex implements Contracts.Api.RPC.Action { | ||
@inject(Identifiers.Application.Instance) | ||
private readonly app!: Contracts.Kernel.Application; | ||
|
||
@inject(Identifiers.Database.Service) | ||
private readonly databaseService!: Contracts.Database.DatabaseService; | ||
|
||
public readonly name: string = "eth_getTransactionByBlockNumberAndIndex"; | ||
|
||
public readonly schema = { | ||
$id: `jsonRpc_${this.name}`, | ||
|
||
maxItems: 2, | ||
minItems: 2, | ||
|
||
prefixItems: [{ $ref: "prefixedHex" }, { $ref: "prefixedHex" }], // TODO: Use block id & limit sequence | ||
type: "array", | ||
}; | ||
|
||
public async handle(parameters: [string, string]): Promise<any> { | ||
const transaction = await this.databaseService.getTransactionByBlockIdAndIndex( | ||
parameters[0].slice(2), | ||
Number.parseInt(parameters[1]), | ||
); | ||
|
||
if (!transaction) { | ||
return null; | ||
} | ||
|
||
return this.app.resolve(TransactionResource).transform(transaction.data); | ||
} | ||
} |
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