Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tall-bulldogs-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@3loop/transaction-decoder': minor
---

Bump effect version to stable 3
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
CHANGELOG.md
**/node_modules
**/dist
**/test/**/*.json

10 changes: 5 additions & 5 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"semi": false,
"tabWidth": 2,
"printWidth": 120,
"singleQuote": true,
"trailingComma": "all"
"semi": false,
"tabWidth": 2,
"printWidth": 120,
"singleQuote": true,
"trailingComma": "all"
}
6 changes: 1 addition & 5 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"recommendations": [
"astro-build.astro-vscode",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
],
"recommendations": ["astro-build.astro-vscode", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode"],
"unwantedRecommendations": []
}
2 changes: 1 addition & 1 deletion apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
"eslint-plugin-astro": "^0.31.0",
"eslint-plugin-mdx": "^2.3.2"
}
}
}
4 changes: 2 additions & 2 deletions apps/docs/src/content/docs/guides/effect-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ const MainLayer = Layer.provideMerge(PublicClientLive, LoadersLayer)
5. Fetch and decode a transaction

```ts
const program = Effect.gen(function* (_) {
const program = Effect.gen(function* () {
const hash = '0xab701677e5003fa029164554b81e01bede20b97eda0e2595acda81acf5628f75'
const chainID = 5

return yield* _(decodeTransactionByHash(hash, chainID))
return yield* decodeTransactionByHash(hash, chainID)
})
```

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "astro/tsconfigs/base"
}
}
2 changes: 1 addition & 1 deletion apps/web/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"components": "@/components",
"utils": "@/lib/utils"
}
}
}
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"autoprefixer": "10.4.15",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"effect": "^2.4.18",
"effect": "^3.0.5",
"eslint": "^8.47.0",
"eslint-config-next": "13.4.19",
"jsonata": "^2.0.3",
Expand Down
106 changes: 49 additions & 57 deletions apps/web/src/lib/contract-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,45 +33,41 @@ export const AbiStoreLive = Layer.succeed(
],
},
set: ({ address = {} }) =>
Effect.gen(function* (_) {
Effect.gen(function* () {
const addressMatches = Object.entries(address)

// Cache all addresses
yield* _(
Effect.all(
addressMatches.map(([key, value]) =>
Effect.promise(() =>
prisma.contractAbi
.create({
data: {
address: key,
abi: value,
},
})
.catch((e) => {
console.error('Failed to cache abi', e)
return null
}),
),
yield* Effect.all(
addressMatches.map(([key, value]) =>
Effect.promise(() =>
prisma.contractAbi
.create({
data: {
address: key,
abi: value,
},
})
.catch((e) => {
console.error('Failed to cache abi', e)
return null
}),
),
{
concurrency: 'inherit',
batching: 'inherit',
},
),
{
concurrency: 'inherit',
batching: 'inherit',
},
)
}),
get: ({ address }) =>
Effect.gen(function* (_) {
Effect.gen(function* () {
const normAddress = address.toLowerCase()
const cached = yield* _(
Effect.promise(() =>
prisma.contractAbi.findFirst({
where: {
address: normAddress,
},
}),
),
const cached = yield* Effect.promise(() =>
prisma.contractAbi.findFirst({
where: {
address: normAddress,
},
}),
)

if (cached != null) {
Expand All @@ -85,8 +81,8 @@ export const AbiStoreLive = Layer.succeed(
// TODO: Provide context of RPCProvider
export const ContractMetaStoreLive = Layer.effect(
ContractMetaStore,
Effect.gen(function* (_) {
const publicClient = yield* _(PublicClient)
Effect.gen(function* () {
const publicClient = yield* PublicClient
const erc20Loader = ERC20RPCStrategyResolver(publicClient)
const nftLoader = NFTRPCStrategyResolver(publicClient)

Expand All @@ -95,38 +91,34 @@ export const ContractMetaStoreLive = Layer.effect(
default: [erc20Loader, nftLoader],
},
get: ({ address, chainID }) =>
Effect.gen(function* (_) {
Effect.gen(function* () {
const normAddress = address.toLowerCase()
const data = yield* _(
Effect.tryPromise(
() =>
prisma.contractMeta.findFirst({
where: {
address: normAddress,
chainID: chainID,
},
}) as Promise<ContractData | null>,
).pipe(Effect.catchAll((_) => Effect.succeed(null))),
)
const data = yield* Effect.tryPromise(
() =>
prisma.contractMeta.findFirst({
where: {
address: normAddress,
chainID: chainID,
},
}) as Promise<ContractData | null>,
).pipe(Effect.catchAll((_) => Effect.succeed(null)))

return data
}),
set: ({ address, chainID }, contractMeta) =>
Effect.gen(function* (_) {
Effect.gen(function* () {
const normAddress = address.toLowerCase()

yield* _(
Effect.tryPromise(() =>
prisma.contractMeta.create({
data: {
...contractMeta,
decimals: contractMeta.decimals ?? 0,
address: normAddress,
chainID: chainID,
},
}),
).pipe(Effect.catchAll((_) => Effect.succeed(null))),
)
yield* Effect.tryPromise(() =>
prisma.contractMeta.create({
data: {
...contractMeta,
decimals: contractMeta.decimals ?? 0,
address: normAddress,
chainID: chainID,
},
}),
).pipe(Effect.catchAll((_) => Effect.succeed(null)))
}),
})
}),
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"dev": "turbo run dev",
"lint": "turbo run lint",
"fix": "turbo run fix",
"check": "prettier --check \"**/*.{ts,tsx,md}\"",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"check": "prettier --check \"**/*.{ts,tsx,json,md}\"",
"format": "prettier --write \"**/*.{ts,tsx,json,md}\"",
"version": "changeset version && pnpm install --no-frozen-lockfile && pnpm format",
"publish-packages": "pnpm run build && changeset publish",
"test": "turbo run test",
Expand All @@ -21,4 +21,4 @@
},
"packageManager": "pnpm@8.6.10",
"name": "@3loop/decoder-monorepo"
}
}
2 changes: 1 addition & 1 deletion packages/eslint-config-custom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-sort-export-all": "^1.4.1"
}
}
}
4 changes: 2 additions & 2 deletions packages/transaction-decoder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ const MainLayer = Layer.provideMerge(PublicClientLive, LoadersLayer)
5. Fetch and decode a transaction

```ts
const program = Effect.gen(function* (_) {
const program = Effect.gen(function* () {
const hash = '0xab701677e5003fa029164554b81e01bede20b97eda0e2595acda81acf5628f75'
const chainID = 5

return yield* _(decodeTransactionByHash(hash, chainID))
return yield* decodeTransactionByHash(hash, chainID)
})
```

Expand Down
Loading