Skip to content

Commit

Permalink
Merge pull request #6 from dfinity-lab/sj/inter-canister-calls
Browse files Browse the repository at this point in the history
update: User inter-canister calls [SDK-702]
  • Loading branch information
Stanley Jones authored Feb 12, 2020
2 parents 94404ae + 16f257e commit 2d8c347
Show file tree
Hide file tree
Showing 19 changed files with 3,635 additions and 3,478 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ install:
- sudo sh /tmp/install-node.sh
- travis_retry sudo apt-get install -y nodejs
- travis_retry wget https://sdk.dfinity.org/install.sh -O /tmp/install-sdk.sh
- DFX_VERSION=0.4.13 sh -c 'yes Y | sh /tmp/install-sdk.sh'
- sh -c 'yes Y | sh /tmp/install-sdk.sh'
- export PATH=/home/$USER/bin:$PATH
script:
- sh bootstrap.sh
Expand Down
5 changes: 2 additions & 3 deletions dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
"output": "canisters"
},
"start": {
"address": "0.0.0.0",
"address": "127.0.0.1",
"port": 8000
}
},
"version": 1
}
}
4,280 changes: 2,297 additions & 1,983 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
{
"author": "Enzo Haussecker",
"dependencies": {
"animate.css": "^3.7.2",
"bootstrap": "^4.3.1",
"copy-webpack-plugin": "^5.1.1",
"font-awesome": "^4.7.0",
"jquery": "^3.4.1",
"jquery-backstretch": "^2.1.18",
"popper.js": "^1.16.0",
"showdown": "^1.9.1",
"tweetnacl": "^1.0.1",
"typed.js": "^2.0.11",
"wowjs": "^1.1.3"
},
"devDependencies": {
"css-loader": "^3.4.2",
"style-loader": "^1.1.2",
"terser-webpack-plugin": "2.2.2",
"webpack": "4.41.3",
"webpack-cli": "3.3.10"
Expand Down
169 changes: 0 additions & 169 deletions src/common/util.mo

This file was deleted.

44 changes: 44 additions & 0 deletions src/graph/database.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import Array "mo:stdlib/array";
import HashMap "mo:stdlib/hashMap";
import Hash "mo:stdlib/hash";
import Iter "mo:stdlib/iter";
import List "mo:stdlib/list";
import Nat "mo:stdlib/nat";
import Option "mo:stdlib/option";

import Types "./types";

module {
type Entry = Types.Entry;
type EntryId = Types.EntryId;

public class Entries() {

func natEq(x : Nat32, y : Nat32) : Bool { x == y };
func hashEntryId(x : EntryId) : Hash.Hash { Nat.toWord32(Nat.fromNat32(x)) };
let hashMap = HashMap.HashMap<EntryId, Entry>(1, natEq, hashEntryId);

public func addConnection(fromUser : EntryId, toUser : EntryId) {
let entry = getEntry(fromUser);
let updated : Entry = {
id = entry.id;
connections = Array.append<EntryId>(entry.connections, [toUser]);
invitations = entry.invitations;
};
ignore hashMap.set(fromUser, updated);
};

func getEntry(entryId : EntryId) : Entry {
let existing = hashMap.get(entryId);
switch (existing) {
case (?existing) { existing };
case (null) { { id = entryId; connections = []; invitations = []; } };
};
};

public func getConnections(userId : EntryId) : [EntryId] {
let entry = getEntry(userId);
entry.connections
};
};
};
Loading

0 comments on commit 2d8c347

Please sign in to comment.