diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/api-kit-e2e-test.yml
similarity index 57%
rename from .github/workflows/e2e-test.yml
rename to .github/workflows/api-kit-e2e-test.yml
index 335e79660..b1e12d337 100644
--- a/.github/workflows/e2e-test.yml
+++ b/.github/workflows/api-kit-e2e-test.yml
@@ -1,4 +1,4 @@
-name: e2e Test
+name: API Kit - E2E Tests
on:
pull_request:
push:
@@ -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
diff --git a/.github/workflows/test_contracts.yml b/.github/workflows/protocol-kit-e2e-test.yml
similarity index 89%
rename from .github/workflows/test_contracts.yml
rename to .github/workflows/protocol-kit-e2e-test.yml
index a4e296596..7e790f43f 100644
--- a/.github/workflows/test_contracts.yml
+++ b/.github/workflows/protocol-kit-e2e-test.yml
@@ -1,5 +1,6 @@
-name: Safe Core SDK Test - Contracts
+name: Protocol Kit - E2E Tests
on:
+ workflow_dispatch:
pull_request:
push:
branches:
@@ -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
diff --git a/.github/workflows/test.yml b/.github/workflows/sdk-test.yml
similarity index 97%
rename from .github/workflows/test.yml
rename to .github/workflows/sdk-test.yml
index 63064b3cd..12c67aba2 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/sdk-test.yml
@@ -1,4 +1,4 @@
-name: Monorepo Test
+name: SDK - Unit Tests
on:
pull_request:
push:
diff --git a/.gitignore b/.gitignore
index 3a4aba22e..99cb3c5ef 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,9 +54,6 @@ cache
artifacts
deployments
-# Typechain
-typechain
-
openapi/
.idea
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 000000000..3af627092
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -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)
+
+## I Have a Question
+
+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.
+
+## I Want to Contribute
+### 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=
+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
+```
+
+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.
diff --git a/LICENSE.md b/LICENSE.md
index 310e6e37c..0e923d187 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -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:
diff --git a/README.md b/README.md
index 5a00cb4d9..33606f604 100644
--- a/README.md
+++ b/README.md
@@ -2,13 +2,30 @@

-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
@@ -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) | [](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) | [](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) | [](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) | [](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) | [](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) | [](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) | [](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) | [](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).
diff --git a/SUPPORT.md b/SUPPORT.md
new file mode 100644
index 000000000..e09b4cadf
--- /dev/null
+++ b/SUPPORT.md
@@ -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! 😊
diff --git a/guides/README.md b/guides/README.md
index cf7ae92fc..707c9a400 100644
--- a/guides/README.md
+++ b/guides/README.md
@@ -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**
@@ -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**
@@ -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
diff --git a/guides/integrating-the-safe-core-sdk.md b/guides/integrating-the-safe-core-sdk.md
index 75f350843..d02e28c10 100644
--- a/guides/integrating-the-safe-core-sdk.md
+++ b/guides/integrating-the-safe-core-sdk.md
@@ -24,16 +24,14 @@ To integrate the [Safe Core SDK](https://github.com/safe-global/safe-core-sdk) i
## 2. Initialize the SDK’s
-### Instantiate an EthAdapter
+### Select your Ethereum `provider` and `signer`
-First of all, we need to create an `EthAdapter`, which contains all the required utilities for the SDKs to interact with the blockchain. It acts as a wrapper for [web3.js](https://web3js.readthedocs.io/) or [ethers.js](https://docs.ethers.org/v6/) Ethereum libraries.
+To use our kits, you need to provide an Ethereum provider and a signer. The provider is the connection to the Ethereum network, while the signer is an account that will sign the transactions (a Safe owner). When using an injected provider like MetaMask, the signer is the account selected in the wallet.
-Depending on the library used by the Dapp, there are two options:
+In the examples below, you can see `provider` and `signer` properties, which represent:
-- [Create an `EthersAdapter` instance](https://github.com/safe-global/safe-core-sdk/tree/main/packages/protocol-kit/src/adapters/ethers)
-- [Create a `Web3Adapter` instance](https://github.com/safe-global/safe-core-sdk/tree/main/packages/protocol-kit/src/adapters/web3)
-
-Once the instance of `EthersAdapter` or `Web3Adapter` is created, it can be used in the SDK initialization.
+- `provider`: You can provide an EIP-1193 compatible provider or an HTTP/WebSocket RPC URL.
+- `signer`: This is an optional parameter. It should be the provider's address you want to use or a private key. If not set, it will try to fetch a connected account from the provider.
### Initialize the Safe API Kit
@@ -42,13 +40,13 @@ As stated in the introduction, the [Safe API Kit](https://github.com/safe-global
```js
import SafeApiKit from '@safe-global/api-kit'
-const safeService = new SafeApiKit({ chainId })
+const apiKit = new SafeApiKit({ chainId })
```
Using the `chainId` is enough for chains where Safe runs a Transaction Service. For those chains where Safe doesn't run a service, use the `txServiceUrl` parameter to set the custom service endpoint.
```js
-const safeService = new SafeApiKit({
+const apiKit = new SafeApiKit({
chainId,
txServiceUrl: 'https://txServiceUrl.com'
})
@@ -59,9 +57,9 @@ const safeService = new SafeApiKit({
```js
import Safe, { SafeFactory } from '@safe-global/protocol-kit'
-const safeFactory = await SafeFactory.create({ ethAdapter })
+const safeFactory = await SafeFactory.init({ provider, signer })
-const safeSdk = await Safe.create({ ethAdapter, safeAddress })
+const protocolKit = await Safe.init({ provider, signer, safeAddress })
```
There are two versions of the Safe contracts: [Safe.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/Safe.sol) that does not trigger events in order to save gas and [SafeL2.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/SafeL2.sol) that does, which is more appropriate for L2 networks.
@@ -69,17 +67,18 @@ There are two versions of the Safe contracts: [Safe.sol](https://github.com/safe
By default `Safe.sol` will be only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the `SafeL2.sol` contract will be used unless you add the property `isL1SafeSingleton` to force the use of the `Safe.sol` contract.
```js
-const safeFactory = await SafeFactory.create({ ethAdapter, isL1SafeSingleton: true })
+const safeFactory = await SafeFactory.init({ provider, signer, isL1SafeSingleton: true })
-const safeSdk = await Safe.create({ ethAdapter, safeAddress, isL1SafeSingleton: true })
+const protocolKit = await Safe.init({ provider, signer, safeAddress, isL1SafeSingleton: true })
```
If the Safe contracts are not deployed to your current network, the property `contractNetworks` will be required to point to the addresses of the Safe contracts previously deployed by you.
```js
-import { ContractNetworksConfig } from '@safe-global/protocol-kit'
+import { ContractNetworksConfig, SafeProvider } from '@safe-global/protocol-kit'
-const chainId = await ethAdapter.getChainId()
+const safeProvider = new SafeProvider({ provider, signer })
+const chainId = await safeProvider.getChainId()
const contractNetworks: ContractNetworksConfig = {
[chainId]: {
safeSingletonAddress: '',
@@ -101,16 +100,16 @@ const contractNetworks: ContractNetworksConfig = {
}
}
-const safeFactory = await SafeFactory.create({ ethAdapter, contractNetworks })
+const safeFactory = await SafeFactory.init({ provider, signer, contractNetworks })
-const safeSdk = await Safe.create({ ethAdapter, safeAddress, contractNetworks })
+const protocolKit = await Safe.init({ provider, signer, safeAddress, contractNetworks })
```
The `SafeFactory` constructor also accepts the property `safeVersion` to specify the Safe contract version that will be deployed. This string can take the values `1.0.0`, `1.1.1`, `1.2.0`, `1.3.0` or `1.4.1`. If not specified, the `DEFAULT_SAFE_VERSION` value will be used.
```js
const safeVersion = 'X.Y.Z'
-const safeFactory = await SafeFactory.create({ ethAdapter, safeVersion })
+const safeFactory = await SafeFactory.init({ provider, signer, safeVersion })
```
## 3. Deploy a new Safe
@@ -127,7 +126,7 @@ const safeAccountConfig: SafeAccountConfig = {
threshold: 2,
// ... (optional params)
}
-const safeSdk = await safeFactory.deploySafe({ safeAccountConfig })
+const protocolKit = await safeFactory.deploySafe({ safeAccountConfig })
```
Calling the method `deploySafe` will deploy the desired Safe and return a Protocol Kit initialized instance ready to be used. Check the [API Reference](https://github.com/safe-global/safe-core-sdk/tree/main/packages/protocol-kit#deploysafe) for more details on additional configuration parameters and callbacks.
@@ -140,42 +139,42 @@ This method takes an array of `MetaTransactionData` objects that represent the i
When the array contains only one transaction, it is not wrapped in the MultiSend.
- ```js
- import { SafeTransactionOptionalProps } from '@safe-global/protocol-kit'
- import { MetaTransactionData } from '@safe-global/safe-core-sdk-types'
-
- const transactions: MetaTransactionData[] = [
- {
- to,
- data,
- value,
- operation
- },
- {
- to,
- data,
- value,
- operation
- }
- // ...
- ]
-
- const options: SafeTransactionOptionalProps = {
- safeTxGas, // Optional
- baseGas, // Optional
- gasPrice, // Optional
- gasToken, // Optional
- refundReceiver, // Optional
- nonce // Optional
+```js
+import { SafeTransactionOptionalProps } from '@safe-global/protocol-kit'
+import { MetaTransactionData } from '@safe-global/safe-core-sdk-types'
+
+const transactions: MetaTransactionData[] = [
+ {
+ to,
+ data,
+ value,
+ operation
+ },
+ {
+ to,
+ data,
+ value,
+ operation
}
+ // ...
+]
+
+const options: SafeTransactionOptionalProps = {
+ safeTxGas, // Optional
+ baseGas, // Optional
+ gasPrice, // Optional
+ gasToken, // Optional
+ refundReceiver, // Optional
+ nonce // Optional
+}
- const safeTransaction = await safeSdk.createTransaction({ transactions, options })
- ```
+const safeTransaction = await protocolKit.createTransaction({ transactions, options })
+```
We can specify the `nonce` of our Safe transaction as long as it is not lower than the current Safe nonce. If multiple transactions are created but not executed they will share the same `nonce` if no `nonce` is specified, validating the first executed transaction and invalidating all the rest. We can prevent this by calling the method `getNextNonce` from the Safe API Kit instance. This method takes all queued/pending transactions into account when calculating the next nonce, creating a unique one for all different transactions.
```js
-const nonce = await safeService.getNextNonce(safeAddress)
+const nonce = await apiKit.getNextNonce(safeAddress)
```
## 5. Propose the transaction to the service
@@ -190,9 +189,9 @@ Once we have the Safe transaction object we can share it with the other owners o
- `origin`: Optional string that allows to provide more information about the app proposing the transaction.
```js
-const safeTxHash = await safeSdk.getTransactionHash(safeTransaction)
-const senderSignature = await safeSdk.signHash(safeTxHash)
-await safeService.proposeTransaction({
+const safeTxHash = await protocolKit.getTransactionHash(safeTransaction)
+const senderSignature = await protocolKit.signHash(safeTxHash)
+await apiKit.proposeTransaction({
safeAddress,
safeTransactionData: safeTransaction.data,
safeTxHash,
@@ -209,13 +208,13 @@ The transaction is then available on the Safe Transaction Service and the owners
Get a list of pending transactions:
```js
-const pendingTxs = await safeService.getPendingTransactions(safeAddress)
+const pendingTxs = await apiKit.getPendingTransactions(safeAddress)
```
Get a specific transaction given its Safe transaction hash:
```js
-const tx = await safeService.getTransaction(safeTxHash)
+const tx = await apiKit.getTransaction(safeTxHash)
```
The retrieved transaction will have this type:
@@ -271,8 +270,8 @@ The owners of the Safe can now sign the transaction obtained from the Safe Trans
// transaction: SafeMultisigTransactionResponse
const hash = transaction.safeTxHash
-let signature = await safeSdk.signHash(hash)
-await safeService.confirmTransaction(hash, signature.data)
+let signature = await protocolKit.signHash(hash)
+await apiKit.confirmTransaction(hash, signature.data)
```
## 8. Execute the transaction
@@ -282,15 +281,15 @@ Once there are enough confirmations in the service the transaction is ready to b
The method `executeTransaction` accepts an instance of the class `SafeTransaction` so the transaction needs to be transformed from the type `SafeMultisigTransactionResponse`.
```js
-const safeTransaction = await safeService.getTransaction(...)
-const executeTxResponse = await safeSdk.executeTransaction(safeTransaction)
+const safeTransaction = await apiKit.getTransaction(...)
+const executeTxResponse = await protocolKit.executeTransaction(safeTransaction)
const receipt = executeTxResponse.transactionResponse && (await executeTxResponse.transactionResponse.wait())
```
Optionally, the `isValidTransaction` method, that returns a boolean value, could be called right before the `executeTransaction` method to check if the transaction will be executed successfully or not.
```js
-const isValidTx = await safeSdk.isValidTransaction(safeTransaction)
+const isValidTx = await protocolKit.isValidTransaction(safeTransaction)
```
## 9. Interface checks
diff --git a/package.json b/package.json
index 60111881e..a482596b3 100644
--- a/package.json
+++ b/package.json
@@ -7,7 +7,6 @@
"build": "lerna run build --stream",
"lint:check": "eslint './packages/**/*.{js,jsx,ts,tsx}'",
"test": "FORCE_COLOR=1 lerna run test --stream",
- "test:ci": "FORCE_COLOR=1 lerna run test:ci --stream",
"play": "ts-node ./playground/config/run.ts",
"format": "lerna run format && prettier --write \"playground/**/*.ts\"",
"prepare": "husky install"
@@ -20,20 +19,20 @@
"author": "Safe (https://safe.global)",
"license": "MIT",
"devDependencies": {
- "@types/jest": "^29.5.11",
+ "@types/jest": "^29.5.12",
"@types/node": "^18.18.8",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
- "eslint-plugin-prettier": "^5.0.1",
+ "eslint-plugin-prettier": "^5.1.3",
"husky": "^8.0.3",
"jest": "^29.7.0",
"lerna": "^7.4.2",
"lint-staged": "^14.0.1",
- "prettier": "^3.1.1",
+ "prettier": "^3.2.5",
"rimraf": "^3.0.2",
- "ts-jest": "^29.1.1",
+ "ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"tsc-alias": "^1.8.8",
"typescript": "^5.3.3"
diff --git a/packages/account-abstraction-kit/README.md b/packages/account-abstraction-kit/README.md
index 6daf9d034..63b7f496f 100644
--- a/packages/account-abstraction-kit/README.md
+++ b/packages/account-abstraction-kit/README.md
@@ -9,36 +9,27 @@ Description TBD
## Table of contents
- [Installation](#installation)
-- [Build](#build)
-- [Initialization](#initialization)
+- [Need Help or Have Questions?](#need-help-or-have-questions)
+- [Contributing](#contributing)
- [License](#license)
-## Installation
+## Installation
Install the package with yarn or npm:
```bash
-yarn install
-npm install
+yarn add @safe-global/account-abstraction-kit-poc
+npm install @safe-global/account-abstraction-kit-poc
```
-## Build
+## Need Help or Have Questions?
-Build the package with yarn or npm:
+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)
-```bash
-yarn build
-npm run build
-```
-
-## Initialization
+## Contributing
-Initialization TBD
-
-```js
-
-```
+Please read our [contribution guidelines](https://github.com/safe-global/safe-core-sdk/tree/main/CONTRIBUTING.md) before submitting any changes. We appreciate your help! 🙌
## License
-This library is [released under MIT](https://github.com/safe-global/account-abstraction-sdk/blob/main/LICENSE.md).
+This library is [released under MIT](https://github.com/safe-global/safe-core-sdk/blob/main/LICENSE.md).
diff --git a/packages/account-abstraction-kit/jest.config.js b/packages/account-abstraction-kit/jest.config.js
index 44aaa1c09..069f7c520 100644
--- a/packages/account-abstraction-kit/jest.config.js
+++ b/packages/account-abstraction-kit/jest.config.js
@@ -5,7 +5,6 @@ const config = {
'^.+\\.ts?$': 'ts-jest'
},
moduleNameMapper: {
- '^@safe-global/protocol-kit/typechain/(.*)$': '/../protocol-kit/typechain/$1',
'^@safe-global/protocol-kit/(.*)$': '/../protocol-kit/src/$1',
'^@safe-global/relay-kit/(.*)$': '/../relay-kit/src/$1',
'^@safe-global/account-abstraction-kit-poc/(.*)$': '/src/$1'
diff --git a/packages/account-abstraction-kit/package.json b/packages/account-abstraction-kit/package.json
index 53119ba28..f059602be 100644
--- a/packages/account-abstraction-kit/package.json
+++ b/packages/account-abstraction-kit/package.json
@@ -1,6 +1,6 @@
{
"name": "@safe-global/account-abstraction-kit-poc",
- "version": "2.1.1",
+ "version": "3.0.0-alpha.0",
"description": "Safe Account Abstraction Kit PoC",
"main": "dist/src/index.js",
"typings": "dist/src/index.d.ts",
@@ -34,8 +34,8 @@
"access": "public"
},
"dependencies": {
- "@safe-global/protocol-kit": "^3.1.1",
- "@safe-global/relay-kit": "^2.1.1",
- "@safe-global/safe-core-sdk-types": "^4.1.1"
+ "@safe-global/protocol-kit": "^4.0.0-alpha.0",
+ "@safe-global/relay-kit": "^3.0.0-alpha.0",
+ "@safe-global/safe-core-sdk-types": "^5.0.0-alpha.0"
}
}
diff --git a/packages/account-abstraction-kit/src/AccountAbstraction.test.ts b/packages/account-abstraction-kit/src/AccountAbstraction.test.ts
index a33980e39..512e128ec 100644
--- a/packages/account-abstraction-kit/src/AccountAbstraction.test.ts
+++ b/packages/account-abstraction-kit/src/AccountAbstraction.test.ts
@@ -1,6 +1,6 @@
-import Safe, { predictSafeAddress } from '@safe-global/protocol-kit'
+import Safe, { predictSafeAddress, SafeProvider } from '@safe-global/protocol-kit'
import { GelatoRelayPack } from '@safe-global/relay-kit'
-import { EthAdapter, SafeTransaction } from '@safe-global/safe-core-sdk-types'
+import { SafeTransaction } from '@safe-global/safe-core-sdk-types'
import AccountAbstraction from './AccountAbstraction'
jest.mock('@safe-global/protocol-kit')
@@ -9,68 +9,73 @@ jest.mock('@safe-global/relay-kit')
const GelatoRelayPackMock = GelatoRelayPack as jest.MockedClass
const predictSafeAddressMock = predictSafeAddress as jest.MockedFunction
const SafeMock = Safe as jest.MockedClass
+const SafeProviderMock = SafeProvider as jest.MockedClass
describe('AccountAbstraction', () => {
- const ethersAdapter = {
- getSignerAddress: jest.fn(),
- isContractDeployed: jest.fn(),
- getChainId: jest.fn()
+ const provider = {
+ request: jest.fn()
}
+
const signerAddress = '0xSignerAddress'
const predictSafeAddress = '0xPredictSafeAddressMock'
beforeEach(() => {
jest.clearAllMocks()
- ethersAdapter.getSignerAddress.mockResolvedValue(signerAddress)
predictSafeAddressMock.mockResolvedValue(predictSafeAddress)
+ SafeProviderMock.prototype.getSignerAddress.mockResolvedValue(signerAddress)
})
describe('init', () => {
- const accountAbstraction = new AccountAbstraction(ethersAdapter as unknown as EthAdapter)
+ const accountAbstraction = new AccountAbstraction({ provider, signer: signerAddress })
it('should initialize a Safe instance with its address if contract is deployed already', async () => {
- ethersAdapter.isContractDeployed.mockResolvedValueOnce(true)
+ SafeProviderMock.prototype.isContractDeployed.mockResolvedValueOnce(true)
await accountAbstraction.init()
- expect(ethersAdapter.getSignerAddress).toHaveBeenCalledTimes(1)
+ expect(SafeProviderMock.prototype.getSignerAddress).toHaveBeenCalledTimes(1)
expect(predictSafeAddressMock).toHaveBeenCalledTimes(1)
- expect(predictSafeAddressMock).toHaveBeenCalledWith({
- ethAdapter: ethersAdapter,
- safeAccountConfig: { owners: ['0xSignerAddress'], threshold: 1 }
- })
- expect(SafeMock.create).toHaveBeenCalledTimes(1)
- expect(SafeMock.create).toHaveBeenCalledWith({
- ethAdapter: ethersAdapter,
- safeAddress: predictSafeAddress
- })
+ expect(predictSafeAddressMock).toHaveBeenCalledWith(
+ expect.objectContaining({
+ safeAccountConfig: { owners: ['0xSignerAddress'], threshold: 1 }
+ })
+ )
+ expect(SafeMock.init).toHaveBeenCalledTimes(1)
+ expect(SafeMock.init).toHaveBeenCalledWith(
+ expect.objectContaining({
+ safeAddress: predictSafeAddress
+ })
+ )
})
it('should initialize a Safe instance with a config if contract is NOT deployed yet', async () => {
- ethersAdapter.isContractDeployed.mockResolvedValueOnce(false)
+ SafeProviderMock.prototype.isContractDeployed.mockResolvedValueOnce(false)
await accountAbstraction.init()
- expect(ethersAdapter.getSignerAddress).toHaveBeenCalledTimes(1)
+ expect(SafeProviderMock.prototype.getSignerAddress).toHaveBeenCalledTimes(1)
expect(predictSafeAddressMock).toHaveBeenCalledTimes(1)
- expect(predictSafeAddressMock).toHaveBeenCalledWith({
- ethAdapter: ethersAdapter,
- safeAccountConfig: { owners: ['0xSignerAddress'], threshold: 1 }
- })
- expect(SafeMock.create).toHaveBeenCalledTimes(1)
- expect(SafeMock.create).toHaveBeenCalledWith({
- ethAdapter: ethersAdapter,
- predictedSafe: { safeAccountConfig: { owners: ['0xSignerAddress'], threshold: 1 } }
- })
+ expect(predictSafeAddressMock).toHaveBeenCalledWith(
+ expect.objectContaining({
+ safeAccountConfig: { owners: ['0xSignerAddress'], threshold: 1 }
+ })
+ )
+ expect(SafeMock.init).toHaveBeenCalledTimes(1)
+ expect(SafeMock.init).toHaveBeenCalledWith(
+ expect.objectContaining({
+ predictedSafe: { safeAccountConfig: { owners: ['0xSignerAddress'], threshold: 1 } }
+ })
+ )
})
it('should throw an error if the provider has not a signer', async () => {
- ethersAdapter.getSignerAddress.mockResolvedValueOnce(undefined)
+ SafeProviderMock.prototype.getSignerAddress.mockResolvedValueOnce(undefined)
expect(accountAbstraction.init()).rejects.toThrow(
- `There's no signer in the provided EthAdapter`
+ `There's no signer available with the provided config (provider, signer)`
)
- expect(SafeMock.create).not.toHaveBeenCalled()
+
+ expect(SafeMock.init).not.toHaveBeenCalled()
})
})
@@ -83,7 +88,7 @@ describe('AccountAbstraction', () => {
}
const initAccountAbstraction = async () => {
- const accountAbstraction = new AccountAbstraction(ethersAdapter as unknown as EthAdapter)
+ const accountAbstraction = new AccountAbstraction({ provider })
await accountAbstraction.init()
return accountAbstraction
}
@@ -92,7 +97,7 @@ describe('AccountAbstraction', () => {
beforeEach(async () => {
jest.clearAllMocks()
- SafeMock.create = () => Promise.resolve(safeInstanceMock as unknown as Safe)
+ SafeMock.init = () => Promise.resolve(safeInstanceMock as unknown as Safe)
accountAbstraction = await initAccountAbstraction()
})
@@ -107,7 +112,7 @@ describe('AccountAbstraction', () => {
})
it('should not be called if the protocol-kit is not initialized', async () => {
- const accountAbstraction = new AccountAbstraction(ethersAdapter as unknown as EthAdapter)
+ const accountAbstraction = new AccountAbstraction({ provider })
expect(accountAbstraction.protocolKit).toBe(undefined)
expect(safeInstanceMock.getNonce).not.toHaveBeenCalled()
})
@@ -124,7 +129,7 @@ describe('AccountAbstraction', () => {
})
it('should not be called if the protocol-kit is not initialized', async () => {
- const accountAbstraction = new AccountAbstraction(ethersAdapter as unknown as EthAdapter)
+ const accountAbstraction = new AccountAbstraction({ provider })
expect(accountAbstraction.protocolKit).toBe(undefined)
expect(safeInstanceMock.getAddress).not.toHaveBeenCalled()
})
@@ -139,7 +144,7 @@ describe('AccountAbstraction', () => {
})
it('should not be called if the protocol-kit is not initialized', async () => {
- const accountAbstraction = new AccountAbstraction(ethersAdapter as unknown as EthAdapter)
+ const accountAbstraction = new AccountAbstraction({ provider })
expect(accountAbstraction.protocolKit).toBe(undefined)
expect(safeInstanceMock.isSafeDeployed).not.toHaveBeenCalled()
})
@@ -181,7 +186,7 @@ describe('AccountAbstraction', () => {
})
it('should throw if the protocol-kit is not initialized', async () => {
- const accountAbstraction = new AccountAbstraction(ethersAdapter as unknown as EthAdapter)
+ const accountAbstraction = new AccountAbstraction({ provider })
accountAbstraction.setRelayKit(
new GelatoRelayPack({ protocolKit: accountAbstraction.protocolKit })
)
@@ -196,7 +201,7 @@ describe('AccountAbstraction', () => {
})
it('should throw if relay-kit is not initialized', async () => {
- const accountAbstraction = new AccountAbstraction(ethersAdapter as unknown as EthAdapter)
+ const accountAbstraction = new AccountAbstraction({ provider })
await accountAbstraction.init()
expect(accountAbstraction.relayTransaction(transactionsMock, optionsMock)).rejects.toThrow(
diff --git a/packages/account-abstraction-kit/src/AccountAbstraction.ts b/packages/account-abstraction-kit/src/AccountAbstraction.ts
index f8ec011ee..dbde9a422 100644
--- a/packages/account-abstraction-kit/src/AccountAbstraction.ts
+++ b/packages/account-abstraction-kit/src/AccountAbstraction.ts
@@ -1,9 +1,13 @@
-import Safe, { SafeAccountConfig, predictSafeAddress } from '@safe-global/protocol-kit'
+import Safe, {
+ SafeAccountConfig,
+ predictSafeAddress,
+ SafeProviderConfig,
+ SafeProvider
+} from '@safe-global/protocol-kit'
import { RelayKitBasePack } from '@safe-global/relay-kit'
import {
MetaTransactionData,
MetaTransactionOptions,
- EthAdapter,
SafeTransaction
} from '@safe-global/safe-core-sdk-types'
@@ -14,21 +18,24 @@ import {
class AccountAbstraction {
protocolKit!: Safe
relayKit?: RelayKitBasePack
- #ethAdapter: EthAdapter
+ #provider: SafeProviderConfig['provider']
+ #signer?: SafeProviderConfig['signer']
/**
* @constructor
- * @param ethAdapter The EthAdapter instance to be used by the Account Abstraction (e.g. EthersAdapter)
+ * @param config The SafeProviderConfig
*/
- constructor(ethAdapter: EthAdapter) {
- this.#ethAdapter = ethAdapter
+ constructor({ provider, signer }: SafeProviderConfig) {
+ this.#provider = provider
+ this.#signer = signer
}
#initializeProtocolKit = async () => {
- const signer = await this.#ethAdapter.getSignerAddress()
+ const safeProvider = new SafeProvider({ provider: this.#provider, signer: this.#signer })
+ const signer = await safeProvider.getSignerAddress()
if (!signer) {
- throw new Error("There's no signer in the provided EthAdapter")
+ throw new Error("There's no signer available with the provided config (provider, signer)")
}
const owners = [signer]
@@ -40,18 +47,23 @@ class AccountAbstraction {
}
const safeAddress = await predictSafeAddress({
- ethAdapter: this.#ethAdapter,
- chainId: await this.#ethAdapter.getChainId(),
+ safeProvider,
+ chainId: await safeProvider.getChainId(),
safeAccountConfig
})
- const isSafeDeployed = await this.#ethAdapter.isContractDeployed(safeAddress)
+ const isSafeDeployed = await safeProvider.isContractDeployed(safeAddress)
if (isSafeDeployed) {
- this.protocolKit = await Safe.create({ ethAdapter: this.#ethAdapter, safeAddress })
+ this.protocolKit = await Safe.init({
+ provider: this.#provider,
+ signer: this.#signer,
+ safeAddress
+ })
} else {
- this.protocolKit = await Safe.create({
- ethAdapter: this.#ethAdapter,
+ this.protocolKit = await Safe.init({
+ provider: this.#provider,
+ signer: this.#signer,
predictedSafe: { safeAccountConfig }
})
}
diff --git a/packages/api-kit/LICENSE.md b/packages/api-kit/LICENSE.md
index 310e6e37c..0e923d187 100644
--- a/packages/api-kit/LICENSE.md
+++ b/packages/api-kit/LICENSE.md
@@ -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:
diff --git a/packages/api-kit/README.md b/packages/api-kit/README.md
index ee6e8a97c..f64afb150 100644
--- a/packages/api-kit/README.md
+++ b/packages/api-kit/README.md
@@ -8,306 +8,46 @@ Software development kit that facilitates the interaction with the [Safe Transac
## Table of contents
+- [Documentation](#documentation)
- [Installation](#installation)
-- [Build](#build)
-- [Tests](#tests)
-- [Initialization](#initialization)
-- [API Reference](#api-reference)
+- [Quick Start](#quick-start)
+- [Need Help or Have Questions?](#need-help-or-have-questions)
+- [Contributing](#contributing)
- [License](#license)
-- [Contributors](#contributors)
-## Installation
+## Documentation
-Install the package with yarn or npm:
-
-```bash
-yarn install
-npm install
-```
-
-## Build
-
-Build the package with yarn or npm:
-
-```bash
-yarn build
-npm run build
-```
+Head to the [API Kit docs](https://docs.safe.global/sdk/api-kit) to learn more about how to use this SDK.
-## Tests
+## Installation
-Create a `.env` file with environment variables. You can use the `.env.example` file as a reference.
-
-Test the package with yarn or npm:
+Install the package with yarn or npm:
```bash
-yarn test
-npm run test
+yarn add @safe-global/api-kit
+npm install @safe-global/api-kit
```
-## Initialization
-
-### Initialize the SafeApiKit
+## Quick Start
```js
import SafeApiKit from '@safe-global/api-kit'
-const safeService = new SafeApiKit({
+const apiKit = new SafeApiKit({
chainId: 1n,
// Optional. txServiceUrl must be used to set a custom service. For example on chains where Safe doesn't run services.
txServiceUrl: 'https://safe-transaction-mainnet.safe.global'
})
```
-## API Reference
-
-### getServiceInfo
-
-Returns the information and configuration of the service.
-
-```js
-const serviceInfo: SafeServiceInfoResponse = await safeService.getServiceInfo()
-```
-
-### getServiceSingletonsInfo
-
-Returns the list of Safe singleton copies.
-
-```js
-const singletons: SafeSingletonResponse = await safeService.getServiceSingletonsInfo()
-```
-
-### decodeData
-
-Decodes the specified Safe transaction data.
-
-```js
-const decodedData = await safeService.decodeData(data)
-```
-
-### getSafesByOwner
-
-Returns the list of Safes where the address provided is an owner.
-
-```js
-const safes: OwnerResponse = await safeService.getSafesByOwner(ownerAddress)
-```
-
-### getSafesByModule
-
-Returns the list of Safes where the module address provided is enabled.
-
-```js
-const safes: ModulesResponse = await getSafesByModule(moduleAddress)
-```
-
-### getTransaction
-
-Returns all the information of a Safe transaction.
-
-```js
-const tx: SafeMultisigTransactionResponse = await safeService.getTransaction(safeTxHash)
-```
-
-### getTransactionConfirmations
-
-Returns the list of confirmations for a given a Safe transaction.
-
-```js
-const confirmations: SafeMultisigConfirmationListResponse =
- await safeService.getTransactionConfirmations(safeTxHash)
-```
-
-### confirmTransaction
-
-Adds a confirmation for a Safe transaction.
-
-```js
-const signature: SignatureResponse = await safeService.confirmTransaction(safeTxHash, signature)
-```
-
-### getSafeInfo
-
-Returns the information and configuration of the provided Safe address.
-
-```js
-const safeInfo: SafeInfoResponse = await safeService.getSafeInfo(safeAddress)
-```
-
-### getSafeDelegates
-
-Returns the list of delegates for a given Safe address.
-
-```js
-const delegateConfig: GetSafeDelegateProps = {
- safeAddress, // Optional
- delegateAddress, // Optional
- delegatorAddress, // Optional
- label, // Optional
- limit, // Optional
- offset // Optional
-}
-const delegates: SafeDelegateListResponse = await safeService.getSafeDelegates(delegateConfig)
-```
-
-### addSafeDelegate
-
-Adds a new delegate for a given Safe address.
-
-```js
-const delegateConfig: AddSafeDelegateProps = {
- safeAddress, // Optional
- delegateAddress,
- delegatorAddress,
- label,
- signer
-}
-await safeService.addSafeDelegate(delegateConfig)
-```
-
-### removeSafeDelegate
-
-Removes a delegate for a given Safe address.
-
-```js
-const delegateConfig: DeleteSafeDelegateProps = {
- delegateAddress,
- delegatorAddress,
- signer
-}
-await safeService.removeSafeDelegate(delegateConfig)
-```
-
-### getSafeCreationInfo
-
-Returns the creation information of a Safe.
-
-```js
-const safeCreationInfo: SafeCreationInfoResponse = await safeService.getSafeCreationInfo(
- safeAddress
-)
-```
-
-### estimateSafeTransaction
-
-Estimates the safeTxGas for a given Safe multi-signature transaction.
-
-```js
-const estimateTx: SafeMultisigTransactionEstimateResponse =
- await safeService.estimateSafeTransaction(safeAddress, safeTransaction)
-```
-
-### proposeTransaction
-
-Creates a new multi-signature transaction and stores it in the Safe Transaction Service.
-
-```js
-const transactionConfig: ProposeTransactionProps = {
- safeAddress,
- safeTxHash,
- safeTransactionData,
- senderAddress,
- senderSignature,
- origin
-}
-await safeService.proposeTransaction(transactionConfig)
-```
-
-### getIncomingTransactions
-
-Returns the history of incoming transactions of a Safe account.
-
-```js
-const incomingTxs: TransferListResponse = await safeService.getIncomingTransactions(safeAddress)
-```
-
-### getModuleTransactions
-
-Returns the history of module transactions of a Safe account.
-
-```js
-const moduleTxs: SafeModuleTransactionListResponse = await safeService.getModuleTransactions(
- safeAddress
-)
-```
-
-### getMultisigTransactions
-
-Returns the history of multi-signature transactions of a Safe account.
-
-```js
-const multisigTxs: SafeMultisigTransactionListResponse = await safeService.getMultisigTransactions(
- safeAddress
-)
-```
-
-### getPendingTransactions
-
-Returns the list of multi-signature transactions that are waiting for the confirmation of the Safe owners.
+## Need Help or Have Questions?
-```js
-const pendingTxs: SafeMultisigTransactionListResponse = await safeService.getPendingTransactions(
- safeAddress
-)
-```
-
-```js
-const pendingTxs: SafeMultisigTransactionListResponse = await safeService.getPendingTransactions(
- safeAddress,
- currentNonce
-)
-```
-
-### getAllTransactions
-
-Returns a list of transactions for a Safe. The list has different structures depending on the transaction type.
-
-```js
-const allTxs: SafeMultisigTransactionListResponse = await safeService.getAllTransactions(
- safeAddress
-)
-```
-
-```js
-const allTxsOptions: AllTransactionsOptions = {
- executed,
- queued,
- trusted
-}
-const allTxs: SafeMultisigTransactionListResponse = await safeService.getAllTransactions(
- safeAddress,
- allTxsOptions
-)
-```
-
-### getNextNonce
-
-Returns the right nonce to propose a new transaction right after the last pending transaction.
-
-```js
-const nextNonce = await safeService.getNextNonce(safeAddress)
-```
-
-### getTokenList
-
-Returns the list of all the ERC20 tokens handled by the Safe.
-
-```js
-const tokens: TokenInfoListResponse = await safeService.getTokenList()
-```
-
-### getToken
-
-Returns the information of a given ERC20 token.
-
-```js
-const token: TokenInfoResponse = await safeService.getToken(tokenAddress)
-```
+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)
-## License
+## Contributing
-This library is released under MIT.
+Please read our [contribution guidelines](https://github.com/safe-global/safe-core-sdk/tree/main/CONTRIBUTING.md) before submitting any changes. We appreciate your help! 🙌
-## Contributors
+## License
-- Germán Martínez ([germartinez](https://github.com/germartinez))
+This library is [released under MIT](https://github.com/safe-global/safe-core-sdk/blob/main/LICENSE.md).
diff --git a/packages/api-kit/hardhat.config.ts b/packages/api-kit/hardhat.config.ts
index 894ebfeb3..6525853ab 100644
--- a/packages/api-kit/hardhat.config.ts
+++ b/packages/api-kit/hardhat.config.ts
@@ -1,5 +1,4 @@
import '@nomicfoundation/hardhat-ethers'
-import '@nomiclabs/hardhat-web3'
import dotenv from 'dotenv'
import { HardhatUserConfig, HttpNetworkUserConfig } from 'hardhat/types'
import yargs from 'yargs'
@@ -41,7 +40,7 @@ const config: HardhatUserConfig = {
},
sepolia: {
...sharedNetworkConfig,
- url: 'https://rpc.ankr.com/eth_sepolia'
+ url: 'https://sepolia.gateway.tenderly.co'
}
},
//@ts-expect-error Type not found
diff --git a/packages/api-kit/package.json b/packages/api-kit/package.json
index 848edfefa..18d6a688f 100644
--- a/packages/api-kit/package.json
+++ b/packages/api-kit/package.json
@@ -1,6 +1,6 @@
{
"name": "@safe-global/api-kit",
- "version": "2.3.2",
+ "version": "2.3.2-alpha.0",
"description": "Safe API Kit",
"main": "dist/src/index.js",
"typings": "dist/src/index.d.ts",
@@ -13,9 +13,11 @@
"scripts": {
"test:web3": "export TESTS_PATH=tests/endpoint && export ETH_LIB=web3 && nyc hardhat test",
"test:ethers": "export TESTS_PATH=tests/endpoint && export ETH_LIB=ethers && nyc --reporter=lcov hardhat test",
+ "test:viem": "export TESTS_PATH=tests/endpoint && export ETH_LIB=viem && nyc hardhat test",
"test": "yarn test:ethers",
"test:ci:web3": "export TESTS_PATH=tests/e2e && export ETH_LIB=web3 && nyc hardhat test",
"test:ci:ethers": "export TESTS_PATH=tests/e2e && export ETH_LIB=ethers && nyc --reporter=lcov hardhat test",
+ "test:ci:viem": "export TESTS_PATH=tests/e2e && export ETH_LIB=viem && nyc --reporter=lcov hardhat test",
"test:ci": "yarn test:ci:ethers",
"format:check": "prettier --check \"*/**/*.{js,json,md,ts}\"",
"format": "prettier --write \"*/**/*.{js,json,md,ts}\"",
@@ -37,27 +39,28 @@
"homepage": "https://github.com/safe-global/safe-core-sdk#readme",
"devDependencies": {
"@nomicfoundation/hardhat-ethers": "^3.0.5",
- "@nomiclabs/hardhat-web3": "^2.0.0",
- "@types/chai": "^4.3.11",
+ "@types/chai": "^4.3.16",
"@types/chai-as-promised": "^7.1.8",
"@types/mocha": "^10.0.6",
- "@types/node-fetch": "^2.6.9",
+ "@types/node-fetch": "^2.6.11",
"@types/sinon-chai": "^3.2.11",
"@types/yargs": "^17.0.32",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
"hardhat": "^2.19.3",
"mocha": "^10.2.0",
- "semver": "^7.5.4",
+ "semver": "^7.6.1",
"sinon": "^14.0.2",
"sinon-chai": "^3.7.0",
"tsconfig-paths": "^4.2.0",
+ "viem": "^2.10.2",
+ "web3": "^4.7.0",
"yargs": "^17.7.2"
},
"dependencies": {
- "@safe-global/protocol-kit": "^3.1.1",
- "@safe-global/safe-core-sdk-types": "^4.1.1",
- "ethers": "^6.7.1",
+ "@safe-global/protocol-kit": "^4.0.0-alpha.0",
+ "@safe-global/safe-core-sdk-types": "^5.0.0-alpha.0",
+ "ethers": "^6.12.1",
"node-fetch": "^2.7.0"
}
}
diff --git a/packages/api-kit/tests/e2e/addMessage.test.ts b/packages/api-kit/tests/e2e/addMessage.test.ts
index bcfc944b2..ca1fa483a 100644
--- a/packages/api-kit/tests/e2e/addMessage.test.ts
+++ b/packages/api-kit/tests/e2e/addMessage.test.ts
@@ -1,14 +1,14 @@
import Safe from '@safe-global/protocol-kit'
-import { EthAdapter } from '@safe-global/safe-core-sdk-types'
import SafeApiKit from '@safe-global/api-kit/index'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getKits } from '../utils/setupKits'
chai.use(chaiAsPromised)
+const PRIVATE_KEY = '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
+
let safeApiKit: SafeApiKit
-let ethAdapter: EthAdapter
let protocolKit: Safe
const generateRandomUUID = (): string => {
@@ -24,14 +24,10 @@ const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
describe('addMessage', () => {
before(async () => {
- ;({ safeApiKit, ethAdapter } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
-
- protocolKit = await Safe.create({
- ethAdapter,
- safeAddress
- })
+ ;({ safeApiKit, protocolKit } = await getKits({
+ safeAddress,
+ signer: PRIVATE_KEY
+ }))
})
it('should fail if safeAddress is empty or invalid', async () => {
diff --git a/packages/api-kit/tests/e2e/addMessageSignature.test.ts b/packages/api-kit/tests/e2e/addMessageSignature.test.ts
index 2a7d74581..b4b5cad94 100644
--- a/packages/api-kit/tests/e2e/addMessageSignature.test.ts
+++ b/packages/api-kit/tests/e2e/addMessageSignature.test.ts
@@ -5,18 +5,21 @@ import Safe, {
SigningMethod,
buildContractSignature
} from '@safe-global/protocol-kit'
-import { EthAdapter, SafeMessage } from '@safe-global/safe-core-sdk-types'
+import { SafeMessage } from '@safe-global/safe-core-sdk-types'
import SafeApiKit from '@safe-global/api-kit/index'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getKits } from '../utils/setupKits'
chai.use(chaiAsPromised)
-let safeApiKit1: SafeApiKit
+const PRIVATE_KEY_1 = '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
+const PRIVATE_KEY_2 = '0xb88ad5789871315d0dab6fc5961d6714f24f35a6393f13a6f426dfecfc00ab44'
+
+let safeApiKit: SafeApiKit
let protocolKit: Safe
-let ethAdapter1: EthAdapter
-let ethAdapter2: EthAdapter
+const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
+const signerSafeAddress = '0xDa8dd250065F19f7A29564396D7F13230b9fC5A3'
const generateRandomUUID = (): string => {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
@@ -27,74 +30,63 @@ const generateRandomUUID = (): string => {
}
const generateMessage = () => `${generateRandomUUID()}: I am the owner of the safe`
-const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
-const signerSafeAddress = '0xDa8dd250065F19f7A29564396D7F13230b9fC5A3'
describe('addMessageSignature', () => {
before(async () => {
- ;({ safeApiKit: safeApiKit1, ethAdapter: ethAdapter1 } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
- ;({ ethAdapter: ethAdapter2 } = await getServiceClient(
- '0xb88ad5789871315d0dab6fc5961d6714f24f35a6393f13a6f426dfecfc00ab44'
- ))
+ ;({ safeApiKit, protocolKit } = await getKits({
+ safeAddress,
+ signer: PRIVATE_KEY_1
+ }))
})
it('should fail if safeAddress is empty', async () => {
await chai
- .expect(safeApiKit1.addMessageSignature('', '0x'))
+ .expect(safeApiKit.addMessageSignature('', '0x'))
.to.be.rejectedWith('Invalid messageHash or signature')
})
it('should fail if signature is empty', async () => {
await chai
- .expect(safeApiKit1.addMessageSignature(safeAddress, ''))
+ .expect(safeApiKit.addMessageSignature(safeAddress, ''))
.to.be.rejectedWith('Invalid messageHash or signature')
})
describe('when adding a new message', () => {
- beforeEach(async () => {
- protocolKit = await Safe.create({
- ethAdapter: ethAdapter1,
- safeAddress
- })
- })
-
it('should allow to add a confirmation signature using the EIP-712', async () => {
const rawMessage: string = generateMessage()
let safeMessage: SafeMessage = protocolKit.createMessage(rawMessage)
safeMessage = await protocolKit.signMessage(safeMessage, 'eth_sign')
- let signerAddress = (await ethAdapter1.getSignerAddress()) || '0x'
+ let signerAddress = (await protocolKit.getSafeProvider().getSignerAddress()) || '0x'
await chai.expect(
- safeApiKit1.addMessage(safeAddress, {
+ safeApiKit.addMessage(safeAddress, {
message: rawMessage,
signature: safeMessage.getSignature(signerAddress)?.data || '0x'
})
).to.be.fulfilled
- protocolKit = await protocolKit.connect({ ethAdapter: ethAdapter2 })
+ protocolKit = await protocolKit.connect({ signer: PRIVATE_KEY_2 })
safeMessage = await protocolKit.signMessage(safeMessage, 'eth_signTypedData_v4')
const safeMessageHash = await protocolKit.getSafeMessageHash(hashSafeMessage(rawMessage))
- signerAddress = (await ethAdapter2.getSignerAddress()) || '0x'
+ signerAddress = (await protocolKit.getSafeProvider().getSignerAddress()) || '0x'
await chai.expect(
- safeApiKit1.addMessageSignature(
+ safeApiKit.addMessageSignature(
safeMessageHash,
safeMessage.getSignature(signerAddress)?.data || '0x'
)
).to.be.fulfilled
- const confirmedMessage = await safeApiKit1.getMessage(safeMessageHash)
+ const confirmedMessage = await safeApiKit.getMessage(safeMessageHash)
chai.expect(confirmedMessage.confirmations.length).to.eq(2)
})
it('should allow to add a confirmation signature using a Safe signer', async () => {
protocolKit = await protocolKit.connect({
- ethAdapter: ethAdapter1,
+ signer: PRIVATE_KEY_1,
safeAddress
})
@@ -104,18 +96,18 @@ describe('addMessageSignature', () => {
let safeMessage: SafeMessage = protocolKit.createMessage(rawMessage)
safeMessage = await protocolKit.signMessage(safeMessage, 'eth_sign')
- const signerAddress = (await ethAdapter1.getSignerAddress()) || '0x'
+ const signerAddress = (await protocolKit.getSafeProvider().getSignerAddress()) || '0x'
const ethSig = safeMessage.getSignature(signerAddress) as EthSafeSignature
await chai.expect(
- safeApiKit1.addMessage(safeAddress, {
+ safeApiKit.addMessage(safeAddress, {
message: rawMessage,
signature: buildSignatureBytes([ethSig])
})
).to.be.fulfilled
protocolKit = await protocolKit.connect({
- ethAdapter: ethAdapter1,
+ signer: PRIVATE_KEY_1,
safeAddress: signerSafeAddress
})
let signerSafeMessage = protocolKit.createMessage(rawMessage)
@@ -126,7 +118,7 @@ describe('addMessageSignature', () => {
)
protocolKit = await protocolKit.connect({
- ethAdapter: ethAdapter2,
+ signer: PRIVATE_KEY_2,
safeAddress: signerSafeAddress
})
signerSafeMessage = await protocolKit.signMessage(
@@ -141,7 +133,7 @@ describe('addMessageSignature', () => {
)
protocolKit = await protocolKit.connect({
- ethAdapter: ethAdapter1,
+ signer: PRIVATE_KEY_1,
safeAddress
})
@@ -156,10 +148,10 @@ describe('addMessageSignature', () => {
const contractSig = buildSignatureBytes([signerSafeSig])
- await chai.expect(safeApiKit1.addMessageSignature(safeMessageHash, contractSig)).to.be
+ await chai.expect(safeApiKit.addMessageSignature(safeMessageHash, contractSig)).to.be
.fulfilled
- const confirmedMessage = await safeApiKit1.getMessage(safeMessageHash)
+ const confirmedMessage = await safeApiKit.getMessage(safeMessageHash)
chai.expect(confirmedMessage.confirmations.length).to.eq(2)
})
})
diff --git a/packages/api-kit/tests/e2e/addSafeDelegate.test.ts b/packages/api-kit/tests/e2e/addSafeDelegate.test.ts
index d91efe0ce..f791c14fd 100644
--- a/packages/api-kit/tests/e2e/addSafeDelegate.test.ts
+++ b/packages/api-kit/tests/e2e/addSafeDelegate.test.ts
@@ -1,25 +1,26 @@
-import { Signer } from 'ethers'
+import { ethers, Signer } from 'ethers'
import SafeApiKit, { AddSafeDelegateProps } from '@safe-global/api-kit/index'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import config from '../utils/config'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
chai.use(chaiAsPromised)
+const PRIVATE_KEY_1 = '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
+const PRIVATE_KEY_2 = '0xb0057716d5917badaf911b193b12b910811c1497b5bada8d7711f758981c3773'
+
let safeApiKit: SafeApiKit
let signer: Signer
describe('addSafeDelegate', () => {
before(async () => {
- ;({ safeApiKit, signer } = await getServiceClient(
- '0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d',
- 'https://safe-transaction-sepolia.staging.5afe.dev/api'
- ))
+ safeApiKit = getApiKit('https://safe-transaction-sepolia.staging.5afe.dev/api')
+ signer = new ethers.Wallet(PRIVATE_KEY_1)
})
it('should fail if Label is empty', async () => {
- const delegateAddress = '0xe4bb611E4e4164D54Ad7361B9d58b0A1eBD462B8'
+ const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
const delegatorAddress = await signer.getAddress()
const delegateConfig: AddSafeDelegateProps = {
delegateAddress,
@@ -61,8 +62,8 @@ describe('addSafeDelegate', () => {
})
it('should fail if Safe address is not checksummed', async () => {
- const safeAddress = '0xe4bb611E4e4164D54Ad7361B9d58b0A1eBD462B8'.toLowerCase()
- const delegateAddress = '0xe4bb611E4e4164D54Ad7361B9d58b0A1eBD462B8'
+ const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'.toLowerCase()
+ const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
const delegatorAddress = await signer.getAddress()
const delegateConfig: AddSafeDelegateProps = {
safeAddress,
@@ -77,8 +78,8 @@ describe('addSafeDelegate', () => {
})
it('should fail if Safe delegate address is not checksummed', async () => {
- const safeAddress = '0xe4bb611E4e4164D54Ad7361B9d58b0A1eBD462B8'
- const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'.toLowerCase()
+ const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
+ const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'.toLowerCase()
const delegatorAddress = await signer.getAddress()
const delegateConfig: AddSafeDelegateProps = {
safeAddress,
@@ -93,8 +94,8 @@ describe('addSafeDelegate', () => {
})
it('should fail if Safe delegator address is not checksummed', async () => {
- const safeAddress = '0xe4bb611E4e4164D54Ad7361B9d58b0A1eBD462B8'
- const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'
+ const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
+ const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
const delegatorAddress = (await signer.getAddress()).toLowerCase()
const delegateConfig: AddSafeDelegateProps = {
safeAddress,
@@ -125,18 +126,15 @@ describe('addSafeDelegate', () => {
})
it('should fail if the signer is not an owner of the Safe', async () => {
- const { safeApiKit, signer } = await getServiceClient(
- '0xb0057716d5917badaf911b193b12b910811c1497b5bada8d7711f758981c3773',
- 'https://safe-transaction-sepolia.staging.5afe.dev/api'
- )
- const safeAddress = '0xe4bb611E4e4164D54Ad7361B9d58b0A1eBD462B8'
- const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'
- const delegatorAddress = await signer.getAddress()
+ const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
+ const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
+ const nonOwnerSigner = new ethers.Wallet(PRIVATE_KEY_2)
+ const delegatorAddress = await nonOwnerSigner.getAddress()
const delegateConfig: AddSafeDelegateProps = {
safeAddress,
delegateAddress,
delegatorAddress,
- signer,
+ signer: nonOwnerSigner,
label: 'Label'
}
await chai
@@ -147,8 +145,8 @@ describe('addSafeDelegate', () => {
})
it('should add a new delegate', async () => {
- const safeAddress = '0xe4bb611E4e4164D54Ad7361B9d58b0A1eBD462B8'
- const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'
+ const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
+ const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
const delegatorAddress = await signer.getAddress()
const delegateConfig: AddSafeDelegateProps = {
safeAddress,
@@ -198,7 +196,7 @@ describe('addSafeDelegate', () => {
})
it('should add a new delegate EIP-3770', async () => {
- const safeAddress = '0xe4bb611E4e4164D54Ad7361B9d58b0A1eBD462B8'
+ const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}`
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
const eip3770DelegateAddress = `${config.EIP_3770_PREFIX}:${delegateAddress}`
diff --git a/packages/api-kit/tests/e2e/confirmTransaction.test.ts b/packages/api-kit/tests/e2e/confirmTransaction.test.ts
index 0be972545..c2878e7f5 100644
--- a/packages/api-kit/tests/e2e/confirmTransaction.test.ts
+++ b/packages/api-kit/tests/e2e/confirmTransaction.test.ts
@@ -4,37 +4,29 @@ import Safe, {
SigningMethod,
buildContractSignature
} from '@safe-global/protocol-kit'
-import { EthAdapter, SafeTransactionDataPartial } from '@safe-global/safe-core-sdk-types'
+import { SafeTransactionDataPartial } from '@safe-global/safe-core-sdk-types'
import SafeApiKit from '@safe-global/api-kit/index'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getKits } from '../utils/setupKits'
chai.use(chaiAsPromised)
-let safeApiKit1: SafeApiKit
+const PRIVATE_KEY_1 = '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
+const PRIVATE_KEY_2 = '0xb88ad5789871315d0dab6fc5961d6714f24f35a6393f13a6f426dfecfc00ab44'
+
+let safeApiKit: SafeApiKit
let protocolKit: Safe
-let ethAdapter1: EthAdapter
-let ethAdapter2: EthAdapter
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const signerSafeAddress = '0xDa8dd250065F19f7A29564396D7F13230b9fC5A3'
describe('proposeTransaction', () => {
before(async () => {
- ;({ safeApiKit: safeApiKit1, ethAdapter: ethAdapter1 } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
- ;({ ethAdapter: ethAdapter2 } = await getServiceClient(
- '0xb88ad5789871315d0dab6fc5961d6714f24f35a6393f13a6f426dfecfc00ab44'
- ))
- })
-
- beforeEach(async () => {
- protocolKit = await Safe.create({
- ethAdapter: ethAdapter1,
+ ;({ safeApiKit, protocolKit } = await getKits({
+ signer: PRIVATE_KEY_1,
safeAddress
- })
+ }))
})
it('should allow to create and confirm transactions signature using a Safe signer', async () => {
@@ -50,7 +42,7 @@ describe('proposeTransaction', () => {
// EOA signature
tx = await protocolKit.signTransaction(tx)
- const signerAddress = (await ethAdapter1.getSignerAddress()) || '0x'
+ const signerAddress = (await protocolKit.getSafeProvider().getSignerAddress()) || '0x'
const ethSig = tx.getSignature(signerAddress) as EthSafeSignature
const txOptions = {
@@ -61,11 +53,11 @@ describe('proposeTransaction', () => {
senderSignature: buildSignatureBytes([ethSig])
}
- await chai.expect(safeApiKit1.proposeTransaction(txOptions)).to.be.fulfilled
+ await chai.expect(safeApiKit.proposeTransaction(txOptions)).to.be.fulfilled
// Signer Safe signature
protocolKit = await protocolKit.connect({
- ethAdapter: ethAdapter1,
+ signer: PRIVATE_KEY_1,
safeAddress: signerSafeAddress
})
@@ -79,7 +71,7 @@ describe('proposeTransaction', () => {
)
protocolKit = await protocolKit.connect({
- ethAdapter: ethAdapter2,
+ signer: PRIVATE_KEY_2,
safeAddress: signerSafeAddress
})
signerSafeTx = await protocolKit.signTransaction(
@@ -94,7 +86,7 @@ describe('proposeTransaction', () => {
)
protocolKit = await protocolKit.connect({
- ethAdapter: ethAdapter1,
+ signer: PRIVATE_KEY_1,
safeAddress
})
@@ -103,9 +95,9 @@ describe('proposeTransaction', () => {
// chai.expect(isValidSignature).to.be.true
const contractSig = buildSignatureBytes([signerSafeSig])
- await chai.expect(safeApiKit1.confirmTransaction(txHash, contractSig)).to.be.fulfilled
+ await chai.expect(safeApiKit.confirmTransaction(txHash, contractSig)).to.be.fulfilled
- const confirmedMessage = await safeApiKit1.getTransaction(txHash)
- chai.expect(confirmedMessage.confirmations.length).to.eq(2)
+ const confirmedMessage = await safeApiKit.getTransaction(txHash)
+ chai.expect(confirmedMessage?.confirmations?.length).to.eq(2)
})
})
diff --git a/packages/api-kit/tests/e2e/decodeData.test.ts b/packages/api-kit/tests/e2e/decodeData.test.ts
index e383ab7b0..7d96a5548 100644
--- a/packages/api-kit/tests/e2e/decodeData.test.ts
+++ b/packages/api-kit/tests/e2e/decodeData.test.ts
@@ -1,7 +1,7 @@
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import SafeApiKit from '@safe-global/api-kit/index'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
chai.use(chaiAsPromised)
@@ -9,9 +9,7 @@ let safeApiKit: SafeApiKit
describe('decodeData', () => {
before(async () => {
- ;({ safeApiKit } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
+ safeApiKit = getApiKit()
})
it('should fail if data is empty', async () => {
diff --git a/packages/api-kit/tests/e2e/getIncomingTransactions.test.ts b/packages/api-kit/tests/e2e/getIncomingTransactions.test.ts
index e0a7dd7be..85c9b1ef8 100644
--- a/packages/api-kit/tests/e2e/getIncomingTransactions.test.ts
+++ b/packages/api-kit/tests/e2e/getIncomingTransactions.test.ts
@@ -2,7 +2,7 @@ import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import SafeApiKit from '@safe-global/api-kit/index'
import config from '../utils/config'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
chai.use(chaiAsPromised)
@@ -10,9 +10,7 @@ let safeApiKit: SafeApiKit
describe('getIncomingTransactions', () => {
before(async () => {
- ;({ safeApiKit } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
+ safeApiKit = getApiKit()
})
it('should fail if Safe address is empty', async () => {
diff --git a/packages/api-kit/tests/e2e/getMessage.test.ts b/packages/api-kit/tests/e2e/getMessage.test.ts
index 527fb6c3a..7a310372c 100644
--- a/packages/api-kit/tests/e2e/getMessage.test.ts
+++ b/packages/api-kit/tests/e2e/getMessage.test.ts
@@ -1,7 +1,7 @@
import SafeApiKit from '@safe-global/api-kit/index'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
chai.use(chaiAsPromised)
@@ -10,9 +10,7 @@ const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
describe('getMessages', () => {
before(async () => {
- ;({ safeApiKit } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
+ safeApiKit = getApiKit()
})
it('should fail if safeAddress is empty', async () => {
diff --git a/packages/api-kit/tests/e2e/getMessages.test.ts b/packages/api-kit/tests/e2e/getMessages.test.ts
index 2826f4b76..ec4768d5a 100644
--- a/packages/api-kit/tests/e2e/getMessages.test.ts
+++ b/packages/api-kit/tests/e2e/getMessages.test.ts
@@ -1,7 +1,7 @@
import SafeApiKit from '@safe-global/api-kit/index'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
chai.use(chaiAsPromised)
@@ -10,9 +10,7 @@ const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
describe('getMessages', () => {
before(async () => {
- ;({ safeApiKit } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
+ safeApiKit = getApiKit()
})
it('should fail if safeAddress is empty or invalid', async () => {
diff --git a/packages/api-kit/tests/e2e/getMultisigTransactions.test.ts b/packages/api-kit/tests/e2e/getMultisigTransactions.test.ts
index d1b1590ff..d617831a0 100644
--- a/packages/api-kit/tests/e2e/getMultisigTransactions.test.ts
+++ b/packages/api-kit/tests/e2e/getMultisigTransactions.test.ts
@@ -2,7 +2,7 @@ import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import SafeApiKit from '@safe-global/api-kit/index'
import config from '../utils/config'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
chai.use(chaiAsPromised)
@@ -10,9 +10,7 @@ let safeApiKit: SafeApiKit
describe('getMultisigTransactions', () => {
before(async () => {
- ;({ safeApiKit } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
+ safeApiKit = getApiKit()
})
it('should fail if Safe address is empty', async () => {
@@ -41,8 +39,8 @@ describe('getMultisigTransactions', () => {
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78' // Safe with multisig transactions
const safeMultisigTransactionListResponse =
await safeApiKit.getMultisigTransactions(safeAddress)
- chai.expect(safeMultisigTransactionListResponse.count).to.be.equal(18)
- chai.expect(safeMultisigTransactionListResponse.results.length).to.be.equal(18)
+ chai.expect(safeMultisigTransactionListResponse.count).to.be.equal(22)
+ chai.expect(safeMultisigTransactionListResponse.results.length).to.be.equal(22)
safeMultisigTransactionListResponse.results.map((transaction) => {
chai.expect(transaction.safe).to.be.equal(safeAddress)
})
@@ -53,8 +51,8 @@ describe('getMultisigTransactions', () => {
const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}`
const safeMultisigTransactionListResponse =
await safeApiKit.getMultisigTransactions(eip3770SafeAddress)
- chai.expect(safeMultisigTransactionListResponse.count).to.be.equal(18)
- chai.expect(safeMultisigTransactionListResponse.results.length).to.be.equal(18)
+ chai.expect(safeMultisigTransactionListResponse.count).to.be.equal(22)
+ chai.expect(safeMultisigTransactionListResponse.results.length).to.be.equal(22)
safeMultisigTransactionListResponse.results.map((transaction) => {
chai.expect(transaction.safe).to.be.equal(safeAddress)
})
diff --git a/packages/api-kit/tests/e2e/getNextNonce.test.ts b/packages/api-kit/tests/e2e/getNextNonce.test.ts
index 4120a13a5..029ac5af3 100644
--- a/packages/api-kit/tests/e2e/getNextNonce.test.ts
+++ b/packages/api-kit/tests/e2e/getNextNonce.test.ts
@@ -2,16 +2,14 @@ import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import SafeApiKit from '@safe-global/api-kit/index'
import config from '../utils/config'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
chai.use(chaiAsPromised)
let safeApiKit: SafeApiKit
describe('getNextNonce', () => {
before(async () => {
- ;({ safeApiKit } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
+ safeApiKit = getApiKit()
})
it('should fail if Safe address is empty', async () => {
@@ -24,14 +22,14 @@ describe('getNextNonce', () => {
it('should return the next Safe nonce when there are pending transactions', async () => {
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const nextNonce = await safeApiKit.getNextNonce(safeAddress)
- chai.expect(nextNonce).to.be.equal(11)
+ chai.expect(nextNonce).to.be.equal(13)
})
it('should return the next Safe nonce when there are pending transactions EIP-3770', async () => {
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}`
const nextNonce = await safeApiKit.getNextNonce(eip3770SafeAddress)
- chai.expect(nextNonce).to.be.equal(11)
+ chai.expect(nextNonce).to.be.equal(13)
})
it('should return the next Safe nonce when there are no pending transactions', async () => {
diff --git a/packages/api-kit/tests/e2e/getPendingTransactions.test.ts b/packages/api-kit/tests/e2e/getPendingTransactions.test.ts
index 53a7f3388..e8d4e3938 100644
--- a/packages/api-kit/tests/e2e/getPendingTransactions.test.ts
+++ b/packages/api-kit/tests/e2e/getPendingTransactions.test.ts
@@ -2,7 +2,7 @@ import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import SafeApiKit from '@safe-global/api-kit/index'
import config from '../utils/config'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
chai.use(chaiAsPromised)
@@ -10,9 +10,7 @@ let safeApiKit: SafeApiKit
describe('getPendingTransactions', () => {
before(async () => {
- ;({ safeApiKit } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
+ safeApiKit = getApiKit()
})
it('should fail if safeAddress is empty', async () => {
diff --git a/packages/api-kit/tests/e2e/getSafeDelegates.test.ts b/packages/api-kit/tests/e2e/getSafeDelegates.test.ts
index fae2bf610..936518536 100644
--- a/packages/api-kit/tests/e2e/getSafeDelegates.test.ts
+++ b/packages/api-kit/tests/e2e/getSafeDelegates.test.ts
@@ -1,21 +1,21 @@
-import { Signer } from 'ethers'
+import { ethers, Signer } from 'ethers'
import SafeApiKit, { DeleteSafeDelegateProps } from '@safe-global/api-kit/index'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import config from '../utils/config'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
chai.use(chaiAsPromised)
+const PRIVATE_KEY = '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
+
let safeApiKit: SafeApiKit
let signer: Signer
describe('getSafeDelegates', () => {
before(async () => {
- ;({ safeApiKit, signer } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676',
- 'https://safe-transaction-sepolia.staging.5afe.dev/api'
- ))
+ safeApiKit = getApiKit('https://safe-transaction-sepolia.staging.5afe.dev/api')
+ signer = new ethers.Wallet(PRIVATE_KEY)
})
it('should fail if Safe address is empty', async () => {
diff --git a/packages/api-kit/tests/e2e/getSafeInfo.test.ts b/packages/api-kit/tests/e2e/getSafeInfo.test.ts
index 7434099ba..a6621ef3b 100644
--- a/packages/api-kit/tests/e2e/getSafeInfo.test.ts
+++ b/packages/api-kit/tests/e2e/getSafeInfo.test.ts
@@ -2,7 +2,7 @@ import SafeApiKit from '@safe-global/api-kit/index'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import config from '../utils/config'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
chai.use(chaiAsPromised)
@@ -10,9 +10,7 @@ let safeApiKit: SafeApiKit
describe('getSafeInfo', () => {
before(async () => {
- ;({ safeApiKit } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
+ safeApiKit = getApiKit()
})
it('should fail if Safe address is empty', async () => {
diff --git a/packages/api-kit/tests/e2e/getSafesByModule.test.ts b/packages/api-kit/tests/e2e/getSafesByModule.test.ts
index 21bcbdfd5..856d96563 100644
--- a/packages/api-kit/tests/e2e/getSafesByModule.test.ts
+++ b/packages/api-kit/tests/e2e/getSafesByModule.test.ts
@@ -2,7 +2,7 @@ import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import SafeApiKit from '@safe-global/api-kit/index'
import config from '../utils/config'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
chai.use(chaiAsPromised)
@@ -11,9 +11,7 @@ const goerliSpendingLimitModule = '0xCFbFaC74C26F8647cBDb8c5caf80BB5b32E43134'
describe('getSafesByModule', () => {
before(async () => {
- ;({ safeApiKit } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
+ safeApiKit = getApiKit()
})
it('should fail if module address is empty', async () => {
diff --git a/packages/api-kit/tests/e2e/getSafesByOwner.test.ts b/packages/api-kit/tests/e2e/getSafesByOwner.test.ts
index 33e00c5c7..ffc356748 100644
--- a/packages/api-kit/tests/e2e/getSafesByOwner.test.ts
+++ b/packages/api-kit/tests/e2e/getSafesByOwner.test.ts
@@ -2,7 +2,7 @@ import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import SafeApiKit from '@safe-global/api-kit/index'
import config from '../utils/config'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
chai.use(chaiAsPromised)
@@ -10,9 +10,7 @@ let safeApiKit: SafeApiKit
describe('getSafesByOwner', () => {
before(async () => {
- ;({ safeApiKit } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
+ safeApiKit = getApiKit()
})
it('should fail if owner address is empty', async () => {
diff --git a/packages/api-kit/tests/e2e/getServiceInfo.test.ts b/packages/api-kit/tests/e2e/getServiceInfo.test.ts
index e63c41dde..7074ff3d3 100644
--- a/packages/api-kit/tests/e2e/getServiceInfo.test.ts
+++ b/packages/api-kit/tests/e2e/getServiceInfo.test.ts
@@ -1,14 +1,12 @@
import { expect } from 'chai'
import SafeApiKit from '@safe-global/api-kit/index'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
let safeApiKit: SafeApiKit
describe('getServiceInfo', () => {
before(async () => {
- ;({ safeApiKit } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
+ safeApiKit = getApiKit()
})
it('should return the Safe info', async () => {
diff --git a/packages/api-kit/tests/e2e/getServiceSingletonsInfo.test.ts b/packages/api-kit/tests/e2e/getServiceSingletonsInfo.test.ts
index cd4d48e5b..0c518db85 100644
--- a/packages/api-kit/tests/e2e/getServiceSingletonsInfo.test.ts
+++ b/packages/api-kit/tests/e2e/getServiceSingletonsInfo.test.ts
@@ -1,15 +1,13 @@
import chai from 'chai'
import SafeApiKit from '@safe-global/api-kit/index'
import semverSatisfies from 'semver/functions/satisfies'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
let safeApiKit: SafeApiKit
describe('getServiceSingletonsInfo', () => {
before(async () => {
- ;({ safeApiKit } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
+ safeApiKit = getApiKit()
})
it('should call getServiceSingletonsInfo', async () => {
diff --git a/packages/api-kit/tests/e2e/getToken.test.ts b/packages/api-kit/tests/e2e/getToken.test.ts
index 693f37ca7..cd1c20046 100644
--- a/packages/api-kit/tests/e2e/getToken.test.ts
+++ b/packages/api-kit/tests/e2e/getToken.test.ts
@@ -2,7 +2,7 @@ import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import SafeApiKit from '@safe-global/api-kit/index'
import config from '../utils/config'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
chai.use(chaiAsPromised)
@@ -10,9 +10,7 @@ let safeApiKit: SafeApiKit
describe('getToken', () => {
before(async () => {
- ;({ safeApiKit } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
+ safeApiKit = getApiKit()
})
it('should fail if token address is empty', async () => {
diff --git a/packages/api-kit/tests/e2e/getTokenList.test.ts b/packages/api-kit/tests/e2e/getTokenList.test.ts
index 6115f76d5..c1e3bc68e 100644
--- a/packages/api-kit/tests/e2e/getTokenList.test.ts
+++ b/packages/api-kit/tests/e2e/getTokenList.test.ts
@@ -1,14 +1,12 @@
import chai from 'chai'
import SafeApiKit from '@safe-global/api-kit/index'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
let safeApiKit: SafeApiKit
describe('getTokenList', () => {
before(async () => {
- ;({ safeApiKit } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
+ safeApiKit = getApiKit()
})
it('should return an array of tokens', async () => {
diff --git a/packages/api-kit/tests/e2e/getTransaction.test.ts b/packages/api-kit/tests/e2e/getTransaction.test.ts
index 50e39a98b..7d459fb3c 100644
--- a/packages/api-kit/tests/e2e/getTransaction.test.ts
+++ b/packages/api-kit/tests/e2e/getTransaction.test.ts
@@ -1,7 +1,7 @@
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import SafeApiKit from '@safe-global/api-kit/index'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
chai.use(chaiAsPromised)
@@ -9,9 +9,7 @@ let safeApiKit: SafeApiKit
describe('getTransaction', () => {
before(async () => {
- ;({ safeApiKit } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
+ safeApiKit = getApiKit()
})
it('should fail if safeTxHash is empty', async () => {
diff --git a/packages/api-kit/tests/e2e/getTransactionConfirmations.test.ts b/packages/api-kit/tests/e2e/getTransactionConfirmations.test.ts
index 5c8103fff..ecd877baa 100644
--- a/packages/api-kit/tests/e2e/getTransactionConfirmations.test.ts
+++ b/packages/api-kit/tests/e2e/getTransactionConfirmations.test.ts
@@ -1,7 +1,7 @@
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import SafeApiKit from '@safe-global/api-kit/index'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
chai.use(chaiAsPromised)
@@ -9,9 +9,7 @@ let safeApiKit: SafeApiKit
describe('getTransactionConfirmations', () => {
before(async () => {
- ;({ safeApiKit } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
+ safeApiKit = getApiKit()
})
it('should fail if safeTxHash is empty', async () => {
@@ -21,8 +19,8 @@ describe('getTransactionConfirmations', () => {
.to.be.rejectedWith('Invalid safeTxHash')
})
- it.skip('should return an empty array if the safeTxHash is not found', async () => {
- const safeTxHash = '0x'
+ it('should return an empty array if the safeTxHash is not found', async () => {
+ const safeTxHash = '0x317834aea988fd3cfa54fd8b2be2c96b4fd70a14d8c9470a7110576b01e6480b'
const transactionConfirmations = await safeApiKit.getTransactionConfirmations(safeTxHash)
chai.expect(transactionConfirmations.count).to.be.equal(0)
chai.expect(transactionConfirmations.results.length).to.be.equal(0)
diff --git a/packages/api-kit/tests/e2e/removeSafeDelegate.test.ts b/packages/api-kit/tests/e2e/removeSafeDelegate.test.ts
index b25073046..cb04880b2 100644
--- a/packages/api-kit/tests/e2e/removeSafeDelegate.test.ts
+++ b/packages/api-kit/tests/e2e/removeSafeDelegate.test.ts
@@ -1,21 +1,21 @@
-import { Signer } from 'ethers'
+import { ethers, Signer } from 'ethers'
import SafeApiKit, { DeleteSafeDelegateProps } from '@safe-global/api-kit/index'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import config from '../utils/config'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit } from '../utils/setupKits'
chai.use(chaiAsPromised)
+const PRIVATE_KEY = '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
+
let safeApiKit: SafeApiKit
let signer: Signer
describe('removeSafeDelegate', () => {
before(async () => {
- ;({ safeApiKit, signer } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676',
- 'https://safe-transaction-sepolia.staging.5afe.dev/api'
- ))
+ safeApiKit = getApiKit('https://safe-transaction-sepolia.staging.5afe.dev/api')
+ signer = new ethers.Wallet(PRIVATE_KEY)
})
it('should fail if Safe delegate address is empty', async () => {
diff --git a/packages/api-kit/tests/endpoint/index.test.ts b/packages/api-kit/tests/endpoint/index.test.ts
index ce34ba1d6..b9a72297e 100644
--- a/packages/api-kit/tests/endpoint/index.test.ts
+++ b/packages/api-kit/tests/endpoint/index.test.ts
@@ -7,19 +7,20 @@ import SafeApiKit, {
} from '@safe-global/api-kit/index'
import * as httpRequests from '@safe-global/api-kit/utils/httpRequests'
import Safe from '@safe-global/protocol-kit'
-import { EthAdapter } from '@safe-global/safe-core-sdk-types'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import sinon from 'sinon'
import sinonChai from 'sinon-chai'
import config from '../utils/config'
-import { getServiceClient } from '../utils/setupServiceClient'
+import { getApiKit, getKits } from '../utils/setupKits'
import { signDelegate } from '@safe-global/api-kit/utils/signDelegate'
chai.use(chaiAsPromised)
chai.use(sinonChai)
-const chainId = '0xaa36a7'
+const PRIVATE_KEY_1 = '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
+
+const chainId = 11155111n
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}`
const randomAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'
@@ -30,22 +31,18 @@ const tokenAddress = '0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14'
const eip3770TokenAddress = `${config.EIP_3770_PREFIX}:${tokenAddress}`
const safeTxHash = '0x317834aea988fd3cfa54fd8b2be2c96b4fd70a14d8c9470a7110576b01e6480a'
const txServiceBaseUrl = 'https://safe-transaction-sepolia.safe.global/api'
-const provider = getDefaultProvider(config.JSON_RPC)
-const signer = new Wallet(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676',
- provider
-)
-let ethAdapter: EthAdapter
+const defaultProvider = getDefaultProvider(config.JSON_RPC)
+const signer = new Wallet(PRIVATE_KEY_1, defaultProvider)
+
+let protocolKit: Safe
let safeApiKit: SafeApiKit
let delegatorAddress: string
let eip3770DelegatorAddress: string
describe('Endpoint tests', () => {
before(async () => {
- ;({ safeApiKit, ethAdapter } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
- delegatorAddress = await signer.getAddress()
+ ;({ safeApiKit, protocolKit } = await getKits({ signer: PRIVATE_KEY_1, safeAddress }))
+ delegatorAddress = (await protocolKit.getSafeProvider().getSignerAddress()) || '0x'
eip3770DelegatorAddress = `${config.EIP_3770_PREFIX}:${delegatorAddress}`
})
@@ -360,12 +357,11 @@ describe('Endpoint tests', () => {
}
const origin = 'Safe Core SDK: Safe API Kit'
const signerAddress = await signer.getAddress()
- const safeSdk = await Safe.create({ ethAdapter, safeAddress })
- const safeTransaction = await safeSdk.createTransaction({
+ const safeTransaction = await protocolKit.createTransaction({
transactions: [safeTransactionData],
options
})
- const senderSignature = await safeSdk.signHash(safeTxHash)
+ const senderSignature = await protocolKit.signHash(safeTxHash)
await chai
.expect(
safeApiKit.proposeTransaction({
@@ -409,12 +405,11 @@ describe('Endpoint tests', () => {
}
const origin = 'Safe Core SDK: Safe API Kit'
const signerAddress = await signer.getAddress()
- const safeSdk = await Safe.create({ ethAdapter, safeAddress })
- const safeTransaction = await safeSdk.createTransaction({
+ const safeTransaction = await protocolKit.createTransaction({
transactions: [safeTransactionData],
options
})
- const senderSignature = await safeSdk.signHash(safeTxHash)
+ const senderSignature = await protocolKit.signHash(safeTxHash)
await chai
.expect(
safeApiKit.proposeTransaction({
@@ -647,12 +642,9 @@ describe('Endpoint tests', () => {
const txServiceUrl = 'http://my-custom-tx-service.com/api'
it('should can instantiate the SafeApiKit with a custom endpoint', async () => {
- ;({ safeApiKit } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676',
- txServiceUrl
- ))
+ const apiKit = getApiKit(txServiceUrl)
- await chai.expect(safeApiKit.getServiceInfo()).to.be.fulfilled
+ await chai.expect(apiKit.getServiceInfo()).to.be.fulfilled
chai.expect(fetchData).to.have.been.calledWith({
url: `${txServiceUrl}/v1/about`,
diff --git a/packages/api-kit/tests/utils/config.ts b/packages/api-kit/tests/utils/config.ts
index abf3c2180..e8486dfe6 100644
--- a/packages/api-kit/tests/utils/config.ts
+++ b/packages/api-kit/tests/utils/config.ts
@@ -1,6 +1,6 @@
const config = {
CHAIN_ID: 11155111n,
- JSON_RPC: 'https://rpc.ankr.com/eth_sepolia',
+ JSON_RPC: 'https://sepolia.gateway.tenderly.co',
EIP_3770_PREFIX: 'sep'
}
diff --git a/packages/api-kit/tests/utils/setupEthAdapter.ts b/packages/api-kit/tests/utils/setupEthAdapter.ts
deleted file mode 100644
index 83b7b3132..000000000
--- a/packages/api-kit/tests/utils/setupEthAdapter.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { AbstractSigner, Provider } from 'ethers'
-import { EthAdapter } from '@safe-global/safe-core-sdk-types'
-import {
- EthersAdapter,
- EthersAdapterConfig,
- Web3Adapter,
- Web3AdapterConfig
-} from '@safe-global/protocol-kit'
-import { ethers, web3 } from 'hardhat'
-
-export async function getEthAdapter(
- signerOrProvider: AbstractSigner | Provider
-): Promise {
- let ethAdapter: EthAdapter
- switch (process.env.ETH_LIB) {
- case 'web3':
- const signerAddress =
- signerOrProvider instanceof AbstractSigner ? await signerOrProvider.getAddress() : undefined
-
- const web3AdapterConfig: Web3AdapterConfig = {
- web3,
- signerAddress
- }
-
- ethAdapter = new Web3Adapter(web3AdapterConfig)
- break
- case 'ethers':
- const ethersAdapterConfig: EthersAdapterConfig = { ethers, signerOrProvider }
- ethAdapter = new EthersAdapter(ethersAdapterConfig)
- break
- default:
- throw new Error('Ethereum library not supported')
- }
- return ethAdapter
-}
diff --git a/packages/api-kit/tests/utils/setupKits.ts b/packages/api-kit/tests/utils/setupKits.ts
new file mode 100644
index 000000000..9da1eff87
--- /dev/null
+++ b/packages/api-kit/tests/utils/setupKits.ts
@@ -0,0 +1,76 @@
+import hre, { ethers } from 'hardhat'
+import Web3 from 'web3'
+import { custom, createWalletClient } from 'viem'
+
+import Safe, { SafeProviderConfig, Eip1193Provider } from '@safe-global/protocol-kit'
+import SafeApiKit from '@safe-global/api-kit/index'
+
+import config from './config'
+
+type GetKits = {
+ protocolKit: Safe
+ safeApiKit: SafeApiKit
+}
+
+type GetKitsOptions = {
+ signer?: SafeProviderConfig['signer']
+ txServiceUrl?: string
+ safeAddress: string
+}
+
+export function getEip1193Provider(): Eip1193Provider {
+ switch (process.env.ETH_LIB) {
+ case 'viem':
+ const client = createWalletClient({
+ transport: custom(hre.network.provider)
+ })
+
+ return { request: client.request } as Eip1193Provider
+
+ case 'web3':
+ const web3Provider = new Web3(hre.network.provider)
+
+ return web3Provider.currentProvider as Eip1193Provider
+
+ case 'ethers':
+ const browserProvider = new ethers.BrowserProvider(hre.network.provider)
+
+ return {
+ request: async (request) => {
+ return browserProvider.send(request.method, [...((request.params as unknown[]) ?? [])])
+ }
+ }
+ default:
+ throw new Error('ETH_LIB not set')
+ }
+}
+
+export async function getProtocolKit({
+ signer,
+ safeAddress
+}: {
+ signer?: GetKitsOptions['signer']
+ safeAddress: GetKitsOptions['safeAddress']
+}): Promise {
+ const provider = getEip1193Provider()
+ const protocolKit = await Safe.init({ provider, signer, safeAddress })
+
+ return protocolKit
+}
+
+export function getApiKit(txServiceUrl?: GetKitsOptions['txServiceUrl']): SafeApiKit {
+ const safeApiKit = new SafeApiKit({ chainId: config.CHAIN_ID, txServiceUrl })
+
+ return safeApiKit
+}
+
+export async function getKits({
+ signer,
+ safeAddress,
+ txServiceUrl
+}: GetKitsOptions): Promise {
+ const protocolKit = await getProtocolKit({ signer, safeAddress })
+ const safeApiKit = getApiKit(txServiceUrl)
+
+ return { protocolKit, safeApiKit }
+}
diff --git a/packages/api-kit/tests/utils/setupServiceClient.ts b/packages/api-kit/tests/utils/setupServiceClient.ts
deleted file mode 100644
index a69e5c1bf..000000000
--- a/packages/api-kit/tests/utils/setupServiceClient.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { getDefaultProvider, Wallet } from 'ethers'
-import { EthAdapter } from '@safe-global/safe-core-sdk-types'
-import SafeApiKit from '@safe-global/api-kit/index'
-import config from '../utils/config'
-import { getEthAdapter } from '../utils/setupEthAdapter'
-
-interface ServiceClientConfig {
- safeApiKit: SafeApiKit
- ethAdapter: EthAdapter
- signer: Wallet
-}
-
-export async function getServiceClient(
- signerPk: string,
- txServiceUrl?: string
-): Promise {
- const provider = getDefaultProvider(config.JSON_RPC)
- const signer = new Wallet(signerPk, provider)
- const ethAdapter = await getEthAdapter(signer)
- const safeApiKit = new SafeApiKit({ chainId: config.CHAIN_ID, txServiceUrl })
- return { safeApiKit, ethAdapter, signer }
-}
diff --git a/packages/auth-kit/README.md b/packages/auth-kit/README.md
index d72f26e16..c96fbba42 100644
--- a/packages/auth-kit/README.md
+++ b/packages/auth-kit/README.md
@@ -6,16 +6,24 @@
The Auth Kit provides a way to authenticate blockchain accounts using email addresses, social accounts or traditional web3 wallets (ex. Metamask). When using web2 methods as your email or social account, a derived Ethereum address will be generated.
-## Reference
+## Documentation
-- [Auth Kit integration guides](https://docs.safe.global/safe-core-aa-sdk/auth-kit)
+- [Auth Kit integration guides](https://docs.safe.global/sdk/auth-kit)
-- [Auth Kit reference](https://docs.safe.global/reference/auth-kit)
+- [Auth Kit reference](https://docs.safe.global/sdk/auth-kit/reference)
## Example
[Check a functional demo](https://github.com/safe-global/safe-core-sdk/tree/main/packages/auth-kit/example) using the `auth-kit`
+## 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
+
+Please read our [contribution guidelines](https://github.com/safe-global/safe-core-sdk/tree/main/CONTRIBUTING.md) before submitting any changes. We appreciate your help! 🙌
+
## License
This library is [released under MIT](https://github.com/safe-global/safe-core-sdk/blob/main/LICENSE.md).
diff --git a/packages/auth-kit/example/README.md b/packages/auth-kit/example/README.md
index dbd6c2456..633607dee 100644
--- a/packages/auth-kit/example/README.md
+++ b/packages/auth-kit/example/README.md
@@ -23,5 +23,4 @@ To use the example properly in your local machine follow these steps:
**In the auth-kit example root folder**
3. `yarn install`
-4. Configure `.env` following `.env.sample`
-5. `yarn start`
+4. `yarn start`
diff --git a/packages/auth-kit/example/src/App.tsx b/packages/auth-kit/example/src/App.tsx
index 26c883ffb..611cc08b8 100644
--- a/packages/auth-kit/example/src/App.tsx
+++ b/packages/auth-kit/example/src/App.tsx
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'
import { BrowserProvider, Eip1193Provider, ethers } from 'ethers'
import { Box, Button, Divider, Grid, Typography } from '@mui/material'
import { EthHashInfo } from '@safe-global/safe-react-components'
-import Safe, { EthersAdapter } from '@safe-global/protocol-kit'
+import Safe from '@safe-global/protocol-kit'
import AppBar from './AppBar'
import {
AuthKitSignInData,
@@ -129,15 +129,9 @@ function App() {
const safeAddress = safeAuthSignInResponse?.safes?.[index] || '0x'
// Wrap Web3Auth provider with ethers
- const provider = new BrowserProvider(safeAuthPack?.getProvider() as Eip1193Provider)
- const signer = await provider.getSigner()
- const ethAdapter = new EthersAdapter({
- ethers,
- signerOrProvider: signer
- })
- const protocolKit = await Safe.create({
- safeAddress,
- ethAdapter
+ const protocolKit = await Safe.init({
+ provider: safeAuthPack?.getProvider() as Eip1193Provider,
+ safeAddress
})
// Create transaction
diff --git a/packages/auth-kit/jest.config.js b/packages/auth-kit/jest.config.js
index e841887cb..e96123e0d 100644
--- a/packages/auth-kit/jest.config.js
+++ b/packages/auth-kit/jest.config.js
@@ -6,7 +6,6 @@ const config = {
'^.+\\.ts?$': 'ts-jest'
},
moduleNameMapper: {
- '^@safe-global/protocol-kit/typechain/(.*)$': '/../protocol-kit/typechain/$1',
'^@safe-global/protocol-kit/(.*)$': '/../protocol-kit/src/$1',
'^@safe-global/auth-kit/(.*)$': '/src/$1'
}
diff --git a/packages/auth-kit/package.json b/packages/auth-kit/package.json
index 031b0e9dc..f4613a831 100644
--- a/packages/auth-kit/package.json
+++ b/packages/auth-kit/package.json
@@ -1,6 +1,6 @@
{
"name": "@safe-global/auth-kit",
- "version": "2.0.5",
+ "version": "2.0.5-alpha.0",
"description": "Authentication library for web2 logins",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
@@ -40,9 +40,9 @@
"react-dom": "^18.2.0"
},
"dependencies": {
- "@safe-global/api-kit": "^2.3.2",
- "@safe-global/protocol-kit": "^3.1.1",
+ "@safe-global/api-kit": "^2.3.2-alpha.0",
+ "@safe-global/protocol-kit": "^4.0.0-alpha.0",
"@web3auth/safeauth-embed": "^0.0.0",
- "ethers": "^6.7.1"
+ "ethers": "^6.12.1"
}
}
diff --git a/packages/onramp-kit/README.md b/packages/onramp-kit/README.md
index b46ae5c49..49e4fbcf8 100644
--- a/packages/onramp-kit/README.md
+++ b/packages/onramp-kit/README.md
@@ -1,4 +1,4 @@
-# OnRamp Kit
+# Onramp Kit
[](https://badge.fury.io/js/%40safe-global%2Fonramp-kit)
[](https://github.com/safe-global/safe-core-sdk/releases)
@@ -6,16 +6,24 @@
The Onramp Kit allows users to buy cryptocurrencies using a credit card and other payment options.
-## Reference
+## Documentation
-- [OnRamp Kit integration guides](https://docs.safe.global/safe-core-aa-sdk/onramp-kit)
+- [Onramp Kit integration guides](https://docs.safe.global/sdk/onramp-kit)
-- [OnRamp Kit reference](https://docs.safe.global/reference/onramp-kit)
+- [Onramp Kit reference](https://docs.safe.global/sdk/onramp-kit/reference)
## Example
[Check a functional demo](https://github.com/safe-global/safe-core-sdk/tree/main/packages/onramp-kit/example) using the `onramp-kit`
+## 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
+
+Please read our [contribution guidelines](https://github.com/safe-global/safe-core-sdk/tree/main/CONTRIBUTING.md) before submitting any changes. We appreciate your help! 🙌
+
## License
This library is [released under MIT](https://github.com/safe-global/safe-core-sdk/blob/main/LICENSE.md).
diff --git a/packages/onramp-kit/example/client/.env.sample b/packages/onramp-kit/example/client/.env.sample
index b3166dbe1..cbe051c43 100644
--- a/packages/onramp-kit/example/client/.env.sample
+++ b/packages/onramp-kit/example/client/.env.sample
@@ -8,6 +8,7 @@ VITE_STRIPE_PUBLIC_KEY=
VITE_SAFE_STRIPE_BACKEND_BASE_URL=
# Configure the Monerium client ID. You need to get one from Monerium.
+# Add the client ID for the authorization code flow here (not the one for the client credentials flow).
# More info here:
# https://monerium.dev/docs/getting-started/create-app
VITE_MONERIUM_CLIENT_ID=
diff --git a/packages/onramp-kit/example/client/package.json b/packages/onramp-kit/example/client/package.json
index c54925480..32a3674ae 100644
--- a/packages/onramp-kit/example/client/package.json
+++ b/packages/onramp-kit/example/client/package.json
@@ -11,7 +11,7 @@
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
- "@monerium/sdk": "^2.9.0",
+ "@monerium/sdk": "^2.12.0",
"@mui/material": "^5.15.15",
"@safe-global/auth-kit": "file:../../../auth-kit",
"@safe-global/onramp-kit": "file:../../",
diff --git a/packages/onramp-kit/example/client/src/AuthContext.tsx b/packages/onramp-kit/example/client/src/AuthContext.tsx
index d1f3c5430..ca4c401b9 100644
--- a/packages/onramp-kit/example/client/src/AuthContext.tsx
+++ b/packages/onramp-kit/example/client/src/AuthContext.tsx
@@ -38,7 +38,7 @@ const AuthProvider = ({ children }: AuthContextProviderProps) => {
const options: SafeAuthInitOptions = {
enableLogging: true,
showWidgetButton: false,
- chainConfig: { chainId: '0x5', rpcTarget: 'https://rpc.ankr.com/eth_goerli' }
+ chainConfig: { chainId: '0xaa36a7', rpcTarget: 'https://sepolia.gateway.tenderly.co' }
}
await authPack.init(options)
diff --git a/packages/onramp-kit/example/client/src/components/monerium/Connected.tsx b/packages/onramp-kit/example/client/src/components/monerium/Connected.tsx
index 8e6e0630b..969f063a1 100644
--- a/packages/onramp-kit/example/client/src/components/monerium/Connected.tsx
+++ b/packages/onramp-kit/example/client/src/components/monerium/Connected.tsx
@@ -31,7 +31,9 @@ function Connected({ authContext, orderState, safe, onLogout, onTransfer }: Conn
{isLoading ? (
-
+ {orderState && [OrderState.placed, OrderState.pending].includes(orderState) && (
+
+ )}
{orderState && (
<>
{orderState === OrderState.placed && Order placed}
diff --git a/packages/onramp-kit/example/client/src/components/monerium/Monerium.tsx b/packages/onramp-kit/example/client/src/components/monerium/Monerium.tsx
index b96d730c3..c97844f30 100644
--- a/packages/onramp-kit/example/client/src/components/monerium/Monerium.tsx
+++ b/packages/onramp-kit/example/client/src/components/monerium/Monerium.tsx
@@ -1,8 +1,7 @@
import { useState, useEffect } from 'react'
-import { ethers } from 'ethers'
import { AuthContext, OrderState, PaymentStandard } from '@monerium/sdk'
import { Box } from '@mui/material'
-import Safe, { EthersAdapter } from '@safe-global/protocol-kit'
+import Safe from '@safe-global/protocol-kit'
import { useAuth } from '../../AuthContext'
import { MoneriumPack, SafeMoneriumClient } from '@safe-global/onramp-kit'
@@ -23,13 +22,8 @@ function Monerium() {
;(async () => {
if (!authProvider || !selectedSafe) return
- const provider = new ethers.BrowserProvider(authProvider)
-
- const safeOwner = await provider.getSigner()
- const ethAdapter = new EthersAdapter({ ethers, signerOrProvider: safeOwner })
-
- const protocolKit = await Safe.create({
- ethAdapter: ethAdapter,
+ const protocolKit = await Safe.init({
+ provider: authProvider,
safeAddress: selectedSafe,
isL1SafeSingleton: true
})
diff --git a/packages/onramp-kit/example/server/.gitignore b/packages/onramp-kit/example/server/.gitignore
index 776f8bc85..0bbbcb2a4 100644
--- a/packages/onramp-kit/example/server/.gitignore
+++ b/packages/onramp-kit/example/server/.gitignore
@@ -25,6 +25,3 @@ build
npm-debug.log*
yarn-debug.log*
yarn-error.log*
-
-typechain
-typechain-types
diff --git a/packages/onramp-kit/example/server/package.json b/packages/onramp-kit/example/server/package.json
index 67e30dc85..d2d50c425 100644
--- a/packages/onramp-kit/example/server/package.json
+++ b/packages/onramp-kit/example/server/package.json
@@ -29,6 +29,6 @@
"@types/node": "^20.12.5",
"nodemon": "^3.1.0",
"ts-node": "^10.9.2",
- "typescript": "^4.9.5"
+ "typescript": "^5.3.2"
}
}
diff --git a/packages/onramp-kit/example/server/yarn.lock b/packages/onramp-kit/example/server/yarn.lock
index 60e772fcd..824bd2083 100644
--- a/packages/onramp-kit/example/server/yarn.lock
+++ b/packages/onramp-kit/example/server/yarn.lock
@@ -1183,10 +1183,10 @@ type-is@~1.6.18:
media-typer "0.3.0"
mime-types "~2.1.24"
-typescript@^4.9.5:
- version "4.9.5"
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
- integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==
+typescript@^5.3.2:
+ version "5.4.5"
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.5.tgz#42ccef2c571fdbd0f6718b1d1f5e6e5ef006f611"
+ integrity sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==
undefsafe@^2.0.5:
version "2.0.5"
diff --git a/packages/onramp-kit/jest.config.js b/packages/onramp-kit/jest.config.js
index 2f1f502fb..919893179 100644
--- a/packages/onramp-kit/jest.config.js
+++ b/packages/onramp-kit/jest.config.js
@@ -7,7 +7,6 @@ const config = {
'^.+\\.ts?$': 'ts-jest'
},
moduleNameMapper: {
- '^@safe-global/protocol-kit/typechain/(.*)$': '/../protocol-kit/typechain/$1',
'^@safe-global/protocol-kit/(.*)$': '/../protocol-kit/src/$1',
'^@safe-global/onramp-kit/(.*)$': '/src/$1'
}
diff --git a/packages/onramp-kit/package.json b/packages/onramp-kit/package.json
index f69691f79..7aee73ef0 100644
--- a/packages/onramp-kit/package.json
+++ b/packages/onramp-kit/package.json
@@ -1,6 +1,6 @@
{
"name": "@safe-global/onramp-kit",
- "version": "3.0.4",
+ "version": "3.0.4-alpha.0",
"description": "Onramp library",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
@@ -35,13 +35,13 @@
"access": "public"
},
"dependencies": {
- "@monerium/sdk": "^2.9.0",
- "@safe-global/api-kit": "^2.3.2",
- "@safe-global/protocol-kit": "^3.1.1",
- "@safe-global/safe-core-sdk-types": "^4.1.1",
+ "@monerium/sdk": "^2.12.0",
+ "@safe-global/api-kit": "^2.3.2-alpha.0",
+ "@safe-global/protocol-kit": "^4.0.0-alpha.0",
+ "@safe-global/safe-core-sdk-types": "^5.0.0-alpha.0",
"@stripe/crypto": "^0.0.4",
"@stripe/stripe-js": "^1.54.2",
- "ethers": "^6.7.1"
+ "ethers": "^6.12.1"
},
"devDependencies": {
"events": "^3.3.0",
diff --git a/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.test.ts b/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.test.ts
index 45865b363..fd29fbd2d 100644
--- a/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.test.ts
+++ b/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.test.ts
@@ -1,7 +1,10 @@
-import { hashMessage } from 'ethers'
+import { Contract, hashMessage } from 'ethers'
import { PaymentStandard } from '@monerium/sdk'
import Safe, * as protocolKitPackage from '@safe-global/protocol-kit'
-import { OperationType } from '@safe-global/safe-core-sdk-types'
+import {
+ OperationType,
+ signMessageLib_1_4_1_ContractArtifacts
+} from '@safe-global/safe-core-sdk-types'
import SafeApiKit from '@safe-global/api-kit'
import { SafeMoneriumClient } from './SafeMoneriumClient'
@@ -41,12 +44,12 @@ describe('SafeMoneriumClient', () => {
beforeEach(() => {
jest.clearAllMocks()
protocolKit.getChainId = jest.fn().mockResolvedValue(5)
- protocolKit.getEthAdapter = jest.fn().mockReturnValue({
+ protocolKit.getSafeProvider = jest.fn().mockReturnValue({
call: jest.fn().mockImplementation(async () => MAGIC_VALUE),
getSignerAddress: jest.fn().mockResolvedValue('0xSignerAddress')
})
- protocolKit.getEthAdapter.call = jest.fn().mockImplementation(async () => MAGIC_VALUE)
+ protocolKit.getSafeProvider.call = jest.fn().mockImplementation(async () => MAGIC_VALUE)
safeMoneriumClient = new SafeMoneriumClient(
{ environment: 'sandbox', clientId: 'mockClientId', redirectUrl: 'http://mockUrl' },
protocolKit
@@ -116,7 +119,7 @@ describe('SafeMoneriumClient', () => {
it('should allow to check if a message is NOT signed in the smart contract if the promise is fulfilled', async () => {
// Promise fulfilled without signature
- protocolKit.getEthAdapter().call = jest.fn().mockImplementation(async () => '0x')
+ protocolKit.getSafeProvider().call = jest.fn().mockImplementation(async () => '0x')
const isMessageSigned = await safeMoneriumClient.isMessageSigned(
'0xSafeAddress',
@@ -136,7 +139,7 @@ describe('SafeMoneriumClient', () => {
}
// promise is rejected with the signature
- protocolKit.getEthAdapter().call = jest
+ protocolKit.getSafeProvider().call = jest
.fn()
.mockImplementation(() =>
Promise.reject(new EthersError('execution reverted: "Hash not approved"', MAGIC_VALUE))
@@ -160,7 +163,7 @@ describe('SafeMoneriumClient', () => {
}
// promise is rejected without a signature
- protocolKit.getEthAdapter().call = jest
+ protocolKit.getSafeProvider().call = jest
.fn()
.mockImplementation(() =>
Promise.reject(new EthersError('execution reverted: "Hash not approved"', '0x'))
@@ -220,11 +223,18 @@ describe('SafeMoneriumClient', () => {
}
jest.spyOn(protocolKitPackage, 'getSignMessageLibContract').mockResolvedValueOnce({
+ safeVersion: '1.3.0',
+ contractName: 'signMessageLibVersion',
+ contract: new Contract('0x0000000000000000000000000000000000000001', []),
+ safeProvider: protocolKit.getSafeProvider() as protocolKitPackage.SafeProvider,
encode: jest.fn(),
+ contractAbi: signMessageLib_1_4_1_ContractArtifacts.abi,
+ contractAddress: '',
getAddress: jest.fn(),
getMessageHash: jest.fn(),
signMessage: jest.fn(),
- estimateGas: jest.fn()
+ estimateGas: jest.fn(),
+ init: jest.fn()
})
protocolKit.createTransaction = jest.fn().mockResolvedValueOnce({
@@ -258,7 +268,7 @@ describe('SafeMoneriumClient', () => {
it('should map the protocol kit chainId to the Monerium Chain types', async () => {
protocolKit.getChainId = jest.fn().mockResolvedValueOnce(1n)
expect(await safeMoneriumClient.getChain()).toBe('ethereum')
- protocolKit.getChainId = jest.fn().mockResolvedValueOnce(5n)
+ protocolKit.getChainId = jest.fn().mockResolvedValueOnce(11155111n)
expect(await safeMoneriumClient.getChain()).toBe('ethereum')
protocolKit.getChainId = jest.fn().mockResolvedValueOnce(100n)
expect(await safeMoneriumClient.getChain()).toBe('gnosis')
@@ -275,8 +285,8 @@ describe('SafeMoneriumClient', () => {
it('should map the protocol kit chainId to the Monerium Network types', async () => {
protocolKit.getChainId = jest.fn().mockResolvedValueOnce(1n)
expect(await safeMoneriumClient.getNetwork()).toBe('mainnet')
- protocolKit.getChainId = jest.fn().mockResolvedValueOnce(5n)
- expect(await safeMoneriumClient.getNetwork()).toBe('goerli')
+ protocolKit.getChainId = jest.fn().mockResolvedValueOnce(11155111n)
+ expect(await safeMoneriumClient.getNetwork()).toBe('sepolia')
protocolKit.getChainId = jest.fn().mockResolvedValueOnce(100n)
expect(await safeMoneriumClient.getNetwork()).toBe('mainnet')
protocolKit.getChainId = jest.fn().mockResolvedValueOnce(10200n)
diff --git a/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.ts b/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.ts
index c1037a803..a9b891bf9 100644
--- a/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.ts
+++ b/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.ts
@@ -10,18 +10,14 @@ import {
placeOrderMessage,
ClassOptions
} from '@monerium/sdk'
-import Safe, { getSignMessageLibContract } from '@safe-global/protocol-kit'
+import Safe, { getSignMessageLibContract, SafeProvider } from '@safe-global/protocol-kit'
import SafeApiKit from '@safe-global/api-kit'
import {
decodeSignatureData,
getErrorMessage,
parseIsValidSignatureErrorResponse
} from '@safe-global/onramp-kit/lib/errors'
-import {
- EthAdapter,
- OperationType,
- SafeMultisigTransactionResponse
-} from '@safe-global/safe-core-sdk-types'
+import { OperationType, SafeMultisigTransactionResponse } from '@safe-global/safe-core-sdk-types'
import {
EIP_1271_BYTES_INTERFACE,
@@ -33,7 +29,7 @@ import { SafeMoneriumOrder } from './types'
export class SafeMoneriumClient extends MoneriumClient {
#protocolKit: Safe
- #ethAdapter: EthAdapter
+ #safeProvider: SafeProvider
/**
* Constructor where the Monerium environment and the Protocol kit instance are set
@@ -44,7 +40,7 @@ export class SafeMoneriumClient extends MoneriumClient {
super(moneriumOptions)
this.#protocolKit = protocolKit
- this.#ethAdapter = protocolKit.getEthAdapter()
+ this.#safeProvider = protocolKit.getSafeProvider()
}
/**
@@ -123,7 +119,7 @@ export class SafeMoneriumClient extends MoneriumClient {
const safeVersion = await this.#protocolKit.getContractVersion()
const signMessageContract = await getSignMessageLibContract({
- ethAdapter: this.#ethAdapter,
+ safeProvider: this.#safeProvider,
safeVersion
})
@@ -151,7 +147,7 @@ export class SafeMoneriumClient extends MoneriumClient {
safeAddress,
safeTransactionData: safeTransaction.data,
safeTxHash,
- senderAddress: (await this.#ethAdapter.getSignerAddress()) || '',
+ senderAddress: (await this.#safeProvider.getSignerAddress()) || '',
senderSignature: senderSignature.data
})
@@ -211,12 +207,12 @@ export class SafeMoneriumClient extends MoneriumClient {
])
const checks = [
- this.#ethAdapter.call({
+ this.#safeProvider.call({
from: safeAddress,
to: safeAddress,
data: eip1271data
}),
- this.#ethAdapter.call({
+ this.#safeProvider.call({
from: safeAddress,
to: safeAddress,
data: eip1271BytesData
diff --git a/packages/protocol-kit/LICENSE.md b/packages/protocol-kit/LICENSE.md
index 310e6e37c..0e923d187 100644
--- a/packages/protocol-kit/LICENSE.md
+++ b/packages/protocol-kit/LICENSE.md
@@ -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:
diff --git a/packages/protocol-kit/README.md b/packages/protocol-kit/README.md
index 355f1616c..27b18df28 100644
--- a/packages/protocol-kit/README.md
+++ b/packages/protocol-kit/README.md
@@ -4,20 +4,22 @@
[](https://github.com/safe-global/safe-core-sdk/releases)
[](https://github.com/safe-global/safe-core-sdk/blob/main/LICENSE.md)
-Software development kit that facilitates the interaction with the [Safe contracts](https://github.com/safe-global/safe-contracts).
+Software development kit that facilitates the interaction with [Safe Smart Accounts](https://github.com/safe-global/safe-smart-account).
## Table of contents
+- [Documentation](#documentation)
- [Installation](#installation)
-- [Build](#build)
-- [Tests](#tests)
-- [Getting Started](#getting-started)
-- [Safe Factory API Reference](#factory-api)
-- [Safe Core SDK API Reference](#sdk-api)
+- [Quick Start](#quick-start)
+- [Need Help or Have Questions?](#need-help-or-have-questions)
+- [Contributing](#contributing)
- [License](#license)
-- [Contributors](#contributors)
-## Installation
+## Documentation
+
+Head to the [Protocol Kit docs](https://docs.safe.global/sdk/protocol-kit) to learn more about how to use this SDK.
+
+## Installation
Install the package with yarn or npm:
@@ -26,285 +28,24 @@ yarn add @safe-global/protocol-kit
npm install @safe-global/protocol-kit
```
-## Build
-
-Build the package with yarn or npm:
-
-```bash
-yarn build
-npm run build
-```
-
-## Tests
-
-Create a `.env` file with environment variables. You can use the `.env.example` file as a reference.
-
-Test the package with yarn or npm:
-
-```bash
-yarn test
-npm run test
-```
-
-## Getting Started
-
-The following steps show how to set up the Protocol Kit, deploy a new Safe, create a Safe transaction, generate the required signatures from owners and execute the transaction. However, using the Protocol Kit alone will not allow for the collection of owner signatures off-chain. To do this and be able to see and confirm the pending transactions shown in the [Safe Web App](https://app.safe.global/), it is recommended that you follow this other [guide](/guides/integrating-the-safe-core-sdk.md) that covers the use of the Protocol Kit, combined with the API Kit.
-
-### 1. Instantiate an EthAdapter
-
-First of all, we need to create an `EthAdapter`, which contains all the required utilities for the SDKs to interact with the blockchain. It acts as a wrapper for [web3.js](https://web3js.readthedocs.io/) or [ethers.js](https://docs.ethers.org/v6/) Ethereum libraries.
-
-Depending on the library used by the Dapp, there are two options:
-
-- [Create an `EthersAdapter` instance](https://github.com/safe-global/safe-core-sdk/tree/main/packages/protocol-kit/src/adapters/ethers)
-- [Create a `Web3Adapter` instance](https://github.com/safe-global/safe-core-sdk/tree/main/packages/protocol-kit/src/adapters/web3)
-
-Once the instance of `EthersAdapter` or `Web3Adapter` is created, it can be used in the SDK initialization.
-
-### 2. Deploy a new Safe
-
-To deploy a new Safe account instantiate the `SafeFactory` class and call the `deploySafe` method with the right params to configure the new Safe. This includes defining the list of owners and the threshold of the Safe. A Safe account with three owners and threshold equal three will be used as the starting point for this example but any Safe configuration is valid.
-
-```js
-import Safe, { SafeFactory, SafeAccountConfig } from '@safe-global/protocol-kit'
-
-const safeFactory = await SafeFactory.create({ ethAdapter })
-
-const owners = ['0x', '0x', '0x']
-const threshold = 3
-const safeAccountConfig: SafeAccountConfig = {
- owners,
- threshold
- // ...
-}
-
-const safeSdk: Safe = await safeFactory.deploySafe({ safeAccountConfig })
-```
-
-The `deploySafe` method executes a transaction from the `owner1` account, deploys a new Safe and returns an instance of the Protocol Kit connected to the new Safe. Check the `deploySafe` method in the [API Reference](#factory-api) for more details on additional configuration parameters and callbacks.
-
-Call the `getAddress` method, for example, to check the address of the newly deployed Safe.
-
-```js
-const newSafeAddress = await safeSdk.getAddress()
-```
-
-To instantiate the Protocol Kit from an existing Safe just pass to it an instance of the `EthAdapter` class and the Safe address.
-
-```js
-import Safe from '@safe-global/protocol-kit'
-
-const safeSdk: Safe = await Safe.create({ ethAdapter: ethAdapterOwner1, safeAddress })
-```
-
-Check the `create` method in the [API Reference](#sdk-api) for more details on additional configuration parameters.
-
-### 3. Create a Safe transaction
-
-```js
-import { MetaTransactionData } from '@safe-global/safe-core-sdk-types'
-
-const safeTransactionData: MetaTransactionData = {
- to: '0x',
- value: '',
- data: '0x'
-}
-const safeTransaction = await safeSdk.createTransaction({ transactions: [safeTransactionData] })
-```
-
-Check the `createTransaction` method in the [API Reference](#sdk-api) for additional details on creating MultiSend transactions.
-
-Before executing this transaction, it must be signed by the owners and this can be done off-chain or on-chain. In this example `owner1` will sign it off-chain, `owner2` will sign it on-chain and `owner3` will execute it (the executor also signs the transaction transparently).
-
-### 3.a. Off-chain signatures
-
-The `owner1` account signs the transaction off-chain.
-
-```js
-const signedSafeTransaction = await safeSdk.signTransaction(safeTransaction)
-```
-
-Because the signature is off-chain, there is no interaction with the contract and the signature becomes available at `signedSafeTransaction.signatures`.
-
-### 3.b. On-chain signatures
-
-To connect `owner2` to the Safe we need to create a new instance of the class `EthAdapter` passing to its constructor the owner we would like to connect. After `owner2` account is connected to the SDK as a signer the transaction hash will be approved on-chain.
-
-```js
-const ethAdapterOwner2 = new EthersAdapter({ ethers, signerOrProvider: owner2 })
-const safeSdk2 = await safeSdk.connect({ ethAdapter: ethAdapterOwner2, safeAddress })
-const txHash = await safeSdk2.getTransactionHash(safeTransaction)
-const approveTxResponse = await safeSdk2.approveTransactionHash(txHash)
-await approveTxResponse.transactionResponse?.wait()
-```
-
-### 4. Transaction execution
-
-Lastly, `owner3` account is connected to the SDK as a signer and executor of the Safe transaction to execute it.
-
-```js
-const ethAdapterOwner3 = new EthersAdapter({ ethers, signerOrProvider: owner3 })
-const safeSdk3 = await safeSdk2.connect({ ethAdapter: ethAdapterOwner3, safeAddress })
-const executeTxResponse = await safeSdk3.executeTransaction(safeTransaction)
-await executeTxResponse.transactionResponse?.wait()
-```
-
-All the signatures used to execute the transaction are now available at `safeTransaction.signatures`.
-
-## Safe Factory API Reference
-
-### create
-
-Returns an instance of the Safe Factory.
-
-```js
-import { SafeFactory } from '@safe-global/protocol-kit'
-
-const safeFactory = await SafeFactory.create({ ethAdapter })
-```
-
-- The `isL1SafeSingleton` flag
-
- There are two versions of the Safe contracts: [Safe.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/Safe.sol) that does not trigger events in order to save gas and [SafeL2.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/SafeL2.sol) that does, which is more appropriate for L2 networks.
-
- By default `Safe.sol` will be only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the `SafeL2.sol` contract will be used unless you add the `isL1SafeSingleton` flag to force the use of the `Safe.sol` contract.
-
- ```js
- const safeFactory = await SafeFactory.create({ ethAdapter, isL1SafeSingleton: true })
- ```
-
-- The `contractNetworks` property
-
- If the Safe contracts are not deployed to your current network, the `contractNetworks` property will be required to point to the addresses of the Safe contracts previously deployed by you.
-
- ```js
- import { ContractNetworksConfig } from '@safe-global/protocol-kit'
-
- const chainId = await ethAdapter.getChainId()
- const contractNetworks: ContractNetworksConfig = {
- [chainId]: {
- safeSingletonAddress: '',
- safeProxyFactoryAddress: '',
- multiSendAddress: '',
- multiSendCallOnlyAddress: '',
- fallbackHandlerAddress: '',
- signMessageLibAddress: '',
- createCallAddress: '',
- simulateTxAccessorAddress: '',
- safeSingletonAbi: '', // Optional. Only needed with web3.js
- safeProxyFactoryAbi: '', // Optional. Only needed with web3.js
- multiSendAbi: '', // Optional. Only needed with web3.js
- multiSendCallOnlyAbi: '', // Optional. Only needed with web3.js
- fallbackHandlerAbi: '', // Optional. Only needed with web3.js
- signMessageLibAbi: '', // Optional. Only needed with web3.js
- createCallAbi: '', // Optional. Only needed with web3.js
- simulateTxAccessorAbi: '' // Optional. Only needed with web3.js
- }
- }
-
- const safeFactory = await SafeFactory.create({ ethAdapter, contractNetworks })
- ```
-
-- The `safeVersion` property
-
- The `SafeFactory` constructor also accepts the `safeVersion` property to specify the Safe contract version that will be deployed. This string can take the values `1.0.0`, `1.1.1`, `1.2.0`, `1.3.0` or `1.4.1`. If not specified, the `DEFAULT_SAFE_VERSION` value will be used.
-
- ```js
- const safeVersion = 'X.Y.Z'
- const safeFactory = await SafeFactory.create({ ethAdapter, safeVersion })
- ```
-
-### deploySafe
-
-Deploys a new Safe and returns an instance of the Protocol Kit connected to the deployed Safe. The Singleton address, contract version and layer instance (`Safe.sol` or `SafeL2.sol`) of the deployed Safe will depend on the configuration used to create the `safeFactory`.
-
-```js
-const safeAccountConfig: SafeAccountConfig = {
- owners,
- threshold,
- to, // Optional
- data, // Optional
- fallbackHandler, // Optional
- paymentToken, // Optional
- payment, // Optional
- paymentReceiver // Optional
-}
-
-const safeSdk = await safeFactory.deploySafe({ safeAccountConfig })
-```
-
-This method can optionally receive the `saltNonce` parameter.
-
-```js
-const safeAccountConfig: SafeAccountConfig = {
- owners,
- threshold,
- to, // Optional
- data, // Optional
- fallbackHandler, // Optional
- paymentToken, // Optional
- payment, // Optional
- paymentReceiver // Optional
-}
-
-const saltNonce = ''
-
-const safeSdk = await safeFactory.deploySafe({ safeAccountConfig, saltNonce })
-```
-
-Optionally, some properties can be passed as execution options:
-
-```js
-const options: Web3TransactionOptions = {
- from, // Optional
- gas, // Optional
- gasPrice, // Optional
- maxFeePerGas, // Optional
- maxPriorityFeePerGas // Optional
- nonce // Optional
-}
-```
-
-```js
-const options: EthersTransactionOptions = {
- from, // Optional
- gasLimit, // Optional
- gasPrice, // Optional
- maxFeePerGas, // Optional
- maxPriorityFeePerGas // Optional
- nonce // Optional
-}
-```
-
-```js
-const safeSdk = await safeFactory.deploySafe({ safeAccountConfig, safeDeploymentConfig, options })
-```
-
-It can also take an optional callback which receives the `txHash` of the Safe deployment transaction prior to returning a new instance of the Protocol Kit:
-
-```js
-const callback = (txHash: string): void => {
- console.log({ txHash })
-}
-
-const safeSdk = await safeFactory.deploySafe({ safeAccountConfig, callback })
-```
-
-## Safe Core SDK API Reference
-
-### create
+## Quick Start
-Returns an instance of the Protocol Kit connected to a Safe. The provided Safe must be a `safeAddress` or a `predictedSafe`.
+- `provider`: You can set an EIP-1193 compatible provider or an HTTP/WebSocket RPC URL.
+- `signer`: This is an optional parameter. It should be the provider's address you want to use or a private key. If not set, it will try to fetch a connected account from the provider.
-Initialization of a deployed Safe using the `safeAddress` property:
+Loading an already deployed Safe, using the `safeAddress` property:
```js
import Safe from '@safe-global/protocol-kit'
-const safeSdk = await Safe.create({ ethAdapter, safeAddress })
+const protocolKit = await Safe.init({
+ provider,
+ signer,
+ safeAddress
+})
```
-Initialization of a not deployed Safe using the `predictedSafe` property. Because Safes are deployed in a deterministic way, passing a `predictedSafe` will allow to initialize the SDK with the Safe configuration and use it to some extent before it is deployed:
+Initialization of an undeployed Safe using the `predictedSafe` property. Because Safes are deployed in a deterministic way, passing a `predictedSafe` will allow to initialize the SDK with the Safe configuration and use it to some extent before it's deployed:
```js
import Safe, { PredictedSafeProps } from '@safe-global/protocol-kit'
@@ -314,719 +55,21 @@ const predictedSafe: PredictedSafeProps = {
safeDeploymentConfig
}
-const safeSdk = await Safe.create({ ethAdapter, predictedSafe })
-```
-
-- The `isL1SafeSingleton` flag
-
- There are two versions of the Safe contracts: [Safe.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/Safe.sol) that does not trigger events in order to save gas and [SafeL2.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/SafeL2.sol) that does, which is more appropriate for L2 networks.
-
- By default `Safe.sol` will be only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the `SafeL2.sol` contract will be used unless you add the `isL1SafeSingleton` flag to force the use of the `Safe.sol` contract.
-
- ```js
- const safeSdk = await Safe.create({ ethAdapter, safeAddress, isL1SafeSingleton: true })
- ```
-
-- The `contractNetworks` property
-
- If the Safe contracts are not deployed to your current network, the `contractNetworks` property will be required to point to the addresses of the Safe contracts previously deployed by you.
-
- ```js
- import { ContractNetworksConfig } from '@safe-global/protocol-kit'
-
- const chainId = await ethAdapter.getChainId()
- const contractNetworks: ContractNetworksConfig = {
- [chainId]: {
- safeSingletonAddress: '',
- safeProxyFactoryAddress: '',
- multiSendAddress: '',
- multiSendCallOnlyAddress: '',
- fallbackHandlerAddress: '',
- signMessageLibAddress: '',
- createCallAddress: '',
- simulateTxAccessorAddress: '',
- safeSingletonAbi: '', // Optional. Only needed with web3.js
- safeProxyFactoryAbi: '', // Optional. Only needed with web3.js
- multiSendAbi: '', // Optional. Only needed with web3.js
- multiSendCallOnlyAbi: '', // Optional. Only needed with web3.js
- fallbackHandlerAbi: '', // Optional. Only needed with web3.js
- signMessageLibAbi: '', // Optional. Only needed with web3.js
- createCallAbi: '', // Optional. Only needed with web3.js
- simulateTxAccessorAbi: '' // Optional. Only needed with web3.js
- }
- }
-
- const safeSdk = await Safe.create({ ethAdapter, safeAddress, contractNetworks })
- ```
-
-### connect
-
-Returns a new instance of the Protocol Kit connected to a new Safe or a new Signer. The new connected signer can be passed via the `ethAdapter` property while the new connected Safe can be passed using a `safeAddress` or a `predictedSafe`.
-
-Connection of a deployed Safe using the `safeAddress` property:
-
-```js
-const safeSdk = await safeSdk.connect({ ethAdapter, safeAddress })
-```
-
-Connection of a not deployed Safe using the `predictedSafe` property. Because Safes are deployed in a deterministic way, passing a `predictedSafe` will allow to connect a Safe to the SDK with the Safe configuration:
-
-```js
-import { PredictedSafeProps } from '@safe-global/protocol-kit'
-
-const predictedSafe: PredictedSafeProps = {
- safeAccountConfig,
- safeDeploymentConfig
-}
-
-const safeSdk = await safeSdk.connect({ ethAdapter, predictedSafe })
-```
-
-- The `isL1SafeSingleton` flag
-
- There are two versions of the Safe contracts: [Safe.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/Safe.sol) that does not trigger events in order to save gas and [SafeL2.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/SafeL2.sol) that does, which is more appropriate for L2 networks.
-
- By default `Safe.sol` will be only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the `SafeL2.sol` contract will be used unless you add the `isL1SafeSingleton` flag to force the use of the `Safe.sol` contract.
-
- ```js
- const safeSdk = await Safe.connect({ ethAdapter, safeAddress, isL1SafeSingleton: true })
- ```
-
-- The `contractNetworks` property
-
- If the Safe contracts are not deployed to your current network, the `contractNetworks` property will be required to point to the addresses of the Safe contracts previously deployed by you.
-
- ```js
- import { ContractNetworksConfig } from '@safe-global/protocol-kit'
-
- const chainId = await ethAdapter.getChainId()
- const contractNetworks: ContractNetworksConfig = {
- [chainId]: {
- safeSingletonAddress: '',
- safeProxyFactoryAddress: '',
- multiSendAddress: '',
- multiSendCallOnlyAddress: '',
- fallbackHandlerAddress: '',
- signMessageLibAddress: '',
- createCallAddress: '',
- simulateTxAccessorAddress: '',
- safeSingletonAbi: '', // Optional. Only needed with web3.js
- safeProxyFactoryAbi: '', // Optional. Only needed with web3.js
- multiSendAbi: '', // Optional. Only needed with web3.js
- multiSendCallOnlyAbi: '', // Optional. Only needed with web3.js
- fallbackHandlerAbi: '', // Optional. Only needed with web3.js
- signMessageLibAbi: '', // Optional. Only needed with web3.js
- createCallAbi: '', // Optional. Only needed with web3.js
- simulateTxAccessorAbi: '' // Optional. Only needed with web3.js
- }
- }
- const safeSdk = await Safe.connect({ ethAdapter, safeAddress, contractNetworks })
- ```
-
-### getAddress
-
-Returns the address of the current SafeProxy contract.
-
-```js
-const safeAddress = await safeSdk.getAddress()
-```
-
-### getContractVersion
-
-Returns the Safe Singleton contract version.
-
-```js
-const contractVersion = await safeSdk.getContractVersion()
-```
-
-### getOwners
-
-Returns the list of Safe owner accounts.
-
-```js
-const ownerAddresses = await safeSdk.getOwners()
-```
-
-### getNonce
-
-Returns the Safe nonce.
-
-```js
-const nonce = await safeSdk.getNonce()
-```
-
-### getThreshold
-
-Returns the Safe threshold.
-
-```js
-const threshold = await safeSdk.getThreshold()
-```
-
-### getChainId
-
-Returns the chainId of the connected network.
-
-```js
-const chainId = await safeSdk.getChainId()
-```
-
-### getBalance
-
-Returns the ETH balance of the Safe.
-
-```js
-const balance = await safeSdk.getBalance()
-```
-
-### getGuard
-
-Returns the enabled Safe guard or 0x address if no guards are enabled.
-
-```js
-const guardAddress = await safeSdk.getGuard()
-```
-
-### getModules
-
-Returns the list of addresses of all the enabled Safe modules.
-
-```js
-const moduleAddresses = await safeSdk.getModules()
-```
-
-### isModuleEnabled
-
-Checks if a specific Safe module is enabled for the current Safe.
-
-```js
-const isEnabled = await safeSdk.isModuleEnabled(moduleAddress)
-```
-
-### isOwner
-
-Checks if a specific address is an owner of the current Safe.
-
-```js
-const isOwner = await safeSdk.isOwner(address)
-```
-
-### createTransaction
-
-Returns a Safe transaction ready to be signed by the owners and executed. The Protocol Kit supports the creation of single Safe transactions but also MultiSend transactions.
-
-This method takes an array of `MetaTransactionData` objects that represent the individual transactions we want to include in our MultiSend transaction.
-
-When the array contains only one transaction, it is not wrapped in the MultiSend.
-
-```js
-const transactions: MetaTransactionData[] = [
- {
- to,
- data,
- value,
- operation // Optional
- },
- {
- to,
- data,
- value,
- operation // Optional
- }
- // ...
-]
-const safeTransaction = await safeSdk.createTransaction({ transactions })
-```
-
-This method can also receive the `options` parameter to set the optional properties in the MultiSend transaction:
-
-```js
-const transactions: MetaTransactionData[] = [
- {
- to,
- data,
- value,
- operation // Optional
- },
- {
- to,
- data,
- value,
- operation // Optional
- }
- // ...
-]
-const options: SafeTransactionOptionalProps = {
- safeTxGas, // Optional
- baseGas, // Optional
- gasPrice, // Optional
- gasToken, // Optional
- refundReceiver, // Optional
- nonce // Optional
-}
-const safeTransaction = await safeSdk.createTransaction({ transactions, options })
-```
-
-In addition, the optional `onlyCalls` parameter, which is `false` by default, allows to force the use of the `MultiSendCallOnly` instead of the `MultiSend` contract when sending a batch transaction:
-
-```js
-const onlyCalls = true
-const safeTransaction = await safeSdk.createTransaction({
- transactions,
- options,
- onlyCalls
+const protocolKit = await Safe.init({
+ provider,
+ signer,
+ predictedSafe
})
```
-If the optional properties are not manually set, the Safe transaction returned will have the default value for each one:
-
-- `operation`: `OperationType.Call` (0) is the default value.
-- `safeTxGas`: The right gas estimation is the default value.
-- `baseGas`: 0 is the default value.
-- `gasPrice`: 0 is the default value.
-- `gasToken`: 0x address is the default value.
-- `refundReceiver`: 0x address is the default value.
-- `nonce`: The current Safe nonce is the default value.
-
-Read more about [create transactions from a Safe](https://docs.safe.global/safe-core-aa-sdk/protocol-kit#making-a-transaction-from-a-safe).
-
-### createRejectionTransaction
-
-Returns a Safe transaction ready to be signed by the owners that invalidates the pending Safe transaction/s with a specific nonce.
-
-```js
-const transactions: MetaTransactionData[] = [
- {
- // ...
- }
-]
-const safeTransaction = await safeSdk.createTransaction({ transactions })
-const rejectionTransaction = await safeSdk.createRejectionTransaction(safeTransaction.data.nonce)
-```
-
-### copyTransaction
-
-Copies a Safe transaction.
-
-```js
-const safeTransaction1 = await safeSdk.createTransaction({ transactions })
-const safeTransaction2 = await copyTransaction(safeTransaction1)
-```
-
-### getTransactionHash
-
-Returns the transaction hash of a Safe transaction.
-
-```js
-const transactions: MetaTransactionData[] = [
- {
- // ...
- }
-]
-const safeTransaction = await safeSdk.createTransaction({ transactions })
-const txHash = await safeSdk.getTransactionHash(safeTransaction)
-```
-
-### signHash
-
-Signs a hash using the current owner account.
-
-```js
-const transactions: MetaTransactionData[] = [
- {
- // ...
- }
-]
-const safeTransaction = await safeSdk.createTransaction({ transactions })
-const txHash = await safeSdk.getTransactionHash(safeTransaction)
-const signature = await safeSdk.signHash(txHash)
-```
-
-### signTypedData
-
-Signs a transaction according to the EIP-712 using the current signer account.
-
-```js
-const transactions: MetaTransactionData[] = [
- {
- // ...
- }
-]
-const safeTransaction = await safeSdk.createTransaction({ transactions })
-const signature = await safeSdk.signTypedData(safeTransaction)
-```
-
-### signTransaction
-
-Returns a new `SafeTransaction` object that includes the signature of the current owner. `eth_sign` will be used by default to generate the signature.
-
-```js
-const transactions: MetaTransactionData[] = [
- {
- // ...
- }
-]
-const safeTransaction = await safeSdk.createTransaction({ transactions })
-const signedSafeTransaction = await safeSdk.signTransaction(safeTransaction)
-```
-
-Optionally, an additional parameter can be passed to specify a different way of signing:
-
-```js
-const signedSafeTransaction = await safeSdk.signTransaction(
- safeTransaction,
- SigningMethod.ETH_SIGN_TYPED_DATA
-)
-```
-
-```js
-const signedSafeTransaction = await safeSdk.signTransaction(safeTransaction, SigningMethod.ETH_SIGN) // default option.
-```
-
-### approveTransactionHash
-
-Approves a hash on-chain using the current owner account.
-
-```js
-const transactions: MetaTransactionData[] = [
- {
- // ...
- }
-]
-const safeTransaction = await safeSdk.createTransaction({ transactions })
-const txHash = await safeSdk.getTransactionHash(safeTransaction)
-const txResponse = await safeSdk.approveTransactionHash(txHash)
-await txResponse.transactionResponse?.wait()
-```
-
-Optionally, some properties can be passed as execution options:
-
-```js
-const options: Web3TransactionOptions = {
- from, // Optional
- gas, // Optional
- gasPrice, // Optional
- maxFeePerGas, // Optional
- maxPriorityFeePerGas // Optional
- nonce // Optional
-}
-```
-
-```js
-const options: EthersTransactionOptions = {
- from, // Optional
- gasLimit, // Optional
- gasPrice, // Optional
- maxFeePerGas, // Optional
- maxPriorityFeePerGas // Optional
- nonce // Optional
-}
-```
-
-```js
-const txResponse = await safeSdk.approveTransactionHash(txHash, options)
-```
-
-### getOwnersWhoApprovedTx
-
-Returns a list of owners who have approved a specific Safe transaction.
-
-```js
-const transactions: MetaTransactionData[] = [
- {
- // ...
- }
-]
-const safeTransaction = await safeSdk.createTransaction({ transactions })
-const txHash = await safeSdk.getTransactionHash(safeTransaction)
-const ownerAddresses = await safeSdk.getOwnersWhoApprovedTx(txHash)
-```
-
-### createEnableFallbackHandlerTx
-
-Returns the Safe transaction to enable the fallback handler.
-
-```js
-const safeTransaction = await safeSdk.createEnableFallbackHandlerTx(fallbackHandlerAddress)
-const txResponse = await safeSdk.executeTransaction(safeTransaction)
-await txResponse.transactionResponse?.wait()
-```
-
-This method can optionally receive the `options` parameter:
-
-```js
-const options: SafeTransactionOptionalProps = {
- safeTxGas, // Optional
- baseGas, // Optional
- gasPrice, // Optional
- gasToken, // Optional
- refundReceiver, // Optional
- nonce // Optional
-}
-const safeTransaction = await safeSdk.createEnableFallbackHandlerTx(fallbackHandlerAddress, options)
-```
-
-### createDisableFallbackHandlerTx
-
-Returns the Safe transaction to disable the fallback handler.
-
-```js
-const safeTransaction = await safeSdk.createDisableFallbackHandlerTx()
-const txResponse = await safeSdk.executeTransaction(safeTransaction)
-await txResponse.transactionResponse?.wait()
-```
-
-This method can optionally receive the `options` parameter:
-
-```js
-const options: SafeTransactionOptionalProps = { ... }
-const safeTransaction = await safeSdk.createDisableFallbackHandlerTx(options)
-```
-
-### createEnableGuardTx
-
-Returns the Safe transaction to enable a Safe guard.
-
-```js
-const safeTransaction = await safeSdk.createEnableGuardTx(guardAddress)
-const txResponse = await safeSdk.executeTransaction(safeTransaction)
-await txResponse.transactionResponse?.wait()
-```
-
-This method can optionally receive the `options` parameter:
+## Need Help or Have Questions?
-```js
-const options: SafeTransactionOptionalProps = {
- safeTxGas, // Optional
- baseGas, // Optional
- gasPrice, // Optional
- gasToken, // Optional
- refundReceiver, // Optional
- nonce // Optional
-}
-const safeTransaction = await safeSdk.createEnableGuardTx(guardAddress, options)
-```
-
-### createDisableGuardTx
-
-Returns the Safe transaction to disable a Safe guard.
-
-```js
-const safeTransaction = await safeSdk.createDisableGuardTx()
-const txResponse = await safeSdk.executeTransaction(safeTransaction)
-await txResponse.transactionResponse?.wait()
-```
-
-This method can optionally receive the `options` parameter:
-
-```js
-const options: SafeTransactionOptionalProps = { ... }
-const safeTransaction = await safeSdk.createDisableGuardTx(options)
-```
-
-### createEnableModuleTx
-
-Returns a Safe transaction ready to be signed that will enable a Safe module.
-
-```js
-const safeTransaction = await safeSdk.createEnableModuleTx(moduleAddress)
-const txResponse = await safeSdk.executeTransaction(safeTransaction)
-await txResponse.transactionResponse?.wait()
-```
-
-This method can optionally receive the `options` parameter:
-
-```js
-const options: SafeTransactionOptionalProps = { ... }
-const safeTransaction = await safeSdk.createEnableModuleTx(moduleAddress, options)
-```
-
-### createDisableModuleTx
-
-Returns a Safe transaction ready to be signed that will disable a Safe module.
-
-```js
-const safeTransaction = await safeSdk.createDisableModuleTx(moduleAddress)
-const txResponse = await safeSdk.executeTransaction(safeTransaction)
-await txResponse.transactionResponse?.wait()
-```
-
-This method can optionally receive the `options` parameter:
-
-```js
-const options: SafeTransactionOptionalProps = { ... }
-const safeTransaction = await safeSdk.createDisableModuleTx(moduleAddress, options)
-```
-
-### createAddOwnerTx
-
-Returns the Safe transaction to add an owner and optionally change the threshold.
-
-```js
-const params: AddOwnerTxParams = {
- ownerAddress,
- threshold // Optional. If `threshold` is not provided the current threshold will not change.
-}
-const safeTransaction = await safeSdk.createAddOwnerTx(params)
-const txResponse = await safeSdk.executeTransaction(safeTransaction)
-await txResponse.transactionResponse?.wait()
-```
-
-This method can optionally receive the `options` parameter:
-
-```js
-const options: SafeTransactionOptionalProps = { ... }
-const safeTransaction = await safeSdk.createAddOwnerTx(params, options)
-```
-
-### createRemoveOwnerTx
-
-Returns the Safe transaction to remove an owner and optionally change the threshold.
-
-```js
-const params: RemoveOwnerTxParams = {
- ownerAddress,
- newThreshold // Optional. If `newThreshold` is not provided, the current threshold will be decreased by one.
-}
-const safeTransaction = await safeSdk.createRemoveOwnerTx(params)
-const txResponse = await safeSdk.executeTransaction(safeTransaction)
-await txResponse.transactionResponse?.wait()
-```
-
-This method can optionally receive the `options` parameter:
-
-```js
-const options: SafeTransactionOptionalProps = { ... }
-const safeTransaction = await safeSdk.createRemoveOwnerTx(params, options)
-```
-
-### createSwapOwnerTx
-
-Returns the Safe transaction to replace an owner of the Safe with a new one.
-
-```js
-const params: SwapOwnerTxParams = {
- oldOwnerAddress,
- newOwnerAddress
-}
-const safeTransaction = await safeSdk.createSwapOwnerTx(params)
-const txResponse = await safeSdk.executeTransaction(safeTransaction)
-await txResponse.transactionResponse?.wait()
-```
-
-This method can optionally receive the `options` parameter:
-
-```js
-const options: SafeTransactionOptionalProps = { ... }
-const safeTransaction = await safeSdk.createSwapOwnerTx(params, options)
-```
-
-### createChangeThresholdTx
-
-Returns the Safe transaction to change the threshold.
-
-```js
-const safeTransaction = await safeSdk.createChangeThresholdTx(newThreshold)
-const txResponse = await safeSdk.executeTransaction(safeTransaction)
-await txResponse.transactionResponse?.wait()
-```
-
-This method can optionally receive the `options` parameter:
-
-```js
-const options: SafeTransactionOptionalProps = { ... }
-const safeTransaction = await safeSdk.createChangeThresholdTx(newThreshold, options)
-```
-
-### isValidTransaction
-
-Checks if a Safe transaction can be executed successfully with no errors.
-
-```js
-const transactions: MetaTransactionData[] = [
- {
- // ...
- }
-]
-const safeTransaction = await safeSdk.createTransaction({ transactions })
-const isValidTx = await safeSdk.isValidTransaction(safeTransaction)
-```
-
-Optionally, some properties can be passed as execution options:
-
-```js
-const options: Web3TransactionOptions = {
- from, // Optional
- gas, // Optional
- gasPrice, // Optional
- maxFeePerGas, // Optional
- maxPriorityFeePerGas // Optional
- nonce // Optional
-}
-```
-
-```js
-const options: EthersTransactionOptions = {
- from, // Optional
- gasLimit, // Optional
- gasPrice, // Optional
- maxFeePerGas, // Optional
- maxPriorityFeePerGas // Optional
- nonce // Optional
-}
-```
-
-```js
-const isValidTx = await safeSdk.isValidTransaction(safeTransaction, options)
-```
-
-### executeTransaction
-
-Executes a Safe transaction.
-
-```js
-const transactions: MetaTransactionData[] = [
- {
- // ...
- }
-]
-const safeTransaction = await safeSdk.createTransaction({ transactions })
-const txResponse = await safeSdk.executeTransaction(safeTransaction)
-await txResponse.transactionResponse?.wait()
-```
-
-Optionally, some properties can be passed as execution options:
-
-```js
-const options: Web3TransactionOptions = {
- from, // Optional
- gas, // Optional
- gasPrice, // Optional
- maxFeePerGas, // Optional
- maxPriorityFeePerGas // Optional
- nonce // Optional
-}
-```
-
-```js
-const options: EthersTransactionOptions = {
- from, // Optional
- gasLimit, // Optional
- gasPrice, // Optional
- maxFeePerGas, // Optional
- maxPriorityFeePerGas // Optional
- nonce // Optional
-}
-```
-
-```js
-const txResponse = await safeSdk.executeTransaction(safeTransaction, options)
-```
+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)
-## License
+## Contributing
-This library is released under MIT.
+Please read our [contribution guidelines](https://github.com/safe-global/safe-core-sdk/tree/main/CONTRIBUTING.md) before submitting any changes. We appreciate your help! 🙌
-## Contributors
+## License
-- Germán Martínez ([germartinez](https://github.com/germartinez))
+This library is [released under MIT](https://github.com/safe-global/safe-core-sdk/blob/main/LICENSE.md).
diff --git a/packages/protocol-kit/hardhat.config.ts b/packages/protocol-kit/hardhat.config.ts
index 5ab637921..1d0aa7a5e 100644
--- a/packages/protocol-kit/hardhat.config.ts
+++ b/packages/protocol-kit/hardhat.config.ts
@@ -2,7 +2,6 @@ import '@nomicfoundation/hardhat-ethers'
import 'hardhat-deploy'
import 'hardhat-deploy-ethers'
import 'tsconfig-paths/register'
-import '@nomiclabs/hardhat-web3'
import dotenv from 'dotenv'
import { HardhatUserConfig, HttpNetworkUserConfig } from 'hardhat/types'
import yargs from 'yargs'
@@ -49,7 +48,6 @@ const config: HardhatUserConfig = {
blockGasLimit: 100000000,
gas: 100000000,
accounts: [
- // Same as ganache-cli -d
{
balance: '100000000000000000000',
privateKey: '0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d'
@@ -94,7 +92,7 @@ const config: HardhatUserConfig = {
},
sepolia: {
...sharedNetworkConfig,
- url: 'https://rpc.ankr.com/eth_sepolia'
+ url: 'https://sepolia.gateway.tenderly.co'
}
},
//@ts-expect-error Type not found
diff --git a/packages/protocol-kit/hardhat/deploy/deploy-contracts.ts b/packages/protocol-kit/hardhat/deploy/deploy-contracts.ts
index 7fc9e21d0..28789b6e7 100644
--- a/packages/protocol-kit/hardhat/deploy/deploy-contracts.ts
+++ b/packages/protocol-kit/hardhat/deploy/deploy-contracts.ts
@@ -188,6 +188,20 @@ const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment): Promise .ts) allows them to be included in the build folder
-function moveTypechainFiles(inDir: string, outDir: string): void {
- readdir(`${inDir}`, (error, files) => {
- if (error) {
- console.log(error)
- }
- if (!existsSync(`${outDir}`)) {
- mkdirSync(`${outDir}`, { recursive: true })
- }
- files.forEach((file) => {
- const pattern = /.d.ts/
- if (!file.match(pattern)) {
- return
- }
- execSync(`cp ${inDir}/${file} ${outDir}/${file}`)
- })
- })
-}
-
-function generateTypes(typechainTarget: string) {
- // Src
- generateTypechainFiles(
- typechainTarget,
- `${outDirSrc}${typechainTarget}/v1.4.1`,
- safeContracts_V1_4_1
- )
- generateTypechainFiles(
- typechainTarget,
- `${outDirSrc}${typechainTarget}/v1.3.0`,
- safeContracts_V1_3_0
- )
- generateTypechainFiles(
- typechainTarget,
- `${outDirSrc}${typechainTarget}/v1.2.0`,
- safeContracts_V1_2_0
- )
- generateTypechainFiles(
- typechainTarget,
- `${outDirSrc}${typechainTarget}/v1.1.1`,
- safeContracts_V1_1_1
- )
- generateTypechainFiles(
- typechainTarget,
- `${outDirSrc}${typechainTarget}/v1.0.0`,
- safeContracts_V1_0_0
- )
- moveTypechainFiles(
- `${typeChainDirectorySrcPath}${typechainTarget}/v1.4.1`,
- `${typeChainDirectoryBuildPath}${typechainTarget}/v1.4.1`
- )
- moveTypechainFiles(
- `${typeChainDirectorySrcPath}${typechainTarget}/v1.3.0`,
- `${typeChainDirectoryBuildPath}${typechainTarget}/v1.3.0`
- )
- moveTypechainFiles(
- `${typeChainDirectorySrcPath}${typechainTarget}/v1.2.0`,
- `${typeChainDirectoryBuildPath}${typechainTarget}/v1.2.0`
- )
- moveTypechainFiles(
- `${typeChainDirectorySrcPath}${typechainTarget}/v1.1.1`,
- `${typeChainDirectoryBuildPath}${typechainTarget}/v1.1.1`
- )
- moveTypechainFiles(
- `${typeChainDirectorySrcPath}${typechainTarget}/v1.0.0`,
- `${typeChainDirectoryBuildPath}${typechainTarget}/v1.0.0`
- )
-
- // Tests
- generateTypechainFiles(
- typechainTarget,
- `${outDirTests}${typechainTarget}/v1.4.1`,
- testContracts_V1_4_1
- )
- generateTypechainFiles(
- typechainTarget,
- `${outDirTests}${typechainTarget}/v1.3.0`,
- testContracts_V1_3_0
- )
- generateTypechainFiles(
- typechainTarget,
- `${outDirTests}${typechainTarget}/v1.2.0`,
- testContracts_V1_2_0
- )
-}
-
-generateTypes('web3-v1')
-generateTypes('ethers-v6')
diff --git a/packages/protocol-kit/src/Safe.ts b/packages/protocol-kit/src/Safe.ts
index 2c07d4aa3..e610ef639 100644
--- a/packages/protocol-kit/src/Safe.ts
+++ b/packages/protocol-kit/src/Safe.ts
@@ -1,5 +1,4 @@
import {
- EthAdapter,
OperationType,
SafeMultisigTransactionResponse,
SafeMultisigConfirmationResponse,
@@ -12,9 +11,9 @@ import {
TransactionResult,
MetaTransactionData,
Transaction,
- CompatibilityFallbackHandlerContract,
EIP712TypedData,
- SafeTransactionData
+ SafeTransactionData,
+ CompatibilityFallbackHandlerContractType
} from '@safe-global/safe-core-sdk-types'
import {
encodeSetupCallData,
@@ -38,7 +37,8 @@ import {
SafeConfigProps,
SigningMethod,
SigningMethodType,
- SwapOwnerTxParams
+ SwapOwnerTxParams,
+ SafeModulesPaginated
} from './types'
import {
EthSafeSignature,
@@ -67,18 +67,18 @@ import { isSafeConfigWithPredictedSafe } from './utils/types'
import {
getCompatibilityFallbackHandlerContract,
getMultiSendCallOnlyContract,
- getProxyFactoryContract,
- getSafeContract
+ getProxyFactoryContract
} from './contracts/safeDeploymentContracts'
import SafeMessage from './utils/messages/SafeMessage'
import semverSatisfies from 'semver/functions/satisfies'
+import SafeProvider from './SafeProvider'
const EQ_OR_GT_1_4_1 = '>=1.4.1'
const EQ_OR_GT_1_3_0 = '>=1.3.0'
class Safe {
#predictedSafe?: PredictedSafeProps
- #ethAdapter!: EthAdapter
+ #safeProvider!: SafeProvider
#contractManager!: ContractManager
#ownerManager!: OwnerManager
#moduleManager!: ModuleManager
@@ -97,10 +97,10 @@ class Safe {
* @throws "MultiSend contract is not deployed on the current network"
* @throws "MultiSendCallOnly contract is not deployed on the current network"
*/
- static async create(config: SafeConfig): Promise {
- const safeSdk = new Safe()
- await safeSdk.init(config)
- return safeSdk
+ static async init(config: SafeConfig): Promise {
+ const protocolKit = new Safe()
+ await protocolKit.#initializeProtocolKit(config)
+ return protocolKit
}
/**
@@ -111,33 +111,41 @@ class Safe {
* @throws "MultiSend contract is not deployed on the current network"
* @throws "MultiSendCallOnly contract is not deployed on the current network"
*/
- private async init(config: SafeConfig): Promise {
- const { ethAdapter, isL1SafeSingleton, contractNetworks } = config
-
- this.#ethAdapter = ethAdapter
+ async #initializeProtocolKit(config: SafeConfig) {
+ const { provider, signer, isL1SafeSingleton, contractNetworks } = config
+ this.#safeProvider = new SafeProvider({
+ provider,
+ signer
+ })
if (isSafeConfigWithPredictedSafe(config)) {
this.#predictedSafe = config.predictedSafe
- this.#contractManager = await ContractManager.create({
- ethAdapter: this.#ethAdapter,
- predictedSafe: this.#predictedSafe,
- isL1SafeSingleton,
- contractNetworks
- })
+ this.#contractManager = await ContractManager.init(
+ {
+ provider,
+ predictedSafe: this.#predictedSafe,
+ isL1SafeSingleton,
+ contractNetworks
+ },
+ this.#safeProvider
+ )
} else {
- this.#contractManager = await ContractManager.create({
- ethAdapter: this.#ethAdapter,
- safeAddress: config.safeAddress,
- isL1SafeSingleton,
- contractNetworks
- })
+ this.#contractManager = await ContractManager.init(
+ {
+ provider,
+ safeAddress: config.safeAddress,
+ isL1SafeSingleton,
+ contractNetworks
+ },
+ this.#safeProvider
+ )
}
- this.#ownerManager = new OwnerManager(this.#ethAdapter, this.#contractManager.safeContract)
- this.#moduleManager = new ModuleManager(this.#ethAdapter, this.#contractManager.safeContract)
- this.#guardManager = new GuardManager(this.#ethAdapter, this.#contractManager.safeContract)
+ this.#ownerManager = new OwnerManager(this.#safeProvider, this.#contractManager.safeContract)
+ this.#moduleManager = new ModuleManager(this.#safeProvider, this.#contractManager.safeContract)
+ this.#guardManager = new GuardManager(this.#safeProvider, this.#contractManager.safeContract)
this.#fallbackHandlerManager = new FallbackHandlerManager(
- this.#ethAdapter,
+ this.#safeProvider,
this.#contractManager.safeContract
)
}
@@ -151,16 +159,18 @@ class Safe {
* @throws "MultiSendCallOnly contract is not deployed on the current network"
*/
async connect(config: ConnectSafeConfig): Promise {
- const { ethAdapter, safeAddress, predictedSafe, isL1SafeSingleton, contractNetworks } = config
+ const { provider, signer, safeAddress, predictedSafe, isL1SafeSingleton, contractNetworks } =
+ config
const configProps: SafeConfigProps = {
- ethAdapter: ethAdapter || this.#ethAdapter,
+ provider: provider || this.#safeProvider.provider,
+ signer,
isL1SafeSingleton: isL1SafeSingleton || this.#contractManager.isL1SafeSingleton,
contractNetworks: contractNetworks || this.#contractManager.contractNetworks
}
// A new existing Safe is connected to the Signer
if (safeAddress) {
- return await Safe.create({
+ return await Safe.init({
safeAddress,
...configProps
})
@@ -168,7 +178,7 @@ class Safe {
// A new predicted Safe is connected to the Signer
if (predictedSafe) {
- return await Safe.create({
+ return await Safe.init({
predictedSafe,
...configProps
})
@@ -176,14 +186,14 @@ class Safe {
// The previous predicted Safe is connected to a new Signer
if (this.#predictedSafe) {
- return await Safe.create({
+ return await Safe.init({
predictedSafe: this.#predictedSafe,
...configProps
})
}
// The previous existing Safe is connected to a new Signer
- return await Safe.create({
+ return await Safe.init({
safeAddress: await this.getAddress(),
...configProps
})
@@ -199,10 +209,10 @@ class Safe {
throw new Error('The Safe already exists')
}
- const chainId = await this.#ethAdapter.getChainId()
+ const chainId = await this.#safeProvider.getChainId()
return getPredictedSafeAddressInitCode({
- ethAdapter: this.#ethAdapter,
+ safeProvider: this.#safeProvider,
chainId,
customContracts: this.#contractManager.contractNetworks?.[chainId.toString()],
...this.#predictedSafe
@@ -223,9 +233,9 @@ class Safe {
)
}
- const chainId = await this.#ethAdapter.getChainId()
+ const chainId = await this.#safeProvider.getChainId()
return predictSafeAddress({
- ethAdapter: this.#ethAdapter,
+ safeProvider: this.#safeProvider,
chainId,
customContracts: this.#contractManager.contractNetworks?.[chainId.toString()],
...this.#predictedSafe
@@ -249,12 +259,12 @@ class Safe {
}
/**
- * Returns the current EthAdapter.
+ * Returns the current SafeProvider.
*
- * @returns The current EthAdapter
+ * @returns The current SafeProvider
*/
- getEthAdapter(): EthAdapter {
- return this.#ethAdapter
+ getSafeProvider(): SafeProvider {
+ return this.#safeProvider
}
/**
@@ -282,7 +292,7 @@ class Safe {
*/
async isSafeDeployed(): Promise {
const safeAddress = await this.getAddress()
- const isSafeDeployed = await this.#ethAdapter.isContractDeployed(safeAddress)
+ const isSafeDeployed = await this.#safeProvider.isContractDeployed(safeAddress)
return isSafeDeployed
}
@@ -326,7 +336,9 @@ class Safe {
return Promise.resolve(0)
}
- return this.#contractManager.safeContract.getNonce()
+ const nonce = await this.#contractManager.safeContract.getNonce()
+
+ return Number(nonce)
}
/**
@@ -348,7 +360,7 @@ class Safe {
* @returns The chainId of the connected network
*/
async getChainId(): Promise {
- return this.#ethAdapter.getChainId()
+ return this.#safeProvider.getChainId()
}
/**
@@ -357,7 +369,7 @@ class Safe {
* @returns The ETH balance of the Safe
*/
async getBalance(): Promise {
- return this.#ethAdapter.getBalance(await this.getAddress())
+ return this.#safeProvider.getBalance(await this.getAddress())
}
/**
@@ -395,7 +407,7 @@ class Safe {
* @param pageSize - The size of the page. It will be the max length of the returning array. Must be greater then 0.
* @returns The list of addresses of all the enabled Safe modules
*/
- async getModulesPaginated(start: string, pageSize: number = 10): Promise {
+ async getModulesPaginated(start: string, pageSize: number = 10): Promise {
return this.#moduleManager.getModulesPaginated(start, pageSize)
}
@@ -474,7 +486,7 @@ class Safe {
return new EthSafeTransaction(
await standardizeSafeTransactionData({
predictedSafe: this.#predictedSafe,
- ethAdapter: this.#ethAdapter,
+ provider: this.#safeProvider.provider,
tx: newTransaction,
contractNetworks: this.#contractManager.contractNetworks
})
@@ -487,7 +499,7 @@ class Safe {
return new EthSafeTransaction(
await standardizeSafeTransactionData({
safeContract: this.#contractManager.safeContract,
- ethAdapter: this.#ethAdapter,
+ provider: this.#safeProvider.provider,
tx: newTransaction,
contractNetworks: this.#contractManager.contractNetworks
})
@@ -559,7 +571,7 @@ class Safe {
* @returns The Safe signature
*/
async signHash(hash: string): Promise {
- const signature = await generateSignature(this.#ethAdapter, hash)
+ const signature = await generateSignature(this.#safeProvider, hash)
return signature
}
@@ -591,9 +603,9 @@ class Safe {
preimageSafeAddress?: string
): Promise {
const owners = await this.getOwners()
- const signerAddress = await this.#ethAdapter.getSignerAddress()
+ const signerAddress = await this.#safeProvider.getSignerAddress()
if (!signerAddress) {
- throw new Error('EthAdapter must be initialized with a signer to use this method')
+ throw new Error('SafeProvider must be initialized with a signer to use this method')
}
const addressIsOwner = owners.some(
@@ -673,11 +685,11 @@ class Safe {
const safeEIP712Args: SafeEIP712Args = {
safeAddress: await this.getAddress(),
safeVersion: await this.getContractVersion(),
- chainId: await this.getEthAdapter().getChainId(),
+ chainId: await this.#safeProvider.getChainId(),
data: eip712Data.data
}
- return generateEIP712Signature(this.#ethAdapter, safeEIP712Args, methodVersion)
+ return generateEIP712Signature(this.#safeProvider, safeEIP712Args, methodVersion)
}
/**
@@ -702,9 +714,10 @@ class Safe {
: safeTransaction
const owners = await this.getOwners()
- const signerAddress = await this.#ethAdapter.getSignerAddress()
+ const signerAddress = await this.#safeProvider.getSignerAddress()
+
if (!signerAddress) {
- throw new Error('EthAdapter must be initialized with a signer to use this method')
+ throw new Error('SafeProvider must be initialized with a signer to use this method')
}
const addressIsOwner = owners.some(
@@ -786,9 +799,9 @@ class Safe {
}
const owners = await this.getOwners()
- const signerAddress = await this.#ethAdapter.getSignerAddress()
+ const signerAddress = await this.#safeProvider.getSignerAddress()
if (!signerAddress) {
- throw new Error('EthAdapter must be initialized with a signer to use this method')
+ throw new Error('SafeProvider must be initialized with a signer to use this method')
}
const addressIsOwner = owners.some(
(owner: string) => signerAddress && sameString(owner, signerAddress)
@@ -796,9 +809,8 @@ class Safe {
if (!addressIsOwner) {
throw new Error('Transaction hashes can only be approved by Safe owners')
}
- if (options?.gas && options?.gasLimit) {
- throw new Error('Cannot specify gas and gasLimit together in transaction options')
- }
+
+ // TODO: fix this
return this.#contractManager.safeContract.approveHash(hash, {
from: signerAddress,
...options
@@ -819,7 +831,7 @@ class Safe {
const owners = await this.getOwners()
const ownersWhoApproved: string[] = []
for (const owner of owners) {
- const approved = await this.#contractManager.safeContract.approvedHashes(owner, txHash)
+ const [approved] = await this.#contractManager.safeContract.approvedHashes([owner, txHash])
if (approved > 0) {
ownersWhoApproved.push(owner)
}
@@ -1143,9 +1155,9 @@ class Safe {
signedSafeTransaction.addSignature(generatePreValidatedSignature(owner))
}
const owners = await this.getOwners()
- const signerAddress = await this.#ethAdapter.getSignerAddress()
+ const signerAddress = await this.#safeProvider.getSignerAddress()
if (!signerAddress) {
- throw new Error('EthAdapter must be initialized with a signer to use this method')
+ throw new Error('SafeProvider must be initialized with a signer to use this method')
}
if (owners.includes(signerAddress)) {
signedSafeTransaction.addSignature(generatePreValidatedSignature(signerAddress))
@@ -1191,7 +1203,7 @@ class Safe {
}
const owners = await this.getOwners()
const threshold = await this.getThreshold()
- const signerAddress = await this.#ethAdapter.getSignerAddress()
+ const signerAddress = await this.#safeProvider.getSignerAddress()
if (
threshold > signedSafeTransaction.signatures.size &&
signerAddress &&
@@ -1217,9 +1229,6 @@ class Safe {
}
}
- if (options?.gas && options?.gasLimit) {
- throw new Error('Cannot specify gas and gasLimit together in transaction options')
- }
const txResponse = await this.#contractManager.safeContract.execTransaction(
signedSafeTransaction,
{
@@ -1244,14 +1253,14 @@ class Safe {
const customContracts = this.#contractManager.contractNetworks?.[chainId.toString()]
const isL1SafeSingleton = this.#contractManager.isL1SafeSingleton
- const safeSingletonContract = await getSafeContract({
- ethAdapter: this.#ethAdapter,
- safeVersion: safeVersion,
+ const safeSingletonContract = await this.#safeProvider.getSafeContract({
+ safeVersion,
isL1SafeSingleton,
- customContracts
+ customContractAbi: customContracts?.safeSingletonAbi,
+ customContractAddress: customContracts?.safeSingletonAddress
})
- const encodedTransaction: string = safeSingletonContract.encode('execTransaction', [
+ const encodedTransaction = safeSingletonContract.encode('execTransaction', [
safeTransaction.data.to,
safeTransaction.data.value,
safeTransaction.data.data,
@@ -1262,7 +1271,7 @@ class Safe {
safeTransaction.data.gasToken,
safeTransaction.data.refundReceiver,
safeTransaction.encodedSignatures()
- ]) as string
+ ])
return encodedTransaction
}
@@ -1345,28 +1354,28 @@ class Safe {
const { safeAccountConfig, safeDeploymentConfig } = this.#predictedSafe
const safeVersion = await this.getContractVersion()
- const ethAdapter = this.#ethAdapter
- const chainId = await ethAdapter.getChainId()
+ const safeProvider = this.#safeProvider
+ const chainId = await safeProvider.getChainId()
const isL1SafeSingleton = this.#contractManager.isL1SafeSingleton
const customContracts = this.#contractManager.contractNetworks?.[chainId.toString()]
- const safeSingletonContract = await getSafeContract({
- ethAdapter: this.#ethAdapter,
+ const safeSingletonContract = await safeProvider.getSafeContract({
safeVersion,
isL1SafeSingleton,
- customContracts
+ customContractAddress: customContracts?.safeSingletonAddress,
+ customContractAbi: customContracts?.safeSingletonAbi
})
// we use the SafeProxyFactory.sol contract, see: https://github.com/safe-global/safe-contracts/blob/main/contracts/proxies/SafeProxyFactory.sol
const safeProxyFactoryContract = await getProxyFactoryContract({
- ethAdapter,
+ safeProvider,
safeVersion,
customContracts
})
// this is the call to the setup method that sets the threshold & owners of the new Safe, see: https://github.com/safe-global/safe-contracts/blob/main/contracts/Safe.sol#L95
const initializer = await encodeSetupCallData({
- ethAdapter,
+ safeProvider,
safeContract: safeSingletonContract,
safeAccountConfig: safeAccountConfig,
customContracts
@@ -1385,7 +1394,7 @@ class Safe {
data: safeProxyFactoryContract.encode('createProxyWithNonce', [
await safeSingletonContract.getAddress(),
initializer, // call to the setup method to set the threshold & owners of the new Safe
- saltNonce
+ BigInt(saltNonce)
])
}
@@ -1407,11 +1416,11 @@ class Safe {
transactions: MetaTransactionData[],
transactionOptions?: TransactionOptions
): Promise {
- const chainId = await this.#ethAdapter.getChainId()
+ const chainId = await this.#safeProvider.getChainId()
// we use the MultiSend contract to create the batch, see: https://github.com/safe-global/safe-contracts/blob/main/contracts/libraries/MultiSendCallOnly.sol
const multiSendCallOnlyContract = await getMultiSendCallOnlyContract({
- ethAdapter: this.#ethAdapter,
+ safeProvider: this.#safeProvider,
safeVersion: await this.getContractVersion(),
customContracts: this.#contractManager.contractNetworks?.[chainId.toString()]
})
@@ -1436,17 +1445,17 @@ class Safe {
*
* @returns The fallback Handler contract
*/
- private async getFallbackHandlerContract(): Promise {
+ async #getFallbackHandlerContract(): Promise {
if (!this.#contractManager.safeContract) {
throw new Error('Safe is not deployed')
}
const safeVersion =
(await this.#contractManager.safeContract.getVersion()) ?? DEFAULT_SAFE_VERSION
- const chainId = await this.#ethAdapter.getChainId()
+ const chainId = await this.#safeProvider.getChainId()
const compatibilityFallbackHandlerContract = await getCompatibilityFallbackHandlerContract({
- ethAdapter: this.#ethAdapter,
+ safeProvider: this.#safeProvider,
safeVersion,
customContracts: this.#contractManager.contractNetworks?.[chainId.toString()]
})
@@ -1485,16 +1494,18 @@ class Safe {
signature: SafeSignature[] | string = '0x'
): Promise => {
const safeAddress = await this.getAddress()
- const fallbackHandler = await this.getFallbackHandlerContract()
+ const fallbackHandler = await this.#getFallbackHandlerContract()
const signatureToCheck =
signature && Array.isArray(signature) ? buildSignatureBytes(signature) : signature
+ // @ts-expect-error Argument of type isValidSignature(bytes32,bytes) is not assignable to parameter of type isValidSignature
const data = fallbackHandler.encode('isValidSignature(bytes32,bytes)', [
messageHash,
signatureToCheck
])
+ // @ts-expect-error Argument of type isValidSignature(bytes32,bytes) is not assignable to parameter of type isValidSignature
const bytesData = fallbackHandler.encode('isValidSignature(bytes,bytes)', [
messageHash,
signatureToCheck
@@ -1502,12 +1513,12 @@ class Safe {
try {
const isValidSignatureResponse = await Promise.all([
- this.#ethAdapter.call({
+ this.#safeProvider.call({
from: safeAddress,
to: safeAddress,
data: data
}),
- this.#ethAdapter.call({
+ this.#safeProvider.call({
from: safeAddress,
to: safeAddress,
data: bytesData
diff --git a/packages/protocol-kit/src/safeFactory/index.ts b/packages/protocol-kit/src/SafeFactory.ts
similarity index 58%
rename from packages/protocol-kit/src/safeFactory/index.ts
rename to packages/protocol-kit/src/SafeFactory.ts
index e81ccdcaa..180170e4f 100644
--- a/packages/protocol-kit/src/safeFactory/index.ts
+++ b/packages/protocol-kit/src/SafeFactory.ts
@@ -14,91 +14,75 @@ import {
import {
ContractNetworksConfig,
SafeAccountConfig,
- SafeDeploymentConfig
+ SafeContractImplementationType,
+ SafeDeploymentConfig,
+ SafeProxyFactoryContractImplementationType,
+ SafeProviderConfig,
+ SafeFactoryConfig,
+ SafeFactoryInitConfig,
+ DeploySafeProps
} from '@safe-global/protocol-kit/types'
-import {
- EthAdapter,
- SafeContract,
- SafeProxyFactoryContract,
- SafeVersion,
- TransactionOptions
-} from '@safe-global/safe-core-sdk-types'
-
-export interface DeploySafeProps {
- safeAccountConfig: SafeAccountConfig
- saltNonce?: string
- options?: TransactionOptions
- callback?: (txHash: string) => void
-}
-
-export interface SafeFactoryConfig {
- /** ethAdapter - Ethereum adapter */
- ethAdapter: EthAdapter
- /** safeVersion - Versions of the Safe deployed by this Factory contract */
- safeVersion?: SafeVersion
- /** isL1SafeSingleton - Forces to use the Safe L1 version of the contract instead of the L2 version */
- isL1SafeSingleton?: boolean
- /** contractNetworks - Contract network configuration */
- contractNetworks?: ContractNetworksConfig
-}
-
-interface SafeFactoryInitConfig {
- /** ethAdapter - Ethereum adapter */
- ethAdapter: EthAdapter
- /** safeVersion - Versions of the Safe deployed by this Factory contract */
- safeVersion: SafeVersion
- /** isL1SafeSingleton - Forces to use the Safe L1 version of the contract instead of the L2 version */
- isL1SafeSingleton?: boolean
- /** contractNetworks - Contract network configuration */
- contractNetworks?: ContractNetworksConfig
-}
+import { SafeVersion } from '@safe-global/safe-core-sdk-types'
+import SafeProvider from '@safe-global/protocol-kit/SafeProvider'
class SafeFactory {
#contractNetworks?: ContractNetworksConfig
#isL1SafeSingleton?: boolean
#safeVersion!: SafeVersion
- #ethAdapter!: EthAdapter
- #safeProxyFactoryContract!: SafeProxyFactoryContract
- #safeContract!: SafeContract
-
- static async create({
- ethAdapter,
+ #safeProxyFactoryContract!: SafeProxyFactoryContractImplementationType
+ #safeContract!: SafeContractImplementationType
+ #provider!: SafeProviderConfig['provider']
+ #signer?: SafeFactoryConfig['signer']
+ #safeProvider!: SafeProvider
+
+ static async init({
+ provider,
+ signer,
safeVersion = DEFAULT_SAFE_VERSION,
isL1SafeSingleton = false,
contractNetworks
}: SafeFactoryConfig): Promise {
const safeFactorySdk = new SafeFactory()
- await safeFactorySdk.init({ ethAdapter, safeVersion, isL1SafeSingleton, contractNetworks })
+ await safeFactorySdk.#initializeSafeFactory({
+ provider,
+ signer,
+ safeVersion,
+ isL1SafeSingleton,
+ contractNetworks
+ })
return safeFactorySdk
}
- private async init({
- ethAdapter,
+ async #initializeSafeFactory({
+ provider,
+ signer,
safeVersion,
isL1SafeSingleton,
contractNetworks
- }: SafeFactoryInitConfig): Promise {
- this.#ethAdapter = ethAdapter
+ }: SafeFactoryInitConfig) {
+ this.#provider = provider
+ this.#signer = signer
+ this.#safeProvider = new SafeProvider({ provider, signer })
this.#safeVersion = safeVersion
this.#isL1SafeSingleton = isL1SafeSingleton
this.#contractNetworks = contractNetworks
- const chainId = await this.#ethAdapter.getChainId()
+ const chainId = await this.#safeProvider.getChainId()
const customContracts = contractNetworks?.[chainId.toString()]
this.#safeProxyFactoryContract = await getProxyFactoryContract({
- ethAdapter,
+ safeProvider: this.#safeProvider,
safeVersion,
customContracts
})
this.#safeContract = await getSafeContract({
- ethAdapter,
+ safeProvider: this.#safeProvider,
safeVersion,
isL1SafeSingleton,
customContracts
})
}
- getEthAdapter(): EthAdapter {
- return this.#ethAdapter
+ getSafeProvider(): SafeProvider {
+ return this.#safeProvider
}
getSafeVersion(): SafeVersion {
@@ -110,14 +94,14 @@ class SafeFactory {
}
async getChainId(): Promise {
- return this.#ethAdapter.getChainId()
+ return this.#safeProvider.getChainId()
}
async predictSafeAddress(
safeAccountConfig: SafeAccountConfig,
saltNonce?: string
): Promise {
- const chainId = await this.#ethAdapter.getChainId()
+ const chainId = await this.#safeProvider.getChainId()
const customContracts = this.#contractNetworks?.[chainId.toString()]
const safeVersion = this.#safeVersion
@@ -127,7 +111,7 @@ class SafeFactory {
}
return predictSafeAddress({
- ethAdapter: this.#ethAdapter,
+ safeProvider: this.#safeProvider,
chainId,
safeAccountConfig,
safeDeploymentConfig,
@@ -145,24 +129,21 @@ class SafeFactory {
validateSafeAccountConfig(safeAccountConfig)
validateSafeDeploymentConfig({ saltNonce })
- const signerAddress = await this.#ethAdapter.getSignerAddress()
+ const signerAddress = await this.#safeProvider.getSignerAddress()
if (!signerAddress) {
- throw new Error('EthAdapter must be initialized with a signer to use this method')
+ throw new Error('SafeProvider must be initialized with a signer to use this method')
}
const chainId = await this.getChainId()
const customContracts = this.#contractNetworks?.[chainId.toString()]
const initializer = await encodeSetupCallData({
- ethAdapter: this.#ethAdapter,
+ safeProvider: this.#safeProvider,
safeAccountConfig,
safeContract: this.#safeContract,
customContracts
})
- if (options?.gas && options?.gasLimit) {
- throw new Error('Cannot specify gas and gasLimit together in transaction options')
- }
- const safeAddress = await this.#safeProxyFactoryContract.createProxy({
+ const safeAddress = await this.#safeProxyFactoryContract.createProxyWithOptions({
safeSingletonAddress: await this.#safeContract.getAddress(),
initializer,
saltNonce: saltNonce || getChainSpecificDefaultSaltNonce(chainId),
@@ -172,12 +153,13 @@ class SafeFactory {
},
callback
})
- const isContractDeployed = await this.#ethAdapter.isContractDeployed(safeAddress)
+ const isContractDeployed = await this.#safeProvider.isContractDeployed(safeAddress)
if (!isContractDeployed) {
throw new Error('SafeProxy contract is not deployed on the current network')
}
- const safe = await Safe.create({
- ethAdapter: this.#ethAdapter,
+ const safe = await Safe.init({
+ provider: this.#provider,
+ signer: this.#signer,
safeAddress,
isL1SafeSingleton: this.#isL1SafeSingleton,
contractNetworks: this.#contractNetworks
diff --git a/packages/protocol-kit/src/SafeProvider.ts b/packages/protocol-kit/src/SafeProvider.ts
new file mode 100644
index 000000000..7b79fde1d
--- /dev/null
+++ b/packages/protocol-kit/src/SafeProvider.ts
@@ -0,0 +1,280 @@
+import {
+ ethers,
+ TransactionResponse,
+ AbstractSigner,
+ Provider,
+ BrowserProvider,
+ JsonRpcProvider
+} from 'ethers'
+import { generateTypedData, validateEip3770Address } from '@safe-global/protocol-kit/utils'
+import { isTypedDataSigner } from '@safe-global/protocol-kit/contracts/utils'
+import { EMPTY_DATA } from '@safe-global/protocol-kit/utils/constants'
+
+import {
+ EIP712TypedDataMessage,
+ EIP712TypedDataTx,
+ Eip3770Address,
+ SafeEIP712Args
+} from '@safe-global/safe-core-sdk-types'
+import {
+ getCompatibilityFallbackHandlerContractInstance,
+ getCreateCallContractInstance,
+ getMultiSendCallOnlyContractInstance,
+ getMultiSendContractInstance,
+ getSafeContractInstance,
+ getSafeProxyFactoryContractInstance,
+ getSignMessageLibContractInstance,
+ getSimulateTxAccessorContractInstance
+} from './contracts/contractInstances'
+import {
+ SafeProviderTransaction,
+ GetContractProps,
+ SafeProviderConfig,
+ Eip1193Provider,
+ HttpTransport,
+ SocketTransport
+} from '@safe-global/protocol-kit/types'
+
+class SafeProvider {
+ #externalProvider: BrowserProvider | JsonRpcProvider
+ signer?: string
+ provider: Eip1193Provider | HttpTransport | SocketTransport
+
+ constructor({ provider, signer }: SafeProviderConfig) {
+ if (typeof provider === 'string') {
+ this.#externalProvider = new JsonRpcProvider(provider)
+ } else {
+ this.#externalProvider = new BrowserProvider(provider)
+ }
+
+ this.provider = provider
+ this.signer = signer
+ }
+
+ getExternalProvider(): Provider {
+ return this.#externalProvider
+ }
+
+ async getExternalSigner(): Promise {
+ // If the signer is not an Ethereum address, it should be a private key
+ if (this.signer && !ethers.isAddress(this.signer)) {
+ const privateKeySigner = new ethers.Wallet(this.signer, this.#externalProvider)
+ return privateKeySigner
+ }
+
+ if (this.signer) {
+ return this.#externalProvider.getSigner(this.signer)
+ }
+
+ if (this.#externalProvider instanceof BrowserProvider) {
+ return this.#externalProvider.getSigner()
+ }
+
+ return undefined
+ }
+
+ isAddress(address: string): boolean {
+ return ethers.isAddress(address)
+ }
+
+ async getEip3770Address(fullAddress: string): Promise {
+ const chainId = await this.getChainId()
+ return validateEip3770Address(fullAddress, chainId)
+ }
+
+ async getBalance(address: string, blockTag?: string | number): Promise {
+ return this.#externalProvider.getBalance(address, blockTag)
+ }
+
+ async getNonce(address: string, blockTag?: string | number): Promise {
+ return this.#externalProvider.getTransactionCount(address, blockTag)
+ }
+
+ async getChainId(): Promise {
+ return (await this.#externalProvider.getNetwork()).chainId
+ }
+
+ getChecksummedAddress(address: string): string {
+ return ethers.getAddress(address)
+ }
+
+ async getSafeContract({
+ safeVersion,
+ customContractAddress,
+ customContractAbi,
+ isL1SafeSingleton
+ }: GetContractProps) {
+ return getSafeContractInstance(
+ safeVersion,
+ this,
+ customContractAddress,
+ customContractAbi,
+ isL1SafeSingleton
+ )
+ }
+
+ async getSafeProxyFactoryContract({
+ safeVersion,
+ customContractAddress,
+ customContractAbi
+ }: GetContractProps) {
+ const signerOrProvider = (await this.getExternalSigner()) || this.#externalProvider
+ return getSafeProxyFactoryContractInstance(
+ safeVersion,
+ this,
+ signerOrProvider,
+ customContractAddress,
+ customContractAbi
+ )
+ }
+
+ async getMultiSendContract({
+ safeVersion,
+ customContractAddress,
+ customContractAbi
+ }: GetContractProps) {
+ return getMultiSendContractInstance(safeVersion, this, customContractAddress, customContractAbi)
+ }
+
+ async getMultiSendCallOnlyContract({
+ safeVersion,
+ customContractAddress,
+ customContractAbi
+ }: GetContractProps) {
+ return getMultiSendCallOnlyContractInstance(
+ safeVersion,
+ this,
+ customContractAddress,
+ customContractAbi
+ )
+ }
+
+ async getCompatibilityFallbackHandlerContract({
+ safeVersion,
+ customContractAddress,
+ customContractAbi
+ }: GetContractProps) {
+ return getCompatibilityFallbackHandlerContractInstance(
+ safeVersion,
+ this,
+ customContractAddress,
+ customContractAbi
+ )
+ }
+
+ async getSignMessageLibContract({
+ safeVersion,
+ customContractAddress,
+ customContractAbi
+ }: GetContractProps) {
+ return getSignMessageLibContractInstance(
+ safeVersion,
+ this,
+ customContractAddress,
+ customContractAbi
+ )
+ }
+
+ async getCreateCallContract({
+ safeVersion,
+ customContractAddress,
+ customContractAbi
+ }: GetContractProps) {
+ return getCreateCallContractInstance(
+ safeVersion,
+ this,
+ customContractAddress,
+ customContractAbi
+ )
+ }
+
+ async getSimulateTxAccessorContract({
+ safeVersion,
+ customContractAddress,
+ customContractAbi
+ }: GetContractProps) {
+ return getSimulateTxAccessorContractInstance(
+ safeVersion,
+ this,
+ customContractAddress,
+ customContractAbi
+ )
+ }
+
+ async getContractCode(address: string, blockTag?: string | number): Promise {
+ return this.#externalProvider.getCode(address, blockTag)
+ }
+
+ async isContractDeployed(address: string, blockTag?: string | number): Promise {
+ const contractCode = await this.#externalProvider.getCode(address, blockTag)
+ return contractCode !== EMPTY_DATA
+ }
+
+ async getStorageAt(address: string, position: string): Promise {
+ const content = await this.#externalProvider.getStorage(address, position)
+ const decodedContent = this.decodeParameters(['address'], content)
+ return decodedContent[0]
+ }
+
+ async getTransaction(transactionHash: string): Promise {
+ return this.#externalProvider.getTransaction(transactionHash) as Promise
+ }
+
+ async getSignerAddress(): Promise {
+ const signer = await this.getExternalSigner()
+
+ return signer?.getAddress()
+ }
+
+ async signMessage(message: string): Promise {
+ const signer = await this.getExternalSigner()
+
+ if (!signer) {
+ throw new Error('SafeProvider must be initialized with a signer to use this method')
+ }
+ const messageArray = ethers.getBytes(message)
+
+ return signer.signMessage(messageArray)
+ }
+
+ async signTypedData(safeEIP712Args: SafeEIP712Args): Promise {
+ const signer = await this.getExternalSigner()
+
+ if (!signer) {
+ throw new Error('SafeProvider must be initialized with a signer to use this method')
+ }
+
+ if (isTypedDataSigner(signer)) {
+ const typedData = generateTypedData(safeEIP712Args)
+ const signature = await signer.signTypedData(
+ typedData.domain,
+ typedData.primaryType === 'SafeMessage'
+ ? { SafeMessage: (typedData as EIP712TypedDataMessage).types.SafeMessage }
+ : { SafeTx: (typedData as EIP712TypedDataTx).types.SafeTx },
+ typedData.message
+ )
+ return signature
+ }
+
+ throw new Error('The current signer does not implement EIP-712 to sign typed data')
+ }
+
+ async estimateGas(transaction: SafeProviderTransaction): Promise {
+ return (await this.#externalProvider.estimateGas(transaction)).toString()
+ }
+
+ call(transaction: SafeProviderTransaction, blockTag?: string | number): Promise {
+ return this.#externalProvider.call({ ...transaction, blockTag })
+ }
+
+ // TODO: fix anys
+ encodeParameters(types: string[], values: any[]): string {
+ return new ethers.AbiCoder().encode(types, values)
+ }
+
+ decodeParameters(types: string[], values: string): { [key: string]: any } {
+ return new ethers.AbiCoder().decode(types, values)
+ }
+}
+
+export default SafeProvider
diff --git a/packages/protocol-kit/src/adapters/ethers/EthersAdapter.ts b/packages/protocol-kit/src/adapters/ethers/EthersAdapter.ts
deleted file mode 100644
index 1c4d5c79e..000000000
--- a/packages/protocol-kit/src/adapters/ethers/EthersAdapter.ts
+++ /dev/null
@@ -1,288 +0,0 @@
-import { generateTypedData, validateEip3770Address } from '@safe-global/protocol-kit/utils'
-import {
- EIP712TypedDataMessage,
- EIP712TypedDataTx,
- Eip3770Address,
- EthAdapter,
- EthAdapterTransaction,
- GetContractProps,
- SafeEIP712Args
-} from '@safe-global/safe-core-sdk-types'
-import { ethers, TransactionResponse, AbstractSigner, Provider } from 'ethers'
-import CompatibilityFallbackHandlerContractEthers from './contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerEthersContract'
-import CreateCallEthersContract from './contracts/CreateCall/CreateCallEthersContract'
-import MultiSendEthersContract from './contracts/MultiSend/MultiSendEthersContract'
-import MultiSendCallOnlyEthersContract from './contracts/MultiSendCallOnly/MultiSendCallOnlyEthersContract'
-import SafeContractEthers from './contracts/Safe/SafeContractEthers'
-import SafeProxyFactoryEthersContract from './contracts/SafeProxyFactory/SafeProxyFactoryEthersContract'
-import SignMessageLibEthersContract from './contracts/SignMessageLib/SignMessageLibEthersContract'
-import SimulateTxAccessorEthersContract from './contracts/SimulateTxAccessor/SimulateTxAccessorEthersContract'
-import {
- getCompatibilityFallbackHandlerContractInstance,
- getCreateCallContractInstance,
- getMultiSendCallOnlyContractInstance,
- getMultiSendContractInstance,
- getSafeContractInstance,
- getSafeProxyFactoryContractInstance,
- getSignMessageLibContractInstance,
- getSimulateTxAccessorContractInstance
-} from './contracts/contractInstancesEthers'
-import { isTypedDataSigner, isSignerCompatible } from './utils'
-
-type Ethers = typeof ethers
-
-export interface EthersAdapterConfig {
- /** ethers - Ethers v6 library */
- ethers: Ethers
- /** signerOrProvider - Ethers signer or provider */
- signerOrProvider: AbstractSigner | Provider
-}
-
-class EthersAdapter implements EthAdapter {
- #ethers: Ethers
- #signer?: AbstractSigner
- #provider: Provider
-
- constructor({ ethers, signerOrProvider }: EthersAdapterConfig) {
- if (!ethers) {
- throw new Error('ethers property missing from options')
- }
- this.#ethers = ethers
- const isSigner = isSignerCompatible(signerOrProvider)
- if (isSigner) {
- const signer = signerOrProvider as AbstractSigner
- if (!signer.provider) {
- throw new Error('Signer must be connected to a provider')
- }
- this.#provider = signer.provider
- this.#signer = signer
- } else {
- this.#provider = signerOrProvider as Provider
- }
- }
-
- getProvider(): Provider {
- return this.#provider
- }
-
- getSigner(): AbstractSigner | undefined {
- return this.#signer
- }
-
- isAddress(address: string): boolean {
- return this.#ethers.isAddress(address)
- }
-
- async getEip3770Address(fullAddress: string): Promise {
- const chainId = await this.getChainId()
- return validateEip3770Address(fullAddress, chainId)
- }
-
- async getBalance(address: string, blockTag?: string | number): Promise {
- return this.#provider.getBalance(address, blockTag)
- }
-
- async getNonce(address: string, blockTag?: string | number): Promise {
- return this.#provider.getTransactionCount(address, blockTag)
- }
-
- async getChainId(): Promise {
- return (await this.#provider.getNetwork()).chainId
- }
-
- getChecksummedAddress(address: string): string {
- return this.#ethers.getAddress(address)
- }
-
- async getSafeContract({
- safeVersion,
- singletonDeployment,
- customContractAddress
- }: GetContractProps): Promise {
- const chainId = await this.getChainId()
- const contractAddress =
- customContractAddress ?? singletonDeployment?.networkAddresses[chainId.toString()]
- if (!contractAddress) {
- throw new Error('Invalid SafeProxy contract address')
- }
- const signerOrProvider = this.#signer || this.#provider
- return getSafeContractInstance(safeVersion, contractAddress, signerOrProvider)
- }
-
- async getSafeProxyFactoryContract({
- safeVersion,
- singletonDeployment,
- customContractAddress
- }: GetContractProps): Promise {
- const chainId = await this.getChainId()
- const contractAddress =
- customContractAddress ?? singletonDeployment?.networkAddresses[chainId.toString()]
- if (!contractAddress) {
- throw new Error('Invalid SafeProxyFactory contract address')
- }
- const signerOrProvider = this.#signer || this.#provider
- return getSafeProxyFactoryContractInstance(safeVersion, contractAddress, signerOrProvider)
- }
-
- async getMultiSendContract({
- safeVersion,
- singletonDeployment,
- customContractAddress
- }: GetContractProps): Promise {
- const chainId = await this.getChainId()
- const contractAddress =
- customContractAddress ?? singletonDeployment?.networkAddresses[chainId.toString()]
- if (!contractAddress) {
- throw new Error('Invalid MultiSend contract address')
- }
- const signerOrProvider = this.#signer || this.#provider
- return getMultiSendContractInstance(safeVersion, contractAddress, signerOrProvider)
- }
-
- async getMultiSendCallOnlyContract({
- safeVersion,
- singletonDeployment,
- customContractAddress
- }: GetContractProps): Promise {
- const chainId = await this.getChainId()
- const contractAddress =
- customContractAddress ?? singletonDeployment?.networkAddresses[chainId.toString()]
- if (!contractAddress) {
- throw new Error('Invalid MultiSendCallOnly contract address')
- }
- const signerOrProvider = this.#signer || this.#provider
- return getMultiSendCallOnlyContractInstance(safeVersion, contractAddress, signerOrProvider)
- }
-
- async getCompatibilityFallbackHandlerContract({
- safeVersion,
- singletonDeployment,
- customContractAddress
- }: GetContractProps): Promise {
- const chainId = await this.getChainId()
- const contractAddress =
- customContractAddress ?? singletonDeployment?.networkAddresses[chainId.toString()]
- if (!contractAddress) {
- throw new Error('Invalid CompatibilityFallbackHandler contract address')
- }
- const signerOrProvider = this.#signer || this.#provider
- return getCompatibilityFallbackHandlerContractInstance(
- safeVersion,
- contractAddress,
- signerOrProvider
- )
- }
-
- async getSignMessageLibContract({
- safeVersion,
- singletonDeployment,
- customContractAddress
- }: GetContractProps): Promise {
- const chainId = await this.getChainId()
- const contractAddress =
- customContractAddress ?? singletonDeployment?.networkAddresses[chainId.toString()]
- if (!contractAddress) {
- throw new Error('Invalid SignMessageLib contract address')
- }
- const signerOrProvider = this.#signer || this.#provider
- return getSignMessageLibContractInstance(safeVersion, contractAddress, signerOrProvider)
- }
-
- async getCreateCallContract({
- safeVersion,
- singletonDeployment,
- customContractAddress
- }: GetContractProps): Promise {
- const chainId = await this.getChainId()
- const contractAddress =
- customContractAddress ?? singletonDeployment?.networkAddresses[chainId.toString()]
- if (!contractAddress) {
- throw new Error('Invalid CreateCall contract address')
- }
- const signerOrProvider = this.#signer || this.#provider
- return getCreateCallContractInstance(safeVersion, contractAddress, signerOrProvider)
- }
-
- async getSimulateTxAccessorContract({
- safeVersion,
- singletonDeployment,
- customContractAddress
- }: GetContractProps): Promise {
- const chainId = await this.getChainId()
- const contractAddress =
- customContractAddress ?? singletonDeployment?.networkAddresses[chainId.toString()]
- if (!contractAddress) {
- throw new Error('Invalid SimulateTxAccessor contract address')
- }
- const signerOrProvider = this.#signer || this.#provider
- return getSimulateTxAccessorContractInstance(safeVersion, contractAddress, signerOrProvider)
- }
-
- async getContractCode(address: string, blockTag?: string | number): Promise {
- return this.#provider.getCode(address, blockTag)
- }
-
- async isContractDeployed(address: string, blockTag?: string | number): Promise {
- const contractCode = await this.#provider.getCode(address, blockTag)
- return contractCode !== '0x'
- }
-
- async getStorageAt(address: string, position: string): Promise {
- const content = await this.#provider.getStorage(address, position)
- const decodedContent = this.decodeParameters(['address'], content)
- return decodedContent[0]
- }
-
- async getTransaction(transactionHash: string): Promise {
- return this.#provider.getTransaction(transactionHash) as Promise
- }
-
- async getSignerAddress(): Promise {
- return this.#signer?.getAddress()
- }
-
- signMessage(message: string): Promise {
- if (!this.#signer) {
- throw new Error('EthAdapter must be initialized with a signer to use this method')
- }
- const messageArray = this.#ethers.getBytes(message)
- return this.#signer.signMessage(messageArray)
- }
-
- async signTypedData(safeEIP712Args: SafeEIP712Args): Promise {
- if (!this.#signer) {
- throw new Error('EthAdapter must be initialized with a signer to use this method')
- }
- if (isTypedDataSigner(this.#signer)) {
- const typedData = generateTypedData(safeEIP712Args)
- const signature = await this.#signer.signTypedData(
- typedData.domain,
- typedData.primaryType === 'SafeMessage'
- ? { SafeMessage: (typedData as EIP712TypedDataMessage).types.SafeMessage }
- : { SafeTx: (typedData as EIP712TypedDataTx).types.SafeTx },
- typedData.message
- )
- return signature
- }
-
- throw new Error('The current signer does not implement EIP-712 to sign typed data')
- }
-
- async estimateGas(transaction: EthAdapterTransaction): Promise {
- return (await this.#provider.estimateGas(transaction)).toString()
- }
-
- call(transaction: EthAdapterTransaction, blockTag?: string | number): Promise {
- return this.#provider.call({ ...transaction, blockTag })
- }
-
- encodeParameters(types: string[], values: any[]): string {
- return new this.#ethers.AbiCoder().encode(types, values)
- }
-
- decodeParameters(types: string[], values: string): { [key: string]: any } {
- return new this.#ethers.AbiCoder().decode(types, values)
- }
-}
-
-export default EthersAdapter
diff --git a/packages/protocol-kit/src/adapters/ethers/README.md b/packages/protocol-kit/src/adapters/ethers/README.md
deleted file mode 100644
index d8313d943..000000000
--- a/packages/protocol-kit/src/adapters/ethers/README.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# Ethers Adapter
-
-Ethers.js wrapper that contains some utilities and the Safe contracts types (generated with `typechain` `ethers-v6`). It is used to initialize the [Protocol Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/protocol-kit).
-
-## How to use
-
-If the app integrating the SDK is using `ethers`, create an instance of the `EthersAdapter`, where `signer` is the Ethereum account we are connecting and the one who will sign the transactions.
-
-> :warning: **NOTE**: Currently only `ethers` `v6` is supported.
-
-```js
-import { ethers } from 'ethers'
-import { EthersAdapter } from '@safe-global/protocol-kit'
-
-const web3Provider = // ...
-const provider = new ethers.BrowserProvider(web3Provider)
-const safeOwner = provider.getSigner(0)
-
-const ethAdapter = new EthersAdapter({
- ethers,
- signerOrProvider: safeOwner
-})
-```
-
-Depending on whether the `ethAdapter` instance is used to sign/execute transactions or just call read-only methods, the `signerOrProvider` property can be a `Signer` or a `Provider`.
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerEthersContract.ts b/packages/protocol-kit/src/adapters/ethers/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerEthersContract.ts
deleted file mode 100644
index 8046de1ea..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerEthersContract.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import {
- Compatibility_fallback_handler as CompatibilityFallbackHandler_V1_3_0,
- Compatibility_fallback_handlerInterface as CompatibilityFallbackHandlerInterface
-} from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/Compatibility_fallback_handler'
-import { Compatibility_fallback_handler as CompatibilityFallbackHandler_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/Compatibility_fallback_handler'
-import { CompatibilityFallbackHandlerContract } from '@safe-global/safe-core-sdk-types'
-
-abstract class CompatibilityFallbackHandlerEthersContract
- implements CompatibilityFallbackHandlerContract
-{
- constructor(
- public contract: CompatibilityFallbackHandler_V1_4_1 | CompatibilityFallbackHandler_V1_3_0
- ) {}
-
- getAddress(): Promise {
- return this.contract.getAddress()
- }
-
- encode: CompatibilityFallbackHandlerInterface['encodeFunctionData'] = (
- methodName: any,
- params: any
- ): string => {
- return this.contract.interface.encodeFunctionData(methodName, params)
- }
-}
-
-export default CompatibilityFallbackHandlerEthersContract
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandler_V1_3_0_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandler_V1_3_0_Ethers.ts
deleted file mode 100644
index 77d36778e..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandler_V1_3_0_Ethers.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Compatibility_fallback_handler as CompatibilityFallbackHandler } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/Compatibility_fallback_handler'
-import CompatibilityFallbackHandlerEthersContract from '../CompatibilityFallbackHandlerEthersContract'
-
-class CompatibilityFallbackHandler_V1_3_0_Ethers extends CompatibilityFallbackHandlerEthersContract {
- constructor(public contract: CompatibilityFallbackHandler) {
- super(contract)
- }
-}
-
-export default CompatibilityFallbackHandler_V1_3_0_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandler_V1_4_1_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandler_V1_4_1_Ethers.ts
deleted file mode 100644
index 0a1e9d9ae..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandler_V1_4_1_Ethers.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Compatibility_fallback_handler as CompatibilityFallbackHandler } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/Compatibility_fallback_handler'
-import CompatibilityFallbackHandlerEthersContract from '../CompatibilityFallbackHandlerEthersContract'
-
-class CompatibilityFallbackHandler_V1_4_1_Ethers extends CompatibilityFallbackHandlerEthersContract {
- constructor(public contract: CompatibilityFallbackHandler) {
- super(contract)
- }
-}
-
-export default CompatibilityFallbackHandler_V1_4_1_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/CreateCallEthersContract.ts b/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/CreateCallEthersContract.ts
deleted file mode 100644
index 78aac08c3..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/CreateCallEthersContract.ts
+++ /dev/null
@@ -1,67 +0,0 @@
-import {
- EthersTransactionOptions,
- EthersTransactionResult
-} from '@safe-global/protocol-kit/adapters/ethers/types'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils'
-import {
- Create_call as CreateCall_V1_3_0,
- Create_callInterface as CreateCallContractInterface
-} from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/Create_call'
-import { Create_call as CreateCall_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/Create_call'
-import { CreateCallContract } from '@safe-global/safe-core-sdk-types'
-
-abstract class CreateCallEthersContract implements CreateCallContract {
- constructor(public contract: CreateCall_V1_4_1 | CreateCall_V1_3_0) {}
-
- getAddress(): Promise {
- return this.contract.getAddress()
- }
-
- async performCreate2(
- value: string,
- deploymentData: string,
- salt: string,
- options?: EthersTransactionOptions
- ): Promise {
- if (options && !options.gasLimit) {
- options.gasLimit = await this.estimateGas('performCreate2', [value, deploymentData, salt], {
- ...options
- })
- }
- const txResponse = await this.contract.performCreate2(value, deploymentData, salt)
- return toTxResult(txResponse, options)
- }
-
- async performCreate(
- value: string,
- deploymentData: string,
- options?: EthersTransactionOptions
- ): Promise {
- if (options && !options.gasLimit) {
- options.gasLimit = await this.estimateGas('performCreate', [value, deploymentData], {
- ...options
- })
- }
- const txResponse = await this.contract.performCreate(value, deploymentData, { ...options })
- return toTxResult(txResponse, options)
- }
-
- encode: CreateCallContractInterface['encodeFunctionData'] = (
- methodName: any,
- params: any
- ): string => {
- return this.contract.interface.encodeFunctionData(methodName, params)
- }
-
- async estimateGas(
- methodName: string,
- params: any[],
- options: EthersTransactionOptions
- ): Promise {
- const method = this.contract.getFunction(methodName)
-
- return (await method.estimateGas(...params, options)).toString()
- }
-}
-
-export default CreateCallEthersContract
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallEthersContract_V1_3_0_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallEthersContract_V1_3_0_Ethers.ts
deleted file mode 100644
index 3f954e55b..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallEthersContract_V1_3_0_Ethers.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Create_call as CreateCall } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/Create_call'
-import CreateCallEthersContract from '../CreateCallEthersContract'
-
-class CreateCallContract_V1_3_0_Ethers extends CreateCallEthersContract {
- constructor(public contract: CreateCall) {
- super(contract)
- }
-}
-
-export default CreateCallContract_V1_3_0_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallEthersContract_V1_4_1_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallEthersContract_V1_4_1_Ethers.ts
deleted file mode 100644
index 6bad21fa7..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallEthersContract_V1_4_1_Ethers.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Create_call as CreateCall } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/Create_call'
-import CreateCallEthersContract from '../CreateCallEthersContract'
-
-class CreateCallContract_V1_4_1_Ethers extends CreateCallEthersContract {
- constructor(public contract: CreateCall) {
- super(contract)
- }
-}
-
-export default CreateCallContract_V1_4_1_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/MultiSendEthersContract.ts b/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/MultiSendEthersContract.ts
deleted file mode 100644
index 25fe02406..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/MultiSendEthersContract.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { Multi_send as MultiSend_V1_1_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.1.1/Multi_send'
-import {
- Multi_send as MultiSend_V1_3_0,
- Multi_sendInterface as MultiSendInterface
-} from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/Multi_send'
-import { Multi_send as MultiSend_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/Multi_send'
-import { MultiSendContract } from '@safe-global/safe-core-sdk-types'
-
-abstract class MultiSendEthersContract implements MultiSendContract {
- constructor(public contract: MultiSend_V1_4_1 | MultiSend_V1_3_0 | MultiSend_V1_1_1) {}
-
- getAddress(): Promise {
- return this.contract.getAddress()
- }
-
- encode: MultiSendInterface['encodeFunctionData'] = (methodName: any, params: any): string => {
- return this.contract.interface.encodeFunctionData(methodName, params)
- }
-}
-
-export default MultiSendEthersContract
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.1.1/MultiSendContract_V1_1_1_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.1.1/MultiSendContract_V1_1_1_Ethers.ts
deleted file mode 100644
index 0d47911d0..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.1.1/MultiSendContract_V1_1_1_Ethers.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Multi_send as MultiSend } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.1.1/Multi_send'
-import MultiSendEthersContract from '../MultiSendEthersContract'
-
-class MultiSendContract_V1_1_1_Ethers extends MultiSendEthersContract {
- constructor(public contract: MultiSend) {
- super(contract)
- }
-}
-
-export default MultiSendContract_V1_1_1_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.3.0/MultiSendContract_V1_3_0_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.3.0/MultiSendContract_V1_3_0_Ethers.ts
deleted file mode 100644
index 81bda33bc..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.3.0/MultiSendContract_V1_3_0_Ethers.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Multi_send as MultiSend } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/Multi_send'
-import MultiSendEthersContract from '../MultiSendEthersContract'
-
-class MultiSendContract_V1_3_0_Ethers extends MultiSendEthersContract {
- constructor(public contract: MultiSend) {
- super(contract)
- }
-}
-
-export default MultiSendContract_V1_3_0_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.4.1/MultiSendContract_V1_4_1_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.4.1/MultiSendContract_V1_4_1_Ethers.ts
deleted file mode 100644
index d7cbc028b..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.4.1/MultiSendContract_V1_4_1_Ethers.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Multi_send as MultiSend } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/Multi_send'
-import MultiSendEthersContract from '../MultiSendEthersContract'
-
-class MultiSendContract_V1_4_1_Ethers extends MultiSendEthersContract {
- constructor(public contract: MultiSend) {
- super(contract)
- }
-}
-
-export default MultiSendContract_V1_4_1_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSendCallOnly/MultiSendCallOnlyEthersContract.ts b/packages/protocol-kit/src/adapters/ethers/contracts/MultiSendCallOnly/MultiSendCallOnlyEthersContract.ts
deleted file mode 100644
index 4f5b02424..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSendCallOnly/MultiSendCallOnlyEthersContract.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import {
- Multi_send_call_only as MultiSendCallOnly_V1_3_0,
- Multi_send_call_onlyInterface as MultiSendCallOnlyInterface
-} from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/Multi_send_call_only'
-import { Multi_send_call_only as MultiSendCallOnly_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/Multi_send_call_only'
-import { MultiSendCallOnlyContract } from '@safe-global/safe-core-sdk-types'
-
-abstract class MultiSendCallOnlyEthersContract implements MultiSendCallOnlyContract {
- constructor(public contract: MultiSendCallOnly_V1_4_1 | MultiSendCallOnly_V1_3_0) {}
-
- getAddress(): Promise {
- return this.contract.getAddress()
- }
-
- encode: MultiSendCallOnlyInterface['encodeFunctionData'] = (
- methodName: any,
- params: any
- ): string => {
- return this.contract.interface.encodeFunctionData(methodName, params)
- }
-}
-
-export default MultiSendCallOnlyEthersContract
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSendCallOnly/v1.3.0/MultiSendCallOnlyContract_V1_3_0_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/MultiSendCallOnly/v1.3.0/MultiSendCallOnlyContract_V1_3_0_Ethers.ts
deleted file mode 100644
index c605dad96..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSendCallOnly/v1.3.0/MultiSendCallOnlyContract_V1_3_0_Ethers.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Multi_send_call_only as MultiSendCallOnly } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/Multi_send_call_only'
-import MultiSendCallOnlyEthersContract from '../MultiSendCallOnlyEthersContract'
-
-class MultiSendCallOnlyContract_V1_3_0_Ethers extends MultiSendCallOnlyEthersContract {
- constructor(public contract: MultiSendCallOnly) {
- super(contract)
- }
-}
-
-export default MultiSendCallOnlyContract_V1_3_0_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSendCallOnly/v1.4.1/MultiSendCallOnlyContract_V1_4_1_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/MultiSendCallOnly/v1.4.1/MultiSendCallOnlyContract_V1_4_1_Ethers.ts
deleted file mode 100644
index 6d4449696..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSendCallOnly/v1.4.1/MultiSendCallOnlyContract_V1_4_1_Ethers.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Multi_send_call_only as MultiSendCallOnly } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/Multi_send_call_only'
-import MultiSendCallOnlyEthersContract from '../MultiSendCallOnlyEthersContract'
-
-class MultiSendCallOnlyContract_V1_4_1_Ethers extends MultiSendCallOnlyEthersContract {
- constructor(public contract: MultiSendCallOnly) {
- super(contract)
- }
-}
-
-export default MultiSendCallOnlyContract_V1_4_1_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/SafeContractEthers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/Safe/SafeContractEthers.ts
deleted file mode 100644
index 718b0909c..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/SafeContractEthers.ts
+++ /dev/null
@@ -1,190 +0,0 @@
-import {
- EthersTransactionOptions,
- EthersTransactionResult
-} from '@safe-global/protocol-kit/adapters/ethers/types'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils'
-import { Gnosis_safe as Safe_V1_0_0 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.0.0/Gnosis_safe'
-import { Gnosis_safe as Safe_V1_1_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.1.1/Gnosis_safe'
-import { Gnosis_safe as Safe_V1_2_0 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.2.0/Gnosis_safe'
-import {
- Gnosis_safeInterface as SafeInterface,
- Gnosis_safe as Safe_V1_3_0
-} from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/Gnosis_safe'
-import { Safe as Safe_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/Safe'
-import {
- SafeContract,
- SafeSetupConfig,
- SafeTransaction,
- SafeTransactionData,
- SafeVersion
-} from '@safe-global/safe-core-sdk-types'
-
-abstract class SafeContractEthers implements SafeContract {
- constructor(
- public contract: Safe_V1_4_1 | Safe_V1_3_0 | Safe_V1_2_0 | Safe_V1_1_1 | Safe_V1_0_0
- ) {}
-
- abstract setup(
- setupConfig: SafeSetupConfig,
- options?: EthersTransactionOptions
- ): Promise
-
- async getVersion(): Promise {
- return (await this.contract.VERSION()) as SafeVersion
- }
-
- getAddress(): Promise {
- return this.contract.getAddress()
- }
-
- async getNonce(): Promise {
- return Number(await this.contract.nonce())
- }
-
- async getThreshold(): Promise {
- return Number(await this.contract.getThreshold())
- }
-
- async getOwners(): Promise {
- return this.contract.getOwners()
- }
-
- async isOwner(address: string): Promise {
- return this.contract.isOwner(address)
- }
-
- async getTransactionHash(safeTransactionData: SafeTransactionData): Promise {
- return this.contract.getTransactionHash(
- safeTransactionData.to,
- safeTransactionData.value,
- safeTransactionData.data,
- safeTransactionData.operation,
- safeTransactionData.safeTxGas,
- safeTransactionData.baseGas,
- safeTransactionData.gasPrice,
- safeTransactionData.gasToken,
- safeTransactionData.refundReceiver,
- safeTransactionData.nonce
- )
- }
-
- async approvedHashes(ownerAddress: string, hash: string): Promise {
- return this.contract.approvedHashes(ownerAddress, hash)
- }
-
- async approveHash(
- hash: string,
- options?: EthersTransactionOptions
- ): Promise {
- if (options && !options.gasLimit) {
- options.gasLimit = await this.estimateGas('approveHash', [hash], { ...options })
- }
- const txResponse = await this.contract.approveHash(hash, { ...options })
- return toTxResult(txResponse, options)
- }
-
- abstract getModules(): Promise
-
- abstract getModulesPaginated(start: string, pageSize: number): Promise
-
- abstract isModuleEnabled(moduleAddress: string): Promise
-
- async isValidTransaction(
- safeTransaction: SafeTransaction,
- options?: EthersTransactionOptions
- ): Promise {
- let isTxValid = false
- try {
- if (options && !options.gasLimit) {
- options.gasLimit = await this.estimateGas(
- 'execTransaction',
- [
- safeTransaction.data.to,
- safeTransaction.data.value,
- safeTransaction.data.data,
- safeTransaction.data.operation,
- safeTransaction.data.safeTxGas,
- safeTransaction.data.baseGas,
- safeTransaction.data.gasPrice,
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- ],
- {
- ...options
- }
- )
- }
- isTxValid = await this.contract.execTransaction.staticCall(
- safeTransaction.data.to,
- safeTransaction.data.value,
- safeTransaction.data.data,
- safeTransaction.data.operation,
- safeTransaction.data.safeTxGas,
- safeTransaction.data.baseGas,
- safeTransaction.data.gasPrice,
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures(),
- { ...options }
- )
- } catch {}
- return isTxValid
- }
-
- async execTransaction(
- safeTransaction: SafeTransaction,
- options?: EthersTransactionOptions
- ): Promise {
- if (options && !options.gasLimit) {
- options.gasLimit = await this.estimateGas(
- 'execTransaction',
- [
- safeTransaction.data.to,
- safeTransaction.data.value,
- safeTransaction.data.data,
- safeTransaction.data.operation,
- safeTransaction.data.safeTxGas,
- safeTransaction.data.baseGas,
- safeTransaction.data.gasPrice,
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- ],
- {
- ...options
- }
- )
- }
- const txResponse = await this.contract.execTransaction(
- safeTransaction.data.to,
- safeTransaction.data.value,
- safeTransaction.data.data,
- safeTransaction.data.operation,
- safeTransaction.data.safeTxGas,
- safeTransaction.data.baseGas,
- safeTransaction.data.gasPrice,
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures(),
- { ...options }
- )
- return toTxResult(txResponse, options)
- }
-
- encode: SafeInterface['encodeFunctionData'] = (methodName: any, params: any): string => {
- return this.contract.interface.encodeFunctionData(methodName, params)
- }
-
- async estimateGas(
- methodName: string,
- params: any[],
- options: EthersTransactionOptions
- ): Promise {
- const method = this.contract.getFunction(methodName)
-
- return (await method.estimateGas(...params, options)).toString()
- }
-}
-
-export default SafeContractEthers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.0.0/SafeContract_V1_0_0_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.0.0/SafeContract_V1_0_0_Ethers.ts
deleted file mode 100644
index 6982e4d0b..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.0.0/SafeContract_V1_0_0_Ethers.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-import {
- EthersTransactionOptions,
- EthersTransactionResult
-} from '@safe-global/protocol-kit/adapters/ethers/types'
-import { sameString, toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils'
-import { EMPTY_DATA, ZERO_ADDRESS } from '@safe-global/protocol-kit/adapters/ethers/utils/constants'
-import { Gnosis_safe as Safe } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.0.0/Gnosis_safe'
-import { SafeSetupConfig } from '@safe-global/safe-core-sdk-types'
-import SafeContractEthers from '../SafeContractEthers'
-import { SENTINEL_ADDRESS } from '@safe-global/protocol-kit/utils/constants'
-
-class SafeContract_V1_0_0_Ethers extends SafeContractEthers {
- constructor(public contract: Safe) {
- super(contract)
- }
-
- async setup(
- setupConfig: SafeSetupConfig,
- options?: EthersTransactionOptions
- ): Promise {
- const {
- owners,
- threshold,
- to = ZERO_ADDRESS,
- data = EMPTY_DATA,
- paymentToken = ZERO_ADDRESS,
- payment = 0,
- paymentReceiver = ZERO_ADDRESS
- } = setupConfig
-
- if (options && !options.gasLimit) {
- options.gasLimit = await this.estimateGas(
- 'setup',
- [owners, threshold, to, data, paymentToken, payment, paymentReceiver],
- {
- ...options
- }
- )
- }
- const txResponse = await this.contract.setup(
- owners,
- threshold,
- to,
- data,
- paymentToken,
- payment,
- paymentReceiver,
- { ...options }
- )
-
- return toTxResult(txResponse, options)
- }
-
- async getModules(): Promise {
- return this.contract.getModules()
- }
-
- async getModulesPaginated(start: string, pageSize: number): Promise {
- if (pageSize <= 0) throw new Error('Invalid page size for fetching paginated modules')
-
- const array = await this.getModules()
- if (start === SENTINEL_ADDRESS) {
- return array.slice(0, pageSize)
- } else {
- const moduleIndex = array.findIndex((module: string) => sameString(module, start))
- return moduleIndex === -1 ? [] : array.slice(moduleIndex + 1, pageSize)
- }
- }
-
- async isModuleEnabled(moduleAddress: string): Promise {
- const modules = await this.getModules()
- const isModuleEnabled = modules.some((enabledModuleAddress: string) =>
- sameString(enabledModuleAddress, moduleAddress)
- )
- return isModuleEnabled
- }
-}
-
-export default SafeContract_V1_0_0_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.1.1/SafeContract_V1_1_1_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.1.1/SafeContract_V1_1_1_Ethers.ts
deleted file mode 100644
index 5b5a7a6c5..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.1.1/SafeContract_V1_1_1_Ethers.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-import {
- EthersTransactionOptions,
- EthersTransactionResult
-} from '@safe-global/protocol-kit/adapters/ethers/types'
-import { sameString, toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils'
-import { EMPTY_DATA, ZERO_ADDRESS } from '@safe-global/protocol-kit/adapters/ethers/utils/constants'
-import { Gnosis_safe as Safe } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.1.1/Gnosis_safe'
-import { SafeSetupConfig } from '@safe-global/safe-core-sdk-types'
-import SafeContractEthers from '../SafeContractEthers'
-
-class SafeContract_V1_1_1_Ethers extends SafeContractEthers {
- constructor(public contract: Safe) {
- super(contract)
- }
-
- async setup(
- setupConfig: SafeSetupConfig,
- options?: EthersTransactionOptions
- ): Promise {
- const {
- owners,
- threshold,
- to = ZERO_ADDRESS,
- data = EMPTY_DATA,
- fallbackHandler = ZERO_ADDRESS,
- paymentToken = ZERO_ADDRESS,
- payment = 0,
- paymentReceiver = ZERO_ADDRESS
- } = setupConfig
-
- if (options && !options.gasLimit) {
- options.gasLimit = await this.estimateGas(
- 'setup',
- [owners, threshold, to, data, fallbackHandler, paymentToken, payment, paymentReceiver],
- {
- ...options
- }
- )
- }
- const txResponse = await this.contract.setup(
- owners,
- threshold,
- to,
- data,
- fallbackHandler,
- paymentToken,
- payment,
- paymentReceiver,
- { ...options }
- )
-
- return toTxResult(txResponse, options)
- }
-
- async getModules(): Promise {
- return this.contract.getModules()
- }
-
- async getModulesPaginated(start: string, pageSize: number): Promise {
- const { array } = await this.contract.getModulesPaginated(start, pageSize)
- return array
- }
-
- async isModuleEnabled(moduleAddress: string): Promise {
- const modules = await this.getModules()
- const isModuleEnabled = modules.some((enabledModuleAddress: string) =>
- sameString(enabledModuleAddress, moduleAddress)
- )
- return isModuleEnabled
- }
-}
-
-export default SafeContract_V1_1_1_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.2.0/SafeContract_V1_2_0_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.2.0/SafeContract_V1_2_0_Ethers.ts
deleted file mode 100644
index 06681a23d..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.2.0/SafeContract_V1_2_0_Ethers.ts
+++ /dev/null
@@ -1,69 +0,0 @@
-import {
- EthersTransactionOptions,
- EthersTransactionResult
-} from '@safe-global/protocol-kit/adapters/ethers/types'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils'
-import { EMPTY_DATA, ZERO_ADDRESS } from '@safe-global/protocol-kit/adapters/ethers/utils/constants'
-import { Gnosis_safe as Safe } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.2.0/Gnosis_safe'
-import { SafeSetupConfig } from '@safe-global/safe-core-sdk-types'
-import SafeContractEthers from '../SafeContractEthers'
-
-class SafeContract_V1_2_0_Ethers extends SafeContractEthers {
- constructor(public contract: Safe) {
- super(contract)
- }
-
- async setup(
- setupConfig: SafeSetupConfig,
- options?: EthersTransactionOptions
- ): Promise {
- const {
- owners,
- threshold,
- to = ZERO_ADDRESS,
- data = EMPTY_DATA,
- fallbackHandler = ZERO_ADDRESS,
- paymentToken = ZERO_ADDRESS,
- payment = 0,
- paymentReceiver = ZERO_ADDRESS
- } = setupConfig
-
- if (options && !options.gasLimit) {
- options.gasLimit = await this.estimateGas(
- 'setup',
- [owners, threshold, to, data, fallbackHandler, paymentToken, payment, paymentReceiver],
- {
- ...options
- }
- )
- }
- const txResponse = await this.contract.setup(
- owners,
- threshold,
- to,
- data,
- fallbackHandler,
- paymentToken,
- payment,
- paymentReceiver,
- { ...options }
- )
-
- return toTxResult(txResponse, options)
- }
-
- async getModules(): Promise {
- return this.contract.getModules()
- }
-
- async getModulesPaginated(start: string, pageSize: number): Promise {
- const { array } = await this.contract.getModulesPaginated(start, pageSize)
- return array
- }
-
- async isModuleEnabled(moduleAddress: string): Promise {
- return this.contract.isModuleEnabled(moduleAddress)
- }
-}
-
-export default SafeContract_V1_2_0_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.3.0/SafeContract_V1_3_0_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.3.0/SafeContract_V1_3_0_Ethers.ts
deleted file mode 100644
index a1d8db4ac..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.3.0/SafeContract_V1_3_0_Ethers.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-import {
- EthersTransactionOptions,
- EthersTransactionResult
-} from '@safe-global/protocol-kit/adapters/ethers/types'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils'
-import {
- EMPTY_DATA,
- SENTINEL_ADDRESS,
- ZERO_ADDRESS
-} from '@safe-global/protocol-kit/adapters/ethers/utils/constants'
-import { Gnosis_safe as Safe } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/Gnosis_safe'
-import { SafeSetupConfig } from '@safe-global/safe-core-sdk-types'
-import SafeContractEthers from '../SafeContractEthers'
-
-class SafeContract_V1_3_0_Ethers extends SafeContractEthers {
- constructor(public contract: Safe) {
- super(contract)
- }
-
- async setup(
- setupConfig: SafeSetupConfig,
- options?: EthersTransactionOptions
- ): Promise {
- const {
- owners,
- threshold,
- to = ZERO_ADDRESS,
- data = EMPTY_DATA,
- fallbackHandler = ZERO_ADDRESS,
- paymentToken = ZERO_ADDRESS,
- payment = 0,
- paymentReceiver = ZERO_ADDRESS
- } = setupConfig
-
- if (options && !options.gasLimit) {
- options.gasLimit = await this.estimateGas(
- 'setup',
- [owners, threshold, to, data, fallbackHandler, paymentToken, payment, paymentReceiver],
- {
- ...options
- }
- )
- }
- const txResponse = await this.contract.setup(
- owners,
- threshold,
- to,
- data,
- fallbackHandler,
- paymentToken,
- payment,
- paymentReceiver,
- { ...options }
- )
-
- return toTxResult(txResponse, options)
- }
-
- async getModules(): Promise {
- return await this.getModulesPaginated(SENTINEL_ADDRESS, 10)
- }
-
- async getModulesPaginated(start: string, pageSize: number): Promise {
- const { array } = await this.contract.getModulesPaginated(start, pageSize)
- return array
- }
-
- async isModuleEnabled(moduleAddress: string): Promise {
- return this.contract.isModuleEnabled(moduleAddress)
- }
-}
-
-export default SafeContract_V1_3_0_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.4.1/SafeContract_V1_4_1_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.4.1/SafeContract_V1_4_1_Ethers.ts
deleted file mode 100644
index 94404de44..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.4.1/SafeContract_V1_4_1_Ethers.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-import {
- EthersTransactionOptions,
- EthersTransactionResult
-} from '@safe-global/protocol-kit/adapters/ethers/types'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils'
-import {
- EMPTY_DATA,
- SENTINEL_ADDRESS,
- ZERO_ADDRESS
-} from '@safe-global/protocol-kit/adapters/ethers/utils/constants'
-import { Safe } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/Safe'
-import { SafeSetupConfig } from '@safe-global/safe-core-sdk-types'
-import SafeContractEthers from '../SafeContractEthers'
-
-class SafeContract_V1_4_1_Ethers extends SafeContractEthers {
- constructor(public contract: Safe) {
- super(contract)
- }
-
- async setup(
- setupConfig: SafeSetupConfig,
- options?: EthersTransactionOptions
- ): Promise {
- const {
- owners,
- threshold,
- to = ZERO_ADDRESS,
- data = EMPTY_DATA,
- fallbackHandler = ZERO_ADDRESS,
- paymentToken = ZERO_ADDRESS,
- payment = 0,
- paymentReceiver = ZERO_ADDRESS
- } = setupConfig
-
- if (options && !options.gasLimit) {
- options.gasLimit = await this.estimateGas(
- 'setup',
- [owners, threshold, to, data, fallbackHandler, paymentToken, payment, paymentReceiver],
- {
- ...options
- }
- )
- }
- const txResponse = await this.contract.setup(
- owners,
- threshold,
- to,
- data,
- fallbackHandler,
- paymentToken,
- payment,
- paymentReceiver,
- { ...options }
- )
-
- return toTxResult(txResponse, options)
- }
-
- async getModules(): Promise {
- return await this.getModulesPaginated(SENTINEL_ADDRESS, 10)
- }
-
- async getModulesPaginated(start: string, pageSize: number): Promise {
- const { array } = await this.contract.getModulesPaginated(start, pageSize)
- return array
- }
-
- async isModuleEnabled(moduleAddress: string): Promise {
- return this.contract.isModuleEnabled(moduleAddress)
- }
-}
-
-export default SafeContract_V1_4_1_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/SafeProxyFactoryEthersContract.ts b/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/SafeProxyFactoryEthersContract.ts
deleted file mode 100644
index d4829c1e9..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/SafeProxyFactoryEthersContract.ts
+++ /dev/null
@@ -1,85 +0,0 @@
-import { EventLog } from 'ethers'
-import { EthersTransactionOptions } from '@safe-global/protocol-kit/adapters/ethers/types'
-import { Proxy_factory as SafeProxyFactory_V1_0_0 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.0.0/Proxy_factory'
-import { Proxy_factory as SafeProxyFactory_V1_1_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.1.1/Proxy_factory'
-import { Proxy_factory as SafeProxyFactory_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/Proxy_factory'
-import { Safe_proxy_factory as SafeProxyFactory_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/Safe_proxy_factory'
-import { SafeProxyFactoryContract } from '@safe-global/safe-core-sdk-types'
-
-export interface CreateProxyProps {
- safeSingletonAddress: string
- initializer: string
- saltNonce: string
- options?: EthersTransactionOptions
- callback?: (txHash: string) => void
-}
-
-class SafeProxyFactoryEthersContract implements SafeProxyFactoryContract {
- constructor(
- public contract:
- | SafeProxyFactory_V1_4_1
- | SafeProxyFactory_V1_3_0
- | SafeProxyFactory_V1_1_1
- | SafeProxyFactory_V1_0_0
- ) {}
-
- getAddress(): Promise {
- return this.contract.getAddress()
- }
-
- async proxyCreationCode(): Promise {
- return this.contract.proxyCreationCode()
- }
-
- async createProxy({
- safeSingletonAddress,
- initializer,
- saltNonce,
- options,
- callback
- }: CreateProxyProps): Promise {
- if (BigInt(saltNonce) < 0) throw new Error('saltNonce must be greater than or equal to 0')
-
- if (options && !options.gasLimit) {
- options.gasLimit = await this.estimateGas(
- 'createProxyWithNonce',
- [safeSingletonAddress, initializer, saltNonce],
- {
- ...options
- }
- )
- }
- const proxyAddress = this.contract
- .createProxyWithNonce(safeSingletonAddress, initializer, saltNonce, { ...options })
- .then(async (txResponse) => {
- if (callback) {
- callback(txResponse.hash)
- }
- const txReceipt = await txResponse.wait()
- const events = txReceipt?.logs as EventLog[]
- const proxyCreationEvent = events.find((event) => event?.eventName === 'ProxyCreation')
- if (!proxyCreationEvent || !proxyCreationEvent.args) {
- throw new Error('SafeProxy was not deployed correctly')
- }
- const proxyAddress: string = proxyCreationEvent.args[0]
- return proxyAddress
- })
- return proxyAddress
- }
-
- encode(methodName: string, params: any[]): string {
- return (this.contract as any).interface.encodeFunctionData(methodName, params)
- }
-
- async estimateGas(
- methodName: string,
- params: any[],
- options: EthersTransactionOptions
- ): Promise {
- const method = this.contract.getFunction(methodName)
-
- return (await method.estimateGas(...params, options)).toString()
- }
-}
-
-export default SafeProxyFactoryEthersContract
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_V1_0_0_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_V1_0_0_Ethers.ts
deleted file mode 100644
index eeb302cce..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_V1_0_0_Ethers.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Proxy_factory as ProxyFactory } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.0.0/Proxy_factory'
-import SafeProxyFactoryEthersContract from '../SafeProxyFactoryEthersContract'
-
-class SafeProxyFactoryContract_V1_0_0_Ethers extends SafeProxyFactoryEthersContract {
- constructor(public contract: ProxyFactory) {
- super(contract)
- }
-}
-
-export default SafeProxyFactoryContract_V1_0_0_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_V1_1_1_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_V1_1_1_Ethers.ts
deleted file mode 100644
index fcac49d5f..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_V1_1_1_Ethers.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Proxy_factory as ProxyFactory } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.1.1/Proxy_factory'
-import SafeProxyFactoryEthersContract from '../SafeProxyFactoryEthersContract'
-
-class SafeProxyFactoryContract_V1_1_1_Ethers extends SafeProxyFactoryEthersContract {
- constructor(public contract: ProxyFactory) {
- super(contract)
- }
-}
-
-export default SafeProxyFactoryContract_V1_1_1_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_V1_3_0_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_V1_3_0_Ethers.ts
deleted file mode 100644
index 12c731c99..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_V1_3_0_Ethers.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Proxy_factory as ProxyFactory } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/Proxy_factory'
-import SafeProxyFactoryEthersContract from '../SafeProxyFactoryEthersContract'
-
-class SafeProxyFactoryContract_V1_3_0_Ethers extends SafeProxyFactoryEthersContract {
- constructor(public contract: ProxyFactory) {
- super(contract)
- }
-}
-
-export default SafeProxyFactoryContract_V1_3_0_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_V1_4_1_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_V1_4_1_Ethers.ts
deleted file mode 100644
index c6d960eaa..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_V1_4_1_Ethers.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Safe_proxy_factory as SafeProxyFactory } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/Safe_proxy_factory'
-import SafeProxyFactoryEthersContract from '../SafeProxyFactoryEthersContract'
-
-class SafeProxyFactoryContract_V1_4_1_Ethers extends SafeProxyFactoryEthersContract {
- constructor(public contract: SafeProxyFactory) {
- super(contract)
- }
-}
-
-export default SafeProxyFactoryContract_V1_4_1_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SignMessageLib/SignMessageLibEthersContract.ts b/packages/protocol-kit/src/adapters/ethers/contracts/SignMessageLib/SignMessageLibEthersContract.ts
deleted file mode 100644
index c147c7aa6..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/SignMessageLib/SignMessageLibEthersContract.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-import {
- EthersTransactionOptions,
- EthersTransactionResult
-} from '@safe-global/protocol-kit/adapters/ethers/types'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils'
-import {
- Sign_message_lib as SignMessageLib_V1_3_0,
- Sign_message_libInterface as SignMessageLibContractInterface
-} from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/Sign_message_lib'
-import { Sign_message_lib as SignMessageLib_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/Sign_message_lib'
-import { SignMessageLibContract } from '@safe-global/safe-core-sdk-types'
-
-abstract class SignMessageLibEthersContract implements SignMessageLibContract {
- constructor(public contract: SignMessageLib_V1_4_1 | SignMessageLib_V1_3_0) {}
-
- getAddress(): Promise {
- return this.contract.getAddress()
- }
-
- async signMessage(
- data: string,
- options?: EthersTransactionOptions
- ): Promise {
- if (options && !options.gasLimit) {
- options.gasLimit = await this.estimateGas('signMessage', [data], { ...options })
- }
- const txResponse = await this.contract.signMessage(data, { ...options })
- return toTxResult(txResponse, options)
- }
-
- async getMessageHash(message: string): Promise {
- return this.contract.getMessageHash(message)
- }
-
- encode: SignMessageLibContractInterface['encodeFunctionData'] = (
- methodName: any,
- params: any
- ): string => {
- return this.contract.interface.encodeFunctionData(methodName, params)
- }
-
- async estimateGas(
- methodName: string,
- params: any[],
- options: EthersTransactionOptions
- ): Promise {
- const method = this.contract.getFunction(methodName)
-
- return (await method.estimateGas(...params, options)).toString()
- }
-}
-
-export default SignMessageLibEthersContract
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_V1_3_0_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_V1_3_0_Ethers.ts
deleted file mode 100644
index ee9d19997..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_V1_3_0_Ethers.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Sign_message_lib as SignMessageLib } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/Sign_message_lib'
-import SignMessageLibEthersContract from '../SignMessageLibEthersContract'
-
-class SignMessageLibContract_V1_3_0_Ethers extends SignMessageLibEthersContract {
- constructor(public contract: SignMessageLib) {
- super(contract)
- }
-}
-
-export default SignMessageLibContract_V1_3_0_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_V1_4_1_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_V1_4_1_Ethers.ts
deleted file mode 100644
index 1e950a45e..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_V1_4_1_Ethers.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Sign_message_lib as SignMessageLib } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/Sign_message_lib'
-import SignMessageLibEthersContract from '../SignMessageLibEthersContract'
-
-class SignMessageLibContract_V1_4_1_Ethers extends SignMessageLibEthersContract {
- constructor(public contract: SignMessageLib) {
- super(contract)
- }
-}
-
-export default SignMessageLibContract_V1_4_1_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SimulateTxAccessor/SimulateTxAccessorEthersContract.ts b/packages/protocol-kit/src/adapters/ethers/contracts/SimulateTxAccessor/SimulateTxAccessorEthersContract.ts
deleted file mode 100644
index 0306dcb3f..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/SimulateTxAccessor/SimulateTxAccessorEthersContract.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import {
- Simulate_tx_accessor as SimulateTxAccessor_V1_3_0,
- Simulate_tx_accessorInterface as SimulateTxAccessorInterface
-} from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/Simulate_tx_accessor'
-import { Simulate_tx_accessor as SimulateTxAccessor_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/Simulate_tx_accessor'
-import { SimulateTxAccessorContract } from '@safe-global/safe-core-sdk-types'
-
-abstract class SimulateTxAccessorEthersContract implements SimulateTxAccessorContract {
- constructor(public contract: SimulateTxAccessor_V1_4_1 | SimulateTxAccessor_V1_3_0) {}
-
- getAddress(): Promise {
- return this.contract.getAddress()
- }
-
- encode: SimulateTxAccessorInterface['encodeFunctionData'] = (
- methodName: any,
- params: any
- ): string => {
- return this.contract.interface.encodeFunctionData(methodName, params)
- }
-}
-
-export default SimulateTxAccessorEthersContract
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_V1_3_0_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_V1_3_0_Ethers.ts
deleted file mode 100644
index 1646cd048..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_V1_3_0_Ethers.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Simulate_tx_accessor as SimulateTxAccessor } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/Simulate_tx_accessor'
-import SimulateTxAccessorEthersContract from '../SimulateTxAccessorEthersContract'
-
-class SimulateTxAccessorContract_V1_3_0_Ethers extends SimulateTxAccessorEthersContract {
- constructor(public contract: SimulateTxAccessor) {
- super(contract)
- }
-}
-
-export default SimulateTxAccessorContract_V1_3_0_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_V1_4_1_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_V1_4_1_Ethers.ts
deleted file mode 100644
index 7315ed1ae..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_V1_4_1_Ethers.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Simulate_tx_accessor as SimulateTxAccessor } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/Simulate_tx_accessor'
-import SimulateTxAccessorEthersContract from '../SimulateTxAccessorEthersContract'
-
-class SimulateTxAccessorContract_V1_4_1_Ethers extends SimulateTxAccessorEthersContract {
- constructor(public contract: SimulateTxAccessor) {
- super(contract)
- }
-}
-
-export default SimulateTxAccessorContract_V1_4_1_Ethers
diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/contractInstancesEthers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/contractInstancesEthers.ts
deleted file mode 100644
index cd179e9ee..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/contractInstancesEthers.ts
+++ /dev/null
@@ -1,249 +0,0 @@
-import { AbstractSigner, Provider } from 'ethers'
-import { Gnosis_safe__factory as SafeSingleton_V1_0_0 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.0.0/factories/Gnosis_safe__factory'
-import { Proxy_factory__factory as SafeProxyFactory_V1_0_0 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.0.0/factories/Proxy_factory__factory'
-import { Gnosis_safe__factory as SafeSingleton_V1_1_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.1.1/factories/Gnosis_safe__factory'
-import { Multi_send__factory as MultiSend_V1_1_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.1.1/factories/Multi_send__factory'
-import { Proxy_factory__factory as SafeProxyFactory_V1_1_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.1.1/factories/Proxy_factory__factory'
-import { Gnosis_safe__factory as SafeSingleton_V1_2_0 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.2.0/factories/Gnosis_safe__factory'
-import { Compatibility_fallback_handler__factory as CompatibilityFallbackHandler_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/factories/Compatibility_fallback_handler__factory'
-import { Create_call__factory as CreateCall_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/factories/Create_call__factory'
-import { Gnosis_safe__factory as SafeSingleton_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/factories/Gnosis_safe__factory'
-import { Multi_send__factory as MultiSend_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/factories/Multi_send__factory'
-import { Multi_send_call_only__factory as MultiSendCallOnly_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/factories/Multi_send_call_only__factory'
-import { Proxy_factory__factory as SafeProxyFactory_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/factories/Proxy_factory__factory'
-import { Sign_message_lib__factory as SignMessageLib_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/factories/Sign_message_lib__factory'
-import { Simulate_tx_accessor__factory as SimulateTxAccessor_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/factories/Simulate_tx_accessor__factory'
-import { Compatibility_fallback_handler__factory as CompatibilityFallbackHandler_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/factories/Compatibility_fallback_handler__factory'
-import { Create_call__factory as CreateCall_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/factories/Create_call__factory'
-import { Multi_send__factory as MultiSend_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/factories/Multi_send__factory'
-import { Multi_send_call_only__factory as MultiSendCallOnly_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/factories/Multi_send_call_only__factory'
-import { Safe__factory as SafeSingleton_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/factories/Safe__factory'
-import { Safe_proxy_factory__factory as SafeProxyFactory_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/factories/Safe_proxy_factory__factory'
-import { Sign_message_lib__factory as SignMessageLib_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/factories/Sign_message_lib__factory'
-import { Simulate_tx_accessor__factory as SimulateTxAccessor_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/factories/Simulate_tx_accessor__factory'
-import { SafeVersion } from '@safe-global/safe-core-sdk-types'
-import CompatibilityFallbackHandler_V1_3_0_Ethers from './CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandler_V1_3_0_Ethers'
-import CompatibilityFallbackHandler_V1_4_1_Ethers from './CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandler_V1_4_1_Ethers'
-import CreateCallContract_V1_3_0_Ethers from './CreateCall/v1.3.0/CreateCallEthersContract_V1_3_0_Ethers'
-import CreateCallContract_V1_4_1_Ethers from './CreateCall/v1.4.1/CreateCallEthersContract_V1_4_1_Ethers'
-import MultiSendContract_V1_1_1_Ethers from './MultiSend/v1.1.1/MultiSendContract_V1_1_1_Ethers'
-import MultiSendContract_V1_3_0_Ethers from './MultiSend/v1.3.0/MultiSendContract_V1_3_0_Ethers'
-import MultiSendContract_V1_4_1_Ethers from './MultiSend/v1.4.1/MultiSendContract_V1_4_1_Ethers'
-import MultiSendCallOnlyContract_V1_3_0_Ethers from './MultiSendCallOnly/v1.3.0/MultiSendCallOnlyContract_V1_3_0_Ethers'
-import MultiSendCallOnlyContract_V1_4_1_Ethers from './MultiSendCallOnly/v1.4.1/MultiSendCallOnlyContract_V1_4_1_Ethers'
-import SafeContract_V1_0_0_Ethers from './Safe/v1.0.0/SafeContract_V1_0_0_Ethers'
-import SafeContract_V1_1_1_Ethers from './Safe/v1.1.1/SafeContract_V1_1_1_Ethers'
-import SafeContract_V1_2_0_Ethers from './Safe/v1.2.0/SafeContract_V1_2_0_Ethers'
-import SafeContract_V1_3_0_Ethers from './Safe/v1.3.0/SafeContract_V1_3_0_Ethers'
-import SafeContract_V1_4_1_Ethers from './Safe/v1.4.1/SafeContract_V1_4_1_Ethers'
-import SafeProxyFactoryContract_V1_0_0_Ethers from './SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_V1_0_0_Ethers'
-import SafeProxyFactoryContract_V1_1_1_Ethers from './SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_V1_1_1_Ethers'
-import SafeProxyFactoryContract_V1_3_0_Ethers from './SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_V1_3_0_Ethers'
-import SafeProxyFactoryContract_V1_4_1_Ethers from './SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_V1_4_1_Ethers'
-import SignMessageLibContract_V1_3_0_Ethers from './SignMessageLib/v1.3.0/SignMessageLibContract_V1_3_0_Ethers'
-import SignMessageLibContract_V1_4_1_Ethers from './SignMessageLib/v1.4.1/SignMessageLibContract_V1_4_1_Ethers'
-import SimulateTxAccessorContract_V1_3_0_Ethers from './SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_V1_3_0_Ethers'
-import SimulateTxAccessorContract_V1_4_1_Ethers from './SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_V1_4_1_Ethers'
-
-export function getSafeContractInstance(
- safeVersion: SafeVersion,
- contractAddress: string,
- signerOrProvider: AbstractSigner | Provider
-):
- | SafeContract_V1_4_1_Ethers
- | SafeContract_V1_3_0_Ethers
- | SafeContract_V1_2_0_Ethers
- | SafeContract_V1_1_1_Ethers
- | SafeContract_V1_0_0_Ethers {
- let safeContract
- switch (safeVersion) {
- case '1.4.1':
- safeContract = SafeSingleton_V1_4_1.connect(contractAddress, signerOrProvider)
- return new SafeContract_V1_4_1_Ethers(safeContract)
- case '1.3.0':
- safeContract = SafeSingleton_V1_3_0.connect(contractAddress, signerOrProvider)
- return new SafeContract_V1_3_0_Ethers(safeContract)
- case '1.2.0':
- safeContract = SafeSingleton_V1_2_0.connect(contractAddress, signerOrProvider)
- return new SafeContract_V1_2_0_Ethers(safeContract)
- case '1.1.1':
- safeContract = SafeSingleton_V1_1_1.connect(contractAddress, signerOrProvider)
- return new SafeContract_V1_1_1_Ethers(safeContract)
- case '1.0.0':
- safeContract = SafeSingleton_V1_0_0.connect(contractAddress, signerOrProvider)
- return new SafeContract_V1_0_0_Ethers(safeContract)
- default:
- throw new Error('Invalid Safe version')
- }
-}
-
-export function getCompatibilityFallbackHandlerContractInstance(
- safeVersion: SafeVersion,
- contractAddress: string,
- signerOrProvider: AbstractSigner | Provider
-): CompatibilityFallbackHandler_V1_4_1_Ethers | CompatibilityFallbackHandler_V1_3_0_Ethers {
- let compatibilityFallbackHandlerContract
- switch (safeVersion) {
- case '1.4.1':
- compatibilityFallbackHandlerContract = CompatibilityFallbackHandler_V1_4_1.connect(
- contractAddress,
- signerOrProvider
- )
- return new CompatibilityFallbackHandler_V1_4_1_Ethers(compatibilityFallbackHandlerContract)
- case '1.3.0':
- case '1.2.0':
- case '1.1.1':
- compatibilityFallbackHandlerContract = CompatibilityFallbackHandler_V1_3_0.connect(
- contractAddress,
- signerOrProvider
- )
- return new CompatibilityFallbackHandler_V1_3_0_Ethers(compatibilityFallbackHandlerContract)
- default:
- throw new Error('Invalid Safe version')
- }
-}
-
-export function getMultiSendContractInstance(
- safeVersion: SafeVersion,
- contractAddress: string,
- signerOrProvider: AbstractSigner | Provider
-):
- | MultiSendContract_V1_4_1_Ethers
- | MultiSendContract_V1_3_0_Ethers
- | MultiSendContract_V1_1_1_Ethers {
- let multiSendContract
- switch (safeVersion) {
- case '1.4.1':
- multiSendContract = MultiSend_V1_4_1.connect(contractAddress, signerOrProvider)
- return new MultiSendContract_V1_4_1_Ethers(multiSendContract)
- case '1.3.0':
- multiSendContract = MultiSend_V1_3_0.connect(contractAddress, signerOrProvider)
- return new MultiSendContract_V1_3_0_Ethers(multiSendContract)
- case '1.2.0':
- case '1.1.1':
- case '1.0.0':
- multiSendContract = MultiSend_V1_1_1.connect(contractAddress, signerOrProvider)
- return new MultiSendContract_V1_1_1_Ethers(multiSendContract)
- default:
- throw new Error('Invalid Safe version')
- }
-}
-
-export function getMultiSendCallOnlyContractInstance(
- safeVersion: SafeVersion,
- contractAddress: string,
- signerOrProvider: AbstractSigner | Provider
-): MultiSendCallOnlyContract_V1_4_1_Ethers | MultiSendCallOnlyContract_V1_3_0_Ethers {
- let multiSendCallOnlyContract
- switch (safeVersion) {
- case '1.4.1':
- multiSendCallOnlyContract = MultiSendCallOnly_V1_4_1.connect(
- contractAddress,
- signerOrProvider
- )
- return new MultiSendCallOnlyContract_V1_4_1_Ethers(multiSendCallOnlyContract)
- case '1.3.0':
- case '1.2.0':
- case '1.1.1':
- case '1.0.0':
- multiSendCallOnlyContract = MultiSendCallOnly_V1_3_0.connect(
- contractAddress,
- signerOrProvider
- )
- return new MultiSendCallOnlyContract_V1_3_0_Ethers(multiSendCallOnlyContract)
- default:
- throw new Error('Invalid Safe version')
- }
-}
-
-export function getSafeProxyFactoryContractInstance(
- safeVersion: SafeVersion,
- contractAddress: string,
- signerOrProvider: AbstractSigner | Provider
-):
- | SafeProxyFactoryContract_V1_4_1_Ethers
- | SafeProxyFactoryContract_V1_3_0_Ethers
- | SafeProxyFactoryContract_V1_1_1_Ethers
- | SafeProxyFactoryContract_V1_0_0_Ethers {
- let safeProxyFactoryContract
- switch (safeVersion) {
- case '1.4.1':
- safeProxyFactoryContract = SafeProxyFactory_V1_4_1.connect(contractAddress, signerOrProvider)
- return new SafeProxyFactoryContract_V1_4_1_Ethers(safeProxyFactoryContract)
- case '1.3.0':
- safeProxyFactoryContract = SafeProxyFactory_V1_3_0.connect(contractAddress, signerOrProvider)
- return new SafeProxyFactoryContract_V1_3_0_Ethers(safeProxyFactoryContract)
- case '1.2.0':
- case '1.1.1':
- safeProxyFactoryContract = SafeProxyFactory_V1_1_1.connect(contractAddress, signerOrProvider)
- return new SafeProxyFactoryContract_V1_1_1_Ethers(safeProxyFactoryContract)
- case '1.0.0':
- safeProxyFactoryContract = SafeProxyFactory_V1_0_0.connect(contractAddress, signerOrProvider)
- return new SafeProxyFactoryContract_V1_0_0_Ethers(safeProxyFactoryContract)
- default:
- throw new Error('Invalid Safe version')
- }
-}
-
-export function getSignMessageLibContractInstance(
- safeVersion: SafeVersion,
- contractAddress: string,
- signerOrProvider: AbstractSigner | Provider
-): SignMessageLibContract_V1_4_1_Ethers | SignMessageLibContract_V1_3_0_Ethers {
- let signMessageLibContract
- switch (safeVersion) {
- case '1.4.1':
- signMessageLibContract = SignMessageLib_V1_4_1.connect(contractAddress, signerOrProvider)
- return new SignMessageLibContract_V1_4_1_Ethers(signMessageLibContract)
- case '1.3.0':
- signMessageLibContract = SignMessageLib_V1_3_0.connect(contractAddress, signerOrProvider)
- return new SignMessageLibContract_V1_3_0_Ethers(signMessageLibContract)
- default:
- throw new Error('Invalid Safe version')
- }
-}
-
-export function getCreateCallContractInstance(
- safeVersion: SafeVersion,
- contractAddress: string,
- signerOrProvider: AbstractSigner | Provider
-): CreateCallContract_V1_4_1_Ethers | CreateCallContract_V1_3_0_Ethers {
- let createCallContract
- switch (safeVersion) {
- case '1.4.1':
- createCallContract = CreateCall_V1_4_1.connect(contractAddress, signerOrProvider)
- return new CreateCallContract_V1_4_1_Ethers(createCallContract)
- case '1.3.0':
- case '1.2.0':
- case '1.1.1':
- case '1.0.0':
- createCallContract = CreateCall_V1_3_0.connect(contractAddress, signerOrProvider)
- return new CreateCallContract_V1_3_0_Ethers(createCallContract)
- default:
- throw new Error('Invalid Safe version')
- }
-}
-
-export function getSimulateTxAccessorContractInstance(
- safeVersion: SafeVersion,
- contractAddress: string,
- signerOrProvider: AbstractSigner | Provider
-): SimulateTxAccessorContract_V1_4_1_Ethers | SimulateTxAccessorContract_V1_3_0_Ethers {
- let simulateTxAccessorContract
- switch (safeVersion) {
- case '1.4.1':
- simulateTxAccessorContract = SimulateTxAccessor_V1_4_1.connect(
- contractAddress,
- signerOrProvider
- )
- return new SimulateTxAccessorContract_V1_4_1_Ethers(simulateTxAccessorContract)
- case '1.3.0':
- simulateTxAccessorContract = SimulateTxAccessor_V1_3_0.connect(
- contractAddress,
- signerOrProvider
- )
- return new SimulateTxAccessorContract_V1_3_0_Ethers(simulateTxAccessorContract)
- default:
- throw new Error('Invalid Safe version')
- }
-}
diff --git a/packages/protocol-kit/src/adapters/ethers/index.ts b/packages/protocol-kit/src/adapters/ethers/index.ts
deleted file mode 100644
index ac2473f50..000000000
--- a/packages/protocol-kit/src/adapters/ethers/index.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import EthersAdapter, { EthersAdapterConfig } from './EthersAdapter'
-import CreateCallEthersContract from './contracts/CreateCall/CreateCallEthersContract'
-import MultiSendEthersContract from './contracts/MultiSend/MultiSendEthersContract'
-import MultiSendCallOnlyEthersContract from './contracts/MultiSendCallOnly/MultiSendCallOnlyEthersContract'
-import SafeContractEthers from './contracts/Safe/SafeContractEthers'
-import SafeProxyFactoryEthersContract, {
- CreateProxyProps
-} from './contracts/SafeProxyFactory/SafeProxyFactoryEthersContract'
-import SignMessageLibEthersContract from './contracts/SignMessageLib/SignMessageLibEthersContract'
-import { EthersTransactionOptions, EthersTransactionResult } from './types'
-
-export {
- CreateCallEthersContract,
- CreateProxyProps,
- EthersAdapter,
- EthersAdapterConfig,
- EthersTransactionOptions,
- EthersTransactionResult,
- MultiSendCallOnlyEthersContract,
- MultiSendEthersContract,
- SafeContractEthers,
- SafeProxyFactoryEthersContract,
- SignMessageLibEthersContract
-}
diff --git a/packages/protocol-kit/src/adapters/ethers/types.ts b/packages/protocol-kit/src/adapters/ethers/types.ts
deleted file mode 100644
index 0c9e606ca..000000000
--- a/packages/protocol-kit/src/adapters/ethers/types.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { ContractTransactionResponse } from 'ethers'
-import { BaseTransactionResult } from '@safe-global/safe-core-sdk-types'
-
-export interface EthersTransactionOptions {
- from?: string
- gasLimit?: number | string
- gasPrice?: number | string
- maxFeePerGas?: number | string
- maxPriorityFeePerGas?: number | string
- nonce?: number
-}
-
-export interface EthersTransactionResult extends BaseTransactionResult {
- transactionResponse: ContractTransactionResponse
- options?: EthersTransactionOptions
-}
diff --git a/packages/protocol-kit/src/adapters/ethers/utils/index.ts b/packages/protocol-kit/src/adapters/ethers/utils/index.ts
deleted file mode 100644
index 3912dcf14..000000000
--- a/packages/protocol-kit/src/adapters/ethers/utils/index.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import { ContractTransactionResponse, Provider, AbstractSigner } from 'ethers'
-import { EthersTransactionOptions, EthersTransactionResult } from '../types'
-
-export function sameString(str1: string, str2: string): boolean {
- return str1.toLowerCase() === str2.toLowerCase()
-}
-
-export function toTxResult(
- transactionResponse: ContractTransactionResponse,
- options?: EthersTransactionOptions
-): EthersTransactionResult {
- return {
- hash: transactionResponse.hash,
- options,
- transactionResponse
- }
-}
-
-export function isTypedDataSigner(signer: any): signer is AbstractSigner {
- return (signer as unknown as AbstractSigner).signTypedData !== undefined
-}
-
-/**
- * Check if the signerOrProvider is compatible with `Signer`
- * @param signerOrProvider - Signer or provider
- * @returns true if the parameter is compatible with `Signer`
- */
-export function isSignerCompatible(signerOrProvider: AbstractSigner | Provider): boolean {
- const candidate = signerOrProvider as AbstractSigner
-
- const isSigntransactionCompatible = typeof candidate.signTransaction === 'function'
- const isSignMessageCompatible = typeof candidate.signMessage === 'function'
- const isGetAddressCompatible = typeof candidate.getAddress === 'function'
-
- return isSigntransactionCompatible && isSignMessageCompatible && isGetAddressCompatible
-}
diff --git a/packages/protocol-kit/src/adapters/web3/README.md b/packages/protocol-kit/src/adapters/web3/README.md
deleted file mode 100644
index 71ab2cf35..000000000
--- a/packages/protocol-kit/src/adapters/web3/README.md
+++ /dev/null
@@ -1,27 +0,0 @@
-# Web3 Adapter
-
-Web3.js wrapper that contains some utilities and the Safe contracts types (generated with `typechain` `web3-v1`). It is used to initialize the [Protocol Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/protocol-kit).
-
-## How to use
-
-If the app integrating the SDK is using `Web3`, create an instance of the `Web3Adapter`, where `signerAddress` is the Ethereum account we are connecting and the one who will sign the transactions.
-
-```js
-import Web3 from 'web3'
-import { Web3Adapter } from '@safe-global/protocol-kit'
-
-const provider = new Web3.providers.HttpProvider('http://localhost:8545')
-const web3 = new Web3(provider)
-const safeOwner = '0x'
-
-const ethAdapter = new Web3Adapter({
- web3,
- signerAddress: safeOwner
-})
-```
-
-In case the `ethAdapter` instance is only used to execute read-only methods the `signerAddress` property can be omitted.
-
-```js
-const readOnlyEthAdapter = new Web3Adapter({ web3 })
-```
diff --git a/packages/protocol-kit/src/adapters/web3/Web3Adapter.ts b/packages/protocol-kit/src/adapters/web3/Web3Adapter.ts
deleted file mode 100644
index f8fca35dc..000000000
--- a/packages/protocol-kit/src/adapters/web3/Web3Adapter.ts
+++ /dev/null
@@ -1,341 +0,0 @@
-import { generateTypedData, validateEip3770Address } from '@safe-global/protocol-kit/utils'
-import {
- Eip3770Address,
- EthAdapter,
- EthAdapterTransaction,
- GetContractProps,
- SafeEIP712Args
-} from '@safe-global/safe-core-sdk-types'
-import Web3 from 'web3'
-import { Transaction } from 'web3-core'
-import { ContractOptions } from 'web3-eth-contract'
-import { AbiItem } from 'web3-utils'
-// TODO remove @types/web3 when migrating to web3@v4
-// Deprecated https://www.npmjs.com/package/@types/web3?activeTab=readme
-// Migration guide https://docs.web3js.org/docs/guides/web3_migration_guide#types
-import type { JsonRPCResponse, Provider } from 'web3/providers'
-import CompatibilityFallbackHandlerWeb3Contract from './contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerWeb3Contract'
-import CreateCallWeb3Contract from './contracts/CreateCall/CreateCallWeb3Contract'
-import MultiSendWeb3Contract from './contracts/MultiSend/MultiSendWeb3Contract'
-import MultiSendCallOnlyWeb3Contract from './contracts/MultiSendCallOnly/MultiSendCallOnlyWeb3Contract'
-import SafeContractWeb3 from './contracts/Safe/SafeContractWeb3'
-import SafeProxyFactoryWeb3Contract from './contracts/SafeProxyFactory/SafeProxyFactoryWeb3Contract'
-import SignMessageLibWeb3Contract from './contracts/SignMessageLib/SignMessageLibWeb3Contract'
-import SimulateTxAccessorWeb3Contract from './contracts/SimulateTxAccessor/SimulateTxAccessorWeb3Contract'
-import {
- getCompatibilityFallbackHandlerContractInstance,
- getCreateCallContractInstance,
- getMultiSendCallOnlyContractInstance,
- getMultiSendContractInstance,
- getSafeContractInstance,
- getSafeProxyFactoryContractInstance,
- getSignMessageLibContractInstance,
- getSimulateTxAccessorContractInstance
-} from './contracts/contractInstancesWeb3'
-import { SigningMethod } from '@safe-global/protocol-kit/types'
-
-export interface Web3AdapterConfig {
- /** web3 - Web3 library */
- web3: Web3
- /** signerAddress - Address of the signer */
- signerAddress?: string
-}
-
-class Web3Adapter implements EthAdapter {
- #web3: Web3
- #signerAddress?: string
-
- constructor({ web3, signerAddress }: Web3AdapterConfig) {
- if (!web3) {
- throw new Error('web3 property missing from options')
- }
- this.#web3 = web3
- this.#signerAddress = signerAddress
- }
-
- isAddress(address: string): boolean {
- return this.#web3.utils.isAddress(address)
- }
-
- async getEip3770Address(fullAddress: string): Promise {
- const chainId = await this.getChainId()
- return validateEip3770Address(fullAddress, chainId)
- }
-
- async getBalance(address: string, defaultBlock?: string | number): Promise {
- const balance = defaultBlock
- ? await this.#web3.eth.getBalance(address, defaultBlock)
- : await this.#web3.eth.getBalance(address)
- return BigInt(balance)
- }
-
- async getNonce(address: string, defaultBlock?: string | number): Promise {
- const nonce = defaultBlock
- ? await this.#web3.eth.getTransactionCount(address, defaultBlock)
- : await this.#web3.eth.getTransactionCount(address)
- return nonce
- }
-
- async getChainId(): Promise {
- return BigInt(await this.#web3.eth.getChainId())
- }
-
- getChecksummedAddress(address: string): string {
- return this.#web3.utils.toChecksumAddress(address)
- }
-
- async getSafeContract({
- safeVersion,
- singletonDeployment,
- customContractAddress,
- customContractAbi
- }: GetContractProps): Promise {
- const chainId = await this.getChainId()
- const contractAddress =
- customContractAddress ?? singletonDeployment?.networkAddresses[chainId.toString()]
- if (!contractAddress) {
- throw new Error('Invalid SafeProxy contract address')
- }
- const safeContract = this.getContract(
- contractAddress,
- customContractAbi ?? (singletonDeployment?.abi as AbiItem[])
- )
- return getSafeContractInstance(safeVersion, safeContract)
- }
-
- async getSafeProxyFactoryContract({
- safeVersion,
- singletonDeployment,
- customContractAddress,
- customContractAbi
- }: GetContractProps): Promise {
- const chainId = await this.getChainId()
- const contractAddress =
- customContractAddress ?? singletonDeployment?.networkAddresses[chainId.toString()]
- if (!contractAddress) {
- throw new Error('Invalid SafeProxyFactory contract address')
- }
- const proxyFactoryContract = this.getContract(
- contractAddress,
- customContractAbi ?? (singletonDeployment?.abi as AbiItem[])
- )
- return getSafeProxyFactoryContractInstance(safeVersion, proxyFactoryContract)
- }
-
- async getMultiSendContract({
- safeVersion,
- singletonDeployment,
- customContractAddress,
- customContractAbi
- }: GetContractProps): Promise {
- const chainId = await this.getChainId()
- const contractAddress =
- customContractAddress ?? singletonDeployment?.networkAddresses[chainId.toString()]
- if (!contractAddress) {
- throw new Error('Invalid MultiSend contract address')
- }
- const multiSendContract = this.getContract(
- contractAddress,
- customContractAbi ?? (singletonDeployment?.abi as AbiItem[])
- )
- return getMultiSendContractInstance(safeVersion, multiSendContract)
- }
-
- async getMultiSendCallOnlyContract({
- safeVersion,
- singletonDeployment,
- customContractAddress,
- customContractAbi
- }: GetContractProps): Promise {
- const chainId = await this.getChainId()
- const contractAddress =
- customContractAddress ?? singletonDeployment?.networkAddresses[chainId.toString()]
- if (!contractAddress) {
- throw new Error('Invalid MultiSendCallOnly contract address')
- }
- const multiSendContract = this.getContract(
- contractAddress,
- customContractAbi ?? (singletonDeployment?.abi as AbiItem[])
- )
- return getMultiSendCallOnlyContractInstance(safeVersion, multiSendContract)
- }
-
- async getCompatibilityFallbackHandlerContract({
- safeVersion,
- singletonDeployment,
- customContractAddress,
- customContractAbi
- }: GetContractProps): Promise {
- const chainId = await this.getChainId()
- const contractAddress =
- customContractAddress ?? singletonDeployment?.networkAddresses[chainId.toString()]
- if (!contractAddress) {
- throw new Error('Invalid Compatibility Fallback Handler contract address')
- }
- const multiSendContract = this.getContract(
- contractAddress,
- customContractAbi ?? (singletonDeployment?.abi as AbiItem[])
- )
- return getCompatibilityFallbackHandlerContractInstance(safeVersion, multiSendContract)
- }
-
- async getSignMessageLibContract({
- safeVersion,
- singletonDeployment,
- customContractAddress,
- customContractAbi
- }: GetContractProps): Promise {
- const chainId = await this.getChainId()
- const contractAddress =
- customContractAddress ?? singletonDeployment?.networkAddresses[chainId.toString()]
- if (!contractAddress) {
- throw new Error('Invalid SignMessageLib contract address')
- }
- const signMessageLibContract = this.getContract(
- contractAddress,
- customContractAbi ?? (singletonDeployment?.abi as AbiItem[])
- )
- return getSignMessageLibContractInstance(safeVersion, signMessageLibContract)
- }
-
- async getCreateCallContract({
- safeVersion,
- singletonDeployment,
- customContractAddress,
- customContractAbi
- }: GetContractProps): Promise {
- const chainId = await this.getChainId()
- const contractAddress =
- customContractAddress ?? singletonDeployment?.networkAddresses[chainId.toString()]
- if (!contractAddress) {
- throw new Error('Invalid CreateCall contract address')
- }
- const createCallContract = this.getContract(
- contractAddress,
- customContractAbi ?? (singletonDeployment?.abi as AbiItem[])
- )
- return getCreateCallContractInstance(safeVersion, createCallContract)
- }
-
- async getSimulateTxAccessorContract({
- safeVersion,
- singletonDeployment,
- customContractAddress,
- customContractAbi
- }: GetContractProps): Promise {
- const chainId = await this.getChainId()
- const contractAddress =
- customContractAddress ?? singletonDeployment?.networkAddresses[chainId.toString()]
- if (!contractAddress) {
- throw new Error('Invalid SimulateTxAccessor contract address')
- }
- const simulateTxAccessorContract = this.getContract(
- contractAddress,
- customContractAbi ?? (singletonDeployment?.abi as AbiItem[])
- )
- return getSimulateTxAccessorContractInstance(safeVersion, simulateTxAccessorContract)
- }
-
- getContract(address: string, abi: AbiItem | AbiItem[], options?: ContractOptions): any {
- return new this.#web3.eth.Contract(abi, address, options)
- }
-
- async getContractCode(address: string, defaultBlock?: string | number): Promise {
- const code = defaultBlock
- ? await this.#web3.eth.getCode(address, defaultBlock)
- : await this.#web3.eth.getCode(address)
- return code
- }
-
- async isContractDeployed(address: string, defaultBlock?: string | number): Promise {
- const contractCode = await this.getContractCode(address, defaultBlock)
- return contractCode !== '0x'
- }
-
- async getStorageAt(address: string, position: string): Promise {
- const content = await this.#web3.eth.getStorageAt(address, position)
- const decodedContent = this.decodeParameters(['address'], content)
- return decodedContent[0]
- }
-
- async getTransaction(transactionHash: string): Promise {
- return this.#web3.eth.getTransaction(transactionHash)
- }
-
- async getSignerAddress(): Promise {
- return this.#signerAddress
- }
-
- signMessage(message: string): Promise {
- if (!this.#signerAddress) {
- throw new Error('EthAdapter must be initialized with a signer to use this method')
- }
- return this.#web3.eth.sign(message, this.#signerAddress)
- }
-
- async signTypedData(
- safeEIP712Args: SafeEIP712Args,
- methodVersion?: 'v3' | 'v4'
- ): Promise {
- if (!this.#signerAddress) {
- throw new Error('This method requires a signer')
- }
- const typedData = generateTypedData(safeEIP712Args)
- let method = SigningMethod.ETH_SIGN_TYPED_DATA_V3
- if (methodVersion === 'v4') {
- method = SigningMethod.ETH_SIGN_TYPED_DATA_V4
- } else if (!methodVersion) {
- method = SigningMethod.ETH_SIGN_TYPED_DATA
- }
- const jsonTypedData = JSON.stringify(typedData)
- const signedTypedData = {
- jsonrpc: '2.0',
- method,
- params:
- methodVersion === 'v3' || methodVersion === 'v4'
- ? [this.#signerAddress, jsonTypedData]
- : [jsonTypedData, this.#signerAddress],
- from: this.#signerAddress,
- id: new Date().getTime()
- }
- return new Promise((resolve, reject) => {
- const provider = this.#web3.currentProvider as Provider
- function callback(err: Error): void
- function callback(err: null, val: JsonRPCResponse): void
- function callback(err: null | Error, val?: JsonRPCResponse): void {
- if (err) {
- reject(err)
- return
- }
-
- if (val?.result == null) {
- reject(new Error("EIP-712 is not supported by user's wallet"))
- return
- }
- resolve(val.result)
- }
- provider.send(signedTypedData, callback)
- })
- }
-
- async estimateGas(
- transaction: EthAdapterTransaction,
- callback?: (error: Error, gas: number) => void
- ): Promise {
- return (await this.#web3.eth.estimateGas(transaction, callback)).toString()
- }
-
- call(transaction: EthAdapterTransaction, defaultBlock?: string | number): Promise {
- return this.#web3.eth.call(transaction, defaultBlock)
- }
-
- encodeParameters(types: string[], values: any[]): string {
- return this.#web3.eth.abi.encodeParameters(types, values)
- }
-
- decodeParameters(types: any[], values: string): { [key: string]: any } {
- return this.#web3.eth.abi.decodeParameters(types, values)
- }
-}
-
-export default Web3Adapter
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerWeb3Contract.ts b/packages/protocol-kit/src/adapters/web3/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerWeb3Contract.ts
deleted file mode 100644
index 8daaab819..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerWeb3Contract.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { Compatibility_fallback_handler as CompatibilityFallbackHandler_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Compatibility_fallback_handler'
-import { Compatibility_fallback_handler as CompatibilityFallbackHandler_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Compatibility_fallback_handler'
-import { CompatibilityFallbackHandlerContract } from '@safe-global/safe-core-sdk-types'
-
-abstract class CompatibilityFallbackHandlerWeb3Contract
- implements CompatibilityFallbackHandlerContract
-{
- constructor(
- public contract: CompatibilityFallbackHandler_V1_4_1 | CompatibilityFallbackHandler_V1_3_0
- ) {}
-
- getAddress(): Promise {
- return Promise.resolve(this.contract.options.address)
- }
-
- encode(methodName: string, params: any[]): string {
- return (this.contract as any).methods[methodName](...params).encodeABI()
- }
-}
-
-export default CompatibilityFallbackHandlerWeb3Contract
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandler_V1_3_0_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandler_V1_3_0_Web3.ts
deleted file mode 100644
index 3d179d43a..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandler_V1_3_0_Web3.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Compatibility_fallback_handler as CompatibilityFallbackHandler } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Compatibility_fallback_handler'
-import CompatibilityFallbackHandlerWeb3Contract from '../CompatibilityFallbackHandlerWeb3Contract'
-
-class CompatibilityFallbackHandler_V1_3_0_Web3 extends CompatibilityFallbackHandlerWeb3Contract {
- constructor(public contract: CompatibilityFallbackHandler) {
- super(contract)
- }
-}
-
-export default CompatibilityFallbackHandler_V1_3_0_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandler_V1_4_1_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandler_V1_4_1_Web3.ts
deleted file mode 100644
index 0670913ab..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandler_V1_4_1_Web3.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Compatibility_fallback_handler as CompatibilityFallbackHandler } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Compatibility_fallback_handler'
-import CompatibilityFallbackHandlerWeb3Contract from '../CompatibilityFallbackHandlerWeb3Contract'
-
-class CompatibilityFallbackHandler_V1_4_1_Web3 extends CompatibilityFallbackHandlerWeb3Contract {
- constructor(public contract: CompatibilityFallbackHandler) {
- super(contract)
- }
-}
-
-export default CompatibilityFallbackHandler_V1_4_1_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/CreateCallWeb3Contract.ts b/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/CreateCallWeb3Contract.ts
deleted file mode 100644
index 54adbf12e..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/CreateCallWeb3Contract.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import {
- Web3TransactionOptions,
- Web3TransactionResult
-} from '@safe-global/protocol-kit/adapters/web3/types'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils'
-import { Create_call as CreateCall_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Create_call'
-import { Create_call as CreateCall_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Create_call'
-import { CreateCallContract } from '@safe-global/safe-core-sdk-types'
-
-abstract class CreateCallWeb3Contract implements CreateCallContract {
- constructor(public contract: CreateCall_V1_4_1 | CreateCall_V1_3_0) {}
-
- getAddress(): Promise {
- return Promise.resolve(this.contract.options.address)
- }
-
- async performCreate2(
- value: string,
- deploymentData: string,
- salt: string,
- options?: Web3TransactionOptions
- ): Promise {
- if (options && !options.gas) {
- options.gas = await this.estimateGas('performCreate2', [value, deploymentData, salt], {
- ...options
- })
- }
- const txResponse = this.contract.methods
- .performCreate2(value, deploymentData, salt)
- .send(options)
- return toTxResult(txResponse, options)
- }
-
- async performCreate(
- value: string,
- deploymentData: string,
- options?: Web3TransactionOptions
- ): Promise {
- if (options && !options.gas) {
- options.gas = await this.estimateGas('performCreate', [value, deploymentData], { ...options })
- }
- const txResponse = this.contract.methods.performCreate(value, deploymentData).send(options)
- return toTxResult(txResponse, options)
- }
-
- encode(methodName: string, params: any[]): string {
- return (this.contract as any).methods[methodName](...params).encodeABI()
- }
-
- async estimateGas(
- methodName: string,
- params: any[],
- options: Web3TransactionOptions
- ): Promise {
- return (
- await (this.contract.methods as any)[methodName](...params).estimateGas(options)
- ).toString()
- }
-}
-
-export default CreateCallWeb3Contract
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/CreateCallEthersContract_V1_3_0_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/CreateCallEthersContract_V1_3_0_Web3.ts
deleted file mode 100644
index c5a3fce5e..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/CreateCallEthersContract_V1_3_0_Web3.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Create_call as CreateCall } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Create_call'
-import CreateCallWeb3Contract from '../CreateCallWeb3Contract'
-
-class CreateCallContract_V1_3_0_Web3 extends CreateCallWeb3Contract {
- constructor(public contract: CreateCall) {
- super(contract)
- }
-}
-
-export default CreateCallContract_V1_3_0_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/CreateCallEthersContract_V1_4_1_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/CreateCallEthersContract_V1_4_1_Web3.ts
deleted file mode 100644
index 78032edb1..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/CreateCallEthersContract_V1_4_1_Web3.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Create_call as CreateCall } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Create_call'
-import CreateCallWeb3Contract from '../CreateCallWeb3Contract'
-
-class CreateCallContract_V1_4_1_Web3 extends CreateCallWeb3Contract {
- constructor(public contract: CreateCall) {
- super(contract)
- }
-}
-
-export default CreateCallContract_V1_4_1_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/MultiSendWeb3Contract.ts b/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/MultiSendWeb3Contract.ts
deleted file mode 100644
index 5f8473fb3..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/MultiSendWeb3Contract.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { Multi_send as MultiSend_V1_1_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.1.1/Multi_send'
-import { Multi_send as MultiSend_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Multi_send'
-import { Multi_send as MultiSend_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Multi_send'
-import { MultiSendContract } from '@safe-global/safe-core-sdk-types'
-
-abstract class MultiSendWeb3Contract implements MultiSendContract {
- constructor(public contract: MultiSend_V1_4_1 | MultiSend_V1_3_0 | MultiSend_V1_1_1) {}
-
- getAddress(): Promise {
- return Promise.resolve(this.contract.options.address)
- }
-
- encode(methodName: string, params: any[]): string {
- return (this.contract as any).methods[methodName](...params).encodeABI()
- }
-}
-
-export default MultiSendWeb3Contract
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/v1.1.1/MultiSendContract_V1_1_1_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/v1.1.1/MultiSendContract_V1_1_1_Web3.ts
deleted file mode 100644
index f12451e6c..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/v1.1.1/MultiSendContract_V1_1_1_Web3.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Multi_send as MultiSend } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.1.1/Multi_send'
-import MultiSendWeb3Contract from '../MultiSendWeb3Contract'
-
-class MultiSendContract_V1_1_1_Web3 extends MultiSendWeb3Contract {
- constructor(public contract: MultiSend) {
- super(contract)
- }
-}
-
-export default MultiSendContract_V1_1_1_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/v1.3.0/MultiSendContract_V1_3_0_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/v1.3.0/MultiSendContract_V1_3_0_Web3.ts
deleted file mode 100644
index 305c97703..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/v1.3.0/MultiSendContract_V1_3_0_Web3.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Multi_send as MultiSend } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Multi_send'
-import MultiSendWeb3Contract from '../MultiSendWeb3Contract'
-
-class MultiSendContract_V1_3_0_Web3 extends MultiSendWeb3Contract {
- constructor(public contract: MultiSend) {
- super(contract)
- }
-}
-
-export default MultiSendContract_V1_3_0_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/v1.4.1/MultiSendContract_V1_4_1_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/v1.4.1/MultiSendContract_V1_4_1_Web3.ts
deleted file mode 100644
index 510dfbd25..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/v1.4.1/MultiSendContract_V1_4_1_Web3.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Multi_send as MultiSend } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Multi_send'
-import MultiSendWeb3Contract from '../MultiSendWeb3Contract'
-
-class MultiSendContract_V1_4_1_Web3 extends MultiSendWeb3Contract {
- constructor(public contract: MultiSend) {
- super(contract)
- }
-}
-
-export default MultiSendContract_V1_4_1_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/MultiSendCallOnly/MultiSendCallOnlyWeb3Contract.ts b/packages/protocol-kit/src/adapters/web3/contracts/MultiSendCallOnly/MultiSendCallOnlyWeb3Contract.ts
deleted file mode 100644
index 7b8e5fa8f..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/MultiSendCallOnly/MultiSendCallOnlyWeb3Contract.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { Multi_send_call_only as MultiSendCallOnly_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Multi_send_call_only'
-import { Multi_send_call_only as MultiSendCallOnly_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Multi_send_call_only'
-import { MultiSendCallOnlyContract } from '@safe-global/safe-core-sdk-types'
-
-abstract class MultiSendCallOnlyWeb3Contract implements MultiSendCallOnlyContract {
- constructor(public contract: MultiSendCallOnly_V1_4_1 | MultiSendCallOnly_V1_3_0) {}
-
- getAddress(): Promise {
- return Promise.resolve(this.contract.options.address)
- }
-
- encode(methodName: string, params: any[]): string {
- return (this.contract as any).methods[methodName](...params).encodeABI()
- }
-}
-
-export default MultiSendCallOnlyWeb3Contract
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/MultiSendCallOnly/v1.3.0/MultiSendCallOnlyContract_V1_3_0_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/MultiSendCallOnly/v1.3.0/MultiSendCallOnlyContract_V1_3_0_Web3.ts
deleted file mode 100644
index 01c66bc1e..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/MultiSendCallOnly/v1.3.0/MultiSendCallOnlyContract_V1_3_0_Web3.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Multi_send_call_only as MultiSendCallOnly } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Multi_send_call_only'
-import MultiSendCallOnlyWeb3Contract from '../MultiSendCallOnlyWeb3Contract'
-
-class MultiSendCallOnlyContract_V1_3_0_Web3 extends MultiSendCallOnlyWeb3Contract {
- constructor(public contract: MultiSendCallOnly) {
- super(contract)
- }
-}
-
-export default MultiSendCallOnlyContract_V1_3_0_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/MultiSendCallOnly/v1.4.1/MultiSendCallOnlyContract_V1_4_1_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/MultiSendCallOnly/v1.4.1/MultiSendCallOnlyContract_V1_4_1_Web3.ts
deleted file mode 100644
index b60d53f2d..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/MultiSendCallOnly/v1.4.1/MultiSendCallOnlyContract_V1_4_1_Web3.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Multi_send_call_only as MultiSendCallOnly } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Multi_send_call_only'
-import MultiSendCallOnlyWeb3Contract from '../MultiSendCallOnlyWeb3Contract'
-
-class MultiSendCallOnlyContract_V1_4_1_Web3 extends MultiSendCallOnlyWeb3Contract {
- constructor(public contract: MultiSendCallOnly) {
- super(contract)
- }
-}
-
-export default MultiSendCallOnlyContract_V1_4_1_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/Safe/SafeContractWeb3.ts b/packages/protocol-kit/src/adapters/web3/contracts/Safe/SafeContractWeb3.ts
deleted file mode 100644
index 8d7a56140..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/Safe/SafeContractWeb3.ts
+++ /dev/null
@@ -1,192 +0,0 @@
-import {
- Web3TransactionOptions,
- Web3TransactionResult
-} from '@safe-global/protocol-kit/adapters/web3/types'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils'
-import { Gnosis_safe as Safe_V1_0_0 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.0.0/Gnosis_safe'
-import { Gnosis_safe as Safe_V1_1_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.1.1/Gnosis_safe'
-import { Gnosis_safe as Safe_V1_2_0 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.2.0/Gnosis_safe'
-import { Gnosis_safe as Safe_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Gnosis_safe'
-import { Safe as Safe_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Safe'
-import {
- SafeContract,
- SafeSetupConfig,
- SafeTransaction,
- SafeTransactionData,
- SafeVersion
-} from '@safe-global/safe-core-sdk-types'
-
-abstract class SafeContractWeb3 implements SafeContract {
- constructor(
- public contract: Safe_V1_4_1 | Safe_V1_3_0 | Safe_V1_2_0 | Safe_V1_1_1 | Safe_V1_0_0
- ) {}
-
- abstract setup(
- setupConfig: SafeSetupConfig,
- options?: Web3TransactionOptions
- ): Promise
-
- async getVersion(): Promise {
- return (await this.contract.methods.VERSION().call()) as SafeVersion
- }
-
- getAddress(): Promise {
- return Promise.resolve(this.contract.options.address)
- }
-
- async getNonce(): Promise {
- return Number(await this.contract.methods.nonce().call())
- }
-
- async getThreshold(): Promise {
- return Number(await this.contract.methods.getThreshold().call())
- }
-
- async getOwners(): Promise {
- return this.contract.methods.getOwners().call()
- }
-
- async isOwner(address: string): Promise {
- return this.contract.methods.isOwner(address).call()
- }
-
- async getTransactionHash(safeTransactionData: SafeTransactionData): Promise {
- return this.contract.methods
- .getTransactionHash(
- safeTransactionData.to,
- safeTransactionData.value,
- safeTransactionData.data,
- safeTransactionData.operation,
- safeTransactionData.safeTxGas,
- safeTransactionData.baseGas,
- safeTransactionData.gasPrice,
- safeTransactionData.gasToken,
- safeTransactionData.refundReceiver,
- safeTransactionData.nonce
- )
- .call()
- }
-
- async approvedHashes(ownerAddress: string, hash: string): Promise {
- return BigInt(await this.contract.methods.approvedHashes(ownerAddress, hash).call())
- }
-
- async approveHash(
- hash: string,
- options?: Web3TransactionOptions
- ): Promise {
- if (options && !options.gas) {
- options.gas = await this.estimateGas('approveHash', [hash], { ...options })
- }
- const txResponse = this.contract.methods.approveHash(hash).send(options)
- return toTxResult(txResponse, options)
- }
-
- abstract getModules(): Promise
-
- abstract getModulesPaginated(start: string, pageSize: number): Promise
-
- abstract isModuleEnabled(moduleAddress: string): Promise
-
- async isValidTransaction(
- safeTransaction: SafeTransaction,
- options?: Web3TransactionOptions
- ): Promise {
- let isTxValid = false
- try {
- if (options && !options.gas) {
- options.gas = await this.estimateGas(
- 'execTransaction',
- [
- safeTransaction.data.to,
- safeTransaction.data.value,
- safeTransaction.data.data,
- safeTransaction.data.operation,
- safeTransaction.data.safeTxGas,
- safeTransaction.data.baseGas,
- safeTransaction.data.gasPrice,
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- ],
- {
- ...options
- }
- )
- }
- isTxValid = await this.contract.methods
- .execTransaction(
- safeTransaction.data.to,
- safeTransaction.data.value,
- safeTransaction.data.data,
- safeTransaction.data.operation,
- safeTransaction.data.safeTxGas,
- safeTransaction.data.baseGas,
- safeTransaction.data.gasPrice,
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- )
- .call(options)
- } catch {}
- return isTxValid
- }
-
- async execTransaction(
- safeTransaction: SafeTransaction,
- options?: Web3TransactionOptions
- ): Promise {
- if (options && !options.gas) {
- options.gas = await this.estimateGas(
- 'execTransaction',
- [
- safeTransaction.data.to,
- safeTransaction.data.value,
- safeTransaction.data.data,
- safeTransaction.data.operation,
- safeTransaction.data.safeTxGas,
- safeTransaction.data.baseGas,
- safeTransaction.data.gasPrice,
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- ],
- {
- ...options
- }
- )
- }
- const txResponse = this.contract.methods
- .execTransaction(
- safeTransaction.data.to,
- safeTransaction.data.value,
- safeTransaction.data.data,
- safeTransaction.data.operation,
- safeTransaction.data.safeTxGas,
- safeTransaction.data.baseGas,
- safeTransaction.data.gasPrice,
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- )
- .send(options)
-
- return toTxResult(txResponse, options)
- }
-
- encode(methodName: string, params: any[]): string {
- return (this.contract.methods as any)[methodName](...params).encodeABI()
- }
-
- async estimateGas(
- methodName: string,
- params: any[],
- options: Web3TransactionOptions
- ): Promise {
- return (
- await (this.contract.methods as any)[methodName](...params).estimateGas(options)
- ).toString()
- }
-}
-
-export default SafeContractWeb3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.0.0/SafeContract_V1_0_0_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.0.0/SafeContract_V1_0_0_Web3.ts
deleted file mode 100644
index 9265d3258..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.0.0/SafeContract_V1_0_0_Web3.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-import {
- Web3TransactionOptions,
- Web3TransactionResult
-} from '@safe-global/protocol-kit/adapters/web3/types'
-import { sameString, toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils'
-import {
- EMPTY_DATA,
- ZERO_ADDRESS,
- SENTINEL_ADDRESS
-} from '@safe-global/protocol-kit/adapters/web3/utils/constants'
-import { Gnosis_safe as Safe } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.0.0/Gnosis_safe'
-import { SafeSetupConfig } from '@safe-global/safe-core-sdk-types'
-import SafeContractWeb3 from '../SafeContractWeb3'
-
-class SafeContract_V1_0_0_Web3 extends SafeContractWeb3 {
- constructor(public contract: Safe) {
- super(contract)
- }
-
- async setup(
- setupConfig: SafeSetupConfig,
- options?: Web3TransactionOptions
- ): Promise {
- const {
- owners,
- threshold,
- to = ZERO_ADDRESS,
- data = EMPTY_DATA,
- paymentToken = ZERO_ADDRESS,
- payment = 0,
- paymentReceiver = ZERO_ADDRESS
- } = setupConfig
-
- if (options && !options.gas) {
- options.gas = await this.estimateGas(
- 'setup',
- [owners, threshold, to, data, paymentToken, payment, paymentReceiver],
- {
- ...options
- }
- )
- }
- const txResponse = this.contract.methods
- .setup(owners, threshold, to, data, paymentToken, payment, paymentReceiver)
- .send(options)
-
- return toTxResult(txResponse, options)
- }
-
- async getModules(): Promise {
- return this.contract.methods.getModules().call()
- }
-
- async getModulesPaginated(start: string, pageSize: number): Promise {
- if (pageSize <= 0) throw new Error('Invalid page size for fetching paginated modules')
-
- const array = await this.getModules()
- if (start === SENTINEL_ADDRESS) {
- return array.slice(0, pageSize)
- } else {
- const moduleIndex = array.findIndex((module: string) => sameString(module, start))
- return moduleIndex === -1 ? [] : array.slice(moduleIndex + 1, pageSize)
- }
- }
-
- async isModuleEnabled(moduleAddress: string): Promise {
- const modules = await this.getModules()
- const isModuleEnabled = modules.some((enabledModuleAddress: string) =>
- sameString(enabledModuleAddress, moduleAddress)
- )
- return isModuleEnabled
- }
-}
-
-export default SafeContract_V1_0_0_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.1.1/SafeContract_V1_1_1_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.1.1/SafeContract_V1_1_1_Web3.ts
deleted file mode 100644
index f957f21a1..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.1.1/SafeContract_V1_1_1_Web3.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-import {
- Web3TransactionOptions,
- Web3TransactionResult
-} from '@safe-global/protocol-kit/adapters/web3/types'
-import { sameString, toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils'
-import { EMPTY_DATA, ZERO_ADDRESS } from '@safe-global/protocol-kit/adapters/web3/utils/constants'
-import { Gnosis_safe as Safe } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.1.1/Gnosis_safe'
-import { SafeSetupConfig } from '@safe-global/safe-core-sdk-types'
-import SafeContractWeb3 from '../SafeContractWeb3'
-
-class SafeContract_V1_1_1_Web3 extends SafeContractWeb3 {
- constructor(public contract: Safe) {
- super(contract)
- }
-
- async setup(
- setupConfig: SafeSetupConfig,
- options?: Web3TransactionOptions
- ): Promise {
- const {
- owners,
- threshold,
- to = ZERO_ADDRESS,
- data = EMPTY_DATA,
- fallbackHandler = ZERO_ADDRESS,
- paymentToken = ZERO_ADDRESS,
- payment = 0,
- paymentReceiver = ZERO_ADDRESS
- } = setupConfig
-
- if (options && !options.gas) {
- options.gas = await this.estimateGas(
- 'setup',
- [owners, threshold, to, data, fallbackHandler, paymentToken, payment, paymentReceiver],
- {
- ...options
- }
- )
- }
- const txResponse = this.contract.methods
- .setup(owners, threshold, to, data, fallbackHandler, paymentToken, payment, paymentReceiver)
- .send(options)
-
- return toTxResult(txResponse, options)
- }
-
- async getModules(): Promise {
- return this.contract.methods.getModules().call()
- }
-
- async getModulesPaginated(start: string, pageSize: number): Promise {
- const { array } = await this.contract.methods.getModulesPaginated(start, pageSize).call()
- return array
- }
-
- async isModuleEnabled(moduleAddress: string): Promise {
- const modules = await this.getModules()
- const isModuleEnabled = modules.some((enabledModuleAddress: string) =>
- sameString(enabledModuleAddress, moduleAddress)
- )
- return isModuleEnabled
- }
-}
-
-export default SafeContract_V1_1_1_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.2.0/SafeContract_V1_2_0_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.2.0/SafeContract_V1_2_0_Web3.ts
deleted file mode 100644
index 1cc9bb831..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.2.0/SafeContract_V1_2_0_Web3.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import {
- Web3TransactionOptions,
- Web3TransactionResult
-} from '@safe-global/protocol-kit/adapters/web3/types'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils'
-import { EMPTY_DATA, ZERO_ADDRESS } from '@safe-global/protocol-kit/adapters/web3/utils/constants'
-import { Gnosis_safe as Safe } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.2.0/Gnosis_safe'
-import { SafeSetupConfig } from '@safe-global/safe-core-sdk-types'
-import SafeContractWeb3 from '../SafeContractWeb3'
-
-class SafeContract_V1_2_0_Web3 extends SafeContractWeb3 {
- constructor(public contract: Safe) {
- super(contract)
- }
-
- async setup(
- setupConfig: SafeSetupConfig,
- options?: Web3TransactionOptions
- ): Promise {
- const {
- owners,
- threshold,
- to = ZERO_ADDRESS,
- data = EMPTY_DATA,
- fallbackHandler = ZERO_ADDRESS,
- paymentToken = ZERO_ADDRESS,
- payment = 0,
- paymentReceiver = ZERO_ADDRESS
- } = setupConfig
-
- if (options && !options.gas) {
- options.gas = await this.estimateGas(
- 'setup',
- [owners, threshold, to, data, fallbackHandler, paymentToken, payment, paymentReceiver],
- {
- ...options
- }
- )
- }
- const txResponse = this.contract.methods
- .setup(owners, threshold, to, data, fallbackHandler, paymentToken, payment, paymentReceiver)
- .send(options)
-
- return toTxResult(txResponse, options)
- }
-
- async getModules(): Promise {
- return this.contract.methods.getModules().call()
- }
-
- async getModulesPaginated(start: string, pageSize: number): Promise {
- const { array } = await this.contract.methods.getModulesPaginated(start, pageSize).call()
- return array
- }
-
- async isModuleEnabled(moduleAddress: string): Promise {
- return this.contract.methods.isModuleEnabled(moduleAddress).call()
- }
-}
-
-export default SafeContract_V1_2_0_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.3.0/SafeContract_V1_3_0_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.3.0/SafeContract_V1_3_0_Web3.ts
deleted file mode 100644
index 62f13e45e..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.3.0/SafeContract_V1_3_0_Web3.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-import {
- Web3TransactionOptions,
- Web3TransactionResult
-} from '@safe-global/protocol-kit/adapters/web3/types'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils'
-import {
- EMPTY_DATA,
- SENTINEL_ADDRESS,
- ZERO_ADDRESS
-} from '@safe-global/protocol-kit/adapters/web3/utils/constants'
-import { Gnosis_safe as Safe } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Gnosis_safe'
-import { SafeSetupConfig } from '@safe-global/safe-core-sdk-types'
-import SafeContractWeb3 from '../SafeContractWeb3'
-
-class SafeContract_V1_3_0_Web3 extends SafeContractWeb3 {
- constructor(public contract: Safe) {
- super(contract)
- }
-
- async setup(
- setupConfig: SafeSetupConfig,
- options?: Web3TransactionOptions
- ): Promise {
- const {
- owners,
- threshold,
- to = ZERO_ADDRESS,
- data = EMPTY_DATA,
- fallbackHandler = ZERO_ADDRESS,
- paymentToken = ZERO_ADDRESS,
- payment = 0,
- paymentReceiver = ZERO_ADDRESS
- } = setupConfig
-
- if (options && !options.gas) {
- options.gas = await this.estimateGas(
- 'setup',
- [owners, threshold, to, data, fallbackHandler, paymentToken, payment, paymentReceiver],
- {
- ...options
- }
- )
- }
- const txResponse = this.contract.methods
- .setup(owners, threshold, to, data, fallbackHandler, paymentToken, payment, paymentReceiver)
- .send(options)
-
- return toTxResult(txResponse, options)
- }
-
- async getModules(): Promise {
- return await this.getModulesPaginated(SENTINEL_ADDRESS, 10)
- }
-
- async getModulesPaginated(start: string, pageSize: number): Promise {
- const { array } = await this.contract.methods.getModulesPaginated(start, pageSize).call()
- return array
- }
-
- async isModuleEnabled(moduleAddress: string): Promise {
- return this.contract.methods.isModuleEnabled(moduleAddress).call()
- }
-}
-
-export default SafeContract_V1_3_0_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.4.1/SafeContract_V1_4_1_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.4.1/SafeContract_V1_4_1_Web3.ts
deleted file mode 100644
index 7751e9394..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.4.1/SafeContract_V1_4_1_Web3.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-import {
- Web3TransactionOptions,
- Web3TransactionResult
-} from '@safe-global/protocol-kit/adapters/web3/types'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils'
-import {
- EMPTY_DATA,
- SENTINEL_ADDRESS,
- ZERO_ADDRESS
-} from '@safe-global/protocol-kit/adapters/web3/utils/constants'
-import { Safe } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Safe'
-import { SafeSetupConfig } from '@safe-global/safe-core-sdk-types'
-import SafeContractWeb3 from '../SafeContractWeb3'
-
-class SafeContract_V1_4_1_Web3 extends SafeContractWeb3 {
- constructor(public contract: Safe) {
- super(contract)
- }
-
- async setup(
- setupConfig: SafeSetupConfig,
- options?: Web3TransactionOptions
- ): Promise {
- const {
- owners,
- threshold,
- to = ZERO_ADDRESS,
- data = EMPTY_DATA,
- fallbackHandler = ZERO_ADDRESS,
- paymentToken = ZERO_ADDRESS,
- payment = 0,
- paymentReceiver = ZERO_ADDRESS
- } = setupConfig
-
- if (options && !options.gas) {
- options.gas = await this.estimateGas(
- 'setup',
- [owners, threshold, to, data, fallbackHandler, paymentToken, payment, paymentReceiver],
- {
- ...options
- }
- )
- }
- const txResponse = this.contract.methods
- .setup(owners, threshold, to, data, fallbackHandler, paymentToken, payment, paymentReceiver)
- .send(options)
-
- return toTxResult(txResponse, options)
- }
-
- async getModules(): Promise {
- return await this.getModulesPaginated(SENTINEL_ADDRESS, 10)
- }
-
- async getModulesPaginated(start: string, pageSize: number): Promise {
- const { array } = await this.contract.methods.getModulesPaginated(start, pageSize).call()
- return array
- }
-
- async isModuleEnabled(moduleAddress: string): Promise {
- return this.contract.methods.isModuleEnabled(moduleAddress).call()
- }
-}
-
-export default SafeContract_V1_4_1_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/SafeProxyFactoryWeb3Contract.ts b/packages/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/SafeProxyFactoryWeb3Contract.ts
deleted file mode 100644
index c0ab63576..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/SafeProxyFactoryWeb3Contract.ts
+++ /dev/null
@@ -1,86 +0,0 @@
-import { Web3TransactionOptions } from '@safe-global/protocol-kit/adapters/web3/types'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils'
-import { Proxy_factory as SafeProxyFactory_V1_0_0 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.0.0/Proxy_factory'
-import { Proxy_factory as SafeProxyFactory_V1_1_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.1.1/Proxy_factory'
-import { Proxy_factory as SafeProxyFactory_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Proxy_factory'
-import { Safe_proxy_factory as SafeProxyFactory_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Safe_proxy_factory'
-import { SafeProxyFactoryContract } from '@safe-global/safe-core-sdk-types'
-import { TransactionReceipt } from 'web3-core/types'
-
-export interface CreateProxyProps {
- safeSingletonAddress: string
- initializer: string
- saltNonce: string
- options?: Web3TransactionOptions
- callback?: (txHash: string) => void
-}
-
-class SafeProxyFactoryWeb3Contract implements SafeProxyFactoryContract {
- constructor(
- public contract:
- | SafeProxyFactory_V1_4_1
- | SafeProxyFactory_V1_3_0
- | SafeProxyFactory_V1_1_1
- | SafeProxyFactory_V1_0_0
- ) {}
-
- getAddress(): Promise {
- return Promise.resolve(this.contract.options.address)
- }
-
- async proxyCreationCode(): Promise {
- return this.contract.methods.proxyCreationCode().call()
- }
-
- async createProxy({
- safeSingletonAddress,
- initializer,
- saltNonce,
- options,
- callback
- }: CreateProxyProps): Promise {
- if (BigInt(saltNonce) < 0) throw new Error('saltNonce must be greater than or equal to 0')
- if (options && !options.gas) {
- options.gas = await this.estimateGas(
- 'createProxyWithNonce',
- [safeSingletonAddress, initializer, saltNonce],
- {
- ...options
- }
- )
- }
- const txResponse = this.contract.methods
- .createProxyWithNonce(safeSingletonAddress, initializer, saltNonce)
- .send(options)
-
- if (callback) {
- const txResult = await toTxResult(txResponse)
- callback(txResult.hash)
- }
-
- const txResult: TransactionReceipt = await new Promise((resolve, reject) =>
- txResponse.once('receipt', (receipt: TransactionReceipt) => resolve(receipt)).catch(reject)
- )
- const proxyAddress = txResult.events?.ProxyCreation?.returnValues?.proxy
- if (!proxyAddress) {
- throw new Error('SafeProxy was not deployed correctly')
- }
- return proxyAddress
- }
-
- encode(methodName: string, params: any[]): string {
- return (this.contract as any).methods[methodName](...params).encodeABI()
- }
-
- async estimateGas(
- methodName: string,
- params: any[],
- options: Web3TransactionOptions
- ): Promise