Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewkmin committed Sep 15, 2023
1 parent b0730d8 commit e2eb5cc
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 69 deletions.
4 changes: 1 addition & 3 deletions packages/viem/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@
},
"devDependencies": {
"hardhat": "^2.12.7",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@openzeppelin/contracts": "^4.9.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.8"
"@openzeppelin/contracts": "^4.9.0"
},
"engines": {
"node": ">=16.0.0"
Expand Down
60 changes: 0 additions & 60 deletions packages/viem/src/__tests__/index-test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import { setBalance, mine } from "@nomicfoundation/hardhat-network-helpers";
import hre from "hardhat";
import { TurnkeyActivityError } from "@turnkey/http";
// import { prepareSendTransaction } from '@wagmi/core';
// import { toAccount } from 'viem/accounts'

import {
type Account,
type Chain,
type Hex,
custom,
WalletClient,
TestClient,
// createWalletClient,
createTestClient,
publicActions,
walletActions,
Expand All @@ -21,21 +12,13 @@ import {
getContractAddress,
parseEther,
parseUnits,
recoverMessageAddress,
recoverTypedDataAddress,
verifyTypedData,
verifyMessage,
} from "viem";
import { foundry, hardhat } from "viem/chains";
// import type { Chain } from "viem";
import { TurnkeyClient } from "@turnkey/http";
import { ApiKeyStamper } from "@turnkey/api-key-stamper";
import { createAccount } from "../";

import Test721 from "./contracts/artifacts/src/__tests__/contracts/source/Test721.sol/Test721.json";

import { expect, beforeEach, describe, test } from "@jest/globals";
import { signMessage } from "viem/dist/types/actions/wallet/signMessage";

// @ts-expect-error
const testCase: typeof test = (...argList) => {
Expand All @@ -51,8 +34,6 @@ describe("TurnkeyAccount", () => {
let walletClient: any;
let eip1193Client: any;
let turnkeyAccount: Account;
// let walletAddress: string;
// let chainId: number;
let chain: Chain | undefined;
let expectedEthAddress: Hex;
let bannedToAddress: Hex;
Expand Down Expand Up @@ -94,9 +75,6 @@ describe("TurnkeyAccount", () => {
`process.env.BANNED_TO_ADDRESS`
) as Hex;

// @ts-ignore
const provider = hre.ethers.provider;

// create new client
const turnkeyClient = new TurnkeyClient(
{
Expand All @@ -116,8 +94,6 @@ describe("TurnkeyAccount", () => {

walletClient = createTestClient({
account: turnkeyAccount,
// chain: hardhat,
// mode: 'hardhat',
chain: foundry,
mode: "anvil",
transport: http(),
Expand All @@ -131,21 +107,11 @@ describe("TurnkeyAccount", () => {
account: turnkeyAccount,
chain: foundry,
mode: "anvil",
// transport: custom(provider),
// transport: custom(hre.network.provider),
transport: http(),
})
.extend(publicActions)
.extend(walletActions);

// hardhat commands
// await setBalance(expectedEthAddress, parseEther("999999"));
// await mine(1);

const balance = await walletClient.getBalance({
address: expectedEthAddress,
});

const client = createTestClient({
chain: foundry,
mode: "anvil",
Expand All @@ -156,15 +122,8 @@ describe("TurnkeyAccount", () => {
address: expectedEthAddress,
value: parseEther("999999"),
});

const mine = await client.mine({ blocks: 1 });
});

// testCase("basics for connected signer", async () => {
// expect(ethers.Signer.isSigner(connectedSigner)).toBe(true);
// expect(await connectedSigner.getAddress()).toBe(expectedEthAddress);
// });

testCase("it signs transactions", async () => {
const request = await walletClient.prepareTransactionRequest({
account: turnkeyAccount,
Expand All @@ -178,10 +137,6 @@ describe("TurnkeyAccount", () => {
});

testCase("it sends transactions", async () => {
const balance = await walletClient.getBalance({
address: turnkeyAccount.address,
});
console.log("balance", balance);
const txHash = await walletClient.sendTransaction({
account: turnkeyAccount,
to: "0x2Ad9eA1E677949a536A270CEC812D6e868C88108",
Expand Down Expand Up @@ -245,13 +200,6 @@ describe("TurnkeyAccount", () => {
account: turnkeyAccount,
message: { raw: stringToHex(message) },
});

// unsure why this fails
// const recoveredAddress = await recoverMessageAddress({
// message,
// signature: signMessageSignature,
// });

const verified = await walletClient.verifyMessage({
address: expectedEthAddress,
message: message,
Expand Down Expand Up @@ -304,13 +252,6 @@ describe("TurnkeyAccount", () => {
} as const;

const signTypedDataSignature = await walletClient.signTypedData(typedData);

// same... why does this fail
// const recoveredAddress = await recoverTypedDataAddress({
// ...typedData,
// signature: signTypedDataSignature,
// });

const verified = await walletClient.verifyTypedData({
...typedData,
address: expectedEthAddress,
Expand Down Expand Up @@ -385,7 +326,6 @@ describe("TurnkeyAccount", () => {
// Mint
// @ts-expect-error
const mintHash = await contract.write.safeMint([expectedEthAddress]);
// await mintTx.wait();

expect(mintHash).toMatch(/^0x/);

Expand Down
6 changes: 0 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e2eb5cc

Please sign in to comment.