Skip to content

Commit

Permalink
feat: expose transaction data from AztecRPC (#2469)
Browse files Browse the repository at this point in the history
This PR relates to #1501 and makes transaction information available to
consumers of `AztecRPC`.

Fix #1501 

# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [ ] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).
  • Loading branch information
alexghr authored Sep 26, 2023
1 parent 3af0753 commit fc00553
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 fc00553

Please sign in to comment.