Skip to content

Conversation

@fazzatti
Copy link
Owner

@fazzatti fazzatti commented Dec 8, 2025

This pull request refactors the codebase to replace the TransactionSigner type with a more generic Signer type across all modules, and consolidates various "verifier" utility functions under a new "type-guards" directory for improved clarity and maintainability. It also introduces new utility type guards and removes redundant code. These changes enhance type safety, code organization, and future extensibility.

Type system and API refactor:

  • Replaced all usages of TransactionSigner with the more general Signer type in account, asset, and transaction config modules, including method signatures and type definitions (core/account/native/index.ts, core/account/native/types.ts, core/asset/sac/index.integration.test.ts, core/asset/sac/index.ts, core/common/types/transaction-config/types.ts) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10].

Type guard consolidation and improvements:

  • Moved all "verifier" functions to a new "type-guards" directory, updating imports and exports throughout the codebase (core/common/index.ts, core/common/type-guards/index.ts, core/common/type-guards/index.unit.test.ts, core/common/type-guards/is-smart-contract-transaction.ts, core/common/verifiers/index.ts, core/common/verifiers/is-defined.ts, core/common/verifiers/is-transaction-signer.ts) [1] [2] [3] [4] [5] [6] [7].

  • Added new type guard utilities: isDefined, hasFunction, and isSigner for more robust runtime type checking (core/common/type-guards/is-defined.ts, core/common/type-guards/has-function.ts, core/common/type-guards/is-signer.ts) [1] [2] [3].

Version update:

  • Bumped the package version to 0.13.0 in core/deno.json to reflect these breaking and structural changes.

@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

❌ Patch coverage is 89.75904% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.10%. Comparing base (45f4a1d) to head (39a3c30).
⚠️ Report is 7 commits behind head on dev.

Files with missing lines Patch % Lines
core/common/type-guards/is-signer.ts 18.18% 9 Missing ⚠️
core/common/type-guards/has-function.ts 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev      #47      +/-   ##
==========================================
+ Coverage   99.01%   99.10%   +0.09%     
==========================================
  Files         144      147       +3     
  Lines        7175     7285     +110     
  Branches      732      733       +1     
==========================================
+ Hits         7104     7220     +116     
+ Misses         71       65       -6     
Flag Coverage Δ
unittests 99.10% <89.75%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
core/account/native/index.ts 100.00% <100.00%> (ø)
core/asset/sac/index.ts 100.00% <100.00%> (ø)
core/common/index.ts 100.00% <100.00%> (ø)
core/common/type-guards/index.ts 100.00% <100.00%> (ø)
core/common/type-guards/is-defined.ts 100.00% <100.00%> (ø)
core/common/type-guards/is-fee-bump-transaction.ts 100.00% <ø> (ø)
core/common/type-guards/is-muxed-id.ts 100.00% <ø> (ø)
core/common/type-guards/is-signing-threshold.ts 100.00% <ø> (ø)
...ommon/type-guards/is-smart-contract-transaction.ts 100.00% <100.00%> (ø)
core/common/type-guards/is-transaction.ts 100.00% <ø> (ø)
... and 15 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the signer infrastructure to enable indirect signing capabilities, where a signer can sign on behalf of multiple targets (public keys or contract IDs) beyond just its own public key. The changes include renaming TransactionSigner to Signer, adding target management to LocalSigner, reorganizing type guards from the verifiers directory to type-guards, and enhancing the isDefined utility to check for both undefined and null.

  • Introduced signsFor() method to the Signer interface for flexible target-based signing
  • Added target management methods (addTarget, removeTarget, getTargets) to LocalSigner
  • Enhanced isDefined type guard to check for both null and undefined (previously only undefined)
  • Created new error handling classes for signer operations (SECRET_NOT_ACCESSIBLE, SIGNER_DESTROYED, CANNOT_REMOVE_MASTER_TARGET)

Reviewed changes

Copilot reviewed 42 out of 46 changed files in this pull request and generated no comments.

Show a summary per file
File Description
core/deno.json Version bump to 0.13.0
plugins/fee-bump/deno.json Version bump to 0.5.0, updated core dependency to ^0.13.0
event-streamer/deno.json Version bump to 0.4.0, updated core dependency to ^0.13.0
core/signer/types.ts Renamed TransactionSigner to Signer, added signsFor() method and ContractId support
core/signer/local/types.ts Updated to use Signer type
core/signer/local/index.ts Added target management, secretKey() method with hiding option, updated error handling
core/signer/local/index.unit.test.ts Comprehensive tests for new target management and secretKey features
core/signer/local/error.ts New error classes for local signer operations
core/signer/error.ts Base error class for signer domain
core/common/type-guards/is-defined.ts Enhanced to check both null and undefined
core/common/type-guards/is-signer.ts New type guard for Signer interface including signsFor
core/common/type-guards/has-function.ts Helper for checking function existence on objects
core/common/type-guards/*.ts Moved from verifiers directory with updated implementations
core/common/verifiers/* Removed in favor of type-guards
core/common/index.ts Updated exports to use type-guards
core/processes/sign-envelope/* Updated to use Signer type and signsFor() method
core/processes/sign-auth-entries/* Updated to use Signer type and signsFor() method
core/processes/wrap-fee-bump/* Updated imports to use type-guards
core/processes/envelope-signing-requirements/* Updated imports to use type-guards
core/processes/assemble-transaction/index.ts Updated imports to use type-guards
core/transformers/pipeline-connectors/index.unit.test.ts Updated imports to use type-guards
core/network/index.ts Updated imports to use type-guards
core/event/parsing/ledger-close-meta.ts Updated imports to use type-guards
core/event/event.ts Updated imports to use type-guards
core/error/types.ts Added 'signer' error domain
core/error/index.unit.test.ts Updated test to use 'account' domain instead of 'accounts'
core/account/native/* Updated to use Signer type
core/asset/sac/* Updated imports and types

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fazzatti fazzatti merged commit 0777adb into dev Dec 8, 2025
9 checks passed
@fazzatti fazzatti deleted the feat/contract-signer branch December 8, 2025 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants