Skip to content

Commit aad9443

Browse files
committed
refactor: rename addContracts -> addContractsFromLogs on PublicContractsDB
Makes the two insertion paths self-documenting: addContractsFromLogs() for raw log data arriving from C++ via the NAPI bridge, and addContractOverrides() for typed ContractClassPublic/ContractInstanceWithAddress objects from TS callers.
1 parent 1473e04 commit aad9443

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

yarn-project/simulator/src/public/public_db_sources.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export class PublicContractsDB implements PublicContractsDBInterface {
5656
this.log = createLogger('simulator:contracts-data-source', bindings);
5757
}
5858

59-
public addContracts(contractDeploymentData: ContractDeploymentData): void {
59+
/** Parses raw log data from the C++/NAPI bridge and inserts the resulting contracts into the current checkpoint. */
60+
public addContractsFromLogs(contractDeploymentData: ContractDeploymentData): void {
6061
const currentState = this.getCurrentState();
6162

6263
this.addContractClassesFromEvents(
@@ -72,8 +73,8 @@ export class PublicContractsDB implements PublicContractsDBInterface {
7273

7374
public addNewContracts(tx: Tx): void {
7475
const contractDeploymentData = AllContractDeploymentData.fromTx(tx);
75-
this.addContracts(contractDeploymentData.getNonRevertibleContractDeploymentData());
76-
this.addContracts(contractDeploymentData.getRevertibleContractDeploymentData());
76+
this.addContractsFromLogs(contractDeploymentData.getNonRevertibleContractDeploymentData());
77+
this.addContractsFromLogs(contractDeploymentData.getRevertibleContractDeploymentData());
7778
}
7879

7980
/** Injects contract class and instance overrides directly into the current checkpoint. */

yarn-project/simulator/src/public/public_tx_simulator/contract_provider_for_cpp.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ export class ContractProviderForCpp implements ContractProvider {
6161
// Construct ContractDeploymentData from plain object.
6262
const contractDeploymentData = ContractDeploymentData.fromPlainObject(rawData);
6363

64-
// Add contracts to the contracts DB
65-
this.log.trace(`Calling contractsDB.addContracts`);
66-
this.contractsDB.addContracts(contractDeploymentData);
64+
this.log.trace(`Calling contractsDB.addContractsFromLogs`);
65+
this.contractsDB.addContractsFromLogs(contractDeploymentData);
6766
};
6867

6968
public getBytecodeCommitment = async (classId: string): Promise<Buffer | undefined> => {

yarn-project/simulator/src/public/public_tx_simulator/public_tx_simulator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
401401
// However, things work as expected because later calls to getters on the hintingContractsDB
402402
// will pick up the new contracts and will generate the necessary hints.
403403
// So, a consumer of the hints will always see the new contracts.
404-
this.contractsDB.addContracts(context.nonRevertibleContractDeploymentData);
404+
this.contractsDB.addContractsFromLogs(context.nonRevertibleContractDeploymentData);
405405
}
406406

407407
/**
@@ -490,7 +490,7 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
490490
// However, things work as expected because later calls to getters on the hintingContractsDB
491491
// will pick up the new contracts and will generate the necessary hints.
492492
// So, a consumer of the hints will always see the new contracts.
493-
this.contractsDB.addContracts(context.revertibleContractDeploymentData);
493+
this.contractsDB.addContractsFromLogs(context.revertibleContractDeploymentData);
494494
}
495495

496496
private async payFee(context: PublicTxContext) {

0 commit comments

Comments
 (0)