Description
contractMetadata (with src/contractMetadata.integration.test.ts) loads on-chain contract details, but the backend should pin and verify expected contract metadata so a swapped or unexpected escrow contract is rejected before any webhook-driven settlement action.
Requirements and context
- Pin expected contract hash/version per network; verify fetched metadata matches before use.
- On mismatch, refuse to operate and emit a safe error via
src/errors/safeErrors.ts; alert via metrics.
- Source expected values from validated
sorobanEnv.ts; document rotation procedure.
- Acceptance: integration test covers matching metadata (proceed) and mismatched metadata (reject).
Suggested execution
- Fork the repo and create a branch:
git checkout -b security/contract-metadata-pinning
- Implement changes:
src/contractMetadata.ts
- Tests:
src/contractMetadata.integration.test.ts
- Docs:
docs/backend
- Include TSDoc/NatSpec-style doc comments
- Validate security assumptions (input validation, auth, signature verification, secret redaction, idempotency)
Test and commit
- Run tests:
npm test (coverage: npm run test:ci)
- Cover edge cases
- Include test output and security notes in the PR
Example commit message
feat(stellar): pin and verify escrow contract metadata
Guidelines
- Minimum 95% line coverage on new/changed code
- No secrets in repo; use
.env + deployment secrets only
- Clear documentation
- Timeframe: 96 hours from assignment
Description
contractMetadata(withsrc/contractMetadata.integration.test.ts) loads on-chain contract details, but the backend should pin and verify expected contract metadata so a swapped or unexpected escrow contract is rejected before any webhook-driven settlement action.Requirements and context
src/errors/safeErrors.ts; alert via metrics.sorobanEnv.ts; document rotation procedure.Suggested execution
git checkout -b security/contract-metadata-pinningsrc/contractMetadata.tssrc/contractMetadata.integration.test.tsdocs/backendTest and commit
npm test(coverage:npm run test:ci)Example commit message
Guidelines
.env+ deployment secrets only