diff --git a/examples/README.md b/examples/README.md
index 925eb23..62b1749 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -22,7 +22,7 @@ The `examples/` directory is a growing & living folder, and open for contributio
- Filters & Logs
- [ ] Blocks
- [ ] Pending Transactions
- - [ ] Events
+ - [x] Events
- Signatures
- [ ] Sign typed data
- [ ] + verify/recover address
diff --git a/examples/logs_block_event_logs/README.md b/examples/logs_block_event_logs/README.md
new file mode 100644
index 0000000..b7b1660
--- /dev/null
+++ b/examples/logs_block_event_logs/README.md
@@ -0,0 +1,3 @@
+# _REPLACE ME_ Example
+
+[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github.com/iosh/cive/tree/main/examples/logs_block_event_logs)
\ No newline at end of file
diff --git a/examples/logs_block_event_logs/index.html b/examples/logs_block_event_logs/index.html
new file mode 100644
index 0000000..4940b90
--- /dev/null
+++ b/examples/logs_block_event_logs/index.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+ Block event logs Example
+ Loading...
+
+
+
diff --git a/examples/logs_block_event_logs/index.tsx b/examples/logs_block_event_logs/index.tsx
new file mode 100644
index 0000000..41de479
--- /dev/null
+++ b/examples/logs_block_event_logs/index.tsx
@@ -0,0 +1,9 @@
+import React from 'react'
+import ReactDOM from 'react-dom/client'
+import App from './src/App'
+import 'bulma/css/bulma.css'
+ReactDOM.createRoot(document.getElementById('app') as HTMLElement).render(
+
+
+ ,
+)
diff --git a/examples/logs_block_event_logs/package.json b/examples/logs_block_event_logs/package.json
new file mode 100644
index 0000000..f0f68bc
--- /dev/null
+++ b/examples/logs_block_event_logs/package.json
@@ -0,0 +1,21 @@
+{
+ "name": "logs_block_event_logs",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "dev": "vite"
+ },
+ "dependencies": {
+ "bulma": "^1.0.2",
+ "cive": "latest",
+ "react": "^18.3.1",
+ "react-dom": "^18.3.1"
+ },
+ "devDependencies": {
+ "@types/react": "^18.3.8",
+ "@types/react-dom": "^18.3.0",
+ "@vitejs/plugin-react": "^4.3.1",
+ "typescript": "^5.6.2",
+ "vite": "^5.4.4"
+ }
+}
diff --git a/examples/logs_block_event_logs/src/App.tsx b/examples/logs_block_event_logs/src/App.tsx
new file mode 100644
index 0000000..a752c87
--- /dev/null
+++ b/examples/logs_block_event_logs/src/App.tsx
@@ -0,0 +1,83 @@
+import { http, createPublicClient } from 'cive'
+import { mainnet } from 'cive/chains'
+import { useCallback, useState } from 'react'
+
+const client = createPublicClient({
+ chain: mainnet,
+ transport: http(),
+})
+export default function App() {
+ const [logs, setLogs] = useState('')
+
+ const handleClick = useCallback(async () => {
+ const epochNumber = await client.getEpochNumber()
+ const logs = await client.getLogs({
+ fromEpoch: epochNumber - 10n,
+ toEpoch: epochNumber,
+ })
+ setLogs(
+ JSON.stringify(
+ logs,
+ (_, value) => (typeof value === 'bigint' ? value.toString() : value),
+ 2,
+ ),
+ )
+ }, [])
+
+ const handleGetLogsWithEvent = useCallback(async () => {
+ const epochNumber = await client.getEpochNumber()
+ const logs = await client.getLogs({
+ fromEpoch: epochNumber - 50n,
+ toEpoch: epochNumber,
+ events: [
+ {
+ inputs: [
+ {
+ indexed: true,
+ name: 'from',
+ type: 'address',
+ },
+ {
+ indexed: true,
+ name: 'to',
+ type: 'address',
+ },
+ {
+ indexed: false,
+ name: 'value',
+ type: 'uint256',
+ },
+ ],
+ name: 'Transfer',
+ type: 'event',
+ },
+ ] as const,
+ })
+ setLogs(
+ JSON.stringify(
+ logs,
+ (_, value) => (typeof value === 'bigint' ? value.toString() : value),
+ 2,
+ ),
+ )
+ }, [])
+
+ return (
+
+
+
+
+
+
+
+ {logs}
+
+
+
+
+ )
+}
diff --git a/examples/logs_block_event_logs/tsconfig.json b/examples/logs_block_event_logs/tsconfig.json
new file mode 100644
index 0000000..f0a2350
--- /dev/null
+++ b/examples/logs_block_event_logs/tsconfig.json
@@ -0,0 +1,24 @@
+{
+ "compilerOptions": {
+ "target": "ES2020",
+ "useDefineForClassFields": true,
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
+ "module": "ESNext",
+ "skipLibCheck": true,
+
+ /* Bundler mode */
+ "moduleResolution": "bundler",
+ "allowImportingTsExtensions": true,
+ "isolatedModules": true,
+ "moduleDetection": "force",
+ "noEmit": true,
+ "jsx": "react-jsx",
+
+ /* Linting */
+ "strict": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noFallthroughCasesInSwitch": true
+ },
+ "include": ["src"]
+}
diff --git a/examples/logs_block_event_logs/vite.config.ts b/examples/logs_block_event_logs/vite.config.ts
new file mode 100644
index 0000000..36f7f4e
--- /dev/null
+++ b/examples/logs_block_event_logs/vite.config.ts
@@ -0,0 +1,7 @@
+import react from '@vitejs/plugin-react'
+import { defineConfig } from 'vite'
+
+// https://vitejs.dev/config/
+export default defineConfig({
+ plugins: [react()],
+})
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 520d24d..396486e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -388,6 +388,37 @@ importers:
specifier: ^5.4.4
version: 5.4.4(@types/node@20.14.10)
+ examples/logs_block_event_logs:
+ dependencies:
+ bulma:
+ specifier: ^1.0.2
+ version: 1.0.2
+ cive:
+ specifier: latest
+ version: 0.5.0(typescript@5.6.3)(zod@3.23.8)
+ react:
+ specifier: ^18.3.1
+ version: 18.3.1
+ react-dom:
+ specifier: ^18.3.1
+ version: 18.3.1(react@18.3.1)
+ devDependencies:
+ '@types/react':
+ specifier: ^18.3.8
+ version: 18.3.11
+ '@types/react-dom':
+ specifier: ^18.3.0
+ version: 18.3.0
+ '@vitejs/plugin-react':
+ specifier: ^4.3.1
+ version: 4.3.1(vite@5.4.4(@types/node@20.14.10))
+ typescript:
+ specifier: ^5.6.2
+ version: 5.6.3
+ vite:
+ specifier: ^5.4.4
+ version: 5.4.4(@types/node@20.14.10)
+
site:
dependencies:
'@types/react':
@@ -425,10 +456,10 @@ importers:
version: 1.3.0
abitype:
specifier: 0.0.0-canary-20240628164201
- version: 0.0.0-canary-20240628164201(patch_hash=yiz5fjudrr2lf4j276yxiakvp4)(typescript@5.6.2)(zod@3.23.8)
+ version: 0.0.0-canary-20240628164201(patch_hash=yiz5fjudrr2lf4j276yxiakvp4)(typescript@5.6.3)(zod@3.23.8)
viem:
specifier: ^2.20.0
- version: 2.20.0(bufferutil@4.0.8)(typescript@5.6.2)(utf-8-validate@6.0.4)(zod@3.23.8)
+ version: 2.20.0(bufferutil@4.0.8)(typescript@5.6.3)(utf-8-validate@6.0.4)(zod@3.23.8)
test:
dependencies:
@@ -3762,6 +3793,11 @@ packages:
engines: {node: '>=14.17'}
hasBin: true
+ typescript@5.6.3:
+ resolution: {integrity: sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==}
+ engines: {node: '>=14.17'}
+ hasBin: true
+
ua-parser-js@1.0.38:
resolution: {integrity: sha512-Aq5ppTOfvrCMgAPneW1HfWj66Xi7XL+/mIy996R1/CLS/rcyJQm6QZdsKrUeivDFQ+Oc9Wyuwor8Ze8peEoUoQ==}
@@ -5404,11 +5440,21 @@ snapshots:
typescript: 5.6.2
zod: 3.23.8
+ abitype@0.0.0-canary-20240628164201(patch_hash=yiz5fjudrr2lf4j276yxiakvp4)(typescript@5.6.3)(zod@3.23.8):
+ optionalDependencies:
+ typescript: 5.6.3
+ zod: 3.23.8
+
abitype@1.0.5(typescript@5.6.2)(zod@3.23.8):
optionalDependencies:
typescript: 5.6.2
zod: 3.23.8
+ abitype@1.0.5(typescript@5.6.3)(zod@3.23.8):
+ optionalDependencies:
+ typescript: 5.6.3
+ zod: 3.23.8
+
accepts@1.3.8:
dependencies:
mime-types: 2.1.35
@@ -5674,7 +5720,21 @@ snapshots:
'@scure/bip32': 1.4.0
'@scure/bip39': 1.3.0
abitype: 0.0.0-canary-20240628164201(patch_hash=yiz5fjudrr2lf4j276yxiakvp4)(typescript@5.6.2)(zod@3.23.8)
- viem: 2.20.0(bufferutil@4.0.8)(typescript@5.6.2)(utf-8-validate@6.0.4)(zod@3.23.8)
+ viem: 2.20.0(typescript@5.6.2)(zod@3.23.8)
+ transitivePeerDependencies:
+ - bufferutil
+ - typescript
+ - utf-8-validate
+ - zod
+
+ cive@0.5.0(typescript@5.6.3)(zod@3.23.8):
+ dependencies:
+ '@noble/curves': 1.4.2
+ '@noble/hashes': 1.4.0
+ '@scure/bip32': 1.4.0
+ '@scure/bip39': 1.3.0
+ abitype: 0.0.0-canary-20240628164201(patch_hash=yiz5fjudrr2lf4j276yxiakvp4)(typescript@5.6.3)(zod@3.23.8)
+ viem: 2.20.0(typescript@5.6.3)(zod@3.23.8)
transitivePeerDependencies:
- bufferutil
- typescript
@@ -7945,6 +8005,8 @@ snapshots:
typescript@5.6.2: {}
+ typescript@5.6.3: {}
+
ua-parser-js@1.0.38: {}
ufo@1.5.3: {}
@@ -8068,7 +8130,25 @@ snapshots:
unist-util-stringify-position: 4.0.0
vfile-message: 4.0.2
- viem@2.20.0(bufferutil@4.0.8)(typescript@5.6.2)(utf-8-validate@6.0.4)(zod@3.23.8):
+ viem@2.20.0(bufferutil@4.0.8)(typescript@5.6.3)(utf-8-validate@6.0.4)(zod@3.23.8):
+ dependencies:
+ '@adraffy/ens-normalize': 1.10.0
+ '@noble/curves': 1.4.0
+ '@noble/hashes': 1.4.0
+ '@scure/bip32': 1.4.0
+ '@scure/bip39': 1.3.0
+ abitype: 1.0.5(typescript@5.6.3)(zod@3.23.8)
+ isows: 1.0.4(ws@8.17.1(bufferutil@4.0.8)(utf-8-validate@6.0.4))
+ webauthn-p256: 0.0.5
+ ws: 8.17.1(bufferutil@4.0.8)(utf-8-validate@6.0.4)
+ optionalDependencies:
+ typescript: 5.6.3
+ transitivePeerDependencies:
+ - bufferutil
+ - utf-8-validate
+ - zod
+
+ viem@2.20.0(typescript@5.6.2)(zod@3.23.8):
dependencies:
'@adraffy/ens-normalize': 1.10.0
'@noble/curves': 1.4.0
@@ -8086,6 +8166,24 @@ snapshots:
- utf-8-validate
- zod
+ viem@2.20.0(typescript@5.6.3)(zod@3.23.8):
+ dependencies:
+ '@adraffy/ens-normalize': 1.10.0
+ '@noble/curves': 1.4.0
+ '@noble/hashes': 1.4.0
+ '@scure/bip32': 1.4.0
+ '@scure/bip39': 1.3.0
+ abitype: 1.0.5(typescript@5.6.3)(zod@3.23.8)
+ isows: 1.0.4(ws@8.17.1(bufferutil@4.0.8)(utf-8-validate@6.0.4))
+ webauthn-p256: 0.0.5
+ ws: 8.17.1(bufferutil@4.0.8)(utf-8-validate@6.0.4)
+ optionalDependencies:
+ typescript: 5.6.3
+ transitivePeerDependencies:
+ - bufferutil
+ - utf-8-validate
+ - zod
+
vite-node@1.6.0(@types/node@20.14.10):
dependencies:
cac: 6.7.14