Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Commit

Permalink
Use Signer instead of Wallet or SignerWithAddress (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nenad Misic authored Sep 18, 2023
1 parent 0c6ccb5 commit 7c5b02d
Show file tree
Hide file tree
Showing 76 changed files with 587 additions and 508 deletions.
4 changes: 2 additions & 2 deletions contracts/core/accounts/scripts/deploy/cutDiamond.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {Signer} from "ethers";
import {HardhatRuntimeEnvironment} from "hardhat/types";
import {DiamondCutFacet__factory, DiamondInit__factory} from "typechain-types";
import {getAxlNetworkName, logger} from "utils";
Expand All @@ -7,7 +7,7 @@ import {FacetCut} from "./types";
export default async function cutDiamond(
address: string,
diamondInit: string,
admin: SignerWithAddress,
admin: Signer,
owner: string,
registrar: string,
facetCuts: FacetCut[],
Expand Down
17 changes: 6 additions & 11 deletions contracts/core/accounts/scripts/deploy/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {ContractFactory} from "ethers";
import {ContractFactory, Signer} from "ethers";
import {HardhatRuntimeEnvironment} from "hardhat/types";
import {
DiamondCutFacet__factory,
Expand All @@ -16,7 +15,7 @@ export async function deployAccountsDiamond(
owner: string,
registrar: string,
diamondAdmin: string,
deployer: SignerWithAddress,
deployer: Signer,
hre: HardhatRuntimeEnvironment
): Promise<{
diamond: Deployment<Diamond__factory>;
Expand Down Expand Up @@ -51,7 +50,7 @@ export async function deployAccountsDiamond(
}

async function deployDiamond(
deployer: SignerWithAddress,
deployer: Signer,
hre: HardhatRuntimeEnvironment
): Promise<{
diamond: Deployment<Diamond__factory>;
Expand All @@ -60,7 +59,7 @@ async function deployDiamond(
const diamondCutFacet = await deploy(new DiamondCutFacet__factory(deployer));

const diamond = await deploy(new Diamond__factory(deployer), [
deployer.address,
await deployer.getAddress(),
diamondCutFacet.contract.address,
]);

Expand All @@ -86,7 +85,7 @@ async function deployDiamond(
* @param admin signer representing administrator of the contract
*/
async function deployDiamondInit(
admin: SignerWithAddress,
admin: Signer,
hre: HardhatRuntimeEnvironment
): Promise<Deployment<DiamondInit__factory>> {
const diamondInit = await deploy(new DiamondInit__factory(admin));
Expand All @@ -96,11 +95,7 @@ async function deployDiamondInit(
return diamondInit;
}

async function setDiamondContractOwner(
address: string,
newOwner: string,
curOwner: SignerWithAddress
) {
async function setDiamondContractOwner(address: string, newOwner: string, curOwner: Signer) {
logger.out(`Transferring ownership from "${curOwner}" to "${newOwner}"...`);
const accountsDiamond = IERC173__factory.connect(address, curOwner);
const tx = await accountsDiamond.transferOwnership(newOwner);
Expand Down
6 changes: 3 additions & 3 deletions contracts/core/accounts/scripts/deploy/deployDiamond.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {Signer} from "ethers";
import {HardhatRuntimeEnvironment} from "hardhat/types";
import {
Diamond,
Expand All @@ -9,7 +9,7 @@ import {
import {logger, updateAddresses} from "utils";

export default async function deployDiamond(
admin: SignerWithAddress,
admin: Signer,
hre: HardhatRuntimeEnvironment
): Promise<{diamond: Diamond; diamondCutFacet: DiamondCutFacet}> {
const DiamondCutFacet = new DiamondCutFacet__factory(admin);
Expand All @@ -18,7 +18,7 @@ export default async function deployDiamond(
logger.out(`DiamondCutFacet deployed at: ${diamondCutFacet.address}`);

const Diamond = new Diamond__factory(admin);
const diamond = await Diamond.deploy(admin.address, diamondCutFacet.address);
const diamond = await Diamond.deploy(await admin.getAddress(), diamondCutFacet.address);
await diamond.deployed();
logger.out(`Diamond deployed at: ${diamond.address}`);

Expand Down
4 changes: 2 additions & 2 deletions contracts/core/accounts/scripts/deploy/deployFacets.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {HardhatRuntimeEnvironment} from "hardhat/types";
import {deploy, logger, updateAddresses} from "utils";
import {FacetCutAction, getSelectors} from "../libraries/diamond";
import getFacetFactoryEntries from "./getFacetFactoryEntries";
import {FacetCut} from "./types";
import {Signer} from "ethers";

export default async function deployFacets(
diamondOwner: SignerWithAddress,
diamondOwner: Signer,
hre: HardhatRuntimeEnvironment
): Promise<FacetCut[]> {
logger.out("Deploying facets...");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {ContractFactory} from "ethers";
import {ContractFactory, Signer} from "ethers";
import {
AccountsDepositWithdrawEndowments__factory,
AccountsAllowance__factory,
Expand All @@ -18,7 +17,7 @@ import {
import {AddressObj} from "utils";

// Getting factories instantiated in bulk as they share the deploy/cut creation logic.
export default function getFacetFactoryEntries(diamondOwner: SignerWithAddress): {
export default function getFacetFactoryEntries(diamondOwner: Signer): {
factory: ContractFactory;
addressField: keyof AddressObj["accounts"]["facets"];
}[] {
Expand Down
4 changes: 2 additions & 2 deletions contracts/core/gasFwd/scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {Signer} from "ethers";
import {HardhatRuntimeEnvironment} from "hardhat/types";
import {GasFwdFactory__factory, GasFwd__factory} from "typechain-types";
import {Deployment} from "types";
import {deploy, logger, updateAddresses} from "utils";

type Data = {
deployer: SignerWithAddress;
deployer: Signer;
proxyAdmin: string;
factoryOwner: string;
registrar: string;
Expand Down
4 changes: 2 additions & 2 deletions contracts/core/index-fund/scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {CONFIG} from "config";
import {Signer} from "ethers";
import {HardhatRuntimeEnvironment} from "hardhat/types";
import {IndexFund__factory} from "typechain-types";
import {ProxyDeployment} from "types";
Expand All @@ -9,7 +9,7 @@ export async function deployIndexFund(
registrar: string,
owner: string,
proxyAdmin: string,
deployer: SignerWithAddress,
deployer: Signer,
hre: HardhatRuntimeEnvironment
): Promise<ProxyDeployment<IndexFund__factory>> {
// data setup
Expand Down
6 changes: 3 additions & 3 deletions contracts/core/registrar/scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {Signer} from "ethers";
import {HardhatRuntimeEnvironment} from "hardhat/types";
import {LocalRegistrar__factory, Registrar__factory} from "typechain-types";
import {ProxyDeployment} from "types";
Expand All @@ -9,7 +9,7 @@ type RegistrarDeployData = {
axelarGasService: string;
router: string;
owner: string;
deployer: SignerWithAddress;
deployer: Signer;
proxyAdmin: string;
treasury: string;
apTeamMultisig: string;
Expand Down Expand Up @@ -75,7 +75,7 @@ export async function deployRegistrar(

type LocalRegistrarDeployData = {
owner: string;
deployer: SignerWithAddress;
deployer: Signer;
proxyAdmin: string;
};

Expand Down
4 changes: 2 additions & 2 deletions contracts/core/router/scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {Signer} from "ethers";
import {HardhatRuntimeEnvironment} from "hardhat/types";
import {Router__factory} from "typechain-types";
import {ProxyDeployment} from "types";
Expand All @@ -7,7 +7,7 @@ import {deployBehindProxy, updateAddresses} from "utils";
export async function deployRouter(
registrar: string,
proxyAdmin: string,
deployer: SignerWithAddress,
deployer: Signer,
hre: HardhatRuntimeEnvironment
): Promise<ProxyDeployment<Router__factory>> {
// data setup
Expand Down
4 changes: 2 additions & 2 deletions contracts/core/vault/scripts/deployVaultEmitter.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {Signer} from "ethers";
import {HardhatRuntimeEnvironment} from "hardhat/types";
import {VaultEmitter__factory} from "typechain-types";
import {ProxyDeployment} from "types";
import {deployBehindProxy, updateAddresses} from "utils";

export async function deployVaultEmitter(
proxyAdmin: string,
deployer: SignerWithAddress,
deployer: Signer,
hre: HardhatRuntimeEnvironment
): Promise<ProxyDeployment<VaultEmitter__factory>> {
// data setup
Expand Down
6 changes: 5 additions & 1 deletion contracts/halo/airdrop/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ export async function deployAirdrop(
const Airdrop = new Airdrop__factory(deployer);
const initData = Airdrop.interface.encodeFunctionData("initialize", [AirdropDataInput]);
// deploy
const {implementation, proxy} = await deployBehindProxy(Airdrop, proxyAdmin.address, initData);
const {implementation, proxy} = await deployBehindProxy(
Airdrop,
await proxyAdmin.getAddress(),
initData
);

// update address file
await updateAddresses(
Expand Down
2 changes: 1 addition & 1 deletion contracts/halo/collector/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function deployCollector(
// deploy
const {implementation, proxy} = await deployBehindProxy(
Collector,
proxyAdmin.address,
await proxyAdmin.getAddress(),
initData
);

Expand Down
2 changes: 1 addition & 1 deletion contracts/halo/community/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function deployCommunity(
// deploy
const {implementation, proxy} = await deployBehindProxy(
Community,
proxyAdmin.address,
await proxyAdmin.getAddress(),
initData
);

Expand Down
6 changes: 5 additions & 1 deletion contracts/halo/gov/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ export async function deployGov(
const Gov = new Gov__factory(deployer);
const initData = Gov.interface.encodeFunctionData("initialize", [haloToken, timelock]);
// deploy
const {implementation, proxy} = await deployBehindProxy(Gov, proxyAdmin.address, initData);
const {implementation, proxy} = await deployBehindProxy(
Gov,
await proxyAdmin.getAddress(),
initData
);

// update address file
await updateAddresses(
Expand Down
6 changes: 5 additions & 1 deletion contracts/halo/staking/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ export async function deployStaking(
const Staking = new Staking__factory(deployer);
const initData = Staking.interface.encodeFunctionData("initialize", [StakingDataInput]);
// deploy
const {implementation, proxy} = await deployBehindProxy(Staking, proxyAdmin.address, initData);
const {implementation, proxy} = await deployBehindProxy(
Staking,
await proxyAdmin.getAddress(),
initData
);

// update address file
await updateAddresses(
Expand Down
6 changes: 5 additions & 1 deletion contracts/halo/vesting/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ export async function deployVesting(
const Vesting = new Vesting__factory(deployer);
const initData = Vesting.interface.encodeFunctionData("initialize", [VestingDataInput]);
// deploy
const {implementation, proxy} = await deployBehindProxy(Vesting, proxyAdmin.address, initData);
const {implementation, proxy} = await deployBehindProxy(
Vesting,
await proxyAdmin.getAddress(),
initData
);

// update address file
await updateAddresses(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {Signer} from "ethers";
import {HardhatRuntimeEnvironment} from "hardhat/types";
import {EndowmentMultiSig__factory} from "typechain-types";
import {Deployment} from "types";
import {deploy, logger, updateAddresses} from "utils";

export async function deployEndowmentMultiSig(
deployer: SignerWithAddress,
deployer: Signer,
hre: HardhatRuntimeEnvironment
): Promise<Deployment<EndowmentMultiSig__factory>> {
logger.out("Deploying EndowmentMultiSig...");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {Signer} from "ethers";
import {HardhatRuntimeEnvironment} from "hardhat/types";
import {EndowmentMultiSigEmitter__factory} from "typechain-types";
import {ProxyDeployment} from "types";
Expand All @@ -7,7 +7,7 @@ import {deployBehindProxy, logger, updateAddresses} from "utils";
export async function deployEndowmentMultiSigEmitter(
factory: string,
proxyAdmin: string,
deployer: SignerWithAddress,
deployer: Signer,
hre: HardhatRuntimeEnvironment
): Promise<ProxyDeployment<EndowmentMultiSigEmitter__factory>> {
logger.out("Deploying EndowmentMultiSigEmitter...");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {Signer} from "ethers";
import {HardhatRuntimeEnvironment} from "hardhat/types";
import {EndowmentMultiSigFactory__factory} from "typechain-types";
import {Deployment} from "types";
Expand All @@ -9,7 +9,7 @@ export async function deployEndowmentMultiSigFactory(
registrar: string,
proxyAdmin: string,
factoryOwner: string,
deployer: SignerWithAddress,
deployer: Signer,
hre: HardhatRuntimeEnvironment
): Promise<Deployment<EndowmentMultiSigFactory__factory>> {
logger.out("Deploying EndowmentMultiSigFactory...");
Expand Down
6 changes: 3 additions & 3 deletions contracts/multisigs/scripts/deployAPTeamMultiSig.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {CONFIG} from "config";
import {Signer} from "ethers";
import {HardhatRuntimeEnvironment} from "hardhat/types";
import {APTeamMultiSig__factory} from "typechain-types";
import {ProxyDeployment} from "types";
import {deployBehindProxy, getSigners, updateAddresses} from "utils";

export async function deployAPTeamMultiSig(
proxyAdmin: string,
deployer: SignerWithAddress,
deployer: Signer,
hre: HardhatRuntimeEnvironment
): Promise<ProxyDeployment<APTeamMultiSig__factory>> {
const {apTeamMultisigOwners} = await getSigners(hre);
const owners = apTeamMultisigOwners
? apTeamMultisigOwners.map((x) => x.address)
? await Promise.all(apTeamMultisigOwners.map((x) => x.getAddress()))
: CONFIG.PROD_CONFIG.APTeamMultiSigOwners;

// data setup
Expand Down
6 changes: 3 additions & 3 deletions contracts/multisigs/scripts/deployCharityApplications.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {CONFIG} from "config";
import {Signer} from "ethers";
import {HardhatRuntimeEnvironment} from "hardhat/types";
import {CharityApplications__factory} from "typechain-types";
import {ProxyDeployment} from "types";
Expand All @@ -9,13 +9,13 @@ export async function deployCharityApplications(
accountsDiamond: string,
proxyAdmin: string,
seedAsset: string,
deployer: SignerWithAddress,
deployer: Signer,
hre: HardhatRuntimeEnvironment
): Promise<ProxyDeployment<CharityApplications__factory>> {
const {charityApplicationsOwners} = await getSigners(hre);
const owners = !charityApplicationsOwners
? CONFIG.PROD_CONFIG.CharityApplicationsOwners
: charityApplicationsOwners.map((x) => x.address);
: await Promise.all(charityApplicationsOwners.map((x) => x.getAddress()));

// data setup
const CharityApplications = new CharityApplications__factory(deployer);
Expand Down
4 changes: 2 additions & 2 deletions contracts/multisigs/scripts/deployProxyAdminMultiSig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {Signer} from "ethers";
import {CONFIG} from "config";
import {HardhatRuntimeEnvironment} from "hardhat/types";
import {ProxyAdminMultiSig__factory} from "typechain-types";
Expand All @@ -7,7 +7,7 @@ import {deploy, updateAddresses} from "utils";

export async function deployProxyAdminMultisig(
owners: string[],
deployer: SignerWithAddress,
deployer: Signer,
hre: HardhatRuntimeEnvironment
): Promise<Deployment<ProxyAdminMultiSig__factory>> {
const proxyAdmin = await deploy(new ProxyAdminMultiSig__factory(deployer), [
Expand Down
Loading

0 comments on commit 7c5b02d

Please sign in to comment.