Skip to content

Commit a6d534a

Browse files
authored
Update effect to stable version (#25)
* Update effect to stable version * Update web to stable effect
1 parent 53588d8 commit a6d534a

File tree

21 files changed

+113
-136
lines changed

21 files changed

+113
-136
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@3loop/transaction-decoder": minor
3+
---
4+
5+
Update Effect to stable version

apps/web/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"class-variance-authority": "^0.7.0",
3131
"clsx": "^2.0.0",
3232
"cmdk": "^0.2.0",
33-
"effect": "^2.0.0-next.27",
33+
"effect": "^2.0.3",
3434
"eslint": "^8.47.0",
3535
"eslint-config-next": "13.4.19",
3636
"ethers": "^6.6.2",
@@ -46,7 +46,9 @@
4646
"usehooks-ts": "^2.9.1"
4747
},
4848
"devDependencies": {
49+
"bufferutil": "^4.0.8",
4950
"prisma": "^5.2.0",
50-
"typescript": "5.1.3"
51+
"typescript": "5.1.3",
52+
"utf-8-validate": "^6.0.3"
5153
}
52-
}
54+
}

apps/web/src/app/tx/[chainID]/[hash]/form.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ export default function DecodingForm({
4545

4646
const router = useRouter();
4747

48-
const onSubmit = (e) => {
48+
const onSubmit = (e: React.FormEvent<HTMLFormElement>) => {
4949
e.preventDefault();
50-
const hash = e.target.hash.value;
50+
const hash = (e.target as any).hash.value;
5151
router.push(`/tx/${currentChainID}/${hash}`);
5252
};
5353

apps/web/src/components/ui/network-select.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@ export function NetworkSelect(props: SelectProps) {
1515
const router = useRouter();
1616
const params = useParams();
1717

18-
const onValueChange = (newChainID) => {
18+
const onValueChange = (newChainID: string) => {
1919
router.push(`/tx/${newChainID}`);
2020
};
2121

22+
const chainID = (params.chainID as string) ?? props.defaultValue;
23+
2224
return (
23-
<Select
24-
defaultValue={props.defaultValue}
25-
onValueChange={onValueChange}
26-
value={params.chainID as string}
27-
>
25+
<Select onValueChange={onValueChange} value={chainID}>
2826
<SelectTrigger className="w-[180px]">
2927
<SelectValue placeholder="Select a network" />
3028
</SelectTrigger>

apps/web/src/lib/decode.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Effect, Layer, pipe } from "effect";
1+
import { Effect, Layer, Runtime, Scope, pipe } from "effect";
22
import { RPCProviderLive } from "./rpc-provider";
33
import {
44
decodeTransactionByHash,
@@ -7,13 +7,7 @@ import {
77
import { AbiStoreLive, ContractMetaStoreLive } from "./contract-loader";
88

99
const LoadersLayer = Layer.mergeAll(AbiStoreLive, ContractMetaStoreLive);
10-
const MainLayer = Layer.provideMerge(RPCProviderLive, LoadersLayer);
11-
12-
const customRuntime = pipe(
13-
Layer.toRuntime(MainLayer),
14-
Effect.scoped,
15-
Effect.runSync,
16-
);
10+
const MainLayer = LoadersLayer.pipe(Layer.provideMerge(RPCProviderLive));
1711

1812
export async function decodeTransaction({
1913
chainID,
@@ -22,10 +16,12 @@ export async function decodeTransaction({
2216
chainID: number;
2317
hash: string;
2418
}): Promise<DecodedTx | undefined> {
25-
return decodeTransactionByHash(hash, chainID)
26-
.pipe(Effect.provideSomeRuntime(customRuntime), Effect.runPromise)
27-
.catch((error: unknown) => {
28-
console.error("Decode error", JSON.stringify(error, null, 2));
29-
return undefined;
30-
});
19+
const runnable = Effect.provide(
20+
decodeTransactionByHash(hash, chainID),
21+
MainLayer,
22+
);
23+
return Effect.runPromise(runnable).catch((error: unknown) => {
24+
console.error("Decode error", JSON.stringify(error, null, 2));
25+
return undefined;
26+
});
3127
}

apps/web/src/lib/prisma.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import { PrismaClient } from "@prisma/client";
22

33
let prisma: PrismaClient;
44

5+
declare global {
6+
var prisma: PrismaClient;
7+
}
8+
59
if (process.env.NODE_ENV === "production") {
610
prisma = new PrismaClient();
711
} else {

apps/web/src/lib/rpc-provider.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import { JsonRpcProvider } from "ethers";
77
import { Layer, Effect } from "effect";
88
import { supportedChains } from "@/app/data";
99

10-
const providerConfigs = supportedChains.reduce((acc, config) => {
11-
return {
12-
...acc,
13-
[config.chainID]: config,
14-
};
15-
}, {});
10+
const providerConfigs: Record<string, (typeof supportedChains)[number]> =
11+
supportedChains.reduce((acc, config) => {
12+
return {
13+
...acc,
14+
[config.chainID]: config,
15+
};
16+
}, {});
1617

1718
const providers: Record<number, RPCProviderObject> = {};
1819

apps/web/tsconfig.json

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
11
{
22
"extends": "tsconfig/nextjs.json",
33
"compilerOptions": {
4-
"exactOptionalPropertyTypes": false,
4+
"strict": true,
55
"target": "ES2015",
66
"isolatedModules": true,
77
"downlevelIteration": true,
8+
"exactOptionalPropertyTypes": false,
89
"plugins": [
910
{
1011
"name": "next"
1112
}
1213
],
1314
"paths": {
14-
"@/*": [
15-
"./src/*"
16-
]
15+
"@/*": ["./src/*"]
1716
}
1817
},
19-
"include": [
20-
"next-env.d.ts",
21-
"**/*.ts",
22-
"**/*.tsx",
23-
".next/types/**/*.ts"
24-
],
25-
"exclude": [
26-
"node_modules"
27-
]
18+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
19+
"exclude": ["node_modules"]
2820
}

packages/transaction-decoder/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Requirements
44

55
- TypeScript 5.x
6-
- `exactOptionalPropertyTypes` and `strict` enabled in your tsconfig.json
6+
- `strict` enabled in your tsconfig.json
77

88
## Getting Started
99

@@ -182,7 +182,7 @@ const program = Effect.gen(function* (_) {
182182
183183
```ts
184184
const customRuntime = pipe(Layer.toRuntime(MainLayer), Effect.scoped, Effect.runSync)
185-
const result = await program.pipe(Effect.provideSomeRuntime(customRuntime), Effect.runPromise)
185+
const result = await program.pipe(Effect.provide(customRuntime), Effect.runPromise)
186186
```
187187
188188
## ABI Strategies

packages/transaction-decoder/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,20 @@
4141
"README.md"
4242
],
4343
"peerDependencies": {
44-
"@effect/schema": "^0.33.2",
45-
"effect": "^2.0.0-next.31",
44+
"@effect/schema": "^0.59.1",
45+
"effect": "^2.0.3",
4646
"ethers": "^6.6.2",
4747
"jsonata": "^2.0.3"
4848
},
4949
"devDependencies": {
50-
"@effect/schema": "^0.33.2",
50+
"@effect/schema": "^0.59.1",
5151
"@total-typescript/ts-reset": "^0.5.1",
5252
"@types/node": "^20.6.0",
5353
"@types/traverse": "^0.6.35",
5454
"@typescript-eslint/eslint-plugin": "^5.59.6",
5555
"@typescript-eslint/parser": "^5.59.6",
5656
"@vitest/coverage-v8": "0.34.2",
57-
"effect": "2.0.0-next.31",
57+
"effect": "2.0.3",
5858
"eslint": "^8.49.0",
5959
"eslint-config-custom": "workspace:*",
6060
"eslint-config-prettier": "^8.10.0",

0 commit comments

Comments
 (0)