Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Linting autofixes
Browse files Browse the repository at this point in the history
  • Loading branch information
voltrevo committed Sep 18, 2023
1 parent 7c95cff commit 4f2a0ac
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ethers, Signer } from "ethers";
import SignerOrProvider from ".//SignerOrProvider";
import SignerOrProvider from "./SignerOrProvider";
import assert from "./assert";

/**
Expand All @@ -8,7 +8,7 @@ import assert from "./assert";
*/
type NonOptionalElementsOf<A extends unknown[]> = A extends [
infer First,
...infer Tail
...infer Tail,
]
? [First, ...NonOptionalElementsOf<Tail>]
: A extends [opt?: unknown]
Expand All @@ -19,7 +19,7 @@ export type ContractFactoryConstructor = {
new (): ethers.ContractFactory;
connect(
address: string,
runner?: ethers.ContractRunner | null
runner?: ethers.ContractRunner | null,
): Pick<ethers.Contract, "getAddress">;
};

Expand Down Expand Up @@ -76,7 +76,7 @@ export default class SafeSingletonFactory {
private constructor(
public signer: ethers.Signer,
public chainId: bigint,
public address: string
public address: string,
) {
if (!signer.provider) {
throw new Error("Expected signer with provider");
Expand Down Expand Up @@ -111,7 +111,7 @@ export default class SafeSingletonFactory {
"Cannot get deployment for SafeSingletonFactory (check",
"https://github.com/safe-global/safe-singleton-factory/tree/main/artifacts",
`for chain id ${chainId})`,
].join(" ")
].join(" "),
);
}

Expand Down Expand Up @@ -142,36 +142,36 @@ export default class SafeSingletonFactory {
calculateAddress<CFC extends ContractFactoryConstructor>(
ContractFactoryConstructor: CFC,
deployParams: DeployParams<CFC>,
salt: ethers.BytesLike = ethers.solidityPacked(["uint256"], [0])
salt: ethers.BytesLike = ethers.solidityPacked(["uint256"], [0]),
) {
return this.viewer.calculateAddress(
ContractFactoryConstructor,
deployParams,
salt
salt,
);
}

async isDeployed<CFC extends ContractFactoryConstructor>(
ContractFactoryConstructor: CFC,
deployParams: DeployParams<CFC>,
salt: ethers.BytesLike = ethers.solidityPacked(["uint256"], [0])
salt: ethers.BytesLike = ethers.solidityPacked(["uint256"], [0]),
): Promise<boolean> {
return this.viewer.isDeployed(
ContractFactoryConstructor,
deployParams,
salt
salt,
);
}

async connectIfDeployed<CFC extends ContractFactoryConstructor>(
ContractFactoryConstructor: CFC,
deployParams: DeployParams<CFC>,
salt: ethers.BytesLike = ethers.solidityPacked(["uint256"], [0])
salt: ethers.BytesLike = ethers.solidityPacked(["uint256"], [0]),
): Promise<ReturnType<CFC["connect"]> | undefined> {
const contract = await this.viewer.connectIfDeployed(
ContractFactoryConstructor,
deployParams,
salt
salt,
);

return contract;
Expand All @@ -180,7 +180,7 @@ export default class SafeSingletonFactory {
async connectOrDeploy<CFC extends ContractFactoryConstructor>(
ContractFactoryConstructor: CFC,
deployParams: DeployParams<CFC>,
salt: ethers.BytesLike = ethers.solidityPacked(["uint256"], [0])
salt: ethers.BytesLike = ethers.solidityPacked(["uint256"], [0]),
): Promise<ReturnType<CFC["connect"]>> {
const contractFactory = new ContractFactoryConstructor();

Expand All @@ -191,15 +191,15 @@ export default class SafeSingletonFactory {
const address = this.calculateAddress(
ContractFactoryConstructor,
deployParams,
salt
salt,
);

const existingCode = await this.provider.getCode(address);

if (existingCode !== "0x") {
return ContractFactoryConstructor.connect(
address,
this.signer
this.signer,
) as ReturnType<CFC["connect"]>;
}

Expand Down Expand Up @@ -237,7 +237,7 @@ export default class SafeSingletonFactory {
}

const balance = await this.provider.getBalance(
this.signer.getAddress()
this.signer.getAddress(),
);

throw new Error(
Expand All @@ -249,7 +249,7 @@ export default class SafeSingletonFactory {
"ETH, need (approx):",
ethers.formatEther(gasEstimate * gasPrice),
"ETH",
].join(" ")
].join(" "),
);
}

Expand All @@ -263,14 +263,14 @@ export default class SafeSingletonFactory {

const deployedCode = await this.provider.getCode(
address,
receipt.blockNumber
receipt.blockNumber,
);

assert(deployedCode !== "0x", "Failed to deploy to expected address");

return ContractFactoryConstructor.connect(
address,
this.signer
this.signer,
) as ReturnType<CFC["connect"]>;
}
}
Expand All @@ -282,7 +282,7 @@ export class SafeSingletonFactoryViewer {

constructor(
public signerOrProvider: SignerOrProvider,
public chainId: bigint
public chainId: bigint,
) {
this.safeSingletonFactoryAddress =
SafeSingletonFactory.deployments[Number(chainId)]?.address ??
Expand Down Expand Up @@ -323,7 +323,7 @@ export class SafeSingletonFactoryViewer {
calculateAddress<CFC extends ContractFactoryConstructor>(
ContractFactoryConstructor: CFC,
deployParams: DeployParams<CFC>,
salt: ethers.BytesLike = ethers.solidityPacked(["uint256"], [0])
salt: ethers.BytesLike = ethers.solidityPacked(["uint256"], [0]),
) {
const contractFactory = new ContractFactoryConstructor();

Expand All @@ -334,19 +334,19 @@ export class SafeSingletonFactoryViewer {
return ethers.getCreate2Address(
this.safeSingletonFactoryAddress,
salt,
ethers.keccak256(initCode)
ethers.keccak256(initCode),
);
}

async isDeployed<CFC extends ContractFactoryConstructor>(
ContractFactoryConstructor: CFC,
deployParams: DeployParams<CFC>,
salt: ethers.BytesLike = ethers.solidityPacked(["uint256"], [0])
salt: ethers.BytesLike = ethers.solidityPacked(["uint256"], [0]),
) {
const address = this.calculateAddress(
ContractFactoryConstructor,
deployParams,
salt
salt,
);

const existingCode = await this.provider.getCode(address);
Expand All @@ -357,17 +357,17 @@ export class SafeSingletonFactoryViewer {
connectAssume<CFC extends ContractFactoryConstructor>(
ContractFactoryConstructor: CFC,
deployParams: DeployParams<CFC>,
salt: ethers.BytesLike = ethers.solidityPacked(["uint256"], [0])
salt: ethers.BytesLike = ethers.solidityPacked(["uint256"], [0]),
): ReturnType<CFC["connect"]> {
const address = this.calculateAddress(
ContractFactoryConstructor,
deployParams,
salt
salt,
);

const contract = ContractFactoryConstructor.connect(
address,
this.signer ?? this.provider
this.signer ?? this.provider,
) as ReturnType<CFC["connect"]>;

return contract;
Expand All @@ -376,12 +376,12 @@ export class SafeSingletonFactoryViewer {
async connectIfDeployed<CFC extends ContractFactoryConstructor>(
ContractFactoryConstructor: CFC,
deployParams: DeployParams<CFC>,
salt: ethers.BytesLike = ethers.solidityPacked(["uint256"], [0])
salt: ethers.BytesLike = ethers.solidityPacked(["uint256"], [0]),
): Promise<ReturnType<CFC["connect"]> | undefined> {
const contract = this.connectAssume(
ContractFactoryConstructor,
deployParams,
salt
salt,
);

const existingCode = await this.provider.getCode(contract.getAddress());
Expand All @@ -396,12 +396,12 @@ export class SafeSingletonFactoryViewer {
async connectOrThrow<CFC extends ContractFactoryConstructor>(
ContractFactoryConstructor: CFC,
deployParams: DeployParams<CFC>,
salt: ethers.BytesLike = ethers.solidityPacked(["uint256"], [0])
salt: ethers.BytesLike = ethers.solidityPacked(["uint256"], [0]),
): Promise<ReturnType<CFC["connect"]>> {
const contract = await this.connectIfDeployed(
ContractFactoryConstructor,
deployParams,
salt
salt,
);

if (!contract) {
Expand All @@ -411,8 +411,8 @@ export class SafeSingletonFactoryViewer {
} not deployed at ${this.calculateAddress(
ContractFactoryConstructor,
deployParams,
salt
)}`
salt,
)}`,
);
}

Expand Down
2 changes: 1 addition & 1 deletion account-integrations/safe/test/hardhat/utils/assert.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function assert(
condition: unknown,
msg = "Assertion failed"
msg = "Assertion failed",
): asserts condition {
if (!condition) {
throw new AssertionError(msg);
Expand Down

0 comments on commit 4f2a0ac

Please sign in to comment.