Skip to content

Commit

Permalink
we dont need to parse everytime this.getKit is called.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronmgdr committed Mar 26, 2024
1 parent 206fc19 commit 70f88fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/cli/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,14 @@ export abstract class BaseCommand extends Command {
}

async getKit() {
if (!this._kit) {
this._kit = newKitFromWeb3(await this.getWeb3())
// return now if kit already has been built instead of doing all that parsing and awaiting
// because this.getKit is called when closing down the command by not returning early this.parse would be called and weird logs occure
if (this._kit) {
return this._kit
}

this._kit = newKitFromWeb3(await this.getWeb3())

const res = await this.parse()
if (res.flags && res.flags.privateKey && !res.flags.useLedger && !res.flags.useAKV) {
this._kit.connection.addAccount(res.flags.privateKey)
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/governance/propose.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ testWithGanache('governance:propose cmd', (web3: Web3) => {
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Couldn't build call for transaction: {"contract":"0x552b9AA0eEe500c60f09456e49FBc1096322714C","function":"approve(address,uint256)","args":["0xFa3df877F98ac5ecd87456a7AcCaa948462412f0","10000000000000000000000000"],"value":"0"}"`
)
}, 8000)
}, 20000)

test('succeeds when proposal contains transactions for contracts verified on celoScan', async () => {
const transactionsToBeSaved = JSON.stringify(transactionsForContractsVerifiedOnCeloScan)
Expand All @@ -410,5 +410,5 @@ testWithGanache('governance:propose cmd', (web3: Web3) => {
'--descriptionURL',
'https://example.com',
])
}, 8000)
}, 20000)
})

0 comments on commit 70f88fc

Please sign in to comment.