Skip to content

Commit 6e8058d

Browse files
committed
Update typescript config and fix type inference
1 parent aed7ceb commit 6e8058d

35 files changed

+614
-493
lines changed

.changeset/fuzzy-mugs-explode.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@3loop/transaction-interpreter': patch
3+
'@3loop/transaction-decoder': patch
4+
---
5+
6+
Update typescript config, compilation and fix type inference

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ yarn-error.log*
3434

3535
# vercel
3636
.vercel
37+
38+
*.tsbuildinfo

apps/docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@astrojs/starlight": "^0.21.5",
1919
"astro": "^4.15.2",
2020
"sharp": "^0.33.5",
21-
"typescript": "5.1.3"
21+
"typescript": "5.7.2"
2222
},
2323
"devDependencies": {
2424
"@typescript-eslint/parser": "^5.62.0",

apps/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
},
5454
"devDependencies": {
5555
"bufferutil": "^4.0.8",
56-
"typescript": "5.1.3",
56+
"typescript": "5.7.3",
5757
"utf-8-validate": "^6.0.4"
5858
}
5959
}

apps/web/src/app/calldata/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DecodeResult } from '@3loop/transaction-decoder'
1+
import type { DecodeResult } from '@3loop/transaction-decoder'
22

33
export interface CalldataParams {
44
data: string

apps/web/tsconfig.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{
2-
"extends": "tsconfig/nextjs.json",
32
"compilerOptions": {
43
"strict": true,
5-
"target": "ES2015",
64
"isolatedModules": true,
75
"downlevelIteration": true,
86
"exactOptionalPropertyTypes": false,
@@ -14,7 +12,17 @@
1412
"paths": {
1513
"@/*": ["./src/*"],
1614
"@3loop/transaction-decoder/*": ["../../packages/transaction-decoder/dist/*"]
17-
}
15+
},
16+
"lib": ["dom", "dom.iterable", "esnext"],
17+
"allowJs": true,
18+
"skipLibCheck": true,
19+
"noEmit": true,
20+
"incremental": true,
21+
"esModuleInterop": true,
22+
"module": "esnext",
23+
"moduleResolution": "node",
24+
"resolveJsonModule": true,
25+
"jsx": "preserve"
1826
},
1927
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
2028
"exclude": ["node_modules"]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
},
1515
"devDependencies": {
1616
"@changesets/cli": "^2.26.2",
17+
"@effect/language-service": "^0.1.0",
1718
"eslint": "^8.47.0",
1819
"prettier": "^3.0.2",
19-
"tsconfig": "workspace:*",
2020
"turbo": "2.1.1"
2121
},
2222
"packageManager": "pnpm@9.9.0",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/dist
22
jest.config.js
3-
*.d.ts
3+
*.tsbuildinfo
44
/example

packages/transaction-decoder/package.json

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,28 @@
88
"license": "GPL-3.0-only",
99
"type": "module",
1010
"exports": {
11+
"./dist/**/*.d.ts": "./dist/**/*.d.ts",
1112
".": {
1213
"require": "./dist/index.cjs",
1314
"import": "./dist/index.js",
1415
"types": "./dist/index.d.ts"
1516
},
1617
"./in-memory": {
17-
"import": {
18-
"types": "./dist/in-memory/index.d.ts",
19-
"default": "./dist/in-memory/index.js"
20-
},
21-
"require": {
22-
"types": "./dist/in-memory/index.d.cts",
23-
"default": "./dist/in-memory/index.cjs"
24-
},
2518
"types": "./dist/in-memory/index.d.ts",
26-
"default": "./dist/in-memory/index.js"
19+
"require": "./dist/in-memory/index.cjs",
20+
"import": "./dist/in-memory/index.js"
2721
},
2822
"./sql": {
29-
"import": {
30-
"types": "./dist/sql/index.d.ts",
31-
"default": "./dist/sql/index.js"
32-
},
33-
"require": {
34-
"types": "./dist/sql/index.d.cts",
35-
"default": "./dist/sql/index.cjs"
36-
},
3723
"types": "./dist/sql/index.d.ts",
38-
"default": "./dist/sql/index.js"
24+
"require": "./dist/sql/index.cjs",
25+
"import": "./dist/sql/index.js"
3926
}
4027
},
4128
"scripts": {
4229
"dev": "tsup --watch",
4330
"coverage": "vitest run --config ./vitest.config.mts --coverage",
44-
"build": "rm -rf dist && tsup",
31+
"build:types": "tsc -b ./tsconfig.types.json",
32+
"build": "rimraf dist && rimraf *.tsbuildinfo && tsup && pnpm run build:types",
4533
"check": "tsc --noEmit",
4634
"lint": "eslint --exit-on-fatal-error --ignore-path .eslintignore --ext .ts .",
4735
"fix": "eslint --ignore-path .eslintignore --ext .ts . --fix",
@@ -65,6 +53,7 @@
6553
}
6654
},
6755
"devDependencies": {
56+
"@swc/core": "^1.11.5",
6857
"@total-typescript/ts-reset": "^0.5.1",
6958
"@types/node": "^20.16.3",
7059
"@typescript-eslint/eslint-plugin": "^5.62.0",
@@ -77,10 +66,10 @@
7766
"glob": "^11.0.0",
7867
"prettier": "^2.8.8",
7968
"quickjs-emscripten": "^0.29.2",
69+
"rimraf": "^6.0.1",
8070
"ts-node": "^10.9.2",
81-
"tsconfig": "workspace:*",
8271
"tsup": "^7.2.0",
83-
"typescript": "5.1.3",
72+
"typescript": "5.7.3",
8473
"viem": "^2.23.2",
8574
"vite": "4.4.9",
8675
"vite-tsconfig-paths": "4.2.0",

packages/transaction-decoder/src/abi-loader.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Effect, Either, RequestResolver, Request, Array, pipe, Data, PrimaryKey, Schema, SchemaAST } from 'effect'
22
import { ContractABI } from './abi-strategy/request-model.js'
33
import { Abi } from 'viem'
4-
import { AbiParams, AbiStore } from './abi-store.js'
4+
import * as AbiStore from './abi-store.js'
55

66
interface LoadParameters {
77
readonly chainID: number
@@ -49,9 +49,9 @@ function makeRequestKey(key: AbiLoader) {
4949
return `abi::${key.chainID}:${key.address}:${key.event}:${key.signature}`
5050
}
5151

52-
const getMany = (requests: Array<AbiParams>) =>
52+
const getMany = (requests: Array<AbiStore.AbiParams>) =>
5353
Effect.gen(function* () {
54-
const { getMany, get } = yield* AbiStore
54+
const { getMany, get } = yield* AbiStore.AbiStore
5555

5656
if (getMany != null) {
5757
return yield* getMany(requests)
@@ -68,7 +68,7 @@ const getMany = (requests: Array<AbiParams>) =>
6868

6969
const setValue = (key: AbiLoader, abi: ContractABI | null) =>
7070
Effect.gen(function* () {
71-
const { set } = yield* AbiStore
71+
const { set } = yield* AbiStore.AbiStore
7272
yield* set(
7373
{
7474
chainID: key.chainID,
@@ -128,12 +128,12 @@ const getBestMatch = (abi: ContractABI | null) => {
128128
const AbiLoaderRequestResolver: Effect.Effect<
129129
RequestResolver.RequestResolver<AbiLoader, never>,
130130
never,
131-
AbiStore
131+
AbiStore.AbiStore
132132
> = RequestResolver.makeBatched((requests: Array<AbiLoader>) =>
133133
Effect.gen(function* () {
134134
if (requests.length === 0) return
135135

136-
const { strategies } = yield* AbiStore
136+
const { strategies } = yield* AbiStore.AbiStore
137137

138138
const requestGroups = Array.groupBy(requests, makeRequestKey)
139139
const uniqueRequests = Object.values(requestGroups).map((group) => group[0])
@@ -239,15 +239,15 @@ const AbiLoaderRequestResolver: Effect.Effect<
239239
},
240240
)
241241
}),
242-
).pipe(RequestResolver.contextFromServices(AbiStore), Effect.withRequestCaching(true))
242+
).pipe(RequestResolver.contextFromServices(AbiStore.AbiStore), Effect.withRequestCaching(true))
243243

244244
// TODO: When failing to decode with one ABI, we should retry with other resolved ABIs
245245
// We can decode with Effect.validateFirst(abis, (abi) => decodeMethod(input as Hex, abi)) and to find the first ABIs
246246
// that decodes successfully. We might enforce a sorted array to prioritize the address match. We will have to think
247247
// how to handle the strategy resolver in this case. Currently, we stop at first successful strategy, which might result
248248
// in a missing Fragment. We treat this issue as a minor one for now, as we epect it to occur rarely on contracts that
249249
// are not verified and with a non standard events structure.
250-
export const getAndCacheAbi = (params: AbiParams) =>
250+
export const getAndCacheAbi = (params: AbiStore.AbiParams) =>
251251
Effect.gen(function* () {
252252
if (params.event === '0x' || params.signature === '0x') {
253253
return yield* Effect.fail(new EmptyCalldataError(params))

0 commit comments

Comments
 (0)