Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
abs3ntdev committed May 27, 2024
2 parents 4a351cd + 7ab8e52 commit d6c5eb7
Show file tree
Hide file tree
Showing 25 changed files with 1,054 additions and 53 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-taxis-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": patch
---

Added Redstone chain.
5 changes: 0 additions & 5 deletions .changeset/sixty-sloths-move.md

This file was deleted.

41 changes: 0 additions & 41 deletions .github/workflows/canary.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Snapshot
on:
workflow_dispatch:

jobs:
canary:
name: Release snapshot version
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
timeout-minutes: 5

steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Install dependencies
uses: ./.github/actions/install-dependencies

- name: Publish Snapshots
continue-on-error: true
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# https://docs.npmjs.com/generating-provenance-statements
NPM_CONFIG_PROVENANCE: true
run: |
snapshot=$(git branch --show-current | tr -cs '[:alnum:]-' '-' | tr '[:upper:]' '[:lower:]' | sed 's/-$//')
npm config set "//registry.npmjs.org/:_authToken" "$NPM_TOKEN"
bun run clean
bun run changeset version --no-git-tag --snapshot $snapshot
bun run changeset:prepublish
bun run changeset publish --no-git-tag --snapshot $snapshot --tag $snapshot
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"build:trustedSetups:end": "mv src/node/trustedSetups.ts src/node/trustedSetups_cjs.ts && mv src/node/trustedSetups_esm.ts src/node/trustedSetups.ts",
"build:types": "tsc --project ./tsconfig.build.json --module esnext --declarationDir ./src/_types --emitDeclarationOnly --declaration --declarationMap",
"changeset": "changeset",
"changeset:prepublish": "bun run version:update && bun scripts/prepublishOnly && bun run build",
"changeset:prepublish": "bun run version:update && bun scripts/prepublishOnly.ts && bun run build",
"changeset:publish": "bun run changeset:prepublish && changeset publish",
"changeset:version": "changeset version && bun install --lockfile-only && bun version:update",
"clean": "rimraf src/_esm src/_cjs src/_types",
Expand Down
4 changes: 2 additions & 2 deletions site/pages/docs/compatibility.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Platform Compatibility [Platforms compatible with Viem]

**viem supports all modern browsers (Chrome, Edge, Firefox, etc) & runtime environments (Node 18+, Deno, Bun, etc).**
**Viem supports all modern browsers (Chrome, Edge, Firefox, etc) & runtime environments (Node 18+, Deno, Bun, etc).**

viem uses modern EcmaScript features such as:
Viem uses modern EcmaScript features such as:

- [`BigInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)
- [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
Expand Down
78 changes: 78 additions & 0 deletions site/pages/docs/installation.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Installation

Install Viem via your package manager, a `<script>` tag, or build from source.

## Package Manager

Install the required packages.

:::code-group
```bash [pnpm]
pnpm add viem
```

```bash [npm]
npm install viem
```

```bash [yarn]
yarn add viem
```

```bash [bun]
bun add wagmi viem@{{viemVersion}} @tanstack/react-query
```
:::

## CDN

If you're not using a package manager, you can also use Viem via an ESM-compatible CDN such as [esm.sh](https://esm.sh). Simply add a `<script type="module">` tag to the bottom of your HTML file with the following content.

```html
<script type="module">
import { createClient } from 'https://esm.sh/viem'
</script>
```

## Using Unreleased Commits

If you can't wait for a new release to test the latest features, you can either install from the `canary` tag (tracks the [`main`](https://github.com/wevm/viem/tree/main) branch).

:::code-group
```bash [pnpm]
pnpm add viem@canary
```

```bash [npm]
npm install viem@canary
```

```bash [yarn]
yarn add viem@canary
```

```bash [bun]
bun add viem@canary
```
:::

Or clone the [Viem repo](https://github.com/wevm/viem) to your local machine, build, and link it yourself.

```bash
gh repo clone wevm/viem
cd viem
bun install
bun run build
bun link --global
```

Then go to the project where you are using Viem and run `bun link --global viem` (or the package manager that you used to link Viem globally).

## Security

Ethereum-related projects are often targeted in attacks to steal users' assets. Make sure you follow security best-practices for your project. Some quick things to get started.

- Pin package versions, upgrade mindfully, and inspect lockfile changes to minimize the risk of [supply-chain attacks](https://nodejs.org/en/guides/security/#supply-chain-attacks).
- Install the [Socket Security](https://socket.dev) [GitHub App](https://github.com/apps/socket-security) to help detect and block supply-chain attacks.
- Add a [Content Security Policy](https://cheatsheetseries.owasp.org/cheatsheets/Content_Security_Policy_Cheat_Sheet.html) to defend against external scripts running in your app.

171 changes: 171 additions & 0 deletions site/pages/experimental/erc7115/issuePermissions.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
---
description: Request permissions from a wallet to perform actions on behalf of a user.
---

# issuePermissions

Request permissions from a wallet to perform actions on behalf of a user.

[Read more.](https://eips.ethereum.org/EIPS/eip-7115)

:::warning[Warning]
This is an experimental action that is not supported in most wallets. It is recommended to have a fallback mechanism if using this in production.
:::

## Usage

:::code-group

```ts twoslash [example.ts]
import { parseEther } from 'viem'
import { account, walletClient } from './config'

const result = await walletClient.issuePermissions({ // [!code focus:99]
account,
expiry: 1716846083638,
permissions: [
{
type: 'native-token-limit',
data: {
amount: parseEther('0.5'),
},
required: true,
},
],
})
```

```ts twoslash [config.ts] filename="config.ts"
import 'viem/window'
// ---cut---
import { createWalletClient, custom } from 'viem'
import { mainnet } from 'viem/chains'
import { walletActionsErc7115 } from 'viem/experimental'

export const walletClient = createWalletClient({
chain: mainnet,
transport: custom(window.ethereum!),
}).extend(walletActionsErc7115())

export const [account] = await walletClient.getAddresses()
```

:::

## Returns

`IssuePermissionsReturnType`

Response from the wallet after issuing permissions.

## Parameters

### account

- **Type:** `Account | Address | undefined`

The Account to scope the permissions to.

```ts twoslash
import { parseEther } from 'viem'
import { account, walletClient } from './config'

const result = await walletClient.issuePermissions({
account, // [!code focus]
expiry: 1716846083638,
permissions: [
{
type: 'native-token-limit',
data: {
amount: parseEther('0.5'),
},
required: true,
},
],
})
```

### expiry

- **Type:** `number`

The timestamp (in seconds) when the permissions will expire.

```ts twoslash
import { parseEther } from 'viem'
import { account, walletClient } from './config'

const result = await walletClient.issuePermissions({
account,
expiry: 1716846083638, // [!code focus]
permissions: [
{
type: 'native-token-limit',
data: {
amount: parseEther('0.5'),
},
required: true,
},
],
})
```

### permissions

- **Type:** `Permission[]`

Set of permissions to grant to the user.

```ts twoslash
// @noErrors
import { parseEther } from 'viem'
import { account, walletClient } from './config'

const result = await walletClient.issuePermissions({
account,
expiry: 1716846083638,
permissions: [ // [!code focus:99]
{
type: 'native-token-limit',
data: {
amount: parseEther('0.5'),
},
required: true,
},
{
type: '
// ^|
}
],
})
```

### signer

- **Type:** `Signer | undefined`

Custom signer type to scope the permissions to.

```ts twoslash
import { parseEther } from 'viem'
import { account, walletClient } from './config'

const result = await walletClient.issuePermissions({
expiry: 1716846083638,
permissions: [
{
type: 'native-token-limit',
data: {
amount: parseEther('0.5'),
},
required: true,
},
],
signer: { // [!code focus]
type: 'key', // [!code focus]
data: { // [!code focus]
id: '...' // [!code focus]
} // [!code focus]
} // [!code focus]
})
```
17 changes: 16 additions & 1 deletion site/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export const sidebar = {
{
text: 'Introduction',
items: [
{ text: 'Why viem', link: '/docs/introduction' },
{ text: 'Why Viem', link: '/docs/introduction' },
{ text: 'Installation', link: '/docs/installation' },
{ text: 'Getting Started', link: '/docs/getting-started' },
{ text: 'Platform Compatibility', link: '/docs/compatibility' },
{ text: 'FAQ', link: '/docs/faq' },
Expand Down Expand Up @@ -1097,6 +1098,20 @@ export const sidebar = {
},
],
},
{
text: 'ERC-7115',
items: [
{
text: 'Actions',
items: [
{
text: 'issuePermissions',
link: '/experimental/erc7115/issuePermissions',
},
],
},
],
},
],
},
'/op-stack': {
Expand Down
Loading

0 comments on commit d6c5eb7

Please sign in to comment.