From bafcfad4a0f6a3364a7d6a7ebe32510ec53a1873 Mon Sep 17 00:00:00 2001 From: Shirren Date: Tue, 12 Dec 2023 08:18:34 +1100 Subject: [PATCH] Ready for another review, improved the wallet options --- scripts/index.ts | 7 ++----- scripts/ledger-signer.ts | 5 ----- scripts/wallet-options.ts | 15 +++++---------- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/scripts/index.ts b/scripts/index.ts index 7e22ca8..6d943a9 100644 --- a/scripts/index.ts +++ b/scripts/index.ts @@ -33,11 +33,10 @@ async function main(): Promise { // Setup wallet const wallets: WalletOptions = await newWalletOptions(environment); - /* - console.log(`[${network}] Contract Deployer Address: ${await wallets.getContractDeployer().getAddress()}`); + //console.log(`[${network}] Contract Deployer Address: ${await wallets.getContractDeployer().getAddress()}`); console.log( `[${network}] Wallet Impl Locator Changer Address: ${await wallets.getWalletImplLocatorChanger().getAddress()}` - );*/ + ); // TOTAL deployment cost = 0.009766773 GWEI = 0.000000000009766773 ETHER // Deployments with esimated gas costs (GWEI) @@ -50,8 +49,6 @@ async function main(): Promise { await multiCallDeploy.deployTransaction.wait(); console.log(`[${network}] Multi Call Deploy deployed to: ${multiCallDeploy.address}`); - return environment; - // 2. Deploy factory with multi call deploy address as deployer role EST // EST gas cost: 0.001239658 const factoryCF: ContractFactory = await newContractFactory(wallets.getContractDeployer(), 'Factory'); diff --git a/scripts/ledger-signer.ts b/scripts/ledger-signer.ts index 8fda7b5..6b705d4 100644 --- a/scripts/ledger-signer.ts +++ b/scripts/ledger-signer.ts @@ -38,7 +38,6 @@ export class LedgerSigner extends ethers.Signer { try { const eth = new Eth(transport); await eth.getAppConfiguration(); - console.log(`?: ${eth}`); return eth; } catch (error) { throw 'LedgerSigner: unable to initialize TransportNodeHid: ' + error; @@ -58,20 +57,16 @@ export class LedgerSigner extends ethers.Signer { } public async getAddress(): Promise { - console.log(`getAddress: on LedgerSigner for path: ${this.path}`); const eth = await this._eth; const MAX_RETRY_COUNT = 50; const WAIT_INTERVAL = 100; for (let i = 0; i < MAX_RETRY_COUNT; i++) { - console.log('In loop'); try { const account = await eth!.getAddress(this.path); - console.log(`account: ${account.address}`); return ethers.utils.getAddress(account.address); } catch (error) { - console.log('getAddress: failed'); if ((error as any).id !== 'TransportLocked') { throw error; } diff --git a/scripts/wallet-options.ts b/scripts/wallet-options.ts index 09e6525..142b8dc 100644 --- a/scripts/wallet-options.ts +++ b/scripts/wallet-options.ts @@ -10,9 +10,8 @@ const mainnetEnv = 'mainnet'; * which used the following type to configure the connect function. */ export class WalletOptions { - useLedger: boolean; - private contractDeployerLedger: LedgerSigner; - private walletImplLocatorImplChangerLedger: LedgerSigner; + private useLedger: boolean; + private ledger: LedgerSigner; private contractDeployer: Signer; private walletImplLocatorImplChanger: Signer; @@ -25,13 +24,9 @@ export class WalletOptions { this.useLedger = false; } - // Setup the 2 ledgers const accountIndex0 = 0; const derivationPath0 = `m/44'/60'/${accountIndex0.toString()}'/0/0`; - this.contractDeployerLedger = new LedgerSigner(hardhat.provider, derivationPath0); - const accountIndex1 = 1; - const derivationPath1 = `m/44'/60'/${accountIndex1.toString()}'/0/0`; - this.walletImplLocatorImplChangerLedger = new LedgerSigner(hardhat.provider, derivationPath1); + this.ledger = new LedgerSigner(hardhat.provider, derivationPath0); // Setup the 2 programmatic wallets this.contractDeployer = contractDeployer; @@ -39,11 +34,11 @@ export class WalletOptions { } public getContractDeployer(): Signer { - return this.useLedger ? this.contractDeployerLedger : this.contractDeployer; + return this.useLedger ? this.ledger : this.contractDeployer; } public getWalletImplLocatorChanger(): Signer { - return this.useLedger ? this.walletImplLocatorImplChangerLedger : this.walletImplLocatorImplChanger; + return this.walletImplLocatorImplChanger; } }