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/guides/integrating-the-safe-core-sdk.md b/guides/integrating-the-safe-core-sdk.md
index 75f350843..7cfc86b34 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
@@ -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.create({ provider, signer })
-const safeSdk = await Safe.create({ ethAdapter, safeAddress })
+const safeSdk = await Safe.create({ 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.create({ provider, signer, isL1SafeSingleton: true })
-const safeSdk = await Safe.create({ ethAdapter, safeAddress, isL1SafeSingleton: true })
+const safeSdk = await Safe.create({ 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.create({ provider, signer, contractNetworks })
-const safeSdk = await Safe.create({ ethAdapter, safeAddress, contractNetworks })
+const safeSdk = await Safe.create({ 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.create({ provider, signer, safeVersion })
```
## 3. Deploy a new Safe
@@ -140,37 +139,37 @@ 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 safeSdk.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.
diff --git a/package.json b/package.json
index 60111881e..318c21638 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"
diff --git a/packages/account-abstraction-kit/src/AccountAbstraction.test.ts b/packages/account-abstraction-kit/src/AccountAbstraction.test.ts
index e5c8bb26d..2c82eebfb 100644
--- a/packages/account-abstraction-kit/src/AccountAbstraction.test.ts
+++ b/packages/account-abstraction-kit/src/AccountAbstraction.test.ts
@@ -1,4 +1,4 @@
-import Safe, { predictSafeAddress, EthAdapter } from '@safe-global/protocol-kit'
+import Safe, { predictSafeAddress, SafeProvider } from '@safe-global/protocol-kit'
import { GelatoRelayPack } from '@safe-global/relay-kit'
import { SafeTransaction } from '@safe-global/safe-core-sdk-types'
import AccountAbstraction from './AccountAbstraction'
@@ -9,67 +9,72 @@ 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(predictSafeAddressMock).toHaveBeenCalledWith(
+ expect.objectContaining({
+ safeAccountConfig: { owners: ['0xSignerAddress'], threshold: 1 }
+ })
+ )
expect(SafeMock.create).toHaveBeenCalledTimes(1)
- expect(SafeMock.create).toHaveBeenCalledWith({
- ethAdapter: ethersAdapter,
- safeAddress: predictSafeAddress
- })
+ expect(SafeMock.create).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(predictSafeAddressMock).toHaveBeenCalledWith(
+ expect.objectContaining({
+ safeAccountConfig: { owners: ['0xSignerAddress'], threshold: 1 }
+ })
+ )
expect(SafeMock.create).toHaveBeenCalledTimes(1)
- expect(SafeMock.create).toHaveBeenCalledWith({
- ethAdapter: ethersAdapter,
- predictedSafe: { safeAccountConfig: { owners: ['0xSignerAddress'], threshold: 1 } }
- })
+ expect(SafeMock.create).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()
})
})
@@ -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
}
@@ -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 0bd1a3fa3..62d50bb7f 100644
--- a/packages/account-abstraction-kit/src/AccountAbstraction.ts
+++ b/packages/account-abstraction-kit/src/AccountAbstraction.ts
@@ -1,4 +1,9 @@
-import Safe, { SafeAccountConfig, predictSafeAddress, EthAdapter } 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,
@@ -13,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]
@@ -39,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.create({
+ provider: this.#provider,
+ signer: this.#signer,
+ safeAddress
+ })
} else {
this.protocolKit = await Safe.create({
- ethAdapter: this.#ethAdapter,
+ provider: this.#provider,
+ signer: this.#signer,
predictedSafe: { safeAccountConfig }
})
}
diff --git a/packages/api-kit/hardhat.config.ts b/packages/api-kit/hardhat.config.ts
index 894ebfeb3..73eeaebd9 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'
diff --git a/packages/api-kit/package.json b/packages/api-kit/package.json
index 264ef3744..703467183 100644
--- a/packages/api-kit/package.json
+++ b/packages/api-kit/package.json
@@ -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,7 +39,6 @@
"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-as-promised": "^7.1.8",
"@types/mocha": "^10.0.6",
@@ -52,10 +53,12 @@
"sinon": "^14.0.2",
"sinon-chai": "^3.7.0",
"tsconfig-paths": "^4.2.0",
+ "viem": "^2.9.19",
+ "web3": "^4.7.0",
"yargs": "^17.7.2"
},
"dependencies": {
- "@safe-global/protocol-kit": "^3.0.2",
+ "@safe-global/protocol-kit": "3.1.0-alpha.0",
"@safe-global/safe-core-sdk-types": "^4.0.2",
"ethers": "^6.7.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 f2324ad5b..b4b5cad94 100644
--- a/packages/api-kit/tests/e2e/addMessageSignature.test.ts
+++ b/packages/api-kit/tests/e2e/addMessageSignature.test.ts
@@ -3,21 +3,23 @@ import Safe, {
buildSignatureBytes,
hashSafeMessage,
SigningMethod,
- buildContractSignature,
- EthAdapter
+ buildContractSignature
} from '@safe-global/protocol-kit'
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) => {
@@ -28,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
})
@@ -105,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)
@@ -127,7 +118,7 @@ describe('addMessageSignature', () => {
)
protocolKit = await protocolKit.connect({
- ethAdapter: ethAdapter2,
+ signer: PRIVATE_KEY_2,
safeAddress: signerSafeAddress
})
signerSafeMessage = await protocolKit.signMessage(
@@ -142,7 +133,7 @@ describe('addMessageSignature', () => {
)
protocolKit = await protocolKit.connect({
- ethAdapter: ethAdapter1,
+ signer: PRIVATE_KEY_1,
safeAddress
})
@@ -157,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 e3b00bf04..3ccb8dc93 100644
--- a/packages/api-kit/tests/e2e/addSafeDelegate.test.ts
+++ b/packages/api-kit/tests/e2e/addSafeDelegate.test.ts
@@ -1,29 +1,33 @@
-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
+let signer1: Signer
+let signer2: Signer
describe('addSafeDelegate', () => {
before(async () => {
- ;({ safeApiKit, signer } = await getServiceClient(
- '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
- ))
+ safeApiKit = getApiKit()
+ signer1 = new ethers.Wallet(PRIVATE_KEY_1)
+ signer2 = new ethers.Wallet(PRIVATE_KEY_2)
})
it('should fail if Label is empty', async () => {
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
- const delegatorAddress = await signer.getAddress()
+ const delegatorAddress = await signer1.getAddress()
const delegateConfig: AddSafeDelegateProps = {
delegateAddress,
delegatorAddress,
- signer,
+ signer: signer1,
label: ''
}
await chai
@@ -33,11 +37,11 @@ describe('addSafeDelegate', () => {
it('should fail if Safe delegate address is empty', async () => {
const delegateAddress = ''
- const delegatorAddress = await signer.getAddress()
+ const delegatorAddress = await signer1.getAddress()
const delegateConfig: AddSafeDelegateProps = {
delegateAddress,
delegatorAddress,
- signer,
+ signer: signer1,
label: 'Label'
}
await chai
@@ -51,7 +55,7 @@ describe('addSafeDelegate', () => {
const delegateConfig: AddSafeDelegateProps = {
delegateAddress,
delegatorAddress,
- signer,
+ signer: signer1,
label: 'Label'
}
await chai
@@ -62,12 +66,12 @@ describe('addSafeDelegate', () => {
it('should fail if Safe address is not checksummed', async () => {
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'.toLowerCase()
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
- const delegatorAddress = await signer.getAddress()
+ const delegatorAddress = await signer1.getAddress()
const delegateConfig: AddSafeDelegateProps = {
safeAddress,
delegateAddress,
delegatorAddress,
- signer,
+ signer: signer1,
label: 'Label'
}
await chai
@@ -78,12 +82,12 @@ describe('addSafeDelegate', () => {
it('should fail if Safe delegate address is not checksummed', async () => {
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'.toLowerCase()
- const delegatorAddress = await signer.getAddress()
+ const delegatorAddress = await signer1.getAddress()
const delegateConfig: AddSafeDelegateProps = {
safeAddress,
delegateAddress,
delegatorAddress,
- signer,
+ signer: signer1,
label: 'Label'
}
await chai
@@ -94,12 +98,12 @@ describe('addSafeDelegate', () => {
it('should fail if Safe delegator address is not checksummed', async () => {
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
- const delegatorAddress = (await signer.getAddress()).toLowerCase()
+ const delegatorAddress = (await signer1.getAddress()).toLowerCase()
const delegateConfig: AddSafeDelegateProps = {
safeAddress,
delegateAddress,
delegatorAddress,
- signer,
+ signer: signer1,
label: 'Label'
}
await chai
@@ -110,12 +114,12 @@ describe('addSafeDelegate', () => {
it('should fail if Safe does not exist', async () => {
const safeAddress = '0x1dF62f291b2E969fB0849d99D9Ce41e2F137006e'
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
- const delegatorAddress = await signer.getAddress()
+ const delegatorAddress = await signer1.getAddress()
const delegateConfig: AddSafeDelegateProps = {
safeAddress,
delegateAddress,
delegatorAddress,
- signer,
+ signer: signer1,
label: 'Label'
}
await chai
@@ -124,17 +128,14 @@ describe('addSafeDelegate', () => {
})
it('should fail if the signer is not an owner of the Safe', async () => {
- const { safeApiKit, signer } = await getServiceClient(
- '0xb0057716d5917badaf911b193b12b910811c1497b5bada8d7711f758981c3773'
- )
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
- const delegatorAddress = await signer.getAddress()
+ const delegatorAddress = await signer2.getAddress()
const delegateConfig: AddSafeDelegateProps = {
safeAddress,
delegateAddress,
delegatorAddress,
- signer,
+ signer: signer2,
label: 'Label'
}
await chai
@@ -147,12 +148,12 @@ describe('addSafeDelegate', () => {
it('should add a new delegate', async () => {
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
- const delegatorAddress = await signer.getAddress()
+ const delegatorAddress = await signer1.getAddress()
const delegateConfig: AddSafeDelegateProps = {
safeAddress,
delegateAddress,
delegatorAddress,
- signer,
+ signer: signer1,
label: 'Label'
}
const { results: initialDelegates } = await safeApiKit.getSafeDelegates({ safeAddress })
@@ -170,11 +171,11 @@ describe('addSafeDelegate', () => {
it('should add a new delegate without specifying a Safe', async () => {
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
- const delegatorAddress = await signer.getAddress()
+ const delegatorAddress = await signer1.getAddress()
const delegateConfig: AddSafeDelegateProps = {
delegateAddress,
delegatorAddress,
- signer,
+ signer: signer1,
label: 'Label'
}
const { results: initialDelegates } = await safeApiKit.getSafeDelegates({
@@ -200,13 +201,13 @@ describe('addSafeDelegate', () => {
const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}`
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
const eip3770DelegateAddress = `${config.EIP_3770_PREFIX}:${delegateAddress}`
- const delegatorAddress = await signer.getAddress()
+ const delegatorAddress = await signer1.getAddress()
const eip3770DelegatorAddress = `${config.EIP_3770_PREFIX}:${delegatorAddress}`
const delegateConfig: AddSafeDelegateProps = {
safeAddress: eip3770SafeAddress,
delegateAddress: eip3770DelegateAddress,
delegatorAddress: eip3770DelegatorAddress,
- signer,
+ signer: signer1,
label: 'Label'
}
const { results: initialDelegates } = await safeApiKit.getSafeDelegates({
diff --git a/packages/api-kit/tests/e2e/confirmTransaction.test.ts b/packages/api-kit/tests/e2e/confirmTransaction.test.ts
index a031faa10..c2878e7f5 100644
--- a/packages/api-kit/tests/e2e/confirmTransaction.test.ts
+++ b/packages/api-kit/tests/e2e/confirmTransaction.test.ts
@@ -2,40 +2,31 @@ import Safe, {
EthSafeSignature,
buildSignatureBytes,
SigningMethod,
- buildContractSignature,
- EthAdapter
+ buildContractSignature
} from '@safe-global/protocol-kit'
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 () => {
@@ -51,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 = {
@@ -62,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
})
@@ -80,7 +71,7 @@ describe('proposeTransaction', () => {
)
protocolKit = await protocolKit.connect({
- ethAdapter: ethAdapter2,
+ signer: PRIVATE_KEY_2,
safeAddress: signerSafeAddress
})
signerSafeTx = await protocolKit.signTransaction(
@@ -95,7 +86,7 @@ describe('proposeTransaction', () => {
)
protocolKit = await protocolKit.connect({
- ethAdapter: ethAdapter1,
+ signer: PRIVATE_KEY_1,
safeAddress
})
@@ -104,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..fc6f63f06 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 () => {
diff --git a/packages/api-kit/tests/e2e/getNextNonce.test.ts b/packages/api-kit/tests/e2e/getNextNonce.test.ts
index 4120a13a5..736b4e13f 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 () => {
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 b88b2c863..a3efeff0d 100644
--- a/packages/api-kit/tests/e2e/getSafeDelegates.test.ts
+++ b/packages/api-kit/tests/e2e/getSafeDelegates.test.ts
@@ -1,20 +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'
- ))
+ safeApiKit = getApiKit()
+ 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 4e642f21f..6c43b792a 100644
--- a/packages/api-kit/tests/e2e/removeSafeDelegate.test.ts
+++ b/packages/api-kit/tests/e2e/removeSafeDelegate.test.ts
@@ -1,20 +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'
- ))
+ safeApiKit = getApiKit()
+ 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 002fb3420..12b78c779 100644
--- a/packages/api-kit/tests/endpoint/index.test.ts
+++ b/packages/api-kit/tests/endpoint/index.test.ts
@@ -7,17 +7,18 @@ 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'
chai.use(chaiAsPromised)
chai.use(sinonChai)
+const PRIVATE_KEY_1 = '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
+
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}`
const randomAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'
@@ -28,22 +29,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}`
})
@@ -364,12 +361,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({
@@ -413,12 +409,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({
@@ -651,12 +646,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/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..f265861ba
--- /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.create({ 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..85b924c62 100644
--- a/packages/auth-kit/README.md
+++ b/packages/auth-kit/README.md
@@ -8,9 +8,9 @@ The Auth Kit provides a way to authenticate blockchain accounts using email addr
## Reference
-- [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
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..cb3e570fb 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
+ provider: safeAuthPack?.getProvider() as Eip1193Provider,
+ safeAddress
})
// Create transaction
diff --git a/packages/auth-kit/package.json b/packages/auth-kit/package.json
index a60365865..a4e2ead8e 100644
--- a/packages/auth-kit/package.json
+++ b/packages/auth-kit/package.json
@@ -41,7 +41,7 @@
},
"dependencies": {
"@safe-global/api-kit": "^2.3.0",
- "@safe-global/protocol-kit": "^3.0.2",
+ "@safe-global/protocol-kit": "3.1.0-alpha.0",
"@web3auth/safeauth-embed": "^0.0.0",
"ethers": "^6.7.1"
}
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..b1d431b41 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://rpc.ankr.com/eth_sepolia' }
}
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..b8c81aa96 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,
+ provider: authProvider,
safeAddress: selectedSafe,
isL1SafeSingleton: true
})
diff --git a/packages/onramp-kit/package.json b/packages/onramp-kit/package.json
index 3ce950ddf..b34fd817b 100644
--- a/packages/onramp-kit/package.json
+++ b/packages/onramp-kit/package.json
@@ -35,9 +35,9 @@
"access": "public"
},
"dependencies": {
- "@monerium/sdk": "^2.9.0",
+ "@monerium/sdk": "^2.12.0",
"@safe-global/api-kit": "^2.3.0",
- "@safe-global/protocol-kit": "^3.0.2",
+ "@safe-global/protocol-kit": "3.1.0-alpha.0",
"@safe-global/safe-core-sdk-types": "^4.0.2",
"@stripe/crypto": "^0.0.4",
"@stripe/stripe-js": "^1.54.2",
diff --git a/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.test.ts b/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.test.ts
index ae567d424..fd29fbd2d 100644
--- a/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.test.ts
+++ b/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.test.ts
@@ -44,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
@@ -119,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',
@@ -139,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))
@@ -163,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'))
@@ -225,15 +225,16 @@ describe('SafeMoneriumClient', () => {
jest.spyOn(protocolKitPackage, 'getSignMessageLibContract').mockResolvedValueOnce({
safeVersion: '1.3.0',
contractName: 'signMessageLibVersion',
- contract: new Contract('target', []),
- adapter: protocolKit.getEthAdapter() as protocolKitPackage.EthersAdapter,
+ 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({
@@ -267,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')
@@ -284,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 3991d9728..a9b891bf9 100644
--- a/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.ts
+++ b/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.ts
@@ -10,7 +10,7 @@ import {
placeOrderMessage,
ClassOptions
} from '@monerium/sdk'
-import Safe, { getSignMessageLibContract, EthAdapter } from '@safe-global/protocol-kit'
+import Safe, { getSignMessageLibContract, SafeProvider } from '@safe-global/protocol-kit'
import SafeApiKit from '@safe-global/api-kit'
import {
decodeSignatureData,
@@ -29,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
@@ -40,7 +40,7 @@ export class SafeMoneriumClient extends MoneriumClient {
super(moneriumOptions)
this.#protocolKit = protocolKit
- this.#ethAdapter = protocolKit.getEthAdapter()
+ this.#safeProvider = protocolKit.getSafeProvider()
}
/**
@@ -119,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
})
@@ -147,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
})
@@ -207,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/hardhat.config.ts b/packages/protocol-kit/hardhat.config.ts
index 5ab637921..2e153c389 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'
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 {
- const { ethAdapter, isL1SafeSingleton, contractNetworks } = config
-
- this.#ethAdapter = ethAdapter
+ 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.create(
+ {
+ 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.create(
+ {
+ 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
)
}
@@ -150,9 +159,11 @@ 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
}
@@ -198,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
@@ -222,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
@@ -248,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
}
/**
@@ -281,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
}
@@ -349,7 +360,7 @@ class Safe {
* @returns The chainId of the connected network
*/
async getChainId(): Promise {
- return this.#ethAdapter.getChainId()
+ return this.#safeProvider.getChainId()
}
/**
@@ -358,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())
}
/**
@@ -396,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)
}
@@ -475,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
})
@@ -488,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
})
@@ -560,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
}
@@ -592,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(
@@ -674,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)
}
/**
@@ -703,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(
@@ -787,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)
@@ -797,9 +809,7 @@ 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,
@@ -1145,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))
@@ -1193,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 &&
@@ -1219,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,
{
@@ -1246,7 +1253,7 @@ class Safe {
const customContracts = this.#contractManager.contractNetworks?.[chainId.toString()]
const isL1SafeSingleton = this.#contractManager.isL1SafeSingleton
- const safeSingletonContract = await this.#ethAdapter.getSafeContract({
+ const safeSingletonContract = await this.#safeProvider.getSafeContract({
safeVersion,
isL1SafeSingleton,
customContractAbi: customContracts?.safeSingletonAbi,
@@ -1347,12 +1354,12 @@ 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 ethAdapter.getSafeContract({
+ const safeSingletonContract = await safeProvider.getSafeContract({
safeVersion,
isL1SafeSingleton,
customContractAddress: customContracts?.safeSingletonAddress,
@@ -1361,14 +1368,14 @@ class Safe {
// 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
@@ -1409,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()]
})
@@ -1445,10 +1452,10 @@ class Safe {
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()]
})
@@ -1506,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 62%
rename from packages/protocol-kit/src/safeFactory/index.ts
rename to packages/protocol-kit/src/SafeFactory.ts
index cbb65a106..2e6bee9e6 100644
--- a/packages/protocol-kit/src/safeFactory/index.ts
+++ b/packages/protocol-kit/src/SafeFactory.ts
@@ -16,86 +16,73 @@ import {
SafeAccountConfig,
SafeContractImplementationType,
SafeDeploymentConfig,
- SafeProxyFactoryContractImplementationType
+ SafeProxyFactoryContractImplementationType,
+ SafeProviderConfig,
+ SafeFactoryConfig,
+ SafeFactoryInitConfig,
+ DeploySafeProps
} from '@safe-global/protocol-kit/types'
-import { EthAdapter } from '@safe-global/protocol-kit/adapters/ethAdapter'
-import { 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!: SafeProxyFactoryContractImplementationType
#safeContract!: SafeContractImplementationType
+ #provider!: SafeProviderConfig['provider']
+ #signer?: SafeFactoryConfig['signer']
+ #safeProvider!: SafeProvider
static async create({
- ethAdapter,
+ provider,
+ signer,
safeVersion = DEFAULT_SAFE_VERSION,
isL1SafeSingleton = false,
contractNetworks
}: SafeFactoryConfig): Promise {
const safeFactorySdk = new SafeFactory()
- await safeFactorySdk.init({ ethAdapter, safeVersion, isL1SafeSingleton, contractNetworks })
+ await safeFactorySdk.init({
+ provider,
+ signer,
+ safeVersion,
+ isL1SafeSingleton,
+ contractNetworks
+ })
return safeFactorySdk
}
private async init({
- ethAdapter,
+ provider,
+ signer,
safeVersion,
isL1SafeSingleton,
contractNetworks
}: SafeFactoryInitConfig): Promise {
- this.#ethAdapter = ethAdapter
+ 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 {
@@ -107,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
@@ -124,7 +111,7 @@ class SafeFactory {
}
return predictSafeAddress({
- ethAdapter: this.#ethAdapter,
+ safeProvider: this.#safeProvider,
chainId,
safeAccountConfig,
safeDeploymentConfig,
@@ -142,24 +129,20 @@ 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.createProxyWithOptions({
safeSingletonAddress: await this.#safeContract.getAddress(),
initializer,
@@ -170,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,
+ provider: this.#provider,
+ signer: this.#signer,
safeAddress,
isL1SafeSingleton: this.#isL1SafeSingleton,
contractNetworks: this.#contractNetworks
diff --git a/packages/protocol-kit/src/adapters/ethers/EthersAdapter.ts b/packages/protocol-kit/src/SafeProvider.ts
similarity index 58%
rename from packages/protocol-kit/src/adapters/ethers/EthersAdapter.ts
rename to packages/protocol-kit/src/SafeProvider.ts
index 5a220e2d2..ea8da1fba 100644
--- a/packages/protocol-kit/src/adapters/ethers/EthersAdapter.ts
+++ b/packages/protocol-kit/src/SafeProvider.ts
@@ -1,11 +1,20 @@
+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 {
EIP712TypedDataMessage,
EIP712TypedDataTx,
Eip3770Address,
SafeEIP712Args
} from '@safe-global/safe-core-sdk-types'
-import { ethers, TransactionResponse, AbstractSigner, Provider } from 'ethers'
import {
getCompatibilityFallbackHandlerContractInstance,
getCreateCallContractInstance,
@@ -15,52 +24,56 @@ import {
getSafeProxyFactoryContractInstance,
getSignMessageLibContractInstance,
getSimulateTxAccessorContractInstance
-} from './contracts/contractInstancesEthers'
-import { isTypedDataSigner, isSignerCompatible } from './utils'
-import { EthAdapter, EthAdapterTransaction, GetContractProps } from '../ethAdapter'
-
-type Ethers = typeof ethers
+} 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)
+ }
-export interface EthersAdapterConfig {
- /** ethers - Ethers v6 library */
- ethers: Ethers
- /** signerOrProvider - Ethers signer or provider */
- signerOrProvider: AbstractSigner | Provider
-}
+ this.provider = provider
+ this.signer = signer
+ }
-class EthersAdapter implements EthAdapter {
- #ethers: Ethers
- #signer?: AbstractSigner
- #provider: Provider
+ getExternalProvider(): Provider {
+ return this.#externalProvider
+ }
- constructor({ ethers, signerOrProvider }: EthersAdapterConfig) {
- if (!ethers) {
- throw new Error('ethers property missing from options')
+ 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
}
- 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
+
+ if (this.signer) {
+ return this.#externalProvider.getSigner(this.signer)
}
- }
- getProvider(): Provider {
- return this.#provider
- }
+ if (this.#externalProvider instanceof BrowserProvider) {
+ return this.#externalProvider.getSigner()
+ }
- getSigner(): AbstractSigner | undefined {
- return this.#signer
+ return undefined
}
isAddress(address: string): boolean {
- return this.#ethers.isAddress(address)
+ return ethers.isAddress(address)
}
async getEip3770Address(fullAddress: string): Promise {
@@ -69,19 +82,19 @@ class EthersAdapter implements EthAdapter {
}
async getBalance(address: string, blockTag?: string | number): Promise {
- return this.#provider.getBalance(address, blockTag)
+ return this.#externalProvider.getBalance(address, blockTag)
}
async getNonce(address: string, blockTag?: string | number): Promise {
- return this.#provider.getTransactionCount(address, blockTag)
+ return this.#externalProvider.getTransactionCount(address, blockTag)
}
async getChainId(): Promise {
- return (await this.#provider.getNetwork()).chainId
+ return (await this.#externalProvider.getNetwork()).chainId
}
getChecksummedAddress(address: string): string {
- return this.#ethers.getAddress(address)
+ return ethers.getAddress(address)
}
async getSafeContract({
@@ -104,7 +117,7 @@ class EthersAdapter implements EthAdapter {
customContractAddress,
customContractAbi
}: GetContractProps) {
- const signerOrProvider = this.#signer || this.#provider
+ const signerOrProvider = (await this.getExternalSigner()) || this.#externalProvider
return getSafeProxyFactoryContractInstance(
safeVersion,
this,
@@ -188,43 +201,51 @@ class EthersAdapter implements EthAdapter {
}
async getContractCode(address: string, blockTag?: string | number): Promise {
- return this.#provider.getCode(address, blockTag)
+ return this.#externalProvider.getCode(address, blockTag)
}
async isContractDeployed(address: string, blockTag?: string | number): Promise {
- const contractCode = await this.#provider.getCode(address, blockTag)
+ const contractCode = await this.#externalProvider.getCode(address, blockTag)
return contractCode !== '0x'
}
async getStorageAt(address: string, position: string): Promise {
- const content = await this.#provider.getStorage(address, position)
+ const content = await this.#externalProvider.getStorage(address, position)
const decodedContent = this.decodeParameters(['address'], content)
return decodedContent[0]
}
async getTransaction(transactionHash: string): Promise {
- return this.#provider.getTransaction(transactionHash) as Promise
+ return this.#externalProvider.getTransaction(transactionHash) as Promise
}
async getSignerAddress(): Promise {
- return this.#signer?.getAddress()
+ const signer = await this.getExternalSigner()
+
+ return signer?.getAddress()
}
- signMessage(message: string): Promise {
- if (!this.#signer) {
- throw new Error('EthAdapter must be initialized with a signer to use this method')
+ 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 = this.#ethers.getBytes(message)
- return this.#signer.signMessage(messageArray)
+ const messageArray = ethers.getBytes(message)
+
+ return 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')
+ const signer = await this.getExternalSigner()
+
+ if (!signer) {
+ throw new Error('SafeProvider must be initialized with a signer to use this method')
}
- if (isTypedDataSigner(this.#signer)) {
+
+ if (isTypedDataSigner(signer)) {
const typedData = generateTypedData(safeEIP712Args)
- const signature = await this.#signer.signTypedData(
+ const signature = await signer.signTypedData(
typedData.domain,
typedData.primaryType === 'SafeMessage'
? { SafeMessage: (typedData as EIP712TypedDataMessage).types.SafeMessage }
@@ -237,22 +258,22 @@ class EthersAdapter implements EthAdapter {
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()
+ async estimateGas(transaction: SafeProviderTransaction): Promise {
+ return (await this.#externalProvider.estimateGas(transaction)).toString()
}
- call(transaction: EthAdapterTransaction, blockTag?: string | number): Promise {
- return this.#provider.call({ ...transaction, blockTag })
+ call(transaction: SafeProviderTransaction, blockTag?: string | number): Promise {
+ return this.#externalProvider.call({ ...transaction, blockTag })
}
// TODO: fix anys
encodeParameters(types: string[], values: any[]): string {
- return new this.#ethers.AbiCoder().encode(types, values)
+ return new ethers.AbiCoder().encode(types, values)
}
decodeParameters(types: string[], values: string): { [key: string]: any } {
- return new this.#ethers.AbiCoder().decode(types, values)
+ return new ethers.AbiCoder().decode(types, values)
}
}
-export default EthersAdapter
+export default SafeProvider
diff --git a/packages/protocol-kit/src/adapters/BaseContract.ts b/packages/protocol-kit/src/adapters/BaseContract.ts
deleted file mode 100644
index 0767683d8..000000000
--- a/packages/protocol-kit/src/adapters/BaseContract.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import { contractName, getContractDeployment } from '@safe-global/protocol-kit/contracts/config'
-import { SafeVersion } from '@safe-global/safe-core-sdk-types'
-
-/**
- * Abstract class BaseContract serves as a base for creating a contract for a specific adapter (Ethers.js, Web3.js, or viem.js)
- * This class is designed to be extended by adapter-specific abstract classes, such as BaseContractEthers, BaseContractWeb3, and BaseContractViem.
- * It includes the core logic for selecting the appropriate ABI and the address from contract deployments.
- *
- * @template ContractAbiType - The ABI associated with the contract.
- *
- * Example subclasses extending this base class:
- * - BaseContractEthers extends BaseContract
- * - BaseContractWeb3 extends BaseContract
- * - BaseContractViem extends BaseContract
- */
-abstract class BaseContract {
- contractAbi: ContractAbiType
- contractAddress: string
-
- abstract contractName: contractName
- abstract safeVersion: SafeVersion
-
- abstract contract: unknown // This needs to be implemented for each adapter.
- abstract adapter: unknown // This needs to be implemented for each adapter.
-
- /**
- * Constructs a new BaseContract instance.
- *
- * @param contractName - The contract name.
- * @param chainId - The chain ID of the contract.
- * @param defaultAbi - The hardcoded ABI of the contract.
- * @param safeVersion - The version of the contract.
- * @param customContractAddress - Optional custom address for the contract.
- * @param customContractAbi - Optional custom ABI for the contract.
- * @throws Will throw an error if the contract address is invalid.
- */
- constructor(
- contractName: contractName,
- chainId: bigint,
- defaultAbi: ContractAbiType,
- safeVersion: SafeVersion,
- customContractAddress?: string,
- customContractAbi?: ContractAbiType
- ) {
- const deployment = getContractDeployment(safeVersion, chainId, contractName)
-
- const contractAddress = customContractAddress || deployment?.defaultAddress
-
- if (!contractAddress) {
- throw new Error(`Invalid ${contractName.replace('Version', '')} contract address`)
- }
-
- this.contractAddress = contractAddress
- this.contractAbi =
- customContractAbi ||
- (deployment?.abi as ContractAbiType) || // this cast is required because abi is set as any[] in safe-deployments
- defaultAbi // if no customAbi and no abi is present in the safe-deployments we use our hardcoded abi
- }
-}
-
-export default BaseContract
diff --git a/packages/protocol-kit/src/adapters/ethAdapter.ts b/packages/protocol-kit/src/adapters/ethAdapter.ts
deleted file mode 100644
index 6512a5e60..000000000
--- a/packages/protocol-kit/src/adapters/ethAdapter.ts
+++ /dev/null
@@ -1,95 +0,0 @@
-import { AbiItem } from 'web3-utils'
-import { Eip3770Address, SafeEIP712Args, SafeVersion } from 'packages/safe-core-sdk-types'
-import {
- CompatibilityFallbackHandlerContractImplementationType,
- CreateCallContractImplementationType,
- MultiSendCallOnlyContractImplementationType,
- MultiSendContractImplementationType,
- SafeContractImplementationType,
- SafeProxyFactoryContractImplementationType,
- SignMessageLibContractImplementationType,
- SimulateTxAccessorContractImplementationType
-} from '../types'
-
-export interface EthAdapterTransaction {
- to: string
- from: string
- data: string
- value?: string
- gasPrice?: number | string
- gasLimit?: number | string
- maxFeePerGas?: number | string
- maxPriorityFeePerGas?: number | string
-}
-
-export interface GetContractProps {
- safeVersion: SafeVersion
- customContractAddress?: string
- customContractAbi?: AbiItem | AbiItem[]
- isL1SafeSingleton?: boolean
-}
-
-export interface EthAdapter {
- isAddress(address: string): boolean
- getEip3770Address(fullAddress: string): Promise
- getBalance(address: string, defaultBlock?: string | number): Promise
- getNonce(address: string, defaultBlock?: string | number): Promise
- getChainId(): Promise
- getChecksummedAddress(address: string): string
- getSafeContract({
- safeVersion,
- customContractAddress,
- customContractAbi,
- isL1SafeSingleton
- }: GetContractProps): Promise
- getMultiSendContract({
- safeVersion,
- customContractAddress,
- customContractAbi
- }: GetContractProps): Promise
- getMultiSendCallOnlyContract({
- safeVersion,
- customContractAddress,
- customContractAbi
- }: GetContractProps): Promise
- getCompatibilityFallbackHandlerContract({
- safeVersion,
- customContractAddress,
- customContractAbi
- }: GetContractProps): Promise
- getSafeProxyFactoryContract({
- safeVersion,
- customContractAddress,
- customContractAbi
- }: GetContractProps): Promise
- getSignMessageLibContract({
- safeVersion,
- customContractAddress,
- customContractAbi
- }: GetContractProps): Promise
- getCreateCallContract({
- safeVersion,
- customContractAddress,
- customContractAbi
- }: GetContractProps): Promise
- getSimulateTxAccessorContract({
- safeVersion,
- customContractAddress,
- customContractAbi
- }: GetContractProps): Promise
- getContractCode(address: string, defaultBlock?: string | number): Promise
- isContractDeployed(address: string, defaultBlock?: string | number): Promise
- getStorageAt(address: string, position: string): Promise
- // TODO: review all any here
- getTransaction(transactionHash: string): Promise
- getSignerAddress(): Promise
- signMessage(message: string): Promise
- signTypedData(safeEIP712Args: SafeEIP712Args, signTypedDataVersion?: string): Promise
- estimateGas(
- transaction: EthAdapterTransaction,
- callback?: (error: Error, gas: number) => void
- ): Promise
- call(transaction: EthAdapterTransaction, defaultBlock?: string | number): Promise
- encodeParameters(types: string[], values: any[]): string
- decodeParameters(types: any[], values: string): { [key: string]: any }
-}
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 9c0429941..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. 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/BaseContractEthers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/BaseContractEthers.ts
deleted file mode 100644
index 50963d29f..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/BaseContractEthers.ts
+++ /dev/null
@@ -1,87 +0,0 @@
-import { Abi } from 'abitype'
-import { Contract, ContractRunner, InterfaceAbi } from 'ethers'
-
-import { contractName } from '@safe-global/protocol-kit/contracts/config'
-import BaseContract from '@safe-global/protocol-kit/adapters/BaseContract'
-import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter'
-import {
- EncodeFunction,
- EstimateGasFunction,
- EthersTransactionOptions,
- GetAddressFunction,
- SafeVersion
-} from '@safe-global/safe-core-sdk-types'
-
-/**
- * Abstract class BaseContractEthers extends BaseContract to specifically integrate with the Ethers.js v6 library.
- * It is designed to be instantiated for different contracts.
- *
- * This abstract class sets up the Ethers v6 Contract object that interacts with the smart contract.
- *
- * Subclasses of BaseContractEthers are expected to represent specific contracts.
- *
- * @template ContractAbiType - The ABI type specific to the version of the contract, extending InterfaceAbi from Ethers.
- * @extends BaseContract - Extends the generic BaseContract with Ethers-specific implementation.
- *
- * Example subclasses:
- * - SafeBaseContractEthers extends BaseContractEthers
- * - CreateCallBaseContractEthers extends BaseContractEthers
- * - SafeProxyFactoryBaseContractEthers extends BaseContractEthers
- */
-abstract class BaseContractEthers<
- ContractAbiType extends InterfaceAbi & Abi
-> extends BaseContract {
- contract: Contract
- adapter: EthersAdapter
-
- /**
- * @constructor
- * Constructs an instance of BaseContractEthers.
- *
- * @param contractName - The contract name.
- * @param chainId - The chain ID of the contract.
- * @param ethersAdapter - An instance of EthersAdapter.
- * @param defaultAbi - The default ABI for the contract. It should be compatible with the specific version of the contract.
- * @param safeVersion - The version of the Safe contract.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the ABI is derived from the Safe deployments or the defaultAbi is used.
- */
- constructor(
- contractName: contractName,
- chainId: bigint,
- ethersAdapter: EthersAdapter,
- defaultAbi: ContractAbiType,
- safeVersion: SafeVersion,
- customContractAddress?: string,
- customContractAbi?: ContractAbiType,
- runner?: ContractRunner | null
- ) {
- super(contractName, chainId, defaultAbi, safeVersion, customContractAddress, customContractAbi)
-
- this.adapter = ethersAdapter
- this.contract = new Contract(
- this.contractAddress,
- this.contractAbi,
- runner || this.adapter.getSigner()
- )
- }
-
- getAddress: GetAddressFunction = () => {
- return this.contract.getAddress()
- }
-
- encode: EncodeFunction = (functionToEncode, args) => {
- return this.contract.interface.encodeFunctionData(functionToEncode, args as ReadonlyArray<[]>)
- }
-
- estimateGas: EstimateGasFunction = (
- functionToEstimate,
- args,
- options = {}
- ) => {
- const contractMethodToEstimate = this.contract.getFunction(functionToEstimate)
- return contractMethodToEstimate.estimateGas(...(args as ReadonlyArray<[]>), options)
- }
-}
-
-export default BaseContractEthers
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 1cef4e9c9..000000000
--- a/packages/protocol-kit/src/adapters/ethers/contracts/contractInstancesEthers.ts
+++ /dev/null
@@ -1,375 +0,0 @@
-import { AbstractSigner, Provider } from 'ethers'
-import { AbiItem } from 'web3-utils'
-import {
- DeepWriteable,
- SafeVersion,
- SafeContract_v1_3_0_Abi,
- SafeContract_v1_4_1_Abi,
- SafeContract_v1_2_0_Abi,
- SafeContract_v1_1_1_Abi,
- SafeContract_v1_0_0_Abi,
- CompatibilityFallbackHandlerContract_v1_4_1_Abi,
- CompatibilityFallbackHandlerContract_v1_3_0_Abi,
- MultiSendContract_v1_4_1_Abi,
- MultiSendContract_v1_3_0_Abi,
- MultiSendContract_v1_1_1_Abi,
- MultiSendCallOnlyContract_v1_4_1_Abi,
- MultiSendCallOnlyContract_v1_3_0_Abi,
- SafeProxyFactoryContract_v1_4_1_Abi,
- SafeProxyFactoryContract_v1_3_0_Abi,
- SafeProxyFactoryContract_v1_1_1_Abi,
- SafeProxyFactoryContract_v1_0_0_Abi,
- SignMessageLibContract_v1_4_1_Abi,
- SignMessageLibContract_v1_3_0_Abi,
- CreateCallContract_v1_4_1_Abi,
- CreateCallContract_v1_3_0_Abi,
- SimulateTxAccessorContract_v1_4_1_Abi,
- SimulateTxAccessorContract_v1_3_0_Abi
-} from '@safe-global/safe-core-sdk-types'
-import CreateCallContract_v1_3_0_Ethers from './CreateCall/v1.3.0/CreateCallContract_v1_3_0_Ethers'
-import CreateCallContract_v1_4_1_Ethers from './CreateCall/v1.4.1/CreateCallContract_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 './MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0_Ethers'
-import MultiSendCallOnlyContract_v1_4_1_Ethers from './MultiSend/v1.4.1/MultiSendCallOnlyContract_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 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 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'
-import CompatibilityFallbackHandlerContract_v1_3_0_Ethers from './CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0_Ethers'
-import CompatibilityFallbackHandlerContract_v1_4_1_Ethers from './CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1_Ethers'
-import EthersAdapter from '../EthersAdapter'
-
-export async function getSafeContractInstance(
- safeVersion: SafeVersion,
- ethersAdapter: EthersAdapter,
- contractAddress?: string,
- customContractAbi?: AbiItem | AbiItem[] | undefined,
- isL1SafeSingleton?: boolean
-): Promise<
- | 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
-> {
- const chainId = await ethersAdapter.getChainId()
-
- switch (safeVersion) {
- case '1.4.1':
- return new SafeContract_v1_4_1_Ethers(
- chainId,
- ethersAdapter,
- isL1SafeSingleton,
- contractAddress,
- customContractAbi as DeepWriteable
- )
-
- case '1.3.0':
- return new SafeContract_v1_3_0_Ethers(
- chainId,
- ethersAdapter,
- isL1SafeSingleton,
- contractAddress,
- customContractAbi as DeepWriteable
- )
-
- case '1.2.0':
- return new SafeContract_v1_2_0_Ethers(
- chainId,
- ethersAdapter,
- isL1SafeSingleton,
- contractAddress,
- customContractAbi as DeepWriteable
- )
-
- case '1.1.1':
- return new SafeContract_v1_1_1_Ethers(
- chainId,
- ethersAdapter,
- isL1SafeSingleton,
- contractAddress,
- customContractAbi as DeepWriteable
- )
-
- case '1.0.0':
- return new SafeContract_v1_0_0_Ethers(
- chainId,
- ethersAdapter,
- isL1SafeSingleton,
- contractAddress,
- customContractAbi as DeepWriteable
- )
-
- default:
- throw new Error('Invalid Safe version')
- }
-}
-
-export async function getCompatibilityFallbackHandlerContractInstance(
- safeVersion: SafeVersion,
- ethersAdapter: EthersAdapter,
- contractAddress?: string,
- customContractAbi?: AbiItem | AbiItem[] | undefined
-): Promise<
- | CompatibilityFallbackHandlerContract_v1_4_1_Ethers
- | CompatibilityFallbackHandlerContract_v1_3_0_Ethers
-> {
- const chainId = await ethersAdapter.getChainId()
- switch (safeVersion) {
- case '1.4.1':
- return new CompatibilityFallbackHandlerContract_v1_4_1_Ethers(
- chainId,
- ethersAdapter,
- contractAddress,
- customContractAbi as DeepWriteable
- )
-
- case '1.3.0':
- case '1.2.0':
- case '1.1.1':
- return new CompatibilityFallbackHandlerContract_v1_3_0_Ethers(
- chainId,
- ethersAdapter,
- contractAddress,
- customContractAbi as DeepWriteable
- )
-
- default:
- throw new Error('Invalid Safe version')
- }
-}
-
-export async function getMultiSendContractInstance(
- safeVersion: SafeVersion,
- ethersAdapter: EthersAdapter,
- contractAddress?: string,
- customContractAbi?: AbiItem | AbiItem[] | undefined
-): Promise<
- | MultiSendContract_v1_4_1_Ethers
- | MultiSendContract_v1_3_0_Ethers
- | MultiSendContract_v1_1_1_Ethers
-> {
- const chainId = await ethersAdapter.getChainId()
- switch (safeVersion) {
- case '1.4.1':
- return new MultiSendContract_v1_4_1_Ethers(
- chainId,
- ethersAdapter,
- contractAddress,
- customContractAbi as DeepWriteable
- )
-
- case '1.3.0':
- return new MultiSendContract_v1_3_0_Ethers(
- chainId,
- ethersAdapter,
- contractAddress,
- customContractAbi as DeepWriteable
- )
-
- case '1.2.0':
- case '1.1.1':
- case '1.0.0':
- return new MultiSendContract_v1_1_1_Ethers(
- chainId,
- ethersAdapter,
- contractAddress,
- customContractAbi as DeepWriteable
- )
-
- default:
- throw new Error('Invalid Safe version')
- }
-}
-
-export async function getMultiSendCallOnlyContractInstance(
- safeVersion: SafeVersion,
- ethersAdapter: EthersAdapter,
- contractAddress?: string,
- customContractAbi?: AbiItem | AbiItem[] | undefined
-): Promise {
- const chainId = await ethersAdapter.getChainId()
- switch (safeVersion) {
- case '1.4.1':
- return new MultiSendCallOnlyContract_v1_4_1_Ethers(
- chainId,
- ethersAdapter,
- contractAddress,
- customContractAbi as DeepWriteable
- )
-
- case '1.3.0':
- case '1.2.0':
- case '1.1.1':
- case '1.0.0':
- return new MultiSendCallOnlyContract_v1_3_0_Ethers(
- chainId,
- ethersAdapter,
- contractAddress,
- customContractAbi as DeepWriteable
- )
- default:
- throw new Error('Invalid Safe version')
- }
-}
-
-export async function getSafeProxyFactoryContractInstance(
- safeVersion: SafeVersion,
- ethersAdapter: EthersAdapter,
- // TODO: remove this ??
- signerOrProvider: AbstractSigner | Provider,
- contractAddress?: string,
- customContractAbi?: AbiItem | AbiItem[] | undefined
-): Promise<
- | SafeProxyFactoryContract_v1_4_1_Ethers
- | SafeProxyFactoryContract_v1_3_0_Ethers
- | SafeProxyFactoryContract_v1_1_1_Ethers
- | SafeProxyFactoryContract_v1_0_0_Ethers
-> {
- const chainId = await ethersAdapter.getChainId()
-
- switch (safeVersion) {
- case '1.4.1':
- return new SafeProxyFactoryContract_v1_4_1_Ethers(
- chainId,
- ethersAdapter,
- contractAddress,
- customContractAbi as DeepWriteable,
- signerOrProvider
- )
-
- case '1.3.0':
- return new SafeProxyFactoryContract_v1_3_0_Ethers(
- chainId,
- ethersAdapter,
- contractAddress,
- customContractAbi as DeepWriteable,
- signerOrProvider
- )
-
- case '1.2.0':
- case '1.1.1':
- return new SafeProxyFactoryContract_v1_1_1_Ethers(
- chainId,
- ethersAdapter,
- contractAddress,
- customContractAbi as DeepWriteable,
- signerOrProvider
- )
-
- case '1.0.0':
- return new SafeProxyFactoryContract_v1_0_0_Ethers(
- chainId,
- ethersAdapter,
- contractAddress,
- customContractAbi as DeepWriteable,
- signerOrProvider
- )
-
- default:
- throw new Error('Invalid Safe version')
- }
-}
-
-export async function getSignMessageLibContractInstance(
- safeVersion: SafeVersion,
- ethersAdapter: EthersAdapter,
- contractAddress?: string,
- customContractAbi?: AbiItem | AbiItem[] | undefined
-): Promise {
- const chainId = await ethersAdapter.getChainId()
-
- switch (safeVersion) {
- case '1.4.1':
- return new SignMessageLibContract_v1_4_1_Ethers(
- chainId,
- ethersAdapter,
- contractAddress,
- customContractAbi as DeepWriteable
- )
-
- case '1.3.0':
- return new SignMessageLibContract_v1_3_0_Ethers(
- chainId,
- ethersAdapter,
- contractAddress,
- customContractAbi as DeepWriteable
- )
-
- default:
- throw new Error('Invalid Safe version')
- }
-}
-
-export async function getCreateCallContractInstance(
- safeVersion: SafeVersion,
- ethersAdapter: EthersAdapter,
- contractAddress?: string,
- customContractAbi?: AbiItem | AbiItem[] | undefined
-): Promise {
- const chainId = await ethersAdapter.getChainId()
-
- switch (safeVersion) {
- case '1.4.1':
- return new CreateCallContract_v1_4_1_Ethers(
- chainId,
- ethersAdapter,
- contractAddress,
- customContractAbi as DeepWriteable
- )
-
- case '1.3.0':
- case '1.2.0':
- case '1.1.1':
- case '1.0.0':
- return new CreateCallContract_v1_3_0_Ethers(
- chainId,
- ethersAdapter,
- contractAddress,
- customContractAbi as DeepWriteable
- )
-
- default:
- throw new Error('Invalid Safe version')
- }
-}
-
-export async function getSimulateTxAccessorContractInstance(
- safeVersion: SafeVersion,
- ethersAdapter: EthersAdapter,
- contractAddress?: string,
- customContractAbi?: AbiItem | AbiItem[] | undefined
-): Promise {
- const chainId = await ethersAdapter.getChainId()
-
- switch (safeVersion) {
- case '1.4.1':
- return new SimulateTxAccessorContract_v1_4_1_Ethers(
- chainId,
- ethersAdapter,
- contractAddress,
- customContractAbi as DeepWriteable
- )
-
- case '1.3.0':
- return new SimulateTxAccessorContract_v1_3_0_Ethers(
- chainId,
- ethersAdapter,
- contractAddress,
- customContractAbi as DeepWriteable
- )
- 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 3fb72d3d5..000000000
--- a/packages/protocol-kit/src/adapters/ethers/index.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import EthersAdapter, { EthersAdapterConfig } from './EthersAdapter'
-import CreateCallBaseContractEthers from './contracts/CreateCall/CreateCallBaseContractEthers'
-import MultiSendBaseContractEthers from './contracts/MultiSend/MultiSendBaseContractEthers'
-import MultiSendCallOnlyBaseContractEthers from './contracts/MultiSend/MultiSendCallOnlyBaseContractEthers'
-import SafeBaseContractEthers from './contracts/Safe/SafeBaseContractEthers'
-import SafeProxyFactoryBaseContractEthers from './contracts/SafeProxyFactory/SafeProxyFactoryBaseContractEthers'
-import SignMessageLibBaseContractEthers from './contracts/SignMessageLib/SignMessageLibBaseContractEthers'
-
-export {
- CreateCallBaseContractEthers,
- EthersAdapter,
- EthersAdapterConfig,
- MultiSendCallOnlyBaseContractEthers,
- MultiSendBaseContractEthers,
- SafeBaseContractEthers,
- SafeProxyFactoryBaseContractEthers,
- SignMessageLibBaseContractEthers
-}
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 bb5990898..000000000
--- a/packages/protocol-kit/src/adapters/ethers/utils/index.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { ContractTransactionResponse, Provider, AbstractSigner } from 'ethers'
-import { EthersTransactionOptions, EthersTransactionResult } from '@safe-global/safe-core-sdk-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 f0f06b4e1..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. 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 c65723533..000000000
--- a/packages/protocol-kit/src/adapters/web3/Web3Adapter.ts
+++ /dev/null
@@ -1,277 +0,0 @@
-import { generateTypedData, validateEip3770Address } from '@safe-global/protocol-kit/utils'
-import { SigningMethod } from '@safe-global/protocol-kit/types'
-import { Eip3770Address, 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 {
- getCompatibilityFallbackHandlerContractInstance,
- getCreateCallContractInstance,
- getMultiSendCallOnlyContractInstance,
- getMultiSendContractInstance,
- getSafeContractInstance,
- getSafeProxyFactoryContractInstance,
- getSignMessageLibContractInstance,
- getSimulateTxAccessorContractInstance
-} from './contracts/contractInstancesWeb3'
-import { EthAdapter, EthAdapterTransaction, GetContractProps } from '../ethAdapter'
-
-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,
- customContractAddress,
- customContractAbi,
- isL1SafeSingleton
- }: GetContractProps) {
- return getSafeContractInstance(
- safeVersion,
- this,
- customContractAddress,
- customContractAbi,
- isL1SafeSingleton
- )
- }
-
- async getSafeProxyFactoryContract({
- safeVersion,
- customContractAddress,
- customContractAbi
- }: GetContractProps) {
- return getSafeProxyFactoryContractInstance(
- safeVersion,
- this,
- 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
- )
- }
-
- getContract(address: string, abi: 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/BaseContractWeb3.ts b/packages/protocol-kit/src/adapters/web3/contracts/BaseContractWeb3.ts
deleted file mode 100644
index 516b8c5de..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/BaseContractWeb3.ts
+++ /dev/null
@@ -1,84 +0,0 @@
-import { Abi } from 'abitype'
-import Contract from 'web3-eth-contract'
-import { AbiItem } from 'web3-utils'
-
-import { contractName } from '@safe-global/protocol-kit/contracts/config'
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import {
- EncodeFunction,
- EstimateGasFunction,
- GetAddressFunction,
- SafeVersion,
- Web3TransactionOptions
-} from '@safe-global/safe-core-sdk-types'
-import BaseContract from '@safe-global/protocol-kit/adapters/BaseContract'
-
-/**
- * Abstract class BaseContractWeb3 extends BaseContract to specifically integrate with the Web3.js library.
- * It is designed to be instantiated for different contracts.
- *
- * This abstract class sets up the Web3 Contract object that interacts with the smart contract.
- *
- * Subclasses of BaseContractWeb3 are expected to represent specific contracts.
- *
- * @template ContractAbiType - The ABI type specific to the version of the contract, extending InterfaceAbi from Web3.
- * @extends BaseContract - Extends the generic BaseContract with Web3-specific implementation.
- *
- * Example subclasses:
- * - SafeBaseContractWeb3 extends BaseContractWeb3
- * - CreateCallBaseContractWeb3 extends BaseContractWeb3
- * - SafeProxyFactoryBaseContractWeb3 extends BaseContractWeb3
- */
-abstract class BaseContractWeb3<
- ContractAbiType extends AbiItem[] & Abi
-> extends BaseContract {
- contract: Contract
- adapter: Web3Adapter
-
- /**
- * @constructor
- * Constructs an instance of BaseContractWeb3.
- *
- * @param contractName - The contract name.
- * @param chainId - The chain ID of the contract.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param defaultAbi - The default ABI for the contract. It should be compatible with the specific version of the contract.
- * @param safeVersion - The version of the Safe contract.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the ABI is derived from the Safe deployments or the defaultAbi is used.
- */
- constructor(
- contractName: contractName,
- chainId: bigint,
- web3Adapter: Web3Adapter,
- defaultAbi: ContractAbiType,
- safeVersion: SafeVersion,
- customContractAddress?: string,
- customContractAbi?: ContractAbiType
- ) {
- super(contractName, chainId, defaultAbi, safeVersion, customContractAddress, customContractAbi)
-
- this.adapter = web3Adapter
- this.contract = web3Adapter.getContract(this.contractAddress, this.contractAbi)
- }
-
- getAddress: GetAddressFunction = () => {
- return Promise.resolve(this.contract.options.address)
- }
-
- encode: EncodeFunction = (functionToEncode, args) => {
- return this.contract.methods[functionToEncode](...(args as Array<[]>)).encodeABI()
- }
-
- estimateGas: EstimateGasFunction = (
- functionToEstimate,
- args,
- options = {}
- ) => {
- return this.contract.methods[functionToEstimate](...(args as Array<[]>))
- .estimateGas(options)
- .then(BigInt)
- }
-}
-
-export default BaseContractWeb3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContractWeb3.ts b/packages/protocol-kit/src/adapters/web3/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContractWeb3.ts
deleted file mode 100644
index b65623ffc..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContractWeb3.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-import { Abi } from 'abitype'
-import { AbiItem } from 'web3-utils'
-
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import BaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/BaseContractWeb3'
-import { SafeVersion } from '@safe-global/safe-core-sdk-types'
-import { contractName } from '@safe-global/protocol-kit/contracts/config'
-
-/**
- * Abstract class CompatibilityFallbackHandlerBaseContractWeb3 extends BaseContractWeb3 to specifically integrate with the CompatibilityFallbackHandler contract.
- * It is designed to be instantiated for different versions of the Safe contract.
- *
- * Subclasses of CompatibilityFallbackHandlerBaseContractWeb3 are expected to represent specific versions of the contract.
- *
- * @template CompatibilityFallbackHandlerContractAbiType - The ABI type specific to the version of the CompatibilityFallbackHandler contract, extending InterfaceAbi from Web3.
- * @extends BaseContractWeb3 - Extends the generic BaseContractWeb3.
- *
- * Example subclasses:
- * - CompatibilityFallbackHandlerContract_v1_4_1_Web3 extends CompatibilityFallbackHandlerBaseContractWeb3
- * - CompatibilityFallbackHandlerContract_v1_3_0_Web3 extends CompatibilityFallbackHandlerBaseContractWeb3
- */
-abstract class CompatibilityFallbackHandlerBaseContractWeb3<
- CompatibilityFallbackHandlerContractAbiType extends AbiItem[] & Abi
-> extends BaseContractWeb3 {
- contractName: contractName
-
- /**
- * @constructor
- * Constructs an instance of CompatibilityFallbackHandlerBaseContractWeb3.
- *
- * @param chainId - The chain ID of the contract.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param defaultAbi - The default ABI for the CompatibilityFallbackHandler contract. It should be compatible with the specific version of the contract.
- * @param safeVersion - The version of the Safe contract.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the ABI is derived from the Safe deployments or the defaultAbi is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- defaultAbi: CompatibilityFallbackHandlerContractAbiType,
- safeVersion: SafeVersion,
- customContractAddress?: string,
- customContractAbi?: CompatibilityFallbackHandlerContractAbiType
- ) {
- const contractName = 'compatibilityFallbackHandler'
-
- super(
- contractName,
- chainId,
- web3Adapter,
- defaultAbi,
- safeVersion,
- customContractAddress,
- customContractAbi
- )
-
- this.contractName = contractName
- }
-}
-
-export default CompatibilityFallbackHandlerBaseContractWeb3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0_Web3.ts
deleted file mode 100644
index 202b8b06e..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0_Web3.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import CompatibilityFallbackHandlerBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContractWeb3'
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import {
- DeepWriteable,
- SafeVersion,
- CompatibilityFallbackHandlerContract_v1_3_0_Abi,
- CompatibilityFallbackHandlerContract_v1_3_0_Contract,
- compatibilityFallbackHandler_1_3_0_ContractArtifacts
-} from '@safe-global/safe-core-sdk-types'
-
-/**
- * CompatibilityFallbackHandlerContract_v1_3_0_Web3 is the implementation specific to the CompatibilityFallbackHandler contract version 1.3.0.
- *
- * This class specializes in handling interactions with the CompatibilityFallbackHandler contract version 1.3.0 using Web3.js.
- *
- * @extends CompatibilityFallbackHandlerBaseContractWeb3 - Inherits from CompatibilityFallbackHandlerBaseContractWeb3 with ABI specific to CompatibilityFallbackHandler contract version 1.3.0.
- * @implements CompatibilityFallbackHandlerContract_v1_3_0_Contract - Implements the interface specific to CompatibilityFallbackHandler contract version 1.3.0.
- */
-class CompatibilityFallbackHandlerContract_v1_3_0_Web3
- extends CompatibilityFallbackHandlerBaseContractWeb3<
- DeepWriteable
- >
- implements CompatibilityFallbackHandlerContract_v1_3_0_Contract
-{
- safeVersion: SafeVersion
-
- /**
- * Constructs an instance of CompatibilityFallbackHandlerContract_v1_3_0_Web3
- *
- * @param chainId - The chain ID where the contract resides.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the CompatibilityFallbackHandler deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.3.0 is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- customContractAddress?: string,
- customContractAbi?: DeepWriteable
- ) {
- const safeVersion = '1.3.0'
- const defaultAbi =
- compatibilityFallbackHandler_1_3_0_ContractArtifacts.abi as DeepWriteable
-
- super(chainId, web3Adapter, defaultAbi, safeVersion, customContractAddress, customContractAbi)
-
- this.safeVersion = safeVersion
- }
-}
-
-export default CompatibilityFallbackHandlerContract_v1_3_0_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1_Web3.ts
deleted file mode 100644
index 67636ab87..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1_Web3.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import CompatibilityFallbackHandlerBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContractWeb3'
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import {
- DeepWriteable,
- SafeVersion,
- CompatibilityFallbackHandlerContract_v1_4_1_Abi,
- CompatibilityFallbackHandlerContract_v1_4_1_Contract,
- compatibilityFallbackHandler_1_4_1_ContractArtifacts
-} from '@safe-global/safe-core-sdk-types'
-
-/**
- * CompatibilityFallbackHandlerContract_v1_4_1_Web3 is the implementation specific to the CompatibilityFallbackHandler contract version 1.4.1.
- *
- * This class specializes in handling interactions with the CompatibilityFallbackHandler contract version 1.4.1 using Web3.js.
- *
- * @extends CompatibilityFallbackHandlerBaseContractWeb3 - Inherits from CompatibilityFallbackHandlerBaseContractWeb3 with ABI specific to CompatibilityFallbackHandler contract version 1.4.1.
- * @implements CompatibilityFallbackHandlerContract_v1_4_1_Contract - Implements the interface specific to CompatibilityFallbackHandler contract version 1.4.1.
- */
-class CompatibilityFallbackHandlerContract_v1_4_1_Web3
- extends CompatibilityFallbackHandlerBaseContractWeb3<
- DeepWriteable
- >
- implements CompatibilityFallbackHandlerContract_v1_4_1_Contract
-{
- safeVersion: SafeVersion
-
- /**
- * Constructs an instance of CompatibilityFallbackHandlerContract_v1_4_1_Web3
- *
- * @param chainId - The chain ID where the contract resides.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the CompatibilityFallbackHandler deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.4.1 is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- customContractAddress?: string,
- customContractAbi?: DeepWriteable
- ) {
- const safeVersion = '1.4.1'
- const defaultAbi =
- compatibilityFallbackHandler_1_4_1_ContractArtifacts.abi as DeepWriteable
-
- super(chainId, web3Adapter, defaultAbi, safeVersion, customContractAddress, customContractAbi)
-
- this.safeVersion = safeVersion
- }
-}
-
-export default CompatibilityFallbackHandlerContract_v1_4_1_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/CreateCallBaseContractWeb3.ts b/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/CreateCallBaseContractWeb3.ts
deleted file mode 100644
index 192a4e472..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/CreateCallBaseContractWeb3.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-import { Abi } from 'abitype'
-import { AbiItem } from 'web3-utils'
-
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import BaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/BaseContractWeb3'
-import { SafeVersion } from '@safe-global/safe-core-sdk-types'
-import { contractName } from '@safe-global/protocol-kit/contracts/config'
-
-/**
- * Abstract class CreateCallBaseContractWeb3 extends BaseContractWeb3 to specifically integrate with the CreateCall contract.
- * It is designed to be instantiated for different versions of the Safe contract.
- *
- * Subclasses of CreateCallBaseContractWeb3 are expected to represent specific versions of the contract.
- *
- * @template CreateCallContractAbiType - The ABI type specific to the version of the CreateCall contract, extending InterfaceAbi from Web3.
- * @extends BaseContractWeb3 - Extends the generic BaseContractWeb3.
- *
- * Example subclasses:
- * - CreateCallContract_v1_4_1_Web3 extends CreateCallBaseContractWeb3
- * - CreateCallContract_v1_3_0_Web3 extends CreateCallBaseContractWeb3
- */
-abstract class CreateCallBaseContractWeb3<
- CreateCallContractAbiType extends AbiItem[] & Abi
-> extends BaseContractWeb3 {
- contractName: contractName
-
- /**
- * @constructor
- * Constructs an instance of CreateCallBaseContractWeb3.
- *
- * @param chainId - The chain ID of the contract.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param defaultAbi - The default ABI for the CreateCall contract. It should be compatible with the specific version of the contract.
- * @param safeVersion - The version of the Safe contract.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the ABI is derived from the Safe deployments or the defaultAbi is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- defaultAbi: CreateCallContractAbiType,
- safeVersion: SafeVersion,
- customContractAddress?: string,
- customContractAbi?: CreateCallContractAbiType
- ) {
- const contractName = 'createCallVersion'
-
- super(
- contractName,
- chainId,
- web3Adapter,
- defaultAbi,
- safeVersion,
- customContractAddress,
- customContractAbi
- )
-
- this.contractName = contractName
- }
-}
-
-export default CreateCallBaseContractWeb3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0_Web3.ts
deleted file mode 100644
index 82a971f6c..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0_Web3.ts
+++ /dev/null
@@ -1,86 +0,0 @@
-import CreateCallBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/CreateCall/CreateCallBaseContractWeb3'
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import {
- DeepWriteable,
- SafeVersion,
- CreateCallContract_v1_3_0_Abi,
- CreateCallContract_v1_3_0_Contract,
- AdapterSpecificContractFunction,
- Web3TransactionOptions,
- createCall_1_3_0_ContractArtifacts
-} from '@safe-global/safe-core-sdk-types'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils'
-
-/**
- * CreateCallContract_v1_3_0_Web3 is the implementation specific to the CreateCall contract version 1.3.0.
- *
- * This class specializes in handling interactions with the CreateCall contract version 1.3.0 using Web3.js.
- *
- * @extends CreateCallBaseContractWeb3 - Inherits from CreateCallBaseContractWeb3 with ABI specific to CreateCall contract version 1.3.0.
- * @implements CreateCallContract_v1_3_0_Contract - Implements the interface specific to CreateCall contract version 1.3.0.
- */
-class CreateCallContract_v1_3_0_Web3
- extends CreateCallBaseContractWeb3>
- implements CreateCallContract_v1_3_0_Contract
-{
- safeVersion: SafeVersion
-
- /**
- * Constructs an instance of CreateCallContract_v1_3_0_Web3
- *
- * @param chainId - The chain ID where the contract resides.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the CreateCall deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.3.0 is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- customContractAddress?: string,
- customContractAbi?: DeepWriteable
- ) {
- const safeVersion = '1.3.0'
- const defaultAbi =
- createCall_1_3_0_ContractArtifacts.abi as DeepWriteable
-
- super(chainId, web3Adapter, defaultAbi, safeVersion, customContractAddress, customContractAbi)
-
- this.safeVersion = safeVersion
- }
-
- /**
- * @param args - Array[value, deploymentData]
- * @param options - Web3TransactionOptions
- * @returns Promise
- */
- performCreate: AdapterSpecificContractFunction<
- CreateCallContract_v1_3_0_Abi,
- 'performCreate',
- Web3TransactionOptions
- > = async (args, options) => {
- if (options && !options.gas) {
- options.gas = (await this.estimateGas('performCreate', [...args], { ...options })).toString()
- }
- const txResponse = this.contract.methods.performCreate(...args).send(options)
- return toTxResult(txResponse, options)
- }
-
- /**
- * @param args - Array[value, deploymentData, salt]
- * @param options - Web3TransactionOptions
- * @returns Promise
- */
- performCreate2: AdapterSpecificContractFunction<
- CreateCallContract_v1_3_0_Abi,
- 'performCreate2',
- Web3TransactionOptions
- > = async (args, options) => {
- if (options && !options.gas) {
- options.gas = (await this.estimateGas('performCreate2', [...args], { ...options })).toString()
- }
- const txResponse = this.contract.methods.performCreate2(...args).send(options)
- return toTxResult(txResponse, options)
- }
-}
-
-export default CreateCallContract_v1_3_0_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1_Web3.ts
deleted file mode 100644
index f01d7fa75..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1_Web3.ts
+++ /dev/null
@@ -1,86 +0,0 @@
-import CreateCallBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/CreateCall/CreateCallBaseContractWeb3'
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import {
- DeepWriteable,
- SafeVersion,
- CreateCallContract_v1_4_1_Abi,
- CreateCallContract_v1_4_1_Contract,
- createCall_1_4_1_ContractArtifacts,
- AdapterSpecificContractFunction,
- Web3TransactionOptions
-} from '@safe-global/safe-core-sdk-types'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils'
-
-/**
- * CreateCallContract_v1_4_1_Web3 is the implementation specific to the CreateCall contract version 1.4.1.
- *
- * This class specializes in handling interactions with the CreateCall contract version 1.4.1 using Web3.js.
- *
- * @extends CreateCallBaseContractWeb3 - Inherits from CreateCallBaseContractWeb3 with ABI specific to CreateCall contract version 1.4.1.
- * @implements CreateCallContract_v1_4_1_Contract - Implements the interface specific to CreateCall contract version 1.4.1.
- */
-class CreateCallContract_v1_4_1_Web3
- extends CreateCallBaseContractWeb3>
- implements CreateCallContract_v1_4_1_Contract
-{
- safeVersion: SafeVersion
-
- /**
- * Constructs an instance of CreateCallContract_v1_4_1_Web3
- *
- * @param chainId - The chain ID where the contract resides.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the CreateCall deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.4.1 is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- customContractAddress?: string,
- customContractAbi?: DeepWriteable
- ) {
- const safeVersion = '1.4.1'
- const defaultAbi =
- createCall_1_4_1_ContractArtifacts.abi as DeepWriteable
-
- super(chainId, web3Adapter, defaultAbi, safeVersion, customContractAddress, customContractAbi)
-
- this.safeVersion = safeVersion
- }
-
- /**
- * @param args - Array[value, deploymentData]
- * @param options - Web3TransactionOptions
- * @returns Promise
- */
- performCreate: AdapterSpecificContractFunction<
- CreateCallContract_v1_4_1_Abi,
- 'performCreate',
- Web3TransactionOptions
- > = async (args, options) => {
- if (options && !options.gas) {
- options.gas = (await this.estimateGas('performCreate', [...args], { ...options })).toString()
- }
- const txResponse = this.contract.methods.performCreate(...args).send(options)
- return toTxResult(txResponse, options)
- }
-
- /**
- * @param args - Array[value, deploymentData, salt]
- * @param options - Web3TransactionOptions
- * @returns Promise
- */
- performCreate2: AdapterSpecificContractFunction<
- CreateCallContract_v1_4_1_Abi,
- 'performCreate2',
- Web3TransactionOptions
- > = async (args, options) => {
- if (options && !options.gas) {
- options.gas = (await this.estimateGas('performCreate2', [...args], { ...options })).toString()
- }
- const txResponse = this.contract.methods.performCreate2(...args).send(options)
- return toTxResult(txResponse, options)
- }
-}
-
-export default CreateCallContract_v1_4_1_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/MultiSendBaseContractWeb3.ts b/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/MultiSendBaseContractWeb3.ts
deleted file mode 100644
index 742462d12..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/MultiSendBaseContractWeb3.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-import { Abi } from 'abitype'
-import { AbiItem } from 'web3-utils'
-
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import { SafeVersion } from '@safe-global/safe-core-sdk-types'
-import BaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/BaseContractWeb3'
-import { contractName } from '@safe-global/protocol-kit/contracts/config'
-
-/**
- * Abstract class MultiSendBaseContractWeb3 extends BaseContractWeb3 to specifically integrate with the MultiSend contract.
- * It is designed to be instantiated for different versions of the MultiSend contract.
- *
- * Subclasses of MultiSendBaseContractWeb3 are expected to represent specific versions of the MultiSend contract.
- *
- * @template MultiSendContractAbiType - The ABI type specific to the version of the MultiSend contract, extending InterfaceAbi from Web3.
- * @extends BaseContractWeb3 - Extends the generic BaseContractWeb3.
- *
- * Example subclasses:
- * - MultiSendContract_v1_4_1_Web3 extends MultiSendBaseContractWeb3
- * - MultiSendContract_v1_3_0_Web3 extends MultiSendBaseContractWeb3
- */
-abstract class MultiSendBaseContractWeb3<
- MultiSendContractAbiType extends AbiItem[] & Abi
-> extends BaseContractWeb3 {
- contractName: contractName
-
- /**
- * @constructor
- * Constructs an instance of MultiSendBaseContractWeb3.
- *
- * @param chainId - The chain ID of the contract.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param defaultAbi - The default ABI for the MultiSend contract. It should be compatible with the specific version of the MultiSend contract.
- * @param safeVersion - The version of the MultiSend contract.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the MultiSend deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the ABI is derived from the MultiSend deployments or the defaultAbi is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- defaultAbi: MultiSendContractAbiType,
- safeVersion: SafeVersion,
- customContractAddress?: string,
- customContractAbi?: MultiSendContractAbiType
- ) {
- const contractName = 'multiSendVersion'
-
- super(
- contractName,
- chainId,
- web3Adapter,
- defaultAbi,
- safeVersion,
- customContractAddress,
- customContractAbi
- )
-
- this.contractName = contractName
- }
-}
-
-export default MultiSendBaseContractWeb3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/MultiSendCallOnlyBaseContractWeb3.ts b/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/MultiSendCallOnlyBaseContractWeb3.ts
deleted file mode 100644
index 7b8344958..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/MultiSendCallOnlyBaseContractWeb3.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-import { Abi } from 'abitype'
-import { AbiItem } from 'web3-utils'
-
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import { SafeVersion } from '@safe-global/safe-core-sdk-types'
-import BaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/BaseContractWeb3'
-import { contractName } from '@safe-global/protocol-kit/contracts/config'
-
-/**
- * Abstract class MultiSendCallOnlyBaseContractWeb3 extends BaseContractWeb3 to specifically integrate with the MultiSendCallOnly contract.
- * It is designed to be instantiated for different versions of the MultiSendCallOnly contract.
- *
- * Subclasses of MultiSendCallOnlyBaseContractWeb3 are expected to represent specific versions of the MultiSendCallOnly contract.
- *
- * @template MultiSendCallOnlyContractAbiType - The ABI type specific to the version of the MultiSendCallOnly contract, extending InterfaceAbi from Web3.
- * @extends BaseContractWeb3 - Extends the generic BaseContractWeb3.
- *
- * Example subclasses:
- * - MultiSendCallOnlyContract_v1_4_1_Web3 extends MultiSendCallOnlyBaseContractWeb3
- * - MultiSendCallOnlyContract_v1_3_0_Web3 extends MultiSendCallOnlyBaseContractWeb3
- */
-abstract class MultiSendCallOnlyBaseContractWeb3<
- MultiSendCallOnlyContractAbiType extends AbiItem[] & Abi
-> extends BaseContractWeb3 {
- contractName: contractName
-
- /**
- * @constructor
- * Constructs an instance of MultiSendCallOnlyBaseContractWeb3.
- *
- * @param chainId - The chain ID of the contract.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param defaultAbi - The default ABI for the MultiSendCallOnly contract. It should be compatible with the specific version of the MultiSendCallOnly contract.
- * @param safeVersion - The version of the MultiSendCallOnly contract.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the MultiSendCallOnly deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the ABI is derived from the MultiSendCallOnly deployments or the defaultAbi is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- defaultAbi: MultiSendCallOnlyContractAbiType,
- safeVersion: SafeVersion,
- customContractAddress?: string,
- customContractAbi?: MultiSendCallOnlyContractAbiType
- ) {
- const contractName = 'multiSendCallOnlyVersion'
-
- super(
- contractName,
- chainId,
- web3Adapter,
- defaultAbi,
- safeVersion,
- customContractAddress,
- customContractAbi
- )
-
- this.contractName = contractName
- }
-}
-
-export default MultiSendCallOnlyBaseContractWeb3
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 3e0cef58d..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/v1.1.1/MultiSendContract_v1_1_1_Web3.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import MultiSendBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/MultiSend/MultiSendBaseContractWeb3'
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import {
- DeepWriteable,
- MultiSendContract_v1_1_1_Abi,
- MultiSendContract_v1_1_1_Contract,
- SafeVersion,
- multisend_1_1_1_ContractArtifacts
-} from '@safe-global/safe-core-sdk-types'
-
-/**
- * MultiSendContract_v1_1_1_Web3 is the implementation specific to the MultiSend contract version 1.1.1.
- *
- * This class specializes in handling interactions with the MultiSend contract version 1.1.1 using Web3.js v6.
- *
- * @extends MultiSendBaseContractWeb3 - Inherits from MultiSendBaseContractWeb3 with ABI specific to MultiSend contract version 1.1.1.
- * @implements MultiSendContract_v1_1_1_Contract - Implements the interface specific to MultiSend contract version 1.1.1.
- */
-class MultiSendContract_v1_1_1_Web3
- extends MultiSendBaseContractWeb3>
- implements MultiSendContract_v1_1_1_Contract
-{
- safeVersion: SafeVersion
-
- /**
- * Constructs an instance of MultiSendContract_v1_1_1_Web3
- *
- * @param chainId - The chain ID where the contract resides.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the MultiSend deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.1.1 is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- customContractAddress?: string,
- customContractAbi?: DeepWriteable
- ) {
- const safeVersion = '1.1.1'
- const defaultAbi =
- multisend_1_1_1_ContractArtifacts.abi as DeepWriteable
-
- super(chainId, web3Adapter, defaultAbi, safeVersion, customContractAddress, customContractAbi)
-
- this.safeVersion = safeVersion
- }
-}
-
-export default MultiSendContract_v1_1_1_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0_Web3.ts
deleted file mode 100644
index 6136259d7..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0_Web3.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import MultiSendCallOnlyBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/MultiSend/MultiSendCallOnlyBaseContractWeb3'
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import {
- DeepWriteable,
- SafeVersion,
- MultiSendCallOnlyContract_v1_3_0_Abi,
- MultiSendCallOnlyContract_v1_3_0_Contract,
- multiSendCallOnly_1_3_0_ContractArtifacts
-} from '@safe-global/safe-core-sdk-types'
-
-/**
- * MultiSendCallOnlyContract_v1_3_0_Web3 is the implementation specific to the MultiSendCallOnly contract version 1.3.0.
- *
- * This class specializes in handling interactions with the MultiSendCallOnly contract version 1.3.0 using Web3.js v6.
- *
- * @extends MultiSendCallOnlyBaseContractWeb3 - Inherits from MultiSendCallOnlyBaseContractWeb3 with ABI specific to MultiSendCallOnly contract version 1.3.0.
- * @implements MultiSendCallOnlyContract_v1_3_0_Contract - Implements the interface specific to MultiSendCallOnly contract version 1.3.0.
- */
-class MultiSendCallOnlyContract_v1_3_0_Web3
- extends MultiSendCallOnlyBaseContractWeb3>
- implements MultiSendCallOnlyContract_v1_3_0_Contract
-{
- safeVersion: SafeVersion
-
- /**
- * Constructs an instance of SafeContract_v1_3_0_Web3
- *
- * @param chainId - The chain ID where the contract resides.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the MultiSendCallOnly deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.3.0 is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- customContractAddress?: string,
- customContractAbi?: DeepWriteable
- ) {
- const safeVersion = '1.3.0'
- const defaultAbi =
- multiSendCallOnly_1_3_0_ContractArtifacts.abi as DeepWriteable
-
- super(chainId, web3Adapter, defaultAbi, safeVersion, customContractAddress, customContractAbi)
-
- this.safeVersion = safeVersion
- }
-}
-
-export default MultiSendCallOnlyContract_v1_3_0_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 1d461327a..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/v1.3.0/MultiSendContract_v1_3_0_Web3.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import MultiSendBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/MultiSend/MultiSendBaseContractWeb3'
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import {
- DeepWriteable,
- SafeVersion,
- MultiSendContract_v1_3_0_Abi,
- MultiSendContract_v1_3_0_Contract,
- multisend_1_3_0_ContractArtifacts
-} from '@safe-global/safe-core-sdk-types'
-
-/**
- * MultiSendContract_v1_3_0_Web3 is the implementation specific to the MultiSend contract version 1.3.0.
- *
- * This class specializes in handling interactions with the MultiSend contract version 1.3.0 using Web3.js v6.
- *
- * @extends MultiSendBaseContractWeb3 - Inherits from MultiSendBaseContractWeb3 with ABI specific to MultiSend contract version 1.3.0.
- * @implements MultiSendContract_v1_3_0_Contract - Implements the interface specific to MultiSend contract version 1.3.0.
- */
-class MultiSendContract_v1_3_0_Web3
- extends MultiSendBaseContractWeb3>
- implements MultiSendContract_v1_3_0_Contract
-{
- safeVersion: SafeVersion
-
- /**
- * Constructs an instance of MultiSendContract_v1_3_0_Web3
- *
- * @param chainId - The chain ID where the contract resides.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the MultiSend deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.3.0 is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- customContractAddress?: string,
- customContractAbi?: DeepWriteable
- ) {
- const safeVersion = '1.3.0'
- const defaultAbi =
- multisend_1_3_0_ContractArtifacts.abi as DeepWriteable
-
- super(chainId, web3Adapter, defaultAbi, safeVersion, customContractAddress, customContractAbi)
-
- this.safeVersion = safeVersion
- }
-}
-
-export default MultiSendContract_v1_3_0_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1_Web3.ts
deleted file mode 100644
index 7879128b5..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1_Web3.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import MultiSendCallOnlyBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/MultiSend/MultiSendCallOnlyBaseContractWeb3'
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import {
- DeepWriteable,
- SafeVersion,
- MultiSendCallOnlyContract_v1_4_1_Abi,
- MultiSendCallOnlyContract_v1_4_1_Contract,
- multiSendCallOnly_1_4_1_ContractArtifacts
-} from '@safe-global/safe-core-sdk-types'
-
-/**
- * MultiSendCallOnlyContract_v1_4_1_Web3 is the implementation specific to the MultiSendCallOnly contract version 1.4.1.
- *
- * This class specializes in handling interactions with the MultiSendCallOnly contract version 1.4.1 using Web3.js v6.
- *
- * @extends MultiSendCallOnlyBaseContractWeb3 - Inherits from MultiSendBaseContractWeb3 with ABI specific to MultiSendCallOnly contract version 1.4.1.
- * @implements MultiSendContract_v1_4_1_Contract - Implements the interface specific to MultiSendCallOnly contract version 1.4.1.
- */
-class MultiSendCallOnlyContract_v1_4_1_Web3
- extends MultiSendCallOnlyBaseContractWeb3>
- implements MultiSendCallOnlyContract_v1_4_1_Contract
-{
- safeVersion: SafeVersion
-
- /**
- * Constructs an instance of MultiSendCallOnlyContract_v1_4_1_Web3
- *
- * @param chainId - The chain ID where the contract resides.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the MultiSendCallOnly deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.4.1 is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- customContractAddress?: string,
- customContractAbi?: DeepWriteable
- ) {
- const safeVersion = '1.4.1'
- const defaultAbi =
- multiSendCallOnly_1_4_1_ContractArtifacts.abi as DeepWriteable
-
- super(chainId, web3Adapter, defaultAbi, safeVersion, customContractAddress, customContractAbi)
-
- this.safeVersion = safeVersion
- }
-}
-
-export default MultiSendCallOnlyContract_v1_4_1_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 3626c5f42..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/MultiSend/v1.4.1/MultiSendContract_v1_4_1_Web3.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import MultiSendBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/MultiSend/MultiSendBaseContractWeb3'
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import {
- DeepWriteable,
- SafeVersion,
- MultiSendContract_v1_4_1_Abi,
- MultiSendContract_v1_4_1_Contract,
- multisend_1_4_1_ContractArtifacts
-} from '@safe-global/safe-core-sdk-types'
-
-/**
- * MultiSendContract_v1_4_1_Web3 is the implementation specific to the MultiSend contract version 1.4.1.
- *
- * This class specializes in handling interactions with the MultiSend contract version 1.4.1 using Web3.js v6.
- *
- * @extends MultiSendBaseContractWeb3 - Inherits from MultiSendBaseContractWeb3 with ABI specific to MultiSend contract version 1.4.1.
- * @implements MultiSendContract_v1_4_1_Contract - Implements the interface specific to MultiSend contract version 1.4.1.
- */
-class MultiSendContract_v1_4_1_Web3
- extends MultiSendBaseContractWeb3>
- implements MultiSendContract_v1_4_1_Contract
-{
- safeVersion: SafeVersion
-
- /**
- * Constructs an instance of MultiSendContract_v1_4_1_Web3
- *
- * @param chainId - The chain ID where the contract resides.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the MultiSend deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.4.1 is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- customContractAddress?: string,
- customContractAbi?: DeepWriteable
- ) {
- const safeVersion = '1.4.1'
- const defaultAbi =
- multisend_1_4_1_ContractArtifacts.abi as DeepWriteable
-
- super(chainId, web3Adapter, defaultAbi, safeVersion, customContractAddress, customContractAbi)
-
- this.safeVersion = safeVersion
- }
-}
-
-export default MultiSendContract_v1_4_1_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/Safe/SafeBaseContractWeb3.ts b/packages/protocol-kit/src/adapters/web3/contracts/Safe/SafeBaseContractWeb3.ts
deleted file mode 100644
index e7f4b6168..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/Safe/SafeBaseContractWeb3.ts
+++ /dev/null
@@ -1,68 +0,0 @@
-import { Abi } from 'abitype'
-import { AbiItem } from 'web3-utils'
-
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import { SafeVersion } from '@safe-global/safe-core-sdk-types'
-import BaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/BaseContractWeb3'
-import { contractName, safeDeploymentsL1ChainIds } from '@safe-global/protocol-kit/contracts/config'
-
-/**
- * Abstract class SafeBaseContractWeb3 extends BaseContractWeb3 to specifically integrate with the Safe contract.
- * It is designed to be instantiated for different versions of the Safe contract.
- *
- * Subclasses of SafeBaseContractWeb3 are expected to represent specific versions of the Safe contract.
- *
- * @template SafeContractAbiType - The ABI type specific to the version of the Safe contract, extending AbiItem.
- * @extends BaseContractWeb3 - Extends the generic BaseContractWeb3.
- *
- * Example subclasses:
- * - SafeContract_v1_4_1_Web3 extends SafeBaseContractWeb3
- * - SafeContract_v1_3_0_Web3 extends SafeBaseContractWeb3
- * - SafeContract_v1_2_0_Web3 extends SafeBaseContractWeb3
- * - SafeContract_v1_1_1_Web3 extends SafeBaseContractWeb3
- * - SafeContract_v1_0_0_Web3 extends SafeBaseContractWeb3
- */
-abstract class SafeBaseContractWeb3<
- SafeContractAbiType extends AbiItem[] & Abi
-> extends BaseContractWeb3 {
- contractName: contractName
-
- /**
- * @constructor
- * Constructs an instance of SafeBaseContractWeb3.
- *
- * @param chainId - The chain ID of the contract.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param defaultAbi - The default ABI for the Safe contract. It should be compatible with the specific version of the Safe contract.
- * @param safeVersion - The version of the Safe contract.
- * @param isL1SafeSingleton - A flag indicating if the contract is a L1 Safe Singleton.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the ABI is derived from the Safe deployments or the defaultAbi is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- defaultAbi: SafeContractAbiType,
- safeVersion: SafeVersion,
- isL1SafeSingleton = false,
- customContractAddress?: string,
- customContractAbi?: SafeContractAbiType
- ) {
- const isL1Contract = safeDeploymentsL1ChainIds.includes(chainId) || isL1SafeSingleton
- const contractName = isL1Contract ? 'safeSingletonVersion' : 'safeSingletonL2Version'
-
- super(
- contractName,
- chainId,
- web3Adapter,
- defaultAbi,
- safeVersion,
- customContractAddress,
- customContractAbi
- )
-
- this.contractName = contractName
- }
-}
-
-export default SafeBaseContractWeb3
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 e2aaaa54c..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.0.0/SafeContract_v1_0_0_Web3.ts
+++ /dev/null
@@ -1,353 +0,0 @@
-import SafeBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/Safe/SafeBaseContractWeb3'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils'
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import { sameString } from '@safe-global/protocol-kit/utils'
-import {
- DeepWriteable,
- safe_1_0_0_ContractArtifacts,
- SafeContract_v1_0_0_Abi,
- SafeContract_v1_0_0_Contract,
- SafeContract_v1_0_0_Function,
- SafeTransaction,
- SafeVersion,
- Web3TransactionOptions,
- Web3TransactionResult
-} from '@safe-global/safe-core-sdk-types'
-import { SENTINEL_ADDRESS } from '@safe-global/protocol-kit/utils/constants'
-
-/**
- * SafeContract_v1_0_0_Web3 is the implementation specific to the Safe contract version 1.0.0.
- *
- * This class specializes in handling interactions with the Safe contract version 1.0.0 using Web3.js.
- *
- * @extends SafeBaseContractWeb3 - Inherits from SafeBaseContractWeb3 with ABI specific to Safe contract version 1.0.0.
- * @implements SafeContract_v1_0_0_Contract - Implements the interface specific to Safe contract version 1.0.0.
- */
-class SafeContract_v1_0_0_Web3
- extends SafeBaseContractWeb3>
- implements SafeContract_v1_0_0_Contract
-{
- safeVersion: SafeVersion
-
- /**
- * Constructs an instance of SafeContract_v1_0_0_Web3
- *
- * @param chainId - The chain ID where the contract resides.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param isL1SafeSingleton - A flag indicating if the contract is a L1 Safe Singleton.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.0.0 is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- isL1SafeSingleton = false,
- customContractAddress?: string,
- customContractAbi?: DeepWriteable
- ) {
- const safeVersion = '1.0.0'
- const defaultAbi = safe_1_0_0_ContractArtifacts.abi as DeepWriteable
-
- super(
- chainId,
- web3Adapter,
- defaultAbi,
- safeVersion,
- isL1SafeSingleton,
- customContractAddress,
- customContractAbi
- )
-
- this.safeVersion = safeVersion
- }
-
- /* ----- Specific v1.0.0 properties ----- */
- DOMAIN_SEPARATOR_TYPEHASH: SafeContract_v1_0_0_Function<'DOMAIN_SEPARATOR_TYPEHASH'> =
- async () => {
- return [await this.contract.methods.DOMAIN_SEPARATOR_TYPEHASH().call()]
- }
-
- SENTINEL_MODULES: SafeContract_v1_0_0_Function<'SENTINEL_MODULES'> = async () => {
- return [await this.contract.methods.SENTINEL_MODULES().call()]
- }
-
- SENTINEL_OWNERS: SafeContract_v1_0_0_Function<'SENTINEL_OWNERS'> = async () => {
- return [await this.contract.methods.SENTINEL_OWNERS().call()]
- }
-
- SAFE_MSG_TYPEHASH: SafeContract_v1_0_0_Function<'SAFE_MSG_TYPEHASH'> = async () => {
- return [await this.contract.methods.SAFE_MSG_TYPEHASH().call()]
- }
-
- SAFE_TX_TYPEHASH: SafeContract_v1_0_0_Function<'SAFE_TX_TYPEHASH'> = async () => {
- return [await this.contract.methods.SAFE_TX_TYPEHASH().call()]
- }
- /* ----- End of specific v1.0.0 properties ----- */
-
- /**
- * @returns Array[contractName]
- */
- NAME: SafeContract_v1_0_0_Function<'NAME'> = async () => {
- return [await this.contract.methods.NAME().call()]
- }
-
- /**
- * @returns Array[safeContractVersion]
- */
- VERSION: SafeContract_v1_0_0_Function<'VERSION'> = async () => {
- return [await this.contract.methods.VERSION().call()]
- }
-
- /**
- * @param args - Array[owner, txHash]
- * @returns Array[approvedHashes]
- */
- approvedHashes: SafeContract_v1_0_0_Function<'approvedHashes'> = async (args) => {
- return [await this.contract.methods.approvedHashes(...args).call()]
- }
-
- /**
- * @returns Array[domainSeparator]
- */
- domainSeparator: SafeContract_v1_0_0_Function<'domainSeparator'> = async () => {
- return [await this.contract.methods.domainSeparator().call()]
- }
-
- /**
- * Returns array of modules.
- * @returns Array[Array[modules]]
- */
- getModules: SafeContract_v1_0_0_Function<'getModules'> = async () => {
- return [await this.contract.methods.getModules().call()]
- }
-
- /**
- * Returns the list of Safe owner accounts.
- * @returns Array[Array[owners]]
- */
- getOwners: SafeContract_v1_0_0_Function<'getOwners'> = async () => {
- return [await this.contract.methods.getOwners().call()]
- }
-
- /**
- * Returns the Safe threshold.
- * @returns Array[threshold]
- */
- getThreshold: SafeContract_v1_0_0_Function<'getThreshold'> = async () => {
- return [await this.contract.methods.getThreshold().call()]
- }
-
- /**
- * Checks if a specific address is an owner of the current Safe.
- * @param args - Array[address]
- * @returns Array[isOwner]
- */
- isOwner: SafeContract_v1_0_0_Function<'isOwner'> = async (args) => {
- return [await this.contract.methods.isOwner(...args).call()]
- }
-
- /**
- * Returns the Safe nonce.
- * @returns Array[nonce]
- */
- nonce: SafeContract_v1_0_0_Function<'nonce'> = async () => {
- return [await this.contract.methods.nonce().call()]
- }
-
- /**
- * @param args - Array[messageHash]
- * @returns Array[signedMessages]
- */
- signedMessages: SafeContract_v1_0_0_Function<'signedMessages'> = async (args) => {
- return [await this.contract.methods.signedMessages(...args).call()]
- }
-
- /**
- * Returns hash of a message that can be signed by owners.
- * @param args - Array[message]
- * @returns Array[messageHash]
- */
- getMessageHash: SafeContract_v1_0_0_Function<'getMessageHash'> = async (args) => {
- return [await this.contract.methods.getMessageHash(...args).call()]
- }
-
- /**
- * Returns the bytes that are hashed to be signed by owners.
- * @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
- * @returns Array[encodedData]
- */
- encodeTransactionData: SafeContract_v1_0_0_Function<'encodeTransactionData'> = async (args) => {
- return [await this.contract.methods.encodeTransactionData(...args).call()]
- }
-
- /**
- * Returns hash to be signed by owners.
- * @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
- * @returns Array[transactionHash]
- */
- getTransactionHash: SafeContract_v1_0_0_Function<'getTransactionHash'> = async (args) => {
- return [await this.contract.methods.getTransactionHash(...args).call()]
- }
-
- /**
- * Marks a hash as approved. This can be used to validate a hash that is used by a signature.
- * @param hash - The hash that should be marked as approved for signatures that are verified by this contract.
- * @param options - Optional transaction options.
- * @returns Transaction result.
- */
- async approveHash(
- hash: string,
- options?: Web3TransactionOptions
- ): Promise {
- if (options && !options.gas) {
- options.gas = (await this.estimateGas('approveHash', [hash], { ...options })).toString()
- }
- const txResponse = this.contract.methods.approveHash(hash).send(options)
- return toTxResult(txResponse, options)
- }
-
- /**
- * Executes a transaction.
- * @param safeTransaction - The Safe transaction to execute.
- * @param options - Transaction options.
- * @returns Transaction result.
- */
- async execTransaction(
- safeTransaction: SafeTransaction,
- options?: Web3TransactionOptions
- ): Promise {
- if (options && !options.gas) {
- options.gas = (
- await this.estimateGas(
- 'execTransaction',
- [
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- ],
- options
- )
- ).toString()
- }
- const txResponse = this.contract.methods
- .execTransaction(
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- )
- .send(options)
-
- return toTxResult(txResponse, options)
- }
-
- async getModulesPaginated(start: string, pageSize: bigint): 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, Number(pageSize))
- } else {
- const moduleIndex = array.findIndex((module: string) => sameString(module, start))
- return moduleIndex === -1 ? [] : array.slice(moduleIndex + 1, Number(pageSize))
- }
- }
-
- /**
- * Checks if a specific Safe module is enabled for the current Safe.
- * @param moduleAddress - The module address to check.
- * @returns True, if the module with the given address is enabled.
- */
- async isModuleEnabled(moduleAddress: string[]): Promise {
- const [modules] = await this.getModules()
- const isModuleEnabled = modules.some((enabledModuleAddress) =>
- sameString(enabledModuleAddress, moduleAddress[0])
- )
- return [isModuleEnabled]
- }
-
- /**
- * Checks whether a given Safe transaction can be executed successfully with no errors.
- * @param safeTransaction - The Safe transaction to check.
- * @param options - Optional transaction options.
- * @returns True, if the given transactions is valid.
- */
- async isValidTransaction(
- safeTransaction: SafeTransaction,
- options?: Web3TransactionOptions
- ): Promise {
- let isTxValid = false
- try {
- if (options && !options.gas) {
- options.gas = (
- await this.estimateGas(
- 'execTransaction',
- [
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- ],
- options
- )
- ).toString()
- }
- isTxValid = await this.contract.methods
- .execTransaction(
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- )
- .call(options)
- } catch {}
- return isTxValid
- }
-
- /**
- * returns the version of the Safe contract.
- *
- * @returns {Promise} A promise that resolves to the version of the Safe contract as string.
- */
- async getVersion(): Promise {
- const [safeVersion] = await this.VERSION()
- return safeVersion as SafeVersion
- }
-
- /**
- * returns the nonce of the Safe contract.
- *
- * @returns {Promise} A promise that resolves to the nonce of the Safe contract.
- */
- async getNonce(): Promise {
- const [nonce] = await this.nonce()
- return nonce
- }
-}
-
-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 1752094cc..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.1.1/SafeContract_v1_1_1_Web3.ts
+++ /dev/null
@@ -1,327 +0,0 @@
-import SafeBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/Safe/SafeBaseContractWeb3'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils'
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import { sameString } from '@safe-global/protocol-kit/utils'
-import {
- DeepWriteable,
- SafeVersion,
- SafeContract_v1_1_1_Abi,
- SafeContract_v1_1_1_Contract,
- SafeContract_v1_1_1_Function,
- SafeTransaction,
- safe_1_1_1_ContractArtifacts,
- Web3TransactionOptions,
- Web3TransactionResult
-} from '@safe-global/safe-core-sdk-types'
-
-/**
- * SafeContract_v1_1_1_Web3 is the implementation specific to the Safe contract version 1.1.1.
- *
- * This class specializes in handling interactions with the Safe contract version 1.1.1 using Web3.js.
- *
- * @extends SafeBaseContractWeb3 - Inherits from SafeBaseContractWeb3 with ABI specific to Safe contract version 1.1.1.
- * @implements SafeContract_v1_1_1_Contract - Implements the interface specific to Safe contract version 1.1.1.
- */
-class SafeContract_v1_1_1_Web3
- extends SafeBaseContractWeb3>
- implements SafeContract_v1_1_1_Contract
-{
- safeVersion: SafeVersion
-
- /**
- * Constructs an instance of SafeContract_v1_1_1_Web3
- *
- * @param chainId - The chain ID where the contract resides.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param isL1SafeSingleton - A flag indicating if the contract is a L1 Safe Singleton.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.1.1 is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- isL1SafeSingleton = false,
- customContractAddress?: string,
- customContractAbi?: DeepWriteable
- ) {
- const safeVersion = '1.1.1'
- const defaultAbi = safe_1_1_1_ContractArtifacts.abi as DeepWriteable
-
- super(
- chainId,
- web3Adapter,
- defaultAbi,
- safeVersion,
- isL1SafeSingleton,
- customContractAddress,
- customContractAbi
- )
-
- this.safeVersion = safeVersion
- }
-
- /**
- * @returns Array[contractName]
- */
- NAME: SafeContract_v1_1_1_Function<'NAME'> = async () => {
- return [await this.contract.methods.NAME().call()]
- }
-
- /**
- * @returns Array[safeContractVersion]
- */
- VERSION: SafeContract_v1_1_1_Function<'VERSION'> = async () => {
- return [await this.contract.methods.VERSION().call()]
- }
-
- /**
- * @param args - Array[owner, txHash]
- * @returns Array[approvedHashes]
- */
- approvedHashes: SafeContract_v1_1_1_Function<'approvedHashes'> = async (args) => {
- return [await this.contract.methods.approvedHashes(...args).call()]
- }
-
- /**
- * @returns Array[domainSeparator]
- */
- domainSeparator: SafeContract_v1_1_1_Function<'domainSeparator'> = async () => {
- return [await this.contract.methods.domainSeparator().call()]
- }
-
- /**
- * Returns array of first 10 modules.
- * @returns Array[Array[modules]]
- */
- getModules: SafeContract_v1_1_1_Function<'getModules'> = async () => {
- return [await this.contract.methods.getModules().call()]
- }
-
- /**
- * Returns array of modules.
- * @param args - Array[start, pageSize]
- * @returns Array[Array[modules], next]
- */
- getModulesPaginated: SafeContract_v1_1_1_Function<'getModulesPaginated'> = async (args) => {
- const res = await this.contract.methods.getModulesPaginated(...args).call()
- return [res.array, res.next]
- }
-
- /**
- * Returns the list of Safe owner accounts.
- * @returns Array[Array[owners]]
- */
- getOwners: SafeContract_v1_1_1_Function<'getOwners'> = async () => {
- return [await this.contract.methods.getOwners().call()]
- }
-
- /**
- * Returns the Safe threshold.
- * @returns Array[threshold]
- */
- getThreshold: SafeContract_v1_1_1_Function<'getThreshold'> = async () => {
- return [await this.contract.methods.getThreshold().call()]
- }
-
- /**
- * Checks if a specific address is an owner of the current Safe.
- * @param args - Array[address]
- * @returns Array[isOwner]
- */
- isOwner: SafeContract_v1_1_1_Function<'isOwner'> = async (args) => {
- return [await this.contract.methods.isOwner(...args).call()]
- }
-
- /**
- * Returns the Safe nonce.
- * @returns Array[nonce]
- */
- nonce: SafeContract_v1_1_1_Function<'nonce'> = async () => {
- return [await this.contract.methods.nonce().call()]
- }
-
- /**
- * @param args - Array[messageHash]
- * @returns Array[signedMessages]
- */
- signedMessages: SafeContract_v1_1_1_Function<'signedMessages'> = async (args) => {
- return [await this.contract.methods.signedMessages(...args).call()]
- }
-
- /**
- * Returns hash of a message that can be signed by owners.
- * @param args - Array[message]
- * @returns Array[messageHash]
- */
- getMessageHash: SafeContract_v1_1_1_Function<'getMessageHash'> = async (args) => {
- return [await this.contract.methods.getMessageHash(...args).call()]
- }
-
- /**
- * Returns the bytes that are hashed to be signed by owners.
- * @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
- * @returns Array[encodedData]
- */
- encodeTransactionData: SafeContract_v1_1_1_Function<'encodeTransactionData'> = async (args) => {
- return [await this.contract.methods.encodeTransactionData(...args).call()]
- }
-
- /**
- * Returns hash to be signed by owners.
- * @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
- * @returns Array[transactionHash]
- */
- getTransactionHash: SafeContract_v1_1_1_Function<'getTransactionHash'> = async (args) => {
- return [await this.contract.methods.getTransactionHash(...args).call()]
- }
-
- /**
- * Marks a hash as approved. This can be used to validate a hash that is used by a signature.
- * @param hash - The hash that should be marked as approved for signatures that are verified by this contract.
- * @param options - Optional transaction options.
- * @returns Transaction result.
- */
- async approveHash(
- hash: string,
- options?: Web3TransactionOptions
- ): Promise {
- if (options && !options.gas) {
- options.gas = (await this.estimateGas('approveHash', [hash], { ...options })).toString()
- }
- const txResponse = this.contract.methods.approveHash(hash).send(options)
- return toTxResult(txResponse, options)
- }
-
- /**
- * Executes a transaction.
- * @param safeTransaction - The Safe transaction to execute.
- * @param options - Transaction options.
- * @returns Transaction result.
- */
- async execTransaction(
- safeTransaction: SafeTransaction,
- options?: Web3TransactionOptions
- ): Promise {
- if (options && !options.gas) {
- options.gas = (
- await this.estimateGas(
- 'execTransaction',
- [
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- ],
- options
- )
- ).toString()
- }
- const txResponse = this.contract.methods
- .execTransaction(
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- )
- .send(options)
-
- return toTxResult(txResponse, options)
- }
-
- /**
- * Checks if a specific Safe module is enabled for the current Safe.
- * @param moduleAddress - The module address to check.
- * @returns True, if the module with the given address is enabled.
- */
- async isModuleEnabled(moduleAddress: string[]): Promise {
- const [modules] = await this.getModules()
- const isModuleEnabled = modules.some((enabledModuleAddress) =>
- sameString(enabledModuleAddress, moduleAddress[0])
- )
- return [isModuleEnabled]
- }
-
- /**
- * Checks whether a given Safe transaction can be executed successfully with no errors.
- * @param safeTransaction - The Safe transaction to check.
- * @param options - Optional transaction options.
- * @returns True, if the given transactions is valid.
- */
- async isValidTransaction(
- safeTransaction: SafeTransaction,
- options?: Web3TransactionOptions
- ): Promise {
- let isTxValid = false
- try {
- if (options && !options.gas) {
- options.gas = (
- await this.estimateGas(
- 'execTransaction',
- [
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- ],
- options
- )
- ).toString()
- }
- isTxValid = await this.contract.methods
- .execTransaction(
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- )
- .call(options)
- } catch {}
- return isTxValid
- }
-
- /**
- * returns the version of the Safe contract.
- *
- * @returns {Promise} A promise that resolves to the version of the Safe contract as string.
- */
- async getVersion(): Promise {
- const [safeVersion] = await this.VERSION()
- return safeVersion as SafeVersion
- }
-
- /**
- * returns the nonce of the Safe contract.
- *
- * @returns {Promise} A promise that resolves to the nonce of the Safe contract.
- */
- async getNonce(): Promise {
- const [nonce] = await this.nonce()
- return nonce
- }
-}
-
-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 0c78e5357..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.2.0/SafeContract_v1_2_0_Web3.ts
+++ /dev/null
@@ -1,323 +0,0 @@
-import SafeBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/Safe/SafeBaseContractWeb3'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils'
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import {
- DeepWriteable,
- SafeVersion,
- safe_1_2_0_ContractArtifacts,
- SafeContract_v1_2_0_Abi,
- SafeContract_v1_2_0_Contract,
- SafeContract_v1_2_0_Function,
- SafeTransaction,
- Web3TransactionOptions,
- Web3TransactionResult
-} from '@safe-global/safe-core-sdk-types'
-
-/**
- * SafeContract_v1_2_0_Web3 is the implementation specific to the Safe contract version 1.2.0.
- *
- * This class specializes in handling interactions with the Safe contract version 1.2.0 using Web3.js.
- *
- * @extends SafeBaseContractWeb3 - Inherits from SafeBaseContractWeb3 with ABI specific to Safe contract version 1.2.0.
- * @implements SafeContract_v1_2_0_Contract - Implements the interface specific to Safe contract version 1.2.0.
- */
-class SafeContract_v1_2_0_Web3
- extends SafeBaseContractWeb3>
- implements SafeContract_v1_2_0_Contract
-{
- safeVersion: SafeVersion
-
- /**
- * Constructs an instance of SafeContract_v1_2_0_Web3
- *
- * @param chainId - The chain ID where the contract resides.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param isL1SafeSingleton - A flag indicating if the contract is a L1 Safe Singleton.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.2.0 is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- isL1SafeSingleton = false,
- customContractAddress?: string,
- customContractAbi?: DeepWriteable
- ) {
- const safeVersion = '1.2.0'
- const defaultAbi = safe_1_2_0_ContractArtifacts.abi as DeepWriteable
-
- super(
- chainId,
- web3Adapter,
- defaultAbi,
- safeVersion,
- isL1SafeSingleton,
- customContractAddress,
- customContractAbi
- )
-
- this.safeVersion = safeVersion
- }
-
- /**
- * @returns Array[contractName]
- */
- NAME: SafeContract_v1_2_0_Function<'NAME'> = async () => {
- return [await this.contract.methods.NAME().call()]
- }
-
- /**
- * @returns Array[safeContractVersion]
- */
- VERSION: SafeContract_v1_2_0_Function<'VERSION'> = async () => {
- return [await this.contract.methods.VERSION().call()]
- }
-
- /**
- * @param args - Array[owner, txHash]
- * @returns Array[approvedHashes]
- */
- approvedHashes: SafeContract_v1_2_0_Function<'approvedHashes'> = async (args) => {
- return [await this.contract.methods.approvedHashes(...args).call()]
- }
-
- /**
- * @returns Array[domainSeparator]
- */
- domainSeparator: SafeContract_v1_2_0_Function<'domainSeparator'> = async () => {
- return [await this.contract.methods.domainSeparator().call()]
- }
-
- /**
- * Returns array of first 10 modules.
- * @returns Array[Array[modules]]
- */
- getModules: SafeContract_v1_2_0_Function<'getModules'> = async () => {
- return [await this.contract.methods.getModules().call()]
- }
-
- /**
- * Returns array of modules.
- * @param args - Array[start, pageSize]
- * @returns Array[Array[modules], next]
- */
- getModulesPaginated: SafeContract_v1_2_0_Function<'getModulesPaginated'> = async (args) => {
- const res = await this.contract.methods.getModulesPaginated(...args).call()
- return [res.array, res.next]
- }
-
- /**
- * Returns the list of Safe owner accounts.
- * @returns Array[Array[owners]]
- */
- getOwners: SafeContract_v1_2_0_Function<'getOwners'> = async () => {
- return [await this.contract.methods.getOwners().call()]
- }
-
- /**
- * Returns the Safe threshold.
- * @returns Array[threshold]
- */
- getThreshold: SafeContract_v1_2_0_Function<'getThreshold'> = async () => {
- return [await this.contract.methods.getThreshold().call()]
- }
-
- /**
- * Checks if a specific Safe module is enabled for the current Safe.
- * @param args - Array[moduleAddress]
- * @returns Array[isEnabled]
- */
- isModuleEnabled: SafeContract_v1_2_0_Function<'isModuleEnabled'> = async (args) => {
- return [await this.contract.methods.isModuleEnabled(...args).call()]
- }
-
- /**
- * Checks if a specific address is an owner of the current Safe.
- * @param args - Array[address]
- * @returns Array[isOwner]
- */
- isOwner: SafeContract_v1_2_0_Function<'isOwner'> = async (args) => {
- return [await this.contract.methods.isOwner(...args).call()]
- }
-
- /**
- * Returns the Safe nonce.
- * @returns Array[nonce]
- */
- nonce: SafeContract_v1_2_0_Function<'nonce'> = async () => {
- return [await this.contract.methods.nonce().call()]
- }
-
- /**
- * @param args - Array[messageHash]
- * @returns Array[signedMessages]
- */
- signedMessages: SafeContract_v1_2_0_Function<'signedMessages'> = async (args) => {
- return [await this.contract.methods.signedMessages(...args).call()]
- }
-
- /**
- * @param args - Array[message]
- * @returns Array[messageHash]
- */
- getMessageHash: SafeContract_v1_2_0_Function<'getMessageHash'> = async (args) => {
- return [await this.contract.methods.getMessageHash(...args).call()]
- }
-
- /**
- * Encodes the data for a transaction to the Safe contract.
- *
- * @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
- * @returns Array[encodedData]
- */
- encodeTransactionData: SafeContract_v1_2_0_Function<'encodeTransactionData'> = async (args) => {
- return [await this.contract.methods.encodeTransactionData(...args).call()]
- }
-
- /**
- * Returns hash to be signed by owners.
- *
- * @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
- * @returns Array[transactionHash]
- */
- getTransactionHash: SafeContract_v1_2_0_Function<'getTransactionHash'> = async (args) => {
- return [await this.contract.methods.getTransactionHash(...args).call()]
- }
-
- /**
- * Marks a hash as approved. This can be used to validate a hash that is used by a signature.
- * @param hash - The hash that should be marked as approved for signatures that are verified by this contract.
- * @param options - Optional transaction options.
- * @returns Transaction result.
- */
- async approveHash(
- hash: string,
- options?: Web3TransactionOptions
- ): Promise {
- if (options && !options.gas) {
- options.gas = (await this.estimateGas('approveHash', [hash], { ...options })).toString()
- }
- const txResponse = this.contract.methods.approveHash(hash).send(options)
- return toTxResult(txResponse, options)
- }
-
- /**
- * Executes a transaction.
- * @param safeTransaction - The Safe transaction to execute.
- * @param options - Transaction options.
- * @returns Transaction result.
- */
- async execTransaction(
- safeTransaction: SafeTransaction,
- options?: Web3TransactionOptions
- ): Promise {
- if (options && !options.gas) {
- options.gas = (
- await this.estimateGas(
- 'execTransaction',
- [
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- ],
- options
- )
- ).toString()
- }
- const txResponse = this.contract.methods
- .execTransaction(
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- )
- .send(options)
-
- return toTxResult(txResponse, options)
- }
-
- /**
- * Checks whether a given Safe transaction can be executed successfully with no errors.
- * @param safeTransaction - The Safe transaction to check.
- * @param options - Optional transaction options.
- * @returns True, if the given transactions is valid.
- */
- async isValidTransaction(
- safeTransaction: SafeTransaction,
- options?: Web3TransactionOptions
- ): Promise {
- let isTxValid = false
- try {
- if (options && !options.gas) {
- options.gas = (
- await this.estimateGas(
- 'execTransaction',
- [
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- ],
- options
- )
- ).toString()
- }
- isTxValid = await this.contract.methods
- .execTransaction(
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- )
- .call(options)
- } catch {}
- return isTxValid
- }
-
- /**
- * returns the version of the Safe contract.
- *
- * @returns {Promise} A promise that resolves to the version of the Safe contract as string.
- */
- async getVersion(): Promise {
- const [safeVersion] = await this.VERSION()
- return safeVersion as SafeVersion
- }
-
- /**
- * returns the nonce of the Safe contract.
- *
- * @returns {Promise} A promise that resolves to the nonce of the Safe contract.
- */
- async getNonce(): Promise {
- const [nonce] = await this.nonce()
- return nonce
- }
-}
-
-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 1d77a6d72..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.3.0/SafeContract_v1_3_0_Web3.ts
+++ /dev/null
@@ -1,344 +0,0 @@
-import SafeBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/Safe/SafeBaseContractWeb3'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils'
-import { SENTINEL_ADDRESS } from '@safe-global/protocol-kit/adapters/web3/utils/constants'
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import {
- DeepWriteable,
- SafeVersion,
- safe_1_3_0_ContractArtifacts,
- SafeContract_v1_3_0_Function,
- SafeContract_v1_3_0_Abi,
- SafeContract_v1_3_0_Contract,
- SafeTransaction,
- Web3TransactionOptions,
- Web3TransactionResult
-} from '@safe-global/safe-core-sdk-types'
-
-/**
- * SafeContract_v1_3_0_Web3 is the implementation specific to the Safe contract version 1.3.0.
- *
- * This class specializes in handling interactions with the Safe contract version 1.3.0 using Web3.js.
- *
- * @extends SafeBaseContractWeb3 - Inherits from SafeBaseContractWeb3 with ABI specific to Safe contract version 1.3.0.
- * @implements SafeContract_v1_3_0_Contract - Implements the interface specific to Safe contract version 1.3.0.
- */
-class SafeContract_v1_3_0_Web3
- extends SafeBaseContractWeb3>
- implements SafeContract_v1_3_0_Contract
-{
- safeVersion: SafeVersion
-
- /**
- * Constructs an instance of SafeContract_v1_3_0_Web3
- *
- * @param chainId - The chain ID where the contract resides.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param isL1SafeSingleton - A flag indicating if the contract is a L1 Safe Singleton.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.3.0 is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- isL1SafeSingleton = false,
- customContractAddress?: string,
- customContractAbi?: DeepWriteable
- ) {
- const safeVersion = '1.3.0'
- const defaultAbi = safe_1_3_0_ContractArtifacts.abi as DeepWriteable
-
- super(
- chainId,
- web3Adapter,
- defaultAbi,
- safeVersion,
- isL1SafeSingleton,
- customContractAddress,
- customContractAbi
- )
-
- this.safeVersion = safeVersion
- }
-
- /**
- * @returns Array[safeContractVersion]
- */
- VERSION: SafeContract_v1_3_0_Function<'VERSION'> = async () => {
- return [await this.contract.methods.VERSION().call()]
- }
-
- /**
- * @param args - Array[owner, txHash]
- * @returns Array[approvedHashes]
- */
- approvedHashes: SafeContract_v1_3_0_Function<'approvedHashes'> = async (args) => {
- return [await this.contract.methods.approvedHashes(...args).call()]
- }
-
- /**
- * Checks whether the signature provided is valid for the provided data, hash and number of required signatures.
- * Will revert otherwise.
- * @param args - Array[dataHash, data, signatures, requiredSignatures]
- * @returns Empty array
- */
- checkNSignatures: SafeContract_v1_3_0_Function<'checkNSignatures'> = async (args) => {
- if (this.contract.methods.checkNSignatures) {
- await this.contract.methods.checkNSignatures(...args).call()
- }
- return []
- }
-
- /**
- * Checks whether the signature provided is valid for the provided data and hash. Will revert otherwise.
- * @param args - Array[dataHash, data, signatures]
- * @returns Empty array
- */
- checkSignatures: SafeContract_v1_3_0_Function<'checkSignatures'> = async (args) => {
- await this.contract.methods.checkSignatures(...args).call()
- return []
- }
-
- /**
- * @returns Array[domainSeparator]
- */
- domainSeparator: SafeContract_v1_3_0_Function<'domainSeparator'> = async () => {
- return [await this.contract.methods.domainSeparator().call()]
- }
-
- /**
- * Encodes the data for a transaction to the Safe contract.
- * @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
- * @returns Array[encodedData]
- */
- encodeTransactionData: SafeContract_v1_3_0_Function<'encodeTransactionData'> = async (args) => {
- return [await this.contract.methods.encodeTransactionData(...args).call()]
- }
-
- /**
- * Returns array of modules.
- * @param args - Array[start, pageSize]
- * @returns Array[Array[modules], next]
- */
- getModulesPaginated: SafeContract_v1_3_0_Function<'getModulesPaginated'> = async (args) => {
- const res = await this.contract.methods.getModulesPaginated(...args).call()
- return [res.array, res.next]
- }
-
- /**
- * Returns the list of Safe owner accounts.
- * @returns Array[Array[owners]]
- */
- getOwners: SafeContract_v1_3_0_Function<'getOwners'> = async () => {
- return [await this.contract.methods.getOwners().call()]
- }
-
- /**
- * Reads `length` bytes of storage in the currents contract
- * @param args - Array[offset, length]
- * @returns Array[storage]
- */
- getStorageAt: SafeContract_v1_3_0_Function<'getStorageAt'> = async (args) => {
- return [await this.contract.methods.getStorageAt(...args).call()]
- }
-
- /**
- * Returns the Safe threshold.
- * @returns Array[threshold]
- */
- getThreshold: SafeContract_v1_3_0_Function<'getThreshold'> = async () => {
- return [await this.contract.methods.getThreshold().call()]
- }
-
- /**
- * Returns hash to be signed by owners.
- * @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
- * @returns Array[transactionHash]
- */
- getTransactionHash: SafeContract_v1_3_0_Function<'getTransactionHash'> = async (args) => {
- return [await this.contract.methods.getTransactionHash(...args).call()]
- }
-
- /**
- * Checks if a specific Safe module is enabled for the current Safe.
- * @param args - Array[moduleAddress]
- * @returns Array[isEnabled]
- */
- isModuleEnabled: SafeContract_v1_3_0_Function<'isModuleEnabled'> = async (args) => {
- return [await this.contract.methods.isModuleEnabled(...args).call()]
- }
-
- /**
- * Checks if a specific address is an owner of the current Safe.
- * @param args - Array[address]
- * @returns Array[isOwner]
- */
- isOwner: SafeContract_v1_3_0_Function<'isOwner'> = async (args) => {
- return [await this.contract.methods.isOwner(...args).call()]
- }
-
- /**
- * Returns the Safe nonce.
- * @returns Array[nonce]
- */
- nonce: SafeContract_v1_3_0_Function<'nonce'> = async () => {
- return [await this.contract.methods.nonce().call()]
- }
-
- /**
- * @param args - Array[messageHash]
- * @returns Array[signedMessages]
- */
- signedMessages: SafeContract_v1_3_0_Function<'signedMessages'> = async (args) => {
- return [await this.contract.methods.signedMessages(...args).call()]
- }
-
- /**
- * Checks whether a given Safe transaction can be executed successfully with no errors.
- * @param safeTransaction - The Safe transaction to check.
- * @param options - Optional transaction options.
- * @returns True, if the given transactions is valid.
- */
- async isValidTransaction(
- safeTransaction: SafeTransaction,
- options?: Web3TransactionOptions
- ): Promise {
- let isTxValid = false
- try {
- if (options && !options.gas) {
- options.gas = (
- await this.estimateGas(
- 'execTransaction',
- [
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- ],
- options
- )
- ).toString()
- }
- isTxValid = await this.contract.methods
- .execTransaction(
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- )
- .call(options)
- } catch {}
- return isTxValid
- }
-
- /**
- * Executes a transaction.
- * @param safeTransaction - The Safe transaction to execute.
- * @param options - Transaction options.
- * @returns Transaction result.
- */
- async execTransaction(
- safeTransaction: SafeTransaction,
- options?: Web3TransactionOptions
- ): Promise {
- if (options && !options.gas) {
- options.gas = (
- await this.estimateGas(
- 'execTransaction',
- [
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- ],
- options
- )
- ).toString()
- }
- const txResponse = this.contract.methods
- .execTransaction(
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- )
- .send(options)
-
- return toTxResult(txResponse, options)
- }
-
- /**
- * Returns array of first 10 modules.
- * @returns Array[modules]
- */
- async getModules(): Promise {
- const [modules] = await this.getModulesPaginated([SENTINEL_ADDRESS, BigInt(10)])
- return [...modules]
- }
-
- /**
- * Marks a hash as approved. This can be used to validate a hash that is used by a signature.
- * @param hash - The hash that should be marked as approved for signatures that are verified by this contract.
- * @param options - Optional transaction options.
- * @returns Transaction result.
- */
- async approveHash(
- hash: string,
- options?: Web3TransactionOptions
- ): Promise {
- if (options && !options.gas) {
- options.gas = (await this.estimateGas('approveHash', [hash], { ...options })).toString()
- }
- const txResponse = this.contract.methods.approveHash(hash).send(options)
- return toTxResult(txResponse, options)
- }
-
- async getChainId(): Promise<[bigint]> {
- return [await this.contract.methods.getChainId().call()]
- }
-
- /**
- * returns the version of the Safe contract.
- *
- * @returns {Promise} A promise that resolves to the version of the Safe contract as string.
- */
- async getVersion(): Promise {
- const [safeVersion] = await this.VERSION()
- return safeVersion as SafeVersion
- }
-
- /**
- * returns the nonce of the Safe contract.
- *
- * @returns {Promise} A promise that resolves to the nonce of the Safe contract.
- */
- async getNonce(): Promise {
- const [nonce] = await this.nonce()
- return nonce
- }
-}
-
-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 307afe685..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/Safe/v1.4.1/SafeContract_v1_4_1_Web3.ts
+++ /dev/null
@@ -1,348 +0,0 @@
-import SafeBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/Safe/SafeBaseContractWeb3'
-import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils'
-import { SENTINEL_ADDRESS } from '@safe-global/protocol-kit/adapters/web3/utils/constants'
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import {
- DeepWriteable,
- safe_1_4_1_ContractArtifacts,
- SafeContract_v1_4_1_Abi,
- SafeContract_v1_4_1_Contract,
- SafeContract_v1_4_1_Function,
- SafeTransaction,
- SafeVersion,
- Web3TransactionOptions,
- Web3TransactionResult
-} from '@safe-global/safe-core-sdk-types'
-
-/**
- * SafeContract_v1_4_1_Web3 is the implementation specific to the Safe contract version 1.4.1.
- *
- * This class specializes in handling interactions with the Safe contract version 1.4.1 using Web3.js.
- *
- * @extends SafeBaseContractWeb3 - Inherits from SafeBaseContractWeb3 with ABI specific to Safe contract version 1.4.1.
- * @implements SafeContract_v1_4_1_Contract - Implements the interface specific to Safe contract version 1.4.1.
- */
-class SafeContract_v1_4_1_Web3
- extends SafeBaseContractWeb3>
- implements SafeContract_v1_4_1_Contract
-{
- safeVersion: SafeVersion
-
- /**
- * Constructs an instance of SafeContract_v1_4_1_Web3
- *
- * @param chainId - The chain ID where the contract resides.
- * @param web3Adapter - An instance of Web3Adapter.
- * @param isL1SafeSingleton - A flag indicating if the contract is a L1 Safe Singleton.
- * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
- * @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.4.1 is used.
- */
- constructor(
- chainId: bigint,
- web3Adapter: Web3Adapter,
- isL1SafeSingleton = false,
- customContractAddress?: string,
- customContractAbi?: DeepWriteable
- ) {
- const safeVersion = '1.4.1'
- const defaultAbi = safe_1_4_1_ContractArtifacts.abi as DeepWriteable
-
- super(
- chainId,
- web3Adapter,
- defaultAbi,
- safeVersion,
- isL1SafeSingleton,
- customContractAddress,
- customContractAbi
- )
-
- this.safeVersion = safeVersion
- }
-
- /**
- * @returns Array[safeContractVersion]
- */
- VERSION: SafeContract_v1_4_1_Function<'VERSION'> = async () => {
- return [await this.contract.methods.VERSION().call()]
- }
-
- /**
- * @param args - Array[owner, txHash]
- * @returns Array[approvedHashes]
- */
- approvedHashes: SafeContract_v1_4_1_Function<'approvedHashes'> = async (args) => {
- return [await this.contract.methods.approvedHashes(...args).call()]
- }
-
- /**
- * Checks whether the signature provided is valid for the provided data, hash and number of required signatures.
- * Will revert otherwise.
- * @param args - Array[dataHash, data, signatures, requiredSignatures]
- * @returns Empty array
- */
- checkNSignatures: SafeContract_v1_4_1_Function<'checkNSignatures'> = async (args) => {
- if (this.contract.methods.checkNSignatures) {
- await this.contract.methods.checkNSignatures(...args).call()
- }
- return []
- }
-
- /**
- * Checks whether the signature provided is valid for the provided data and hash. Will revert otherwise.
- * @param args - Array[dataHash, data, signatures]
- * @returns Empty array
- */
- checkSignatures: SafeContract_v1_4_1_Function<'checkSignatures'> = async (args) => {
- await this.contract.methods.checkSignatures(...args).call()
- return []
- }
-
- /**
- * @returns Array[domainSeparator]
- */
- domainSeparator: SafeContract_v1_4_1_Function<'domainSeparator'> = async () => {
- return [await this.contract.methods.domainSeparator().call()]
- }
-
- /**
- * Encodes the data for a transaction to the Safe contract.
- * @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
- * @returns Array[encodedData]
- */
- encodeTransactionData: SafeContract_v1_4_1_Function<'encodeTransactionData'> = async (args) => {
- return [await this.contract.methods.encodeTransactionData(...args).call()]
- }
-
- /**
- * Returns array of modules.
- * @param args - Array[start, pageSize]
- * @returns Array[Array[modules], next]
- */
- getModulesPaginated: SafeContract_v1_4_1_Function<'getModulesPaginated'> = async (args) => {
- const res = await this.contract.methods.getModulesPaginated(...args).call()
- return [res.array, res.next]
- }
-
- /**
- * Returns the list of Safe owner accounts.
- * @returns Array[Array[owners]]
- */
- getOwners: SafeContract_v1_4_1_Function<'getOwners'> = async () => {
- return [await this.contract.methods.getOwners().call()]
- }
-
- /**
- * Reads `length` bytes of storage in the currents contract
- * @param args - Array[offset, length]
- * @returns Array[storage]
- */
- getStorageAt: SafeContract_v1_4_1_Function<'getStorageAt'> = async (args) => {
- return [await this.contract.methods.getStorageAt(...args).call()]
- }
-
- /**
- * Returns the Safe threshold.
- * @returns Array[threshold]
- */
- getThreshold: SafeContract_v1_4_1_Function<'getThreshold'> = async () => {
- return [await this.contract.methods.getThreshold().call()]
- }
-
- /**
- * Returns hash to be signed by owners.
- * @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
- * @returns Array[transactionHash]
- */
- getTransactionHash: SafeContract_v1_4_1_Function<'getTransactionHash'> = async (args) => {
- return [await this.contract.methods.getTransactionHash(...args).call()]
- }
-
- /**
- * Checks if a specific Safe module is enabled for the current Safe.
- * @param args - Array[moduleAddress]
- * @returns Array[isEnabled]
- */
- isModuleEnabled: SafeContract_v1_4_1_Function<'isModuleEnabled'> = async (args) => {
- return [await this.contract.methods.isModuleEnabled(...args).call()]
- }
-
- /**
- * Checks if a specific address is an owner of the current Safe.
- * @param args - Array[address]
- * @returns Array[isOwner]
- */
- isOwner: SafeContract_v1_4_1_Function<'isOwner'> = async (args) => {
- return [await this.contract.methods.isOwner(...args).call()]
- }
-
- /**
- * Returns the Safe nonce.
- * @returns Array[nonce]
- */
- nonce: SafeContract_v1_4_1_Function<'nonce'> = async () => {
- return [await this.contract.methods.nonce().call()]
- }
-
- /**
- * @param args - Array[messageHash]
- * @returns Array[signedMessages]
- */
- signedMessages: SafeContract_v1_4_1_Function<'signedMessages'> = async (args) => {
- return [await this.contract.methods.signedMessages(...args).call()]
- }
-
- /**
- * Checks whether a given Safe transaction can be executed successfully with no errors.
- * @param safeTransaction - The Safe transaction to check.
- * @param options - Optional transaction options.
- * @returns True, if the given transactions is valid.
- */
- async isValidTransaction(
- safeTransaction: SafeTransaction,
- options?: Web3TransactionOptions
- ): Promise {
- let isTxValid = false
- try {
- if (options && !options.gas) {
- options.gas = (
- await this.estimateGas(
- 'execTransaction',
- [
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- ],
- options
- )
- ).toString()
- }
- isTxValid = await this.contract.methods
- .execTransaction(
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- )
- .call(options)
- } catch {}
- return isTxValid
- }
-
- /**
- * Executes a transaction.
- * @param safeTransaction - The Safe transaction to execute.
- * @param options - Transaction options.
- * @returns Transaction result.
- */
- async execTransaction(
- safeTransaction: SafeTransaction,
- options?: Web3TransactionOptions
- ): Promise {
- if (options && !options.gas) {
- options.gas = (
- await this.estimateGas(
- 'execTransaction',
- [
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- ],
- options
- )
- ).toString()
- }
- const txResponse = this.contract.methods
- .execTransaction(
- safeTransaction.data.to,
- BigInt(safeTransaction.data.value),
- safeTransaction.data.data,
- safeTransaction.data.operation,
- BigInt(safeTransaction.data.safeTxGas),
- BigInt(safeTransaction.data.baseGas),
- BigInt(safeTransaction.data.gasPrice),
- safeTransaction.data.gasToken,
- safeTransaction.data.refundReceiver,
- safeTransaction.encodedSignatures()
- )
- .send(options)
-
- return toTxResult(txResponse, options)
- }
-
- /**
- * Returns array of first 10 modules.
- * @returns Array[modules]
- */
- async getModules(): Promise {
- const [modules] = await this.getModulesPaginated([SENTINEL_ADDRESS, BigInt(10)])
- return [...modules]
- }
-
- /**
- * Marks a hash as approved. This can be used to validate a hash that is used by a signature.
- * @param hash - The hash that should be marked as approved for signatures that are verified by this contract.
- * @param options - Optional transaction options.
- * @returns Transaction result.
- */
- async approveHash(
- hash: string,
- options?: Web3TransactionOptions
- ): Promise {
- if (options && !options.gas) {
- options.gas = (await this.estimateGas('approveHash', [hash], { ...options })).toString()
- }
- const txResponse = this.contract.methods.approveHash(hash).send(options)
- return toTxResult(txResponse, options)
- }
-
- /**
- * Returns the chain id of the Safe contract. (Custom method - not defined in the Safe Contract)
- * @returns Array[chainId]
- */
- async getChainId(): Promise<[bigint]> {
- return [await this.contract.methods.getChainId().call()]
- }
-
- /**
- * returns the version of the Safe contract.
- *
- * @returns {Promise} A promise that resolves to the version of the Safe contract as string.
- */
- async getVersion(): Promise {
- const [safeVersion] = await this.VERSION()
- return safeVersion as SafeVersion
- }
-
- /**
- * returns the nonce of the Safe contract.
- *
- * @returns {Promise} A promise that resolves to the nonce of the Safe contract.
- */
- async getNonce(): Promise {
- const [nonce] = await this.nonce()
- return nonce
- }
-}
-
-export default SafeContract_v1_4_1_Web3
diff --git a/packages/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/SafeProxyFactoryBaseContractWeb3.ts b/packages/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/SafeProxyFactoryBaseContractWeb3.ts
deleted file mode 100644
index af6c48c1a..000000000
--- a/packages/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/SafeProxyFactoryBaseContractWeb3.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-import { Abi } from 'abitype'
-import { AbiItem } from 'web3-utils'
-
-import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter'
-import BaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/BaseContractWeb3'
-import { contractName } from '@safe-global/protocol-kit/contracts/config'
-import {
- CreateProxyProps as CreateProxyPropsGeneral,
- SafeVersion,
- Web3TransactionOptions
-} from '@safe-global/safe-core-sdk-types'
-
-export interface CreateProxyProps extends CreateProxyPropsGeneral {
- options?: Web3TransactionOptions
-}
-
-/**
- * Abstract class SafeProxyFactoryBaseContractWeb3 extends BaseContractWeb3 to specifically integrate with the SafeProxyFactory contract.
- * It is designed to be instantiated for different versions of the Safe contract.
- *
- * Subclasses of SafeProxyFactoryBaseContractWeb3 are expected to represent specific versions of the contract.
- *
- * @template SafeProxyFactoryContractAbiType - The ABI type specific to the version of the Safe Proxy Factory contract, extending AbiItem[].
- * @extends BaseContractWeb3