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 - Extends the generic BaseContractWeb3. - * - * Example subclasses: - * - SafeProxyFactoryContract_v1_4_1_Web3 extends SafeProxyFactoryBaseContractWeb3 - * - SafeProxyFactoryContract_v1_3_0_Web3 extends SafeProxyFactoryBaseContractWeb3 - * - SafeProxyFactoryContract_v1_2_0_Web3 extends SafeProxyFactoryBaseContractWeb3 - * - SafeProxyFactoryContract_v1_1_1_Web3 extends SafeProxyFactoryBaseContractWeb3 - * - SafeProxyFactoryContract_v1_0_0_Web3 extends SafeProxyFactoryBaseContractWeb3 - */ -abstract class SafeProxyFactoryBaseContractWeb3< - SafeProxyFactoryContractAbiType extends AbiItem[] & Abi -> extends BaseContractWeb3 { - contractName: contractName - - /** - * @constructor - * Constructs an instance of SafeProxyFactoryBaseContractWeb3. - * - * @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 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: SafeProxyFactoryContractAbiType, - safeVersion: SafeVersion, - customContractAddress?: string, - customContractAbi?: SafeProxyFactoryContractAbiType - ) { - const contractName = 'safeProxyFactoryVersion' - - super( - contractName, - chainId, - web3Adapter, - defaultAbi, - safeVersion, - customContractAddress, - customContractAbi - ) - - this.contractName = contractName - } -} - -export default SafeProxyFactoryBaseContractWeb3 diff --git a/packages/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0_Web3.ts deleted file mode 100644 index d69d4876a..000000000 --- a/packages/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0_Web3.ts +++ /dev/null @@ -1,136 +0,0 @@ -import { TransactionReceipt } from 'web3-core/types' -import SafeProxyFactoryBaseContractWeb3, { - CreateProxyProps -} from '@safe-global/protocol-kit/adapters/web3/contracts/SafeProxyFactory/SafeProxyFactoryBaseContractWeb3' -import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils' -import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter' -import { - DeepWriteable, - SafeVersion, - SafeProxyFactoryContract_v1_0_0_Abi, - SafeProxyFactoryContract_v1_0_0_Contract, - SafeProxyFactoryContract_v1_0_0_Function, - safeProxyFactory_1_0_0_ContractArtifacts -} from '@safe-global/safe-core-sdk-types' - -/** - * SafeProxyFactoryContract_v1_0_0_Web3 is the implementation specific to the Safe Proxy Factory contract version 1.0.0. - * - * This class specializes in handling interactions with the Safe Proxy Factory contract version 1.0.0 using Web3.js. - * - * @extends SafeProxyFactoryBaseContractWeb3 - Inherits from SafeProxyFactoryBaseContractWeb3 with ABI specific to Safe Proxy Factory contract version 1.0.0. - * @implements SafeProxyFactoryContract_v1_0_0_Contract - Implements the interface specific to Safe Proxy Factory contract version 1.0.0. - */ -class SafeProxyFactoryContract_v1_0_0_Web3 - extends SafeProxyFactoryBaseContractWeb3> - implements SafeProxyFactoryContract_v1_0_0_Contract -{ - safeVersion: SafeVersion - - /** - * Constructs an instance of SafeProxyFactoryContract_v1_0_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 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, - customContractAddress?: string, - customContractAbi?: DeepWriteable - ) { - const safeVersion = '1.0.0' - const defaultAbi = - safeProxyFactory_1_0_0_ContractArtifacts.abi as DeepWriteable - - super(chainId, web3Adapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) - - this.safeVersion = safeVersion - } - - /** - * Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address. - * @returns Array[creationCode] - */ - proxyCreationCode: SafeProxyFactoryContract_v1_0_0_Function<'proxyCreationCode'> = async () => { - return [await this.contract.methods.proxyCreationCode().call()] - } - - /** - * Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed. - * @returns Array[runtimeCode] - */ - proxyRuntimeCode: SafeProxyFactoryContract_v1_0_0_Function<'proxyRuntimeCode'> = async () => { - return [await this.contract.methods.proxyRuntimeCode().call()] - } - - /** - * Allows to create new proxy contact and execute a message call to the new proxy within one transaction. - * @param args - Array[masterCopy, data] - * @returns Array[proxyAddress] - */ - createProxy: SafeProxyFactoryContract_v1_0_0_Function<'createProxy'> = async (args) => { - return [await this.contract.methods.createProxy(...args).call()] - } - - /** - * Allows to create new proxy contract and execute a message call to the new proxy within one transaction. - * @param args - Array[masterCopy, initializer, saltNonce] - * @returns Array[proxyAddress] - */ - createProxyWithNonce: SafeProxyFactoryContract_v1_0_0_Function<'createProxyWithNonce'> = async ( - args - ) => { - return [await this.contract.methods.createProxyWithNonce(...args).call()] - } - - /** - * Allows to create new proxy contract and execute a message call to the new proxy within one transaction. - * @param {CreateProxyProps} props - Properties for the new proxy contract. - * @returns The address of the new proxy contract. - */ - async createProxyWithOptions({ - safeSingletonAddress, - initializer, - saltNonce, - options, - callback - }: CreateProxyProps): Promise { - const saltNonceBigInt = BigInt(saltNonce) - - if (saltNonceBigInt < 0) throw new Error('saltNonce must be greater than or equal to 0') - if (options && !options.gas) { - options.gas = ( - await this.estimateGas( - 'createProxyWithNonce', - [safeSingletonAddress, initializer, saltNonceBigInt], - { - ...options - } - ) - ).toString() - } - - const txResponse = this.contract.methods - .createProxyWithNonce(safeSingletonAddress, initializer, saltNonce) - .send(options) - - if (callback) { - const txResult = await toTxResult(txResponse) - callback(txResult.hash) - } - - const txResult: TransactionReceipt = await new Promise((resolve, reject) => - txResponse.once('receipt', (receipt: TransactionReceipt) => resolve(receipt)).catch(reject) - ) - const proxyAddress = txResult.events?.ProxyCreation?.returnValues?.proxy - if (!proxyAddress) { - throw new Error('SafeProxy was not deployed correctly') - } - return proxyAddress - } -} - -export default SafeProxyFactoryContract_v1_0_0_Web3 diff --git a/packages/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1_Web3.ts deleted file mode 100644 index 8bc6ca814..000000000 --- a/packages/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1_Web3.ts +++ /dev/null @@ -1,156 +0,0 @@ -import { TransactionReceipt } from 'web3-core/types' -import SafeProxyFactoryBaseContractWeb3, { - CreateProxyProps -} from '@safe-global/protocol-kit/adapters/web3/contracts/SafeProxyFactory/SafeProxyFactoryBaseContractWeb3' -import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils' -import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter' -import { - DeepWriteable, - SafeVersion, - SafeProxyFactoryContract_v1_1_1_Abi, - SafeProxyFactoryContract_v1_1_1_Contract, - SafeProxyFactoryContract_v1_1_1_Function, - safeProxyFactory_1_1_1_ContractArtifacts -} from '@safe-global/safe-core-sdk-types' - -/** - * SafeProxyFactoryContract_v1_1_1_Web3 is the implementation specific to the Safe Proxy Factory contract version 1.1.1. - * - * This class specializes in handling interactions with the Safe Proxy Factory contract version 1.1.1 using Web3.js. - * - * @extends SafeProxyFactoryBaseContractWeb3 - Inherits from SafeProxyFactoryBaseContractWeb3 with ABI specific to Safe Proxy Factory contract version 1.1.1. - * @implements SafeProxyFactoryContract_v1_1_1_Contract - Implements the interface specific to Safe Proxy Factory contract version 1.1.1. - */ -class SafeProxyFactoryContract_v1_1_1_Web3 - extends SafeProxyFactoryBaseContractWeb3> - implements SafeProxyFactoryContract_v1_1_1_Contract -{ - safeVersion: SafeVersion - - /** - * Constructs an instance of SafeProxyFactoryContract_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 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, - customContractAddress?: string, - customContractAbi?: DeepWriteable - ) { - const safeVersion = '1.1.1' - const defaultAbi = - safeProxyFactory_1_1_1_ContractArtifacts.abi as DeepWriteable - - super(chainId, web3Adapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) - - this.safeVersion = safeVersion - } - - /** - * Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address. - * @returns Array[creationCode] - */ - proxyCreationCode: SafeProxyFactoryContract_v1_1_1_Function<'proxyCreationCode'> = async () => { - return [await this.contract.methods.proxyCreationCode().call()] - } - - /** - * Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed. - * @returns Array[runtimeCode] - */ - proxyRuntimeCode: SafeProxyFactoryContract_v1_1_1_Function<'proxyRuntimeCode'> = async () => { - return [await this.contract.methods.proxyRuntimeCode().call()] - } - - /** - * Allows to get the address for a new proxy contact created via `createProxyWithNonce`. - * @param args - Array[masterCopy, initializer, saltNonce] - * @returns Array[proxyAddress] - */ - calculateCreateProxyWithNonceAddress: SafeProxyFactoryContract_v1_1_1_Function<'calculateCreateProxyWithNonceAddress'> = - async (args) => { - return [await this.contract.methods.calculateCreateProxyWithNonceAddress(...args).call()] - } - - /** - * Allows to create new proxy contact and execute a message call to the new proxy within one transaction. - * @param args - Array[masterCopy, data] - * @returns Array[proxyAddress] - */ - createProxy: SafeProxyFactoryContract_v1_1_1_Function<'createProxy'> = async (args) => { - return [await this.contract.methods.createProxy(...args).call()] - } - - /** - * Allows to create new proxy contract, execute a message call to the new proxy and call a specified callback within one transaction. - * @param args - Array[masterCopy, initializer, saltNonce, callback] - * @returns Array[proxyAddress] - */ - createProxyWithCallback: SafeProxyFactoryContract_v1_1_1_Function<'createProxyWithCallback'> = - async (args) => { - return [await this.contract.methods.createProxyWithCallback(...args).call()] - } - - /** - * Allows to create new proxy contract and execute a message call to the new proxy within one transaction. - * @param args - Array[masterCopy, initializer, saltNonce] - * @returns Array[proxyAddress] - */ - createProxyWithNonce: SafeProxyFactoryContract_v1_1_1_Function<'createProxyWithNonce'> = async ( - args - ) => { - return [await this.contract.methods.createProxyWithNonce(...args).call()] - } - - /** - * Allows to create new proxy contract and execute a message call to the new proxy within one transaction. - * @param {CreateProxyProps} props - Properties for the new proxy contract. - * @returns The address of the new proxy contract. - */ - async createProxyWithOptions({ - safeSingletonAddress, - initializer, - saltNonce, - options, - callback - }: CreateProxyProps): Promise { - const saltNonceBigInt = BigInt(saltNonce) - - if (saltNonceBigInt < 0) throw new Error('saltNonce must be greater than or equal to 0') - if (options && !options.gas) { - options.gas = ( - await this.estimateGas( - 'createProxyWithNonce', - [safeSingletonAddress, initializer, saltNonceBigInt], - { - ...options - } - ) - ).toString() - } - - const txResponse = this.contract.methods - .createProxyWithNonce(safeSingletonAddress, initializer, saltNonce) - .send(options) - - if (callback) { - const txResult = await toTxResult(txResponse) - callback(txResult.hash) - } - - const txResult: TransactionReceipt = await new Promise((resolve, reject) => - txResponse.once('receipt', (receipt: TransactionReceipt) => resolve(receipt)).catch(reject) - ) - const proxyAddress = txResult.events?.ProxyCreation?.returnValues?.proxy - if (!proxyAddress) { - throw new Error('SafeProxy was not deployed correctly') - } - return proxyAddress - } -} - -export default SafeProxyFactoryContract_v1_1_1_Web3 diff --git a/packages/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0_Web3.ts deleted file mode 100644 index c643e0640..000000000 --- a/packages/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0_Web3.ts +++ /dev/null @@ -1,156 +0,0 @@ -import { TransactionReceipt } from 'web3-core/types' -import SafeProxyFactoryBaseContractWeb3, { - CreateProxyProps -} from '@safe-global/protocol-kit/adapters/web3/contracts/SafeProxyFactory/SafeProxyFactoryBaseContractWeb3' -import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils' -import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter' -import { - DeepWriteable, - SafeVersion, - SafeProxyFactoryContract_v1_3_0_Abi, - SafeProxyFactoryContract_v1_3_0_Contract, - SafeProxyFactoryContract_v1_3_0_Function, - safeProxyFactory_1_3_0_ContractArtifacts -} from '@safe-global/safe-core-sdk-types' - -/** - * SafeProxyFactoryContract_v1_3_0_Web3 is the implementation specific to the Safe Proxy Factory contract version 1.3.0. - * - * This class specializes in handling interactions with the Safe Proxy Factory contract version 1.3.0 using Web3.js. - * - * @extends SafeProxyFactoryBaseContractWeb3 - Inherits from SafeProxyFactoryBaseContractWeb3 with ABI specific to Safe Proxy Factory contract version 1.3.0. - * @implements SafeProxyFactoryContract_v1_3_0_Contract - Implements the interface specific to Safe Proxy Factory contract version 1.3.0. - */ -class SafeProxyFactoryContract_v1_3_0_Web3 - extends SafeProxyFactoryBaseContractWeb3> - implements SafeProxyFactoryContract_v1_3_0_Contract -{ - safeVersion: SafeVersion - - /** - * Constructs an instance of SafeProxyFactoryContract_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 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, - customContractAddress?: string, - customContractAbi?: DeepWriteable - ) { - const safeVersion = '1.3.0' - const defaultAbi = - safeProxyFactory_1_3_0_ContractArtifacts.abi as DeepWriteable - - super(chainId, web3Adapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) - - this.safeVersion = safeVersion - } - - /** - * Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address. - * @returns Array[creationCode] - */ - proxyCreationCode: SafeProxyFactoryContract_v1_3_0_Function<'proxyCreationCode'> = async () => { - return [await this.contract.methods.proxyCreationCode().call()] - } - - /** - * Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed. - * @returns Array[runtimeCode] - */ - proxyRuntimeCode: SafeProxyFactoryContract_v1_3_0_Function<'proxyRuntimeCode'> = async () => { - return [await this.contract.methods.proxyRuntimeCode().call()] - } - - /** - * Allows to get the address for a new proxy contact created via `createProxyWithNonce`. - * @param args - Array[singleton, initializer, saltNonce] - * @returns Array[proxyAddress] - */ - calculateCreateProxyWithNonceAddress: SafeProxyFactoryContract_v1_3_0_Function<'calculateCreateProxyWithNonceAddress'> = - async (args) => { - return [await this.contract.methods.calculateCreateProxyWithNonceAddress(...args).call()] - } - - /** - * Allows to create new proxy contact and execute a message call to the new proxy within one transaction. - * @param args - Array[singleton, data] - * @returns Array[proxyAddress] - */ - createProxy: SafeProxyFactoryContract_v1_3_0_Function<'createProxy'> = async (args) => { - return [await this.contract.methods.createProxy(...args).call()] - } - - /** - * Allows to create new proxy contract, execute a message call to the new proxy and call a specified callback within one transaction. - * @param args - Array[singleton, initializer, saltNonce, callback] - * @returns Array[proxyAddress] - */ - createProxyWithCallback: SafeProxyFactoryContract_v1_3_0_Function<'createProxyWithCallback'> = - async (args) => { - return [await this.contract.methods.createProxyWithCallback(...args).call()] - } - - /** - * Allows to create new proxy contract and execute a message call to the new proxy within one transaction. - * @param args - Array[singleton, initializer, saltNonce] - * @returns Array[proxyAddress] - */ - createProxyWithNonce: SafeProxyFactoryContract_v1_3_0_Function<'createProxyWithNonce'> = async ( - args - ) => { - return [await this.contract.methods.createProxyWithNonce(...args).call()] - } - - /** - * Allows to create new proxy contract and execute a message call to the new proxy within one transaction. - * @param {CreateProxyProps} props - Properties for the new proxy contract. - * @returns The address of the new proxy contract. - */ - async createProxyWithOptions({ - safeSingletonAddress, - initializer, - saltNonce, - options, - callback - }: CreateProxyProps): Promise { - const saltNonceBigInt = BigInt(saltNonce) - - if (saltNonceBigInt < 0) throw new Error('saltNonce must be greater than or equal to 0') - if (options && !options.gas) { - options.gas = ( - await this.estimateGas( - 'createProxyWithNonce', - [safeSingletonAddress, initializer, saltNonceBigInt], - { - ...options - } - ) - ).toString() - } - - const txResponse = this.contract.methods - .createProxyWithNonce(safeSingletonAddress, initializer, saltNonce) - .send(options) - - if (callback) { - const txResult = await toTxResult(txResponse) - callback(txResult.hash) - } - - const txResult: TransactionReceipt = await new Promise((resolve, reject) => - txResponse.once('receipt', (receipt: TransactionReceipt) => resolve(receipt)).catch(reject) - ) - const proxyAddress = txResult.events?.ProxyCreation?.returnValues?.proxy - if (!proxyAddress) { - throw new Error('SafeProxy was not deployed correctly') - } - return proxyAddress - } -} - -export default SafeProxyFactoryContract_v1_3_0_Web3 diff --git a/packages/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1_Web3.ts deleted file mode 100644 index 8c02f7153..000000000 --- a/packages/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1_Web3.ts +++ /dev/null @@ -1,146 +0,0 @@ -import { TransactionReceipt } from 'web3-core/types' -import SafeProxyFactoryBaseContractWeb3, { - CreateProxyProps -} from '@safe-global/protocol-kit/adapters/web3/contracts/SafeProxyFactory/SafeProxyFactoryBaseContractWeb3' -import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils' -import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter' -import { - DeepWriteable, - SafeVersion, - SafeProxyFactoryContract_v1_4_1_Abi, - SafeProxyFactoryContract_v1_4_1_Contract, - SafeProxyFactoryContract_v1_4_1_Function, - safeProxyFactory_1_4_1_ContractArtifacts -} from '@safe-global/safe-core-sdk-types' - -/** - * SafeProxyFactoryContract_v1_4_1_Web3 is the implementation specific to the Safe Proxy Factory contract version 1.4.1. - * - * This class specializes in handling interactions with the Safe Proxy Factory contract version 1.4.1 using Web3.js. - * - * @extends SafeProxyFactoryBaseContractWeb3 - Inherits from SafeProxyFactoryBaseContractWeb3 with ABI specific to Safe Proxy Factory contract version 1.4.1. - * @implements SafeProxyFactoryContract_v1_4_1_Contract - Implements the interface specific to Safe Proxy Factory contract version 1.4.1. - */ -class SafeProxyFactoryContract_v1_4_1_Web3 - extends SafeProxyFactoryBaseContractWeb3> - implements SafeProxyFactoryContract_v1_4_1_Contract -{ - safeVersion: SafeVersion - - /** - * Constructs an instance of SafeProxyFactoryContract_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 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, - customContractAddress?: string, - customContractAbi?: DeepWriteable - ) { - const safeVersion = '1.4.1' - const defaultAbi = - safeProxyFactory_1_4_1_ContractArtifacts.abi as DeepWriteable - - super(chainId, web3Adapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) - - this.safeVersion = safeVersion - } - - /** - * Returns the ID of the chain the contract is currently deployed on. - * @returns Array[chainId] - */ - getChainId: SafeProxyFactoryContract_v1_4_1_Function<'getChainId'> = async () => { - return [await this.contract.methods.getChainId().call()] - } - - /** - * Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address. - * @returns Array[creationCode] - */ - proxyCreationCode: SafeProxyFactoryContract_v1_4_1_Function<'proxyCreationCode'> = async () => { - return [await this.contract.methods.proxyCreationCode().call()] - } - - /** - * Deploys a new chain-specific proxy with singleton and salt. Optionally executes an initializer call to a new proxy. - * @param args - Array[singleton, initializer, saltNonce] - * @returns Array[proxy] - */ - createChainSpecificProxyWithNonce: SafeProxyFactoryContract_v1_4_1_Function<'createChainSpecificProxyWithNonce'> = - async (args) => { - return [await this.contract.methods.createChainSpecificProxyWithNonce(...args).call()] - } - - /** - * Deploy a new proxy with singleton and salt. - * Optionally executes an initializer call to a new proxy and calls a specified callback address. - * @param args - Array[singleton, initializer, saltNonce, callback] - * @returns Array[proxy] - */ - createProxyWithCallback: SafeProxyFactoryContract_v1_4_1_Function<'createProxyWithCallback'> = - async (args) => { - return [await this.contract.methods.createProxyWithCallback(...args).call()] - } - - /** - * Deploys a new proxy with singleton and salt. Optionally executes an initializer call to a new proxy. - * @param args - Array[singleton, initializer, saltNonce] - * @returns Array[proxy] - */ - createProxyWithNonce: SafeProxyFactoryContract_v1_4_1_Function<'createProxyWithNonce'> = async ( - args - ) => { - return [await this.contract.methods.createProxyWithNonce(...args).call()] - } - - /** - * Allows to create new proxy contract and execute a message call to the new proxy within one transaction. - * @param {CreateProxyProps} props - Properties for the new proxy contract. - * @returns The address of the new proxy contract. - */ - async createProxyWithOptions({ - safeSingletonAddress, - initializer, - saltNonce, - options, - callback - }: CreateProxyProps): Promise { - const saltNonceBigInt = BigInt(saltNonce) - - if (saltNonceBigInt < 0) throw new Error('saltNonce must be greater than or equal to 0') - if (options && !options.gas) { - options.gas = ( - await this.estimateGas( - 'createProxyWithNonce', - [safeSingletonAddress, initializer, saltNonceBigInt], - { ...options } - ) - ).toString() - } - - const txResponse = this.contract.methods - .createProxyWithNonce(safeSingletonAddress, initializer, saltNonce) - .send(options) - - if (callback) { - const txResult = await toTxResult(txResponse) - callback(txResult.hash) - } - - const txResult: TransactionReceipt = await new Promise((resolve, reject) => - txResponse.once('receipt', (receipt: TransactionReceipt) => resolve(receipt)).catch(reject) - ) - const proxyAddress = txResult.events?.ProxyCreation?.returnValues?.proxy - if (!proxyAddress) { - throw new Error('SafeProxy was not deployed correctly') - } - return proxyAddress - } -} - -export default SafeProxyFactoryContract_v1_4_1_Web3 diff --git a/packages/protocol-kit/src/adapters/web3/contracts/SignMessageLib/SignMessageLibBaseContractWeb3.ts b/packages/protocol-kit/src/adapters/web3/contracts/SignMessageLib/SignMessageLibBaseContractWeb3.ts deleted file mode 100644 index 690b9c87d..000000000 --- a/packages/protocol-kit/src/adapters/web3/contracts/SignMessageLib/SignMessageLibBaseContractWeb3.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 SignMessageLibBaseContractWeb3 extends BaseContractWeb3 to specifically integrate with the SignMessageLib contract. - * It is designed to be instantiated for different versions of the SignMessageLib contract. - * - * Subclasses of SignMessageLibBaseContractWeb3 are expected to represent specific versions of the SignMessageLib contract. - * - * @template SignMessageLibContractAbiType - The ABI type specific to the version of the SignMessageLib contract, extending InterfaceAbi from Web3. - * @extends BaseContractWeb3 - Extends the generic BaseContractWeb3. - * - * Example subclasses: - * - SignMessageLibContract_v1_4_1_Web3 extends SignMessageLibBaseContractWeb3 - * - SignMessageLibContract_v1_3_0_Web3 extends SignMessageLibBaseContractWeb3 - */ -abstract class SignMessageLibBaseContractWeb3< - SignMessageLibContractAbiType extends AbiItem[] & Abi -> extends BaseContractWeb3 { - contractName: contractName - - /** - * @constructor - * Constructs an instance of SignMessageLibBaseContractWeb3. - * - * @param chainId - The chain ID of the contract. - * @param web3Adapter - An instance of Web3Adapter. - * @param defaultAbi - The default ABI for the SignMessageLib contract. It should be compatible with the specific version of the SignMessageLib contract. - * @param safeVersion - The version of the SignMessageLib contract. - * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the SignMessageLib deployments based on the chainId and safeVersion. - * @param customContractAbi - Optional custom ABI for the contract. If not provided, the ABI is derived from the SignMessageLib deployments or the defaultAbi is used. - */ - constructor( - chainId: bigint, - web3Adapter: Web3Adapter, - defaultAbi: SignMessageLibContractAbiType, - safeVersion: SafeVersion, - customContractAddress?: string, - customContractAbi?: SignMessageLibContractAbiType - ) { - const contractName = 'signMessageLibVersion' - - super( - contractName, - chainId, - web3Adapter, - defaultAbi, - safeVersion, - customContractAddress, - customContractAbi - ) - - this.contractName = contractName - } -} - -export default SignMessageLibBaseContractWeb3 diff --git a/packages/protocol-kit/src/adapters/web3/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0_Web3.ts deleted file mode 100644 index 4af50966f..000000000 --- a/packages/protocol-kit/src/adapters/web3/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0_Web3.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils' -import SignMessageLibBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/SignMessageLib/SignMessageLibBaseContractWeb3' -import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter' -import { - DeepWriteable, - AdapterSpecificContractFunction, - SafeVersion, - SignMessageLibContract_v1_3_0_Abi, - SignMessageLibContract_v1_3_0_Contract, - SignMessageLibContract_v1_3_0_Function, - Web3TransactionOptions, - signMessageLib_1_3_0_ContractArtifacts -} from '@safe-global/safe-core-sdk-types' - -/** - * SignMessageLibContract_v1_3_0_Web3 is the implementation specific to the SignMessageLib contract version 1.3.0. - * - * This class specializes in handling interactions with the SignMessageLib contract version 1.3.0 using Web3.js v6. - * - * @extends SignMessageLibBaseContractWeb3 - Inherits from SignMessageLibBaseContractWeb3 with ABI specific to SignMessageLib contract version 1.3.0. - * @implements SignMessageLibContract_v1_3_0_Contract - Implements the interface specific to SignMessageLib contract version 1.3.0. - */ -class SignMessageLibContract_v1_3_0_Web3 - extends SignMessageLibBaseContractWeb3> - implements SignMessageLibContract_v1_3_0_Contract -{ - safeVersion: SafeVersion - - /** - * Constructs an instance of SignMessageLibContract_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 SignMessageLib 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 = - signMessageLib_1_3_0_ContractArtifacts.abi as DeepWriteable - - super(chainId, web3Adapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) - - this.safeVersion = safeVersion - } - - /** - * @param args - Array[message] - */ - getMessageHash: SignMessageLibContract_v1_3_0_Function<'getMessageHash'> = async (args) => { - return [await this.contract.methods.getMessageHash(...args).call()] - } - - /** - * @param args - Array[data] - */ - signMessage: AdapterSpecificContractFunction< - SignMessageLibContract_v1_3_0_Abi, - 'signMessage', - Web3TransactionOptions - > = async (data, options) => { - if (options && !options.gas) { - options.gas = Number(await this.estimateGas('signMessage', data, { ...options })) - } - - const txResponse = this.contract.methods.signMessage(data).send(options) - - return toTxResult(txResponse, options) - } -} - -export default SignMessageLibContract_v1_3_0_Web3 diff --git a/packages/protocol-kit/src/adapters/web3/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1_Web3.ts deleted file mode 100644 index 92ece8403..000000000 --- a/packages/protocol-kit/src/adapters/web3/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1_Web3.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils' -import SignMessageLibBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/SignMessageLib/SignMessageLibBaseContractWeb3' -import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter' -import { - DeepWriteable, - SafeVersion, - AdapterSpecificContractFunction, - SignMessageLibContract_v1_4_1_Abi, - SignMessageLibContract_v1_4_1_Contract, - SignMessageLibContract_v1_4_1_Function, - Web3TransactionOptions, - signMessageLib_1_4_1_ContractArtifacts -} from '@safe-global/safe-core-sdk-types' - -/** - * SignMessageLibContract_v1_4_1_Web3 is the implementation specific to the SignMessageLib contract version 1.4.1. - * - * This class specializes in handling interactions with the SignMessageLib contract version 1.4.1 using Web3.js v6. - * - * @extends SignMessageLibBaseContractWeb3 - Inherits from SignMessageLibBaseContractWeb3 with ABI specific to SignMessageLib contract version 1.4.1. - * @implements SignMessageLibContract_v1_4_1_Contract - Implements the interface specific to SignMessageLib contract version 1.4.1. - */ -class SignMessageLibContract_v1_4_1_Web3 - extends SignMessageLibBaseContractWeb3> - implements SignMessageLibContract_v1_4_1_Contract -{ - safeVersion: SafeVersion - - /** - * Constructs an instance of SignMessageLibContract_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 SignMessageLib 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 = - signMessageLib_1_4_1_ContractArtifacts.abi as DeepWriteable - - super(chainId, web3Adapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) - - this.safeVersion = safeVersion - } - - /** - * @param args - Array[message] - */ - getMessageHash: SignMessageLibContract_v1_4_1_Function<'getMessageHash'> = async (args) => { - return [await this.contract.methods.getMessageHash(...args).call()] - } - - /** - * @param args - Array[data] - */ - signMessage: AdapterSpecificContractFunction< - SignMessageLibContract_v1_4_1_Abi, - 'signMessage', - Web3TransactionOptions - > = async (data, options) => { - if (options && !options.gas) { - options.gas = Number(await this.estimateGas('signMessage', data, { ...options })) - } - - const txResponse = this.contract.methods.signMessage(data).send(options) - - return toTxResult(txResponse, options) - } -} - -export default SignMessageLibContract_v1_4_1_Web3 diff --git a/packages/protocol-kit/src/adapters/web3/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContractWeb3.ts b/packages/protocol-kit/src/adapters/web3/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContractWeb3.ts deleted file mode 100644 index a1316c6e2..000000000 --- a/packages/protocol-kit/src/adapters/web3/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContractWeb3.ts +++ /dev/null @@ -1,61 +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 SimulateTxAccessorBaseContractWeb3 extends BaseContractWeb3 to specifically integrate with the SimulateTxAccessor contract. - * It is designed to be instantiated for different versions of the Safe contract. - * - * Subclasses of SimulateTxAccessorBaseContractWeb3 are expected to represent specific versions of the contract. - * - * @template SimulateTxAccessorContractAbiType - The ABI type specific to the version of the SimulateTxAccessor contract, extending InterfaceAbi from Web3. - * @extends BaseContractWeb3 - Extends the generic BaseContractWeb3. - * - * Example subclasses: - * - SimulateTxAccessorContract_v1_4_1_Web3 extends SimulateTxAccessorBaseContractWeb3 - * - SimulateTxAccessorContract_v1_3_0_Web3 extends SimulateTxAccessorBaseContractWeb3 - */ -abstract class SimulateTxAccessorBaseContractWeb3< - SimulateTxAccessorContractAbiType extends AbiItem[] & Abi -> extends BaseContractWeb3 { - contractName: contractName - - /** - * @constructor - * Constructs an instance of SimulateTxAccessorBaseContractWeb3. - * - * @param chainId - The chain ID of the contract. - * @param web3Adapter - An instance of Web3Adapter. - * @param defaultAbi - The default ABI for the SimulateTxAccessor 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: SimulateTxAccessorContractAbiType, - safeVersion: SafeVersion, - customContractAddress?: string, - customContractAbi?: SimulateTxAccessorContractAbiType - ) { - const contractName = 'simulateTxAccessorVersion' - - super( - contractName, - chainId, - web3Adapter, - defaultAbi, - safeVersion, - customContractAddress, - customContractAbi - ) - - this.contractName = contractName - } -} - -export default SimulateTxAccessorBaseContractWeb3 diff --git a/packages/protocol-kit/src/adapters/web3/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0_Web3.ts deleted file mode 100644 index 1ed1715e2..000000000 --- a/packages/protocol-kit/src/adapters/web3/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0_Web3.ts +++ /dev/null @@ -1,58 +0,0 @@ -import SimulateTxAccessorBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContractWeb3' -import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter' -import { - DeepWriteable, - SafeVersion, - SimulateTxAccessorContract_v1_3_0_Abi, - SimulateTxAccessorContract_v1_3_0_Contract, - SimulateTxAccessorContract_v1_3_0_Function, - simulateTxAccessor_1_3_0_ContractArtifacts -} from '@safe-global/safe-core-sdk-types' - -/** - * SimulateTxAccessorContract_v1_3_0_Web3 is the implementation specific to the SimulateTxAccessor contract version 1.3.0. - * - * This class specializes in handling interactions with the SimulateTxAccessor contract version 1.3.0 using Web3.js. - * - * @extends SimulateTxAccessorBaseContractWeb3 - Inherits from SimulateTxAccessorBaseContractWeb3 with ABI specific to SimulateTxAccessor contract version 1.3.0. - * @implements SimulateTxAccessorContract_v1_3_0_Contract - Implements the interface specific to SimulateTxAccessor contract version 1.3.0. - */ -class SimulateTxAccessorContract_v1_3_0_Web3 - extends SimulateTxAccessorBaseContractWeb3> - implements SimulateTxAccessorContract_v1_3_0_Contract -{ - safeVersion: SafeVersion - - /** - * Constructs an instance of SimulateTxAccessorContract_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 SimulateTxAccessor 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 = - simulateTxAccessor_1_3_0_ContractArtifacts.abi as DeepWriteable - - super(chainId, web3Adapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) - - this.safeVersion = safeVersion - } - - /** - * @param args - Array[to, value, data, operation] - * @returns Array[estimate, success, returnData] - */ - simulate: SimulateTxAccessorContract_v1_3_0_Function<'simulate'> = (args) => { - return this.contract.methods.simulate(...args).call() - } -} - -export default SimulateTxAccessorContract_v1_3_0_Web3 diff --git a/packages/protocol-kit/src/adapters/web3/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1_Web3.ts deleted file mode 100644 index 003e6356c..000000000 --- a/packages/protocol-kit/src/adapters/web3/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1_Web3.ts +++ /dev/null @@ -1,58 +0,0 @@ -import SimulateTxAccessorBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContractWeb3' -import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter' -import { - DeepWriteable, - SafeVersion, - SimulateTxAccessorContract_v1_4_1_Abi, - SimulateTxAccessorContract_v1_4_1_Contract, - SimulateTxAccessorContract_v1_4_1_Function, - simulateTxAccessor_1_4_1_ContractArtifacts -} from '@safe-global/safe-core-sdk-types' - -/** - * SimulateTxAccessorContract_v1_4_1_Web3 is the implementation specific to the SimulateTxAccessor contract version 1.4.1. - * - * This class specializes in handling interactions with the SimulateTxAccessor contract version 1.4.1 using Web3.js. - * - * @extends SimulateTxAccessorBaseContractWeb3 - Inherits from SimulateTxAccessorBaseContractWeb3 with ABI specific to SimulateTxAccessor contract version 1.4.1. - * @implements SimulateTxAccessorContract_v1_4_1_Contract - Implements the interface specific to SimulateTxAccessor contract version 1.4.1. - */ -class SimulateTxAccessorContract_v1_4_1_Web3 - extends SimulateTxAccessorBaseContractWeb3> - implements SimulateTxAccessorContract_v1_4_1_Contract -{ - safeVersion: SafeVersion - - /** - * Constructs an instance of SimulateTxAccessorContract_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 SimulateTxAccessor 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 = - simulateTxAccessor_1_4_1_ContractArtifacts.abi as DeepWriteable - - super(chainId, web3Adapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) - - this.safeVersion = safeVersion - } - - /** - * @param args - Array[to, value, data, operation] - * @returns Array[estimate, success, returnData] - */ - simulate: SimulateTxAccessorContract_v1_4_1_Function<'simulate'> = (args) => { - return this.contract.methods.simulate(...args).call() - } -} - -export default SimulateTxAccessorContract_v1_4_1_Web3 diff --git a/packages/protocol-kit/src/adapters/web3/contracts/contractInstancesWeb3.ts b/packages/protocol-kit/src/adapters/web3/contracts/contractInstancesWeb3.ts deleted file mode 100644 index f47398c02..000000000 --- a/packages/protocol-kit/src/adapters/web3/contracts/contractInstancesWeb3.ts +++ /dev/null @@ -1,358 +0,0 @@ -import { AbiItem } from 'web3-utils' -import { - DeepWriteable, - SafeVersion, - CompatibilityFallbackHandlerContract_v1_3_0_Abi, - CompatibilityFallbackHandlerContract_v1_4_1_Abi, - CreateCallContract_v1_3_0_Abi, - CreateCallContract_v1_4_1_Abi, - MultiSendCallOnlyContract_v1_3_0_Abi, - MultiSendCallOnlyContract_v1_4_1_Abi, - MultiSendContract_v1_1_1_Abi, - MultiSendContract_v1_3_0_Abi, - MultiSendContract_v1_4_1_Abi, - SafeContract_v1_0_0_Abi, - SafeContract_v1_1_1_Abi, - SafeContract_v1_2_0_Abi, - SafeContract_v1_3_0_Abi, - SafeContract_v1_4_1_Abi, - SafeProxyFactoryContract_v1_0_0_Abi, - SafeProxyFactoryContract_v1_1_1_Abi, - SafeProxyFactoryContract_v1_3_0_Abi, - SafeProxyFactoryContract_v1_4_1_Abi, - SignMessageLibContract_v1_3_0_Abi, - SignMessageLibContract_v1_4_1_Abi, - SimulateTxAccessorContract_v1_3_0_Abi, - SimulateTxAccessorContract_v1_4_1_Abi -} from '@safe-global/safe-core-sdk-types' -import SafeContract_v1_0_0_Web3 from './Safe/v1.0.0/SafeContract_v1_0_0_Web3' -import SafeContract_v1_1_1_Web3 from './Safe/v1.1.1/SafeContract_v1_1_1_Web3' -import SafeContract_v1_2_0_Web3 from './Safe/v1.2.0/SafeContract_v1_2_0_Web3' -import SafeContract_v1_3_0_Web3 from './Safe/v1.3.0/SafeContract_v1_3_0_Web3' -import SafeContract_v1_4_1_Web3 from './Safe/v1.4.1/SafeContract_v1_4_1_Web3' -import SafeProxyFactoryContract_v1_0_0_Web3 from './SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0_Web3' -import SafeProxyFactoryContract_v1_1_1_Web3 from './SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1_Web3' -import SafeProxyFactoryContract_v1_3_0_Web3 from './SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0_Web3' -import SafeProxyFactoryContract_v1_4_1_Web3 from './SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1_Web3' -import SimulateTxAccessorContract_v1_3_0_Web3 from './SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0_Web3' -import SimulateTxAccessorContract_v1_4_1_Web3 from './SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1_Web3' -import CreateCallContract_v1_3_0_Web3 from './CreateCall/v1.3.0/CreateCallContract_v1_3_0_Web3' -import CreateCallContract_v1_4_1_Web3 from './CreateCall/v1.4.1/CreateCallContract_v1_4_1_Web3' -import MultiSendContract_v1_1_1_Web3 from './MultiSend/v1.1.1/MultiSendContract_v1_1_1_Web3' -import MultiSendContract_v1_3_0_Web3 from './MultiSend/v1.3.0/MultiSendContract_v1_3_0_Web3' -import MultiSendContract_v1_4_1_Web3 from './MultiSend/v1.4.1/MultiSendContract_v1_4_1_Web3' -import MultiSendCallOnlyContract_v1_3_0_Web3 from './MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0_Web3' -import MultiSendCallOnlyContract_v1_4_1_Web3 from './MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1_Web3' -import SignMessageLibContract_v1_3_0_Web3 from './SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0_Web3' -import SignMessageLibContract_v1_4_1_Web3 from './SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1_Web3' -import CompatibilityFallbackHandlerContract_v1_4_1_Web3 from './CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1_Web3' -import CompatibilityFallbackHandlerContract_v1_3_0_Web3 from './CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0_Web3' -import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter' - -// TODO: create a JSdoc for this function -export async function getSafeContractInstance( - safeVersion: SafeVersion, - web3Adapter: Web3Adapter, - contractAddress?: string, - customContractAbi?: AbiItem | AbiItem[] | undefined, - isL1SafeSingleton?: boolean -): Promise< - | SafeContract_v1_4_1_Web3 - | SafeContract_v1_3_0_Web3 - | SafeContract_v1_2_0_Web3 - | SafeContract_v1_1_1_Web3 - | SafeContract_v1_0_0_Web3 -> { - const chainId = await web3Adapter.getChainId() - - switch (safeVersion) { - case '1.4.1': - return new SafeContract_v1_4_1_Web3( - chainId, - web3Adapter, - isL1SafeSingleton, - contractAddress, - customContractAbi as DeepWriteable - ) - - case '1.3.0': - return new SafeContract_v1_3_0_Web3( - chainId, - web3Adapter, - isL1SafeSingleton, - contractAddress, - customContractAbi as DeepWriteable - ) - - case '1.2.0': - return new SafeContract_v1_2_0_Web3( - chainId, - web3Adapter, - isL1SafeSingleton, - contractAddress, - customContractAbi as DeepWriteable - ) - - case '1.1.1': - return new SafeContract_v1_1_1_Web3( - chainId, - web3Adapter, - isL1SafeSingleton, - contractAddress, - customContractAbi as DeepWriteable - ) - - case '1.0.0': - return new SafeContract_v1_0_0_Web3( - chainId, - web3Adapter, - isL1SafeSingleton, - contractAddress, - customContractAbi as DeepWriteable - ) - - default: - throw new Error('Invalid Safe version') - } -} - -export async function getCompatibilityFallbackHandlerContractInstance( - safeVersion: SafeVersion, - web3Adapter: Web3Adapter, - contractAddress?: string, - customContractAbi?: AbiItem | AbiItem[] | undefined -): Promise< - | CompatibilityFallbackHandlerContract_v1_4_1_Web3 - | CompatibilityFallbackHandlerContract_v1_3_0_Web3 -> { - const chainId = await web3Adapter.getChainId() - - switch (safeVersion) { - case '1.4.1': - return new CompatibilityFallbackHandlerContract_v1_4_1_Web3( - chainId, - web3Adapter, - contractAddress, - customContractAbi as DeepWriteable - ) - case '1.3.0': - case '1.2.0': - case '1.1.1': - return new CompatibilityFallbackHandlerContract_v1_3_0_Web3( - chainId, - web3Adapter, - contractAddress, - customContractAbi as DeepWriteable - ) - default: - throw new Error('Invalid Safe version') - } -} - -export async function getMultiSendContractInstance( - safeVersion: SafeVersion, - web3Adapter: Web3Adapter, - contractAddress?: string, - customContractAbi?: AbiItem | AbiItem[] | undefined -): Promise< - MultiSendContract_v1_4_1_Web3 | MultiSendContract_v1_3_0_Web3 | MultiSendContract_v1_1_1_Web3 -> { - const chainId = await web3Adapter.getChainId() - - switch (safeVersion) { - case '1.4.1': - return new MultiSendContract_v1_4_1_Web3( - chainId, - web3Adapter, - contractAddress, - customContractAbi as DeepWriteable - ) - case '1.3.0': - return new MultiSendContract_v1_3_0_Web3( - chainId, - web3Adapter, - contractAddress, - customContractAbi as DeepWriteable - ) - case '1.2.0': - case '1.1.1': - case '1.0.0': - return new MultiSendContract_v1_1_1_Web3( - chainId, - web3Adapter, - contractAddress, - customContractAbi as DeepWriteable - ) - default: - throw new Error('Invalid Safe version') - } -} - -export async function getMultiSendCallOnlyContractInstance( - safeVersion: SafeVersion, - web3Adapter: Web3Adapter, - contractAddress?: string, - customContractAbi?: AbiItem | AbiItem[] | undefined -): Promise { - const chainId = await web3Adapter.getChainId() - - switch (safeVersion) { - case '1.4.1': - return new MultiSendCallOnlyContract_v1_4_1_Web3( - chainId, - web3Adapter, - 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_Web3( - chainId, - web3Adapter, - contractAddress, - customContractAbi as DeepWriteable - ) - default: - throw new Error('Invalid Safe version') - } -} - -export async function getSafeProxyFactoryContractInstance( - safeVersion: SafeVersion, - web3Adapter: Web3Adapter, - contractAddress?: string, - customContractAbi?: AbiItem | AbiItem[] | undefined -) { - const chainId = await web3Adapter.getChainId() - - switch (safeVersion) { - case '1.4.1': - return new SafeProxyFactoryContract_v1_4_1_Web3( - chainId, - web3Adapter, - contractAddress, - customContractAbi as DeepWriteable - ) - - case '1.3.0': - return new SafeProxyFactoryContract_v1_3_0_Web3( - chainId, - web3Adapter, - contractAddress, - customContractAbi as DeepWriteable - ) - - case '1.2.0': - case '1.1.1': - return new SafeProxyFactoryContract_v1_1_1_Web3( - chainId, - web3Adapter, - contractAddress, - customContractAbi as DeepWriteable - ) - - case '1.0.0': - return new SafeProxyFactoryContract_v1_0_0_Web3( - chainId, - web3Adapter, - contractAddress, - customContractAbi as DeepWriteable - ) - - default: - throw new Error('Invalid Safe version') - } -} - -export async function getSignMessageLibContractInstance( - safeVersion: SafeVersion, - web3Adapter: Web3Adapter, - contractAddress?: string, - customContractAbi?: AbiItem | AbiItem[] | undefined -): Promise { - const chainId = await web3Adapter.getChainId() - - switch (safeVersion) { - case '1.4.1': - return new SignMessageLibContract_v1_4_1_Web3( - chainId, - web3Adapter, - contractAddress, - customContractAbi as DeepWriteable - ) - - case '1.3.0': - return new SignMessageLibContract_v1_3_0_Web3( - chainId, - web3Adapter, - contractAddress, - customContractAbi as DeepWriteable - ) - - default: - throw new Error('Invalid Safe version') - } -} - -export async function getCreateCallContractInstance( - safeVersion: SafeVersion, - web3Adapter: Web3Adapter, - contractAddress?: string, - customContractAbi?: AbiItem | AbiItem[] | undefined -): Promise { - const chainId = await web3Adapter.getChainId() - - switch (safeVersion) { - case '1.4.1': - return new CreateCallContract_v1_4_1_Web3( - chainId, - web3Adapter, - 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_Web3( - chainId, - web3Adapter, - contractAddress, - customContractAbi as DeepWriteable - ) - - default: - throw new Error('Invalid Safe version') - } -} - -export async function getSimulateTxAccessorContractInstance( - safeVersion: SafeVersion, - web3Adapter: Web3Adapter, - contractAddress?: string, - customContractAbi?: AbiItem | AbiItem[] | undefined -): Promise { - const chainId = await web3Adapter.getChainId() - - switch (safeVersion) { - case '1.4.1': - return new SimulateTxAccessorContract_v1_4_1_Web3( - chainId, - web3Adapter, - contractAddress, - customContractAbi as DeepWriteable - ) - case '1.3.0': - return new SimulateTxAccessorContract_v1_3_0_Web3( - chainId, - web3Adapter, - contractAddress, - customContractAbi as DeepWriteable - ) - default: - throw new Error('Invalid Safe version') - } -} diff --git a/packages/protocol-kit/src/adapters/web3/index.ts b/packages/protocol-kit/src/adapters/web3/index.ts deleted file mode 100644 index b22c91417..000000000 --- a/packages/protocol-kit/src/adapters/web3/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -import Web3Adapter, { Web3AdapterConfig } from './Web3Adapter' -import CreateCallBaseContractWeb3 from './contracts/CreateCall/CreateCallBaseContractWeb3' -import MultiSendBaseContractWeb3 from './contracts/MultiSend/MultiSendBaseContractWeb3' -import MultiSendCallOnlyBaseContractWeb3 from './contracts/MultiSend/MultiSendCallOnlyBaseContractWeb3' -import SafeBaseContractWeb3 from './contracts/Safe/SafeBaseContractWeb3' -import SafeProxyFactoryBaseContractWeb3 from './contracts/SafeProxyFactory/SafeProxyFactoryBaseContractWeb3' -import SignMessageLibBaseContractWeb3 from './contracts/SignMessageLib/SignMessageLibBaseContractWeb3' - -export { - CreateCallBaseContractWeb3, - MultiSendCallOnlyBaseContractWeb3, - MultiSendBaseContractWeb3, - SafeBaseContractWeb3, - SafeProxyFactoryBaseContractWeb3, - SignMessageLibBaseContractWeb3, - Web3Adapter, - Web3AdapterConfig -} diff --git a/packages/protocol-kit/src/adapters/web3/utils/constants.ts b/packages/protocol-kit/src/adapters/web3/utils/constants.ts deleted file mode 100644 index b8a31c39f..000000000 --- a/packages/protocol-kit/src/adapters/web3/utils/constants.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const ZERO_ADDRESS = `0x${'0'.repeat(40)}` -export const EMPTY_DATA = '0x' -export const SENTINEL_ADDRESS = '0x0000000000000000000000000000000000000001' diff --git a/packages/protocol-kit/src/adapters/web3/utils/index.ts b/packages/protocol-kit/src/adapters/web3/utils/index.ts deleted file mode 100644 index 0fb1f63b8..000000000 --- a/packages/protocol-kit/src/adapters/web3/utils/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Web3TransactionOptions, Web3TransactionResult } from 'packages/safe-core-sdk-types' -import { PromiEvent, TransactionReceipt } from 'web3-core/types' - -export function sameString(str1: string, str2: string): boolean { - return str1.toLowerCase() === str2.toLowerCase() -} - -export async function toTxResult( - promiEvent: PromiEvent, - options?: Web3TransactionOptions -): Promise { - return new Promise((resolve, reject) => - promiEvent - .once('transactionHash', (hash: string) => resolve({ hash, promiEvent, options })) - .catch(reject) - ) -} diff --git a/packages/protocol-kit/src/contracts/BaseContract.ts b/packages/protocol-kit/src/contracts/BaseContract.ts new file mode 100644 index 000000000..3e553421e --- /dev/null +++ b/packages/protocol-kit/src/contracts/BaseContract.ts @@ -0,0 +1,104 @@ +import { Abi } from 'abitype' +import { Contract, ContractRunner, InterfaceAbi } from 'ethers' + +import { contractName, getContractDeployment } from '@safe-global/protocol-kit/contracts/config' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' +import { + EncodeFunction, + EstimateGasFunction, + GetAddressFunction, + SafeVersion +} from '@safe-global/safe-core-sdk-types' + +/** + * Abstract class BaseContract + * 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 BaseContract are expected to represent specific contracts. + * + * @template ContractAbiType - The ABI type specific to the version of the contract, extending InterfaceAbi from Ethers. + * + * Example subclasses: + * - SafeBaseContract extends BaseContract + * - CreateCallBaseContract extends BaseContract + * - SafeProxyFactoryBaseContract extends BaseContract + */ +class BaseContract { + contractAbi: ContractAbiType + contractAddress: string + contractName: contractName + safeVersion: SafeVersion + safeProvider: SafeProvider + contract!: Contract + runner?: ContractRunner | null + + /** + * @constructor + * Constructs an instance of BaseContract. + * + * @param contractName - The contract name. + * @param chainId - The chain ID of the contract. + * @param safeProvider - An instance of SafeProvider. + * @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, + safeProvider: SafeProvider, + defaultAbi: ContractAbiType, + safeVersion: SafeVersion, + customContractAddress?: string, + customContractAbi?: ContractAbiType, + runner?: ContractRunner | null + ) { + const deployment = getContractDeployment(safeVersion, chainId, contractName) + + const contractAddress = + customContractAddress || + deployment?.networkAddresses[chainId.toString()] || + deployment?.defaultAddress + + if (!contractAddress) { + throw new Error(`Invalid ${contractName.replace('Version', '')} contract address`) + } + + this.contractName = contractName + this.safeVersion = safeVersion + this.contractAddress = contractAddress + this.contractAbi = + customContractAbi || + (deployment?.abi as unknown 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 + + this.runner = runner + this.safeProvider = safeProvider + } + + async init() { + this.contract = new Contract( + this.contractAddress, + this.contractAbi, + this.runner || (await this.safeProvider.getExternalSigner()) + ) + } + + 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 BaseContract diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContractEthers.ts b/packages/protocol-kit/src/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContract.ts similarity index 57% rename from packages/protocol-kit/src/adapters/ethers/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContractEthers.ts rename to packages/protocol-kit/src/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContract.ts index 8dab8970f..2583b1b10 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContractEthers.ts +++ b/packages/protocol-kit/src/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContract.ts @@ -1,35 +1,35 @@ import { Abi } from 'abitype' import { ContractRunner, InterfaceAbi } from 'ethers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' -import BaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/BaseContractEthers' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' +import BaseContract from '@safe-global/protocol-kit/contracts/BaseContract' import { SafeVersion } from '@safe-global/safe-core-sdk-types' import { contractName } from '@safe-global/protocol-kit/contracts/config' /** - * Abstract class CompatibilityFallbackHandlerBaseContractEthers extends BaseContractEthers to specifically integrate with the CompatibilityFallbackHandler contract. + * Abstract class CompatibilityFallbackHandlerBaseContract extends BaseContract to specifically integrate with the CompatibilityFallbackHandler contract. * It is designed to be instantiated for different versions of the Safe contract. * - * Subclasses of CompatibilityFallbackHandlerBaseContractEthers are expected to represent specific versions of the contract. + * Subclasses of CompatibilityFallbackHandlerBaseContract 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 Ethers. - * @extends BaseContractEthers - Extends the generic BaseContractEthers. + * @extends BaseContract - Extends the generic BaseContract. * * Example subclasses: - * - CompatibilityFallbackHandlerContract_v1_4_1_Ethers extends CompatibilityFallbackHandlerBaseContractEthers - * - CompatibilityFallbackHandlerContract_v1_3_0_Ethers extends CompatibilityFallbackHandlerBaseContractEthers + * - CompatibilityFallbackHandlerContract_v1_4_1 extends CompatibilityFallbackHandlerBaseContract + * - CompatibilityFallbackHandlerContract_v1_3_0 extends CompatibilityFallbackHandlerBaseContract */ -abstract class CompatibilityFallbackHandlerBaseContractEthers< +abstract class CompatibilityFallbackHandlerBaseContract< CompatibilityFallbackHandlerContractAbiType extends InterfaceAbi & Abi -> extends BaseContractEthers { +> extends BaseContract { contractName: contractName /** * @constructor - * Constructs an instance of CompatibilityFallbackHandlerBaseContractEthers. + * Constructs an instance of CompatibilityFallbackHandlerBaseContract. * * @param chainId - The chain ID of the contract. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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. @@ -37,7 +37,7 @@ abstract class CompatibilityFallbackHandlerBaseContractEthers< */ constructor( chainId: bigint, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, defaultAbi: CompatibilityFallbackHandlerContractAbiType, safeVersion: SafeVersion, customContractAddress?: string, @@ -49,7 +49,7 @@ abstract class CompatibilityFallbackHandlerBaseContractEthers< super( contractName, chainId, - ethersAdapter, + safeProvider, defaultAbi, safeVersion, customContractAddress, @@ -61,4 +61,4 @@ abstract class CompatibilityFallbackHandlerBaseContractEthers< } } -export default CompatibilityFallbackHandlerBaseContractEthers +export default CompatibilityFallbackHandlerBaseContract diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0_Ethers.ts b/packages/protocol-kit/src/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0.ts similarity index 56% rename from packages/protocol-kit/src/adapters/ethers/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0_Ethers.ts rename to packages/protocol-kit/src/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0.ts index e44ea6764..349e010d7 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0_Ethers.ts +++ b/packages/protocol-kit/src/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0.ts @@ -1,5 +1,5 @@ -import CompatibilityFallbackHandlerBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import CompatibilityFallbackHandlerBaseContract from '@safe-global/protocol-kit/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion, CompatibilityFallbackHandlerContract_v1_3_0_Abi, @@ -8,40 +8,40 @@ import { } from '@safe-global/safe-core-sdk-types' /** - * CompatibilityFallbackHandlerContract_v1_3_0_Ethers is the implementation specific to the CompatibilityFallbackHandler contract version 1.3.0. + * CompatibilityFallbackHandlerContract_v1_3_0 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 Ethers.js v6. * - * @extends CompatibilityFallbackHandlerBaseContractEthers - Inherits from CompatibilityFallbackHandlerBaseContractEthers with ABI specific to CompatibilityFallbackHandler contract version 1.3.0. + * @extends CompatibilityFallbackHandlerBaseContract - Inherits from CompatibilityFallbackHandlerBaseContract 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_Ethers - extends CompatibilityFallbackHandlerBaseContractEthers +class CompatibilityFallbackHandlerContract_v1_3_0 + extends CompatibilityFallbackHandlerBaseContract implements CompatibilityFallbackHandlerContract_v1_3_0_Contract { safeVersion: SafeVersion /** - * Constructs an instance of CompatibilityFallbackHandlerContract_v1_3_0_Ethers + * Constructs an instance of CompatibilityFallbackHandlerContract_v1_3_0 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, customContractAddress?: string, customContractAbi?: CompatibilityFallbackHandlerContract_v1_3_0_Abi ) { const safeVersion = '1.3.0' const defaultAbi = compatibilityFallbackHandler_1_3_0_ContractArtifacts.abi - super(chainId, ethersAdapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) + super(chainId, safeProvider, defaultAbi, safeVersion, customContractAddress, customContractAbi) this.safeVersion = safeVersion } } -export default CompatibilityFallbackHandlerContract_v1_3_0_Ethers +export default CompatibilityFallbackHandlerContract_v1_3_0 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1_Ethers.ts b/packages/protocol-kit/src/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1.ts similarity index 56% rename from packages/protocol-kit/src/adapters/ethers/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1_Ethers.ts rename to packages/protocol-kit/src/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1.ts index 9c224ad1d..3cf7af032 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1_Ethers.ts +++ b/packages/protocol-kit/src/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1.ts @@ -1,5 +1,5 @@ -import CompatibilityFallbackHandlerBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import CompatibilityFallbackHandlerBaseContract from '@safe-global/protocol-kit/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { compatibilityFallbackHandler_1_4_1_ContractArtifacts, CompatibilityFallbackHandlerContract_v1_4_1_Abi, @@ -8,40 +8,40 @@ import { } from '@safe-global/safe-core-sdk-types' /** - * CompatibilityFallbackHandlerContract_v1_4_1_Ethers is the implementation specific to the CompatibilityFallbackHandler contract version 1.4.1. + * CompatibilityFallbackHandlerContract_v1_4_1 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 Ethers.js v6. * - * @extends CompatibilityFallbackHandlerBaseContractEthers - Inherits from CompatibilityFallbackHandlerBaseContractEthers with ABI specific to CompatibilityFallbackHandler contract version 1.4.1. + * @extends CompatibilityFallbackHandlerBaseContract - Inherits from CompatibilityFallbackHandlerBaseContract 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_Ethers - extends CompatibilityFallbackHandlerBaseContractEthers +class CompatibilityFallbackHandlerContract_v1_4_1 + extends CompatibilityFallbackHandlerBaseContract implements CompatibilityFallbackHandlerContract_v1_4_1_Contract { safeVersion: SafeVersion /** - * Constructs an instance of CompatibilityFallbackHandlerContract_v1_4_1_Ethers + * Constructs an instance of CompatibilityFallbackHandlerContract_v1_4_1 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, customContractAddress?: string, customContractAbi?: CompatibilityFallbackHandlerContract_v1_4_1_Abi ) { const safeVersion = '1.4.1' const defaultAbi = compatibilityFallbackHandler_1_4_1_ContractArtifacts.abi - super(chainId, ethersAdapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) + super(chainId, safeProvider, defaultAbi, safeVersion, customContractAddress, customContractAbi) this.safeVersion = safeVersion } } -export default CompatibilityFallbackHandlerContract_v1_4_1_Ethers +export default CompatibilityFallbackHandlerContract_v1_4_1 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/CreateCallBaseContractEthers.ts b/packages/protocol-kit/src/contracts/CreateCall/CreateCallBaseContract.ts similarity index 61% rename from packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/CreateCallBaseContractEthers.ts rename to packages/protocol-kit/src/contracts/CreateCall/CreateCallBaseContract.ts index 93c5c1c83..9dc3ae51d 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/CreateCallBaseContractEthers.ts +++ b/packages/protocol-kit/src/contracts/CreateCall/CreateCallBaseContract.ts @@ -1,35 +1,35 @@ import { Abi } from 'abitype' import { ContractRunner, InterfaceAbi } from 'ethers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' -import BaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/BaseContractEthers' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' +import BaseContract from '@safe-global/protocol-kit/contracts/BaseContract' import { SafeVersion } from '@safe-global/safe-core-sdk-types' import { contractName } from '@safe-global/protocol-kit/contracts/config' /** - * Abstract class CreateCallBaseContractEthers extends BaseContractEthers to specifically integrate with the CreateCall contract. + * Abstract class CreateCallBaseContract extends BaseContract to specifically integrate with the CreateCall contract. * It is designed to be instantiated for different versions of the Safe contract. * - * Subclasses of CreateCallBaseContractEthers are expected to represent specific versions of the contract. + * Subclasses of CreateCallBaseContract 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 Ethers. - * @extends BaseContractEthers - Extends the generic BaseContractEthers. + * @extends BaseContract - Extends the generic BaseContract. * * Example subclasses: - * - CreateCallContract_v1_4_1_Ethers extends CreateCallBaseContractEthers - * - CreateCallContract_v1_3_0_Ethers extends CreateCallBaseContractEthers + * - CreateCallContract_v1_4_1 extends CreateCallBaseContract + * - CreateCallContract_v1_3_0 extends CreateCallBaseContract */ -abstract class CreateCallBaseContractEthers< +abstract class CreateCallBaseContract< CreateCallContractAbiType extends InterfaceAbi & Abi -> extends BaseContractEthers { +> extends BaseContract { contractName: contractName /** * @constructor - * Constructs an instance of CreateCallBaseContractEthers. + * Constructs an instance of CreateCallBaseContract. * * @param chainId - The chain ID of the contract. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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. @@ -37,7 +37,7 @@ abstract class CreateCallBaseContractEthers< */ constructor( chainId: bigint, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, defaultAbi: CreateCallContractAbiType, safeVersion: SafeVersion, customContractAddress?: string, @@ -49,7 +49,7 @@ abstract class CreateCallBaseContractEthers< super( contractName, chainId, - ethersAdapter, + safeProvider, defaultAbi, safeVersion, customContractAddress, @@ -61,4 +61,4 @@ abstract class CreateCallBaseContractEthers< } } -export default CreateCallBaseContractEthers +export default CreateCallBaseContract diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0_Ethers.ts b/packages/protocol-kit/src/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0.ts similarity index 53% rename from packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0_Ethers.ts rename to packages/protocol-kit/src/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0.ts index 34d6a76af..9d44b93c7 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0_Ethers.ts +++ b/packages/protocol-kit/src/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0.ts @@ -1,61 +1,59 @@ -import CreateCallBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/CreateCall/CreateCallBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import CreateCallBaseContract from '@safe-global/protocol-kit/contracts/CreateCall/CreateCallBaseContract' import { SafeVersion, CreateCallContract_v1_3_0_Abi, CreateCallContract_v1_3_0_Contract, createCall_1_3_0_ContractArtifacts, - AdapterSpecificContractFunction, - EthersTransactionOptions + SafeContractFunction } from '@safe-global/safe-core-sdk-types' -import { toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils' +import { toTxResult } from '@safe-global/protocol-kit/contracts/utils' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' /** - * CreateCallContract_v1_3_0_Ethers is the implementation specific to the CreateCall contract version 1.3.0. + * CreateCallContract_v1_3_0 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 Ethers.js v6. * - * @extends CreateCallBaseContractEthers - Inherits from CreateCallBaseContractEthers with ABI specific to CreateCall contract version 1.3.0. + * @extends CreateCallBaseContract - Inherits from CreateCallBaseContract 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_Ethers - extends CreateCallBaseContractEthers +class CreateCallContract_v1_3_0 + extends CreateCallBaseContract implements CreateCallContract_v1_3_0_Contract { safeVersion: SafeVersion /** - * Constructs an instance of CreateCallContract_v1_3_0_Ethers + * Constructs an instance of CreateCallContract_v1_3_0 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, customContractAddress?: string, customContractAbi?: CreateCallContract_v1_3_0_Abi ) { const safeVersion = '1.3.0' const defaultAbi = createCall_1_3_0_ContractArtifacts.abi - super(chainId, ethersAdapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) + super(chainId, safeProvider, defaultAbi, safeVersion, customContractAddress, customContractAbi) this.safeVersion = safeVersion } /** * @param args - Array[value, deploymentData] - * @param options - EthersTransactionOptions - * @returns Promise + * @param options - TransactionOptions + * @returns Promise */ - performCreate: AdapterSpecificContractFunction< - CreateCallContract_v1_3_0_Abi, - 'performCreate', - EthersTransactionOptions - > = async (args, options) => { + performCreate: SafeContractFunction = async ( + args, + options + ) => { if (options && !options.gasLimit) { options.gasLimit = ( await this.estimateGas('performCreate', [...args], { ...options }) @@ -67,14 +65,13 @@ class CreateCallContract_v1_3_0_Ethers /** * @param args - Array[value, deploymentData, salt] - * @param options - EthersTransactionOptions - * @returns Promise + * @param options - TransactionOptions + * @returns Promise */ - performCreate2: AdapterSpecificContractFunction< - CreateCallContract_v1_3_0_Abi, - 'performCreate2', - EthersTransactionOptions - > = async (args, options) => { + performCreate2: SafeContractFunction = async ( + args, + options + ) => { if (options && !options.gasLimit) { options.gasLimit = (await this.estimateGas('performCreate2', args, options)).toString() } @@ -83,4 +80,4 @@ class CreateCallContract_v1_3_0_Ethers } } -export default CreateCallContract_v1_3_0_Ethers +export default CreateCallContract_v1_3_0 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1_Ethers.ts b/packages/protocol-kit/src/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1.ts similarity index 53% rename from packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1_Ethers.ts rename to packages/protocol-kit/src/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1.ts index 6c04c3c53..f9f1e0094 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1_Ethers.ts +++ b/packages/protocol-kit/src/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1.ts @@ -1,61 +1,59 @@ -import CreateCallBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/CreateCall/CreateCallBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import CreateCallBaseContract from '@safe-global/protocol-kit/contracts/CreateCall/CreateCallBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion, CreateCallContract_v1_4_1_Abi, CreateCallContract_v1_4_1_Contract, createCall_1_4_1_ContractArtifacts, - AdapterSpecificContractFunction, - EthersTransactionOptions + SafeContractFunction } from '@safe-global/safe-core-sdk-types' -import { toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils' +import { toTxResult } from '@safe-global/protocol-kit/contracts/utils' /** - * CreateCallContract_v1_4_1_Ethers is the implementation specific to the CreateCall contract version 1.4.1. + * CreateCallContract_v1_4_1 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 Ethers.js v6. * - * @extends CreateCallBaseContractEthers - Inherits from CreateCallBaseContractEthers with ABI specific to CreateCall contract version 1.4.1. + * @extends CreateCallBaseContract - Inherits from CreateCallBaseContract 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_Ethers - extends CreateCallBaseContractEthers +class CreateCallContract_v1_4_1 + extends CreateCallBaseContract implements CreateCallContract_v1_4_1_Contract { safeVersion: SafeVersion /** - * Constructs an instance of CreateCallContract_v1_4_1_Ethers + * Constructs an instance of CreateCallContract_v1_4_1 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, customContractAddress?: string, customContractAbi?: CreateCallContract_v1_4_1_Abi ) { const safeVersion = '1.4.1' const defaultAbi = createCall_1_4_1_ContractArtifacts.abi - super(chainId, ethersAdapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) + super(chainId, safeProvider, defaultAbi, safeVersion, customContractAddress, customContractAbi) this.safeVersion = safeVersion } /** * @param args - Array[value, deploymentData] - * @param options - EthersTransactionOptions - * @returns Promise + * @param options - TransactionOptions + * @returns Promise */ - performCreate: AdapterSpecificContractFunction< - CreateCallContract_v1_4_1_Abi, - 'performCreate', - EthersTransactionOptions - > = async (args, options) => { + performCreate: SafeContractFunction = async ( + args, + options + ) => { if (options && !options.gasLimit) { options.gasLimit = (await this.estimateGas('performCreate', args, options)).toString() } @@ -65,14 +63,13 @@ class CreateCallContract_v1_4_1_Ethers /** * @param args - Array[value, deploymentData, salt] - * @param options - EthersTransactionOptions - * @returns Promise + * @param options - TransactionOptions + * @returns Promise */ - performCreate2: AdapterSpecificContractFunction< - CreateCallContract_v1_4_1_Abi, - 'performCreate2', - EthersTransactionOptions - > = async (args, options) => { + performCreate2: SafeContractFunction = async ( + args, + options + ) => { if (options && !options.gasLimit) { options.gasLimit = ( await this.estimateGas('performCreate2', [...args], { ...options }) @@ -83,4 +80,4 @@ class CreateCallContract_v1_4_1_Ethers } } -export default CreateCallContract_v1_4_1_Ethers +export default CreateCallContract_v1_4_1 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/MultiSendBaseContractEthers.ts b/packages/protocol-kit/src/contracts/MultiSend/MultiSendBaseContract.ts similarity index 60% rename from packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/MultiSendBaseContractEthers.ts rename to packages/protocol-kit/src/contracts/MultiSend/MultiSendBaseContract.ts index a03e1a621..835be1b2f 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/MultiSendBaseContractEthers.ts +++ b/packages/protocol-kit/src/contracts/MultiSend/MultiSendBaseContract.ts @@ -1,35 +1,35 @@ import { Abi } from 'abitype' import { InterfaceAbi } from 'ethers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion } from '@safe-global/safe-core-sdk-types' -import BaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/BaseContractEthers' +import BaseContract from '@safe-global/protocol-kit/contracts/BaseContract' import { contractName } from '@safe-global/protocol-kit/contracts/config' /** - * Abstract class MultiSendBaseContractEthers extends BaseContractEthers to specifically integrate with the MultiSend contract. + * Abstract class MultiSendBaseContract extends BaseContract to specifically integrate with the MultiSend contract. * It is designed to be instantiated for different versions of the MultiSend contract. * - * Subclasses of MultiSendBaseContractEthers are expected to represent specific versions of the MultiSend contract. + * Subclasses of MultiSendBaseContract 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 Ethers. - * @extends BaseContractEthers - Extends the generic BaseContractEthers. + * @extends BaseContract - Extends the generic BaseContract. * * Example subclasses: - * - MultiSendContract_v1_4_1_Ethers extends MultiSendBaseContractEthers - * - MultiSendContract_v1_3_0_Ethers extends MultiSendBaseContractEthers + * - MultiSendContract_v1_4_1 extends MultiSendBaseContract + * - MultiSendContract_v1_3_0 extends MultiSendBaseContract */ -abstract class MultiSendBaseContractEthers< +abstract class MultiSendBaseContract< MultiSendContractAbiType extends InterfaceAbi & Abi -> extends BaseContractEthers { +> extends BaseContract { contractName: contractName /** * @constructor - * Constructs an instance of MultiSendBaseContractEthers. + * Constructs an instance of MultiSendBaseContract. * * @param chainId - The chain ID of the contract. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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. @@ -37,7 +37,7 @@ abstract class MultiSendBaseContractEthers< */ constructor( chainId: bigint, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, defaultAbi: MultiSendContractAbiType, safeVersion: SafeVersion, customContractAddress?: string, @@ -48,7 +48,7 @@ abstract class MultiSendBaseContractEthers< super( contractName, chainId, - ethersAdapter, + safeProvider, defaultAbi, safeVersion, customContractAddress, @@ -59,4 +59,4 @@ abstract class MultiSendBaseContractEthers< } } -export default MultiSendBaseContractEthers +export default MultiSendBaseContract diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/MultiSendCallOnlyBaseContractEthers.ts b/packages/protocol-kit/src/contracts/MultiSend/MultiSendCallOnlyBaseContract.ts similarity index 59% rename from packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/MultiSendCallOnlyBaseContractEthers.ts rename to packages/protocol-kit/src/contracts/MultiSend/MultiSendCallOnlyBaseContract.ts index af007b4ad..bd69961e1 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/MultiSendCallOnlyBaseContractEthers.ts +++ b/packages/protocol-kit/src/contracts/MultiSend/MultiSendCallOnlyBaseContract.ts @@ -1,35 +1,35 @@ import { Abi } from 'abitype' import { InterfaceAbi } from 'ethers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion } from '@safe-global/safe-core-sdk-types' -import BaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/BaseContractEthers' +import BaseContract from '@safe-global/protocol-kit/contracts/BaseContract' import { contractName } from '@safe-global/protocol-kit/contracts/config' /** - * Abstract class MultiSendCallOnlyBaseContractEthers extends BaseContractEthers to specifically integrate with the MultiSendCallOnly contract. + * Abstract class MultiSendCallOnlyBaseContract extends BaseContract to specifically integrate with the MultiSendCallOnly contract. * It is designed to be instantiated for different versions of the MultiSendCallOnly contract. * - * Subclasses of MultiSendCallOnlyBaseContractEthers are expected to represent specific versions of the MultiSendCallOnly contract. + * Subclasses of MultiSendCallOnlyBaseContract 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 Ethers. - * @extends BaseContractEthers - Extends the generic BaseContractEthers. + * @extends BaseContract - Extends the generic BaseContract. * * Example subclasses: - * - MultiSendCallOnlyContract_v1_4_1_Ethers extends MultiSendCallOnlyBaseContractEthers - * - MultiSendCallOnlyContract_v1_3_0_Ethers extends MultiSendCallOnlyBaseContractEthers + * - MultiSendCallOnlyContract_v1_4_1 extends MultiSendCallOnlyBaseContract + * - MultiSendCallOnlyContract_v1_3_0 extends MultiSendCallOnlyBaseContract */ -abstract class MultiSendCallOnlyBaseContractEthers< +abstract class MultiSendCallOnlyBaseContract< MultiSendCallOnlyContractAbiType extends InterfaceAbi & Abi -> extends BaseContractEthers { +> extends BaseContract { contractName: contractName /** * @constructor - * Constructs an instance of MultiSendCallOnlyBaseContractEthers. + * Constructs an instance of MultiSendCallOnlyBaseContract. * * @param chainId - The chain ID of the contract. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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. @@ -37,7 +37,7 @@ abstract class MultiSendCallOnlyBaseContractEthers< */ constructor( chainId: bigint, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, defaultAbi: MultiSendCallOnlyContractAbiType, safeVersion: SafeVersion, customContractAddress?: string, @@ -48,7 +48,7 @@ abstract class MultiSendCallOnlyBaseContractEthers< super( contractName, chainId, - ethersAdapter, + safeProvider, defaultAbi, safeVersion, customContractAddress, @@ -59,4 +59,4 @@ abstract class MultiSendCallOnlyBaseContractEthers< } } -export default MultiSendCallOnlyBaseContractEthers +export default MultiSendCallOnlyBaseContract diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.1.1/MultiSendContract_v1_1_1_Ethers.ts b/packages/protocol-kit/src/contracts/MultiSend/v1.1.1/MultiSendContract_v1_1_1.ts similarity index 56% rename from packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.1.1/MultiSendContract_v1_1_1_Ethers.ts rename to packages/protocol-kit/src/contracts/MultiSend/v1.1.1/MultiSendContract_v1_1_1.ts index 1b93d3ce7..9f7897565 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.1.1/MultiSendContract_v1_1_1_Ethers.ts +++ b/packages/protocol-kit/src/contracts/MultiSend/v1.1.1/MultiSendContract_v1_1_1.ts @@ -1,5 +1,5 @@ -import MultiSendBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/MultiSend/MultiSendBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import MultiSendBaseContract from '@safe-global/protocol-kit/contracts/MultiSend/MultiSendBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion, multisend_1_1_1_ContractArtifacts, @@ -8,40 +8,40 @@ import { } from '@safe-global/safe-core-sdk-types' /** - * MultiSendContract_v1_1_1_Ethers is the implementation specific to the MultiSend contract version 1.1.1. + * MultiSendContract_v1_1_1 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 Ethers.js v6. * - * @extends MultiSendBaseContractEthers - Inherits from MultiSendBaseContractEthers with ABI specific to MultiSend contract version 1.1.1. + * @extends MultiSendBaseContract - Inherits from MultiSendBaseContract 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_Ethers - extends MultiSendBaseContractEthers +class MultiSendContract_v1_1_1 + extends MultiSendBaseContract implements MultiSendContract_v1_1_1_Contract { safeVersion: SafeVersion /** - * Constructs an instance of MultiSendContract_v1_1_1_Ethers + * Constructs an instance of MultiSendContract_v1_1_1 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, customContractAddress?: string, customContractAbi?: MultiSendContract_v1_1_1_Abi ) { const safeVersion = '1.1.1' const defaultAbi = multisend_1_1_1_ContractArtifacts.abi - super(chainId, ethersAdapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) + super(chainId, safeProvider, defaultAbi, safeVersion, customContractAddress, customContractAbi) this.safeVersion = safeVersion } } -export default MultiSendContract_v1_1_1_Ethers +export default MultiSendContract_v1_1_1 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0_Ethers.ts b/packages/protocol-kit/src/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0.ts similarity index 55% rename from packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0_Ethers.ts rename to packages/protocol-kit/src/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0.ts index 912e8b9b0..74e8ffb8f 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0_Ethers.ts +++ b/packages/protocol-kit/src/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0.ts @@ -1,5 +1,5 @@ -import MultiSendCallOnlyBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/MultiSend/MultiSendCallOnlyBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import MultiSendCallOnlyBaseContract from '@safe-global/protocol-kit/contracts/MultiSend/MultiSendCallOnlyBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion, MultiSendCallOnlyContract_v1_3_0_Abi, @@ -8,40 +8,40 @@ import { } from '@safe-global/safe-core-sdk-types' /** - * MultiSendCallOnlyContract_v1_3_0_Ethers is the implementation specific to the MultiSendCallOnly contract version 1.3.0. + * MultiSendCallOnlyContract_v1_3_0 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 Ethers.js v6. * - * @extends MultiSendCallOnlyBaseContractEthers - Inherits from MultiSendCallOnlyBaseContractEthers with ABI specific to MultiSendCallOnly contract version 1.3.0. + * @extends MultiSendCallOnlyBaseContract - Inherits from MultiSendCallOnlyBaseContract 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_Ethers - extends MultiSendCallOnlyBaseContractEthers +class MultiSendCallOnlyContract_v1_3_0 + extends MultiSendCallOnlyBaseContract implements MultiSendCallOnlyContract_v1_3_0_Contract { safeVersion: SafeVersion /** - * Constructs an instance of MultiSendCallOnlyContract_v1_3_0_Ethers + * Constructs an instance of MultiSendCallOnlyContract_v1_3_0 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, customContractAddress?: string, customContractAbi?: MultiSendCallOnlyContract_v1_3_0_Abi ) { const safeVersion = '1.3.0' const defaultAbi = multiSendCallOnly_1_3_0_ContractArtifacts.abi - super(chainId, ethersAdapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) + super(chainId, safeProvider, defaultAbi, safeVersion, customContractAddress, customContractAbi) this.safeVersion = safeVersion } } -export default MultiSendCallOnlyContract_v1_3_0_Ethers +export default MultiSendCallOnlyContract_v1_3_0 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.3.0/MultiSendContract_v1_3_0_Ethers.ts b/packages/protocol-kit/src/contracts/MultiSend/v1.3.0/MultiSendContract_v1_3_0.ts similarity index 56% rename from packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.3.0/MultiSendContract_v1_3_0_Ethers.ts rename to packages/protocol-kit/src/contracts/MultiSend/v1.3.0/MultiSendContract_v1_3_0.ts index 8a11bcb3e..ac5146f6e 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.3.0/MultiSendContract_v1_3_0_Ethers.ts +++ b/packages/protocol-kit/src/contracts/MultiSend/v1.3.0/MultiSendContract_v1_3_0.ts @@ -1,5 +1,5 @@ -import MultiSendBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/MultiSend/MultiSendBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import MultiSendBaseContract from '@safe-global/protocol-kit/contracts/MultiSend/MultiSendBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion, multisend_1_3_0_ContractArtifacts, @@ -8,40 +8,40 @@ import { } from '@safe-global/safe-core-sdk-types' /** - * MultiSendContract_v1_3_0_Ethers is the implementation specific to the MultiSend contract version 1.3.0. + * MultiSendContract_v1_3_0 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 Ethers.js v6. * - * @extends MultiSendBaseContractEthers - Inherits from MultiSendBaseContractEthers with ABI specific to MultiSend contract version 1.3.0. + * @extends MultiSendBaseContract - Inherits from MultiSendBaseContract 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_Ethers - extends MultiSendBaseContractEthers +class MultiSendContract_v1_3_0 + extends MultiSendBaseContract implements MultiSendContract_v1_3_0_Contract { safeVersion: SafeVersion /** - * Constructs an instance of MultiSendContract_v1_3_0_Ethers + * Constructs an instance of MultiSendContract_v1_3_0 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, customContractAddress?: string, customContractAbi?: MultiSendContract_v1_3_0_Abi ) { const safeVersion = '1.3.0' const defaultAbi = multisend_1_3_0_ContractArtifacts.abi - super(chainId, ethersAdapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) + super(chainId, safeProvider, defaultAbi, safeVersion, customContractAddress, customContractAbi) this.safeVersion = safeVersion } } -export default MultiSendContract_v1_3_0_Ethers +export default MultiSendContract_v1_3_0 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1_Ethers.ts b/packages/protocol-kit/src/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1.ts similarity index 55% rename from packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1_Ethers.ts rename to packages/protocol-kit/src/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1.ts index 6f5d93f02..339502906 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1_Ethers.ts +++ b/packages/protocol-kit/src/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1.ts @@ -1,5 +1,5 @@ -import MultiSendCallOnlyBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/MultiSend/MultiSendCallOnlyBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import MultiSendCallOnlyBaseContract from '@safe-global/protocol-kit/contracts/MultiSend/MultiSendCallOnlyBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion, multiSendCallOnly_1_4_1_ContractArtifacts, @@ -8,40 +8,40 @@ import { } from '@safe-global/safe-core-sdk-types' /** - * MultiSendCallOnlyContract_v1_4_1_Ethers is the implementation specific to the MultiSend contract version 1.4.1. + * MultiSendCallOnlyContract_v1_4_1 is the implementation specific to the MultiSend contract version 1.4.1. * * This class specializes in handling interactions with the MultiSendCallOnly contract version 1.4.1 using Ethers.js v6. * - * @extends MultiSendCallOnlyBaseContractEthers - Inherits from MultiSendBaseContractEthers with ABI specific to MultiSendCallOnly contract version 1.4.1. + * @extends MultiSendCallOnlyBaseContract - Inherits from MultiSendBaseContract with ABI specific to MultiSendCallOnly contract version 1.4.1. * @implements MultiSendCallOnlyContract_v1_4_1_Contract - Implements the interface specific to MultiSendCallOnly contract version 1.4.1. */ -class MultiSendCallOnlyContract_v1_4_1_Ethers - extends MultiSendCallOnlyBaseContractEthers +class MultiSendCallOnlyContract_v1_4_1 + extends MultiSendCallOnlyBaseContract implements MultiSendCallOnlyContract_v1_4_1_Contract { safeVersion: SafeVersion /** - * Constructs an instance of MultiSendCallOnlyContract_v1_4_1_Ethers + * Constructs an instance of MultiSendCallOnlyContract_v1_4_1 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, customContractAddress?: string, customContractAbi?: MultiSendCallOnlyContract_v1_4_1_Abi ) { const safeVersion = '1.4.1' const defaultAbi = multiSendCallOnly_1_4_1_ContractArtifacts.abi - super(chainId, ethersAdapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) + super(chainId, safeProvider, defaultAbi, safeVersion, customContractAddress, customContractAbi) this.safeVersion = safeVersion } } -export default MultiSendCallOnlyContract_v1_4_1_Ethers +export default MultiSendCallOnlyContract_v1_4_1 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.4.1/MultiSendContract_v1_4_1_Ethers.ts b/packages/protocol-kit/src/contracts/MultiSend/v1.4.1/MultiSendContract_v1_4_1.ts similarity index 56% rename from packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.4.1/MultiSendContract_v1_4_1_Ethers.ts rename to packages/protocol-kit/src/contracts/MultiSend/v1.4.1/MultiSendContract_v1_4_1.ts index ba5bbdab6..845ca5c4b 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/MultiSend/v1.4.1/MultiSendContract_v1_4_1_Ethers.ts +++ b/packages/protocol-kit/src/contracts/MultiSend/v1.4.1/MultiSendContract_v1_4_1.ts @@ -1,5 +1,5 @@ -import MultiSendBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/MultiSend/MultiSendBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import MultiSendBaseContract from '@safe-global/protocol-kit/contracts/MultiSend/MultiSendBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion, MultiSendContract_v1_4_1_Abi, @@ -8,40 +8,40 @@ import { } from '@safe-global/safe-core-sdk-types' /** - * MultiSendContract_v1_4_1_Ethers is the implementation specific to the MultiSend contract version 1.4.1. + * MultiSendContract_v1_4_1 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 Ethers.js v6. * - * @extends MultiSendBaseContractEthers - Inherits from MultiSendBaseContractEthers with ABI specific to MultiSend contract version 1.4.1. + * @extends MultiSendBaseContract - Inherits from MultiSendBaseContract 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_Ethers - extends MultiSendBaseContractEthers +class MultiSendContract_v1_4_1 + extends MultiSendBaseContract implements MultiSendContract_v1_4_1_Contract { safeVersion: SafeVersion /** - * Constructs an instance of MultiSendContract_v1_4_1_Ethers + * Constructs an instance of MultiSendContract_v1_4_1 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, customContractAddress?: string, customContractAbi?: MultiSendContract_v1_4_1_Abi ) { const safeVersion = '1.4.1' const defaultAbi = multisend_1_4_1_ContractArtifacts.abi - super(chainId, ethersAdapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) + super(chainId, safeProvider, defaultAbi, safeVersion, customContractAddress, customContractAbi) this.safeVersion = safeVersion } } -export default MultiSendContract_v1_4_1_Ethers +export default MultiSendContract_v1_4_1 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/SafeBaseContractEthers.ts b/packages/protocol-kit/src/contracts/Safe/SafeBaseContract.ts similarity index 60% rename from packages/protocol-kit/src/adapters/ethers/contracts/Safe/SafeBaseContractEthers.ts rename to packages/protocol-kit/src/contracts/Safe/SafeBaseContract.ts index 02ac88eb9..ed826fa3d 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/SafeBaseContractEthers.ts +++ b/packages/protocol-kit/src/contracts/Safe/SafeBaseContract.ts @@ -1,38 +1,38 @@ import { Abi } from 'abitype' import { InterfaceAbi } from 'ethers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion } from '@safe-global/safe-core-sdk-types' -import BaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/BaseContractEthers' +import BaseContract from '@safe-global/protocol-kit/contracts/BaseContract' import { contractName, safeDeploymentsL1ChainIds } from '@safe-global/protocol-kit/contracts/config' /** - * Abstract class SafeBaseContractEthers extends BaseContractEthers to specifically integrate with the Safe contract. + * Abstract class SafeBaseContract extends BaseContract to specifically integrate with the Safe contract. * It is designed to be instantiated for different versions of the Safe contract. * - * Subclasses of SafeBaseContractEthers are expected to represent specific versions of the Safe contract. + * Subclasses of SafeBaseContract are expected to represent specific versions of the Safe contract. * * @template SafeContractAbiType - The ABI type specific to the version of the Safe contract, extending InterfaceAbi from Ethers. - * @extends BaseContractEthers - Extends the generic BaseContractEthers. + * @extends BaseContract - Extends the generic BaseContract. * * Example subclasses: - * - SafeContract_v1_4_1_Ethers extends SafeBaseContractEthers - * - SafeContract_v1_3_0_Ethers extends SafeBaseContractEthers - * - SafeContract_v1_2_0_Ethers extends SafeBaseContractEthers - * - SafeContract_v1_1_1_Ethers extends SafeBaseContractEthers - * - SafeContract_v1_0_0_Ethers extends SafeBaseContractEthers + * - SafeContract_v1_4_1 extends SafeBaseContract + * - SafeContract_v1_3_0 extends SafeBaseContract + * - SafeContract_v1_2_0 extends SafeBaseContract + * - SafeContract_v1_1_1 extends SafeBaseContract + * - SafeContract_v1_0_0 extends SafeBaseContract */ -abstract class SafeBaseContractEthers< +abstract class SafeBaseContract< SafeContractAbiType extends InterfaceAbi & Abi -> extends BaseContractEthers { +> extends BaseContract { contractName: contractName /** * @constructor - * Constructs an instance of SafeBaseContractEthers. + * Constructs an instance of SafeBaseContract. * * @param chainId - The chain ID of the contract. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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. @@ -41,7 +41,7 @@ abstract class SafeBaseContractEthers< */ constructor( chainId: bigint, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, defaultAbi: SafeContractAbiType, safeVersion: SafeVersion, isL1SafeSingleton = false, @@ -54,7 +54,7 @@ abstract class SafeBaseContractEthers< super( contractName, chainId, - ethersAdapter, + safeProvider, defaultAbi, safeVersion, customContractAddress, @@ -65,4 +65,4 @@ abstract class SafeBaseContractEthers< } } -export default SafeBaseContractEthers +export default SafeBaseContract diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.0.0/SafeContract_v1_0_0_Ethers.ts b/packages/protocol-kit/src/contracts/Safe/v1.0.0/SafeContract_v1_0_0.ts similarity index 84% rename from packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.0.0/SafeContract_v1_0_0_Ethers.ts rename to packages/protocol-kit/src/contracts/Safe/v1.0.0/SafeContract_v1_0_0.ts index 4522ae6fa..c969d0446 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.0.0/SafeContract_v1_0_0_Ethers.ts +++ b/packages/protocol-kit/src/contracts/Safe/v1.0.0/SafeContract_v1_0_0.ts @@ -1,7 +1,7 @@ -import SafeBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/Safe/SafeBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' -import { toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils' -import { sameString } from '@safe-global/protocol-kit/utils' +import SafeBaseContract from '@safe-global/protocol-kit/contracts/Safe/SafeBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' +import { toTxResult } from '@safe-global/protocol-kit/contracts/utils' +import { sameString, isSentinelAddress } from '@safe-global/protocol-kit/utils' import { SafeVersion, SafeContract_v1_0_0_Abi, @@ -9,37 +9,37 @@ import { SafeTransaction, SafeContract_v1_0_0_Contract, safe_1_0_0_ContractArtifacts, - EthersTransactionOptions, - EthersTransactionResult + TransactionOptions, + TransactionResult } from '@safe-global/safe-core-sdk-types' import { SENTINEL_ADDRESS } from '@safe-global/protocol-kit/utils/constants' /** - * SafeContract_v1_0_0_Ethers is the implementation specific to the Safe contract version 1.0.0. + * SafeContract_v1_0_0 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 Ethers.js v6. * - * @extends SafeBaseContractEthers - Inherits from SafeBaseContractEthers with ABI specific to Safe contract version 1.0.0. + * @extends SafeBaseContract - Inherits from SafeBaseContract 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_Ethers - extends SafeBaseContractEthers +class SafeContract_v1_0_0 + extends SafeBaseContract implements SafeContract_v1_0_0_Contract { safeVersion: SafeVersion /** - * Constructs an instance of SafeContract_v1_0_0_Ethers + * Constructs an instance of SafeContract_v1_0_0 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, isL1SafeSingleton = false, customContractAddress?: string, customContractAbi?: SafeContract_v1_0_0_Abi @@ -49,7 +49,7 @@ class SafeContract_v1_0_0_Ethers super( chainId, - ethersAdapter, + safeProvider, defaultAbi, safeVersion, isL1SafeSingleton, @@ -194,10 +194,7 @@ class SafeContract_v1_0_0_Ethers * @param options - Optional transaction options. * @returns Transaction result. */ - async approveHash( - hash: string, - options?: EthersTransactionOptions - ): Promise { + async approveHash(hash: string, options?: TransactionOptions): Promise { const gasLimit = options?.gasLimit || (await this.estimateGas('approveHash', [hash], options)) const txResponse = await this.contract.approveHash(hash, { ...options, gasLimit }) @@ -212,8 +209,8 @@ class SafeContract_v1_0_0_Ethers */ async execTransaction( safeTransaction: SafeTransaction, - options?: EthersTransactionOptions - ): Promise { + options?: TransactionOptions + ): Promise { const gasLimit = options?.gasLimit || (await this.estimateGas( @@ -250,15 +247,25 @@ class SafeContract_v1_0_0_Ethers return toTxResult(txResponse, options) } - async getModulesPaginated(start: string, pageSize: bigint): Promise { + async getModulesPaginated([start, pageSize]: [string, bigint]): Promise<[string[], string]> { if (pageSize <= 0) throw new Error('Invalid page size for fetching paginated modules') + const size = Number(pageSize) const [array] = await this.getModules() - if (start === SENTINEL_ADDRESS) { - return array.slice(0, Number(pageSize)) + + if (isSentinelAddress(start)) { + const next = pageSize < array.length ? array[size] : SENTINEL_ADDRESS + return [array.slice(0, size), next] } else { const moduleIndex = array.findIndex((module: string) => sameString(module, start)) - return moduleIndex === -1 ? [] : array.slice(moduleIndex + 1, Number(pageSize)) + if (moduleIndex === -1) { + return [[], SENTINEL_ADDRESS] + } + + const nextElementIndex = moduleIndex + 1 + const nextPageAddress = + nextElementIndex + size < array.length ? array[nextElementIndex + size] : SENTINEL_ADDRESS + return [array.slice(moduleIndex + 1, nextElementIndex + size), nextPageAddress] } } @@ -267,10 +274,10 @@ class SafeContract_v1_0_0_Ethers * @param moduleAddress - The module address to check. * @returns True, if the module with the given address is enabled. */ - async isModuleEnabled(moduleAddress: string[]): Promise { + async isModuleEnabled([moduleAddress]: [string]): Promise<[boolean]> { const [modules] = await this.getModules() const isModuleEnabled = modules.some((enabledModuleAddress) => - sameString(enabledModuleAddress, moduleAddress[0]) + sameString(enabledModuleAddress, moduleAddress) ) return [isModuleEnabled] } @@ -283,7 +290,7 @@ class SafeContract_v1_0_0_Ethers */ async isValidTransaction( safeTransaction: SafeTransaction, - options: EthersTransactionOptions = {} + options: TransactionOptions = {} ): Promise { try { const gasLimit = @@ -344,4 +351,4 @@ class SafeContract_v1_0_0_Ethers } } -export default SafeContract_v1_0_0_Ethers +export default SafeContract_v1_0_0 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.1.1/SafeContract_v1_1_1_Ethers.ts b/packages/protocol-kit/src/contracts/Safe/v1.1.1/SafeContract_v1_1_1.ts similarity index 88% rename from packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.1.1/SafeContract_v1_1_1_Ethers.ts rename to packages/protocol-kit/src/contracts/Safe/v1.1.1/SafeContract_v1_1_1.ts index 3668a760c..970eb6b5a 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.1.1/SafeContract_v1_1_1_Ethers.ts +++ b/packages/protocol-kit/src/contracts/Safe/v1.1.1/SafeContract_v1_1_1.ts @@ -1,6 +1,6 @@ -import SafeBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/Safe/SafeBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' -import { toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils' +import SafeBaseContract from '@safe-global/protocol-kit/contracts/Safe/SafeBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' +import { toTxResult } from '@safe-global/protocol-kit/contracts/utils' import { sameString } from '@safe-global/protocol-kit/utils' import { SafeVersion, @@ -9,36 +9,36 @@ import { SafeContract_v1_1_1_Function, SafeTransaction, safe_1_1_1_ContractArtifacts, - EthersTransactionOptions, - EthersTransactionResult + TransactionOptions, + TransactionResult } from '@safe-global/safe-core-sdk-types' /** - * SafeContract_v1_1_1_Ethers is the implementation specific to the Safe contract version 1.1.1. + * SafeContract_v1_1_1 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 Ethers.js v6. * - * @extends SafeBaseContractEthers - Inherits from SafeBaseContractEthers with ABI specific to Safe contract version 1.1.1. + * @extends SafeBaseContract - Inherits from SafeBaseContract 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_Ethers - extends SafeBaseContractEthers +class SafeContract_v1_1_1 + extends SafeBaseContract implements SafeContract_v1_1_1_Contract { safeVersion: SafeVersion /** - * Constructs an instance of SafeContract_v1_1_1_Ethers + * Constructs an instance of SafeContract_v1_1_1 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, isL1SafeSingleton = false, customContractAddress?: string, customContractAbi?: SafeContract_v1_1_1_Abi @@ -48,7 +48,7 @@ class SafeContract_v1_1_1_Ethers super( chainId, - ethersAdapter, + safeProvider, defaultAbi, safeVersion, isL1SafeSingleton, @@ -180,10 +180,7 @@ class SafeContract_v1_1_1_Ethers * @param options - Optional transaction options. * @returns Transaction result. */ - async approveHash( - hash: string, - options?: EthersTransactionOptions - ): Promise { + async approveHash(hash: string, options?: TransactionOptions): Promise { const gasLimit = options?.gasLimit || (await this.estimateGas('approveHash', [hash], options)) const txResponse = await this.contract.approveHash(hash, { ...options, gasLimit }) @@ -198,8 +195,8 @@ class SafeContract_v1_1_1_Ethers */ async execTransaction( safeTransaction: SafeTransaction, - options?: EthersTransactionOptions - ): Promise { + options?: TransactionOptions + ): Promise { const gasLimit = options?.gasLimit || (await this.estimateGas( @@ -241,10 +238,10 @@ class SafeContract_v1_1_1_Ethers * @param moduleAddress - The module address to check. * @returns True, if the module with the given address is enabled. */ - async isModuleEnabled(moduleAddress: string[]): Promise { + async isModuleEnabled([moduleAddress]: [string]): Promise<[boolean]> { const [modules] = await this.getModules() const isModuleEnabled = modules.some((enabledModuleAddress) => - sameString(enabledModuleAddress, moduleAddress[0]) + sameString(enabledModuleAddress, moduleAddress) ) return [isModuleEnabled] } @@ -257,7 +254,7 @@ class SafeContract_v1_1_1_Ethers */ async isValidTransaction( safeTransaction: SafeTransaction, - options: EthersTransactionOptions = {} + options: TransactionOptions = {} ): Promise { try { const gasLimit = @@ -318,4 +315,4 @@ class SafeContract_v1_1_1_Ethers } } -export default SafeContract_v1_1_1_Ethers +export default SafeContract_v1_1_1 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.2.0/SafeContract_v1_2_0_Ethers.ts b/packages/protocol-kit/src/contracts/Safe/v1.2.0/SafeContract_v1_2_0.ts similarity index 88% rename from packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.2.0/SafeContract_v1_2_0_Ethers.ts rename to packages/protocol-kit/src/contracts/Safe/v1.2.0/SafeContract_v1_2_0.ts index ff4fd7f9e..e6f130ad6 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.2.0/SafeContract_v1_2_0_Ethers.ts +++ b/packages/protocol-kit/src/contracts/Safe/v1.2.0/SafeContract_v1_2_0.ts @@ -1,6 +1,6 @@ -import SafeBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/Safe/SafeBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' -import { toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils' +import SafeBaseContract from '@safe-global/protocol-kit/contracts/Safe/SafeBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' +import { toTxResult } from '@safe-global/protocol-kit/contracts/utils' import { SafeVersion, SafeContract_v1_2_0_Abi, @@ -8,36 +8,36 @@ import { SafeContract_v1_2_0_Function, SafeTransaction, safe_1_2_0_ContractArtifacts, - EthersTransactionOptions, - EthersTransactionResult + TransactionOptions, + TransactionResult } from '@safe-global/safe-core-sdk-types' /** - * SafeContract_v1_2_0_Ethers is the implementation specific to the Safe contract version 1.2.0. + * SafeContract_v1_2_0 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 Ethers.js v6. * - * @extends SafeBaseContractEthers - Inherits from SafeBaseContractEthers with ABI specific to Safe contract version 1.2.0. + * @extends SafeBaseContract - Inherits from SafeBaseContract 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_Ethers - extends SafeBaseContractEthers +class SafeContract_v1_2_0 + extends SafeBaseContract implements SafeContract_v1_2_0_Contract { safeVersion: SafeVersion /** - * Constructs an instance of SafeContract_v1_2_0_Ethers + * Constructs an instance of SafeContract_v1_2_0 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, isL1SafeSingleton = false, customContractAddress?: string, customContractAbi?: SafeContract_v1_2_0_Abi @@ -47,7 +47,7 @@ class SafeContract_v1_2_0_Ethers super( chainId, - ethersAdapter, + safeProvider, defaultAbi, safeVersion, isL1SafeSingleton, @@ -189,10 +189,7 @@ class SafeContract_v1_2_0_Ethers * @param options - Optional transaction options. * @returns Transaction result. */ - async approveHash( - hash: string, - options?: EthersTransactionOptions - ): Promise { + async approveHash(hash: string, options?: TransactionOptions): Promise { const gasLimit = options?.gasLimit || (await this.estimateGas('approveHash', [hash], options)) const txResponse = await this.contract.approveHash(hash, { ...options, gasLimit }) @@ -207,8 +204,8 @@ class SafeContract_v1_2_0_Ethers */ async execTransaction( safeTransaction: SafeTransaction, - options?: EthersTransactionOptions - ): Promise { + options?: TransactionOptions + ): Promise { const gasLimit = options?.gasLimit || (await this.estimateGas( @@ -259,10 +256,7 @@ class SafeContract_v1_2_0_Ethers * @param options - Optional transaction options. * @returns True, if the given transactions is valid. */ - async isValidTransaction( - safeTransaction: SafeTransaction, - options: EthersTransactionOptions = {} - ) { + async isValidTransaction(safeTransaction: SafeTransaction, options: TransactionOptions = {}) { try { const gasLimit = options?.gasLimit || @@ -322,4 +316,4 @@ class SafeContract_v1_2_0_Ethers } } -export default SafeContract_v1_2_0_Ethers +export default SafeContract_v1_2_0 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.3.0/SafeContract_v1_3_0_Ethers.ts b/packages/protocol-kit/src/contracts/Safe/v1.3.0/SafeContract_v1_3_0.ts similarity index 87% rename from packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.3.0/SafeContract_v1_3_0_Ethers.ts rename to packages/protocol-kit/src/contracts/Safe/v1.3.0/SafeContract_v1_3_0.ts index 959892cdf..66d48071e 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.3.0/SafeContract_v1_3_0_Ethers.ts +++ b/packages/protocol-kit/src/contracts/Safe/v1.3.0/SafeContract_v1_3_0.ts @@ -1,7 +1,7 @@ -import SafeBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/Safe/SafeBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' -import { toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils' -import { SENTINEL_ADDRESS } from '@safe-global/protocol-kit/adapters/ethers/utils/constants' +import SafeBaseContract from '@safe-global/protocol-kit/contracts/Safe/SafeBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' +import { toTxResult } from '@safe-global/protocol-kit/contracts/utils' +import { SENTINEL_ADDRESS } from '@safe-global/protocol-kit/utils/constants' import { SafeVersion, SafeContract_v1_3_0_Abi, @@ -9,35 +9,35 @@ import { SafeContract_v1_3_0_Function, SafeTransaction, safe_1_3_0_ContractArtifacts, - EthersTransactionOptions, - EthersTransactionResult + TransactionOptions, + TransactionResult } from '@safe-global/safe-core-sdk-types' /** - * SafeContract_v1_3_0_Ethers is the implementation specific to the Safe contract version 1.3.0. + * SafeContract_v1_3_0 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 Ethers.js v6. * - * @extends SafeBaseContractEthers - Inherits from SafeBaseContractEthers with ABI specific to Safe contract version 1.3.0. + * @extends SafeBaseContract - Inherits from SafeBaseContract 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_Ethers - extends SafeBaseContractEthers +class SafeContract_v1_3_0 + extends SafeBaseContract implements SafeContract_v1_3_0_Contract { safeVersion: SafeVersion /** - * Constructs an instance of SafeContract_v1_3_0_Ethers + * Constructs an instance of SafeContract_v1_3_0 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, isL1SafeSingleton = false, customContractAddress?: string, customContractAbi?: SafeContract_v1_3_0_Abi @@ -47,7 +47,7 @@ class SafeContract_v1_3_0_Ethers super( chainId, - ethersAdapter, + safeProvider, defaultAbi, safeVersion, isL1SafeSingleton, @@ -194,10 +194,7 @@ class SafeContract_v1_3_0_Ethers * @param options - Optional transaction options. * @returns True, if the given transactions is valid. */ - async isValidTransaction( - safeTransaction: SafeTransaction, - options: EthersTransactionOptions = {} - ) { + async isValidTransaction(safeTransaction: SafeTransaction, options: TransactionOptions = {}) { try { const gasLimit = options?.gasLimit || @@ -244,8 +241,8 @@ class SafeContract_v1_3_0_Ethers */ async execTransaction( safeTransaction: SafeTransaction, - options?: EthersTransactionOptions - ): Promise { + options?: TransactionOptions + ): Promise { const gasLimit = options?.gasLimit || (await this.estimateGas( @@ -286,9 +283,9 @@ class SafeContract_v1_3_0_Ethers * Returns array of first 10 modules. * @returns Array[modules] */ - async getModules(): Promise { + async getModules(): Promise<[string[]]> { const [modules] = await this.getModulesPaginated([SENTINEL_ADDRESS, BigInt(10)]) - return [...modules] + return [modules.map((module) => module)] } /** @@ -297,10 +294,7 @@ class SafeContract_v1_3_0_Ethers * @param options - Optional transaction options. * @returns Transaction result. */ - async approveHash( - hash: string, - options?: EthersTransactionOptions - ): Promise { + async approveHash(hash: string, options?: TransactionOptions): Promise { const gasLimit = options?.gasLimit || (await this.estimateGas('approveHash', [hash], options)) const txResponse = await this.contract.approveHash(hash, { ...options, gasLimit }) @@ -336,4 +330,4 @@ class SafeContract_v1_3_0_Ethers } } -export default SafeContract_v1_3_0_Ethers +export default SafeContract_v1_3_0 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.4.1/SafeContract_v1_4_1_Ethers.ts b/packages/protocol-kit/src/contracts/Safe/v1.4.1/SafeContract_v1_4_1.ts similarity index 87% rename from packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.4.1/SafeContract_v1_4_1_Ethers.ts rename to packages/protocol-kit/src/contracts/Safe/v1.4.1/SafeContract_v1_4_1.ts index 38b7a21a8..c77c1131a 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/Safe/v1.4.1/SafeContract_v1_4_1_Ethers.ts +++ b/packages/protocol-kit/src/contracts/Safe/v1.4.1/SafeContract_v1_4_1.ts @@ -1,7 +1,7 @@ -import SafeBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/Safe/SafeBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' -import { toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils' -import { SENTINEL_ADDRESS } from '@safe-global/protocol-kit/adapters/ethers/utils/constants' +import SafeBaseContract from '@safe-global/protocol-kit/contracts/Safe/SafeBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' +import { toTxResult } from '@safe-global/protocol-kit/contracts/utils' +import { SENTINEL_ADDRESS } from '@safe-global/protocol-kit/utils/constants' import { SafeVersion, SafeContract_v1_4_1_Abi, @@ -9,36 +9,36 @@ import { SafeContract_v1_4_1_Function, SafeTransaction, safe_1_4_1_ContractArtifacts, - EthersTransactionOptions, - EthersTransactionResult + TransactionOptions, + TransactionResult } from '@safe-global/safe-core-sdk-types' /** - * SafeContract_v1_4_1_Ethers is the implementation specific to the Safe contract version 1.4.1. + * SafeContract_v1_4_1 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 Ethers.js v6. * - * @extends SafeBaseContractEthers - Inherits from SafeBaseContractEthers with ABI specific to Safe contract version 1.4.1. + * @extends SafeBaseContract - Inherits from SafeBaseContract 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_Ethers - extends SafeBaseContractEthers +class SafeContract_v1_4_1 + extends SafeBaseContract implements SafeContract_v1_4_1_Contract { safeVersion: SafeVersion /** - * Constructs an instance of SafeContract_v1_4_1_Ethers + * Constructs an instance of SafeContract_v1_4_1 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, isL1SafeSingleton = false, customContractAddress?: string, customContractAbi?: SafeContract_v1_4_1_Abi @@ -48,7 +48,7 @@ class SafeContract_v1_4_1_Ethers super( chainId, - ethersAdapter, + safeProvider, defaultAbi, safeVersion, isL1SafeSingleton, @@ -195,10 +195,7 @@ class SafeContract_v1_4_1_Ethers * @param options - Optional transaction options. * @returns True, if the given transactions is valid. */ - async isValidTransaction( - safeTransaction: SafeTransaction, - options: EthersTransactionOptions = {} - ) { + async isValidTransaction(safeTransaction: SafeTransaction, options: TransactionOptions = {}) { try { const gasLimit = options?.gasLimit || @@ -245,8 +242,8 @@ class SafeContract_v1_4_1_Ethers */ async execTransaction( safeTransaction: SafeTransaction, - options?: EthersTransactionOptions - ): Promise { + options?: TransactionOptions + ): Promise { const gasLimit = options?.gasLimit || (await this.estimateGas( @@ -287,9 +284,9 @@ class SafeContract_v1_4_1_Ethers * Returns array of first 10 modules. * @returns Array[modules] */ - async getModules(): Promise { + async getModules(): Promise<[string[]]> { const [modules] = await this.getModulesPaginated([SENTINEL_ADDRESS, BigInt(10)]) - return [...modules] + return [modules.map((module) => module)] } /** @@ -298,10 +295,7 @@ class SafeContract_v1_4_1_Ethers * @param options - Optional transaction options. * @returns Transaction result. */ - async approveHash( - hash: string, - options?: EthersTransactionOptions - ): Promise { + async approveHash(hash: string, options?: TransactionOptions): Promise { const gasLimit = options?.gasLimit || (await this.estimateGas('approveHash', [hash], options)) const txResponse = await this.contract.approveHash(hash, { ...options, gasLimit }) @@ -337,4 +331,4 @@ class SafeContract_v1_4_1_Ethers } } -export default SafeContract_v1_4_1_Ethers +export default SafeContract_v1_4_1 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/SafeProxyFactoryBaseContractEthers.ts b/packages/protocol-kit/src/contracts/SafeProxyFactory/SafeProxyFactoryBaseContract.ts similarity index 53% rename from packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/SafeProxyFactoryBaseContractEthers.ts rename to packages/protocol-kit/src/contracts/SafeProxyFactory/SafeProxyFactoryBaseContract.ts index d2538b20c..67d8c9e4e 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/SafeProxyFactoryBaseContractEthers.ts +++ b/packages/protocol-kit/src/contracts/SafeProxyFactory/SafeProxyFactoryBaseContract.ts @@ -1,45 +1,45 @@ import { Abi } from 'abitype' import { ContractRunner, InterfaceAbi } from 'ethers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' -import BaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/BaseContractEthers' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' +import BaseContract from '@safe-global/protocol-kit/contracts/BaseContract' import { SafeVersion, - EthersTransactionOptions, + TransactionOptions, CreateProxyProps as CreateProxyPropsGeneral } from '@safe-global/safe-core-sdk-types' import { contractName } from '@safe-global/protocol-kit/contracts/config' export interface CreateProxyProps extends CreateProxyPropsGeneral { - options?: EthersTransactionOptions + options?: TransactionOptions } /** - * Abstract class SafeProxyFactoryBaseContractEthers extends BaseContractEthers to specifically integrate with the SafeProxyFactory contract. + * Abstract class SafeProxyFactoryBaseContract extends BaseContract to specifically integrate with the SafeProxyFactory contract. * It is designed to be instantiated for different versions of the Safe contract. * - * Subclasses of SafeProxyFactoryBaseContractEthers are expected to represent specific versions of the contract. + * Subclasses of SafeProxyFactoryBaseContract 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 InterfaceAbi from Ethers. - * @extends BaseContractEthers - Extends the generic BaseContractEthers. + * @extends BaseContract - Extends the generic BaseContract. * * Example subclasses: - * - SafeProxyFactoryContract_v1_4_1_Ethers extends SafeProxyFactoryBaseContractEthers - * - SafeProxyFactoryContract_v1_3_0_Ethers extends SafeProxyFactoryBaseContractEthers - * - SafeProxyFactoryContract_v1_2_0_Ethers extends SafeProxyFactoryBaseContractEthers - * - SafeProxyFactoryContract_v1_1_1_Ethers extends SafeProxyFactoryBaseContractEthers - * - SafeProxyFactoryContract_v1_0_0_Ethers extends SafeProxyFactoryBaseContractEthers + * - SafeProxyFactoryContract_v1_4_1 extends SafeProxyFactoryBaseContract + * - SafeProxyFactoryContract_v1_3_0 extends SafeProxyFactoryBaseContract + * - SafeProxyFactoryContract_v1_2_0 extends SafeProxyFactoryBaseContract + * - SafeProxyFactoryContract_v1_1_1 extends SafeProxyFactoryBaseContract + * - SafeProxyFactoryContract_v1_0_0 extends SafeProxyFactoryBaseContract */ -abstract class SafeProxyFactoryBaseContractEthers< +abstract class SafeProxyFactoryBaseContract< SafeProxyFactoryContractAbiType extends InterfaceAbi & Abi -> extends BaseContractEthers { +> extends BaseContract { contractName: contractName /** * @constructor - * Constructs an instance of SafeProxyFactoryBaseContractEthers. + * Constructs an instance of SafeProxyFactoryBaseContract. * * @param chainId - The chain ID of the contract. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @param defaultAbi - The default ABI for the Safe 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. @@ -47,7 +47,7 @@ abstract class SafeProxyFactoryBaseContractEthers< */ constructor( chainId: bigint, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, defaultAbi: SafeProxyFactoryContractAbiType, safeVersion: SafeVersion, customContractAddress?: string, @@ -59,7 +59,7 @@ abstract class SafeProxyFactoryBaseContractEthers< super( contractName, chainId, - ethersAdapter, + safeProvider, defaultAbi, safeVersion, customContractAddress, @@ -71,4 +71,4 @@ abstract class SafeProxyFactoryBaseContractEthers< } } -export default SafeProxyFactoryBaseContractEthers +export default SafeProxyFactoryBaseContract diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0_Ethers.ts b/packages/protocol-kit/src/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0.ts similarity index 82% rename from packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0_Ethers.ts rename to packages/protocol-kit/src/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0.ts index 7b3ba97cd..100e61e67 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0_Ethers.ts +++ b/packages/protocol-kit/src/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0.ts @@ -1,8 +1,8 @@ import { ContractRunner, EventLog } from 'ethers' -import SafeProxyFactoryBaseContractEthers, { +import SafeProxyFactoryBaseContract, { CreateProxyProps -} from '@safe-global/protocol-kit/adapters/ethers/contracts/SafeProxyFactory/SafeProxyFactoryBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +} from '@safe-global/protocol-kit/contracts/SafeProxyFactory/SafeProxyFactoryBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion, SafeProxyFactoryContract_v1_0_0_Abi, @@ -12,30 +12,30 @@ import { } from '@safe-global/safe-core-sdk-types' /** - * SafeProxyFactoryContract_v1_0_0_Ethers is the implementation specific to the Safe Proxy Factory contract version 1.0.0. + * SafeProxyFactoryContract_v1_0_0 is the implementation specific to the Safe Proxy Factory contract version 1.0.0. * * This class specializes in handling interactions with the Safe Proxy Factory contract version 1.0.0 using Ethers.js v6. * - * @extends SafeProxyFactoryBaseContractEthers - Inherits from SafeProxyFactoryBaseContractEthers with ABI specific to Safe Proxy Factory contract version 1.0.0. + * @extends SafeProxyFactoryBaseContract - Inherits from SafeProxyFactoryBaseContract with ABI specific to Safe Proxy Factory contract version 1.0.0. * @implements SafeProxyFactoryContract_v1_0_0_Contract - Implements the interface specific to Safe Proxy Factory contract version 1.0.0. */ -class SafeProxyFactoryContract_v1_0_0_Ethers - extends SafeProxyFactoryBaseContractEthers +class SafeProxyFactoryContract_v1_0_0 + extends SafeProxyFactoryBaseContract implements SafeProxyFactoryContract_v1_0_0_Contract { safeVersion: SafeVersion /** - * Constructs an instance of SafeProxyFactoryContract_v1_0_0_Ethers + * Constructs an instance of SafeProxyFactoryContract_v1_0_0 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, customContractAddress?: string, customContractAbi?: SafeProxyFactoryContract_v1_0_0_Abi, runner?: ContractRunner | null @@ -45,7 +45,7 @@ class SafeProxyFactoryContract_v1_0_0_Ethers super( chainId, - ethersAdapter, + safeProvider, defaultAbi, safeVersion, customContractAddress, @@ -137,4 +137,4 @@ class SafeProxyFactoryContract_v1_0_0_Ethers } } -export default SafeProxyFactoryContract_v1_0_0_Ethers +export default SafeProxyFactoryContract_v1_0_0 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1_Ethers.ts b/packages/protocol-kit/src/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1.ts similarity index 85% rename from packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1_Ethers.ts rename to packages/protocol-kit/src/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1.ts index f466f8d0c..8cd499342 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1_Ethers.ts +++ b/packages/protocol-kit/src/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1.ts @@ -1,8 +1,8 @@ import { ContractRunner, EventLog } from 'ethers' -import SafeProxyFactoryBaseContractEthers, { +import SafeProxyFactoryBaseContract, { CreateProxyProps -} from '@safe-global/protocol-kit/adapters/ethers/contracts/SafeProxyFactory/SafeProxyFactoryBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +} from '@safe-global/protocol-kit/contracts/SafeProxyFactory/SafeProxyFactoryBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion, SafeProxyFactoryContract_v1_1_1_Abi, @@ -12,30 +12,30 @@ import { } from '@safe-global/safe-core-sdk-types' /** - * SafeProxyFactoryContract_v1_1_1_Ethers is the implementation specific to the Safe Proxy Factory contract version 1.1.1. + * SafeProxyFactoryContract_v1_1_1 is the implementation specific to the Safe Proxy Factory contract version 1.1.1. * * This class specializes in handling interactions with the Safe Proxy Factory contract version 1.1.1 using Ethers.js v6. * - * @extends SafeProxyFactoryBaseContractEthers - Inherits from SafeProxyFactoryBaseContractEthers with ABI specific to Safe Proxy Factory contract version 1.1.1. + * @extends SafeProxyFactoryBaseContract - Inherits from SafeProxyFactoryBaseContract with ABI specific to Safe Proxy Factory contract version 1.1.1. * @implements SafeProxyFactoryContract_v1_1_1_Contract - Implements the interface specific to Safe Proxy Factory contract version 1.1.1. */ -class SafeProxyFactoryContract_v1_1_1_Ethers - extends SafeProxyFactoryBaseContractEthers +class SafeProxyFactoryContract_v1_1_1 + extends SafeProxyFactoryBaseContract implements SafeProxyFactoryContract_v1_1_1_Contract { safeVersion: SafeVersion /** - * Constructs an instance of SafeProxyFactoryContract_v1_1_1_Ethers + * Constructs an instance of SafeProxyFactoryContract_v1_1_1 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, customContractAddress?: string, customContractAbi?: SafeProxyFactoryContract_v1_1_1_Abi, runner?: ContractRunner | null @@ -45,7 +45,7 @@ class SafeProxyFactoryContract_v1_1_1_Ethers super( chainId, - ethersAdapter, + safeProvider, defaultAbi, safeVersion, customContractAddress, @@ -157,4 +157,4 @@ class SafeProxyFactoryContract_v1_1_1_Ethers } } -export default SafeProxyFactoryContract_v1_1_1_Ethers +export default SafeProxyFactoryContract_v1_1_1 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0_Ethers.ts b/packages/protocol-kit/src/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0.ts similarity index 85% rename from packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0_Ethers.ts rename to packages/protocol-kit/src/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0.ts index 84b1650da..66ca7aabb 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0_Ethers.ts +++ b/packages/protocol-kit/src/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0.ts @@ -1,8 +1,8 @@ import { ContractRunner, EventLog } from 'ethers' -import SafeProxyFactoryBaseContractEthers, { +import SafeProxyFactoryBaseContract, { CreateProxyProps -} from '@safe-global/protocol-kit/adapters/ethers/contracts/SafeProxyFactory/SafeProxyFactoryBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +} from '@safe-global/protocol-kit/contracts/SafeProxyFactory/SafeProxyFactoryBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion, SafeProxyFactoryContract_v1_3_0_Abi, @@ -12,30 +12,30 @@ import { } from '@safe-global/safe-core-sdk-types' /** - * SafeProxyFactoryContract_v1_3_0_Ethers is the implementation specific to the Safe Proxy Factory contract version 1.3.0. + * SafeProxyFactoryContract_v1_3_0 is the implementation specific to the Safe Proxy Factory contract version 1.3.0. * * This class specializes in handling interactions with the Safe Proxy Factory contract version 1.3.0 using Ethers.js v6. * - * @extends SafeProxyFactoryBaseContractEthers - Inherits from SafeProxyFactoryBaseContractEthers with ABI specific to Safe Proxy Factory contract version 1.3.0. + * @extends SafeProxyFactoryBaseContract - Inherits from SafeProxyFactoryBaseContract with ABI specific to Safe Proxy Factory contract version 1.3.0. * @implements SafeProxyFactoryContract_v1_3_0_Contract - Implements the interface specific to Safe Proxy Factory contract version 1.3.0. */ -class SafeProxyFactoryContract_v1_3_0_Ethers - extends SafeProxyFactoryBaseContractEthers +class SafeProxyFactoryContract_v1_3_0 + extends SafeProxyFactoryBaseContract implements SafeProxyFactoryContract_v1_3_0_Contract { safeVersion: SafeVersion /** - * Constructs an instance of SafeProxyFactoryContract_v1_3_0_Ethers + * Constructs an instance of SafeProxyFactoryContract_v1_3_0 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, customContractAddress?: string, customContractAbi?: SafeProxyFactoryContract_v1_3_0_Abi, runner?: ContractRunner | null @@ -45,7 +45,7 @@ class SafeProxyFactoryContract_v1_3_0_Ethers super( chainId, - ethersAdapter, + safeProvider, defaultAbi, safeVersion, customContractAddress, @@ -157,4 +157,4 @@ class SafeProxyFactoryContract_v1_3_0_Ethers } } -export default SafeProxyFactoryContract_v1_3_0_Ethers +export default SafeProxyFactoryContract_v1_3_0 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1_Ethers.ts b/packages/protocol-kit/src/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1.ts similarity index 84% rename from packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1_Ethers.ts rename to packages/protocol-kit/src/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1.ts index 32edc278f..425a11e26 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1_Ethers.ts +++ b/packages/protocol-kit/src/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1.ts @@ -1,8 +1,7 @@ import { ContractRunner, EventLog } from 'ethers' -import SafeProxyFactoryBaseContractEthers, { +import SafeProxyFactoryBaseContract, { CreateProxyProps -} from '@safe-global/protocol-kit/adapters/ethers/contracts/SafeProxyFactory/SafeProxyFactoryBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +} from '@safe-global/protocol-kit/contracts/SafeProxyFactory/SafeProxyFactoryBaseContract' import { SafeVersion, SafeProxyFactoryContract_v1_4_1_Abi, @@ -10,32 +9,33 @@ import { SafeProxyFactoryContract_v1_4_1_Function, safeProxyFactory_1_4_1_ContractArtifacts } from '@safe-global/safe-core-sdk-types' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' /** - * SafeProxyFactoryContract_v1_4_1_Ethers is the implementation specific to the Safe Proxy Factory contract version 1.4.1. + * SafeProxyFactoryContract_v1_4_1 is the implementation specific to the Safe Proxy Factory contract version 1.4.1. * * This class specializes in handling interactions with the Safe Proxy Factory contract version 1.4.1 using Ethers.js v6. * - * @extends SafeProxyFactoryBaseContractEthers - Inherits from SafeProxyFactoryBaseContractEthers with ABI specific to Safe Proxy Factory contract version 1.4.1. + * @extends SafeProxyFactoryBaseContract - Inherits from SafeProxyFactoryBaseContract with ABI specific to Safe Proxy Factory contract version 1.4.1. * @implements SafeProxyFactoryContract_v1_4_1_Contract - Implements the interface specific to Safe Proxy Factory contract version 1.4.1. */ -class SafeProxyFactoryContract_v1_4_1_Ethers - extends SafeProxyFactoryBaseContractEthers +class SafeProxyFactoryContract_v1_4_1 + extends SafeProxyFactoryBaseContract implements SafeProxyFactoryContract_v1_4_1_Contract { safeVersion: SafeVersion /** - * Constructs an instance of SafeProxyFactoryContract_v1_4_1_Ethers + * Constructs an instance of SafeProxyFactoryContract_v1_4_1 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, customContractAddress?: string, customContractAbi?: SafeProxyFactoryContract_v1_4_1_Abi, runner?: ContractRunner | null @@ -45,7 +45,7 @@ class SafeProxyFactoryContract_v1_4_1_Ethers super( chainId, - ethersAdapter, + safeProvider, defaultAbi, safeVersion, customContractAddress, @@ -149,4 +149,4 @@ class SafeProxyFactoryContract_v1_4_1_Ethers } } -export default SafeProxyFactoryContract_v1_4_1_Ethers +export default SafeProxyFactoryContract_v1_4_1 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SignMessageLib/SignMessageLibBaseContractEthers.ts b/packages/protocol-kit/src/contracts/SignMessageLib/SignMessageLibBaseContract.ts similarity index 60% rename from packages/protocol-kit/src/adapters/ethers/contracts/SignMessageLib/SignMessageLibBaseContractEthers.ts rename to packages/protocol-kit/src/contracts/SignMessageLib/SignMessageLibBaseContract.ts index 5c17e91da..264019128 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/SignMessageLib/SignMessageLibBaseContractEthers.ts +++ b/packages/protocol-kit/src/contracts/SignMessageLib/SignMessageLibBaseContract.ts @@ -1,35 +1,35 @@ import { Abi } from 'abitype' import { InterfaceAbi } from 'ethers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion } from '@safe-global/safe-core-sdk-types' -import BaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/BaseContractEthers' +import BaseContract from '@safe-global/protocol-kit/contracts/BaseContract' import { contractName } from '@safe-global/protocol-kit/contracts/config' /** - * Abstract class SignMessageLibBaseContractEthers extends BaseContractEthers to specifically integrate with the SignMessageLib contract. + * Abstract class SignMessageLibBaseContract extends BaseContract to specifically integrate with the SignMessageLib contract. * It is designed to be instantiated for different versions of the SignMessageLib contract. * - * Subclasses of SignMessageLibBaseContractEthers are expected to represent specific versions of the SignMessageLib contract. + * Subclasses of SignMessageLibBaseContract are expected to represent specific versions of the SignMessageLib contract. * * @template SignMessageLibContractAbiType - The ABI type specific to the version of the SignMessageLib contract, extending InterfaceAbi from Ethers. - * @extends BaseContractEthers - Extends the generic BaseContractEthers. + * @extends BaseContract - Extends the generic BaseContract. * * Example subclasses: - * - SignMessageLibContract_v1_4_1_Ethers extends SignMessageLibBaseContractEthers - * - SignMessageLibContract_v1_3_0_Ethers extends SignMessageLibBaseContractEthers + * - SignMessageLibContract_v1_4_1 extends SignMessageLibBaseContract + * - SignMessageLibContract_v1_3_0 extends SignMessageLibBaseContract */ -abstract class SignMessageLibBaseContractEthers< +abstract class SignMessageLibBaseContract< SignMessageLibContractAbiType extends InterfaceAbi & Abi -> extends BaseContractEthers { +> extends BaseContract { contractName: contractName /** * @constructor - * Constructs an instance of SignMessageLibBaseContractEthers. + * Constructs an instance of SignMessageLibBaseContract. * * @param chainId - The chain ID of the contract. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @param defaultAbi - The default ABI for the SignMessageLib contract. It should be compatible with the specific version of the SignMessageLib contract. * @param safeVersion - The version of the SignMessageLib contract. * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the SignMessageLib deployments based on the chainId and safeVersion. @@ -37,7 +37,7 @@ abstract class SignMessageLibBaseContractEthers< */ constructor( chainId: bigint, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, defaultAbi: SignMessageLibContractAbiType, safeVersion: SafeVersion, customContractAddress?: string, @@ -48,7 +48,7 @@ abstract class SignMessageLibBaseContractEthers< super( contractName, chainId, - ethersAdapter, + safeProvider, defaultAbi, safeVersion, customContractAddress, @@ -59,4 +59,4 @@ abstract class SignMessageLibBaseContractEthers< } } -export default SignMessageLibBaseContractEthers +export default SignMessageLibBaseContract diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0_Ethers.ts b/packages/protocol-kit/src/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0.ts similarity index 56% rename from packages/protocol-kit/src/adapters/ethers/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0_Ethers.ts rename to packages/protocol-kit/src/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0.ts index 04e4f1324..f506a61de 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0_Ethers.ts +++ b/packages/protocol-kit/src/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0.ts @@ -1,52 +1,50 @@ -import { toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils' -import SignMessageLibBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/SignMessageLib/SignMessageLibBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import { toTxResult } from '@safe-global/protocol-kit/contracts/utils' +import SignMessageLibBaseContract from '@safe-global/protocol-kit/contracts/SignMessageLib/SignMessageLibBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion, - AdapterSpecificContractFunction, + SafeContractFunction, SignMessageLibContract_v1_3_0_Abi, SignMessageLibContract_v1_3_0_Contract, SignMessageLibContract_v1_3_0_Function, - signMessageLib_1_3_0_ContractArtifacts, - EthersTransactionOptions + signMessageLib_1_3_0_ContractArtifacts } from '@safe-global/safe-core-sdk-types' /** - * SignMessageLibContract_v1_3_0_Ethers is the implementation specific to the SignMessageLib contract version 1.3.0. + * SignMessageLibContract_v1_3_0 is the implementation specific to the SignMessageLib contract version 1.3.0. * * This class specializes in handling interactions with the SignMessageLib contract version 1.3.0 using Ethers.js v6. * - * @extends SignMessageLibBaseContractEthers - Inherits from SignMessageLibBaseContractEthers with ABI specific to SignMessageLib contract version 1.3.0. + * @extends SignMessageLibBaseContract - Inherits from SignMessageLibBaseContract with ABI specific to SignMessageLib contract version 1.3.0. * @implements SignMessageLibContract_v1_3_0_Contract - Implements the interface specific to SignMessageLib contract version 1.3.0. */ -class SignMessageLibContract_v1_3_0_Ethers - extends SignMessageLibBaseContractEthers +class SignMessageLibContract_v1_3_0 + extends SignMessageLibBaseContract implements SignMessageLibContract_v1_3_0_Contract { safeVersion: SafeVersion /** - * Constructs an instance of SignMessageLibContract_v1_3_0_Ethers + * Constructs an instance of SignMessageLibContract_v1_3_0 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the SignMessageLib 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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, customContractAddress?: string, customContractAbi?: SignMessageLibContract_v1_3_0_Abi ) { const safeVersion = '1.3.0' const defaultAbi = signMessageLib_1_3_0_ContractArtifacts.abi - super(chainId, ethersAdapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) + super(chainId, safeProvider, defaultAbi, safeVersion, customContractAddress, customContractAbi) this.safeVersion = safeVersion } - /** * @param args - Array[message] */ @@ -57,11 +55,10 @@ class SignMessageLibContract_v1_3_0_Ethers /** * @param args - Array[data] */ - signMessage: AdapterSpecificContractFunction< - SignMessageLibContract_v1_3_0_Abi, - 'signMessage', - EthersTransactionOptions - > = async (data, options) => { + signMessage: SafeContractFunction = async ( + data, + options + ) => { if (options && !options.gasLimit) { options.gasLimit = Number(await this.estimateGas('signMessage', data, { ...options })) } @@ -72,4 +69,4 @@ class SignMessageLibContract_v1_3_0_Ethers } } -export default SignMessageLibContract_v1_3_0_Ethers +export default SignMessageLibContract_v1_3_0 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1_Ethers.ts b/packages/protocol-kit/src/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1.ts similarity index 56% rename from packages/protocol-kit/src/adapters/ethers/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1_Ethers.ts rename to packages/protocol-kit/src/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1.ts index 69dd8f26f..e00dc2183 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1_Ethers.ts +++ b/packages/protocol-kit/src/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1.ts @@ -1,48 +1,47 @@ -import { toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils' -import SignMessageLibBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/SignMessageLib/SignMessageLibBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import { toTxResult } from '@safe-global/protocol-kit/contracts/utils' +import SignMessageLibBaseContract from '@safe-global/protocol-kit/contracts/SignMessageLib/SignMessageLibBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion, - AdapterSpecificContractFunction, + SafeContractFunction, SignMessageLibContract_v1_4_1_Abi, SignMessageLibContract_v1_4_1_Contract, SignMessageLibContract_v1_4_1_Function, - signMessageLib_1_4_1_ContractArtifacts, - EthersTransactionOptions + signMessageLib_1_4_1_ContractArtifacts } from '@safe-global/safe-core-sdk-types' /** - * SignMessageLibContract_v1_4_1_Ethers is the implementation specific to the SignMessageLib contract version 1.4.1. + * SignMessageLibContract_v1_4_1 is the implementation specific to the SignMessageLib contract version 1.4.1. * * This class specializes in handling interactions with the SignMessageLib contract version 1.4.1 using Ethers.js v6. * - * @extends SignMessageLibBaseContractEthers - Inherits from SignMessageLibBaseContractEthers with ABI specific to SignMessageLib contract version 1.4.1. + * @extends SignMessageLibBaseContract - Inherits from SignMessageLibBaseContract with ABI specific to SignMessageLib contract version 1.4.1. * @implements SignMessageLibContract_v1_4_1_Contract - Implements the interface specific to SignMessageLib contract version 1.4.1. */ -class SignMessageLibContract_v1_4_1_Ethers - extends SignMessageLibBaseContractEthers +class SignMessageLibContract_v1_4_1 + extends SignMessageLibBaseContract implements SignMessageLibContract_v1_4_1_Contract { safeVersion: SafeVersion /** - * Constructs an instance of SignMessageLibContract_v1_4_1_Ethers + * Constructs an instance of SignMessageLibContract_v1_4_1 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the SignMessageLib 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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, customContractAddress?: string, customContractAbi?: SignMessageLibContract_v1_4_1_Abi ) { const safeVersion = '1.4.1' const defaultAbi = signMessageLib_1_4_1_ContractArtifacts.abi - super(chainId, ethersAdapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) + super(chainId, safeProvider, defaultAbi, safeVersion, customContractAddress, customContractAbi) this.safeVersion = safeVersion } @@ -57,11 +56,10 @@ class SignMessageLibContract_v1_4_1_Ethers /** * @param args - Array[data] */ - signMessage: AdapterSpecificContractFunction< - SignMessageLibContract_v1_4_1_Abi, - 'signMessage', - EthersTransactionOptions - > = async (data, options) => { + signMessage: SafeContractFunction = async ( + data, + options + ) => { if (options && !options.gasLimit) { options.gasLimit = Number(await this.estimateGas('signMessage', data, { ...options })) } @@ -72,4 +70,4 @@ class SignMessageLibContract_v1_4_1_Ethers } } -export default SignMessageLibContract_v1_4_1_Ethers +export default SignMessageLibContract_v1_4_1 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContractEthers.ts b/packages/protocol-kit/src/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContract.ts similarity index 59% rename from packages/protocol-kit/src/adapters/ethers/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContractEthers.ts rename to packages/protocol-kit/src/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContract.ts index 63ab75f51..1fda7217b 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContractEthers.ts +++ b/packages/protocol-kit/src/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContract.ts @@ -1,35 +1,35 @@ import { Abi } from 'abitype' import { ContractRunner, InterfaceAbi } from 'ethers' -import BaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/BaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import BaseContract from '@safe-global/protocol-kit/contracts/BaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion } from '@safe-global/safe-core-sdk-types' import { contractName } from '@safe-global/protocol-kit/contracts/config' /** - * Abstract class SimulateTxAccessorBaseContractEthers extends BaseContractEthers to specifically integrate with the SimulateTxAccessor contract. + * Abstract class SimulateTxAccessorBaseContract extends BaseContract to specifically integrate with the SimulateTxAccessor contract. * It is designed to be instantiated for different versions of the Safe contract. * - * Subclasses of SimulateTxAccessorBaseContractEthers are expected to represent specific versions of the contract. + * Subclasses of SimulateTxAccessorBaseContract are expected to represent specific versions of the contract. * * @template SimulateTxAccessorContractAbiType - The ABI type specific to the version of the SimulateTxAccessor contract, extending InterfaceAbi from Ethers. - * @extends BaseContractEthers - Extends the generic BaseContractEthers. + * @extends BaseContract - Extends the generic BaseContract. * * Example subclasses: - * - SimulateTxAccessorContract_v1_4_1_Ethers extends SimulateTxAccessorBaseContractEthers - * - SimulateTxAccessorContract_v1_3_0_Ethers extends SimulateTxAccessorBaseContractEthers + * - SimulateTxAccessorContract_v1_4_1 extends SimulateTxAccessorBaseContract + * - SimulateTxAccessorContract_v1_3_0 extends SimulateTxAccessorBaseContract */ -abstract class SimulateTxAccessorBaseContractEthers< +abstract class SimulateTxAccessorBaseContract< SimulateTxAccessorContractAbiType extends InterfaceAbi & Abi -> extends BaseContractEthers { +> extends BaseContract { contractName: contractName /** * @constructor - * Constructs an instance of SimulateTxAccessorBaseContractEthers. + * Constructs an instance of SimulateTxAccessorBaseContract. * * @param chainId - The chain ID of the contract. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @param defaultAbi - The default ABI for the SimulateTxAccessor 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. @@ -37,7 +37,7 @@ abstract class SimulateTxAccessorBaseContractEthers< */ constructor( chainId: bigint, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, defaultAbi: SimulateTxAccessorContractAbiType, safeVersion: SafeVersion, customContractAddress?: string, @@ -49,7 +49,7 @@ abstract class SimulateTxAccessorBaseContractEthers< super( contractName, chainId, - ethersAdapter, + safeProvider, defaultAbi, safeVersion, customContractAddress, @@ -61,4 +61,4 @@ abstract class SimulateTxAccessorBaseContractEthers< } } -export default SimulateTxAccessorBaseContractEthers +export default SimulateTxAccessorBaseContract diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0_Ethers.ts b/packages/protocol-kit/src/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0.ts similarity index 62% rename from packages/protocol-kit/src/adapters/ethers/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0_Ethers.ts rename to packages/protocol-kit/src/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0.ts index db78db111..97d04b92a 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0_Ethers.ts +++ b/packages/protocol-kit/src/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0.ts @@ -1,5 +1,5 @@ -import SimulateTxAccessorBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import SimulateTxAccessorBaseContract from '@safe-global/protocol-kit/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion, simulateTxAccessor_1_3_0_ContractArtifacts, @@ -9,37 +9,37 @@ import { } from '@safe-global/safe-core-sdk-types' /** - * SimulateTxAccessorContract_v1_3_0_Ethers is the implementation specific to the SimulateTxAccessor contract version 1.3.0. + * SimulateTxAccessorContract_v1_3_0 is the implementation specific to the SimulateTxAccessor contract version 1.3.0. * * This class specializes in handling interactions with the SimulateTxAccessor contract version 1.3.0 using Ethers.js v6. * - * @extends SimulateTxAccessorBaseContractEthers - Inherits from SimulateTxAccessorBaseContractEthers with ABI specific to SimulateTxAccessor contract version 1.3.0. + * @extends SimulateTxAccessorBaseContract - Inherits from SimulateTxAccessorBaseContract with ABI specific to SimulateTxAccessor contract version 1.3.0. * @implements SimulateTxAccessorContract_v1_3_0_Contract - Implements the interface specific to SimulateTxAccessor contract version 1.3.0. */ -class SimulateTxAccessorContract_v1_3_0_Ethers - extends SimulateTxAccessorBaseContractEthers +class SimulateTxAccessorContract_v1_3_0 + extends SimulateTxAccessorBaseContract implements SimulateTxAccessorContract_v1_3_0_Contract { safeVersion: SafeVersion /** - * Constructs an instance of SimulateTxAccessorContract_v1_3_0_Ethers + * Constructs an instance of SimulateTxAccessorContract_v1_3_0 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the SimulateTxAccessor 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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, customContractAddress?: string, customContractAbi?: SimulateTxAccessorContract_v1_3_0_Abi ) { const safeVersion = '1.3.0' const defaultAbi = simulateTxAccessor_1_3_0_ContractArtifacts.abi - super(chainId, ethersAdapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) + super(chainId, safeProvider, defaultAbi, safeVersion, customContractAddress, customContractAbi) this.safeVersion = safeVersion } @@ -53,4 +53,4 @@ class SimulateTxAccessorContract_v1_3_0_Ethers } } -export default SimulateTxAccessorContract_v1_3_0_Ethers +export default SimulateTxAccessorContract_v1_3_0 diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1_Ethers.ts b/packages/protocol-kit/src/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1.ts similarity index 62% rename from packages/protocol-kit/src/adapters/ethers/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1_Ethers.ts rename to packages/protocol-kit/src/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1.ts index 7746a78f1..294562199 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1_Ethers.ts +++ b/packages/protocol-kit/src/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1.ts @@ -1,5 +1,5 @@ -import SimulateTxAccessorBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContractEthers' -import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import SimulateTxAccessorBaseContract from '@safe-global/protocol-kit/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContract' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeVersion, simulateTxAccessor_1_4_1_ContractArtifacts, @@ -8,37 +8,37 @@ import { SimulateTxAccessorContract_v1_4_1_Function } from '@safe-global/safe-core-sdk-types' /** - * SimulateTxAccessorContract_v1_4_1_Ethers is the implementation specific to the SimulateTxAccessor contract version 1.4.1. + * SimulateTxAccessorContract_v1_4_1 is the implementation specific to the SimulateTxAccessor contract version 1.4.1. * * This class specializes in handling interactions with the SimulateTxAccessor contract version 1.4.1 using Ethers.js v6. * - * @extends SimulateTxAccessorBaseContractEthers - Inherits from SimulateTxAccessorBaseContractEthers with ABI specific to SimulateTxAccessor contract version 1.4.1. + * @extends SimulateTxAccessorBaseContract - Inherits from SimulateTxAccessorBaseContract with ABI specific to SimulateTxAccessor contract version 1.4.1. * @implements SimulateTxAccessorContract_v1_4_1_Contract - Implements the interface specific to SimulateTxAccessor contract version 1.4.1. */ -class SimulateTxAccessorContract_v1_4_1_Ethers - extends SimulateTxAccessorBaseContractEthers +class SimulateTxAccessorContract_v1_4_1 + extends SimulateTxAccessorBaseContract implements SimulateTxAccessorContract_v1_4_1_Contract { safeVersion: SafeVersion /** - * Constructs an instance of SimulateTxAccessorContract_v1_4_1_Ethers + * Constructs an instance of SimulateTxAccessorContract_v1_4_1 * * @param chainId - The chain ID where the contract resides. - * @param ethersAdapter - An instance of EthersAdapter. + * @param safeProvider - An instance of SafeProvider. * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the SimulateTxAccessor 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, - ethersAdapter: EthersAdapter, + safeProvider: SafeProvider, customContractAddress?: string, customContractAbi?: SimulateTxAccessorContract_v1_4_1_Abi ) { const safeVersion = '1.4.1' const defaultAbi = simulateTxAccessor_1_4_1_ContractArtifacts.abi - super(chainId, ethersAdapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) + super(chainId, safeProvider, defaultAbi, safeVersion, customContractAddress, customContractAbi) this.safeVersion = safeVersion } @@ -52,4 +52,4 @@ class SimulateTxAccessorContract_v1_4_1_Ethers } } -export default SimulateTxAccessorContract_v1_4_1_Ethers +export default SimulateTxAccessorContract_v1_4_1 diff --git a/packages/protocol-kit/src/adapters/ethers/utils/constants.ts b/packages/protocol-kit/src/contracts/constants.ts similarity index 100% rename from packages/protocol-kit/src/adapters/ethers/utils/constants.ts rename to packages/protocol-kit/src/contracts/constants.ts diff --git a/packages/protocol-kit/src/contracts/contractInstances.ts b/packages/protocol-kit/src/contracts/contractInstances.ts new file mode 100644 index 000000000..4021c9bfb --- /dev/null +++ b/packages/protocol-kit/src/contracts/contractInstances.ts @@ -0,0 +1,413 @@ +import { JsonFragment, AbstractSigner, Provider } from 'ethers' +import { + 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 from './CreateCall/v1.3.0/CreateCallContract_v1_3_0' +import CreateCallContract_v1_4_1 from './CreateCall/v1.4.1/CreateCallContract_v1_4_1' +import MultiSendContract_v1_1_1 from './MultiSend/v1.1.1/MultiSendContract_v1_1_1' +import MultiSendContract_v1_3_0 from './MultiSend/v1.3.0/MultiSendContract_v1_3_0' +import MultiSendContract_v1_4_1 from './MultiSend/v1.4.1/MultiSendContract_v1_4_1' +import MultiSendCallOnlyContract_v1_3_0 from './MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0' +import MultiSendCallOnlyContract_v1_4_1 from './MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1' +import SignMessageLibContract_v1_3_0 from './SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0' +import SignMessageLibContract_v1_4_1 from './SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1' +import SafeContract_v1_0_0 from './Safe/v1.0.0/SafeContract_v1_0_0' +import SafeContract_v1_1_1 from './Safe/v1.1.1/SafeContract_v1_1_1' +import SafeContract_v1_2_0 from './Safe/v1.2.0/SafeContract_v1_2_0' +import SafeContract_v1_3_0 from './Safe/v1.3.0/SafeContract_v1_3_0' +import SafeContract_v1_4_1 from './Safe/v1.4.1/SafeContract_v1_4_1' +import SafeProxyFactoryContract_v1_0_0 from './SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0' +import SafeProxyFactoryContract_v1_1_1 from './SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1' +import SafeProxyFactoryContract_v1_3_0 from './SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0' +import SafeProxyFactoryContract_v1_4_1 from './SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1' +import SimulateTxAccessorContract_v1_3_0 from './SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0' +import SimulateTxAccessorContract_v1_4_1 from './SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1' +import CompatibilityFallbackHandlerContract_v1_3_0 from './CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0' +import CompatibilityFallbackHandlerContract_v1_4_1 from './CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1' +import SafeProvider from '../SafeProvider' + +export async function getSafeContractInstance( + safeVersion: SafeVersion, + safeProvider: SafeProvider, + contractAddress?: string, + customContractAbi?: JsonFragment | JsonFragment[] | undefined, + isL1SafeSingleton?: boolean +): Promise< + | SafeContract_v1_4_1 + | SafeContract_v1_3_0 + | SafeContract_v1_2_0 + | SafeContract_v1_1_1 + | SafeContract_v1_0_0 +> { + const chainId = await safeProvider.getChainId() + let safeContractInstance + + switch (safeVersion) { + case '1.4.1': + safeContractInstance = new SafeContract_v1_4_1( + chainId, + safeProvider, + isL1SafeSingleton, + contractAddress, + customContractAbi as SafeContract_v1_4_1_Abi + ) + break + case '1.3.0': + safeContractInstance = new SafeContract_v1_3_0( + chainId, + safeProvider, + isL1SafeSingleton, + contractAddress, + customContractAbi as SafeContract_v1_3_0_Abi + ) + break + case '1.2.0': + safeContractInstance = new SafeContract_v1_2_0( + chainId, + safeProvider, + isL1SafeSingleton, + contractAddress, + customContractAbi as SafeContract_v1_2_0_Abi + ) + break + case '1.1.1': + safeContractInstance = new SafeContract_v1_1_1( + chainId, + safeProvider, + isL1SafeSingleton, + contractAddress, + customContractAbi as SafeContract_v1_1_1_Abi + ) + break + case '1.0.0': + safeContractInstance = new SafeContract_v1_0_0( + chainId, + safeProvider, + isL1SafeSingleton, + contractAddress, + customContractAbi as SafeContract_v1_0_0_Abi + ) + break + default: + throw new Error('Invalid Safe version') + } + + await safeContractInstance.init() + + return safeContractInstance +} + +export async function getCompatibilityFallbackHandlerContractInstance( + safeVersion: SafeVersion, + safeProvider: SafeProvider, + contractAddress?: string, + customContractAbi?: JsonFragment | JsonFragment[] | undefined +): Promise< + CompatibilityFallbackHandlerContract_v1_4_1 | CompatibilityFallbackHandlerContract_v1_3_0 +> { + const chainId = await safeProvider.getChainId() + let compatibilityFallbackHandlerInstance + + switch (safeVersion) { + case '1.4.1': + compatibilityFallbackHandlerInstance = new CompatibilityFallbackHandlerContract_v1_4_1( + chainId, + safeProvider, + contractAddress, + customContractAbi as CompatibilityFallbackHandlerContract_v1_4_1_Abi + ) + break + case '1.3.0': + case '1.2.0': + case '1.1.1': + compatibilityFallbackHandlerInstance = new CompatibilityFallbackHandlerContract_v1_3_0( + chainId, + safeProvider, + contractAddress, + customContractAbi as CompatibilityFallbackHandlerContract_v1_3_0_Abi + ) + break + default: + throw new Error('Invalid Safe version') + } + + await compatibilityFallbackHandlerInstance.init() + + return compatibilityFallbackHandlerInstance +} + +export async function getMultiSendContractInstance( + safeVersion: SafeVersion, + safeProvider: SafeProvider, + contractAddress?: string, + customContractAbi?: JsonFragment | JsonFragment[] | undefined +): Promise { + const chainId = await safeProvider.getChainId() + let multiSendContractInstance + + switch (safeVersion) { + case '1.4.1': + multiSendContractInstance = new MultiSendContract_v1_4_1( + chainId, + safeProvider, + contractAddress, + customContractAbi as MultiSendContract_v1_4_1_Abi + ) + break + case '1.3.0': + multiSendContractInstance = new MultiSendContract_v1_3_0( + chainId, + safeProvider, + contractAddress, + customContractAbi as MultiSendContract_v1_3_0_Abi + ) + break + case '1.2.0': + case '1.1.1': + case '1.0.0': + multiSendContractInstance = new MultiSendContract_v1_1_1( + chainId, + safeProvider, + contractAddress, + customContractAbi as MultiSendContract_v1_1_1_Abi + ) + break + default: + throw new Error('Invalid Safe version') + } + + await multiSendContractInstance.init() + + return multiSendContractInstance +} + +export async function getMultiSendCallOnlyContractInstance( + safeVersion: SafeVersion, + safeProvider: SafeProvider, + contractAddress?: string, + customContractAbi?: JsonFragment | JsonFragment[] | undefined +): Promise { + const chainId = await safeProvider.getChainId() + let multiSendCallOnlyContractInstance + + switch (safeVersion) { + case '1.4.1': + multiSendCallOnlyContractInstance = new MultiSendCallOnlyContract_v1_4_1( + chainId, + safeProvider, + contractAddress, + customContractAbi as MultiSendCallOnlyContract_v1_4_1_Abi + ) + break + case '1.3.0': + case '1.2.0': + case '1.1.1': + case '1.0.0': + multiSendCallOnlyContractInstance = new MultiSendCallOnlyContract_v1_3_0( + chainId, + safeProvider, + contractAddress, + customContractAbi as MultiSendCallOnlyContract_v1_3_0_Abi + ) + break + default: + throw new Error('Invalid Safe version') + } + + await multiSendCallOnlyContractInstance.init() + + return multiSendCallOnlyContractInstance +} + +export async function getSafeProxyFactoryContractInstance( + safeVersion: SafeVersion, + safeProvider: SafeProvider, + // TODO: remove this ?? + signerOrProvider: AbstractSigner | Provider, + contractAddress?: string, + customContractAbi?: JsonFragment | JsonFragment[] | undefined +): Promise< + | SafeProxyFactoryContract_v1_4_1 + | SafeProxyFactoryContract_v1_3_0 + | SafeProxyFactoryContract_v1_1_1 + | SafeProxyFactoryContract_v1_0_0 +> { + const chainId = await safeProvider.getChainId() + let safeProxyFactoryContractInstance + + switch (safeVersion) { + case '1.4.1': + safeProxyFactoryContractInstance = new SafeProxyFactoryContract_v1_4_1( + chainId, + safeProvider, + contractAddress, + customContractAbi as SafeProxyFactoryContract_v1_4_1_Abi, + signerOrProvider + ) + break + case '1.3.0': + safeProxyFactoryContractInstance = new SafeProxyFactoryContract_v1_3_0( + chainId, + safeProvider, + contractAddress, + customContractAbi as SafeProxyFactoryContract_v1_3_0_Abi, + signerOrProvider + ) + break + case '1.2.0': + case '1.1.1': + safeProxyFactoryContractInstance = new SafeProxyFactoryContract_v1_1_1( + chainId, + safeProvider, + contractAddress, + customContractAbi as SafeProxyFactoryContract_v1_1_1_Abi, + signerOrProvider + ) + break + case '1.0.0': + safeProxyFactoryContractInstance = new SafeProxyFactoryContract_v1_0_0( + chainId, + safeProvider, + contractAddress, + customContractAbi as SafeProxyFactoryContract_v1_0_0_Abi, + signerOrProvider + ) + break + default: + throw new Error('Invalid Safe version') + } + + await safeProxyFactoryContractInstance.init() + + return safeProxyFactoryContractInstance +} + +export async function getSignMessageLibContractInstance( + safeVersion: SafeVersion, + safeProvider: SafeProvider, + contractAddress?: string, + customContractAbi?: JsonFragment | JsonFragment[] | undefined +): Promise { + const chainId = await safeProvider.getChainId() + let signMessageLibContractInstance + + switch (safeVersion) { + case '1.4.1': + signMessageLibContractInstance = new SignMessageLibContract_v1_4_1( + chainId, + safeProvider, + contractAddress, + customContractAbi as SignMessageLibContract_v1_4_1_Abi + ) + break + case '1.3.0': + signMessageLibContractInstance = new SignMessageLibContract_v1_3_0( + chainId, + safeProvider, + contractAddress, + customContractAbi as SignMessageLibContract_v1_3_0_Abi + ) + break + default: + throw new Error('Invalid Safe version') + } + + await signMessageLibContractInstance.init() + + return signMessageLibContractInstance +} + +export async function getCreateCallContractInstance( + safeVersion: SafeVersion, + safeProvider: SafeProvider, + contractAddress?: string, + customContractAbi?: JsonFragment | JsonFragment[] | undefined +): Promise { + const chainId = await safeProvider.getChainId() + let createCallContractInstance + + switch (safeVersion) { + case '1.4.1': + createCallContractInstance = new CreateCallContract_v1_4_1( + chainId, + safeProvider, + contractAddress, + customContractAbi as CreateCallContract_v1_4_1_Abi + ) + break + case '1.3.0': + case '1.2.0': + case '1.1.1': + case '1.0.0': + createCallContractInstance = new CreateCallContract_v1_3_0( + chainId, + safeProvider, + contractAddress, + customContractAbi as CreateCallContract_v1_3_0_Abi + ) + break + default: + throw new Error('Invalid Safe version') + } + + await createCallContractInstance.init() + + return createCallContractInstance +} + +export async function getSimulateTxAccessorContractInstance( + safeVersion: SafeVersion, + safeProvider: SafeProvider, + contractAddress?: string, + customContractAbi?: JsonFragment | JsonFragment[] | undefined +): Promise { + const chainId = await safeProvider.getChainId() + let simulateTxAccessorContractInstance + + switch (safeVersion) { + case '1.4.1': + simulateTxAccessorContractInstance = new SimulateTxAccessorContract_v1_4_1( + chainId, + safeProvider, + contractAddress, + customContractAbi as SimulateTxAccessorContract_v1_4_1_Abi + ) + break + case '1.3.0': + simulateTxAccessorContractInstance = new SimulateTxAccessorContract_v1_3_0( + chainId, + safeProvider, + contractAddress, + customContractAbi as SimulateTxAccessorContract_v1_3_0_Abi + ) + break + default: + throw new Error('Invalid Safe version') + } + + await simulateTxAccessorContractInstance.init() + + return simulateTxAccessorContractInstance +} diff --git a/packages/protocol-kit/src/contracts/index.ts b/packages/protocol-kit/src/contracts/index.ts new file mode 100644 index 000000000..009c4b5a3 --- /dev/null +++ b/packages/protocol-kit/src/contracts/index.ts @@ -0,0 +1,15 @@ +import CreateCallBaseContract from './CreateCall/CreateCallBaseContract' +import MultiSendBaseContract from './MultiSend/MultiSendBaseContract' +import MultiSendCallOnlyBaseContract from './MultiSend/MultiSendCallOnlyBaseContract' +import SafeBaseContract from './Safe/SafeBaseContract' +import SafeProxyFactoryBaseContract from './SafeProxyFactory/SafeProxyFactoryBaseContract' +import SignMessageLibBaseContract from './SignMessageLib/SignMessageLibBaseContract' + +export { + CreateCallBaseContract, + MultiSendCallOnlyBaseContract, + MultiSendBaseContract, + SafeBaseContract, + SafeProxyFactoryBaseContract, + SignMessageLibBaseContract +} diff --git a/packages/protocol-kit/src/contracts/safeDeploymentContracts.ts b/packages/protocol-kit/src/contracts/safeDeploymentContracts.ts index 79e2284c5..cff605dca 100644 --- a/packages/protocol-kit/src/contracts/safeDeploymentContracts.ts +++ b/packages/protocol-kit/src/contracts/safeDeploymentContracts.ts @@ -1,3 +1,4 @@ +import SafeProvider from '../SafeProvider' import { CompatibilityFallbackHandlerContractImplementationType, ContractNetworkConfig, @@ -10,10 +11,9 @@ import { SimulateTxAccessorContractImplementationType } from '@safe-global/protocol-kit/types' import { SafeVersion } from '@safe-global/safe-core-sdk-types' -import { EthAdapter } from '@safe-global/protocol-kit/adapters/ethAdapter' export interface GetContractInstanceProps { - ethAdapter: EthAdapter + safeProvider: SafeProvider safeVersion: SafeVersion customContracts?: ContractNetworkConfig } @@ -24,19 +24,19 @@ export interface GetSafeContractInstanceProps extends GetContractInstanceProps { } export async function getSafeContract({ - ethAdapter, + safeProvider, safeVersion, customSafeAddress, isL1SafeSingleton, customContracts }: GetSafeContractInstanceProps): Promise { - const safeContract = await ethAdapter.getSafeContract({ + const safeContract = await safeProvider.getSafeContract({ safeVersion, customContractAddress: customSafeAddress ?? customContracts?.safeSingletonAddress, customContractAbi: customContracts?.safeSingletonAbi, isL1SafeSingleton }) - const isContractDeployed = await ethAdapter.isContractDeployed(await safeContract.getAddress()) + const isContractDeployed = await safeProvider.isContractDeployed(await safeContract.getAddress()) if (!isContractDeployed) { throw new Error('SafeProxy contract is not deployed on the current network') } @@ -44,16 +44,16 @@ export async function getSafeContract({ } export async function getProxyFactoryContract({ - ethAdapter, + safeProvider, safeVersion, customContracts }: GetContractInstanceProps): Promise { - const safeProxyFactoryContract = await ethAdapter.getSafeProxyFactoryContract({ + const safeProxyFactoryContract = await safeProvider.getSafeProxyFactoryContract({ safeVersion, customContractAddress: customContracts?.safeProxyFactoryAddress, customContractAbi: customContracts?.safeProxyFactoryAbi }) - const isContractDeployed = await ethAdapter.isContractDeployed( + const isContractDeployed = await safeProvider.isContractDeployed( await safeProxyFactoryContract.getAddress() ) if (!isContractDeployed) { @@ -63,16 +63,16 @@ export async function getProxyFactoryContract({ } export async function getCompatibilityFallbackHandlerContract({ - ethAdapter, + safeProvider, safeVersion, customContracts }: GetContractInstanceProps): Promise { - const fallbackHandlerContract = await ethAdapter.getCompatibilityFallbackHandlerContract({ + const fallbackHandlerContract = await safeProvider.getCompatibilityFallbackHandlerContract({ safeVersion, customContractAddress: customContracts?.fallbackHandlerAddress, customContractAbi: customContracts?.fallbackHandlerAbi }) - const isContractDeployed = await ethAdapter.isContractDeployed( + const isContractDeployed = await safeProvider.isContractDeployed( await fallbackHandlerContract.getAddress() ) if (!isContractDeployed) { @@ -82,16 +82,16 @@ export async function getCompatibilityFallbackHandlerContract({ } export async function getMultiSendContract({ - ethAdapter, + safeProvider, safeVersion, customContracts }: GetContractInstanceProps): Promise { - const multiSendContract = await ethAdapter.getMultiSendContract({ + const multiSendContract = await safeProvider.getMultiSendContract({ safeVersion, customContractAddress: customContracts?.multiSendAddress, customContractAbi: customContracts?.multiSendAbi }) - const isContractDeployed = await ethAdapter.isContractDeployed( + const isContractDeployed = await safeProvider.isContractDeployed( await multiSendContract.getAddress() ) if (!isContractDeployed) { @@ -101,16 +101,16 @@ export async function getMultiSendContract({ } export async function getMultiSendCallOnlyContract({ - ethAdapter, + safeProvider, safeVersion, customContracts }: GetContractInstanceProps): Promise { - const multiSendCallOnlyContract = await ethAdapter.getMultiSendCallOnlyContract({ + const multiSendCallOnlyContract = await safeProvider.getMultiSendCallOnlyContract({ safeVersion, customContractAddress: customContracts?.multiSendCallOnlyAddress, customContractAbi: customContracts?.multiSendCallOnlyAbi }) - const isContractDeployed = await ethAdapter.isContractDeployed( + const isContractDeployed = await safeProvider.isContractDeployed( await multiSendCallOnlyContract.getAddress() ) if (!isContractDeployed) { @@ -120,16 +120,16 @@ export async function getMultiSendCallOnlyContract({ } export async function getSignMessageLibContract({ - ethAdapter, + safeProvider, safeVersion, customContracts }: GetContractInstanceProps): Promise { - const signMessageLibContract = await ethAdapter.getSignMessageLibContract({ + const signMessageLibContract = await safeProvider.getSignMessageLibContract({ safeVersion, customContractAddress: customContracts?.signMessageLibAddress, customContractAbi: customContracts?.signMessageLibAbi }) - const isContractDeployed = await ethAdapter.isContractDeployed( + const isContractDeployed = await safeProvider.isContractDeployed( await signMessageLibContract.getAddress() ) if (!isContractDeployed) { @@ -139,16 +139,16 @@ export async function getSignMessageLibContract({ } export async function getCreateCallContract({ - ethAdapter, + safeProvider, safeVersion, customContracts }: GetContractInstanceProps): Promise { - const createCallContract = await ethAdapter.getCreateCallContract({ + const createCallContract = await safeProvider.getCreateCallContract({ safeVersion, customContractAddress: customContracts?.createCallAddress, customContractAbi: customContracts?.createCallAbi }) - const isContractDeployed = await ethAdapter.isContractDeployed( + const isContractDeployed = await safeProvider.isContractDeployed( await createCallContract.getAddress() ) if (!isContractDeployed) { @@ -158,16 +158,16 @@ export async function getCreateCallContract({ } export async function getSimulateTxAccessorContract({ - ethAdapter, + safeProvider, safeVersion, customContracts }: GetContractInstanceProps): Promise { - const simulateTxAccessorContract = await ethAdapter.getSimulateTxAccessorContract({ + const simulateTxAccessorContract = await safeProvider.getSimulateTxAccessorContract({ safeVersion, customContractAddress: customContracts?.simulateTxAccessorAddress, customContractAbi: customContracts?.simulateTxAccessorAbi }) - const isContractDeployed = await ethAdapter.isContractDeployed( + const isContractDeployed = await safeProvider.isContractDeployed( await simulateTxAccessorContract.getAddress() ) if (!isContractDeployed) { diff --git a/packages/protocol-kit/src/contracts/utils.ts b/packages/protocol-kit/src/contracts/utils.ts index e5c9a2c75..fd3a16a15 100644 --- a/packages/protocol-kit/src/contracts/utils.ts +++ b/packages/protocol-kit/src/contracts/utils.ts @@ -1,10 +1,20 @@ -import { isAddress, zeroPadValue } from 'ethers' +import { + ContractTransactionResponse, + Provider, + AbstractSigner, + isAddress, + zeroPadValue +} from 'ethers' import { keccak_256 } from '@noble/hashes/sha3' import { DEFAULT_SAFE_VERSION } from '@safe-global/protocol-kit/contracts/config' import { EMPTY_DATA, ZERO_ADDRESS } from '@safe-global/protocol-kit/utils/constants' import { createMemoizedFunction } from '@safe-global/protocol-kit/utils/memoized' -import { EthAdapter } from '@safe-global/protocol-kit/adapters/ethAdapter' -import { SafeProxyFactoryContractType, SafeVersion } from '@safe-global/safe-core-sdk-types' +import { + SafeProxyFactoryContractType, + SafeVersion, + TransactionOptions, + TransactionResult +} from '@safe-global/safe-core-sdk-types' import { generateAddress2, keccak256, toBuffer } from 'ethereumjs-util' import semverSatisfies from 'semver/functions/satisfies' @@ -21,6 +31,7 @@ import { SafeContractImplementationType, SafeDeploymentConfig } from '../types' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' // keccak256(toUtf8Bytes('Safe Account Abstraction')) export const PREDETERMINED_SALT_NONCE = @@ -48,7 +59,7 @@ const ZKSYNC_SAFE_PROXY_DEPLOYED_BYTECODE: { const ZKSYNC_CREATE2_PREFIX = '0x2020dba91b30cc0006188af794c2fb30dd8520db7e2c088b7fc7c103c00ca494' export interface PredictSafeAddressProps { - ethAdapter: EthAdapter + safeProvider: SafeProvider chainId: bigint // required for performance safeAccountConfig: SafeAccountConfig safeDeploymentConfig?: SafeDeploymentConfig @@ -57,7 +68,7 @@ export interface PredictSafeAddressProps { } export interface encodeSetupCallDataProps { - ethAdapter: EthAdapter + safeProvider: SafeProvider safeAccountConfig: SafeAccountConfig safeContract: SafeContractImplementationType customContracts?: ContractNetworkConfig @@ -82,7 +93,7 @@ const memoizedGetCompatibilityFallbackHandlerContract = createMemoizedFunction( ) export async function encodeSetupCallData({ - ethAdapter, + safeProvider, safeAccountConfig, safeContract, customContracts, @@ -117,7 +128,7 @@ export async function encodeSetupCallData({ const isValidAddress = fallbackHandlerAddress !== undefined && isAddress(fallbackHandlerAddress) if (!isValidAddress) { const fallbackHandlerContract = await memoizedGetCompatibilityFallbackHandlerContract({ - ethAdapter, + safeProvider, safeVersion, customContracts }) @@ -142,19 +153,19 @@ type MemoizedGetProxyFactoryContractProps = GetContractInstanceProps & { chainId type MemoizedGetSafeContractInstanceProps = GetSafeContractInstanceProps & { chainId: string } const memoizedGetProxyFactoryContract = createMemoizedFunction( - ({ ethAdapter, safeVersion, customContracts }: MemoizedGetProxyFactoryContractProps) => - getProxyFactoryContract({ ethAdapter, safeVersion, customContracts }) + ({ safeProvider, safeVersion, customContracts }: MemoizedGetProxyFactoryContractProps) => + getProxyFactoryContract({ safeProvider, safeVersion, customContracts }) ) const memoizedGetProxyCreationCode = createMemoizedFunction( async ({ - ethAdapter, + safeProvider, safeVersion, customContracts, chainId }: MemoizedGetProxyFactoryContractProps) => { const safeProxyFactoryContract = await memoizedGetProxyFactoryContract({ - ethAdapter, + safeProvider, safeVersion, customContracts, chainId @@ -166,12 +177,12 @@ const memoizedGetProxyCreationCode = createMemoizedFunction( const memoizedGetSafeContract = createMemoizedFunction( ({ - ethAdapter, + safeProvider, safeVersion, isL1SafeSingleton, customContracts }: MemoizedGetSafeContractInstanceProps) => - getSafeContract({ ethAdapter, safeVersion, isL1SafeSingleton, customContracts }) + getSafeContract({ safeProvider, safeVersion, isL1SafeSingleton, customContracts }) ) /** @@ -186,7 +197,7 @@ export function getChainSpecificDefaultSaltNonce(chainId: bigint): string { } export async function getPredictedSafeAddressInitCode({ - ethAdapter, + safeProvider, chainId, safeAccountConfig, safeDeploymentConfig = {}, @@ -202,14 +213,14 @@ export async function getPredictedSafeAddressInitCode({ } = safeDeploymentConfig const safeProxyFactoryContract = await memoizedGetProxyFactoryContract({ - ethAdapter, + safeProvider, safeVersion, customContracts, chainId: chainId.toString() }) const safeContract = await memoizedGetSafeContract({ - ethAdapter, + safeProvider, safeVersion, isL1SafeSingleton, customContracts, @@ -217,14 +228,14 @@ export async function getPredictedSafeAddressInitCode({ }) const initializer = await encodeSetupCallData({ - ethAdapter, + safeProvider, safeAccountConfig, safeContract, customContracts, customSafeVersion: safeVersion // it is more efficient if we provide the safeVersion manually }) - const encodedNonce = toBuffer(ethAdapter.encodeParameters(['uint256'], [saltNonce])).toString( + const encodedNonce = toBuffer(safeProvider.encodeParameters(['uint256'], [saltNonce])).toString( 'hex' ) const safeSingletonAddress = await safeContract.getAddress() @@ -244,7 +255,7 @@ export async function getPredictedSafeAddressInitCode({ } export async function predictSafeAddress({ - ethAdapter, + safeProvider, chainId, safeAccountConfig, safeDeploymentConfig = {}, @@ -260,21 +271,21 @@ export async function predictSafeAddress({ } = safeDeploymentConfig const safeProxyFactoryContract = await memoizedGetProxyFactoryContract({ - ethAdapter, + safeProvider, safeVersion, customContracts, chainId: chainId.toString() }) const proxyCreationCode = await memoizedGetProxyCreationCode({ - ethAdapter, + safeProvider, safeVersion, customContracts, chainId: chainId.toString() }) const safeContract = await memoizedGetSafeContract({ - ethAdapter, + safeProvider, safeVersion, isL1SafeSingleton, customContracts, @@ -282,20 +293,22 @@ export async function predictSafeAddress({ }) const initializer = await encodeSetupCallData({ - ethAdapter, + safeProvider, safeAccountConfig, safeContract, customContracts, customSafeVersion: safeVersion // it is more efficient if we provide the safeVersion manually }) - const encodedNonce = toBuffer(ethAdapter.encodeParameters(['uint256'], [saltNonce])).toString( + const encodedNonce = toBuffer(safeProvider.encodeParameters(['uint256'], [saltNonce])).toString( 'hex' ) const salt = keccak256( toBuffer('0x' + keccak256(toBuffer(initializer)).toString('hex') + encodedNonce) ) - const input = ethAdapter.encodeParameters(['address'], [await safeContract.getAddress()]) + + const input = safeProvider.encodeParameters(['address'], [await safeContract.getAddress()]) + const from = await safeProxyFactoryContract.getAddress() // On the zkSync Era chain, the counterfactual deployment address is calculated differently @@ -303,16 +316,15 @@ export async function predictSafeAddress({ if (isZkSyncEraChain) { const proxyAddress = zkSyncEraCreate2Address(from, safeVersion, salt, input) - return ethAdapter.getChecksummedAddress(proxyAddress) + return safeProvider.getChecksummedAddress(proxyAddress) } const constructorData = toBuffer(input).toString('hex') const initCode = proxyCreationCode + constructorData const proxyAddress = '0x' + generateAddress2(toBuffer(from), toBuffer(salt), toBuffer(initCode)).toString('hex') - const predictedAddress = ethAdapter.getChecksummedAddress(proxyAddress) - return predictedAddress + return safeProvider.getChecksummedAddress(proxyAddress) } export const validateSafeAccountConfig = ({ owners, threshold }: SafeAccountConfig): void => { @@ -361,3 +373,37 @@ export function zkSyncEraCreate2Address( return addressBytes } + +export function sameString(str1: string, str2: string): boolean { + return str1.toLowerCase() === str2.toLowerCase() +} + +export function toTxResult( + transactionResponse: ContractTransactionResponse, + options?: TransactionOptions +): TransactionResult { + 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/index.ts b/packages/protocol-kit/src/index.ts index 3be9e0734..55f076393 100644 --- a/packages/protocol-kit/src/index.ts +++ b/packages/protocol-kit/src/index.ts @@ -1,24 +1,13 @@ import Safe from './Safe' +import SafeProvider from './SafeProvider' import { - CreateCallBaseContractEthers, - EthersAdapter, - EthersAdapterConfig, - MultiSendBaseContractEthers, - MultiSendCallOnlyBaseContractEthers, - SafeBaseContractEthers, - SafeProxyFactoryBaseContractEthers, - SignMessageLibBaseContractEthers -} from './adapters/ethers' -import { - CreateCallBaseContractWeb3, - MultiSendBaseContractWeb3, - MultiSendCallOnlyBaseContractWeb3, - SafeBaseContractWeb3, - SafeProxyFactoryBaseContractWeb3, - SignMessageLibBaseContractWeb3, - Web3Adapter, - Web3AdapterConfig -} from './adapters/web3' + CreateCallBaseContract, + MultiSendBaseContract, + MultiSendCallOnlyBaseContract, + SafeBaseContract, + SafeProxyFactoryBaseContract, + SignMessageLibBaseContract +} from './contracts' import { DEFAULT_SAFE_VERSION } from './contracts/config' import { getCompatibilityFallbackHandlerContract, @@ -37,25 +26,7 @@ import { getPredictedSafeAddressInitCode } from './contracts/utils' import ContractManager from './managers/contractManager' -import SafeFactory, { DeploySafeProps, SafeFactoryConfig } from './safeFactory' -import { - AddOwnerTxParams, - ConnectSafeConfig, - ConnectSafeConfigWithPredictedSafe, - ConnectSafeConfigWithSafeAddress, - ContractNetworksConfig, - CreateTransactionProps, - PredictedSafeProps, - RemoveOwnerTxParams, - SafeAccountConfig, - SafeConfig, - SafeConfigWithPredictedSafe, - SafeConfigWithSafeAddress, - SafeDeploymentConfig, - StandardizeSafeTransactionDataProps, - SwapOwnerTxParams, - SigningMethod -} from './types' +import SafeFactory from './SafeFactory' import { EthSafeSignature, estimateTxBaseGas, @@ -88,55 +59,25 @@ import { hashSafeMessage, generateTypedData } from './utils/eip-712' -import { EthAdapter } from './adapters/ethAdapter' export { - AddOwnerTxParams, estimateTxBaseGas, estimateTxGas, estimateSafeTxGas, estimateSafeDeploymentGas, - ConnectSafeConfig, - ConnectSafeConfigWithPredictedSafe, - ConnectSafeConfigWithSafeAddress, ContractManager, - ContractNetworksConfig, - CreateCallBaseContractEthers, - CreateCallBaseContractWeb3, + CreateCallBaseContract, createERC20TokenTransferTransaction, - CreateTransactionProps, DEFAULT_SAFE_VERSION, - DeploySafeProps, - EthAdapter, EthSafeSignature, - EthersAdapter, - EthersAdapterConfig, - MultiSendCallOnlyBaseContractEthers, - MultiSendCallOnlyBaseContractWeb3, - MultiSendBaseContractEthers, - MultiSendBaseContractWeb3, + MultiSendCallOnlyBaseContract, + MultiSendBaseContract, PREDETERMINED_SALT_NONCE, - PredictedSafeProps, - RemoveOwnerTxParams, - SafeAccountConfig, - SafeConfig, - SafeConfigWithPredictedSafe, - SafeConfigWithSafeAddress, - SafeBaseContractEthers, - SafeBaseContractWeb3, - SafeDeploymentConfig, + SafeBaseContract, SafeFactory, - SafeFactoryConfig, - SafeProxyFactoryBaseContractEthers, - SafeProxyFactoryBaseContractWeb3, + SafeProxyFactoryBaseContract, SafeTransactionOptionalProps, - SignMessageLibBaseContractEthers, - SignMessageLibBaseContractWeb3, - StandardizeSafeTransactionDataProps, - SwapOwnerTxParams, - SigningMethod, - Web3Adapter, - Web3AdapterConfig, + SignMessageLibBaseContract, encodeCreateProxyWithNonce, encodeMultiSendData, encodeSetupCallData, @@ -163,7 +104,10 @@ export { getEip712TxTypes, getEip712MessageTypes, hashSafeMessage, - generateTypedData + generateTypedData, + SafeProvider } +export * from './types' + export default Safe diff --git a/packages/protocol-kit/src/managers/contractManager.ts b/packages/protocol-kit/src/managers/contractManager.ts index 3e186189e..26388e07b 100644 --- a/packages/protocol-kit/src/managers/contractManager.ts +++ b/packages/protocol-kit/src/managers/contractManager.ts @@ -13,6 +13,7 @@ import { } from '@safe-global/protocol-kit/types' import { SafeVersion } from '@safe-global/safe-core-sdk-types' import { isSafeConfigWithPredictedSafe } from '../utils/types' +import SafeProvider from '../SafeProvider' class ContractManager { #contractNetworks?: ContractNetworksConfig @@ -21,16 +22,16 @@ class ContractManager { #multiSendContract!: MultiSendContractImplementationType #multiSendCallOnlyContract!: MultiSendCallOnlyContractImplementationType - static async create(config: SafeConfig): Promise { + static async create(config: SafeConfig, safeProvider: SafeProvider): Promise { const contractManager = new ContractManager() - await contractManager.init(config) + await contractManager.init(config, safeProvider) return contractManager } - async init(config: SafeConfig): Promise { - const { ethAdapter, isL1SafeSingleton, contractNetworks, predictedSafe, safeAddress } = config + async init(config: SafeConfig, safeProvider: SafeProvider): Promise { + const { isL1SafeSingleton, contractNetworks, predictedSafe, safeAddress } = config - const chainId = await ethAdapter.getChainId() + const chainId = await safeProvider.getChainId() const customContracts = contractNetworks?.[chainId.toString()] this.#contractNetworks = contractNetworks this.#isL1SafeSingleton = isL1SafeSingleton @@ -42,7 +43,7 @@ class ContractManager { } else { // We use the default version of the Safe contract to get the correct version of this Safe const defaultSafeContractInstance = await getSafeContract({ - ethAdapter, + safeProvider, safeVersion: DEFAULT_SAFE_VERSION, isL1SafeSingleton, customSafeAddress: safeAddress, @@ -58,7 +59,7 @@ class ContractManager { this.#safeContract = isTheDefaultSafeVersion ? defaultSafeContractInstance : await getSafeContract({ - ethAdapter, + safeProvider, safeVersion, isL1SafeSingleton, customSafeAddress: safeAddress, @@ -67,13 +68,13 @@ class ContractManager { } this.#multiSendContract = await getMultiSendContract({ - ethAdapter, + safeProvider, safeVersion, customContracts }) this.#multiSendCallOnlyContract = await getMultiSendCallOnlyContract({ - ethAdapter, + safeProvider, safeVersion, customContracts }) diff --git a/packages/protocol-kit/src/managers/fallbackHandlerManager.ts b/packages/protocol-kit/src/managers/fallbackHandlerManager.ts index 098d96a4b..088581747 100644 --- a/packages/protocol-kit/src/managers/fallbackHandlerManager.ts +++ b/packages/protocol-kit/src/managers/fallbackHandlerManager.ts @@ -6,22 +6,22 @@ import { sameString } from '@safe-global/protocol-kit/utils' import { ZERO_ADDRESS } from '@safe-global/protocol-kit/utils/constants' -import { EthAdapter } from '@safe-global/protocol-kit/adapters/ethAdapter' import { SafeContractImplementationType } from '@safe-global/protocol-kit/types' +import SafeProvider from '../SafeProvider' class FallbackHandlerManager { - #ethAdapter: EthAdapter + #safeProvider: SafeProvider #safeContract?: SafeContractImplementationType // keccak256("fallback_manager.handler.address") #slot = '0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5' - constructor(ethAdapter: EthAdapter, safeContract?: SafeContractImplementationType) { - this.#ethAdapter = ethAdapter + constructor(safeProvider: SafeProvider, safeContract?: SafeContractImplementationType) { + this.#safeProvider = safeProvider this.#safeContract = safeContract } private validateFallbackHandlerAddress(fallbackHandlerAddress: string): void { - const isValidAddress = this.#ethAdapter.isAddress(fallbackHandlerAddress) + const isValidAddress = this.#safeProvider.isAddress(fallbackHandlerAddress) if (!isValidAddress || isZeroAddress(fallbackHandlerAddress)) { throw new Error('Invalid fallback handler address provided') } @@ -59,7 +59,7 @@ class FallbackHandlerManager { async getFallbackHandler(): Promise { const safeContract = await this.isFallbackHandlerCompatible() - return this.#ethAdapter.getStorageAt(await safeContract.getAddress(), this.#slot) + return this.#safeProvider.getStorageAt(await safeContract.getAddress(), this.#slot) } async encodeEnableFallbackHandlerData(fallbackHandlerAddress: string): Promise { @@ -69,7 +69,6 @@ class FallbackHandlerManager { const currentFallbackHandler = await this.getFallbackHandler() this.validateFallbackHandlerIsNotEnabled(currentFallbackHandler, fallbackHandlerAddress) - // @ts-expect-error Expression produces a union type that is too complex to represent return safeContract.encode('setFallbackHandler', [fallbackHandlerAddress]) } diff --git a/packages/protocol-kit/src/managers/guardManager.ts b/packages/protocol-kit/src/managers/guardManager.ts index 53cf08f31..9f82e96ac 100644 --- a/packages/protocol-kit/src/managers/guardManager.ts +++ b/packages/protocol-kit/src/managers/guardManager.ts @@ -6,22 +6,22 @@ import { sameString } from '@safe-global/protocol-kit/utils' import { ZERO_ADDRESS } from '@safe-global/protocol-kit/utils/constants' -import { EthAdapter } from '@safe-global/protocol-kit/adapters/ethAdapter' import { SafeContractImplementationType } from '@safe-global/protocol-kit/types' +import SafeProvider from '../SafeProvider' class GuardManager { - #ethAdapter: EthAdapter + #safeProvider: SafeProvider #safeContract?: SafeContractImplementationType // keccak256("guard_manager.guard.address") #slot = '0x4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c8' - constructor(ethAdapter: EthAdapter, safeContract?: SafeContractImplementationType) { - this.#ethAdapter = ethAdapter + constructor(safeProvider: SafeProvider, safeContract?: SafeContractImplementationType) { + this.#safeProvider = safeProvider this.#safeContract = safeContract } private validateGuardAddress(guardAddress: string): void { - const isValidAddress = this.#ethAdapter.isAddress(guardAddress) + const isValidAddress = this.#safeProvider.isAddress(guardAddress) if (!isValidAddress || isZeroAddress(guardAddress)) { throw new Error('Invalid guard address provided') } @@ -56,7 +56,7 @@ class GuardManager { async getGuard(): Promise { const safeContract = await this.isGuardCompatible() - return this.#ethAdapter.getStorageAt(await safeContract.getAddress(), this.#slot) + return this.#safeProvider.getStorageAt(await safeContract.getAddress(), this.#slot) } async encodeEnableGuardData(guardAddress: string): Promise { diff --git a/packages/protocol-kit/src/managers/moduleManager.ts b/packages/protocol-kit/src/managers/moduleManager.ts index 7d420b5a6..0e91160d7 100644 --- a/packages/protocol-kit/src/managers/moduleManager.ts +++ b/packages/protocol-kit/src/managers/moduleManager.ts @@ -1,19 +1,22 @@ import { isRestrictedAddress, sameString } from '@safe-global/protocol-kit/utils/address' import { SENTINEL_ADDRESS } from '@safe-global/protocol-kit/utils/constants' -import { EthAdapter } from '@safe-global/protocol-kit/adapters/ethAdapter' -import { SafeContractImplementationType } from '@safe-global/protocol-kit/types' +import { + SafeContractImplementationType, + SafeModulesPaginated +} from '@safe-global/protocol-kit/types' +import SafeProvider from '../SafeProvider' class ModuleManager { - #ethAdapter: EthAdapter + #safeProvider: SafeProvider #safeContract?: SafeContractImplementationType - constructor(ethAdapter: EthAdapter, safeContract?: SafeContractImplementationType) { - this.#ethAdapter = ethAdapter + constructor(safeProvider: SafeProvider, safeContract?: SafeContractImplementationType) { + this.#safeProvider = safeProvider this.#safeContract = safeContract } private validateModuleAddress(moduleAddress: string): void { - const isValidAddress = this.#ethAdapter.isAddress(moduleAddress) + const isValidAddress = this.#safeProvider.isAddress(moduleAddress) if (!isValidAddress || isRestrictedAddress(moduleAddress)) { throw new Error('Invalid module address provided') } @@ -46,17 +49,13 @@ class ModuleManager { return [...modules] } - //TODO: Implement getModulesPaginated in the new code - async getModulesPaginated(start: string, pageSize: number): Promise { - console.log('getModulesPaginated', start, pageSize) - return [] - // if (!this.#safeContract) { - // throw new Error('Safe is not deployed') - // } - - // const [modules] = await this.#safeContract.getModulesPaginated(start, pageSize) + async getModulesPaginated(start: string, pageSize: number): Promise { + if (!this.#safeContract) { + throw new Error('Safe is not deployed') + } - // return [...modules] + const [modules, next] = await this.#safeContract.getModulesPaginated([start, BigInt(pageSize)]) + return { modules: modules as string[], next } } async isModuleEnabled(moduleAddress: string): Promise { diff --git a/packages/protocol-kit/src/managers/ownerManager.ts b/packages/protocol-kit/src/managers/ownerManager.ts index c59898f68..4b40270d2 100644 --- a/packages/protocol-kit/src/managers/ownerManager.ts +++ b/packages/protocol-kit/src/managers/ownerManager.ts @@ -1,19 +1,19 @@ import { isRestrictedAddress, sameString } from '@safe-global/protocol-kit/utils/address' import { SENTINEL_ADDRESS } from '@safe-global/protocol-kit/utils/constants' -import { EthAdapter } from '@safe-global/protocol-kit/adapters/ethAdapter' import { SafeContractImplementationType } from '../types' +import SafeProvider from '../SafeProvider' class OwnerManager { - #ethAdapter: EthAdapter + #safeProvider: SafeProvider #safeContract?: SafeContractImplementationType - constructor(ethAdapter: EthAdapter, safeContract?: SafeContractImplementationType) { - this.#ethAdapter = ethAdapter + constructor(safeProvider: SafeProvider, safeContract?: SafeContractImplementationType) { + this.#safeProvider = safeProvider this.#safeContract = safeContract } private validateOwnerAddress(ownerAddress: string, errorMessage?: string): void { - const isValidAddress = this.#ethAdapter.isAddress(ownerAddress) + const isValidAddress = this.#safeProvider.isAddress(ownerAddress) if (!isValidAddress || isRestrictedAddress(ownerAddress)) { throw new Error(errorMessage || 'Invalid owner address provided') } diff --git a/packages/protocol-kit/src/types/contracts.ts b/packages/protocol-kit/src/types/contracts.ts new file mode 100644 index 000000000..612f3fd28 --- /dev/null +++ b/packages/protocol-kit/src/types/contracts.ts @@ -0,0 +1,118 @@ +import { JsonFragment } from 'ethers' +import { SafeVersion } from '@safe-global/safe-core-sdk-types' + +import SafeContract_v1_0_0 from '@safe-global/protocol-kit/contracts/Safe/v1.0.0/SafeContract_v1_0_0' +import SafeContract_v1_1_1 from '@safe-global/protocol-kit/contracts/Safe/v1.1.1/SafeContract_v1_1_1' +import SafeContract_v1_2_0 from '@safe-global/protocol-kit/contracts/Safe/v1.2.0/SafeContract_v1_2_0' +import SafeContract_v1_3_0 from '@safe-global/protocol-kit/contracts/Safe/v1.3.0/SafeContract_v1_3_0' +import SafeContract_v1_4_1 from '@safe-global/protocol-kit/contracts/Safe/v1.4.1/SafeContract_v1_4_1' +import MultiSendContract_v1_1_1 from '@safe-global/protocol-kit/contracts/MultiSend/v1.1.1/MultiSendContract_v1_1_1' +import MultiSendContract_v1_3_0 from '@safe-global/protocol-kit/contracts/MultiSend/v1.3.0/MultiSendContract_v1_3_0' +import MultiSendContract_v1_4_1 from '@safe-global/protocol-kit/contracts/MultiSend/v1.4.1/MultiSendContract_v1_4_1' +import MultiSendCallOnlyContract_v1_4_1 from '@safe-global/protocol-kit/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1' +import MultiSendCallOnlyContract_v1_3_0 from '@safe-global/protocol-kit/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0' +import CompatibilityFallbackHandlerContract_v1_3_0 from '@safe-global/protocol-kit/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0' +import CompatibilityFallbackHandlerContract_v1_4_1 from '@safe-global/protocol-kit/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1' +import SafeProxyFactoryContract_v1_0_0 from '@safe-global/protocol-kit/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0' +import SafeProxyFactoryContract_v1_1_1 from '@safe-global/protocol-kit/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1' +import SafeProxyFactoryContract_v1_3_0 from '@safe-global/protocol-kit/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0' +import SafeProxyFactoryContract_v1_4_1 from '@safe-global/protocol-kit/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1' +import SignMessageLibContract_v1_3_0 from '@safe-global/protocol-kit/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0' +import SignMessageLibContract_v1_4_1 from '@safe-global/protocol-kit/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1' +import SimulateTxAccessorContract_v1_3_0 from '@safe-global/protocol-kit/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0' +import SimulateTxAccessorContract_v1_4_1 from '@safe-global/protocol-kit/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1' +import CreateCallContract_v1_3_0 from '@safe-global/protocol-kit/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0' +import CreateCallContract_v1_4_1 from '@safe-global/protocol-kit/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1' + +// Safe contract implementation types +export type SafeContractImplementationType = + | SafeContract_v1_0_0 + | SafeContract_v1_1_1 + | SafeContract_v1_2_0 + | SafeContract_v1_3_0 + | SafeContract_v1_4_1 + +// MultiSend contract implementation types +export type MultiSendContractImplementationType = + | MultiSendContract_v1_1_1 + | MultiSendContract_v1_3_0 + | MultiSendContract_v1_4_1 + +// MultiSendCallOnly contract implementation types +export type MultiSendCallOnlyContractImplementationType = + | MultiSendCallOnlyContract_v1_3_0 + | MultiSendCallOnlyContract_v1_4_1 + +// CompatibilityFallbackHandler contract implementation types +export type CompatibilityFallbackHandlerContractImplementationType = + | CompatibilityFallbackHandlerContract_v1_3_0 + | CompatibilityFallbackHandlerContract_v1_4_1 + +// SafeProxyFactory contract implementation types +export type SafeProxyFactoryContractImplementationType = + | SafeProxyFactoryContract_v1_0_0 + | SafeProxyFactoryContract_v1_1_1 + | SafeProxyFactoryContract_v1_3_0 + | SafeProxyFactoryContract_v1_4_1 + +// SignMessageLib contract implementation types +export type SignMessageLibContractImplementationType = + | SignMessageLibContract_v1_3_0 + | SignMessageLibContract_v1_4_1 + +// SimulateTxAccessor contract implementation types +export type SimulateTxAccessorContractImplementationType = + | SimulateTxAccessorContract_v1_3_0 + | SimulateTxAccessorContract_v1_4_1 + +// CreateCall contract implementation types +export type CreateCallContractImplementationType = + | CreateCallContract_v1_3_0 + | CreateCallContract_v1_4_1 + +export type GetContractProps = { + safeVersion: SafeVersion + customContractAddress?: string + customContractAbi?: JsonFragment | JsonFragment[] + isL1SafeSingleton?: boolean +} + +export type ContractNetworkConfig = { + /** safeSingletonAddress - Address of the Safe Singleton contract deployed on a specific network */ + safeSingletonAddress: string + /** safeSingletonAbi - Abi of the Safe Singleton contract deployed on a specific network */ + safeSingletonAbi?: JsonFragment | JsonFragment[] + /** safeProxyFactoryAddress - Address of the SafeProxyFactory contract deployed on a specific network */ + safeProxyFactoryAddress: string + /** safeProxyFactoryAbi - Abi of the SafeProxyFactory contract deployed on a specific network */ + safeProxyFactoryAbi?: JsonFragment | JsonFragment[] + /** multiSendAddress - Address of the MultiSend contract deployed on a specific network */ + multiSendAddress: string + /** multiSendAbi - Abi of the MultiSend contract deployed on a specific network */ + multiSendAbi?: JsonFragment | JsonFragment[] + /** multiSendCallOnlyAddress - Address of the MultiSendCallOnly contract deployed on a specific network */ + multiSendCallOnlyAddress: string + /** multiSendCallOnlyAbi - Abi of the MultiSendCallOnly contract deployed on a specific network */ + multiSendCallOnlyAbi?: JsonFragment | JsonFragment[] + /** fallbackHandlerAddress - Address of the Fallback Handler contract deployed on a specific network */ + fallbackHandlerAddress: string + /** fallbackHandlerAbi - Abi of the Fallback Handler contract deployed on a specific network */ + fallbackHandlerAbi?: JsonFragment | JsonFragment[] + /** signMessageLibAddress - Address of the SignMessageLib contract deployed on a specific network */ + signMessageLibAddress: string + /** signMessageLibAbi - Abi of the SignMessageLib contract deployed on a specific network */ + signMessageLibAbi?: JsonFragment | JsonFragment[] + /** createCallAddress - Address of the CreateCall contract deployed on a specific network */ + createCallAddress: string + /** createCallAbi - Abi of the CreateCall contract deployed on a specific network */ + createCallAbi?: JsonFragment | JsonFragment[] + /** simulateTxAccessorAddress - Address of the SimulateTxAccessor contract deployed on a specific network */ + simulateTxAccessorAddress: string + /** simulateTxAccessorAbi - Abi of the SimulateTxAccessor contract deployed on a specific network */ + simulateTxAccessorAbi?: JsonFragment | JsonFragment[] +} + +export type ContractNetworksConfig = { + /** id - Network id */ + [id: string]: ContractNetworkConfig +} diff --git a/packages/protocol-kit/src/types/index.ts b/packages/protocol-kit/src/types/index.ts index 71cac78fc..6fd85f361 100644 --- a/packages/protocol-kit/src/types/index.ts +++ b/packages/protocol-kit/src/types/index.ts @@ -1,384 +1,6 @@ -import { SafeTransactionOptionalProps } from '@safe-global/protocol-kit/utils/transactions' -import { EthAdapter } from '@safe-global/protocol-kit/adapters/ethAdapter' -import { - MetaTransactionData, - SafeTransactionDataPartial, - SafeVersion -} from '@safe-global/safe-core-sdk-types' -import { AbiItem } from 'web3-utils' -import SafeContract_v1_0_0_Ethers from '@safe-global/protocol-kit/adapters/ethers/contracts/Safe/v1.0.0/SafeContract_v1_0_0_Ethers' -import SafeContract_v1_1_1_Ethers from '@safe-global/protocol-kit/adapters/ethers/contracts/Safe/v1.1.1/SafeContract_v1_1_1_Ethers' -import SafeContract_v1_2_0_Ethers from '@safe-global/protocol-kit/adapters/ethers/contracts/Safe/v1.2.0/SafeContract_v1_2_0_Ethers' -import SafeContract_v1_3_0_Ethers from '@safe-global/protocol-kit/adapters/ethers/contracts/Safe/v1.3.0/SafeContract_v1_3_0_Ethers' -import SafeContract_v1_4_1_Ethers from '@safe-global/protocol-kit/adapters/ethers/contracts/Safe/v1.4.1/SafeContract_v1_4_1_Ethers' -import SafeContract_v1_0_0_Web3 from '@safe-global/protocol-kit/adapters/web3/contracts/Safe/v1.0.0/SafeContract_v1_0_0_Web3' -import SafeContract_v1_1_1_Web3 from '@safe-global/protocol-kit/adapters/web3/contracts/Safe/v1.1.1/SafeContract_v1_1_1_Web3' -import SafeContract_v1_2_0_Web3 from '@safe-global/protocol-kit/adapters/web3/contracts/Safe/v1.2.0/SafeContract_v1_2_0_Web3' -import SafeContract_v1_3_0_Web3 from '@safe-global/protocol-kit/adapters/web3/contracts/Safe/v1.3.0/SafeContract_v1_3_0_Web3' -import SafeContract_v1_4_1_Web3 from '@safe-global/protocol-kit/adapters/web3/contracts/Safe/v1.4.1/SafeContract_v1_4_1_Web3' -import MultiSendContract_v1_1_1_Web3 from '@safe-global/protocol-kit/adapters/web3/contracts/MultiSend/v1.1.1/MultiSendContract_v1_1_1_Web3' -import MultiSendContract_v1_1_1_Ethers from '@safe-global/protocol-kit/adapters/ethers/contracts/MultiSend/v1.1.1/MultiSendContract_v1_1_1_Ethers' -import MultiSendContract_v1_3_0_Web3 from '@safe-global/protocol-kit/adapters/web3/contracts/MultiSend/v1.3.0/MultiSendContract_v1_3_0_Web3' -import MultiSendContract_v1_3_0_Ethers from '@safe-global/protocol-kit/adapters/ethers/contracts/MultiSend/v1.3.0/MultiSendContract_v1_3_0_Ethers' -import MultiSendContract_v1_4_1_Web3 from '@safe-global/protocol-kit/adapters/web3/contracts/MultiSend/v1.4.1/MultiSendContract_v1_4_1_Web3' -import MultiSendContract_v1_4_1_Ethers from '@safe-global/protocol-kit/adapters/ethers/contracts/MultiSend/v1.4.1/MultiSendContract_v1_4_1_Ethers' -import MultiSendCallOnlyContract_v1_4_1_Ethers from '@safe-global/protocol-kit/adapters/ethers/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1_Ethers' -import MultiSendCallOnlyContract_v1_3_0_Ethers from '@safe-global/protocol-kit/adapters/ethers/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0_Ethers' -import MultiSendCallOnlyContract_v1_3_0_Web3 from '@safe-global/protocol-kit/adapters/web3/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0_Web3' -import MultiSendCallOnlyContract_v1_4_1_Web3 from '@safe-global/protocol-kit/adapters/web3/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1_Web3' -import CompatibilityFallbackHandlerContract_v1_3_0_Web3 from '../adapters/web3/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0_Web3' -import CompatibilityFallbackHandlerContract_v1_3_0_Ethers from '../adapters/ethers/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0_Ethers' -import CompatibilityFallbackHandlerContract_v1_4_1_Web3 from '../adapters/web3/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1_Web3' -import CompatibilityFallbackHandlerContract_v1_4_1_Ethers from '../adapters/ethers/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1_Ethers' -import SafeProxyFactoryContract_v1_0_0_Web3 from '../adapters/web3/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0_Web3' -import SafeProxyFactoryContract_v1_0_0_Ethers from '../adapters/ethers/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0_Ethers' -import SafeProxyFactoryContract_v1_1_1_Web3 from '../adapters/web3/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1_Web3' -import SafeProxyFactoryContract_v1_1_1_Ethers from '../adapters/ethers/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1_Ethers' -import SafeProxyFactoryContract_v1_3_0_Web3 from '../adapters/web3/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0_Web3' -import SafeProxyFactoryContract_v1_3_0_Ethers from '../adapters/ethers/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0_Ethers' -import SafeProxyFactoryContract_v1_4_1_Web3 from '../adapters/web3/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1_Web3' -import SafeProxyFactoryContract_v1_4_1_Ethers from '../adapters/ethers/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1_Ethers' -import SignMessageLibContract_v1_3_0_Web3 from '../adapters/web3/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0_Web3' -import SignMessageLibContract_v1_3_0_Ethers from '../adapters/ethers/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0_Ethers' -import SignMessageLibContract_v1_4_1_Web3 from '../adapters/web3/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1_Web3' -import SignMessageLibContract_v1_4_1_Ethers from '../adapters/ethers/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1_Ethers' -import SimulateTxAccessorContract_v1_3_0_Web3 from '../adapters/web3/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0_Web3' -import SimulateTxAccessorContract_v1_3_0_Ethers from '../adapters/ethers/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0_Ethers' -import SimulateTxAccessorContract_v1_4_1_Web3 from '../adapters/web3/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1_Web3' -import SimulateTxAccessorContract_v1_4_1_Ethers from '../adapters/ethers/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1_Ethers' -import CreateCallContract_v1_3_0_Web3 from '../adapters/web3/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0_Web3' -import CreateCallContract_v1_3_0_Ethers from '../adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0_Ethers' -import CreateCallContract_v1_4_1_Web3 from '../adapters/web3/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1_Web3' -import CreateCallContract_v1_4_1_Ethers from '../adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1_Ethers' - -export interface SafeAccountConfig { - owners: string[] - threshold: number - to?: string - data?: string - fallbackHandler?: string - paymentToken?: string - payment?: number - paymentReceiver?: string -} - -export interface SafeDeploymentConfig { - saltNonce?: string - safeVersion?: SafeVersion -} - -export interface PredictedSafeProps { - safeAccountConfig: SafeAccountConfig - safeDeploymentConfig?: SafeDeploymentConfig -} - -export interface ContractNetworkConfig { - /** safeSingletonAddress - Address of the Safe Singleton contract deployed on a specific network */ - safeSingletonAddress: string - /** safeSingletonAbi - Abi of the Safe Singleton contract deployed on a specific network */ - safeSingletonAbi?: AbiItem | AbiItem[] - /** safeProxyFactoryAddress - Address of the SafeProxyFactory contract deployed on a specific network */ - safeProxyFactoryAddress: string - /** safeProxyFactoryAbi - Abi of the SafeProxyFactory contract deployed on a specific network */ - safeProxyFactoryAbi?: AbiItem | AbiItem[] - /** multiSendAddress - Address of the MultiSend contract deployed on a specific network */ - multiSendAddress: string - /** multiSendAbi - Abi of the MultiSend contract deployed on a specific network */ - multiSendAbi?: AbiItem | AbiItem[] - /** multiSendCallOnlyAddress - Address of the MultiSendCallOnly contract deployed on a specific network */ - multiSendCallOnlyAddress: string - /** multiSendCallOnlyAbi - Abi of the MultiSendCallOnly contract deployed on a specific network */ - multiSendCallOnlyAbi?: AbiItem | AbiItem[] - /** fallbackHandlerAddress - Address of the Fallback Handler contract deployed on a specific network */ - fallbackHandlerAddress: string - /** fallbackHandlerAbi - Abi of the Fallback Handler contract deployed on a specific network */ - fallbackHandlerAbi?: AbiItem | AbiItem[] - /** signMessageLibAddress - Address of the SignMessageLib contract deployed on a specific network */ - signMessageLibAddress: string - /** signMessageLibAbi - Abi of the SignMessageLib contract deployed on a specific network */ - signMessageLibAbi?: AbiItem | AbiItem[] - /** createCallAddress - Address of the CreateCall contract deployed on a specific network */ - createCallAddress: string - /** createCallAbi - Abi of the CreateCall contract deployed on a specific network */ - createCallAbi?: AbiItem | AbiItem[] - /** simulateTxAccessorAddress - Address of the SimulateTxAccessor contract deployed on a specific network */ - simulateTxAccessorAddress: string - /** simulateTxAccessorAbi - Abi of the SimulateTxAccessor contract deployed on a specific network */ - simulateTxAccessorAbi?: AbiItem | AbiItem[] -} - -export interface ContractNetworksConfig { - /** id - Network id */ - [id: string]: ContractNetworkConfig -} - -type SafeConfigWithSafeAddressProps = { - /** safeAddress - The address of the Safe account to use */ - safeAddress: string - /** predictedSafe - The configuration of the Safe that is not yet deployed */ - predictedSafe?: never -} - -type SafeConfigWithPredictedSafeProps = { - /** safeAddress - The address of the Safe account to use */ - safeAddress?: never - /** predictedSafe - The configuration of the Safe that is not yet deployed */ - predictedSafe: PredictedSafeProps -} - -export type SafeConfigProps = { - /** ethAdapter - Ethereum adapter */ - ethAdapter: EthAdapter - /** isL1SafeSingleton - Forces to use the Safe L1 version of the contract instead of the L2 version */ - isL1SafeSingleton?: boolean - /** contractNetworks - Contract network configuration */ - contractNetworks?: ContractNetworksConfig -} - -export type SafeConfigWithSafeAddress = SafeConfigProps & SafeConfigWithSafeAddressProps -export type SafeConfigWithPredictedSafe = SafeConfigProps & SafeConfigWithPredictedSafeProps -export type SafeConfig = SafeConfigWithSafeAddress | SafeConfigWithPredictedSafe - -type ConnectSafeConfigWithSafeAddressProps = { - /** safeAddress - The address of the Safe account to use */ - safeAddress?: string - /** predictedSafe - The configuration of the Safe that is not yet deployed */ - predictedSafe?: never -} - -type ConnectSafeConfigWithPredictedSafeProps = { - /** safeAddress - The address of the Safe account to use */ - safeAddress?: never - /** predictedSafe - The configuration of the Safe that is not yet deployed */ - predictedSafe?: PredictedSafeProps -} - -type ConnectSafeConfigProps = { - /** ethAdapter - Ethereum adapter */ - ethAdapter?: EthAdapter - /** isL1SafeSingleton - Forces to use the Safe L1 version of the contract instead of the L2 version */ - isL1SafeSingleton?: boolean - /** contractNetworks - Contract network configuration */ - contractNetworks?: ContractNetworksConfig -} - -export type ConnectSafeConfigWithSafeAddress = ConnectSafeConfigProps & - ConnectSafeConfigWithSafeAddressProps -export type ConnectSafeConfigWithPredictedSafe = ConnectSafeConfigProps & - ConnectSafeConfigWithPredictedSafeProps -export type ConnectSafeConfig = - | ConnectSafeConfigWithSafeAddress - | ConnectSafeConfigWithPredictedSafe - -export interface CreateTransactionProps { - /** transactions - The transaction array to process */ - transactions: MetaTransactionData[] - /** options - The transaction array optional properties */ - options?: SafeTransactionOptionalProps - /** onlyCalls - Forces the execution of the transaction array with MultiSendCallOnly contract */ - onlyCalls?: boolean -} - -export interface AddOwnerTxParams { - /** ownerAddress - The address of the new owner */ - ownerAddress: string - /** threshold - The new threshold */ - threshold?: number -} - -export interface RemoveOwnerTxParams { - /** ownerAddress - The address of the owner that will be removed */ - ownerAddress: string - /** threshold - The new threshold */ - threshold?: number -} - -export interface SwapOwnerTxParams { - /** oldOwnerAddress - The old owner address */ - oldOwnerAddress: string - /** newOwnerAddress - The new owner address */ - newOwnerAddress: string -} - -type StandardizeSafeTxDataWithSafeContractProps = { - /** safeContract - The Safe contract to use */ - safeContract: SafeContractImplementationType - /** predictedSafe - The configuration of the Safe that is not yet deployed */ - predictedSafe?: never -} - -type StandardizeSafeTxDataWithPredictedSafeProps = { - /** safeContract - The Safe contract to use */ - safeContract?: never - /** predictedSafe - The configuration of the Safe that is not yet deployed */ - predictedSafe: PredictedSafeProps -} - -interface StandardizeSafeTransactionData { - /** ethAdapter - Ethereum adapter */ - ethAdapter: EthAdapter - /** tx - Safe transaction */ - tx: SafeTransactionDataPartial - /** contractNetworks - Contract network configuration */ - contractNetworks?: ContractNetworksConfig -} - -export type StandardizeSafeTxDataWithSafeContract = StandardizeSafeTransactionData & - StandardizeSafeTxDataWithSafeContractProps -export type StandardizeSafeTxDataWithPredictedSafe = StandardizeSafeTransactionData & - StandardizeSafeTxDataWithPredictedSafeProps -export type StandardizeSafeTransactionDataProps = - | StandardizeSafeTxDataWithSafeContract - | StandardizeSafeTxDataWithPredictedSafe - -export enum SigningMethod { - ETH_SIGN = 'eth_sign', - ETH_SIGN_TYPED_DATA = 'eth_signTypedData', - ETH_SIGN_TYPED_DATA_V3 = 'eth_signTypedData_v3', - ETH_SIGN_TYPED_DATA_V4 = 'eth_signTypedData_v4', - SAFE_SIGNATURE = 'safe_sign' -} - -export type SigningMethodType = SigningMethod | string - -// Safe contract implementation types - -export type SafeContract_v1_0_0_ImplementationType = - | SafeContract_v1_0_0_Web3 - | SafeContract_v1_0_0_Ethers - -export type SafeContract_v1_1_0_ImplementationType = - | SafeContract_v1_1_1_Web3 - | SafeContract_v1_1_1_Ethers - -export type SafeContract_v1_2_0_ImplementationType = - | SafeContract_v1_2_0_Web3 - | SafeContract_v1_2_0_Ethers - -export type SafeContract_v1_3_0_ImplementationType = - | SafeContract_v1_3_0_Web3 - | SafeContract_v1_3_0_Ethers - -export type SafeContract_v1_4_1_ImplementationType = - | SafeContract_v1_4_1_Web3 - | SafeContract_v1_4_1_Ethers - -export type SafeContractImplementationType = - | SafeContract_v1_0_0_ImplementationType - | SafeContract_v1_1_0_ImplementationType - | SafeContract_v1_2_0_ImplementationType - | SafeContract_v1_3_0_ImplementationType - | SafeContract_v1_4_1_ImplementationType - -// MultiSend contract implementation types - -export type MultiSendContract_v1_1_1_ImplementationType = - | MultiSendContract_v1_1_1_Web3 - | MultiSendContract_v1_1_1_Ethers - -export type MultiSendContract_v1_3_0_ImplementationType = - | MultiSendContract_v1_3_0_Web3 - | MultiSendContract_v1_3_0_Ethers - -export type MultiSendContract_v1_4_1_ImplementationType = - | MultiSendContract_v1_4_1_Web3 - | MultiSendContract_v1_4_1_Ethers - -export type MultiSendContractImplementationType = - | MultiSendContract_v1_1_1_ImplementationType - | MultiSendContract_v1_3_0_ImplementationType - | MultiSendContract_v1_4_1_ImplementationType - -// MultiSendCallOnly contract implementation types - -export type MultiSendCallOnlyContract_v1_3_0_ImplementationType = - | MultiSendCallOnlyContract_v1_3_0_Web3 - | MultiSendCallOnlyContract_v1_3_0_Ethers - -export type MultiSendCallOnlyContract_v1_4_1_ImplementationType = - | MultiSendCallOnlyContract_v1_4_1_Web3 - | MultiSendCallOnlyContract_v1_4_1_Ethers - -export type MultiSendCallOnlyContractImplementationType = - | MultiSendCallOnlyContract_v1_3_0_ImplementationType - | MultiSendCallOnlyContract_v1_4_1_ImplementationType - -// CompatibilityFallbackHandler contract implementation types - -export type CompatibilityFallbackHandlerContract_v1_3_0_ImplementationType = - | CompatibilityFallbackHandlerContract_v1_3_0_Web3 - | CompatibilityFallbackHandlerContract_v1_3_0_Ethers - -export type CompatibilityFallbackHandlerContract_v1_4_1_ImplementationType = - | CompatibilityFallbackHandlerContract_v1_4_1_Web3 - | CompatibilityFallbackHandlerContract_v1_4_1_Ethers - -export type CompatibilityFallbackHandlerContractImplementationType = - | CompatibilityFallbackHandlerContract_v1_3_0_ImplementationType - | CompatibilityFallbackHandlerContract_v1_4_1_ImplementationType - -// SafeProxyFactory contract implementation types - -export type SafeProxyFactoryContract_v1_0_0_ImplementationType = - | SafeProxyFactoryContract_v1_0_0_Web3 - | SafeProxyFactoryContract_v1_0_0_Ethers - -export type SafeProxyFactoryContract_v1_1_1_ImplementationType = - | SafeProxyFactoryContract_v1_1_1_Web3 - | SafeProxyFactoryContract_v1_1_1_Ethers - -export type SafeProxyFactoryContract_v1_3_0_ImplementationType = - | SafeProxyFactoryContract_v1_3_0_Web3 - | SafeProxyFactoryContract_v1_3_0_Ethers - -export type SafeProxyFactoryContract_v1_4_1_ImplementationType = - | SafeProxyFactoryContract_v1_4_1_Web3 - | SafeProxyFactoryContract_v1_4_1_Ethers - -export type SafeProxyFactoryContractImplementationType = - | SafeProxyFactoryContract_v1_0_0_ImplementationType - | SafeProxyFactoryContract_v1_1_1_ImplementationType - | SafeProxyFactoryContract_v1_3_0_ImplementationType - | SafeProxyFactoryContract_v1_4_1_ImplementationType - -// SignMessageLib contract implementation types - -export type SignMessageLibContract_v1_3_0_ImplementationType = - | SignMessageLibContract_v1_3_0_Web3 - | SignMessageLibContract_v1_3_0_Ethers - -export type SignMessageLibContract_v1_4_1_ImplementationType = - | SignMessageLibContract_v1_4_1_Web3 - | SignMessageLibContract_v1_4_1_Ethers - -export type SignMessageLibContractImplementationType = - | SignMessageLibContract_v1_3_0_ImplementationType - | SignMessageLibContract_v1_4_1_ImplementationType - -// SimulateTxAccessor contract implementation types - -export type SimulateTxAccessorContract_v1_3_0_ImplementationType = - | SimulateTxAccessorContract_v1_3_0_Web3 - | SimulateTxAccessorContract_v1_3_0_Ethers - -export type SimulateTxAccessorContract_v1_4_1_ImplementationType = - | SimulateTxAccessorContract_v1_4_1_Web3 - | SimulateTxAccessorContract_v1_4_1_Ethers - -export type SimulateTxAccessorContractImplementationType = - | SimulateTxAccessorContract_v1_3_0_ImplementationType - | SimulateTxAccessorContract_v1_4_1_ImplementationType - -// CreateCall contract implementation types - -export type CreateCallContract_v1_3_0_ImplementationType = - | CreateCallContract_v1_3_0_Web3 - | CreateCallContract_v1_3_0_Ethers - -export type CreateCallContract_v1_4_1_ImplementationType = - | CreateCallContract_v1_4_1_Web3 - | CreateCallContract_v1_4_1_Ethers - -export type CreateCallContractImplementationType = - | CreateCallContract_v1_3_0_ImplementationType - | CreateCallContract_v1_4_1_ImplementationType +export * from './contracts' +export * from './safeConfig' +export * from './safeFactory' +export * from './safeProvider' +export * from './signing' +export * from './transactions' diff --git a/packages/protocol-kit/src/types/safeConfig.ts b/packages/protocol-kit/src/types/safeConfig.ts new file mode 100644 index 000000000..5e9f9b9ab --- /dev/null +++ b/packages/protocol-kit/src/types/safeConfig.ts @@ -0,0 +1,83 @@ +import { SafeVersion } from '@safe-global/safe-core-sdk-types' + +import { SafeProviderConfig } from './safeProvider' +import { ContractNetworksConfig } from './contracts' + +export type SafeAccountConfig = { + owners: string[] + threshold: number + to?: string + data?: string + fallbackHandler?: string + paymentToken?: string + payment?: number + paymentReceiver?: string +} + +export type SafeDeploymentConfig = { + saltNonce?: string + safeVersion?: SafeVersion +} + +export type PredictedSafeProps = { + safeAccountConfig: SafeAccountConfig + safeDeploymentConfig?: SafeDeploymentConfig +} + +type SafeConfigWithSafeAddressProps = { + /** safeAddress - The address of the Safe account to use */ + safeAddress: string + /** predictedSafe - The configuration of the Safe that is not yet deployed */ + predictedSafe?: never +} + +type SafeConfigWithPredictedSafeProps = { + /** safeAddress - The address of the Safe account to use */ + safeAddress?: never + /** predictedSafe - The configuration of the Safe that is not yet deployed */ + predictedSafe: PredictedSafeProps +} + +export type SafeConfigProps = { + provider: SafeProviderConfig['provider'] + signer?: SafeProviderConfig['signer'] + /** isL1SafeSingleton - Forces to use the Safe L1 version of the contract instead of the L2 version */ + isL1SafeSingleton?: boolean + /** contractNetworks - Contract network configuration */ + contractNetworks?: ContractNetworksConfig +} + +export type SafeConfigWithSafeAddress = SafeConfigProps & SafeConfigWithSafeAddressProps +export type SafeConfigWithPredictedSafe = SafeConfigProps & SafeConfigWithPredictedSafeProps +export type SafeConfig = SafeConfigWithSafeAddress | SafeConfigWithPredictedSafe + +type ConnectSafeConfigWithSafeAddressProps = { + /** safeAddress - The address of the Safe account to use */ + safeAddress?: string + /** predictedSafe - The configuration of the Safe that is not yet deployed */ + predictedSafe?: never +} + +type ConnectSafeConfigWithPredictedSafeProps = { + /** safeAddress - The address of the Safe account to use */ + safeAddress?: never + /** predictedSafe - The configuration of the Safe that is not yet deployed */ + predictedSafe?: PredictedSafeProps +} + +type ConnectSafeConfigProps = { + provider?: SafeProviderConfig['provider'] + signer?: SafeProviderConfig['signer'] + /** isL1SafeSingleton - Forces to use the Safe L1 version of the contract instead of the L2 version */ + isL1SafeSingleton?: boolean + /** contractNetworks - Contract network configuration */ + contractNetworks?: ContractNetworksConfig +} + +export type ConnectSafeConfigWithSafeAddress = ConnectSafeConfigProps & + ConnectSafeConfigWithSafeAddressProps +export type ConnectSafeConfigWithPredictedSafe = ConnectSafeConfigProps & + ConnectSafeConfigWithPredictedSafeProps +export type ConnectSafeConfig = + | ConnectSafeConfigWithSafeAddress + | ConnectSafeConfigWithPredictedSafe diff --git a/packages/protocol-kit/src/types/safeFactory.ts b/packages/protocol-kit/src/types/safeFactory.ts new file mode 100644 index 000000000..f31d36df8 --- /dev/null +++ b/packages/protocol-kit/src/types/safeFactory.ts @@ -0,0 +1,35 @@ +import { SafeVersion, TransactionOptions } from '@safe-global/safe-core-sdk-types' + +import { SafeProviderConfig } from './safeProvider' +import { SafeAccountConfig } from './safeConfig' +import { ContractNetworksConfig } from './contracts' + +export type DeploySafeProps = { + safeAccountConfig: SafeAccountConfig + saltNonce?: string + options?: TransactionOptions + callback?: (txHash: string) => void +} + +export type SafeFactoryConfig = { + provider: SafeProviderConfig['provider'] + signer?: SafeProviderConfig['signer'] + /** 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 +} + +export type SafeFactoryInitConfig = { + provider: SafeProviderConfig['provider'] + signer?: SafeProviderConfig['signer'] + privateKeyOrMnemonic?: string + /** 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 +} diff --git a/packages/protocol-kit/src/types/safeProvider.ts b/packages/protocol-kit/src/types/safeProvider.ts new file mode 100644 index 000000000..af47b84bb --- /dev/null +++ b/packages/protocol-kit/src/types/safeProvider.ts @@ -0,0 +1,36 @@ +export type RequestArguments = { + readonly method: string + readonly params?: readonly unknown[] | object +} + +export type Eip1193Provider = { + request: (args: RequestArguments) => Promise +} + +export type HexAddress = string +export type PrivateKey = string +export type HttpTransport = string +export type SocketTransport = string +export type SafeSigner = HexAddress | PrivateKey + +export type SafeProviderConfig = { + /** signerOrProvider - Ethers signer or provider */ + provider: Eip1193Provider | HttpTransport | SocketTransport + signer?: HexAddress | PrivateKey +} + +export type SafeProviderTransaction = { + to: string + from: string + data: string + value?: string + gasPrice?: number | string + gasLimit?: number | string + maxFeePerGas?: number | string + maxPriorityFeePerGas?: number | string +} + +export type SafeModulesPaginated = { + modules: string[] + next: string +} diff --git a/packages/protocol-kit/src/types/signing.ts b/packages/protocol-kit/src/types/signing.ts new file mode 100644 index 000000000..3cb5f5792 --- /dev/null +++ b/packages/protocol-kit/src/types/signing.ts @@ -0,0 +1,9 @@ +export enum SigningMethod { + ETH_SIGN = 'eth_sign', + ETH_SIGN_TYPED_DATA = 'eth_signTypedData', + ETH_SIGN_TYPED_DATA_V3 = 'eth_signTypedData_v3', + ETH_SIGN_TYPED_DATA_V4 = 'eth_signTypedData_v4', + SAFE_SIGNATURE = 'safe_sign' +} + +export type SigningMethodType = SigningMethod | string diff --git a/packages/protocol-kit/src/types/transactions.ts b/packages/protocol-kit/src/types/transactions.ts new file mode 100644 index 000000000..15582c2fa --- /dev/null +++ b/packages/protocol-kit/src/types/transactions.ts @@ -0,0 +1,68 @@ +import { MetaTransactionData, SafeTransactionDataPartial } from '@safe-global/safe-core-sdk-types' +import { SafeTransactionOptionalProps } from '@safe-global/protocol-kit/utils/transactions' + +import { SafeProviderConfig } from './safeProvider' +import { SafeContractImplementationType } from './contracts' +import { ContractNetworksConfig } from './contracts' +import { PredictedSafeProps } from './safeConfig' + +export type CreateTransactionProps = { + /** transactions - The transaction array to process */ + transactions: MetaTransactionData[] + /** options - The transaction array optional properties */ + options?: SafeTransactionOptionalProps + /** onlyCalls - Forces the execution of the transaction array with MultiSendCallOnly contract */ + onlyCalls?: boolean +} + +type StandardizeSafeTxDataWithSafeContractProps = { + /** safeContract - The Safe contract to use */ + safeContract: SafeContractImplementationType + /** predictedSafe - The configuration of the Safe that is not yet deployed */ + predictedSafe?: never +} + +type StandardizeSafeTxDataWithPredictedSafeProps = { + /** safeContract - The Safe contract to use */ + safeContract?: never + /** predictedSafe - The configuration of the Safe that is not yet deployed */ + predictedSafe: PredictedSafeProps +} + +type StandardizeSafeTransactionData = { + provider: SafeProviderConfig['provider'] + signer?: SafeProviderConfig['signer'] + /** tx - Safe transaction */ + tx: SafeTransactionDataPartial + /** contractNetworks - Contract network configuration */ + contractNetworks?: ContractNetworksConfig +} + +export type StandardizeSafeTxDataWithSafeContract = StandardizeSafeTransactionData & + StandardizeSafeTxDataWithSafeContractProps +export type StandardizeSafeTxDataWithPredictedSafe = StandardizeSafeTransactionData & + StandardizeSafeTxDataWithPredictedSafeProps +export type StandardizeSafeTransactionDataProps = + | StandardizeSafeTxDataWithSafeContract + | StandardizeSafeTxDataWithPredictedSafe + +export type AddOwnerTxParams = { + /** ownerAddress - The address of the new owner */ + ownerAddress: string + /** threshold - The new threshold */ + threshold?: number +} + +export type RemoveOwnerTxParams = { + /** ownerAddress - The address of the owner that will be removed */ + ownerAddress: string + /** threshold - The new threshold */ + threshold?: number +} + +export type SwapOwnerTxParams = { + /** oldOwnerAddress - The old owner address */ + oldOwnerAddress: string + /** newOwnerAddress - The new owner address */ + newOwnerAddress: string +} diff --git a/packages/protocol-kit/src/utils/address.ts b/packages/protocol-kit/src/utils/address.ts index 5906f3c8b..472011460 100644 --- a/packages/protocol-kit/src/utils/address.ts +++ b/packages/protocol-kit/src/utils/address.ts @@ -8,7 +8,7 @@ export function isZeroAddress(address: string): boolean { return sameString(address, ZERO_ADDRESS) } -function isSentinelAddress(address: string): boolean { +export function isSentinelAddress(address: string): boolean { return sameString(address, SENTINEL_ADDRESS) } diff --git a/packages/protocol-kit/src/utils/eip-3770/config.ts b/packages/protocol-kit/src/utils/eip-3770/config.ts index fda3b3e01..f4909daef 100644 --- a/packages/protocol-kit/src/utils/eip-3770/config.ts +++ b/packages/protocol-kit/src/utils/eip-3770/config.ts @@ -209,6 +209,4 @@ export const networks: NetworkShortName[] = [ if (process.env.TEST_NETWORK === 'hardhat') { networks.push({ shortName: 'local', chainId: 31337n }) -} else if (process.env.TEST_NETWORK === 'ganache') { - networks.push({ shortName: 'local', chainId: 1337n }) } diff --git a/packages/protocol-kit/src/utils/eip-3770/index.ts b/packages/protocol-kit/src/utils/eip-3770/index.ts index 835a72a5b..ff2319cc4 100644 --- a/packages/protocol-kit/src/utils/eip-3770/index.ts +++ b/packages/protocol-kit/src/utils/eip-3770/index.ts @@ -1,5 +1,5 @@ +import { ethers } from 'ethers' import { Eip3770Address } from '@safe-global/safe-core-sdk-types' -import { isAddress, isHexStrict } from 'web3-utils' import { networks } from './config' export function parseEip3770Address(fullAddress: string): Eip3770Address { @@ -29,7 +29,7 @@ export function validateEip3770NetworkPrefix(prefix: string, currentChainId: big } export function validateEthereumAddress(address: string): void { - const isValidAddress = isHexStrict(address) && isAddress(address) + const isValidAddress = ethers.isHexString(address) && ethers.isAddress(address) if (!isValidAddress) { throw new Error(`Invalid Ethereum address ${address}`) } diff --git a/packages/protocol-kit/src/utils/erc-20/index.ts b/packages/protocol-kit/src/utils/erc-20/index.ts index b1b1ea72c..57273e4c9 100644 --- a/packages/protocol-kit/src/utils/erc-20/index.ts +++ b/packages/protocol-kit/src/utils/erc-20/index.ts @@ -19,7 +19,7 @@ const ERC20_ABI = [ * @throws "Invalid ERC-20 decimals" */ export async function getERC20Decimals(tokenAddress: string, safe: Safe): Promise { - const ethAdapter = safe.getEthAdapter() + const safeProvider = safe.getSafeProvider() const erc20Interface = new Interface(ERC20_ABI) const getTokenDecimalsTransaction = { @@ -29,7 +29,7 @@ export async function getERC20Decimals(tokenAddress: string, safe: Safe): Promis data: erc20Interface.encodeFunctionData('decimals') } - const response = await ethAdapter.call(getTokenDecimalsTransaction) + const response = await safeProvider.call(getTokenDecimalsTransaction) const decimals = Number(response) diff --git a/packages/protocol-kit/src/utils/memoized.ts b/packages/protocol-kit/src/utils/memoized.ts index 757707cd9..703d018a7 100644 --- a/packages/protocol-kit/src/utils/memoized.ts +++ b/packages/protocol-kit/src/utils/memoized.ts @@ -1,12 +1,43 @@ +import SafeProvider from '../SafeProvider' + export function createMemoizedFunction) => ReturnType>( callback: T, cache: Record> = {} ) { + const replacer = createSafeContractSerializerReplacer() return (...args: Parameters): ReturnType => { - const key = JSON.stringify(args) + const key = JSON.stringify(args, replacer) cache[key] = cache[key] || callback(...args) return cache[key] } } + +// EIP1193 providers from web3.currentProvider and hre.network.provider fail to serialize BigInts +function createSafeContractSerializerReplacer() { + const seen = new Set() + + return (_: string, value: unknown) => { + // Serialize Bigints as strings + if (typeof value === 'bigint') { + return value.toString() + } + + // Avoid circular references + if (value instanceof SafeProvider && value !== null) { + if (seen.has(value)) { + return undefined + } + seen.add(value) + return { + $safeProvider: { + provider: typeof value.provider === 'object' ? 'EIP1193Provider' : value.provider, + signer: value.signer + } + } + } + + return value + } +} diff --git a/packages/protocol-kit/src/utils/safeVersions.ts b/packages/protocol-kit/src/utils/safeVersions.ts index 3da9bcc25..76f052adb 100644 --- a/packages/protocol-kit/src/utils/safeVersions.ts +++ b/packages/protocol-kit/src/utils/safeVersions.ts @@ -1,12 +1,10 @@ import semverSatisfies from 'semver/functions/satisfies' -import { - SafeContractImplementationType, - SafeContract_v1_0_0_ImplementationType, - SafeContract_v1_1_0_ImplementationType, - SafeContract_v1_2_0_ImplementationType, - SafeContract_v1_3_0_ImplementationType, - SafeContract_v1_4_1_ImplementationType -} from '@safe-global/protocol-kit/types' +import { SafeContractImplementationType } from '@safe-global/protocol-kit/types' +import SafeContract_v1_0_0 from '@safe-global/protocol-kit/contracts/Safe/v1.0.0/SafeContract_v1_0_0' +import SafeContract_v1_1_1 from '@safe-global/protocol-kit/contracts/Safe/v1.1.1/SafeContract_v1_1_1' +import SafeContract_v1_2_0 from '@safe-global/protocol-kit/contracts/Safe/v1.2.0/SafeContract_v1_2_0' +import SafeContract_v1_3_0 from '@safe-global/protocol-kit/contracts/Safe/v1.3.0/SafeContract_v1_3_0' +import SafeContract_v1_4_1 from '@safe-global/protocol-kit/contracts/Safe/v1.4.1/SafeContract_v1_4_1' export enum SAFE_FEATURES { SAFE_TX_GAS_OPTIONAL = 'SAFE_TX_GAS_OPTIONAL', @@ -37,27 +35,21 @@ export const hasSafeFeature = (feature: SAFE_FEATURES, version: string): boolean } export type SafeContractCompatibleWithFallbackHandler = - | SafeContract_v1_1_0_ImplementationType - | SafeContract_v1_2_0_ImplementationType - | SafeContract_v1_3_0_ImplementationType - | SafeContract_v1_4_1_ImplementationType + | SafeContract_v1_1_1 + | SafeContract_v1_2_0 + | SafeContract_v1_3_0 + | SafeContract_v1_4_1 -export type SafeContractCompatibleWithGuardManager = - | SafeContract_v1_3_0_ImplementationType - | SafeContract_v1_4_1_ImplementationType +export type SafeContractCompatibleWithGuardManager = SafeContract_v1_3_0 | SafeContract_v1_4_1 -export type SafeContractCompatibleWithModuleManager = - | SafeContract_v1_3_0_ImplementationType - | SafeContract_v1_4_1_ImplementationType +export type SafeContractCompatibleWithModuleManager = SafeContract_v1_3_0 | SafeContract_v1_4_1 export type SafeContractCompatibleWithRequiredTxGas = - | SafeContract_v1_0_0_ImplementationType - | SafeContract_v1_1_0_ImplementationType - | SafeContract_v1_2_0_ImplementationType + | SafeContract_v1_0_0 + | SafeContract_v1_1_1 + | SafeContract_v1_2_0 -export type SafeContractCompatibleWithSimulateAndRevert = - | SafeContract_v1_3_0_ImplementationType - | SafeContract_v1_4_1_ImplementationType +export type SafeContractCompatibleWithSimulateAndRevert = SafeContract_v1_3_0 | SafeContract_v1_4_1 export async function isSafeContractCompatibleWithRequiredTxGas( safeContract: SafeContractImplementationType diff --git a/packages/protocol-kit/src/utils/signatures/utils.ts b/packages/protocol-kit/src/utils/signatures/utils.ts index 58d638f52..dcc26c477 100644 --- a/packages/protocol-kit/src/utils/signatures/utils.ts +++ b/packages/protocol-kit/src/utils/signatures/utils.ts @@ -1,5 +1,5 @@ import { ethers } from 'ethers' -import { EthAdapter } from '@safe-global/protocol-kit/adapters/ethAdapter' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { SafeSignature, SafeEIP712Args, @@ -106,31 +106,32 @@ export const adjustVInSignature: AdjustVOverload = ( } export async function generateSignature( - ethAdapter: EthAdapter, + safeProvider: SafeProvider, hash: string ): Promise { - const signerAddress = await ethAdapter.getSignerAddress() + const signerAddress = await 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') } - let signature = await ethAdapter.signMessage(hash) + let signature = await safeProvider.signMessage(hash) signature = adjustVInSignature(SigningMethod.ETH_SIGN, signature, hash, signerAddress) return new EthSafeSignature(signerAddress, signature) } export async function generateEIP712Signature( - ethAdapter: EthAdapter, + safeProvider: SafeProvider, safeEIP712Args: SafeEIP712Args, methodVersion?: 'v3' | 'v4' ): Promise { - const signerAddress = await ethAdapter.getSignerAddress() + const signerAddress = await 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') } - let signature = await ethAdapter.signTypedData(safeEIP712Args, methodVersion) + //@ts-expect-error: Evaluate removal of methodVersion and use v4 + let signature = await safeProvider.signTypedData(safeEIP712Args, methodVersion) signature = adjustVInSignature(SigningMethod.ETH_SIGN_TYPED_DATA, signature) return new EthSafeSignature(signerAddress, signature) diff --git a/packages/protocol-kit/src/utils/transactions/gas.ts b/packages/protocol-kit/src/utils/transactions/gas.ts index d1541e699..dff83c07b 100644 --- a/packages/protocol-kit/src/utils/transactions/gas.ts +++ b/packages/protocol-kit/src/utils/transactions/gas.ts @@ -1,7 +1,7 @@ import { OperationType, SafeVersion, SafeTransaction } from '@safe-global/safe-core-sdk-types' -import { EthAdapter } from '@safe-global/protocol-kit/adapters/ethAdapter' import semverSatisfies from 'semver/functions/satisfies' import Safe from '@safe-global/protocol-kit/Safe' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { ContractNetworksConfig, SafeContractImplementationType @@ -63,16 +63,16 @@ function estimateDataGasCosts(data: string): number { export async function estimateGas( safeVersion: SafeVersion, safeContract: SafeContractImplementationType, - ethAdapter: EthAdapter, + safeProvider: SafeProvider, to: string, valueInWei: string, data: string, operation: OperationType, customContracts?: ContractNetworksConfig ) { - const chainId = await ethAdapter.getChainId() + const chainId = await safeProvider.getChainId() const simulateTxAccessorContract = await getSimulateTxAccessorContract({ - ethAdapter, + safeProvider, safeVersion, customContracts: customContracts?.[chainId.toString()] }) @@ -100,7 +100,7 @@ export async function estimateGas( } try { - const encodedResponse = await ethAdapter.call(transactionToEstimateGas) + const encodedResponse = await safeProvider.call(transactionToEstimateGas) return decodeSafeTxGas(encodedResponse) } catch (error: any) { @@ -110,7 +110,7 @@ export async function estimateGas( export async function estimateTxGas( safeContract: SafeContractImplementationType, - ethAdapter: EthAdapter, + safeProvider: SafeProvider, to: string, valueInWei: string, data: string, @@ -122,7 +122,6 @@ export async function estimateTxGas( const safeContractCompatibleWithRequiredTxGas = await isSafeContractCompatibleWithRequiredTxGas(safeContract) - // @ts-expect-error Expression produces a union type that is too complex to represent const estimateData = safeContractCompatibleWithRequiredTxGas.encode('requiredTxGas', [ to, BigInt(valueInWei), @@ -131,7 +130,7 @@ export async function estimateTxGas( ]) try { - const estimateResponse = await ethAdapter.estimateGas({ + const estimateResponse = await safeProvider.estimateGas({ to: safeAddress, from: safeAddress, data: estimateData @@ -144,7 +143,7 @@ export async function estimateTxGas( let additionalGas = 10000 for (let i = 0; i < 10; i++) { try { - const estimateResponse = await ethAdapter.call({ + const estimateResponse = await safeProvider.call({ to: safeAddress, from: safeAddress, data: estimateData, @@ -162,7 +161,7 @@ export async function estimateTxGas( } try { - const estimateGas = await ethAdapter.estimateGas({ + const estimateGas = await safeProvider.estimateGas({ to, from: safeAddress, value: valueInWei, @@ -214,19 +213,20 @@ export async function estimateTxBaseGas( const signatures = '0x' const safeVersion = await safe.getContractVersion() - const ethAdapter = safe.getEthAdapter() + const safeProvider = safe.getSafeProvider() const isL1SafeSingleton = safe.getContractManager().isL1SafeSingleton const chainId = await safe.getChainId() const customContracts = safe.getContractManager().contractNetworks?.[chainId.toString()] const safeSingletonContract = await getSafeContract({ - ethAdapter, + safeProvider, safeVersion, isL1SafeSingleton, customContracts }) - // @ts-expect-error Expression produces a union type that is too complex to represent + //@ts-expect-error: Type too complex to represent. + //TODO: We should explore contract versions and map to the correct types const execTransactionData = safeSingletonContract.encode('execTransaction', [ to, BigInt(value), @@ -325,13 +325,13 @@ async function estimateSafeTxGasWithRequiredTxGas( const isSafeDeployed = await safe.isSafeDeployed() const safeAddress = await safe.getAddress() const safeVersion = await safe.getContractVersion() - const ethAdapter = safe.getEthAdapter() + const safeProvider = safe.getSafeProvider() const isL1SafeSingleton = safe.getContractManager().isL1SafeSingleton const chainId = await safe.getChainId() const customContracts = safe.getContractManager().contractNetworks?.[chainId.toString()] const safeSingletonContract = await getSafeContract({ - ethAdapter, + safeProvider, safeVersion, isL1SafeSingleton, customContracts @@ -344,7 +344,7 @@ async function estimateSafeTxGasWithRequiredTxGas( 'requiredTxGas', [ safeTransaction.data.to, - safeTransaction.data.value, + BigInt(safeTransaction.data.value), safeTransaction.data.data, safeTransaction.data.operation ] @@ -359,7 +359,7 @@ async function estimateSafeTxGasWithRequiredTxGas( from: safeAddress } try { - const encodedResponse = await ethAdapter.call(transactionToEstimateGas) + const encodedResponse = await safeProvider.call(transactionToEstimateGas) const safeTxGas = '0x' + encodedResponse.slice(-32) @@ -385,11 +385,11 @@ async function estimateSafeTxGasWithRequiredTxGas( // TO-DO: Improve decoding /* - const simulateAndRevertResponse = ethAdapter.decodeParameters( + const simulateAndRevertResponse = safeProvider.decodeParameters( ['bool', 'bytes'], encodedResponse ) - const returnedData = ethAdapter.decodeParameters(['uint256', 'bool', 'bytes'], simulateAndRevertResponse[1]) + const returnedData = safeProvider.decodeParameters(['uint256', 'bool', 'bytes'], simulateAndRevertResponse[1]) */ function decodeSafeTxGas(encodedDataResponse: string): string { const [, encodedSafeTxGas] = encodedDataResponse.split('0x') @@ -400,7 +400,11 @@ function decodeSafeTxGas(encodedDataResponse: string): string { type GnosisChainEstimationError = { info: { error: { data: string | { data: string } } } } type EthersEstimationError = { data: string } -type EstimationError = Error & EthersEstimationError & GnosisChainEstimationError +type ViemEstimationError = { info: { error: { message: string } } } +type EstimationError = Error & + EthersEstimationError & + GnosisChainEstimationError & + ViemEstimationError /** * Parses the SafeTxGas estimation response from different providers. @@ -417,6 +421,12 @@ function parseSafeTxGasErrorResponse(error: EstimationError) { return decodeSafeTxGas(ethersData) } + // viem + const viemError = error?.info?.error?.message + if (viemError) { + return decodeSafeTxGas(viemError) + } + // gnosis-chain const gnosisChainProviderData = error?.info?.error?.data @@ -455,13 +465,13 @@ async function estimateSafeTxGasWithSimulate( const isSafeDeployed = await safe.isSafeDeployed() const safeAddress = await safe.getAddress() const safeVersion = await safe.getContractVersion() - const ethAdapter = safe.getEthAdapter() + const safeProvider = safe.getSafeProvider() const chainId = await safe.getChainId() const customContracts = safe.getContractManager().contractNetworks?.[chainId.toString()] const isL1SafeSingleton = safe.getContractManager().isL1SafeSingleton const safeSingletonContract = await getSafeContract({ - ethAdapter, + safeProvider, safeVersion, isL1SafeSingleton, customContracts @@ -469,7 +479,7 @@ async function estimateSafeTxGasWithSimulate( // new version of the estimation const simulateTxAccessorContract = await getSimulateTxAccessorContract({ - ethAdapter, + safeProvider, safeVersion, customContracts }) @@ -500,7 +510,7 @@ async function estimateSafeTxGasWithSimulate( } try { - const encodedResponse = await ethAdapter.call(transactionToEstimateGas) + const encodedResponse = await safeProvider.call(transactionToEstimateGas) const safeTxGas = decodeSafeTxGas(encodedResponse) @@ -510,8 +520,6 @@ async function estimateSafeTxGasWithSimulate( } catch (error: any) { return parseSafeTxGasErrorResponse(error) } - - return '0' } /** @@ -531,10 +539,10 @@ export async function estimateSafeDeploymentGas(safe: Safe): Promise { return '0' } - const ethAdapter = safe.getEthAdapter() + const safeProvider = safe.getSafeProvider() const safeDeploymentTransaction = await safe.createSafeDeploymentTransaction() - const estimation = await ethAdapter.estimateGas({ + const estimation = await safeProvider.estimateGas({ ...safeDeploymentTransaction, from: ZERO_ADDRESS // if we use the Safe address the estimation always fails due to CREATE2 }) diff --git a/packages/protocol-kit/src/utils/transactions/utils.ts b/packages/protocol-kit/src/utils/transactions/utils.ts index 6d331312f..583752527 100644 --- a/packages/protocol-kit/src/utils/transactions/utils.ts +++ b/packages/protocol-kit/src/utils/transactions/utils.ts @@ -1,4 +1,5 @@ -import { Interface, getBytes, solidityPacked as solidityPack } from 'ethers' +import { ethers, Interface, getBytes, solidityPacked as solidityPack } from 'ethers' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { DEFAULT_SAFE_VERSION } from '@safe-global/protocol-kit/contracts/config' import { StandardizeSafeTransactionDataProps } from '@safe-global/protocol-kit/types' import { hasSafeFeature, SAFE_FEATURES } from '@safe-global/protocol-kit/utils' @@ -13,7 +14,6 @@ import { SafeVersion } from '@safe-global/safe-core-sdk-types' import semverSatisfies from 'semver/functions/satisfies' -import { hexToNumber, hexToNumberString, toChecksumAddress } from 'web3-utils' import { estimateGas, estimateTxGas } from './gas' export function standardizeMetaTransactionData( @@ -29,7 +29,7 @@ export function standardizeMetaTransactionData( export async function standardizeSafeTransactionData({ safeContract, predictedSafe, - ethAdapter, + provider, tx, contractNetworks }: StandardizeSafeTransactionDataProps): Promise { @@ -78,11 +78,13 @@ export async function standardizeSafeTransactionData({ } let safeTxGas + + const safeProvider = new SafeProvider({ provider }) if (semverSatisfies(safeVersion, '>=1.3.0')) { safeTxGas = await estimateGas( safeVersion, safeContract, - ethAdapter, + safeProvider, standardizedTxs.to, standardizedTxs.value, standardizedTxs.data, @@ -92,7 +94,7 @@ export async function standardizeSafeTransactionData({ } else { safeTxGas = await estimateTxGas( safeContract, - ethAdapter, + safeProvider, standardizedTxs.to, standardizedTxs.value, standardizedTxs.data, @@ -140,9 +142,9 @@ export function decodeMultiSendData(encodedData: string): MetaTransactionData[] const data = `0x${decodedData.slice(index, (index += dataLength))}` txs.push({ - operation: hexToNumber(operation) as OperationType, - to: toChecksumAddress(to), - value: hexToNumberString(value), + operation: Number(operation) as OperationType, + to: ethers.getAddress(to), + value: BigInt(value).toString(), data }) } diff --git a/packages/protocol-kit/tests/e2e/contractManager.test.ts b/packages/protocol-kit/tests/e2e/contractManager.test.ts index 7307a62ae..7168ffca9 100644 --- a/packages/protocol-kit/tests/e2e/contractManager.test.ts +++ b/packages/protocol-kit/tests/e2e/contractManager.test.ts @@ -16,7 +16,7 @@ import { getSignMessageLib, getSimulateTxAccessor } from './utils/setupContracts' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' chai.use(chaiAsPromised) @@ -27,19 +27,19 @@ describe('Safe contracts manager', () => { const accounts = await getAccounts() const chainId = BigInt(await getChainId()) const contractNetworks = await getContractNetworks(chainId) + const provider = getEip1193Provider() return { safe: await getSafeWithOwners([accounts[0].address]), accounts, contractNetworks, - chainId + chainId, + provider } }) describe('create', async () => { it('should initialize the SDK with a Safe that is not deployed', async () => { - const { accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { accounts, contractNetworks, provider } = await setupTests() const predictedSafe: PredictedSafeProps = { safeAccountConfig: { owners: [accounts[0].address], @@ -51,7 +51,7 @@ describe('Safe contracts manager', () => { } chai.expect( await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -59,14 +59,12 @@ describe('Safe contracts manager', () => { }) it('should fail if the current network is not a default network and no contractNetworks is provided', async () => { - const { safe, accounts } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, provider } = await setupTests() const safeAddress = await safe.getAddress() await chai .expect( Safe.create({ - ethAdapter, + provider, safeAddress }) ) @@ -74,13 +72,11 @@ describe('Safe contracts manager', () => { }) it('should fail if SafeProxy contract is not deployed on the current network', async () => { - const { accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { contractNetworks, provider } = await setupTests() await chai .expect( Safe.create({ - ethAdapter, + provider, safeAddress: ZERO_ADDRESS, contractNetworks }) @@ -89,7 +85,7 @@ describe('Safe contracts manager', () => { }) it('should fail if MultiSend contract is specified in contractNetworks but not deployed', async () => { - const { safe, accounts, chainId } = await setupTests() + const { safe, chainId, provider } = await setupTests() const customContractNetworks: ContractNetworksConfig = { [chainId.toString()]: { safeSingletonAddress: ZERO_ADDRESS, @@ -110,13 +106,12 @@ describe('Safe contracts manager', () => { simulateTxAccessorAbi: (await getSimulateTxAccessor()).abi } } - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const safeAddress = await safe.getAddress() await chai .expect( Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks: customContractNetworks }) @@ -125,12 +120,10 @@ describe('Safe contracts manager', () => { }) it('should set the MultiSend contract available on the current network', async () => { - const { safe, accounts, chainId, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, chainId, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) diff --git a/packages/protocol-kit/tests/e2e/core.test.ts b/packages/protocol-kit/tests/e2e/core.test.ts index e097f7072..7e53961f3 100644 --- a/packages/protocol-kit/tests/e2e/core.test.ts +++ b/packages/protocol-kit/tests/e2e/core.test.ts @@ -7,7 +7,7 @@ import { deployments } from 'hardhat' import { itif } from './utils/helpers' import { getContractNetworks } from './utils/setupContractNetworks' import { getSafeWithOwners } from './utils/setupContracts' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' import { waitSafeTxReceipt } from './utils/transactions' @@ -28,9 +28,11 @@ describe('Safe Info', () => { safeVersion: safeVersionDeployed } } + const provider = getEip1193Provider() return { chainId, safe: await getSafeWithOwners([accounts[0].address, accounts[1].address]), + provider, predictedSafe, accounts, contractNetworks @@ -41,12 +43,10 @@ describe('Safe Info', () => { itif(safeVersionDeployed < '1.3.0')( 'should fail to connect a Safe { - const { predictedSafe, safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -62,64 +62,62 @@ describe('Safe Info', () => { itif(safeVersionDeployed >= '1.3.0')( 'should connect a Safe >=v1.3.0 that is not deployed', async () => { - const { predictedSafe, safe, accounts, contractNetworks } = await setupTests() + const { predictedSafe, safe, accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) const safeSdk2 = await safeSdk.connect({ predictedSafe }) chai - .expect(await safeSdk2.getEthAdapter().getSignerAddress()) + .expect(await safeSdk2.getSafeProvider().getSignerAddress()) .to.be.eq(await account1.signer.getAddress()) } ) it('should connect a deployed Safe', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, accounts, contractNetworks, provider } = await setupTests() + const [account1, account2, account3] = accounts const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) chai.expect(await safeSdk.getAddress()).to.be.eq(safeAddress) chai - .expect(await safeSdk.getEthAdapter().getSignerAddress()) + .expect(await safeSdk.getSafeProvider().getSignerAddress()) .to.be.eq(await account1.signer.getAddress()) - const ethAdapter2 = await getEthAdapter(account2.signer) const safeSdk2 = await safeSdk.connect({ - ethAdapter: ethAdapter2, + signer: account2.address, contractNetworks }) chai.expect(await safeSdk2.getAddress()).to.be.eq(safeAddress) chai - .expect(await safeSdk2.getEthAdapter().getSignerAddress()) + .expect(await safeSdk2.getSafeProvider().getSignerAddress()) .to.be.eq(await account2.signer.getAddress()) - const safe2 = await getSafeWithOwners([accounts[2].address]) + const safe2 = await getSafeWithOwners([account3.address]) const safe2Address = await safe2.getAddress() - const safeSdk3 = await safeSdk2.connect({ safeAddress: safe2Address }) + const safeSdk3 = await safeSdk2.connect({ + safeAddress: safe2Address, + signer: account3.address + }) chai.expect(await safeSdk3.getAddress()).to.be.eq(safe2Address) chai - .expect(await safeSdk3.getEthAdapter().getSignerAddress()) - .to.be.eq(await account2.signer.getAddress()) + .expect(await safeSdk3.getSafeProvider().getSignerAddress()) + .to.be.eq(await account3.signer.getAddress()) }) }) describe('getContractVersion', async () => { it('should return the contract version of a Safe that is not deployed with a custom version configuration', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -128,15 +126,13 @@ describe('Safe Info', () => { }) it('should return the contract version of a Safe that is not deployed with a default version configuration', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() const safeConfig: PredictedSafeProps = { ...predictedSafe, safeDeploymentConfig: {} } const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe: safeConfig, contractNetworks }) @@ -145,12 +141,10 @@ describe('Safe Info', () => { }) it('should return the Safe contract version', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -163,11 +157,9 @@ describe('Safe Info', () => { itif(safeVersionDeployed < '1.3.0')( 'should fail to return the address of a Safe { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -183,18 +175,16 @@ describe('Safe Info', () => { itif(safeVersionDeployed >= '1.3.0')( 'should return the address of a Safe >=v1.3.0 that is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) const safeAddress = await safeSdk.getAddress() const safeFactory = await SafeFactory.create({ - ethAdapter, + provider, safeVersion: safeVersionDeployed, contractNetworks }) @@ -206,12 +196,10 @@ describe('Safe Info', () => { ) it('should return the address of a deployed Safe', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -219,30 +207,27 @@ describe('Safe Info', () => { }) }) - describe('getEthAdapter', async () => { - it('should return the connected EthAdapter', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + describe('getEip1193Provider', async () => { + it('should return the connected SafeProvider', async () => { + const { safe, accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: safeAddress, contractNetworks }) chai - .expect(await safeSdk.getEthAdapter().getSignerAddress()) + .expect(await safeSdk.getSafeProvider().getSignerAddress()) .to.be.eq(await account1.signer.getAddress()) }) }) describe('getNonce', async () => { it('should return the nonce of a Safe that is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -250,13 +235,12 @@ describe('Safe Info', () => { }) it('should return the Safe nonce', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: safeAddress, contractNetworks }) @@ -276,11 +260,9 @@ describe('Safe Info', () => { describe('getChainId', async () => { it('should return the chainId of a Safe that is not deployed', async () => { - const { predictedSafe, accounts, chainId, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, chainId, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -288,12 +270,10 @@ describe('Safe Info', () => { }) it('should return the chainId of the current network', async () => { - const { safe, accounts, chainId, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, chainId, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: safeAddress, contractNetworks }) @@ -305,11 +285,9 @@ describe('Safe Info', () => { itif(safeVersionDeployed < '1.3.0')( 'should fail to return the balance of a Safe { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -324,38 +302,49 @@ describe('Safe Info', () => { itif(safeVersionDeployed >= '1.3.0')( 'should return the balance of a Safe >=v1.3.0 that is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() + const { predictedSafe, accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) chai.expect(await safeSdk.getBalance()).to.be.eq(0n) - await account1.signer.sendTransaction({ + + const txResponse = await account1.signer.sendTransaction({ to: await safeSdk.getAddress(), value: BigInt(`${1e18}`) }) + await txResponse.wait(1) + + // TODO: Not working without this delay + await new Promise((resolve) => setTimeout(resolve, 500)) + chai.expect(await safeSdk.getBalance()).to.be.eq(BigInt(`${1e18}`)) } ) it('should return the balance of a deployed Safe', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, + signer: account1.address, safeAddress, contractNetworks }) chai.expect(await safeSdk.getBalance()).to.be.eq(0n) - await account1.signer.sendTransaction({ - to: await safeSdk.getAddress(), + + const txResponse = await account1.signer.sendTransaction({ + to: safeAddress, value: BigInt(`${1e18}`) }) + await txResponse.wait(1) + + // TODO: Not working without this delay + await new Promise((resolve) => setTimeout(resolve, 500)) + chai.expect(await safeSdk.getBalance()).to.be.eq(BigInt(`${1e18}`)) }) }) diff --git a/packages/protocol-kit/tests/e2e/createSafeDeploymentTransaction.test.ts b/packages/protocol-kit/tests/e2e/createSafeDeploymentTransaction.test.ts index 6e307d87c..5c4feb530 100644 --- a/packages/protocol-kit/tests/e2e/createSafeDeploymentTransaction.test.ts +++ b/packages/protocol-kit/tests/e2e/createSafeDeploymentTransaction.test.ts @@ -6,11 +6,12 @@ import { safeVersionDeployed } from '@safe-global/protocol-kit/hardhat/deploy/de import Safe, { PREDETERMINED_SALT_NONCE, PredictedSafeProps, + SafeProvider, encodeSetupCallData } from '@safe-global/protocol-kit/index' import { getContractNetworks } from './utils/setupContractNetworks' import { getSafeWithOwners, getFactory } from './utils/setupContracts' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' import { itif } from './utils/helpers' @@ -22,7 +23,7 @@ describe('createSafeDeploymentTransaction', () => { const accounts = await getAccounts() const chainId = BigInt(await getChainId()) const contractNetworks = await getContractNetworks(chainId) - + const provider = getEip1193Provider() const predictedSafe: PredictedSafeProps = { safeAccountConfig: { owners: [accounts[0].address], @@ -37,18 +38,16 @@ describe('createSafeDeploymentTransaction', () => { accounts, contractNetworks, predictedSafe, - chainId + chainId, + provider } }) itif(safeVersionDeployed == '1.4.1')('should return a Safe deployment transactions', async () => { - const { accounts, contractNetworks, predictedSafe } = await setupTests() - const [account1] = accounts - - const ethAdapter = await getEthAdapter(account1.signer) + const { contractNetworks, predictedSafe, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -66,13 +65,10 @@ describe('createSafeDeploymentTransaction', () => { }) itif(safeVersionDeployed == '1.3.0')('should return a Safe deployment transactions', async () => { - const { accounts, contractNetworks, predictedSafe } = await setupTests() - const [account1] = accounts - - const ethAdapter = await getEthAdapter(account1.signer) + const { contractNetworks, predictedSafe, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -90,13 +86,10 @@ describe('createSafeDeploymentTransaction', () => { }) itif(safeVersionDeployed == '1.2.0')('should return a Safe deployment transactions', async () => { - const { accounts, contractNetworks, predictedSafe } = await setupTests() - const [account1] = accounts - - const ethAdapter = await getEthAdapter(account1.signer) + const { contractNetworks, predictedSafe, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -114,13 +107,10 @@ describe('createSafeDeploymentTransaction', () => { }) itif(safeVersionDeployed == '1.1.1')('should return a Safe deployment transactions', async () => { - const { accounts, contractNetworks, predictedSafe } = await setupTests() - const [account1] = accounts - - const ethAdapter = await getEthAdapter(account1.signer) + const { contractNetworks, predictedSafe, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -138,13 +128,10 @@ describe('createSafeDeploymentTransaction', () => { }) itif(safeVersionDeployed == '1.0.0')('should return a Safe deployment transactions', async () => { - const { accounts, contractNetworks, predictedSafe } = await setupTests() - const [account1] = accounts - - const ethAdapter = await getEthAdapter(account1.signer) + const { contractNetworks, predictedSafe, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -162,21 +149,18 @@ describe('createSafeDeploymentTransaction', () => { }) it('should contain the initializer setup call in the deployment data to sets the threshold & owners of the deployed Safe', async () => { - const { accounts, contractNetworks, predictedSafe, chainId } = await setupTests() - const [account1] = accounts - - const ethAdapter = await getEthAdapter(account1.signer) + const { contractNetworks, predictedSafe, chainId, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) - + const safeProvider = safeSdk.getSafeProvider() const deploymentTransaction = await safeSdk.createSafeDeploymentTransaction() const customContract = contractNetworks[chainId.toString()] - const safeContract = await ethAdapter.getSafeContract({ + const safeContract = await safeProvider.getSafeContract({ safeVersion: safeVersionDeployed, customContractAddress: customContract?.safeSingletonAddress, customContractAbi: customContract?.safeSingletonAbi @@ -184,7 +168,7 @@ describe('createSafeDeploymentTransaction', () => { // this is the call to the setup method that sets the threshold & owners of the new Safe const initializer = await encodeSetupCallData({ - ethAdapter, + safeProvider, safeContract, safeAccountConfig: predictedSafe.safeAccountConfig, customContracts: contractNetworks[chainId.toString()] @@ -196,18 +180,16 @@ describe('createSafeDeploymentTransaction', () => { describe('salt nonce', () => { it('should include the predetermined salt nonce in the Safe deployment data', async () => { - const { accounts, contractNetworks, predictedSafe, chainId } = await setupTests() - const [account1] = accounts - - const ethAdapter = await getEthAdapter(account1.signer) + const { contractNetworks, predictedSafe, chainId, provider } = await setupTests() + const safeProvider = new SafeProvider({ provider }) const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) - const predeterminedSaltNonceEncoded = ethAdapter.encodeParameters( + const predeterminedSaltNonceEncoded = safeProvider.encodeParameters( ['uint256'], [`0x${Buffer.from(keccak_256(PREDETERMINED_SALT_NONCE + chainId)).toString('hex')}`] ) @@ -221,20 +203,18 @@ describe('createSafeDeploymentTransaction', () => { }) it('should include the custom salt nonce in the Safe deployment data', async () => { - const { accounts, contractNetworks, predictedSafe } = await setupTests() - const [account1] = accounts - - const ethAdapter = await getEthAdapter(account1.signer) + const { contractNetworks, predictedSafe, provider } = await setupTests() + const safeProvider = new SafeProvider({ provider }) const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) const customSaltNonce = '123456789' - const customSaltNonceEncoded = ethAdapter.encodeParameters(['uint256'], [customSaltNonce]) + const customSaltNonceEncoded = safeProvider.encodeParameters(['uint256'], [customSaltNonce]) const deploymentTransaction = await safeSdk.createSafeDeploymentTransaction(customSaltNonce) @@ -243,15 +223,12 @@ describe('createSafeDeploymentTransaction', () => { }) it('should include the salt nonce included in the safeDeploymentConfig in the Safe deployment data', async () => { - const { accounts, contractNetworks, predictedSafe } = await setupTests() - const [account1] = accounts - - const ethAdapter = await getEthAdapter(account1.signer) + const { contractNetworks, predictedSafe, provider } = await setupTests() const customSaltNonce = '123456789' const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe: { ...predictedSafe, safeDeploymentConfig: { @@ -262,7 +239,9 @@ describe('createSafeDeploymentTransaction', () => { contractNetworks }) - const saltNonceEncoded = ethAdapter.encodeParameters(['uint256'], [customSaltNonce]) + const saltNonceEncoded = safeSdk + .getSafeProvider() + .encodeParameters(['uint256'], [customSaltNonce]) const deploymentTransaction = await safeSdk.createSafeDeploymentTransaction(customSaltNonce) @@ -272,15 +251,14 @@ describe('createSafeDeploymentTransaction', () => { }) it('should throw an error if predicted Safe is not present', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) diff --git a/packages/protocol-kit/tests/e2e/createTransaction.test.ts b/packages/protocol-kit/tests/e2e/createTransaction.test.ts index 4e5717862..814e796c2 100644 --- a/packages/protocol-kit/tests/e2e/createTransaction.test.ts +++ b/packages/protocol-kit/tests/e2e/createTransaction.test.ts @@ -2,16 +2,17 @@ import { safeVersionDeployed } from '@safe-global/protocol-kit/hardhat/deploy/de import Safe, { PredictedSafeProps, SafeTransactionOptionalProps, - standardizeSafeTransactionData + standardizeSafeTransactionData, + SafeContractImplementationType as SafeContract } from '@safe-global/protocol-kit/index' -import { SafeContract, SafeTransactionDataPartial } from '@safe-global/safe-core-sdk-types' +import { SafeTransactionDataPartial } from '@safe-global/safe-core-sdk-types' import chai from 'chai' import chaiAsPromised from 'chai-as-promised' import { deployments } from 'hardhat' import { itif } from './utils/helpers' import { getContractNetworks } from './utils/setupContractNetworks' import { getERC20Mintable, getSafeWithOwners } from './utils/setupContracts' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' chai.use(chaiAsPromised) @@ -31,6 +32,7 @@ describe('Transactions creation', () => { const accounts = await getAccounts() const chainId = BigInt(await getChainId()) const contractNetworks = await getContractNetworks(chainId) + const provider = getEip1193Provider() const predictedSafe: PredictedSafeProps = { safeAccountConfig: { owners: [accounts[0].address], @@ -46,7 +48,8 @@ describe('Transactions creation', () => { accounts, chainId, contractNetworks, - predictedSafe + predictedSafe, + provider } }) @@ -54,13 +57,12 @@ describe('Transactions creation', () => { itif(safeVersionDeployed >= '1.3.0')( 'should return a transaction with safeTxGas=0 if safeVersion>=1.3.0 and gasPrice=0', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -71,7 +73,7 @@ describe('Transactions creation', () => { } const safeTxData = await standardizeSafeTransactionData({ safeContract: safeSdk.getContractManager().safeContract as SafeContract, - ethAdapter, + provider, tx: txDataPartial, contractNetworks }) @@ -82,13 +84,12 @@ describe('Transactions creation', () => { itif(safeVersionDeployed >= '1.3.0')( 'should return a transaction with estimated safeTxGas if safeVersion>=1.3.0 and gasPrice>0', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -100,7 +101,7 @@ describe('Transactions creation', () => { } const safeTxData = await standardizeSafeTransactionData({ safeContract: safeSdk.getContractManager().safeContract as SafeContract, - ethAdapter, + provider, tx: txDataPartial, contractNetworks }) @@ -111,13 +112,12 @@ describe('Transactions creation', () => { itif(safeVersionDeployed >= '1.3.0')( 'should return a transaction with defined safeTxGas if safeVersion>=1.3.0', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -130,7 +130,7 @@ describe('Transactions creation', () => { } const safeTxData = await standardizeSafeTransactionData({ safeContract: safeSdk.getContractManager().safeContract as SafeContract, - ethAdapter, + provider, tx: txDataPartial, contractNetworks }) @@ -141,13 +141,12 @@ describe('Transactions creation', () => { itif(safeVersionDeployed < '1.3.0')( 'should return a transaction with estimated safeTxGas if safeVersion<1.3.0', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -158,7 +157,7 @@ describe('Transactions creation', () => { } const safeTxData = await standardizeSafeTransactionData({ safeContract: safeSdk.getContractManager().safeContract as SafeContract, - ethAdapter, + provider, tx: txDataPartial, contractNetworks }) @@ -169,13 +168,12 @@ describe('Transactions creation', () => { itif(safeVersionDeployed < '1.3.0')( 'should return a transaction with defined safeTxGas of 0 if safeVersion<1.3.0', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -188,7 +186,7 @@ describe('Transactions creation', () => { } const safeTxData = await standardizeSafeTransactionData({ safeContract: safeSdk.getContractManager().safeContract as SafeContract, - ethAdapter, + provider, tx: txDataPartial, contractNetworks }) @@ -199,13 +197,12 @@ describe('Transactions creation', () => { itif(safeVersionDeployed < '1.3.0')( 'should return a transaction with defined safeTxGas if safeVersion<1.3.0', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -218,7 +215,7 @@ describe('Transactions creation', () => { } const safeTxData = await standardizeSafeTransactionData({ safeContract: safeSdk.getContractManager().safeContract as SafeContract, - ethAdapter, + provider, tx: txDataPartial, contractNetworks }) @@ -229,11 +226,10 @@ describe('Transactions creation', () => { describe('createTransaction', async () => { it('should create a single transaction with gasPrice=0', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, accounts, contractNetworks, provider } = await setupTests() + const [, account2] = accounts const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -251,13 +247,12 @@ describe('Transactions creation', () => { }) it('should create a single transaction with gasPrice=0', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -282,13 +277,12 @@ describe('Transactions creation', () => { }) it('should create a single transaction with gasPrice>0', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -313,13 +307,12 @@ describe('Transactions creation', () => { }) it('should create a single transaction when passing a transaction array with length=1', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -335,13 +328,12 @@ describe('Transactions creation', () => { }) it('should create a single transaction when passing a transaction array with length=1 and options', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -364,13 +356,12 @@ describe('Transactions creation', () => { }) it('should fail when creating a MultiSend transaction passing a transaction array with length=0', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -379,13 +370,12 @@ describe('Transactions creation', () => { }) it('should create a MultiSend transaction', async () => { - const { accounts, contractNetworks, erc20Mintable, chainId } = await setupTests() + const { accounts, contractNetworks, erc20Mintable, chainId, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -414,13 +404,12 @@ describe('Transactions creation', () => { }) it('should create a MultiSend transaction with options', async () => { - const { accounts, contractNetworks, erc20Mintable, chainId } = await setupTests() + const { accounts, contractNetworks, erc20Mintable, chainId, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -460,12 +449,10 @@ describe('Transactions creation', () => { itif(safeVersionDeployed < '1.3.0')( 'should fail to create a transaction if the Safe with version { - const { safe, predictedSafe, accounts, contractNetworks } = await setupTests() - const account = accounts[0] - const ethAdapter = await getEthAdapter(account.signer) + const { safe, predictedSafe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) diff --git a/packages/protocol-kit/tests/e2e/createTransactionBatch.test.ts b/packages/protocol-kit/tests/e2e/createTransactionBatch.test.ts index d5e3e6c65..58a8f847f 100644 --- a/packages/protocol-kit/tests/e2e/createTransactionBatch.test.ts +++ b/packages/protocol-kit/tests/e2e/createTransactionBatch.test.ts @@ -5,7 +5,7 @@ import { safeVersionDeployed } from '@safe-global/protocol-kit/hardhat/deploy/de import Safe, { PredictedSafeProps } from '@safe-global/protocol-kit/index' import { getContractNetworks } from './utils/setupContractNetworks' import { getERC20Mintable, getSafeWithOwners, getMultiSendCallOnly } from './utils/setupContracts' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' import { OperationType } from '@safe-global/safe-core-sdk-types' @@ -44,11 +44,11 @@ describe('createTransactionBatch', () => { const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) + const provider = getEip1193Provider() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) diff --git a/packages/protocol-kit/tests/e2e/eip1271-contract-signatures.test.ts b/packages/protocol-kit/tests/e2e/eip1271-contract-signatures.test.ts index c7aac7a0c..d11181548 100644 --- a/packages/protocol-kit/tests/e2e/eip1271-contract-signatures.test.ts +++ b/packages/protocol-kit/tests/e2e/eip1271-contract-signatures.test.ts @@ -7,7 +7,7 @@ import chaiAsPromised from 'chai-as-promised' import { deployments } from 'hardhat' import { getContractNetworks } from './utils/setupContractNetworks' import { getSafeWithOwners } from './utils/setupContracts' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' import { waitSafeTxReceipt } from './utils/transactions' import { itif } from './utils/helpers' @@ -23,6 +23,7 @@ describe('The EIP1271 implementation', () => { const contractNetworks = await getContractNetworks(BigInt(chainId)) const fallbackHandlerAddress = contractNetworks[chainId].fallbackHandlerAddress const [account1, account2, account3, account4, account5] = accounts + const provider = getEip1193Provider() // Create a 1/1 signer Safe const signerSafe1_1 = await getSafeWithOwners( @@ -59,7 +60,8 @@ describe('The EIP1271 implementation', () => { accounts, contractNetworks, chainId, - fallbackHandlerAddress + fallbackHandlerAddress, + provider } }) @@ -71,20 +73,15 @@ describe('The EIP1271 implementation', () => { accounts, signerSafeAddress1_1, signerSafeAddress2_3, - contractNetworks + contractNetworks, + provider } = await setupTests() // Create adapters and the protocol kit instance const [account1, account2, account3, account4, account5] = accounts - const ethAdapter1 = await getEthAdapter(account1.signer) - const ethAdapter2 = await getEthAdapter(account2.signer) - const ethAdapter3 = await getEthAdapter(account3.signer) - const ethAdapter4 = await getEthAdapter(account4.signer) - const ethAdapter5 = await getEthAdapter(account5.signer) - let protocolKit = await Safe.create({ - ethAdapter: ethAdapter1, + provider: provider, safeAddress, contractNetworks }) @@ -102,12 +99,14 @@ describe('The EIP1271 implementation', () => { // EOA signatures tx = await protocolKit.signTransaction(tx) // Owner 1 signature - protocolKit = await protocolKit.connect({ ethAdapter: ethAdapter2 }) // Connect another owner + protocolKit = await protocolKit.connect({ + signer: account2.address + }) // Connect another owner tx = await protocolKit.signTransaction(tx) // Owner 2 signature // 1/1 Signer Safe signature protocolKit = await protocolKit.connect({ - ethAdapter: ethAdapter3, + signer: account3.address, safeAddress: signerSafeAddress1_1 }) let signerSafeTx1_1 = await protocolKit.createTransaction({ @@ -126,7 +125,7 @@ describe('The EIP1271 implementation', () => { // 2/3 Signer Safe signature protocolKit = await protocolKit.connect({ - ethAdapter: ethAdapter4, + signer: account4.address, safeAddress: signerSafeAddress2_3 }) let signerSafeTx2_3 = await protocolKit.createTransaction({ @@ -137,7 +136,9 @@ describe('The EIP1271 implementation', () => { SigningMethod.SAFE_SIGNATURE, safeAddress ) - protocolKit = await protocolKit.connect({ ethAdapter: ethAdapter5 }) + protocolKit = await protocolKit.connect({ + signer: account5.address + }) signerSafeTx2_3 = await protocolKit.signTransaction( signerSafeTx2_3, SigningMethod.SAFE_SIGNATURE, @@ -154,7 +155,11 @@ describe('The EIP1271 implementation', () => { to: safeAddress, value: 1_000_000_000_000_000_000n // 1 ETH }) - protocolKit = await protocolKit.connect({ ethAdapter: ethAdapter1, safeAddress }) + protocolKit = await protocolKit.connect({ + provider: provider, + signer: account1.address, + safeAddress + }) const execResponse = await protocolKit.executeTransaction(tx) await waitSafeTxReceipt(execResponse) @@ -173,7 +178,8 @@ describe('The EIP1271 implementation', () => { signerSafeAddress1_1, signerSafeAddress2_3, contractNetworks, - chainId + chainId, + provider } = await setupTests() const MESSAGE = { @@ -226,14 +232,8 @@ describe('The EIP1271 implementation', () => { // Create adapters and the protocol kit instance const [account1, account2, account3, account4, account5] = accounts - const ethAdapter1 = await getEthAdapter(account1.signer) - const ethAdapter2 = await getEthAdapter(account2.signer) - const ethAdapter3 = await getEthAdapter(account3.signer) - const ethAdapter4 = await getEthAdapter(account4.signer) - const ethAdapter5 = await getEthAdapter(account5.signer) - let protocolKit = await Safe.create({ - ethAdapter: ethAdapter1, + provider, safeAddress, contractNetworks }) @@ -242,12 +242,14 @@ describe('The EIP1271 implementation', () => { // EOA signatures message = await protocolKit.signMessage(message) // Owner 1 signature - protocolKit = await protocolKit.connect({ ethAdapter: ethAdapter2 }) // Connect another owner + protocolKit = await protocolKit.connect({ + signer: account2.address + }) // Connect another owner message = await protocolKit.signMessage(message) // Owner 2 signature // 1/1 Signer Safe signature protocolKit = await protocolKit.connect({ - ethAdapter: ethAdapter3, + signer: account3.address, safeAddress: signerSafeAddress1_1 }) let signerSafeMessage1_1 = protocolKit.createMessage(MESSAGE) @@ -264,7 +266,7 @@ describe('The EIP1271 implementation', () => { // 2/3 Signer Safe signature protocolKit = await protocolKit.connect({ - ethAdapter: ethAdapter4, + signer: account4.address, safeAddress: signerSafeAddress2_3 }) let signerSafeMessage2_3 = protocolKit.createMessage(MESSAGE) @@ -273,7 +275,9 @@ describe('The EIP1271 implementation', () => { SigningMethod.SAFE_SIGNATURE, safeAddress ) - protocolKit = await protocolKit.connect({ ethAdapter: ethAdapter5 }) + protocolKit = await protocolKit.connect({ + signer: account5.address + }) signerSafeMessage2_3 = await protocolKit.signMessage( signerSafeMessage2_3, SigningMethod.SAFE_SIGNATURE, @@ -286,7 +290,10 @@ describe('The EIP1271 implementation', () => { message.addSignature(signerSafeSig2_3) // Connect the original Safe - protocolKit = await protocolKit.connect({ ethAdapter: ethAdapter1, safeAddress }) + protocolKit = await protocolKit.connect({ + signer: account1.address, + safeAddress + }) chai.expect( await protocolKit.isValidSignature(hashSafeMessage(MESSAGE), message.encodedSignatures()) diff --git a/packages/protocol-kit/tests/e2e/eip1271.test.ts b/packages/protocol-kit/tests/e2e/eip1271.test.ts index 47f772272..8e97e5655 100644 --- a/packages/protocol-kit/tests/e2e/eip1271.test.ts +++ b/packages/protocol-kit/tests/e2e/eip1271.test.ts @@ -14,7 +14,7 @@ import chaiAsPromised from 'chai-as-promised' import { deployments } from 'hardhat' import { getContractNetworks } from './utils/setupContractNetworks' import { getSafeWithOwners } from './utils/setupContracts' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' import { waitSafeTxReceipt } from './utils/transactions' import { itif } from './utils/helpers' @@ -48,6 +48,7 @@ describe('The EIP1271 implementation', () => { const contractNetworks = await getContractNetworks(BigInt(chainId)) const fallbackHandlerAddress = contractNetworks[chainId].fallbackHandlerAddress const [account1, account2] = accounts + const provider = getEip1193Provider() // Create a 1/2 Safe to sign the messages const signerSafe = await getSafeWithOwners( @@ -65,25 +66,24 @@ describe('The EIP1271 implementation', () => { ) const safeAddress = await safe.getAddress() - // Adapter and Safe instance for owner 1 - const ethAdapter1 = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter: ethAdapter1, + provider, safeAddress, contractNetworks }) // Adapter and Safe instance for owner 2 - const ethAdapter2 = await getEthAdapter(account2.signer) const safeSdk2 = await Safe.create({ - ethAdapter: ethAdapter2, + provider, + signer: account2.address, safeAddress, contractNetworks }) // Adapter and Safe instance for owner 3 const safeSdk3 = await Safe.create({ - ethAdapter: ethAdapter1, + provider, + signer: account1.address, safeAddress: signerSafeAddress, contractNetworks }) @@ -95,9 +95,8 @@ describe('The EIP1271 implementation', () => { signerSafeAddress, accounts, contractNetworks, + provider, chainId, - ethAdapter1, - ethAdapter2, safeSdk1, safeSdk2, safeSdk3, @@ -108,14 +107,14 @@ describe('The EIP1271 implementation', () => { itif(safeVersionDeployed >= '1.3.0')( 'should validate on-chain messages (Approved hashes)', async () => { - const { contractNetworks, safeSdk1, safeSdk2, ethAdapter1 } = await setupTests() + const { contractNetworks, safeSdk1, safeSdk2 } = await setupTests() const chainId = await safeSdk1.getChainId() const safeVersion = await safeSdk1.getContractVersion() const customContract = contractNetworks[chainId.toString()] - const signMessageLibContract = await ethAdapter1.getSignMessageLibContract({ + const signMessageLibContract = await safeSdk1.getSafeProvider().getSignMessageLibContract({ safeVersion, customContractAddress: customContract.signMessageLibAddress, customContractAbi: customContract.signMessageLibAbi @@ -380,7 +379,7 @@ describe('The EIP1271 implementation', () => { // EOA sign const safeMessage1 = safeSdk1.createMessage(MESSAGE) const signedMessage1: SafeMessage = await safeSdk1.signMessage(safeMessage1) - const signerAddress1 = (await safeSdk1.getEthAdapter().getSignerAddress()) as string + const signerAddress1 = (await safeSdk1.getSafeProvider().getSignerAddress()) as string const ethSig = signedMessage1.getSignature(signerAddress1) as EthSafeSignature // Signer Safe sign @@ -390,7 +389,7 @@ describe('The EIP1271 implementation', () => { SigningMethod.SAFE_SIGNATURE, safeAddress ) - const signerAddress2 = (await safeSdk3.getEthAdapter().getSignerAddress()) as string + const signerAddress2 = (await safeSdk3.getSafeProvider().getSignerAddress()) as string const safeSignerSig = await buildContractSignature( [signedMessage2.getSignature(signerAddress2) as EthSafeSignature], signerSafeAddress diff --git a/packages/protocol-kit/tests/e2e/erc-20.test.ts b/packages/protocol-kit/tests/e2e/erc-20.test.ts index d9018189b..82b44fc7f 100644 --- a/packages/protocol-kit/tests/e2e/erc-20.test.ts +++ b/packages/protocol-kit/tests/e2e/erc-20.test.ts @@ -1,4 +1,5 @@ import Safe, { + SafeProvider, createERC20TokenTransferTransaction, getERC20Decimals, isGasTokenCompatibleWithHandlePayment @@ -11,7 +12,7 @@ import sinonChai from 'sinon-chai' import { deployments } from 'hardhat' import { itif } from './utils/helpers' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getContractNetworks } from './utils/setupContractNetworks' import { getSafeWithOwners } from './utils/setupContracts' import { getAccounts } from './utils/setupTestNetwork' @@ -23,16 +24,24 @@ chai.use(chaiAsPromised) const ERC20_TOKEN_ADDRESS = '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d' describe('ERC-20 utils', () => { + let callStub: sinon.SinonStub + + afterEach(() => { + callStub.restore() + }) + const setupTests = deployments.createFixture(async ({ deployments, getChainId }) => { await deployments.fixture() const accounts = await getAccounts() const chainId = BigInt(await getChainId()) const contractNetworks = await getContractNetworks(chainId) + const provider = getEip1193Provider() return { safe: await getSafeWithOwners([accounts[0].address, accounts[1].address]), contractNetworks, - accounts + accounts, + provider } }) @@ -40,19 +49,15 @@ describe('ERC-20 utils', () => { itif(safeVersionDeployed >= '1.3.0')( 'should return the correct decimals for a standard ERC20 token', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() - const [account1] = accounts - - const ethAdapter = await getEthAdapter(account1.signer) - // mock decimals() call - sinon.stub(ethAdapter, 'call').returns(Promise.resolve('0x12')) + callStub = sinon.stub(SafeProvider.prototype, 'call').returns(Promise.resolve('0x12')) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -66,18 +71,14 @@ describe('ERC-20 utils', () => { itif(safeVersionDeployed >= '1.3.0')( 'should return the correct decimals for a non-standard ERC20 token', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() - const [account1] = accounts - - const ethAdapter = await getEthAdapter(account1.signer) - // mock decimals() call - sinon.stub(ethAdapter, 'call').returns(Promise.resolve('0x06')) + callStub = sinon.stub(SafeProvider.prototype, 'call').returns(Promise.resolve('0x06')) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -91,18 +92,14 @@ describe('ERC-20 utils', () => { itif(safeVersionDeployed >= '1.3.0')( 'should throw an error if decimals() fn is not defined', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() - const [account1] = accounts - - const ethAdapter = await getEthAdapter(account1.signer) - // mock decimals() call - sinon.stub(ethAdapter, 'call').returns(Promise.resolve('0x')) + callStub = sinon.stub(SafeProvider.prototype, 'call').returns(Promise.resolve('0x')) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -118,15 +115,11 @@ describe('ERC-20 utils', () => { itif(safeVersionDeployed >= '1.3.0')( 'should return true if it is the Native token', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() - const [account1] = accounts - - const ethAdapter = await getEthAdapter(account1.signer) - const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -143,18 +136,14 @@ describe('ERC-20 utils', () => { itif(safeVersionDeployed >= '1.3.0')( 'should return true if it is an standard ERC20 token', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() - const [account1] = accounts - - const ethAdapter = await getEthAdapter(account1.signer) - // mock decimals() call - sinon.stub(ethAdapter, 'call').returns(Promise.resolve('0x12')) + callStub = sinon.stub(SafeProvider.prototype, 'call').returns(Promise.resolve('0x12')) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -171,18 +160,14 @@ describe('ERC-20 utils', () => { itif(safeVersionDeployed >= '1.3.0')( 'should return false for a non-standard ERC20 token', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() - const [account1] = accounts - - const ethAdapter = await getEthAdapter(account1.signer) - // mock decimals() call - sinon.stub(ethAdapter, 'call').returns(Promise.resolve('0x06')) + callStub = sinon.stub(SafeProvider.prototype, 'call').returns(Promise.resolve('0x06')) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -202,11 +187,7 @@ describe('ERC-20 utils', () => { const toAddress = '0xbc2BB26a6d821e69A38016f3858561a1D80d4182' const amount = '12345' - const transfer = await createERC20TokenTransferTransaction( - ERC20_TOKEN_ADDRESS, - toAddress, - amount - ) + const transfer = createERC20TokenTransferTransaction(ERC20_TOKEN_ADDRESS, toAddress, amount) chai.expect(transfer).to.be.deep.equal({ to: ERC20_TOKEN_ADDRESS, diff --git a/packages/protocol-kit/tests/e2e/execution.test.ts b/packages/protocol-kit/tests/e2e/execution.test.ts index 0baf12792..fccd152da 100644 --- a/packages/protocol-kit/tests/e2e/execution.test.ts +++ b/packages/protocol-kit/tests/e2e/execution.test.ts @@ -1,17 +1,13 @@ import { safeVersionDeployed } from '@safe-global/protocol-kit/hardhat/deploy/deploy-contracts' -import Safe, { - EthersTransactionOptions, - SigningMethod, - Web3TransactionOptions -} from '@safe-global/protocol-kit/index' -import { MetaTransactionData, TransactionOptions } from '@safe-global/safe-core-sdk-types' +import Safe, { SigningMethod } from '@safe-global/protocol-kit/index' +import { TransactionOptions, MetaTransactionData } from '@safe-global/safe-core-sdk-types' import chai from 'chai' import chaiAsPromised from 'chai-as-promised' import { deployments } from 'hardhat' import { itif } from './utils/helpers' import { getContractNetworks } from './utils/setupContractNetworks' import { getERC20Mintable, getSafeWithOwners } from './utils/setupContracts' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' import { waitSafeTxReceipt } from './utils/transactions' @@ -23,29 +19,30 @@ describe('Transactions execution', () => { const accounts = await getAccounts() const chainId = BigInt(await getChainId()) const contractNetworks = await getContractNetworks(chainId) + const provider = getEip1193Provider() + return { erc20Mintable: await getERC20Mintable(), safe: await getSafeWithOwners([accounts[0].address, accounts[1].address]), accounts, - contractNetworks + contractNetworks, + provider } }) describe('isValidTransaction', async () => { it('should return false if a transaction will not be executed successfully', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter1 = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter: ethAdapter1, + provider, safeAddress, contractNetworks }) - const ethAdapter2 = await getEthAdapter(account2.signer) const safeSdk2 = await safeSdk1.connect({ - ethAdapter: ethAdapter2, + signer: account2.address, contractNetworks }) await account1.signer.sendTransaction({ @@ -71,13 +68,12 @@ describe('Transactions execution', () => { }) it('should return true if a transaction will execute successfully', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -101,13 +97,12 @@ describe('Transactions execution', () => { describe('executeTransaction', async () => { it('should fail if there are not enough Ether funds', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -125,18 +120,19 @@ describe('Transactions execution', () => { }) it('should fail if there are not enough signatures (1 missing)', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2, account3] = accounts const safe = await getSafeWithOwners([account1.address, account2.address, account3.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) - const ethAdapter2 = await getEthAdapter(account2.signer) - const safeSdk2 = await safeSdk1.connect({ ethAdapter: ethAdapter2 }) + + const safeSdk2 = await safeSdk1.connect({ + signer: account2.address + }) const safeTransactionData = { to: safeAddress, value: '0', @@ -153,13 +149,12 @@ describe('Transactions execution', () => { }) it('should fail if there are not enough signatures (>1 missing)', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2, account3] = accounts const safe = await getSafeWithOwners([account1.address, account2.address, account3.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -175,19 +170,17 @@ describe('Transactions execution', () => { }) it('should fail if the user tries to execute a transaction that was rejected', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter1 = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter: ethAdapter1, + provider, safeAddress, contractNetworks }) - const ethAdapter2 = await getEthAdapter(account2.signer) const safeSdk2 = await safeSdk1.connect({ - ethAdapter: ethAdapter2, + signer: account2.address, contractNetworks }) await account1.signer.sendTransaction({ @@ -205,46 +198,33 @@ describe('Transactions execution', () => { const txRejectResponse = await safeSdk2.executeTransaction(signedRejectTx) await waitSafeTxReceipt(txRejectResponse) const signedTx = await safeSdk1.signTransaction(tx) - await chai - .expect(safeSdk2.executeTransaction(signedTx)) - .to.be.rejectedWith(safeVersionDeployed >= '1.3.0' ? 'GS026' : 'Invalid owner provided') - }) - - it('should fail if a user tries to execute a transaction with options: { gas, gasLimit }', async () => { - const { accounts, contractNetworks } = await setupTests() - const [account1, account2] = accounts - const safe = await getSafeWithOwners([account1.address]) - const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) - const safeSdk1 = await Safe.create({ - ethAdapter, - safeAddress, - contractNetworks - }) - await account1.signer.sendTransaction({ - to: safeAddress, - value: 1_000_000_000_000_000_000n // 1 ETH - }) - const safeTransactionData = { - to: account2.address, - value: '500000000000000000', // 0.5 ETH - data: '0x' + try { + await safeSdk2.executeTransaction(signedTx) + } catch (error) { + console.log(error) + } + if (process.env.ETH_LIB === 'viem') { + try { + await safeSdk2.executeTransaction(signedTx) + } catch (error) { + chai + .expect((error as any)?.info?.error?.message) + .includes(safeVersionDeployed >= '1.3.0' ? 'GS026' : 'Invalid owner provided') + } + } else { + await chai + .expect(safeSdk2.executeTransaction(signedTx)) + .to.be.rejectedWith(safeVersionDeployed >= '1.3.0' ? 'GS026' : 'Invalid owner provided') } - const tx = await safeSdk1.createTransaction({ transactions: [safeTransactionData] }) - const options: TransactionOptions = { gas: 123456, gasLimit: 123456 } - await chai - .expect(safeSdk1.executeTransaction(tx, options)) - .to.be.rejectedWith('Cannot specify gas and gasLimit together in transaction options') }) it('should fail if a user tries to execute a transaction with options: { nonce: }', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -258,20 +238,19 @@ describe('Transactions execution', () => { data: '0x' } const tx = await safeSdk1.createTransaction({ transactions: [safeTransactionData] }) - const execOptions: EthersTransactionOptions = { nonce: 123456789 } + const execOptions: TransactionOptions = { nonce: 123456789 } await chai .expect(safeSdk1.executeTransaction(tx, execOptions)) .to.be.rejectedWith('Nonce too high') }) it('should execute a transaction with threshold 1', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -298,7 +277,7 @@ describe('Transactions execution', () => { itif(process.env.ETH_LIB === 'web3' && safeVersionDeployed === '1.0.0')( 'should execute a transaction with threshold >1 and all different kind of signatures with web3 provider and safeVersion===1.0.0', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2, account3] = accounts const safe = await getSafeWithOwners([account1.address, account2.address, account3.address]) const safeAddress = await safe.getAddress() @@ -306,16 +285,17 @@ describe('Transactions execution', () => { to: safeAddress, value: 1_000_000_000_000_000_000n // 1 ETH }) - const ethAdapter1 = await getEthAdapter(account1.signer) - const ethAdapter2 = await getEthAdapter(account2.signer) - const ethAdapter3 = await getEthAdapter(account3.signer) const safeSdk1 = await Safe.create({ - ethAdapter: ethAdapter1, + provider, safeAddress, contractNetworks }) - const safeSdk2 = await safeSdk1.connect({ ethAdapter: ethAdapter2 }) - const safeSdk3 = await safeSdk1.connect({ ethAdapter: ethAdapter3 }) + const safeSdk2 = await safeSdk1.connect({ + signer: account2.address + }) + const safeSdk3 = await safeSdk1.connect({ + signer: account3.address + }) const safeInitialBalance = await safeSdk1.getBalance() const safeTransactionData = { to: account2.address, @@ -345,7 +325,7 @@ describe('Transactions execution', () => { itif(process.env.ETH_LIB === 'web3' && safeVersionDeployed > '1.0.0')( 'should execute a transaction with threshold >1 and all different kind of signatures with web3 provider and safeVersion>1.0.0', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2, account3, account4] = accounts const safe = await getSafeWithOwners([ account1.address, @@ -358,18 +338,20 @@ describe('Transactions execution', () => { to: safeAddress, value: 1_000_000_000_000_000_000n // 1 ETH }) - const ethAdapter1 = await getEthAdapter(account1.signer) - const ethAdapter2 = await getEthAdapter(account2.signer) - const ethAdapter3 = await getEthAdapter(account3.signer) - const ethAdapter4 = await getEthAdapter(account4.signer) const safeSdk1 = await Safe.create({ - ethAdapter: ethAdapter1, + provider, safeAddress, contractNetworks }) - const safeSdk2 = await safeSdk1.connect({ ethAdapter: ethAdapter2 }) - const safeSdk3 = await safeSdk1.connect({ ethAdapter: ethAdapter3 }) - const safeSdk4 = await safeSdk1.connect({ ethAdapter: ethAdapter4 }) + const safeSdk2 = await safeSdk1.connect({ + signer: account2.address + }) + const safeSdk3 = await safeSdk1.connect({ + signer: account3.address + }) + const safeSdk4 = await safeSdk1.connect({ + signer: account4.address + }) const safeInitialBalance = await safeSdk1.getBalance() const safeTransactionData = { to: account2.address, @@ -394,6 +376,7 @@ describe('Transactions execution', () => { const txResponse2 = await safeSdk1.executeTransaction(signedTx) await waitSafeTxReceipt(txResponse2) + await new Promise((resolve) => setTimeout(resolve, 500)) const safeFinalBalance = await safeSdk1.getBalance() chai.expect(safeInitialBalance).to.be.eq(safeFinalBalance + BigInt(tx.data.value)) } @@ -402,7 +385,7 @@ describe('Transactions execution', () => { itif(process.env.ETH_LIB === 'ethers' && safeVersionDeployed === '1.0.0')( 'should execute a transaction with threshold >1 and all different kind of signatures with ethers provider and safeVersion===1.0.0', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2, account3, account4, account5] = accounts const safe = await getSafeWithOwners([ account1.address, @@ -416,20 +399,23 @@ describe('Transactions execution', () => { to: safeAddress, value: 1_000_000_000_000_000_000n // 1 ETH }) - const ethAdapter1 = await getEthAdapter(account1.signer) - const ethAdapter2 = await getEthAdapter(account2.signer) - const ethAdapter3 = await getEthAdapter(account3.signer) - const ethAdapter4 = await getEthAdapter(account4.signer) - const ethAdapter5 = await getEthAdapter(account5.signer) const safeSdk1 = await Safe.create({ - ethAdapter: ethAdapter1, + provider, safeAddress, contractNetworks }) - const safeSdk2 = await safeSdk1.connect({ ethAdapter: ethAdapter2 }) - const safeSdk3 = await safeSdk1.connect({ ethAdapter: ethAdapter3 }) - const safeSdk4 = await safeSdk1.connect({ ethAdapter: ethAdapter4 }) - const safeSdk5 = await safeSdk1.connect({ ethAdapter: ethAdapter5 }) + const safeSdk2 = await safeSdk1.connect({ + signer: account2.address + }) + const safeSdk3 = await safeSdk1.connect({ + signer: account3.address + }) + const safeSdk4 = await safeSdk1.connect({ + signer: account4.address + }) + const safeSdk5 = await safeSdk1.connect({ + signer: account5.address + }) const safeInitialBalance = await safeSdk1.getBalance() const safeTransactionData = { to: account2.address, @@ -465,7 +451,7 @@ describe('Transactions execution', () => { itif(process.env.ETH_LIB === 'ethers' && safeVersionDeployed > '1.0.0')( 'should execute a transaction with threshold >1 and all different kind of signatures with ethers provider and safeVersion>1.0.0', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2, account3, account4, account5, account6] = accounts const safe = await getSafeWithOwners([ account1.address, @@ -480,22 +466,26 @@ describe('Transactions execution', () => { to: safeAddress, value: 1_000_000_000_000_000_000n // 1 ETH }) - const ethAdapter1 = await getEthAdapter(account1.signer) - const ethAdapter2 = await getEthAdapter(account2.signer) - const ethAdapter3 = await getEthAdapter(account3.signer) - const ethAdapter4 = await getEthAdapter(account4.signer) - const ethAdapter5 = await getEthAdapter(account5.signer) - const ethAdapter6 = await getEthAdapter(account6.signer) const safeSdk1 = await Safe.create({ - ethAdapter: ethAdapter1, + provider, safeAddress, contractNetworks }) - const safeSdk2 = await safeSdk1.connect({ ethAdapter: ethAdapter2 }) - const safeSdk3 = await safeSdk1.connect({ ethAdapter: ethAdapter3 }) - const safeSdk4 = await safeSdk1.connect({ ethAdapter: ethAdapter4 }) - const safeSdk5 = await safeSdk1.connect({ ethAdapter: ethAdapter5 }) - const safeSdk6 = await safeSdk1.connect({ ethAdapter: ethAdapter6 }) + const safeSdk2 = await safeSdk1.connect({ + signer: account2.address + }) + const safeSdk3 = await safeSdk1.connect({ + signer: account3.address + }) + const safeSdk4 = await safeSdk1.connect({ + signer: account4.address + }) + const safeSdk5 = await safeSdk1.connect({ + signer: account5.address + }) + const safeSdk6 = await safeSdk1.connect({ + signer: account6.address + }) const safeInitialBalance = await safeSdk1.getBalance() const safeTransactionData = { to: account2.address, @@ -532,19 +522,22 @@ describe('Transactions execution', () => { ) it('should execute a transaction when is not submitted by an owner', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1, account2, account3] = accounts - const ethAdapter1 = await getEthAdapter(account1.signer) + const { safe, accounts, contractNetworks, provider } = await setupTests() + const [, account2, account3] = accounts const safeAddress = await safe.getAddress() const safeSdk1 = await Safe.create({ - ethAdapter: ethAdapter1, + provider, safeAddress, contractNetworks }) - const ethAdapter2 = await getEthAdapter(account2.signer) - const safeSdk2 = await safeSdk1.connect({ ethAdapter: ethAdapter2 }) - const ethAdapter3 = await getEthAdapter(account3.signer) - const safeSdk3 = await safeSdk1.connect({ ethAdapter: ethAdapter3 }) + const safeSdk2 = await safeSdk1.connect({ + signer: account2.address + }) + + const safeSdk3 = await safeSdk1.connect({ + signer: account3.address + }) + await account2.signer.sendTransaction({ to: safeAddress, value: 1_000_000_000_000_000_000n // 1 ETH @@ -569,13 +562,12 @@ describe('Transactions execution', () => { itif(process.env.ETH_LIB === 'ethers')( 'should execute a transaction with options: { gasLimit }', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -589,10 +581,10 @@ describe('Transactions execution', () => { data: '0x' } const tx = await safeSdk1.createTransaction({ transactions: [safeTransactionData] }) - const execOptions: EthersTransactionOptions = { gasLimit: 123456 } + const execOptions: TransactionOptions = { gasLimit: 123456 } const txResponse = await safeSdk1.executeTransaction(tx, execOptions) await waitSafeTxReceipt(txResponse) - const txConfirmed = await ethAdapter.getTransaction(txResponse.hash) + const txConfirmed = await safeSdk1.getSafeProvider().getTransaction(txResponse.hash) chai.expect(execOptions.gasLimit).to.be.eq(Number(txConfirmed.gasLimit)) } ) @@ -600,13 +592,12 @@ describe('Transactions execution', () => { itif(process.env.ETH_LIB === 'ethers')( 'should execute a transaction with options: { gasLimit, gasPrice }', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -620,13 +611,13 @@ describe('Transactions execution', () => { data: '0x' } const tx = await safeSdk1.createTransaction({ transactions: [safeTransactionData] }) - const execOptions: EthersTransactionOptions = { + const execOptions: TransactionOptions = { gasLimit: 123456, gasPrice: 170000000 } const txResponse = await safeSdk1.executeTransaction(tx, execOptions) await waitSafeTxReceipt(txResponse) - const txConfirmed = await ethAdapter.getTransaction(txResponse.hash) + const txConfirmed = await safeSdk1.getSafeProvider().getTransaction(txResponse.hash) chai.expect(execOptions.gasPrice).to.be.eq(Number(txConfirmed.gasPrice)) chai.expect(execOptions.gasLimit).to.be.eq(Number(txConfirmed.gasLimit)) } @@ -635,13 +626,12 @@ describe('Transactions execution', () => { itif(process.env.ETH_LIB === 'ethers')( 'should execute a transaction with options: { maxFeePerGas, maxPriorityFeePerGas }', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -661,7 +651,7 @@ describe('Transactions execution', () => { } const txResponse = await safeSdk1.executeTransaction(tx, execOptions) await waitSafeTxReceipt(txResponse) - const txConfirmed = await ethAdapter.getTransaction(txResponse.hash) + const txConfirmed = await safeSdk1.getSafeProvider().getTransaction(txResponse.hash) chai.expect(BigInt(execOptions.maxFeePerGas)).to.be.eq(txConfirmed.maxFeePerGas) chai .expect(BigInt(execOptions.maxPriorityFeePerGas)) @@ -670,15 +660,14 @@ describe('Transactions execution', () => { ) itif(process.env.ETH_LIB === 'web3')( - 'should execute a transaction with options: { gas }', + 'should execute a transaction with options: { gasPrice }', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -692,59 +681,26 @@ describe('Transactions execution', () => { data: '0x' } const tx = await safeSdk1.createTransaction({ transactions: [safeTransactionData] }) - const execOptions: Web3TransactionOptions = { gas: 123456 } - const txResponse = await safeSdk1.executeTransaction(tx, execOptions) - await waitSafeTxReceipt(txResponse) - const txConfirmed = await ethAdapter.getTransaction(txResponse.hash) - chai.expect(execOptions.gas).to.be.eq(txConfirmed.gas) - } - ) - - itif(process.env.ETH_LIB === 'web3')( - 'should execute a transaction with options: { gas, gasPrice }', - async () => { - const { accounts, contractNetworks } = await setupTests() - const [account1, account2] = accounts - const safe = await getSafeWithOwners([account1.address]) - const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) - const safeSdk1 = await Safe.create({ - ethAdapter, - safeAddress, - contractNetworks - }) - await account1.signer.sendTransaction({ - to: safeAddress, - value: 1_000_000_000_000_000_000n // 1 ETH - }) - const safeTransactionData = { - to: account2.address, - value: '500000000000000000', // 0.5 ETH - data: '0x' - } - const tx = await safeSdk1.createTransaction({ transactions: [safeTransactionData] }) - const execOptions: Web3TransactionOptions = { + const execOptions = { gas: 123456, gasPrice: 170000000 } const txResponse = await safeSdk1.executeTransaction(tx, execOptions) await waitSafeTxReceipt(txResponse) - const txConfirmed = await ethAdapter.getTransaction(txResponse.hash) + const txConfirmed = await safeSdk1.getSafeProvider().getTransaction(txResponse.hash) chai.expect(execOptions.gasPrice).to.be.eq(Number(txConfirmed.gasPrice)) - chai.expect(execOptions.gas).to.be.eq(txConfirmed.gas) } ) itif(process.env.ETH_LIB === 'web3')( 'should execute a transaction with options: { maxFeePerGas, maxPriorityFeePerGas }', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -764,7 +720,7 @@ describe('Transactions execution', () => { } const txResponse = await safeSdk1.executeTransaction(tx, execOptions) await waitSafeTxReceipt(txResponse) - const txConfirmed = await ethAdapter.getTransaction(txResponse.hash) + const txConfirmed = await safeSdk1.getSafeProvider().getTransaction(txResponse.hash) chai.expect(BigInt(execOptions.maxFeePerGas)).to.be.eq(BigInt(txConfirmed.maxFeePerGas)) chai .expect(BigInt(execOptions.maxPriorityFeePerGas)) @@ -773,13 +729,12 @@ describe('Transactions execution', () => { ) it('should execute a transaction with options: { nonce }', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -792,32 +747,35 @@ describe('Transactions execution', () => { value: '500000000000000000', // 0.5 ETH data: '0x' } - const currentNonce = await ethAdapter.getNonce(account1.address, 'pending') + const currentNonce = await safeSdk1.getSafeProvider().getNonce(account1.address, 'pending') const tx = await safeSdk1.createTransaction({ transactions: [safeTransactionData] }) - const execOptions: EthersTransactionOptions = { nonce: currentNonce } + const execOptions: TransactionOptions = { nonce: currentNonce } const txResponse = await safeSdk1.executeTransaction(tx, execOptions) await waitSafeTxReceipt(txResponse) - const txConfirmed = await ethAdapter.getTransaction(txResponse.hash) + const txConfirmed = await safeSdk1.getSafeProvider().getTransaction(txResponse.hash) chai.expect(execOptions.nonce).to.be.eq(txConfirmed.nonce) }) }) describe('executeTransaction (MultiSend)', async () => { it('should execute a batch transaction with threshold >1', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2, account3] = accounts const safe = await getSafeWithOwners([account1.address, account2.address, account3.address]) const safeAddress = await safe.getAddress() - const ethAdapter1 = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter: ethAdapter1, + provider, safeAddress, contractNetworks }) - const ethAdapter2 = await getEthAdapter(account2.signer) - const safeSdk2 = await safeSdk1.connect({ ethAdapter: ethAdapter2 }) - const ethAdapter3 = await getEthAdapter(account3.signer) - const safeSdk3 = await safeSdk1.connect({ ethAdapter: ethAdapter3 }) + + const safeSdk2 = await safeSdk1.connect({ + signer: account2.address + }) + + const safeSdk3 = await safeSdk1.connect({ + signer: account3.address + }) await account1.signer.sendTransaction({ to: safeAddress, value: 2_000_000_000_000_000_000n // 2 ETH @@ -849,20 +807,23 @@ describe('Transactions execution', () => { }) it('should execute a batch transaction with contract calls and threshold >1', async () => { - const { accounts, contractNetworks, erc20Mintable } = await setupTests() + const { accounts, contractNetworks, erc20Mintable, provider } = await setupTests() const [account1, account2, account3] = accounts const safe = await getSafeWithOwners([account1.address, account2.address, account3.address]) const safeAddress = await safe.getAddress() - const ethAdapter1 = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter: ethAdapter1, + provider, safeAddress, contractNetworks }) - const ethAdapter2 = await getEthAdapter(account2.signer) - const safeSdk2 = await safeSdk1.connect({ ethAdapter: ethAdapter2 }) - const ethAdapter3 = await getEthAdapter(account3.signer) - const safeSdk3 = await safeSdk1.connect({ ethAdapter: ethAdapter3 }) + + const safeSdk2 = await safeSdk1.connect({ + signer: account2.address + }) + + const safeSdk3 = await safeSdk1.connect({ + signer: account3.address + }) await erc20Mintable.mint(safeAddress, '1200000000000000000') // 1.2 ERC20 const safeInitialERC20Balance = await erc20Mintable.balanceOf(safeAddress) diff --git a/packages/protocol-kit/tests/e2e/fallbackHandlerManager.test.ts b/packages/protocol-kit/tests/e2e/fallbackHandlerManager.test.ts index 3adcc3159..1af49cb0f 100644 --- a/packages/protocol-kit/tests/e2e/fallbackHandlerManager.test.ts +++ b/packages/protocol-kit/tests/e2e/fallbackHandlerManager.test.ts @@ -14,7 +14,7 @@ import { getDefaultCallbackHandler, getSafeWithOwners } from './utils/setupContracts' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' import { waitSafeTxReceipt } from './utils/transactions' @@ -35,12 +35,15 @@ describe('Fallback handler manager', () => { safeVersion: safeVersionDeployed } } + const provider = getEip1193Provider() + return { safe: await getSafeWithOwners([accounts[0].address]), accounts, contractNetworks, defaultCallbackHandler: await getDefaultCallbackHandler(), - predictedSafe + predictedSafe, + provider } }) @@ -48,12 +51,10 @@ describe('Fallback handler manager', () => { itif(safeVersionDeployed < '1.1.1')( 'should fail if getting the enabled fallback handler is not supported', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -67,11 +68,9 @@ describe('Fallback handler manager', () => { ) itif(safeVersionDeployed >= '1.1.1')('should fail if the Safe is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -79,12 +78,10 @@ describe('Fallback handler manager', () => { }) itif(safeVersionDeployed >= '1.1.1')('should return the enabled fallback handler', async () => { - const { safe, accounts, contractNetworks, defaultCallbackHandler } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, defaultCallbackHandler, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -107,12 +104,10 @@ describe('Fallback handler manager', () => { itif(safeVersionDeployed < '1.3.0')( 'should fail if the Safe with version { - const { predictedSafe, accounts, contractNetworks, defaultCallbackHandler } = + const { predictedSafe, contractNetworks, defaultCallbackHandler, provider } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -128,12 +123,10 @@ describe('Fallback handler manager', () => { itif(safeVersionDeployed >= '1.3.0')( 'should fail if the Safe with version >=v1.3.0 is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks, defaultCallbackHandler } = + const { predictedSafe, contractNetworks, defaultCallbackHandler, provider } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -145,12 +138,10 @@ describe('Fallback handler manager', () => { itif(safeVersionDeployed < '1.1.1')( 'should fail if enabling a fallback handler is not supported', async () => { - const { safe, accounts, contractNetworks, defaultCallbackHandler } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, defaultCallbackHandler, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -164,12 +155,10 @@ describe('Fallback handler manager', () => { ) itif(safeVersionDeployed >= '1.1.1')('should fail if address is invalid', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -180,12 +169,10 @@ describe('Fallback handler manager', () => { itif(safeVersionDeployed >= '1.1.1')( 'should fail if address is equal to 0x address', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -195,12 +182,10 @@ describe('Fallback handler manager', () => { ) itif(safeVersionDeployed >= '1.1.1')('should fail if address is already enabled', async () => { - const { safe, accounts, contractNetworks, defaultCallbackHandler } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, defaultCallbackHandler, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -216,12 +201,10 @@ describe('Fallback handler manager', () => { itif(safeVersionDeployed >= '1.1.1')( 'should build the transaction with the optional props', async () => { - const { safe, accounts, contractNetworks, defaultCallbackHandler } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, defaultCallbackHandler, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -247,12 +230,10 @@ describe('Fallback handler manager', () => { ) itif(safeVersionDeployed >= '1.1.1')('should enable a fallback handler', async () => { - const { safe, accounts, contractNetworks, defaultCallbackHandler } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, defaultCallbackHandler, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -275,11 +256,9 @@ describe('Fallback handler manager', () => { itif(safeVersionDeployed < '1.3.0')( 'should fail if the Safe with version { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -295,12 +274,10 @@ describe('Fallback handler manager', () => { itif(safeVersionDeployed >= '1.3.0')( 'should fail if the Safe with version >=v1.3.0 is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks, defaultCallbackHandler } = + const { predictedSafe, contractNetworks, defaultCallbackHandler, provider } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -312,13 +289,12 @@ describe('Fallback handler manager', () => { itif(safeVersionDeployed < '1.1.1')( 'should fail if disabling a fallback handler is not supported', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -334,12 +310,10 @@ describe('Fallback handler manager', () => { itif(safeVersionDeployed >= '1.1.1')( 'should fail if no fallback handler is enabled', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -357,13 +331,12 @@ describe('Fallback handler manager', () => { itif(safeVersionDeployed >= '1.1.1')( 'should build the transaction with the optional props', async () => { - const { accounts, contractNetworks, defaultCallbackHandler } = await setupTests() + const { accounts, contractNetworks, defaultCallbackHandler, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -395,13 +368,12 @@ describe('Fallback handler manager', () => { ) itif(safeVersionDeployed >= '1.1.1')('should disable an enabled fallback handler', async () => { - const { accounts, contractNetworks, defaultCallbackHandler } = await setupTests() + const { accounts, contractNetworks, defaultCallbackHandler, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -411,6 +383,7 @@ describe('Fallback handler manager', () => { ) const txResponse = await safeSdk.executeTransaction(tx) await waitSafeTxReceipt(txResponse) + await new Promise((resolve) => setTimeout(resolve, 500)) chai .expect(await safeSdk.getFallbackHandler()) .to.be.eq(await defaultCallbackHandler.getAddress()) diff --git a/packages/protocol-kit/tests/e2e/getEncodedTransaction.test.ts b/packages/protocol-kit/tests/e2e/getEncodedTransaction.test.ts index 1f4056ec6..8cd49ca9b 100644 --- a/packages/protocol-kit/tests/e2e/getEncodedTransaction.test.ts +++ b/packages/protocol-kit/tests/e2e/getEncodedTransaction.test.ts @@ -4,7 +4,7 @@ import chai from 'chai' import { deployments } from 'hardhat' import { getContractNetworks } from './utils/setupContractNetworks' import { getSafeWithOwners } from './utils/setupContracts' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' import { itif } from './utils/helpers' @@ -14,22 +14,24 @@ describe('getEncodedTransaction', () => { const accounts = await getAccounts() const chainId = BigInt(await getChainId()) const contractNetworks = await getContractNetworks(chainId) + const provider = getEip1193Provider() + return { accounts, - contractNetworks + contractNetworks, + provider } }) itif(safeVersionDeployed >= '1.3.0')('should return a transaction encoded', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -52,15 +54,14 @@ describe('getEncodedTransaction', () => { }) itif(safeVersionDeployed <= '1.2.0')('should return a transaction encoded', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -83,15 +84,14 @@ describe('getEncodedTransaction', () => { }) it('should return a signed transaction with the signatures encoded', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) diff --git a/packages/protocol-kit/tests/e2e/guardManager.test.ts b/packages/protocol-kit/tests/e2e/guardManager.test.ts index 1d723acf5..35c04e427 100644 --- a/packages/protocol-kit/tests/e2e/guardManager.test.ts +++ b/packages/protocol-kit/tests/e2e/guardManager.test.ts @@ -10,7 +10,7 @@ import { deployments } from 'hardhat' import { itif } from './utils/helpers' import { getContractNetworks } from './utils/setupContractNetworks' import { getDebugTransactionGuard, getSafeWithOwners } from './utils/setupContracts' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' import { waitSafeTxReceipt } from './utils/transactions' @@ -22,6 +22,7 @@ describe('Safe guard manager', () => { const accounts = await getAccounts() const chainId = BigInt(await getChainId()) const contractNetworks = await getContractNetworks(chainId) + const provider = getEip1193Provider() const predictedSafe: PredictedSafeProps = { safeAccountConfig: { owners: [accounts[0].address], @@ -36,7 +37,8 @@ describe('Safe guard manager', () => { safe: await getSafeWithOwners([accounts[0].address]), accounts, contractNetworks, - predictedSafe + predictedSafe, + provider } }) @@ -44,12 +46,10 @@ describe('Safe guard manager', () => { itif(safeVersionDeployed < '1.3.0')( 'should fail if getting the enabled guard is not supported', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -63,11 +63,9 @@ describe('Safe guard manager', () => { ) itif(safeVersionDeployed >= '1.3.0')('should fail if the Safe is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -77,12 +75,10 @@ describe('Safe guard manager', () => { itif(safeVersionDeployed >= '1.3.0')( 'should return 0x address when no Safe guard is enabled', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -91,12 +87,10 @@ describe('Safe guard manager', () => { ) itif(safeVersionDeployed >= '1.3.0')('should return the enabled Safe guard', async () => { - const { safe, accounts, contractNetworks, debugTransactionGuard } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, debugTransactionGuard, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -112,12 +106,10 @@ describe('Safe guard manager', () => { itif(safeVersionDeployed < '1.3.0')( 'should fail if enabling a Safe guard is not supported', async () => { - const { safe, accounts, contractNetworks, debugTransactionGuard } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, debugTransactionGuard, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -131,12 +123,11 @@ describe('Safe guard manager', () => { ) itif(safeVersionDeployed >= '1.3.0')('should fail if the Safe is not deployed', async () => { - const { predictedSafe, accounts, debugTransactionGuard, contractNetworks } = + const { predictedSafe, debugTransactionGuard, contractNetworks, provider } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -145,12 +136,10 @@ describe('Safe guard manager', () => { }) itif(safeVersionDeployed >= '1.3.0')('should fail if address is invalid', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -161,12 +150,11 @@ describe('Safe guard manager', () => { itif(safeVersionDeployed >= '1.3.0')( 'should fail if address is equal to 0x address', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() + const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -176,12 +164,11 @@ describe('Safe guard manager', () => { ) itif(safeVersionDeployed >= '1.3.0')('should fail if address is already enabled', async () => { - const { safe, accounts, contractNetworks, debugTransactionGuard } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, debugTransactionGuard, provider } = await setupTests() + const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -195,12 +182,11 @@ describe('Safe guard manager', () => { itif(safeVersionDeployed >= '1.3.0')( 'should build the transaction with the optional props', async () => { - const { safe, accounts, contractNetworks, debugTransactionGuard } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, debugTransactionGuard, provider } = await setupTests() + const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -226,12 +212,11 @@ describe('Safe guard manager', () => { ) itif(safeVersionDeployed >= '1.3.0')('should enable a Safe guard', async () => { - const { safe, accounts, contractNetworks, debugTransactionGuard } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, debugTransactionGuard, provider } = await setupTests() + const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -247,13 +232,12 @@ describe('Safe guard manager', () => { itif(safeVersionDeployed < '1.3.0')( 'should fail if disabling a Safe guard is not supported', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -267,11 +251,10 @@ describe('Safe guard manager', () => { ) itif(safeVersionDeployed >= '1.3.0')('should fail if the Safe is not deployed', async () => { - const { accounts, predictedSafe, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() + const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -280,12 +263,11 @@ describe('Safe guard manager', () => { }) itif(safeVersionDeployed >= '1.3.0')('should fail if no Safe guard is enabled', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() + const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -296,13 +278,12 @@ describe('Safe guard manager', () => { itif(safeVersionDeployed >= '1.3.0')( 'should build the transaction with the optional props', async () => { - const { accounts, contractNetworks, debugTransactionGuard } = await setupTests() + const { accounts, contractNetworks, debugTransactionGuard, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -329,13 +310,12 @@ describe('Safe guard manager', () => { ) itif(safeVersionDeployed >= '1.3.0')('should disable an enabled Safe guard', async () => { - const { accounts, contractNetworks, debugTransactionGuard } = await setupTests() + const { accounts, contractNetworks, debugTransactionGuard, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) diff --git a/packages/protocol-kit/tests/e2e/moduleManager.test.ts b/packages/protocol-kit/tests/e2e/moduleManager.test.ts index c9366938a..62513be7c 100644 --- a/packages/protocol-kit/tests/e2e/moduleManager.test.ts +++ b/packages/protocol-kit/tests/e2e/moduleManager.test.ts @@ -11,11 +11,14 @@ import { getContractNetworks } from './utils/setupContractNetworks' import { getDailyLimitModule, getSafeWithOwners, - getSocialRecoveryModule + getSocialRecoveryModule, + getStateChannelModule, + getWhiteListModule } from './utils/setupContracts' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' import { waitSafeTxReceipt } from './utils/transactions' +import semverSatisfies from 'semver/functions/satisfies' chai.use(chaiAsPromised) @@ -34,23 +37,26 @@ describe('Safe modules manager', () => { safeVersion: safeVersionDeployed } } + const provider = getEip1193Provider() + return { dailyLimitModule: await getDailyLimitModule(), socialRecoveryModule: await getSocialRecoveryModule(), + stateChannelModule: await getStateChannelModule(), + whiteListModule: await getWhiteListModule(), safe: await getSafeWithOwners([accounts[0].address]), accounts, contractNetworks, - predictedSafe + predictedSafe, + provider } }) describe('getModules', async () => { it('should fail if the Safe is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -58,30 +64,38 @@ describe('Safe modules manager', () => { }) it('should return all the enabled modules', async () => { - const { safe, accounts, dailyLimitModule, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, dailyLimitModule, socialRecoveryModule, contractNetworks, provider } = + await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) chai.expect((await safeSdk.getModules()).length).to.be.eq(0) - const tx = await safeSdk.createEnableModuleTx(await dailyLimitModule.getAddress()) - const txResponse = await safeSdk.executeTransaction(tx) - await waitSafeTxReceipt(txResponse) - chai.expect((await safeSdk.getModules()).length).to.be.eq(1) + const enableDailyLimitModuleTx = await safeSdk.createEnableModuleTx( + await dailyLimitModule.getAddress() + ) + const enableDailyLimitModuleTxResponse = + await safeSdk.executeTransaction(enableDailyLimitModuleTx) + const socialRecoveryModuleTx = await safeSdk.createEnableModuleTx( + await socialRecoveryModule.getAddress() + ) + const socialRecoveryModuleTxResponse = + await safeSdk.executeTransaction(socialRecoveryModuleTx) + await Promise.all([ + waitSafeTxReceipt(enableDailyLimitModuleTxResponse), + waitSafeTxReceipt(socialRecoveryModuleTxResponse) + ]) + chai.expect((await safeSdk.getModules()).length).to.be.eq(2) }) }) describe('getModulesPaginated', async () => { it('should fail if the Safe is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -91,83 +105,149 @@ describe('Safe modules manager', () => { }) it('should return the enabled modules', async () => { - const { safe, accounts, dailyLimitModule, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, dailyLimitModule, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) - chai.expect((await safeSdk.getModulesPaginated(SENTINEL_ADDRESS, 10)).length).to.be.eq(0) + + const emptyModuleList = await safeSdk.getModulesPaginated(SENTINEL_ADDRESS, 10) const tx = await safeSdk.createEnableModuleTx(await dailyLimitModule.getAddress()) const txResponse = await safeSdk.executeTransaction(tx) await waitSafeTxReceipt(txResponse) - chai.expect((await safeSdk.getModulesPaginated(SENTINEL_ADDRESS, 10)).length).to.be.eq(1) + const moduleList = await safeSdk.getModulesPaginated(SENTINEL_ADDRESS, 10) + + chai.expect(emptyModuleList.modules.length).to.be.eq(0) + chai.expect(emptyModuleList.next).to.be.eq(SENTINEL_ADDRESS) + chai.expect(moduleList.modules.length).to.be.eq(1) + chai.expect(emptyModuleList.next).to.be.eq(SENTINEL_ADDRESS) }) it('should constraint returned modules by pageSize', async () => { - const { safe, accounts, dailyLimitModule, contractNetworks, socialRecoveryModule } = - await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { + safe, + dailyLimitModule, + contractNetworks, + socialRecoveryModule, + stateChannelModule, + whiteListModule, + provider + } = await setupTests() const safeAddress = await safe.getAddress() - const dailyLimitsAddress = await await dailyLimitModule.getAddress() - const socialRecoveryAddress = await await socialRecoveryModule.getAddress() + const dailyLimitsAddress = await dailyLimitModule.getAddress() + const socialRecoveryAddress = await socialRecoveryModule.getAddress() + const stateChannelAddress = await stateChannelModule.getAddress() + const whiteListAddress = await whiteListModule.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) + const currentPageNext = semverSatisfies(await safeSdk.getContractVersion(), '>=1.4.1') + + chai + .expect((await safeSdk.getModulesPaginated(SENTINEL_ADDRESS, 10)).modules.length) + .to.be.eq(0) + + const moduleDeployment = [ + dailyLimitsAddress, + socialRecoveryAddress, + stateChannelAddress, + whiteListAddress + ].map(async (moduleAddress) => { + const txModule = await safeSdk.createEnableModuleTx(moduleAddress) + const moduleResponse = await safeSdk.executeTransaction(txModule) + await waitSafeTxReceipt(moduleResponse) + }) + + await Promise.all(moduleDeployment) - chai.expect((await safeSdk.getModulesPaginated(SENTINEL_ADDRESS, 10)).length).to.be.eq(0) - const txDailyLimits = await safeSdk.createEnableModuleTx(dailyLimitsAddress) - const dailyLimitsResponse = await safeSdk.executeTransaction(txDailyLimits) - await waitSafeTxReceipt(dailyLimitsResponse) - const txSocialRecovery = await safeSdk.createEnableModuleTx(socialRecoveryAddress) - const soecialRecoveryResponse = await safeSdk.executeTransaction(txSocialRecovery) - await waitSafeTxReceipt(soecialRecoveryResponse) - - chai.expect((await safeSdk.getModulesPaginated(SENTINEL_ADDRESS, 10)).length).to.be.eq(2) - chai.expect((await safeSdk.getModulesPaginated(SENTINEL_ADDRESS, 1)).length).to.be.eq(1) - chai.expect((await safeSdk.getModulesPaginated(SENTINEL_ADDRESS, 1)).length).to.be.eq(1) + const modules1 = await safeSdk.getModulesPaginated(SENTINEL_ADDRESS, 10) + const modules2 = await safeSdk.getModulesPaginated(SENTINEL_ADDRESS, 1) + const modules3 = await safeSdk.getModulesPaginated(SENTINEL_ADDRESS, 2) + + chai.expect(modules1.modules.length).to.be.eq(4) + chai + .expect(modules1.modules) + .to.deep.eq([ + whiteListAddress, + stateChannelAddress, + socialRecoveryAddress, + dailyLimitsAddress + ]) + chai.expect(modules1.next).to.be.eq(SENTINEL_ADDRESS) + + chai.expect(modules2.modules.length).to.be.eq(1) + chai.expect(modules2.modules).to.deep.eq([whiteListAddress]) + chai.expect(modules2.next).to.be.eq(currentPageNext ? whiteListAddress : stateChannelAddress) + + chai.expect(modules3.modules.length).to.be.eq(2) + chai.expect(modules3.modules).to.deep.eq([whiteListAddress, stateChannelAddress]) + chai + .expect(modules3.next) + .to.be.eq(currentPageNext ? stateChannelAddress : socialRecoveryAddress) }) it('should offset the returned modules', async () => { - const { safe, accounts, dailyLimitModule, contractNetworks, socialRecoveryModule } = - await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { + safe, + dailyLimitModule, + contractNetworks, + socialRecoveryModule, + stateChannelModule, + whiteListModule, + provider + } = await setupTests() const safeAddress = await safe.getAddress() - const dailyLimitsAddress = await await dailyLimitModule.getAddress() - const socialRecoveryAddress = await await socialRecoveryModule.getAddress() + const dailyLimitsAddress = await dailyLimitModule.getAddress() + const socialRecoveryAddress = await socialRecoveryModule.getAddress() + const stateChannelAddress = await stateChannelModule.getAddress() + const whiteListAddress = await whiteListModule.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) + const currentPageNext = semverSatisfies(await safeSdk.getContractVersion(), '>=1.4.1') + + const moduleDeployment = [ + dailyLimitsAddress, + socialRecoveryAddress, + stateChannelAddress, + whiteListAddress + ].map(async (moduleAddress) => { + const txModule = await safeSdk.createEnableModuleTx(moduleAddress) + const moduleResponse = await safeSdk.executeTransaction(txModule) + await waitSafeTxReceipt(moduleResponse) + }) + + await Promise.all(moduleDeployment) - const txDailyLimits = await safeSdk.createEnableModuleTx(dailyLimitsAddress) - const dailyLimitsResponse = await safeSdk.executeTransaction(txDailyLimits) - await waitSafeTxReceipt(dailyLimitsResponse) - const txSocialRecovery = await safeSdk.createEnableModuleTx(socialRecoveryAddress) - const soecialRecoveryResponse = await safeSdk.executeTransaction(txSocialRecovery) - await waitSafeTxReceipt(soecialRecoveryResponse) + const { + modules: [firstModule, secondModule, thirdModule, fourthModule] + } = await safeSdk.getModulesPaginated(SENTINEL_ADDRESS, 10) - const [firstModule, secondModule] = await safeSdk.getModulesPaginated(SENTINEL_ADDRESS, 10) + const modules1 = await safeSdk.getModulesPaginated(firstModule, 10) + const modules2 = await safeSdk.getModulesPaginated(firstModule, 2) + const modules3 = await safeSdk.getModulesPaginated(firstModule, 3) - chai.expect((await safeSdk.getModulesPaginated(SENTINEL_ADDRESS, 10)).length).to.be.eq(2) - chai.expect((await safeSdk.getModulesPaginated(firstModule, 10)).length).to.be.eq(1) - chai.expect((await safeSdk.getModulesPaginated(secondModule, 10)).length).to.be.eq(0) + chai + .expect((await safeSdk.getModulesPaginated(SENTINEL_ADDRESS, 10)).modules.length) + .to.be.eq(4) + chai.expect(modules1.modules).to.deep.eq([secondModule, thirdModule, fourthModule]) + chai.expect(modules1.next).to.be.eq(SENTINEL_ADDRESS) + chai.expect(modules2.modules).to.deep.eq([secondModule, thirdModule]) + chai.expect(modules2.next).to.be.eq(currentPageNext ? thirdModule : fourthModule) + chai.expect(modules3.modules).to.deep.eq([secondModule, thirdModule, fourthModule]) + chai.expect(modules3.next).to.be.eq(SENTINEL_ADDRESS) }) it('should fail if pageSize is invalid', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -180,11 +260,9 @@ describe('Safe modules manager', () => { describe('isModuleEnabled', async () => { it('should fail if the Safe is not deployed', async () => { - const { predictedSafe, accounts, dailyLimitModule, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, dailyLimitModule, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -193,12 +271,10 @@ describe('Safe modules manager', () => { }) it('should return true if a module is enabled', async () => { - const { safe, accounts, dailyLimitModule, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, dailyLimitModule, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -212,11 +288,9 @@ describe('Safe modules manager', () => { describe('createEnableModuleTx', async () => { it('should fail if the Safe is not deployed', async () => { - const { predictedSafe, accounts, dailyLimitModule, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, dailyLimitModule, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -225,12 +299,10 @@ describe('Safe modules manager', () => { }) it('should fail if address is invalid', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -239,12 +311,10 @@ describe('Safe modules manager', () => { }) it('should fail if address is equal to sentinel', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -253,12 +323,10 @@ describe('Safe modules manager', () => { }) it('should fail if address is equal to 0x address', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -267,12 +335,10 @@ describe('Safe modules manager', () => { }) it('should fail if address is already enabled', async () => { - const { safe, accounts, dailyLimitModule, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, dailyLimitModule, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -284,12 +350,10 @@ describe('Safe modules manager', () => { }) it('should build the transaction with the optional props', async () => { - const { safe, accounts, dailyLimitModule, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, dailyLimitModule, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -311,12 +375,10 @@ describe('Safe modules manager', () => { }) it('should enable a Safe module', async () => { - const { safe, accounts, dailyLimitModule, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, dailyLimitModule, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -332,11 +394,9 @@ describe('Safe modules manager', () => { describe('createDisableModuleTx', async () => { it('should fail if the Safe is not deployed', async () => { - const { predictedSafe, accounts, dailyLimitModule, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, dailyLimitModule, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -345,12 +405,10 @@ describe('Safe modules manager', () => { }) it('should fail if address is invalid', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -359,12 +417,10 @@ describe('Safe modules manager', () => { }) it('should fail if address is equal to sentinel', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -373,12 +429,10 @@ describe('Safe modules manager', () => { }) it('should fail if address is equal to 0x address', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -387,12 +441,10 @@ describe('Safe modules manager', () => { }) it('should fail if address is not enabled', async () => { - const { safe, accounts, dailyLimitModule, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, dailyLimitModule, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -401,13 +453,12 @@ describe('Safe modules manager', () => { }) it('should build the transaction with the optional props', async () => { - const { dailyLimitModule, accounts, contractNetworks } = await setupTests() + const { dailyLimitModule, accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -436,14 +487,13 @@ describe('Safe modules manager', () => { }) it('should disable Safe modules', async () => { - const { dailyLimitModule, accounts, socialRecoveryModule, contractNetworks } = + const { dailyLimitModule, accounts, socialRecoveryModule, contractNetworks, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) diff --git a/packages/protocol-kit/tests/e2e/offChainSignatures.test.ts b/packages/protocol-kit/tests/e2e/offChainSignatures.test.ts index 5d463c998..a20f15366 100644 --- a/packages/protocol-kit/tests/e2e/offChainSignatures.test.ts +++ b/packages/protocol-kit/tests/e2e/offChainSignatures.test.ts @@ -7,7 +7,7 @@ import { deployments } from 'hardhat' import { itif } from './utils/helpers' import { getContractNetworks } from './utils/setupContractNetworks' import { getSafeWithOwners } from './utils/setupContracts' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' chai.use(chaiAsPromised) @@ -27,21 +27,22 @@ describe('Off-chain signatures', () => { safeVersion: safeVersionDeployed } } + const provider = getEip1193Provider() + return { safe: await getSafeWithOwners([accounts[0].address, accounts[1].address]), accounts, contractNetworks, - predictedSafe + predictedSafe, + provider } }) describe('signHash', async () => { it('should sign a transaction hash with the current signer if the Safe is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -51,12 +52,10 @@ describe('Off-chain signatures', () => { }) it('should sign a transaction hash with the current signer', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -76,17 +75,15 @@ describe('Off-chain signatures', () => { itif(safeVersionDeployed < '1.3.0')( 'should fail to sign a transaction if the Safe with version { - const { safe, predictedSafe, accounts, contractNetworks } = await setupTests() - const account = accounts[0] - const ethAdapter = await getEthAdapter(account.signer) + const { safe, predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) const safeAddress = await safe.getAddress() const safeSdkExistingSafe = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -110,11 +107,9 @@ describe('Off-chain signatures', () => { itif(safeVersionDeployed >= '1.3.0')( 'should sign a transaction with the current signer if the Safe with version >=v1.3.0 is using predicted config', async () => { - const { safe, predictedSafe, accounts, contractNetworks } = await setupTests() - const account = accounts[0] - const ethAdapter = await getEthAdapter(account.signer) + const { safe, predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -133,13 +128,13 @@ describe('Off-chain signatures', () => { ) it('should fail if the signature is added by an account that is not an owner', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, accounts, contractNetworks, provider } = await setupTests() const account3 = accounts[2] - const ethAdapter = await getEthAdapter(account3.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, + signer: account3.address, contractNetworks }) const safeTransactionData = { @@ -154,12 +149,10 @@ describe('Off-chain signatures', () => { }) it('should ignore duplicated signatures', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -180,12 +173,10 @@ describe('Off-chain signatures', () => { itif(safeVersionDeployed === '1.0.0')( 'should fail if the signature of the current signer is added using eth_sign and safeVersion===1.0.0', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: safeAddress, contractNetworks }) @@ -204,12 +195,10 @@ describe('Off-chain signatures', () => { itif(safeVersionDeployed > '1.0.0')( 'should add the signature of the current signer using eth_sign if safeVersion>1.0.0', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -226,111 +215,51 @@ describe('Off-chain signatures', () => { } ) - itif(process.env.ETH_LIB === 'ethers')( - 'should add the signature of the current signer using eth_signTypedData with ethers provider', - async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) - const safeAddress = await safe.getAddress() - const safeSdk = await Safe.create({ - ethAdapter, - safeAddress, - contractNetworks - }) - const safeTransactionData = { - to: safeAddress, - value: '0', - data: '0x' - } - const tx = await safeSdk.createTransaction({ transactions: [safeTransactionData] }) - chai.expect(tx.signatures.size).to.be.eq(0) - const signedTx = await safeSdk.signTransaction(tx, SigningMethod.ETH_SIGN_TYPED_DATA) - chai.expect(tx.signatures.size).to.be.eq(0) - chai.expect(signedTx.signatures.size).to.be.eq(1) - } - ) - - itif(process.env.ETH_LIB === 'web3')( - 'should fail if the signature of the current signer is added using eth_signTypedData with web3 provider', - async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) - const safeAddress = await safe.getAddress() - const safeSdk = await Safe.create({ - ethAdapter, - safeAddress, - contractNetworks - }) - const safeTransactionData = { - to: safeAddress, - value: '0', - data: '0x' - } - const tx = await safeSdk.createTransaction({ transactions: [safeTransactionData] }) - await chai - .expect(safeSdk.signTransaction(tx, SigningMethod.ETH_SIGN_TYPED_DATA)) - .to.be.rejectedWith("EIP-712 is not supported by user's wallet") - } - ) - - itif(process.env.ETH_LIB === 'ethers')( - 'should add the signature of the current signer using eth_signTypedData_v3 with ethers provider', - async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) - const safeAddress = await safe.getAddress() - const safeSdk = await Safe.create({ - ethAdapter, - safeAddress, - contractNetworks - }) - const safeTransactionData = { - to: safeAddress, - value: '0', - data: '0x' - } - const tx = await safeSdk.createTransaction({ transactions: [safeTransactionData] }) - chai.expect(tx.signatures.size).to.be.eq(0) - const signedTx = await safeSdk.signTransaction(tx, SigningMethod.ETH_SIGN_TYPED_DATA_V3) - chai.expect(tx.signatures.size).to.be.eq(0) - chai.expect(signedTx.signatures.size).to.be.eq(1) + it('should add the signature of the current signer using eth_signTypedData', async () => { + const { safe, contractNetworks, provider } = await setupTests() + const safeAddress = await safe.getAddress() + const safeSdk = await Safe.create({ + provider, + safeAddress, + contractNetworks + }) + const safeTransactionData = { + to: safeAddress, + value: '0', + data: '0x' } - ) + const tx = await safeSdk.createTransaction({ transactions: [safeTransactionData] }) + chai.expect(tx.signatures.size).to.be.eq(0) + const signedTx = await safeSdk.signTransaction(tx, SigningMethod.ETH_SIGN_TYPED_DATA) + chai.expect(tx.signatures.size).to.be.eq(0) + chai.expect(signedTx.signatures.size).to.be.eq(1) + }) - itif(process.env.ETH_LIB === 'web3')( - 'should fail if the signature of the current signer is added using eth_signTypedData_v3 with web3 provider', - async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) - const safeAddress = await safe.getAddress() - const safeSdk = await Safe.create({ - ethAdapter, - safeAddress, - contractNetworks - }) - const safeTransactionData = { - to: safeAddress, - value: '0', - data: '0x' - } - const tx = await safeSdk.createTransaction({ transactions: [safeTransactionData] }) - await chai - .expect(safeSdk.signTransaction(tx, SigningMethod.ETH_SIGN_TYPED_DATA_V3)) - .to.be.rejectedWith("EIP-712 is not supported by user's wallet") + it('should add the signature of the current signer using eth_signTypedData_v3', async () => { + const { safe, contractNetworks, provider } = await setupTests() + const safeAddress = await safe.getAddress() + const safeSdk = await Safe.create({ + provider, + safeAddress, + contractNetworks + }) + const safeTransactionData = { + to: safeAddress, + value: '0', + data: '0x' } - ) + const tx = await safeSdk.createTransaction({ transactions: [safeTransactionData] }) + chai.expect(tx.signatures.size).to.be.eq(0) + const signedTx = await safeSdk.signTransaction(tx, SigningMethod.ETH_SIGN_TYPED_DATA_V3) + chai.expect(tx.signatures.size).to.be.eq(0) + chai.expect(signedTx.signatures.size).to.be.eq(1) + }) it('should add the signature of the current signer using eth_signTypedData_v4', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -347,12 +276,10 @@ describe('Off-chain signatures', () => { }) it('should add the signature of the current signer using eth_signTypedData_v4 by default', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -369,12 +296,11 @@ describe('Off-chain signatures', () => { }) it('should sign a transaction received from the Safe Transaction Service', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -429,7 +355,7 @@ describe('Off-chain signatures', () => { const signedTx = await safeSdk.signTransaction(safeServiceTransaction) chai.expect(safeServiceTransaction.confirmations?.length).to.be.eq(2) chai.expect(signedTx.signatures.size).to.be.eq(3) - const signerAddress = await ethAdapter.getSignerAddress() + const signerAddress = account1.address const signerSignature = signedTx.signatures.get(signerAddress!.toLowerCase())?.data chai .expect(signedTx.encodedSignatures()) diff --git a/packages/protocol-kit/tests/e2e/onChainSignatures.test.ts b/packages/protocol-kit/tests/e2e/onChainSignatures.test.ts index dfbe38e61..cfb98b211 100644 --- a/packages/protocol-kit/tests/e2e/onChainSignatures.test.ts +++ b/packages/protocol-kit/tests/e2e/onChainSignatures.test.ts @@ -5,7 +5,7 @@ import chaiAsPromised from 'chai-as-promised' import { deployments } from 'hardhat' import { getContractNetworks } from './utils/setupContractNetworks' import { getSafeWithOwners } from './utils/setupContracts' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' import { waitSafeTxReceipt } from './utils/transactions' @@ -26,21 +26,22 @@ describe('On-chain signatures', () => { safeVersion: safeVersionDeployed } } + const provider = getEip1193Provider() + return { safe: await getSafeWithOwners([accounts[0].address, accounts[1].address]), accounts, contractNetworks, - predictedSafe + predictedSafe, + provider } }) describe('approveTransactionHash', async () => { it('should fail if the Safe is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk1 = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -51,12 +52,12 @@ describe('On-chain signatures', () => { }) it('should fail if a transaction hash is approved by an account that is not an owner', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, accounts, contractNetworks, provider } = await setupTests() const account3 = accounts[2] - const ethAdapter = await getEthAdapter(account3.signer) const safeAddress = await safe.getAddress() const safeSdk1 = await Safe.create({ - ethAdapter, + provider, + signer: account3.address, safeAddress, contractNetworks }) @@ -73,12 +74,11 @@ describe('On-chain signatures', () => { }) it('should approve the transaction hash', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk1 = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -95,12 +95,11 @@ describe('On-chain signatures', () => { }) it('should ignore a duplicated signatures', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeAddress = await safe.getAddress() const safeSdk1 = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -123,11 +122,9 @@ describe('On-chain signatures', () => { describe('getOwnersWhoApprovedTx', async () => { it('should fail if Safe is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter1 = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk1 = await Safe.create({ - ethAdapter: ethAdapter1, + provider, predictedSafe, contractNetworks }) @@ -137,17 +134,17 @@ describe('On-chain signatures', () => { }) it('should return the list of owners who approved a transaction hash', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1, account2] = accounts - const ethAdapter1 = await getEthAdapter(account1.signer) + const { safe, accounts, contractNetworks, provider } = await setupTests() + const [, account2] = accounts const safeAddress = await safe.getAddress() const safeSdk1 = await Safe.create({ - ethAdapter: ethAdapter1, + provider, safeAddress: safeAddress, contractNetworks }) - const ethAdapter2 = await getEthAdapter(account2.signer) - const safeSdk2 = await safeSdk1.connect({ ethAdapter: ethAdapter2 }) + const safeSdk2 = await safeSdk1.connect({ + signer: account2.address + }) const safeTransactionData = { to: safeAddress, value: '0', diff --git a/packages/protocol-kit/tests/e2e/ownerManager.test.ts b/packages/protocol-kit/tests/e2e/ownerManager.test.ts index 801428580..9cb046b9f 100644 --- a/packages/protocol-kit/tests/e2e/ownerManager.test.ts +++ b/packages/protocol-kit/tests/e2e/ownerManager.test.ts @@ -9,7 +9,7 @@ import chaiAsPromised from 'chai-as-promised' import { deployments } from 'hardhat' import { getContractNetworks } from './utils/setupContractNetworks' import { getSafeWithOwners } from './utils/setupContracts' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' import { waitSafeTxReceipt } from './utils/transactions' @@ -21,6 +21,7 @@ describe('Safe owners manager', () => { const accounts = await getAccounts() const chainId = BigInt(await getChainId()) const contractNetworks = await getContractNetworks(chainId) + const provider = getEip1193Provider() const predictedSafe: PredictedSafeProps = { safeAccountConfig: { owners: [accounts[0].address], @@ -38,17 +39,16 @@ describe('Safe owners manager', () => { ]), accounts, contractNetworks, - predictedSafe + predictedSafe, + provider } }) describe('getOwners', async () => { it('should fail if the Safe is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -56,12 +56,11 @@ describe('Safe owners manager', () => { }) it('should return the list of Safe owners', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address, account2.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -74,11 +73,10 @@ describe('Safe owners manager', () => { describe('isOwner', async () => { it('should fail if the Safe is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() + const { predictedSafe, accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -86,12 +84,11 @@ describe('Safe owners manager', () => { }) it('should return true if an account is an owner of the connected Safe', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -100,12 +97,11 @@ describe('Safe owners manager', () => { }) it('should return false if an account is not an owner of the connected Safe', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -116,11 +112,10 @@ describe('Safe owners manager', () => { describe('createAddOwnerTx', async () => { it('should fail if the Safe is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, accounts, contractNetworks, provider } = await setupTests() + const [, account2] = accounts const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -129,12 +124,11 @@ describe('Safe owners manager', () => { }) it('should fail if address is invalid', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -143,12 +137,11 @@ describe('Safe owners manager', () => { }) it('should fail if address is equal to sentinel', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -157,12 +150,11 @@ describe('Safe owners manager', () => { }) it('should fail if address is equal to 0x address', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -171,12 +163,11 @@ describe('Safe owners manager', () => { }) it('should fail if address is already an owner', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -185,12 +176,11 @@ describe('Safe owners manager', () => { }) it('should fail if the threshold is bigger than the number of owners', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -205,12 +195,11 @@ describe('Safe owners manager', () => { }) it('should fail if the threshold is not bigger than 0', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -219,12 +208,11 @@ describe('Safe owners manager', () => { }) it('should build the transaction with the optional props', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -246,12 +234,11 @@ describe('Safe owners manager', () => { }) it('should add an owner and keep the same threshold', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -271,12 +258,11 @@ describe('Safe owners manager', () => { }) it('should add an owner and update the threshold', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -300,11 +286,10 @@ describe('Safe owners manager', () => { describe('createRemoveOwnerTx', async () => { it('should fail if the Safe is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, accounts, contractNetworks, provider } = await setupTests() + const [, account2] = accounts const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -313,11 +298,9 @@ describe('Safe owners manager', () => { }) it('should fail if address is invalid', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -326,11 +309,9 @@ describe('Safe owners manager', () => { }) it('should fail if address is equal to sentinel', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -339,11 +320,9 @@ describe('Safe owners manager', () => { }) it('should fail if address is equal to 0x address', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -352,11 +331,10 @@ describe('Safe owners manager', () => { }) it('should fail if address is not an owner', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1, , , account4] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, accounts, contractNetworks, provider } = await setupTests() + const [, , , account4] = accounts const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -365,11 +343,10 @@ describe('Safe owners manager', () => { }) it('should fail if the threshold is bigger than the number of owners', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -384,11 +361,10 @@ describe('Safe owners manager', () => { }) it('should fail if the threshold is not bigger than 0', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -397,11 +373,10 @@ describe('Safe owners manager', () => { }) it('should build the transaction with the optional props', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts - const ethAdapter1 = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter: ethAdapter1, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -423,18 +398,19 @@ describe('Safe owners manager', () => { }) it('should remove the first owner of a Safe and decrease the threshold', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, accounts, contractNetworks, provider } = await setupTests() const [account1, account2, account3] = accounts - const ethAdapter1 = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter: ethAdapter1, + provider, safeAddress: await safe.getAddress(), contractNetworks }) - const ethAdapter2 = await getEthAdapter(account2.signer) - const safeSdk2 = await safeSdk1.connect({ ethAdapter: ethAdapter2 }) - const ethAdapter3 = await getEthAdapter(account3.signer) - const safeSdk3 = await safeSdk1.connect({ ethAdapter: ethAdapter3 }) + const safeSdk2 = await safeSdk1.connect({ + signer: account2.address + }) + const safeSdk3 = await safeSdk1.connect({ + signer: account3.address + }) const initialThreshold = await safeSdk1.getThreshold() const initialOwners = await safeSdk1.getOwners() chai.expect(initialOwners.length).to.be.eq(3) @@ -455,19 +431,18 @@ describe('Safe owners manager', () => { }) it('should remove any owner of a Safe and decrease the threshold', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, accounts, contractNetworks, provider } = await setupTests() const [account1, account2, account3] = accounts - const ethAdapter1 = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter: ethAdapter1, + provider, safeAddress: await safe.getAddress(), contractNetworks }) - const ethAdapter2 = await getEthAdapter(account2.signer) - const safeSdk2 = await safeSdk1.connect({ ethAdapter: ethAdapter2 }) - const ethAdapter3 = await getEthAdapter(account3.signer) + const safeSdk2 = await safeSdk1.connect({ + signer: account2.address + }) const safeSdk3 = await safeSdk1.connect({ - ethAdapter: ethAdapter3, + signer: account3.address, contractNetworks }) const initialThreshold = await safeSdk1.getThreshold() @@ -490,18 +465,19 @@ describe('Safe owners manager', () => { }) it('should remove an owner and update the threshold', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, accounts, contractNetworks, provider } = await setupTests() const [account1, account2, account3] = accounts - const ethAdapter1 = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter: ethAdapter1, + provider, safeAddress: await safe.getAddress(), contractNetworks }) - const ethAdapter2 = await getEthAdapter(account2.signer) - const safeSdk2 = await safeSdk1.connect({ ethAdapter: ethAdapter2 }) - const ethAdapter3 = await getEthAdapter(account3.signer) - const safeSdk3 = await safeSdk1.connect({ ethAdapter: ethAdapter3 }) + const safeSdk2 = await safeSdk1.connect({ + signer: account2.address + }) + const safeSdk3 = await safeSdk1.connect({ + signer: account3.address + }) const newThreshold = 1 const initialOwners = await safeSdk1.getOwners() chai.expect(initialOwners.length).to.be.eq(3) @@ -526,11 +502,10 @@ describe('Safe owners manager', () => { describe('createSwapOwnerTx', async () => { it('should fail if the Safe is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() + const { predictedSafe, accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -542,12 +517,11 @@ describe('Safe owners manager', () => { }) it('should fail if old address is invalid', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -559,12 +533,11 @@ describe('Safe owners manager', () => { }) it('should fail if new address is invalid', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -576,12 +549,11 @@ describe('Safe owners manager', () => { }) it('should fail if old address is equal to sentinel', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -593,12 +565,11 @@ describe('Safe owners manager', () => { }) it('should fail if new address is equal to sentinel', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -610,12 +581,11 @@ describe('Safe owners manager', () => { }) it('should fail if old address is equal to 0x address', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -627,12 +597,11 @@ describe('Safe owners manager', () => { }) it('should fail if new address is equal to 0x address', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -644,12 +613,11 @@ describe('Safe owners manager', () => { }) it('should fail if old address is not an owner', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2, , account4] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -661,12 +629,11 @@ describe('Safe owners manager', () => { }) it('should fail if new address is already an owner', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -678,12 +645,11 @@ describe('Safe owners manager', () => { }) it('should build the transaction with the optional props', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -708,12 +674,11 @@ describe('Safe owners manager', () => { }) it('should replace the first owner of a Safe', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -732,18 +697,19 @@ describe('Safe owners manager', () => { }) it('should replace any owner of a Safe', async () => { - const { safe, accounts, contractNetworks } = await setupTests() + const { safe, accounts, contractNetworks, provider } = await setupTests() const [account1, account2, account3, account4] = accounts - const ethAdapter1 = await getEthAdapter(account1.signer) const safeSdk1 = await Safe.create({ - ethAdapter: ethAdapter1, + provider, safeAddress: await safe.getAddress(), contractNetworks }) - const ethAdapter2 = await getEthAdapter(account2.signer) - const safeSdk2 = await safeSdk1.connect({ ethAdapter: ethAdapter2 }) - const ethAdapter3 = await getEthAdapter(account3.signer) - const safeSdk3 = await safeSdk1.connect({ ethAdapter: ethAdapter3 }) + const safeSdk2 = await safeSdk1.connect({ + signer: account2.address + }) + const safeSdk3 = await safeSdk1.connect({ + signer: account3.address + }) const initialOwners = await safeSdk1.getOwners() chai.expect(initialOwners.length).to.be.eq(3) chai.expect(initialOwners[0]).to.be.eq(account1.address) diff --git a/packages/protocol-kit/tests/e2e/safeFactory.test.ts b/packages/protocol-kit/tests/e2e/safeFactory.test.ts index 6d4d3c3bb..9d476f8e2 100644 --- a/packages/protocol-kit/tests/e2e/safeFactory.test.ts +++ b/packages/protocol-kit/tests/e2e/safeFactory.test.ts @@ -4,7 +4,8 @@ import { ContractNetworksConfig, DeploySafeProps, SafeAccountConfig, - SafeFactory + SafeFactory, + SafeProvider } from '@safe-global/protocol-kit/index' import { ZERO_ADDRESS } from '@safe-global/protocol-kit/utils/constants' import chai from 'chai' @@ -23,7 +24,7 @@ import { getSignMessageLib, getSimulateTxAccessor } from './utils/setupContracts' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' chai.use(chaiAsPromised) @@ -34,28 +35,27 @@ describe('SafeProxyFactory', () => { const accounts = await getAccounts() const chainId = BigInt(await getChainId()) const contractNetworks = await getContractNetworks(chainId) + const provider = getEip1193Provider() + return { defaultCallbackHandler: await getDefaultCallbackHandler(), chainId, accounts, - contractNetworks + contractNetworks, + provider } }) describe('create', async () => { it('should fail if the current network is not a default network and no contractNetworks is provided', async () => { - const { accounts } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { provider } = await setupTests() chai - .expect(SafeFactory.create({ ethAdapter })) + .expect(SafeFactory.create({ provider })) .rejectedWith('Invalid SafeProxyFactory contract') }) it('should fail if the contractNetworks provided are not deployed', async () => { - const { accounts, chainId } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { chainId, provider } = await setupTests() const contractNetworks: ContractNetworksConfig = { [chainId.toString()]: { safeSingletonAddress: ZERO_ADDRESS, @@ -77,50 +77,44 @@ describe('SafeProxyFactory', () => { } } chai - .expect(SafeFactory.create({ ethAdapter, contractNetworks })) + .expect(SafeFactory.create({ provider, contractNetworks })) .rejectedWith('SafeProxyFactory contract is not deployed on the current network') }) it('should instantiate the SafeProxyFactory', async () => { - const { accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) - const safeFactory = await SafeFactory.create({ ethAdapter, contractNetworks }) - const networkId = await ethAdapter.getChainId() + const { contractNetworks, provider } = await setupTests() + const safeProvider = new SafeProvider({ provider }) + const safeFactory = await SafeFactory.create({ provider, contractNetworks }) + const networkId = await safeProvider.getChainId() chai .expect(await safeFactory.getAddress()) - .to.be.eq(contractNetworks[networkId].safeProxyFactoryAddress) + .to.be.eq(contractNetworks[networkId.toString()].safeProxyFactoryAddress) }) }) - describe('getEthAdapter', async () => { - it('should return the connected EthAdapter', async () => { - const { accounts, contractNetworks } = await setupTests() + describe('getEip1193Provider', async () => { + it('should return the connected SafeProvider', async () => { + const { accounts, contractNetworks, provider } = await setupTests() const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) - const safeFactory = await SafeFactory.create({ ethAdapter, contractNetworks }) + const safeFactory = await SafeFactory.create({ provider, contractNetworks }) chai - .expect(await safeFactory.getEthAdapter().getSignerAddress()) + .expect(await safeFactory.getSafeProvider().getSignerAddress()) .to.be.eq(await account1.signer.getAddress()) }) }) describe('getChainId', async () => { it('should return the chainId of the current network', async () => { - const { accounts, chainId, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) - const safeFactory = await SafeFactory.create({ ethAdapter, contractNetworks }) + const { chainId, contractNetworks, provider } = await setupTests() + const safeFactory = await SafeFactory.create({ provider, contractNetworks }) chai.expect(await safeFactory.getChainId()).to.be.eq(chainId) }) }) describe('predictSafeAddress', async () => { it('should fail if there are no owners', async () => { - const { accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) - const safeFactory = await SafeFactory.create({ ethAdapter, contractNetworks }) + const { contractNetworks, provider } = await setupTests() + const safeFactory = await SafeFactory.create({ provider, contractNetworks }) const owners: string[] = [] const threshold = 2 const safeAccountConfig: SafeAccountConfig = { owners, threshold } @@ -132,10 +126,9 @@ describe('SafeProxyFactory', () => { }) it('should fail if the threshold is lower than 0', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) - const safeFactory = await SafeFactory.create({ ethAdapter, contractNetworks }) + const safeFactory = await SafeFactory.create({ provider, contractNetworks }) const owners = [account1.address, account2.address] const invalidThreshold = 0 const safeAccountConfig: SafeAccountConfig = { owners, threshold: invalidThreshold } @@ -147,10 +140,9 @@ describe('SafeProxyFactory', () => { }) it('should fail if the threshold is higher than the threshold', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) - const safeFactory = await SafeFactory.create({ ethAdapter, contractNetworks }) + const safeFactory = await SafeFactory.create({ provider, contractNetworks }) const owners = [account1.address, account2.address] const invalidThreshold = 3 const safeAccountConfig: SafeAccountConfig = { owners, threshold: invalidThreshold } @@ -162,11 +154,10 @@ describe('SafeProxyFactory', () => { }) it('should fail if the saltNonce is lower than 0', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeFactory = await SafeFactory.create({ - ethAdapter, + provider, safeVersion: safeVersionDeployed, contractNetworks }) @@ -181,11 +172,10 @@ describe('SafeProxyFactory', () => { }) it('should predict a new Safe with saltNonce', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeFactory = await SafeFactory.create({ - ethAdapter, + provider, safeVersion: safeVersionDeployed, contractNetworks }) @@ -208,11 +198,10 @@ describe('SafeProxyFactory', () => { itif(safeVersionDeployed > '1.0.0')( 'should predict a new Safe with the default CompatibilityFallbackHandler', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeFactory = await SafeFactory.create({ - ethAdapter, + provider, safeVersion: safeVersionDeployed, contractNetworks }) @@ -237,11 +226,10 @@ describe('SafeProxyFactory', () => { itif(safeVersionDeployed > '1.0.0')( 'should predict a new Safe with a custom fallback handler', async () => { - const { accounts, contractNetworks, defaultCallbackHandler } = await setupTests() + const { accounts, contractNetworks, defaultCallbackHandler, provider } = await setupTests() const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeFactory = await SafeFactory.create({ - ethAdapter, + provider, safeVersion: safeVersionDeployed, contractNetworks }) @@ -269,10 +257,8 @@ describe('SafeProxyFactory', () => { describe('deploySafe', async () => { it('should fail if there are no owners', async () => { - const { accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) - const safeFactory = await SafeFactory.create({ ethAdapter, contractNetworks }) + const { contractNetworks, provider } = await setupTests() + const safeFactory = await SafeFactory.create({ provider, contractNetworks }) const owners: string[] = [] const threshold = 2 const safeAccountConfig: SafeAccountConfig = { owners, threshold } @@ -283,10 +269,9 @@ describe('SafeProxyFactory', () => { }) it('should fail if the threshold is lower than 0', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) - const safeFactory = await SafeFactory.create({ ethAdapter, contractNetworks }) + const safeFactory = await SafeFactory.create({ provider, contractNetworks }) const owners = [account1.address, account2.address] const threshold = 0 const safeAccountConfig: SafeAccountConfig = { owners, threshold } @@ -297,10 +282,9 @@ describe('SafeProxyFactory', () => { }) it('should fail if the threshold is higher than the threshold', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) - const safeFactory = await SafeFactory.create({ ethAdapter, contractNetworks }) + const safeFactory = await SafeFactory.create({ provider, contractNetworks }) const owners = [account1.address, account2.address] const threshold = 3 const safeAccountConfig: SafeAccountConfig = { owners, threshold } @@ -311,11 +295,10 @@ describe('SafeProxyFactory', () => { }) it('should fail if the saltNonce is lower than 0', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeFactory = await SafeFactory.create({ - ethAdapter, + provider, safeVersion: safeVersionDeployed, contractNetworks }) @@ -332,11 +315,10 @@ describe('SafeProxyFactory', () => { itif(safeVersionDeployed > '1.0.0')( 'should deploy a new Safe with custom fallback handler', async () => { - const { accounts, contractNetworks, defaultCallbackHandler } = await setupTests() + const { accounts, contractNetworks, defaultCallbackHandler, provider } = await setupTests() const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeFactory = await SafeFactory.create({ - ethAdapter, + provider, safeVersion: safeVersionDeployed, contractNetworks }) @@ -361,11 +343,10 @@ describe('SafeProxyFactory', () => { itif(safeVersionDeployed > '1.0.0')( 'should deploy a new Safe with the default CompatibilityFallbackHandler', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeFactory = await SafeFactory.create({ - ethAdapter, + provider, safeVersion: safeVersionDeployed, contractNetworks }) @@ -383,11 +364,10 @@ describe('SafeProxyFactory', () => { ) it('should deploy a new Safe without saltNonce', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeFactory = await SafeFactory.create({ - ethAdapter, + provider, safeVersion: safeVersionDeployed, contractNetworks }) @@ -403,11 +383,10 @@ describe('SafeProxyFactory', () => { }) it('should deploy a new Safe with saltNonce', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeFactory = await SafeFactory.create({ - ethAdapter, + provider, safeVersion: safeVersionDeployed, contractNetworks }) @@ -424,15 +403,14 @@ describe('SafeProxyFactory', () => { }) it('should deploy a new Safe with callback', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts let callbackResult = '' const callback = (txHash: string) => { callbackResult = txHash } - const ethAdapter = await getEthAdapter(account1.signer) const safeFactory = await SafeFactory.create({ - ethAdapter, + provider, safeVersion: safeVersionDeployed, contractNetworks }) @@ -450,10 +428,9 @@ describe('SafeProxyFactory', () => { itif(safeVersionDeployed === DEFAULT_SAFE_VERSION)( 'should deploy last Safe version by default', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) - const safeFactory = await SafeFactory.create({ ethAdapter, contractNetworks }) + const safeFactory = await SafeFactory.create({ provider, contractNetworks }) const owners = [account1.address, account2.address] const threshold = 2 const safeAccountConfig: SafeAccountConfig = { owners, threshold } @@ -465,11 +442,10 @@ describe('SafeProxyFactory', () => { ) it('should deploy a specific Safe version', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts - const ethAdapter = await getEthAdapter(account1.signer) const safeFactory = await SafeFactory.create({ - ethAdapter, + provider, safeVersion: safeVersionDeployed, contractNetworks }) diff --git a/packages/protocol-kit/tests/e2e/ethAdapters.test.ts b/packages/protocol-kit/tests/e2e/safeProvider.test.ts similarity index 72% rename from packages/protocol-kit/tests/e2e/ethAdapters.test.ts rename to packages/protocol-kit/tests/e2e/safeProvider.test.ts index 2cc109250..f63532f67 100644 --- a/packages/protocol-kit/tests/e2e/ethAdapters.test.ts +++ b/packages/protocol-kit/tests/e2e/safeProvider.test.ts @@ -12,8 +12,9 @@ import { getSafeSingleton, getSignMessageLib } from './utils/setupContracts' -import { getEthAdapter, getNetworkProvider } from './utils/setupEthAdapter' +import { getEip1193Provider, getSafeProviderFromNetwork } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' +import { SafeProvider } from '@safe-global/protocol-kit/index' chai.use(chaiAsPromised) @@ -23,18 +24,21 @@ describe('Safe contracts', () => { const accounts = await getAccounts() const chainId = BigInt(await getChainId()) const contractNetworks = await getContractNetworks(chainId) + const provider = getEip1193Provider() + return { accounts, contractNetworks, - chainId + chainId, + provider } }) describe('getSafeContract', async () => { it('should return an L1 Safe contract from safe-deployments', async () => { - const ethAdapter = await getEthAdapter(getNetworkProvider('mainnet')) + const safeProvider = getSafeProviderFromNetwork('mainnet') const safeVersion: SafeVersion = '1.3.0' - const safeContract = await ethAdapter.getSafeContract({ + const safeContract = await safeProvider.getSafeContract({ safeVersion }) chai @@ -43,9 +47,9 @@ describe('Safe contracts', () => { }) it('should return an L2 Safe contract from safe-deployments', async () => { - const ethAdapter = await getEthAdapter(getNetworkProvider('gnosis')) + const safeProvider = getSafeProviderFromNetwork('gnosis') const safeVersion: SafeVersion = '1.3.0' - const safeContract = await ethAdapter.getSafeContract({ + const safeContract = await safeProvider.getSafeContract({ safeVersion }) chai @@ -54,10 +58,10 @@ describe('Safe contracts', () => { }) it('should return an L1 Safe contract from safe-deployments using the L1 flag', async () => { - const ethAdapter = await getEthAdapter(getNetworkProvider('gnosis')) + const safeProvider = getSafeProviderFromNetwork('gnosis') const safeVersion: SafeVersion = '1.3.0' const isL1SafeSingleton = true - const safeContract = await ethAdapter.getSafeContract({ + const safeContract = await safeProvider.getSafeContract({ safeVersion, isL1SafeSingleton }) @@ -67,12 +71,11 @@ describe('Safe contracts', () => { }) it('should return a Safe contract from the custom addresses', async () => { - const { accounts, contractNetworks, chainId } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { contractNetworks, chainId, provider } = await setupTests() + const safeProvider = new SafeProvider({ provider }) const safeVersion: SafeVersion = '1.3.0' const customContract = contractNetworks[chainId.toString()] - const safeContract = await ethAdapter.getSafeContract({ + const safeContract = await safeProvider.getSafeContract({ safeVersion, customContractAddress: customContract?.safeSingletonAddress, customContractAbi: customContract?.safeSingletonAbi @@ -85,9 +88,9 @@ describe('Safe contracts', () => { describe('getMultiSendContract', async () => { it('should return a MultiSend contract from safe-deployments', async () => { - const ethAdapter = await getEthAdapter(getNetworkProvider('mainnet')) + const safeProvider = getSafeProviderFromNetwork('mainnet') const safeVersion: SafeVersion = '1.3.0' - const multiSendContract = await ethAdapter.getMultiSendContract({ + const multiSendContract = await safeProvider.getMultiSendContract({ safeVersion }) chai @@ -96,12 +99,11 @@ describe('Safe contracts', () => { }) it('should return a MultiSend contract from the custom addresses', async () => { - const { accounts, contractNetworks, chainId } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { contractNetworks, chainId, provider } = await setupTests() + const safeProvider = new SafeProvider({ provider }) const safeVersion: SafeVersion = '1.3.0' const customContract = contractNetworks[chainId.toString()] - const multiSendContract = await ethAdapter.getMultiSendContract({ + const multiSendContract = await safeProvider.getMultiSendContract({ safeVersion, customContractAddress: customContract.multiSendAddress, customContractAbi: customContract.multiSendAbi @@ -114,9 +116,9 @@ describe('Safe contracts', () => { describe('getMultiSendCallOnlyContract', async () => { it('should return a MultiSendCallOnly contract from safe-deployments', async () => { - const ethAdapter = await getEthAdapter(getNetworkProvider('mainnet')) + const safeProvider = getSafeProviderFromNetwork('mainnet') const safeVersion: SafeVersion = '1.3.0' - const multiSendCallOnlyContract = await ethAdapter.getMultiSendCallOnlyContract({ + const multiSendCallOnlyContract = await safeProvider.getMultiSendCallOnlyContract({ safeVersion }) chai @@ -125,12 +127,11 @@ describe('Safe contracts', () => { }) it('should return a MultiSendCallOnly contract from the custom addresses', async () => { - const { accounts, contractNetworks, chainId } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { contractNetworks, chainId, provider } = await setupTests() + const safeProvider = new SafeProvider({ provider }) const safeVersion: SafeVersion = '1.3.0' const customContract = contractNetworks[chainId.toString()] - const multiSendCallOnlyContract = await ethAdapter.getMultiSendCallOnlyContract({ + const multiSendCallOnlyContract = await safeProvider.getMultiSendCallOnlyContract({ safeVersion, customContractAddress: customContract.multiSendCallOnlyAddress, customContractAbi: customContract.multiSendCallOnlyAbi @@ -143,10 +144,10 @@ describe('Safe contracts', () => { describe('getCompatibilityFallbackHandlerContract', async () => { it('should return a CompatibilityFallbackHandler contract from safe-deployments', async () => { - const ethAdapter = await getEthAdapter(getNetworkProvider('mainnet')) + const safeProvider = getSafeProviderFromNetwork('mainnet') const safeVersion: SafeVersion = '1.3.0' const compatibilityFallbackHandlerContract = - await ethAdapter.getCompatibilityFallbackHandlerContract({ + await safeProvider.getCompatibilityFallbackHandlerContract({ safeVersion }) chai @@ -155,13 +156,12 @@ describe('Safe contracts', () => { }) it('should return a CompatibilityFallbackHandler contract from the custom addresses', async () => { - const { accounts, contractNetworks, chainId } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { contractNetworks, chainId, provider } = await setupTests() + const safeProvider = new SafeProvider({ provider }) const safeVersion: SafeVersion = '1.3.0' const customContract = contractNetworks[chainId.toString()] const compatibilityFallbackHandlerContract = - await ethAdapter.getCompatibilityFallbackHandlerContract({ + await safeProvider.getCompatibilityFallbackHandlerContract({ safeVersion, customContractAddress: customContract.fallbackHandlerAddress, customContractAbi: customContract.fallbackHandlerAbi @@ -174,9 +174,9 @@ describe('Safe contracts', () => { describe('getSafeProxyFactoryContract', async () => { it('should return a SafeProxyFactory contract from safe-deployments', async () => { - const ethAdapter = await getEthAdapter(getNetworkProvider('mainnet')) + const safeProvider = getSafeProviderFromNetwork('mainnet') const safeVersion: SafeVersion = '1.3.0' - const factoryContract = await ethAdapter.getSafeProxyFactoryContract({ + const factoryContract = await safeProvider.getSafeProxyFactoryContract({ safeVersion }) chai @@ -185,12 +185,11 @@ describe('Safe contracts', () => { }) it('should return a SafeProxyFactory contract from the custom addresses', async () => { - const { accounts, contractNetworks, chainId } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { contractNetworks, chainId, provider } = await setupTests() + const safeProvider = new SafeProvider({ provider }) const safeVersion: SafeVersion = '1.3.0' const customContract = contractNetworks[chainId.toString()] - const factoryContract = await ethAdapter.getSafeProxyFactoryContract({ + const factoryContract = await safeProvider.getSafeProxyFactoryContract({ safeVersion, customContractAddress: customContract.safeProxyFactoryAddress, customContractAbi: customContract.safeProxyFactoryAbi @@ -203,9 +202,9 @@ describe('Safe contracts', () => { describe('getSignMessageLibContract', async () => { it('should return a SignMessageLib contract from safe-deployments', async () => { - const ethAdapter = await getEthAdapter(getNetworkProvider('mainnet')) + const safeProvider = getSafeProviderFromNetwork('mainnet') const safeVersion: SafeVersion = '1.3.0' - const signMessageLibContract = await ethAdapter.getSignMessageLibContract({ + const signMessageLibContract = await safeProvider.getSignMessageLibContract({ safeVersion }) chai @@ -214,12 +213,11 @@ describe('Safe contracts', () => { }) it('should return a SignMessageLib contract from the custom addresses', async () => { - const { accounts, contractNetworks, chainId } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { contractNetworks, chainId, provider } = await setupTests() + const safeProvider = new SafeProvider({ provider }) const safeVersion: SafeVersion = '1.3.0' const customContract = contractNetworks[chainId.toString()] - const signMessageLibContract = await ethAdapter.getSignMessageLibContract({ + const signMessageLibContract = await safeProvider.getSignMessageLibContract({ safeVersion, customContractAddress: customContract.signMessageLibAddress, customContractAbi: customContract.signMessageLibAbi @@ -232,9 +230,9 @@ describe('Safe contracts', () => { describe('getCreateCallContract', async () => { it('should return a CreateCall contract from safe-deployments', async () => { - const ethAdapter = await getEthAdapter(getNetworkProvider('mainnet')) + const safeProvider = getSafeProviderFromNetwork('mainnet') const safeVersion: SafeVersion = '1.3.0' - const createCallContract = await ethAdapter.getCreateCallContract({ + const createCallContract = await safeProvider.getCreateCallContract({ safeVersion }) chai @@ -243,12 +241,11 @@ describe('Safe contracts', () => { }) it('should return a SafeProxyFactory contract from the custom addresses', async () => { - const { accounts, contractNetworks, chainId } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { contractNetworks, chainId, provider } = await setupTests() + const safeProvider = new SafeProvider({ provider }) const safeVersion: SafeVersion = '1.3.0' const customContract = contractNetworks[chainId.toString()] - const createCallContract = await ethAdapter.getCreateCallContract({ + const createCallContract = await safeProvider.getCreateCallContract({ safeVersion, customContractAddress: customContract.createCallAddress, customContractAbi: customContract.createCallAbi diff --git a/packages/protocol-kit/tests/e2e/threshold.test.ts b/packages/protocol-kit/tests/e2e/threshold.test.ts index 7397ad20f..254f2ad0d 100644 --- a/packages/protocol-kit/tests/e2e/threshold.test.ts +++ b/packages/protocol-kit/tests/e2e/threshold.test.ts @@ -8,7 +8,7 @@ import chaiAsPromised from 'chai-as-promised' import { deployments } from 'hardhat' import { getContractNetworks } from './utils/setupContractNetworks' import { getSafeWithOwners } from './utils/setupContracts' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' import { waitSafeTxReceipt } from './utils/transactions' @@ -29,21 +29,22 @@ describe('Safe Threshold', () => { safeVersion: safeVersionDeployed } } + const provider = getEip1193Provider() + return { safe: await getSafeWithOwners([accounts[0].address]), accounts, contractNetworks, - predictedSafe + predictedSafe, + provider } }) describe('getThreshold', async () => { it('should fail if the Safe is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -51,11 +52,9 @@ describe('Safe Threshold', () => { }) it('should return the Safe threshold', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -65,11 +64,9 @@ describe('Safe Threshold', () => { describe('createChangeThresholdTx', async () => { it('should fail if the Safe is not deployed', async () => { - const { predictedSafe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { predictedSafe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -80,11 +77,9 @@ describe('Safe Threshold', () => { }) it('should fail if the threshold is bigger than the number of owners', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -97,11 +92,9 @@ describe('Safe Threshold', () => { }) it('should fail if the threshold is not bigger than 0', async () => { - const { safe, accounts, contractNetworks } = await setupTests() - const [account1] = accounts - const ethAdapter = await getEthAdapter(account1.signer) + const { safe, contractNetworks, provider } = await setupTests() const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -112,12 +105,11 @@ describe('Safe Threshold', () => { }) it('should build the transaction with the optional props', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address, account2.address], 1) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) @@ -141,12 +133,11 @@ describe('Safe Threshold', () => { }) it('should change the threshold', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address, account2.address], 1) - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress: await safe.getAddress(), contractNetworks }) diff --git a/packages/protocol-kit/tests/e2e/utils/setupContracts.ts b/packages/protocol-kit/tests/e2e/utils/setupContracts.ts index 10bf717bc..af82e3ba7 100644 --- a/packages/protocol-kit/tests/e2e/utils/setupContracts.ts +++ b/packages/protocol-kit/tests/e2e/utils/setupContracts.ts @@ -1,4 +1,4 @@ -import { Contract, ZeroAddress } from 'ethers' +import { Contract, ZeroAddress, JsonFragment } from 'ethers' import { compatibilityFallbackHandlerDeployed, createCallDeployed, @@ -12,13 +12,12 @@ import { } from '@safe-global/protocol-kit/hardhat/deploy/deploy-contracts' import { deployments, ethers } from 'hardhat' import semverSatisfies from 'semver/functions/satisfies' -import { AbiItem } from 'web3-utils' // TODO: changue contract por abitype objts export const getSafeSingleton = async (): Promise<{ contract: Contract - abi: AbiItem | AbiItem[] + abi: JsonFragment | JsonFragment[] }> => { const SafeDeployment = await deployments.get(safeDeployed.name) const Safe = await ethers.getContractFactory(safeDeployed.name) @@ -30,7 +29,7 @@ export const getSafeSingleton = async (): Promise<{ export const getFactory = async (): Promise<{ contract: Contract - abi: AbiItem | AbiItem[] + abi: JsonFragment | JsonFragment[] }> => { const FactoryDeployment = await deployments.get(proxyFactoryDeployed.name) const Factory = await ethers.getContractFactory(proxyFactoryDeployed.name) @@ -90,7 +89,7 @@ export const getSafeWithOwners = async ( export const getCompatibilityFallbackHandler = async (): Promise<{ contract: Contract - abi: AbiItem | AbiItem[] + abi: JsonFragment | JsonFragment[] }> => { const CompatibilityFallbackHandlerDeployment = await deployments.get( compatibilityFallbackHandlerDeployed.name @@ -106,7 +105,7 @@ export const getCompatibilityFallbackHandler = async (): Promise<{ export const getMultiSend = async (): Promise<{ contract: Contract - abi: AbiItem | AbiItem[] + abi: JsonFragment | JsonFragment[] }> => { const MultiSendDeployment = await deployments.get(multiSendDeployed.name) const MultiSend = await ethers.getContractFactory(multiSendDeployed.name) @@ -118,7 +117,7 @@ export const getMultiSend = async (): Promise<{ export const getMultiSendCallOnly = async (): Promise<{ contract: Contract - abi: AbiItem | AbiItem[] + abi: JsonFragment | JsonFragment[] }> => { const MultiSendCallOnlyDeployment = await deployments.get(multiSendCallOnlyDeployed.name) const MultiSendCallOnly = await ethers.getContractFactory(multiSendCallOnlyDeployed.name) @@ -130,7 +129,7 @@ export const getMultiSendCallOnly = async (): Promise<{ export const getSignMessageLib = async (): Promise<{ contract: Contract - abi: AbiItem | AbiItem[] + abi: JsonFragment | JsonFragment[] }> => { const SignMessageLibDeployment = await deployments.get(signMessageLibDeployed.name) const SignMessageLib = await ethers.getContractFactory(signMessageLibDeployed.name) @@ -142,7 +141,7 @@ export const getSignMessageLib = async (): Promise<{ export const getCreateCall = async (): Promise<{ contract: Contract - abi: AbiItem | AbiItem[] + abi: JsonFragment | JsonFragment[] }> => { const CreateCallDeployment = await deployments.get(createCallDeployed.name) const CreateCall = await ethers.getContractFactory(createCallDeployed.name) @@ -154,7 +153,7 @@ export const getCreateCall = async (): Promise<{ export const getSimulateTxAccessor = async (): Promise<{ contract: Contract - abi: AbiItem | AbiItem[] + abi: JsonFragment | JsonFragment[] }> => { const SimulateTxAccessorDeployment = await deployments.get(simulateTxAccessorDeployed.name) const SimulateTxAccessor = await ethers.getContractFactory(simulateTxAccessorDeployed.name) @@ -176,6 +175,18 @@ export const getSocialRecoveryModule = async (): Promise => { return SocialRecoveryModule.attach(SocialRecoveryModuleDeployment.address) } +export const getStateChannelModule = async (): Promise => { + const StateChannelModuleDeployment = await deployments.get('StateChannelModule') + const StateChannelModule = await ethers.getContractFactory('StateChannelModule') + return StateChannelModule.attach(StateChannelModuleDeployment.address) +} + +export const getWhiteListModule = async (): Promise => { + const WhiteListModuleDeployment = await deployments.get('WhitelistModule') + const WhiteListModule = await ethers.getContractFactory('WhitelistModule') + return WhiteListModule.attach(WhiteListModuleDeployment.address) +} + export const getERC20Mintable = async (): Promise => { const ERC20MintableDeployment = await deployments.get('ERC20Mintable') const ERC20Mintable = await ethers.getContractFactory('ERC20Mintable') diff --git a/packages/protocol-kit/tests/e2e/utils/setupEthAdapter.ts b/packages/protocol-kit/tests/e2e/utils/setupEthAdapter.ts deleted file mode 100644 index 2367e2caa..000000000 --- a/packages/protocol-kit/tests/e2e/utils/setupEthAdapter.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { Provider, AbstractSigner } from 'ethers' -import { - EthersAdapter, - EthersAdapterConfig, - Web3Adapter, - Web3AdapterConfig -} from '@safe-global/protocol-kit/index' -import { EthAdapter } from '@safe-global/protocol-kit/adapters/ethAdapter' -import { ethers, web3 } from 'hardhat' -import Web3 from 'web3' -import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers' - -type Network = 'mainnet' | 'gnosis' | 'zksync' | 'goerli' | 'sepolia' - -export async function getEthAdapter( - signerOrProvider: AbstractSigner | Provider | Web3 -): Promise { - let ethAdapter: EthAdapter - switch (process.env.ETH_LIB) { - case 'web3': - const signerAddress = - signerOrProvider instanceof HardhatEthersSigner - ? await signerOrProvider.getAddress() - : undefined - - const web3Instance = signerOrProvider instanceof Web3 ? signerOrProvider : web3 - const web3AdapterConfig: Web3AdapterConfig = { web3: web3Instance, signerAddress } - ethAdapter = new Web3Adapter(web3AdapterConfig) - break - case 'ethers': - const ethersAdapterConfig: EthersAdapterConfig = { - ethers, - signerOrProvider: signerOrProvider as Provider - } - ethAdapter = new EthersAdapter(ethersAdapterConfig) - break - default: - throw new Error('Ethereum library not supported') - } - - return ethAdapter -} - -export function getNetworkProvider(network: Network): Provider | Web3 { - let rpcUrl: string - switch (network) { - case 'zksync': - rpcUrl = 'https://mainnet.era.zksync.io' - break - case 'gnosis': - rpcUrl = 'https://rpc.gnosischain.com' - break - case 'goerli': - rpcUrl = 'https://rpc.ankr.com/eth_goerli' - break - case 'sepolia': - rpcUrl = 'https://rpc.ankr.com/eth_sepolia' - break - case 'mainnet': - rpcUrl = 'https://rpc.ankr.com/eth' - break - default: - throw new Error('Chain not supported') - } - - let provider - switch (process.env.ETH_LIB) { - case 'web3': - provider = new Web3(rpcUrl) - break - case 'ethers': - provider = new ethers.JsonRpcProvider(rpcUrl) - break - default: - throw new Error('Ethereum library not supported') - } - - return provider -} diff --git a/packages/protocol-kit/tests/e2e/utils/setupProvider.ts b/packages/protocol-kit/tests/e2e/utils/setupProvider.ts new file mode 100644 index 000000000..bd24b0984 --- /dev/null +++ b/packages/protocol-kit/tests/e2e/utils/setupProvider.ts @@ -0,0 +1,64 @@ +import hre, { ethers } from 'hardhat' +import Web3 from 'web3' +import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers' +import { custom, createWalletClient } from 'viem' + +import { SafeProvider } from '@safe-global/protocol-kit/index' +import { Eip1193Provider } from '@safe-global/protocol-kit/types' + +type Network = 'mainnet' | 'gnosis' | 'zksync' | 'goerli' | 'sepolia' + +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 function getSafeProviderFromNetwork( + network: Network, + signer?: HardhatEthersSigner +): SafeProvider { + let rpcUrl: string + switch (network) { + case 'zksync': + rpcUrl = 'https://mainnet.era.zksync.io' + break + case 'gnosis': + rpcUrl = 'https://rpc.gnosischain.com' + break + case 'goerli': + rpcUrl = 'https://rpc.ankr.com/eth_goerli' + break + case 'sepolia': + rpcUrl = 'https://rpc.ankr.com/eth_sepolia' + break + case 'mainnet': + rpcUrl = 'https://rpc.ankr.com/eth' + break + default: + throw new Error('Chain not supported') + } + + return new SafeProvider({ provider: rpcUrl, signer: signer?.address }) +} diff --git a/packages/protocol-kit/tests/e2e/utils/setupTestNetwork.ts b/packages/protocol-kit/tests/e2e/utils/setupTestNetwork.ts index 8e08c7cb0..43455ad0d 100644 --- a/packages/protocol-kit/tests/e2e/utils/setupTestNetwork.ts +++ b/packages/protocol-kit/tests/e2e/utils/setupTestNetwork.ts @@ -1,22 +1,10 @@ import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers' -import { ethers, Web3 } from 'hardhat' +import { ethers } from 'hardhat' interface Account { signer: HardhatEthersSigner address: string } -async function getGanacheAccounts(): Promise { - const web3 = new Web3('http://localhost:8545') - const provider = new ethers.BrowserProvider(web3.currentProvider as any) - const accounts: Account[] = [] - for (let i = 0; i < 10; i++) { - const signer = provider.getSigner(i) - const account: Account = { signer, address: await signer.getAddress() } - accounts.push(account) - } - return accounts -} - async function getHardhatAccounts(): Promise { const wallets = await ethers.getSigners() @@ -32,7 +20,6 @@ async function getHardhatAccounts(): Promise { } export async function getAccounts(): Promise { - const accounts = - process.env.TEST_NETWORK === 'ganache' ? await getGanacheAccounts() : await getHardhatAccounts() + const accounts = await getHardhatAccounts() return accounts } diff --git a/packages/protocol-kit/tests/e2e/utils/transactions.ts b/packages/protocol-kit/tests/e2e/utils/transactions.ts index a4071f3b0..27265dbd1 100644 --- a/packages/protocol-kit/tests/e2e/utils/transactions.ts +++ b/packages/protocol-kit/tests/e2e/utils/transactions.ts @@ -1,28 +1,19 @@ import { ContractTransactionReceipt } from 'ethers' import { TransactionResult } from '@safe-global/safe-core-sdk-types' -import { EthAdapter } from '@safe-global/protocol-kit/adapters/ethAdapter' -import { TransactionReceipt } from 'web3-core/types' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' export async function waitSafeTxReceipt( txResult: TransactionResult -): Promise { - const receipt: ContractTransactionReceipt | TransactionReceipt | undefined = txResult.promiEvent - ? await new Promise( - (resolve, reject) => - txResult.promiEvent && - txResult.promiEvent - .on('confirmation', (_confirmationNumber: any, receipt: TransactionReceipt) => - resolve(receipt) - ) - .catch(reject) - ) - : txResult.transactionResponse && (await txResult.transactionResponse.wait()) +): Promise { + const receipt: ContractTransactionReceipt | null | undefined = + txResult.transactionResponse && (await txResult.transactionResponse.wait()) + return receipt } export async function getTransaction( - ethAdapter: EthAdapter, + safeProvider: SafeProvider, transactionHash: string ): Promise { - return ethAdapter.getTransaction(transactionHash) + return safeProvider.getTransaction(transactionHash) } diff --git a/packages/protocol-kit/tests/e2e/utilsContracts.test.ts b/packages/protocol-kit/tests/e2e/utilsContracts.test.ts index 475f2d8a5..f2a6cdf0e 100644 --- a/packages/protocol-kit/tests/e2e/utilsContracts.test.ts +++ b/packages/protocol-kit/tests/e2e/utilsContracts.test.ts @@ -1,10 +1,9 @@ import chai from 'chai' import { deployments } from 'hardhat' - import { getAccounts } from './utils/setupTestNetwork' import { getContractNetworks } from './utils/setupContractNetworks' import { getDefaultCallbackHandler } from './utils/setupContracts' -import { getEthAdapter, getNetworkProvider } from './utils/setupEthAdapter' +import { getEip1193Provider, getSafeProviderFromNetwork } from './utils/setupProvider' import { PREDETERMINED_SALT_NONCE, predictSafeAddress @@ -13,20 +12,23 @@ import { safeVersionDeployed } from '@safe-global/protocol-kit/hardhat/deploy/de import { SafeDeploymentConfig, SafeAccountConfig, - ContractNetworksConfig + ContractNetworksConfig, + Eip1193Provider } from '@safe-global/protocol-kit/types' import Safe, { SafeFactory, DeploySafeProps } from '@safe-global/protocol-kit/index' -import { EthAdapter } from '@safe-global/protocol-kit/adapters/ethAdapter' +import SafeProvider from '@safe-global/protocol-kit/SafeProvider' import { itif } from './utils/helpers' // test util funcion to deploy a safe (needed to check the expected Safe Address) async function deploySafe( deploySafeProps: DeploySafeProps, - ethAdapter: EthAdapter, - contractNetworks: ContractNetworksConfig + provider: Eip1193Provider, + contractNetworks: ContractNetworksConfig, + signerAddress?: string ): Promise { const safeFactory = await SafeFactory.create({ - ethAdapter, + provider, + signer: signerAddress, safeVersion: safeVersionDeployed, contractNetworks }) @@ -40,24 +42,27 @@ describe('Contract utils', () => { const accounts = await getAccounts() const chainId = BigInt(await getChainId()) const contractNetworks = await getContractNetworks(chainId) + const provider = getEip1193Provider() + return { defaultCallbackHandler: await getDefaultCallbackHandler(), chainId, accounts, - contractNetworks + contractNetworks, + provider } }) describe('predictSafeAddress', () => { it('returns the predicted address of a 1/1 Safe', async () => { - const { accounts, contractNetworks, chainId } = await setupTests() + const { accounts, contractNetworks, chainId, provider } = await setupTests() // 1/1 Safe const [owner1] = accounts const owners = [owner1.address] const threshold = 1 const safeVersion = safeVersionDeployed - const ethAdapter = await getEthAdapter(owner1.signer) + const safeProvider = new SafeProvider({ provider }) const customContracts = contractNetworks[chainId.toString()] const safeAccountConfig: SafeAccountConfig = { @@ -71,7 +76,7 @@ describe('Contract utils', () => { } const predictedSafeAddress = await predictSafeAddress({ - ethAdapter, + safeProvider, chainId, safeAccountConfig, safeDeploymentConfig, @@ -81,8 +86,9 @@ describe('Contract utils', () => { // we deploy the Safe with the given configuration and the deployed Safe address should be equal to the predicted one const deployedSafe = await deploySafe( { safeAccountConfig, saltNonce: safeDeploymentConfig.saltNonce }, - ethAdapter, - contractNetworks + provider, + contractNetworks, + owner1.address ) // We ensure the Safe is deployed, as getAddress() function is able to return an address for a predictedSafe @@ -94,14 +100,14 @@ describe('Contract utils', () => { }) it('returns the predicted address of a 1/2 Safe', async () => { - const { accounts, contractNetworks, chainId } = await setupTests() + const { accounts, contractNetworks, chainId, provider } = await setupTests() // 1/2 Safe const [owner1, owner2] = accounts const owners = [owner1.address, owner2.address] const threshold = 1 const safeVersion = safeVersionDeployed - const ethAdapter = await getEthAdapter(owner1.signer) + const safeProvider = new SafeProvider({ provider }) const customContracts = contractNetworks[chainId.toString()] const safeAccountConfig: SafeAccountConfig = { @@ -115,7 +121,7 @@ describe('Contract utils', () => { } const predictedSafeAddress = await predictSafeAddress({ - ethAdapter, + safeProvider, chainId, safeAccountConfig, safeDeploymentConfig, @@ -125,8 +131,9 @@ describe('Contract utils', () => { // we deploy the Safe with the given configuration and the deployed Safe address should be equal to the predicted one const deployedSafe = await deploySafe( { safeAccountConfig, saltNonce: safeDeploymentConfig.saltNonce }, - ethAdapter, - contractNetworks + provider, + contractNetworks, + owner1.address ) // We ensure the Safe is deployed, as getAddress() function is able to return an address for a predictedSafe @@ -138,14 +145,14 @@ describe('Contract utils', () => { }) it('returns the predicted address of a 2/2 Safe', async () => { - const { accounts, contractNetworks, chainId } = await setupTests() + const { accounts, contractNetworks, chainId, provider } = await setupTests() // 2/2 Safe const [owner1, owner2] = accounts const owners = [owner1.address, owner2.address] const threshold = 2 const safeVersion = safeVersionDeployed - const ethAdapter = await getEthAdapter(owner1.signer) + const safeProvider = new SafeProvider({ provider }) const customContracts = contractNetworks[chainId.toString()] const safeAccountConfig: SafeAccountConfig = { @@ -159,7 +166,7 @@ describe('Contract utils', () => { } const predictedSafeAddress = await predictSafeAddress({ - ethAdapter, + safeProvider, chainId, safeAccountConfig, safeDeploymentConfig, @@ -169,8 +176,9 @@ describe('Contract utils', () => { // we deploy the Safe with the given configuration and the deployed Safe address should be equal to the predicted one const deployedSafe = await deploySafe( { safeAccountConfig, saltNonce: safeDeploymentConfig.saltNonce }, - ethAdapter, - contractNetworks + provider, + contractNetworks, + owner1.address ) // We ensure the Safe is deployed, as getAddress() function is able to return an address for a predictedSafe @@ -182,14 +190,14 @@ describe('Contract utils', () => { }) it('should fail if the provided threshold is invalid (greater than owners length)', async () => { - const { accounts, contractNetworks, chainId } = await setupTests() + const { accounts, contractNetworks, chainId, provider } = await setupTests() // invalid threshold 3/2 Safe const [owner1, owner2] = accounts const owners = [owner1.address, owner2.address] const invalidThreshold = 3 const safeVersion = safeVersionDeployed - const ethAdapter = await getEthAdapter(owner1.signer) + const safeProvider = new SafeProvider({ provider }) const customContracts = contractNetworks[chainId.toString()] const safeAccountConfig: SafeAccountConfig = { @@ -203,7 +211,7 @@ describe('Contract utils', () => { } const predictSafeAddressWithInvalidThreshold = { - ethAdapter, + safeProvider, chainId, safeAccountConfig, safeDeploymentConfig, @@ -216,14 +224,14 @@ describe('Contract utils', () => { }) it('should fail if the provided threshold is invalid (zero value)', async () => { - const { accounts, contractNetworks, chainId } = await setupTests() + const { accounts, contractNetworks, chainId, provider } = await setupTests() // invalid threshold 0/2 Safe const [owner1, owner2] = accounts const owners = [owner1.address, owner2.address] const invalidThreshold = 0 const safeVersion = safeVersionDeployed - const ethAdapter = await getEthAdapter(owner1.signer) + const safeProvider = new SafeProvider({ provider }) const customContracts = contractNetworks[chainId.toString()] const safeAccountConfig: SafeAccountConfig = { @@ -237,7 +245,7 @@ describe('Contract utils', () => { } const predictSafeAddressWithInvalidThreshold = { - ethAdapter, + safeProvider, chainId, safeAccountConfig, safeDeploymentConfig, @@ -250,14 +258,14 @@ describe('Contract utils', () => { }) it('should fail if the provided threshold is invalid (negative value)', async () => { - const { accounts, contractNetworks, chainId } = await setupTests() + const { accounts, contractNetworks, chainId, provider } = await setupTests() // invalid threshold -2/2 Safe const [owner1, owner2] = accounts const owners = [owner1.address, owner2.address] const invalidThreshold = -2 const safeVersion = safeVersionDeployed - const ethAdapter = await getEthAdapter(owner1.signer) + const safeProvider = new SafeProvider({ provider }) const customContracts = contractNetworks[chainId.toString()] const safeAccountConfig: SafeAccountConfig = { @@ -271,7 +279,7 @@ describe('Contract utils', () => { } const predictSafeAddressWithInvalidThreshold = { - ethAdapter, + safeProvider, chainId, safeAccountConfig, safeDeploymentConfig, @@ -284,13 +292,13 @@ describe('Contract utils', () => { }) it('should fail if no owners are present (empty array)', async () => { - const { accounts, contractNetworks, chainId } = await setupTests() + const { contractNetworks, chainId, provider } = await setupTests() // invalid owners 1/0 Safe const invalidOwners: string[] = [] const threshold = 1 const safeVersion = safeVersionDeployed - const ethAdapter = await getEthAdapter(accounts[0].signer) + const safeProvider = new SafeProvider({ provider }) const customContracts = contractNetworks[chainId.toString()] const safeAccountConfig: SafeAccountConfig = { @@ -304,7 +312,7 @@ describe('Contract utils', () => { } const predictSafeAddressWithInvalidThreshold = { - ethAdapter, + safeProvider, chainId, safeAccountConfig, safeDeploymentConfig, @@ -317,14 +325,14 @@ describe('Contract utils', () => { }) it('returns different addresses with different saltNonce value but same Safe config (threshold & owners)', async () => { - const { accounts, contractNetworks, chainId } = await setupTests() + const { accounts, contractNetworks, chainId, provider } = await setupTests() // 1/2 Safe const [owner1, owner2] = accounts const owners = [owner1.address, owner2.address] const threshold = 1 const safeVersion = safeVersionDeployed - const ethAdapter = await getEthAdapter(owner1.signer) + const safeProvider = new SafeProvider({ provider }) const customContracts = contractNetworks[chainId.toString()] const safeAccountConfig: SafeAccountConfig = { @@ -337,7 +345,7 @@ describe('Contract utils', () => { const thirdSaltNonce = '3' const predictedSafeAddress1 = await predictSafeAddress({ - ethAdapter, + safeProvider, chainId, safeAccountConfig, safeDeploymentConfig: { @@ -350,8 +358,9 @@ describe('Contract utils', () => { // we deploy the Safe with the given configuration and the deployed Safe address should be equal to the predicted one const firstDeployedSafe = await deploySafe( { safeAccountConfig, saltNonce: firstSaltNonce }, - ethAdapter, - contractNetworks + provider, + contractNetworks, + owner1.address ) // We ensure the Safe is deployed, as getAddress() function is able to return an address for a predictedSafe @@ -360,7 +369,7 @@ describe('Contract utils', () => { chai.expect(predictedSafeAddress1).to.be.equal(await firstDeployedSafe.getAddress()) const predictedSafeAddress2 = await predictSafeAddress({ - ethAdapter, + safeProvider, chainId, safeAccountConfig, safeDeploymentConfig: { @@ -373,8 +382,9 @@ describe('Contract utils', () => { // we deploy the Safe with the given configuration and the deployed Safe address should be equal to the predicted one const secondDeployedSafe = await deploySafe( { safeAccountConfig, saltNonce: secondSaltNonce }, - ethAdapter, - contractNetworks + provider, + contractNetworks, + owner1.address ) // We ensure the Safe is deployed, as getAddress() function is able to return an address for a predictedSafe @@ -383,7 +393,7 @@ describe('Contract utils', () => { chai.expect(predictedSafeAddress2).to.be.equal(await secondDeployedSafe.getAddress()) const predictedSafeAddress3 = await predictSafeAddress({ - ethAdapter, + safeProvider, chainId, safeAccountConfig, safeDeploymentConfig: { @@ -396,8 +406,9 @@ describe('Contract utils', () => { // we deploy the Safe with the given configuration and the deployed Safe address should be equal to the predicted one const thirdDeployedSafe = await deploySafe( { safeAccountConfig, saltNonce: thirdSaltNonce }, - ethAdapter, - contractNetworks + provider, + contractNetworks, + owner1.address ) // We ensure the Safe is deployed, as getAddress() function is able to return an address for a predictedSafe @@ -407,14 +418,14 @@ describe('Contract utils', () => { }) it('returns the same predicted address for multiple calls to predictedSafeAddress with the same config (owners, threshold & saltNonce)', async () => { - const { accounts, contractNetworks, chainId } = await setupTests() + const { accounts, contractNetworks, chainId, provider } = await setupTests() // 2/2 Safe const [owner1, owner2] = accounts const owners = [owner1.address, owner2.address] const threshold = 2 const safeVersion = safeVersionDeployed - const ethAdapter = await getEthAdapter(owner1.signer) + const safeProvider = new SafeProvider({ provider }) const customContracts = contractNetworks[chainId.toString()] const safeAccountConfig: SafeAccountConfig = { @@ -430,15 +441,16 @@ describe('Contract utils', () => { // we deploy the Safe with the given configuration and the deployed Safe address should be equal to the predicted one const deployedSafe = await deploySafe( { safeAccountConfig, saltNonce: safeDeploymentConfig.saltNonce }, - ethAdapter, - contractNetworks + provider, + contractNetworks, + owner1.address ) // We ensure the Safe is deployed, as getAddress() function is able to return an address for a predictedSafe const isSafeDeployed = await deployedSafe.isSafeDeployed() const expectedSafeAddress = await deployedSafe.getAddress() const firstPredictedSafeAddress = await predictSafeAddress({ - ethAdapter, + safeProvider, chainId, safeAccountConfig, safeDeploymentConfig, @@ -446,7 +458,7 @@ describe('Contract utils', () => { }) const secondPredictedSafeAddress = await predictSafeAddress({ - ethAdapter, + safeProvider, chainId, safeAccountConfig, safeDeploymentConfig, @@ -454,7 +466,7 @@ describe('Contract utils', () => { }) const thirdPredictedSafeAddress = await predictSafeAddress({ - ethAdapter, + safeProvider, chainId, safeAccountConfig, safeDeploymentConfig, @@ -471,13 +483,12 @@ describe('Contract utils', () => { itif(safeVersionDeployed > '1.0.0')( 'safeDeploymentConfig is an optional parameter', async () => { - const { accounts, contractNetworks, chainId } = await setupTests() + const { accounts, contractNetworks, chainId, provider } = await setupTests() // 1/1 Safe const [owner1] = accounts const owners = [owner1.address] const threshold = 1 - const ethAdapter = await getEthAdapter(owner1.signer) const customContracts = contractNetworks[chainId.toString()] const safeAccountConfig: SafeAccountConfig = { @@ -485,15 +496,22 @@ describe('Contract utils', () => { threshold } + const safeProvider = new SafeProvider({ provider }) + const predictedSafeAddress = await predictSafeAddress({ - ethAdapter, + safeProvider, chainId, safeAccountConfig, customContracts }) // we deploy the Safe by providing only the safeAccountConfig (owners & threshold) - const deployedSafe = await deploySafe({ safeAccountConfig }, ethAdapter, contractNetworks) + const deployedSafe = await deploySafe( + { safeAccountConfig }, + provider, + contractNetworks, + owner1.address + ) // We ensure the Safe is deployed const isSafeDeployed = await deployedSafe.isSafeDeployed() @@ -511,9 +529,9 @@ describe('Contract utils', () => { const { contractNetworks } = await setupTests() const safeVersion = safeVersionDeployed - // Create EthAdapter instance - const ethAdapter = await getEthAdapter(getNetworkProvider('zksync')) - const chainId = await ethAdapter.getChainId() + // Create SafeProvider instance + const safeProvider = getSafeProviderFromNetwork('zksync') + const chainId = await safeProvider.getChainId() const customContracts = contractNetworks[chainId.toString()] // We check real deployments from zksync return the expected address. @@ -530,7 +548,7 @@ describe('Contract utils', () => { const expectedSafeAddress1 = '0x4e19dA81a54eFbaBeb9AD50646f7643076475D65' const firstPredictedSafeAddress = await predictSafeAddress({ - ethAdapter, + safeProvider, chainId, safeAccountConfig: safeAccountConfig1, safeDeploymentConfig: safeDeploymentConfig1, @@ -552,7 +570,7 @@ describe('Contract utils', () => { const expectedSafeAddress2 = '0x60c7F13dE7C8Fb88b3845e58859658bdc44243F8' const secondPredictedSafeAddress = await predictSafeAddress({ - ethAdapter, + safeProvider, chainId, safeAccountConfig: safeAccountConfig2, safeDeploymentConfig: safeDeploymentConfig2, @@ -575,7 +593,7 @@ describe('Contract utils', () => { const expectedSafeAddress3 = '0xD971FAA20db3ad4d51D453047ca03Ce4ec164CE2' const thirdPredictedSafeAddress = await predictSafeAddress({ - ethAdapter, + safeProvider, chainId, safeAccountConfig: safeAccountConfig3, safeDeploymentConfig: safeDeploymentConfig3, @@ -597,10 +615,10 @@ describe('Contract utils', () => { const [owner] = accounts const safeVersion = safeVersionDeployed - const gnosisEthAdapter = await getEthAdapter(getNetworkProvider('gnosis')) - const zkSyncEthAdapter = await getEthAdapter(getNetworkProvider('zksync')) - const sepoliaEthAdapter = await getEthAdapter(getNetworkProvider('sepolia')) - const mainnetEthAdapter = await getEthAdapter(getNetworkProvider('mainnet')) + const gnosisSafeProvider = getSafeProviderFromNetwork('gnosis') + const zkSyncSafeProvider = getSafeProviderFromNetwork('zksync') + const sepoliaSafeProvider = getSafeProviderFromNetwork('sepolia') + const mainnetSafeProvider = getSafeProviderFromNetwork('mainnet') // 1/1 Safe const safeAccountConfig: SafeAccountConfig = { @@ -613,37 +631,37 @@ describe('Contract utils', () => { } const gnosisPredictedSafeAddress = await predictSafeAddress({ - ethAdapter: gnosisEthAdapter, - chainId: await gnosisEthAdapter.getChainId(), + safeProvider: gnosisSafeProvider, + chainId: await gnosisSafeProvider.getChainId(), safeAccountConfig: safeAccountConfig, safeDeploymentConfig: safeDeploymentConfig }) const zkSyncPredictedSafeAddress = await predictSafeAddress({ - ethAdapter: zkSyncEthAdapter, - chainId: await zkSyncEthAdapter.getChainId(), + safeProvider: zkSyncSafeProvider, + chainId: await zkSyncSafeProvider.getChainId(), safeAccountConfig: safeAccountConfig, safeDeploymentConfig: safeDeploymentConfig }) const sepoliaPredictedSafeAddress = await predictSafeAddress({ - ethAdapter: sepoliaEthAdapter, - chainId: await sepoliaEthAdapter.getChainId(), + safeProvider: sepoliaSafeProvider, + chainId: await sepoliaSafeProvider.getChainId(), safeAccountConfig: safeAccountConfig, safeDeploymentConfig: safeDeploymentConfig }) const mainnetPredictedSafeAddress = await predictSafeAddress({ - ethAdapter: mainnetEthAdapter, - chainId: await mainnetEthAdapter.getChainId(), + safeProvider: mainnetSafeProvider, + chainId: await mainnetSafeProvider.getChainId(), safeAccountConfig: safeAccountConfig, safeDeploymentConfig: safeDeploymentConfig }) - const expectedGnosisSafeAddress = '0x30421B2bE26942448CD6C690f21F551BF6C8A45F' + const expectedGnosisSafeAddress = '0x39aC50A7B35c43429397D0481EBa8769B5e4b9a6' const expectedSkSyncSafeAddress = '0x4680B7AC23A98d5D68c21e3d6F8cBC9576A5920A' - const expectedSepoliaSafeAddress = '0x7f44E49C9E4C7D19fA2A704c2E66527Bd4688f99' - const expectedMainnetSafeAddress = '0x9C1C8c37a68242cEC6d68Ab091583c81FBF479C0' + const expectedSepoliaSafeAddress = '0x643bD5C3Fd6c546c1452A16f978C350F8a0A2a8D' + const expectedMainnetSafeAddress = '0x22b257EABfA3B8BC9e0C5f6BA03400933834675B' // returns the correct predicted address for each chain chai.expect(gnosisPredictedSafeAddress).to.be.equal(expectedGnosisSafeAddress) diff --git a/packages/protocol-kit/tests/e2e/wrapSafeTransactionIntoDeploymentBatch.test.ts b/packages/protocol-kit/tests/e2e/wrapSafeTransactionIntoDeploymentBatch.test.ts index ba6c14285..d1cb7081d 100644 --- a/packages/protocol-kit/tests/e2e/wrapSafeTransactionIntoDeploymentBatch.test.ts +++ b/packages/protocol-kit/tests/e2e/wrapSafeTransactionIntoDeploymentBatch.test.ts @@ -6,7 +6,7 @@ import Safe, { PredictedSafeProps } from '@safe-global/protocol-kit/index' import { getContractNetworks } from './utils/setupContractNetworks' import { itif } from './utils/helpers' import { getSafeWithOwners, getMultiSendCallOnly } from './utils/setupContracts' -import { getEthAdapter } from './utils/setupEthAdapter' +import { getEip1193Provider } from './utils/setupProvider' import { getAccounts } from './utils/setupTestNetwork' chai.use(chaiAsPromised) @@ -29,25 +29,26 @@ describe('wrapSafeTransactionIntoDeploymentBatch', () => { safeVersion: safeVersionDeployed } } + const provider = getEip1193Provider() return { accounts, contractNetworks, predictedSafe, - chainId + chainId, + provider } }) it('should throw an error if the Safe is already deployed', async () => { - const { accounts, contractNetworks } = await setupTests() + const { accounts, contractNetworks, provider } = await setupTests() const [account1, account2] = accounts const safe = await getSafeWithOwners([account1.address]) const safeAddress = await safe.getAddress() - const ethAdapter = await getEthAdapter(account1.signer) const safeSdk = await Safe.create({ - ethAdapter, + provider, safeAddress, contractNetworks }) @@ -70,13 +71,11 @@ describe('wrapSafeTransactionIntoDeploymentBatch', () => { itif(safeVersionDeployed == '1.4.1')( 'should return a batch transaction with the Safe deployment Transaction and the Safe Transaction', async () => { - const { accounts, contractNetworks, predictedSafe } = await setupTests() - const [account1, account2] = accounts - - const ethAdapter = await getEthAdapter(account1.signer) + const { accounts, contractNetworks, predictedSafe, provider } = await setupTests() + const [, account2] = accounts const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -106,13 +105,11 @@ describe('wrapSafeTransactionIntoDeploymentBatch', () => { itif(safeVersionDeployed == '1.3.0')( 'should return a batch transaction with the Safe deployment Transaction and the Safe Transaction', async () => { - const { accounts, contractNetworks, predictedSafe } = await setupTests() - const [account1, account2] = accounts - - const ethAdapter = await getEthAdapter(account1.signer) + const { accounts, contractNetworks, predictedSafe, provider } = await setupTests() + const [, account2] = accounts const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -142,13 +139,11 @@ describe('wrapSafeTransactionIntoDeploymentBatch', () => { itif(safeVersionDeployed >= '1.3.0')( 'should include the custom salt nonce in the Safe deployment data', async () => { - const { accounts, contractNetworks, predictedSafe } = await setupTests() - const [account1, account2] = accounts - - const ethAdapter = await getEthAdapter(account1.signer) + const { accounts, contractNetworks, predictedSafe, provider } = await setupTests() + const [, account2] = accounts const safeSdk = await Safe.create({ - ethAdapter, + provider, predictedSafe, contractNetworks }) @@ -171,7 +166,9 @@ describe('wrapSafeTransactionIntoDeploymentBatch', () => { customSaltNonce ) - const customSaltNonceEncoded = ethAdapter.encodeParameters(['uint256'], [customSaltNonce]) + const customSaltNonceEncoded = safeSdk + .getSafeProvider() + .encodeParameters(['uint256'], [customSaltNonce]) // custom salt nonce included in the deployment data chai.expect(batchTransaction.data).to.contains(customSaltNonceEncoded.replace('0x', '')) diff --git a/packages/relay-kit/src/packs/safe-4337/Safe4337Pack.test.ts b/packages/relay-kit/src/packs/safe-4337/Safe4337Pack.test.ts index cc84ca34f..506b2a41d 100644 --- a/packages/relay-kit/src/packs/safe-4337/Safe4337Pack.test.ts +++ b/packages/relay-kit/src/packs/safe-4337/Safe4337Pack.test.ts @@ -193,7 +193,8 @@ describe('Safe4337Pack', () => { expect(encodeFunctionDataSpy).toHaveBeenCalledWith('enableModules', [[safe4337ModuleAddress]]) expect(safeCreateSpy).toHaveBeenCalledWith({ - ethAdapter: safe4337Pack.protocolKit.getEthAdapter(), + provider: safe4337Pack.protocolKit.getSafeProvider().provider, + signer: safe4337Pack.protocolKit.getSafeProvider().signer, predictedSafe: { safeDeploymentConfig: { safeVersion: constants.DEFAULT_SAFE_VERSION, @@ -259,7 +260,8 @@ describe('Safe4337Pack', () => { expect(encodeFunctionDataSpy).toHaveBeenNthCalledWith(4, 'multiSend', [multiSendData]) expect(safeCreateSpy).toHaveBeenCalledWith({ - ethAdapter: safe4337Pack.protocolKit.getEthAdapter(), + provider: safe4337Pack.protocolKit.getSafeProvider().provider, + signer: safe4337Pack.protocolKit.getSafeProvider().signer, predictedSafe: { safeDeploymentConfig: { safeVersion: constants.DEFAULT_SAFE_VERSION, diff --git a/packages/relay-kit/src/packs/safe-4337/Safe4337Pack.ts b/packages/relay-kit/src/packs/safe-4337/Safe4337Pack.ts index d5b5d10b6..9e8c854fa 100644 --- a/packages/relay-kit/src/packs/safe-4337/Safe4337Pack.ts +++ b/packages/relay-kit/src/packs/safe-4337/Safe4337Pack.ts @@ -2,7 +2,7 @@ import { ethers } from 'ethers' import semverSatisfies from 'semver/functions/satisfies' import Safe, { EthSafeSignature, - EthersAdapter, + SafeProvider, SigningMethod, encodeMultiSendData, getMultiSendContract @@ -105,7 +105,7 @@ export class Safe4337Pack extends RelayKitBasePack<{ * @return {Promise} The Promise object that will be resolved into an instance of Safe4337Pack. */ static async init(initOptions: Safe4337InitOptions): Promise { - const { ethersAdapter, options, bundlerUrl, rpcUrl, customContracts, paymasterOptions } = + const { provider, signer, options, bundlerUrl, rpcUrl, customContracts, paymasterOptions } = initOptions let protocolKit: Safe const bundlerClient = getEip4337BundlerProvider(bundlerUrl) @@ -143,7 +143,8 @@ export class Safe4337Pack extends RelayKitBasePack<{ // Existing Safe if ('safeAddress' in options) { protocolKit = await Safe.create({ - ethAdapter: ethersAdapter, + provider, + signer, safeAddress: options.safeAddress }) @@ -211,7 +212,7 @@ export class Safe4337Pack extends RelayKitBasePack<{ ]) const multiSendContract = await getMultiSendContract({ - ethAdapter: ethersAdapter, + safeProvider: new SafeProvider({ provider, signer }), safeVersion: options.safeVersion || DEFAULT_SAFE_VERSION }) @@ -220,7 +221,8 @@ export class Safe4337Pack extends RelayKitBasePack<{ } protocolKit = await Safe.create({ - ethAdapter: ethersAdapter, + provider, + signer, predictedSafe: { safeDeploymentConfig: { safeVersion: options.safeVersion || DEFAULT_SAFE_VERSION, @@ -424,9 +426,9 @@ export class Safe4337Pack extends RelayKitBasePack<{ signingMethod: SigningMethod = SigningMethod.ETH_SIGN_TYPED_DATA_V4 ): Promise { const owners = await this.protocolKit.getOwners() - const signerAddress = await this.protocolKit.getEthAdapter().getSignerAddress() + const signerAddress = await this.protocolKit.getSafeProvider().getSignerAddress() if (!signerAddress) { - throw new Error('EthAdapter must be initialized with a signer to use this method') + throw new Error('There is no signer address available to sign the SafeOperation') } const addressIsOwner = owners.some( @@ -446,7 +448,7 @@ export class Safe4337Pack extends RelayKitBasePack<{ ) { signature = await this.#signTypedData(safeOperation.data) } else { - const chainId = await this.protocolKit.getEthAdapter().getChainId() + const chainId = await this.protocolKit.getSafeProvider().getChainId() const safeOpHash = this.#getSafeUserOperationHash(safeOperation.data, chainId) signature = await this.protocolKit.signHash(safeOpHash) @@ -570,17 +572,14 @@ export class Safe4337Pack extends RelayKitBasePack<{ /** * Signs typed data. - * This is currently only EthersAdapter compatible (Reflected in the init() props). If I want to make it compatible with any EthAdapter I need to either: - * - Add a SafeOp type to the protocol-kit (createSafeOperation, signSafeOperation, etc) - * - Allow to pass the data types (SafeOp, SafeMessage, SafeTx) to the signTypedData method and refactor the protocol-kit to allow any kind of data signing from outside (Currently only SafeTx and SafeMessage) * * @param {SafeUserOperation} safeUserOperation - Safe user operation to sign. * @return {Promise} The SafeSignature object containing the data and the signatures. */ async #signTypedData(safeUserOperation: SafeUserOperation): Promise { - const ethAdapter = this.protocolKit.getEthAdapter() as EthersAdapter - const signer = ethAdapter.getSigner() as ethers.Signer - const chainId = await ethAdapter.getChainId() + const safeProvider = this.protocolKit.getSafeProvider() + const signer = (await safeProvider.getExternalSigner()) as ethers.Signer + const chainId = await safeProvider.getChainId() const signerAddress = await signer.getAddress() const signature = await signer.signTypedData( { diff --git a/packages/relay-kit/src/packs/safe-4337/testing-utils/helpers.ts b/packages/relay-kit/src/packs/safe-4337/testing-utils/helpers.ts index 69a7f67a7..0e347508e 100644 --- a/packages/relay-kit/src/packs/safe-4337/testing-utils/helpers.ts +++ b/packages/relay-kit/src/packs/safe-4337/testing-utils/helpers.ts @@ -1,5 +1,4 @@ import { ethers } from 'ethers' -import * as protocolKit from '@safe-global/protocol-kit' import { Safe4337InitOptions } from '../types' import { Safe4337Pack } from '../Safe4337Pack' import * as fixtures from './fixtures' @@ -14,19 +13,13 @@ export const generateTransferCallData = (to: string, value: bigint) => { export const createSafe4337Pack = async ( initOptions: Partial ): Promise => { - const provider = new ethers.JsonRpcProvider(fixtures.RPC_URL) - const signer = new ethers.Wallet(process.env.PRIVATE_KEY || '0x', provider) - const ethersAdapter = new protocolKit.EthersAdapter({ - ethers, - signerOrProvider: signer - }) - const safe4337Pack = await Safe4337Pack.init({ + provider: fixtures.RPC_URL, + signer: process.env.PRIVATE_KEY, options: { safeAddress: '' }, ...initOptions, - ethersAdapter, rpcUrl: fixtures.RPC_URL, bundlerUrl: fixtures.BUNDLER_URL }) diff --git a/packages/relay-kit/src/packs/safe-4337/types.ts b/packages/relay-kit/src/packs/safe-4337/types.ts index ddb701b37..95458c849 100644 --- a/packages/relay-kit/src/packs/safe-4337/types.ts +++ b/packages/relay-kit/src/packs/safe-4337/types.ts @@ -1,4 +1,4 @@ -import Safe, { EthersAdapter } from '@safe-global/protocol-kit' +import Safe, { SafeProviderConfig } from '@safe-global/protocol-kit' import { MetaTransactionData, SafeVersion } from '@safe-global/safe-core-sdk-types' import { ethers } from 'ethers' import SafeOperation from './SafeOperation' @@ -24,7 +24,8 @@ export type PaymasterOptions = { } export type Safe4337InitOptions = { - ethersAdapter: EthersAdapter + provider: SafeProviderConfig['provider'] + signer?: SafeProviderConfig['signer'] bundlerUrl: string rpcUrl: string safeModulesVersion?: string diff --git a/packages/safe-core-sdk-types/package.json b/packages/safe-core-sdk-types/package.json index 5d9ff7e33..63bd9979d 100644 --- a/packages/safe-core-sdk-types/package.json +++ b/packages/safe-core-sdk-types/package.json @@ -29,10 +29,7 @@ ], "homepage": "https://github.com/safe-global/safe-core-sdk#readme", "dependencies": { - "@safe-global/safe-deployments": "^1.34.0", - "ethers": "^6.7.1", - "web3-core": "^1.10.3", - "web3-utils": "^1.10.3" + "@safe-global/safe-deployments": "^1.34.0" }, "devDependencies": { "abitype": "^1.0.2" diff --git a/packages/safe-core-sdk-types/src/contracts/CreateCall/CreateCallBaseContract.ts b/packages/safe-core-sdk-types/src/contracts/CreateCall/CreateCallBaseContract.ts index 61b985a44..c88aad08e 100644 --- a/packages/safe-core-sdk-types/src/contracts/CreateCall/CreateCallBaseContract.ts +++ b/packages/safe-core-sdk-types/src/contracts/CreateCall/CreateCallBaseContract.ts @@ -1,6 +1,6 @@ import { Abi } from 'abitype' import BaseContract, { - AdapterSpecificContractFunction, + SafeContractFunction, ContractReadFunctionNames, EstimateGasFunction } from '../common/BaseContract' @@ -16,8 +16,8 @@ export type CreateCallBaseContract = BaseCont ContractReadFunctionNames > & { estimateGas: EstimateGasFunction - performCreate: AdapterSpecificContractFunction - performCreate2: AdapterSpecificContractFunction + performCreate: SafeContractFunction + performCreate2: SafeContractFunction } export default CreateCallBaseContract diff --git a/packages/safe-core-sdk-types/src/contracts/SignMessageLib/SignMessageLibBaseContract.ts b/packages/safe-core-sdk-types/src/contracts/SignMessageLib/SignMessageLibBaseContract.ts index 296bb8edf..de869c05a 100644 --- a/packages/safe-core-sdk-types/src/contracts/SignMessageLib/SignMessageLibBaseContract.ts +++ b/packages/safe-core-sdk-types/src/contracts/SignMessageLib/SignMessageLibBaseContract.ts @@ -1,6 +1,6 @@ import { Abi } from 'abitype' import BaseContract, { - AdapterSpecificContractFunction, + SafeContractFunction, ContractReadFunctionNames, EstimateGasFunction } from '../common/BaseContract' @@ -16,7 +16,7 @@ type SignMessageLibBaseContract = BaseCon ContractReadFunctionNames > & { estimateGas: EstimateGasFunction - signMessage: AdapterSpecificContractFunction + signMessage: SafeContractFunction } export default SignMessageLibBaseContract diff --git a/packages/safe-core-sdk-types/src/contracts/common/BaseContract.ts b/packages/safe-core-sdk-types/src/contracts/common/BaseContract.ts index c30cba631..a71fdb40b 100644 --- a/packages/safe-core-sdk-types/src/contracts/common/BaseContract.ts +++ b/packages/safe-core-sdk-types/src/contracts/common/BaseContract.ts @@ -4,15 +4,11 @@ import { ExtractAbiFunction, ExtractAbiFunctionNames } from 'abitype' -import { SafeVersion } from '@safe-global/safe-core-sdk-types/types' import { - EthersTransactionOptions, - EthersTransactionResult -} from '@safe-global/safe-core-sdk-types/ethereumLibs/ethers/types' -import { - Web3TransactionOptions, - Web3TransactionResult -} from '@safe-global/safe-core-sdk-types/ethereumLibs/web3/types' + SafeVersion, + TransactionOptions, + TransactionResult +} from '@safe-global/safe-core-sdk-types/types' /** * Extracts the names of read-only functions (view or pure) from a given contract ABI. @@ -66,28 +62,22 @@ export type EncodeFunction< ExtractAbiFunctionNames = ExtractAbiFunctionNames > = ( functionToEncode: ContractFunctionName, - // TODO: remove `DeepWriteable` here when web3 dependency is removed - args: DeepWriteable> + args: ExtractFunctionArgs ) => string /** * Estimates the gas required for a function call on a contract. * * @template ContractAbi - The ABI of the contract. - * @template TransactionOptions - The transaction options object. * @template ContractFunctionName - The function for which gas is being estimated, derived from the ABI. */ export type EstimateGasFunction< ContractAbi extends Abi, - TransactionOptions extends EthersTransactionOptions | Web3TransactionOptions = - | EthersTransactionOptions - | Web3TransactionOptions, ContractFunctionName extends ExtractAbiFunctionNames = ExtractAbiFunctionNames > = ( functionToEncode: ContractFunctionName, - // TODO: remove `DeepWriteable` here when web3 dependency is removed - args: DeepWriteable>, + args: ExtractFunctionArgs, options?: TransactionOptions ) => Promise @@ -107,8 +97,7 @@ export type ContractFunction< // input parameters (only if function has inputs, otherwise no parameters) ...args: ExtractFunctionArgs['length'] extends 0 ? [] - : // TODO: remove `DeepWriteable` here when web3 dependency is removed - [DeepWriteable>] + : [ExtractFunctionArgs] // returned values as a Promise ) => Promise> @@ -117,23 +106,14 @@ export type ContractFunction< * * @template ContractAbi - The ABI of the contract. * @template ContractFunctionName - The function name, derived from the ABI. - * @template TransactionOptions - The transaction options type depending on the Adapter. - * @template TransactionResult - The transaction result type depending on the Adapter. */ -export type AdapterSpecificContractFunction< +export type SafeContractFunction< ContractAbi extends Abi, ContractFunctionName extends - ExtractAbiFunctionNames = ExtractAbiFunctionNames, - TransactionOptions extends EthersTransactionOptions | Web3TransactionOptions = - | EthersTransactionOptions - | Web3TransactionOptions, - TransactionResult extends EthersTransactionResult | Web3TransactionResult = - | EthersTransactionResult - | Web3TransactionResult + ExtractAbiFunctionNames = ExtractAbiFunctionNames > = ( - // TODO: remove `DeepWriteable` here when web3 dependency is removed - args: DeepWriteable< - AbiParametersToPrimitiveTypes['inputs']> + args: AbiParametersToPrimitiveTypes< + ExtractAbiFunction['inputs'] >, options?: TransactionOptions ) => Promise @@ -158,16 +138,4 @@ type BaseContract< getAddress: GetAddressFunction } -/** - * Removes `readonly` modifier from all properties in T recursively. - * - * @template T - The type to make writable. - */ -export type DeepWriteable = T extends object & NotFunction - ? { -readonly [K in keyof T]: DeepWriteable } - : T - -type Not = T extends U ? never : T -type NotFunction = Not any> - export default BaseContract diff --git a/packages/safe-core-sdk-types/src/ethereumLibs/ethers/types.ts b/packages/safe-core-sdk-types/src/ethereumLibs/ethers/types.ts deleted file mode 100644 index f30a84fe5..000000000 --- a/packages/safe-core-sdk-types/src/ethereumLibs/ethers/types.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { ContractTransactionResponse } from 'ethers' -import { BaseTransactionResult } from '@safe-global/safe-core-sdk-types/types' - -export interface EthersTransactionOptions { - from?: string - gasLimit?: number | string - gasPrice?: number | string - maxFeePerGas?: number | string - maxPriorityFeePerGas?: number | string - nonce?: number -} - -export interface EthersTransactionResult extends BaseTransactionResult { - transactionResponse: ContractTransactionResponse - options?: EthersTransactionOptions -} diff --git a/packages/safe-core-sdk-types/src/ethereumLibs/web3/types.ts b/packages/safe-core-sdk-types/src/ethereumLibs/web3/types.ts deleted file mode 100644 index c321dfa4b..000000000 --- a/packages/safe-core-sdk-types/src/ethereumLibs/web3/types.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { PromiEvent, TransactionReceipt } from 'web3-core/types' -import { BaseTransactionResult } from '@safe-global/safe-core-sdk-types/types' - -export interface Web3TransactionOptions { - from?: string - gas?: number | string - gasPrice?: number | string - maxFeePerGas?: number | string - maxPriorityFeePerGas?: number | string - nonce?: number -} - -export interface Web3TransactionResult extends BaseTransactionResult { - promiEvent: PromiEvent - options?: Web3TransactionOptions -} diff --git a/packages/safe-core-sdk-types/src/index.ts b/packages/safe-core-sdk-types/src/index.ts index 1833e387b..ef9abd2ee 100644 --- a/packages/safe-core-sdk-types/src/index.ts +++ b/packages/safe-core-sdk-types/src/index.ts @@ -7,8 +7,6 @@ export * from './contracts/SignMessageLib' export * from './contracts/SimulateTxAccessor' export * from './contracts/common/BaseContract' export * from './contracts/assets' -export * from './ethereumLibs/ethers/types' -export * from './ethereumLibs/web3/types' export * from './types' // see docs: https://abitype.dev/config diff --git a/packages/safe-core-sdk-types/src/types.ts b/packages/safe-core-sdk-types/src/types.ts index b32e6b0d5..62634abf5 100644 --- a/packages/safe-core-sdk-types/src/types.ts +++ b/packages/safe-core-sdk-types/src/types.ts @@ -1,6 +1,3 @@ -import { ContractTransactionResponse } from 'ethers' -import { PromiEvent, TransactionReceipt } from 'web3-core/types' - export type SafeVersion = '1.4.1' | '1.3.0' | '1.2.0' | '1.1.1' | '1.0.0' export enum OperationType { @@ -86,7 +83,6 @@ interface TransactionBase { export interface TransactionOptions { from?: string - gas?: number | string gasLimit?: number | string gasPrice?: number | string maxFeePerGas?: number | string @@ -99,8 +95,7 @@ export interface BaseTransactionResult { } export interface TransactionResult extends BaseTransactionResult { - promiEvent?: PromiEvent - transactionResponse?: ContractTransactionResponse + transactionResponse: unknown options?: TransactionOptions } diff --git a/playground/api-kit/confirm-transaction.ts b/playground/api-kit/confirm-transaction.ts index 8e4b0ccaf..10c7ee3b6 100644 --- a/playground/api-kit/confirm-transaction.ts +++ b/playground/api-kit/confirm-transaction.ts @@ -1,6 +1,5 @@ +import Safe from '@safe-global/protocol-kit' import SafeApiKit from '@safe-global/api-kit' -import Safe, { EthersAdapter } from '@safe-global/protocol-kit' -import { ethers } from 'ethers' // This file can be used to play around with the Safe Core SDK @@ -21,41 +20,27 @@ const config: Config = { } async function main() { - const provider = new ethers.JsonRpcProvider(config.RPC_URL) - const signer = new ethers.Wallet(config.SIGNER_ADDRESS_PRIVATE_KEY, provider) - - // Create EthAdapter instance - const ethAdapter = new EthersAdapter({ - ethers, - signerOrProvider: signer - }) - // Create Safe instance - const safe = await Safe.create({ - ethAdapter, + const protocolKit = await Safe.create({ + provider: config.RPC_URL, + signer: config.SIGNER_ADDRESS_PRIVATE_KEY, safeAddress: config.SAFE_ADDRESS }) // Create Safe API Kit instance - const service = new SafeApiKit({ + const apiKit = new SafeApiKit({ chainId: config.CHAIN_ID }) // Get the transaction - const transaction = await service.getTransaction(config.SAFE_TX_HASH) - // const transactions = await service.getPendingTransactions() - // const transactions = await service.getIncomingTransactions() - // const transactions = await service.getMultisigTransactions() - // const transactions = await service.getModuleTransactions() - // const transactions = await service.getAllTransactions() - - const safeTxHash = transaction.transactionHash - const signature = await safe.signHash(safeTxHash) + const safeTransaction = await apiKit.getTransaction(config.SAFE_TX_HASH) + const safeTxHash = safeTransaction.safeTxHash + const signature = await protocolKit.signHash(safeTxHash) // Confirm the Safe transaction - const signatureResponse = await service.confirmTransaction(safeTxHash, signature.data) + const signatureResponse = await apiKit.confirmTransaction(safeTxHash, signature.data) - const signerAddress = await signer.getAddress() + const signerAddress = await protocolKit.getSafeProvider().getSignerAddress() console.log('Added a new signature to transaction with safeTxGas:', config.SAFE_TX_HASH) console.log('- Signer:', signerAddress) console.log('- Signer signature:', signatureResponse.signature) diff --git a/playground/api-kit/execute-transaction.ts b/playground/api-kit/execute-transaction.ts index 039b2b807..b48272bb3 100644 --- a/playground/api-kit/execute-transaction.ts +++ b/playground/api-kit/execute-transaction.ts @@ -1,6 +1,5 @@ +import Safe from '@safe-global/protocol-kit' import SafeApiKit from '@safe-global/api-kit' -import Safe, { EthersAdapter } from '@safe-global/protocol-kit' -import { ethers } from 'ethers' // This file can be used to play around with the Safe Core SDK @@ -21,38 +20,29 @@ const config: Config = { } async function main() { - const provider = new ethers.JsonRpcProvider(config.RPC_URL) - const signer = new ethers.Wallet(config.SIGNER_ADDRESS_PRIVATE_KEY, provider) - - // Create EthAdapter instance - const ethAdapter = new EthersAdapter({ - ethers, - signerOrProvider: signer - }) - // Create Safe instance - const safe = await Safe.create({ - ethAdapter, + const protocolKit = await Safe.create({ + provider: config.RPC_URL, + signer: config.SIGNER_ADDRESS_PRIVATE_KEY, safeAddress: config.SAFE_ADDRESS }) // Create Safe API Kit instance - const service = new SafeApiKit({ + const apiKit = new SafeApiKit({ chainId: config.CHAIN_ID }) // Get the transaction - const safeTransaction = await service.getTransaction(config.SAFE_TX_HASH) - - const isTxExecutable = await safe.isValidTransaction(safeTransaction) + const safeTransaction = await apiKit.getTransaction(config.SAFE_TX_HASH) + const isTxExecutable = await protocolKit.isValidTransaction(safeTransaction) if (isTxExecutable) { // Execute the transaction - const txResponse = await safe.executeTransaction(safeTransaction) + const txResponse = await protocolKit.executeTransaction(safeTransaction) const contractReceipt = await txResponse.transactionResponse?.wait() console.log('Transaction executed.') - console.log('- Transaction hash:', contractReceipt?.transactionHash) + console.log('- Transaction hash:', contractReceipt?.hash) } else { console.log('Transaction invalid. Transaction was not executed.') } diff --git a/playground/api-kit/propose-transaction.ts b/playground/api-kit/propose-transaction.ts index 279584f41..d2a6a38df 100644 --- a/playground/api-kit/propose-transaction.ts +++ b/playground/api-kit/propose-transaction.ts @@ -1,7 +1,6 @@ +import Safe from '@safe-global/protocol-kit' import SafeApiKit from '@safe-global/api-kit' -import Safe, { EthersAdapter } from '@safe-global/protocol-kit' import { OperationType, SafeTransactionDataPartial } from '@safe-global/safe-core-sdk-types' -import { ethers } from 'ethers' // This file can be used to play around with the Safe Core SDK @@ -20,51 +19,45 @@ const config: Config = { } async function main() { - const provider = new ethers.JsonRpcProvider(config.RPC_URL) - const signer = new ethers.Wallet(config.SIGNER_ADDRESS_PRIVATE_KEY, provider) - - // Create EthAdapter instance - const ethAdapter = new EthersAdapter({ - ethers, - signerOrProvider: signer - }) - // Create Safe instance - const safe = await Safe.create({ - ethAdapter, + const protocolKit = await Safe.create({ + provider: config.RPC_URL, + signer: config.SIGNER_ADDRESS_PRIVATE_KEY, safeAddress: config.SAFE_ADDRESS }) // Create Safe API Kit instance - const service = new SafeApiKit({ + const apiKit = new SafeApiKit({ chainId: config.CHAIN_ID }) // Create transaction const safeTransactionData: SafeTransactionDataPartial = { - to: '0x', + to: config.SAFE_ADDRESS, value: '1', // 1 wei data: '0x', operation: OperationType.Call } - const safeTransaction = await safe.createTransaction({ transactions: [safeTransactionData] }) + const safeTransaction = await protocolKit.createTransaction({ + transactions: [safeTransactionData] + }) - const senderAddress = await signer.getAddress() - const safeTxHash = await safe.getTransactionHash(safeTransaction) - const signature = await safe.signHash(safeTxHash) + const signerAddress = (await protocolKit.getSafeProvider().getSignerAddress()) || '0x' + const safeTxHash = await protocolKit.getTransactionHash(safeTransaction) + const signature = await protocolKit.signHash(safeTxHash) // Propose transaction to the service - await service.proposeTransaction({ + await apiKit.proposeTransaction({ safeAddress: config.SAFE_ADDRESS, safeTransactionData: safeTransaction.data, safeTxHash, - senderAddress, + senderAddress: signerAddress, senderSignature: signature.data }) console.log('Proposed a transaction with Safe:', config.SAFE_ADDRESS) console.log('- safeTxHash:', safeTxHash) - console.log('- Sender:', senderAddress) + console.log('- Sender:', signerAddress) console.log('- Sender signature:', signature.data) } diff --git a/playground/config/run.ts b/playground/config/run.ts index 726c12ebd..d295ee942 100644 --- a/playground/config/run.ts +++ b/playground/config/run.ts @@ -8,7 +8,7 @@ const playgroundProtocolKitPaths = { 'create-execute-transaction': 'protocol-kit/create-execute-transaction', 'deploy-safe': 'protocol-kit/deploy-safe', 'generate-safe-address': 'protocol-kit/generate-safe-address', - eip1271: 'protocol-kit/eip1271' + 'validate-signatures': 'protocol-kit/validate-signatures' } const playgroundApiKitPaths = { 'propose-transaction': 'api-kit/propose-transaction', diff --git a/playground/protocol-kit/create-execute-transaction.ts b/playground/protocol-kit/create-execute-transaction.ts index 90e1ceb79..97ad9d720 100644 --- a/playground/protocol-kit/create-execute-transaction.ts +++ b/playground/protocol-kit/create-execute-transaction.ts @@ -1,6 +1,5 @@ -import { ethers } from 'ethers' import * as dotenv from 'dotenv' -import Safe, { EthersAdapter, SigningMethod } from '@safe-global/protocol-kit' +import Safe, { SigningMethod } from '@safe-global/protocol-kit' import { OperationType, SafeTransactionDataPartial } from '@safe-global/safe-core-sdk-types' dotenv.config() @@ -25,18 +24,10 @@ const config: Config = { } async function main() { - const provider = new ethers.JsonRpcProvider(config.RPC_URL) - const signer = new ethers.Wallet(config.SIGNER_ADDRESS_PRIVATE_KEY, provider) - - // Create EthAdapter instance - const ethAdapter = new EthersAdapter({ - ethers, - signerOrProvider: signer - }) - // Create Safe instance const safe = await Safe.create({ - ethAdapter, + provider: config.RPC_URL, + signer: config.SIGNER_ADDRESS_PRIVATE_KEY, safeAddress: config.SAFE_ADDRESS }) diff --git a/playground/protocol-kit/deploy-safe.ts b/playground/protocol-kit/deploy-safe.ts index 3ce239bee..e68136e3a 100644 --- a/playground/protocol-kit/deploy-safe.ts +++ b/playground/protocol-kit/deploy-safe.ts @@ -1,7 +1,5 @@ import { SafeAccountConfig, SafeFactory } from '@safe-global/protocol-kit' -import { EthersAdapter } from '@safe-global/protocol-kit' import { SafeVersion } from '@safe-global/safe-core-sdk-types' -import { ethers } from 'ethers' // This file can be used to play around with the Safe Core SDK @@ -28,21 +26,16 @@ const config: Config = { } async function main() { - const provider = new ethers.JsonRpcProvider(config.RPC_URL) - const deployerSigner = new ethers.Wallet(config.DEPLOYER_ADDRESS_PRIVATE_KEY, provider) - - // Create EthAdapter instance - const ethAdapter = new EthersAdapter({ - ethers, - signerOrProvider: deployerSigner - }) - const safeVersion = config.DEPLOY_SAFE.SAFE_VERSION as SafeVersion console.log('safe config: ', config.DEPLOY_SAFE) // Create SafeFactory instance - const safeFactory = await SafeFactory.create({ ethAdapter, safeVersion }) + const safeFactory = await SafeFactory.create({ + provider: config.RPC_URL, + signer: config.DEPLOYER_ADDRESS_PRIVATE_KEY, + safeVersion + }) // Config of the deployed Safe const safeAccountConfig: SafeAccountConfig = { diff --git a/playground/protocol-kit/eip1271.ts b/playground/protocol-kit/eip1271.ts deleted file mode 100644 index 10129eea3..000000000 --- a/playground/protocol-kit/eip1271.ts +++ /dev/null @@ -1,65 +0,0 @@ -import Safe from '@safe-global/protocol-kit' -import { EthersAdapter, hashSafeMessage } from '@safe-global/protocol-kit' -import { ethers, JsonRpcProvider } from 'ethers' - -// This file can be used to play around with the Safe Core SDK - -interface Config { - RPC_URL: string - OWNER1_PRIVATE_KEY: string - OWNER2_PRIVATE_KEY: string - OWNER3_PRIVATE_KEY: string - SAFE_2_3_ADDRESS: string -} - -const config: Config = { - RPC_URL: '', - // Create a Safe 2/3 with 3 owners and fill this info - OWNER1_PRIVATE_KEY: '', - OWNER2_PRIVATE_KEY: '', - OWNER3_PRIVATE_KEY: '', - SAFE_2_3_ADDRESS: '' -} - -async function main() { - const provider = new JsonRpcProvider(config.RPC_URL) - const signer1 = new ethers.Wallet(config.OWNER1_PRIVATE_KEY, provider) - const signer2 = new ethers.Wallet(config.OWNER2_PRIVATE_KEY, provider) - - // Create safeSdk instances - const safeSdk1 = await Safe.create({ - ethAdapter: new EthersAdapter({ - ethers, - signerOrProvider: signer1 - }), - safeAddress: config.SAFE_2_3_ADDRESS - }) - - const safeSdk2 = await Safe.create({ - ethAdapter: new EthersAdapter({ - ethers, - signerOrProvider: signer2 - }), - safeAddress: config.SAFE_2_3_ADDRESS - }) - - const MESSAGE_TO_SIGN = 'I am the owner of this Safe account' - - const messageHash = hashSafeMessage(MESSAGE_TO_SIGN) - const safeMessageHash = await safeSdk1.getSafeMessageHash(messageHash) - - const ethSignSig = await safeSdk1.signHash(safeMessageHash) - const typedDataSig = await safeSdk2.signTypedData(safeSdk2.createMessage(MESSAGE_TO_SIGN), 'v4') - - // Validate the signature sending the Safe message hash and the concatenated signatures - const isValid = await safeSdk1.isValidSignature(messageHash, [typedDataSig, ethSignSig]) - - console.log('Message: ', MESSAGE_TO_SIGN) - console.log('Message Hash: ', messageHash) - console.log('Safe Message Hash: ', safeMessageHash) - console.log('Signatures: ', ethSignSig, typedDataSig) - - console.log(`The signature is ${isValid ? 'valid' : 'invalid'}`) -} - -main() diff --git a/playground/protocol-kit/generate-safe-address.ts b/playground/protocol-kit/generate-safe-address.ts index b71ba39da..8443f9946 100644 --- a/playground/protocol-kit/generate-safe-address.ts +++ b/playground/protocol-kit/generate-safe-address.ts @@ -1,18 +1,17 @@ import { - EthersAdapter, + SafeProvider, SafeAccountConfig, SafeDeploymentConfig, predictSafeAddress } from '@safe-global/protocol-kit' import { SafeVersion } from '@safe-global/safe-core-sdk-types' -import { ethers } from 'ethers' // This script can be used to generate a custom Safe address const config: Config = { // REQUIRED PARAMETERS owners: ['0x680cde08860141F9D223cE4E620B10Cd6741037E'], - rpcUrl: 'https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161', + rpcUrl: 'https://rpc.ankr.com/eth_sepolia', // OPTIONAL PARAMETERS pattern: '0x5afe', safeVersion: '1.3.0', @@ -29,7 +28,7 @@ async function generateSafeAddresses() { threshold: config.threshold } - const chainId = await ethAdapter.getChainId() + const chainId = await safeProvider.getChainId() // infinite loop to search a valid Safe addresses for (saltNonce; true; saltNonce++ && iteractions++) { @@ -41,7 +40,7 @@ async function generateSafeAddresses() { // we predict the Safe address using the current saltNonce const predictedSafeAddress = await predictSafeAddress({ - ethAdapter, + safeProvider, chainId, safeAccountConfig, safeDeploymentConfig @@ -60,11 +59,8 @@ async function generateSafeAddresses() { } } -const provider = new ethers.JsonRpcProvider(config.rpcUrl) - -const ethAdapter = new EthersAdapter({ - ethers, - signerOrProvider: provider +const safeProvider = new SafeProvider({ + provider: config.rpcUrl }) const start = Date.now() diff --git a/playground/protocol-kit/validate-signatures.ts b/playground/protocol-kit/validate-signatures.ts new file mode 100644 index 000000000..45d41b476 --- /dev/null +++ b/playground/protocol-kit/validate-signatures.ts @@ -0,0 +1,86 @@ +import Safe, { SigningMethod, buildContractSignature } from '@safe-global/protocol-kit' +import { hashSafeMessage } from '@safe-global/protocol-kit' + +// This file can be used to play around with the Safe Core SDK + +interface Config { + RPC_URL: string + OWNER1_PRIVATE_KEY: string + OWNER2_PRIVATE_KEY: string + SAFE_3_3_ADDRESS: string + SIGNER_SAFE_ADDRESS: string +} + +// To run this script, you need a Safe with the following configuration +// - 3/3 Safe with 3 owners and threshold 3 +// - Owner 1: public address from OWNER1_PRIVATE_KEY +// - Owner 2: public address from OWNER2_PRIVATE_KEY +// - Owner 3: SIGNER_SAFE_ADDRESS (1/1 with OWNER1_PRIVATE_KEY public address as owner) +const config: Config = { + RPC_URL: 'https://rpc.ankr.com/eth_sepolia', + OWNER1_PRIVATE_KEY: '', + OWNER2_PRIVATE_KEY: '', + SIGNER_SAFE_ADDRESS: '', + SAFE_3_3_ADDRESS: '' +} + +async function main() { + // Create safeSdk instances + let protocolKit = await Safe.create({ + provider: config.RPC_URL, + signer: config.OWNER1_PRIVATE_KEY, + safeAddress: config.SAFE_3_3_ADDRESS + }) + + const MESSAGE = 'I am the owner of this Safe account' + + let message = protocolKit.createMessage(MESSAGE) + + message = await protocolKit.signMessage(message) // Owner 1 signature + + protocolKit = await protocolKit.connect({ + signer: config.OWNER2_PRIVATE_KEY, + safeAddress: config.SAFE_3_3_ADDRESS + }) // Connect another owner + + message = await protocolKit.signMessage(message, SigningMethod.ETH_SIGN_TYPED_DATA_V4) // Owner 2 signature + + protocolKit = await protocolKit.connect({ + signer: config.OWNER1_PRIVATE_KEY, + safeAddress: config.SIGNER_SAFE_ADDRESS + }) + + let signerSafeMessage = protocolKit.createMessage(MESSAGE) + signerSafeMessage = await protocolKit.signMessage( + signerSafeMessage, + SigningMethod.SAFE_SIGNATURE, + config.SAFE_3_3_ADDRESS + ) + + message.addSignature( + await buildContractSignature( + Array.from(signerSafeMessage.signatures.values()), + config.SIGNER_SAFE_ADDRESS + ) + ) + + protocolKit = await protocolKit.connect({ + signer: config.OWNER1_PRIVATE_KEY, + safeAddress: config.SAFE_3_3_ADDRESS + }) + + // Validate the signature sending the Safe message hash and the concatenated signatures + const messageHash = hashSafeMessage(MESSAGE) + const safeMessageHash = await protocolKit.getSafeMessageHash(messageHash) + + const isValid = await protocolKit.isValidSignature(messageHash, message.encodedSignatures()) + + console.log('Message: ', MESSAGE) + console.log('Message Hash: ', messageHash) + console.log('Safe Message Hash: ', safeMessageHash) + console.log('Signatures: ', message.signatures.values()) + + console.log(`The signature is ${isValid ? 'valid' : 'invalid'}`) +} + +main() diff --git a/playground/relay-kit/paid-transaction.ts b/playground/relay-kit/paid-transaction.ts index 47b5b6aa2..2d82913b2 100644 --- a/playground/relay-kit/paid-transaction.ts +++ b/playground/relay-kit/paid-transaction.ts @@ -6,19 +6,19 @@ import { OperationType } from '@safe-global/safe-core-sdk-types' import { ethers } from 'ethers' -import { EthersAdapter } from '@safe-global/protocol-kit' // Check the status of a transaction after it is relayed: // https://relay.gelato.digital/tasks/status/ // Check the status of a transaction after it is executed: -// https://goerli.etherscan.io/tx/ +// https://sepolia.etherscan.io/tx/ const config = { - SAFE_SIGNER_PRIVATE_KEY: '', - RPC_URL: 'https://goerli.infura.io/v3/' + SAFE_SIGNER_PRIVATE_KEY: '' } +const RPC_URL = 'https://rpc.ankr.com/eth_sepolia' + const mockOnRampConfig = { ADDRESS: '
', PRIVATE_KEY: '' @@ -30,7 +30,7 @@ const txConfig = { VALUE: '', // Options: GAS_LIMIT: '', - GAS_TOKEN: ethers.ZeroAddress + GAS_TOKEN: '0x0000000000000000000000000000000000000000' } async function main() { @@ -38,15 +38,10 @@ async function main() { // SDK Initialization - const provider = new ethers.JsonRpcProvider(config.RPC_URL) - const signer = new ethers.Wallet(config.SAFE_SIGNER_PRIVATE_KEY, provider) - - const safeAccountAbstraction = new AccountAbstraction( - new EthersAdapter({ - ethers, - signerOrProvider: signer - }) - ) + const safeAccountAbstraction = new AccountAbstraction({ + provider: RPC_URL, + signer: config.SAFE_SIGNER_PRIVATE_KEY + }) await safeAccountAbstraction.init() @@ -62,18 +57,20 @@ async function main() { const isSafeDeployed = await safeAccountAbstraction.protocolKit.isSafeDeployed() console.log({ isSafeDeployed }) + const ethersProvider = safeAccountAbstraction.protocolKit.getSafeProvider().getExternalProvider() + // Fake on-ramp to transfer enough funds to the Safe address - const chainId = (await provider.getNetwork()).chainId + const chainId = (await ethersProvider.getNetwork()).chainId const relayFee = BigInt( await relayPack.getEstimateFee(chainId, txConfig.GAS_LIMIT, txConfig.GAS_TOKEN) ) - const safeBalance = await provider.getBalance(predictedSafeAddress) + const safeBalance = await ethersProvider.getBalance(predictedSafeAddress) console.log({ minSafeBalance: ethers.formatEther(relayFee.toString()) }) console.log({ safeBalance: ethers.formatEther(safeBalance.toString()) }) if (safeBalance < relayFee) { - const fakeOnRampSigner = new ethers.Wallet(mockOnRampConfig.PRIVATE_KEY, provider) + const fakeOnRampSigner = new ethers.Wallet(mockOnRampConfig.PRIVATE_KEY, ethersProvider) const fundingAmount = safeBalance < relayFee ? relayFee - safeBalance : safeBalance - relayFee const onRampResponse = await fakeOnRampSigner.sendTransaction({ to: predictedSafeAddress, @@ -82,7 +79,7 @@ async function main() { console.log(`Funding the Safe with ${ethers.formatEther(fundingAmount.toString())} ETH`) await onRampResponse.wait() - const safeBalanceAfter = await provider.getBalance(predictedSafeAddress) + const safeBalanceAfter = await ethersProvider.getBalance(predictedSafeAddress) console.log({ safeBalance: ethers.formatEther(safeBalanceAfter.toString()) }) } diff --git a/playground/relay-kit/sponsored-transaction.ts b/playground/relay-kit/sponsored-transaction.ts index 08f11d553..d450adc5a 100644 --- a/playground/relay-kit/sponsored-transaction.ts +++ b/playground/relay-kit/sponsored-transaction.ts @@ -1,5 +1,4 @@ import AccountAbstraction from '@safe-global/account-abstraction-kit-poc' -import { EthersAdapter } from '@safe-global/protocol-kit' import { GelatoRelayPack } from '@safe-global/relay-kit' import { MetaTransactionData, @@ -15,14 +14,15 @@ import { ethers } from 'ethers' // https://relay.gelato.digital/tasks/status/ // Check the status of a transaction after it is executed: -// https://goerli.etherscan.io/tx/ +// https://sepolia.etherscan.io/tx/ const config = { SAFE_SIGNER_PRIVATE_KEY: '', - RPC_URL: 'https://goerli.infura.io/v3/', RELAY_API_KEY: '' } +const RPC_URL = 'https://rpc.ankr.com/eth_sepolia' + const mockOnRampConfig = { ADDRESS: '
', PRIVATE_KEY: '' @@ -39,15 +39,10 @@ async function main() { // SDK Initialization - const provider = new ethers.JsonRpcProvider(config.RPC_URL) - const signer = new ethers.Wallet(config.SAFE_SIGNER_PRIVATE_KEY, provider) - - const safeAccountAbstraction = new AccountAbstraction( - new EthersAdapter({ - ethers, - signerOrProvider: signer - }) - ) + const safeAccountAbstraction = new AccountAbstraction({ + provider: RPC_URL, + signer: config.SAFE_SIGNER_PRIVATE_KEY + }) await safeAccountAbstraction.init() @@ -68,10 +63,11 @@ async function main() { // Fake on-ramp to fund the Safe - const safeBalance = await provider.getBalance(predictedSafeAddress) + const ethersProvider = safeAccountAbstraction.protocolKit.getSafeProvider().getExternalProvider() + const safeBalance = await ethersProvider.getBalance(predictedSafeAddress) console.log({ safeBalance: ethers.formatEther(safeBalance.toString()) }) if (safeBalance < BigInt(txConfig.VALUE)) { - const fakeOnRampSigner = new ethers.Wallet(mockOnRampConfig.PRIVATE_KEY, provider) + const fakeOnRampSigner = new ethers.Wallet(mockOnRampConfig.PRIVATE_KEY, ethersProvider) const onRampResponse = await fakeOnRampSigner.sendTransaction({ to: predictedSafeAddress, value: txConfig.VALUE @@ -79,7 +75,7 @@ async function main() { console.log(`Funding the Safe with ${ethers.formatEther(txConfig.VALUE.toString())} ETH`) await onRampResponse.wait() - const safeBalanceAfter = await provider.getBalance(predictedSafeAddress) + const safeBalanceAfter = await ethersProvider.getBalance(predictedSafeAddress) console.log({ safeBalance: ethers.formatEther(safeBalanceAfter.toString()) }) } diff --git a/playground/relay-kit/usdc-transfer-4337-counterfactual.ts b/playground/relay-kit/usdc-transfer-4337-counterfactual.ts index 637e3d3e7..6e0469470 100644 --- a/playground/relay-kit/usdc-transfer-4337-counterfactual.ts +++ b/playground/relay-kit/usdc-transfer-4337-counterfactual.ts @@ -1,5 +1,4 @@ -import { EthersAdapter } from '@safe-global/protocol-kit' -import { ethers } from 'ethers' +import { ethers, AbstractSigner } from 'ethers' import { Safe4337Pack } from '@safe-global/relay-kit' // Safe owner PK @@ -7,6 +6,9 @@ const PRIVATE_KEY = '' const PIMLICO_API_KEY = '' +// Safe owner address +const OWNER_ADDRESS = '' + // RPC URL const RPC_URL = 'https://rpc.ankr.com/eth_sepolia' // SEPOLIA // const RPC_URL = 'https://rpc.gnosischain.com/' // GNOSIS @@ -24,21 +26,14 @@ const usdcTokenAddress = '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238' // SEPOLIA // const usdcTokenAddress = '0xddafbb505ad214d7b80b1f830fccc89b60fb7a83' // GNOSIS async function main() { - // Instantiate EtherAdapter - const provider = new ethers.JsonRpcProvider(RPC_URL) - const signer = new ethers.Wallet(PRIVATE_KEY, provider) - const ethersAdapter = new EthersAdapter({ - ethers, - signerOrProvider: signer - }) - // 1) Initialize pack const safe4337Pack = await Safe4337Pack.init({ - ethersAdapter, + provider: RPC_URL, + signer: PRIVATE_KEY, rpcUrl: RPC_URL, bundlerUrl: BUNDLER_URL, options: { - owners: [await signer.getAddress()], + owners: [OWNER_ADDRESS], threshold: 1, saltNonce: '4337' + '1' // to update the address } @@ -65,9 +60,17 @@ async function main() { console.log(`sending ${nativeTokenAmount} ETH...`) - const transactionFundingResponse = await signer.sendTransaction(fundingSafe) + const ethersSigner = await safe4337Pack.protocolKit.getSafeProvider().getExternalSigner() + const signerAddress = await safe4337Pack.protocolKit.getSafeProvider().getSignerAddress() + const ethersProvider = safe4337Pack.protocolKit.getSafeProvider().getExternalProvider() + + if (!ethersSigner || !signerAddress) { + throw new Error('No signer found!') + } + + const transactionFundingResponse = await ethersSigner?.sendTransaction(fundingSafe) - await transactionFundingResponse.wait() + await transactionFundingResponse?.wait() // Create transaction batch with two 0.1 USDC transfers @@ -76,18 +79,18 @@ async function main() { console.log(`sending USDC...`) // send 0.2 USDC to the Safe - await transfer(signer, usdcTokenAddress, senderAddress, usdcAmount * 2n) + await transfer(ethersSigner, usdcTokenAddress, senderAddress, usdcAmount * 2n) console.log(`creating the Safe batch...`) const transferUSDC = { to: usdcTokenAddress, - data: generateTransferCallData(signer.address, usdcAmount), + data: generateTransferCallData(signerAddress, usdcAmount), value: '0' } const transactions = [transferUSDC, transferUSDC] - const timestamp = (await provider.getBlock('latest'))?.timestamp || 0 + const timestamp = (await ethersProvider.getBlock('latest'))?.timestamp || 0 // 2) Create transaction batch const safeOperation = await safe4337Pack.createTransaction({ @@ -127,7 +130,7 @@ async function main() { main() -async function transfer(signer: ethers.Wallet, tokenAddress: string, to: string, amount: bigint) { +async function transfer(signer: AbstractSigner, tokenAddress: string, to: string, amount: bigint) { const transferEC20 = { to: tokenAddress, data: generateTransferCallData(to, amount), diff --git a/playground/relay-kit/usdc-transfer-4337-erc20-counterfactual.ts b/playground/relay-kit/usdc-transfer-4337-erc20-counterfactual.ts index f8ec40b1c..c58e401f0 100644 --- a/playground/relay-kit/usdc-transfer-4337-erc20-counterfactual.ts +++ b/playground/relay-kit/usdc-transfer-4337-erc20-counterfactual.ts @@ -1,4 +1,3 @@ -import { EthersAdapter } from '@safe-global/protocol-kit' import { ethers } from 'ethers' import { Safe4337Pack } from '@safe-global/relay-kit' @@ -7,6 +6,9 @@ const PRIVATE_KEY = '' const PIMLICO_API_KEY = '' +// Safe owner address +const OWNER_ADDRESS = '' + // CHAIN const CHAIN_NAME = 'sepolia' // const CHAIN_NAME = 'gnosis' @@ -28,17 +30,10 @@ const usdcTokenAddress = '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238' // SEPOLIA // const usdcTokenAddress = '0xddafbb505ad214d7b80b1f830fccc89b60fb7a83' // GNOSIS async function main() { - // Instantiate EtherAdapter - const provider = new ethers.JsonRpcProvider(RPC_URL) - const signer = new ethers.Wallet(PRIVATE_KEY, provider) - const ethersAdapter = new EthersAdapter({ - ethers, - signerOrProvider: signer - }) - // 1) Initialize pack with the paymaster data const safe4337Pack = await Safe4337Pack.init({ - ethersAdapter, + provider: RPC_URL, + signer: PRIVATE_KEY, rpcUrl: RPC_URL, bundlerUrl: BUNDLER_URL, paymasterOptions: { @@ -47,7 +42,7 @@ async function main() { // amountToApprove?: bigint // optional value to set the paymaster approve amount on the deployment }, options: { - owners: [await signer.getAddress()], + owners: [OWNER_ADDRESS], threshold: 1, saltNonce: '4337' + '1' // to update the address } @@ -68,8 +63,15 @@ async function main() { console.log(`sending USDC...`) + const ethersSigner = await safe4337Pack.protocolKit.getSafeProvider().getExternalSigner() + const ethersProvider = safe4337Pack.protocolKit.getSafeProvider().getExternalProvider() + + if (!ethersSigner) { + throw new Error('No signer found!') + } + // send 15 USDC to the Safe - await transfer(signer, usdcTokenAddress, senderAddress, usdcAmount * 150n) + await transfer(ethersSigner, usdcTokenAddress, senderAddress, usdcAmount * 150n) console.log(`creating the Safe batch...`) @@ -79,7 +81,7 @@ async function main() { value: '0' } const transactions = [transferUSDC, transferUSDC] - const timestamp = (await provider.getBlock('latest'))?.timestamp || 0 + const timestamp = (await ethersProvider.getBlock('latest'))?.timestamp || 0 // 2) Create transaction batch const safeOperation = await safe4337Pack.createTransaction({ @@ -126,7 +128,12 @@ const generateTransferCallData = (to: string, value: bigint) => { return iface.encodeFunctionData('transfer', [to, value]) } -async function transfer(signer: ethers.Wallet, tokenAddress: string, to: string, amount: bigint) { +async function transfer( + signer: ethers.AbstractSigner, + tokenAddress: string, + to: string, + amount: bigint +) { const transferEC20 = { to: tokenAddress, data: generateTransferCallData(to, amount), diff --git a/playground/relay-kit/usdc-transfer-4337-erc20.ts b/playground/relay-kit/usdc-transfer-4337-erc20.ts index 911a8b8e7..be36163e3 100644 --- a/playground/relay-kit/usdc-transfer-4337-erc20.ts +++ b/playground/relay-kit/usdc-transfer-4337-erc20.ts @@ -1,4 +1,3 @@ -import { EthersAdapter } from '@safe-global/protocol-kit' import { ethers } from 'ethers' import { Safe4337Pack } from '@safe-global/relay-kit' @@ -31,17 +30,10 @@ const usdcTokenAddress = '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238' // SEPOLIA // const usdcTokenAddress = '0xddafbb505ad214d7b80b1f830fccc89b60fb7a83' // GNOSIS async function main() { - // Instantiate EtherAdapter - const provider = new ethers.JsonRpcProvider(RPC_URL) - const signer = new ethers.Wallet(PRIVATE_KEY, provider) - const ethersAdapter = new EthersAdapter({ - ethers, - signerOrProvider: signer - }) - // 1) Initialize pack with the paymaster data const safe4337Pack = await Safe4337Pack.init({ - ethersAdapter, + provider: RPC_URL, + signer: PRIVATE_KEY, rpcUrl: RPC_URL, bundlerUrl: BUNDLER_URL, paymasterOptions: { @@ -65,8 +57,15 @@ async function main() { console.log(`sending USDC...`) + const ethersSigner = await safe4337Pack.protocolKit.getSafeProvider().getExternalSigner() + const ethersProvider = safe4337Pack.protocolKit.getSafeProvider().getExternalProvider() + + if (!ethersSigner) { + throw new Error('No signer found!') + } + // send 5 USDC to the Safe - await transfer(signer, usdcTokenAddress, senderAddress, usdcAmount * 50n) + await transfer(ethersSigner, usdcTokenAddress, senderAddress, usdcAmount * 50n) console.log(`creating the Safe batch...`) @@ -76,7 +75,7 @@ async function main() { value: '0' } const transactions = [transferUSDC, transferUSDC] - const timestamp = (await provider.getBlock('latest'))?.timestamp || 0 + const timestamp = (await ethersProvider.getBlock('latest'))?.timestamp || 0 // 2) Create transaction batch const safeOperation = await safe4337Pack.createTransaction({ @@ -123,7 +122,12 @@ const generateTransferCallData = (to: string, value: bigint) => { return iface.encodeFunctionData('transfer', [to, value]) } -async function transfer(signer: ethers.Wallet, tokenAddress: string, to: string, amount: bigint) { +async function transfer( + signer: ethers.AbstractSigner, + tokenAddress: string, + to: string, + amount: bigint +) { const transferEC20 = { to: tokenAddress, data: generateTransferCallData(to, amount), diff --git a/playground/relay-kit/usdc-transfer-4337-sponsored-counterfactual.ts b/playground/relay-kit/usdc-transfer-4337-sponsored-counterfactual.ts index 218b12866..c855a1f03 100644 --- a/playground/relay-kit/usdc-transfer-4337-sponsored-counterfactual.ts +++ b/playground/relay-kit/usdc-transfer-4337-sponsored-counterfactual.ts @@ -1,4 +1,3 @@ -import { EthersAdapter } from '@safe-global/protocol-kit' import { ethers } from 'ethers' import { Safe4337Pack } from '@safe-global/relay-kit' @@ -7,6 +6,9 @@ const PRIVATE_KEY = '' const PIMLICO_API_KEY = '' +// Safe owner address +const OWNER_ADDRESS = '' + // PolicyId is an optional parameter, you can create one here: https://dashboard.pimlico.io/sponsorship-policies const POLICY_ID = '' @@ -34,17 +36,10 @@ const usdcTokenAddress = '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238' // SEPOLIA // const usdcTokenAddress = '0xddafbb505ad214d7b80b1f830fccc89b60fb7a83' // GNOSIS async function main() { - // Instantiate EtherAdapter - const provider = new ethers.JsonRpcProvider(RPC_URL) - const signer = new ethers.Wallet(PRIVATE_KEY, provider) - const ethersAdapter = new EthersAdapter({ - ethers, - signerOrProvider: signer - }) - // 1) Initialize pack with the paymaster data const safe4337Pack = await Safe4337Pack.init({ - ethersAdapter, + provider: RPC_URL, + signer: PRIVATE_KEY, rpcUrl: RPC_URL, bundlerUrl: BUNDLER_URL, paymasterOptions: { @@ -54,7 +49,7 @@ async function main() { paymasterUrl: PAYMASTER_URL }, options: { - owners: [await signer.getAddress()], + owners: [OWNER_ADDRESS], threshold: 1, saltNonce: '4337' + '1' // to update the address } @@ -75,8 +70,15 @@ async function main() { console.log(`sending USDC...`) + const ethersSigner = await safe4337Pack.protocolKit.getSafeProvider().getExternalSigner() + const ethersProvider = safe4337Pack.protocolKit.getSafeProvider().getExternalProvider() + + if (!ethersSigner) { + throw new Error('No signer found!') + } + // send 0.2 USDC to the Safe - await transfer(signer, usdcTokenAddress, senderAddress, usdcAmount * 2n) + await transfer(ethersSigner, usdcTokenAddress, senderAddress, usdcAmount * 2n) console.log(`creating the Safe batch...`) @@ -86,7 +88,7 @@ async function main() { value: '0' } const transactions = [transferUSDC, transferUSDC] - const timestamp = (await provider.getBlock('latest'))?.timestamp || 0 + const timestamp = (await ethersProvider.getBlock('latest'))?.timestamp || 0 // 2) Create transaction batch const safeOperation = await safe4337Pack.createTransaction({ @@ -133,7 +135,12 @@ const generateTransferCallData = (to: string, value: bigint) => { return iface.encodeFunctionData('transfer', [to, value]) } -async function transfer(signer: ethers.Wallet, tokenAddress: string, to: string, amount: bigint) { +async function transfer( + signer: ethers.AbstractSigner, + tokenAddress: string, + to: string, + amount: bigint +) { const transferEC20 = { to: tokenAddress, data: generateTransferCallData(to, amount), diff --git a/playground/relay-kit/usdc-transfer-4337-sponsored.ts b/playground/relay-kit/usdc-transfer-4337-sponsored.ts index 39af77cfd..6a398623d 100644 --- a/playground/relay-kit/usdc-transfer-4337-sponsored.ts +++ b/playground/relay-kit/usdc-transfer-4337-sponsored.ts @@ -1,4 +1,3 @@ -import { EthersAdapter } from '@safe-global/protocol-kit' import { ethers } from 'ethers' import { Safe4337Pack } from '@safe-global/relay-kit' @@ -37,17 +36,10 @@ const usdcTokenAddress = '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238' // SEPOLIA // const usdcTokenAddress = '0xddafbb505ad214d7b80b1f830fccc89b60fb7a83' // GNOSIS async function main() { - // Instantiate EtherAdapter - const provider = new ethers.JsonRpcProvider(RPC_URL) - const signer = new ethers.Wallet(PRIVATE_KEY, provider) - const ethersAdapter = new EthersAdapter({ - ethers, - signerOrProvider: signer - }) - // 1) Initialize pack with the paymaster data const safe4337Pack = await Safe4337Pack.init({ - ethersAdapter, + provider: RPC_URL, + signer: PRIVATE_KEY, rpcUrl: RPC_URL, bundlerUrl: BUNDLER_URL, paymasterOptions: { @@ -76,7 +68,8 @@ async function main() { value: '0' } const transactions = [transferUSDC, transferUSDC] - const timestamp = (await provider.getBlock('latest'))?.timestamp || 0 + const ethersProvider = safe4337Pack.protocolKit.getSafeProvider().getExternalProvider() + const timestamp = (await ethersProvider.getBlock('latest'))?.timestamp || 0 // 2) Create transaction batch const safeOperation = await safe4337Pack.createTransaction({ diff --git a/playground/relay-kit/usdc-transfer-4337.ts b/playground/relay-kit/usdc-transfer-4337.ts index 048eb6ab0..f1e91bf9f 100644 --- a/playground/relay-kit/usdc-transfer-4337.ts +++ b/playground/relay-kit/usdc-transfer-4337.ts @@ -1,4 +1,3 @@ -import { EthersAdapter } from '@safe-global/protocol-kit' import { ethers } from 'ethers' import { Safe4337Pack } from '@safe-global/relay-kit' @@ -21,17 +20,10 @@ const RPC_URL = 'https://rpc.ankr.com/eth_sepolia' const usdcTokenAddress = '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238' async function main() { - // Instantiate EtherAdapter - const provider = new ethers.JsonRpcProvider(RPC_URL) - const signer = new ethers.Wallet(PRIVATE_KEY, provider) - const ethersAdapter = new EthersAdapter({ - ethers, - signerOrProvider: signer - }) - // 1) Initialize pack const safe4337Pack = await Safe4337Pack.init({ - ethersAdapter, + provider: RPC_URL, + signer: PRIVATE_KEY, rpcUrl: RPC_URL, bundlerUrl: BUNDLER_URL, options: { @@ -55,7 +47,8 @@ async function main() { value: '0' } const transactions = [transferUSDC, transferUSDC] - const timestamp = (await provider.getBlock('latest'))?.timestamp || 0 + const ethersProvider = safe4337Pack.protocolKit.getSafeProvider().getExternalProvider() + const timestamp = (await ethersProvider.getBlock('latest'))?.timestamp || 0 // 2) Create transaction batch const safeOperation = await safe4337Pack.createTransaction({ diff --git a/yarn.lock b/yarn.lock index e4c59a208..b610f419c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17,6 +17,11 @@ resolved "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.9.2.tgz" integrity sha512-0h+FrQDqe2Wn+IIGFkTCd4aAwTJ+7834Ek1COohCyV26AXhwQ7WQaz+4F/nLOeVl/3BtWHOHLPsq46V8YB46Eg== +"@adraffy/ens-normalize@^1.8.8": + version "1.10.1" + resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz#63430d04bd8c5e74f8d7d049338f1cd9d4f02069" + integrity sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw== + "@ampproject/remapping@^2.2.0": version "2.2.1" resolved "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz" @@ -397,14 +402,6 @@ resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.56.0.tgz#ef20350fec605a7f7035a01764731b2de0f3782b" integrity sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A== -"@ethereumjs/common@2.6.5", "@ethereumjs/common@^2.6.4": - version "2.6.5" - resolved "https://registry.npmjs.org/@ethereumjs/common/-/common-2.6.5.tgz" - integrity sha512-lRyVQOeCDaIVtgfbowla32pzeDv2Obr8oR8Put5RdUBNRGr1VGPGQNGP6elWIpgK3YdpzqTOh4GyUGOureVeeA== - dependencies: - crc-32 "^1.2.0" - ethereumjs-util "^7.1.5" - "@ethereumjs/common@^3.2.0": version "3.2.0" resolved "https://registry.yarnpkg.com/@ethereumjs/common/-/common-3.2.0.tgz#b71df25845caf5456449163012074a55f048e0a0" @@ -431,14 +428,6 @@ resolved "https://registry.yarnpkg.com/@ethereumjs/rlp/-/rlp-5.0.1.tgz#56c5433b9242f956e354fd7e4ce3523815e24854" integrity sha512-Ab/Hfzz+T9Zl+65Nkg+9xAmwKPLicsnQ4NW49pgvJp9ovefuic95cgOS9CbPc9izIEgsqm1UitV0uNveCvud9w== -"@ethereumjs/tx@3.5.2": - version "3.5.2" - resolved "https://registry.npmjs.org/@ethereumjs/tx/-/tx-3.5.2.tgz" - integrity sha512-gQDNJWKrSDGu2w7w0PzVXVBNMzb7wwdDOmOqczmhNjqFxFuIbhVJDwiGEnxFNC2/b8ifcZzY7MLcluizohRzNw== - dependencies: - "@ethereumjs/common" "^2.6.4" - ethereumjs-util "^7.1.5" - "@ethereumjs/tx@^4.2.0": version "4.2.0" resolved "https://registry.yarnpkg.com/@ethereumjs/tx/-/tx-4.2.0.tgz#5988ae15daf5a3b3c815493bc6b495e76009e853" @@ -476,7 +465,7 @@ "@ethereumjs/rlp" "^5.0.1" ethereum-cryptography "^2.1.2" -"@ethersproject/abi@5.7.0", "@ethersproject/abi@^5.1.2", "@ethersproject/abi@^5.6.3", "@ethersproject/abi@^5.7.0": +"@ethersproject/abi@5.7.0", "@ethersproject/abi@^5.1.2", "@ethersproject/abi@^5.7.0": version "5.7.0" resolved "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.7.0.tgz" integrity sha512-351ktp42TiRcYB3H1OP8yajPeAQstMW/yCFokj/AthP9bLHzQFPlOrxOcwYEDkUAICmOHljvN4K39OMTMUa9RA== @@ -751,7 +740,7 @@ "@ethersproject/constants" "^5.7.0" "@ethersproject/logger" "^5.7.0" -"@ethersproject/transactions@5.7.0", "@ethersproject/transactions@^5.6.2", "@ethersproject/transactions@^5.7.0": +"@ethersproject/transactions@5.7.0", "@ethersproject/transactions@^5.7.0": version "5.7.0" resolved "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.7.0.tgz" integrity sha512-kmcNicCp1lp8qanMTC3RIikGgoJ80ztTyvtsFvCYpSCfkjhD0jZ2LOrnbcuxuToLIUYYf+4XwD1rP+B/erDIhQ== @@ -1261,10 +1250,10 @@ semver "^7.5.4" superstruct "^1.0.3" -"@monerium/sdk@^2.9.0": - version "2.9.0" - resolved "https://registry.yarnpkg.com/@monerium/sdk/-/sdk-2.9.0.tgz#ec7296623853acd0b7477b1b088f8c8fae42f197" - integrity sha512-6tr1fWau5tca2xjgIB/7NLJQFoVLcRvGQh6gqzgPJZCS9kRIVlupGk1MaejFdGWOmoEqJSFVUzi0TGhEJK+VcA== +"@monerium/sdk@^2.12.0": + version "2.12.0" + resolved "https://registry.yarnpkg.com/@monerium/sdk/-/sdk-2.12.0.tgz#57ccc1668a354c28d083c29928690f15fe11c479" + integrity sha512-tZxQNAlUpCbVkZfWIVB2yWYjyYZGKckEfzUZbWQyDdxUo487iNJQRr1Z64MZofJ/gKCPfOPJbiZzUGWbl8eLQA== dependencies: crypto-js "^4.2.0" @@ -1275,7 +1264,7 @@ dependencies: "@noble/hashes" "1.3.1" -"@noble/curves@1.2.0": +"@noble/curves@1.2.0", "@noble/curves@~1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.2.0.tgz#92d7e12e4e49b23105a2555c6984d41733d65c35" integrity sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw== @@ -1302,7 +1291,7 @@ resolved "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz" integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ== -"@noble/hashes@^1.3.1", "@noble/hashes@^1.3.3", "@noble/hashes@~1.3.0", "@noble/hashes@~1.3.1": +"@noble/hashes@^1.3.1", "@noble/hashes@^1.3.3", "@noble/hashes@~1.3.0", "@noble/hashes@~1.3.1", "@noble/hashes@~1.3.2": version "1.3.3" resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.3.tgz#39908da56a4adc270147bb07968bf3b16cfe1699" integrity sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA== @@ -1541,13 +1530,6 @@ "@nomicfoundation/solidity-analyzer-win32-ia32-msvc" "0.1.1" "@nomicfoundation/solidity-analyzer-win32-x64-msvc" "0.1.1" -"@nomiclabs/hardhat-web3@^2.0.0": - version "2.0.0" - resolved "https://registry.npmjs.org/@nomiclabs/hardhat-web3/-/hardhat-web3-2.0.0.tgz" - integrity sha512-zt4xN+D+fKl3wW2YlTX3k9APR3XZgPkxJYf36AcliJn3oujnKEVRZaHu0PhgLjO+gR+F/kiYayo9fgd2L8970Q== - dependencies: - "@types/bignumber.js" "^5.0.0" - "@npmcli/fs@^2.1.0": version "2.1.2" resolved "https://registry.npmjs.org/@npmcli/fs/-/fs-2.1.2.tgz" @@ -1842,20 +1824,6 @@ picocolors "^1.0.0" tslib "^2.6.0" -"@safe-global/protocol-kit@^3.0.2": - version "3.0.2" - resolved "https://registry.yarnpkg.com/@safe-global/protocol-kit/-/protocol-kit-3.0.2.tgz#cfa4c5e890c101aa89e11768d07b2bc5455f72fb" - integrity sha512-Jxvvfu4yqEdWeOuY3VWOOs/q5f27om3tctL2guOCDbAuSx3Vd1peaKRwLiREkvrrqKEW0tfmzUSsqtmlJExfBw== - dependencies: - "@noble/hashes" "^1.3.3" - "@safe-global/safe-deployments" "^1.34.0" - ethereumjs-util "^7.1.5" - ethers "^6.7.1" - semver "^7.5.4" - web3 "^1.10.3" - web3-core "^1.10.3" - web3-utils "^1.10.3" - "@safe-global/safe-contracts-v1.4.1@npm:@safe-global/safe-contracts@1.4.1": version "1.4.1" resolved "https://registry.npmjs.org/@safe-global/safe-contracts/-/safe-contracts-1.4.1.tgz" @@ -1878,6 +1846,11 @@ resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.3.tgz#8584115565228290a6c6c4961973e0903bb3df2f" integrity sha512-/+SgoRjLq7Xlf0CWuLHq2LUZeL/w65kfzAPG5NH9pcmBhs+nunQTn4gvdwgMTIXnt9b2C/1SeL2XiysZEyIC9Q== +"@scure/base@~1.1.2": + version "1.1.6" + resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.6.tgz#8ce5d304b436e4c84f896e0550c83e4d88cb917d" + integrity sha512-ok9AWwhcgYuGG3Zfhyqg+zwl+Wn5uE+dwC0NV/2qQkx4dABbb/bx96vWu8NSj+BNjjSjno+JRYRjle1jV08k3g== + "@scure/bip32@1.1.5": version "1.1.5" resolved "https://registry.npmjs.org/@scure/bip32/-/bip32-1.1.5.tgz" @@ -1896,6 +1869,15 @@ "@noble/hashes" "~1.3.1" "@scure/base" "~1.1.0" +"@scure/bip32@1.3.2": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.3.2.tgz#90e78c027d5e30f0b22c1f8d50ff12f3fb7559f8" + integrity sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA== + dependencies: + "@noble/curves" "~1.2.0" + "@noble/hashes" "~1.3.2" + "@scure/base" "~1.1.2" + "@scure/bip39@1.1.1": version "1.1.1" resolved "https://registry.npmjs.org/@scure/bip39/-/bip39-1.1.1.tgz" @@ -2014,11 +1996,6 @@ resolved "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz" integrity sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA== -"@sindresorhus/is@^4.0.0", "@sindresorhus/is@^4.6.0": - version "4.6.0" - resolved "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz" - integrity sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw== - "@sinonjs/commons@^1.7.0": version "1.8.6" resolved "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.6.tgz" @@ -2076,20 +2053,6 @@ resolved "https://registry.npmjs.org/@stripe/stripe-js/-/stripe-js-1.54.2.tgz" integrity sha512-R1PwtDvUfs99cAjfuQ/WpwJ3c92+DAMy9xGApjqlWQMj0FKQabUAys2swfTRNzuYAYJh7NqK2dzcYVNkKLEKUg== -"@szmarczak/http-timer@^4.0.5": - version "4.0.6" - resolved "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz" - integrity sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w== - dependencies: - defer-to-connect "^2.0.0" - -"@szmarczak/http-timer@^5.0.1": - version "5.0.1" - resolved "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-5.0.1.tgz" - integrity sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw== - dependencies: - defer-to-connect "^2.0.1" - "@tootallnate/once@2": version "2.0.0" resolved "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz" @@ -2266,14 +2229,7 @@ dependencies: "@babel/types" "^7.3.0" -"@types/bignumber.js@^5.0.0": - version "5.0.0" - resolved "https://registry.npmjs.org/@types/bignumber.js/-/bignumber.js-5.0.0.tgz" - integrity sha512-0DH7aPGCClywOFaxxjE6UwpN2kQYe9LwuDQMv+zYA97j5GkOMo8e66LYT+a8JYU7jfmUFRZLa9KycxHDsKXJCA== - dependencies: - bignumber.js "*" - -"@types/bn.js@*", "@types/bn.js@^5.1.0", "@types/bn.js@^5.1.1": +"@types/bn.js@*", "@types/bn.js@^5.1.0": version "5.1.1" resolved "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.1.tgz" integrity sha512-qNrYbZqMx0uJAfKnKclPh+dTwK33KfLHYqtyODwd5HnXOjnkhc4qgn3BrK6RWyGZm5+sIFE7Q7Vz6QQtJB7w7g== @@ -2287,16 +2243,6 @@ dependencies: "@types/node" "*" -"@types/cacheable-request@^6.0.1", "@types/cacheable-request@^6.0.2": - version "6.0.3" - resolved "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz" - integrity sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw== - dependencies: - "@types/http-cache-semantics" "*" - "@types/keyv" "^3.1.4" - "@types/node" "*" - "@types/responselike" "^1.0.0" - "@types/chai-as-promised@^7.1.8": version "7.1.8" resolved "https://registry.npmjs.org/@types/chai-as-promised/-/chai-as-promised-7.1.8.tgz" @@ -2323,11 +2269,6 @@ dependencies: "@types/node" "*" -"@types/http-cache-semantics@*": - version "4.0.1" - resolved "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz" - integrity sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ== - "@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1": version "2.0.4" resolved "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz" @@ -2369,13 +2310,6 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== -"@types/keyv@^3.1.4": - version "3.1.4" - resolved "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz" - integrity sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg== - dependencies: - "@types/node" "*" - "@types/lru-cache@^5.1.0": version "5.1.1" resolved "https://registry.npmjs.org/@types/lru-cache/-/lru-cache-5.1.1.tgz" @@ -2421,11 +2355,6 @@ resolved "https://registry.npmjs.org/@types/node/-/node-18.15.13.tgz" integrity sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q== -"@types/node@^12.12.6": - version "12.20.55" - resolved "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz" - integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ== - "@types/normalize-package-data@^2.4.0": version "2.4.1" resolved "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz" @@ -2451,13 +2380,6 @@ "@types/node" "*" safe-buffer "~5.1.1" -"@types/responselike@^1.0.0": - version "1.0.0" - resolved "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz" - integrity sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA== - dependencies: - "@types/node" "*" - "@types/secp256k1@^4.0.1": version "4.0.3" resolved "https://registry.npmjs.org/@types/secp256k1/-/secp256k1-4.0.3.tgz" @@ -2513,6 +2435,13 @@ "@types/bn.js" "*" "@types/underscore" "*" +"@types/ws@8.5.3": + version "8.5.3" + resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.3.tgz#7d25a1ffbecd3c4f2d35068d0b283c037003274d" + integrity sha512-6YOoWjruKj1uLf3INHH7D3qTXwFfEsg1kf3c0uDdSBJwfa/llkwIjrAGV7j7mVgGNbzTQ3HiHKKDXl6bJPD97w== + dependencies: + "@types/node" "*" + "@types/yargs-parser@*": version "21.0.0" resolved "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz" @@ -2674,6 +2603,16 @@ abbrev@^1.0.0: resolved "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz" integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== +abitype@0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/abitype/-/abitype-0.7.1.tgz#16db20abe67de80f6183cf75f3de1ff86453b745" + integrity sha512-VBkRHTDZf9Myaek/dO3yMmOzB/y2s3Zo6nVU7yaw1G+TvCHAjwaJzNGN9yo4K5D8bU/VZXKP1EJpRhFr862PlQ== + +abitype@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/abitype/-/abitype-1.0.0.tgz#237176dace81d90d018bebf3a45cb42f2a2d9e97" + integrity sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ== + abitype@^0.1.6: version "0.1.8" resolved "https://registry.npmjs.org/abitype/-/abitype-0.1.8.tgz" @@ -2691,11 +2630,6 @@ abort-controller@^3.0.0: dependencies: event-target-shim "^5.0.0" -abortcontroller-polyfill@^1.7.5: - version "1.7.5" - resolved "https://registry.npmjs.org/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.5.tgz" - integrity sha512-JMJ5soJWP18htbbxJjG7bG6yuI6pRhgJ0scHHTfkUjf6wjP912xZWvM+A4sJK3gqd9E8fcPbDnOefbA9Th/FIQ== - abstract-level@^1.0.0, abstract-level@^1.0.2, abstract-level@^1.0.3: version "1.0.3" resolved "https://registry.npmjs.org/abstract-level/-/abstract-level-1.0.3.tgz" @@ -2709,14 +2643,6 @@ abstract-level@^1.0.0, abstract-level@^1.0.2, abstract-level@^1.0.3: module-error "^1.0.1" queue-microtask "^1.2.3" -accepts@~1.3.8: - version "1.3.8" - resolved "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz" - integrity sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw== - dependencies: - mime-types "~2.1.34" - negotiator "0.6.3" - acorn-globals@^7.0.0: version "7.0.1" resolved "https://registry.npmjs.org/acorn-globals/-/acorn-globals-7.0.1.tgz" @@ -2784,7 +2710,7 @@ aggregate-error@^3.0.0: clean-stack "^2.0.0" indent-string "^4.0.0" -ajv@^6.12.3, ajv@^6.12.4: +ajv@^6.12.4: version "6.12.6" resolved "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -2907,11 +2833,6 @@ array-differ@^3.0.0: resolved "https://registry.npmjs.org/array-differ/-/array-differ-3.0.0.tgz" integrity sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg== -array-flatten@1.1.1: - version "1.1.1" - resolved "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz" - integrity sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg== - array-ify@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/array-ify/-/array-ify-1.0.0.tgz" @@ -2932,28 +2853,11 @@ arrify@^2.0.1: resolved "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz" integrity sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug== -asn1@~0.2.3: - version "0.2.6" - resolved "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz" - integrity sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ== - dependencies: - safer-buffer "~2.1.0" - -assert-plus@1.0.0, assert-plus@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz" - integrity sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw== - assertion-error@^1.1.0: version "1.1.0" resolved "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz" integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== -async-limiter@~1.0.0: - version "1.0.1" - resolved "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz" - integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ== - async-mutex@^0.4.0: version "0.4.0" resolved "https://registry.npmjs.org/async-mutex/-/async-mutex-0.4.0.tgz" @@ -2976,16 +2880,6 @@ available-typed-arrays@^1.0.5: resolved "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz" integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw== -aws-sign2@~0.7.0: - version "0.7.0" - resolved "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz" - integrity sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA== - -aws4@^1.8.0: - version "1.12.0" - resolved "https://registry.npmjs.org/aws4/-/aws4-1.12.0.tgz" - integrity sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg== - axios@0.27.2: version "0.27.2" resolved "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz" @@ -3075,7 +2969,7 @@ balanced-match@^1.0.0: resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== -base-x@^3.0.2, base-x@^3.0.8: +base-x@^3.0.2: version "3.0.9" resolved "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz" integrity sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ== @@ -3092,13 +2986,6 @@ base64url@^3.0.1: resolved "https://registry.npmjs.org/base64url/-/base64url-3.0.1.tgz" integrity sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A== -bcrypt-pbkdf@^1.0.0: - version "1.0.2" - resolved "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz" - integrity sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w== - dependencies: - tweetnacl "^0.14.3" - bech32@1.1.4: version "1.1.4" resolved "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz" @@ -3119,7 +3006,7 @@ bigint-crypto-utils@^3.0.23: resolved "https://registry.npmjs.org/bigint-crypto-utils/-/bigint-crypto-utils-3.2.2.tgz" integrity sha512-U1RbE3aX9ayCUVcIPHuPDPKcK3SFOXf93J1UK/iHlJuQB7bhagPIX06/CLpLEsDThJ7KA4Dhrnzynl+d2weTiw== -bignumber.js@*, bignumber.js@^9.0.0, bignumber.js@^9.1.2: +bignumber.js@^9.1.2: version "9.1.2" resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.2.tgz#b7c4242259c008903b13707983b5f4bbd31eda0c" integrity sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug== @@ -3143,17 +3030,7 @@ blakejs@^1.1.0: resolved "https://registry.npmjs.org/blakejs/-/blakejs-1.2.1.tgz" integrity sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ== -bluebird@^3.5.0: - version "3.7.2" - resolved "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz" - integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== - -bn.js@4.11.6: - version "4.11.6" - resolved "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz" - integrity sha512-XWwnNNFCuuSQ0m3r3C4LE3EiORltHd9M05pq6FOlVeiophzRbMo50Sbz1ehl8K3Z+jw9+vmgnXefY1hz8X+2wA== - -bn.js@^4.11.0, bn.js@^4.11.6, bn.js@^4.11.8, bn.js@^4.11.9: +bn.js@^4.11.0, bn.js@^4.11.8, bn.js@^4.11.9: version "4.12.0" resolved "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz" integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== @@ -3163,24 +3040,6 @@ bn.js@^5.1.2, bn.js@^5.2.0, bn.js@^5.2.1: resolved "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz" integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== -body-parser@1.20.2, body-parser@^1.16.0: - version "1.20.2" - resolved "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz" - integrity sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA== - dependencies: - bytes "3.1.2" - content-type "~1.0.5" - debug "2.6.9" - depd "2.0.0" - destroy "1.2.0" - http-errors "2.0.0" - iconv-lite "0.4.24" - on-finished "2.4.1" - qs "6.11.0" - raw-body "2.5.2" - type-is "~1.6.18" - unpipe "1.0.0" - bowser@^2.11.0: version "2.11.0" resolved "https://registry.npmjs.org/bowser/-/bowser-2.11.0.tgz" @@ -3292,17 +3151,12 @@ buffer-from@^1.0.0: resolved "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz" integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== -buffer-to-arraybuffer@^0.0.5: - version "0.0.5" - resolved "https://registry.npmjs.org/buffer-to-arraybuffer/-/buffer-to-arraybuffer-0.0.5.tgz" - integrity sha512-3dthu5CYiVB1DEJp61FtApNnNndTckcqe4pFcLdvHtrpG+kcyekCJKg4MRiDcFW7A6AODnXB9U4dwQiCW5kzJQ== - buffer-xor@^1.0.3: version "1.0.3" resolved "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz" integrity sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ== -buffer@^5.0.5, buffer@^5.5.0, buffer@^5.6.0: +buffer@^5.5.0: version "5.7.1" resolved "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz" integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== @@ -3318,13 +3172,6 @@ buffer@^6.0.3: base64-js "^1.3.1" ieee754 "^1.2.1" -bufferutil@^4.0.1: - version "4.0.8" - resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.8.tgz#1de6a71092d65d7766c4d8a522b261a6e787e8ea" - integrity sha512-4T53u4PdgsXqKaIctwF8ifXlRTTmEPJ8iEPWFdGZvcf7sbwYo6FKFEX9eNNAnzFZ7EzJAQ3CJeOtCRA4rDp7Pw== - dependencies: - node-gyp-build "^4.3.0" - builtins@^1.0.3: version "1.0.3" resolved "https://registry.npmjs.org/builtins/-/builtins-1.0.3.tgz" @@ -3397,29 +3244,6 @@ cacache@^17.0.0: tar "^6.1.11" unique-filename "^3.0.0" -cacheable-lookup@^5.0.3: - version "5.0.4" - resolved "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz" - integrity sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA== - -cacheable-lookup@^6.0.4: - version "6.1.0" - resolved "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-6.1.0.tgz" - integrity sha512-KJ/Dmo1lDDhmW2XDPMo+9oiy/CeqosPguPCrgcVzKyZrL6pM1gU2GmPY/xo6OQPTUaA/c0kwHuywB4E6nmT9ww== - -cacheable-request@^7.0.2: - version "7.0.2" - resolved "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.2.tgz" - integrity sha512-pouW8/FmiPQbuGpkXQ9BAPv/Mo5xDGANgSNXzTzJ8DrKGuXOssM4wIQRjfanNRh3Yu5cfYPvcorqbhg2KIJtew== - dependencies: - clone-response "^1.0.2" - get-stream "^5.1.0" - http-cache-semantics "^4.0.0" - keyv "^4.0.0" - lowercase-keys "^2.0.0" - normalize-url "^6.0.1" - responselike "^2.0.0" - caching-transform@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz" @@ -3473,11 +3297,6 @@ case@^1.6.3: resolved "https://registry.npmjs.org/case/-/case-1.6.3.tgz" integrity sha512-mzDSXIPaFwVDvZAHqZ9VlbyF4yyXRuX6IvB06WvPYkqJVO24kX1PPhv9bfpKNFZyxYFmmgo03HUiD8iklmJYRQ== -caseless@~0.12.0: - version "0.12.0" - resolved "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz" - integrity sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw== - catering@^2.1.0, catering@^2.1.1: version "2.1.1" resolved "https://registry.npmjs.org/catering/-/catering-2.1.1.tgz" @@ -3565,11 +3384,6 @@ chokidar@3.5.3, chokidar@^3.4.0, chokidar@^3.5.2, chokidar@^3.5.3: optionalDependencies: fsevents "~2.3.2" -chownr@^1.1.4: - version "1.1.4" - resolved "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz" - integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg== - chownr@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz" @@ -3585,17 +3399,6 @@ ci-info@^3.2.0, ci-info@^3.6.1: resolved "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz" integrity sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ== -cids@^0.7.1: - version "0.7.5" - resolved "https://registry.npmjs.org/cids/-/cids-0.7.5.tgz" - integrity sha512-zT7mPeghoWAu+ppn8+BS1tQ5qGmbMfB4AregnQjA/qHY3GC1m1ptI9GkWNlgeu38r7CuRdXB47uY2XgAYt6QVA== - dependencies: - buffer "^5.5.0" - class-is "^1.1.0" - multibase "~0.6.0" - multicodec "^1.0.0" - multihashes "~0.4.15" - cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: version "1.0.4" resolved "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz" @@ -3609,11 +3412,6 @@ cjs-module-lexer@^1.0.0: resolved "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz" integrity sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA== -class-is@^1.1.0: - version "1.1.0" - resolved "https://registry.npmjs.org/class-is/-/class-is-1.1.0.tgz" - integrity sha512-rhjH9AG1fvabIDoGRVH587413LPjTZgmDF9fOFCbFJQV4yuocX1mHxxvXI4g3cGwbVY9wAYIoKlg1N79frJKQw== - classic-level@^1.2.0: version "1.3.0" resolved "https://registry.npmjs.org/classic-level/-/classic-level-1.3.0.tgz" @@ -3703,13 +3501,6 @@ clone-deep@4.0.1: kind-of "^6.0.2" shallow-clone "^3.0.0" -clone-response@^1.0.2: - version "1.0.3" - resolved "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz" - integrity sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA== - dependencies: - mimic-response "^1.0.0" - clone@^1.0.2: version "1.0.4" resolved "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz" @@ -3772,7 +3563,7 @@ columnify@1.6.0: strip-ansi "^6.0.1" wcwidth "^1.0.0" -combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6: +combined-stream@^1.0.8: version "1.0.8" resolved "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz" integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== @@ -3832,27 +3623,6 @@ console-control-strings@^1.1.0: resolved "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz" integrity sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ== -content-disposition@0.5.4: - version "0.5.4" - resolved "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz" - integrity sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ== - dependencies: - safe-buffer "5.2.1" - -content-hash@^2.5.2: - version "2.5.2" - resolved "https://registry.npmjs.org/content-hash/-/content-hash-2.5.2.tgz" - integrity sha512-FvIQKy0S1JaWV10sMsA7TRx8bpU+pqPkhbsfvOJAdjRXvYxEckAwQWGwtRjiaJfh+E0DvcWUGqcdjwMGFjsSdw== - dependencies: - cids "^0.7.1" - multicodec "^0.5.5" - multihashes "^0.4.15" - -content-type@~1.0.4, content-type@~1.0.5: - version "1.0.5" - resolved "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz" - integrity sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA== - conventional-changelog-angular@7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/conventional-changelog-angular/-/conventional-changelog-angular-7.0.0.tgz#5eec8edbff15aa9b1680a8dcfbd53e2d7eb2ba7a" @@ -3936,39 +3706,16 @@ convert-source-map@^2.0.0: resolved "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz" integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg== -cookie-signature@1.0.6: - version "1.0.6" - resolved "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz" - integrity sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ== - -cookie@0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.6.0.tgz#2798b04b071b0ecbff0dbb62a505a8efa4e19051" - integrity sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw== - cookie@^0.4.1: version "0.4.2" resolved "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz" integrity sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA== -core-util-is@1.0.2: - version "1.0.2" - resolved "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz" - integrity sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ== - core-util-is@~1.0.0: version "1.0.3" resolved "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz" integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== -cors@^2.8.1: - version "2.8.5" - resolved "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz" - integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g== - dependencies: - object-assign "^4" - vary "^1" - cosmiconfig@^8.2.0: version "8.3.6" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-8.3.6.tgz#060a2b871d66dba6c8538ea1118ba1ac16f5fae3" @@ -3979,7 +3726,7 @@ cosmiconfig@^8.2.0: parse-json "^5.2.0" path-type "^4.0.0" -crc-32@^1.2.0: +crc-32@^1.2.0, crc-32@^1.2.2: version "1.2.2" resolved "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz" integrity sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ== @@ -4068,26 +3815,11 @@ cssstyle@^2.3.0: dependencies: cssom "~0.3.6" -d@1, d@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/d/-/d-1.0.1.tgz" - integrity sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA== - dependencies: - es5-ext "^0.10.50" - type "^1.0.1" - dargs@^7.0.0: version "7.0.0" resolved "https://registry.npmjs.org/dargs/-/dargs-7.0.0.tgz" integrity sha512-2iy1EkLdlBzQGvbweYRFxmFath8+K7+AKB0TlhHWkNuH+TmovaMH/Wp7V7R4u7f4SnX3OgLsU9t1NI9ioDnUpg== -dashdash@^1.12.0: - version "1.14.1" - resolved "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz" - integrity sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g== - dependencies: - assert-plus "^1.0.0" - data-urls@^3.0.2: version "3.0.2" resolved "https://registry.npmjs.org/data-urls/-/data-urls-3.0.2.tgz" @@ -4102,13 +3834,6 @@ dateformat@^3.0.3: resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae" integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q== -debug@2.6.9, debug@^2.2.0: - version "2.6.9" - resolved "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz" - integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== - dependencies: - ms "2.0.0" - debug@4, debug@4.3.4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4, debug@~4.3.1, debug@~4.3.2: version "4.3.4" resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz" @@ -4139,25 +3864,6 @@ decimal.js@^10.4.2: resolved "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz" integrity sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA== -decode-uri-component@^0.2.0: - version "0.2.2" - resolved "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz" - integrity sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ== - -decompress-response@^3.3.0: - version "3.3.0" - resolved "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz" - integrity sha512-BzRPQuY1ip+qDonAOz42gRm/pg9F768C+npV/4JOsxRC2sq+Rlk+Q4ZCAsOhnIaMrgarILY+RMUIvMmmX1qAEA== - dependencies: - mimic-response "^1.0.0" - -decompress-response@^6.0.0: - version "6.0.0" - resolved "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz" - integrity sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ== - dependencies: - mimic-response "^3.1.0" - dedent@0.7.0: version "0.7.0" resolved "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz" @@ -4217,11 +3923,6 @@ defaults@^1.0.3: dependencies: clone "^1.0.2" -defer-to-connect@^2.0.0, defer-to-connect@^2.0.1: - version "2.0.1" - resolved "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz" - integrity sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg== - define-data-property@^1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz" @@ -4261,11 +3962,6 @@ deprecation@^2.0.0: resolved "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz" integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ== -destroy@1.2.0: - version "1.2.0" - resolved "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz" - integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg== - detect-indent@^5.0.0: version "5.0.0" resolved "https://registry.npmjs.org/detect-indent/-/detect-indent-5.0.0.tgz" @@ -4310,11 +4006,6 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" -dom-walk@^0.1.0: - version "0.1.2" - resolved "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.2.tgz" - integrity sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w== - domexception@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/domexception/-/domexception-4.0.0.tgz" @@ -4349,19 +4040,6 @@ eastasianwidth@^0.2.0: resolved "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz" integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== -ecc-jsbn@~0.1.1: - version "0.1.2" - resolved "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz" - integrity sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw== - dependencies: - jsbn "~0.1.0" - safer-buffer "^2.1.0" - -ee-first@1.1.1: - version "1.1.1" - resolved "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz" - integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== - ejs@^3.1.7: version "3.1.9" resolved "https://registry.npmjs.org/ejs/-/ejs-3.1.9.tgz" @@ -4374,7 +4052,7 @@ electron-to-chromium@^1.4.535: resolved "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.589.tgz" integrity sha512-zF6y5v/YfoFIgwf2dDfAqVlPPsyQeWNpEWXbAlDUS8Ax4Z2VoiiZpAPC0Jm9hXEkJm2vIZpwB6rc4KnLTQffbQ== -elliptic@6.5.4, elliptic@^6.4.0, elliptic@^6.5.2, elliptic@^6.5.4: +elliptic@6.5.4, elliptic@^6.5.2, elliptic@^6.5.4: version "6.5.4" resolved "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz" integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== @@ -4407,11 +4085,6 @@ encode-utf8@^1.0.2: resolved "https://registry.npmjs.org/encode-utf8/-/encode-utf8-1.0.3.tgz" integrity sha512-ucAnuBEhUK4boH2HjVYG5Q2mQyPorvv0u/ocS+zhdw0S8AlHYY+GOFhP1Gio5z4icpP2ivFSvhtFjQi8+T9ppw== -encodeurl@~1.0.2: - version "1.0.2" - resolved "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz" - integrity sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w== - encoding@^0.1.13: version "0.1.13" resolved "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz" @@ -4476,52 +4149,16 @@ error-ex@^1.3.1: dependencies: is-arrayish "^0.2.1" -es5-ext@^0.10.35, es5-ext@^0.10.50: - version "0.10.62" - resolved "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz" - integrity sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA== - dependencies: - es6-iterator "^2.0.3" - es6-symbol "^3.1.3" - next-tick "^1.1.0" - es6-error@^4.0.1: version "4.1.1" resolved "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz" integrity sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg== -es6-iterator@^2.0.3: - version "2.0.3" - resolved "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz" - integrity sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g== - dependencies: - d "1" - es5-ext "^0.10.35" - es6-symbol "^3.1.1" - -es6-promise@^4.2.8: - version "4.2.8" - resolved "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz" - integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== - -es6-symbol@^3.1.1, es6-symbol@^3.1.3: - version "3.1.3" - resolved "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz" - integrity sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA== - dependencies: - d "^1.0.1" - ext "^1.1.2" - escalade@^3.1.1: version "3.1.1" resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz" integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== -escape-html@~1.0.3: - version "1.0.3" - resolved "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz" - integrity sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow== - escape-string-regexp@4.0.0, escape-string-regexp@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz" @@ -4657,40 +4294,6 @@ esutils@^2.0.2: resolved "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== -etag@~1.8.1: - version "1.8.1" - resolved "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz" - integrity sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg== - -eth-ens-namehash@2.0.8: - version "2.0.8" - resolved "https://registry.npmjs.org/eth-ens-namehash/-/eth-ens-namehash-2.0.8.tgz" - integrity sha512-VWEI1+KJfz4Km//dadyvBBoBeSQ0MHTXPvr8UIXiLW6IanxvAV+DmlZAijZwAyggqGUfwQBeHf7tc9wzc1piSw== - dependencies: - idna-uts46-hx "^2.3.1" - js-sha3 "^0.5.7" - -eth-lib@0.2.8: - version "0.2.8" - resolved "https://registry.npmjs.org/eth-lib/-/eth-lib-0.2.8.tgz" - integrity sha512-ArJ7x1WcWOlSpzdoTBX8vkwlkSQ85CjjifSZtV4co64vWxSV8geWfPI9x4SVYu3DSxnX4yWFVTtGL+j9DUFLNw== - dependencies: - bn.js "^4.11.6" - elliptic "^6.4.0" - xhr-request-promise "^0.1.2" - -eth-lib@^0.1.26: - version "0.1.29" - resolved "https://registry.npmjs.org/eth-lib/-/eth-lib-0.1.29.tgz" - integrity sha512-bfttrr3/7gG4E02HoWTDUcDDslN003OlOoBxk9virpAZQ1ja/jDgwkWB8QfJF7ojuEowrqy+lzp9VcJG7/k5bQ== - dependencies: - bn.js "^4.11.6" - elliptic "^6.4.0" - nano-json-stream-parser "^0.1.2" - servify "^0.1.12" - ws "^3.0.0" - xhr-request-promise "^0.1.2" - eth-testing@^1.14.0: version "1.14.0" resolved "https://registry.npmjs.org/eth-testing/-/eth-testing-1.14.0.tgz" @@ -4699,13 +4302,6 @@ eth-testing@^1.14.0: abitype "^0.1.6" ethers "^5.5.4" -ethereum-bloom-filters@^1.0.6: - version "1.0.10" - resolved "https://registry.npmjs.org/ethereum-bloom-filters/-/ethereum-bloom-filters-1.0.10.tgz" - integrity sha512-rxJ5OFN3RwjQxDcFP2Z5+Q9ho4eIdEmSc2ht0fCu8Se9nbXjZ7/031uXoUYJ87KHCOdVeiUuwSnoS7hmYAGVHA== - dependencies: - js-sha3 "^0.8.0" - ethereum-cryptography@0.1.3, ethereum-cryptography@^0.1.3: version "0.1.3" resolved "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-0.1.3.tgz" @@ -4841,14 +4437,6 @@ ethers@^6.7.1, ethers@^6.8.1: tslib "2.4.0" ws "8.5.0" -ethjs-unit@0.1.6: - version "0.1.6" - resolved "https://registry.npmjs.org/ethjs-unit/-/ethjs-unit-0.1.6.tgz" - integrity sha512-/Sn9Y0oKl0uqQuvgFk/zQgR7aw1g36qX/jzSQ5lSwlO0GigPymk4eGQfeNTD03w1dPOqfz8V77Cy43jH56pagw== - dependencies: - bn.js "4.11.6" - number-to-bn "1.7.0" - ethjs-util@0.1.6, ethjs-util@^0.1.6: version "0.1.6" resolved "https://registry.npmjs.org/ethjs-util/-/ethjs-util-0.1.6.tgz" @@ -4862,11 +4450,6 @@ event-target-shim@^5.0.0: resolved "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz" integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== -eventemitter3@4.0.4: - version "4.0.4" - resolved "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.4.tgz" - integrity sha512-rlaVLnVxtxvoyLsQQFBx53YmXHDxRIzzTLbdfxqi4yocpSjAxXwkU0cScM5JgSKMqEhrZpnvQ2D9gjylR0AimQ== - eventemitter3@^4.0.4: version "4.0.7" resolved "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz" @@ -4951,55 +4534,6 @@ expect@^29.0.0, expect@^29.7.0: jest-message-util "^29.7.0" jest-util "^29.7.0" -express@^4.14.0: - version "4.19.2" - resolved "https://registry.yarnpkg.com/express/-/express-4.19.2.tgz#e25437827a3aa7f2a827bc8171bbbb664a356465" - integrity sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q== - dependencies: - accepts "~1.3.8" - array-flatten "1.1.1" - body-parser "1.20.2" - content-disposition "0.5.4" - content-type "~1.0.4" - cookie "0.6.0" - cookie-signature "1.0.6" - debug "2.6.9" - depd "2.0.0" - encodeurl "~1.0.2" - escape-html "~1.0.3" - etag "~1.8.1" - finalhandler "1.2.0" - fresh "0.5.2" - http-errors "2.0.0" - merge-descriptors "1.0.1" - methods "~1.1.2" - on-finished "2.4.1" - parseurl "~1.3.3" - path-to-regexp "0.1.7" - proxy-addr "~2.0.7" - qs "6.11.0" - range-parser "~1.2.1" - safe-buffer "5.2.1" - send "0.18.0" - serve-static "1.15.0" - setprototypeof "1.2.0" - statuses "2.0.1" - type-is "~1.6.18" - utils-merge "1.0.1" - vary "~1.1.2" - -ext@^1.1.2: - version "1.7.0" - resolved "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz" - integrity sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw== - dependencies: - type "^2.7.2" - -extend@~3.0.2: - version "3.0.2" - resolved "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz" - integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== - external-editor@^3.0.3: version "3.1.0" resolved "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz" @@ -5009,16 +4543,6 @@ external-editor@^3.0.3: iconv-lite "^0.4.24" tmp "^0.0.33" -extsprintf@1.3.0: - version "1.3.0" - resolved "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz" - integrity sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g== - -extsprintf@^1.2.0: - version "1.4.1" - resolved "https://registry.npmjs.org/extsprintf/-/extsprintf-1.4.1.tgz" - integrity sha512-Wrk35e8ydCKDj/ArClo1VrPVmN8zph5V4AtHwIuHhvMXsKf73UT3BOD+azBIW+3wOJ4FhEH7zyaJCFvChjYvMA== - fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: version "3.1.3" resolved "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz" @@ -5102,19 +4626,6 @@ fill-range@^7.0.1: dependencies: to-regex-range "^5.0.1" -finalhandler@1.2.0: - version "1.2.0" - resolved "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz" - integrity sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg== - dependencies: - debug "2.6.9" - encodeurl "~1.0.2" - escape-html "~1.0.3" - on-finished "2.4.1" - parseurl "~1.3.3" - statuses "2.0.1" - unpipe "~1.0.0" - find-cache-dir@^3.2.0: version "3.3.2" resolved "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz" @@ -5200,16 +4711,6 @@ foreground-child@^3.1.0: cross-spawn "^7.0.0" signal-exit "^4.0.1" -forever-agent@~0.6.1: - version "0.6.1" - resolved "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz" - integrity sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw== - -form-data-encoder@1.7.1: - version "1.7.1" - resolved "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.1.tgz" - integrity sha512-EFRDrsMm/kyqbTQocNvRXMLjc7Es2Vk+IQFx/YW7hkUH1eBl4J1fqiP34l74Yt0pFLCNpc06fkbVk00008mzjg== - form-data@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz" @@ -5219,20 +4720,6 @@ form-data@^4.0.0: combined-stream "^1.0.8" mime-types "^2.1.12" -form-data@~2.3.2: - version "2.3.3" - resolved "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz" - integrity sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.6" - mime-types "^2.1.12" - -forwarded@0.2.0: - version "0.2.0" - resolved "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz" - integrity sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow== - fp-ts@1.19.3: version "1.19.3" resolved "https://registry.npmjs.org/fp-ts/-/fp-ts-1.19.3.tgz" @@ -5243,11 +4730,6 @@ fp-ts@^1.0.0: resolved "https://registry.npmjs.org/fp-ts/-/fp-ts-1.19.5.tgz" integrity sha512-wDNqTimnzs8QqpldiId9OavWK2NptormjXnRJTQecNjzwfyp6P/8s/zG8e4h3ja3oqkKaY72UlTjQYt/1yXf9A== -fresh@0.5.2: - version "0.5.2" - resolved "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz" - integrity sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q== - fromentries@^1.2.0: version "1.3.2" resolved "https://registry.npmjs.org/fromentries/-/fromentries-1.3.2.tgz" @@ -5287,15 +4769,6 @@ fs-extra@^11.1.0, fs-extra@^11.1.1: jsonfile "^6.0.1" universalify "^2.0.0" -fs-extra@^4.0.2: - version "4.0.3" - resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz" - integrity sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg== - dependencies: - graceful-fs "^4.1.2" - jsonfile "^4.0.0" - universalify "^0.1.0" - fs-extra@^7.0.1: version "7.0.1" resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz" @@ -5305,13 +4778,6 @@ fs-extra@^7.0.1: jsonfile "^4.0.0" universalify "^0.1.0" -fs-minipass@^1.2.7: - version "1.2.7" - resolved "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz" - integrity sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA== - dependencies: - minipass "^2.6.0" - fs-minipass@^2.0.0, fs-minipass@^2.1.0: version "2.1.0" resolved "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz" @@ -5410,25 +4876,11 @@ get-stream@6.0.0: resolved "https://registry.npmjs.org/get-stream/-/get-stream-6.0.0.tgz" integrity sha512-A1B3Bh1UmL0bidM/YX2NsCOTnGJePL9rO/M+Mw3m9f2gUpfokS0hi5Eah0WSUEWZdZhIZtMjkIYS7mDfOqNHbg== -get-stream@^5.1.0: - version "5.2.0" - resolved "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz" - integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== - dependencies: - pump "^3.0.0" - get-stream@^6.0.0, get-stream@^6.0.1: version "6.0.1" resolved "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz" integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== -getpass@^0.1.1: - version "0.1.7" - resolved "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz" - integrity sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng== - dependencies: - assert-plus "^1.0.0" - git-raw-commits@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/git-raw-commits/-/git-raw-commits-3.0.0.tgz#5432f053a9744f67e8db03dbc48add81252cfdeb" @@ -5558,14 +5010,6 @@ glob@^9.2.0, glob@^9.3.1: minipass "^4.2.4" path-scurry "^1.6.1" -global@~4.4.0: - version "4.4.0" - resolved "https://registry.npmjs.org/global/-/global-4.4.0.tgz" - integrity sha512-wv/LAoHdRE3BeTGz53FAamhGlPLhlssK45usmGFThIi4XqnBmjKQ16u+RNbP7WvigRZDxUsM0J3gcQ5yicaL0w== - dependencies: - min-document "^2.19.0" - process "^0.11.10" - globals@^11.1.0: version "11.12.0" resolved "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz" @@ -5597,42 +5041,6 @@ gopd@^1.0.1: dependencies: get-intrinsic "^1.1.3" -got@12.1.0: - version "12.1.0" - resolved "https://registry.npmjs.org/got/-/got-12.1.0.tgz" - integrity sha512-hBv2ty9QN2RdbJJMK3hesmSkFTjVIHyIDDbssCKnSmq62edGgImJWD10Eb1k77TiV1bxloxqcFAVK8+9pkhOig== - dependencies: - "@sindresorhus/is" "^4.6.0" - "@szmarczak/http-timer" "^5.0.1" - "@types/cacheable-request" "^6.0.2" - "@types/responselike" "^1.0.0" - cacheable-lookup "^6.0.4" - cacheable-request "^7.0.2" - decompress-response "^6.0.0" - form-data-encoder "1.7.1" - get-stream "^6.0.1" - http2-wrapper "^2.1.10" - lowercase-keys "^3.0.0" - p-cancelable "^3.0.0" - responselike "^2.0.0" - -got@^11.8.5: - version "11.8.6" - resolved "https://registry.npmjs.org/got/-/got-11.8.6.tgz" - integrity sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g== - dependencies: - "@sindresorhus/is" "^4.0.0" - "@szmarczak/http-timer" "^4.0.5" - "@types/cacheable-request" "^6.0.1" - "@types/responselike" "^1.0.0" - cacheable-lookup "^5.0.3" - cacheable-request "^7.0.2" - decompress-response "^6.0.0" - http2-wrapper "^1.0.0-beta.5.2" - lowercase-keys "^2.0.0" - p-cancelable "^2.0.0" - responselike "^2.0.0" - graceful-fs@4.2.11, graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@^4.2.0, graceful-fs@^4.2.6, graceful-fs@^4.2.9: version "4.2.11" resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz" @@ -5655,19 +5063,6 @@ handlebars@^4.7.7: optionalDependencies: uglify-js "^3.1.4" -har-schema@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz" - integrity sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q== - -har-validator@~5.1.3: - version "5.1.5" - resolved "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz" - integrity sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w== - dependencies: - ajv "^6.12.3" - har-schema "^2.0.0" - hard-rejection@^2.1.0: version "2.1.0" resolved "https://registry.npmjs.org/hard-rejection/-/hard-rejection-2.1.0.tgz" @@ -5892,7 +5287,7 @@ html-escaper@^2.0.0: resolved "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz" integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== -http-cache-semantics@^4.0.0, http-cache-semantics@^4.1.0, http-cache-semantics@^4.1.1: +http-cache-semantics@^4.1.0, http-cache-semantics@^4.1.1: version "4.1.1" resolved "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz" integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ== @@ -5908,11 +5303,6 @@ http-errors@2.0.0: statuses "2.0.1" toidentifier "1.0.1" -http-https@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/http-https/-/http-https-1.0.0.tgz" - integrity sha512-o0PWwVCSp3O0wS6FvNr6xfBCHgt0m1tvPLFOCc2iFDKTRAXhB7m8klDf7ErowFH8POa6dVdGatKU5I1YYwzUyg== - http-proxy-agent@^5.0.0: version "5.0.0" resolved "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz" @@ -5922,31 +5312,6 @@ http-proxy-agent@^5.0.0: agent-base "6" debug "4" -http-signature@~1.2.0: - version "1.2.0" - resolved "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz" - integrity sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ== - dependencies: - assert-plus "^1.0.0" - jsprim "^1.2.2" - sshpk "^1.7.0" - -http2-wrapper@^1.0.0-beta.5.2: - version "1.0.3" - resolved "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz" - integrity sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg== - dependencies: - quick-lru "^5.1.1" - resolve-alpn "^1.0.0" - -http2-wrapper@^2.1.10: - version "2.2.0" - resolved "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-2.2.0.tgz" - integrity sha512-kZB0wxMo0sh1PehyjJUWRFEd99KC5TLjZ2cULC4f9iqJBAmKQQXEICjxl5iPJRwP40dpeHFqqhm7tYCvODpqpQ== - dependencies: - quick-lru "^5.1.1" - resolve-alpn "^1.2.0" - https-proxy-agent@^5.0.0, https-proxy-agent@^5.0.1: version "5.0.1" resolved "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz" @@ -5991,13 +5356,6 @@ iconv-lite@0.6.3, iconv-lite@^0.6.2: dependencies: safer-buffer ">= 2.1.2 < 3.0.0" -idna-uts46-hx@^2.3.1: - version "2.3.1" - resolved "https://registry.npmjs.org/idna-uts46-hx/-/idna-uts46-hx-2.3.1.tgz" - integrity sha512-PWoF9Keq6laYdIRwwCdhTPl60xRqAloYNMQLiyUnG42VjT53oW07BXIRM+NK7eQjzXjAk2gUvX9caRxlnF9TAA== - dependencies: - punycode "2.1.0" - ieee754@^1.1.13, ieee754@^1.2.1: version "1.2.1" resolved "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz" @@ -6127,11 +5485,6 @@ ip@^2.0.0: resolved "https://registry.yarnpkg.com/ip/-/ip-2.0.1.tgz#e8f3595d33a3ea66490204234b77636965307105" integrity sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ== -ipaddr.js@1.9.1: - version "1.9.1" - resolved "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz" - integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== - is-arguments@^1.0.4: version "1.1.1" resolved "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz" @@ -6201,11 +5554,6 @@ is-fullwidth-code-point@^4.0.0: resolved "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz" integrity sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ== -is-function@^1.0.1: - version "1.0.2" - resolved "https://registry.npmjs.org/is-function/-/is-function-1.0.2.tgz" - integrity sha512-lw7DUp0aWXYg+CBCN+JKkcE0Q2RayZnSvnZBlwgxHBQhqt5pZNVy4Ri7H9GmmXkdu7LUthszM+Tor1u/2iBcpQ== - is-generator-fn@^2.0.0: version "2.1.0" resolved "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz" @@ -6329,7 +5677,7 @@ is-typed-array@^1.1.10, is-typed-array@^1.1.3: gopd "^1.0.1" has-tostringtag "^1.0.0" -is-typedarray@^1.0.0, is-typedarray@~1.0.0: +is-typedarray@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz" integrity sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA== @@ -6381,10 +5729,10 @@ isomorphic-ws@^5.0.0: resolved "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz" integrity sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw== -isstream@~0.1.2: - version "0.1.2" - resolved "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz" - integrity sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g== +isows@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.3.tgz#93c1cf0575daf56e7120bab5c8c448b0809d0d74" + integrity sha512-2cKei4vlmg2cxEjm3wVSqn8pcoRF/LX/wpifuuNquFO4SQmPwarClT+SUCA2lt+l581tTeZIPIZuIDo2jWN1fg== istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.2.0: version "3.2.0" @@ -6864,16 +6212,11 @@ js-sdsl@^4.1.4: resolved "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.4.0.tgz" integrity sha512-FfVSdx6pJ41Oa+CF7RDaFmTnCaFhua+SNYQX74riGOpl96x+2jQCqEfQ2bnXu/5DPCqlRuiqyvTJM0Qjz26IVg== -js-sha3@0.8.0, js-sha3@^0.8.0: +js-sha3@0.8.0: version "0.8.0" resolved "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz" integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== -js-sha3@^0.5.7: - version "0.5.7" - resolved "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz" - integrity sha512-GII20kjaPX0zJ8wzkTbNDYMY7msuZcTWk8S5UOh6806Jq/wz1J8/bnr8uGU0DAUmYDjj2Mr4X1cW8v/GLYnR+g== - "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz" @@ -6894,11 +6237,6 @@ js-yaml@^3.10.0, js-yaml@^3.13.1: argparse "^1.0.7" esprima "^4.0.0" -jsbn@~0.1.0: - version "0.1.1" - resolved "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz" - integrity sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg== - jsdom@^20.0.0: version "20.0.3" resolved "https://registry.npmjs.org/jsdom/-/jsdom-20.0.3.tgz" @@ -6936,11 +6274,6 @@ jsesc@^2.5.1: resolved "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz" integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== -json-buffer@3.0.1: - version "3.0.1" - resolved "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz" - integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== - json-parse-better-errors@^1.0.1: version "1.0.2" resolved "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz" @@ -6961,11 +6294,6 @@ json-schema-traverse@^0.4.1: resolved "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz" integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== -json-schema@0.4.0: - version "0.4.0" - resolved "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz" - integrity sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA== - json-stable-stringify-without-jsonify@^1.0.1: version "1.0.1" resolved "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz" @@ -6981,7 +6309,7 @@ json-stable-stringify@^1.0.2: jsonify "^0.0.1" object-keys "^1.1.1" -json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1: +json-stringify-safe@^5.0.1: version "5.0.1" resolved "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz" integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA== @@ -7034,16 +6362,6 @@ jsonschema@^1.4.1: resolved "https://registry.npmjs.org/jsonschema/-/jsonschema-1.4.1.tgz" integrity sha512-S6cATIPVv1z0IlxdN+zUk5EPjkGCdnhN4wVSBlvoUO1tOLJootbo9CquNJmbIh4yikWHiUedhRYrNPn1arpEmQ== -jsprim@^1.2.2: - version "1.4.2" - resolved "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz" - integrity sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw== - dependencies: - assert-plus "1.0.0" - extsprintf "1.3.0" - json-schema "0.4.0" - verror "1.10.0" - just-extend@^4.0.2: version "4.2.1" resolved "https://registry.npmjs.org/just-extend/-/just-extend-4.2.1.tgz" @@ -7058,13 +6376,6 @@ keccak@^3.0.0, keccak@^3.0.2: node-gyp-build "^4.2.0" readable-stream "^3.6.0" -keyv@^4.0.0: - version "4.5.2" - resolved "https://registry.npmjs.org/keyv/-/keyv-4.5.2.tgz" - integrity sha512-5MHbFaKn8cNSmVW7BYnijeAVlE4cYA/SVkifVgrh7yotnfhKmjuXpDKjrABLnT0SfHWV21P8ow07OGfRrNDg8g== - dependencies: - json-buffer "3.0.1" - kind-of@^6.0.2, kind-of@^6.0.3: version "6.0.3" resolved "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz" @@ -7385,16 +6696,6 @@ loupe@^2.3.6: dependencies: get-func-name "^2.0.0" -lowercase-keys@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz" - integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA== - -lowercase-keys@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-3.0.0.tgz" - integrity sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ== - lru-cache@^5.1.1: version "5.1.1" resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz" @@ -7530,11 +6831,6 @@ md5.js@^1.3.4: inherits "^2.0.1" safe-buffer "^5.1.2" -media-typer@0.3.0: - version "0.3.0" - resolved "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz" - integrity sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ== - memory-level@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/memory-level/-/memory-level-1.0.0.tgz" @@ -7566,11 +6862,6 @@ meow@^8.1.2: type-fest "^0.18.0" yargs-parser "^20.2.3" -merge-descriptors@1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz" - integrity sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w== - merge-stream@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz" @@ -7581,11 +6872,6 @@ merge2@^1.3.0, merge2@^1.4.1: resolved "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz" integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== -methods@~1.1.2: - version "1.1.2" - resolved "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz" - integrity sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w== - micro-ftch@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/micro-ftch/-/micro-ftch-0.3.1.tgz#6cb83388de4c1f279a034fb0cf96dfc050853c5f" @@ -7604,18 +6890,13 @@ mime-db@1.52.0: resolved "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz" integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== -mime-types@^2.1.12, mime-types@^2.1.16, mime-types@~2.1.19, mime-types@~2.1.24, mime-types@~2.1.34: +mime-types@^2.1.12: version "2.1.35" resolved "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz" integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== dependencies: mime-db "1.52.0" -mime@1.6.0: - version "1.6.0" - resolved "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz" - integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== - mimic-fn@^2.1.0: version "2.1.0" resolved "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz" @@ -7626,23 +6907,6 @@ mimic-fn@^4.0.0: resolved "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz" integrity sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw== -mimic-response@^1.0.0: - version "1.0.1" - resolved "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz" - integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== - -mimic-response@^3.1.0: - version "3.1.0" - resolved "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz" - integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ== - -min-document@^2.19.0: - version "2.19.0" - resolved "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz" - integrity sha512-9Wy1B3m3f66bPPmU5hdA4DR4PB2OfDU/+GS3yAB7IQozE3tqXaVv2zOjgla7MEGSRv95+ILmOuvhLkOK6wJtCQ== - dependencies: - dom-walk "^0.1.0" - min-indent@^1.0.0: version "1.0.1" resolved "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz" @@ -7779,14 +7043,6 @@ minipass-sized@^1.0.3: dependencies: minipass "^3.0.0" -minipass@^2.6.0, minipass@^2.9.0: - version "2.9.0" - resolved "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz" - integrity sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg== - dependencies: - safe-buffer "^5.1.2" - yallist "^3.0.0" - minipass@^3.0.0, minipass@^3.1.1, minipass@^3.1.6: version "3.3.6" resolved "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz" @@ -7809,13 +7065,6 @@ minipass@^5.0.0: resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.0.4.tgz#dbce03740f50a4786ba994c1fb908844d27b038c" integrity sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ== -minizlib@^1.3.3: - version "1.3.3" - resolved "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz" - integrity sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q== - dependencies: - minipass "^2.9.0" - minizlib@^2.1.1, minizlib@^2.1.2: version "2.1.2" resolved "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz" @@ -7824,25 +7073,6 @@ minizlib@^2.1.1, minizlib@^2.1.2: minipass "^3.0.0" yallist "^4.0.0" -mkdirp-promise@^5.0.1: - version "5.0.1" - resolved "https://registry.npmjs.org/mkdirp-promise/-/mkdirp-promise-5.0.1.tgz" - integrity sha512-Hepn5kb1lJPtVW84RFT40YG1OddBNTOVUZR2bzQUHc+Z03en8/3uX0+060JDhcEzyO08HmipsN9DcnFMxhIL9w== - dependencies: - mkdirp "*" - -mkdirp@*: - version "3.0.0" - resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.0.tgz" - integrity sha512-7+JDnNsyCvZXoUJdkMR0oUE2AmAdsNXGTmRbiOjYIwQ6q+bL6NwrozGQdPcmYaNcrhH37F50HHBUzoaBV6FITQ== - -mkdirp@^0.5.5: - version "0.5.6" - resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz" - integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== - dependencies: - minimist "^1.2.6" - mkdirp@^1.0.3, mkdirp@^1.0.4: version "1.0.4" resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz" @@ -7882,11 +7112,6 @@ mocha@^10.0.0, mocha@^10.2.0: yargs-parser "20.2.4" yargs-unparser "2.0.0" -mock-fs@^4.1.0: - version "4.14.0" - resolved "https://registry.npmjs.org/mock-fs/-/mock-fs-4.14.0.tgz" - integrity sha512-qYvlv/exQ4+svI3UOvPUpLDF0OMX5euvUH0Ny4N5QyRyhNdgAgUrVH3iUINSzEPLvx0kbo/Bp28GJKIqvE7URw== - modify-values@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022" @@ -7897,11 +7122,6 @@ module-error@^1.0.1, module-error@^1.0.2: resolved "https://registry.npmjs.org/module-error/-/module-error-1.0.2.tgz" integrity sha512-0yuvsqSCv8LbaOKhnsQ/T5JhyFlCYLPXK3U2sgV10zoKQwzs/MyfuQUOZQ1V/6OCOJsK/TRgNVrPuPDqtdMFtA== -ms@2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz" - integrity sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A== - ms@2.1.2: version "2.1.2" resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz" @@ -7912,46 +7132,6 @@ ms@2.1.3, ms@^2.0.0: resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== -multibase@^0.7.0: - version "0.7.0" - resolved "https://registry.npmjs.org/multibase/-/multibase-0.7.0.tgz" - integrity sha512-TW8q03O0f6PNFTQDvh3xxH03c8CjGaaYrjkl9UQPG6rz53TQzzxJVCIWVjzcbN/Q5Y53Zd0IBQBMVktVgNx4Fg== - dependencies: - base-x "^3.0.8" - buffer "^5.5.0" - -multibase@~0.6.0: - version "0.6.1" - resolved "https://registry.npmjs.org/multibase/-/multibase-0.6.1.tgz" - integrity sha512-pFfAwyTjbbQgNc3G7D48JkJxWtoJoBMaR4xQUOuB8RnCgRqaYmWNFeJTTvrJ2w51bjLq2zTby6Rqj9TQ9elSUw== - dependencies: - base-x "^3.0.8" - buffer "^5.5.0" - -multicodec@^0.5.5: - version "0.5.7" - resolved "https://registry.npmjs.org/multicodec/-/multicodec-0.5.7.tgz" - integrity sha512-PscoRxm3f+88fAtELwUnZxGDkduE2HD9Q6GHUOywQLjOGT/HAdhjLDYNZ1e7VR0s0TP0EwZ16LNUTFpoBGivOA== - dependencies: - varint "^5.0.0" - -multicodec@^1.0.0: - version "1.0.4" - resolved "https://registry.npmjs.org/multicodec/-/multicodec-1.0.4.tgz" - integrity sha512-NDd7FeS3QamVtbgfvu5h7fd1IlbaC4EQ0/pgU4zqE2vdHCmBGsUa0TiM8/TdSeG6BMPC92OOCf8F1ocE/Wkrrg== - dependencies: - buffer "^5.6.0" - varint "^5.0.0" - -multihashes@^0.4.15, multihashes@~0.4.15: - version "0.4.21" - resolved "https://registry.npmjs.org/multihashes/-/multihashes-0.4.21.tgz" - integrity sha512-uVSvmeCWf36pU2nB4/1kzYZjsXD9vofZKpgudqkceYY5g2aZZXJ5r9lxuzoRLl1OAp28XljXsEJ/X/85ZsKmKw== - dependencies: - buffer "^5.5.0" - multibase "^0.7.0" - varint "^5.0.0" - multimatch@5.0.0: version "5.0.0" resolved "https://registry.npmjs.org/multimatch/-/multimatch-5.0.0.tgz" @@ -7987,11 +7167,6 @@ mylas@^2.1.9: resolved "https://registry.npmjs.org/mylas/-/mylas-2.1.13.tgz" integrity sha512-+MrqnJRtxdF+xngFfUUkIMQrUUL0KsxbADUkn23Z/4ibGg192Q+z+CQyiYwvWTsYjJygmMR8+w3ZDa98Zh6ESg== -nano-json-stream-parser@^0.1.2: - version "0.1.2" - resolved "https://registry.npmjs.org/nano-json-stream-parser/-/nano-json-stream-parser-0.1.2.tgz" - integrity sha512-9MqxMH/BSJC7dnLsEMPyfN5Dvoo49IsPFYMcHw3Bcfc2kN0lpHRBSzlMSVx4HGyJ7s9B31CyBTVehWJoQ8Ctew== - nanoid@3.3.3: version "3.3.3" resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz" @@ -8007,7 +7182,7 @@ natural-compare@^1.4.0: resolved "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz" integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== -negotiator@0.6.3, negotiator@^0.6.3: +negotiator@^0.6.3: version "0.6.3" resolved "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz" integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== @@ -8017,11 +7192,6 @@ neo-async@^2.6.0: resolved "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz" integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== -next-tick@^1.1.0: - version "1.1.0" - resolved "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz" - integrity sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ== - nise@^5.1.2: version "5.1.4" resolved "https://registry.npmjs.org/nise/-/nise-5.1.4.tgz" @@ -8142,11 +7312,6 @@ normalize-path@^3.0.0, normalize-path@~3.0.0: resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== -normalize-url@^6.0.1: - version "6.1.0" - resolved "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz" - integrity sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A== - npm-bundled@^1.1.2: version "1.1.2" resolved "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.1.2.tgz" @@ -8261,14 +7426,6 @@ npmlog@^6.0.0, npmlog@^6.0.2: gauge "^4.0.3" set-blocking "^2.0.0" -number-to-bn@1.7.0: - version "1.7.0" - resolved "https://registry.npmjs.org/number-to-bn/-/number-to-bn-1.7.0.tgz" - integrity sha512-wsJ9gfSz1/s4ZsJN01lyonwuxA1tml6X1yBDnfpMglypcBRFZZkus26EdPSlqS5GJfYddVZa22p3VNb3z5m5Ig== - dependencies: - bn.js "4.11.6" - strip-hex-prefix "1.0.0" - nwsapi@^2.2.2: version "2.2.4" resolved "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.4.tgz" @@ -8360,16 +7517,6 @@ nyc@^15.1.0: test-exclude "^6.0.0" yargs "^15.0.2" -oauth-sign@~0.9.0: - version "0.9.0" - resolved "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz" - integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== - -object-assign@^4, object-assign@^4.1.0, object-assign@^4.1.1: - version "4.1.1" - resolved "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz" - integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== - object-inspect@^1.9.0: version "1.12.3" resolved "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz" @@ -8390,20 +7537,6 @@ oblivious-set@1.1.1: resolved "https://registry.npmjs.org/oblivious-set/-/oblivious-set-1.1.1.tgz" integrity sha512-Oh+8fK09mgGmAshFdH6hSVco6KZmd1tTwNFWj35OvzdmJTMZtAkbn05zar2iG3v6sDs1JLEtOiBGNb6BHwkb2w== -oboe@2.1.5: - version "2.1.5" - resolved "https://registry.npmjs.org/oboe/-/oboe-2.1.5.tgz" - integrity sha512-zRFWiF+FoicxEs3jNI/WYUrVEgA7DeET/InK0XQuudGHRg8iIob3cNPrJTKaz4004uaA9Pbe+Dwa8iluhjLZWA== - dependencies: - http-https "^1.0.0" - -on-finished@2.4.1: - version "2.4.1" - resolved "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz" - integrity sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg== - dependencies: - ee-first "1.1.1" - once@^1.3.0, once@^1.3.1, once@^1.4.0: version "1.4.0" resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz" @@ -8488,16 +7621,6 @@ os-tmpdir@~1.0.2: resolved "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz" integrity sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g== -p-cancelable@^2.0.0: - version "2.1.1" - resolved "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz" - integrity sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg== - -p-cancelable@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/p-cancelable/-/p-cancelable-3.0.0.tgz" - integrity sha512-mlVgR3PGuzlo0MmTdk4cXqXWlwQDLnONTAg6sm62XkMJEiRxN3GL3SffkYvqwonbkJBcrI7Uvv5Zh9yjvn2iUw== - p-finally@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz" @@ -8647,11 +7770,6 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" -parse-headers@^2.0.0: - version "2.0.5" - resolved "https://registry.npmjs.org/parse-headers/-/parse-headers-2.0.5.tgz" - integrity sha512-ft3iAoLOB/MlwbNXgzy43SWGP6sQki2jQvAyBg/zDFAgr9bfNWZIUj42Kw2eJIl8kEi4PbgE6U1Zau/HwI75HA== - parse-json@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz" @@ -8691,11 +7809,6 @@ parse5@^7.0.0, parse5@^7.1.1: dependencies: entities "^4.4.0" -parseurl@~1.3.3: - version "1.3.3" - resolved "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz" - integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== - path-exists@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz" @@ -8734,11 +7847,6 @@ path-scurry@^1.10.1, path-scurry@^1.6.1: lru-cache "^9.1.1 || ^10.0.0" minipass "^5.0.0 || ^6.0.2 || ^7.0.0" -path-to-regexp@0.1.7: - version "0.1.7" - resolved "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz" - integrity sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ== - path-to-regexp@^1.7.0: version "1.8.0" resolved "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz" @@ -8774,11 +7882,6 @@ pbkdf2@^3.0.17: safe-buffer "^5.0.1" sha.js "^2.4.8" -performance-now@^2.1.0: - version "2.1.0" - resolved "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz" - integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow== - picocolors@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz" @@ -8924,20 +8027,12 @@ protocols@^2.0.0, protocols@^2.0.1: resolved "https://registry.npmjs.org/protocols/-/protocols-2.0.1.tgz" integrity sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q== -proxy-addr@~2.0.7: - version "2.0.7" - resolved "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz" - integrity sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg== - dependencies: - forwarded "0.2.0" - ipaddr.js "1.9.1" - proxy-from-env@^1.1.0: version "1.1.0" resolved "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz" integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== -psl@^1.1.28, psl@^1.1.33: +psl@^1.1.33: version "1.9.0" resolved "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz" integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag== @@ -8950,11 +8045,6 @@ pump@^3.0.0: end-of-stream "^1.1.0" once "^1.3.1" -punycode@2.1.0: - version "2.1.0" - resolved "https://registry.npmjs.org/punycode/-/punycode-2.1.0.tgz" - integrity sha512-Yxz2kRwT90aPiWEMHVYnEf4+rhwF1tBmmZ4KepCP+Wkium9JxtWnUm1nqGwpiAHr/tnTSeHqr3wb++jgSkXjhA== - punycode@^2.1.0, punycode@^2.1.1: version "2.3.0" resolved "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz" @@ -8965,13 +8055,6 @@ pure-rand@^6.0.0: resolved "https://registry.npmjs.org/pure-rand/-/pure-rand-6.0.1.tgz" integrity sha512-t+x1zEHDjBwkDGY5v5ApnZ/utcd4XYDiJsaQQoptTXgUXX95sDg1elCdJghzicm7n2mbCBJ3uYWr6M22SO19rg== -qs@6.11.0: - version "6.11.0" - resolved "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz" - integrity sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q== - dependencies: - side-channel "^1.0.4" - qs@^6.9.4: version "6.11.1" resolved "https://registry.npmjs.org/qs/-/qs-6.11.1.tgz" @@ -8979,20 +8062,6 @@ qs@^6.9.4: dependencies: side-channel "^1.0.4" -qs@~6.5.2: - version "6.5.3" - resolved "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz" - integrity sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA== - -query-string@^5.0.1: - version "5.1.1" - resolved "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz" - integrity sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw== - dependencies: - decode-uri-component "^0.2.0" - object-assign "^4.1.0" - strict-uri-encode "^1.0.0" - querystringify@^2.1.1: version "2.2.0" resolved "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz" @@ -9013,11 +8082,6 @@ quick-lru@^4.0.1: resolved "https://registry.npmjs.org/quick-lru/-/quick-lru-4.0.1.tgz" integrity sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g== -quick-lru@^5.1.1: - version "5.1.1" - resolved "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz" - integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== - randombytes@^2.1.0: version "2.1.0" resolved "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz" @@ -9025,12 +8089,7 @@ randombytes@^2.1.0: dependencies: safe-buffer "^5.1.0" -range-parser@~1.2.1: - version "1.2.1" - resolved "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz" - integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== - -raw-body@2.5.2, raw-body@^2.4.1: +raw-body@^2.4.1: version "2.5.2" resolved "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz" integrity sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA== @@ -9186,32 +8245,6 @@ release-zalgo@^1.0.0: dependencies: es6-error "^4.0.1" -request@^2.79.0: - version "2.88.2" - resolved "https://registry.npmjs.org/request/-/request-2.88.2.tgz" - integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== - dependencies: - aws-sign2 "~0.7.0" - aws4 "^1.8.0" - caseless "~0.12.0" - combined-stream "~1.0.6" - extend "~3.0.2" - forever-agent "~0.6.1" - form-data "~2.3.2" - har-validator "~5.1.3" - http-signature "~1.2.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.19" - oauth-sign "~0.9.0" - performance-now "^2.1.0" - qs "~6.5.2" - safe-buffer "^5.1.2" - tough-cookie "~2.5.0" - tunnel-agent "^0.6.0" - uuid "^3.3.2" - require-directory@^2.1.1: version "2.1.1" resolved "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz" @@ -9232,11 +8265,6 @@ requires-port@^1.0.0: resolved "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz" integrity sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ== -resolve-alpn@^1.0.0, resolve-alpn@^1.2.0: - version "1.2.1" - resolved "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz" - integrity sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g== - resolve-cwd@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz" @@ -9275,13 +8303,6 @@ resolve@^1.10.0, resolve@^1.20.0: path-parse "^1.0.7" supports-preserve-symlinks-flag "^1.0.0" -responselike@^2.0.0: - version "2.0.1" - resolved "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz" - integrity sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw== - dependencies: - lowercase-keys "^2.0.0" - restore-cursor@^3.1.0: version "3.1.0" resolved "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz" @@ -9387,7 +8408,7 @@ rxjs@^7.5.5: dependencies: tslib "^2.1.0" -safe-buffer@5.2.1, safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@^5.2.1, safe-buffer@~5.2.0: +safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: version "5.2.1" resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -9397,7 +8418,7 @@ safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: +"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0": version "2.1.2" resolved "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== @@ -9416,7 +8437,7 @@ scheduler@^0.23.0: dependencies: loose-envify "^1.1.0" -scrypt-js@3.0.1, scrypt-js@^3.0.0, scrypt-js@^3.0.1: +scrypt-js@3.0.1, scrypt-js@^3.0.0: version "3.0.1" resolved "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz" integrity sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA== @@ -9454,25 +8475,6 @@ semver@^7.0.0, semver@^7.1.1, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semve dependencies: lru-cache "^6.0.0" -send@0.18.0: - version "0.18.0" - resolved "https://registry.npmjs.org/send/-/send-0.18.0.tgz" - integrity sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg== - dependencies: - debug "2.6.9" - depd "2.0.0" - destroy "1.2.0" - encodeurl "~1.0.2" - escape-html "~1.0.3" - etag "~1.8.1" - fresh "0.5.2" - http-errors "2.0.0" - mime "1.6.0" - ms "2.1.3" - on-finished "2.4.1" - range-parser "~1.2.1" - statuses "2.0.1" - serialize-javascript@6.0.0: version "6.0.0" resolved "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz" @@ -9480,27 +8482,6 @@ serialize-javascript@6.0.0: dependencies: randombytes "^2.1.0" -serve-static@1.15.0: - version "1.15.0" - resolved "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz" - integrity sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g== - dependencies: - encodeurl "~1.0.2" - escape-html "~1.0.3" - parseurl "~1.3.3" - send "0.18.0" - -servify@^0.1.12: - version "0.1.12" - resolved "https://registry.npmjs.org/servify/-/servify-0.1.12.tgz" - integrity sha512-/xE6GvsKKqyo1BAY+KxOWXcLpPsUUyji7Qg3bVD7hh1eRze5bR1uYiuDA/k3Gof1s9BTzQZEJK8sNcNGFIzeWw== - dependencies: - body-parser "^1.16.0" - cors "^2.8.1" - express "^4.14.0" - request "^2.79.0" - xhr "^2.3.3" - set-blocking@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz" @@ -9583,20 +8564,6 @@ sigstore@^1.3.0, sigstore@^1.4.0: "@sigstore/tuf" "^1.0.3" make-fetch-happen "^11.0.1" -simple-concat@^1.0.0: - version "1.0.1" - resolved "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz" - integrity sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q== - -simple-get@^2.7.0: - version "2.8.2" - resolved "https://registry.npmjs.org/simple-get/-/simple-get-2.8.2.tgz" - integrity sha512-Ijd/rV5o+mSBBs4F/x9oDPtTx9Zb6X9brmnXvMW4J7IR15ngi9q5xxqWBKU744jTZiaXtxaPL7uHG6vtN8kUkw== - dependencies: - decompress-response "^3.3.0" - once "^1.3.1" - simple-concat "^1.0.0" - sinon-chai@^3.7.0: version "3.7.0" resolved "https://registry.npmjs.org/sinon-chai/-/sinon-chai-3.7.0.tgz" @@ -9772,21 +8739,6 @@ sprintf-js@~1.0.2: resolved "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz" integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== -sshpk@^1.7.0: - version "1.17.0" - resolved "https://registry.npmjs.org/sshpk/-/sshpk-1.17.0.tgz" - integrity sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ== - dependencies: - asn1 "~0.2.3" - assert-plus "^1.0.0" - bcrypt-pbkdf "^1.0.0" - dashdash "^1.12.0" - ecc-jsbn "~0.1.1" - getpass "^0.1.1" - jsbn "~0.1.0" - safer-buffer "^2.0.2" - tweetnacl "~0.14.0" - ssri@^10.0.0, ssri@^10.0.1: version "10.0.3" resolved "https://registry.npmjs.org/ssri/-/ssri-10.0.3.tgz" @@ -9820,11 +8772,6 @@ statuses@2.0.1: resolved "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz" integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ== -strict-uri-encode@^1.0.0: - version "1.1.0" - resolved "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz" - integrity sha512-R3f198pcvnB+5IpnBlRkphuE9n46WyVl8I39W/ZUTZLz4nqSP/oLYUrcnJrw462Ds8he4YKMov2efsTIw1BDGQ== - string-argv@0.3.2: version "0.3.2" resolved "https://registry.npmjs.org/string-argv/-/string-argv-0.3.2.tgz" @@ -9979,23 +8926,6 @@ supports-preserve-symlinks-flag@^1.0.0: resolved "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz" integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== -swarm-js@^0.1.40: - version "0.1.42" - resolved "https://registry.npmjs.org/swarm-js/-/swarm-js-0.1.42.tgz" - integrity sha512-BV7c/dVlA3R6ya1lMlSSNPLYrntt0LUq4YMgy3iwpCIc6rZnS5W2wUoctarZ5pXlpKtxDDf9hNziEkcfrxdhqQ== - dependencies: - bluebird "^3.5.0" - buffer "^5.0.5" - eth-lib "^0.1.26" - fs-extra "^4.0.2" - got "^11.8.5" - mime-types "^2.1.16" - mkdirp-promise "^5.0.1" - mock-fs "^4.1.0" - setimmediate "^1.0.5" - tar "^4.0.2" - xhr-request "^1.0.1" - symbol-tree@^3.2.4: version "3.2.4" resolved "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz" @@ -10032,19 +8962,6 @@ tar@6.1.11: mkdirp "^1.0.3" yallist "^4.0.0" -tar@^4.0.2: - version "4.4.19" - resolved "https://registry.npmjs.org/tar/-/tar-4.4.19.tgz" - integrity sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA== - dependencies: - chownr "^1.1.4" - fs-minipass "^1.2.7" - minipass "^2.9.0" - minizlib "^1.3.3" - mkdirp "^0.5.5" - safe-buffer "^5.2.1" - yallist "^3.1.1" - tar@^6.1.11, tar@^6.1.2: version "6.1.13" resolved "https://registry.npmjs.org/tar/-/tar-6.1.13.tgz" @@ -10094,11 +9011,6 @@ through@2, "through@>=2.2.7 <3", through@^2.3.4, through@^2.3.6: resolved "https://registry.npmjs.org/through/-/through-2.3.8.tgz" integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg== -timed-out@^4.0.1: - version "4.0.1" - resolved "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz" - integrity sha512-G7r3AhovYtr5YKOWQkta8RKAPb+J9IsO4uVmzjl8AZwfhs8UcUwTiD6gcJYSgOtzyjvQKrKYn41syHbUWMkafA== - titleize@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/titleize/-/titleize-3.0.0.tgz#71c12eb7fdd2558aa8a44b0be83b8a76694acd53" @@ -10150,14 +9062,6 @@ tough-cookie@^4.1.2: universalify "^0.2.0" url-parse "^1.5.3" -tough-cookie@~2.5.0: - version "2.5.0" - resolved "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz" - integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== - dependencies: - psl "^1.1.28" - punycode "^2.1.1" - tr46@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz" @@ -10263,23 +9167,11 @@ tuf-js@^1.1.7: debug "^4.3.4" make-fetch-happen "^11.1.1" -tunnel-agent@^0.6.0: - version "0.6.0" - resolved "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz" - integrity sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w== - dependencies: - safe-buffer "^5.0.1" - tweetnacl-util@^0.15.1: version "0.15.1" resolved "https://registry.npmjs.org/tweetnacl-util/-/tweetnacl-util-0.15.1.tgz" integrity sha512-RKJBIj8lySrShN4w6i/BonWp2Z/uxwC3h4y7xsRrpP59ZboCd0GpEVsOnMDYLMmKBpYhb5TgHzZXy7wTfYFBRw== -tweetnacl@^0.14.3, tweetnacl@~0.14.0: - version "0.14.5" - resolved "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz" - integrity sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA== - tweetnacl@^1.0.3: version "1.0.3" resolved "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz" @@ -10344,24 +9236,6 @@ type-fest@^1.0.2: resolved "https://registry.npmjs.org/type-fest/-/type-fest-1.4.0.tgz" integrity sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA== -type-is@~1.6.18: - version "1.6.18" - resolved "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz" - integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== - dependencies: - media-typer "0.3.0" - mime-types "~2.1.24" - -type@^1.0.1: - version "1.2.0" - resolved "https://registry.npmjs.org/type/-/type-1.2.0.tgz" - integrity sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg== - -type@^2.7.2: - version "2.7.2" - resolved "https://registry.npmjs.org/type/-/type-2.7.2.tgz" - integrity sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw== - typedarray-to-buffer@^3.1.5: version "3.1.5" resolved "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz" @@ -10384,11 +9258,6 @@ uglify-js@^3.1.4: resolved "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz" integrity sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g== -ultron@~1.1.0: - version "1.1.1" - resolved "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz" - integrity sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og== - undici-types@~5.26.4: version "5.26.5" resolved "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz" @@ -10454,7 +9323,7 @@ unload@^2.4.1: resolved "https://registry.npmjs.org/unload/-/unload-2.4.1.tgz" integrity sha512-IViSAm8Z3sRBYA+9wc0fLQmU9Nrxb16rcDmIiR6Y9LJSZzI7QY5QsDhqPpKOjAn0O9/kfK1TfNEMMAGPTIraPw== -unpipe@1.0.0, unpipe@~1.0.0: +unpipe@1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz" integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== @@ -10492,23 +9361,6 @@ url-parse@^1.5.3: querystringify "^2.1.1" requires-port "^1.0.0" -url-set-query@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/url-set-query/-/url-set-query-1.0.0.tgz" - integrity sha512-3AChu4NiXquPfeckE5R5cGdiHCMWJx1dwCWOmWIL4KHAziJNOFIYJlpGFeKDvwLPHovZRCxK3cYlwzqI9Vp+Gg== - -utf-8-validate@^5.0.2: - version "5.0.10" - resolved "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz" - integrity sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ== - dependencies: - node-gyp-build "^4.3.0" - -utf8@3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/utf8/-/utf8-3.0.0.tgz" - integrity sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ== - util-deprecate@^1.0.1, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" @@ -10525,16 +9377,6 @@ util@^0.12.5: is-typed-array "^1.1.3" which-typed-array "^1.1.2" -utils-merge@1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz" - integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA== - -uuid@^3.3.2: - version "3.4.0" - resolved "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz" - integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== - uuid@^8.3.2: version "8.3.2" resolved "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz" @@ -10586,24 +9428,19 @@ validate-npm-package-name@^3.0.0: dependencies: builtins "^1.0.3" -varint@^5.0.0: - version "5.0.2" - resolved "https://registry.npmjs.org/varint/-/varint-5.0.2.tgz" - integrity sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow== - -vary@^1, vary@~1.1.2: - version "1.1.2" - resolved "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz" - integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== - -verror@1.10.0: - version "1.10.0" - resolved "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz" - integrity sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw== +viem@^2.9.19: + version "2.9.21" + resolved "https://registry.yarnpkg.com/viem/-/viem-2.9.21.tgz#a7dd3d4c827088e5336e5a6b35ec0283d2938595" + integrity sha512-8GtxPjPGpiN5cmr19zSX9mb1LX/eON3MPxxAd3QmyUFn69Rp566zlREOqE7zM35y5yX59fXwnz6O3X7e9+C9zg== dependencies: - assert-plus "^1.0.0" - core-util-is "1.0.2" - extsprintf "^1.2.0" + "@adraffy/ens-normalize" "1.10.0" + "@noble/curves" "1.2.0" + "@noble/hashes" "1.3.2" + "@scure/bip32" "1.3.2" + "@scure/bip39" "1.2.1" + abitype "1.0.0" + isows "1.0.3" + ws "8.13.0" w3c-xmlserializer@^4.0.0: version "4.0.0" @@ -10626,235 +9463,218 @@ wcwidth@^1.0.0, wcwidth@^1.0.1: dependencies: defaults "^1.0.3" -web3-bzz@1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-bzz/-/web3-bzz-1.10.3.tgz" - integrity sha512-XDIRsTwekdBXtFytMpHBuun4cK4x0ZMIDXSoo1UVYp+oMyZj07c7gf7tNQY5qZ/sN+CJIas4ilhN25VJcjSijQ== +web3-core@^4.3.0, web3-core@^4.3.2: + version "4.3.2" + resolved "https://registry.yarnpkg.com/web3-core/-/web3-core-4.3.2.tgz#f24b11d6a57dee527de8d42c89de2a439f0c4bed" + integrity sha512-uIMVd/j4BgOnwfpY8ZT+QKubOyM4xohEhFZXz9xB8wimXWMMlYVlIK/TbfHqFolS9uOerdSGhsMbcK9lETae8g== + dependencies: + web3-errors "^1.1.4" + web3-eth-accounts "^4.1.0" + web3-eth-iban "^4.0.7" + web3-providers-http "^4.1.0" + web3-providers-ws "^4.0.7" + web3-types "^1.3.1" + web3-utils "^4.1.0" + web3-validator "^2.0.3" + optionalDependencies: + web3-providers-ipc "^4.0.7" + +web3-errors@^1.1.3, web3-errors@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/web3-errors/-/web3-errors-1.1.4.tgz#5667a0a5f66fc936e101ef32032ccc1e8ca4d5a1" + integrity sha512-WahtszSqILez+83AxGecVroyZsMuuRT+KmQp4Si5P4Rnqbczno1k748PCrZTS1J4UCPmXMG2/Vt+0Bz2zwXkwQ== dependencies: - "@types/node" "^12.12.6" - got "12.1.0" - swarm-js "^0.1.40" + web3-types "^1.3.1" -web3-core-helpers@1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-core-helpers/-/web3-core-helpers-1.10.3.tgz" - integrity sha512-Yv7dQC3B9ipOc5sWm3VAz1ys70Izfzb8n9rSiQYIPjpqtJM+3V4EeK6ghzNR6CO2es0+Yu9CtCkw0h8gQhrTxA== +web3-eth-abi@^4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/web3-eth-abi/-/web3-eth-abi-4.2.1.tgz#b1260dace8380221f12f4274af240c1dfed1045c" + integrity sha512-IE91WUhhiDpBtbkl/DHUoZz7z7T5FXvl3zPLkrxT+dNlOT+wni+US/67jQCLvJRbqf9ApQ26lVYry0bovFgyqA== dependencies: - web3-eth-iban "1.10.3" - web3-utils "1.10.3" + abitype "0.7.1" + web3-errors "^1.1.4" + web3-types "^1.6.0" + web3-utils "^4.2.3" + web3-validator "^2.0.5" -web3-core-method@1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-core-method/-/web3-core-method-1.10.3.tgz" - integrity sha512-VZ/Dmml4NBmb0ep5PTSg9oqKoBtG0/YoMPei/bq/tUdlhB2dMB79sbeJPwx592uaV0Vpk7VltrrrBv5hTM1y4Q== +web3-eth-accounts@^4.1.0, web3-eth-accounts@^4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/web3-eth-accounts/-/web3-eth-accounts-4.1.2.tgz#652d6e3daf4d6cb3fe67cec6a878e768f6e8b8e8" + integrity sha512-y0JynDeTDnclyuE9mShXLeEj+BCrPHxPHOyPCgTchUBQsALF9+0OhP7WiS3IqUuu0Hle5bjG2f5ddeiPtNEuLg== dependencies: - "@ethersproject/transactions" "^5.6.2" - web3-core-helpers "1.10.3" - web3-core-promievent "1.10.3" - web3-core-subscriptions "1.10.3" - web3-utils "1.10.3" + "@ethereumjs/rlp" "^4.0.1" + crc-32 "^1.2.2" + ethereum-cryptography "^2.0.0" + web3-errors "^1.1.4" + web3-types "^1.6.0" + web3-utils "^4.2.3" + web3-validator "^2.0.5" -web3-core-promievent@1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-core-promievent/-/web3-core-promievent-1.10.3.tgz" - integrity sha512-HgjY+TkuLm5uTwUtaAfkTgRx/NzMxvVradCi02gy17NxDVdg/p6svBHcp037vcNpkuGeFznFJgULP+s2hdVgUQ== +web3-eth-contract@^4.3.0, web3-eth-contract@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/web3-eth-contract/-/web3-eth-contract-4.4.0.tgz#21760ef39ab95b34c55e7eaee316e0632e56cd21" + integrity sha512-pZ/w6Lb6ZDUUs7f5GCKXiHDAGGvt2tdwiHkvgmQTRnq9b0MEsUpteDyPYspHxKzQWLgbeK37jPb8zbQe4kE/Hg== + dependencies: + web3-core "^4.3.2" + web3-errors "^1.1.4" + web3-eth "^4.6.0" + web3-eth-abi "^4.2.1" + web3-types "^1.6.0" + web3-utils "^4.2.3" + web3-validator "^2.0.5" + +web3-eth-ens@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/web3-eth-ens/-/web3-eth-ens-4.2.0.tgz#8734b034efd48a735f7052fef0205653a78b84cb" + integrity sha512-qYj34te2UctoObt8rlEIY/t2MuTMiMiiHhO2JAHRGqSLCQ7b8DM3RpvkiiSB0N0ZyEn+CetZqJCTYb8DNKBS/g== + dependencies: + "@adraffy/ens-normalize" "^1.8.8" + web3-core "^4.3.2" + web3-errors "^1.1.4" + web3-eth "^4.5.0" + web3-eth-contract "^4.3.0" + web3-net "^4.0.7" + web3-types "^1.5.0" + web3-utils "^4.2.2" + web3-validator "^2.0.5" + +web3-eth-iban@^4.0.7: + version "4.0.7" + resolved "https://registry.yarnpkg.com/web3-eth-iban/-/web3-eth-iban-4.0.7.tgz#ee504f845d7b6315f0be78fcf070ccd5d38e4aaf" + integrity sha512-8weKLa9KuKRzibC87vNLdkinpUE30gn0IGY027F8doeJdcPUfsa4IlBgNC4k4HLBembBB2CTU0Kr/HAOqMeYVQ== dependencies: - eventemitter3 "4.0.4" + web3-errors "^1.1.3" + web3-types "^1.3.0" + web3-utils "^4.0.7" + web3-validator "^2.0.3" -web3-core-requestmanager@1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-core-requestmanager/-/web3-core-requestmanager-1.10.3.tgz" - integrity sha512-VT9sKJfgM2yBOIxOXeXiDuFMP4pxzF6FT+y8KTLqhDFHkbG3XRe42Vm97mB/IvLQCJOmokEjl3ps8yP1kbggyw== +web3-eth-personal@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/web3-eth-personal/-/web3-eth-personal-4.0.8.tgz#b51628c560de550ca8b354fa784f9556aae6065c" + integrity sha512-sXeyLKJ7ddQdMxz1BZkAwImjqh7OmKxhXoBNF3isDmD4QDpMIwv/t237S3q4Z0sZQamPa/pHebJRWVuvP8jZdw== dependencies: - util "^0.12.5" - web3-core-helpers "1.10.3" - web3-providers-http "1.10.3" - web3-providers-ipc "1.10.3" - web3-providers-ws "1.10.3" - -web3-core-subscriptions@1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-core-subscriptions/-/web3-core-subscriptions-1.10.3.tgz" - integrity sha512-KW0Mc8sgn70WadZu7RjQ4H5sNDJ5Lx8JMI3BWos+f2rW0foegOCyWhRu33W1s6ntXnqeBUw5rRCXZRlA3z+HNA== - dependencies: - eventemitter3 "4.0.4" - web3-core-helpers "1.10.3" - -web3-core@1.10.3, web3-core@^1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-core/-/web3-core-1.10.3.tgz" - integrity sha512-Vbk0/vUNZxJlz3RFjAhNNt7qTpX8yE3dn3uFxfX5OHbuon5u65YEOd3civ/aQNW745N0vGUlHFNxxmn+sG9DIw== - dependencies: - "@types/bn.js" "^5.1.1" - "@types/node" "^12.12.6" - bignumber.js "^9.0.0" - web3-core-helpers "1.10.3" - web3-core-method "1.10.3" - web3-core-requestmanager "1.10.3" - web3-utils "1.10.3" - -web3-eth-abi@1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.10.3.tgz" - integrity sha512-O8EvV67uhq0OiCMekqYsDtb6FzfYzMXT7VMHowF8HV6qLZXCGTdB/NH4nJrEh2mFtEwVdS6AmLFJAQd2kVyoMQ== - dependencies: - "@ethersproject/abi" "^5.6.3" - web3-utils "1.10.3" - -web3-eth-accounts@1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-eth-accounts/-/web3-eth-accounts-1.10.3.tgz" - integrity sha512-8MipGgwusDVgn7NwKOmpeo3gxzzd+SmwcWeBdpXknuyDiZSQy9tXe+E9LeFGrmys/8mLLYP79n3jSbiTyv+6pQ== - dependencies: - "@ethereumjs/common" "2.6.5" - "@ethereumjs/tx" "3.5.2" - "@ethereumjs/util" "^8.1.0" - eth-lib "0.2.8" - scrypt-js "^3.0.1" - uuid "^9.0.0" - web3-core "1.10.3" - web3-core-helpers "1.10.3" - web3-core-method "1.10.3" - web3-utils "1.10.3" - -web3-eth-contract@1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-eth-contract/-/web3-eth-contract-1.10.3.tgz" - integrity sha512-Y2CW61dCCyY4IoUMD4JsEQWrILX4FJWDWC/Txx/pr3K/+fGsBGvS9kWQN5EsVXOp4g7HoFOfVh9Lf7BmVVSRmg== - dependencies: - "@types/bn.js" "^5.1.1" - web3-core "1.10.3" - web3-core-helpers "1.10.3" - web3-core-method "1.10.3" - web3-core-promievent "1.10.3" - web3-core-subscriptions "1.10.3" - web3-eth-abi "1.10.3" - web3-utils "1.10.3" - -web3-eth-ens@1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-eth-ens/-/web3-eth-ens-1.10.3.tgz" - integrity sha512-hR+odRDXGqKemw1GFniKBEXpjYwLgttTES+bc7BfTeoUyUZXbyDHe5ifC+h+vpzxh4oS0TnfcIoarK0Z9tFSiQ== - dependencies: - content-hash "^2.5.2" - eth-ens-namehash "2.0.8" - web3-core "1.10.3" - web3-core-helpers "1.10.3" - web3-core-promievent "1.10.3" - web3-eth-abi "1.10.3" - web3-eth-contract "1.10.3" - web3-utils "1.10.3" - -web3-eth-iban@1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-eth-iban/-/web3-eth-iban-1.10.3.tgz" - integrity sha512-ZCfOjYKAjaX2TGI8uif5ah+J3BYFuo+47JOIV1RIz2l7kD9VfnxvRH5UiQDRyMALQC7KFd2hUqIEtHklapNyKA== + web3-core "^4.3.0" + web3-eth "^4.3.1" + web3-rpc-methods "^1.1.3" + web3-types "^1.3.0" + web3-utils "^4.0.7" + web3-validator "^2.0.3" + +web3-eth@^4.3.1, web3-eth@^4.5.0, web3-eth@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/web3-eth/-/web3-eth-4.6.0.tgz#75c177e2bde88a613a6996fab515f104e16921da" + integrity sha512-8KtxlGsomovoFULqEpfixgmCpaJ2YIJGxbXUfezh2coXHjVgEopQhARYtKGClyV5kkdCIqwHS8Gvsm6TVNqH6Q== + dependencies: + setimmediate "^1.0.5" + web3-core "^4.3.2" + web3-errors "^1.1.4" + web3-eth-abi "^4.2.1" + web3-eth-accounts "^4.1.2" + web3-net "^4.0.7" + web3-providers-ws "^4.0.7" + web3-rpc-methods "^1.2.0" + web3-types "^1.6.0" + web3-utils "^4.2.3" + web3-validator "^2.0.5" + +web3-net@^4.0.7: + version "4.0.7" + resolved "https://registry.yarnpkg.com/web3-net/-/web3-net-4.0.7.tgz#ed2c1bd700cf94be93a6dbd8bd8aa413d8681942" + integrity sha512-SzEaXFrBjY25iQGk5myaOfO9ZyfTwQEa4l4Ps4HDNVMibgZji3WPzpjq8zomVHMwi8bRp6VV7YS71eEsX7zLow== + dependencies: + web3-core "^4.3.0" + web3-rpc-methods "^1.1.3" + web3-types "^1.3.0" + web3-utils "^4.0.7" + +web3-providers-http@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/web3-providers-http/-/web3-providers-http-4.1.0.tgz#8d7afda67d1d8542ca85b30f60a3d1fe1993b561" + integrity sha512-6qRUGAhJfVQM41E5t+re5IHYmb5hSaLc02BE2MaRQsz2xKA6RjmHpOA5h/+ojJxEpI9NI2CrfDKOAgtJfoUJQg== dependencies: - bn.js "^5.2.1" - web3-utils "1.10.3" - -web3-eth-personal@1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-eth-personal/-/web3-eth-personal-1.10.3.tgz" - integrity sha512-avrQ6yWdADIvuNQcFZXmGLCEzulQa76hUOuVywN7O3cklB4nFc/Gp3yTvD3bOAaE7DhjLQfhUTCzXL7WMxVTsw== - dependencies: - "@types/node" "^12.12.6" - web3-core "1.10.3" - web3-core-helpers "1.10.3" - web3-core-method "1.10.3" - web3-net "1.10.3" - web3-utils "1.10.3" - -web3-eth@1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-eth/-/web3-eth-1.10.3.tgz" - integrity sha512-Uk1U2qGiif2mIG8iKu23/EQJ2ksB1BQXy3wF3RvFuyxt8Ft9OEpmGlO7wOtAyJdoKzD5vcul19bJpPcWSAYZhA== - dependencies: - web3-core "1.10.3" - web3-core-helpers "1.10.3" - web3-core-method "1.10.3" - web3-core-subscriptions "1.10.3" - web3-eth-abi "1.10.3" - web3-eth-accounts "1.10.3" - web3-eth-contract "1.10.3" - web3-eth-ens "1.10.3" - web3-eth-iban "1.10.3" - web3-eth-personal "1.10.3" - web3-net "1.10.3" - web3-utils "1.10.3" - -web3-net@1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-net/-/web3-net-1.10.3.tgz" - integrity sha512-IoSr33235qVoI1vtKssPUigJU9Fc/Ph0T9CgRi15sx+itysmvtlmXMNoyd6Xrgm9LuM4CIhxz7yDzH93B79IFg== - dependencies: - web3-core "1.10.3" - web3-core-method "1.10.3" - web3-utils "1.10.3" - -web3-providers-http@1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-providers-http/-/web3-providers-http-1.10.3.tgz" - integrity sha512-6dAgsHR3MxJ0Qyu3QLFlQEelTapVfWNTu5F45FYh8t7Y03T1/o+YAkVxsbY5AdmD+y5bXG/XPJ4q8tjL6MgZHw== - dependencies: - abortcontroller-polyfill "^1.7.5" cross-fetch "^4.0.0" - es6-promise "^4.2.8" - web3-core-helpers "1.10.3" + web3-errors "^1.1.3" + web3-types "^1.3.0" + web3-utils "^4.0.7" -web3-providers-ipc@1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-providers-ipc/-/web3-providers-ipc-1.10.3.tgz" - integrity sha512-vP5WIGT8FLnGRfswTxNs9rMfS1vCbMezj/zHbBe/zB9GauBRTYVrUo2H/hVrhLg8Ut7AbsKZ+tCJ4mAwpKi2hA== +web3-providers-ipc@^4.0.7: + version "4.0.7" + resolved "https://registry.yarnpkg.com/web3-providers-ipc/-/web3-providers-ipc-4.0.7.tgz#9ec4c8565053af005a5170ba80cddeb40ff3e3d3" + integrity sha512-YbNqY4zUvIaK2MHr1lQFE53/8t/ejHtJchrWn9zVbFMGXlTsOAbNoIoZWROrg1v+hCBvT2c9z8xt7e/+uz5p1g== dependencies: - oboe "2.1.5" - web3-core-helpers "1.10.3" + web3-errors "^1.1.3" + web3-types "^1.3.0" + web3-utils "^4.0.7" -web3-providers-ws@1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-providers-ws/-/web3-providers-ws-1.10.3.tgz" - integrity sha512-/filBXRl48INxsh6AuCcsy4v5ndnTZ/p6bl67kmO9aK1wffv7CT++DrtclDtVMeDGCgB3van+hEf9xTAVXur7Q== +web3-providers-ws@^4.0.7: + version "4.0.7" + resolved "https://registry.yarnpkg.com/web3-providers-ws/-/web3-providers-ws-4.0.7.tgz#7a78a0dcf077e0e802da524fbb37d080b356c14b" + integrity sha512-n4Dal9/rQWjS7d6LjyEPM2R458V8blRm0eLJupDEJOOIBhGYlxw5/4FthZZ/cqB7y/sLVi7K09DdYx2MeRtU5w== dependencies: - eventemitter3 "4.0.4" - web3-core-helpers "1.10.3" - websocket "^1.0.32" + "@types/ws" "8.5.3" + isomorphic-ws "^5.0.0" + web3-errors "^1.1.3" + web3-types "^1.3.0" + web3-utils "^4.0.7" + ws "^8.8.1" -web3-shh@1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-shh/-/web3-shh-1.10.3.tgz" - integrity sha512-cAZ60CPvs9azdwMSQ/PSUdyV4PEtaW5edAZhu3rCXf6XxQRliBboic+AvwUvB6j3eswY50VGa5FygfVmJ1JVng== +web3-rpc-methods@^1.1.3, web3-rpc-methods@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/web3-rpc-methods/-/web3-rpc-methods-1.2.0.tgz#761dcb036ab16edb2b03e80c11e3f5df24690345" + integrity sha512-CWJ/g4I4WyYvLkf21wCZAehdhU/VjX/OAPHnqF5/FPDJlogOsOnGXHqi1Z5AP+ocdt395PNubd8jyMMJoYGSBA== dependencies: - web3-core "1.10.3" - web3-core-method "1.10.3" - web3-core-subscriptions "1.10.3" - web3-net "1.10.3" + web3-core "^4.3.2" + web3-types "^1.5.0" + web3-validator "^2.0.4" + +web3-types@^1.3.0, web3-types@^1.3.1, web3-types@^1.5.0, web3-types@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/web3-types/-/web3-types-1.6.0.tgz#ebe7f140c31f7cc0ad15f238ad7e7ac72797ff3b" + integrity sha512-qgOtADqlD5hw+KPKBUGaXAcdNLL0oh6qTeVgXwewCfbL/lG9R+/GrgMQB1gbTJ3cit8hMwtH8KX2Em6OwO0HRw== -web3-utils@1.10.3, web3-utils@^1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.3.tgz" - integrity sha512-OqcUrEE16fDBbGoQtZXWdavsPzbGIDc5v3VrRTZ0XrIpefC/viZ1ZU9bGEemazyS0catk/3rkOOxpzTfY+XsyQ== +web3-utils@^4.0.7, web3-utils@^4.1.0, web3-utils@^4.2.2, web3-utils@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/web3-utils/-/web3-utils-4.2.3.tgz#e1d30c4b087cd95f4307baeb80e3160f174e1cfd" + integrity sha512-m5plKTC2YtQntHITQRyIePw52UVP1IrShhmA2FACtn4zmc5ADmrXOlQWiPzxFP/18eRJsAaUAw2+CQn1u4WPxQ== dependencies: - "@ethereumjs/util" "^8.1.0" - bn.js "^5.2.1" - ethereum-bloom-filters "^1.0.6" - ethereum-cryptography "^2.1.2" - ethjs-unit "0.1.6" - number-to-bn "1.7.0" - randombytes "^2.1.0" - utf8 "3.0.0" + ethereum-cryptography "^2.0.0" + eventemitter3 "^5.0.1" + web3-errors "^1.1.4" + web3-types "^1.6.0" + web3-validator "^2.0.5" -web3@^1.10.3: - version "1.10.3" - resolved "https://registry.npmjs.org/web3/-/web3-1.10.3.tgz" - integrity sha512-DgUdOOqC/gTqW+VQl1EdPxrVRPB66xVNtuZ5KD4adVBtko87hkgM8BTZ0lZ8IbUfnQk6DyjcDujMiH3oszllAw== +web3-validator@^2.0.3, web3-validator@^2.0.4, web3-validator@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/web3-validator/-/web3-validator-2.0.5.tgz#de1984bdb34f292251b86400dba7169700db0849" + integrity sha512-2gLOSW8XqEN5pw5jVUm20EB7A8SbQiekpAtiI0JBmCIV0a2rp97v8FgWY5E3UEqnw5WFfEqvcDVW92EyynDTyQ== dependencies: - web3-bzz "1.10.3" - web3-core "1.10.3" - web3-eth "1.10.3" - web3-eth-personal "1.10.3" - web3-net "1.10.3" - web3-shh "1.10.3" - web3-utils "1.10.3" + ethereum-cryptography "^2.0.0" + util "^0.12.5" + web3-errors "^1.1.4" + web3-types "^1.5.0" + zod "^3.21.4" + +web3@^4.7.0: + version "4.8.0" + resolved "https://registry.yarnpkg.com/web3/-/web3-4.8.0.tgz#c7c7d2a7616ae387f8b2e3a3e416153a4bff479a" + integrity sha512-kQSF2NlHk8yjS3SRiJW3S+U5ibkEmVRhB4/GYsVwGvdAkFC2b+EIE1Ob7J56OmqW9VBZgkx1+SuWqo5JTIJSYQ== + dependencies: + web3-core "^4.3.2" + web3-errors "^1.1.4" + web3-eth "^4.6.0" + web3-eth-abi "^4.2.1" + web3-eth-accounts "^4.1.2" + web3-eth-contract "^4.4.0" + web3-eth-ens "^4.2.0" + web3-eth-iban "^4.0.7" + web3-eth-personal "^4.0.8" + web3-net "^4.0.7" + web3-providers-http "^4.1.0" + web3-providers-ws "^4.0.7" + web3-rpc-methods "^1.2.0" + web3-types "^1.6.0" + web3-utils "^4.2.3" + web3-validator "^2.0.5" webidl-conversions@^3.0.0: version "3.0.1" @@ -10866,18 +9686,6 @@ webidl-conversions@^7.0.0: resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz" integrity sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g== -websocket@^1.0.32: - version "1.0.34" - resolved "https://registry.npmjs.org/websocket/-/websocket-1.0.34.tgz" - integrity sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ== - dependencies: - bufferutil "^4.0.1" - debug "^2.2.0" - es5-ext "^0.10.50" - typedarray-to-buffer "^3.1.5" - utf-8-validate "^5.0.2" - yaeti "^0.0.6" - whatwg-encoding@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz" @@ -11061,20 +9869,16 @@ ws@7.4.6: resolved "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz" integrity sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A== +ws@8.13.0: + version "8.13.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.13.0.tgz#9a9fb92f93cf41512a0735c8f4dd09b8a1211cd0" + integrity sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA== + ws@8.5.0: version "8.5.0" resolved "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz" integrity sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg== -ws@^3.0.0: - version "3.3.3" - resolved "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz" - integrity sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA== - dependencies: - async-limiter "~1.0.0" - safe-buffer "~5.1.0" - ultron "~1.1.0" - ws@^7.4.6: version "7.5.9" resolved "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz" @@ -11085,41 +9889,16 @@ ws@^8.11.0, ws@^8.5.0: resolved "https://registry.yarnpkg.com/ws/-/ws-8.14.2.tgz#6c249a806eb2db7a20d26d51e7709eab7b2e6c7f" integrity sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g== +ws@^8.8.1: + version "8.16.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.16.0.tgz#d1cd774f36fbc07165066a60e40323eab6446fd4" + integrity sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ== + ws@~8.11.0: version "8.11.0" resolved "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz" integrity sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg== -xhr-request-promise@^0.1.2: - version "0.1.3" - resolved "https://registry.npmjs.org/xhr-request-promise/-/xhr-request-promise-0.1.3.tgz" - integrity sha512-YUBytBsuwgitWtdRzXDDkWAXzhdGB8bYm0sSzMPZT7Z2MBjMSTHFsyCT1yCRATY+XC69DUrQraRAEgcoCRaIPg== - dependencies: - xhr-request "^1.1.0" - -xhr-request@^1.0.1, xhr-request@^1.1.0: - version "1.1.0" - resolved "https://registry.npmjs.org/xhr-request/-/xhr-request-1.1.0.tgz" - integrity sha512-Y7qzEaR3FDtL3fP30k9wO/e+FBnBByZeybKOhASsGP30NIkRAAkKD/sCnLvgEfAIEC1rcmK7YG8f4oEnIrrWzA== - dependencies: - buffer-to-arraybuffer "^0.0.5" - object-assign "^4.1.1" - query-string "^5.0.1" - simple-get "^2.7.0" - timed-out "^4.0.1" - url-set-query "^1.0.0" - xhr "^2.0.4" - -xhr@^2.0.4, xhr@^2.3.3: - version "2.6.0" - resolved "https://registry.npmjs.org/xhr/-/xhr-2.6.0.tgz" - integrity sha512-/eCGLb5rxjx5e3mF1A7s+pLlR6CGyqWN91fv1JgER5mVWg1MZmlhBvy9kjcsOdRk8RrIujotWyJamfyrp+WIcA== - dependencies: - global "~4.4.0" - is-function "^1.0.1" - parse-headers "^2.0.0" - xtend "^4.0.0" - xml-name-validator@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz" @@ -11135,7 +9914,7 @@ xmlhttprequest-ssl@~2.0.0: resolved "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.0.0.tgz" integrity sha512-QKxVRxiRACQcVuQEYFsI1hhkrMlrXHPegbbd1yn9UHOmRxY+si12nQYzri3vbzt8VdTTRviqcKxcyllFas5z2A== -xtend@^4.0.0, xtend@~4.0.1: +xtend@~4.0.1: version "4.0.2" resolved "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz" integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== @@ -11150,12 +9929,7 @@ y18n@^5.0.5: resolved "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz" integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== -yaeti@^0.0.6: - version "0.0.6" - resolved "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz" - integrity sha512-MvQa//+KcZCUkBTIC9blM+CU9J2GzuTytsOUwf2lidtvkx/6gnEp1QvJv34t9vdjhFmha/mUiNDbN0D0mJWdug== - -yallist@^3.0.0, yallist@^3.0.2, yallist@^3.1.1: +yallist@^3.0.2: version "3.1.1" resolved "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz" integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== @@ -11260,3 +10034,8 @@ zksync-web3@^0.14.3: version "0.14.3" resolved "https://registry.npmjs.org/zksync-web3/-/zksync-web3-0.14.3.tgz" integrity sha512-hT72th4AnqyLW1d5Jlv8N2B/qhEnl2NePK2A3org7tAa24niem/UAaHMkEvmWI3SF9waYUPtqAtjpf+yvQ9zvQ== + +zod@^3.21.4: + version "3.22.4" + resolved "https://registry.yarnpkg.com/zod/-/zod-3.22.4.tgz#f31c3a9386f61b1f228af56faa9255e845cf3fff" + integrity sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==