ic-mops 0.8.5 → 0.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -1
- package/.mops/base@0.7.4/LICENSE +0 -208
- package/.mops/base@0.7.4/README.md +0 -64
- package/.mops/base@0.7.4/mops.toml +0 -5
- package/.mops/base@0.7.4/src/Array.mo +0 -686
- package/.mops/base@0.7.4/src/AssocList.mo +0 -203
- package/.mops/base@0.7.4/src/Blob.mo +0 -55
- package/.mops/base@0.7.4/src/Bool.mo +0 -44
- package/.mops/base@0.7.4/src/Buffer.mo +0 -1937
- package/.mops/base@0.7.4/src/CertifiedData.mo +0 -29
- package/.mops/base@0.7.4/src/Char.mo +0 -67
- package/.mops/base@0.7.4/src/Debug.mo +0 -15
- package/.mops/base@0.7.4/src/Deque.mo +0 -75
- package/.mops/base@0.7.4/src/Error.mo +0 -41
- package/.mops/base@0.7.4/src/ExperimentalCycles.mo +0 -51
- package/.mops/base@0.7.4/src/ExperimentalInternetComputer.mo +0 -36
- package/.mops/base@0.7.4/src/ExperimentalStableMemory.mo +0 -121
- package/.mops/base@0.7.4/src/Float.mo +0 -150
- package/.mops/base@0.7.4/src/Func.mo +0 -38
- package/.mops/base@0.7.4/src/Hash.mo +0 -83
- package/.mops/base@0.7.4/src/HashMap.mo +0 -229
- package/.mops/base@0.7.4/src/Heap.mo +0 -113
- package/.mops/base@0.7.4/src/Int.mo +0 -150
- package/.mops/base@0.7.4/src/Int16.mo +0 -159
- package/.mops/base@0.7.4/src/Int32.mo +0 -160
- package/.mops/base@0.7.4/src/Int64.mo +0 -161
- package/.mops/base@0.7.4/src/Int8.mo +0 -160
- package/.mops/base@0.7.4/src/Iter.mo +0 -220
- package/.mops/base@0.7.4/src/IterType.mo +0 -7
- package/.mops/base@0.7.4/src/List.mo +0 -433
- package/.mops/base@0.7.4/src/Nat.mo +0 -75
- package/.mops/base@0.7.4/src/Nat16.mo +0 -146
- package/.mops/base@0.7.4/src/Nat32.mo +0 -146
- package/.mops/base@0.7.4/src/Nat64.mo +0 -146
- package/.mops/base@0.7.4/src/Nat8.mo +0 -146
- package/.mops/base@0.7.4/src/None.mo +0 -19
- package/.mops/base@0.7.4/src/Option.mo +0 -160
- package/.mops/base@0.7.4/src/Order.mo +0 -46
- package/.mops/base@0.7.4/src/Prelude.mo +0 -33
- package/.mops/base@0.7.4/src/Principal.mo +0 -58
- package/.mops/base@0.7.4/src/RBTree.mo +0 -218
- package/.mops/base@0.7.4/src/Random.mo +0 -188
- package/.mops/base@0.7.4/src/Result.mo +0 -210
- package/.mops/base@0.7.4/src/Stack.mo +0 -40
- package/.mops/base@0.7.4/src/Text.mo +0 -615
- package/.mops/base@0.7.4/src/Time.mo +0 -37
- package/.mops/base@0.7.4/src/Trie.mo +0 -1200
- package/.mops/base@0.7.4/src/TrieMap.mo +0 -180
- package/.mops/base@0.7.4/src/TrieSet.mo +0 -97
- package/.mops/base@0.8.3/LICENSE +0 -208
- package/.mops/base@0.8.3/README.md +0 -64
- package/.mops/base@0.8.3/mops.toml +0 -6
- package/.mops/base@0.8.3/src/Array.mo +0 -717
- package/.mops/base@0.8.3/src/AssocList.mo +0 -404
- package/.mops/base@0.8.3/src/Blob.mo +0 -212
- package/.mops/base@0.8.3/src/Bool.mo +0 -44
- package/.mops/base@0.8.3/src/Buffer.mo +0 -2660
- package/.mops/base@0.8.3/src/CertifiedData.mo +0 -53
- package/.mops/base@0.8.3/src/Char.mo +0 -65
- package/.mops/base@0.8.3/src/Debug.mo +0 -56
- package/.mops/base@0.8.3/src/Deque.mo +0 -243
- package/.mops/base@0.8.3/src/Error.mo +0 -68
- package/.mops/base@0.8.3/src/ExperimentalCycles.mo +0 -151
- package/.mops/base@0.8.3/src/ExperimentalInternetComputer.mo +0 -60
- package/.mops/base@0.8.3/src/ExperimentalStableMemory.mo +0 -348
- package/.mops/base@0.8.3/src/Float.mo +0 -843
- package/.mops/base@0.8.3/src/Func.mo +0 -46
- package/.mops/base@0.8.3/src/Hash.mo +0 -82
- package/.mops/base@0.8.3/src/HashMap.mo +0 -457
- package/.mops/base@0.8.3/src/Heap.mo +0 -233
- package/.mops/base@0.8.3/src/Int.mo +0 -365
- package/.mops/base@0.8.3/src/Int16.mo +0 -521
- package/.mops/base@0.8.3/src/Int32.mo +0 -522
- package/.mops/base@0.8.3/src/Int64.mo +0 -522
- package/.mops/base@0.8.3/src/Int8.mo +0 -522
- package/.mops/base@0.8.3/src/Iter.mo +0 -227
- package/.mops/base@0.8.3/src/IterType.mo +0 -7
- package/.mops/base@0.8.3/src/List.mo +0 -930
- package/.mops/base@0.8.3/src/Nat.mo +0 -305
- package/.mops/base@0.8.3/src/Nat16.mo +0 -144
- package/.mops/base@0.8.3/src/Nat32.mo +0 -144
- package/.mops/base@0.8.3/src/Nat64.mo +0 -144
- package/.mops/base@0.8.3/src/Nat8.mo +0 -144
- package/.mops/base@0.8.3/src/None.mo +0 -19
- package/.mops/base@0.8.3/src/Option.mo +0 -154
- package/.mops/base@0.8.3/src/Order.mo +0 -46
- package/.mops/base@0.8.3/src/Prelude.mo +0 -33
- package/.mops/base@0.8.3/src/Principal.mo +0 -249
- package/.mops/base@0.8.3/src/RBTree.mo +0 -681
- package/.mops/base@0.8.3/src/Random.mo +0 -270
- package/.mops/base@0.8.3/src/Result.mo +0 -209
- package/.mops/base@0.8.3/src/Stack.mo +0 -93
- package/.mops/base@0.8.3/src/Text.mo +0 -761
- package/.mops/base@0.8.3/src/Time.mo +0 -36
- package/.mops/base@0.8.3/src/Timer.mo +0 -62
- package/.mops/base@0.8.3/src/Trie.mo +0 -1603
- package/.mops/base@0.8.3/src/TrieMap.mo +0 -392
- package/.mops/base@0.8.3/src/TrieSet.mo +0 -148
- package/network.txt +0 -1
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
/// Module for interacting with Principals (users and canisters).
|
|
2
|
-
///
|
|
3
|
-
/// Principals are used to identify entities that can interact with the Internet
|
|
4
|
-
/// Computer. These entities are either users or canisters.
|
|
5
|
-
///
|
|
6
|
-
/// Example textual representation of Principals:
|
|
7
|
-
///
|
|
8
|
-
/// `un4fu-tqaaa-aaaab-qadjq-cai`
|
|
9
|
-
///
|
|
10
|
-
/// In Motoko, there is a primitive Principal type called `Principal`. As an example
|
|
11
|
-
/// of where you might see Principals, you can access the Principal of the
|
|
12
|
-
/// caller of your shared function.
|
|
13
|
-
///
|
|
14
|
-
/// ```motoko no-repl
|
|
15
|
-
/// shared(msg) func foo() {
|
|
16
|
-
/// let caller : Principal = msg.caller;
|
|
17
|
-
/// };
|
|
18
|
-
/// ```
|
|
19
|
-
///
|
|
20
|
-
/// Then, you can use this module to work with the `Principal`.
|
|
21
|
-
///
|
|
22
|
-
/// Import from the base library to use this module.
|
|
23
|
-
/// ```motoko name=import
|
|
24
|
-
/// import Principal "mo:base/Principal";
|
|
25
|
-
/// ```
|
|
26
|
-
|
|
27
|
-
import Prim "mo:⛔";
|
|
28
|
-
import Blob "Blob";
|
|
29
|
-
import Hash "Hash";
|
|
30
|
-
module {
|
|
31
|
-
|
|
32
|
-
public type Principal = Prim.Types.Principal;
|
|
33
|
-
|
|
34
|
-
/// Get the `Principal` identifier of an actor.
|
|
35
|
-
///
|
|
36
|
-
/// Example:
|
|
37
|
-
/// ```motoko include=import no-repl
|
|
38
|
-
/// actor MyCanister {
|
|
39
|
-
/// func getPrincipal() : Principal {
|
|
40
|
-
/// let principal = Principal.fromActor(MyCanister);
|
|
41
|
-
/// }
|
|
42
|
-
/// }
|
|
43
|
-
/// ```
|
|
44
|
-
public func fromActor(a : actor {}) : Principal = Prim.principalOfActor a;
|
|
45
|
-
|
|
46
|
-
/// Convert a `Principal` to its `Blob` (bytes) representation.
|
|
47
|
-
///
|
|
48
|
-
/// Example:
|
|
49
|
-
/// ```motoko include=import
|
|
50
|
-
/// let principal = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
51
|
-
/// let blob = Principal.toBlob(principal); // => \00\00\00\00\00\30\00\D3\01\01
|
|
52
|
-
/// ```
|
|
53
|
-
public func toBlob(p : Principal) : Blob = Prim.blobOfPrincipal p;
|
|
54
|
-
|
|
55
|
-
/// Converts a `Blob` (bytes) representation of a `Principal` to a `Principal` value.
|
|
56
|
-
///
|
|
57
|
-
/// Example:
|
|
58
|
-
/// ```motoko include=import
|
|
59
|
-
/// let blob = "\00\00\00\00\00\30\00\D3\01\01" : Blob;
|
|
60
|
-
/// let principal = Principal.fromBlob(blob);
|
|
61
|
-
/// Principal.toText(principal) // => "un4fu-tqaaa-aaaab-qadjq-cai"
|
|
62
|
-
/// ```
|
|
63
|
-
public func fromBlob(b : Blob) : Principal = Prim.principalOfBlob b;
|
|
64
|
-
|
|
65
|
-
/// Converts a `Principal` to its `Text` representation.
|
|
66
|
-
///
|
|
67
|
-
/// Example:
|
|
68
|
-
/// ```motoko include=import
|
|
69
|
-
/// let principal = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
70
|
-
/// Principal.toText(principal) // => "un4fu-tqaaa-aaaab-qadjq-cai"
|
|
71
|
-
/// ```
|
|
72
|
-
public func toText(p : Principal) : Text = debug_show (p);
|
|
73
|
-
|
|
74
|
-
/// Converts a `Text` representation of a `Principal` to a `Principal` value.
|
|
75
|
-
///
|
|
76
|
-
/// Example:
|
|
77
|
-
/// ```motoko include=import
|
|
78
|
-
/// let principal = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
79
|
-
/// Principal.toText(principal) // => "un4fu-tqaaa-aaaab-qadjq-cai"
|
|
80
|
-
/// ```
|
|
81
|
-
public func fromText(t : Text) : Principal = fromActor(actor (t));
|
|
82
|
-
|
|
83
|
-
private let anonymousPrincipal : Blob = "\04";
|
|
84
|
-
|
|
85
|
-
/// Checks if the given principal represents an anonymous user.
|
|
86
|
-
///
|
|
87
|
-
/// Example:
|
|
88
|
-
/// ```motoko include=import
|
|
89
|
-
/// let principal = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
90
|
-
/// Principal.isAnonymous(principal) // => false
|
|
91
|
-
/// ```
|
|
92
|
-
public func isAnonymous(p : Principal) : Bool = Prim.blobOfPrincipal p == anonymousPrincipal;
|
|
93
|
-
|
|
94
|
-
/// Hashes the given principal by hashing its `Blob` representation.
|
|
95
|
-
///
|
|
96
|
-
/// Example:
|
|
97
|
-
/// ```motoko include=import
|
|
98
|
-
/// let principal = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
99
|
-
/// Principal.hash(principal) // => 2_742_573_646
|
|
100
|
-
/// ```
|
|
101
|
-
public func hash(principal : Principal) : Hash.Hash = Blob.hash(Prim.blobOfPrincipal(principal));
|
|
102
|
-
|
|
103
|
-
/// General purpose comparison function for `Principal`. Returns the `Order` (
|
|
104
|
-
/// either `#less`, `#equal`, or `#greater`) of comparing `principal1` with
|
|
105
|
-
/// `principal2`.
|
|
106
|
-
///
|
|
107
|
-
/// Example:
|
|
108
|
-
/// ```motoko include=import
|
|
109
|
-
/// let principal1 = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
110
|
-
/// let principal2 = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
111
|
-
/// Principal.compare(principal1, principal2) // => #equal
|
|
112
|
-
/// ```
|
|
113
|
-
public func compare(principal1 : Principal, principal2 : Principal) : {
|
|
114
|
-
#less;
|
|
115
|
-
#equal;
|
|
116
|
-
#greater
|
|
117
|
-
} {
|
|
118
|
-
if (principal1 < principal2) {
|
|
119
|
-
#less
|
|
120
|
-
} else if (principal1 == principal2) {
|
|
121
|
-
#equal
|
|
122
|
-
} else {
|
|
123
|
-
#greater
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
/// Equality function for Principal types.
|
|
128
|
-
/// This is equivalent to `principal1 == principal2`.
|
|
129
|
-
///
|
|
130
|
-
/// Example:
|
|
131
|
-
/// ```motoko include=import
|
|
132
|
-
/// let principal1 = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
133
|
-
/// let principal2 = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
134
|
-
/// ignore Principal.equal(principal1, principal2);
|
|
135
|
-
/// principal1 == principal2 // => true
|
|
136
|
-
/// ```
|
|
137
|
-
///
|
|
138
|
-
/// Note: The reason why this function is defined in this library (in addition
|
|
139
|
-
/// to the existing `==` operator) is so that you can use it as a function
|
|
140
|
-
/// value to pass to a higher order function. It is not possible to use `==`
|
|
141
|
-
/// as a function value at the moment.
|
|
142
|
-
///
|
|
143
|
-
/// Example:
|
|
144
|
-
/// ```motoko include=import
|
|
145
|
-
/// import Buffer "mo:base/Buffer";
|
|
146
|
-
///
|
|
147
|
-
/// let buffer1 = Buffer.Buffer<Principal>(3);
|
|
148
|
-
/// let buffer2 = Buffer.Buffer<Principal>(3);
|
|
149
|
-
/// Buffer.equal(buffer1, buffer2, Principal.equal) // => true
|
|
150
|
-
/// ```
|
|
151
|
-
public func equal(principal1 : Principal, principal2 : Principal) : Bool {
|
|
152
|
-
principal1 == principal2
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
/// Inequality function for Principal types.
|
|
156
|
-
/// This is equivalent to `principal1 != principal2`.
|
|
157
|
-
///
|
|
158
|
-
/// Example:
|
|
159
|
-
/// ```motoko include=import
|
|
160
|
-
/// let principal1 = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
161
|
-
/// let principal2 = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
162
|
-
/// ignore Principal.notEqual(principal1, principal2);
|
|
163
|
-
/// principal1 != principal2 // => false
|
|
164
|
-
/// ```
|
|
165
|
-
///
|
|
166
|
-
/// Note: The reason why this function is defined in this library (in addition
|
|
167
|
-
/// to the existing `!=` operator) is so that you can use it as a function
|
|
168
|
-
/// value to pass to a higher order function. It is not possible to use `!=`
|
|
169
|
-
/// as a function value at the moment.
|
|
170
|
-
public func notEqual(principal1 : Principal, principal2 : Principal) : Bool {
|
|
171
|
-
principal1 != principal2
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
/// "Less than" function for Principal types.
|
|
175
|
-
/// This is equivalent to `principal1 < principal2`.
|
|
176
|
-
///
|
|
177
|
-
/// Example:
|
|
178
|
-
/// ```motoko include=import
|
|
179
|
-
/// let principal1 = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
180
|
-
/// let principal2 = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
181
|
-
/// ignore Principal.less(principal1, principal2);
|
|
182
|
-
/// principal1 < principal2 // => false
|
|
183
|
-
/// ```
|
|
184
|
-
///
|
|
185
|
-
/// Note: The reason why this function is defined in this library (in addition
|
|
186
|
-
/// to the existing `<` operator) is so that you can use it as a function
|
|
187
|
-
/// value to pass to a higher order function. It is not possible to use `<`
|
|
188
|
-
/// as a function value at the moment.
|
|
189
|
-
public func less(principal1 : Principal, principal2 : Principal) : Bool {
|
|
190
|
-
principal1 < principal2
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
/// "Less than or equal to" function for Principal types.
|
|
194
|
-
/// This is equivalent to `principal1 <= principal2`.
|
|
195
|
-
///
|
|
196
|
-
/// Example:
|
|
197
|
-
/// ```motoko include=import
|
|
198
|
-
/// let principal1 = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
199
|
-
/// let principal2 = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
200
|
-
/// ignore Principal.lessOrEqual(principal1, principal2);
|
|
201
|
-
/// principal1 <= principal2 // => true
|
|
202
|
-
/// ```
|
|
203
|
-
///
|
|
204
|
-
/// Note: The reason why this function is defined in this library (in addition
|
|
205
|
-
/// to the existing `<=` operator) is so that you can use it as a function
|
|
206
|
-
/// value to pass to a higher order function. It is not possible to use `<=`
|
|
207
|
-
/// as a function value at the moment.
|
|
208
|
-
public func lessOrEqual(principal1 : Principal, principal2 : Principal) : Bool {
|
|
209
|
-
principal1 <= principal2
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
/// "Greater than" function for Principal types.
|
|
213
|
-
/// This is equivalent to `principal1 > principal2`.
|
|
214
|
-
///
|
|
215
|
-
/// Example:
|
|
216
|
-
/// ```motoko include=import
|
|
217
|
-
/// let principal1 = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
218
|
-
/// let principal2 = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
219
|
-
/// ignore Principal.greater(principal1, principal2);
|
|
220
|
-
/// principal1 > principal2 // => false
|
|
221
|
-
/// ```
|
|
222
|
-
///
|
|
223
|
-
/// Note: The reason why this function is defined in this library (in addition
|
|
224
|
-
/// to the existing `>` operator) is so that you can use it as a function
|
|
225
|
-
/// value to pass to a higher order function. It is not possible to use `>`
|
|
226
|
-
/// as a function value at the moment.
|
|
227
|
-
public func greater(principal1 : Principal, principal2 : Principal) : Bool {
|
|
228
|
-
principal1 > principal2
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
/// "Greater than or equal to" function for Principal types.
|
|
232
|
-
/// This is equivalent to `principal1 >= principal2`.
|
|
233
|
-
///
|
|
234
|
-
/// Example:
|
|
235
|
-
/// ```motoko include=import
|
|
236
|
-
/// let principal1 = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
237
|
-
/// let principal2 = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai");
|
|
238
|
-
/// ignore Principal.greaterOrEqual(principal1, principal2);
|
|
239
|
-
/// principal1 >= principal2 // => true
|
|
240
|
-
/// ```
|
|
241
|
-
///
|
|
242
|
-
/// Note: The reason why this function is defined in this library (in addition
|
|
243
|
-
/// to the existing `>=` operator) is so that you can use it as a function
|
|
244
|
-
/// value to pass to a higher order function. It is not possible to use `>=`
|
|
245
|
-
/// as a function value at the moment.
|
|
246
|
-
public func greaterOrEqual(principal1 : Principal, principal2 : Principal) : Bool {
|
|
247
|
-
principal1 >= principal2
|
|
248
|
-
}
|
|
249
|
-
}
|