Skip to content

Commit

Permalink
Merge branch 'feat/refactor-list-transactions-with-starkscan' into ch…
Browse files Browse the repository at this point in the history
…ore/update-execute-txn-with-new-txn-data
  • Loading branch information
stanleyyconsensys committed Dec 10, 2024
2 parents bb69ff5 + df09180 commit 817e874
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 16 deletions.
10 changes: 3 additions & 7 deletions packages/starknet-snap/src/chain/transaction-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ describe('TransactionService', () => {
);
}

isTransactionHasSameContractOrAnDeploy(
tx: Transaction,
contractAddress: string,
) {
return super.isTransactionHasSameContractOrAnDeploy(tx, contractAddress);
hasMatchingContractOrIsDeploy(tx: Transaction, contractAddress: string) {
return super.hasMatchingContractOrIsDeploy(tx, contractAddress);
}
}

Expand Down Expand Up @@ -132,8 +129,7 @@ describe('TransactionService', () => {
const service = mockTransactionService(network, dataClient);

const filteredTransactions = transactionsFromDataClientOrState.filter(
(tx) =>
service.isTransactionHasSameContractOrAnDeploy(tx, contractAddress),
(tx) => service.hasMatchingContractOrIsDeploy(tx, contractAddress),
);

return {
Expand Down
4 changes: 2 additions & 2 deletions packages/starknet-snap/src/chain/transaction-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ export class TransactionService {
): AsyncGenerator<Transaction> {
for (const tx of transactions) {
// Only return transaction that are related to the contract address or a deployed transactions.
if (this.isTransactionHasSameContractOrAnDeploy(tx, contractAddress)) {
if (this.hasMatchingContractOrIsDeploy(tx, contractAddress)) {
yield tx;
}
}
}

protected isTransactionHasSameContractOrAnDeploy(
protected hasMatchingContractOrIsDeploy(
tx: Transaction,
contractAddress: string,
) {
Expand Down
4 changes: 2 additions & 2 deletions packages/starknet-snap/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import {
watchAsset,
getAddrFromStarkName,
getTransactionStatus,
ListTransactions,
listTransactions,
} from './rpcs';
import { signDeployAccountTransaction } from './signDeployAccountTransaction';
import type {
Expand Down Expand Up @@ -240,7 +240,7 @@ export const onRpcRequest: OnRpcRequestHandler = async ({
return await getStoredNetworks(apiParams);

case RpcMethod.GetTransactions:
return await ListTransactions.execute(
return await listTransactions.execute(
apiParams.requestParams as unknown as ListTransactionsParams,
);

Expand Down
8 changes: 4 additions & 4 deletions packages/starknet-snap/src/rpcs/list-transaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { InvalidRequestParamsError } from '../utils/exceptions';
import * as factory from '../utils/factory';
import { mockAccount } from './__tests__/helper';
import { ListTransactions } from './list-transactions';
import { listTransactions } from './list-transactions';
import type { ListTransactionsParams } from './list-transactions';

jest.mock('../utils/logger');
Expand Down Expand Up @@ -48,7 +48,7 @@ describe('listTransactions', () => {
const { transactions, getTransactionsSpy, chainId, account } =
await prepareListTransactions();

const result = await ListTransactions.execute({
const result = await listTransactions.execute({
chainId,
senderAddress: account.address,
contractAddress: ETHER_SEPOLIA_TESTNET.address,
Expand All @@ -67,7 +67,7 @@ describe('listTransactions', () => {
const { getTransactionsSpy, chainId, account } =
await prepareListTransactions();

await ListTransactions.execute({
await listTransactions.execute({
chainId,
senderAddress: account.address,
contractAddress: ETHER_SEPOLIA_TESTNET.address,
Expand All @@ -82,7 +82,7 @@ describe('listTransactions', () => {

it('throws `InvalidRequestParamsError` when request parameter is not correct', async () => {
await expect(
ListTransactions.execute({} as unknown as ListTransactionsParams),
listTransactions.execute({} as unknown as ListTransactionsParams),
).rejects.toThrow(InvalidRequestParamsError);
});
});
2 changes: 1 addition & 1 deletion packages/starknet-snap/src/rpcs/list-transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ export class ListTransactionsRpc extends ChainRpcController<
}
}

export const ListTransactions = new ListTransactionsRpc();
export const listTransactions = new ListTransactionsRpc();

0 comments on commit 817e874

Please sign in to comment.