Skip to content

Commit

Permalink
chore: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Nov 22, 2024
1 parent ee33c07 commit 718282a
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 8 deletions.
52 changes: 45 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Experimental Next-gen Account for Ethereum.
- [`experimental_disconnect`](#experimental_disconnect)
- [`experimental_grantSession`](#experimental_grantsession)
- [`experimental_sessions`](#experimental_sessions)
- [Wagmi Reference](#wagmi-reference)
- [Available ERC-5792 Capabilities](#available-erc-5792-capabilities)
- [`atomicBatch`](#atomicbatch)
- [`createAccount`](#createaccount)
Expand Down Expand Up @@ -91,10 +92,10 @@ export const wagmiConfig = createConfig({
})
```

This means you can now use Wagmi-compatible Hooks like `W.useConnect`:
This means you can now use Wagmi-compatible Hooks like `useConnect`. For more info, check out the [Wagmi Reference](#wagmi-reference).

```tsx twoslash
import { W } from 'porto/react'
```tsx
import { W } from 'porto/wagmi'
import { useConnectors } from 'wagmi'

function Connect() {
Expand All @@ -107,7 +108,7 @@ function Connect() {
onClick={() =>
connect.mutate({
connector,
grantSession: true
grantSession: true,
})
}
>
Expand All @@ -118,7 +119,7 @@ function Connect() {
connect.mutate({
connector,
createAccount: true,
grantSession: true
grantSession: true,
}
)}
>
Expand Down Expand Up @@ -289,6 +290,43 @@ Lists the active sessions on the account.
{ expiry: number, id: `0x${string}` }[]
```

## Wagmi Reference

Porto implements the following [Wagmi](https://github.com/wevm/wagmi) VanillaJS Actions and React Hooks that map directly to the [experimental JSON-RPC methods](#json-rpc-reference).

> [!NOTE]
> Porto only supports the React version of Wagmi at the moment. If you are interested in adding support for other Wagmi Adapters, please create a Pull Request.
### VanillaJS Actions

Import via named export or `A` namespace (better autocomplete DX and does not impact tree shaking).

- `connect`
- `createAccount`
- `disconnect`
- `grantSession`
- `sessions`

```ts
import { A } from 'porto/wagmi/actions'
import { connect } from 'porto/wagmi/actions'
```

### React Hooks

Import via named export or `W` namespace (better autocomplete DX and does not impact tree shaking).

- `useConnect`
- `useCreateAccount`
- `useDisconnect`
- `useGrantSession`
- `useSessions`

```ts
import { W } from 'porto/wagmi'
import { useConnect } from 'porto/wagmi'
```

## Available ERC-5792 Capabilities

Porto implements the following [ERC-5792 capabilities](https://eips.ethereum.org/EIPS/eip-5792#wallet_getcapabilities) to define extended behavior:
Expand Down Expand Up @@ -413,6 +451,6 @@ Licensed under either of <a href="LICENSE-APACHE">Apache License, Version

<sub>
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in these crates by you, as defined in the Apache-2.0 license,
for inclusion in these packages by you, as defined in the Apache-2.0 license,
shall be dual licensed as above, without any additional terms or conditions.
</sub>
</sub>
8 changes: 8 additions & 0 deletions src/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export {
connect,
createAccount,
disconnect,
grantSession,
sessions,
} from './internal/wagmi/core.js'
export * as A from './internal/wagmi/core.js'
12 changes: 11 additions & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,23 @@
"types": "./_dist/wagmi.d.ts",
"default": "./_dist/wagmi.js"
},
"./wagmi/actions": {
"types": "./_dist/actions.d.ts",
"default": "./_dist/actions.js"
},
"./wagmi/query": {
"types": "./_dist/query.d.ts",
"default": "./_dist/query.js"
},
"./package.json": "./package.json"
},
"typesVersions": {
"*": {
"Chains": ["./_dist/Chains.d.ts"],
"Porto": ["./_dist/Porto.d.ts"],
"wagmi": ["./_dist/wagmi.d.ts"]
"wagmi": ["./_dist/wagmi.d.ts"],
"wagmi/actions": ["./_dist/actions.d.ts"],
"wagmi/query": ["./_dist/query.d.ts"]
}
},
"files": [
Expand Down
2 changes: 2 additions & 0 deletions src/query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { sessionsQueryKey } from './internal/wagmi/query.js'
export * as Q from './internal/wagmi/query.js'
1 change: 1 addition & 0 deletions src/wagmi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export {
useConnect,
useCreateAccount,
useDisconnect,
useGrantSession,
Expand Down

0 comments on commit 718282a

Please sign in to comment.