refactor: extract shared identity/signer setup into helpers#38
refactor: extract shared identity/signer setup into helpers#38
Conversation
📝 WalkthroughWalkthroughCentralized identity key selection and signer creation into getIdentityKey, createSigner, and prepareTransition; replaced per-operation signer setup across data contract, document, and token operations; introduced DEFAULT_SECURITY_LEVELS and CONTRACT_SECURITY_LEVELS; expanded imports to include DataContract, Document, IdentitySigner, and Identifier. Net change: +85/-417 (−332 lines). Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Add prepareTransition, getIdentityKey, and createSigner helper functions to eliminate duplicated boilerplate across 18 state transition operations. Reduces app.js by ~330 lines while maintaining identical behavior. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@public/app.js`:
- Around line 1511-1540: The security-level arrays DEFAULT_SECURITY_LEVELS and
CONTRACT_SECURITY_LEVELS are using string values while getIdentityKey compares
against numeric k.securityLevel; update those constant arrays to use the numeric
enum values (e.g., 1,2,3 for Critical/High/Medium and 1,2 for Critical/High) so
the includes() check in getIdentityKey will succeed; verify no other code
expects string labels and adjust any references to DEFAULT_SECURITY_LEVELS or
CONTRACT_SECURITY_LEVELS accordingly.
🧹 Nitpick comments (1)
public/app.js (1)
2236-2238: Remove unusedidentityfrom destructuring.The
identityvariable is destructured but never used in this block—n.ownerIdis used directly for all identity-related operations. Consider matching the pattern used indataContractUpdate(line 2322).Suggested fix
- const { identity, identityKey, signer } = await prepareTransition( + const { identityKey, signer } = await prepareTransition( c, n.ownerId, n.privateKeyWif, n.keyId, CONTRACT_SECURITY_LEVELS );
b261636 to
72cab62
Compare
Add prepareTransition, getIdentityKey, and createSigner helper functions to eliminate duplicated boilerplate across 18 state transition operations.
Reduces app.js by ~330 lines while maintaining identical behavior.
All tests pass locally.
Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com
Summary by CodeRabbit