Skip to content

Commit

Permalink
fix: tweak imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Apr 26, 2024
1 parent 978ece2 commit e8c45db
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 40 deletions.
5 changes: 5 additions & 0 deletions .changeset/ten-wolves-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": patch
---

Tweaked imports and added `/*#__PURE__*/` annotations for better tree-shaking.
2 changes: 1 addition & 1 deletion .size-limit.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
{
"name": "viem/chains",
"path": "./src/_esm/chains/index.js",
"limit": "17.3 kB",
"limit": "28 kB",
"import": "*"
},
{
Expand Down
Binary file modified bun.lockb
Binary file not shown.
12 changes: 3 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
{
"workspaces": [
"examples/*",
"environments/*",
"site",
"src",
"test"
],
"workspaces": ["examples/*", "environments/*", "site", "src", "test"],
"private": true,
"type": "module",
"scripts": {
Expand Down Expand Up @@ -54,7 +48,7 @@
"@changesets/changelog-github": "^0.4.5",
"@changesets/cli": "^2.23.2",
"@ethereumjs/rlp": "^5.0.0",
"@size-limit/preset-big-lib": "^8.2.4",
"@size-limit/preset-big-lib": "^11.1.2",
"@types/fs-extra": "^9.0.13",
"@viem/anvil": "0.0.5",
"@vitest/coverage-v8": "^1.0.4",
Expand All @@ -66,7 +60,7 @@
"globby": "^13.2.2",
"rimraf": "^4.4.1",
"simple-git-hooks": "^2.8.1",
"size-limit": "^8.2.4",
"size-limit": "^11.1.2",
"typescript": "5.4.2",
"vite": "^5.0.7",
"vitest": "^1.0.4"
Expand Down
2 changes: 1 addition & 1 deletion src/actions/public/verifyHash.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Address } from 'abitype'

import { signatureToHex } from '../../accounts/index.js'
import type { Client } from '../../clients/createClient.js'
import type { Transport } from '../../clients/transports/createTransport.js'
import { universalSignatureValidatorAbi } from '../../constants/abis.js'
Expand All @@ -20,6 +19,7 @@ import {
import { type IsHexErrorType, isHex } from '../../utils/data/isHex.js'
import { type ToHexErrorType, bytesToHex } from '../../utils/encoding/toHex.js'
import { getAction } from '../../utils/getAction.js'
import { signatureToHex } from '../../utils/signature/signatureToHex.js'
import { type CallErrorType, type CallParameters, call } from './call.js'

export type VerifyHashParameters = Pick<
Expand Down
2 changes: 1 addition & 1 deletion src/actions/public/verifyMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
SignableMessage,
Signature,
} from '../../types/misc.js'
import { hashMessage } from '../../utils/index.js'
import { hashMessage } from '../../utils/signature/hashMessage.js'
import type { HashMessageErrorType } from '../../utils/signature/hashMessage.js'
import {
type VerifyHashErrorType,
Expand Down
12 changes: 6 additions & 6 deletions src/actions/public/watchEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import type { Filter } from '../../types/filter.js'
import type { Log } from '../../types/log.js'
import type { LogTopic } from '../../types/misc.js'
import type { GetPollOptions } from '../../types/transport.js'
import type { EncodeEventTopicsParameters } from '../../utils/index.js'
import {
type EncodeEventTopicsParameters,
encodeEventTopics,
} from '../../utils/abi/encodeEventTopics.js'
import { type ObserveErrorType, observe } from '../../utils/observe.js'
import { poll } from '../../utils/poll.js'
import { type StringifyErrorType, stringify } from '../../utils/stringify.js'
Expand All @@ -23,12 +26,9 @@ import {
import { InvalidInputRpcError } from '../../errors/rpc.js'
import type { ErrorType } from '../../errors/utils.js'
import type { BlockNumber } from '../../types/block.js'
import { decodeEventLog } from '../../utils/abi/decodeEventLog.js'
import { formatLog } from '../../utils/formatters/log.js'
import { getAction } from '../../utils/getAction.js'
import {
decodeEventLog,
encodeEventTopics,
formatLog,
} from '../../utils/index.js'
import {
type CreateEventFilterParameters,
createEventFilter,
Expand Down
10 changes: 5 additions & 5 deletions src/celo/fees.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Client } from '../clients/createClient.js'
import {
type Address,
type ChainEstimateFeesPerGasFnParameters,
type ChainFees,
type Hex,
import type {
Address,
ChainEstimateFeesPerGasFnParameters,
ChainFees,
Hex,
} from '../index.js'

import { formatters } from './formatters.js'
Expand Down
2 changes: 1 addition & 1 deletion src/chains/definitions/areonNetwork.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineChain } from '../../utils/chain/defineChain.js'

export const areonNetwork = defineChain({
export const areonNetwork = /*#__PURE__*/ defineChain({
id: 463,
name: 'Areon Network',
nativeCurrency: { decimals: 18, name: 'AREA', symbol: 'AREA' },
Expand Down
2 changes: 1 addition & 1 deletion src/chains/definitions/areonNetworkTestnet.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineChain } from '../../utils/chain/defineChain.js'

export const areonNetworkTestnet = defineChain({
export const areonNetworkTestnet = /*#__PURE__*/ defineChain({
id: 462,
name: 'Areon Network Testnet',
nativeCurrency: { decimals: 18, name: 'TAREA', symbol: 'TAREA' },
Expand Down
2 changes: 1 addition & 1 deletion src/chains/definitions/darwinia.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineChain } from '../../utils/chain/defineChain.js'

export const darwinia = defineChain({
export const darwinia = /*#__PURE__*/ defineChain({
id: 46,
name: 'Darwinia Network',
nativeCurrency: {
Expand Down
2 changes: 1 addition & 1 deletion src/chains/definitions/immutableZkEvmTestnet.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineChain } from '../../utils/chain/defineChain.js'

export const immutableZkEvmTestnet = defineChain({
export const immutableZkEvmTestnet = /*#__PURE__*/ defineChain({
id: 13473,
name: 'Immutable zkEVM Testnet',
nativeCurrency: {
Expand Down
2 changes: 1 addition & 1 deletion src/chains/definitions/reyaNetwork.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineChain } from '../../utils/chain/defineChain.js'

export const reyaNetwork = defineChain({
export const reyaNetwork = /*#__PURE__*/ defineChain({
id: 1729,
name: 'Reya Network',
nativeCurrency: { decimals: 18, name: 'Ether', symbol: 'ETH' },
Expand Down
2 changes: 1 addition & 1 deletion src/experimental/eip5792/actions/sendCalls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { OneOf } from '../../../types/utils.js'
import { parseAccount } from '../../../utils/accounts.js'
import type { RequestErrorType } from '../../../utils/buildRequest.js'
import { numberToHex } from '../../../utils/encoding/toHex.js'
import { getTransactionError } from '../../../utils/index.js'
import { getTransactionError } from '../../../utils/errors/getTransactionError.js'

export type SendCallsParameters<
chain extends Chain | undefined = Chain | undefined,
Expand Down
6 changes: 3 additions & 3 deletions src/utils/abi/parseEventLogs.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { Abi } from 'abitype'
import type { ErrorType } from '../../errors/utils.js'
import {
AbiEventSignatureNotFoundError,
DecodeLogDataMismatch,
DecodeLogTopicsMismatch,
type RpcLog,
} from '../../index.js'
} from '../../errors/abi.js'
import type { ErrorType } from '../../errors/utils.js'
import type { ContractEventName } from '../../types/contract.js'
import type { Log } from '../../types/log.js'
import type { RpcLog } from '../../types/rpc.js'
import {
type DecodeEventLogErrorType,
decodeEventLog,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/encoding/toRlp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseError } from '../../errors/base.js'
import type { ErrorType } from '../../errors/utils.js'
import { BaseError } from '../../index.js'
import type { ByteArray, Hex } from '../../types/misc.js'
import {
type CreateCursorErrorType,
Expand Down
8 changes: 2 additions & 6 deletions src/utils/signature/signatureToCompactSignature.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import type { ErrorType } from '../../errors/utils.js'
import type { CompactSignature, Signature } from '../../types/misc.js'
import {
type BytesToHexErrorType,
type HexToBytesErrorType,
bytesToHex,
hexToBytes,
} from '../index.js'
import { type HexToBytesErrorType, hexToBytes } from '../encoding/toBytes.js'
import { type BytesToHexErrorType, bytesToHex } from '../encoding/toHex.js'

export type SignatureToCompactSignatureErrorType =
| HexToBytesErrorType
Expand Down
5 changes: 4 additions & 1 deletion src/zksync/utils/assertEip712Request.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { ErrorType } from '../../errors/utils.js'
import { type AssertRequestErrorType, assertRequest } from '../../index.js'
import type { ExactPartial } from '../../types/utils.js'
import {
type AssertRequestErrorType,
assertRequest,
} from '../../utils/transaction/assertRequest.js'
import type { zkSync } from '../../zksync/chains.js'
import type { SendTransactionParameters } from '../actions/sendTransaction.js'
import { InvalidEip712TransactionError } from '../errors/transaction.js'
Expand Down

0 comments on commit e8c45db

Please sign in to comment.