Skip to content
Open
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
138 changes: 17 additions & 121 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ members = [
"client",
"test",
"local-db",
"replayer",
"handler",
# "replayer",
"examples/minimal",
# "examples/draw-card",
"examples/raffle",
Expand All @@ -32,6 +33,7 @@ race-api = { path = "api", version = ">=0.2.6" }
race-local-db = { path = "local-db", version = ">=0.2.6" }
race-proc-macro = { path = "proc-macro", version = ">=0.2.6" }
race-core = { path = "core", version = ">=0.2.6" }
race-handler = { path = "handler", version = ">=0.2.6" }
race-client = { path = "client", version = ">=0.2.6" }
race-encryptor = { path = "encryptor", version = ">=0.2.6" }
race-event-record = { path = "event-record", version = ">=0.2.6" }
Expand Down
9 changes: 5 additions & 4 deletions api/src/effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ pub struct ActionTimeout {
pub timeout: u64,
}

/// The parameters for launching a new subgame.
#[derive(BorshSerialize, BorshDeserialize, Debug, PartialEq, Eq, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct SubGame {
pub struct LaunchSubGame {
pub id: usize,
pub bundle_addr: String,
pub init_account: InitAccount,
Expand All @@ -79,7 +80,7 @@ pub struct SubGameLeave {
pub player_ids: Vec<u64>,
}

impl SubGame {
impl LaunchSubGame {
pub fn try_new<S: BorshSerialize>(
id: usize,
bundle_addr: String,
Expand Down Expand Up @@ -255,7 +256,7 @@ pub struct Effect {
pub handler_state: Option<Vec<u8>>,
pub error: Option<HandleError>,
pub transfer: Option<Transfer>,
pub launch_sub_games: Vec<SubGame>,
pub launch_sub_games: Vec<LaunchSubGame>,
pub bridge_events: Vec<EmitBridgeEvent>,
pub is_init: bool,
pub entry_lock: Option<EntryLock>,
Expand Down Expand Up @@ -432,7 +433,7 @@ impl Effect {
return Err(HandleError::CantLaunchMoreSubGames);
}
let sub_game_id = self.curr_sub_game_id;
self.launch_sub_games.push(SubGame {
self.launch_sub_games.push(LaunchSubGame {
id: sub_game_id,
bundle_addr,
init_account: InitAccount {
Expand Down
2 changes: 1 addition & 1 deletion api/src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub use crate::effect::{Effect, SubGame};
pub use crate::effect::{Effect, LaunchSubGame};
pub use crate::init_account::InitAccount;
pub use crate::engine::GameHandler;
pub use crate::error::{HandleError, HandleResult};
Expand Down
16 changes: 0 additions & 16 deletions api/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,6 @@ pub type Ciphertext = Vec<u8>;
pub type SecretDigest = Vec<u8>;
pub type SecretKey = Vec<u8>;

#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct Signature {
pub signer: String,
pub timestamp: u64,
pub signature: Vec<u8>,
}

impl std::fmt::Display for Signature {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"[{:?}](signer: {}, timestamp: {})",
self.signature, self.signer, self.timestamp
)
}
}

#[derive(Hash, Debug, BorshDeserialize, BorshSerialize, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
Expand Down
7 changes: 4 additions & 3 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use clap::{arg, Command};
use prettytable::{row, Table};
use race_core::error::Result;
use race_core::entry_type::EntryType;
use race_core::{
transport::TransportT,
types::{
AddRecipientSlotParams, CloseGameAccountParams, CreateGameAccountParams, CreateRecipientParams, CreateRegistrationParams, EntryType, PublishGameParams, RecipientClaimParams, RecipientSlotInit, RegisterGameParams, ServerAccount, UnregisterGameParams
AddRecipientSlotParams, CloseGameAccountParams, CreateGameAccountParams, CreateRecipientParams, CreateRegistrationParams, PublishGameParams, RecipientClaimParams, RecipientSlotInit, RegisterGameParams, ServerAccount, UnregisterGameParams
},
};
use race_env::{default_keyfile, parse_with_default_rpc};
Expand All @@ -12,7 +14,6 @@ use race_storage::{
metadata::{make_metadata, MetadataT},
};
use race_transport::TransportBuilder;
use race_core::error::Result;
use serde::{Deserialize, Serialize};
use tracing::level_filters::LevelFilter;
use std::{
Expand Down Expand Up @@ -399,7 +400,7 @@ async fn server_info(addr: &str, transport: Arc<dyn TransportT>) {
.expect("Network error")
{
Some(server_account) => {
let ServerAccount { addr, endpoint } = server_account;
let ServerAccount { addr, endpoint, .. } = server_account;
println!("Server account: {}", addr);
println!("Server endpoint: {}", endpoint);
}
Expand Down
15 changes: 1 addition & 14 deletions client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use race_core::{
encryptor::EncryptorT,
secret::SecretState,
types::{
AttachGameParams, Ciphertext, ClientMode, SecretIdent, SecretKey,
Ciphertext, ClientMode, SecretIdent, SecretKey,
SubmitEventParams,
},
};
Expand Down Expand Up @@ -97,19 +97,6 @@ impl Client {
}
}

pub async fn attach_game(&self) -> Result<()> {
let key = self.encryptor.export_public_key(None)?;
self.connection
.attach_game(
&self.game_addr,
AttachGameParams {
key,
signer: self.addr.clone(),
},
)
.await
}

pub async fn submit_event(&self, event: Event) -> Result<()> {
self.connection
.submit_event(&self.game_addr, SubmitEventParams { event })
Expand Down
Loading
Loading