diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c34e3ef1..19122656 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,9 @@ { "name": "swanky-env", - "image": "ghcr.io/swankyhub/swanky-cli/swanky-base:swanky3.1.0-beta.0_v2.1.0", - + "image": "ghcr.io/inkdevhub/swanky-cli/swanky-base:swanky3.1.0-beta.0_v2.1.1", + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2.8.0": {} + }, // Mount the workspace volume "mounts": ["source=${localWorkspaceFolder},target=/workspaces,type=bind,consistency=cached"], "workspaceFolder": "/workspaces", diff --git a/.github/ISSUE_TEMPLATE/backlog-ticket.md b/.github/ISSUE_TEMPLATE/backlog-ticket.md deleted file mode 100644 index 1d1fab10..00000000 --- a/.github/ISSUE_TEMPLATE/backlog-ticket.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -name: Backlog Ticket -about: New feature/ticket for the project -title: '' -labels: '' -assignees: '' - ---- - -# Overview (What and Why) -{Write description of what the feature should be, why} - -# How -{Describe what needs to be done.} - -- [ ] Task 1 -- [ ] Task 2 - -# Definition of Done -{Write definition of done, how to verify} - -- [ ] Unit test cases (delete if not applicable) -- [ ] Docs updated (delete if not applicable) -- [ ] PR approved and merged to master (delete if not applicable) - -# Open Issues and Blockers -{Dependencies issue or PR or some other blocker.} diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 00000000..7524d9ba --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,67 @@ +name: Bug Report +description: Create a report to help us improve +title: "[BUG]: " +labels: ["bug"] +projects: ["swanky-cli"] + +body: + - type: textarea + id: what-happened + attributes: + label: What happened? + description: Tell us what happened. In particular, tell us how and why you are using this project, and describe the bug that you encountered. Please note that we are not able to support all conceivable use cases, but the more information you are able to provide the more equipped we will be to help. + placeholder: Write your bug report here + validations: + required: true + - type: textarea + id: steps-to-reproduce + attributes: + label: Steps to reproduce + description: Replace the example steps below with actual steps to reproduce the bug you're reporting. + value: | + 1. Go to '...' + 2. Click on '....' + 3. Scroll down to '....' + 4. See error + validations: + required: true + - type: textarea + id: expected-behavior + attributes: + label: Expected behavior + description: Tell us what should happen + placeholder: Write your expected behavior here. + validations: + required: true + - type: textarea + id: actual-behavior + attributes: + label: Actual behavior + description: Tell us what happens instead + placeholder: Write your actual behavior here. + validations: + required: true + - type: textarea + id: environment + attributes: + label: Environment + description: Describe the environment in which you encountered this bug. Use the list below as a starting point and add additional information if you think it's relevant. + value: | + - Operating System + - Project version/tag: (run 'swanky version') + - Rust version (run `rustup show`) + - Node version (run `node --version`) + validations: + required: true + - type: textarea + id: logs + attributes: + label: Logs, Errors, Screenshots + description: Please provide the text of any logs or errors that you experienced; if applicable, provide screenshots to help illustrate the problem. + placeholder: | + Paste your logs here + - type: textarea + id: additional-info + attributes: + label: Additional information + description: Add any other context about the problem here. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index cf35c2d8..00000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: "[BUG]" -labels: bug -assignees: '' - ---- - -**Description** - -> Tell us what happened. In particular, tell us how and why you are using this project, and describe the bug that you encountered. Please note that we are not able to support all conceivable use cases, but the more information you are able to provide the more equipped we will be to help. - -**Steps to Reproduce** - -> Replace the example steps below with actual steps to reproduce the bug you're reporting. - -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected vs. Actual Behavior** - -> What did you expect to happen after you followed the steps you described in the last section? What actually happened? - -**Environment** - -> Describe the environment in which you encountered this bug. Use the list below as a starting point and add additional information if you think it's relevant. - -- Operating system: -- Project version/tag: (run 'swanky version') -- Rust version (run `rustup show`): -- Node version (run `node --version`) - -**Logs, Errors or Screenshots** - -> Please provide the text of any logs or errors that you experienced; if applicable, provide screenshots to help illustrate the problem. - -**Additional Information** - -> Please add any other details that you think may help us solve your problem. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..ec4bb386 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/new-feature.yml b/.github/ISSUE_TEMPLATE/new-feature.yml new file mode 100644 index 00000000..9759a9cf --- /dev/null +++ b/.github/ISSUE_TEMPLATE/new-feature.yml @@ -0,0 +1,43 @@ +name: Feature request +description: New feature/ticket for the project +labels: ["enhancement"] +projects: ["swanky-cli"] + +body: + - type: textarea + id: overview + attributes: + label: Overview (What and Why) + description: Write description of what the feature should be, why + validations: + required: true + + - type: textarea + id: how + attributes: + label: How to do it? + description: Describe what needs to be done. + placeholder: | + - Task 1 + - Task 2 + validations: + required: true + + - type: textarea + id: definition-of-done + attributes: + label: Definition of Done + description: Write definition of done, how to verify + placeholder: | + - Unit test cases + - Docs updated + - PR approved and merged to master + - etc. + validations: + required: true + + - type: textarea + id: open-issues-and-blockers + attributes: + label: Open Issues and Blockers + description: Dependencies issue or PR or some other blocker. diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index f079b4b5..24b1e07a 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -45,7 +45,7 @@ jobs: with: node-version: ${{ env.NODE_VER }} - - name: yarn test + - name: Check test run: yarn && yarn test lint-check: @@ -60,7 +60,7 @@ jobs: with: node-version: ${{ env.NODE_VER }} - - name: yarn lint + - name: Check lint run: yarn && yarn lint build-check: @@ -75,5 +75,20 @@ jobs: with: node-version: ${{ env.NODE_VER }} - - name: yarn build - run: yarn && yarn build \ No newline at end of file + - name: Check build + run: yarn && yarn build + + format-check: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + steps: + - name: Checkout the source code + uses: actions/checkout@v3 + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VER }} + + - name: Check formatting + run: yarn && yarn format \ No newline at end of file diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 00000000..593ac77a --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,35 @@ +# This configuration file was automatically generated by Gitpod. +# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml) +# and commit this file to your remote git repository to share the goodness with others. + +# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart + +ports: + - name: Swanky Node + port: 9944 + +vscode: + extensions: + - rust-lang.rust-analyzer + +tasks: + - init: | + # Add wasm target + rustup target add wasm32-unknown-unknown + + # Add necessary components + rustup component add rust-src + + # Install or update cargo packages + cargo install --force --locked cargo-contract + cargo install cargo-dylint dylint-link + + yarn install + yarn build + command: | + echo "Swanky Dev Environment ready!" + echo "Use Swanky directly by running \"./bin/run.js COMMAND\"" + echo "For example:" + echo "./bin/run.js init temp_project" + echo "cd temp_project" + echo "../bin/run.js contract compile flipper" diff --git a/README.md b/README.md index 51a6b4e4..4bc281dd 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- +

@@ -19,9 +19,9 @@ You can find more detailed info on installing and using Swanky CLI on [official # Quick start -If you use a devcontainer (see next section), or a [`swanky-base`](https://github.com/AstarNetwork/swanky-cli/pkgs/container/swanky-cli%2Fswanky-base) image, swanky will be preinstalled and globally available and you can use it to generate and develop smart contracts right away. +If you use a devcontainer (see next section), or a [`swanky-base`](https://github.com/inkdevhub/swanky-cli/pkgs/container/swanky-cli%2Fswanky-base) image, swanky will be preinstalled and globally available and you can use it to generate and develop smart contracts right away. -Otherwise, you can install it from [`npm`](https://www.npmjs.com/package/@astar-network/swanky-cli), or download the [binaries for your system](https://github.com/AstarNetwork/swanky-cli/releases/) +Otherwise, you can install it from [`npm`](https://www.npmjs.com/package/@astar-network/swanky-cli), or download the [binaries for your system](https://github.com/inkdevhub/swanky-cli/releases/) For a quick start, you can run @@ -64,7 +64,7 @@ This repo hosts a pre built Docker image that comes with the latest version of s You can use it directly as a container on your machine, or as a base for a dev container (or codespaces). -[Here is a template repo with a .devcontainer preconfigured](https://github.com/AstarNetwork/swanky-dev-container). +[Here is a template repo with a .devcontainer preconfigured](https://github.com/inkdevhub/swanky-dev-container). To use it, create a new repo from the template, and either start a devcontainer locally, or run it in a GitHub Codespace @@ -79,7 +79,7 @@ A newly generated project will have a `swanky.config.json` file that will get po "node": { "localPath": "/Users/sasapul/Work/astar/swanky-cli/temp_proj/bin/swanky-node", "polkadotPalletVersions": "polkadot-v0.9.39", - "supportedInk": "v4.2.0" + "supportedInk": "v5.0.0" }, "accounts": [ { @@ -106,7 +106,7 @@ A newly generated project will have a `swanky.config.json` file that will get po "url": "wss://rpc.shiden.astar.network" }, "shibuya": { - "url": "wss://rpc.shibuya.astar.network" + "url": "wss://shibuya.public.blastapi.io" } }, "contracts": { @@ -126,6 +126,51 @@ A newly generated project will have a `swanky.config.json` file that will get po } ``` +Also, global config will be created in your home directory, in `~/swanky` folder. + +## Example: + +```json +{ + "accounts": [ + { + "alias": "alice", + "mnemonic": "//Alice", + "isDev": true, + "address": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" + }, + { + "alias": "bob", + "mnemonic": "//Bob", + "isDev": true, + "address": "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty" + }, + { + "mnemonic": "broken estate advance smooth noble place wine choose scare east effort evil", + "isDev": true, + "alias": "global", + "address": "5FhfjMxbrJnjxuP5rP1ZorNaDJdE1n5LYpd7jTi9ByfVX1P1" + } + ], + "networks": { + "local": { + "url": "ws://127.0.0.1:9944" + }, + "astar": { + "url": "wss://rpc.astar.network" + }, + "shiden": { + "url": "wss://rpc.shiden.astar.network" + }, + "shibuya": { + "url": "wss://shibuya.public.blastapi.io" + } + } +} +``` + +You can use accounts and networks from the global config in any swanky project. + # Network Management You can deploy/call wasm smart contracts on any chains supporting the substrate contracts module ([`pallet-contracts`](https://github.com/paritytech/substrate/tree/master/frame/contracts)) by swanky-cli. @@ -177,7 +222,7 @@ cd temp_project # Reporting issues -Please report any issue or bug you encounter, as well as any feature and improvement requests to the [issues section](https://github.com/AstarNetwork/swanky-cli/issues) +Please report any issue or bug you encounter, as well as any feature and improvement requests to the [issues section](https://github.com/inkdevhub/swanky-cli/issues) # Command help @@ -187,7 +232,7 @@ $ npm install -g @astar-network/swanky-cli $ swanky COMMAND running command... $ swanky (--version|-V|-v) -@astar-network/swanky-cli/3.1.0-beta.0 darwin-x64 node-v20.2.0 +@astar-network/swanky-cli/4.0.0-beta.0 darwin-x64 node-v21.7.1 $ swanky --help [COMMAND] USAGE $ swanky COMMAND @@ -196,10 +241,13 @@ USAGE +* [`swanky account balance [ALIAS]`](#swanky-account-balance-alias) * [`swanky account create`](#swanky-account-create) +* [`swanky account default [ACCOUNTALIAS]`](#swanky-account-default-accountalias) +* [`swanky account faucet ALIAS`](#swanky-account-faucet-alias) * [`swanky account list`](#swanky-account-list) * [`swanky account ls`](#swanky-account-ls) -* [`swanky check`](#swanky-check) +* [`swanky clear [CONTRACTNAME]`](#swanky-clear-contractname) * [`swanky contract compile [CONTRACTNAME]`](#swanky-contract-compile-contractname) * [`swanky contract deploy CONTRACTNAME`](#swanky-contract-deploy-contractname) * [`swanky contract explain CONTRACTNAME`](#swanky-contract-explain-contractname) @@ -207,22 +255,52 @@ USAGE * [`swanky contract query CONTRACTNAME MESSAGENAME`](#swanky-contract-query-contractname-messagename) * [`swanky contract test [CONTRACTNAME]`](#swanky-contract-test-contractname) * [`swanky contract tx CONTRACTNAME MESSAGENAME`](#swanky-contract-tx-contractname-messagename) -* [`swanky contract typegen CONTRACTNAME`](#swanky-contract-typegen-contractname) -* [`swanky help [COMMANDS]`](#swanky-help-commands) +* [`swanky contract verify [CONTRACTNAME]`](#swanky-contract-verify-contractname) +* [`swanky env check`](#swanky-env-check) +* [`swanky env install`](#swanky-env-install) +* [`swanky generate tests [CONTRACTNAME]`](#swanky-generate-tests-contractname) +* [`swanky generate types CONTRACTNAME`](#swanky-generate-types-contractname) +* [`swanky help [COMMAND]`](#swanky-help-command) * [`swanky init PROJECTNAME`](#swanky-init-projectname) +* [`swanky node chopsticks init`](#swanky-node-chopsticks-init) +* [`swanky node chopsticks start`](#swanky-node-chopsticks-start) * [`swanky node install`](#swanky-node-install) * [`swanky node purge`](#swanky-node-purge) * [`swanky node start`](#swanky-node-start) +* [`swanky node version`](#swanky-node-version) * [`swanky plugins`](#swanky-plugins) * [`swanky plugins:install PLUGIN...`](#swanky-pluginsinstall-plugin) * [`swanky plugins:inspect PLUGIN...`](#swanky-pluginsinspect-plugin) * [`swanky plugins:install PLUGIN...`](#swanky-pluginsinstall-plugin-1) * [`swanky plugins:link PLUGIN`](#swanky-pluginslink-plugin) * [`swanky plugins:uninstall PLUGIN...`](#swanky-pluginsuninstall-plugin) +* [`swanky plugins reset`](#swanky-plugins-reset) * [`swanky plugins:uninstall PLUGIN...`](#swanky-pluginsuninstall-plugin-1) * [`swanky plugins:uninstall PLUGIN...`](#swanky-pluginsuninstall-plugin-2) * [`swanky plugins update`](#swanky-plugins-update) * [`swanky version`](#swanky-version) +* [`swanky zombienet init`](#swanky-zombienet-init) +* [`swanky zombienet start`](#swanky-zombienet-start) + +## `swanky account balance [ALIAS]` + +Balance of an account + +``` +USAGE + $ swanky account balance [ALIAS] [-v] + +ARGUMENTS + ALIAS Alias of account to be used + +FLAGS + -v, --verbose Display more info in the result logs + +DESCRIPTION + Balance of an account +``` + +_See code: [src/commands/account/balance.ts](https://github.com/inkdevhub/swanky-cli/blob/v4.0.0-beta.0/src/commands/account/balance.ts)_ ## `swanky account create` @@ -230,17 +308,61 @@ Create a new dev account in config ``` USAGE - $ swanky account create [-v] [-g] [-d] + $ swanky account create [-v] [-g] [-n] [-d] FLAGS - -d, --dev - -g, --generate - -v, --verbose Display more info in the result logs + -d, --dev Make this account a dev account for local network usage. + -g, --global Create account globally stored in Swanky system config. + -n, --new Generate a brand new account. + -v, --verbose Display more info in the result logs DESCRIPTION Create a new dev account in config ``` +_See code: [src/commands/account/create.ts](https://github.com/inkdevhub/swanky-cli/blob/v4.0.0-beta.0/src/commands/account/create.ts)_ + +## `swanky account default [ACCOUNTALIAS]` + +Set default account to use + +``` +USAGE + $ swanky account default [ACCOUNTALIAS] [-v] [-g] + +ARGUMENTS + ACCOUNTALIAS Alias of account to be used as default + +FLAGS + -g, --global Set default account globally in Swanky system config. + -v, --verbose Display more info in the result logs + +DESCRIPTION + Set default account to use +``` + +_See code: [src/commands/account/default.ts](https://github.com/inkdevhub/swanky-cli/blob/v4.0.0-beta.0/src/commands/account/default.ts)_ + +## `swanky account faucet ALIAS` + +Transfer some tokens from faucet to an account + +``` +USAGE + $ swanky account faucet ALIAS [-v] + +ARGUMENTS + ALIAS Alias of account to be used + +FLAGS + -v, --verbose Display more info in the result logs + +DESCRIPTION + Transfer some tokens from faucet to an account +``` + +_See code: [src/commands/account/faucet.ts](https://github.com/inkdevhub/swanky-cli/blob/v4.0.0-beta.0/src/commands/account/faucet.ts)_ + ## `swanky account list` List dev accounts stored in config @@ -259,6 +381,8 @@ ALIASES $ swanky account ls ``` +_See code: [src/commands/account/list.ts](https://github.com/inkdevhub/swanky-cli/blob/v4.0.0-beta.0/src/commands/account/list.ts)_ + ## `swanky account ls` List dev accounts stored in config @@ -277,22 +401,21 @@ ALIASES $ swanky account ls ``` -## `swanky check` - -Check installed package versions and compatibility +## `swanky clear [CONTRACTNAME]` ``` USAGE - $ swanky check [-v] + $ swanky clear [CONTRACTNAME] [-v] [-a] + +ARGUMENTS + CONTRACTNAME Name of the contract artifact to clear FLAGS + -a, --all Select all the project artifacts for delete -v, --verbose Display more info in the result logs - -DESCRIPTION - Check installed package versions and compatibility ``` -_See code: [dist/commands/check/index.ts](https://github.com/AstarNetwork/swanky-cli/blob/v3.1.0-beta.0/dist/commands/check/index.ts)_ +_See code: [src/commands/clear/index.ts](https://github.com/inkdevhub/swanky-cli/blob/v4.0.0-beta.0/src/commands/clear/index.ts)_ ## `swanky contract compile [CONTRACTNAME]` @@ -300,27 +423,31 @@ Compile the smart contract(s) in your contracts directory ``` USAGE - $ swanky contract compile [CONTRACTNAME] [-v] [-r] [-a] + $ swanky contract compile [CONTRACTNAME] [-v] [-r] [--verifiable] [-a] ARGUMENTS CONTRACTNAME Name of the contract to compile FLAGS - -a, --all Set all to true to compile all contracts - -r, --release A production contract should always be build in `release` mode for building optimized wasm - -v, --verbose Display more info in the result logs + -a, --all Set all to true to compile all contracts + -r, --release A production contract should always be build in `release` mode for building optimized wasm + -v, --verbose Display more info in the result logs + --verifiable A production contract should be build in `verifiable` mode to deploy on a public network. Ensure + Docker Engine is up and running. DESCRIPTION Compile the smart contract(s) in your contracts directory ``` +_See code: [src/commands/contract/compile.ts](https://github.com/inkdevhub/swanky-cli/blob/v4.0.0-beta.0/src/commands/contract/compile.ts)_ + ## `swanky contract deploy CONTRACTNAME` Deploy contract to a running node ``` USAGE - $ swanky contract deploy CONTRACTNAME --account [-v] [-g ] [-a ] [-c ] [-n ] + $ swanky contract deploy CONTRACTNAME [-v] [--account ] [-g ] [-a ] [-c ] [-n ] ARGUMENTS CONTRACTNAME Name of the contract to deploy @@ -329,14 +456,16 @@ FLAGS -a, --args=... -c, --constructorName= [default: new] Constructor function name of a contract to deploy -g, --gas= - -n, --network= Network name to connect to + -n, --network= [default: local] Network name to connect to -v, --verbose Display more info in the result logs - --account= (required) Alias of account to be used + --account= Account alias to deploy contract with DESCRIPTION Deploy contract to a running node ``` +_See code: [src/commands/contract/deploy.ts](https://github.com/inkdevhub/swanky-cli/blob/v4.0.0-beta.0/src/commands/contract/deploy.ts)_ + ## `swanky contract explain CONTRACTNAME` Explain contract messages based on the contracts' metadata @@ -355,6 +484,8 @@ DESCRIPTION Explain contract messages based on the contracts' metadata ``` +_See code: [src/commands/contract/explain.ts](https://github.com/inkdevhub/swanky-cli/blob/v4.0.0-beta.0/src/commands/contract/explain.ts)_ + ## `swanky contract new CONTRACTNAME` Generate a new smart contract template inside a project @@ -368,12 +499,14 @@ ARGUMENTS FLAGS -v, --verbose - --template=