-
Notifications
You must be signed in to change notification settings - Fork 128
Refactored fcl-core interaction-template-utils folder files to TypeScript #2474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactored fcl-core interaction-template-utils folder files to TypeScript #2474
Conversation
...-core/src/interaction-template-utils/generate-dependency-pin/generate-dependency-pin.test.ts
Outdated
Show resolved
Hide resolved
...s/fcl-core/src/interaction-template-utils/generate-template-id/generate-template-id-1.1.0.ts
Outdated
Show resolved
Hide resolved
…late-id/generate-template-id-1.1.0.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com>
|
…e-interaction-utils
import {invariant} from "@onflow/util-invariant" | ||
import type {InteractionTemplate100} from "../interaction-template" | ||
|
||
export interface DeriveCadenceByNetwork100Params { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a common naming pattern with the version like that on types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function names were already with the version inside like that, so I followed the pattern and named the params in the same way. Overall that looks consistent with the other function names in the folder.
There was a problem hiding this 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 fcl-core interaction-template-utils folder from JavaScript to TypeScript, updating import paths and adding type annotations throughout the module. Key changes include conversion of JavaScript files to TypeScript (with removal of explicit “.js” extensions), addition of interfaces and type assertions, and adjustments in related test files.
Reviewed Changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
packages/fcl-core/src/interaction-template-utils/verify-dependency-pin-same-at-block.ts | Converted function to TypeScript with updated import paths and type definitions. |
packages/fcl-core/src/interaction-template-utils/verify-dependency-pin-same-at-block.test.ts | Updated test imports to reference TypeScript files. |
packages/fcl-core/src/interaction-template-utils/utils/replace-string-imports.ts | New TypeScript version implementing string replacement for imports. |
packages/fcl-core/src/interaction-template-utils/utils/replace-string-imports.js | Removed in favor of the new TS version. |
packages/fcl-core/src/interaction-template-utils/utils/hash.ts | Added type annotations to the hash utility. |
packages/fcl-core/src/interaction-template-utils/utils/generate-import.ts | Refactored to TypeScript with explicit types. |
packages/fcl-core/src/interaction-template-utils/utils/generate-import.js | Removed in favor of the new TS version. |
packages/fcl-core/src/interaction-template-utils/utils/find-imports.ts | Converted to TypeScript and added non-null assertions. |
packages/fcl-core/src/interaction-template-utils/utils/find-imports.test.ts | Updated test imports for TypeScript. |
packages/fcl-core/src/interaction-template-utils/interaction-template.ts | New file defining interfaces and types for interaction templates. |
packages/fcl-core/src/interaction-template-utils/index.ts | Updated re-exports to remove file extensions. |
packages/fcl-core/src/interaction-template-utils/get-template-message.ts | Added TypeScript typing and updated invariant imports. |
packages/fcl-core/src/interaction-template-utils/get-template-message.test.ts | Updated test imports with TS casting where necessary. |
packages/fcl-core/src/interaction-template-utils/get-template-argument-message.ts | Added type interfaces and updated invariant conditions. |
packages/fcl-core/src/interaction-template-utils/get-template-argument-message.test.ts | Updated test imports using TypeScript assertions. |
packages/fcl-core/src/interaction-template-utils/get-interaction-template-audits.ts | Converted to TypeScript with updated argument types and import paths. |
packages/fcl-core/src/interaction-template-utils/generate-template-id/generate-template-id.ts | Added type annotations and updated invariant usage. |
packages/fcl-core/src/interaction-template-utils/generate-template-id/generate-template-id-1.1.0.ts | Refactored to TypeScript with detailed types for generation logic. |
packages/fcl-core/src/interaction-template-utils/generate-template-id/generate-template-id-1.1.0.test.ts | Updated test imports and added type assertions. |
packages/fcl-core/src/interaction-template-utils/generate-template-id/generate-template-id-1.0.0.ts | Converted to TypeScript with explicit interface usage. |
packages/fcl-core/src/interaction-template-utils/generate-dependency-pin/generate-dependency-pin.ts | Refactored function to TS with updated type definitions and a version switch. |
packages/fcl-core/src/interaction-template-utils/generate-dependency-pin/generate-dependency-pin.test.ts | Updated test to properly spy on console.warn and use TS casts. |
packages/fcl-core/src/interaction-template-utils/generate-dependency-pin/generate-dependency-pin-1.1.0.ts | Converted to TypeScript with explicit return types and type assertions. |
packages/fcl-core/src/interaction-template-utils/generate-dependency-pin/generate-dependency-pin-1.0.0.ts | Converted function to TS with added interface for parameters. |
packages/fcl-core/src/interaction-template-utils/derive-cadence-by-network/derive-cadence-by-network.ts | Added TypeScript typings and updated the switch to call version-specific implementations. |
packages/fcl-core/src/interaction-template-utils/derive-cadence-by-network/derive-cadence-by-network.test.ts | Updated test files to include proper type assertions on templates. |
packages/fcl-core/src/interaction-template-utils/derive-cadence-by-network/derive-cadence-by-network-1.1.0.ts | Converted to TypeScript with enhanced type safety and corrected invariant messages. |
packages/fcl-core/src/interaction-template-utils/derive-cadence-by-network/derive-cadence-by-network-1.0.0.ts | New TypeScript implementation with full type annotations and template dependency replacement logic. |
packages/fcl-core/src/interaction-template-utils/derive-cadence-by-network/derive-cadence-by-network-1.0.0.js | Removed in favor of the new TypeScript version. |
Comments suppressed due to low confidence (1)
packages/fcl-core/src/interaction-template-utils/verify-dependency-pin-same-at-block.ts:140
- The error message in the debug log uses '(net as any).pin', which is inconsistent with the earlier reference '(net as any).dependency_pin.pin'. Consider updating the error message to use '(net as any).dependency_pin.pin' for clarity.
template: ${(net as any).pin}
@@ -423,15 +423,15 @@ describe("1.1.0, verify dependency pin same", () => { | |||
}) | |||
|
|||
afterAll(() => { | |||
console.warn.mockRestore() | |||
//console.warn.mockRestore() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//console.warn.mockRestore() | |
console.warn.mockRestore() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented 👍
@@ -46,7 +56,7 @@ export async function deriveCadenceByNetwork110({network, template}) { | |||
) | |||
|
|||
invariant( | |||
template?.data?.cadence?.body, | |||
template?.data?.cadence?.body as any, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
template?.data?.cadence?.body as any, | |
!!template?.data?.cadence?.body, |
...s/fcl-core/src/interaction-template-utils/generate-template-id/generate-template-id-1.0.0.ts
Outdated
Show resolved
Hide resolved
packages/fcl-core/src/interaction-template-utils/generate-template-id/generate-template-id.ts
Outdated
Show resolved
Hide resolved
…late-id/generate-template-id-1.0.0.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com>
…late-id/generate-template-id.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com>
…e-interaction-utils
…e-interaction-utils
* Added core types export (#2437) Co-authored-by: mfbz <mfbz@users.noreply.github.com> * Refactored fcl-core current-user folder files to TypeScript (#2454) * Refactored current-user folder with corresponding type definitions * Renamed CurrentUserFull to CurrentUserService * Improved CurrentUser interface --------- Co-authored-by: mfbz <mfbz@users.noreply.github.com> * Refactored root files (#2479) Co-authored-by: mfbz <mfbz@users.noreply.github.com> * Refactored serialize folder (#2476) Co-authored-by: mfbz <mfbz@users.noreply.github.com> * Refactored fcl-core document folder files to TypeScript (#2464) * Refactored document folder * Update packages/fcl-core/src/document/document.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> --------- Co-authored-by: mfbz <mfbz@users.noreply.github.com> Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Refactored fcl-core utils folder files to TypeScript (#2477) * Refactored utils folder * Update packages/fcl-core/src/utils/chain-id/chain-id-watcher.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Update packages/fcl-core/src/utils/chain-id/chain-id-watcher.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Fixed minor typo --------- Co-authored-by: mfbz <mfbz@users.noreply.github.com> Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Refactored fcl-core events folder files to TypeScript (#2472) * Refactored legacy events file * Fixed for compatibility --------- Co-authored-by: mfbz <mfbz@users.noreply.github.com> * Refactored fcl-core app utils folder files to TypeScript (#2442) * Refactored app-utils folder * Added new types export * Update packages/fcl-core/src/fcl-core.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Cleaned up any usage --------- Co-authored-by: mfbz <mfbz@users.noreply.github.com> Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Refactored fcl-core exec folder files to TypeScript (#2473) * Completed exec folder refactoring * Substituted correct current-user usage * Improved mutate options interface * Cleanup any usage * Refactored any usage to only when needed --------- Co-authored-by: mfbz <mfbz@users.noreply.github.com> * Refactored fcl-core discovery folder files to TypeScript (#2462) * Refactored discovery folder * Reused ActorContext from util-actor package * Minor fix --------- Co-authored-by: mfbz <mfbz@users.noreply.github.com> * Refactored fcl-core wallet-utils folder files to TypeScript (#2478) * Refactored wallet-utils folder * Made account proof data optional * Update packages/fcl-core/src/wallet-utils/encode-account-proof.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Update packages/fcl-core/src/wallet-utils/encode-account-proof.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Update packages/fcl-core/src/wallet-utils/encode-account-proof.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Improved sendMsgToFCL msg param * Update packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Update packages/fcl-core/src/wallet-utils/CompositeSignature.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Update packages/fcl-core/src/wallet-utils/on-message-from-fcl.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Update packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Update packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Update packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Update packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Update packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Update packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Removed useless casts --------- Co-authored-by: mfbz <mfbz@users.noreply.github.com> Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Fixed connection not working * Refactored fcl-core interaction-template-utils folder files to TypeScript (#2474) * Completed refactoring of interaction-template-utils folder * Update packages/fcl-core/src/interaction-template-utils/generate-template-id/generate-template-id-1.1.0.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Improved dependency pin test * Fixed console warn spy on tests * Added suggestion * Update packages/fcl-core/src/interaction-template-utils/generate-template-id/generate-template-id-1.0.0.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Update packages/fcl-core/src/interaction-template-utils/generate-template-id/generate-template-id.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> --------- Co-authored-by: mfbz <mfbz@users.noreply.github.com> Co-authored-by: Jordan Ribbink 6D40 <17958158+jribbink@users.noreply.github.com> * Refactored fcl-core normalizers folder files to TypeScript (#2475) * Refactored normalizers folder * Fixed post merging issues * Updated comments * Updated service normalizers * Update packages/fcl-core/src/normalizers/service/open-id.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: mfbz <mfbz@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Big documentation update (#2532) Co-authored-by: mfbz <mfbz@users.noreply.github.com> * Added changeset --------- Co-authored-by: mfbz <mfbz@users.noreply.github.com> Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Closes #2448