Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.0 #57

Merged
merged 46 commits into from
Sep 28, 2023
Merged

v1.0 #57

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
51e3d32
docs(changeset): Restructure directory layout and extends viem client"
kyscott18 Sep 20, 2023
c17fe9d
RELEASING: Releasing 1 package(s)
kyscott18 Sep 20, 2023
a8eb6ed
prerelease
kyscott18 Sep 20, 2023
89be0b8
refactor erc721 abi, remove id field
kyscott18 Sep 22, 2023
88a51b0
pass full request to reads
kyscott18 Sep 22, 2023
a7b45b7
Fix: bug with getERC20 return type
kyscott18 Sep 22, 2023
0f4896b
erc721 and 1155 base assets
kyscott18 Sep 22, 2023
2ebc824
Merge pull request #53 from kyscott18/721
kyscott18 Sep 22, 2023
be2f35f
Merge pull request #54 from kyscott18/req
kyscott18 Sep 22, 2023
a8d3004
Merge pull request #55 from kyscott18/base
kyscott18 Sep 22, 2023
64ac88a
docs(changeset): bug fixes
kyscott18 Sep 22, 2023
d3f56e8
RELEASING: Releasing 1 package(s)
kyscott18 Sep 22, 2023
c147f62
release new version
kyscott18 Sep 25, 2023
d2dc6f3
wallet action decorator
kyscott18 Sep 25, 2023
ac2f203
Merge pull request #56 from kyscott18/decorator
kyscott18 Sep 25, 2023
f2de386
RELEASING: Releasing 0 package(s)
kyscott18 Sep 25, 2023
89add6a
docs(changeset): Add decorator to extend viem
kyscott18 Sep 25, 2023
388d0db
RELEASING: Releasing 1 package(s)
kyscott18 Sep 25, 2023
9a45a2b
version
kyscott18 Sep 25, 2023
959bd95
docs
kyscott18 Sep 26, 2023
32b3f29
change to write contract
kyscott18 Sep 26, 2023
ad4046c
docs(changeset): Change wallet actions to write contract
kyscott18 Sep 26, 2023
0237238
RELEASING: Releasing 1 package(s)
kyscott18 Sep 26, 2023
a7d3912
p
kyscott18 Sep 26, 2023
4eb30d2
rename docs
kyscott18 Sep 26, 2023
b94a7ee
Revert "change to write contract"
kyscott18 Sep 26, 2023
459498d
minify
kyscott18 Sep 26, 2023
c385d61
update readme
kyscott18 Sep 26, 2023
1934924
Update README.md
kyscott18 Sep 26, 2023
28dc03e
Update README.md
kyscott18 Sep 26, 2023
5b2e356
Update README.md
kyscott18 Sep 26, 2023
8d6298d
docs
kyscott18 Sep 26, 2023
df7fbab
Update example.md
kyscott18 Sep 26, 2023
e59663d
example
kyscott18 Sep 26, 2023
08c222a
docs
kyscott18 Sep 27, 2023
d0747f8
update deps
kyscott18 Sep 27, 2023
22f43d0
docs(changeset): Update dependencies, revert simulate changes
kyscott18 Sep 27, 2023
0b511f0
RELEASING: Releasing 1 package(s)
kyscott18 Sep 27, 2023
681174b
publish next 4
kyscott18 Sep 27, 2023
89db9c0
cleanup mono
kyscott18 Sep 27, 2023
b286801
docs
kyscott18 Sep 27, 2023
aa84cff
more docs
kyscott18 Sep 28, 2023
348afa7
try fix actions #1
kyscott18 Sep 28, 2023
cd53366
try fix actions #2
kyscott18 Sep 28, 2023
ec34933
RELEASING: Releasing 2 package(s)
kyscott18 Sep 28, 2023
a32f4ab
publish
kyscott18 Sep 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 38 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,77 @@
# Reverse Mirage [![GitHub Actions][gha-badge]][gha] [![npm version][npm-badge]][npm] [![npm bundle size][bundle-badge]][bundle]
# Reverse Mirage [![GitHub Actions][gha-badge]][gha] [![npm version][npm-badge]][npm]

[gha]: https://github.com/kyscott18/reverse-mirage/actions
[gha-badge]: https://github.com/kyscott18/reverse-mirage/actions/workflows/main.yml/badge.svg
[npm]: https://www.npmjs.com/package/reverse-mirage/v/latest
[npm-badge]: https://img.shields.io/npm/v/reverse-mirage/latest.svg
[bundle]: https://bundlephobia.com/result?p=reverse-mirage@latest
[bundle-badge]:https://img.shields.io/bundlephobia/minzip/reverse-mirage/latest.svg

Application level typescript utilities for Ethereum.
Building blocks for Ethereum app development. Built using [Viem](https://viem.sh).

## Features

- ✅ ~30x faster than `@uniswap/sdk-core`
- ✅ 10x-100x faster, 10.4x smaller than [`@uniswap/sdk-core`](https://github.com/uniswap/sdk-core)
- ✅ Abstactions for most commonly used token standards
- ✅ Supports `permit`
- ✅ Extensible to build apps and libraries
- ✅ Seamless extension to [Viem](https://github.com/wagmi-dev/viem)
- ✅ TypeScript ready
- ✅ Test suite running against [forked](https://ethereum.org/en/glossary/#fork) Ethereum network
- ✅ Test suite running against local Ethereum network

## Example

```ts
import { createPublicClient, http } from 'viem'
import {publicActions, amountToNumber} from 'reverse-mirage'
import { mainnet } from 'viem/chains'
import { publicActionsReverseMirage, amountToNumber } from 'reverse-mirage'

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

// read token metadata
const usdc = await publicClient.getERC20({
address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // usdc
id: mainnet.id
})

console.log(usdc.decimals) // 6
console.log(usdc.name) // USD Coin

// read a balance
const vitalikBalance = await publicClient.getERC20Balance({
erc20: usdc,
address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' // vitalik
})

console.log(vitalikBalance.amount) // 420690000n
console.log(amountToNumber(vitalikBalance)) // 420.69
```

## Installation

```sh
$ npm i reverse-mirage
```

## Benchmarks

Benchmarks are done with [mitata](https://github.com/evanwashere/mitata). To reproduce:

```sh
$ cd packages/core/
$ bun run src/amount/utils.bench.ts
```

### Results

* amount add: `reverse mirage` **8.17x** faster than `@uniswap/sdk-core`
* amount equal to: `reverse-mirage` **10.63x** faster than `@uniswap/sdk-core`
* amount to number: `reverse-mirage` **136.14x** faster than `@uniswap/sdk-core`
* amount to significant: `reverse-mirage` **30.03x** faster than `@uniswap/sdk-core`

## Bundle Size

`reverse-mirage`: **5.12 kB**

`@uniswap/sdk-core`: **53.4 kB**
65 changes: 21 additions & 44 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,34 @@ import { defineConfig } from "vitepress";
export default defineConfig({
title: "Reverse Mirage",
description: "Application level typescript utilities for Ethereum",
head: [["script", { src: "/_vercel/insights/script.js" }]],
head: [
["script", { src: "https://cdn.vercel-insights.com/v1/script.debug.js" }],
],
themeConfig: {
search: {
provider: "local",
},

sidebar: [
{ text: "Introduction", link: "/" },
{
text: "Introduction",
text: "Overview",
items: [
{ text: "Getting started", link: "/" },
{ text: "Installation", link: "/installation" },
{ text: "Getting started", link: "/start" },
{ text: "Benchmarks", link: "/benchmark" },
{ text: "Examples", link: "/example" },
],
},
{
text: "ERC20",
collapsed: true,
items: [
{ text: "Introduction", link: "" },

{
text: "Utilities",
items: [
{
text: "createERC20",
link: "",
link: "/erc20/createERC20",
},
{
text: "createERC20Amount",
Expand Down Expand Up @@ -102,19 +104,19 @@ export default defineConfig({
text: "Wallet Actions",
items: [
{
text: "simulateERC20Transfer",
text: "writeERC20Transfer",
link: "",
},
{
text: "simulateERC20Approve",
text: "writeERC20Approve",
link: "",
},
{
text: "simulateERC20TransferFrom",
text: "writeERC20TransferFrom",
link: "",
},
{
text: "simulateERC20Permit",
text: "writeERC20Permit",
link: "",
},
{
Expand All @@ -129,7 +131,6 @@ export default defineConfig({
text: "Native",
collapsed: true,
items: [
{ text: "Introduction", link: "" },
{
text: "Utilities",
items: [
Expand All @@ -154,8 +155,6 @@ export default defineConfig({
text: "WETH",
collapsed: true,
items: [
{ text: "Introduction", link: "" },

{
text: "Utilities",
items: [
Expand All @@ -169,11 +168,11 @@ export default defineConfig({
text: "Wallet Actions",
items: [
{
text: "simulateWETHDeposit",
text: "writeWETHDeposit",
link: "",
},
{
text: "simulateWETHWithdraw",
text: "writeWETHWithdraw",
link: "",
},
],
Expand All @@ -184,7 +183,6 @@ export default defineConfig({
text: "ERC721",
collapsed: true,
items: [
{ text: "Introduction", link: "" },
{
text: "Utilities",
items: [
Expand All @@ -196,10 +194,6 @@ export default defineConfig({
text: "createERC721Data",
link: "",
},
{
text: "createERC721DataID",
link: "",
},
],
},
{
Expand Down Expand Up @@ -245,25 +239,21 @@ export default defineConfig({
text: "getERC721Data",
link: "",
},
{
text: "getERC721DataID",
link: "",
},
],
},
{
text: "Wallet Actions",
items: [
{
text: "simulateERC721Transfer",
text: "writeERC721Transfer",
link: "",
},
{
text: "simulateERC721Approve",
text: "writeERC721Approve",
link: "",
},
{
text: "simulateERC721SetApprovalForAll",
text: "writeERC721SetApprovalForAll",
link: "",
},
],
Expand All @@ -274,7 +264,6 @@ export default defineConfig({
text: "ERC1155",
collapsed: true,
items: [
{ text: "Introduction", link: "" },
{
text: "Utilities",
items: [
Expand Down Expand Up @@ -313,15 +302,15 @@ export default defineConfig({
text: "Wallet Actions",
items: [
{
text: "simulateERC1155Transfer",
text: "writeERC1155Transfer",
link: "",
},
{
text: "simulateERC1155TransferBatch",
text: "writeERC1155TransferBatch",
link: "",
},
{
text: "simulateERC1155SetApprovalForAll",
text: "writeERC1155SetApprovalForAll",
link: "",
},
],
Expand All @@ -332,7 +321,6 @@ export default defineConfig({
text: "Amount",
collapsed: true,
items: [
{ text: "Introduction", link: "" },
{
text: "createAmountFromString",
link: "",
Expand Down Expand Up @@ -387,7 +375,6 @@ export default defineConfig({
text: "Price",
collapsed: true,
items: [
{ text: "Introduction", link: "" },
{
text: "createPrice",
link: "",
Expand Down Expand Up @@ -458,7 +445,6 @@ export default defineConfig({
text: "Fraction",
collapsed: true,
items: [
{ text: "Introduction", link: "" },
{
text: "createFraction",
link: "",
Expand Down Expand Up @@ -517,15 +503,6 @@ export default defineConfig({
text: "Chains",
link: "",
},
{
text: "Utilities",
items: [
{
text: "getQueryKey",
link: "",
},
],
},
],

socialLinks: [
Expand Down
14 changes: 14 additions & 0 deletions docs/benchmark.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Benchmarks

## Results

* amount add: `reverse mirage` **8.17x** faster than `@uniswap/sdk-core`
* amount equal to: `reverse-mirage` **10.63x** faster than `@uniswap/sdk-core`
* amount to number: `reverse-mirage` **136.14x** faster than `@uniswap/sdk-core`
* amount to significant: `reverse-mirage` **30.03x** faster than `@uniswap/sdk-core`

## Bundle Size

`reverse-mirage`: **5.12 kB**

`@uniswap/sdk-core`: **53.4 kB**
41 changes: 41 additions & 0 deletions docs/erc20/createERC20.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
head:
- - meta
- property: og:title
content: createERC20
- - meta
- name: description
content: Create an erc20.
- - meta
- property: og:description
content: Creates an erc20.

---

# createERC20

Creates an `erc20`.

## Usage

::: code-group

```ts [example.ts]
import { createERC20 } from 'reverse-mirage'

const usdc = createERC20({ // [!code focus:7]
address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
name: 'USD Coin',
symbol: 'USDC',
decimals: 6,
chainID: 1,
})
```

:::

## Returns

`erc20`

The erc20 token that was just created.
12 changes: 12 additions & 0 deletions docs/example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Examples

A [beta interface](https://github.com/kyscott18/reverse-mirage/tree/v1/examples/next-interface) has been built using `reverse-mirage`.

## Features

* Runs on an anvil local node
* Query balances, automatically update after transactions
* Transfer test tokens
* Reset node state from interface

<img width="1014" alt="Screenshot 2023-09-26 at 5 25 36 PM" src="https://github.com/kyscott18/reverse-mirage/assets/43524469/406b46d3-9777-44b0-92c6-c236a7e16c28">
Loading