Skip to content

Commit

Permalink
fix CI & build scripts (#46)
Browse files Browse the repository at this point in the history
* remove tsbuildinfo on build:type. needed to rebuild types_/

* don't error if buildinfo file DNE

* tweak typecheck script to ignore types_/

* chore: format

* update lockfile

* chore: format

* (temp) disable commit hook so I can separate a commit

* fix broken vitest (needs lint)

* lint

* re-enable pre-commit hook

* fix global window.ethereum definition

* remove old code

* ignore generated.ts

* ignore generated.ts in other tsconfi

* upgrade vite, vitest, disable non-test-related test errors, disable anvil tests

* upgrade vite, vitest, disable non-test-related test errors, disable anvil tests

* chore: format

---------

Co-authored-by: zeroXbrock <[email protected]>
  • Loading branch information
zeroXbrock and zeroXbrock authored Jun 21, 2024
1 parent 4c97f07 commit bede0f8
Show file tree
Hide file tree
Showing 30 changed files with 106 additions and 111 deletions.
Binary file modified bun.lockb
Binary file not shown.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "bun run clean && bun run build:cjs && bun run build:esm && bun run build:types",
"build:cjs": "tsc --project ./tsconfig.build.json --module commonjs --outDir ./src/_cjs --removeComments --verbatimModuleSyntax false && printf '{\"type\":\"commonjs\"}' > ./src/_cjs/package.json",
"build:esm": "tsc --project ./tsconfig.build.json --module es2015 --outDir ./src/_esm && printf '{\"type\": \"module\",\"sideEffects\":false}' > ./src/_esm/package.json",
"build:types": "tsc --project ./tsconfig.build.json --module esnext --declarationDir ./src/_types --emitDeclarationOnly --declaration --declarationMap",
"build:types": "rm -f tsconfig.build.tsbuildinfo && tsc --project ./tsconfig.build.json --module esnext --declarationDir ./src/_types --emitDeclarationOnly --declaration --declarationMap",
"changeset": "changeset",
"changeset:release": "bun run build && changeset publish",
"changeset:version": "changeset version && bun scripts/updateVersion.ts && bun install --lockfile-only",
Expand All @@ -27,11 +27,11 @@
"test:parser": "vitest -c ./test/vitest.config.ts ./src/chains/suave/parsers.test.ts",
"test:cov": "vitest dev -c ./test/vitest.config.ts --coverage",
"test:ci": "CI=true vitest -c ./test/vitest.config.ts --coverage --retry=3 --bail=1",
"test:typecheck": "SKIP_GLOBAL_SETUP=true vitest typecheck -c ./test/vitest.config.ts",
"test:typecheck": "SKIP_GLOBAL_SETUP=true vitest --typecheck.ignoreSourceErrors -c ./test/vitest.config.ts",
"test:ui": "vitest dev -c ./test/vitest.config.ts --ui",
"vectors": "bun test vectors/**/*.test.ts",
"vectors:generate": "bun vectors/generate.ts",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --project ./tsconfig.typecheck.json --module esnext --noEmit"
},
"devDependencies": {
"@actions/core": "1.10.0",
Expand All @@ -54,8 +54,8 @@
"simple-git-hooks": "^2.8.1",
"size-limit": "^8.2.4",
"typescript": "5.0.4",
"vite": "^4.4.2",
"vitest": "~0.34.3",
"vite": "^5.3.1",
"vitest": "^1.6.0",
"which-pm-runs": "^1.1.0"
},
"simple-git-hooks": {
Expand Down
9 changes: 6 additions & 3 deletions playgrounds/browser/src/components/actions/GetTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ function GetTransactionByHashAndIndex({ client }: { client: PublicClient }) {
const handleGetTransaction = async () => {
if (blockHash && index) {
setTransaction(
await client.getTransaction({ blockHash, index: parseInt(index) }),
await client.getTransaction({
blockHash,
index: Number.parseInt(index),
}),
)
}
}
Expand Down Expand Up @@ -111,7 +114,7 @@ function GetTransactionByNumberAndIndex({ client }: { client: PublicClient }) {
setTransaction(
await client.getTransaction({
blockNumber: BigInt(blockNumber),
index: parseInt(index),
index: Number.parseInt(index),
}),
)
}
Expand Down Expand Up @@ -159,7 +162,7 @@ function GetTransactionByTagAndIndex({ client }: { client: PublicClient }) {
setTransaction(
await client.getTransaction({
blockTag,
index: parseInt(index),
index: Number.parseInt(index),
}),
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WalletClient, parseEther } from 'viem'
import { type WalletClient, parseEther } from 'viem'
import { goerli } from 'viem/chains'

export function SendTransaction({ client }: { client: WalletClient }) {
Expand Down
2 changes: 1 addition & 1 deletion site/.vitepress/sidebar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DefaultTheme } from 'vitepress'
import type { DefaultTheme } from 'vitepress'

export const sidebar: DefaultTheme.Sidebar = {
'/docs/': [
Expand Down
2 changes: 1 addition & 1 deletion site/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {}
export type {}
2 changes: 1 addition & 1 deletion src/actions/wallet/signTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { AccountNotFoundError } from '../../errors/account.js'
import type { ErrorType } from '../../errors/utils.js'
import type { GetAccountParameter } from '../../types/account.js'
import type { Chain, GetChain } from '../../types/chain.js'
import { type RpcTransactionRequest } from '../../types/rpc.js'
import type { RpcTransactionRequest } from '../../types/rpc.js'
import type {
TransactionRequest,
TransactionSerializable,
Expand Down
2 changes: 1 addition & 1 deletion src/chains/celo/formatters.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ChainFormatters } from '../../types/chain.js'
import type { ChainFormatters } from '../../types/chain.js'
import type { Hash } from '../../types/misc.js'
import type { RpcTransaction } from '../../types/rpc.js'
import { hexToBigInt } from '../../utils/encoding/fromHex.js'
Expand Down
4 changes: 2 additions & 2 deletions src/chains/optimism/formatters.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type ChainFormatters } from '../../types/chain.js'
import type { ChainFormatters } from '../../types/chain.js'
import type { Hash } from '../../types/misc.js'
import { type RpcTransaction } from '../../types/rpc.js'
import type { RpcTransaction } from '../../types/rpc.js'
import { hexToBigInt } from '../../utils/encoding/fromHex.js'
import { defineBlock } from '../../utils/formatters/block.js'
import {
Expand Down
26 changes: 13 additions & 13 deletions src/chains/suave/formatters.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { zeroAddress } from '../../constants/address.js'
import { type ChainFormatters } from '../../types/chain.js'
import type { ChainFormatters } from '../../types/chain.js'
import type { Hash, Hex } from '../../types/misc.js'
import type { RpcTransaction } from '../../types/rpc.js'
import type {
Expand All @@ -22,16 +22,16 @@ import {
formatTransactionRequest,
} from '../../utils/formatters/transactionRequest.js'
import { suaveRigil } from '../index.js'
import {
type ConfidentialComputeRecord,
type RpcTransactionReceiptSuave,
type RpcTransactionRequestSuave,
type RpcTransactionSuave,
type SuaveBlockOverrides,
type SuaveTxType,
type TransactionReceiptSuave,
type TransactionRequestSuave,
type TransactionSuave,
import type {
ConfidentialComputeRecord,
RpcTransactionReceiptSuave,
RpcTransactionRequestSuave,
RpcTransactionSuave,
SuaveBlockOverrides,
SuaveTxType,
TransactionReceiptSuave,
TransactionRequestSuave,
TransactionSuave,
} from './types.js'

export const formattersSuave = {
Expand Down Expand Up @@ -75,7 +75,7 @@ export const formattersSuave = {
return {
// format original eth params as legacy tx
...formatTransaction({ ...args, type: '0x0' } as RpcTransaction),
chainId: parseInt(args.chainId, 16),
chainId: Number.parseInt(args.chainId, 16),
accessList: args.accessList,
// ... then replace and add fields as needed
gasPrice: hexToBigInt(args.gasPrice as Hex),
Expand All @@ -99,7 +99,7 @@ export const formattersSuave = {
confidentialInputsHash: args.requestRecord.confidentialInputsHash,
chainId:
args.requestRecord.chainId &&
parseInt(args.requestRecord.chainId, 16),
Number.parseInt(args.requestRecord.chainId, 16),
type: args.requestRecord.type,
typeHex: args.requestRecord.typeHex,
} as ConfidentialComputeRecord,
Expand Down
2 changes: 1 addition & 1 deletion src/chains/suave/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
hexToSignature,
keccak256,
} from '../../index.js'
import { type Hex } from '../../types/misc.js'
import type { Hex } from '../../types/misc.js'
import { suaveRigil } from '../index.js'
import {
serializeConfidentialComputeRecord,
Expand Down
2 changes: 1 addition & 1 deletion src/clients/transports/custom.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assertType, describe, expect, test, vi } from 'vitest'

import type { EIP1193RequestFn } from '../../index.js'
import '../../types/window.js'
import '../../types/global.js'
import { type CustomTransport, custom } from './custom.js'

vi.stubGlobal('window', {
Expand Down
62 changes: 14 additions & 48 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,42 +86,18 @@
},
"typesVersions": {
"*": {
"abi": [
"./_types/abi/index.d.ts"
],
"accounts": [
"./_types/accounts/index.d.ts"
],
"actions": [
"./_types/actions/index.d.ts"
],
"chains": [
"./_types/chains/index.d.ts"
],
"chains/utils": [
"./_types/chains/utils/index.d.ts"
],
"contract": [
"./_types/contract/index.d.ts"
],
"ens": [
"./_types/ens/index.d.ts"
],
"public": [
"./_types/public/index.d.ts"
],
"test": [
"./_types/test/index.d.ts"
],
"utils": [
"./_types/utils/index.d.ts"
],
"wallet": [
"./_types/wallet/index.d.ts"
],
"window": [
"./_types/window/index.d.ts"
]
"abi": ["./_types/abi/index.d.ts"],
"accounts": ["./_types/accounts/index.d.ts"],
"actions": ["./_types/actions/index.d.ts"],
"chains": ["./_types/chains/index.d.ts"],
"chains/utils": ["./_types/chains/utils/index.d.ts"],
"contract": ["./_types/contract/index.d.ts"],
"ens": ["./_types/ens/index.d.ts"],
"public": ["./_types/public/index.d.ts"],
"test": ["./_types/test/index.d.ts"],
"utils": ["./_types/utils/index.d.ts"],
"wallet": ["./_types/wallet/index.d.ts"],
"window": ["./_types/window/index.d.ts"]
}
},
"peerDependencies": {
Expand All @@ -145,22 +121,12 @@
},
"license": "MIT",
"repository": "flashbots/suave-viem",
"authors": [
"awkweb.eth",
"jxom.eth"
],
"authors": ["awkweb.eth", "jxom.eth"],
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/wagmi-dev"
}
],
"keywords": [
"eth",
"ethereum",
"dapps",
"wallet",
"web3",
"suave"
]
"keywords": ["eth", "ethereum", "dapps", "wallet", "web3", "suave"]
}
2 changes: 1 addition & 1 deletion src/types/window.ts → src/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { EIP1193Provider } from './eip1193.js'
import { type EIP1193Provider } from './eip1193.ts'

declare global {
interface Window {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/abi/decodeAbiParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ function decodeBytes<const TParam extends AbiParameter>(
return { consumed: 32, value }
}

const value = slice(data, position, position + parseInt(size), {
const value = slice(data, position, position + Number.parseInt(size), {
strict: true,
})
return { consumed: 32, value }
Expand All @@ -293,7 +293,7 @@ function decodeNumber<const TParam extends AbiParameter>(
{ param }: { param: TParam },
) {
const signed = param.type.startsWith('int')
const size = parseInt(param.type.split('int')[1] || '256')
const size = Number.parseInt(param.type.split('int')[1] || '256')
return {
consumed: 32,
value:
Expand Down
4 changes: 2 additions & 2 deletions src/utils/abi/encodeAbiParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ function encodeBytes<const TParam extends AbiParameter>(
encoded: concat([padHex(numberToHex(bytesSize, { size: 32 })), value_]),
}
}
if (bytesSize !== parseInt(paramSize))
if (bytesSize !== Number.parseInt(paramSize))
throw new AbiEncodingBytesSizeMismatchError({
expectedSize: parseInt(paramSize),
expectedSize: Number.parseInt(paramSize),
value,
})
return { dynamic: false, encoded: padHex(value, { dir: 'right' }) }
Expand Down
6 changes: 3 additions & 3 deletions src/utils/abi/encodePacked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function encode<const TPackedAbiType extends PackedAbiType | unknown>(
const intMatch = (type as string).match(integerRegex)
if (intMatch) {
const [_type, baseType, bits = '256'] = intMatch
const size = parseInt(bits) / 8
const size = Number.parseInt(bits) / 8
return numberToHex(value as number, {
size: isArray ? 32 : size,
signed: baseType === 'int',
Expand All @@ -117,9 +117,9 @@ function encode<const TPackedAbiType extends PackedAbiType | unknown>(
const bytesMatch = (type as string).match(bytesRegex)
if (bytesMatch) {
const [_type, size] = bytesMatch
if (parseInt(size) !== ((value as Hex).length - 2) / 2)
if (Number.parseInt(size) !== ((value as Hex).length - 2) / 2)
throw new BytesSizeMismatchError({
expectedSize: parseInt(size),
expectedSize: Number.parseInt(size),
givenSize: ((value as Hex).length - 2) / 2,
})
return pad(value as Hex, { dir: 'right', size: isArray ? 32 : null }) as Hex
Expand Down
3 changes: 2 additions & 1 deletion src/utils/buildRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ export function buildRequest<TRequest extends (args: any) => Promise<any>>(
// If we find a Retry-After header, let's retry after the given time.
if (error && error instanceof HttpRequestError) {
const retryAfter = error?.headers?.get('Retry-After')
if (retryAfter?.match(/\d/)) return parseInt(retryAfter) * 1000
if (retryAfter?.match(/\d/))
return Number.parseInt(retryAfter) * 1000
}

// Otherwise, let's retry with an exponential backoff.
Expand Down
2 changes: 1 addition & 1 deletion src/utils/ccip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Abi, Address } from 'abitype'

import { type CallParameters, call } from '../actions/public/call.js'
import type { Transport } from '../clients/transports/createTransport.js'
import { type BaseError } from '../errors/base.js'
import type { BaseError } from '../errors/base.js'
import {
OffchainLookupError,
OffchainLookupResponseMalformedError,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/ens/avatar/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export function parseNftUri(uri_: string): ParsedNft {
throw new EnsAvatarInvalidNftUriError({ reason: 'ERC namespace not found' })

return {
chainID: parseInt(chainID),
chainID: Number.parseInt(chainID),
namespace: erc_namespace.toLowerCase(),
contractAddress: contractAddress as Address,
tokenID,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/promise/withCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export type WithCacheParameters = {
*/
export async function withCache<TData>(
fn: () => Promise<TData>,
{ cacheKey, cacheTime = Infinity }: WithCacheParameters,
{ cacheKey, cacheTime = Number.POSITIVE_INFINITY }: WithCacheParameters,
) {
const cache = getCache<TData>(cacheKey)

Expand Down
2 changes: 1 addition & 1 deletion src/utils/transaction/serializeAccessList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { ErrorType } from '../../errors/utils.js'
import type { Hex } from '../../types/misc.js'
import type { AccessList } from '../../types/transaction.js'
import { type IsAddressErrorType, isAddress } from '../address/isAddress.js'
import { type RecursiveArray } from '../encoding/toRlp.js'
import type { RecursiveArray } from '../encoding/toRlp.js'

export type SerializeAccessListErrorType =
| InvalidStorageKeySizeErrorType
Expand Down
6 changes: 3 additions & 3 deletions src/utils/typedData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function validateTypedData<
// and will throw.
numberToHex(value, {
signed: base === 'int',
size: parseInt(size_) / 8,
size: Number.parseInt(size_) / 8,
})
}

Expand All @@ -67,9 +67,9 @@ export function validateTypedData<
const bytesMatch = type.match(bytesRegex)
if (bytesMatch) {
const [_type, size_] = bytesMatch
if (size_ && size(value as Hex) !== parseInt(size_))
if (size_ && size(value as Hex) !== Number.parseInt(size_))
throw new BytesSizeMismatchError({
expectedSize: parseInt(size_),
expectedSize: Number.parseInt(size_),
givenSize: size(value as Hex),
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/window/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import '../types/window.js'
import '../types/global.js'
Loading

0 comments on commit bede0f8

Please sign in to comment.