-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into swap
# Conflicts: # frontend/app/src/components/home/profile/Accounts.svelte
- Loading branch information
Showing
178 changed files
with
2,228 additions
and
879 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). | ||
|
||
## [unreleased] | ||
|
||
### Added | ||
|
||
- Introduce the Escrow canister for supporting P2P trades ([#4903](https://github.com/open-chat-labs/open-chat/pull/4903)) | ||
- Implement `create_offer` and `notify_deposit` ([#4904](https://github.com/open-chat-labs/open-chat/pull/4904)) | ||
- Transfer out funds once trade is complete ([#4906](https://github.com/open-chat-labs/open-chat/pull/4906)) | ||
- Implement `cancel_offer` ([#4907](https://github.com/open-chat-labs/open-chat/pull/4907)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "escrow_canister" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
candid = { workspace = true } | ||
candid_gen = { path = "../../../libraries/candid_gen" } | ||
icrc-ledger-types = { workspace = true } | ||
serde = { workspace = true } | ||
sha256 = { path = "../../../libraries/sha256" } | ||
types = { path = "../../../libraries/types" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
service : { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use candid::Principal; | ||
use icrc_ledger_types::icrc1::account::Subaccount; | ||
use sha256::sha256; | ||
use types::UserId; | ||
|
||
mod lifecycle; | ||
mod queries; | ||
mod updates; | ||
|
||
pub use lifecycle::*; | ||
pub use queries::*; | ||
pub use updates::*; | ||
|
||
pub fn deposit_subaccount(user_id: UserId, offer_id: u32) -> Subaccount { | ||
let mut bytes = Vec::new(); | ||
bytes.extend_from_slice(Principal::from(user_id).as_slice()); | ||
bytes.extend_from_slice(&offer_id.to_be_bytes()); | ||
sha256(&bytes) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use candid::CandidType; | ||
use serde::{Deserialize, Serialize}; | ||
use types::{BuildVersion, CanisterId}; | ||
|
||
#[derive(CandidType, Serialize, Deserialize, Debug)] | ||
pub struct Args { | ||
pub cycles_dispenser_canister_id: CanisterId, | ||
pub wasm_version: BuildVersion, | ||
pub test_mode: bool, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod init; | ||
pub mod post_upgrade; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use candid::CandidType; | ||
use serde::{Deserialize, Serialize}; | ||
use types::BuildVersion; | ||
|
||
#[derive(CandidType, Serialize, Deserialize, Debug)] | ||
pub struct Args { | ||
pub wasm_version: BuildVersion, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[allow(deprecated)] | ||
fn main() { | ||
candid::export_service!(); | ||
std::print!("{}", __export_service()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub struct Args { | ||
pub offer_id: u32, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub enum Response { | ||
Success, | ||
OfferAlreadyAccepted, | ||
OfferExpired, | ||
OfferNotFound, | ||
NotAuthorized, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use types::{TimestampMillis, TokenInfo}; | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub struct Args { | ||
pub input_token: TokenInfo, | ||
pub input_amount: u128, | ||
pub output_token: TokenInfo, | ||
pub output_amount: u128, | ||
pub expires_at: TimestampMillis, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub enum Response { | ||
Success(SuccessResult), | ||
InvalidOffer(String), | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub struct SuccessResult { | ||
pub id: u32, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub mod cancel_offer; | ||
pub mod create_offer; | ||
pub mod notify_deposit; |
25 changes: 25 additions & 0 deletions
25
backend/canisters/escrow/api/src/updates/notify_deposit.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use types::UserId; | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub struct Args { | ||
pub offer_id: u32, | ||
pub user_id: Option<UserId>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub enum Response { | ||
Success, | ||
BalanceTooLow(BalanceTooLowResult), | ||
OfferAlreadyAccepted, | ||
OfferCancelled, | ||
OfferExpired, | ||
OfferNotFound, | ||
InternalError(String), | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub struct BalanceTooLowResult { | ||
pub balance: u128, | ||
pub balance_required: u128, | ||
} |
Oops, something went wrong.