Skip to content

Commit

Permalink
pulled latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alenmestrov committed Dec 23, 2024
1 parent 0182e26 commit 647192c
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 9 deletions.
3 changes: 2 additions & 1 deletion contracts/icp/context-config/.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

# DFX CANISTER ENVIRONMENT VARIABLES
DFX_VERSION='0.24.2'
DFX_VERSION='0.24.3'
DFX_NETWORK='local'
CANISTER_ID_LEDGER='bd3sg-teaaa-aaaaa-qaaba-cai'
CANISTER_ID_CONTEXT_CONTRACT='bkyz2-fmaaa-aaaaa-qaaaq-cai'
CANISTER_ID='bkyz2-fmaaa-aaaaa-qaaaq-cai'
CANISTER_CANDID_PATH='/Users/alen/www/calimero/core/contracts/icp/context-config/./res/calimero_context_config_icp.did'
Expand Down
35 changes: 30 additions & 5 deletions contracts/icp/context-config/deploy_devnet.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
#!/bin/bash
set -e

# Build the contract
# Build both contracts
echo "Building contracts..."
cd "$(dirname $0)"
./build.sh
cd ../context-proxy
./build.sh
cd ../context-config

# Stop the replica
# Stop and start dfx
echo "Restarting dfx..."
dfx stop
dfx start --background --clean

# Start the replica
dfx start --background
# Force remove existing canisters if they exist
echo "Cleaning up old canisters..."
dfx canister delete context_contract || true
dfx canister delete ledger || true

# Deploy the contract
# Create and deploy canisters
echo "Deploying contracts..."
dfx canister create --all --force
dfx deploy

# Get the proxy wasm
echo "Reading proxy WASM..."
PROXY_WASM=$(xxd -p ../context-proxy/res/calimero_context_proxy_icp.wasm | tr -d '\n')

# Set proxy code in context config
echo "Setting proxy code in context config..."
dfx canister call context_contract set_proxy_code "(
vec {$(echo $PROXY_WASM | sed 's/\([0-9a-f]\{2\}\)/0x\1;/g')},
principal \"$LEDGER_ID\"
)"

echo "Deployment complete!"
19 changes: 18 additions & 1 deletion contracts/icp/context-config/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
"package": "calimero-context-config-icp",
"candid": "./res/calimero_context_config_icp.did",
"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",
"remote": {
"candid": "https://raw.githubusercontent.com/dfinity/ic/aba60ffbc46acfc8990bf4d5685c1360bd7026b9/rs/ledger_suite/icp/ledger.did",
"id": {
"ic": "ryjl3-tyaaa-aaaaa-aaaba-cai"
}
},
"init_arg": "(variant { Init = record { minting_account = \"62c39e7c2484a1a9aa0864f9fb402558537111c3e6db3c37f793ab460f137ae4\"; initial_values = vec {}; send_whitelist = vec {}; token_name = opt \"Internet Computer\"; token_symbol = opt \"ICP\"; transfer_fee = opt record { e8s = 10_000 }; archive_options = opt record { trigger_threshold = 2_000_000; num_blocks_to_archive = 1_000_000; controller_id = principal \"aaaaa-aa\"; cycles_for_archive_creation = opt (0 : nat64); node_max_memory_size_bytes = null; max_message_size_bytes = null }}})"
}
},
"defaults": {
Expand All @@ -12,6 +24,11 @@
"packtool": ""
}
},
"output_env_file": ".env",
"networks": {
"local": {
"bind": "127.0.0.1:8080",
"type": "persistent"
}
},
"version": 1
}
6 changes: 4 additions & 2 deletions contracts/icp/context-config/src/mutate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,10 @@ fn add_members(
let mut ctx_members = guard_ref.get_mut();

for member in members {
ctx_members.insert(member);
let _ignored = context.member_nonces.entry(member).or_default();
if ctx_members.insert(member) {
// returns true if the value was newly inserted
let _ignored = context.member_nonces.entry(member).or_default();
}
}

Ok(())
Expand Down
9 changes: 9 additions & 0 deletions contracts/icp/context-proxy/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
"packtool": ""
}
},
"networks": {
"local": {
"bind": "127.0.0.1:8080",
"type": "persistent",
"replica": {
"subnet_type": "system"
}
}
},
"output_env_file": ".env",
"version": 1
}

0 comments on commit 647192c

Please sign in to comment.