diff --git a/contracts/clients/src/AddressRegistryWrapper.ts b/contracts/clients/src/AddressRegistryWrapper.ts index 393fd4ac5..e085b5455 100644 --- a/contracts/clients/src/AddressRegistryWrapper.ts +++ b/contracts/clients/src/AddressRegistryWrapper.ts @@ -1,22 +1,31 @@ -/* eslint-disable camelcase */ - import { BigNumber, BigNumberish, ethers, Signer } from "ethers"; import { AddressRegistry } from "../typechain-types/contracts/AddressRegistry"; -import { AddressRegistry__factory } from "../typechain-types/factories/contracts/AddressRegistry__factory"; +import { AddressRegistry__factory as AddressRegistryFactory } from "../typechain-types/factories/contracts/AddressRegistry__factory"; import SignerOrProvider from "./helpers/SignerOrProvider"; import SafeSingletonFactory, { SafeSingletonFactoryViewer, } from "./SafeSingletonFactory"; +/** + * A wrapper around the `AddressRegistry` contract to provide a more ergonomic + * interface, especially for `reverseLookup`. + */ export default class AddressRegistryWrapper { constructor(public registry: AddressRegistry) {} + /** + * Deploys a new `AddressRegistry` contract the traditional way. + */ static async deployNew(signer: Signer): Promise { - const factory = new AddressRegistry__factory(signer); + const factory = new AddressRegistryFactory(signer); return new AddressRegistryWrapper(await factory.deploy()); } + /** + * Uses Gnosis Safe's factory to get an `AddressRegistry` contract at a + * predetermined address. Deploys if it doesn't already exist. + */ static async connectOrDeploy( signerOrFactory: Signer | SafeSingletonFactory, salt: ethers.utils.BytesLike = ethers.utils.solidityPack(["uint256"], [0]), @@ -24,7 +33,7 @@ export default class AddressRegistryWrapper { const factory = await SafeSingletonFactory.from(signerOrFactory); const registry = await factory.connectOrDeploy( - AddressRegistry__factory, + AddressRegistryFactory, [], salt, ); @@ -32,6 +41,10 @@ export default class AddressRegistryWrapper { return new AddressRegistryWrapper(registry); } + /** + * Uses Gnosis Safe's factory to get an `AddressRegistry` contract at a + * predetermined address. Returns undefined if it doesn't exist. + */ static async connectIfDeployed( signerOrProvider: SignerOrProvider, salt: ethers.utils.BytesLike = ethers.utils.solidityPack(["uint256"], [0]), @@ -41,7 +54,7 @@ export default class AddressRegistryWrapper { ); const registry = await factoryViewer.connectIfDeployed( - AddressRegistry__factory, + AddressRegistryFactory, [], salt, ); @@ -49,12 +62,19 @@ export default class AddressRegistryWrapper { return registry ? new AddressRegistryWrapper(registry) : undefined; } + /** + * Uses an id to lookup an address, the same way that happens on chain. + */ async lookup(id: BigNumberish): Promise { const address = await this.registry.addresses(id); return address === ethers.constants.AddressZero ? undefined : address; } + /** + * Uses an address to lookup an id - the reverse of what happens on chain, by + * making use of the indexed `AddressRegistered` event. + */ async reverseLookup(address: string): Promise { const events = await this.registry.queryFilter( this.registry.filters.AddressRegistered(null, address), @@ -65,6 +85,9 @@ export default class AddressRegistryWrapper { return id; } + /** + * Registers an address and returns the id that was assigned to it. + */ async register(address: string): Promise { await (await this.registry.register(address)).wait(); @@ -77,6 +100,10 @@ export default class AddressRegistryWrapper { return id; } + /** + * Registers an address if it hasn't already been registered, and returns the + * id that was assigned to it. + */ async registerIfNeeded(address: string): Promise { let id = await this.reverseLookup(address); diff --git a/contracts/clients/src/BlsPublicKeyRegistryWrapper.ts b/contracts/clients/src/BlsPublicKeyRegistryWrapper.ts index 1e8ed8d76..2b716758a 100644 --- a/contracts/clients/src/BlsPublicKeyRegistryWrapper.ts +++ b/contracts/clients/src/BlsPublicKeyRegistryWrapper.ts @@ -1,10 +1,8 @@ -/* eslint-disable camelcase */ - import { BigNumber, BigNumberish, ethers, Signer } from "ethers"; import { solidityKeccak256 } from "ethers/lib/utils"; import { BLSPublicKeyRegistry, - BLSPublicKeyRegistry__factory, + BLSPublicKeyRegistry__factory as BLSPublicKeyRegistryFactory, } from "../typechain-types"; import SignerOrProvider from "./helpers/SignerOrProvider"; import SafeSingletonFactory, { @@ -12,15 +10,26 @@ import SafeSingletonFactory, { } from "./SafeSingletonFactory"; import { PublicKey } from "./signer"; +/** + * A wrapper around the `BLSPublicKeyRegistry` contract to provide a more + * ergonomic interface, especially for `reverseLookup`. + */ export default class BlsPublicKeyRegistryWrapper { constructor(public registry: BLSPublicKeyRegistry) {} + /** + * Deploys a new `BLSPublicKeyRegistry` contract the traditional way. + */ static async deployNew(signer: Signer): Promise { - const factory = new BLSPublicKeyRegistry__factory(signer); + const factory = new BLSPublicKeyRegistryFactory(signer); return new BlsPublicKeyRegistryWrapper(await factory.deploy()); } + /** + * Uses Gnosis Safe's factory to get an `BLSPublicKeyRegistry` contract at a + * predetermined address. Deploys if it doesn't already exist. + */ static async connectOrDeploy( signerOrFactory: Signer | SafeSingletonFactory, salt: ethers.utils.BytesLike = ethers.utils.solidityPack(["uint256"], [0]), @@ -28,7 +37,7 @@ export default class BlsPublicKeyRegistryWrapper { const factory = await SafeSingletonFactory.from(signerOrFactory); const registry = await factory.connectOrDeploy( - BLSPublicKeyRegistry__factory, + BLSPublicKeyRegistryFactory, [], salt, ); @@ -36,6 +45,10 @@ export default class BlsPublicKeyRegistryWrapper { return new BlsPublicKeyRegistryWrapper(registry); } + /** + * Uses Gnosis Safe's factory to get an `BLSPublicKeyRegistry` contract at a + * predetermined address. Returns undefined if it doesn't exist. + */ static async connectIfDeployed( signerOrProvider: SignerOrProvider, salt: ethers.utils.BytesLike = ethers.utils.solidityPack(["uint256"], [0]), @@ -45,7 +58,7 @@ export default class BlsPublicKeyRegistryWrapper { ); const registry = await factoryViewer.connectIfDeployed( - BLSPublicKeyRegistry__factory, + BLSPublicKeyRegistryFactory, [], salt, ); @@ -53,6 +66,9 @@ export default class BlsPublicKeyRegistryWrapper { return registry ? new BlsPublicKeyRegistryWrapper(registry) : undefined; } + /** + * Uses an id to lookup a public key, the same way that happens on chain. + */ async lookup(id: BigNumberish): Promise { const blsPublicKey = await Promise.all([ this.registry.blsPublicKeys(id, 0), @@ -68,6 +84,10 @@ export default class BlsPublicKeyRegistryWrapper { return blsPublicKey; } + /** + * Uses a public key to lookup an id - the reverse of what happens on chain, + * by making use of the indexed `BLSPublicKeyRegistered` event. + */ async reverseLookup(blsPublicKey: PublicKey): Promise { const blsPublicKeyHash = solidityKeccak256(["uint256[4]"], [blsPublicKey]); @@ -80,6 +100,9 @@ export default class BlsPublicKeyRegistryWrapper { return id; } + /** + * Registers a public key and returns the id. + */ async register(blsPublicKey: PublicKey): Promise { await (await this.registry.register(blsPublicKey)).wait(); @@ -92,6 +115,10 @@ export default class BlsPublicKeyRegistryWrapper { return id; } + /** + * Registers a public key if it hasn't already been registered, and returns + * the id that was assigned to it. + */ async registerIfNeeded(blsPublicKey: PublicKey): Promise { let id = await this.reverseLookup(blsPublicKey); diff --git a/contracts/clients/src/BlsRegistrationCompressor.ts b/contracts/clients/src/BlsRegistrationCompressor.ts index ff141066c..57a0cbecf 100644 --- a/contracts/clients/src/BlsRegistrationCompressor.ts +++ b/contracts/clients/src/BlsRegistrationCompressor.ts @@ -1,13 +1,11 @@ -/* eslint-disable camelcase */ - import { BigNumber, ethers, Signer } from "ethers"; import { - AddressRegistry__factory, + AddressRegistry__factory as AddressRegistryFactory, AggregatorUtilities, - AggregatorUtilities__factory, - BLSPublicKeyRegistry__factory, + AggregatorUtilities__factory as AggregatorUtilitiesFactory, + BLSPublicKeyRegistry__factory as BLSPublicKeyRegistryFactory, BLSRegistration, - BLSRegistration__factory, + BLSRegistration__factory as BLSRegistrationFactory, } from "../typechain-types"; import AddressRegistryWrapper from "./AddressRegistryWrapper"; import BlsPublicKeyRegistryWrapper from "./BlsPublicKeyRegistryWrapper"; @@ -43,18 +41,18 @@ export default class BlsRegistrationCompressor implements IOperationCompressor { return new BlsRegistrationCompressor( blsRegistration, new BlsPublicKeyRegistryWrapper( - BLSPublicKeyRegistry__factory.connect( + BLSPublicKeyRegistryFactory.connect( blsPublicKeyRegistryAddress, blsRegistration.signer, ), ), new AddressRegistryWrapper( - AddressRegistry__factory.connect( + AddressRegistryFactory.connect( addressRegistryAddress, blsRegistration.signer, ), ), - AggregatorUtilities__factory.connect( + AggregatorUtilitiesFactory.connect( aggregatorUtilitiesAddress, blsRegistration.signer, ), @@ -62,12 +60,10 @@ export default class BlsRegistrationCompressor implements IOperationCompressor { } static async deployNew(signer: Signer): Promise { - const blsPublicKeyRegistryFactory = new BLSPublicKeyRegistry__factory( - signer, - ); + const blsPublicKeyRegistryFactory = new BLSPublicKeyRegistryFactory(signer); - const addressRegistryFactory = new AddressRegistry__factory(signer); - const aggregatorUtilitiesFactory = new AggregatorUtilities__factory(signer); + const addressRegistryFactory = new AddressRegistryFactory(signer); + const aggregatorUtilitiesFactory = new AggregatorUtilitiesFactory(signer); const [ blsPublicKeyRegistryContract, @@ -79,7 +75,7 @@ export default class BlsRegistrationCompressor implements IOperationCompressor { aggregatorUtilitiesFactory.deploy(), ]); - const blsRegistrationFactory = new BLSRegistration__factory(signer); + const blsRegistrationFactory = new BLSRegistrationFactory(signer); const blsRegistrationContract = await blsRegistrationFactory.deploy( blsPublicKeyRegistryContract.address, @@ -105,11 +101,11 @@ export default class BlsRegistrationCompressor implements IOperationCompressor { await Promise.all([ BlsPublicKeyRegistryWrapper.connectOrDeploy(factory, salt), AddressRegistryWrapper.connectOrDeploy(factory, salt), - factory.connectOrDeploy(AggregatorUtilities__factory, [], salt), + factory.connectOrDeploy(AggregatorUtilitiesFactory, [], salt), ]); const blsRegistrationContract = await factory.connectOrDeploy( - BLSRegistration__factory, + BLSRegistrationFactory, [ blsPublicKeyRegistry.registry.address, addressRegistry.registry.address, @@ -135,25 +131,25 @@ export default class BlsRegistrationCompressor implements IOperationCompressor { ); const blsPublicKeyRegistryAddress = factoryViewer.calculateAddress( - BLSPublicKeyRegistry__factory, + BLSPublicKeyRegistryFactory, [], salt, ); const addressRegistryAddress = factoryViewer.calculateAddress( - AddressRegistry__factory, + AddressRegistryFactory, [], salt, ); const aggregatorUtilitiesAddress = factoryViewer.calculateAddress( - AggregatorUtilities__factory, + AggregatorUtilitiesFactory, [], salt, ); const blsRegistration = await factoryViewer.connectIfDeployed( - BLSRegistration__factory, + BLSRegistrationFactory, [ blsPublicKeyRegistryAddress, addressRegistryAddress, diff --git a/contracts/clients/src/BlsWalletWrapper.ts b/contracts/clients/src/BlsWalletWrapper.ts index 607a5e763..cba87a78a 100644 --- a/contracts/clients/src/BlsWalletWrapper.ts +++ b/contracts/clients/src/BlsWalletWrapper.ts @@ -1,5 +1,3 @@ -/* eslint-disable camelcase */ - import { ethers, BigNumber } from "ethers"; import { keccak256, solidityKeccak256, solidityPack } from "ethers/lib/utils"; import { @@ -13,10 +11,10 @@ import { import { BLSWallet, - BLSWallet__factory, - TransparentUpgradeableProxy__factory, + BLSWallet__factory as BLSWalletFactory, + TransparentUpgradeableProxy__factory as TransparentUpgradeableProxyFactory, VerificationGateway, - VerificationGateway__factory, + VerificationGateway__factory as VerificationGatewayFactory, } from "../typechain-types"; import getRandomBlsPrivateKey from "./signer/getRandomBlsPrivateKey"; @@ -48,7 +46,7 @@ export default class BlsWalletWrapper { verificationGateway.provider, ); - return BLSWallet__factory.connect( + return BLSWalletFactory.connect( contractAddress, verificationGateway.provider, ); @@ -78,7 +76,7 @@ export default class BlsWalletWrapper { ): Promise { blsWalletSigner ??= await this.#BlsWalletSigner(signerOrProvider); - const verificationGateway = VerificationGateway__factory.connect( + const verificationGateway = VerificationGatewayFactory.connect( verificationGatewayAddress, signerOrProvider, ); @@ -143,7 +141,7 @@ export default class BlsWalletWrapper { verificationGatewayAddress: string, provider: ethers.providers.Provider, ): Promise { - const verificationGateway = VerificationGateway__factory.connect( + const verificationGateway = VerificationGatewayFactory.connect( verificationGatewayAddress, provider, ); @@ -171,7 +169,7 @@ export default class BlsWalletWrapper { verificationGateway.provider, ); - this.walletContract = BLSWallet__factory.connect( + this.walletContract = BLSWalletFactory.connect( this.address, verificationGateway.provider, ); @@ -201,7 +199,7 @@ export default class BlsWalletWrapper { verificationGatewayAddress: string, signerOrProvider: SignerOrProvider, ): Promise { - const verificationGateway = VerificationGateway__factory.connect( + const verificationGateway = VerificationGatewayFactory.connect( verificationGatewayAddress, signerOrProvider, ); @@ -215,7 +213,7 @@ export default class BlsWalletWrapper { publicKeyHash, ); - const walletContract = BLSWallet__factory.connect( + const walletContract = BLSWalletFactory.connect( contractAddress, signerOrProvider, ); @@ -257,7 +255,7 @@ export default class BlsWalletWrapper { ? await this.walletContract.trustedBLSGateway() : this.defaultGatewayAddress; - const gateway = VerificationGateway__factory.connect( + const gateway = VerificationGatewayFactory.connect( gatewayAddress, this.walletContract.provider, ); @@ -391,7 +389,7 @@ export default class BlsWalletWrapper { ]); const initFunctionParams = - BLSWallet__factory.createInterface().encodeFunctionData("initialize", [ + BLSWalletFactory.createInterface().encodeFunctionData("initialize", [ verificationGateway.address, ]); @@ -401,7 +399,7 @@ export default class BlsWalletWrapper { ethers.utils.solidityKeccak256( ["bytes", "bytes"], [ - TransparentUpgradeableProxy__factory.bytecode, + TransparentUpgradeableProxyFactory.bytecode, ethers.utils.defaultAbiCoder.encode( ["address", "address", "bytes"], [blsWalletLogicAddress, proxyAdminAddress, initFunctionParams], diff --git a/contracts/clients/src/BundleCompressor.ts b/contracts/clients/src/BundleCompressor.ts index fb4e006c3..6d15a355f 100644 --- a/contracts/clients/src/BundleCompressor.ts +++ b/contracts/clients/src/BundleCompressor.ts @@ -4,13 +4,26 @@ import IOperationCompressor from "./IOperationCompressor"; import { Bundle, Operation, PublicKey } from "./signer"; import Range from "./helpers/Range"; +/** + * Produces compressed bundles that can be passed to `BLSExpanderDelegator.run` + * instead of `VerificationGateway.processBundle`. + * + * The compression of operations is delegated to other compressors that you + * inject using `.addCompressor`. For each operation of the bundle, these + * compressors are tried in the order they were added, and the first one that + * succeeds is used. Note that `expanderIndex` is unrelated to this order - it + * just needs to match the index that the corresponding expander contract is + * registered at in BLSExpanderDelegator. + */ export default class BundleCompressor { compressors: [number, IOperationCompressor][] = []; + /** Add an operation compressor. */ addCompressor(expanderIndex: number, compressor: IOperationCompressor) { this.compressors.push([expanderIndex, compressor]); } + /** Compresses a single operation. */ async compressOperation( blsPublicKey: PublicKey, operation: Operation, @@ -37,6 +50,7 @@ export default class BundleCompressor { return hexJoin([encodeVLQ(expanderIndex), data]); } + /** Compresses a bundle. */ async compress(bundle: Bundle): Promise { const len = bundle.operations.length; diff --git a/contracts/clients/src/Experimental.ts b/contracts/clients/src/Experimental.ts new file mode 100644 index 000000000..c08eced82 --- /dev/null +++ b/contracts/clients/src/Experimental.ts @@ -0,0 +1,7 @@ +/** + * The Experimental namespace exposes APIs that are unstable. + * Unstable in the sense that the APIs will be less functional, less well-tested, and/or are expected to change. + */ + +export { default as BlsProvider } from "./BlsProvider"; +export { default as BlsSigner } from "./BlsSigner"; diff --git a/contracts/clients/src/FallbackCompressor.ts b/contracts/clients/src/FallbackCompressor.ts index 09133569c..cae1f251a 100644 --- a/contracts/clients/src/FallbackCompressor.ts +++ b/contracts/clients/src/FallbackCompressor.ts @@ -1,11 +1,9 @@ -/* eslint-disable camelcase */ - import { ethers, Signer } from "ethers"; import { - AddressRegistry__factory, - BLSPublicKeyRegistry__factory, + AddressRegistry__factory as AddressRegistryFactory, + BLSPublicKeyRegistry__factory as BLSPublicKeyRegistryFactory, FallbackExpander, - FallbackExpander__factory, + FallbackExpander__factory as FallbackExpanderFactory, } from "../typechain-types"; import AddressRegistryWrapper from "./AddressRegistryWrapper"; import BlsPublicKeyRegistryWrapper from "./BlsPublicKeyRegistryWrapper"; @@ -42,13 +40,13 @@ export default class FallbackCompressor implements IOperationCompressor { return new FallbackCompressor( fallbackExpander, new BlsPublicKeyRegistryWrapper( - BLSPublicKeyRegistry__factory.connect( + BLSPublicKeyRegistryFactory.connect( blsPublicKeyRegistryAddress, fallbackExpander.signer, ), ), new AddressRegistryWrapper( - AddressRegistry__factory.connect( + AddressRegistryFactory.connect( addressRegistryAddress, fallbackExpander.signer, ), @@ -57,11 +55,9 @@ export default class FallbackCompressor implements IOperationCompressor { } static async deployNew(signer: Signer): Promise { - const blsPublicKeyRegistryFactory = new BLSPublicKeyRegistry__factory( - signer, - ); + const blsPublicKeyRegistryFactory = new BLSPublicKeyRegistryFactory(signer); - const addressRegistryFactory = new AddressRegistry__factory(signer); + const addressRegistryFactory = new AddressRegistryFactory(signer); const [blsPublicKeyRegistryContract, addressRegistryContract] = await Promise.all([ @@ -69,7 +65,7 @@ export default class FallbackCompressor implements IOperationCompressor { addressRegistryFactory.deploy(), ]); - const fallbackExpanderFactory = new FallbackExpander__factory(signer); + const fallbackExpanderFactory = new FallbackExpanderFactory(signer); const fallbackExpanderContract = await fallbackExpanderFactory.deploy( blsPublicKeyRegistryContract.address, @@ -95,7 +91,7 @@ export default class FallbackCompressor implements IOperationCompressor { ]); const fallbackExpanderContract = await factory.connectOrDeploy( - FallbackExpander__factory, + FallbackExpanderFactory, [blsPublicKeyRegistry.registry.address, addressRegistry.registry.address], salt, ); @@ -116,7 +112,7 @@ export default class FallbackCompressor implements IOperationCompressor { ); const blsPublicKeyRegistry = await factoryViewer.connectIfDeployed( - BLSPublicKeyRegistry__factory, + BLSPublicKeyRegistryFactory, [], salt, ); @@ -126,7 +122,7 @@ export default class FallbackCompressor implements IOperationCompressor { } const addressRegistry = await factoryViewer.connectIfDeployed( - AddressRegistry__factory, + AddressRegistryFactory, [], salt, ); @@ -136,7 +132,7 @@ export default class FallbackCompressor implements IOperationCompressor { } const fallbackExpander = await factoryViewer.connectIfDeployed( - FallbackExpander__factory, + FallbackExpanderFactory, [blsPublicKeyRegistry.address, addressRegistry.address], salt, ); diff --git a/contracts/clients/src/index.ts b/contracts/clients/src/index.ts index d9aff5308..f3ced88cd 100644 --- a/contracts/clients/src/index.ts +++ b/contracts/clients/src/index.ts @@ -1,38 +1,31 @@ -import Aggregator from "./Aggregator"; -import BlsWalletWrapper from "./BlsWalletWrapper"; -import BlsProvider from "./BlsProvider"; -import BlsSigner from "./BlsSigner"; +export { default as Aggregator } from "./Aggregator"; +export { default as BlsWalletWrapper } from "./BlsWalletWrapper"; -// eslint-disable-next-line camelcase -import { VerificationGateway__factory } from "../typechain-types/factories/contracts/VerificationGateway__factory"; -import type { VerificationGateway } from "../typechain-types/contracts/VerificationGateway"; - -// eslint-disable-next-line camelcase -import { AggregatorUtilities__factory } from "../typechain-types/factories/contracts/AggregatorUtilities__factory"; -import type { AggregatorUtilities } from "../typechain-types/contracts/AggregatorUtilities"; - -// eslint-disable-next-line camelcase -import { ERC20__factory } from "../typechain-types/factories/@openzeppelin/contracts/token/ERC20/ERC20__factory"; -import type { ERC20 } from "../typechain-types/@openzeppelin/contracts/token/ERC20/ERC20"; - -// eslint-disable-next-line camelcase -import { MockERC20__factory } from "../typechain-types/factories/contracts/mock/MockERC20__factory"; -import type { MockERC20 } from "../typechain-types/contracts/mock/MockERC20"; - -import { NetworkConfig, getConfig, validateConfig } from "./NetworkConfig"; -import { +export { NetworkConfig, getConfig, validateConfig } from "./NetworkConfig"; +export { MultiNetworkConfig, getMultiConfig, validateMultiConfig, } from "./MultiNetworkConfig"; +export { BlsWalletContracts, connectToContracts } from "./BlsWalletContracts"; -import { +export { OperationResult, getOperationResults, decodeError, OperationResultError, } from "./OperationResults"; -import { BlsWalletContracts, connectToContracts } from "./BlsWalletContracts"; + +export { + VerificationGateway__factory as VerificationGatewayFactory, + AggregatorUtilities__factory as AggregatorUtilitiesFactory, + ERC20__factory as ERC20Factory, + MockERC20__factory as MockERC20Factory, + type VerificationGateway, + type AggregatorUtilities, + type ERC20, + type MockERC20, +} from "../typechain-types"; export * from "./signer"; @@ -48,46 +41,4 @@ export { default as BlsRegistrationCompressor } from "./BlsRegistrationCompresso export { default as BundleCompressor } from "./BundleCompressor"; export * from "./encodeUtils"; -const Experimental_ = { - BlsProvider, - BlsSigner, -}; - -/** - * The Experimental namespace exposes APIs that are unstable. - * Unstable in the sense that the APIs will be less functional, less well-tested, and/or are expected to change. - */ -namespace Experimental { - export const BlsProvider = Experimental_.BlsProvider; - export const BlsSigner = Experimental_.BlsSigner; -} - -export { - Aggregator, - BlsWalletWrapper, - NetworkConfig, - getConfig, - validateConfig, - MultiNetworkConfig, - getMultiConfig, - validateMultiConfig, - OperationResult, - OperationResultError, - getOperationResults, - decodeError, - // eslint-disable-next-line camelcase - VerificationGateway__factory, - VerificationGateway, - // eslint-disable-next-line camelcase - AggregatorUtilities__factory, - AggregatorUtilities, - // eslint-disable-next-line camelcase - ERC20__factory, - ERC20, - // eslint-disable-next-line camelcase - MockERC20__factory, - MockERC20, - BlsWalletContracts, - connectToContracts, - Experimental, -}; +export * as Experimental from "./Experimental"; diff --git a/contracts/shared/deploy.ts b/contracts/shared/deploy.ts index e1d47eb98..e03b5f5a6 100644 --- a/contracts/shared/deploy.ts +++ b/contracts/shared/deploy.ts @@ -1,26 +1,24 @@ -/* eslint-disable camelcase */ - import { ethers } from "ethers"; import { AddressRegistry, - AddressRegistry__factory, + AddressRegistry__factory as AddressRegistryFactory, AggregatorUtilities, - AggregatorUtilities__factory, + AggregatorUtilities__factory as AggregatorUtilitiesFactory, BLSExpander, BLSExpanderDelegator, - BLSExpanderDelegator__factory, - BLSExpander__factory, + BLSExpanderDelegator__factory as BLSExpanderDelegatorFactory, + BLSExpander__factory as BLSExpanderFactory, BLSOpen, - BLSOpen__factory, + BLSOpen__factory as BLSOpenFactory, BLSPublicKeyRegistry, - BLSPublicKeyRegistry__factory, + BLSPublicKeyRegistry__factory as BLSPublicKeyRegistryFactory, BNPairingPrecompileCostEstimator, - BNPairingPrecompileCostEstimator__factory, + BNPairingPrecompileCostEstimator__factory as BNPairingPrecompileCostEstimatorFactory, FallbackExpander, - FallbackExpander__factory, - BLSRegistration__factory, + FallbackExpander__factory as FallbackExpanderFactory, + BLSRegistration__factory as BLSRegistrationFactory, VerificationGateway, - VerificationGateway__factory, + VerificationGateway__factory as VerificationGatewayFactory, BLSRegistration, } from "../typechain-types"; @@ -48,7 +46,7 @@ export default async function deploy( const singletonFactory = await SafeSingletonFactory.init(signer); const precompileCostEstimator = await singletonFactory.connectOrDeploy( - BNPairingPrecompileCostEstimator__factory, + BNPairingPrecompileCostEstimatorFactory, [], salt, ); @@ -56,19 +54,19 @@ export default async function deploy( await (await precompileCostEstimator.run()).wait(); const blsLibrary = await singletonFactory.connectOrDeploy( - BLSOpen__factory, + BLSOpenFactory, [], salt, ); const verificationGateway = await singletonFactory.connectOrDeploy( - VerificationGateway__factory, + VerificationGatewayFactory, [blsLibrary.address], salt, ); const aggregatorUtilities = await singletonFactory.connectOrDeploy( - AggregatorUtilities__factory, + AggregatorUtilitiesFactory, [], salt, ); @@ -109,37 +107,37 @@ async function deployExpanders( salt: ethers.utils.BytesLike = ethers.utils.solidityPack(["uint256"], [0]), ) { const blsExpander = await singletonFactory.connectOrDeploy( - BLSExpander__factory, + BLSExpanderFactory, [verificationGateway.address], salt, ); const blsExpanderDelegator = await singletonFactory.connectOrDeploy( - BLSExpanderDelegator__factory, + BLSExpanderDelegatorFactory, [verificationGateway.address], salt, ); const blsPublicKeyRegistry = await singletonFactory.connectOrDeploy( - BLSPublicKeyRegistry__factory, + BLSPublicKeyRegistryFactory, [], salt, ); const addressRegistry = await singletonFactory.connectOrDeploy( - AddressRegistry__factory, + AddressRegistryFactory, [], salt, ); const fallbackExpander = await singletonFactory.connectOrDeploy( - FallbackExpander__factory, + FallbackExpanderFactory, [blsPublicKeyRegistry.address, addressRegistry.address], salt, ); const blsRegistration = await singletonFactory.connectOrDeploy( - BLSRegistration__factory, + BLSRegistrationFactory, [ blsPublicKeyRegistry.address, addressRegistry.address, diff --git a/contracts/shared/helpers/Fixture.ts b/contracts/shared/helpers/Fixture.ts index d172dbff1..959216a92 100644 --- a/contracts/shared/helpers/Fixture.ts +++ b/contracts/shared/helpers/Fixture.ts @@ -1,5 +1,3 @@ -/* eslint-disable camelcase */ - import "@nomiclabs/hardhat-ethers"; import { ethers, network } from "hardhat"; import { diff --git a/contracts/shared/helpers/TokenHelper.ts b/contracts/shared/helpers/TokenHelper.ts index 4e6d8ba19..2bb18f08c 100644 --- a/contracts/shared/helpers/TokenHelper.ts +++ b/contracts/shared/helpers/TokenHelper.ts @@ -3,8 +3,10 @@ import { utils, BigNumber, Signer } from "ethers"; import { BlsWalletWrapper } from "../../clients/src"; import Fixture from "./Fixture"; -/* eslint-disable camelcase */ -import { IERC20, MockERC20__factory } from "../../typechain-types"; +import { + IERC20, + MockERC20__factory as MockERC20Factory, +} from "../../typechain-types"; export default class TokenHelper { static readonly initialSupply = utils.parseUnits("1000000"); @@ -24,7 +26,7 @@ export default class TokenHelper { balanceAddress: string | undefined = undefined, ): Promise { const [signer] = await ethers.getSigners(); - const mockERC20 = await new MockERC20__factory(signer).deploy( + const mockERC20 = await new MockERC20Factory(signer).deploy( "AnyToken", "TOK", TokenHelper.initialSupply, diff --git a/contracts/test-integration/BlsProvider.test.ts b/contracts/test-integration/BlsProvider.test.ts index d5d9f90cc..96ec4fb06 100644 --- a/contracts/test-integration/BlsProvider.test.ts +++ b/contracts/test-integration/BlsProvider.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable camelcase */ import chai, { expect } from "chai"; import { ethers } from "ethers"; import { formatEther, parseEther } from "ethers/lib/utils"; @@ -6,7 +5,7 @@ import { formatEther, parseEther } from "ethers/lib/utils"; import { BlsWalletWrapper, Experimental, - MockERC20__factory, + MockERC20Factory, NetworkConfig, } from "../clients/src"; import getNetworkConfig from "../shared/helpers/getNetworkConfig"; @@ -62,7 +61,7 @@ describe("BlsProvider", () => { it("calls a getter method on a contract using call()", async () => { // Arrange const expectedSupply = "1000000.0"; - const testERC20 = MockERC20__factory.connect( + const testERC20 = MockERC20Factory.connect( networkConfig.addresses.testToken, blsProvider, ); @@ -429,7 +428,7 @@ describe("JsonRpcProvider", () => { it("calls a getter method on a contract", async () => { // Arrange const expectedSupply = "1000000.0"; - const testERC20 = MockERC20__factory.connect( + const testERC20 = MockERC20Factory.connect( networkConfig.addresses.testToken, regularProvider, ); diff --git a/contracts/test-integration/BlsSigner.test.ts b/contracts/test-integration/BlsSigner.test.ts index 162ae8147..da09aeeba 100644 --- a/contracts/test-integration/BlsSigner.test.ts +++ b/contracts/test-integration/BlsSigner.test.ts @@ -14,8 +14,7 @@ import { ActionData, BlsWalletWrapper, NetworkConfig, - // eslint-disable-next-line camelcase - MockERC20__factory, + MockERC20Factory, } from "../clients/src"; import getNetworkConfig from "../shared/helpers/getNetworkConfig"; @@ -556,8 +555,7 @@ describe("BlsSigner", () => { // Arrange const spy = chai.spy.on(Experimental.BlsProvider.prototype, "call"); - // eslint-disable-next-line camelcase - const testERC20 = MockERC20__factory.connect( + const testERC20 = MockERC20Factory.connect( networkConfig.addresses.testToken, blsProvider, ); diff --git a/contracts/test/addressRegistry-test.ts b/contracts/test/addressRegistry-test.ts index 95d2adc40..591bd7407 100644 --- a/contracts/test/addressRegistry-test.ts +++ b/contracts/test/addressRegistry-test.ts @@ -1,5 +1,3 @@ -/* eslint-disable camelcase */ - import { expect } from "chai"; import { ethers } from "hardhat"; import { AddressRegistryWrapper } from "../clients/src"; diff --git a/contracts/test/blsPublicKeyRegistry-test.ts b/contracts/test/blsPublicKeyRegistry-test.ts index 906b63fce..e4940e797 100644 --- a/contracts/test/blsPublicKeyRegistry-test.ts +++ b/contracts/test/blsPublicKeyRegistry-test.ts @@ -1,5 +1,3 @@ -/* eslint-disable camelcase */ - import { expect } from "chai"; import { BigNumber } from "ethers"; import { ethers } from "hardhat"; diff --git a/contracts/test/deploy-test.ts b/contracts/test/deploy-test.ts index 35f4f73d1..cb796f9ef 100644 --- a/contracts/test/deploy-test.ts +++ b/contracts/test/deploy-test.ts @@ -1,10 +1,8 @@ -/* eslint-disable camelcase */ - import { expect } from "chai"; import { ethers } from "hardhat"; import { SafeSingletonFactory } from "../clients/src"; -import { MockERC20__factory } from "../typechain-types"; +import { MockERC20__factory as MockERC20Factory } from "../typechain-types"; describe("SafeSingletonFactory", async () => { it("should deploy SafeSingletonFactory to expected address", async () => { @@ -20,13 +18,13 @@ describe("SafeSingletonFactory", async () => { const singletonFactory = await SafeSingletonFactory.init(signer); const expectedAddress = singletonFactory.calculateAddress( - MockERC20__factory, + MockERC20Factory, ["TestToken123", "TOK", 0], ); expect(await ethers.provider.getCode(expectedAddress)).to.equal("0x"); - await singletonFactory.connectOrDeploy(MockERC20__factory, [ + await singletonFactory.connectOrDeploy(MockERC20Factory, [ "TestToken123", "TOK", 0, @@ -39,7 +37,7 @@ describe("SafeSingletonFactory", async () => { const [signer] = await ethers.getSigners(); const singletonFactory = await SafeSingletonFactory.init(signer); - await singletonFactory.connectOrDeploy(MockERC20__factory, [ + await singletonFactory.connectOrDeploy(MockERC20Factory, [ "TestToken123", "TOK", 0, @@ -48,7 +46,7 @@ describe("SafeSingletonFactory", async () => { const txCount = await signer.getTransactionCount(); // Deploy the same contract (with the same salt (defaults to 0)) - await singletonFactory.connectOrDeploy(MockERC20__factory, [ + await singletonFactory.connectOrDeploy(MockERC20Factory, [ "TestToken123", "TOK", 0, diff --git a/contracts/test/pseudoFloat-test.ts b/contracts/test/pseudoFloat-test.ts index 90638148c..9e9b94343 100644 --- a/contracts/test/pseudoFloat-test.ts +++ b/contracts/test/pseudoFloat-test.ts @@ -1,18 +1,19 @@ -/* eslint-disable camelcase */ - import { expect } from "chai"; import { BigNumber } from "ethers"; import { RLP } from "ethers/lib/utils"; import { ethers } from "hardhat"; import { encodePseudoFloat } from "../clients/src"; -import { PseudoFloat, PseudoFloat__factory } from "../typechain-types"; +import { + PseudoFloat, + PseudoFloat__factory as PseudoFloatFactory, +} from "../typechain-types"; describe("PseudoFloat", function () { let pseudoFloat: PseudoFloat; this.beforeAll(async () => { const [eoa] = await ethers.getSigners(); - const factory = new PseudoFloat__factory(eoa); + const factory = new PseudoFloatFactory(eoa); pseudoFloat = await factory.deploy(); }); diff --git a/contracts/test/regIndex-test.ts b/contracts/test/regIndex-test.ts index 5e095d784..29fe464ae 100644 --- a/contracts/test/regIndex-test.ts +++ b/contracts/test/regIndex-test.ts @@ -1,17 +1,18 @@ -/* eslint-disable camelcase */ - import { expect } from "chai"; import { BigNumber } from "ethers"; import { ethers } from "hardhat"; import { encodeRegIndex } from "../clients/src"; -import { RegIndex, RegIndex__factory } from "../typechain-types"; +import { + RegIndex, + RegIndex__factory as RegIndexFactory, +} from "../typechain-types"; describe("RegIndex", function () { let regIndex: RegIndex; this.beforeAll(async () => { const [eoa] = await ethers.getSigners(); - const factory = new RegIndex__factory(eoa); + const factory = new RegIndexFactory(eoa); regIndex = await factory.deploy(); }); diff --git a/contracts/test/vlq-test.ts b/contracts/test/vlq-test.ts index fd70ad223..1342aa07f 100644 --- a/contracts/test/vlq-test.ts +++ b/contracts/test/vlq-test.ts @@ -1,14 +1,13 @@ -/* eslint-disable camelcase */ import { expect } from "chai"; import { ethers } from "hardhat"; -import { VLQ, VLQ__factory } from "../typechain-types"; +import { VLQ, VLQ__factory as VLQFactory } from "../typechain-types"; describe("VLQ", function () { let vlq: VLQ; this.beforeAll(async () => { const [eoa] = await ethers.getSigners(); - const factory = new VLQ__factory(eoa); + const factory = new VLQFactory(eoa); vlq = await factory.deploy(); });