Skip to content

Commit

Permalink
feat: get transaction from AztecRPC
Browse files Browse the repository at this point in the history
  • Loading branch information
alexghr committed Sep 22, 2023
1 parent 747b92f commit d3ab1d4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ContractData,
ExtendedContractData,
L2BlockL2Logs,
L2Tx,
NotePreimage,
Tx,
TxExecutionRequest,
Expand Down Expand Up @@ -41,6 +42,7 @@ export function getHttpRpcServer(aztecRpcServer: AztecRPC): JsonRpcServer {
GrumpkinScalar,
NotePreimage,
AuthWitness,
L2Tx,
},
{ Tx, TxReceipt, L2BlockL2Logs },
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
KeyStore,
L2Block,
L2BlockL2Logs,
L2Tx,
LogType,
NodeInfo,
NotePreimage,
Expand Down Expand Up @@ -302,6 +303,10 @@ export class AztecRPCServer implements AztecRPC {
return new TxReceipt(txHash, TxStatus.DROPPED, 'Tx dropped by P2P node.');
}

public async getTx(txHash: TxHash): Promise<L2Tx | undefined> {
return await this.node.getTx(txHash);
}

async getBlockNumber(): Promise<number> {
return await this.node.getBlockNumber();
}
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/aztec.js/src/aztec_rpc_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
ContractData,
ExtendedContractData,
L2BlockL2Logs,
L2Tx,
NotePreimage,
Tx,
TxExecutionRequest,
Expand All @@ -31,6 +32,7 @@ export const createAztecRpcClient = (url: string, fetch = makeFetch([1, 2, 3], t
GrumpkinScalar,
NotePreimage,
AuthWitness,
L2Tx,
},
{ Tx, TxReceipt, L2BlockL2Logs },
false,
Expand Down
4 changes: 4 additions & 0 deletions yarn-project/aztec.js/src/wallet/base_wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ExtendedContractData,
FunctionCall,
L2BlockL2Logs,
L2Tx,
NodeInfo,
NotePreimage,
SyncStatus,
Expand Down Expand Up @@ -61,6 +62,9 @@ export abstract class BaseWallet implements Wallet {
sendTx(tx: Tx): Promise<TxHash> {
return this.rpc.sendTx(tx);
}
getTx(txHash: TxHash): Promise<L2Tx | undefined> {
return this.rpc.getTx(txHash);
}
getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
return this.rpc.getTxReceipt(txHash);
}
Expand Down
8 changes: 8 additions & 0 deletions yarn-project/types/src/interfaces/aztec_rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
ContractData,
ExtendedContractData,
L2BlockL2Logs,
L2Tx,
NotePreimage,
Tx,
TxExecutionRequest,
Expand Down Expand Up @@ -170,6 +171,13 @@ export interface AztecRPC {
*/
getTxReceipt(txHash: TxHash): Promise<TxReceipt>;

/**
* Fetches a transaction by its hash.
* @param txHash - The transaction hash
* @returns A transaction object or undefined if the transaction hasn't been mined yet
*/
getTx(txHash: TxHash): Promise<L2Tx | undefined>;

/**
* Retrieves the private storage data at a specified contract address and storage slot.
* The returned data is data at the storage slot or throws an error if the contract is not deployed.
Expand Down

0 comments on commit d3ab1d4

Please sign in to comment.