Skip to content

Commit

Permalink
Updated deps
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Aug 19, 2021
1 parent 4e17c64 commit 7de8b96
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 27 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build-and-test:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout code
uses: actions/checkout@v2

- uses: cachix/install-nix-action@v12
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: build-holochain
run: |
cd $GITHUB_WORKSPACE
nix-shell . --run "cd dna && CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown"
nix-shell . --run "cd dna && hc dna pack workdir"
- name: test-holochain
run: |
cd $GITHUB_WORKSPACE
nix-shell . --run "cd dna/tests && npm install"
nix-shell . --run "cd dna/tests && npm test"
24 changes: 12 additions & 12 deletions dna/Cargo.lock

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

2 changes: 0 additions & 2 deletions dna/workdir/dna/dna.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ zomes:
bundled: ../../target/wasm32-unknown-unknown/release/invitations.wasm
- name: chess
bundled: ../../target/wasm32-unknown-unknown/release/hc_zome_chess.wasm
- name: joining_code
bundled: ../../target/wasm32-unknown-unknown/release/joining_code.wasm
2 changes: 1 addition & 1 deletion dna/zomes/chess/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ chrono = {version = "0.4", features = ["serde"]}

hdk = {git = "https://github.com/holochain/holochain", rev = "363af6d8af8d18e4616f6aa56ad4d1f0fabaafb7", package = "hdk", version = "0.0.101-alpha.0"}

holochain_turn_based_game = {git ="http://github.com/eyss/holochain-turn-based-game", rev ="5e07a5f7c3d12d246eede978b65ce0d5f7f15f49"}
hc_turn_based_game = {git ="http://github.com/eyss/hc-turn-based-game", rev ="4a34bf9fd1e008fb13cffe7ef591b45da6a4560a"}
chess = "3.2.0"
2 changes: 1 addition & 1 deletion dna/zomes/chess/src/chess_game.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use chess::{ChessMove, Color, Game, GameResult, Piece, Square};
use hdk::prelude::holo_hash::{AgentPubKeyB64, EntryHashB64};
use hdk::prelude::*;
use holochain_turn_based_game::prelude::TurnBasedGame;
use hc_turn_based_game::prelude::TurnBasedGame;
use std::str::FromStr;

#[derive(Clone, Debug)]
Expand Down
7 changes: 5 additions & 2 deletions dna/zomes/chess/src/current_games.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ pub fn add_current_game(game_hash: EntryHash, players: Vec<AgentPubKey>) -> Exte
}

pub fn remove_current_game(game_hash: EntryHash, players: Vec<AgentPubKey>) -> ExternResult<()> {
warn!("Removing current game for {:?}", players);
for agent in players {
let link_to_current_game = get_current_games_for(agent)?
let link_to_current_game = get_current_games_for(agent.clone())?
.into_iter()
.find(|link| link.target.eq(&game_hash));

if let Some(link) = link_to_current_game {
warn!("Current game for {} {}", agent, link.create_link_hash);
delete_link(link.create_link_hash)?;
}
}
Expand All @@ -37,7 +39,8 @@ fn current_games_tag() -> LinkTag {
}

fn get_current_games_for(agent: AgentPubKey) -> ExternResult<Vec<Link>> {
let links = get_links(agent.into(), Some(current_games_tag()))?;
let links = get_links(agent.clone().into(), Some(current_games_tag()))?;
warn!("Current games for {} {:?}", agent, links);

Ok(links.into_inner())
}
16 changes: 8 additions & 8 deletions dna/zomes/chess/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use hdk::prelude::holo_hash::{AgentPubKeyB64, EntryHashB64};
use hdk::prelude::*;
use holochain_turn_based_game::prelude::*;
use hc_turn_based_game::prelude::*;

use chrono::serde::ts_milliseconds;
use chrono::{DateTime, NaiveDateTime, Utc};
Expand Down Expand Up @@ -44,15 +44,15 @@ entry_defs![

#[hdk_extern]
pub fn init(_: ()) -> ExternResult<InitCallbackResult> {
holochain_turn_based_game::prelude::init_turn_based_games()
hc_turn_based_game::prelude::init_turn_based_games()
}

#[hdk_extern]
pub fn create_game(opponent: AgentPubKeyB64) -> ExternResult<EntryHashB64> {
let my_pub_key = agent_info()?.agent_initial_pubkey;
let players = vec![opponent.clone(), AgentPubKeyB64::from(my_pub_key.clone())];

let game_hash = holochain_turn_based_game::prelude::create_game(players.clone())?;
let game_hash = hc_turn_based_game::prelude::create_game(players.clone())?;

current_games::add_current_game(
game_hash.clone().into(),
Expand All @@ -64,7 +64,7 @@ pub fn create_game(opponent: AgentPubKeyB64) -> ExternResult<EntryHashB64> {

#[hdk_extern]
pub fn make_move(input: MakeMoveInput) -> ExternResult<EntryHashB64> {
holochain_turn_based_game::prelude::create_move(
hc_turn_based_game::prelude::create_move(
input.game_hash,
input.previous_move_hash,
input.game_move,
Expand All @@ -73,12 +73,12 @@ pub fn make_move(input: MakeMoveInput) -> ExternResult<EntryHashB64> {

#[hdk_extern]
pub fn get_game(game_hash: EntryHashB64) -> ExternResult<GameEntry> {
holochain_turn_based_game::prelude::get_game(game_hash)
hc_turn_based_game::prelude::get_game(game_hash)
}

#[hdk_extern]
pub fn get_game_moves(game_hash: EntryHashB64) -> ExternResult<Vec<MoveInfo>> {
holochain_turn_based_game::prelude::get_game_moves(game_hash)
hc_turn_based_game::prelude::get_game_moves(game_hash)
}

#[hdk_extern]
Expand All @@ -104,14 +104,14 @@ pub fn get_my_current_games(_: ()) -> ExternResult<Vec<EntryHashB64>> {

#[hdk_extern]
fn validate_create_entry_game_entry(data: ValidateData) -> ExternResult<ValidateCallbackResult> {
holochain_turn_based_game::prelude::validate_game_entry::<ChessGame, ChessGameMove>(data)
hc_turn_based_game::prelude::validate_game_entry::<ChessGame, ChessGameMove>(data)
// TODO: add validation for read-only agents
}

#[hdk_extern]
fn validate_create_entry_game_move_entry(
data: ValidateData,
) -> ExternResult<ValidateCallbackResult> {
holochain_turn_based_game::prelude::validate_game_move_entry::<ChessGame, ChessGameMove>(data)
hc_turn_based_game::prelude::validate_game_move_entry::<ChessGame, ChessGameMove>(data)
// TODO: add validation for read-only agents
}
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"start-alice": "HC_PORT=8888 concurrently -k --names ui,hc \"ENV=hcdev npm run start-ui\" \"APP_ID=elemental-chess ADMIN_PORT=9000 npm run start-holochain\"",
"start-bob": "HC_PORT=8889 concurrently -k --names ui,hc \"ENV=hcdev npm run start-ui\" \"APP_ID=elemental-chess ADMIN_PORT=9001 npm run start-holochain\"",
"start-ui": "concurrently -k --names tsc,web-dev-server \"npm run build-watch\" \"sleep 5 && web-dev-server --config web-dev-server.config.mjs\"",
"start-holochain": "RUST_LOG=warn hc s -f=$ADMIN_PORT generate -r=$HC_PORT ../dna/workdir/happ/elemental-chess.happ --app-id=$APP_ID network -b https://bootstrap-staging.holo.host quic",
"start-holochain": "RUST_LOG=info WASM_LOG=trace hc s -f=$ADMIN_PORT generate -r=$HC_PORT ../dna/workdir/happ/elemental-chess.happ --app-id=$APP_ID network -b https://bootstrap-staging.holo.host quic",
"build-watch": "rimraf dist && rollup -c rollup.config.js -w",
"build-holochain": "rimraf dist && ENV=hc rollup -c rollup.config.js",
"build-holo": "rimraf dist && ENV=holo rollup -c rollup.config.js",
Expand Down

0 comments on commit 7de8b96

Please sign in to comment.