Skip to content

Commit

Permalink
chore: organize imports
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed May 1, 2023
1 parent 3526346 commit cd05137
Show file tree
Hide file tree
Showing 247 changed files with 479 additions and 397 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/bench.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getOctokit, context } from '@actions/github'
import { context, getOctokit } from '@actions/github'

type Report = {
testResults: {
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"editor.formatOnSave": true,
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"editor.codeActionsOnSave": {
"source.organizeImports.rome": true
},
"[typescript]": {
"editor.defaultFormatter": "rome.rome"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/clients/public-client/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createPublicClient, http, stringify } from 'viem'
import { mainnet, polygon, optimism } from 'viem/chains'
import { mainnet, optimism, polygon } from 'viem/chains'

const publicClients = [
createPublicClient({
Expand Down
2 changes: 1 addition & 1 deletion examples/clients/wallet-client/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'viem/window'
import React, { useState } from 'react'
import ReactDOM from 'react-dom/client'
import { Address, createWalletClient, custom, parseEther } from 'viem'
import { goerli } from 'viem/chains'
import 'viem/window'

const walletClient = createWalletClient({
chain: goerli,
Expand Down
2 changes: 1 addition & 1 deletion examples/clients/wallet-client/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'

// https://vitejs.dev/config/
export default defineConfig({
Expand Down
6 changes: 3 additions & 3 deletions examples/contracts/deploying-contracts/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import 'viem/window'
import { wagmiContract } from './contract'
import React, { useEffect, useState } from 'react'
import ReactDOM from 'react-dom/client'
import {
Address,
Hash,
TransactionReceipt,
createWalletClient,
createPublicClient,
createWalletClient,
custom,
http,
stringify,
} from 'viem'
import { goerli } from 'viem/chains'
import { wagmiContract } from './contract'
import 'viem/window'

const publicClient = createPublicClient({
chain: goerli,
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/deploying-contracts/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'

// https://vitejs.dev/config/
export default defineConfig({
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/multicall/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { wagmiContract } from './contract'
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'
import { wagmiContract } from './contract'

const client = createPublicClient({
chain: mainnet,
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/reading-contracts/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { wagmiContract } from './contract'
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'
import { wagmiContract } from './contract'

const client = createPublicClient({
chain: mainnet,
Expand Down
6 changes: 3 additions & 3 deletions examples/contracts/writing-to-contracts/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import 'viem/window'
import { wagmiContract } from './contract'
import React, { useEffect, useState } from 'react'
import ReactDOM from 'react-dom/client'
import {
Address,
Hash,
TransactionReceipt,
createWalletClient,
createPublicClient,
createWalletClient,
custom,
http,
stringify,
} from 'viem'
import { goerli } from 'viem/chains'
import { wagmiContract } from './contract'
import 'viem/window'

const publicClient = createPublicClient({
chain: goerli,
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/writing-to-contracts/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'

// https://vitejs.dev/config/
export default defineConfig({
Expand Down
2 changes: 1 addition & 1 deletion examples/signing/typed-data/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'viem/window'
import React, { useState } from 'react'
import ReactDOM from 'react-dom/client'
import { Address, Hash, createWalletClient, custom } from 'viem'
import { goerli } from 'viem/chains'
import 'viem/window'

const walletClient = createWalletClient({
chain: goerli,
Expand Down
2 changes: 1 addition & 1 deletion examples/signing/typed-data/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'

// https://vitejs.dev/config/
export default defineConfig({
Expand Down
4 changes: 2 additions & 2 deletions examples/transactions/sending-transactions/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import 'viem/window'
import React, { useEffect, useState } from 'react'
import ReactDOM from 'react-dom/client'
import {
Address,
Hash,
TransactionReceipt,
createWalletClient,
createPublicClient,
createWalletClient,
custom,
http,
parseEther,
stringify,
} from 'viem'
import { goerli } from 'viem/chains'
import 'viem/window'

const publicClient = createPublicClient({
chain: goerli,
Expand Down
2 changes: 1 addition & 1 deletion examples/transactions/sending-transactions/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'

// https://vitejs.dev/config/
export default defineConfig({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parseEther, WalletClient } from 'viem'
import { WalletClient, parseEther } from 'viem'
import { goerli } from 'viem/chains'

export function SendTransaction({ client }: { client: WalletClient }) {
Expand Down
2 changes: 1 addition & 1 deletion playgrounds/browser/src/components/clients/HttpPublic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { GetBalance } from '../actions/GetBalance'
import { GetBlock } from '../actions/GetBlock'
import { GetBlockNumber } from '../actions/GetBlockNumber'
import { GetTransaction } from '../actions/GetTransaction'
import { WatchBlocks } from '../actions/WatchBlocks'
import { WatchBlockNumber } from '../actions/WatchBlockNumber'
import { WatchBlocks } from '../actions/WatchBlocks'
import { WatchPendingTransactions } from '../actions/WatchPendingTransactions'

const apiKey = 'PjT72qifrAFZ4WV_drrd30N5onftY5VA'
Expand Down
2 changes: 1 addition & 1 deletion playgrounds/browser/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { App } from './App'
import React from 'react'
import ReactDOM from 'react-dom/client'
import { App } from './App'

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
Expand Down
2 changes: 1 addition & 1 deletion playgrounds/browser/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'

// https://vitejs.dev/config/
export default defineConfig({
Expand Down
3 changes: 3 additions & 0 deletions rome.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@
"trailingComma": "all",
"semicolons": "asNeeded"
}
},
"organizeImports": {
"enabled": true
}
}
4 changes: 2 additions & 2 deletions site/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import defaultTheme from 'vitepress/theme'
import './index.css'
import SvgImage from './components/SvgImage.vue'
import './index.css'
import defaultTheme from 'vitepress/theme'

export default {
...defaultTheme,
Expand Down
6 changes: 3 additions & 3 deletions src/_test/ccip.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { sign } from '../accounts/utils/sign.js'
import { signatureToHex } from '../accounts/utils/signatureToHex.js'
import type { Hex } from '../types/index.js'
import {
decodeAbiParameters,
encodeAbiParameters,
parseAbiParameters,
} from '../utils/abi/index.js'
import { sign } from '../accounts/utils/sign.js'
import { signatureToHex } from '../accounts/utils/signatureToHex.js'
import { stringToHex } from '../utils/encoding/index.js'
import { keccak256 } from '../utils/hash/index.js'
import { accounts } from './constants.js'
import { createHttpServer } from './utils.js'
import type { Hex } from '../types/index.js'

export function createCcipServer() {
return createHttpServer(async (req, res) => {
Expand Down
6 changes: 3 additions & 3 deletions src/_test/setup.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { fetchLogs } from '@viem/anvil'
import { afterAll, afterEach, beforeAll, beforeEach, vi } from 'vitest'

import { setAutomine, setIntervalMining } from '../test.js'
import { cleanupCache, listenersCache } from '../utils/observe.js'
import { promiseCache, responseCache } from '../utils/promise/withCache.js'
import { setBlockNumber, testClient } from './utils.js'
import { setAutomine, setIntervalMining } from '../test.js'
import { fetchLogs } from '@viem/anvil'
import { poolId } from './constants.js'
import { setBlockNumber, testClient } from './utils.js'

beforeAll(() => {
vi.mock('../errors/utils.ts', () => ({
Expand Down
7 changes: 4 additions & 3 deletions src/_test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* c8 ignore start */
import type { Abi } from 'abitype'
import ensAvatarTokenUri from '../../contracts/out/EnsAvatarTokenUri.sol/EnsAvatarTokenUri.json'

import erc20InvalidTransferEvent from '../../contracts/out/ERC20InvalidTransferEvent.sol/ERC20InvalidTransferEvent.json'
import ensAvatarTokenUri from '../../contracts/out/EnsAvatarTokenUri.sol/EnsAvatarTokenUri.json'
import errorsExample from '../../contracts/out/ErrorsExample.sol/ErrorsExample.json'
import offchainLookupExample from '../../contracts/out/OffchainLookupExample.sol/OffchainLookupExample.json'
import type { DeployContractParameters } from '../actions/index.js'
Expand All @@ -24,8 +25,9 @@ import {
http,
webSocket,
} from '../clients/index.js'
import type { Hex } from '../types/index.js'
import { namehash } from '../ens.js'
import { RpcError } from '../types/eip1193.js'
import type { Hex } from '../types/index.js'
import { rpc } from '../utils/index.js'
import { baycContractConfig, ensRegistryConfig } from './abis.js'
import { accounts, address, localHttpUrl, localWsUrl } from './constants.js'
Expand All @@ -39,7 +41,6 @@ import {
import type { RequestListener } from 'http'
import { createServer } from 'http'
import type { AddressInfo } from 'net'
import { namehash } from '../ens.js'

export const anvilChain = {
...localhost,
Expand Down
1 change: 1 addition & 0 deletions src/accounts/generateMnemonic.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, test } from 'vitest'

import { generateMnemonic } from './generateMnemonic.js'
import { czech } from './wordlists/czech.js'
import { english } from './wordlists/english.js'
Expand Down
1 change: 1 addition & 0 deletions src/accounts/generatePrivateKey.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, test } from 'vitest'

import { generatePrivateKey } from './generatePrivateKey.js'

test('default', () => {
Expand Down
5 changes: 3 additions & 2 deletions src/accounts/hdKeyToAccount.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { HDKey } from './index.js'
import { describe, expect, test } from 'vitest'
import { getAddress, parseEther, parseGwei, toBytes } from '../utils/index.js'

import { accounts, typedData } from '../_test/index.js'
import { getAddress, parseEther, parseGwei, toBytes } from '../utils/index.js'
import { hdKeyToAccount } from './hdKeyToAccount.js'
import { HDKey } from './index.js'

const hdKey = HDKey.fromMasterSeed(
toBytes(
Expand Down
3 changes: 2 additions & 1 deletion src/accounts/mnemonicToAccount.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, test } from 'vitest'
import { getAddress, parseEther, parseGwei } from '../utils/index.js'

import { accounts, typedData } from '../_test/index.js'
import { getAddress, parseEther, parseGwei } from '../utils/index.js'
import { mnemonicToAccount } from './mnemonicToAccount.js'

const mnemonic = 'test test test test test test test test test test test junk'
Expand Down
2 changes: 1 addition & 1 deletion src/accounts/mnemonicToAccount.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HDKey } from '@scure/bip32'
import { mnemonicToSeedSync } from '@scure/bip39'
import { hdKeyToAccount } from './hdKeyToAccount.js'

import { hdKeyToAccount } from './hdKeyToAccount.js'
import type { HDAccount, HDOptions } from './types.js'

/**
Expand Down
3 changes: 2 additions & 1 deletion src/accounts/privateKeyToAccount.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect, test } from 'vitest'
import { parseEther, parseGwei } from '../utils/index.js'

import { accounts, typedData } from '../_test/index.js'
import { parseEther, parseGwei } from '../utils/index.js'
import { privateKeyToAccount } from './privateKeyToAccount.js'

test('default', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/accounts/privateKeyToAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { secp256k1 } from '@noble/curves/secp256k1'

import type { Hex } from '../types/index.js'
import { toHex } from '../utils/index.js'
import { toAccount } from './toAccount.js'
import type { PrivateKeyAccount } from './types.js'
import {
publicKeyToAddress,
signMessage,
signTransaction,
signTypedData,
} from './utils/index.js'
import { toAccount } from './toAccount.js'
import type { PrivateKeyAccount } from './types.js'

/**
* @description Creates an Account from a private key.
Expand Down
1 change: 1 addition & 0 deletions src/accounts/toAccount.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, test } from 'vitest'

import { accounts } from '../_test/index.js'
import { toAccount } from './toAccount.js'

Expand Down
1 change: 1 addition & 0 deletions src/accounts/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { HDKey } from '@scure/bip32'
import type { Address, TypedData } from 'abitype'

import type {
Hash,
Hex,
Expand Down
1 change: 1 addition & 0 deletions src/accounts/utils/parseAccount.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, test } from 'vitest'

import { accounts } from '../../_test/index.js'
import { privateKeyToAccount } from '../privateKeyToAccount.js'
import { parseAccount } from './parseAccount.js'
Expand Down
1 change: 1 addition & 0 deletions src/accounts/utils/publicKeyToAddress.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, test } from 'vitest'

import { publicKeyToAddress } from './publicKeyToAddress.js'

test('default', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/accounts/utils/publicKeyToAddress.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Address, Hex } from '../../types/index.js'
import { keccak256 } from '../../utils/index.js'
import { checksumAddress } from '../../utils/address/index.js'
import { keccak256 } from '../../utils/index.js'

/**
* @description Converts an ECDSA public key to an address.
Expand Down
1 change: 1 addition & 0 deletions src/accounts/utils/sign.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, test } from 'vitest'

import { accounts } from '../../_test/index.js'
import { sign } from './sign.js'

Expand Down
1 change: 1 addition & 0 deletions src/accounts/utils/signMessage.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, test } from 'vitest'

import { accounts } from '../../_test/index.js'
import { signMessage } from './signMessage.js'

Expand Down
5 changes: 3 additions & 2 deletions src/accounts/utils/signTransaction.bench.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Wallet } from 'ethers'
import { Wallet as WalletV6 } from 'ethers@6'
import { bench, describe } from 'vitest'

import { accounts } from '../../_test/index.js'
import type { TransactionSerializableBase } from '../../types/index.js'
import { parseEther } from '../../utils/index.js'
import { signTransaction } from './signTransaction.js'
import { Wallet } from 'ethers'
import { Wallet as WalletV6 } from 'ethers@6'

const base = {
to: accounts[1].address,
Expand Down
Loading

0 comments on commit cd05137

Please sign in to comment.