Skip to content

Commit

Permalink
chore: fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
blakecduncan committed Oct 26, 2023
1 parent 2a52289 commit f1089a9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ jobs:
run: yarn build

- name: Link SDK
run: yarn --cwd packages/accounts link
run: yarn --cwd packages/accounts link

- name: Install E2E tests
run: yarn --cwd e2e-tests link @zerodev/sdk && yarn --cwd e2e-tests

- name: E2E tests
env:
API_KEY: ${{ secrets.API_KEY }}
Expand Down
52 changes: 32 additions & 20 deletions packages/accounts/src/kernel-zerodev/owner/getCustodialOwner.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {SignTypedDataParams, SmartAccountSigner} from "@alchemy/aa-core";
import type { SignTypedDataParams, SmartAccountSigner } from "@alchemy/aa-core";
import { API_URL } from "../constants.js";
import axios from "axios";
import {TurnkeyClient} from "@turnkey/http";
import { TurnkeyClient } from "@turnkey/http";

/**
* Params to get a custodial owner
Expand All @@ -20,7 +20,7 @@ type GetCustodialOwnerParams = {

// Or read them from the custodial file path
custodialFilePath?: string;
}
};

/**
* Returns a signer for a custodial wallet via TurnKey
Expand Down Expand Up @@ -54,7 +54,7 @@ export async function getCustodialOwner(
// Ensure we have the required values
if (!privateKey || !publicKey || !keyId) {
throw new Error(
"Must provide custodialFilePath or privateKey, publicKey, and keyId."
"Must provide custodialFilePath or privateKey, publicKey, and keyId."
);
}

Expand All @@ -65,34 +65,45 @@ export async function getCustodialOwner(
let ApiKeyStamper;
// TODO: Would be cleaner with something like radash and a tryit function?
try {
TurnkeyClient = require.resolve("@turnkey/http") && require("@turnkey/http").TurnkeyClient;
ApiKeyStamper = require.resolve("@turnkey/api-key-stamper") && require("@turnkey/api-key-stamper").ApiKeyStamper;
TurnkeyClient =
require.resolve("@turnkey/http") &&
require("@turnkey/http").TurnkeyClient;
ApiKeyStamper =
require.resolve("@turnkey/api-key-stamper") &&
require("@turnkey/api-key-stamper").ApiKeyStamper;
} catch (error) {
console.log("@turnkey/http or @turnkey/api-key-stamper module not available. Skipping FS operation...");
return;
console.log(
"@turnkey/http or @turnkey/api-key-stamper module not available. Skipping FS operation..."
);
return;
}

// Build the turnkey client
turnKeyClient = new TurnkeyClient(
{
baseUrl: "https://api.turnkey.com",
},
new ApiKeyStamper({
apiPublicKey: publicKey,
apiPrivateKey: privateKey,
})
{
baseUrl: "https://api.turnkey.com",
},
new ApiKeyStamper({
apiPublicKey: publicKey,
apiPrivateKey: privateKey,
})
);
}

// Get the wallet identifier from the API
const response = await axios.post<any, {data: {walletId: string}}>(`${apiUrl}/wallets/${identifier}`, {
keyId,
});
const response = await axios.post<any, { data: { walletId: string } }>(
`${apiUrl}/wallets/${identifier}`,
{
keyId,
}
);

// Build the turnkey viem account
let createAccount;
try {
createAccount = require.resolve("@turnkey/viem") && require("@turnkey/viem").createAccount;
createAccount =
require.resolve("@turnkey/viem") &&
require("@turnkey/viem").createAccount;
} catch (error) {
console.log("@turnkey/viem module not available. Skipping FS operation...");
return;
Expand All @@ -115,6 +126,7 @@ export async function getCustodialOwner(
return turnkeySigner.signMessage({ message: { raw: msg } });
}
},
signTypedData: async (params: SignTypedDataParams) => turnkeySigner.signTypedData(params),
signTypedData: async (params: SignTypedDataParams) =>
turnkeySigner.signTypedData(params),
};
}

0 comments on commit f1089a9

Please sign in to comment.