From 3a6fcf5993c0d60aecc234db693275230c705d71 Mon Sep 17 00:00:00 2001 From: mfbz Date: Thu, 29 May 2025 10:30:52 +0200 Subject: [PATCH 01/16] Refactored wallet-utils folder --- .../src/wallet-utils/CompositeSignature.js | 18 ----- .../src/wallet-utils/CompositeSignature.ts | 25 +++++++ ...f.test.js => encode-account-proof.test.ts} | 6 +- ...count-proof.js => encode-account-proof.ts} | 26 +++++--- packages/fcl-core/src/wallet-utils/index.js | 13 ---- packages/fcl-core/src/wallet-utils/index.ts | 13 ++++ .../src/wallet-utils/inject-ext-service.js | 10 --- .../src/wallet-utils/inject-ext-service.ts | 12 ++++ ...age-from-fcl.js => on-message-from-fcl.ts} | 15 +++-- ...{send-msg-to-fcl.js => send-msg-to-fcl.ts} | 65 ++++++++++--------- ...let-utils.test.js => wallet-utils.test.ts} | 0 11 files changed, 114 insertions(+), 89 deletions(-) delete mode 100644 packages/fcl-core/src/wallet-utils/CompositeSignature.js create mode 100644 packages/fcl-core/src/wallet-utils/CompositeSignature.ts rename packages/fcl-core/src/wallet-utils/{encode-account-proof.test.js => encode-account-proof.test.ts} (90%) rename packages/fcl-core/src/wallet-utils/{encode-account-proof.js => encode-account-proof.ts} (68%) delete mode 100644 packages/fcl-core/src/wallet-utils/index.js create mode 100644 packages/fcl-core/src/wallet-utils/index.ts delete mode 100644 packages/fcl-core/src/wallet-utils/inject-ext-service.js create mode 100644 packages/fcl-core/src/wallet-utils/inject-ext-service.ts rename packages/fcl-core/src/wallet-utils/{on-message-from-fcl.js => on-message-from-fcl.ts} (57%) rename packages/fcl-core/src/wallet-utils/{send-msg-to-fcl.js => send-msg-to-fcl.ts} (56%) rename packages/fcl-core/src/wallet-utils/{wallet-utils.test.js => wallet-utils.test.ts} (100%) diff --git a/packages/fcl-core/src/wallet-utils/CompositeSignature.js b/packages/fcl-core/src/wallet-utils/CompositeSignature.js deleted file mode 100644 index 5450c596e..000000000 --- a/packages/fcl-core/src/wallet-utils/CompositeSignature.js +++ /dev/null @@ -1,18 +0,0 @@ -import {withPrefix} from "@onflow/util-address" -import {COMPOSITE_SIGNATURE_PRAGMA} from "../normalizers/service/__vsn" - -/** - * @description - * Constructs a new CompositeSignature instance. - * - * @param {string} addr - Flow Address - * @param {number} keyId - Key ID - * @param {string} signature - Signature as a hex string - */ -export function CompositeSignature(addr, keyId, signature) { - this.f_type = COMPOSITE_SIGNATURE_PRAGMA.f_type - this.f_vsn = COMPOSITE_SIGNATURE_PRAGMA.f_vsn - this.addr = withPrefix(addr) - this.keyId = Number(keyId) - this.signature = signature -} diff --git a/packages/fcl-core/src/wallet-utils/CompositeSignature.ts b/packages/fcl-core/src/wallet-utils/CompositeSignature.ts new file mode 100644 index 000000000..3632a6805 --- /dev/null +++ b/packages/fcl-core/src/wallet-utils/CompositeSignature.ts @@ -0,0 +1,25 @@ +import {withPrefix} from "@onflow/util-address" +import {COMPOSITE_SIGNATURE_PRAGMA} from "../normalizers/service/__vsn" + +/** + * @description Constructs a new CompositeSignature instance. + * + * @param {string} addr Flow Address + * @param {number} keyId Key ID + * @param {string} signature Signature as a hex string + */ +export class CompositeSignature { + f_type: string + f_vsn: string + addr: string + keyId: number + signature: string + + constructor(addr: string, keyId: number | string, signature: string) { + this.f_type = COMPOSITE_SIGNATURE_PRAGMA.f_type + this.f_vsn = COMPOSITE_SIGNATURE_PRAGMA.f_vsn + this.addr = withPrefix(addr) + this.keyId = Number(keyId) + this.signature = signature + } +} diff --git a/packages/fcl-core/src/wallet-utils/encode-account-proof.test.js b/packages/fcl-core/src/wallet-utils/encode-account-proof.test.ts similarity index 90% rename from packages/fcl-core/src/wallet-utils/encode-account-proof.test.js rename to packages/fcl-core/src/wallet-utils/encode-account-proof.test.ts index 471adce93..928bb9b5a 100644 --- a/packages/fcl-core/src/wallet-utils/encode-account-proof.test.js +++ b/packages/fcl-core/src/wallet-utils/encode-account-proof.test.ts @@ -1,4 +1,4 @@ -import {encodeAccountProof} from "./encode-account-proof.js" +import {encodeAccountProof} from "./encode-account-proof" const address = "0xABC123DEF456" const appIdentifier = "AWESOME-APP-ID" @@ -22,14 +22,14 @@ describe("encode account proof", () => { test("encode account proof with missing address", () => { expect.assertions(1) expect(() => { - encodeAccountProof({nonce, appIdentifier}) + encodeAccountProof({nonce, appIdentifier} as any) }).toThrow(Error) }) test("encode account proof with missing appIdentifier", () => { expect.assertions(1) expect(() => { - encodeAccountProof({address, nonce}) + encodeAccountProof({address, nonce} as any) }).toThrow(Error) }) diff --git a/packages/fcl-core/src/wallet-utils/encode-account-proof.js b/packages/fcl-core/src/wallet-utils/encode-account-proof.ts similarity index 68% rename from packages/fcl-core/src/wallet-utils/encode-account-proof.js rename to packages/fcl-core/src/wallet-utils/encode-account-proof.ts index 0b01477a2..7f0afee94 100644 --- a/packages/fcl-core/src/wallet-utils/encode-account-proof.js +++ b/packages/fcl-core/src/wallet-utils/encode-account-proof.ts @@ -2,30 +2,36 @@ import {sansPrefix} from "@onflow/util-address" import {invariant} from "@onflow/util-invariant" import {Buffer, encode as rlpEncode} from "@onflow/rlp" -const rightPaddedHexBuffer = (value, pad) => +export interface AccountProofData { + address: string + nonce: string + appIdentifier: string +} + +const rightPaddedHexBuffer = (value: string, pad: number): Buffer => Buffer.from(value.padEnd(pad * 2, "0"), "hex") -const leftPaddedHexBuffer = (value, pad) => +const leftPaddedHexBuffer = (value: string, pad: number): Buffer => Buffer.from(value.padStart(pad * 2, "0"), "hex") -const addressBuffer = addr => leftPaddedHexBuffer(addr, 8) +const addressBuffer = (addr: string): Buffer => leftPaddedHexBuffer(addr, 8) -const nonceBuffer = nonce => Buffer.from(nonce, "hex") +const nonceBuffer = (nonce: string): Buffer => Buffer.from(nonce, "hex") export const encodeAccountProof = ( - {address, nonce, appIdentifier}, - includeDomainTag = true -) => { + {address, nonce, appIdentifier}: AccountProofData, + includeDomainTag: boolean = true +): string => { invariant( - address, + address as any, "Encode Message For Provable Authn Error: address must be defined" ) invariant( - nonce, + nonce as any, "Encode Message For Provable Authn Error: nonce must be defined" ) invariant( - appIdentifier, + appIdentifier as any, "Encode Message For Provable Authn Error: appIdentifier must be defined" ) diff --git a/packages/fcl-core/src/wallet-utils/index.js b/packages/fcl-core/src/wallet-utils/index.js deleted file mode 100644 index 1757de831..000000000 --- a/packages/fcl-core/src/wallet-utils/index.js +++ /dev/null @@ -1,13 +0,0 @@ -export { - sendMsgToFCL, - ready, - close, - approve, - decline, - redirect, -} from "./send-msg-to-fcl.js" -export {onMessageFromFCL} from "./on-message-from-fcl.js" -export {encodeMessageFromSignable} from "@onflow/sdk" -export {CompositeSignature} from "./CompositeSignature.js" -export {encodeAccountProof} from "./encode-account-proof.js" -export {injectExtService} from "./inject-ext-service.js" diff --git a/packages/fcl-core/src/wallet-utils/index.ts b/packages/fcl-core/src/wallet-utils/index.ts new file mode 100644 index 000000000..a37d0051d --- /dev/null +++ b/packages/fcl-core/src/wallet-utils/index.ts @@ -0,0 +1,13 @@ +export { + sendMsgToFCL, + ready, + close, + approve, + decline, + redirect, +} from "./send-msg-to-fcl" +export {onMessageFromFCL} from "./on-message-from-fcl" +export {encodeMessageFromSignable} from "@onflow/sdk" +export {CompositeSignature} from "./CompositeSignature" +export {encodeAccountProof} from "./encode-account-proof" +export {injectExtService} from "./inject-ext-service" diff --git a/packages/fcl-core/src/wallet-utils/inject-ext-service.js b/packages/fcl-core/src/wallet-utils/inject-ext-service.js deleted file mode 100644 index b5c607707..000000000 --- a/packages/fcl-core/src/wallet-utils/inject-ext-service.js +++ /dev/null @@ -1,10 +0,0 @@ -export function injectExtService(service) { - if (service.type === "authn" && service.endpoint != null) { - if (!Array.isArray(window.fcl_extensions)) { - window.fcl_extensions = [] - } - window.fcl_extensions.push(service) - } else { - console.warn("Authn service is required") - } -} diff --git a/packages/fcl-core/src/wallet-utils/inject-ext-service.ts b/packages/fcl-core/src/wallet-utils/inject-ext-service.ts new file mode 100644 index 000000000..e3b82481c --- /dev/null +++ b/packages/fcl-core/src/wallet-utils/inject-ext-service.ts @@ -0,0 +1,12 @@ +import type {Service} from "@onflow/typedefs" + +export function injectExtService(service: Service): void { + if (service.type === "authn" && service.endpoint != null) { + if (!Array.isArray((window as any).fcl_extensions)) { + ;(window as any).fcl_extensions = [] + } + ;(window as any).fcl_extensions.push(service) + } else { + console.warn("Authn service is required") + } +} diff --git a/packages/fcl-core/src/wallet-utils/on-message-from-fcl.js b/packages/fcl-core/src/wallet-utils/on-message-from-fcl.ts similarity index 57% rename from packages/fcl-core/src/wallet-utils/on-message-from-fcl.js rename to packages/fcl-core/src/wallet-utils/on-message-from-fcl.ts index 585269fe2..b9946ced8 100644 --- a/packages/fcl-core/src/wallet-utils/on-message-from-fcl.js +++ b/packages/fcl-core/src/wallet-utils/on-message-from-fcl.ts @@ -2,12 +2,15 @@ * @description * Listens for messages from FCL * - * @param {string} messageType - Message type - * @param {Function} cb - Callback function - * @returns {Function} - Function to remove event listener + * @param {string} messageType Message type + * @param {Function} cb Callback function + * @returns {Function} Function to remove event listener */ -export const onMessageFromFCL = (messageType, cb = () => {}) => { - const buildData = data => { +export const onMessageFromFCL = ( + messageType: string, + cb: (data: any, context: {origin: string}) => void = () => {} +): (() => void) => { + const buildData = (data: any): any => { if (data.deprecated) console.warn("DEPRECATION NOTICE", data.deprecated.message) delete data?.body?.interaction @@ -15,7 +18,7 @@ export const onMessageFromFCL = (messageType, cb = () => {}) => { return data } - const internal = e => { + const internal = (e: MessageEvent): void => { const {data, origin} = e if (typeof data !== "object") return if (typeof data == null) return diff --git a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.js b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts similarity index 56% rename from packages/fcl-core/src/wallet-utils/send-msg-to-fcl.js rename to packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts index 2362dc177..f3bd86d7f 100644 --- a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.js +++ b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts @@ -3,14 +3,20 @@ import { FCL_RESPONSE_PARAM_NAME, } from "../utils/constants" import {onMessageFromFCL} from "./on-message-from-fcl" -import {URL} from "../utils/url" + +export interface PollingResponse { + f_type: "PollingResponse" + f_vsn: "1.0.0" + status: "APPROVED" | "DECLINED" | "REDIRECT" + reason: string | null + data: any +} /** - * @description - * Sends message to FCL window + * @description Sends message to FCL window * - * @param {string} type - Message type - * @param {object} msg - Message object + * @param {string} type Message type + * @param {PollingResponse} msg Message object * @returns {void} * * @example @@ -22,7 +28,10 @@ import {URL} from "../utils/url" * data: data, * }) */ -export const sendMsgToFCL = (type, msg = {}) => { +export const sendMsgToFCL = ( + type: string, + msg: PollingResponse = {} as PollingResponse +): void => { const data = {...msg, type} const urlParams = new URLSearchParams(window.location.search) @@ -41,75 +50,73 @@ export const sendMsgToFCL = (type, msg = {}) => { } /** - * @description - * Listens for "FCL:VIEW:READY:RESPONSE" and sends "FCL:VIEW:READY" + * @description Listens for "FCL:VIEW:READY:RESPONSE" and sends "FCL:VIEW:READY" * - * @param {Function} cb - Callback function - * @param {object} msg - Message object + * @param {Function} cb Callback function + * @param {PollingResponse} msg Message object * @returns {void} */ -export const ready = (cb, msg = {}) => { +export const ready = ( + cb: (data: any, context: {origin: string}) => void, + msg: PollingResponse = {} as PollingResponse +): void => { onMessageFromFCL("FCL:VIEW:READY:RESPONSE", cb) sendMsgToFCL("FCL:VIEW:READY") } /** - * @description - * Sends "FCL:VIEW:CLOSE" + * @description Sends "FCL:VIEW:CLOSE" * * @returns {void} */ -export const close = () => { +export const close = (): void => { sendMsgToFCL("FCL:VIEW:CLOSE") } /** - * @description - * Sends "FCL:VIEW:RESPONSE" with status "APPROVED" + * @description Sends "FCL:VIEW:RESPONSE" with status "APPROVED" * - * @param {object} data - Data object + * @param {object} data Data object * @returns {void} */ -export const approve = data => { +export const approve = (data: any): void => { sendMsgToFCL("FCL:VIEW:RESPONSE", { f_type: "PollingResponse", f_vsn: "1.0.0", status: "APPROVED", reason: null, data: data, - }) + } as PollingResponse) } /** - * @description - * Sends "FCL:VIEW:RESPONSE" with status "DECLINED" + * @description Sends "FCL:VIEW:RESPONSE" with status "DECLINED" * - * @param {string} reason - Reason for declining + * @param {string} reason Reason for declining * @returns {void} */ -export const decline = reason => { +export const decline = (reason: string): void => { sendMsgToFCL("FCL:VIEW:RESPONSE", { f_type: "PollingResponse", f_vsn: "1.0.0", status: "DECLINED", reason: reason, data: null, - }) + } as PollingResponse) } /** - * @description - * Sends "FCL:VIEW:RESPONSE" with status "REDIRECT" + * @description Sends "FCL:VIEW:RESPONSE" with status "REDIRECT" * - * @param {object} data - Data object + * @param {object} data Data object * @returns {void} */ -export const redirect = data => { +export const redirect = (data: any): void => { sendMsgToFCL("FCL:VIEW:RESPONSE", { f_type: "PollingResponse", f_vsn: "1.0.0", status: "REDIRECT", reason: null, data: data, - }) + } as PollingResponse) } diff --git a/packages/fcl-core/src/wallet-utils/wallet-utils.test.js b/packages/fcl-core/src/wallet-utils/wallet-utils.test.ts similarity index 100% rename from packages/fcl-core/src/wallet-utils/wallet-utils.test.js rename to packages/fcl-core/src/wallet-utils/wallet-utils.test.ts From 1c0e12fc753080e07bc355b225845bf03a4c38b1 Mon Sep 17 00:00:00 2001 From: mfbz Date: Tue, 3 Jun 2025 21:01:53 +0200 Subject: [PATCH 02/16] Made account proof data optional --- .../wallet-utils/encode-account-proof.test.ts | 4 ++-- .../src/wallet-utils/encode-account-proof.ts | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/fcl-core/src/wallet-utils/encode-account-proof.test.ts b/packages/fcl-core/src/wallet-utils/encode-account-proof.test.ts index 928bb9b5a..60a5adb08 100644 --- a/packages/fcl-core/src/wallet-utils/encode-account-proof.test.ts +++ b/packages/fcl-core/src/wallet-utils/encode-account-proof.test.ts @@ -22,14 +22,14 @@ describe("encode account proof", () => { test("encode account proof with missing address", () => { expect.assertions(1) expect(() => { - encodeAccountProof({nonce, appIdentifier} as any) + encodeAccountProof({nonce, appIdentifier}) }).toThrow(Error) }) test("encode account proof with missing appIdentifier", () => { expect.assertions(1) expect(() => { - encodeAccountProof({address, nonce} as any) + encodeAccountProof({address, nonce}) }).toThrow(Error) }) diff --git a/packages/fcl-core/src/wallet-utils/encode-account-proof.ts b/packages/fcl-core/src/wallet-utils/encode-account-proof.ts index 7f0afee94..43f52499c 100644 --- a/packages/fcl-core/src/wallet-utils/encode-account-proof.ts +++ b/packages/fcl-core/src/wallet-utils/encode-account-proof.ts @@ -3,9 +3,9 @@ import {invariant} from "@onflow/util-invariant" import {Buffer, encode as rlpEncode} from "@onflow/rlp" export interface AccountProofData { - address: string - nonce: string - appIdentifier: string + address?: string + nonce?: string + appIdentifier?: string } const rightPaddedHexBuffer = (value: string, pad: number): Buffer => @@ -36,7 +36,7 @@ export const encodeAccountProof = ( ) invariant( - nonce.length >= 64, + nonce!.length >= 64, "Encode Message For Provable Authn Error: nonce must be minimum of 32 bytes" ) @@ -50,15 +50,15 @@ export const encodeAccountProof = ( ACCOUNT_PROOF_DOMAIN_TAG, rlpEncode([ appIdentifier, - addressBuffer(sansPrefix(address)), - nonceBuffer(nonce), + addressBuffer(sansPrefix(address!)), + nonceBuffer(nonce!), ]), ]).toString("hex") } return rlpEncode([ appIdentifier, - addressBuffer(sansPrefix(address)), - nonceBuffer(nonce), + addressBuffer(sansPrefix(address!)), + nonceBuffer(nonce!), ]).toString("hex") } From 028adb59ccd73eb2ad2852cc7957cfe15762c5b5 Mon Sep 17 00:00:00 2001 From: Michael Fabozzi <39808567+mfbz@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:26:10 +0200 Subject: [PATCH 03/16] Update packages/fcl-core/src/wallet-utils/encode-account-proof.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> --- packages/fcl-core/src/wallet-utils/encode-account-proof.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fcl-core/src/wallet-utils/encode-account-proof.ts b/packages/fcl-core/src/wallet-utils/encode-account-proof.ts index 43f52499c..f66cdd7a3 100644 --- a/packages/fcl-core/src/wallet-utils/encode-account-proof.ts +++ b/packages/fcl-core/src/wallet-utils/encode-account-proof.ts @@ -23,7 +23,7 @@ export const encodeAccountProof = ( includeDomainTag: boolean = true ): string => { invariant( - address as any, + !!address, "Encode Message For Provable Authn Error: address must be defined" ) invariant( From 5a3407a98f90601c7dbfb7586cb223286a3b6943 Mon Sep 17 00:00:00 2001 From: Michael Fabozzi <39808567+mfbz@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:26:19 +0200 Subject: [PATCH 04/16] Update packages/fcl-core/src/wallet-utils/encode-account-proof.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> --- packages/fcl-core/src/wallet-utils/encode-account-proof.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fcl-core/src/wallet-utils/encode-account-proof.ts b/packages/fcl-core/src/wallet-utils/encode-account-proof.ts index f66cdd7a3..d194fa967 100644 --- a/packages/fcl-core/src/wallet-utils/encode-account-proof.ts +++ b/packages/fcl-core/src/wallet-utils/encode-account-proof.ts @@ -27,7 +27,7 @@ export const encodeAccountProof = ( "Encode Message For Provable Authn Error: address must be defined" ) invariant( - nonce as any, + !!nonce, "Encode Message For Provable Authn Error: nonce must be defined" ) invariant( From 923ee2943a06f3017528efef5c1d2f7fdcb9eae1 Mon Sep 17 00:00:00 2001 From: Michael Fabozzi <39808567+mfbz@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:26:27 +0200 Subject: [PATCH 05/16] Update packages/fcl-core/src/wallet-utils/encode-account-proof.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> --- packages/fcl-core/src/wallet-utils/encode-account-proof.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fcl-core/src/wallet-utils/encode-account-proof.ts b/packages/fcl-core/src/wallet-utils/encode-account-proof.ts index d194fa967..e6bbb08bf 100644 --- a/packages/fcl-core/src/wallet-utils/encode-account-proof.ts +++ b/packages/fcl-core/src/wallet-utils/encode-account-proof.ts @@ -31,7 +31,7 @@ export const encodeAccountProof = ( "Encode Message For Provable Authn Error: nonce must be defined" ) invariant( - appIdentifier as any, + !!appIdentifier, "Encode Message For Provable Authn Error: appIdentifier must be defined" ) From 31831f7ea38007b2d285eb201c9966faad00fe72 Mon Sep 17 00:00:00 2001 From: mfbz Date: Fri, 13 Jun 2025 15:32:43 +0200 Subject: [PATCH 06/16] Improved sendMsgToFCL msg param --- packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts index f3bd86d7f..cc8c3f5d4 100644 --- a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts +++ b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts @@ -28,10 +28,7 @@ export interface PollingResponse { * data: data, * }) */ -export const sendMsgToFCL = ( - type: string, - msg: PollingResponse = {} as PollingResponse -): void => { +export const sendMsgToFCL = (type: string, msg?: PollingResponse): void => { const data = {...msg, type} const urlParams = new URLSearchParams(window.location.search) From 4e716dbef8e76fdf81bb354af91ab5bf635a2ee4 Mon Sep 17 00:00:00 2001 From: Michael Fabozzi <39808567+mfbz@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:36:18 +0200 Subject: [PATCH 07/16] Update packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> --- packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts index cc8c3f5d4..3e01ce4fb 100644 --- a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts +++ b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts @@ -49,9 +49,8 @@ export const sendMsgToFCL = (type: string, msg?: PollingResponse): void => { /** * @description Listens for "FCL:VIEW:READY:RESPONSE" and sends "FCL:VIEW:READY" * - * @param {Function} cb Callback function - * @param {PollingResponse} msg Message object - * @returns {void} + * @param cb Callback function + * @param msg Message object */ export const ready = ( cb: (data: any, context: {origin: string}) => void, From f89b10d5cdfff16e7f4a58860917e6299684b1eb Mon Sep 17 00:00:00 2001 From: Michael Fabozzi <39808567+mfbz@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:36:34 +0200 Subject: [PATCH 08/16] Update packages/fcl-core/src/wallet-utils/CompositeSignature.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> --- packages/fcl-core/src/wallet-utils/CompositeSignature.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/fcl-core/src/wallet-utils/CompositeSignature.ts b/packages/fcl-core/src/wallet-utils/CompositeSignature.ts index 3632a6805..82085e1bf 100644 --- a/packages/fcl-core/src/wallet-utils/CompositeSignature.ts +++ b/packages/fcl-core/src/wallet-utils/CompositeSignature.ts @@ -4,9 +4,9 @@ import {COMPOSITE_SIGNATURE_PRAGMA} from "../normalizers/service/__vsn" /** * @description Constructs a new CompositeSignature instance. * - * @param {string} addr Flow Address - * @param {number} keyId Key ID - * @param {string} signature Signature as a hex string + * @param addr Flow Address + * @param keyId Key ID + * @param signature Signature as a hex string */ export class CompositeSignature { f_type: string From 147b83e03dd734e1bbc48105989e7465c64b4a46 Mon Sep 17 00:00:00 2001 From: Michael Fabozzi <39808567+mfbz@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:36:45 +0200 Subject: [PATCH 09/16] Update packages/fcl-core/src/wallet-utils/on-message-from-fcl.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> --- packages/fcl-core/src/wallet-utils/on-message-from-fcl.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/fcl-core/src/wallet-utils/on-message-from-fcl.ts b/packages/fcl-core/src/wallet-utils/on-message-from-fcl.ts index b9946ced8..18dff7b65 100644 --- a/packages/fcl-core/src/wallet-utils/on-message-from-fcl.ts +++ b/packages/fcl-core/src/wallet-utils/on-message-from-fcl.ts @@ -2,9 +2,9 @@ * @description * Listens for messages from FCL * - * @param {string} messageType Message type - * @param {Function} cb Callback function - * @returns {Function} Function to remove event listener + * @param messageType Message type + * @param cb Callback function + * @returns Function to remove event listener */ export const onMessageFromFCL = ( messageType: string, From c98d8d6c4318b0f17dba92e35ba355a68f96a591 Mon Sep 17 00:00:00 2001 From: Michael Fabozzi <39808567+mfbz@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:37:02 +0200 Subject: [PATCH 10/16] Update packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> --- packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts index 3e01ce4fb..5c46cb98c 100644 --- a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts +++ b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts @@ -62,8 +62,6 @@ export const ready = ( /** * @description Sends "FCL:VIEW:CLOSE" - * - * @returns {void} */ export const close = (): void => { sendMsgToFCL("FCL:VIEW:CLOSE") From 464dd57f0338c71e50c4f6a7b0a3e827ade79f57 Mon Sep 17 00:00:00 2001 From: Michael Fabozzi <39808567+mfbz@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:37:11 +0200 Subject: [PATCH 11/16] Update packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> --- packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts index 5c46cb98c..1111cf3e2 100644 --- a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts +++ b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts @@ -70,8 +70,7 @@ export const close = (): void => { /** * @description Sends "FCL:VIEW:RESPONSE" with status "APPROVED" * - * @param {object} data Data object - * @returns {void} + * @param data Data object */ export const approve = (data: any): void => { sendMsgToFCL("FCL:VIEW:RESPONSE", { From dffc739de9a8b068ff08cc8d154fe4e327a996cf Mon Sep 17 00:00:00 2001 From: Michael Fabozzi <39808567+mfbz@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:37:18 +0200 Subject: [PATCH 12/16] Update packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> --- packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts index 1111cf3e2..ef052a8f2 100644 --- a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts +++ b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts @@ -85,8 +85,7 @@ export const approve = (data: any): void => { /** * @description Sends "FCL:VIEW:RESPONSE" with status "DECLINED" * - * @param {string} reason Reason for declining - * @returns {void} + * @param reason Reason for declining */ export const decline = (reason: string): void => { sendMsgToFCL("FCL:VIEW:RESPONSE", { From 95817c7cf51788ccd52de103016c0bca47425e5d Mon Sep 17 00:00:00 2001 From: Michael Fabozzi <39808567+mfbz@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:37:28 +0200 Subject: [PATCH 13/16] Update packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> --- packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts index ef052a8f2..6fae2ae5b 100644 --- a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts +++ b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts @@ -15,8 +15,8 @@ export interface PollingResponse { /** * @description Sends message to FCL window * - * @param {string} type Message type - * @param {PollingResponse} msg Message object + * @param type Message type + * @param msg Message object * @returns {void} * * @example From 70b5533f39aeb635761d40a27aab22d5c23645d1 Mon Sep 17 00:00:00 2001 From: Michael Fabozzi <39808567+mfbz@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:37:36 +0200 Subject: [PATCH 14/16] Update packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> --- packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts index 6fae2ae5b..b1568e171 100644 --- a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts +++ b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts @@ -17,7 +17,6 @@ export interface PollingResponse { * * @param type Message type * @param msg Message object - * @returns {void} * * @example * sendMsgToFCL("FCL:VIEW:RESPONSE", { From 53d48f4eb1dbc80bea76b9f49eab174ab50f5da6 Mon Sep 17 00:00:00 2001 From: Michael Fabozzi <39808567+mfbz@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:37:49 +0200 Subject: [PATCH 15/16] Update packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> --- packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts index b1568e171..2bfe1f45e 100644 --- a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts +++ b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts @@ -99,8 +99,7 @@ export const decline = (reason: string): void => { /** * @description Sends "FCL:VIEW:RESPONSE" with status "REDIRECT" * - * @param {object} data Data object - * @returns {void} + * @param data Data object */ export const redirect = (data: any): void => { sendMsgToFCL("FCL:VIEW:RESPONSE", { From b0cdbd5bdadf05e5706851df6eacddfa0a47a0e3 Mon Sep 17 00:00:00 2001 From: mfbz Date: Tue, 17 Jun 2025 23:34:11 +0200 Subject: [PATCH 16/16] Removed useless casts --- packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts index 2bfe1f45e..5b57528be 100644 --- a/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts +++ b/packages/fcl-core/src/wallet-utils/send-msg-to-fcl.ts @@ -78,7 +78,7 @@ export const approve = (data: any): void => { status: "APPROVED", reason: null, data: data, - } as PollingResponse) + }) } /** @@ -93,7 +93,7 @@ export const decline = (reason: string): void => { status: "DECLINED", reason: reason, data: null, - } as PollingResponse) + }) } /** @@ -108,5 +108,5 @@ export const redirect = (data: any): void => { status: "REDIRECT", reason: null, data: data, - } as PollingResponse) + }) }