From 5d7a1e12a7c8c5bf67032399f4f8748c144a3054 Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Tue, 10 Nov 2026 10:56:36 -0700 Subject: [PATCH] chore: Warn user if they are not using a TurnkeySparkSigner --- .changeset/olive-worlds-deny.md | 5 ++++ packages/spark/src/__tests__/wallet.test.ts | 26 +++++++++++++++++++++ packages/spark/src/signer.ts | 4 ++++ packages/spark/src/wallet.ts | 8 +++++++ 4 files changed, 43 insertions(+) create mode 100644 .changeset/olive-worlds-deny.md diff --git a/.changeset/olive-worlds-deny.md b/.changeset/olive-worlds-deny.md new file mode 100644 index 000000000..f32922c12 --- /dev/null +++ b/.changeset/olive-worlds-deny.md @@ -0,0 +1,5 @@ +--- +"@turnkey/spark": patch +--- + +Warn users if they are not using TurnkeySparkSigner with TurnkeySparkWallet diff --git a/packages/spark/src/__tests__/wallet.test.ts b/packages/spark/src/__tests__/wallet.test.ts index 2121ff278..272a99437 100644 --- a/packages/spark/src/__tests__/wallet.test.ts +++ b/packages/spark/src/__tests__/wallet.test.ts @@ -468,6 +468,32 @@ At the moment, withdrawal requests are leaking test funds into the BTC wallet ${ }, TEST_TIMEOUT, ); + + describe("Signer warnings", () => { + let consoleWarnSpy: jest.SpyInstance; + + beforeEach(() => { + consoleWarnSpy = jest.spyOn(console, "warn").mockImplementation(); + }); + + afterEach(() => { + consoleWarnSpy.mockRestore(); + }); + + it("should warn if the signer is not a TurnkeySparkSigner", async () => { + await createSparkWallet({} as TurnkeySparkSigner); + + expect(consoleWarnSpy).toHaveBeenCalledWith( + "Warning: The provided signer is not a TurnkeySparkSigner.", + ); + }); + + it("should not warn if the signer is a TurnkeySparkSigner", async () => { + await createSparkWallet(senderSigner); + + expect(consoleWarnSpy).not.toHaveBeenCalled(); + }); + }); }); /** diff --git a/packages/spark/src/signer.ts b/packages/spark/src/signer.ts index fec6f56a8..eacc67697 100644 --- a/packages/spark/src/signer.ts +++ b/packages/spark/src/signer.ts @@ -373,6 +373,10 @@ export class TurnkeySparkSigner implements SparkSigner { } } + isTurnkeySparkSigner(): boolean { + return true; + } + // --------------------------------------------------------------------------- // Identity key operations (already working) // --------------------------------------------------------------------------- diff --git a/packages/spark/src/wallet.ts b/packages/spark/src/wallet.ts index 2d1fad537..b9f7251d0 100644 --- a/packages/spark/src/wallet.ts +++ b/packages/spark/src/wallet.ts @@ -20,6 +20,8 @@ export class TurnkeySparkWallet extends SparkWallet { constructor(options?: ConfigOptions, signerArg?: SparkSigner) { super(options, signerArg); + warnIfNotTurnkeySigner(signerArg); + this.transferService = new TurnkeyTransferService( this.config, this.connectionManager, @@ -127,3 +129,9 @@ export class TurnkeySparkWallet extends SparkWallet { return (this as any).logging as LoggingService | undefined; } } + +const warnIfNotTurnkeySigner = (signer: SparkSigner | undefined) => { + if (!(signer as TurnkeySparkSigner)?.isTurnkeySparkSigner?.()) { + console.warn("Warning: The provided signer is not a TurnkeySparkSigner."); + } +};