pimlicolabs / permissionless.js

TypeScript utilities built on viem for ERC-4337: Account Abstraction
https://docs.pimlico.io/permissionless
MIT License
167 stars 46 forks source link

7677 mvp #284

Closed plusminushalf closed 1 week ago

plusminushalf commented 1 week ago

Usage:

In your APP use the Erc5792HelperProvider to provide the possible capabilities that you would like to pass. Example:

<Erc5792HelperProvider
    capabilities={{
        paymasterService: {
            [baseSepolia.id]: {
                url: `https://api.pimlico.io/v2/${baseSepolia.id}/rpc?apikey=`
            }
        }
    }}
>
    <App />
</Erc5792HelperProvider>

Then use useSendTransaction and useWaitForTransactionReceipt like you would from wagmi but import them instead from @permissionless/wagmi.

Example:

 import {
    useSendTransaction,
    useWaitForTransactionReceipt
} from "@permissionless/wagmi"

const {
    sendTransaction,
    data: transactionReference,
    isPending
} = useSendTransaction()

const { data: receipt, isPending: isReceiptPending } =
    useWaitForTransactionReceipt({
        id: transactionReference
    })

console.log({
    transactionHash: transactionReference,
    isPending,
    receipt,
    isReceiptPending
})

How to show if a call is sponsored:

import { useAvailableCapabilities } from "./useAvailableCapabilities"
const { capabilities } = useAvailableCapabilities()

if(capabilities.paymasterService) {
      // hell yeah sponsored!
  }
changeset-bot[bot] commented 1 week ago

🦋 Changeset detected

Latest commit: a9fac836a74bb4986810594aadf7b65d0042522b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | --------------------- | ----- | | @permissionless/wagmi | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

codecov[bot] commented 1 week ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 90.15%. Comparing base (836ed20) to head (a9fac83). Report is 20 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #284 +/- ## ======================================= Coverage 90.15% 90.15% ======================================= Files 61 61 Lines 8339 8341 +2 Branches 267 267 ======================================= + Hits 7518 7520 +2 Misses 821 821 ``` | [Flag](https://app.codecov.io/gh/pimlicolabs/permissionless.js/pull/284/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pimlicolabs) | Coverage Δ | | |---|---|---| | [](https://app.codecov.io/gh/pimlicolabs/permissionless.js/pull/284/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pimlicolabs) | `90.15% <ø> (?)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pimlicolabs#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.