Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
dalechyn committed Oct 12, 2024
0 parents commit e4e529c
Show file tree
Hide file tree
Showing 36 changed files with 9,094 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
7 changes: 7 additions & 0 deletions .github/actions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# .github/actions

Reusable actions that are used in other actions are here

## setup

Setups forge pnpm node and caches node modules
17 changes: 17 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Setup
runs:
using: composite
steps:
- uses: pnpm/action-setup@v2
with:
version: 9.12.0

- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
registry-url: https://registry.npmjs.org
cache: pnpm

- name: Install node modules
run: pnpm install --frozen-lockfile
shell: bash
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Version

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
version:
name: Release
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: "Setup"
uses: ./.github/actions/setup

- name: Build
shell: bash
run: pnpm build

- name: Set deployment token
run: npm config set '//registry.npmjs.org/:_authToken' "${{ secrets.NPM_TOKEN }}"

- name: Handle Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
title: "chore: version packages"
commit: "chore: version packages"
publish: pnpm release:publish
version: pnpm release:version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

61 changes: 61 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Verify
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Set up node
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: 18

- name: Install dependencies
run: pnpm install

- name: Lint code
run: pnpm format && pnpm lint

types:
name: Types
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Set up node
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: 18

- name: Install dependencies
run: pnpm install

- name: Check types
run: pnpm typecheck
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
bench
_lib
_cjs
_esm
_types
dist
cache
node_modules
tsconfig*.tsbuildinfo
*.tgz
vitest.config.ts.timestamp*
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore-workspace-root-check=true

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.12.1
83 changes: 83 additions & 0 deletions .scripts/preconstruct.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import fs from 'node:fs/promises'
import path from 'node:path'
import { glob } from 'fast-glob'

// Get all package.json files
const packagePaths = await glob('**/package.json', {
ignore: ['**/dist/**', '**/node_modules/**'],
})

let _count = 0
for (const packagePath of packagePaths) {
type Package = {
bin?: Record<string, string> | undefined
exports?:
| Record<string, { types: string; default: string } | string>
| undefined
name?: string | undefined
private?: boolean | undefined
}
const file = Bun.file(packagePath)
const packageJson = (await file.json()) as Package

// Skip private packages
if (packageJson.private) continue
if (!packageJson.exports) continue

_count += 1

const dir = path.resolve(path.dirname(packagePath))

// Empty dist directory
const distDirName = '_lib'
const dist = path.resolve(dir, distDirName)
let files: string[] = []
try {
files = await fs.readdir(dist)
} catch {
await fs.mkdir(dist)
}

const promises: Promise<void>[] = []
for (const file of files) {
promises.push(
fs.rm(path.join(dist, file), { recursive: true, force: true }),
)
}
await Promise.all(promises)

// Link exports to dist locations
for (const [key, exports] of Object.entries(packageJson.exports)) {
// Skip `package.json` exports
if (/package\.json$/.test(key)) continue

let entries: any
if (typeof exports === 'string')
entries = [
['default', exports],
['types', exports.replace('.js', '.d.ts')],
]
else entries = Object.entries(exports)

// Link exports to dist locations
for (const [, value] of entries as [
type: 'types' | 'default',
value: string,
][]) {
const srcDir = path.resolve(
dir,
path.dirname(value).replace(distDirName, ''),
)
const srcFilePath = path.resolve(srcDir, 'index.ts')

const distDir = path.resolve(dir, path.dirname(value))
const distFileName = path.basename(value)
const distFilePath = path.resolve(distDir, distFileName)

await fs.mkdir(distDir, { recursive: true })

// Symlink src to dist file
await fs.symlink(srcFilePath, distFilePath, 'file').catch(() => {})
}
}
}
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023-present Vladyslav Dalechyn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<p align="center">
<a href="https://viem-quoter.vercel.app/">
<h1>Viem Quoter</h1>
</a>
</p>

<p align="center">
Viem extension for quoting prices from different DEXes across all chains
<p>

<br>

## Features

- Get UniswapV3 ETH price or any other pool quote.
- Seamless extension to [Viem](https://github.com/wagmi-dev/viem)
- TypeScript ready

## Overview

```ts
import { publicViemQuoterActions } from 'viem-quoter'
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'

const publicClient = createPublicClient({
chain: mainnet,
transport: http(),
}).extend(publicViemQuoterActions)

console.log(await publicClient.getUniswapV3EthPrice())
```

## Authors

- [@dalechyn](https://github.com/dalechyn) (dalechyn.eth [Twitter](https://twitter.com/dalechyn) [Warpcast](https://warpcast.com/dalechyn.eth))

## License

[MIT](LICENSE.md) License
Loading

0 comments on commit e4e529c

Please sign in to comment.