remove caller ctx in docs, add notice to existing methods#81
Conversation
WalkthroughThis pull request removes documentation and examples related to caller context management and multi-user testing from the simulator README, while adding consistent JSDoc security warnings across the simulator API classes clarifying that ChangesWitness Value Security Documentation
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/simulator/README.md`:
- Around line 206-218: The test snippet uses a one-arg constructor new
MyContractSimulator(val) but the earlier "Extending the Base Simulator" example
defines a two-argument constructor; update the test to call MyContractSimulator
with the same two-arg signature used earlier (e.g., pass the initial value and
the second required parameter such as the owner/signer or a default/mock) so the
example is consistent and copy/pasteable, and ensure the README text around the
snippet explains the second parameter if it isn't obvious.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cbf6f19b-660b-470b-b856-c184e304eca2
📒 Files selected for processing (3)
packages/simulator/README.mdpackages/simulator/src/core/AbstractSimulator.tspackages/simulator/src/core/ContractSimulator.ts
| let simulator: MyContractSimulator; | ||
| let val = 123n; | ||
| let newVal = 456n; | ||
|
|
||
| describe('MyContract', () => { | ||
| beforeEach(() => { | ||
| simulator = new MyContractSimulator( | ||
| zOwner, | ||
| { privateState: MyPrivateState.generate() } | ||
| ); | ||
| simulator = new MyContractSimulator(val); | ||
| }); | ||
|
|
||
| it('should transfer ownership', () => { | ||
| let newOwner = '0'.repeat(63) + '2'; | ||
| let zNewOwner = { bytes: encodeCoinPublicKey(newOwner) }; | ||
|
|
||
| simulator.as(owner).transferOwnership(zNewOwner); | ||
|
|
||
| expect(simulator.getPublicState()._owner).toEqual(zNewOwner); | ||
| it('should set new value', () => { | ||
| simulator.setVal(newVal); | ||
| expect(simulator.getPublicState()._val).toEqual(newVal); | ||
| }); |
There was a problem hiding this comment.
Keep test snippet constructor usage consistent with earlier class example.
Line 212 currently uses new MyContractSimulator(val), but the earlier “Extending the Base Simulator” example defines a two-arg constructor. This can confuse readers and break copy/paste flows.
Suggested doc fix
- simulator = new MyContractSimulator(val);
+ simulator = new MyContractSimulator(val, 'example-arg2');📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let simulator: MyContractSimulator; | |
| let val = 123n; | |
| let newVal = 456n; | |
| describe('MyContract', () => { | |
| beforeEach(() => { | |
| simulator = new MyContractSimulator( | |
| zOwner, | |
| { privateState: MyPrivateState.generate() } | |
| ); | |
| simulator = new MyContractSimulator(val); | |
| }); | |
| it('should transfer ownership', () => { | |
| let newOwner = '0'.repeat(63) + '2'; | |
| let zNewOwner = { bytes: encodeCoinPublicKey(newOwner) }; | |
| simulator.as(owner).transferOwnership(zNewOwner); | |
| expect(simulator.getPublicState()._owner).toEqual(zNewOwner); | |
| it('should set new value', () => { | |
| simulator.setVal(newVal); | |
| expect(simulator.getPublicState()._val).toEqual(newVal); | |
| }); | |
| let simulator: MyContractSimulator; | |
| let val = 123n; | |
| let newVal = 456n; | |
| describe('MyContract', () => { | |
| beforeEach(() => { | |
| simulator = new MyContractSimulator(val, 'example-arg2'); | |
| }); | |
| it('should set new value', () => { | |
| simulator.setVal(newVal); | |
| expect(simulator.getPublicState()._val).toEqual(newVal); | |
| }); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/simulator/README.md` around lines 206 - 218, The test snippet uses a
one-arg constructor new MyContractSimulator(val) but the earlier "Extending the
Base Simulator" example defines a two-argument constructor; update the test to
call MyContractSimulator with the same two-arg signature used earlier (e.g.,
pass the initial value and the second required parameter such as the
owner/signer or a default/mock) so the example is consistent and copy/pasteable,
and ensure the README text around the snippet explains the second parameter if
it isn't obvious.
|
LGTM! Thank you @andrew-fleming! |
Types of changes
What types of changes does your code introduce to OpenZeppelin Midnight Contracts?
Put an
xin the boxes that applyZOwnablePKin the contracts lib still uses the coin public key (+ secret nonce so it's not insecure) so the caller context logic in the simulator should not be removed yet (it'll break the ZOwnablePK tests)Summary by CodeRabbit
Release Notes