Skip to content

Commit

Permalink
chore: remove all ethers5 peer deps
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysu committed Dec 15, 2023
1 parent d3a85d1 commit e825cff
Show file tree
Hide file tree
Showing 29 changed files with 101 additions and 130 deletions.
3 changes: 0 additions & 3 deletions packages/blockchain-bindings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@
"typescript": "5.2.2"
},
"prettier": "@lens-protocol/prettier-config",
"peerDependencies": {
"ethers": "^5.7.2"
},
"babel": {
"presets": [
"@babel/preset-env",
Expand Down
1 change: 0 additions & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/LensClient.spec.ts
Original file line number Diff line number Diff line change
@@ -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__';
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/__helpers__/BundlrUploader.ts
Original file line number Diff line number Diff line change
@@ -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) {}
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/__helpers__/setup.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/gated/__helpers/setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Wallet } from 'ethers';
import { Wallet } from '@ethersproject/wallet';

import { buildTestEnvironment } from '../../__helpers__';
import { LensClient } from '../LensClient';
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/gated/__tests__/LensClient.spec.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { TypedDataDomain, TypedDataField } from 'ethers';
import type { TypedDataDomain, TypedDataField } from '@ethersproject/abstract-signer';

export type TypedData = {
domain: TypedDataDomain;
Expand Down
2 changes: 1 addition & 1 deletion packages/gated-content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
1 change: 0 additions & 1 deletion packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions packages/react-v1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -88,7 +87,6 @@
"typescript": "5.2.2"
},
"peerDependencies": {
"ethers": "^5.7.2",
"react": "^18.2.0"
},
"prettier": "@lens-protocol/prettier-config",
Expand Down
2 changes: 0 additions & 2 deletions packages/react-web-v1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -72,7 +71,6 @@
"typescript": "5.2.2"
},
"peerDependencies": {
"ethers": "^5.7.2",
"react": "^18.2.0"
},
"peerDependenciesMeta": {
Expand Down
1 change: 0 additions & 1 deletion packages/react-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 2 additions & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down Expand Up @@ -104,7 +106,6 @@
},
"peerDependencies": {
"@types/react": "^18.0.0",
"ethers": "^5.7.2",
"react": "^18.2.0"
},
"peerDependenciesMeta": {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/polls/adapters/SnapshotVoteFactory.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getAddress } from '@ethersproject/address';
import {
SafeApolloClient,
GetSnapshotProposalDocument,
Expand All @@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getAddress } from '@ethersproject/address';
import {
SnapshotProposal,
SnapshotSpaceId,
Expand All @@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { BigNumber } from '@ethersproject/bignumber';
import { MaxUint256 } from '@ethersproject/constants';
import { erc20, bigNumber } from '@lens-protocol/blockchain-bindings';
import {
IPaidTransactionGateway,
TokenAllowanceLimit,
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';

Expand All @@ -18,7 +19,7 @@ function resolveApproveAmount(request: TokenAllowanceRequest): BigNumber {
case TokenAllowanceLimit.EXACT:
return bigNumber(request.amount);
case TokenAllowanceLimit.INFINITE:
return constants.MaxUint256;
return MaxUint256;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { JsonRpcProvider } from '@ethersproject/providers';
import { FeeHistoryResult } from '@lens-protocol/blockchain-bindings';
import {
Amount,
Expand All @@ -6,7 +7,6 @@ import {
Denomination,
never,
} from '@lens-protocol/shared-kernel';
import { providers } from 'ethers';

export class Eip1559GasPriceEstimate<T extends CryptoNativeAsset = CryptoNativeAsset> {
constructor(readonly baseFee: Amount<T>, readonly maxPriorityFeePerGas: Amount<T>) {}
Expand Down Expand Up @@ -92,7 +92,7 @@ export type CryptoNativeAmountFactory<T extends CryptoNativeAsset> = (

export class Eip1559GasPriceEstimator<T extends CryptoNativeAsset> {
constructor(
private readonly provider: providers.JsonRpcProvider,
private readonly provider: JsonRpcProvider,
private readonly createAmount: CryptoNativeAmountFactory<T>,
) {}

Expand Down
24 changes: 12 additions & 12 deletions packages/react/src/wallet/adapters/ConcreteWallet.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -159,9 +159,9 @@ export class ConcreteWallet extends Wallet {
const signedCall = SignedProtocolCall.create({ unsignedCall, signature });
return success(signedCall);
} catch (err) {
assertErrorObjectWithCode<errors>(err);
assertErrorObjectWithCode<ErrorCode>(err);

if (err.code === errors.ACTION_REJECTED) {
if (err.code === ErrorCode.ACTION_REJECTED) {
return failure(new UserRejectedError());
}

Expand Down Expand Up @@ -195,9 +195,9 @@ export class ConcreteWallet extends Wallet {
const signature = await signer.signMessage(message);
return success(signature as Signature);
} catch (err) {
assertErrorObjectWithCode<errors>(err);
assertErrorObjectWithCode<ErrorCode>(err);

if (err.code === errors.ACTION_REJECTED) {
if (err.code === ErrorCode.ACTION_REJECTED) {
return failure(new UserRejectedError());
}
throw err;
Expand Down Expand Up @@ -239,12 +239,12 @@ export class ConcreteWallet extends Wallet {

return success(transaction);
} catch (err) {
assertErrorObjectWithCode<errors>(err);
assertErrorObjectWithCode<ErrorCode>(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()));
}

Expand Down Expand Up @@ -289,9 +289,9 @@ export class ConcreteWallet extends Wallet {
);
return success(signedVote);
} catch (err) {
assertErrorObjectWithCode<errors>(err);
assertErrorObjectWithCode<ErrorCode>(err);

if (err.code === errors.ACTION_REJECTED) {
if (err.code === ErrorCode.ACTION_REJECTED) {
return failure(new UserRejectedError());
}
throw err;
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/wallet/adapters/IProviderFactory.ts
Original file line number Diff line number Diff line change
@@ -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<providers.JsonRpcProvider>;
createProvider(config: CreateProviderConfig): Promise<JsonRpcProvider>;
}
7 changes: 3 additions & 4 deletions packages/react/src/wallet/adapters/__helpers__/mocks.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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';

Expand Down Expand Up @@ -95,7 +94,7 @@ export function mockUnsignedTransactionRequest({
type MockedISignerFactoryConfig = {
address: EvmAddress;
chainType?: ChainType;
signerResult: Result<providers.JsonRpcSigner, WalletConnectionError>;
signerResult: Result<JsonRpcSigner, WalletConnectionError>;
};

export function mockISignerFactory({
Expand All @@ -118,7 +117,7 @@ export function mockSignedVote(): SignedVote {

type MockedIProviderFactoryConfig = {
chainType: ChainType;
provider: providers.JsonRpcProvider;
provider: JsonRpcProvider;
};

export function mockIProviderFactory({
Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/wallet/infrastructure/ProviderFactory.ts
Original file line number Diff line number Diff line change
@@ -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<providers.JsonRpcProvider>;
export type GetProvider = (config: { chainId: number }) => Promise<JsonRpcProvider>;

export interface IProviderBinding {
getProvider: GetProvider;
Expand All @@ -16,7 +16,7 @@ export class ProviderFactory implements IProviderFactory {
private readonly chains: ChainConfigRegistry,
) {}

async createProvider(config: { chainType: ChainType }): Promise<providers.JsonRpcProvider> {
async createProvider(config: { chainType: ChainType }): Promise<JsonRpcProvider> {
const chainId = this.chains[config.chainType]?.chainId ?? never('Unable to determine chainId');
const provider = await this.bindings.getProvider({ chainId });

Expand Down
11 changes: 6 additions & 5 deletions packages/react/src/wallet/infrastructure/SignerFactory.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -54,9 +55,9 @@ export class SignerFactory implements ISignerFactory {
}
}
} catch (err) {
assertErrorObjectWithCode<errors>(err);
assertErrorObjectWithCode<ErrorCode>(err);

if (err.code === errors.UNSUPPORTED_OPERATION) {
if (err.code === ErrorCode.UNSUPPORTED_OPERATION) {
return failure(new WalletConnectionError(WalletConnectionErrorReason.INCORRECT_CHAIN));
}
}
Expand All @@ -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,
Expand Down Expand Up @@ -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();
Expand Down
Loading

0 comments on commit e825cff

Please sign in to comment.