Skip to content

Commit e4e529c

Browse files
committed
feat: init
0 parents  commit e4e529c

36 files changed

+9094
-0
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "restricted",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}

.github/actions/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# .github/actions
2+
3+
Reusable actions that are used in other actions are here
4+
5+
## setup
6+
7+
Setups forge pnpm node and caches node modules

.github/actions/setup/action.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Setup
2+
runs:
3+
using: composite
4+
steps:
5+
- uses: pnpm/action-setup@v2
6+
with:
7+
version: 9.12.0
8+
9+
- uses: actions/setup-node@v3
10+
with:
11+
node-version-file: ".nvmrc"
12+
registry-url: https://registry.npmjs.org
13+
cache: pnpm
14+
15+
- name: Install node modules
16+
run: pnpm install --frozen-lockfile
17+
shell: bash

.github/workflows/release.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Version
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
jobs:
11+
version:
12+
name: Release
13+
runs-on: ubuntu-latest
14+
environment: release
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
id-token: write
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
with:
23+
submodules: recursive
24+
25+
- name: "Setup"
26+
uses: ./.github/actions/setup
27+
28+
- name: Build
29+
shell: bash
30+
run: pnpm build
31+
32+
- name: Set deployment token
33+
run: npm config set '//registry.npmjs.org/:_authToken' "${{ secrets.NPM_TOKEN }}"
34+
35+
- name: Handle Release Pull Request or Publish to npm
36+
id: changesets
37+
uses: changesets/action@v1
38+
with:
39+
title: "chore: version packages"
40+
commit: "chore: version packages"
41+
publish: pnpm release:publish
42+
version: pnpm release:version
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
46+

.github/workflows/verify.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Verify
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
10+
jobs:
11+
lint:
12+
name: Lint
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 5
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v3
19+
20+
- name: Set up pnpm
21+
uses: pnpm/action-setup@v2
22+
with:
23+
version: 8
24+
25+
- name: Set up node
26+
uses: actions/setup-node@v3
27+
with:
28+
cache: pnpm
29+
node-version: 18
30+
31+
- name: Install dependencies
32+
run: pnpm install
33+
34+
- name: Lint code
35+
run: pnpm format && pnpm lint
36+
37+
types:
38+
name: Types
39+
runs-on: ubuntu-latest
40+
timeout-minutes: 5
41+
42+
steps:
43+
- name: Checkout code
44+
uses: actions/checkout@v3
45+
46+
- name: Set up pnpm
47+
uses: pnpm/action-setup@v2
48+
with:
49+
version: 8
50+
51+
- name: Set up node
52+
uses: actions/setup-node@v3
53+
with:
54+
cache: pnpm
55+
node-version: 18
56+
57+
- name: Install dependencies
58+
run: pnpm install
59+
60+
- name: Check types
61+
run: pnpm typecheck

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
bench
25+
_lib
26+
_cjs
27+
_esm
28+
_types
29+
dist
30+
cache
31+
node_modules
32+
tsconfig*.tsbuildinfo
33+
*.tgz
34+
vitest.config.ts.timestamp*

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ignore-workspace-root-check=true
2+

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18.12.1

.scripts/preconstruct.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import fs from 'node:fs/promises'
2+
import path from 'node:path'
3+
import { glob } from 'fast-glob'
4+
5+
// Get all package.json files
6+
const packagePaths = await glob('**/package.json', {
7+
ignore: ['**/dist/**', '**/node_modules/**'],
8+
})
9+
10+
let _count = 0
11+
for (const packagePath of packagePaths) {
12+
type Package = {
13+
bin?: Record<string, string> | undefined
14+
exports?:
15+
| Record<string, { types: string; default: string } | string>
16+
| undefined
17+
name?: string | undefined
18+
private?: boolean | undefined
19+
}
20+
const file = Bun.file(packagePath)
21+
const packageJson = (await file.json()) as Package
22+
23+
// Skip private packages
24+
if (packageJson.private) continue
25+
if (!packageJson.exports) continue
26+
27+
_count += 1
28+
29+
const dir = path.resolve(path.dirname(packagePath))
30+
31+
// Empty dist directory
32+
const distDirName = '_lib'
33+
const dist = path.resolve(dir, distDirName)
34+
let files: string[] = []
35+
try {
36+
files = await fs.readdir(dist)
37+
} catch {
38+
await fs.mkdir(dist)
39+
}
40+
41+
const promises: Promise<void>[] = []
42+
for (const file of files) {
43+
promises.push(
44+
fs.rm(path.join(dist, file), { recursive: true, force: true }),
45+
)
46+
}
47+
await Promise.all(promises)
48+
49+
// Link exports to dist locations
50+
for (const [key, exports] of Object.entries(packageJson.exports)) {
51+
// Skip `package.json` exports
52+
if (/package\.json$/.test(key)) continue
53+
54+
let entries: any
55+
if (typeof exports === 'string')
56+
entries = [
57+
['default', exports],
58+
['types', exports.replace('.js', '.d.ts')],
59+
]
60+
else entries = Object.entries(exports)
61+
62+
// Link exports to dist locations
63+
for (const [, value] of entries as [
64+
type: 'types' | 'default',
65+
value: string,
66+
][]) {
67+
const srcDir = path.resolve(
68+
dir,
69+
path.dirname(value).replace(distDirName, ''),
70+
)
71+
const srcFilePath = path.resolve(srcDir, 'index.ts')
72+
73+
const distDir = path.resolve(dir, path.dirname(value))
74+
const distFileName = path.basename(value)
75+
const distFilePath = path.resolve(distDir, distFileName)
76+
77+
await fs.mkdir(distDir, { recursive: true })
78+
79+
// Symlink src to dist file
80+
await fs.symlink(srcFilePath, distFilePath, 'file').catch(() => {})
81+
}
82+
}
83+
}

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023-present Vladyslav Dalechyn
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<p align="center">
2+
<a href="https://viem-quoter.vercel.app/">
3+
<h1>Viem Quoter</h1>
4+
</a>
5+
</p>
6+
7+
<p align="center">
8+
Viem extension for quoting prices from different DEXes across all chains
9+
<p>
10+
11+
<br>
12+
13+
## Features
14+
15+
- Get UniswapV3 ETH price or any other pool quote.
16+
- Seamless extension to [Viem](https://github.com/wagmi-dev/viem)
17+
- TypeScript ready
18+
19+
## Overview
20+
21+
```ts
22+
import { publicViemQuoterActions } from 'viem-quoter'
23+
import { createPublicClient, http } from 'viem'
24+
import { mainnet } from 'viem/chains'
25+
26+
const publicClient = createPublicClient({
27+
chain: mainnet,
28+
transport: http(),
29+
}).extend(publicViemQuoterActions)
30+
31+
console.log(await publicClient.getUniswapV3EthPrice())
32+
```
33+
34+
## Authors
35+
36+
- [@dalechyn](https://github.com/dalechyn) (dalechyn.eth [Twitter](https://twitter.com/dalechyn) [Warpcast](https://warpcast.com/dalechyn.eth))
37+
38+
## License
39+
40+
[MIT](LICENSE.md) License

0 commit comments

Comments
 (0)