From d1750f82e29a70408689246ded079d741618cb16 Mon Sep 17 00:00:00 2001
From: Igor Papandinas
Date: Mon, 18 Mar 2024 14:25:15 +0400
Subject: [PATCH] chore: prettier fmt script command added
---
README.md | 117 +++++++------
package.json | 1 +
src/commands/account/create.ts | 9 +-
src/commands/account/list.ts | 8 +-
src/commands/clear/index.ts | 41 +++--
src/commands/contract/compile.ts | 8 +-
src/commands/contract/deploy.ts | 10 +-
src/commands/contract/explain.ts | 2 +-
src/commands/contract/new.ts | 3 +-
src/commands/contract/query.ts | 4 +-
src/commands/contract/test.ts | 3 +-
src/commands/contract/verify.ts | 96 +++++------
src/commands/env/check.ts | 63 ++++---
src/commands/env/install.ts | 29 ++--
src/commands/generate/tests.ts | 22 ++-
src/commands/generate/types.ts | 2 +-
src/commands/init/index.ts | 38 ++--
src/commands/node/chopsticks/init.ts | 12 +-
src/commands/node/chopsticks/start.ts | 21 ++-
src/commands/node/install.ts | 20 ++-
src/commands/node/start.ts | 2 +-
src/commands/node/version.ts | 5 +-
src/commands/zombienet/init.ts | 17 +-
src/commands/zombienet/start.ts | 13 +-
src/lib/account.ts | 11 +-
src/lib/cargoContractInfo.ts | 2 +-
src/lib/checks.ts | 10 +-
src/lib/config-builder.ts | 17 +-
src/lib/config.ts | 16 +-
src/lib/contract.ts | 5 +-
src/lib/contractCall.ts | 38 ++--
src/lib/nodeInfo.ts | 239 +++++++++++++++-----------
src/lib/swankyCommand.ts | 11 +-
src/lib/tasks.ts | 52 ++++--
src/lib/templates.ts | 14 +-
src/lib/zombienetInfo.ts | 31 ++--
src/types/index.ts | 61 +++----
37 files changed, 590 insertions(+), 463 deletions(-)
diff --git a/README.md b/README.md
index 3a15ee12..1fedbedf 100644
--- a/README.md
+++ b/README.md
@@ -3,14 +3,15 @@
-* [Docs and guide](#docs-and-guide)
-* [Quick start](#quick-start)
-* [Base image and dev container](#base-image-and-dev-container)
-* [Config](#config)
-* [Network Management](#network-management)
-* [Development and contributing](#development-and-contributing)
-* [Reporting issues](#reporting-issues)
-* [Command help](#command-help)
+
+- [Docs and guide](#docs-and-guide)
+- [Quick start](#quick-start)
+- [Base image and dev container](#base-image-and-dev-container)
+- [Config](#config)
+- [Network Management](#network-management)
+- [Development and contributing](#development-and-contributing)
+- [Reporting issues](#reporting-issues)
+- [Command help](#command-help)
# Docs and guide
@@ -127,6 +128,7 @@ 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
@@ -167,6 +169,7 @@ Also, global config will be created in your home directory, in `~/swanky` folder
}
}
```
+
You can use accounts and networks from the global config in any swanky project.
# Network Management
@@ -225,6 +228,7 @@ Please report any issue or bug you encounter, as well as any feature and improve
# Command help
+
```sh-session
$ npm install -g @astar-network/swanky-cli
$ swanky COMMAND
@@ -236,48 +240,50 @@ USAGE
$ swanky COMMAND
...
```
+
-* [`swanky account create`](#swanky-account-create)
-* [`swanky account list`](#swanky-account-list)
-* [`swanky account ls`](#swanky-account-ls)
-* [`swanky account balance`](#swanky-account-balance)
-* [`swanky account faucet`](#swanky-account-faucet)
-* [`swanky account default`](#swanky-account-default)
-* [`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)
-* [`swanky contract new CONTRACTNAME`](#swanky-contract-new-contractname)
-* [`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 verify CONTRACTNAME`](#swanky-contract-verify-contractname)
-* [`swanky env check`](#swanky-env-check)
-* [`swanky env install`](#swanky-env-install)
-* [`swanky generate tests`](#swanky-generate-tests)
-* [`swanky generate types`](#swanky-generate-types)
-* [`swanky help [COMMANDS]`](#swanky-help-commands)
-* [`swanky init PROJECTNAME`](#swanky-init-projectname)
-* [`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 node chopsticks init`](#swanky-node-chopsticks-init)
-* [`swanky node chopsticks start`](#swanky-node-chopsticks-start)
-* [`swanky zombienet init`](#swanky-zombienet-init)
-* [`swanky zombienet start`](#swanky-zombienet-start)
-* [`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: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 account create`](#swanky-account-create)
+- [`swanky account list`](#swanky-account-list)
+- [`swanky account ls`](#swanky-account-ls)
+- [`swanky account balance`](#swanky-account-balance)
+- [`swanky account faucet`](#swanky-account-faucet)
+- [`swanky account default`](#swanky-account-default)
+- [`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)
+- [`swanky contract new CONTRACTNAME`](#swanky-contract-new-contractname)
+- [`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 verify CONTRACTNAME`](#swanky-contract-verify-contractname)
+- [`swanky env check`](#swanky-env-check)
+- [`swanky env install`](#swanky-env-install)
+- [`swanky generate tests`](#swanky-generate-tests)
+- [`swanky generate types`](#swanky-generate-types)
+- [`swanky help [COMMANDS]`](#swanky-help-commands)
+- [`swanky init PROJECTNAME`](#swanky-init-projectname)
+- [`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 node chopsticks init`](#swanky-node-chopsticks-init)
+- [`swanky node chopsticks start`](#swanky-node-chopsticks-start)
+- [`swanky zombienet init`](#swanky-zombienet-init)
+- [`swanky zombienet start`](#swanky-zombienet-start)
+- [`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: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 account create`
@@ -296,7 +302,9 @@ FLAGS
DESCRIPTION
Create a new dev account in config
```
+
_See code: [src/commands/account/create.ts](https://github.com/inkdevhub/swanky-cli/blob/master/src/commands/account/create.ts)_
+
## `swanky account list`
List dev accounts stored in config
@@ -314,8 +322,8 @@ DESCRIPTION
ALIASES
$ swanky account ls
```
-_See code: [src/commands/account/list.ts](https://github.com/inkdevhub/swanky-cli/blob/master/src/commands/account/list.ts)_
+_See code: [src/commands/account/list.ts](https://github.com/inkdevhub/swanky-cli/blob/master/src/commands/account/list.ts)_
## `swanky account ls`
@@ -394,7 +402,7 @@ FLAGS
DESCRIPTION
Set default account to use
-```
+```
_See code: [src/commands/account/default.ts](https://github.com/inkdevhub/swanky-cli/blob/master/src/commands/account/default.ts)_
@@ -463,7 +471,6 @@ DESCRIPTION
Deploy contract to a running node
```
-
_See code: [src/commands/contract/deploy.ts](https://github.com/inkdevhub/swanky-cli/blob/master/src/commands/contract/deploy.ts)_
## `swanky contract explain CONTRACTNAME`
@@ -507,7 +514,6 @@ DESCRIPTION
_See code: [src/commands/contract/new.ts](https://github.com/inkdevhub/swanky-cli/blob/master/src/commands/contract/new.ts)_
-
## `swanky contract query CONTRACTNAME MESSAGENAME`
Call a query message on smart contract
@@ -659,7 +665,7 @@ FLAGS
DESCRIPTION
Generate test files for the specified contract
-```
+```
_See code: [src/commands/generate/tests.ts](https://github.com/inkdevhub/swanky-cli/blob/master/src/commands/generate/tests.ts)_
@@ -849,7 +855,7 @@ _See code: [src/commands/node/chopsticks/start.ts](https://github.com/inkdevhub/
Initialize Zombienet
-```
+```
USAGE
$ swanky zombienet init [-v] [-b polkadot|polkadot-parachain|astar-collator]
@@ -936,7 +942,7 @@ ALIASES
$ swanky plugins add
EXAMPLES
- $ swanky plugins:install myplugin
+ $ swanky plugins:install myplugin
$ swanky plugins:install https://github.com/someuser/someplugin
@@ -999,7 +1005,7 @@ ALIASES
$ swanky plugins add
EXAMPLES
- $ swanky plugins:install myplugin
+ $ swanky plugins:install myplugin
$ swanky plugins:install https://github.com/someuser/someplugin
@@ -1137,4 +1143,5 @@ FLAG DESCRIPTIONS
```
_See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v1.3.7/src/commands/version.ts)_
+
diff --git a/package.json b/package.json
index 575a6ad6..00f8d8e8 100644
--- a/package.json
+++ b/package.json
@@ -110,6 +110,7 @@
}
},
"scripts": {
+ "format": "prettier --write \"**/*.{js,jsx,ts,tsx,css,md}\"",
"lint": "eslint . --ext .ts --quiet --config .eslintrc",
"postpack": "shx rm -f oclif.manifest.json",
"prepack": "yarn build && oclif manifest && oclif readme",
diff --git a/src/commands/account/create.ts b/src/commands/account/create.ts
index c088d275..bd10a90e 100644
--- a/src/commands/account/create.ts
+++ b/src/commands/account/create.ts
@@ -1,6 +1,12 @@
import { Flags } from "@oclif/core";
import chalk from "chalk";
-import { ChainAccount, encrypt, getSwankyConfig, isLocalConfigCheck, SwankyAccountCommand } from "../../lib/index.js";
+import {
+ ChainAccount,
+ encrypt,
+ getSwankyConfig,
+ isLocalConfigCheck,
+ SwankyAccountCommand,
+} from "../../lib/index.js";
import { AccountData } from "../../types/index.js";
import inquirer from "inquirer";
import { SwankyCommand } from "../../lib/swankyCommand.js";
@@ -14,7 +20,6 @@ export class CreateAccount extends SwankyAccountCommand {
global: Flags.boolean({
char: "g",
description: "Create account globally stored in Swanky system config.",
-
}),
new: Flags.boolean({
char: "n",
diff --git a/src/commands/account/list.ts b/src/commands/account/list.ts
index 67f05ecd..3e2afc08 100644
--- a/src/commands/account/list.ts
+++ b/src/commands/account/list.ts
@@ -13,11 +13,11 @@ export class ListAccounts extends SwankyCommand {
async run(): Promise {
const countOfDevAccounts = this.swankyConfig.accounts.filter((account) => account.isDev).length;
- if(countOfDevAccounts !== 0) {
+ if (countOfDevAccounts !== 0) {
this.log(`${chalk.greenBright("✔")} Stored dev accounts:`);
for (const account of this.swankyConfig.accounts) {
- if(account.isDev){
+ if (account.isDev) {
this.log(`\t${chalk.yellowBright("Alias: ")} ${account.alias} \
${chalk.yellowBright("Address: ")} ${account.address} ${this.swankyConfig.defaultAccount === account.alias ? chalk.greenBright("<- Default") : ""}`);
}
@@ -26,11 +26,11 @@ ${chalk.yellowBright("Address: ")} ${account.address} ${this.swankyConfig.defaul
const countOfProdAccounts = this.swankyConfig.accounts.length - countOfDevAccounts;
- if(countOfProdAccounts !== 0) {
+ if (countOfProdAccounts !== 0) {
this.log(`${chalk.greenBright("✔")} Stored prod accounts:`);
for (const account of this.swankyConfig.accounts) {
- if(!account.isDev){
+ if (!account.isDev) {
this.log(`\t${chalk.yellowBright("Alias: ")} ${account.alias} \
${chalk.yellowBright("Address: ")} ${account.address} ${this.swankyConfig.defaultAccount === account.alias ? chalk.greenBright("<- Default") : ""}`);
}
diff --git a/src/commands/clear/index.ts b/src/commands/clear/index.ts
index 67b15d2e..08208872 100644
--- a/src/commands/clear/index.ts
+++ b/src/commands/clear/index.ts
@@ -6,13 +6,12 @@ import { Args, Flags } from "@oclif/core";
import { ensureContractNameOrAllFlagIsSet } from "../../lib/checks.js";
interface Folder {
- name: string,
- contractName?: string,
- path: string
+ name: string;
+ contractName?: string;
+ path: string;
}
export default class Clear extends SwankyCommand {
-
static flags = {
all: Flags.boolean({
char: "a",
@@ -42,29 +41,37 @@ export default class Clear extends SwankyCommand {
}
public async run(): Promise {
-
const { flags, args } = await this.parse(Clear);
ensureContractNameOrAllFlagIsSet(args, flags);
const workDirectory = process.cwd();
- const foldersToDelete: Folder[] = flags.all ?
- [
- { name: "Artifacts", path: path.join(workDirectory, "./artifacts") },
- { name: "Target", path: path.join(workDirectory, "./target") }
- ]
- : args.contractName ?
- [
- { name: "Artifacts", contractName: args.contractName, path: path.join(workDirectory, "./artifacts/", args.contractName) },
+ const foldersToDelete: Folder[] = flags.all
+ ? [
+ { name: "Artifacts", path: path.join(workDirectory, "./artifacts") },
{ name: "Target", path: path.join(workDirectory, "./target") },
- { name: "TestArtifacts", contractName: args.contractName, path: path.join(workDirectory, "./tests/", args.contractName, "/artifacts") }
]
- : [];
+ : args.contractName
+ ? [
+ {
+ name: "Artifacts",
+ contractName: args.contractName,
+ path: path.join(workDirectory, "./artifacts/", args.contractName),
+ },
+ { name: "Target", path: path.join(workDirectory, "./target") },
+ {
+ name: "TestArtifacts",
+ contractName: args.contractName,
+ path: path.join(workDirectory, "./tests/", args.contractName, "/artifacts"),
+ },
+ ]
+ : [];
for (const folder of foldersToDelete) {
- await this.spinner.runCommand(async () => this.deleteFolder(folder.path),
+ await this.spinner.runCommand(
+ async () => this.deleteFolder(folder.path),
`Deleting the ${folder.name} folder ${folder.contractName ? `for ${folder.contractName} contract` : ""}`,
`Successfully deleted the ${folder.name} folder ${folder.contractName ? `for ${folder.contractName} contract` : ""}\n at ${folder.path}`
);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/commands/contract/compile.ts b/src/commands/contract/compile.ts
index 967f5982..5d12c1fd 100644
--- a/src/commands/contract/compile.ts
+++ b/src/commands/contract/compile.ts
@@ -11,7 +11,11 @@ import {
import { InputError, ProcessError } from "../../lib/errors.js";
import { BuildMode, SwankyConfig } from "../../index.js";
import { ConfigBuilder } from "../../lib/config-builder.js";
-import { ensureContractNameOrAllFlagIsSet, ensureContractPathExists, ensureCargoContractVersionCompatibility, } from "../../lib/checks.js";
+import {
+ ensureContractNameOrAllFlagIsSet,
+ ensureContractPathExists,
+ ensureCargoContractVersionCompatibility,
+} from "../../lib/checks.js";
export class CompileContract extends SwankyCommand {
static description = "Compile the smart contract(s) in your contracts directory";
@@ -120,7 +124,7 @@ export class CompileContract extends SwankyCommand {
});
},
`Compiling ${contractName} contract`,
- `${contractName} Contract compiled successfully`,
+ `${contractName} Contract compiled successfully`
);
const artifactsPath = compilationResult as string;
diff --git a/src/commands/contract/deploy.ts b/src/commands/contract/deploy.ts
index 7a2e32df..87d965d8 100644
--- a/src/commands/contract/deploy.ts
+++ b/src/commands/contract/deploy.ts
@@ -16,7 +16,11 @@ import chalk from "chalk";
import { SwankyCommand } from "../../lib/swankyCommand.js";
import { ApiError, ProcessError } from "../../lib/errors.js";
import { ConfigBuilder } from "../../lib/config-builder.js";
-import { contractFromRecord, ensureArtifactsExist, ensureDevAccountNotInProduction } from "../../lib/checks.js";
+import {
+ contractFromRecord,
+ ensureArtifactsExist,
+ ensureDevAccountNotInProduction,
+} from "../../lib/checks.js";
export class DeployContract extends SwankyCommand {
static description = "Deploy contract to a running node";
@@ -59,7 +63,7 @@ export class DeployContract extends SwankyCommand {
const contractRecord = findContractRecord(localConfig, args.contractName);
- const contract = (await contractFromRecord(contractRecord));
+ const contract = await contractFromRecord(contractRecord);
await ensureArtifactsExist(contract);
@@ -97,7 +101,7 @@ export class DeployContract extends SwankyCommand {
const accountData = this.findAccountByAlias(accountAlias);
ensureDevAccountNotInProduction(accountData, flags.network);
-
+
const mnemonic = accountData.isDev
? (accountData.mnemonic as string)
: decrypt(
diff --git a/src/commands/contract/explain.ts b/src/commands/contract/explain.ts
index 03c6d614..4f89bf4e 100644
--- a/src/commands/contract/explain.ts
+++ b/src/commands/contract/explain.ts
@@ -19,7 +19,7 @@ export class ExplainContract extends SwankyCommand {
const contractRecord = findContractRecord(this.swankyConfig, args.contractName);
- const contract = (await contractFromRecord(contractRecord));
+ const contract = await contractFromRecord(contractRecord);
await ensureArtifactsExist(contract);
diff --git a/src/commands/contract/new.ts b/src/commands/contract/new.ts
index 27b3281f..e51fccf1 100644
--- a/src/commands/contract/new.ts
+++ b/src/commands/contract/new.ts
@@ -7,7 +7,8 @@ import {
processTemplates,
getTemplates,
prepareTestFiles,
- getSwankyConfig, configName,
+ getSwankyConfig,
+ configName,
} from "../../lib/index.js";
import { email, name, pickTemplate } from "../../lib/prompts.js";
import { kebabCase, pascalCase, snakeCase } from "change-case";
diff --git a/src/commands/contract/query.ts b/src/commands/contract/query.ts
index 262610f1..3c28a1ee 100644
--- a/src/commands/contract/query.ts
+++ b/src/commands/contract/query.ts
@@ -14,7 +14,7 @@ export class Query extends ContractCall {
const contract = new ContractPromise(
this.api.apiInst,
this.metadata,
- this.deploymentInfo.address,
+ this.deploymentInfo.address
);
const storageDepositLimit = null;
@@ -29,7 +29,7 @@ export class Query extends ContractCall {
gasLimit,
storageDepositLimit,
},
- ...flags.params,
+ ...flags.params
);
await this.api.apiInst.disconnect();
diff --git a/src/commands/contract/test.ts b/src/commands/contract/test.ts
index eb61895b..ce6e1dbd 100644
--- a/src/commands/contract/test.ts
+++ b/src/commands/contract/test.ts
@@ -57,7 +57,7 @@ export class TestContract extends SwankyCommand {
for (const contractName of contractNames) {
const contractRecord = findContractRecord(this.swankyConfig, contractName);
- const contract = (await contractFromRecord(contractRecord));
+ const contract = await contractFromRecord(contractRecord);
console.log(`Testing contract: ${contractName}`);
@@ -139,7 +139,6 @@ export class TestContract extends SwankyCommand {
global.contractTypesPath = path.resolve(testDir, "typedContract");
-
try {
await new Promise((resolve, reject) => {
mocha.run((failures) => {
diff --git a/src/commands/contract/verify.ts b/src/commands/contract/verify.ts
index 1add044b..70857f6f 100644
--- a/src/commands/contract/verify.ts
+++ b/src/commands/contract/verify.ts
@@ -10,7 +10,11 @@ import { InputError, ProcessError } from "../../lib/errors.js";
import { spawn } from "node:child_process";
import { ConfigBuilder } from "../../lib/config-builder.js";
import { BuildData, SwankyConfig } from "../../index.js";
-import { ensureContractNameOrAllFlagIsSet, ensureContractPathExists, ensureCargoContractVersionCompatibility } from "../../lib/checks.js";
+import {
+ ensureContractNameOrAllFlagIsSet,
+ ensureContractPathExists,
+ ensureCargoContractVersionCompatibility,
+} from "../../lib/checks.js";
export class VerifyContract extends SwankyCommand {
static description = "Verify the smart contract(s) in your contracts directory";
@@ -43,9 +47,7 @@ export class VerifyContract extends SwankyCommand {
`Cargo contract tool is required for verifiable mode. Please ensure it is installed.`
);
- ensureCargoContractVersionCompatibility(cargoContractVersion, "4.0.0", [
- "4.0.0-alpha",
- ]);
+ ensureCargoContractVersionCompatibility(cargoContractVersion, "4.0.0", ["4.0.0-alpha"]);
ensureContractNameOrAllFlagIsSet(args, flags);
@@ -62,53 +64,52 @@ export class VerifyContract extends SwankyCommand {
await ensureContractPathExists(contractName);
-
- if(!contractRecord.build) {
+ if (!contractRecord.build) {
throw new InputError(`Contract ${contractName} is not compiled. Please compile it first`);
}
await spinner.runCommand(
async () => {
- return new Promise((resolve, reject) => {
- if(contractRecord.build!.isVerified) {
- this.logger.info(`Contract ${contractName} is already verified`);
- resolve(true);
- }
- const compileArgs = [
- "contract",
- "verify",
- `artifacts/${contractName}/${contractName}.contract`,
- "--manifest-path",
- `contracts/${contractName}/Cargo.toml`,
- ];
- const compile = spawn("cargo", compileArgs);
- this.logger.info(`Running verify command: [${JSON.stringify(compile.spawnargs)}]`);
- let outputBuffer = "";
- let errorBuffer = "";
-
- compile.stdout.on("data", (data) => {
- outputBuffer += data.toString();
- spinner.ora.clear();
- });
-
- compile.stderr.on("data", (data) => {
- errorBuffer += data;
- });
-
- compile.on("exit", (code) => {
- if (code === 0) {
- const regex = /Successfully verified contract (.*) against reference contract (.*)/;
- const match = outputBuffer.match(regex);
- if (match) {
- this.logger.info(`Contract ${contractName} verification done.`);
- resolve(true);
- }
- } else {
- reject(new ProcessError(errorBuffer));
+ return new Promise((resolve, reject) => {
+ if (contractRecord.build!.isVerified) {
+ this.logger.info(`Contract ${contractName} is already verified`);
+ resolve(true);
+ }
+ const compileArgs = [
+ "contract",
+ "verify",
+ `artifacts/${contractName}/${contractName}.contract`,
+ "--manifest-path",
+ `contracts/${contractName}/Cargo.toml`,
+ ];
+ const compile = spawn("cargo", compileArgs);
+ this.logger.info(`Running verify command: [${JSON.stringify(compile.spawnargs)}]`);
+ let outputBuffer = "";
+ let errorBuffer = "";
+
+ compile.stdout.on("data", (data) => {
+ outputBuffer += data.toString();
+ spinner.ora.clear();
+ });
+
+ compile.stderr.on("data", (data) => {
+ errorBuffer += data;
+ });
+
+ compile.on("exit", (code) => {
+ if (code === 0) {
+ const regex = /Successfully verified contract (.*) against reference contract (.*)/;
+ const match = outputBuffer.match(regex);
+ if (match) {
+ this.logger.info(`Contract ${contractName} verification done.`);
+ resolve(true);
}
- });
+ } else {
+ reject(new ProcessError(errorBuffer));
+ }
});
- },
+ });
+ },
`Verifying ${contractName} contract`,
`${contractName} Contract verified successfully`
);
@@ -116,16 +117,15 @@ export class VerifyContract extends SwankyCommand {
await this.spinner.runCommand(async () => {
const buildData = {
...contractRecord.build,
- isVerified: true
+ isVerified: true,
} as BuildData;
-
+
const newLocalConfig = new ConfigBuilder(localConfig)
.addContractBuild(args.contractName, buildData)
.build();
-
+
await this.storeConfig(newLocalConfig, "local");
}, "Writing config");
-
}
}
}
diff --git a/src/commands/env/check.ts b/src/commands/env/check.ts
index 417e6741..7cc763a8 100644
--- a/src/commands/env/check.ts
+++ b/src/commands/env/check.ts
@@ -1,5 +1,11 @@
import { Listr } from "listr2";
-import { extractCargoContractVersion, extractCargoDylintVersion, extractCargoNightlyVersion, extractCargoVersion, extractRustVersion } from "../../lib/index.js";
+import {
+ extractCargoContractVersion,
+ extractCargoDylintVersion,
+ extractCargoNightlyVersion,
+ extractCargoVersion,
+ extractRustVersion,
+} from "../../lib/index.js";
import { SwankyConfig } from "../../types/index.js";
import { pathExistsSync, writeJson } from "fs-extra/esm";
import { readFileSync } from "fs";
@@ -17,7 +23,7 @@ interface Ctx {
os: {
platform: string;
architecture: string;
- },
+ };
versions: {
tools: {
rust?: string | null;
@@ -134,7 +140,8 @@ export class Check extends SwankyCommand {
{
title: "Check swanky node",
task: async (ctx) => {
- ctx.versions.swankyNode = this.swankyConfig.node.version !== "" ? this.swankyConfig.node.version : null;
+ ctx.versions.swankyNode =
+ this.swankyConfig.node.version !== "" ? this.swankyConfig.node.version : null;
},
},
{
@@ -175,12 +182,16 @@ export class Check extends SwankyCommand {
Object.entries(ctx.versions.contracts).forEach(([contract, inkDependencies]) => {
Object.entries(inkDependencies).forEach(([depName, version]) => {
if (semver.gt(version, supportedInk)) {
- mismatched[
- `${contract}-${depName}`
- ] = `Version of ${depName} (${version}) in ${chalk.yellowBright(contract)} is higher than supported ink version (${supportedInk}) in current Swanky node version (${swankyNodeVersion}). A Swanky node update can fix this warning.`;
+ mismatched[`${contract}-${depName}`] =
+ `Version of ${depName} (${version}) in ${chalk.yellowBright(contract)} is higher than supported ink version (${supportedInk}) in current Swanky node version (${swankyNodeVersion}). A Swanky node update can fix this warning.`;
}
- if (version.startsWith(">") || version.startsWith("<") || version.startsWith("^") || version.startsWith("~")) {
+ if (
+ version.startsWith(">") ||
+ version.startsWith("<") ||
+ version.startsWith("^") ||
+ version.startsWith("~")
+ ) {
ctx.looseDefinitionDetected = true;
}
});
@@ -188,7 +199,9 @@ export class Check extends SwankyCommand {
ctx.mismatchedVersions = mismatched;
if (Object.entries(mismatched).length > 0) {
- throw new Warn("Ink versions in contracts don't match the Swanky node's supported version.");
+ throw new Warn(
+ "Ink versions in contracts don't match the Swanky node's supported version."
+ );
}
},
exitOnError: false,
@@ -200,25 +213,28 @@ export class Check extends SwankyCommand {
task: async (ctx) => {
const cargoContractVersion = ctx.versions.tools.cargoContract!;
const dependencyIdx = CARGO_CONTRACT_INK_DEPS.findIndex((dep) =>
- semver.satisfies(cargoContractVersion.replace(/-.*$/, ""), `>=${dep.minCargoContractVersion}`)
+ semver.satisfies(
+ cargoContractVersion.replace(/-.*$/, ""),
+ `>=${dep.minCargoContractVersion}`
+ )
);
if (dependencyIdx === -1) {
throw new Warn(`cargo-contract version ${cargoContractVersion} is not supported`);
}
-
+
const validInkVersionRange = CARGO_CONTRACT_INK_DEPS[dependencyIdx].validInkVersionRange;
- const minCargoContractVersion = dependencyIdx === 0
- ? CARGO_CONTRACT_INK_DEPS[dependencyIdx].minCargoContractVersion
- : CARGO_CONTRACT_INK_DEPS[dependencyIdx - 1].minCargoContractVersion
+ const minCargoContractVersion =
+ dependencyIdx === 0
+ ? CARGO_CONTRACT_INK_DEPS[dependencyIdx].minCargoContractVersion
+ : CARGO_CONTRACT_INK_DEPS[dependencyIdx - 1].minCargoContractVersion;
const mismatched: Record = {};
Object.entries(ctx.versions.contracts).forEach(([contract, inkPackages]) => {
Object.entries(inkPackages).forEach(([inkPackage, version]) => {
if (!semver.satisfies(version, validInkVersionRange)) {
- mismatched[
- `${contract}-${inkPackage}`
- ] = `Version of ${inkPackage} (${version}) in ${chalk.yellowBright(contract)} requires cargo-contract version >=${minCargoContractVersion}, but version ${cargoContractVersion} is installed`;
+ mismatched[`${contract}-${inkPackage}`] =
+ `Version of ${inkPackage} (${version}) in ${chalk.yellowBright(contract)} requires cargo-contract version >=${minCargoContractVersion}, but version ${cargoContractVersion} is installed`;
}
});
});
@@ -260,7 +276,7 @@ export class Check extends SwankyCommand {
},
swankyConfig: this.swankyConfig,
looseDefinitionDetected: false,
- mismatchedVersions: {}
+ mismatchedVersions: {},
});
Object.values(context.mismatchedVersions).forEach((mismatch) => this.warn(mismatch));
@@ -274,14 +290,17 @@ export class Check extends SwankyCommand {
const output = {
...context.os,
- ...context.versions
- }
+ ...context.versions,
+ };
const filePath = flags.print;
if (filePath !== undefined) {
- await this.spinner.runCommand(async () => {
- writeJson(filePath, output, { spaces: 2 });
- }, `Writing output to file ${chalk.yellowBright(filePath)}`);
+ await this.spinner.runCommand(
+ async () => {
+ writeJson(filePath, output, { spaces: 2 });
+ },
+ `Writing output to file ${chalk.yellowBright(filePath)}`
+ );
}
}
}
diff --git a/src/commands/env/install.ts b/src/commands/env/install.ts
index b7978484..8b3f8621 100644
--- a/src/commands/env/install.ts
+++ b/src/commands/env/install.ts
@@ -23,7 +23,7 @@ export class Install extends SwankyCommand {
const { flags } = await this.parse(Install);
const depsArray = flags.deps ?? [];
- const localConfig = getSwankyConfig('local') as SwankyConfig;
+ const localConfig = getSwankyConfig("local") as SwankyConfig;
const depsToInstall = depsArray.length > 0 ? this.parseDeps(depsArray) : localConfig.env;
if (Object.keys(depsToInstall).length === 0) {
@@ -41,14 +41,19 @@ export class Install extends SwankyCommand {
}
parseDeps(deps: string[]): Record {
- return deps.reduce((acc, dep) => {
- const [key, value] = dep.split('@');
- if (!Object.keys(SUPPORTED_DEPS).includes(key)) {
- throw new InputError(`Unsupported dependency '${key}'. Supported: ${Object.keys(SUPPORTED_DEPS).join(", ")}`);
- }
- acc[key] = value || 'latest';
- return acc;
- }, {} as Record);
+ return deps.reduce(
+ (acc, dep) => {
+ const [key, value] = dep.split("@");
+ if (!Object.keys(SUPPORTED_DEPS).includes(key)) {
+ throw new InputError(
+ `Unsupported dependency '${key}'. Supported: ${Object.keys(SUPPORTED_DEPS).join(", ")}`
+ );
+ }
+ acc[key] = value || "latest";
+ return acc;
+ },
+ {} as Record
+ );
}
async installDeps(dependencies: Record) {
@@ -62,10 +67,8 @@ export class Install extends SwankyCommand {
async updateLocalConfig(newDeps: Record): Promise {
await this.spinner.runCommand(async () => {
- const newLocalConfig = new ConfigBuilder(getSwankyConfig('local'))
- .updateEnv(newDeps)
- .build();
- await this.storeConfig(newLocalConfig, 'local');
+ const newLocalConfig = new ConfigBuilder(getSwankyConfig("local")).updateEnv(newDeps).build();
+ await this.storeConfig(newLocalConfig, "local");
}, "Updating Swanky config with new Dev Dependencies...");
}
}
diff --git a/src/commands/generate/tests.ts b/src/commands/generate/tests.ts
index 0c9a7b04..e15dced9 100644
--- a/src/commands/generate/tests.ts
+++ b/src/commands/generate/tests.ts
@@ -1,5 +1,10 @@
import { Args, Flags } from "@oclif/core";
-import { findContractRecord, getTemplates, prepareTestFiles, processTemplates } from "../../lib/index.js";
+import {
+ findContractRecord,
+ getTemplates,
+ prepareTestFiles,
+ processTemplates,
+} from "../../lib/index.js";
import { SwankyCommand } from "../../lib/swankyCommand.js";
import { ConfigError, InputError } from "../../lib/errors.js";
import path from "node:path";
@@ -55,15 +60,14 @@ export class GenerateTests extends SwankyCommand {
templates.templatesPath,
process.cwd(),
args.contractName,
- templateName,
+ templateName
);
}
async checkContract(name: string) {
-
const contractRecord = findContractRecord(this.swankyConfig, name);
- const contract = (await contractFromRecord(contractRecord));
+ const contract = await contractFromRecord(contractRecord);
await ensureArtifactsExist(contract);
}
@@ -71,7 +75,7 @@ export class GenerateTests extends SwankyCommand {
async checkOverwrite(
testPath: string,
testType: TestType,
- contractName?: string,
+ contractName?: string
): Promise {
if (!existsSync(testPath)) return true; // No need to overwrite
const message =
@@ -120,17 +124,17 @@ export class GenerateTests extends SwankyCommand {
templatesPath: string,
projectPath: string,
contractName?: string,
- templateName?: string,
+ templateName?: string
): Promise {
if (testType === "e2e") {
await this.spinner.runCommand(
() => prepareTestFiles("e2e", templatesPath, projectPath),
- "Generating e2e test helpers",
+ "Generating e2e test helpers"
);
} else {
await this.spinner.runCommand(
() => prepareTestFiles("mocha", templatesPath, projectPath, templateName, contractName),
- `Generating tests for ${contractName} with mocha`,
+ `Generating tests for ${contractName} with mocha`
);
}
await this.spinner.runCommand(
@@ -141,7 +145,7 @@ export class GenerateTests extends SwankyCommand {
contract_name: contractName ?? "",
contract_name_pascal: contractName ? pascalCase(contractName) : "",
}),
- "Processing templates",
+ "Processing templates"
);
}
}
diff --git a/src/commands/generate/types.ts b/src/commands/generate/types.ts
index 746eb622..109ca62e 100644
--- a/src/commands/generate/types.ts
+++ b/src/commands/generate/types.ts
@@ -19,7 +19,7 @@ export class GenerateTypes extends SwankyCommand {
const contractRecord = findContractRecord(this.swankyConfig, args.contractName);
- const contract = (await contractFromRecord(contractRecord));
+ const contract = await contractFromRecord(contractRecord);
await ensureArtifactsExist(contract);
diff --git a/src/commands/init/index.ts b/src/commands/init/index.ts
index 2dfa6312..0d6b986b 100644
--- a/src/commands/init/index.ts
+++ b/src/commands/init/index.ts
@@ -17,7 +17,7 @@ import {
installDeps,
prepareTestFiles,
processTemplates,
- swankyNodeVersions
+ swankyNodeVersions,
} from "../../lib/index.js";
import { SwankyCommand } from "../../lib/swankyCommand.js";
import { InputError, UnknownError } from "../../lib/errors.js";
@@ -146,10 +146,8 @@ export class Init extends SwankyCommand {
if (useSwankyNode) {
const versions = Array.from(swankyNodeVersions.keys());
let nodeVersion = DEFAULT_NODE_INFO.version;
- await inquirer.prompt([
- pickNodeVersion(versions),
- ]).then((answers) => {
- nodeVersion = answers.version;
+ await inquirer.prompt([pickNodeVersion(versions)]).then((answers) => {
+ nodeVersion = answers.version;
});
const nodeInfo = swankyNodeVersions.get(nodeVersion)!;
@@ -158,9 +156,13 @@ export class Init extends SwankyCommand {
task: downloadNode,
args: [this.projectPath, nodeInfo, this.spinner],
runningMessage: "Downloading Swanky node",
- callback: (localPath) => this.configBuilder.updateNodeSettings({ supportedInk: nodeInfo.supportedInk,
- polkadotPalletVersions: nodeInfo.polkadotPalletVersions,
- version: nodeInfo.version, localPath }),
+ callback: (localPath) =>
+ this.configBuilder.updateNodeSettings({
+ supportedInk: nodeInfo.supportedInk,
+ polkadotPalletVersions: nodeInfo.polkadotPalletVersions,
+ version: nodeInfo.version,
+ localPath,
+ }),
});
}
}
@@ -191,7 +193,7 @@ export class Init extends SwankyCommand {
runningMessage,
successMessage,
failMessage,
- shouldExitOnError,
+ shouldExitOnError
);
if (result && callback) {
callback(result as string);
@@ -271,7 +273,7 @@ export class Init extends SwankyCommand {
runningMessage: "Processing templates",
});
- this.configBuilder.updateContracts( {
+ this.configBuilder.updateContracts({
[contractName as string]: {
name: contractName,
moduleName: snakeCase(contractName),
@@ -291,7 +293,7 @@ export class Init extends SwankyCommand {
} catch (cause) {
throw new InputError(
`Error reading target directory [${chalk.yellowBright(pathToExistingProject)}]`,
- { cause },
+ { cause }
);
}
@@ -311,7 +313,7 @@ export class Init extends SwankyCommand {
const candidatesList: CopyCandidates = await getCopyCandidatesList(
pathToExistingProject,
- copyGlobsList,
+ copyGlobsList
);
const testDir = await detectTests(pathToExistingProject);
@@ -473,10 +475,10 @@ async function confirmCopyList(candidatesList: CopyCandidates) {
(
item: PathEntry & {
group: "contracts" | "crates" | "tests";
- },
+ }
) => {
resultingList[item.group]?.push(item);
- },
+ }
);
return resultingList;
}
@@ -503,7 +505,7 @@ async function detectTests(pathToExistingProject: string): Promise {
const { selectedDirectory } = await inquirer.prompt([
{
@@ -574,7 +576,7 @@ async function getCopyCandidatesList(
pathsToCopy: {
contractsDirectories: string[];
cratesDirectories: string[];
- },
+ }
) {
const detectedPaths = {
contracts: await getDirsAndFiles(projectPath, pathsToCopy.contractsDirectories),
@@ -595,7 +597,7 @@ async function getGlobPaths(projectPath: string, globList: string[], isDirOnly:
onlyDirectories: isDirOnly,
deep: 1,
objectMode: true,
- },
+ }
);
}
diff --git a/src/commands/node/chopsticks/init.ts b/src/commands/node/chopsticks/init.ts
index fd3ab620..7611cc9b 100644
--- a/src/commands/node/chopsticks/init.ts
+++ b/src/commands/node/chopsticks/init.ts
@@ -1,10 +1,6 @@
import path from "node:path";
import { SwankyCommand } from "../../../lib/swankyCommand.js";
-import {
- copyChopsticksTemplateFile,
- getSwankyConfig,
- getTemplates,
-} from "../../../lib/index.js";
+import { copyChopsticksTemplateFile, getSwankyConfig, getTemplates } from "../../../lib/index.js";
import { ConfigBuilder } from "../../../lib/config-builder.js";
import { SwankyConfig } from "../../../types/index.js";
@@ -21,9 +17,8 @@ export class InitChopsticks extends SwankyCommand {
const configPath = path.resolve(projectPath, "node", "config");
await this.spinner.runCommand(
- () =>
- copyChopsticksTemplateFile(chopsticksTemplatePath, configPath),
- "Copying Chopsticks template files...",
+ () => copyChopsticksTemplateFile(chopsticksTemplatePath, configPath),
+ "Copying Chopsticks template files..."
);
await this.spinner.runCommand(async () => {
@@ -36,4 +31,3 @@ export class InitChopsticks extends SwankyCommand {
this.log("Chopsticks config initialized successfully");
}
}
-
diff --git a/src/commands/node/chopsticks/start.ts b/src/commands/node/chopsticks/start.ts
index bde4a77f..07859131 100644
--- a/src/commands/node/chopsticks/start.ts
+++ b/src/commands/node/chopsticks/start.ts
@@ -8,10 +8,10 @@ export class StartChopsticks extends SwankyCommand {
static description = "Start chopsticks";
static flags = {
- "config": Flags.string({
+ config: Flags.string({
description: "Path to the chopsticks config file",
- })
- }
+ }),
+ };
async run(): Promise {
const { flags } = await this.parse(StartChopsticks);
@@ -20,20 +20,19 @@ export class StartChopsticks extends SwankyCommand {
const chopsticksConfigPath = flags.config ?? this.swankyConfig.node.chopsticks?.configPath;
- if(!chopsticksConfigPath) {
- throw new ConfigError("Chopsticks config not set in swanky config. Please set it in swanky config or provide the path to the chopsticks config file using --config flag.");
+ if (!chopsticksConfigPath) {
+ throw new ConfigError(
+ "Chopsticks config not set in swanky config. Please set it in swanky config or provide the path to the chopsticks config file using --config flag."
+ );
}
if (!(await pathExists(chopsticksConfigPath))) {
throw new FileError(`Chopsticks config file not found at ${flags.config}`);
}
- await execaCommand(
- `npx @acala-network/chopsticks@latest --config=${chopsticksConfigPath}`,
- {
- stdio: "inherit",
- }
- );
+ await execaCommand(`npx @acala-network/chopsticks@latest --config=${chopsticksConfigPath}`, {
+ stdio: "inherit",
+ });
this.log("Chopsticks started successfully.");
}
diff --git a/src/commands/node/install.ts b/src/commands/node/install.ts
index 9af510e1..5630a38a 100644
--- a/src/commands/node/install.ts
+++ b/src/commands/node/install.ts
@@ -13,27 +13,29 @@ export class InstallNode extends SwankyCommand {
static flags = {
"set-version": Flags.string({
- description: "Specify version of swanky node to install. \n List of supported versions: " + Array.from(swankyNodeVersions.keys()).join(", "),
+ description:
+ "Specify version of swanky node to install. \n List of supported versions: " +
+ Array.from(swankyNodeVersions.keys()).join(", "),
required: false,
}),
- }
+ };
async run(): Promise {
const { flags } = await this.parse(InstallNode);
if (flags.verbose) {
this.spinner.verbose = true;
}
- let nodeVersion= DEFAULT_NODE_INFO.version;
+ let nodeVersion = DEFAULT_NODE_INFO.version;
if (flags["set-version"]) {
nodeVersion = flags["set-version"];
- if(!swankyNodeVersions.has(nodeVersion)) {
- throw new InputError(`Version ${nodeVersion} is not supported.\n List of supported versions: ${Array.from(swankyNodeVersions.keys()).join(", ")}`);
+ if (!swankyNodeVersions.has(nodeVersion)) {
+ throw new InputError(
+ `Version ${nodeVersion} is not supported.\n List of supported versions: ${Array.from(swankyNodeVersions.keys()).join(", ")}`
+ );
}
} else {
const versions = Array.from(swankyNodeVersions.keys());
- await inquirer.prompt([
- pickNodeVersion(versions),
- ]).then((answers) => {
+ await inquirer.prompt([pickNodeVersion(versions)]).then((answers) => {
nodeVersion = answers.version;
});
}
@@ -41,7 +43,7 @@ export class InstallNode extends SwankyCommand {
const projectPath = path.resolve();
if (this.swankyConfig.node.localPath !== "") {
- const { overwrite } =await inquirer.prompt([
+ const { overwrite } = await inquirer.prompt([
choice("overwrite", "Swanky node already installed. Do you want to overwrite it?"),
]);
if (!overwrite) {
diff --git a/src/commands/node/start.ts b/src/commands/node/start.ts
index 89155083..7d161a7a 100644
--- a/src/commands/node/start.ts
+++ b/src/commands/node/start.ts
@@ -36,7 +36,7 @@ export class StartNode extends SwankyCommand {
// Non-Persistent mode (`--dev`) allows all CORS origin, without `--dev`, users need to specify origins by `--rpc-cors`.
await execaCommand(
`${this.swankyConfig.node.localPath} \
- ${ semver.gte(this.swankyConfig.node.version, "1.6.0") ? `--finalize-delay-sec ${flags.finalizeDelaySec}` : ""} \
+ ${semver.gte(this.swankyConfig.node.version, "1.6.0") ? `--finalize-delay-sec ${flags.finalizeDelaySec}` : ""} \
${flags.tmp ? "--dev" : `--rpc-cors ${flags.rpcCors}`}`,
{
stdio: "inherit",
diff --git a/src/commands/node/version.ts b/src/commands/node/version.ts
index a6937d09..e957d282 100644
--- a/src/commands/node/version.ts
+++ b/src/commands/node/version.ts
@@ -2,10 +2,9 @@ import { SwankyCommand } from "../../lib/swankyCommand.js";
export class NodeVersion extends SwankyCommand {
static description = "Show swanky node version";
async run(): Promise {
- if(this.swankyConfig.node.version === ""){
+ if (this.swankyConfig.node.version === "") {
this.log("Swanky node is not installed");
- }
- else {
+ } else {
this.log(`Swanky node version: ${this.swankyConfig.node.version}`);
}
}
diff --git a/src/commands/zombienet/init.ts b/src/commands/zombienet/init.ts
index e1082106..11a3da5c 100644
--- a/src/commands/zombienet/init.ts
+++ b/src/commands/zombienet/init.ts
@@ -65,13 +65,12 @@ As a result users of MacOS need to clone the Polkadot repo (https://github.com/p
if (!Object.keys(zombienet.binaries).includes(binaryName)) {
this.error(`Binary ${binaryName} not found in Zombienet config`);
}
- zombienetData.binaries[binaryName] = zombienet.binaries[binaryName as keyof typeof zombienet.binaries];
+ zombienetData.binaries[binaryName] =
+ zombienet.binaries[binaryName as keyof typeof zombienet.binaries];
}
await this.spinner.runCommand(async () => {
- const newLocalConfig = new ConfigBuilder(localConfig)
- .addZombienet(zombienetData)
- .build();
+ const newLocalConfig = new ConfigBuilder(localConfig).addZombienet(zombienetData).build();
await this.storeConfig(newLocalConfig, "local");
}, "Writing config");
@@ -81,24 +80,22 @@ As a result users of MacOS need to clone the Polkadot repo (https://github.com/p
if (binArray.length === 1 && binArray[0] === "polkadot") {
await spinner.runCommand(
- () =>
- copyZombienetTemplateFile(zombienetTemplatePath, configPath),
- "Copying template files",
+ () => copyZombienetTemplateFile(zombienetTemplatePath, configPath),
+ "Copying template files"
);
} else {
await spinner.runCommand(
() => buildZombienetConfigFromBinaries(binArray, zombienetTemplatePath, configPath),
- "Copying template files",
+ "Copying template files"
);
}
// Install binaries based on zombie config
await this.spinner.runCommand(
() => downloadZombienetBinaries(binArray, projectPath, localConfig, this.spinner),
- "Downloading Zombienet binaries",
+ "Downloading Zombienet binaries"
);
this.log("ZombieNet config Installed successfully");
}
}
-
diff --git a/src/commands/zombienet/start.ts b/src/commands/zombienet/start.ts
index 72f5b221..360b7db3 100644
--- a/src/commands/zombienet/start.ts
+++ b/src/commands/zombienet/start.ts
@@ -4,7 +4,6 @@ import { pathExistsSync } from "fs-extra/esm";
import { execaCommand } from "execa";
import { Flags } from "@oclif/core";
-
export class StartZombienet extends SwankyCommand {
static description = "Start Zombienet";
@@ -20,21 +19,21 @@ export class StartZombienet extends SwankyCommand {
async run(): Promise {
const { flags } = await this.parse(StartZombienet);
const projectPath = path.resolve();
- const binPath = path.resolve(projectPath, "zombienet", "bin")
+ const binPath = path.resolve(projectPath, "zombienet", "bin");
if (!pathExistsSync(path.resolve(binPath, "zombienet"))) {
this.error("Zombienet has not initialized. Run `swanky zombienet:init` first");
}
await execaCommand(
- `./zombienet/bin/zombienet \
+ `./zombienet/bin/zombienet \
spawn --provider native \
${flags["config-path"]}
`,
- {
- stdio: "inherit",
- }
+ {
+ stdio: "inherit",
+ }
);
this.log("ZombieNet started successfully");
}
-}
\ No newline at end of file
+}
diff --git a/src/lib/account.ts b/src/lib/account.ts
index e0f7e242..ecd2d420 100644
--- a/src/lib/account.ts
+++ b/src/lib/account.ts
@@ -66,13 +66,17 @@ export abstract class SwankyAccountCommand extends Swa
);
} catch (cause) {
if (cause instanceof Error) {
- if (cause.message.includes('ECONNREFUSED') && canBeSkipped) {
- this.warn(`Unable to connect to the node. Skipping faucet transfer for ${chalk.yellowBright(accountData.alias)}.`);
+ if (cause.message.includes("ECONNREFUSED") && canBeSkipped) {
+ this.warn(
+ `Unable to connect to the node. Skipping faucet transfer for ${chalk.yellowBright(accountData.alias)}.`
+ );
} else {
throw new ApiError("Error transferring tokens from faucet account", { cause });
}
} else {
- throw new ApiError("An unknown error occurred during faucet transfer", { cause: new Error(String(cause)) });
+ throw new ApiError("An unknown error occurred during faucet transfer", {
+ cause: new Error(String(cause)),
+ });
}
} finally {
if (api) {
@@ -81,4 +85,3 @@ export abstract class SwankyAccountCommand extends Swa
}
}
}
-
diff --git a/src/lib/cargoContractInfo.ts b/src/lib/cargoContractInfo.ts
index eafdd57d..52be5e21 100644
--- a/src/lib/cargoContractInfo.ts
+++ b/src/lib/cargoContractInfo.ts
@@ -10,4 +10,4 @@ export const CARGO_CONTRACT_INK_DEPS: CargoContractInkDependency[] = [
{ minCargoContractVersion: "2.2.0", validInkVersionRange: "<5.0.0" },
{ minCargoContractVersion: "2.0.2", validInkVersionRange: "<4.2.0" },
{ minCargoContractVersion: "2.0.0", validInkVersionRange: "<4.0.1" },
-];
\ No newline at end of file
+];
diff --git a/src/lib/checks.ts b/src/lib/checks.ts
index c709372b..87237663 100644
--- a/src/lib/checks.ts
+++ b/src/lib/checks.ts
@@ -19,7 +19,9 @@ export function ensureContractNameOrAllFlagIsSet(
export async function ensureContractPathExists(contractName: string, projectPath = "") {
const contractPath = path.resolve(projectPath, "contracts", contractName);
if (!(await pathExists(contractPath))) {
- throw new InputError(`Contract folder not found ${chalk.yellowBright(contractName)} at path: ${contractPath}`);
+ throw new InputError(
+ `Contract folder not found ${chalk.yellowBright(contractName)} at path: ${contractPath}`
+ );
}
}
@@ -28,7 +30,7 @@ export async function contractFromRecord(contractRecord: ContractData) {
if (!(await contract.pathExists())) {
throw new FileError(
- `Path to contract ${contractRecord.name} does not exist: ${contract.contractPath}`,
+ `Path to contract ${contractRecord.name} does not exist: ${contract.contractPath}`
);
}
return contract;
@@ -38,7 +40,7 @@ export async function ensureArtifactsExist(contract: Contract) {
const artifactsCheck = await contract.artifactsExist();
if (!artifactsCheck.result) {
throw new FileError(
- `No artifact file found at path: ${artifactsCheck.missingPaths.toString()}`,
+ `No artifact file found at path: ${artifactsCheck.missingPaths.toString()}`
);
}
}
@@ -77,4 +79,4 @@ export function ensureCargoContractVersionCompatibility(
`cargo-contract version >= ${minimalVersion} required, but found version ${cargoContractVersion}. Please update to a compatible version.`
);
}
-}
\ No newline at end of file
+}
diff --git a/src/lib/config-builder.ts b/src/lib/config-builder.ts
index 8a2d5e3b..58c0e53c 100644
--- a/src/lib/config-builder.ts
+++ b/src/lib/config-builder.ts
@@ -1,4 +1,11 @@
-import { AccountData, BuildData, DeploymentData, SwankyConfig, SwankySystemConfig, ZombienetData } from "../index.js";
+import {
+ AccountData,
+ BuildData,
+ DeploymentData,
+ SwankyConfig,
+ SwankySystemConfig,
+ ZombienetData,
+} from "../index.js";
import { snakeCase } from "change-case";
export class ConfigBuilder {
@@ -34,7 +41,7 @@ export class ConfigBuilder {
updateEnv(env: Record): ConfigBuilder {
if ("env" in this.config) {
- this.config.env = {...this.config.env, ...env};
+ this.config.env = { ...this.config.env, ...env };
}
return this;
}
@@ -79,10 +86,10 @@ export class ConfigBuilder {
}
addChopsticks(path: string): ConfigBuilder {
- if("node" in this.config) {
- this.config.node.chopsticks ={
+ if ("node" in this.config) {
+ this.config.node.chopsticks = {
configPath: path,
- }
+ };
}
return this;
}
diff --git a/src/lib/config.ts b/src/lib/config.ts
index 193af1bc..db869f2c 100644
--- a/src/lib/config.ts
+++ b/src/lib/config.ts
@@ -2,9 +2,9 @@ import { configName, SwankyConfig } from "../index.js";
import { FileError } from "./errors.js";
export function ensureSwankyNodeInstalled(config: SwankyConfig) {
- if (config.node.localPath === "") {
- throw new FileError('Swanky node is not installed. Please run `swanky node:install` first.');
- }
+ if (config.node.localPath === "") {
+ throw new FileError("Swanky node is not installed. Please run `swanky node:install` first.");
+ }
}
// //deploy
@@ -36,9 +36,9 @@ export function ensureSwankyNodeInstalled(config: SwankyConfig) {
// }
export function findContractRecord(config: SwankyConfig, contractName: string) {
- const contractRecord = config.contracts[contractName];
- if (!contractRecord) {
- throw new FileError(`Cannot find a contract named ${contractName} in "${configName()}"`);
- }
- return contractRecord;
+ const contractRecord = config.contracts[contractName];
+ if (!contractRecord) {
+ throw new FileError(`Cannot find a contract named ${contractName} in "${configName()}"`);
+ }
+ return contractRecord;
}
diff --git a/src/lib/contract.ts b/src/lib/contract.ts
index 22dc127e..463be595 100644
--- a/src/lib/contract.ts
+++ b/src/lib/contract.ts
@@ -26,7 +26,6 @@ export class Contract {
return pathExists(this.contractPath);
}
-
async artifactsExist(): Promise<{ result: boolean; missingPaths: string[] }> {
const missingPaths: string[] = [];
let result = true;
@@ -48,7 +47,7 @@ export class Contract {
missingPaths: [],
};
const artifactPath = path.resolve("typedContracts", `${this.name}`);
- if(!(await pathExists(artifactPath))) {
+ if (!(await pathExists(artifactPath))) {
result.result = false;
result.missingPaths.push(artifactPath);
}
@@ -64,7 +63,7 @@ export class Contract {
async getBundle() {
const contractArtifactPath = `${this.moduleName}.contract`;
await this.ensureArtifactExists(contractArtifactPath);
- return readJSON(path.resolve(this.artifactsPath, contractArtifactPath), 'utf8');
+ return readJSON(path.resolve(this.artifactsPath, contractArtifactPath), "utf8");
}
async getWasm(): Promise {
diff --git a/src/lib/contractCall.ts b/src/lib/contractCall.ts
index b42c0ae1..dcd7c840 100644
--- a/src/lib/contractCall.ts
+++ b/src/lib/contractCall.ts
@@ -15,7 +15,11 @@ import chalk from "chalk";
import { SwankyCommand } from "./swankyCommand.js";
import { cryptoWaitReady } from "@polkadot/util-crypto/crypto";
import { NetworkError } from "./errors.js";
-import { contractFromRecord, ensureArtifactsExist, ensureDevAccountNotInProduction } from "./checks.js";
+import {
+ contractFromRecord,
+ ensureArtifactsExist,
+ ensureDevAccountNotInProduction,
+} from "./checks.js";
export type JoinedFlagsType = Interfaces.InferredFlags<
(typeof ContractCall)["baseFlags"] & T["flags"]
@@ -43,7 +47,7 @@ export abstract class ContractCall extends SwankyComma
default: "local",
description: "Name of network to connect to",
}),
- }
+ };
protected flags!: JoinedFlagsType;
protected args!: Record;
@@ -61,19 +65,19 @@ export abstract class ContractCall extends SwankyComma
const contractRecord = findContractRecord(this.swankyConfig, args.contractName);
- const contract = (await contractFromRecord(contractRecord));
+ const contract = await contractFromRecord(contractRecord);
await ensureArtifactsExist(contract);
const deploymentData = flags.address
? contract.deployments.find(
- (deployment: DeploymentData) => deployment.address === flags.address,
- )
+ (deployment: DeploymentData) => deployment.address === flags.address
+ )
: contract.deployments[0];
if (!deploymentData?.address)
throw new NetworkError(
- `Cannot find a deployment with address: ${flags.address} in "${configName()}"`,
+ `Cannot find a deployment with address: ${flags.address} in "${configName()}"`
);
this.deploymentInfo = deploymentData;
@@ -93,17 +97,17 @@ export abstract class ContractCall extends SwankyComma
const mnemonic = accountData.isDev
? (accountData.mnemonic as string)
: decrypt(
- accountData.mnemonic as Encrypted,
- (
- await inquirer.prompt([
- {
- type: "password",
- message: `Enter password for ${chalk.yellowBright(accountData.alias)}: `,
- name: "password",
- },
- ])
- ).password,
- );
+ accountData.mnemonic as Encrypted,
+ (
+ await inquirer.prompt([
+ {
+ type: "password",
+ message: `Enter password for ${chalk.yellowBright(accountData.alias)}: `,
+ name: "password",
+ },
+ ])
+ ).password
+ );
const account = (await this.spinner.runCommand(async () => {
await cryptoWaitReady();
diff --git a/src/lib/nodeInfo.ts b/src/lib/nodeInfo.ts
index 59e2f415..9051baa6 100644
--- a/src/lib/nodeInfo.ts
+++ b/src/lib/nodeInfo.ts
@@ -4,120 +4,155 @@ export interface nodeInfo {
supportedInk: string;
downloadUrl: {
darwin: {
- "arm64"?: string;
- "x64"?: string;
+ arm64?: string;
+ x64?: string;
};
linux: {
- "arm64"?: string;
- "x64"?: string;
+ arm64?: string;
+ x64?: string;
};
};
}
export const swankyNodeVersions = new Map([
- ["1.6.0", {
- version: "1.6.0",
- polkadotPalletVersions: "polkadot-v0.9.39",
- supportedInk: "v4.3.0",
- downloadUrl: {
- darwin: {
- "arm64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.6.0/swanky-node-v1.6.0-macOS-universal.tar.gz",
- "x64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.6.0/swanky-node-v1.6.0-macOS-universal.tar.gz"
+ [
+ "1.6.0",
+ {
+ version: "1.6.0",
+ polkadotPalletVersions: "polkadot-v0.9.39",
+ supportedInk: "v4.3.0",
+ downloadUrl: {
+ darwin: {
+ arm64:
+ "https://github.com/AstarNetwork/swanky-node/releases/download/v1.6.0/swanky-node-v1.6.0-macOS-universal.tar.gz",
+ x64: "https://github.com/AstarNetwork/swanky-node/releases/download/v1.6.0/swanky-node-v1.6.0-macOS-universal.tar.gz",
+ },
+ linux: {
+ arm64:
+ "https://github.com/AstarNetwork/swanky-node/releases/download/v1.6.0/swanky-node-v1.6.0-ubuntu-aarch64.tar.gz",
+ x64: "https://github.com/AstarNetwork/swanky-node/releases/download/v1.6.0/swanky-node-v1.6.0-ubuntu-x86_64.tar.gz",
+ },
},
- linux: {
- "arm64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.6.0/swanky-node-v1.6.0-ubuntu-aarch64.tar.gz",
- "x64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.6.0/swanky-node-v1.6.0-ubuntu-x86_64.tar.gz",
- }
- }
- }],
- ["1.5.0", {
- version: "1.5.0",
- polkadotPalletVersions: "polkadot-v0.9.39",
- supportedInk: "v4.0.0",
- downloadUrl: {
- darwin: {
- "arm64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.5.0/swanky-node-v1.5.0-macOS-universal.tar.gz",
- "x64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.5.0/swanky-node-v1.5.0-macOS-universal.tar.gz"
+ },
+ ],
+ [
+ "1.5.0",
+ {
+ version: "1.5.0",
+ polkadotPalletVersions: "polkadot-v0.9.39",
+ supportedInk: "v4.0.0",
+ downloadUrl: {
+ darwin: {
+ arm64:
+ "https://github.com/AstarNetwork/swanky-node/releases/download/v1.5.0/swanky-node-v1.5.0-macOS-universal.tar.gz",
+ x64: "https://github.com/AstarNetwork/swanky-node/releases/download/v1.5.0/swanky-node-v1.5.0-macOS-universal.tar.gz",
+ },
+ linux: {
+ arm64:
+ "https://github.com/AstarNetwork/swanky-node/releases/download/v1.5.0/swanky-node-v1.5.0-ubuntu-aarch64.tar.gz",
+ x64: "https://github.com/AstarNetwork/swanky-node/releases/download/v1.5.0/swanky-node-v1.5.0-ubuntu-x86_64.tar.gz",
+ },
},
- linux: {
- "arm64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.5.0/swanky-node-v1.5.0-ubuntu-aarch64.tar.gz",
- "x64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.5.0/swanky-node-v1.5.0-ubuntu-x86_64.tar.gz",
- }
- }
- }],
- ["1.4.0", {
- version: "1.4.0",
- polkadotPalletVersions: "polkadot-v0.9.37",
- supportedInk: "v4.0.0",
- downloadUrl: {
- darwin: {
- "arm64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.4.0/swanky-node-v1.4.0-macOS-universal.tar.gz",
- "x64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.4.0/swanky-node-v1.4.0-macOS-universal.tar.gz"
+ },
+ ],
+ [
+ "1.4.0",
+ {
+ version: "1.4.0",
+ polkadotPalletVersions: "polkadot-v0.9.37",
+ supportedInk: "v4.0.0",
+ downloadUrl: {
+ darwin: {
+ arm64:
+ "https://github.com/AstarNetwork/swanky-node/releases/download/v1.4.0/swanky-node-v1.4.0-macOS-universal.tar.gz",
+ x64: "https://github.com/AstarNetwork/swanky-node/releases/download/v1.4.0/swanky-node-v1.4.0-macOS-universal.tar.gz",
+ },
+ linux: {
+ arm64:
+ "https://github.com/AstarNetwork/swanky-node/releases/download/v1.4.0/swanky-node-v1.4.0-ubuntu-aarch64.tar.gz",
+ x64: "https://github.com/AstarNetwork/swanky-node/releases/download/v1.4.0/swanky-node-v1.4.0-ubuntu-x86_64.tar.gz",
+ },
},
- linux: {
- "arm64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.4.0/swanky-node-v1.4.0-ubuntu-aarch64.tar.gz",
- "x64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.4.0/swanky-node-v1.4.0-ubuntu-x86_64.tar.gz",
- }
- }
- }],
- ["1.3.0", {
- version: "1.3.0",
- polkadotPalletVersions: "polkadot-v0.9.37",
- supportedInk: "v4.0.0",
- downloadUrl: {
- darwin: {
- "arm64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.3.0/swanky-node-v1.3.0-macOS-universal.tar.gz",
- "x64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.3.0/swanky-node-v1.3.0-macOS-universal.tar.gz"
+ },
+ ],
+ [
+ "1.3.0",
+ {
+ version: "1.3.0",
+ polkadotPalletVersions: "polkadot-v0.9.37",
+ supportedInk: "v4.0.0",
+ downloadUrl: {
+ darwin: {
+ arm64:
+ "https://github.com/AstarNetwork/swanky-node/releases/download/v1.3.0/swanky-node-v1.3.0-macOS-universal.tar.gz",
+ x64: "https://github.com/AstarNetwork/swanky-node/releases/download/v1.3.0/swanky-node-v1.3.0-macOS-universal.tar.gz",
+ },
+ linux: {
+ arm64:
+ "https://github.com/AstarNetwork/swanky-node/releases/download/v1.3.0/swanky-node-v1.3.0-ubuntu-aarch64.tar.gz",
+ x64: "https://github.com/AstarNetwork/swanky-node/releases/download/v1.3.0/swanky-node-v1.3.0-ubuntu-x86_64.tar.gz",
+ },
},
- linux: {
- "arm64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.3.0/swanky-node-v1.3.0-ubuntu-aarch64.tar.gz",
- "x64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.3.0/swanky-node-v1.3.0-ubuntu-x86_64.tar.gz",
- }
- }
- }],
- ["1.2.0", {
- version: "1.2.0",
- polkadotPalletVersions: "polkadot-v0.9.37",
- supportedInk: "v4.0.0",
- downloadUrl: {
- darwin: {
- "arm64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.2.0/swanky-node-v1.2.0-macOS-universal.tar.gz",
- "x64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.2.0/swanky-node-v1.2.0-macOS-universal.tar.gz"
+ },
+ ],
+ [
+ "1.2.0",
+ {
+ version: "1.2.0",
+ polkadotPalletVersions: "polkadot-v0.9.37",
+ supportedInk: "v4.0.0",
+ downloadUrl: {
+ darwin: {
+ arm64:
+ "https://github.com/AstarNetwork/swanky-node/releases/download/v1.2.0/swanky-node-v1.2.0-macOS-universal.tar.gz",
+ x64: "https://github.com/AstarNetwork/swanky-node/releases/download/v1.2.0/swanky-node-v1.2.0-macOS-universal.tar.gz",
+ },
+ linux: {
+ arm64:
+ "https://github.com/AstarNetwork/swanky-node/releases/download/v1.2.0/swanky-node-v1.2.0-ubuntu-aarch64.tar.gz",
+ x64: "https://github.com/AstarNetwork/swanky-node/releases/download/v1.2.0/swanky-node-v1.2.0-ubuntu-x86_64.tar.gz",
+ },
},
- linux: {
- "arm64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.2.0/swanky-node-v1.2.0-ubuntu-aarch64.tar.gz",
- "x64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.2.0/swanky-node-v1.2.0-ubuntu-x86_64.tar.gz",
- }
- }
- }],
- ["1.1.0", {
- version: "1.1.0",
- polkadotPalletVersions: "polkadot-v0.9.37",
- supportedInk: "v4.0.0",
- downloadUrl: {
- darwin: {
- "arm64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.1.0/swanky-node-v1.1.0-macOS-x86_64.tar.gz",
- "x64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.1.0/swanky-node-v1.1.0-macOS-x86_64.tar.gz"
+ },
+ ],
+ [
+ "1.1.0",
+ {
+ version: "1.1.0",
+ polkadotPalletVersions: "polkadot-v0.9.37",
+ supportedInk: "v4.0.0",
+ downloadUrl: {
+ darwin: {
+ arm64:
+ "https://github.com/AstarNetwork/swanky-node/releases/download/v1.1.0/swanky-node-v1.1.0-macOS-x86_64.tar.gz",
+ x64: "https://github.com/AstarNetwork/swanky-node/releases/download/v1.1.0/swanky-node-v1.1.0-macOS-x86_64.tar.gz",
+ },
+ linux: {
+ arm64:
+ "https://github.com/AstarNetwork/swanky-node/releases/download/v1.1.0/swanky-node-v1.1.0-ubuntu-x86_64.tar.gz",
+ x64: "https://github.com/AstarNetwork/swanky-node/releases/download/v1.1.0/swanky-node-v1.1.0-ubuntu-x86_64.tar.gz",
+ },
},
- linux: {
- "arm64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.1.0/swanky-node-v1.1.0-ubuntu-x86_64.tar.gz",
- "x64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.1.0/swanky-node-v1.1.0-ubuntu-x86_64.tar.gz",
- }
- }
- }],
- ["1.0.0", {
- version: "1.0.0",
- polkadotPalletVersions: "polkadot-v0.9.30",
- supportedInk: "v3.4.0",
- downloadUrl: {
- darwin: {
- "arm64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.0.0/swanky-node-v1.0.0-macOS-x86_64.tar.gz",
- "x64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.0.0/swanky-node-v1.0.0-macOS-x86_64.tar.gz"
+ },
+ ],
+ [
+ "1.0.0",
+ {
+ version: "1.0.0",
+ polkadotPalletVersions: "polkadot-v0.9.30",
+ supportedInk: "v3.4.0",
+ downloadUrl: {
+ darwin: {
+ arm64:
+ "https://github.com/AstarNetwork/swanky-node/releases/download/v1.0.0/swanky-node-v1.0.0-macOS-x86_64.tar.gz",
+ x64: "https://github.com/AstarNetwork/swanky-node/releases/download/v1.0.0/swanky-node-v1.0.0-macOS-x86_64.tar.gz",
+ },
+ linux: {
+ arm64:
+ "https://github.com/AstarNetwork/swanky-node/releases/download/v1.0.0/swanky-node-v1.0.0-ubuntu-x86_64.tar.gz",
+ x64: "https://github.com/AstarNetwork/swanky-node/releases/download/v1.0.0/swanky-node-v1.0.0-ubuntu-x86_64.tar.gz",
+ },
},
- linux: {
- "arm64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.0.0/swanky-node-v1.0.0-ubuntu-x86_64.tar.gz",
- "x64": "https://github.com/AstarNetwork/swanky-node/releases/download/v1.0.0/swanky-node-v1.0.0-ubuntu-x86_64.tar.gz",
- }
- }
- }]
+ },
+ ],
]);
diff --git a/src/lib/swankyCommand.ts b/src/lib/swankyCommand.ts
index d3c3ff43..0f7155b9 100644
--- a/src/lib/swankyCommand.ts
+++ b/src/lib/swankyCommand.ts
@@ -1,9 +1,12 @@
import { Command, Flags, Interfaces } from "@oclif/core";
import chalk from "chalk";
-import { buildSwankyConfig,
+import {
+ buildSwankyConfig,
configName,
getSwankyConfig,
- getSystemConfigDirectoryPath, Spinner } from "./index.js";
+ getSystemConfigDirectoryPath,
+ Spinner,
+} from "./index.js";
import { AccountData, SwankyConfig, SwankySystemConfig } from "../types/index.js";
import { writeJSON } from "fs-extra/esm";
import { existsSync, mkdirSync } from "fs";
@@ -144,7 +147,9 @@ export abstract class SwankyCommand extends Command {
);
if (!accountData) {
- throw new ConfigError(`Provided account alias ${chalk.yellowBright(alias)} not found in swanky.config.json`);
+ throw new ConfigError(
+ `Provided account alias ${chalk.yellowBright(alias)} not found in swanky.config.json`
+ );
}
return accountData;
diff --git a/src/lib/tasks.ts b/src/lib/tasks.ts
index 0755b9d8..26b418dd 100644
--- a/src/lib/tasks.ts
+++ b/src/lib/tasks.ts
@@ -6,7 +6,15 @@ import process from "node:process";
import { nodeInfo } from "./nodeInfo.js";
import decompress from "decompress";
import { Spinner } from "./spinner.js";
-import { DependencyName, Relaychain, SupportedArch, SupportedPlatforms, SwankyConfig, TestType, ZombienetConfig } from "../types/index.js";
+import {
+ DependencyName,
+ Relaychain,
+ SupportedArch,
+ SupportedPlatforms,
+ SwankyConfig,
+ TestType,
+ ZombienetConfig,
+} from "../types/index.js";
import { ConfigError, NetworkError, ProcessError } from "./errors.js";
import { BinaryNames } from "./zombienetInfo.js";
import { zombienetConfig } from "../commands/zombienet/init.js";
@@ -71,9 +79,7 @@ export function osCheck() {
const supportedArchs = supportedConfigs[platform as keyof typeof supportedConfigs];
if (!supportedArchs.includes(arch)) {
- throw new ConfigError(
- `Architecture '${arch}' is not supported on platform '${platform}'.`
- );
+ throw new ConfigError(`Architecture '${arch}' is not supported on platform '${platform}'.`);
}
return { platform, arch };
@@ -121,13 +127,13 @@ export async function downloadNode(projectPath: string, nodeInfo: nodeInfo, spin
const platformDlUrls = nodeInfo.downloadUrl[process.platform as SupportedPlatforms];
if (!platformDlUrls)
throw new ConfigError(
- `Could not download swanky-node. Platform ${process.platform} not supported!`,
+ `Could not download swanky-node. Platform ${process.platform} not supported!`
);
const dlUrl = platformDlUrls[process.arch as SupportedArch];
if (!dlUrl)
throw new ConfigError(
- `Could not download swanky-node. Platform ${process.platform} Arch ${process.arch} not supported!`,
+ `Could not download swanky-node. Platform ${process.platform} Arch ${process.arch} not supported!`
);
const dlFileDetails = await new Promise((resolve, reject) => {
@@ -144,7 +150,7 @@ export async function downloadNode(projectPath: string, nodeInfo: nodeInfo, spin
});
dl.start().catch((error: Error) =>
- reject(new Error(`Error downloading node: , ${error.message}`)),
+ reject(new Error(`Error downloading node: , ${error.message}`))
);
});
@@ -165,7 +171,12 @@ export async function downloadNode(projectPath: string, nodeInfo: nodeInfo, spin
return path.resolve(binPath, dlFileDetails.filePath);
}
-export async function downloadZombienetBinaries(binaries: string[], projectPath: string, swankyConfig: SwankyConfig, spinner: Spinner) {
+export async function downloadZombienetBinaries(
+ binaries: string[],
+ projectPath: string,
+ swankyConfig: SwankyConfig,
+ spinner: Spinner
+) {
const binPath = path.resolve(projectPath, "zombienet", "bin");
await ensureDir(binPath);
@@ -182,29 +193,31 @@ export async function downloadZombienetBinaries(binaries: string[], projectPath:
const platformDlUrls = zombienetInfo.downloadUrl[process.platform as SupportedPlatforms];
if (!platformDlUrls)
throw new ConfigError(
- `Could not download ${binaryName}. Platform ${process.platform} not supported!`,
+ `Could not download ${binaryName}. Platform ${process.platform} not supported!`
);
let dlUrl = platformDlUrls[process.arch as SupportedArch];
if (!dlUrl)
throw new ConfigError(
- `Could not download ${binaryName}. Platform ${process.platform} Arch ${process.arch} not supported!`,
+ `Could not download ${binaryName}. Platform ${process.platform} Arch ${process.arch} not supported!`
);
dlUrl = dlUrl.replace("${version}", version);
dlUrls.set(binaryName, dlUrl);
}
- for (const binaryName of Object.keys(zombienetInfo.binaries).filter((binaryName) => binaries.includes(binaryName))) {
+ for (const binaryName of Object.keys(zombienetInfo.binaries).filter((binaryName) =>
+ binaries.includes(binaryName)
+ )) {
const binaryInfo = zombienetInfo.binaries[binaryName as BinaryNames];
const version = binaryInfo.version;
const platformDlUrls = binaryInfo.downloadUrl[process.platform as SupportedPlatforms];
if (!platformDlUrls)
throw new ConfigError(
- `Could not download ${binaryName}. Platform ${process.platform} not supported!`,
+ `Could not download ${binaryName}. Platform ${process.platform} not supported!`
);
let dlUrl = platformDlUrls[process.arch as SupportedArch];
if (!dlUrl)
throw new ConfigError(
- `Could not download ${binaryName}. Platform ${process.platform} Arch ${process.arch} not supported!`,
+ `Could not download ${binaryName}. Platform ${process.platform} Arch ${process.arch} not supported!`
);
dlUrl = dlUrl.replace(/\$\{version}/gi, version);
dlUrls.set(binaryName, dlUrl);
@@ -225,7 +238,7 @@ export async function downloadZombienetBinaries(binaries: string[], projectPath:
});
dl.start().catch((error: Error) =>
- reject(new Error(`Error downloading ${binaryName}: , ${error.message}`)),
+ reject(new Error(`Error downloading ${binaryName}: , ${error.message}`))
);
});
@@ -249,7 +262,11 @@ export async function downloadZombienetBinaries(binaries: string[], projectPath:
}
}
-export async function buildZombienetConfigFromBinaries(binaries: string[], templatePath: string, configPath: string) {
+export async function buildZombienetConfigFromBinaries(
+ binaries: string[],
+ templatePath: string,
+ configPath: string
+) {
await ensureDir(configPath);
const configBuilder = {
settings: {
@@ -264,7 +281,9 @@ export async function buildZombienetConfigFromBinaries(binaries: string[], templ
} as ZombienetConfig;
for (const binaryName of binaries) {
- const template = TOML.parse(readFileSync(path.resolve(templatePath, binaryName + ".toml"), "utf8"));
+ const template = TOML.parse(
+ readFileSync(path.resolve(templatePath, binaryName + ".toml"), "utf8")
+ );
if (template.parachains !== undefined) {
(template.parachains as any).forEach((parachain: any) => {
configBuilder.parachains.push(parachain);
@@ -279,7 +298,6 @@ export async function buildZombienetConfigFromBinaries(binaries: string[], templ
if (template.relaychain !== undefined) {
configBuilder.relaychain = template.relaychain as unknown as Relaychain;
}
-
}
writeFileSync(path.resolve(configPath, zombienetConfig), TOML.stringify(configBuilder as any));
diff --git a/src/lib/templates.ts b/src/lib/templates.ts
index d0479e66..7820fa48 100644
--- a/src/lib/templates.ts
+++ b/src/lib/templates.ts
@@ -35,11 +35,11 @@ export function getTemplates() {
export async function copyContractTemplateFiles(
contractTemplatePath: string,
contractName: string,
- projectPath: string,
+ projectPath: string
) {
await copy(
path.resolve(contractTemplatePath, "contract"),
- path.resolve(projectPath, "contracts", contractName),
+ path.resolve(projectPath, "contracts", contractName)
);
}
@@ -47,7 +47,7 @@ export async function copyZombienetTemplateFile(templatePath: string, configPath
await ensureDir(configPath);
await copy(
path.resolve(templatePath, zombienetConfig),
- path.resolve(configPath, zombienetConfig),
+ path.resolve(configPath, zombienetConfig)
);
}
@@ -55,7 +55,7 @@ export async function copyChopsticksTemplateFile(templatePath: string, configPat
await ensureDir(configPath);
await copy(
path.resolve(templatePath, chopsticksConfig),
- path.resolve(configPath, chopsticksConfig),
+ path.resolve(configPath, chopsticksConfig)
);
}
@@ -65,12 +65,12 @@ export async function copyCommonTemplateFiles(templatesPath: string, projectPath
await Promise.all(
commonFiles.map(async (file) => {
await copy(path.resolve(templatesPath, file), path.resolve(projectPath, file));
- }),
+ })
);
await rename(path.resolve(projectPath, "gitignore"), path.resolve(projectPath, ".gitignore"));
await rename(
path.resolve(projectPath, "mocharc.json"),
- path.resolve(projectPath, ".mocharc.json"),
+ path.resolve(projectPath, ".mocharc.json")
);
await copy(path.resolve(templatesPath, "github"), path.resolve(projectPath, ".github"));
}
@@ -87,4 +87,4 @@ export async function processTemplates(projectPath: string, templateData: Record
await rm(tplFilePath);
await writeFile(tplFilePath.split(".hbs")[0], compiledFile);
}
-}
\ No newline at end of file
+}
diff --git a/src/lib/zombienetInfo.ts b/src/lib/zombienetInfo.ts
index 3b6b0faf..add21553 100644
--- a/src/lib/zombienetInfo.ts
+++ b/src/lib/zombienetInfo.ts
@@ -6,21 +6,23 @@ export const zombienet = {
version: "1.3.89",
downloadUrl: {
darwin: {
- "arm64": "https://github.com/paritytech/zombienet/releases/download/v${version}/zombienet-macos",
- "x64": "https://github.com/paritytech/zombienet/releases/download/v${version}/zombienet-macos",
+ arm64:
+ "https://github.com/paritytech/zombienet/releases/download/v${version}/zombienet-macos",
+ x64: "https://github.com/paritytech/zombienet/releases/download/v${version}/zombienet-macos",
},
linux: {
- "arm64": "https://github.com/paritytech/zombienet/releases/download/v${version}/zombienet-linux-arm64",
- "x64": "https://github.com/paritytech/zombienet/releases/download/v${version}/zombienet-linux-x64",
+ arm64:
+ "https://github.com/paritytech/zombienet/releases/download/v${version}/zombienet-linux-arm64",
+ x64: "https://github.com/paritytech/zombienet/releases/download/v${version}/zombienet-linux-x64",
},
},
binaries: {
- "polkadot": {
+ polkadot: {
version: "0.9.43",
downloadUrl: {
linux: {
- "arm64": "https://github.com/paritytech/polkadot/releases/download/v${version}/polkadot",
- "x64": "https://github.com/paritytech/polkadot/releases/download/v${version}/polkadot",
+ arm64: "https://github.com/paritytech/polkadot/releases/download/v${version}/polkadot",
+ x64: "https://github.com/paritytech/polkadot/releases/download/v${version}/polkadot",
},
},
},
@@ -28,8 +30,9 @@ export const zombienet = {
version: "0.9.430",
downloadUrl: {
linux: {
- "arm64": "https://github.com/paritytech/cumulus/releases/download/v${version}/polkadot-parachain",
- "x64": "https://github.com/paritytech/cumulus/releases/download/v${version}/polkadot-parachain",
+ arm64:
+ "https://github.com/paritytech/cumulus/releases/download/v${version}/polkadot-parachain",
+ x64: "https://github.com/paritytech/cumulus/releases/download/v${version}/polkadot-parachain",
},
},
},
@@ -37,12 +40,14 @@ export const zombienet = {
version: "5.28.0",
downloadUrl: {
darwin: {
- "arm64": "https://github.com/AstarNetwork/Astar/releases/download/v${version}/astar-collator-v${version}-macOS-x86_64.tar.gz",
- "x64": "https://github.com/AstarNetwork/Astar/releases/download/v${version}/astar-collator-v${version}-macOS-x86_64.tar.gz",
+ arm64:
+ "https://github.com/AstarNetwork/Astar/releases/download/v${version}/astar-collator-v${version}-macOS-x86_64.tar.gz",
+ x64: "https://github.com/AstarNetwork/Astar/releases/download/v${version}/astar-collator-v${version}-macOS-x86_64.tar.gz",
},
linux: {
- "arm64": "https://github.com/AstarNetwork/Astar/releases/download/v${version}/astar-collator-v${version}-ubuntu-aarch64.tar.gz",
- "x64": "https://github.com/AstarNetwork/Astar/releases/download/v${version}/astar-collator-v${version}-ubuntu-x86_64.tar.gz",
+ arm64:
+ "https://github.com/AstarNetwork/Astar/releases/download/v${version}/astar-collator-v${version}-ubuntu-aarch64.tar.gz",
+ x64: "https://github.com/AstarNetwork/Astar/releases/download/v${version}/astar-collator-v${version}-ubuntu-x86_64.tar.gz",
},
},
},
diff --git a/src/types/index.ts b/src/types/index.ts
index b5e27a42..a8266944 100644
--- a/src/types/index.ts
+++ b/src/types/index.ts
@@ -12,7 +12,10 @@ export interface ChainProperty {
export type ExtrinsicPayload = SubmittableExtrinsic<"promise">;
-export interface Encrypted { iv: string; data: string }
+export interface Encrypted {
+ iv: string;
+ data: string;
+}
export interface AccountData {
isDev: boolean;
@@ -44,15 +47,15 @@ export interface DeploymentData {
export interface DownloadUrl {
darwin: {
- "arm64": string,
- "x64": string
- },
+ arm64: string;
+ x64: string;
+ };
linux: {
- "arm64": string,
- "x64": string
- }
+ arm64: string;
+ x64: string;
+ };
}
-export interface SwankyConfig extends SwankySystemConfig{
+export interface SwankyConfig extends SwankySystemConfig {
node: {
polkadotPalletVersions: string;
localPath: string;
@@ -70,7 +73,7 @@ export interface SwankyConfig extends SwankySystemConfig{
export interface SwankySystemConfig {
defaultAccount: string | null;
accounts: AccountData[];
- networks: Record;
+ networks: Record;
}
export interface ZombienetData {
@@ -80,37 +83,37 @@ export interface ZombienetData {
}
export interface ZombienetConfig {
- settings: { timeout: number },
- relaychain: Relaychain,
- parachains: Parachain[],
- hrmp_channels?: HrmpChannel[],
+ settings: { timeout: number };
+ relaychain: Relaychain;
+ parachains: Parachain[];
+ hrmp_channels?: HrmpChannel[];
}
export interface Relaychain {
- default_command: string,
- chain: string,
- nodes: Node[]
+ default_command: string;
+ chain: string;
+ nodes: Node[];
}
export interface Node {
- name: string,
+ name: string;
}
export interface HrmpChannel {
- sender: number,
- recipient: number,
- max_capacity: number,
- max_message_size: number
+ sender: number;
+ recipient: number;
+ max_capacity: number;
+ max_message_size: number;
}
export interface Parachain {
- id: number,
- chain: string,
- cumulus_based: boolean,
- collator: Collator
+ id: number;
+ chain: string;
+ cumulus_based: boolean;
+ collator: Collator;
}
export interface Collator {
- name: string,
- command: string,
- rpc_port: number,
- args: string[],
+ name: string;
+ command: string;
+ rpc_port: number;
+ args: string[];
}
export enum BuildMode {