Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Locked gate #6095

Merged
merged 3 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions backend/canisters/community/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Added

- Add `Locked` gate ([#6095](https://github.com/open-chat-labs/open-chat/pull/6095))

### Changed

- Fix fee then retry transfer if fee too high ([#6063](https://github.com/open-chat-labs/open-chat/pull/6063))
Expand Down
4 changes: 4 additions & 0 deletions backend/canisters/group/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Added

- Add `Locked` gate ([#6095](https://github.com/open-chat-labs/open-chat/pull/6095))

### Changed

- Fix fee then retry transfer if fee too high ([#6063](https://github.com/open-chat-labs/open-chat/pull/6063))
Expand Down
4 changes: 4 additions & 0 deletions backend/canisters/group_index/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Added

- Add `Locked` gate ([#6095](https://github.com/open-chat-labs/open-chat/pull/6095))

### Changed

- Clear old data from the failed upgrades log ([#6062](https://github.com/open-chat-labs/open-chat/pull/6062))
Expand Down
3 changes: 3 additions & 0 deletions backend/canisters/group_index/impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ pub struct AccessGateMetrics {
pub token_balance: u32,
#[serde(default)]
pub composite: u32,
#[serde(default)]
pub locked: u32,
}

impl AccessGateMetrics {
Expand All @@ -393,6 +395,7 @@ impl AccessGateMetrics {
AccessGate::Payment(_) => self.payment += 1,
AccessGate::TokenBalance(_) => self.token_balance += 1,
AccessGate::Composite(_) => self.composite += 1,
AccessGate::Locked => self.locked += 1,
}
}
}
4 changes: 4 additions & 0 deletions backend/canisters/local_group_index/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Added

- Add `Locked` gate ([#6095](https://github.com/open-chat-labs/open-chat/pull/6095))

### Changed

- Clear old data from the failed upgrades log ([#6062](https://github.com/open-chat-labs/open-chat/pull/6062))
Expand Down
1 change: 1 addition & 0 deletions backend/canisters/local_user_index/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Support submitting proof of uniqueness to LocalUserIndex ([#6068](https://github.com/open-chat-labs/open-chat/pull/6068))
- Support submitting proof of diamond membership to LocalUserIndex ([#6084](https://github.com/open-chat-labs/open-chat/pull/6084))
- Add `Locked` gate ([#6095](https://github.com/open-chat-labs/open-chat/pull/6095))

### Changed

Expand Down
4 changes: 4 additions & 0 deletions backend/canisters/user/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Added

- Add `Locked` gate ([#6095](https://github.com/open-chat-labs/open-chat/pull/6095))

### Changed

- Improve check for empty and dormant users ([#6073](https://github.com/open-chat-labs/open-chat/pull/6073))
Expand Down
1 change: 1 addition & 0 deletions backend/libraries/gated_groups/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ async fn check_non_composite_gate(gate: AccessGate, args: CheckGateArgs) -> Chec
AccessGate::Payment(g) => try_transfer_from(&g, args.user_id, args.this_canister, args.now).await,
AccessGate::TokenBalance(g) => check_token_balance_gate(&g, args.user_id).await,
AccessGate::Composite(_) => unreachable!(),
AccessGate::Locked => CheckIfPassesGateResult::Failed(GateCheckFailedReason::Locked),
}
}

Expand Down
2 changes: 2 additions & 0 deletions backend/libraries/types/can.did
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,7 @@ type AccessGate = variant {
inner : vec AccessGate;
and : bool;
};
Locked;
};

type AccessGateUpdate = variant {
Expand Down Expand Up @@ -1577,6 +1578,7 @@ type GateCheckFailedReason = variant {
PaymentFailed : ICRC2_TransferFromError;
InsufficientBalance : nat;
FailedVerifiedCredentialCheck : text;
Locked;
};

type VerifiedCredentialGateArgs = record {
Expand Down
3 changes: 3 additions & 0 deletions backend/libraries/types/src/gated_groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub enum AccessGate {
Payment(PaymentGate),
TokenBalance(TokenBalanceGate),
Composite(CompositeGate),
Locked,
}

impl AccessGate {
Expand Down Expand Up @@ -45,6 +46,7 @@ impl AccessGate {
AccessGate::Payment(_) => "payment",
AccessGate::TokenBalance(_) => "token_balance",
AccessGate::Composite(_) => "composite",
AccessGate::Locked => "locked",
}
}
}
Expand Down Expand Up @@ -101,6 +103,7 @@ pub enum GateCheckFailedReason {
PaymentFailed(TransferFromError),
InsufficientBalance(u128),
FailedVerifiedCredentialCheck(String),
Locked,
}

#[derive(CandidType, Serialize, Deserialize, Clone, Debug)]
Expand Down
Loading