Skip to content

Commit

Permalink
feat: add option to constructor signer with inner params directly
Browse files Browse the repository at this point in the history
  • Loading branch information
avasisht23 committed Nov 14, 2023
1 parent f05b469 commit fc6f764
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/signers/src/magic/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from "@alchemy/aa-core";
import { Magic, type MagicUserMetadata } from "magic-sdk";
import { createWalletClient, custom, type Hash } from "viem";
import type { MagicAuthParams } from "./types.js";
import type { MagicAuthParams, MagicSDKParams } from "./types.js";

export class MagicSigner
implements
Expand All @@ -14,8 +14,13 @@ export class MagicSigner
inner: Magic;
private signer: WalletClientSigner | undefined;

constructor({ inner }: { inner: Magic }) {
this.inner = inner;
constructor(params: MagicSDKParams | { inner: Magic }) {
if ("inner" in params) {
this.inner = params.inner;
return;
}

this.inner = new Magic(params.apiKey, params.options);
}

get signerType() {
Expand Down
13 changes: 13 additions & 0 deletions packages/signers/src/magic/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
import type {
MagicSDKAdditionalConfiguration,
MagicSDKExtensionsOption,
} from "magic-sdk";

export interface MagicAuthParams {
authenticate: () => Promise<void>;
}

export type MagicSDKParams = {
apiKey: string;
options?: MagicSDKAdditionalConfiguration<
string,
MagicSDKExtensionsOption<string>
>;
};

0 comments on commit fc6f764

Please sign in to comment.