Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clean script working
  • Loading branch information
fbielejec committed Sep 19, 2022
commit 260039d67229ccfcffd004becafe7500441e75dd
1 change: 1 addition & 0 deletions bin/cliain/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/target
target
docker/data
!target/release/cliain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Maybe end the file with a newline, it's polite.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

8 changes: 8 additions & 0 deletions bin/cliain/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
FROM ubuntu:jammy-20220531

RUN apt update && \
apt install wget -y && \
apt clean && \
rm -rf /var/lib/apt/lists/*

RUN wget http://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.16_amd64.deb
RUN dpkg -i libssl1.1_1.1.1f-1ubuntu2.16_amd64.deb

COPY target/release/cliain /usr/local/bin
RUN chmod +x /usr/local/bin/cliain

Expand Down
11 changes: 11 additions & 0 deletions contracts/marketplace/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,17 @@ pub mod marketplace {
Ok(())
}

/// Terminates the contract
///
/// Should only be called by the contract Owner
#[ink(message)]
pub fn terminate(&mut self) -> Result<(), Error> {
let caller = self.env().caller();
let this = self.env().account_id();
Self::ensure_role(Role::Owner(this))?;
self.env().terminate_contract(caller)
}

fn current_price(&self) -> Balance {
let block = self.env().block_number();
let elapsed = block.saturating_sub(self.current_start_block.into());
Expand Down
74 changes: 51 additions & 23 deletions contracts/scripts/clean.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,67 @@

set -euo pipefail

# remove games (all 3)
# + remove code
# remove ticket tokens (all 3)
# + remove code
# remove reward tokens (all 3)
# + remove code
# remove marketplaces (all 3)
# + remove code

# remove access control
# + remove code

# local contract_name=$1
# local contract_address=$(cat "$CONTRACTS_PATH"/addresses.json | jq --raw-output ".$contract_name")
# local ticket_address=$(cat "$CONTRACTS_PATH"/addresses.json | jq --raw-output ".${contract_name}_ticket")

# --- FUNCTIONS

function terminate_contract {
local contract_address=$1
cargo contract call --url "$NODE" --contract $contract_address --message terminate --suri "$AUTHORITY_SEED"
}
local contract_name=$1
local contract_dir=$2
local contract_address=$(get_address $contract_name)

# remove code hash
cd "$CONTRACTS_PATH"/$contract_dir
cargo contract call --url "$NODE" --contract $contract_address --message terminate --suri "$AUTHORITY_SEED"
}

# docker build --tag aleph-node:spec_version_6 -f ./docker/Dockerfile .
# public.ecr.aws/p6e8q1z1/cliain
function get_address {
local contract_name=$1
cat "$CONTRACTS_PATH"/addresses.json | jq --raw-output ".$contract_name"
}

docker run -e RUST_LOG=info "${CLIAIN_IMAGE}"
function remove_contract_code {
local code_hash=$(cat "$CONTRACTS_PATH"/addresses.json | jq --raw-output ".$1")

docker run --network host -e RUST_LOG=info "${CLIAIN_IMAGE}" --seed "$AUTHORITY_SEED" --node "$NODE" contract-remove-code --code-hash $code_hash
}

# --- GLOBAL CONSTANTS

CONTRACTS_PATH=$(pwd)/contracts
CLIAIN_IMAGE=public.ecr.aws/p6e8q1z1/cliain:latest

# --- CLEAN BUTTON CONTRACT

terminate_contract early_bird_special button
terminate_contract early_bird_special_marketplace marketplace
terminate_contract early_bird_special_ticket ticket_token
terminate_contract early_bird_special_token game_token

echo "succesfully terminated early_bird_special"

terminate_contract back_to_the_future button
terminate_contract back_to_the_future_ticket ticket_token
terminate_contract back_to_the_future_token game_token
terminate_contract back_to_the_future_marketplace marketplace

echo "succesfully terminated back_to_the_future"

terminate_contract the_pressiah_cometh button
terminate_contract the_pressiah_cometh_ticket ticket_token
terminate_contract the_pressiah_cometh_token game_token
terminate_contract the_pressiah_cometh_marketplace marketplace

echo "succesfully terminated the_pressiah_cometh"

remove_contract_code button_code_hash
remove_contract_code ticket_token_code_hash
remove_contract_code game_token_code_hash
remove_contract_code marketplace_code_hash

echo "succesfully removed code hashes"

# remove access control as last
terminate_contract access_control access_control
remove_contract_code access_control_code_hash

echo "succesfully terminated and removed AccessControl"

exit $?
2 changes: 2 additions & 0 deletions contracts/scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ jq -n --arg early_bird_special "$EARLY_BIRD_SPECIAL" \
--arg ticket_token_code_hash "$TICKET_TOKEN_CODE_HASH" \
--arg game_token_code_hash "$GAME_TOKEN_CODE_HASH" \
--arg marketplace_code_hash "$MARKETPLACE_CODE_HASH" \
--arg access_control "$ACCESS_CONTROL" \
--arg access_control_code_hash "$ACCESS_CONTROL_CODE_HASH" \
'{early_bird_special: $early_bird_special,
early_bird_special_marketplace: $early_bird_special_marketplace,
Expand All @@ -276,6 +277,7 @@ jq -n --arg early_bird_special "$EARLY_BIRD_SPECIAL" \
the_pressiah_cometh_ticket: $the_pressiah_cometh_ticket,
the_pressiah_cometh_token: $the_pressiah_cometh_token,
the_pressiah_cometh_marketplace: $the_pressiah_cometh_marketplace,
access_control: $access_control,
button_code_hash: $button_code_hash,
ticket_token_code_hash: $ticket_token_code_hash,
game_token_code_hash: $game_token_code_hash,
Expand Down