safe-global / safe-core-sdk

The Safe{Core} SDK allows builders to add account abstraction functionality into their apps.
https://docs.safe.global/sdk/overview
MIT License
242 stars 177 forks source link

[SDK Refactoring] Create new top level package `safe-kit` #866

Closed yagopv closed 3 days ago

yagopv commented 1 week ago

Context / issue

We want to create a new package offering an opinionated formula and a user-friendly experience for developers. We would like to offer an experience where we implement a top-level function createSafeClient(options) to interact with Safe. This new package will use the other kits internally, and it should be the primary package that most developers should use, leaving the other kits for more advanced implementations or core features.

Using the package should be similar to this code snippet:

import { createSafeClient } from '@safe-global/safe-kit'

const safeClient = await createSafeClient({ signer, provider, chain })

const safeTxHash = await safeClient.send({ transactions })

The send() method will wrap the typical operations for creatingTransaction, signTransaction and executeTransaction making the developer experience better. The transaction signing would take place based on the provided signer

flowchart LR
    A[send] -->|transaction| B(createTransaction)
    B(createTransaction) --> C(signTransaction)
    C(signTransaction) --> D(executeTransaction)
    A[send] -->|message| E(createMessage)
    E(createMessage) --> F(signMessage)
    F(signMessage) --> |if on-chain| D(executeTransaction)
    A[send] -->|userOperation| H(createRelayKitTransaction)
    H(createRelayKitTransaction) --> I(signSafeOperation)
    I(signSafeOperation) --> J(executeRelayKitTransaction)

Proposed solution

Create top level package in the safe-core-sdk repo

Additional context

Research document

Related tickets

Create Package Implement createSafeClient and send Add Multisig Add testing