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 04efee1 commit 86a3a6b
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 @@ -9,6 +9,7 @@ import {
ExtendedContractData,
L2Block,
L2BlockL2Logs,
L2Tx,
NotePreimage,
Tx,
TxExecutionRequest,
Expand Down Expand Up @@ -43,6 +44,7 @@ export function getHttpRpcServer(aztecRpcServer: AztecRPC): JsonRpcServer {
NotePreimage,
AuthWitness,
L2Block,
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 @@ -5,6 +5,7 @@ import {
ContractData,
ExtendedContractData,
L2BlockL2Logs,
L2Tx,
NotePreimage,
Tx,
TxExecutionRequest,
Expand Down Expand Up @@ -138,6 +139,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. Returns only data
* encrypted for the specified owner that has been already decrypted by the RPC server. Note that there
Expand Down

0 comments on commit 86a3a6b

Please sign in to comment.