diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 000000000..d18f3a96e --- /dev/null +++ b/.changeset/config.json @@ -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": [] +} diff --git a/.changeset/lovely-nails-count.md b/.changeset/lovely-nails-count.md new file mode 100644 index 000000000..6bfc9eae0 --- /dev/null +++ b/.changeset/lovely-nails-count.md @@ -0,0 +1,5 @@ +--- +'@chugsplash/plugins': patch +--- + +Adds some nice spinners to hardhat tasks diff --git a/packages/plugins/package.json b/packages/plugins/package.json index 343fc963b..d51aa4060 100644 --- a/packages/plugins/package.json +++ b/packages/plugins/package.json @@ -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": { diff --git a/packages/plugins/src/hardhat/tasks.ts b/packages/plugins/src/hardhat/tasks.ts index b2486df3c..4340476d0 100644 --- a/packages/plugins/src/hardhat/tasks.ts +++ b/packages/plugins/src/hardhat/tasks.ts @@ -19,6 +19,7 @@ import { CanonicalChugSplashConfig, ChugSplashActionBundle, } from '@chugsplash/core' +import ora from 'ora' import { getContractArtifact, getStorageLayout } from './artifacts' @@ -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( @@ -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', @@ -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( { @@ -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}`) } ) @@ -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 { diff --git a/yarn.lock b/yarn.lock index 99eef64f8..1bfbe820c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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" @@ -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" @@ -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"