-
Notifications
You must be signed in to change notification settings - Fork 18
/
Main.mo
72 lines (56 loc) · 2.65 KB
/
Main.mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import System "lib/System";
import Types "Types";
import Core "Core";
import State "State";
import History "History";
import Snapshot "Snapshot";
shared ({ caller = installer }) actor class Main() {
let sys = System.IC();
stable var _state_v0 : State.Stable.State = State.Stable.initialState(sys);
stable var _history_v0 : History.History = History.init(sys, installer);
let core = Core.Core(installer, sys, _state_v0, _history_v0);
/// Login and fetch user details. Creates an account if none exists for the caller principal.
public shared ({ caller }) func login() : async Types.Resp.Login {
core.login(caller);
};
/// If you've already created an account, you can use this method to speed up the login process.
public query ({ caller }) func fastLogin() : async ?Types.Resp.Login {
core.fastLogin(caller);
};
/// Get a list of connected Ethereum wallets.
public query ({ caller }) func getEthWallets() : async Types.Resp.GetEthWallets {
core.getEthWallets(caller);
};
/// Connect a new Ethereum wallet, using the given ECDSA signature for authorization.
public shared ({ caller }) func connectEthWallet(wallet : Types.EthWallet, signedPrincipal : Types.SignedPrincipal) : async Types.Resp.ConnectEthWallet {
await core.connectEthWallet(caller, wallet, signedPrincipal);
};
/// Check if an NFT is currently owned by the given principal.
public shared ({ caller }) func isNftOwned(principal : Principal, nft : Types.Nft.Nft) : async Bool {
await core.isNftOwned(caller, principal, nft);
};
/// Verify that the given NFTs are owned by the caller, and store the results.
public shared ({ caller }) func addNfts(nfts : [Types.Nft.Nft]) : async Bool {
await core.addNfts(caller, nfts);
};
/// Retrieve the NFTs which were previously verified via `addNfts()`.
public query ({ caller }) func getNfts() : async [Types.Nft.Nft] {
core.getNfts(caller);
};
/// Hide or show all NFTs with the given smart contract or wallet address.
public shared ({ caller }) func setAddressFiltered(address : Types.Address.Address, filtered : Bool) : async Bool {
await core.setAddressFiltered(caller, address, filtered);
};
/// Retrieve the full log for this canister.
public query ({ caller }) func getHistory() : async ?[History.Event] {
core.getHistory(caller);
};
/// Retrieve a public-facing log for this canister.
public query ({ caller }) func getPublicHistory() : async [Types.PublicEvent] {
core.getPublicHistory(caller);
};
/// Retrieve a Candid representation of the canister's internal state.
public query ({ caller }) func getState() : async ?[Snapshot.Entry] {
core.getState(caller);
};
};