diff --git a/yarn-project/aztec.js/src/contract/deploy_method.ts b/yarn-project/aztec.js/src/contract/deploy_method.ts index 92bbab14bc4..f028556ef44 100644 --- a/yarn-project/aztec.js/src/contract/deploy_method.ts +++ b/yarn-project/aztec.js/src/contract/deploy_method.ts @@ -81,6 +81,10 @@ export class DeployMethod extends Bas */ public async create(options: DeployOptions = {}): Promise { if (!this.txRequest) { + const calls = await this.request(options); + if (calls.length === 0) { + throw new Error(`No function calls needed to deploy contract ${this.artifact.name}`); + } this.txRequest = await this.wallet.createTxExecutionRequest(await this.request(options)); // TODO: Should we add the contracts to the DB here, or once the tx has been sent or mined? await this.pxe.addContracts([{ artifact: this.artifact, instance: this.instance! }]); diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts index d7c932ad855..b6ca78c82bb 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts @@ -503,13 +503,13 @@ describe('e2e_deploy_contract', () => { logger.debug(`Call a public function to check that it was publicly deployed`); const receipt = await contract.methods.emit_unencrypted(42).send().wait(); const logs = await pxe.getUnencryptedLogs({ txHash: receipt.txHash }); - expect(logs.logs[0].log.data.toString('hex')).toEqual('2a'); + expect(logs.logs[0].log.data.toString('hex').replace(/^0+/, '')).toEqual('2a'); }); - it('deploys a contract with no constructor and no public deployment as a noop', async () => { + it('refuses to deploy a contract with no constructor and no public deployment', async () => { logger.debug(`Deploying contract with no constructor and skipping public deploy`); const opts = { skipPublicDeployment: true, skipClassRegistration: true }; - await TestContract.deploy(wallet).send(opts).deployed(); + await expect(TestContract.deploy(wallet).simulate(opts)).rejects.toThrow(/no function calls needed/i); }); it.skip('publicly deploys and calls a public function in the same batched call', async () => {