Skip to content

Commit 62ad893

Browse files
author
sklppy88
committed
init
1 parent 9d3b351 commit 62ad893

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

yarn-project/pxe/src/database/contracts/contract_artifact_db.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface ContractArtifactDatabase {
99
* Adds a new contract artifact to the database or updates an existing one.
1010
* @param id - Id of the corresponding contract class.
1111
* @param contract - Contract artifact to add.
12+
* @throws - If there are duplicate private function selectors.
1213
*/
1314
addContractArtifact(id: Fr, contract: ContractArtifact): Promise<void>;
1415
/**

yarn-project/pxe/src/database/kv_pxe_database.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
type TaggingSecret,
1010
computePoint,
1111
} from '@aztec/circuits.js';
12-
import { type ContractArtifact } from '@aztec/foundation/abi';
12+
import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/foundation/abi';
1313
import { toBufferBE } from '@aztec/foundation/bigint-buffer';
1414
import { Fr } from '@aztec/foundation/fields';
1515
import {
@@ -129,6 +129,16 @@ export class KVPxeDatabase implements PxeDatabase {
129129
}
130130

131131
public async addContractArtifact(id: Fr, contract: ContractArtifact): Promise<void> {
132+
const privateSelectors = contract.functions
133+
.filter(functionArtifact => functionArtifact.functionType === FunctionType.PRIVATE)
134+
.map(privateFunctionArtifact =>
135+
FunctionSelector.fromNameAndParameters(privateFunctionArtifact.name, privateFunctionArtifact.parameters),
136+
);
137+
138+
if (privateSelectors.length !== new Set(privateSelectors).size) {
139+
throw new Error('Repeated function selectors of private functions');
140+
}
141+
132142
await this.#contractArtifacts.set(id.toString(), contractArtifactToBuffer(contract));
133143
}
134144

0 commit comments

Comments
 (0)