Skip to content

Commit

Permalink
feat!: Add EIP-1193 compatibility and use Abitype for contract types (s…
Browse files Browse the repository at this point in the history
…afe-global#604)

* feat(protocol-kit): add ABIType for Safe Contract 1.3.0 + ethers.js

* feat(protocol-kit): Add ABIType for Safe Contract 1.3.0 + Web3.js (safe-global#633)

* feat(protocol-kit): Add ABIType for Safe Contract 1.4.1 + Web3.js (safe-global#637)

* feat(protocol-kit): Add ABItype for Safe Contract v1.4.1 + ethers.js (safe-global#624)

* feat(protocol-kit): Add ABItype for Safe Contract v1.2.0 + ethers.js (safe-global#627)

* feat(protocol-kit): Add ABIType for Safe Contract v1.1.1 for Ethers.js + Web3.js (safe-global#643)

* feat(protocol-kit): Add ABIType for Safe Contract v1.2.0 for web3.js (safe-global#644)

* feat(protocol-kit): Add ABIType for Multisend (safe-global#663)

* feat(protocol-kit): Add ABIType for SignMessageLib  (safe-global#676)

* feat(protocol-kit): Add ABIType for Safe Proxy Factory (safe-global#664)

* feat(protocol-kit): Add ABIType for Safe Contract v1.0.0 (safe-global#727)

* feat(protocol-kit): Add ABIType for SimulateTxAccessor (safe-global#744)

* feat(protocol-kit): Add ABIType for CreateCall (safe-global#742)

* feat:(protocol-kit) Add ABIType for Compatibility FallbackHandler

* feat(protocol-kit): Use AbiTypes in SignMessageLib and SimulateTxAccessor

* feat(protocol-kit): refactor and improve contract classes for Abitype (safe-global#758)

* Add compatibiliy for EIP-1193

* Remove ethAdapter for SafeAdapter

* fix protocol-kit tests

* fix moduleManager

* Move SafeFactory to the root level

* Rename signerAddress to signer

* Rename SafeProvider properties

* Rename files with EthAdapter suffix

* Remove Ethers suffix from contracts

* Remove remaining EthersAdapter instances

* Simplify provider retrieval in test

* Fix api-kit tests

* Remove web3 specific related tests

* Remove web3 gas options

* Add viem specific error handling

* Update api-kit playgrounds

* Update relay-kit playgrounds

* Move SafeFactory types to types folder

* Fix protocol-kit playgrounds and improve eip1271 one

* Add viem support for api-kit testing

* Remove Adapter from the specific contract function

* fix(auth-kit/onramp-kit): Migrate to Sepolia + various small fixes (safe-global#788)

* fix(onramp-kit): Use valid mock contract address to fix unit test

* Bump `@monerium/sdk` to v2.12.0 for Sepolia support

* fix(onramp-kit): Fix unit test to use sepolia instead of goerli

* Fix BaseContract not selecting specific chain deployments

* Fix safeTxGas estimation for viem

* Update contracts being memoized in the dev branch. Now seems to be working

* Allow tests to continue on error to see all the errors in the actions

* Fix account abstraction kit tests

* Remove RPC from playground config and use fixed sepolia one

* Fix signer not propagated

* fix(protocol kit): Get modules paginated incorrect interface (safe-global#787)

* Move abitype to dependencies

* chore: bump dependencies with minor changes

* Rename ContractManager to follow same approach

* fix BaseContract provider (safe-global#811)

* remove unused properties from contract assets (safe-global#809)

* chore: add CONTRIBUTING and SUPPORT files (safe-global#815)

* remove API reference from api-kit and protocol-kit

* Add tests for externalProvider and externalSigner

---------

Co-authored-by: Daniel <[email protected]>
Co-authored-by: Tim <[email protected]>
Co-authored-by: Yago Pérez Vázquez <[email protected]>
Co-authored-by: leonardotc <[email protected]>
  • Loading branch information
5 people authored May 16, 2024
1 parent 84d1589 commit 12dccb6
Show file tree
Hide file tree
Showing 340 changed files with 15,901 additions and 10,442 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: e2e Test
name: API Kit - E2E Tests
on:
pull_request:
push:
Expand All @@ -18,7 +18,15 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: |
yarn install --frozen-lockfile
yarn build
yarn test:ci
- name: Yarn install
run: yarn install --frozen-lockfile

- name: Build
run: yarn build

- name: Test
run: |
cd packages/api-kit
yarn test:ci:ethers
yarn test:ci:web3
yarn test:ci:viem
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Safe Core SDK Test - Contracts
name: Protocol Kit - E2E Tests
on:
workflow_dispatch:
pull_request:
push:
branches:
Expand All @@ -11,7 +12,7 @@ jobs:
strategy:
matrix:
node-version: [20.x]
provider: [ethers, web3]
provider: [ethers, web3, viem]
contract-version: [v1.0.0, v1.1.1, v1.2.0, v1.3.0, v1.4.1]
steps:
- uses: actions/checkout@v4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Monorepo Test
name: SDK - Unit Tests
on:
pull_request:
push:
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ cache
artifacts
deployments

# Typechain
typechain

openapi/

.idea
Expand Down
86 changes: 86 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Contributing Guidelines

First off, **thank you** for considering contributing to this project!

## Table of contents

- [I Have a Question](#i-have-a-question)
- [I Want to Contribute](#i-want-to-contribute)

## <a name="i-have-a-question">I Have a Question</a>

See our [support guidelines](https://github.com/safe-global/safe-core-sdk/tree/main/SUPPORT.md). **Do not** use GitHub issues for general support or questions.

## <a name="i-want-to-contribute">I Want to Contribute</a>
### Legal Notice
You will need to agree to [our CLA](https://safe.global/cla) in order to be possible to consider your contribution.

### Starting Guide

By following the steps bellow you will understand the development process and worflow.
1. [Forking the repository](#forking-the-repository)
2. [Installing Node and Yarn](#installing-node-and-yarn)
3. [Installing dependencies](#installing-dependencies)
4. [Running the tests](#running-the-tests)
5. [Using the playground](#using-the-playground)
6. [Submitting a pull request](#submitting-a-pull-request)

#### Forking the repository

The first step would be to [fork the repository](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo#forking-a-repository). This will allow you to get a current copy of the repository state. Follow the steps to also clone your forked repository locally.

For active development we use the `development` branch. Our `main` branch contains only the currently published code. All new branches should be created from `development`.

#### Installing Node and Yarn

The Safe{Core} SDK uses [Node](https://nodejs.org) as development environment and Yarn to manage the dependencies. You will need to make sure you are using the [latest Node LTS version](https://nodejs.org/en/about/previous-releases) and that you have available Yarn v1.

You can check which versions you are using with:

```bash
node -v
yarn -v
```

#### Installing dependencies

The Safe{Core} SDK uses a mono-repository structure managed by [Yarn Workspaces](https://classic.yarnpkg.com/lang/en/docs/workspaces/) and [Lerna](https://lerna.js.org). From the root of the repository you will need to install the whole dependency stack and do the project build. Some packages depend on each other, so even when modifiying only one package it's better to run the full build.

Install all dependencies and build the whole project by using the following commands at the project root.

```bash
yarn install
yarn build
```

#### Running the tests

There is already a test script that can be launched from the root of the repository and will use [Lerna](https://lerna.js.org) to run all the tests from all the packages.

```bash
yarn test
```

If you would like to test individual packages, **once you make sure you did the build from the root**, you can:

```bash
yarn test --scope=<package-name>
yarn test --scope=@safe-global/protocol-kit
yarn test --scope=@safe-global/api-kit
```

For some packages you may need to fill a .env file with some configuration. In those packages you will be able to find a `.env.example` file specifying the necessary parameters.

#### Using the playground

You can use the playground section to do some manual testing using a specific Safe or configuration. The playground can be run from the root of the project as follow:

```bash
yarn play <playground-command>
```

You can find more information about the available commands [in the specific section.](https://github.com/safe-global/safe-core-sdk/tree/main/playground)

#### Submitting a pull request

From the forked repository you can [open a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) to the original repository. Make sure to select the `safe-global:development` branch as the target branch.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-2023 Safe Ecosystem Foundation
Copyright (c) 2021-2024 Safe Ecosystem Foundation

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
39 changes: 34 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,30 @@

![Safe_Logos_Core_SDK_Black](https://github.com/safe-global/safe-core-sdk/assets/6764315/7202a24a-2981-4b31-9cf5-ace1c3b2c4fa)

Software developer tools that facilitate the interaction with the Safe [contracts](https://github.com/safe-global/safe-contracts) and [services](https://github.com/safe-global/safe-transaction-service).
## Table of contents

- [About](#about)
- [Documentation](#documentation)
- [Guides](#guides)
- [Packages](#packages)
- [Need Help or Have Questions?](#need-help-or-have-questions)
- [Contributing](#contributing)
- [Playground](#playground)
- [License](#license)

## About

This is a mono-repository containing Javascript software developer tools that facilitate the interaction with [Safe Smart Accounts](https://github.com/safe-global/safe-smart-account) and [services](https://github.com/safe-global/safe-transaction-service).

## Documentation

Visit [our documentation site](https://docs.safe.global/sdk/overview) to start developing using our SDK.

## Guides

| Title | Description |
| ------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Integrating the Safe Core SDK](https://github.com/safe-global/safe-core-sdk/blob/main/guides/integrating-the-safe-core-sdk.md) | This guide shows how to use the [Protocol Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/protocol-kit) and [API Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/api-kit). |
| [Integrating the Safe{Core} SDK](https://github.com/safe-global/safe-core-sdk/blob/main/guides/integrating-the-safe-core-sdk.md) | This guide shows how to use the [Protocol Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/protocol-kit) and [API Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/api-kit). |

## Packages

Expand All @@ -17,10 +34,22 @@ Software developer tools that facilitate the interaction with the Safe [contract
| [api-kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/api-kit) | [![NPM Version](https://badge.fury.io/js/%40safe-global%2Fapi-kit.svg)](https://badge.fury.io/js/%40safe-global%2Fapi-kit) | [Safe Transaction Service API](https://github.com/safe-global/safe-transaction-service) client library |
| [auth-kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/auth-kit) | [![NPM Version](https://badge.fury.io/js/%40safe-global%2Fauth-kit.svg)](https://badge.fury.io/js/%40safe-global%2Fauth-kit) | Typescript library to create an Ethereum address and authenticating a blockchain account using an email address, social media account, or traditional crypto wallets like Metamask |
| [onramp-kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/onramp-kit) | [![NPM Version](https://badge.fury.io/js/%40safe-global%2Fonramp-kit.svg)](https://badge.fury.io/js/%40safe-global%2Fonramp-kit) | Typescript library that allows users to buy cryptocurrencies using a credit card and other payment options |
| [protocol-kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/protocol-kit) | [![NPM Version](https://badge.fury.io/js/%40safe-global%2Fprotocol-kit.svg)](https://badge.fury.io/js/%40safe-global%2Fprotocol-kit) | TypeScript library that facilitates the interaction with the [Safe contracts](https://github.com/safe-global/safe-contracts) |
| [relay-kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/relay-kit) | ​​​[![NPM Version](https://badge.fury.io/js/%40safe-global%2Frelay-kit.svg)](https://badge.fury.io/js/%40safe-global%2Frelay-kit)| Library to abstract transaction fees payment (gas fees), allowing the use of native tokens or ERC-20​​ |
| [protocol-kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/protocol-kit) | [![NPM Version](https://badge.fury.io/js/%40safe-global%2Fprotocol-kit.svg)](https://badge.fury.io/js/%40safe-global%2Fprotocol-kit) | TypeScript library that facilitates the interaction with [Safe Smart Accounts](https://github.com/safe-global/safe-smart-account) |
| [relay-kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/relay-kit) | ​​​[![NPM Version](https://badge.fury.io/js/%40safe-global%2Frelay-kit.svg)](https://badge.fury.io/js/%40safe-global%2Frelay-kit)| Library that lets users to pay transaction fees (gas fees) using the native blockchain token or ERC-20 tokens.​This kit enables the use of ERC-4337 with Safe |
| [safe-core-sdk-types](https://github.com/safe-global/safe-core-sdk/tree/main/packages/safe-core-sdk-types) | [![NPM Version](https://badge.fury.io/js/%40safe-global%2Fsafe-core-sdk-types.svg)](https://badge.fury.io/js/%40safe-global%2Fsafe-core-sdk-types) | Common types extracted from the [Safe Core SDK](https://github.com/safe-global/safe-core-sdk/tree/main/packages) packages |

## Need Help or Have Questions?

If you have any doubts, questions, or need assistance, feel free to reach out! [Here you will find how to get support.](https://github.com/safe-global/safe-core-sdk/tree/main/SUPPORT.md)

## Contributing

If you are interested in contributing, please read the [Contributing Guidelines](https://github.com/safe-global/safe-core-sdk/tree/main/CONTRIBUTING.md) **before opening an issue or submitting a pull request**.

## Playground

This project includes a [playground](https://github.com/safe-global/safe-core-sdk/tree/main/playground/README.md) with a few scripts that can be used as a starting point to use the Safe Core SDK.
This project includes a [playground](https://github.com/safe-global/safe-core-sdk/tree/main/playground/README.md) with a few scripts that can be used as a starting point to use the Safe{Core} SDK.

## License

This library is released under [MIT](https://github.com/safe-global/safe-core-sdk/tree/main/LICENSE.md).
23 changes: 23 additions & 0 deletions SUPPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Support Guidelines

We appreciate your interest in our project. If you have questions, need help, or encounter issues, please follow these guidelines:

1. **GitHub Issues**: **Do not** use GitHub issues for general support or questions. Issues are primarily for bug reports, feature requests, and discussions related to code changes.

2. **Stack Exchange**: For support-related questions, we recommend using [Stack Exchange with the appropriate tags](https://ethereum.stackexchange.com/questions/tagged/safe-core). The **safe-core** tag should always be included. Many community members and experts monitor Stack Exchange and can provide timely assistance.

3. **Search First**: Before posting a new question, search existing issues and Stack Exchange to see if your question has already been answered. You might find a solution without waiting for a response.

4. **Be Specific**: When asking for help, provide as much context as possible. Include relevant details such as error messages, steps to reproduce, testing addresses, and the version of our project packages you're using.

5. **Be Respectful**: Treat others with kindness and respect. We're all here to learn and help each other.

## Getting Help

If you need assistance, follow these steps:

1. **Documentation**: Refer to our [project's documentation](https://docs.safe.global/sdk/overview) for usage instructions, FAQs, and troubleshooting tips.

2. **Stack Exchange**: Search for existing answers or ask a new question on Stack Exchange. Use relevant tags as **safe-core**.

Remember that GitHub issues are not the right place for general support. Let's keep our issue tracker focused on improving the project! 😊
6 changes: 3 additions & 3 deletions guides/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Read about the basics of Safe and how it compares to other solutions [here](http

## Safe Core SDK

The [Safe Core SDK](https://github.com/safe-global/safe-core-sdk) is a monorepo that contains software developer tools that allows interaction with the [Safe contracts](https://github.com/safe-global/safe-contracts) and the [Safe Transaction Service](https://github.com/safe-global/safe-transaction-service).
The [Safe Core SDK](https://github.com/safe-global/safe-core-sdk) is a monorepo that contains software developer tools that allows interaction with [Safe Smart Accounts](https://github.com/safe-global/safe-smart-account) and the [Safe Transaction Service](https://github.com/safe-global/safe-transaction-service).

In this guide we will use the following packages to deploy new Safes, create transactions, collect off-chain signatures and execute transactions:
* **safe-core-sdk-types**
Expand All @@ -22,7 +22,7 @@ In this guide we will use the following packages to deploy new Safes, create tra
- Approve Safe transactions on-chain
- Execute Safe transactions once they have the required confirmations

Check the complete [API reference](/packages/protocol-kit#api-reference) for more details.
Check the complete [API reference](https://docs.safe.global/sdk/protocol-kit/reference) for more details.

* **api-kit**

Expand All @@ -33,7 +33,7 @@ In this guide we will use the following packages to deploy new Safes, create tra
- Get the transaction history of a Safe (and filter by pending, incoming, multisig transactions, etc.)
- Get balances, list of tokens, etc.

Check the complete [API reference](/packages/api-kit#api-reference) for more details.
Check the complete [API reference](https://docs.safe.global/sdk/api-kit/reference) for more details.

## Prerequisites

Expand Down
Loading

0 comments on commit 12dccb6

Please sign in to comment.