Skip to content

Commit

Permalink
chore: rename solady -> erc7739
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Aug 7, 2024
1 parent 389bd9d commit cca5573
Show file tree
Hide file tree
Showing 27 changed files with 128 additions and 110 deletions.
23 changes: 15 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions site/pages/experimental/erc7739/client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Extending Client with ERC-7739 Actions [Setting up your Viem Client]

To use the experimental functionality of ERC-7739, you can extend your existing (or new) Viem Client with experimental ERC-7739 Actions.

```ts
import { createPublicClient, createWalletClient, http } from 'viem'
import { mainnet } from 'viem/chains'
import { erc7739Actions } from 'viem/experimental' // [!code focus]
const walletClient = createWalletClient({
chain: mainnet,
transport: custom(window.ethereum!),
}).extend(erc7739Actions()) // [!code focus]

const id = await walletClient.signMessage({/* ... */})
```
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
description: Hashes an EIP-191 message via Solady's ERC-1271 format.
description: Hashes an EIP-191 message via ERC-7739 format.
---

# hashMessage

Calculates a [EIP-191](https://eips.ethereum.org/EIPS/eip-191) personal sign hash via Solady's [ERC-1271 `PersonalSign` format](https://github.com/Vectorized/solady/blob/678c9163550810b08f0ffb09624c9f7532392303/src/accounts/ERC1271.sol#L154-L166).
Calculates a [EIP-191](https://eips.ethereum.org/EIPS/eip-191) personal sign hash via [ERC-7739 `PersonalSign` format](https://eips.ethereum.org/EIPS/eip-7739).

## Import

```ts
import { hashMessage } from 'viem/experimental/solady'
import { hashMessage } from 'viem/experimental/erc7739'
```

## Usage

```ts
import { hashMessage } from 'viem/experimental/solady'
import { hashMessage } from 'viem/experimental/erc7739'

// Hash a UTF-8 value.
hashMessage({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Hashes EIP-712 typed data via Solady's ERC-1271 format.

# hashTypedData

Hashes [EIP-712](https://eips.ethereum.org/EIPS/eip-712) typed data via Solady's [ERC-1271 `TypedDataSign` format](https://github.com/Vectorized/solady/blob/678c9163550810b08f0ffb09624c9f7532392303/src/accounts/ERC1271.sol#L130-L151).
Hashes [EIP-712](https://eips.ethereum.org/EIPS/eip-712) typed data via [ERC-7739 `TypedDataSign` format](https://eips.ethereum.org/EIPS/eip-7739).

## Import

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ description: Signs a personal sign message via Solady's ERC-1271 format.

# signMessage

Signs an [EIP-191](https://eips.ethereum.org/EIPS/eip-191) personal sign message via Solady's [ERC-1271 `PersonalSign` format](https://github.com/Vectorized/solady/blob/678c9163550810b08f0ffb09624c9f7532392303/src/accounts/ERC1271.sol#L154-L166).
Signs an [EIP-191](https://eips.ethereum.org/EIPS/eip-191) personal sign message via [ERC-7739 `PersonalSign` format](https://eips.ethereum.org/EIPS/eip-7739).

This Action is suitable to sign messages for contracts (e.g. ERC-4337 Smart Accounts) that implement (or conform to) Solady's [ERC1271.sol](https://github.com/Vectorized/solady/blob/main/src/accounts/ERC1271.sol).
This Action is suitable to sign messages for contracts (e.g. ERC-4337 Smart Accounts) that implement (or conform to) [ERC-7739](https://eips.ethereum.org/EIPS/eip-7739) (e.g. Solady's [ERC1271.sol](https://github.com/Vectorized/solady/blob/main/src/accounts/ERC1271.sol)).

With the calculated signature, you can use [`verifyMessage`](/docs/actions/public/verifyMessage) to verify the signature

Expand Down Expand Up @@ -38,12 +38,12 @@ const signature_2 = await walletClient.signMessage({
```ts twoslash [config.ts] filename="config.ts"
import { createWalletClient, http } from 'viem'
import { mainnet } from 'viem/chains'
import { soladyActions } from 'viem/experimental'
import { erc7739Actions } from 'viem/experimental'

export const walletClient = createWalletClient({
chain: mainnet,
transport: http(),
}).extend(soladyActions())
}).extend(erc7739Actions())

export const [account] = await walletClient.getAddresses()
// @log: ↑ JSON-RPC Account
Expand Down Expand Up @@ -72,7 +72,7 @@ const signature = await walletClient.signMessage({ // [!code focus:99]

```ts [config.ts (JSON-RPC Account)]
import { createWalletClient, custom } from 'viem'
import { soladyActions } from 'viem/experimental'
import { erc7739Actions } from 'viem/experimental'

// Retrieve Account from an EIP-1193 Provider.
const [account] = await window.ethereum.request({
Expand All @@ -82,20 +82,20 @@ const [account] = await window.ethereum.request({
export const walletClient = createWalletClient({
account,
transport: custom(window.ethereum!)
}).extend(soladyActions({
}).extend(erc7739Actions({
verifier: '0xCB9fA1eA9b8A3bf422a8639f23Df77ea66020eC2'
}))
```

```ts twoslash [config.ts (Local Account)] filename="config.ts"
import { createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { soladyActions } from 'viem/experimental'
import { erc7739Actions } from 'viem/experimental'

export const walletClient = createWalletClient({
account: privateKeyToAccount('0x...'),
transport: http()
}).extend(soladyActions({
}).extend(erc7739Actions({
verifier: '0xCB9fA1eA9b8A3bf422a8639f23Df77ea66020eC2'
}))
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ description: Signs typed data via Solady's ERC-1271 format.

# signTypedData

Signs [EIP-712](https://eips.ethereum.org/EIPS/eip-712) typed data via Solady's [ERC-1271 `TypedDataSign` format](https://github.com/Vectorized/solady/blob/678c9163550810b08f0ffb09624c9f7532392303/src/accounts/ERC1271.sol#L130-L151).
Signs [EIP-712](https://eips.ethereum.org/EIPS/eip-712) typed data via [ERC-7739 `TypedDataSign` format](https://eips.ethereum.org/EIPS/eip-7739).

This Action is suitable to sign messages for contracts (e.g. ERC-4337 Smart Accounts) that implement (or conform to) Solady's [ERC1271.sol](https://github.com/Vectorized/solady/blob/main/src/accounts/ERC1271.sol).
This Action is suitable to sign messages for contracts (e.g. ERC-4337 Smart Accounts) that implement (or conform to) [ERC-7739](https://eips.ethereum.org/EIPS/eip-7739) (e.g. Solady's [ERC1271.sol](https://github.com/Vectorized/solady/blob/main/src/accounts/ERC1271.sol)).

With the calculated signature, you can use [`verifyTypedData`](/docs/actions/public/verifyTypedData) to verify the signature

Expand Down Expand Up @@ -66,12 +66,12 @@ export const types = {
```ts twoslash [config.ts] filename="config.ts"
import { createWalletClient, http } from 'viem'
import { mainnet } from 'viem/chains'
import { soladyActions } from 'viem/experimental'
import { erc7739 } from 'viem/experimental'

export const walletClient = createWalletClient({
chain: mainnet,
transport: http(),
}).extend(soladyActions())
}).extend(erc7739())

export const [account] = await walletClient.getAddresses()
// @log: ↑ JSON-RPC Account
Expand Down Expand Up @@ -137,7 +137,7 @@ export const types = {

```ts [config.ts (JSON-RPC Account)]
import { createWalletClient, custom } from 'viem'
import { soladyActions } from 'viem/experimental'
import { erc7739 } from 'viem/experimental'

// Retrieve Account from an EIP-1193 Provider.
const [account] = await window.ethereum.request({
Expand All @@ -147,20 +147,20 @@ const [account] = await window.ethereum.request({
export const walletClient = createWalletClient({
account,
transport: custom(window.ethereum!)
}).extend(soladyActions({
}).extend(erc7739({
verifier: '0xCB9fA1eA9b8A3bf422a8639f23Df77ea66020eC2'
}))
```

```ts twoslash [config.ts (Local Account)] filename="config.ts"
import { createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { soladyActions } from 'viem/experimental'
import { erc7739 } from 'viem/experimental'

export const walletClient = createWalletClient({
account: privateKeyToAccount('0x...'),
transport: http()
}).extend(soladyActions({
}).extend(erc7739({
verifier: '0xCB9fA1eA9b8A3bf422a8639f23Df77ea66020eC2'
}))
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# wrapTypedDataSignature

Wraps a EIP-712 typed data signature into Solady's ERC-1271 format for verification.
Wraps a EIP-712 typed data signature into via [ERC-7739](https://eips.ethereum.org/EIPS/eip-7739) format for verification.

## Import

```ts
import { wrapTypedDataSignature } from 'viem/experimental/solady'
import { wrapTypedDataSignature } from 'viem/experimental/erc7739'
```

## Usage

```ts
import { wrapTypedDataSignature } from 'viem/experimental/solady'
import { wrapTypedDataSignature } from 'viem/experimental/erc7739'

wrapTypedDataSignature({
domain: {
Expand Down
16 changes: 0 additions & 16 deletions site/pages/experimental/solady/client.md

This file was deleted.

8 changes: 4 additions & 4 deletions site/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1321,22 +1321,22 @@ export const sidebar = {
],
},
{
text: 'Solady',
text: 'ERC-7739',
items: [
{
text: 'Client',
link: '/experimental/solady/client',
link: '/experimental/erc7739/client',
},
{
text: 'Actions',
items: [
{
text: 'signMessage',
link: '/experimental/solady/signMessage',
link: '/experimental/erc7739/signMessage',
},
{
text: 'signTypedData',
link: '/experimental/solady/signTypedData',
link: '/experimental/erc7739/signTypedData',
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { readContract } from '../../../actions/public/readContract.js'
import { signMessage as signMessage_ } from '../../../actions/wallet/signMessage.js'
import type { Client } from '../../../clients/createClient.js'
import { entryPoint07Address } from '../../../constants/address.js'
import { signMessage } from '../../../experimental/solady/actions/signMessage.js'
import { signTypedData } from '../../../experimental/solady/actions/signTypedData.js'
import { signMessage } from '../../../experimental/erc7739/actions/signMessage.js'
import { signTypedData } from '../../../experimental/erc7739/actions/signTypedData.js'
import type { Account } from '../../../types/account.js'
import type { Hex } from '../../../types/misc.js'
import type { TypedDataDefinition } from '../../../types/typedData.js'
Expand Down
2 changes: 1 addition & 1 deletion src/actions/public/verifyHash.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { zksync } from '../../chains/index.js'
import { createClient } from '../../clients/createClient.js'
import { http } from '../../clients/transports/http.js'
import { serializeErc6492Signature } from '../../experimental/index.js'
import { signMessage as signMessageErc1271 } from '../../experimental/solady/actions/signMessage.js'
import { signMessage as signMessageErc1271 } from '../../experimental/erc7739/actions/signMessage.js'
import type { Hex } from '../../types/misc.js'
import {
encodeFunctionData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ test('no account', async () => {
[AccountNotFoundError: Could not find an Account to execute with this Action.
Please provide an Account with the \`account\` argument on the Action, or by supplying an \`account\` to the Client.
Docs: https://viem.sh/experimental/solady/signMessage
Docs: https://viem.sh/experimental/erc7739/signMessage
Version: viem@x.y.z]
`,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export type SignMessageReturnType = Hex
export type SignMessageErrorType = ErrorType

/**
* Signs a [EIP-191](https://eips.ethereum.org/EIPS/eip-191) personal sign message via Solady's [ERC1271 `PersonalSign` format](https://github.com/Vectorized/solady/blob/678c9163550810b08f0ffb09624c9f7532392303/src/accounts/ERC1271.sol#L154-L166).
* Signs a [EIP-191](https://eips.ethereum.org/EIPS/eip-191) personal sign message via [ERC-7739 `PersonalSign` format](https://eips.ethereum.org/EIPS/eip-7702).
*
* This Action is suitable to sign messages for Smart Accounts that implement (or conform to) Solady's [ERC1271.sol](https://github.com/Vectorized/solady/blob/main/src/accounts/ERC1271.sol).
* This Action is suitable to sign messages for Smart Accounts that implement (or conform to) [ERC-7739](https://eips.ethereum.org/EIPS/eip-7702) (e.g. Solady's [ERC1271.sol](https://github.com/Vectorized/solady/blob/main/src/accounts/ERC1271.sol)).
*
* - Docs: https://viem.sh/experimental/solady/signMessage
* - Docs: https://viem.sh/experimental/erc7739/signMessage
*
* With the calculated signature, you can:
* - use [`verifyMessage`](https://viem.sh/docs/utilities/verifyMessage) to verify the signature,
Expand All @@ -64,7 +64,7 @@ export type SignMessageErrorType = ErrorType
* @example
* import { createWalletClient, custom } from 'viem'
* import { mainnet } from 'viem/chains'
* import { signMessage } from 'viem/experimental/solady'
* import { signMessage } from 'viem/experimental/erc7739'
*
* const client = createWalletClient({
* chain: mainnet,
Expand All @@ -82,7 +82,7 @@ export type SignMessageErrorType = ErrorType
* import { createWalletClient, custom } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { mainnet } from 'viem/chains'
* import { signMessage } from 'viem/experimental/solady'
* import { signMessage } from 'viem/experimental/erc7739'
*
* const client = createWalletClient({
* account: '0xE8Df82fA4E10e6A12a9Dab552bceA2acd26De9bb',
Expand Down Expand Up @@ -113,7 +113,7 @@ export async function signMessage<

if (!account_)
throw new AccountNotFoundError({
docsPath: '/experimental/solady/signMessage',
docsPath: '/experimental/erc7739/signMessage',
})
const account = parseAccount(account_)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ test('no account', async () => {
[AccountNotFoundError: Could not find an Account to execute with this Action.
Please provide an Account with the \`account\` argument on the Action, or by supplying an \`account\` to the Client.
Docs: https://viem.sh/experimental/solady/signTypedData
Docs: https://viem.sh/experimental/erc7739/signTypedData
Version: viem@x.y.z]
`)
})
Loading

0 comments on commit cca5573

Please sign in to comment.