Skip to content

Commit

Permalink
feat(plg): add some nice spinners (#2)
Browse files Browse the repository at this point in the history
Minor PR, just adding some nice spinners to the output of running the
hardhat tasks.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
smartcontracts and mergify[bot] authored Jul 18, 2022
1 parent 21e6f2c commit 310dfd9
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 3 deletions.
10 changes: 10 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://unpkg.com/@changesets/config@1.6.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"linked": [],
"access": "public",
"baseBranch": "develop",
"updateInternalDependencies": "patch",
"ignore": []
}
5 changes: 5 additions & 0 deletions .changeset/lovely-nails-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chugsplash/plugins': patch
---

Adds some nice spinners to hardhat tasks
1 change: 1 addition & 0 deletions packages/plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"ethers": "^5.6.9",
"ipfs-http-client": "56.0.3",
"node-fetch": "^2.6.7",
"ora": "^5.4.1",
"semver": "^7.3.7"
},
"devDependencies": {
Expand Down
23 changes: 20 additions & 3 deletions packages/plugins/src/hardhat/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
CanonicalChugSplashConfig,
ChugSplashActionBundle,
} from '@chugsplash/core'
import ora from 'ora'

import { getContractArtifact, getStorageLayout } from './artifacts'

Expand All @@ -32,6 +33,8 @@ const TASK_CHUGSPLASH_BUNDLE_REMOTE = 'chugsplash-bundle-remote'
const TASK_CHUGSPLASH_VERIFY = 'chugsplash-verify'
const TASK_CHUGSPLASH_COMMIT = 'chugsplash-commit'

const spinner = ora()

subtask(TASK_CHUGSPLASH_LOAD)
.addParam('deployConfig', undefined, undefined, types.string)
.setAction(
Expand Down Expand Up @@ -157,9 +160,11 @@ task(TASK_CHUGSPLASH_COMMIT)
},
hre
) => {
spinner.start('Compiling deploy config...')
const config: ChugSplashConfig = await hre.run(TASK_CHUGSPLASH_LOAD, {
deployConfig: args.deployConfig,
})
spinner.succeed('Compiled deploy config')

const ipfs = create({
url: args.ipfsUrl || 'https://ipfs.infura.io:5001/api/v0',
Expand Down Expand Up @@ -191,6 +196,7 @@ task(TASK_CHUGSPLASH_COMMIT)
})

// Publish config to IPFS
spinner.start('Publishing config to IPFS...')
const configPublishResult = await ipfs.add(
JSON.stringify(
{
Expand All @@ -201,13 +207,16 @@ task(TASK_CHUGSPLASH_COMMIT)
2
)
)
spinner.succeed('Published config to IPFS')

spinner.start('Building artifact bundle...')
const bundle = await hre.run(TASK_CHUGSPLASH_BUNDLE_LOCAL, {
deployConfig: args.deployConfig,
})
spinner.succeed('Built artifact bundle')

console.log(`Config: ipfs://${configPublishResult.path}`)
console.log(`Bundle: ${bundle.root}`)
spinner.succeed(`Config: ipfs://${configPublishResult.path}`)
spinner.succeed(`Bundle: ${bundle.root}`)
}
)

Expand All @@ -226,22 +235,30 @@ task(TASK_CHUGSPLASH_VERIFY)
config: CanonicalChugSplashConfig
bundle: ChugSplashActionBundle
}> => {
spinner.start('Fetching config, this might take a while...')
const config: CanonicalChugSplashConfig = await hre.run(
TASK_CHUGSPLASH_FETCH,
{
configUri: args.configUri,
}
)
spinner.succeed('Fetched config')

spinner.start('Building artifact bundle...')
const bundle: ChugSplashActionBundle = await hre.run(
TASK_CHUGSPLASH_BUNDLE_REMOTE,
{
deployConfig: config,
}
)
spinner.succeed('Built artifact bundle')

if (bundle.root !== args.bundleHash) {
throw new Error('bundle hash does not match')
spinner.fail(
'Bundle hash generated from downloaded config does NOT match given hash'
)
} else {
spinner.succeed('Bundle hash verified')
}

return {
Expand Down
34 changes: 34 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1924,6 +1924,15 @@ bintrees@1.0.2:
resolved "https://registry.yarnpkg.com/bintrees/-/bintrees-1.0.2.tgz#49f896d6e858a4a499df85c38fb399b9aff840f8"
integrity sha512-VOMgTMwjAaUG580SXn3LacVgjurrbMme7ZZNYGSSV7mmtY6QQRh0Eg3pwIcntQ77DErK1L0NxkbetjcoXzVwKw==

bl@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/bl/-/bl-4.1.0.tgz#451535264182bec2fbbc83a62ab98cf11d9f7b3a"
integrity sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==
dependencies:
buffer "^5.5.0"
inherits "^2.0.4"
readable-stream "^3.4.0"

blakejs@^1.1.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/blakejs/-/blakejs-1.2.1.tgz#5057e4206eadb4a97f7c0b6e197a505042fc3814"
Expand Down Expand Up @@ -2294,6 +2303,11 @@ cli-cursor@^3.1.0:
dependencies:
restore-cursor "^3.1.0"

cli-spinners@^2.5.0:
version "2.6.1"
resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.6.1.tgz#adc954ebe281c37a6319bfa401e6dd2488ffb70d"
integrity sha512-x/5fWmGMnbKQAaNwN+UZlV79qBLM9JFnJuJ03gIi5whrob0xV0ofNVHy9DhwGdsMJQc2OKv0oGmLzvaqvAVv+g==

cli-truncate@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cli-truncate/-/cli-truncate-2.1.0.tgz#c39e28bf05edcde5be3b98992a22deed5a2b93c7"
Expand Down Expand Up @@ -4514,6 +4528,11 @@ is-hex-prefixed@1.0.0:
resolved "https://registry.yarnpkg.com/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz#7d8d37e6ad77e5d127148913c573e082d777f554"
integrity sha512-WvtOiug1VFrE9v1Cydwm+FnXd3+w9GaeVUss5W4v/SLy3UW00vP+6iNF2SdnfiBoLy4bTqVdkftNGTUeOFVsbA==

is-interactive@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-interactive/-/is-interactive-1.0.0.tgz#cea6e6ae5c870a7b0a0004070b7b587e0252912e"
integrity sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==

is-ip@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/is-ip/-/is-ip-3.1.0.tgz#2ae5ddfafaf05cb8008a62093cf29734f657c5d8"
Expand Down Expand Up @@ -5799,6 +5818,21 @@ optionator@^0.9.1:
type-check "^0.4.0"
word-wrap "^1.2.3"

ora@^5.4.1:
version "5.4.1"
resolved "https://registry.yarnpkg.com/ora/-/ora-5.4.1.tgz#1b2678426af4ac4a509008e5e4ac9e9959db9e18"
integrity sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==
dependencies:
bl "^4.1.0"
chalk "^4.1.0"
cli-cursor "^3.1.0"
cli-spinners "^2.5.0"
is-interactive "^1.0.0"
is-unicode-supported "^0.1.0"
log-symbols "^4.1.0"
strip-ansi "^6.0.0"
wcwidth "^1.0.1"

os-tmpdir@~1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
Expand Down

0 comments on commit 310dfd9

Please sign in to comment.