Skip to content

Commit

Permalink
First version
Browse files Browse the repository at this point in the history
  • Loading branch information
ninegua committed Jul 7, 2021
1 parent 83b53fb commit af40bff
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "release"

on:
push:
tags:
- '*'

jobs:
release:
name: "Release"
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: cachix/install-nix-action@v13
with:
nix_path: nixpkgs=channel:nixos-21.05
- uses: cachix/cachix-action@v10
with:
name: ninegua
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix-build
- name: Upload release package
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
file: result/bin/*
file_glob: true
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
CANISTERS=blackhole
SRC=$(CANISTERS:%=src/%.mo)
OBJ=$(CANISTERS:%=dist/%.wasm)
OBJ_OPT=$(CANISTERS:%=dist/%-opt.wasm)
IDL=$(CANISTERS:%=dist/%.did)
MOC_OPT=--package base .vessel/base/927119e172964f4038ebc7018f9cc1b688544bfa/src

build: $(OBJ) $(IDL) $(OBJ_OPT)

clean:
rm -f dist

dist:
@mkdir -p $@

dist/%.wasm: src/%.mo | dist
moc $(MOC_OPT) -o $@ $<

dist/%.did: src/%.mo | dist
moc $(MOC_OPT) --idl -o $@ $<

.PHONY: build clean really-clean

UTIL_DIR?=/nix/store/4gaariri115lys3l5mfip6knn0v78clp-ic-utils
include $(UTIL_DIR)/share/mk/inc.mk
23 changes: 23 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{ pkgs ? import <nixpkgs> { } }:
let
ic-utils = import (builtins.fetchGit {
url = "http://github.com/ninegua/ic-utils";
rev = "56d404d73dd5253372a1d50997df51e2ddc4d6fb";
}) { inherit pkgs; };
motoko-base = builtins.fetchGit {
url = "https://github.com/dfinity/motoko-base";
rev = "927119e172964f4038ebc7018f9cc1b688544bfa";
};
in pkgs.stdenv.mkDerivation {
name = "ic-blackhole";
version = "0.0.0";
phases = [ "buildPhase" "installPhase" ];
src = ./.;
nativeBuildInputs = [ pkgs.binaryen ];
buildPhase = ''
export PATH=${ic-utils}/bin:$PATH
cp -r $src/* .
make MOC_OPT='--package base ${motoko-base}/src/' UTIL_DIR='${ic-utils}'
'';
installPhase = "mkdir -p $out/bin && install -m 644 dist/* $out/bin/";
}
32 changes: 32 additions & 0 deletions src/blackhole.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Nat "mo:base/Nat";
import Nat8 "mo:base/Nat8";
import Principal "mo:base/Principal";

This comment has been minimized.

Copy link
@rossberg

rossberg Jul 7, 2021

AFAICS, all these imports are unused. :)

This comment has been minimized.

Copy link
@ninegua

ninegua Jul 7, 2021

Author Owner

Thanks! So types and modules are in different name spaces, and these are built-in types? TIL.

This comment has been minimized.

Copy link
@rossberg

rossberg Jul 7, 2021

Yup, exactly.


actor {
public type canister_id = Principal;

public type definite_canister_settings = {
freezing_threshold : Nat;
controllers : [Principal];
memory_allocation : Nat;
compute_allocation : Nat;
};

public type canister_status = {
status : { #stopped; #stopping; #running };
memory_size : Nat;
cycles : Nat;
settings : definite_canister_settings;
module_hash : ?[Nat8];
};

public type IC = actor {
canister_status : { canister_id : canister_id } -> async canister_status;
};

let ic : IC = actor("aaaaa-aa");

public func canister_status(request : { canister_id : canister_id }) : async canister_status {
await ic.canister_status(request)
}
}

0 comments on commit af40bff

Please sign in to comment.