diff --git a/src/commands/contract/deploy.ts b/src/commands/contract/deploy.ts index 22ca3d89..6eaef42d 100644 --- a/src/commands/contract/deploy.ts +++ b/src/commands/contract/deploy.ts @@ -2,8 +2,8 @@ import { Args, Flags } from "@oclif/core"; import path from "node:path"; import { writeJSON } from "fs-extra/esm"; import { cryptoWaitReady } from "@polkadot/util-crypto/crypto"; -import { resolveNetworkUrl, ChainApi, ChainAccount, decrypt, AbiType } from "../../lib/index.js"; -import { AccountData, Encrypted } from "../../types/index.js"; +import { AbiType, ChainAccount, ChainApi, decrypt, resolveNetworkUrl } from "../../lib/index.js"; +import { AccountData, BuildMode, Encrypted } from "../../types/index.js"; import inquirer from "inquirer"; import chalk from "chalk"; import { Contract } from "../../lib/contract.js"; @@ -98,11 +98,11 @@ export class DeployContract extends SwankyCommand { }, "Initialising")) as ChainAccount; const buildMode = await contract.getBuildMode(); - if(buildMode !== 'Release') { + if(buildMode !== BuildMode.Verifiable) { await inquirer.prompt([ { type: "confirm", - message: `You are deploying a contract in debug mode. Are you sure you want to continue?`, + message: `You are deploying a not verified contract in ${buildMode === BuildMode.Release ? "release" : "debug"} mode. Are you sure you want to continue?`, name: "confirm", }, ]).then((answers) => { diff --git a/src/lib/contract.ts b/src/lib/contract.ts index d65d4f42..264ce382 100644 --- a/src/lib/contract.ts +++ b/src/lib/contract.ts @@ -1,5 +1,5 @@ import { AbiType, consts, printContractInfo } from "./index.js"; -import { ContractData, DeploymentData } from "../types/index.js"; +import { BuildMode, ContractData, DeploymentData } from "../types/index.js"; import { pathExists, readJSON } from "fs-extra/esm"; import path from "node:path"; import { FileError } from "./errors.js"; @@ -50,7 +50,7 @@ export class Contract { return readJSON(path.resolve(this.artifactsPath, `${this.moduleName}.json`)); } - async getBuildMode(): Promise { + async getBuildMode(): Promise { const check = await this.artifactsExist(); if (!check.result && check.missingTypes.includes(".contract")) { throw new FileError( @@ -58,7 +58,7 @@ export class Contract { ); } const contractJson = JSON.parse(fs.readFileSync(path.resolve(this.artifactsPath, `${this.moduleName}.json`), 'utf8')); - return contractJson.source.build_info.build_mode; + return contractJson.image && (contractJson.image as string).startsWith("paritytech/contracts-verifiable") ? BuildMode.Verifiable : contractJson.source.build_info.build_mode; } async getBundle() { const check = await this.artifactsExist(); diff --git a/src/types/index.ts b/src/types/index.ts index aa13a0df..1b3646a1 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -49,5 +49,11 @@ export interface SwankyConfig { networks: Record } +export enum BuildMode { + Debug = "Debug", + Release = "Release", + Verifiable = "Verifiable", +} + export type SupportedPlatforms = "darwin" | "linux"; export type SupportedArch = "arm64" | "x64";