Skip to content

Commit

Permalink
fix: updated script for devnet deployment, adjusted initial context c…
Browse files Browse the repository at this point in the history
…ontract principal, removed static IDs of canisters
  • Loading branch information
alenmestrov committed Dec 26, 2024
1 parent f99d909 commit 95d0d1d
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 22 deletions.
76 changes: 59 additions & 17 deletions contracts/icp/context-config/deploy_devnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,27 @@ get_account_id() {
dfx ledger account-id --of-principal "$principal"
}

echo "Checking dependencies..."
command -v dfx >/dev/null 2>&1 || { echo "dfx is required but not installed. Aborting." >&2; exit 1; }
command -v cargo >/dev/null 2>&1 || { echo "cargo is required but not installed. Aborting." >&2; exit 1; }

dfxvm default 0.24.3

# Stop dfx and clean up all state
dfx stop
rm -rf .dfx
rm -rf ~/.config/dfx/replica-configuration/
rm -rf ~/.config/dfx/identity/minting
rm -rf ~/.config/dfx/identity/initial
rm -rf ~/.config/dfx/identity/archive
rm -rf ~/.cache/dfinity/
rm -rf ~/.config/dfx/
dfxvm default 0.24.3
# Remove canister_ids.json if it exists
if [ -f "canister_ids.json" ]; then
rm canister_ids.json
fi

# Generate minting account
dfx identity new minting --storage-mode=plaintext || true
dfx identity use minting
Expand All @@ -35,27 +56,38 @@ ARCHIVE_PRINCIPAL=$(dfx identity get-principal)
# Switch back to default identity
dfx identity use default

# Stop dfx and clean up all state
dfx stop
rm -rf .dfx
rm -rf ~/.config/dfx/replica-configuration/
rm -rf ~/.cache/dfinity/
# Remove canister_ids.json if it exists
if [ -f "canister_ids.json" ]; then
rm canister_ids.json
fi

# Start dfx with clean state
dfx start --clean --background

# Define canister IDs
CONTEXT_ID="br5f7-7uaaa-aaaaa-qaaca-cai"
LEDGER_ID="be2us-64aaa-aaaaa-qaabq-cai"
dfx identity use default

# Create initial identity if needed
dfx identity new --storage-mode=plaintext minting || true
# dfx identity use minting

echo "Creating and deploying canister..."
dfx canister create context_contract
dfx canister create ledger

# Create canisters
echo "Creating canisters..."
dfx canister create context_contract --specified-id "$CONTEXT_ID"
dfx canister create ledger --specified-id "$LEDGER_ID"
# Get the context ID
CONTEXT_ID=$(dfx canister id context_contract)
echo "Context ID: $CONTEXT_ID"

# Get the wallet ID and seed it
WALLET_ID=$(dfx identity get-wallet)
echo "Wallet ID: $WALLET_ID"

# abricate cycles for the wallet
dfx ledger fabricate-cycles --canister $WALLET_ID --amount 200000

# Transfer cycles from wallet to context contract
dfx canister deposit-cycles 1000000000000000000 $CONTEXT_ID

echo "Done! Cycles transferred to context contract: $CONTEXT_ID"

# Get the IDs
CONTEXT_ID=$(dfx canister id context_contract)
LEDGER_ID=$(dfx canister id ledger)

# Build contracts
echo "Building contracts..."
Expand Down Expand Up @@ -114,6 +146,16 @@ dfx canister call context_contract set_proxy_code --argument-file "$TEMP_CMD"
# Clean up
rm "$TEMP_CMD"

# # First top up the wallet with extra buffer
# dfx canister deposit-cycles 3000000000000000 $(dfx identity get-wallet) # 3000T cycles

# # Then top up the context contract with enough for 100+ proxies
# dfx canister deposit-cycles 200000000000000 context_contract # 200T cycles

# # Get the canister ID first
# CONTEXT_ID=$(dfx canister id context_contract)
# dfx canister deposit-cycles 1000000000000000 $CONTEXT_ID # 100T cycles

# Print all relevant information at the end
echo -e "\n=== Deployment Summary ==="
echo "Context Contract ID: ${CONTEXT_ID}"
Expand Down
10 changes: 6 additions & 4 deletions contracts/icp/context-config/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
"context_contract": {
"package": "calimero-context-config-icp",
"candid": "./res/calimero_context_config_icp.did",
"type": "rust",
"id": "br5f7-7uaaa-aaaaa-qaaca-cai"
"type": "rust"
},
"ledger": {
"type": "custom",
"wasm": "https://download.dfinity.systems/ic/aba60ffbc46acfc8990bf4d5685c1360bd7026b9/canisters/ledger-canister.wasm.gz",
"candid": "https://raw.githubusercontent.com/dfinity/ic/aba60ffbc46acfc8990bf4d5685c1360bd7026b9/rs/ledger_suite/icp/ledger.did",
"id": "be2us-64aaa-aaaaa-qaabq-cai"
"candid": "https://raw.githubusercontent.com/dfinity/ic/aba60ffbc46acfc8990bf4d5685c1360bd7026b9/rs/ledger_suite/icp/ledger.did"
}
},
"defaults": {
Expand All @@ -25,5 +23,9 @@
"type": "persistent"
}
},
"routing_table": {
"start_canister_id": "aaaaa-aa",
"end_canister_id": "zzzzz-zz"
},
"version": 1
}
2 changes: 1 addition & 1 deletion crates/merod/src/cli/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ impl InitCommand {
"0x1b991ee006e2d1e372ab96d0a957401fa200358f317b681df2948f30e17c29c"
.parse()?
}
ConfigProtocol::Icp => "br5f7-7uaaa-aaaaa-qaaca-cai".parse()?,
ConfigProtocol::Icp => "bkyz2-fmaaa-aaaaa-qaaaq-cai".parse()?,
},
},
},
Expand Down

0 comments on commit 95d0d1d

Please sign in to comment.