8000 Refactored fcl-core interaction-template-utils folder files to TypeScript by mfbz · Pull Request #2474 · onflow/fcl-js · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged

Conversation

mfbz
Copy link
Contributor
@mfbz mfbz commented May 27, 2025

Closes #2448

@mfbz mfbz requested a review from a team as a code owner May 27, 2025 16:29
…late-id/generate-template-id-1.1.0.ts

Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com>
Copy link
changeset-bot bot commented Jun 13, 2025

⚠️ No Changeset found

Latest commit: c6460ee

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mfbz mfbz requested a review from jribbink June 16, 2025 13:48
import {invariant} from "@onflow/util-invariant"
import type {InteractionTemplate100} from "../interaction-template"

export interface DeriveCadenceByNetwork100Params {
Copy link
Member

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?

Copy link
Contributor Author

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.

@chasefleming chasefleming requested a review from Copilot June 23, 2025 16:23
Copy link
@Copilot 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 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}

@mfbz mfbz requested a review from chasefleming June 23, 2025 16:55
@@ -423,15 +423,15 @@ describe("1.1.0, verify dependency pin same", () => {
})

afterAll(() => {
console.warn.mockRestore()
//console.warn.mockRestore()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
//console.warn.mockRestore()
console.warn.mockRestore()

Copy link
Contributor Author

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,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
template?.data?.cadence?.body as any,
!!template?.data?.cadence?.body,

mfbz and others added 5 commits June 23, 2025 21:35
…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>
@mfbz mfbz requested a review from jribbink June 23, 2025 19:37
@mfbz mfbz merged commit d06e883 into feature/typescript-fcl-core Jun 23, 2025
1 check passed
@mfbz mfbz deleted the mfbz/refactor-fcl-core-interaction-utils branch June 23, 2025 20:19
mfbz added a commit that referenced this pull request Jun 25, 2025
* 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>
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.

3 participants
0