Skip to content

Commit

Permalink
Merge branch 'feat--icp-contracts' into icp_query_mutate_integration
Browse files Browse the repository at this point in the history
  • Loading branch information
alenmestrov committed Dec 2, 2024
2 parents 70e8a42 + f1213c0 commit 590cdec
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 21 deletions.
26 changes: 11 additions & 15 deletions contracts/icp/context-config/build.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
#!/bin/bash

# Exit on error
#!/bin/sh
set -e

# Ensure we have the wasm32 target
rustup target add wasm32-unknown-unknown
cd "$(dirname $0)"

# Build the contract
cargo build --target wasm32-unknown-unknown --release
TARGET="${CARGO_TARGET_DIR:-./target}"

rustup target add wasm32-unknown-unknown

# Generate the candid interface
candid-extractor target/wasm32-unknown-unknown/release/context_contract.wasm > context_contract.did
cargo build --target wasm32-unknown-unknown --profile app-release

# Stop the replica
dfx stop
mkdir -p res

# Start the replica
dfx start --background
cp $TARGET/wasm32-unknown-unknown/app-release/context_contract.wasm ./res/context_contract.wasm

# Deploy the contract
dfx deploy
if command -v wasm-opt > /dev/null; then
wasm-opt -Oz ./res/context_contract.wasm -o ./res/context_contract.wasm
fi
16 changes: 16 additions & 0 deletions contracts/icp/context-config/deploy_devnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Build the contract
bash ./build.sh

# Generate the candid interface
candid-extractor res/context_contract.wasm > context_contract.did

# Stop the replica
dfx stop

# Start the replica
dfx start --background

# Deploy the contract
dfx deploy
4 changes: 0 additions & 4 deletions contracts/icp/context-config/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ impl ICContextId {
pub fn new(bytes: [u8; 32]) -> Self {
Self(Identity(bytes))
}

pub fn as_bytes(&self) -> [u8; 32] {
self.0.as_bytes()
}
}

impl ReprBytes for ICContextId {
Expand Down
4 changes: 2 additions & 2 deletions contracts/icp/context-config/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::time::{Duration, SystemTime, UNIX_EPOCH};

use calimero_context_config::repr::ReprBytes;
use candid::Principal;
use context_contract::types::{
ContextRequest, ContextRequestKind, ICApplication, ICApplicationId, ICBlobId, ICCapability,
Expand All @@ -11,8 +12,7 @@ use rand::Rng;

fn setup() -> (PocketIc, Principal) {
let pic = PocketIc::new();
let wasm = std::fs::read("target/wasm32-unknown-unknown/release/context_contract.wasm")
.expect("failed to read wasm");
let wasm = std::fs::read("res/context_contract.wasm").expect("failed to read wasm");
let canister = pic.create_canister();
pic.add_cycles(canister, 2_000_000_000_000);
pic.install_canister(
Expand Down
1 change: 1 addition & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ cd "$(dirname $0)"
../contracts/registry/build.sh
../contracts/context-config/build.sh
../contracts/proxy-lib/build-test-deps.sh
../contracts/icp/context-config/build.sh

# Run cargo test
cargo test

0 comments on commit 590cdec

Please sign in to comment.