Skip to content

Commit

Permalink
📦 feat: Add @evmts/viem package (#473)
Browse files Browse the repository at this point in the history
## Description

Added new package @evmts/viem for using evmts with viem

## Testing

Explain the quality checks that have been done on the code changes

## Additional Information

- [ ] I read the [contributing docs](../docs/contributing.md) (if this
is your first contribution)

Your ENS/address:

---------

Co-authored-by: Will Cory <[email protected]>
  • Loading branch information
roninjin10 and Will Cory authored Sep 18, 2023
1 parent dbc2da6 commit 9f44e3f
Show file tree
Hide file tree
Showing 19 changed files with 3,044 additions and 940 deletions.
52 changes: 52 additions & 0 deletions .changeset/empty-queens-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
"@evmts/viem": minor
---

Added new package @evmts/viem as a new way to wrap viem with evmts functionality

# @evmts/viem

A [viem](https://viem.sh) extension for integrating viem with EVMts. [Extensions](https://viem.sh/docs/clients/custom.html) allow plugins to decorate viem clients with additional functionality.

## Installation

#### npm:

```bash
npm install @viem/evmts-extension
```

#### pnpm:

```bash
pnpm install @viem/evmts-extension
```
#### bun:

```bash
bun install @viem/evmts-extension
```

#### yarn:

```bash
yarn add @viem/evmts-extension
```
## Basic Usage

```typescript
import { getContractFromEvmts } from '@evmts/viem'
import { publicClient } from './client'

const contract = getContractFromEvmts({
evmts: await import('./MyContract.sol'),
publicClient,
})

// 2. Call contract methods, listen to events, etc.
const result = await contract.read.totalSupply()
const unwatch = contract.watchEvent.Transfer(
{ from: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e' },
{ onLogs(logs) { console.log(logs) } }
)
```
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ jobs:
with:
name: "@evmts/core"
working-directory: "./core"
- name: 'Report @evmts/viem Coverage'
if: always() # Also generate the report if tests are failing
uses: davelosert/vitest-coverage-report-action@v2
with:
name: "@evmts/viem"
working-directory: "./viem"
- name: 'Report @evmts/ethers Coverage'
if: always() # Also generate the report if tests are failing
uses: davelosert/vitest-coverage-report-action@v2
Expand Down
2 changes: 1 addition & 1 deletion bundlers/bundler/src/unplugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const evmtsUnplugin = createUnplugin(unpluginFn)
// Hacks to make types portable
// we should manually type these at some point

export const vitePluginEvmts = evmtsUnplugin.vite as typeof evmtsUnplugin.rollup
export const vitePluginEvmts = evmtsUnplugin.vite as any as typeof evmtsUnplugin.rollup
export const rollupPluginEvmts = evmtsUnplugin.rollup
export const esbuildPluginEvmts = evmtsUnplugin.esbuild
export const webpackPluginEvmts =
Expand Down
Loading

1 comment on commit 9f44e3f

@vercel
Copy link

@vercel vercel bot commented on 9f44e3f Sep 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

evmts-docs – ./

evmts-docs-evmts.vercel.app
evmts.dev
evmts-docs-git-main-evmts.vercel.app

Please sign in to comment.