Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove more dan layer code #4490

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
112 changes: 0 additions & 112 deletions applications/tari_console_wallet/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
#[clap(long, alias = "issuer")]
pub contract_issuer: Option<String>,
#[clap(long, alias = "runtime")]
pub runtime: Option<String>,
}

#[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<String>,
#[clap(long, alias = "committee")]
pub validator_committee: Option<Vec<String>>,
#[clap(long, alias = "acceptance_period")]
pub acceptance_period_expiry: Option<String>,
#[clap(long, alias = "quorum_required")]
pub minimum_quorum_required: Option<String>,
}

#[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<String>,
#[clap(long, alias = "proposal_id")]
pub proposal_id: Option<String>,
#[clap(long, alias = "committee")]
pub validator_committee: Option<Vec<String>>,
#[clap(long, alias = "acceptance_period")]
pub acceptance_period_expiry: Option<String>,
#[clap(long, alias = "quorum_required")]
pub minimum_quorum_required: Option<String>,
}

#[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<String>,
}

#[derive(Debug, Args, Clone)]
pub struct PublishFileArgs {
pub file_path: PathBuf,
}

#[derive(Debug, Args, Clone)]
pub struct PublishUpdateProposalArgs {
pub file_path: PathBuf,
}
50 changes: 0 additions & 50 deletions integration_tests/features/NFT.feature

This file was deleted.

65 changes: 0 additions & 65 deletions integration_tests/features/WalletCli.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
103 changes: 0 additions & 103 deletions integration_tests/features/support/wallet_cli_steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/,
Expand Down Expand Up @@ -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);
}
);
22 changes: 0 additions & 22 deletions integration_tests/features/support/world.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down