Skip to content

Commit

Permalink
Merge branch 'master' into mraszyk/pic
Browse files Browse the repository at this point in the history
  • Loading branch information
mraszyk committed Nov 18, 2024
2 parents 848eec4 + b64644e commit 5291707
Show file tree
Hide file tree
Showing 26 changed files with 4,515 additions and 284 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@
/rust/send_http_post/ @dfinity/growth
/rust/simd/ @dfinity/execution
/rust/threshold-ecdsa/ @dfinity/crypto-team
/rust/threshold-mock/ @dfinity/crypto-team
/rust/threshold-schnorr/ @dfinity/crypto-team
/rust/token_transfer/ @dfinity/growth
/rust/token_transfer_from/ @dfinity/growth
/rust/vetkd/ @dfinity/crypto-team
/rust/x509/ @dfinity/crypto-team

/svelte/svelte-motoko-starter/ @dfinity/sdk
/svelte/svelte-starter/ @dfinity/sdk
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/close-stale-issues.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
steps:
- uses: actions/stale@v5
with:
days-before-issue-stale: 30
days-before-issue-close: 14
days-before-issue-stale: 182
days-before-issue-close: 182
stale-issue-label: "stale"
stale-issue-message: "This issue is stale because it has been open for 30 days with no activity."
close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
days-before-pr-stale: -1
days-before-pr-close: -1
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/rust-parallel-calls-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- master
pull_request:
paths:
- rust/parallel-calls/**
- rust/parallel_calls/**
- .github/workflows/provision-darwin.sh
- .github/workflows/provision-linux.sh
- .github/workflows/rust-parallel-calls-example.yml
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/rust-threshold-mock-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: rust-threshold-mock
on:
push:
branches:
- master
pull_request:
paths:
- rust/threshold-mock/**
- .github/workflows/provision-darwin.sh
- .github/workflows/provision-linux.sh
- .github/workflows/rust-threshold-mock-example.yml
- .ic-commit
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
rust-threshold-mock-darwin:
runs-on: macos-15
steps:
- uses: actions/checkout@v1
- name: Provision Darwin
run: bash .github/workflows/provision-darwin.sh
- name: Install PocketIC server Darwin
uses: dfinity/pocketic@main
with:
pocket-ic-server-version: "6.0.0"
- name: Build threshold-mock Darwin
run: |
pushd rust/threshold-mock
cargo build --target wasm32-unknown-unknown --release
popd
- name: Lint threshold-mock Darwin
run: |
pushd rust/threshold-mock
cargo fmt --all -- --check && cargo clippy --all-targets --all-features -- -D warnings
popd
- name: Test threshold-mock Darwin
run: |
pushd rust/threshold-mock
cargo test
popd
rust-threshold-mock-linux:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
- name: Provision Linux
run: bash .github/workflows/provision-linux.sh
- name: Install PocketIC server Linux
uses: dfinity/pocketic@main
with:
pocket-ic-server-version: "6.0.0"
- name: Build threshold-mock Linux
run: |
pushd rust/threshold-mock
cargo build --target wasm32-unknown-unknown --release
popd
- name: Lint threshold-mock Linux
run: |
pushd rust/threshold-mock
cargo fmt --all -- --check && cargo clippy --all-targets --all-features -- -D warnings
popd
- name: Test threshold-mock Linux
run: |
pushd rust/threshold-mock
cargo test
popd
2 changes: 1 addition & 1 deletion .github/workflows/rust-x509-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency:
cancel-in-progress: true
jobs:
rust-x509-darwin:
runs-on: macos-12
runs-on: macos-15
steps:
- uses: actions/checkout@v1
- name: Provision Darwin
Expand Down
12 changes: 6 additions & 6 deletions archive/motoko/defi/src/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions rust/basic_bitcoin/src/basic_bitcoin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ thread_local! {
// The bitcoin network to connect to.
//
// When developing locally this should be `Regtest`.
// When deploying to the IC this should be `Testnet`.
// `Mainnet` is currently unsupported.
// When deploying to the IC this should be `Testnet` or `Mainnet`.
static NETWORK: Cell<BitcoinNetwork> = Cell::new(BitcoinNetwork::Testnet);

// The derivation path to use for the threshold key.
Expand Down
26 changes: 26 additions & 0 deletions rust/canister-snapshots/src/chat/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@ use std::{cell::RefCell, collections::HashSet};

thread_local! {
static CHAT: RefCell<Vec<String>> = Default::default();
static LENGTH: RefCell<u64> = Default::default();
}

/// Appends a new message to the chat database.
#[ic_cdk_macros::update]
fn append(message: String) {
// Ensure that the length of the chat is consistent with the actual chat
// contents.
assert_eq!(
LENGTH.with_borrow(|len| *len),
CHAT.with_borrow(|chat| chat.len() as u64)
);
CHAT.with_borrow_mut(|chat| chat.push(message));
LENGTH.with_borrow_mut(|len| *len += 1);
}

/// Dumps all the chat messages.
Expand Down Expand Up @@ -36,6 +44,7 @@ fn remove_spam() -> u64 {
for message in chat {
if message.split(" ").any(|word| spam_keywords.contains(word)) {
spam += 1;
ic_cdk::println!("Found spam message: {message}");
new_chat.push("(removed spam message)".into());
} else {
new_chat.push(message);
Expand All @@ -47,5 +56,22 @@ fn remove_spam() -> u64 {
ic_cdk::println!("Removed {spam} messages, updating the chat...");
CHAT.set(new_chat);
}
ic_cdk::println!("Filtered chat: {:?}", CHAT.with_borrow(|chat| chat.clone()));
spam
}

#[ic_cdk_macros::pre_upgrade]
fn pre_upgrade() {
let chat = CHAT.with_borrow(|chat| chat.clone());
let length = LENGTH.with_borrow(|len| *len);
ic_cdk::storage::stable_save((chat, length)).expect("failed to save stable state");
}

#[ic_cdk_macros::post_upgrade]
fn post_upgrade() {
let (chat, length): (Vec<String>, u64) =
ic_cdk::storage::stable_restore().expect("failed to restore stable state");

CHAT.set(chat);
LENGTH.with_borrow_mut(|len| *len = length);
}
Loading

0 comments on commit 5291707

Please sign in to comment.