Skip to content

Commit

Permalink
chore: add examples template
Browse files Browse the repository at this point in the history
  • Loading branch information
iosh committed Sep 12, 2024
1 parent e72ddcf commit f8363dc
Show file tree
Hide file tree
Showing 9 changed files with 256 additions and 104 deletions.
34 changes: 34 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Examples

The `examples/` directory is a growing & living folder, and open for contributions.


- Epoch
- [ ] Fetching Epoch
- [ ] Watching Epoch
- Clients
- [ ] Public (w/ HTTP, WebSocket, Fallback)
- [ ] Wallet – JSON-RPC Account (`window.fluent`)
- [ ] Wallet - JSON-RPC Account (WalletConnect v2)
- Contracts
- [ ] Deploying
- [ ] Reading
- [ ] Writing
- [ ] Multicall
- [ ] Call
- [ ] Events
- [ ] Simulating Method Calls
- Filters & Logs
- [ ] Blocks
- [ ] Pending Transactions
- [ ] Events
- Signatures
- [ ] Sign typed data
- [ ] + verify/recover address
- [ ] Sign message (+ recover message address)
- [ ] + verify/recover address
- Transactions
- [ ] Fetching Transactions & Receipts
- [ ] Transaction Types (EIP-1559, Legacy, etc)
- [ ] Simulating Transactions
- [ ] Sending Transactions (& Waiting for Receipt)
3 changes: 3 additions & 0 deletions examples/_template/README.md
Original file line number Diff line number Diff line change
@@ -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/PATH/TO/EXAMPLE/DIR)
17 changes: 17 additions & 0 deletions examples/_template/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<h1>_REPLACE ME_ Example</h1>
<div id="app">Loading...</div>
<script type="module">
import out from './index.ts';
document.querySelector('#app').innerHTML = Array.isArray(out)
? out.map(x => `<div style="margin-bottom: 16px;">${x}</div>`).join('')
: out;
</script>
</body>
</html>
11 changes: 11 additions & 0 deletions examples/_template/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { http, createPublicClient } from 'cive'
import { mainnet } from 'cive/chains'

const client = createPublicClient({
chain: mainnet,
transport: http(),
})

const epochNumber = await client.getEpochNumber()

export default [`epoch number: ${epochNumber}`]
15 changes: 15 additions & 0 deletions examples/_template/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "example-template",
"private": true,
"type": "module",
"scripts": {
"dev": "vite"
},
"dependencies": {
"cive": "latest"
},
"devDependencies": {
"typescript": "^5.0.3",
"vite": "^5.4.4"
}
}
19 changes: 19 additions & 0 deletions examples/_template/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ESNext", "DOM"],
"moduleResolution": "Node",
"strict": true,
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"noEmit": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"skipLibCheck": true
},
"include": ["src"]
}
Loading

0 comments on commit f8363dc

Please sign in to comment.