diff --git a/applications/tari_console_wallet/src/cli.rs b/applications/tari_console_wallet/src/cli.rs index a0f0e338b8..03015aa625 100644 --- a/applications/tari_console_wallet/src/cli.rs +++ b/applications/tari_console_wallet/src/cli.rs @@ -201,115 +201,3 @@ pub struct ClaimShaAtomicSwapRefundArgs { #[clap(short, long, default_value = "Claimed HTLC atomic swap refund")] pub message: String, } - -#[derive(Debug, Args, Clone)] -pub struct ContractCommand { - #[clap(subcommand)] - pub subcommand: ContractSubcommand, -} - -#[derive(Debug, Subcommand, Clone)] -pub enum ContractSubcommand { - /// Generates a new contract definition JSON spec file that can be edited and passed to other contract definition - /// commands. - InitDefinition(InitDefinitionArgs), - - /// A generator for constitution files that can be edited and passed to other contract commands - InitConstitution(InitConstitutionArgs), - - /// A generator for update proposal files that can be edited and passed to other contract commands - InitUpdateProposal(InitUpdateProposalArgs), - - /// A generator for amendment files that can be edited and passed to other contract commands - InitAmendment(InitAmendmentArgs), - - /// Creates and publishes a contract definition UTXO from the JSON spec file. - PublishDefinition(PublishFileArgs), - - /// Creates and publishes a contract definition UTXO from the JSON spec file. - PublishConstitution(PublishFileArgs), - - /// Creates and publishes a contract update proposal UTXO from the JSON spec file. - PublishUpdateProposal(PublishFileArgs), - - /// Creates and publishes a contract amendment UTXO from the JSON spec file. - PublishAmendment(PublishFileArgs), -} - -#[derive(Debug, Args, Clone)] -pub struct InitDefinitionArgs { - /// The destination path of the contract definition to create - pub dest_path: PathBuf, - /// Force overwrite the destination file if it already exists - #[clap(short = 'f', long)] - pub force: bool, - #[clap(long, alias = "name")] - pub contract_name: Option, - #[clap(long, alias = "issuer")] - pub contract_issuer: Option, - #[clap(long, alias = "runtime")] - pub runtime: Option, -} - -#[derive(Debug, Args, Clone)] -pub struct InitConstitutionArgs { - /// The destination path of the contract definition to create - pub dest_path: PathBuf, - /// Force overwrite the destination file if it already exists - #[clap(short = 'f', long)] - pub force: bool, - #[clap(long, alias = "id")] - pub contract_id: Option, - #[clap(long, alias = "committee")] - pub validator_committee: Option>, - #[clap(long, alias = "acceptance_period")] - pub acceptance_period_expiry: Option, - #[clap(long, alias = "quorum_required")] - pub minimum_quorum_required: Option, -} - -#[derive(Debug, Args, Clone)] -pub struct InitUpdateProposalArgs { - /// The destination path of the contract definition to create - pub dest_path: PathBuf, - /// Force overwrite the destination file if it already exists - #[clap(short = 'f', long)] - pub force: bool, - #[clap(long, alias = "id")] - pub contract_id: Option, - #[clap(long, alias = "proposal_id")] - pub proposal_id: Option, - #[clap(long, alias = "committee")] - pub validator_committee: Option>, - #[clap(long, alias = "acceptance_period")] - pub acceptance_period_expiry: Option, - #[clap(long, alias = "quorum_required")] - pub minimum_quorum_required: Option, -} - -#[derive(Debug, Args, Clone)] -pub struct InitAmendmentArgs { - /// The destination path of the contract amendment to create - pub dest_path: PathBuf, - - /// Force overwrite the destination file if it already exists - #[clap(short = 'f', long)] - pub force: bool, - - /// The source file path of the update proposal to amend - #[clap(short = 'p', long)] - pub proposal_file_path: PathBuf, - - #[clap(long, alias = "activation_window")] - pub activation_window: Option, -} - -#[derive(Debug, Args, Clone)] -pub struct PublishFileArgs { - pub file_path: PathBuf, -} - -#[derive(Debug, Args, Clone)] -pub struct PublishUpdateProposalArgs { - pub file_path: PathBuf, -} diff --git a/integration_tests/features/NFT.feature b/integration_tests/features/NFT.feature deleted file mode 100644 index 0e76dac85f..0000000000 --- a/integration_tests/features/NFT.feature +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2022 The Tari Project -# SPDX-License-Identifier: BSD-3-Clause - -@dan -Feature: NFT - - @broken - Scenario: Minting tokens - Given I have a seed node SEED - And I have wallet WALLET_A connected to seed node SEED - And I have mining node MINER connected to seed node SEED and wallet WALLET_A - And mining node MINER mines 5 blocks - Then I wait for wallet WALLET_A to have at least 1000000 uT - And I wait 30 seconds - And I register asset FACTORY on wallet WALLET_A - Then I have asset FACTORY on wallet WALLET_A with status ENCUMBEREDTOBERECEIVED - And mining node MINER mines 1 block - # TODO: remove recovery and do the test on just one wallet - When I recover wallet WALLET_A into wallet WALLET_B connected to all seed nodes - Then I have asset FACTORY on wallet WALLET_B with status UNSPENT - And I mint tokens "TOKEN1 TOKEN2" for asset FACTORY on wallet WALLET_B - Then I have token TOKEN1 for asset FACTORY on wallet WALLET_B in state ENCUMBEREDTOBERECEIVED - And mining node MINER mines 1 block - # TODO: remove recovery and do the test on just one wallet - When I recover wallet WALLET_B into wallet WALLET_C connected to all seed nodes - Then I have token TOKEN1 for asset FACTORY on wallet WALLET_C in state UNSPENT - # TODO: If the following lines fail, we can rewrite the both tests to single wallet - Then I have token TOKEN1 for asset FACTORY on wallet WALLET_B in state ENCUMBEREDTOBERECEIVED - Then I have asset FACTORY on wallet WALLET_A with status ENCUMBEREDTOBERECEIVED - - @broken - Scenario: Minting tokens via command line - Given I have a seed node SEED - And I have wallet WALLET_A connected to seed node SEED - And I have mining node MINER connected to seed node SEED and wallet WALLET_A - And mining node MINER mines 5 blocks - Then I wait for wallet WALLET_A to have at least 1000000 uT - And I wait 30 seconds - And I register asset FACTORY on wallet WALLET_A via command line - Then I have asset FACTORY on wallet WALLET_A with status ENCUMBEREDTOBERECEIVED - And mining node MINER mines 1 block - # TODO: remove recovery and do the test on just one wallet - When I recover wallet WALLET_A into wallet WALLET_B connected to all seed nodes - Then I have asset FACTORY on wallet WALLET_B with status UNSPENT - And I mint tokens "TOKEN1 TOKEN2" for asset FACTORY on wallet WALLET_B via command line - Then I have token TOKEN1 for asset FACTORY on wallet WALLET_B in state ENCUMBEREDTOBERECEIVED - And mining node MINER mines 1 block - # TODO: remove recovery and do the test on just one wallet - When I recover wallet WALLET_B into wallet WALLET_C connected to all seed nodes - Then I have token TOKEN1 for asset FACTORY on wallet WALLET_C in state UNSPENT diff --git a/integration_tests/features/WalletCli.feature b/integration_tests/features/WalletCli.feature index a11ce1dfc6..000f9b655c 100644 --- a/integration_tests/features/WalletCli.feature +++ b/integration_tests/features/WalletCli.feature @@ -140,68 +140,3 @@ Feature: Wallet CLI And I have wallet WALLET connected to base node BASE Then I run whois BASE on wallet WALLET via command line - @dan @critical - Scenario: As a user I want to publish a contract definition via command line - Given I have a base node BASE - And I have wallet WALLET connected to base node BASE - And I have mining node MINE connected to base node BASE and wallet WALLET - And mining node MINE mines 4 blocks - Then I wait for wallet WALLET to have at least 1000000 uT - And I publish a contract definition DEF1 from file "fixtures/contract_definition.json" on wallet WALLET via command line - And mining node MINE mines 8 blocks - Then wallet WALLET has at least 1 transactions that are all TRANSACTION_STATUS_MINED_CONFIRMED and not cancelled - Then WALLET is connected to BASE - - @dan @critical - Scenario: As a user I want to publish a contract constitution via command line - Given I have a base node BASE - And I have wallet WALLET connected to base node BASE - And I have mining node MINE connected to base node BASE and wallet WALLET - And mining node MINE mines 4 blocks - Then I wait for wallet WALLET to have at least 1000000 uT - And I publish a contract definition DEF1 from file "fixtures/contract_definition.json" on wallet WALLET via command line - And mining node MINE mines 8 blocks - Then wallet WALLET has at least 1 transactions that are all TRANSACTION_STATUS_MINED_CONFIRMED and not cancelled - And I publish a contract constitution from file "fixtures/contract_constitution.json" on wallet WALLET via command line - And mining node MINE mines 8 blocks - Then wallet WALLET has at least 2 transactions that are all TRANSACTION_STATUS_MINED_CONFIRMED and not cancelled - Then WALLET is connected to BASE - - @dan @critical - Scenario: As a user I want to publish a contract update proposal via command line - Given I have a base node BASE - And I have wallet WALLET connected to base node BASE - And I have mining node MINE connected to base node BASE and wallet WALLET - And mining node MINE mines 4 blocks - Then I wait for wallet WALLET to have at least 1000000 uT - And I publish a contract definition DEF1 from file "fixtures/contract_definition.json" on wallet WALLET via command line - And mining node MINE mines 8 blocks - Then wallet WALLET has at least 1 transactions that are all TRANSACTION_STATUS_MINED_CONFIRMED and not cancelled - When I publish a contract constitution from file "fixtures/contract_constitution.json" on wallet WALLET via command line - And mining node MINE mines 8 blocks - Then wallet WALLET has at least 2 transactions that are all TRANSACTION_STATUS_MINED_CONFIRMED and not cancelled - And I publish a contract update proposal from file "fixtures/contract_update_proposal.json" on wallet WALLET via command line - And mining node MINE mines 8 blocks - Then wallet WALLET has at least 3 transactions that are all TRANSACTION_STATUS_MINED_CONFIRMED and not cancelled - Then WALLET is connected to BASE - - @dan @critical - Scenario: As a user I want to publish a contract amendment via command line - Given I have a base node BASE - And I have wallet WALLET connected to base node BASE - And I have mining node MINE connected to base node BASE and wallet WALLET - And mining node MINE mines 4 blocks - Then I wait for wallet WALLET to have at least 1000000 uT - And I publish a contract definition DEF1 from file "fixtures/contract_definition.json" on wallet WALLET via command line - And mining node MINE mines 8 blocks - Then wallet WALLET has at least 1 transactions that are all TRANSACTION_STATUS_MINED_CONFIRMED and not cancelled - When I publish a contract constitution from file "fixtures/contract_constitution.json" on wallet WALLET via command line - And mining node MINE mines 8 blocks - Then wallet WALLET has at least 2 transactions that are all TRANSACTION_STATUS_MINED_CONFIRMED and not cancelled - And I publish a contract update proposal from file "fixtures/contract_update_proposal.json" on wallet WALLET via command line - And mining node MINE mines 8 blocks - Then wallet WALLET has at least 3 transactions that are all TRANSACTION_STATUS_MINED_CONFIRMED and not cancelled - And I publish a contract amendment from file "fixtures/contract_amendment.json" on wallet WALLET via command line - And mining node MINE mines 8 blocks - Then wallet WALLET has at least 4 transactions that are all TRANSACTION_STATUS_MINED_CONFIRMED and not cancelled - Then WALLET is connected to BASE diff --git a/integration_tests/features/support/wallet_cli_steps.js b/integration_tests/features/support/wallet_cli_steps.js index d8507dd416..3d071f759a 100644 --- a/integration_tests/features/support/wallet_cli_steps.js +++ b/integration_tests/features/support/wallet_cli_steps.js @@ -22,9 +22,7 @@ const { Given, Then, When } = require("@cucumber/cucumber"); const { expect } = require("chai"); -const fs = require("fs"); const { waitFor, sleep } = require("../../helpers/util"); -const path = require("path"); Given( /I change the password of wallet (.*) to (.*) via command line/, @@ -242,104 +240,3 @@ When( } } ); - -Then( - "I publish a contract definition {word} from file {string} on wallet {word} via command line", - { timeout: 120 * 1000 }, - async function (definition_name, relative_file_path, wallet_name) { - let absolute_path = path.resolve(relative_file_path); - let wallet = this.getWallet(wallet_name); - let output = await wallet_run_command( - wallet, - `contract publish-definition ${absolute_path}` - ); - - let contract_id = await this.parseContractId(output.buffer); - this.saveContractDefinition(definition_name, contract_id); - - console.log(output.buffer); - } -); - -Then( - "I publish a contract constitution from file {string} on wallet {word} via command line", - { timeout: 120 * 1000 }, - async function (relative_file_path, wallet_name) { - let absolute_path = path.resolve(relative_file_path); - let wallet = this.getWallet(wallet_name); - - let output = await wallet_run_command( - wallet, - `contract publish-constitution ${absolute_path}` - ); - console.log(output.buffer); - } -); - -Then( - "I publish the contract constitution {word} on wallet {word} via command line", - { timeout: 120 * 1000 }, - async function (constitution_name, wallet_name) { - let constitution = this.fetchContractConstitution(constitution_name); - let wallet = this.getWallet(wallet_name); - - let absolute_path = await wallet.writeConstitutionFile(constitution); - let output = await wallet_run_command( - wallet, - `contract publish-constitution ${absolute_path}` - ); - console.log(output.buffer); - } -); - -When( - "I create a contract constitution {word} for contract {word} from file {string}", - async function (constitution_name, contract_name, relative_file_path) { - let absolute_path = path.resolve(relative_file_path); - let contract_id = this.fetchContract(contract_name); - - let constitution = JSON.parse(fs.readFileSync(absolute_path, "utf8")); - constitution["contract_id"] = contract_id; - - this.saveContractConstitution(constitution_name, constitution); - } -); - -When( - "I add {word} to the validator committee on {word}", - async function (vn_name, constitution_name) { - let vn = this.getNode(vn_name); - let constitution = this.fetchContractConstitution(constitution_name); - constitution["validator_committee"] = [vn.getPubKey()]; - } -); - -Then( - "I publish a contract update proposal from file {string} on wallet {word} via command line", - { timeout: 120 * 1000 }, - async function (relative_file_path, wallet_name) { - let absolute_path = path.resolve(relative_file_path); - let wallet = this.getWallet(wallet_name); - - let output = await wallet_run_command( - wallet, - `contract publish-update-proposal ${absolute_path}` - ); - console.log(output.buffer); - } -); - -Then( - "I publish a contract amendment from file {string} on wallet {word} via command line", - { timeout: 120 * 1000 }, - async function (relative_file_path, wallet_name) { - let absolute_path = path.resolve(relative_file_path); - let wallet = this.getWallet(wallet_name); - - let output = await wallet_run_command( - wallet, - `contract publish-amendment ${absolute_path}` - ); - console.log(output.buffer); - } -); diff --git a/integration_tests/features/support/world.js b/integration_tests/features/support/world.js index 843509d884..37db97cfa8 100644 --- a/integration_tests/features/support/world.js +++ b/integration_tests/features/support/world.js @@ -78,34 +78,12 @@ class CustomWorld { return res; } - saveContractDefinition(contract_definition_name, contract_id) { - this.contract_definitions[contract_definition_name] = contract_id; - } - - fetchContract(contract_name) { - return this.contract_definitions[contract_name]; - } - - saveContractConstitution(constitution_name, constitution_data) { - this.constitutions[constitution_name] = constitution_data; - } - - fetchContractConstitution(constitution_name) { - return this.constitutions[constitution_name]; - } - getRandomSeedName() { let keys = Object.keys(this.seeds); let r = Math.random() * keys.length; return keys[r]; } - async parseContractId(output) { - let regex = /contract_id is (\w*) \(TxID/; - let matches = output.match(regex); - return matches[1]; - } - currentBaseNodeName() { return Object.keys(this.nodes)[0]; } diff --git a/integration_tests/helpers/walletProcess.js b/integration_tests/helpers/walletProcess.js index d8e932591f..6806266187 100644 --- a/integration_tests/helpers/walletProcess.js +++ b/integration_tests/helpers/walletProcess.js @@ -12,7 +12,6 @@ const WalletClient = require("./walletClient"); const csvParser = require("csv-parser"); const tari_crypto = require("tari_crypto"); const { OutputType } = require("./types"); -const uuid = require("uuid"); let outputProcess; @@ -464,22 +463,6 @@ class WalletProcess { } return outputs; } - - async writeConstitutionFile(constitution) { - let data = JSON.stringify(constitution); - let absolute_path = path.resolve(this.baseDir + "/" + uuid.v4() + ".json"); - - fs.writeFile(absolute_path, data, "utf8", (err) => { - if (err) { - console.log(`Error writing file: ${err}`); - } else { - console.log("returning filepath:", absolute_path); - return absolute_path; - } - }); - - return absolute_path; - } } module.exports = WalletProcess;