From e825cffa223d0e452ea265d04532643e7519bebe Mon Sep 17 00:00:00 2001 From: Kris Urbas <605420+krzysu@users.noreply.github.com> Date: Fri, 15 Dec 2023 14:57:00 +0100 Subject: [PATCH] chore: remove all ethers5 peer deps --- packages/blockchain-bindings/package.json | 3 - packages/client/package.json | 1 - packages/client/src/LensClient.spec.ts | 2 +- .../client/src/__helpers__/BundlrUploader.ts | 2 +- packages/client/src/__helpers__/setup.ts | 2 +- packages/client/src/gated/__helpers/setup.ts | 2 +- .../src/gated/__tests__/LensClient.spec.ts | 2 +- packages/client/src/types.ts | 2 +- packages/gated-content/package.json | 2 +- packages/react-native/package.json | 1 - packages/react-v1/package.json | 2 - packages/react-web-v1/package.json | 2 - packages/react-web/package.json | 1 - packages/react/package.json | 3 +- .../src/polls/adapters/SnapshotVoteFactory.ts | 2 +- .../__tests__/SnapshotVoteFactory.spec.ts | 2 +- .../adapters/ApproveTransactionGateway.ts | 5 +- .../adapters/Eip1559GasPriceEstimator.ts | 4 +- .../src/wallet/adapters/ConcreteWallet.ts | 24 ++-- .../src/wallet/adapters/IProviderFactory.ts | 4 +- .../src/wallet/adapters/__helpers__/mocks.ts | 7 +- .../wallet/infrastructure/ProviderFactory.ts | 6 +- .../wallet/infrastructure/SignerFactory.ts | 11 +- .../infrastructure/__helpers__/mocks.ts | 5 +- packages/shared-kernel/package.json | 5 +- .../src/crypto/__helpers__/mocks.ts | 4 +- packages/wagmi/package.json | 3 +- packages/wagmi/src/index.ts | 12 +- pnpm-lock.yaml | 110 ++++++++---------- 29 files changed, 101 insertions(+), 130 deletions(-) diff --git a/packages/blockchain-bindings/package.json b/packages/blockchain-bindings/package.json index 59ddae3bfe..9d9439ec67 100644 --- a/packages/blockchain-bindings/package.json +++ b/packages/blockchain-bindings/package.json @@ -61,9 +61,6 @@ "typescript": "5.2.2" }, "prettier": "@lens-protocol/prettier-config", - "peerDependencies": { - "ethers": "^5.7.2" - }, "babel": { "presets": [ "@babel/preset-env", diff --git a/packages/client/package.json b/packages/client/package.json index c0a0e0abd3..c43004cf94 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -89,7 +89,6 @@ "@types/node": "^18.18.12", "dotenv": "^16.3.1", "eslint": "^8.54.0", - "ethers": "^5.7.2", "jest": "^29.7.0", "prettier": "^3.1.0", "ts-jest": "^29.1.1", diff --git a/packages/client/src/LensClient.spec.ts b/packages/client/src/LensClient.spec.ts index 37dfb58b1c..e3fc299c50 100644 --- a/packages/client/src/LensClient.spec.ts +++ b/packages/client/src/LensClient.spec.ts @@ -1,5 +1,5 @@ +import { Wallet } from '@ethersproject/wallet'; import { InMemoryStorageProvider } from '@lens-protocol/storage'; -import { Wallet } from 'ethers'; import { LensClient } from '.'; import { buildTestEnvironment } from './__helpers__'; diff --git a/packages/client/src/__helpers__/BundlrUploader.ts b/packages/client/src/__helpers__/BundlrUploader.ts index 9321dde6f7..1430069baa 100644 --- a/packages/client/src/__helpers__/BundlrUploader.ts +++ b/packages/client/src/__helpers__/BundlrUploader.ts @@ -1,6 +1,6 @@ import { NodeBundlr } from '@bundlr-network/client'; +import { Wallet } from '@ethersproject/wallet'; import { UnknownObject } from '@lens-protocol/shared-kernel'; -import { Wallet } from 'ethers'; export class BundlrUploader { constructor(private readonly signer: Wallet) {} diff --git a/packages/client/src/__helpers__/setup.ts b/packages/client/src/__helpers__/setup.ts index 02d091522e..722b6399ce 100644 --- a/packages/client/src/__helpers__/setup.ts +++ b/packages/client/src/__helpers__/setup.ts @@ -1,5 +1,5 @@ +import { Wallet } from '@ethersproject/wallet'; import { invariant, never, UnknownObject } from '@lens-protocol/shared-kernel'; -import { Wallet } from 'ethers'; import { LensClient } from '../LensClient'; import { ProfileFragment } from '../graphql'; diff --git a/packages/client/src/gated/__helpers/setup.ts b/packages/client/src/gated/__helpers/setup.ts index 1333ae841b..ce357d531f 100644 --- a/packages/client/src/gated/__helpers/setup.ts +++ b/packages/client/src/gated/__helpers/setup.ts @@ -1,4 +1,4 @@ -import { Wallet } from 'ethers'; +import { Wallet } from '@ethersproject/wallet'; import { buildTestEnvironment } from '../../__helpers__'; import { LensClient } from '../LensClient'; diff --git a/packages/client/src/gated/__tests__/LensClient.spec.ts b/packages/client/src/gated/__tests__/LensClient.spec.ts index 831706dd2d..6ec9c8c247 100644 --- a/packages/client/src/gated/__tests__/LensClient.spec.ts +++ b/packages/client/src/gated/__tests__/LensClient.spec.ts @@ -1,8 +1,8 @@ +import { Wallet } from '@ethersproject/wallet'; import { faker } from '@faker-js/faker'; import { isEncryptedPublicationMetadata } from '@lens-protocol/gated-content'; import * as metadata from '@lens-protocol/metadata'; import { invariant } from '@lens-protocol/shared-kernel'; -import { Wallet } from 'ethers'; import { authenticate, diff --git a/packages/client/src/types.ts b/packages/client/src/types.ts index c41ddb7e22..c43e90e1a2 100644 --- a/packages/client/src/types.ts +++ b/packages/client/src/types.ts @@ -1,4 +1,4 @@ -import type { TypedDataDomain, TypedDataField } from 'ethers'; +import type { TypedDataDomain, TypedDataField } from '@ethersproject/abstract-signer'; export type TypedData = { domain: TypedDataDomain; diff --git a/packages/gated-content/package.json b/packages/gated-content/package.json index ce7ac6e693..c09d171013 100644 --- a/packages/gated-content/package.json +++ b/packages/gated-content/package.json @@ -52,7 +52,7 @@ "@lit-protocol/encryption": "2.1.62", "@lit-protocol/node-client": "^2.1.62", "@lit-protocol/types": "2.1.62", - "siwe": "^1.1.6", + "siwe": "^2.1.4", "traverse": "^0.6.7", "tslib": "^2.6.2" }, diff --git a/packages/react-native/package.json b/packages/react-native/package.json index d58813e310..db1e13f480 100644 --- a/packages/react-native/package.json +++ b/packages/react-native/package.json @@ -84,7 +84,6 @@ }, "peerDependencies": { "@types/react": "^18.0.0", - "ethers": "^5.7.2", "react": "~18.2.0", "react-native": "~0.72.7", "react-native-mmkv": "~2.11.0" diff --git a/packages/react-v1/package.json b/packages/react-v1/package.json index 8e60ee16a2..810b4cff54 100644 --- a/packages/react-v1/package.json +++ b/packages/react-v1/package.json @@ -75,7 +75,6 @@ "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", "ethereum-waffle": "^4.0.10", - "ethers": "^5.7.2", "ganache": "7.7.4", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", @@ -88,7 +87,6 @@ "typescript": "5.2.2" }, "peerDependencies": { - "ethers": "^5.7.2", "react": "^18.2.0" }, "prettier": "@lens-protocol/prettier-config", diff --git a/packages/react-web-v1/package.json b/packages/react-web-v1/package.json index ea90439a38..c6b1c58192 100644 --- a/packages/react-web-v1/package.json +++ b/packages/react-web-v1/package.json @@ -60,7 +60,6 @@ "eslint": "^8.54.0", "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", - "ethers": "^5.7.2", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "jest-mock-extended": "^3.0.5", @@ -72,7 +71,6 @@ "typescript": "5.2.2" }, "peerDependencies": { - "ethers": "^5.7.2", "react": "^18.2.0" }, "peerDependenciesMeta": { diff --git a/packages/react-web/package.json b/packages/react-web/package.json index 7b0d2f356c..00d1cde834 100644 --- a/packages/react-web/package.json +++ b/packages/react-web/package.json @@ -86,7 +86,6 @@ "peerDependencies": { "@types/react": "^18.0.0", "@xmtp/react-sdk": "^3.0.0", - "ethers": "^5.7.2", "react": "^18.2.0" }, "peerDependenciesMeta": { diff --git a/packages/react/package.json b/packages/react/package.json index 21fe658a74..17ea67b244 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -51,8 +51,10 @@ "@ethersproject/abstract-signer": "^5.7.0", "@ethersproject/address": "^5.7.0", "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/constants": "^5.7.0", "@ethersproject/contracts": "^5.7.0", "@ethersproject/hash": "^5.7.0", + "@ethersproject/logger": "^5.7.0", "@ethersproject/providers": "^5.7.2", "@ethersproject/wallet": "^5.7.0", "@lens-protocol/api-bindings": "workspace:*", @@ -104,7 +106,6 @@ }, "peerDependencies": { "@types/react": "^18.0.0", - "ethers": "^5.7.2", "react": "^18.2.0" }, "peerDependenciesMeta": { diff --git a/packages/react/src/polls/adapters/SnapshotVoteFactory.ts b/packages/react/src/polls/adapters/SnapshotVoteFactory.ts index d5804cae7b..6b2d7668f2 100644 --- a/packages/react/src/polls/adapters/SnapshotVoteFactory.ts +++ b/packages/react/src/polls/adapters/SnapshotVoteFactory.ts @@ -1,3 +1,4 @@ +import { getAddress } from '@ethersproject/address'; import { SafeApolloClient, GetSnapshotProposalDocument, @@ -15,7 +16,6 @@ import { VoteChoice, } from '@lens-protocol/domain/use-cases/polls'; import { invariant, InvariantError, never } from '@lens-protocol/shared-kernel'; -import { getAddress } from 'ethers/lib/utils'; import { vote2Types, voteArray2Types, voteString2Types } from './types'; diff --git a/packages/react/src/polls/adapters/__tests__/SnapshotVoteFactory.spec.ts b/packages/react/src/polls/adapters/__tests__/SnapshotVoteFactory.spec.ts index 266258489f..24f844be49 100644 --- a/packages/react/src/polls/adapters/__tests__/SnapshotVoteFactory.spec.ts +++ b/packages/react/src/polls/adapters/__tests__/SnapshotVoteFactory.spec.ts @@ -1,3 +1,4 @@ +import { getAddress } from '@ethersproject/address'; import { SnapshotProposal, SnapshotSpaceId, @@ -12,7 +13,6 @@ import { AppId, PollId } from '@lens-protocol/domain/entities'; import { mockAppId, mockCreateUnsignedVoteRequest, mockWallet } from '@lens-protocol/domain/mocks'; import { InvariantError, never } from '@lens-protocol/shared-kernel'; import { mockEvmAddress } from '@lens-protocol/shared-kernel/mocks'; -import { getAddress } from 'ethers/lib/utils'; import { SnapshotVoteFactory, UnsignedVote } from '../SnapshotVoteFactory'; import { vote2Types, voteArray2Types, voteString2Types } from '../types'; diff --git a/packages/react/src/transactions/adapters/ApproveTransactionGateway.ts b/packages/react/src/transactions/adapters/ApproveTransactionGateway.ts index 1c17bf447e..86415a2a80 100644 --- a/packages/react/src/transactions/adapters/ApproveTransactionGateway.ts +++ b/packages/react/src/transactions/adapters/ApproveTransactionGateway.ts @@ -1,3 +1,5 @@ +import { BigNumber } from '@ethersproject/bignumber'; +import { MaxUint256 } from '@ethersproject/constants'; import { erc20, bigNumber } from '@lens-protocol/blockchain-bindings'; import { IPaidTransactionGateway, @@ -5,7 +7,6 @@ import { TokenAllowanceRequest, } from '@lens-protocol/domain/use-cases/transactions'; import { Amount, BigDecimal, CryptoNativeAsset, Data } from '@lens-protocol/shared-kernel'; -import { BigNumber, constants } from 'ethers'; import { AbstractContractCallGateway, ContractCallDetails } from './AbstractContractCallGateway'; @@ -18,7 +19,7 @@ function resolveApproveAmount(request: TokenAllowanceRequest): BigNumber { case TokenAllowanceLimit.EXACT: return bigNumber(request.amount); case TokenAllowanceLimit.INFINITE: - return constants.MaxUint256; + return MaxUint256; } } diff --git a/packages/react/src/transactions/adapters/Eip1559GasPriceEstimator.ts b/packages/react/src/transactions/adapters/Eip1559GasPriceEstimator.ts index 79e5c9a7ed..09529b70c1 100644 --- a/packages/react/src/transactions/adapters/Eip1559GasPriceEstimator.ts +++ b/packages/react/src/transactions/adapters/Eip1559GasPriceEstimator.ts @@ -1,3 +1,4 @@ +import { JsonRpcProvider } from '@ethersproject/providers'; import { FeeHistoryResult } from '@lens-protocol/blockchain-bindings'; import { Amount, @@ -6,7 +7,6 @@ import { Denomination, never, } from '@lens-protocol/shared-kernel'; -import { providers } from 'ethers'; export class Eip1559GasPriceEstimate { constructor(readonly baseFee: Amount, readonly maxPriorityFeePerGas: Amount) {} @@ -92,7 +92,7 @@ export type CryptoNativeAmountFactory = ( export class Eip1559GasPriceEstimator { constructor( - private readonly provider: providers.JsonRpcProvider, + private readonly provider: JsonRpcProvider, private readonly createAmount: CryptoNativeAmountFactory, ) {} diff --git a/packages/react/src/wallet/adapters/ConcreteWallet.ts b/packages/react/src/wallet/adapters/ConcreteWallet.ts index 6e9033ca05..106fc9b29c 100644 --- a/packages/react/src/wallet/adapters/ConcreteWallet.ts +++ b/packages/react/src/wallet/adapters/ConcreteWallet.ts @@ -1,4 +1,6 @@ -import { TypedDataSigner } from '@ethersproject/abstract-signer'; +import { TypedDataSigner, Signer } from '@ethersproject/abstract-signer'; +import { getAddress } from '@ethersproject/address'; +import { ErrorCode } from '@ethersproject/logger'; import { TransactionRequest } from '@ethersproject/providers'; import { TypedData } from '@lens-protocol/blockchain-bindings'; import { @@ -27,8 +29,6 @@ import { PromiseResult, success, } from '@lens-protocol/shared-kernel'; -import { errors, Signer } from 'ethers'; -import { getAddress } from 'ethers/lib/utils'; import { z } from 'zod'; import { UnsignedVote } from '../../polls/adapters/SnapshotVoteFactory'; @@ -159,9 +159,9 @@ export class ConcreteWallet extends Wallet { const signedCall = SignedProtocolCall.create({ unsignedCall, signature }); return success(signedCall); } catch (err) { - assertErrorObjectWithCode(err); + assertErrorObjectWithCode(err); - if (err.code === errors.ACTION_REJECTED) { + if (err.code === ErrorCode.ACTION_REJECTED) { return failure(new UserRejectedError()); } @@ -195,9 +195,9 @@ export class ConcreteWallet extends Wallet { const signature = await signer.signMessage(message); return success(signature as Signature); } catch (err) { - assertErrorObjectWithCode(err); + assertErrorObjectWithCode(err); - if (err.code === errors.ACTION_REJECTED) { + if (err.code === ErrorCode.ACTION_REJECTED) { return failure(new UserRejectedError()); } throw err; @@ -239,12 +239,12 @@ export class ConcreteWallet extends Wallet { return success(transaction); } catch (err) { - assertErrorObjectWithCode(err); + assertErrorObjectWithCode(err); switch (err.code) { - case errors.ACTION_REJECTED: + case ErrorCode.ACTION_REJECTED: return failure(new UserRejectedError(err.message)); - case errors.INSUFFICIENT_FUNDS: + case ErrorCode.INSUFFICIENT_FUNDS: return failure(new InsufficientGasError(matic())); } @@ -289,9 +289,9 @@ export class ConcreteWallet extends Wallet { ); return success(signedVote); } catch (err) { - assertErrorObjectWithCode(err); + assertErrorObjectWithCode(err); - if (err.code === errors.ACTION_REJECTED) { + if (err.code === ErrorCode.ACTION_REJECTED) { return failure(new UserRejectedError()); } throw err; diff --git a/packages/react/src/wallet/adapters/IProviderFactory.ts b/packages/react/src/wallet/adapters/IProviderFactory.ts index 8a6f19b32c..ffa35ad58b 100644 --- a/packages/react/src/wallet/adapters/IProviderFactory.ts +++ b/packages/react/src/wallet/adapters/IProviderFactory.ts @@ -1,10 +1,10 @@ +import { JsonRpcProvider } from '@ethersproject/providers'; import { ChainType } from '@lens-protocol/shared-kernel'; -import { providers } from 'ethers'; export type CreateProviderConfig = { chainType: ChainType; }; export interface IProviderFactory { - createProvider(config: CreateProviderConfig): Promise; + createProvider(config: CreateProviderConfig): Promise; } diff --git a/packages/react/src/wallet/adapters/__helpers__/mocks.ts b/packages/react/src/wallet/adapters/__helpers__/mocks.ts index 924a2e3cab..7f260cc1d6 100644 --- a/packages/react/src/wallet/adapters/__helpers__/mocks.ts +++ b/packages/react/src/wallet/adapters/__helpers__/mocks.ts @@ -1,4 +1,4 @@ -import { TransactionRequest } from '@ethersproject/providers'; +import { TransactionRequest, JsonRpcProvider, JsonRpcSigner } from '@ethersproject/providers'; import { faker } from '@faker-js/faker'; import { TypedData } from '@lens-protocol/blockchain-bindings'; import { @@ -15,7 +15,6 @@ import { } from '@lens-protocol/domain/mocks'; import { ChainType, EvmAddress, Result } from '@lens-protocol/shared-kernel'; import { mockEvmAddress } from '@lens-protocol/shared-kernel/mocks'; -import { providers } from 'ethers'; import { mock } from 'jest-mock-extended'; import { when } from 'jest-when'; @@ -95,7 +94,7 @@ export function mockUnsignedTransactionRequest({ type MockedISignerFactoryConfig = { address: EvmAddress; chainType?: ChainType; - signerResult: Result; + signerResult: Result; }; export function mockISignerFactory({ @@ -118,7 +117,7 @@ export function mockSignedVote(): SignedVote { type MockedIProviderFactoryConfig = { chainType: ChainType; - provider: providers.JsonRpcProvider; + provider: JsonRpcProvider; }; export function mockIProviderFactory({ diff --git a/packages/react/src/wallet/infrastructure/ProviderFactory.ts b/packages/react/src/wallet/infrastructure/ProviderFactory.ts index ab45116891..86768f112e 100644 --- a/packages/react/src/wallet/infrastructure/ProviderFactory.ts +++ b/packages/react/src/wallet/infrastructure/ProviderFactory.ts @@ -1,10 +1,10 @@ +import { JsonRpcProvider } from '@ethersproject/providers'; import { ChainType, invariant, never } from '@lens-protocol/shared-kernel'; -import { providers } from 'ethers'; import { ChainConfigRegistry } from '../../chains'; import { IProviderFactory } from '../adapters/IProviderFactory'; -export type GetProvider = (config: { chainId: number }) => Promise; +export type GetProvider = (config: { chainId: number }) => Promise; export interface IProviderBinding { getProvider: GetProvider; @@ -16,7 +16,7 @@ export class ProviderFactory implements IProviderFactory { private readonly chains: ChainConfigRegistry, ) {} - async createProvider(config: { chainType: ChainType }): Promise { + async createProvider(config: { chainType: ChainType }): Promise { const chainId = this.chains[config.chainType]?.chainId ?? never('Unable to determine chainId'); const provider = await this.bindings.getProvider({ chainId }); diff --git a/packages/react/src/wallet/infrastructure/SignerFactory.ts b/packages/react/src/wallet/infrastructure/SignerFactory.ts index ad63da6f4f..211e29b42c 100644 --- a/packages/react/src/wallet/infrastructure/SignerFactory.ts +++ b/packages/react/src/wallet/infrastructure/SignerFactory.ts @@ -1,8 +1,9 @@ +import { hexValue } from '@ethersproject/bytes'; +import { ErrorCode } from '@ethersproject/logger'; import { JsonRpcProvider } from '@ethersproject/providers'; import { AddEthereumChainParameter, isTheSameAddress } from '@lens-protocol/blockchain-bindings'; import { WalletConnectionError, WalletConnectionErrorReason } from '@lens-protocol/domain/entities'; import { ChainType, failure, PromiseResult, success } from '@lens-protocol/shared-kernel'; -import { errors, utils } from 'ethers'; import { ChainConfigRegistry } from '../../chains'; import { CreateSignerConfig, ISignerFactory, RequiredSigner } from '../adapters/ConcreteWallet'; @@ -54,9 +55,9 @@ export class SignerFactory implements ISignerFactory { } } } catch (err) { - assertErrorObjectWithCode(err); + assertErrorObjectWithCode(err); - if (err.code === errors.UNSUPPORTED_OPERATION) { + if (err.code === ErrorCode.UNSUPPORTED_OPERATION) { return failure(new WalletConnectionError(WalletConnectionErrorReason.INCORRECT_CHAIN)); } } @@ -67,7 +68,7 @@ export class SignerFactory implements ISignerFactory { private createAddEthereumChainParameter(chainType: ChainType): AddEthereumChainParameter { const chainConfig = this.chains[chainType]; return { - chainId: utils.hexValue(chainConfig.chainId), + chainId: hexValue(chainConfig.chainId), chainName: chainConfig.name, nativeCurrency: { name: chainConfig.nativeCurrency.name, @@ -96,7 +97,7 @@ export class SignerFactory implements ISignerFactory { try { if (signer.provider && signer.provider instanceof JsonRpcProvider) { await signer.provider.send('wallet_switchEthereumChain', [ - { chainId: utils.hexValue(chainConfig.chainId) }, + { chainId: hexValue(chainConfig.chainId) }, ]); return success(); diff --git a/packages/react/src/wallet/infrastructure/__helpers__/mocks.ts b/packages/react/src/wallet/infrastructure/__helpers__/mocks.ts index 864f88c792..b67f694c7e 100644 --- a/packages/react/src/wallet/infrastructure/__helpers__/mocks.ts +++ b/packages/react/src/wallet/infrastructure/__helpers__/mocks.ts @@ -1,6 +1,5 @@ -import { Networkish } from '@ethersproject/providers'; +import { Networkish, JsonRpcProvider } from '@ethersproject/providers'; import { ChainType } from '@lens-protocol/shared-kernel'; -import { providers } from 'ethers'; import { mock } from 'jest-mock-extended'; import { when } from 'jest-when'; @@ -8,7 +7,7 @@ import { production } from '../../../environments'; import { RequiredSigner } from '../../adapters/ConcreteWallet'; import { ISignerBinding } from '../SignerFactory'; -export class VoidJsonRpcProvider extends providers.JsonRpcProvider { +export class VoidJsonRpcProvider extends JsonRpcProvider { constructor(network: Networkish) { super('', network); this.send = jest.fn(); diff --git a/packages/shared-kernel/package.json b/packages/shared-kernel/package.json index db23bb30d6..026e3c408a 100644 --- a/packages/shared-kernel/package.json +++ b/packages/shared-kernel/package.json @@ -46,6 +46,7 @@ "@babel/core": "^7.23.3", "@babel/preset-env": "^7.23.3", "@babel/preset-typescript": "^7.23.3", + "@ethersproject/address": "^5.7.0", "@lens-protocol/eslint-config": "workspace:*", "@lens-protocol/prettier-config": "workspace:*", "@lens-protocol/tsconfig": "workspace:*", @@ -53,15 +54,11 @@ "@types/lodash": "^4.14.202", "@types/uuid": "^9.0.7", "eslint": "^8.54.0", - "ethers": "^5.7.2", "jest": "^29.7.0", "prettier": "^2.8.8", "ts-jest": "^29.1.1", "typescript": "5.2.2" }, - "peerDependencies": { - "ethers": "^5.7.2" - }, "peerDependenciesMeta": { "ethers": { "optional": true diff --git a/packages/shared-kernel/src/crypto/__helpers__/mocks.ts b/packages/shared-kernel/src/crypto/__helpers__/mocks.ts index baf17cb52b..127e255186 100644 --- a/packages/shared-kernel/src/crypto/__helpers__/mocks.ts +++ b/packages/shared-kernel/src/crypto/__helpers__/mocks.ts @@ -1,4 +1,4 @@ -import { utils } from 'ethers'; +import { getAddress } from '@ethersproject/address'; import { Amount, Denomination } from '../Amount'; import { erc20, Erc20 } from '../Asset'; @@ -17,7 +17,7 @@ export function mockUint256HexString() { } export function mockEvmAddress(): EvmAddress { - return utils.getAddress(`0x${genRanHex(20 * 2)}`); + return getAddress(`0x${genRanHex(20 * 2)}`); } export function mockEtherAmount(value: number | string) { diff --git a/packages/wagmi/package.json b/packages/wagmi/package.json index 90dac943dd..09166afe7a 100644 --- a/packages/wagmi/package.json +++ b/packages/wagmi/package.json @@ -32,6 +32,7 @@ }, "license": "MIT", "dependencies": { + "@ethersproject/providers": "^5.7.2", "@lens-protocol/shared-kernel": "workspace:*" }, "devDependencies": { @@ -43,7 +44,6 @@ "@lens-protocol/react-web": "workspace:*", "@lens-protocol/tsconfig": "workspace:*", "@types/node": "^18.18.12", - "ethers": "^5.7.2", "prettier": "^2.8.8", "react": "^18.2.0", "react-dom": "^18.2.0", @@ -53,7 +53,6 @@ }, "peerDependencies": { "@lens-protocol/react-web": "workspace:*", - "ethers": "^5.7.2", "viem": "^1.19.5", "wagmi": "^1.4.7" }, diff --git a/packages/wagmi/src/index.ts b/packages/wagmi/src/index.ts index 0718ae4d92..f7eae7d76d 100644 --- a/packages/wagmi/src/index.ts +++ b/packages/wagmi/src/index.ts @@ -1,6 +1,6 @@ +import { JsonRpcProvider, JsonRpcSigner, Web3Provider } from '@ethersproject/providers'; import { IBindings } from '@lens-protocol/react-web'; import { invariant } from '@lens-protocol/shared-kernel'; -import { providers } from 'ethers'; import { PublicClient, WalletClient } from 'wagmi'; import { getPublicClient, getWalletClient } from 'wagmi/actions'; @@ -8,21 +8,19 @@ function providerFromPublicClient({ publicClient, }: { publicClient: PublicClient; -}): providers.JsonRpcProvider { +}): JsonRpcProvider { const { chain, transport } = publicClient; const network = { chainId: chain.id, name: chain.name, ensAddress: chain.contracts?.ensRegistry?.address, }; - return new providers.Web3Provider(transport, network); + return new Web3Provider(transport, network); } -async function signerFromWalletClient( - walletClient: WalletClient, -): Promise { +async function signerFromWalletClient(walletClient: WalletClient): Promise { const { account, transport } = walletClient; - const provider = new providers.Web3Provider(transport, 'any'); + const provider = new Web3Provider(transport, 'any'); const signer = provider.getSigner(account.address); return signer; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7666519cc4..43f7b1631d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -162,7 +162,7 @@ importers: version: link:../../packages/client '@lens-protocol/metadata': specifier: ^1.0.5 - version: 1.0.5 + version: 1.0.5(zod@3.22.4) '@lens-protocol/react-web': specifier: workspace:* version: link:../../packages/react-web @@ -597,9 +597,6 @@ importers: eslint: specifier: ^8.54.0 version: 8.54.0 - ethers: - specifier: ^5.7.2 - version: 5.7.2 jest: specifier: ^29.7.0 version: 29.7.0(@types/node@18.18.12) @@ -732,8 +729,8 @@ importers: specifier: 2.1.62 version: 2.1.62 siwe: - specifier: ^1.1.6 - version: 1.1.6(ethers@5.7.2) + specifier: ^2.1.4 + version: 2.1.4(ethers@5.7.2) traverse: specifier: ^0.6.7 version: 0.6.7 @@ -861,12 +858,18 @@ importers: '@ethersproject/bignumber': specifier: ^5.7.0 version: 5.7.0 + '@ethersproject/constants': + specifier: ^5.7.0 + version: 5.7.0 '@ethersproject/contracts': specifier: ^5.7.0 version: 5.7.0 '@ethersproject/hash': specifier: ^5.7.0 version: 5.7.0 + '@ethersproject/logger': + specifier: ^5.7.0 + version: 5.7.0 '@ethersproject/providers': specifier: ^5.7.2 version: 5.7.2 @@ -1212,9 +1215,6 @@ importers: ethereum-waffle: specifier: ^4.0.10 version: 4.0.10(@ensdomains/ens@0.4.4)(@ensdomains/resolver@0.2.4)(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typescript@5.2.2) - ethers: - specifier: ^5.7.2 - version: 5.7.2 ganache: specifier: 7.7.4 version: 7.7.4 @@ -1344,22 +1344,22 @@ importers: dependencies: '@lens-protocol/api-bindings': specifier: 0.10.1 - version: 0.10.1(ethers@5.7.2)(jest-mock-extended@3.0.5)(jest-when@3.6.0)(react-dom@18.2.0)(react@18.2.0) + version: 0.10.1(jest-mock-extended@3.0.5)(jest-when@3.6.0)(react-dom@18.2.0)(react@18.2.0) '@lens-protocol/domain': specifier: 0.10.1 version: 0.10.1(ethers@5.7.2)(jest-mock-extended@3.0.5)(jest-when@3.6.0) '@lens-protocol/gated-content': specifier: 0.3.3 - version: 0.3.3(@ethersproject/providers@5.7.2)(@types/react@18.2.38)(ethers@5.7.2)(jest-mock-extended@3.0.5)(jest-when@3.6.0)(react-dom@18.2.0)(react@18.2.0)(zod@3.22.4) + version: 0.3.3(@ethersproject/providers@5.7.2)(@types/react@18.2.38)(jest-mock-extended@3.0.5)(jest-when@3.6.0)(react-dom@18.2.0)(react@18.2.0)(zod@3.22.4) '@lens-protocol/react': specifier: 1.3.1 - version: 1.3.1(@types/react@18.2.38)(ethers@5.7.2)(jest-mock-extended@3.0.5)(jest-when@3.6.0)(react-dom@18.2.0)(react@18.2.0) + version: 1.3.1(@types/react@18.2.38)(jest-mock-extended@3.0.5)(jest-when@3.6.0)(react-dom@18.2.0)(react@18.2.0) '@lens-protocol/shared-kernel': specifier: 0.10.0 version: 0.10.0(ethers@5.7.2) '@lens-protocol/storage': specifier: 0.7.4 - version: 0.7.4(ethers@5.7.2) + version: 0.7.4 tslib: specifier: ^2.6.2 version: 2.6.2 @@ -1406,9 +1406,6 @@ importers: eslint-plugin-react-hooks: specifier: ^4.6.0 version: 4.6.0(eslint@8.54.0) - ethers: - specifier: ^5.7.2 - version: 5.7.2 jest: specifier: ^29.7.0 version: 29.7.0(@types/node@18.18.12) @@ -1458,6 +1455,9 @@ importers: '@babel/preset-typescript': specifier: ^7.23.3 version: 7.23.3(@babel/core@7.23.3) + '@ethersproject/address': + specifier: ^5.7.0 + version: 5.7.0 '@lens-protocol/eslint-config': specifier: workspace:* version: link:../eslint-config @@ -1479,9 +1479,6 @@ importers: eslint: specifier: ^8.54.0 version: 8.54.0 - ethers: - specifier: ^5.7.2 - version: 5.7.2 jest: specifier: ^29.7.0 version: 29.7.0(@types/node@18.18.12) @@ -1551,6 +1548,9 @@ importers: packages/wagmi: dependencies: + '@ethersproject/providers': + specifier: ^5.7.2 + version: 5.7.2 '@lens-protocol/shared-kernel': specifier: workspace:* version: link:../shared-kernel @@ -1579,9 +1579,6 @@ importers: '@types/node': specifier: ^18.18.12 version: 18.18.12 - ethers: - specifier: ^5.7.2 - version: 5.7.2 prettier: specifier: ^2.8.8 version: 2.8.8 @@ -5753,7 +5750,7 @@ packages: '@jridgewell/sourcemap-codec': 1.4.15 dev: true - /@lens-protocol/api-bindings@0.10.1(ethers@5.7.2)(jest-mock-extended@3.0.5)(jest-when@3.6.0)(react-dom@18.2.0)(react@18.2.0): + /@lens-protocol/api-bindings@0.10.1(jest-mock-extended@3.0.5)(jest-when@3.6.0)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-0tbJJLl1FgxUeFqh9RpIf53teTq3wxid4ZBJA3SyPTQHqhpFs0TpM99gw7T48Jk0dKaGZTkyyiU4Z+0jXaOH7g==} peerDependencies: '@faker-js/faker': ^7.6.0 @@ -5780,10 +5777,8 @@ packages: - wait-for-expect dev: false - /@lens-protocol/blockchain-bindings@0.9.2(ethers@5.7.2)(jest-mock-extended@3.0.5)(jest-when@3.6.0): + /@lens-protocol/blockchain-bindings@0.9.2(jest-mock-extended@3.0.5)(jest-when@3.6.0): resolution: {integrity: sha512-3MIg7ymBsqMQjJQLZNsQ0IwUAm3fZkvOK6T/96t8FT1J3erJuL0+NUgP211qhbsEsyjuhl3GsgOO6ARX281cKA==} - peerDependencies: - ethers: ^5.7.2 || 5.7.2 dependencies: '@ethersproject/abi': 5.7.0 '@ethersproject/providers': 5.7.2 @@ -5829,7 +5824,7 @@ packages: - ethers dev: false - /@lens-protocol/gated-content@0.3.3(@ethersproject/providers@5.7.2)(@types/react@18.2.38)(ethers@5.7.2)(jest-mock-extended@3.0.5)(jest-when@3.6.0)(react-dom@18.2.0)(react@18.2.0)(zod@3.22.4): + /@lens-protocol/gated-content@0.3.3(@ethersproject/providers@5.7.2)(@types/react@18.2.38)(jest-mock-extended@3.0.5)(jest-when@3.6.0)(react-dom@18.2.0)(react@18.2.0)(zod@3.22.4): resolution: {integrity: sha512-mamBOBOojBr8Yy8Msy7W7GuEmrMuBG0d6Y3h2yu9Mkvvkg01hweTzdbrUHMwVebdPWs4YC7uHDhZHAaFDPGgmg==} peerDependencies: '@ethersproject/contracts': ^5.7.0 @@ -5842,17 +5837,16 @@ packages: '@ethersproject/address': 5.7.0 '@ethersproject/bignumber': 5.7.0 '@ethersproject/providers': 5.7.2 - '@lens-protocol/api-bindings': 0.10.1(ethers@5.7.2)(jest-mock-extended@3.0.5)(jest-when@3.6.0)(react-dom@18.2.0)(react@18.2.0) + '@lens-protocol/api-bindings': 0.10.1(jest-mock-extended@3.0.5)(jest-when@3.6.0)(react-dom@18.2.0)(react@18.2.0) '@lens-protocol/domain': 0.10.1(ethers@5.7.2)(jest-mock-extended@3.0.5)(jest-when@3.6.0) '@lens-protocol/shared-kernel': 0.10.0(ethers@5.7.2) - '@lens-protocol/storage': 0.7.4(ethers@5.7.2) + '@lens-protocol/storage': 0.7.4 '@lit-protocol/constants': 2.1.62 '@lit-protocol/crypto': 2.1.62 '@lit-protocol/encryption': 2.1.62 '@lit-protocol/node-client': 2.1.62(@ethersproject/providers@5.7.2)(@types/react@18.2.38)(react@18.2.0) '@lit-protocol/types': 2.1.62 - ethers: 5.7.2 - siwe: 1.1.6(ethers@5.7.2) + siwe: 1.1.6 tslib: 2.6.2 zod: 3.22.4 transitivePeerDependencies: @@ -5884,18 +5878,6 @@ packages: - wait-for-expect dev: false - /@lens-protocol/metadata@1.0.5: - resolution: {integrity: sha512-ZRy4rg6QlYe8d4FlpEMHAHJGQaAsxrf4BSps3XspBkTkiOx0rBTn0aMxLxPndJ7IJFoSj425xmg6wRbdcdewrg==} - engines: {node: ^v18.12.1} - peerDependencies: - zod: ^3.22.3 - peerDependenciesMeta: - zod: - optional: true - dependencies: - uuid: 9.0.1 - dev: false - /@lens-protocol/metadata@1.0.5(zod@3.22.4): resolution: {integrity: sha512-ZRy4rg6QlYe8d4FlpEMHAHJGQaAsxrf4BSps3XspBkTkiOx0rBTn0aMxLxPndJ7IJFoSj425xmg6wRbdcdewrg==} engines: {node: ^v18.12.1} @@ -5908,7 +5890,7 @@ packages: uuid: 9.0.1 zod: 3.22.4 - /@lens-protocol/react@1.3.1(@types/react@18.2.38)(ethers@5.7.2)(jest-mock-extended@3.0.5)(jest-when@3.6.0)(react-dom@18.2.0)(react@18.2.0): + /@lens-protocol/react@1.3.1(@types/react@18.2.38)(jest-mock-extended@3.0.5)(jest-when@3.6.0)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-2mFHPHKK2c4860eTClj3sB3fk0jAzvCQGJkQhtyebhsg59E4VdZEZwQXJH9l4/sf+qWnC6Ya/dpUvugRiNaBAg==} peerDependencies: ethers: ^5.7.2 || 5.7.2 @@ -5917,13 +5899,12 @@ packages: '@apollo/client': 3.8.7(graphql@16.8.1)(react-dom@18.2.0)(react@18.2.0) '@ethersproject/abstract-signer': 5.7.0 '@ethersproject/providers': 5.7.2 - '@lens-protocol/api-bindings': 0.10.1(ethers@5.7.2)(jest-mock-extended@3.0.5)(jest-when@3.6.0)(react-dom@18.2.0)(react@18.2.0) - '@lens-protocol/blockchain-bindings': 0.9.2(ethers@5.7.2)(jest-mock-extended@3.0.5)(jest-when@3.6.0) + '@lens-protocol/api-bindings': 0.10.1(jest-mock-extended@3.0.5)(jest-when@3.6.0)(react-dom@18.2.0)(react@18.2.0) + '@lens-protocol/blockchain-bindings': 0.9.2(jest-mock-extended@3.0.5)(jest-when@3.6.0) '@lens-protocol/domain': 0.10.1(ethers@5.7.2)(jest-mock-extended@3.0.5)(jest-when@3.6.0) - '@lens-protocol/gated-content': 0.3.3(@ethersproject/providers@5.7.2)(@types/react@18.2.38)(ethers@5.7.2)(jest-mock-extended@3.0.5)(jest-when@3.6.0)(react-dom@18.2.0)(react@18.2.0)(zod@3.22.4) + '@lens-protocol/gated-content': 0.3.3(@ethersproject/providers@5.7.2)(@types/react@18.2.38)(jest-mock-extended@3.0.5)(jest-when@3.6.0)(react-dom@18.2.0)(react@18.2.0)(zod@3.22.4) '@lens-protocol/shared-kernel': 0.10.0(ethers@5.7.2) - '@lens-protocol/storage': 0.7.4(ethers@5.7.2) - ethers: 5.7.2 + '@lens-protocol/storage': 0.7.4 graphql: 16.8.1 jwt-decode: 3.1.2 lodash: 4.17.21 @@ -5977,7 +5958,7 @@ packages: uuid: 9.0.1 dev: false - /@lens-protocol/storage@0.7.4(ethers@5.7.2): + /@lens-protocol/storage@0.7.4: resolution: {integrity: sha512-ezr44IhhcF3OEgJrqCmeOUX1p+UMYhU1sv6ua8AqbpTJZT33nPhXbyiXOYjtPTXi2VZJZPBpKU8rpkixrEgXTA==} dependencies: '@lens-protocol/shared-kernel': 0.10.0(ethers@5.7.2) @@ -9424,7 +9405,7 @@ packages: optionalDependencies: '@randlabs/myalgo-connect': 1.4.2 algosdk: 1.24.1 - arweave-stream-tx: 1.2.2 + arweave-stream-tx: 1.2.2(arweave@1.11.8) multistream: 4.1.0 tmp-promise: 3.0.3 transitivePeerDependencies: @@ -9611,16 +9592,6 @@ packages: engines: {node: '>=0.10.0'} dev: true - /arweave-stream-tx@1.2.2: - resolution: {integrity: sha512-bNt9rj0hbAEzoUZEF2s6WJbIz8nasZlZpxIw03Xm8fzb9gRiiZlZGW3lxQLjfc9Z0VRUWDzwtqoYeEoB/JDToQ==} - requiresBuild: true - peerDependencies: - arweave: ^1.10.0 - dependencies: - exponential-backoff: 3.1.1 - dev: false - optional: true - /arweave-stream-tx@1.2.2(arweave@1.11.8): resolution: {integrity: sha512-bNt9rj0hbAEzoUZEF2s6WJbIz8nasZlZpxIw03Xm8fzb9gRiiZlZGW3lxQLjfc9Z0VRUWDzwtqoYeEoB/JDToQ==} requiresBuild: true @@ -18625,7 +18596,7 @@ packages: /sisteransi@1.0.5: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} - /siwe@1.1.6(ethers@5.7.2): + /siwe@1.1.6: resolution: {integrity: sha512-3WRdEil32Tc2vuNzqJ2/Z/MIvsvy0Nkzc2ov+QujmpHO7tM83dgcb47z0Pu236T4JQkOQCqQkq3AJ/rVIezniA==} peerDependencies: ethers: 5.5.1 || 5.7.2 @@ -18633,7 +18604,18 @@ packages: '@spruceid/siwe-parser': 1.1.3 '@stablelib/random': 1.0.2 apg-js: 4.2.1 + dev: false + + /siwe@2.1.4(ethers@5.7.2): + resolution: {integrity: sha512-Dke1Qqa3mgiLm3vjqw/+SQ7dl8WV/Pfk3AlQBF94cBFydTYhztngqYrikzE3X5UTsJ6565dfVbQptszsuYZNYg==} + peerDependencies: + ethers: ^5.6.8 || ^6.0.8 || 5.7.2 + dependencies: + '@spruceid/siwe-parser': 1.1.3 + '@stablelib/random': 1.0.2 ethers: 5.7.2 + uri-js: 4.4.1 + valid-url: 1.0.9 dev: false /slash@3.0.0: @@ -20217,6 +20199,10 @@ packages: '@types/istanbul-lib-coverage': 2.0.6 convert-source-map: 2.0.0 + /valid-url@1.0.9: + resolution: {integrity: sha512-QQDsV8OnSf5Uc30CKSwG9lnhMPe6exHtTXLRYX8uMwKENy640pU+2BgBL0LRbDh/eYRahNCS7aewCx0wf3NYVA==} + dev: false + /validate-npm-package-license@3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} dependencies: