@hazae41/stdbob 0.1.3 → 0.1.4
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 +1 -1
- package/src/mods/bigints/mod.ts +0 -37
- package/src/mods/blobs/mod.ts +3 -22
- package/src/mods/console/mod.ts +1 -2
- package/src/mods/ed25519/mod.ts +1 -4
- package/src/mods/env/mod.ts +1 -2
- package/src/mods/mod.ts +3 -2
- package/src/mods/modules/mod.ts +5 -10
- package/src/mods/{refs → pointers}/mod.ts +3 -5
- package/src/mods/records/mod.ts +47 -0
- package/src/mods/secp256k1/mod.ts +22 -0
- package/src/mods/sha256/mod.ts +1 -2
- package/src/mods/storage/mod.ts +3 -6
- package/src/mods/texts/mod.ts +1 -18
- package/src/mods/tuples/mod.ts +108 -0
- package/src/mods/wraps/mod.ts +22 -0
- package/src/mods/packs/mod.ts +0 -107
package/package.json
CHANGED
package/src/mods/bigints/mod.ts
CHANGED
|
@@ -86,7 +86,6 @@ export namespace bigints {
|
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
88
|
* Increment a bigint by 1n
|
|
89
|
-
* @param value
|
|
90
89
|
*/
|
|
91
90
|
// @ts-ignore: decorator
|
|
92
91
|
@external("bigints", "inc")
|
|
@@ -94,7 +93,6 @@ export namespace bigints {
|
|
|
94
93
|
|
|
95
94
|
/**
|
|
96
95
|
* Decrement a bigint by 1n
|
|
97
|
-
* @param value
|
|
98
96
|
*/
|
|
99
97
|
// @ts-ignore: decorator
|
|
100
98
|
@external("bigints", "dec")
|
|
@@ -102,7 +100,6 @@ export namespace bigints {
|
|
|
102
100
|
|
|
103
101
|
/**
|
|
104
102
|
* Negate a bigint
|
|
105
|
-
* @param value
|
|
106
103
|
*/
|
|
107
104
|
// @ts-ignore: decorator
|
|
108
105
|
@external("bigints", "neg")
|
|
@@ -110,8 +107,6 @@ export namespace bigints {
|
|
|
110
107
|
|
|
111
108
|
/**
|
|
112
109
|
* Add left and right
|
|
113
|
-
* @param left
|
|
114
|
-
* @param right
|
|
115
110
|
*/
|
|
116
111
|
// @ts-ignore: decorator
|
|
117
112
|
@external("bigints", "add")
|
|
@@ -119,8 +114,6 @@ export namespace bigints {
|
|
|
119
114
|
|
|
120
115
|
/**
|
|
121
116
|
* Subtract right from left
|
|
122
|
-
* @param left
|
|
123
|
-
* @param right
|
|
124
117
|
*/
|
|
125
118
|
// @ts-ignore: decorator
|
|
126
119
|
@external("bigints", "sub")
|
|
@@ -128,8 +121,6 @@ export namespace bigints {
|
|
|
128
121
|
|
|
129
122
|
/**
|
|
130
123
|
* Multiply left by right
|
|
131
|
-
* @param left
|
|
132
|
-
* @param right
|
|
133
124
|
*/
|
|
134
125
|
// @ts-ignore: decorator
|
|
135
126
|
@external("bigints", "mul")
|
|
@@ -137,8 +128,6 @@ export namespace bigints {
|
|
|
137
128
|
|
|
138
129
|
/**
|
|
139
130
|
* Divide left by right (throw if right is zero)
|
|
140
|
-
* @param left
|
|
141
|
-
* @param right
|
|
142
131
|
*/
|
|
143
132
|
// @ts-ignore: decorator
|
|
144
133
|
@external("bigints", "div")
|
|
@@ -146,8 +135,6 @@ export namespace bigints {
|
|
|
146
135
|
|
|
147
136
|
/**
|
|
148
137
|
* Raise left to the power of right
|
|
149
|
-
* @param left
|
|
150
|
-
* @param right
|
|
151
138
|
*/
|
|
152
139
|
// @ts-ignore: decorator
|
|
153
140
|
@external("bigints", "pow")
|
|
@@ -155,8 +142,6 @@ export namespace bigints {
|
|
|
155
142
|
|
|
156
143
|
/**
|
|
157
144
|
* Remainder of left divided by right
|
|
158
|
-
* @param left
|
|
159
|
-
* @param right
|
|
160
145
|
*/
|
|
161
146
|
// @ts-ignore: decorator
|
|
162
147
|
@external("bigints", "mod")
|
|
@@ -164,8 +149,6 @@ export namespace bigints {
|
|
|
164
149
|
|
|
165
150
|
/**
|
|
166
151
|
* True if left is less than right
|
|
167
|
-
* @param left
|
|
168
|
-
* @param right
|
|
169
152
|
*/
|
|
170
153
|
// @ts-ignore: decorator
|
|
171
154
|
@external("bigints", "lt")
|
|
@@ -173,8 +156,6 @@ export namespace bigints {
|
|
|
173
156
|
|
|
174
157
|
/**
|
|
175
158
|
* True if left is less than or equal to right
|
|
176
|
-
* @param left
|
|
177
|
-
* @param right
|
|
178
159
|
*/
|
|
179
160
|
// @ts-ignore: decorator
|
|
180
161
|
@external("bigints", "lte")
|
|
@@ -182,8 +163,6 @@ export namespace bigints {
|
|
|
182
163
|
|
|
183
164
|
/**
|
|
184
165
|
* True if left is greater than right
|
|
185
|
-
* @param left
|
|
186
|
-
* @param right
|
|
187
166
|
*/
|
|
188
167
|
// @ts-ignore: decorator
|
|
189
168
|
@external("bigints", "gt")
|
|
@@ -191,8 +170,6 @@ export namespace bigints {
|
|
|
191
170
|
|
|
192
171
|
/**
|
|
193
172
|
* True if left is greater than or equal to right
|
|
194
|
-
* @param left
|
|
195
|
-
* @param right
|
|
196
173
|
*/
|
|
197
174
|
// @ts-ignore: decorator
|
|
198
175
|
@external("bigints", "gte")
|
|
@@ -200,8 +177,6 @@ export namespace bigints {
|
|
|
200
177
|
|
|
201
178
|
/**
|
|
202
179
|
* True if left is equal to right
|
|
203
|
-
* @param left
|
|
204
|
-
* @param right
|
|
205
180
|
*/
|
|
206
181
|
// @ts-ignore: decorator
|
|
207
182
|
@external("bigints", "eq")
|
|
@@ -209,8 +184,6 @@ export namespace bigints {
|
|
|
209
184
|
|
|
210
185
|
/**
|
|
211
186
|
* True if left is not equal to right
|
|
212
|
-
* @param left
|
|
213
|
-
* @param right
|
|
214
187
|
*/
|
|
215
188
|
// @ts-ignore: decorator
|
|
216
189
|
@external("bigints", "neq")
|
|
@@ -218,8 +191,6 @@ export namespace bigints {
|
|
|
218
191
|
|
|
219
192
|
/**
|
|
220
193
|
* The smaller of left and right
|
|
221
|
-
* @param left
|
|
222
|
-
* @param right
|
|
223
194
|
*/
|
|
224
195
|
// @ts-ignore: decorator
|
|
225
196
|
@external("bigints", "min")
|
|
@@ -227,8 +198,6 @@ export namespace bigints {
|
|
|
227
198
|
|
|
228
199
|
/**
|
|
229
200
|
* The larger of left and right
|
|
230
|
-
* @param left
|
|
231
|
-
* @param right
|
|
232
201
|
*/
|
|
233
202
|
// @ts-ignore: decorator
|
|
234
203
|
@external("bigints", "max")
|
|
@@ -236,7 +205,6 @@ export namespace bigints {
|
|
|
236
205
|
|
|
237
206
|
/**
|
|
238
207
|
* Create a bigint from a base-16 string
|
|
239
|
-
* @param text
|
|
240
208
|
*/
|
|
241
209
|
// @ts-ignore: decorator
|
|
242
210
|
@external("bigints", "from_base16")
|
|
@@ -244,7 +212,6 @@ export namespace bigints {
|
|
|
244
212
|
|
|
245
213
|
/**
|
|
246
214
|
* Convert a bigint to a base-16 string
|
|
247
|
-
* @param bigint
|
|
248
215
|
*/
|
|
249
216
|
// @ts-ignore: decorator
|
|
250
217
|
@external("bigints", "to_base16")
|
|
@@ -252,7 +219,6 @@ export namespace bigints {
|
|
|
252
219
|
|
|
253
220
|
/**
|
|
254
221
|
* Create a bigint from a base-10 string
|
|
255
|
-
* @param text
|
|
256
222
|
*/
|
|
257
223
|
// @ts-ignore: decorator
|
|
258
224
|
@external("bigints", "from_base10")
|
|
@@ -260,7 +226,6 @@ export namespace bigints {
|
|
|
260
226
|
|
|
261
227
|
/**
|
|
262
228
|
* Convert a bigint to a base-10 string
|
|
263
|
-
* @param bigint
|
|
264
229
|
*/
|
|
265
230
|
// @ts-ignore: decorator
|
|
266
231
|
@external("bigints", "to_base10")
|
|
@@ -268,7 +233,6 @@ export namespace bigints {
|
|
|
268
233
|
|
|
269
234
|
/**
|
|
270
235
|
* Create a bigint from a 64-bit integer
|
|
271
|
-
* @param bigint
|
|
272
236
|
*/
|
|
273
237
|
// @ts-ignore: decorator
|
|
274
238
|
@external("bigints", "identity")
|
|
@@ -276,7 +240,6 @@ export namespace bigints {
|
|
|
276
240
|
|
|
277
241
|
/**
|
|
278
242
|
* Convert a bigint to a 64-bit integer
|
|
279
|
-
* @param bigint
|
|
280
243
|
*/
|
|
281
244
|
// @ts-ignore: decorator
|
|
282
245
|
@external("bigints", "identity")
|
package/src/mods/blobs/mod.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { textref } from "../texts/mod"
|
|
2
|
+
import { wrapref } from "../wraps/mod"
|
|
2
3
|
|
|
3
4
|
export type blobref = externref
|
|
4
5
|
|
|
@@ -17,8 +18,6 @@ export namespace blobs {
|
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Save the given buffer into a blob
|
|
20
|
-
* @param buffer
|
|
21
|
-
* @returns
|
|
22
21
|
*/
|
|
23
22
|
export function save(buffer: ArrayBuffer): blobref {
|
|
24
23
|
const bytes = Uint8Array.wrap(buffer)
|
|
@@ -30,8 +29,6 @@ export namespace blobs {
|
|
|
30
29
|
|
|
31
30
|
/**
|
|
32
31
|
* Load the given blob into a buffer
|
|
33
|
-
* @param blob
|
|
34
|
-
* @returns
|
|
35
32
|
*/
|
|
36
33
|
export function load(blob: blobref): ArrayBuffer {
|
|
37
34
|
const bytes = new Uint8Array(length(blob))
|
|
@@ -43,7 +40,6 @@ export namespace blobs {
|
|
|
43
40
|
|
|
44
41
|
/**
|
|
45
42
|
* The length of the given blob
|
|
46
|
-
* @param blob
|
|
47
43
|
*/
|
|
48
44
|
// @ts-ignore: decorator
|
|
49
45
|
@external("blobs", "length")
|
|
@@ -51,8 +47,6 @@ export namespace blobs {
|
|
|
51
47
|
|
|
52
48
|
/**
|
|
53
49
|
* Concatenate two blobs
|
|
54
|
-
* @param left
|
|
55
|
-
* @param right
|
|
56
50
|
*/
|
|
57
51
|
// @ts-ignore: decorator
|
|
58
52
|
@external("blobs", "concat")
|
|
@@ -60,8 +54,6 @@ export namespace blobs {
|
|
|
60
54
|
|
|
61
55
|
/**
|
|
62
56
|
* True if left and right have the same data
|
|
63
|
-
* @param left
|
|
64
|
-
* @param right
|
|
65
57
|
*/
|
|
66
58
|
// @ts-ignore: decorator
|
|
67
59
|
@external("blobs", "equals")
|
|
@@ -69,8 +61,6 @@ export namespace blobs {
|
|
|
69
61
|
|
|
70
62
|
/**
|
|
71
63
|
* True if the data in haystack contains the data in needle (at any offset)
|
|
72
|
-
* @param haystack
|
|
73
|
-
* @param needle
|
|
74
64
|
*/
|
|
75
65
|
// @ts-ignore: decorator
|
|
76
66
|
@external("blobs", "includes")
|
|
@@ -78,9 +68,6 @@ export namespace blobs {
|
|
|
78
68
|
|
|
79
69
|
/**
|
|
80
70
|
* Slice the given blob from start (inclusive) to until (exclusive)
|
|
81
|
-
* @param blob
|
|
82
|
-
* @param start
|
|
83
|
-
* @param until
|
|
84
71
|
*/
|
|
85
72
|
// @ts-ignore: decorator
|
|
86
73
|
@external("blobs", "slice")
|
|
@@ -88,7 +75,6 @@ export namespace blobs {
|
|
|
88
75
|
|
|
89
76
|
/**
|
|
90
77
|
* Create a blob from a base-16 string
|
|
91
|
-
* @param text
|
|
92
78
|
*/
|
|
93
79
|
// @ts-ignore: decorator
|
|
94
80
|
@external("blobs", "from_base16")
|
|
@@ -96,7 +82,6 @@ export namespace blobs {
|
|
|
96
82
|
|
|
97
83
|
/**
|
|
98
84
|
* Convert a blob to a base-16 string
|
|
99
|
-
* @param blob
|
|
100
85
|
*/
|
|
101
86
|
// @ts-ignore: decorator
|
|
102
87
|
@external("blobs", "to_base16")
|
|
@@ -104,7 +89,6 @@ export namespace blobs {
|
|
|
104
89
|
|
|
105
90
|
/**
|
|
106
91
|
* Create a blob from a base-64 string
|
|
107
|
-
* @param text
|
|
108
92
|
*/
|
|
109
93
|
// @ts-ignore: decorator
|
|
110
94
|
@external("blobs", "from_base64")
|
|
@@ -112,7 +96,6 @@ export namespace blobs {
|
|
|
112
96
|
|
|
113
97
|
/**
|
|
114
98
|
* Convert a blob to a base-64 string
|
|
115
|
-
* @param blob
|
|
116
99
|
*/
|
|
117
100
|
// @ts-ignore: decorator
|
|
118
101
|
@external("blobs", "to_base64")
|
|
@@ -120,18 +103,16 @@ export namespace blobs {
|
|
|
120
103
|
|
|
121
104
|
/**
|
|
122
105
|
* Encode the given value into a blob
|
|
123
|
-
* @param value
|
|
124
106
|
*/
|
|
125
107
|
// @ts-ignore: decorator
|
|
126
108
|
@external("blobs", "encode")
|
|
127
109
|
export declare function encode<T>(value: T): blobref
|
|
128
110
|
|
|
129
111
|
/**
|
|
130
|
-
* Decode the given blob into a value of type T (assuming it was encoded from a value of type T)
|
|
131
|
-
* @param blob
|
|
112
|
+
* Decode the given blob into a value of type T (assuming it was encoded from a value of type T) in a in a wrapref or null if it failed
|
|
132
113
|
*/
|
|
133
114
|
// @ts-ignore: decorator
|
|
134
115
|
@external("blobs", "decode")
|
|
135
|
-
export declare function decode
|
|
116
|
+
export declare function decode(blob: blobref): wrapref
|
|
136
117
|
|
|
137
118
|
}
|
package/src/mods/console/mod.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { textref } from "../mod";
|
|
1
|
+
import { textref } from "../texts/mod";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Log messages to the console
|
|
@@ -7,7 +7,6 @@ export namespace console {
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Log the given message to the console
|
|
10
|
-
* @param message
|
|
11
10
|
*/
|
|
12
11
|
// @ts-ignore: decorator
|
|
13
12
|
@external("console", "log")
|
package/src/mods/ed25519/mod.ts
CHANGED
|
@@ -7,12 +7,9 @@ export namespace ed25519 {
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Verify that the given signature is valid for the given payload and public key
|
|
10
|
-
* @param pubkey
|
|
11
|
-
* @param signature
|
|
12
|
-
* @param payload
|
|
13
10
|
*/
|
|
14
11
|
// @ts-ignore: decorator
|
|
15
12
|
@external("ed25519", "verify")
|
|
16
|
-
export declare function verify(
|
|
13
|
+
export declare function verify(identity: blobref, signature: blobref, message: blobref): bool
|
|
17
14
|
|
|
18
15
|
}
|
package/src/mods/env/mod.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { textref } from "../mod"
|
|
1
|
+
import { textref } from "../texts/mod"
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Execution environment
|
|
@@ -21,7 +21,6 @@ export namespace env {
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Stop execution with the given message
|
|
24
|
-
* @param message
|
|
25
24
|
*/
|
|
26
25
|
// @ts-ignore: decorator
|
|
27
26
|
@external("env", "panic")
|
package/src/mods/mod.ts
CHANGED
|
@@ -4,10 +4,11 @@ export * from "./console/mod"
|
|
|
4
4
|
export * from "./ed25519/mod"
|
|
5
5
|
export * from "./env/mod"
|
|
6
6
|
export * from "./modules/mod"
|
|
7
|
-
export * from "./
|
|
8
|
-
export * from "./
|
|
7
|
+
export * from "./pointers/mod"
|
|
8
|
+
export * from "./records/mod"
|
|
9
9
|
export * from "./sha256/mod"
|
|
10
10
|
export * from "./storage/mod"
|
|
11
11
|
export * from "./symbols/mod"
|
|
12
12
|
export * from "./texts/mod"
|
|
13
|
+
export * from "./tuples/mod"
|
|
13
14
|
|
package/src/mods/modules/mod.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { blobref } from "../blobs/mod"
|
|
2
|
-
import { packref } from "../packs/mod"
|
|
3
2
|
import { textref } from "../texts/mod"
|
|
3
|
+
import { tupleref } from "../tuples/mod"
|
|
4
|
+
import { wrapref } from "../wraps/mod"
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Modules have an address and can be called by other modules
|
|
@@ -16,29 +17,23 @@ export namespace modules {
|
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Get the code of the given module
|
|
19
|
-
* @param module
|
|
20
20
|
*/
|
|
21
21
|
// @ts-ignore: decorator
|
|
22
22
|
@external("modules", "load")
|
|
23
23
|
export declare function load(module: textref): blobref
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* Call the given method of the given module with the given parameters then return the result in a
|
|
27
|
-
* @param module
|
|
28
|
-
* @param method
|
|
29
|
-
* @param params
|
|
26
|
+
* Call the given method of the given module with the given parameters then return the result in a wrapref or null if it failed
|
|
30
27
|
*/
|
|
31
28
|
// @ts-ignore: decorator
|
|
32
29
|
@external("modules", "call")
|
|
33
|
-
export declare function call(module: textref, method: textref, params:
|
|
30
|
+
export declare function call(module: textref, method: textref, params: tupleref): wrapref
|
|
34
31
|
|
|
35
32
|
/**
|
|
36
33
|
* Create a new module with the given code and salt then return its address
|
|
37
|
-
* @param code
|
|
38
|
-
* @param salt
|
|
39
34
|
*/
|
|
40
35
|
// @ts-ignore: decorator
|
|
41
36
|
@external("modules", "create")
|
|
42
|
-
export declare function create
|
|
37
|
+
export declare function create(code: blobref, salt: blobref): textref
|
|
43
38
|
|
|
44
39
|
}
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Convert between externrefs and local i32 indices (for use in data structures)
|
|
3
3
|
*/
|
|
4
|
-
export namespace
|
|
4
|
+
export namespace pointers {
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Convert an externref to an i32 index
|
|
8
|
-
* @param ref
|
|
9
8
|
*/
|
|
10
9
|
// @ts-ignore: decorator
|
|
11
|
-
@external("
|
|
10
|
+
@external("pointers", "numerize")
|
|
12
11
|
export declare function numerize(ref: externref): i32
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Convert an i32 index back to an externref
|
|
16
|
-
* @param index
|
|
17
15
|
*/
|
|
18
16
|
// @ts-ignore: decorator
|
|
19
|
-
@external("
|
|
17
|
+
@external("pointers", "denumerize")
|
|
20
18
|
export declare function denumerize(index: i32): externref
|
|
21
19
|
|
|
22
20
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { tupleref } from "../mod";
|
|
2
|
+
import { textref } from "../texts/mod";
|
|
3
|
+
import { wrapref } from "../wraps/mod";
|
|
4
|
+
|
|
5
|
+
export type recordref = externref
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Records are external references to records of values (e.g. objects in JavaScript)
|
|
9
|
+
*/
|
|
10
|
+
export namespace records {
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Create a new record
|
|
14
|
+
*/
|
|
15
|
+
// @ts-ignore: decorator
|
|
16
|
+
@external("records", "create")
|
|
17
|
+
export declare function create(): recordref
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get the value at the given index in the given record in a wrapref or null if not found
|
|
21
|
+
*/
|
|
22
|
+
// @ts-ignore: decorator
|
|
23
|
+
@external("records", "get")
|
|
24
|
+
export declare function get(record: recordref, key: textref): wrapref
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Set the value at the given index in the given record
|
|
28
|
+
*/
|
|
29
|
+
// @ts-ignore: decorator
|
|
30
|
+
@external("records", "set")
|
|
31
|
+
export declare function set<T>(record: recordref, key: textref, value: T): void
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Concatenate two records (e.g. {...left, ...right} in JavaScript)
|
|
35
|
+
*/
|
|
36
|
+
// @ts-ignore: decorator
|
|
37
|
+
@external("records", "concat")
|
|
38
|
+
export declare function concat(left: recordref, right: recordref): recordref
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Get the entries of a given record
|
|
42
|
+
*/
|
|
43
|
+
// @ts-ignore: decorator
|
|
44
|
+
@external("records", "entries")
|
|
45
|
+
export declare function entries(record: recordref): tupleref
|
|
46
|
+
|
|
47
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { blobref } from "../blobs/mod";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Secp256k1 elliptic curve digital signature algorithm
|
|
5
|
+
*/
|
|
6
|
+
export namespace secp256k1 {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Verify that the given signature is valid for the given payload and public key
|
|
10
|
+
*/
|
|
11
|
+
// @ts-ignore: decorator
|
|
12
|
+
@external("secp256k1", "verify")
|
|
13
|
+
export declare function verify(identity: blobref, signature: blobref, digest: blobref): bool
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Recover the public key from the given signature and payload
|
|
17
|
+
*/
|
|
18
|
+
// @ts-ignore: decorator
|
|
19
|
+
@external("secp256k1", "recover")
|
|
20
|
+
export declare function recover(signature: blobref, digest: blobref): blobref
|
|
21
|
+
|
|
22
|
+
}
|
package/src/mods/sha256/mod.ts
CHANGED
|
@@ -7,10 +7,9 @@ export namespace sha256 {
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* The SHA-256 digest of the given payload
|
|
10
|
-
* @param payload
|
|
11
10
|
*/
|
|
12
11
|
// @ts-ignore: decorator
|
|
13
12
|
@external("sha256", "digest")
|
|
14
|
-
export declare function digest(
|
|
13
|
+
export declare function digest(message: blobref): blobref
|
|
15
14
|
|
|
16
15
|
}
|
package/src/mods/storage/mod.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { wrapref } from "../wraps/mod";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Persistent public key-value storage
|
|
@@ -6,17 +6,14 @@ import { packref } from "../mod";
|
|
|
6
6
|
export namespace storage {
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Get the value associated with the given key in a
|
|
10
|
-
* @param key
|
|
9
|
+
* Get the value associated with the given key in a wrapref or null if not found
|
|
11
10
|
*/
|
|
12
11
|
// @ts-ignore: decorator
|
|
13
12
|
@external("storage", "get")
|
|
14
|
-
export declare function get<K>(key: K):
|
|
13
|
+
export declare function get<K>(key: K): wrapref
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Set the value associated with the given key
|
|
18
|
-
* @param key
|
|
19
|
-
* @param value
|
|
20
17
|
*/
|
|
21
18
|
// @ts-ignore: decorator
|
|
22
19
|
@external("storage", "set")
|
package/src/mods/texts/mod.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { blobref, blobs } from "../mod"
|
|
1
|
+
import { blobref, blobs } from "../blobs/mod"
|
|
2
2
|
|
|
3
3
|
export type textref = externref
|
|
4
4
|
|
|
@@ -9,7 +9,6 @@ export namespace texts {
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* The length of the given text
|
|
12
|
-
* @param text
|
|
13
12
|
*/
|
|
14
13
|
// @ts-ignore: decorator
|
|
15
14
|
@external("texts", "length")
|
|
@@ -17,8 +16,6 @@ export namespace texts {
|
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* Concatenate two texts
|
|
20
|
-
* @param left
|
|
21
|
-
* @param right
|
|
22
19
|
*/
|
|
23
20
|
// @ts-ignore: decorator
|
|
24
21
|
@external("texts", "concat")
|
|
@@ -26,8 +23,6 @@ export namespace texts {
|
|
|
26
23
|
|
|
27
24
|
/**
|
|
28
25
|
* True if left and right are equal
|
|
29
|
-
* @param left
|
|
30
|
-
* @param right
|
|
31
26
|
*/
|
|
32
27
|
// @ts-ignore: decorator
|
|
33
28
|
@external("texts", "equals")
|
|
@@ -35,8 +30,6 @@ export namespace texts {
|
|
|
35
30
|
|
|
36
31
|
/**
|
|
37
32
|
* True if left includes right (at any offset)
|
|
38
|
-
* @param haystack
|
|
39
|
-
* @param needle
|
|
40
33
|
*/
|
|
41
34
|
// @ts-ignore: decorator
|
|
42
35
|
@external("texts", "includes")
|
|
@@ -44,9 +37,6 @@ export namespace texts {
|
|
|
44
37
|
|
|
45
38
|
/**
|
|
46
39
|
* Slice the given text from start (inclusive) to until (exclusive)
|
|
47
|
-
* @param text
|
|
48
|
-
* @param start
|
|
49
|
-
* @param until
|
|
50
40
|
*/
|
|
51
41
|
// @ts-ignore: decorator
|
|
52
42
|
@external("texts", "slice")
|
|
@@ -54,7 +44,6 @@ export namespace texts {
|
|
|
54
44
|
|
|
55
45
|
/**
|
|
56
46
|
* Create a text from a UTF-8 blob
|
|
57
|
-
* @param blob
|
|
58
47
|
*/
|
|
59
48
|
// @ts-ignore: decorator
|
|
60
49
|
@external("texts", "from_utf8")
|
|
@@ -62,7 +51,6 @@ export namespace texts {
|
|
|
62
51
|
|
|
63
52
|
/**
|
|
64
53
|
* Convert a text to a UTF-8 blob
|
|
65
|
-
* @param text
|
|
66
54
|
*/
|
|
67
55
|
// @ts-ignore: decorator
|
|
68
56
|
@external("texts", "to_utf8")
|
|
@@ -70,7 +58,6 @@ export namespace texts {
|
|
|
70
58
|
|
|
71
59
|
/**
|
|
72
60
|
* Convert the given text to uppercase
|
|
73
|
-
* @param text
|
|
74
61
|
*/
|
|
75
62
|
// @ts-ignore: decorator
|
|
76
63
|
@external("texts", "to_uppercase")
|
|
@@ -78,7 +65,6 @@ export namespace texts {
|
|
|
78
65
|
|
|
79
66
|
/**
|
|
80
67
|
* Convert the given text to lowercase
|
|
81
|
-
* @param text
|
|
82
68
|
*/
|
|
83
69
|
// @ts-ignore: decorator
|
|
84
70
|
@external("texts", "to_lowercase")
|
|
@@ -86,7 +72,6 @@ export namespace texts {
|
|
|
86
72
|
|
|
87
73
|
/**
|
|
88
74
|
* Trim the given text by removing whitespace from both ends
|
|
89
|
-
* @param text
|
|
90
75
|
*/
|
|
91
76
|
// @ts-ignore: decorator
|
|
92
77
|
@external("texts", "trim")
|
|
@@ -94,7 +79,6 @@ export namespace texts {
|
|
|
94
79
|
|
|
95
80
|
/**
|
|
96
81
|
* Create a text from a string
|
|
97
|
-
* @param string
|
|
98
82
|
* @returns
|
|
99
83
|
*/
|
|
100
84
|
export function fromString(string: string): textref {
|
|
@@ -108,7 +92,6 @@ export namespace texts {
|
|
|
108
92
|
|
|
109
93
|
/**
|
|
110
94
|
* Convert a text to a string
|
|
111
|
-
* @param text
|
|
112
95
|
* @returns
|
|
113
96
|
*/
|
|
114
97
|
export function toString(text: textref): string {
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { wrapref } from "../wraps/mod";
|
|
2
|
+
|
|
3
|
+
export type tupleref = externref
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Tuples are external references to tuples of values (e.g. arrays in JavaScript)
|
|
7
|
+
*/
|
|
8
|
+
export namespace tuples {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Create a new tuple
|
|
12
|
+
*/
|
|
13
|
+
// @ts-ignore: decorator
|
|
14
|
+
@external("tuples", "create")
|
|
15
|
+
export declare function create(): tupleref
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Create a new tuple with the given arguments
|
|
19
|
+
*/
|
|
20
|
+
// @ts-ignore: decorator
|
|
21
|
+
@external("tuples", "create")
|
|
22
|
+
export declare function create1<A>(arg0: A): tupleref
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create a new tuple with the given arguments
|
|
26
|
+
*/
|
|
27
|
+
// @ts-ignore: decorator
|
|
28
|
+
@external("tuples", "create")
|
|
29
|
+
export declare function create2<A, B>(arg0: A, arg1: B): tupleref
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Create a new tuple with the given arguments
|
|
33
|
+
*/
|
|
34
|
+
// @ts-ignore: decorator
|
|
35
|
+
@external("tuples", "create")
|
|
36
|
+
export declare function create3<A, B, C>(arg0: A, arg1: B, arg2: C): tupleref
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create a new tuple with the given arguments
|
|
40
|
+
*/
|
|
41
|
+
// @ts-ignore: decorator
|
|
42
|
+
@external("tuples", "create")
|
|
43
|
+
export declare function create4<A, B, C, D>(arg0: A, arg1: B, arg2: C, arg3: D): tupleref
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Create a new tuple with the given arguments
|
|
47
|
+
*/
|
|
48
|
+
// @ts-ignore: decorator
|
|
49
|
+
@external("tuples", "create")
|
|
50
|
+
export declare function create5<A, B, C, D, E>(arg0: A, arg1: B, arg2: C, arg3: D, arg4: E): tupleref
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Create a new tuple with the given arguments
|
|
54
|
+
*/
|
|
55
|
+
// @ts-ignore: decorator
|
|
56
|
+
@external("tuples", "create")
|
|
57
|
+
export declare function create6<A, B, C, D, E, F>(arg0: A, arg1: B, arg2: C, arg3: D, arg4: E, arg5: F): tupleref
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Create a new tuple with the given arguments
|
|
61
|
+
*/
|
|
62
|
+
// @ts-ignore: decorator
|
|
63
|
+
@external("tuples", "create")
|
|
64
|
+
export declare function create7<A, B, C, D, E, F, G>(arg0: A, arg1: B, arg2: C, arg3: D, arg4: E, arg5: F, arg6: G): tupleref
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Create a new tuple with the given arguments
|
|
68
|
+
*/
|
|
69
|
+
// @ts-ignore: decorator
|
|
70
|
+
@external("tuples", "create")
|
|
71
|
+
export declare function create8<A, B, C, D, E, F, G, H>(arg0: A, arg1: B, arg2: C, arg3: D, arg4: E, arg5: F, arg6: G, arg7: H): tupleref
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Create a new tuple with the given arguments
|
|
75
|
+
*/
|
|
76
|
+
// @ts-ignore: decorator
|
|
77
|
+
@external("tuples", "create")
|
|
78
|
+
export declare function create9<A, B, C, D, E, F, G, H, I>(arg0: A, arg1: B, arg2: C, arg3: D, arg4: E, arg5: F, arg6: G, arg7: H, arg8: I): tupleref
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Get the length of the given tuple
|
|
82
|
+
*/
|
|
83
|
+
// @ts-ignore: decorator: decorator
|
|
84
|
+
@external("tuples", "length")
|
|
85
|
+
export declare function length(tuple: tupleref): i32
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Get the value at the given index in the given tuple into a wrapref or null if not found
|
|
89
|
+
*/
|
|
90
|
+
// @ts-ignore: decorator
|
|
91
|
+
@external("tuples", "get")
|
|
92
|
+
export declare function get(tuple: tupleref, index: i32): wrapref
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Concatenate two tuples (e.g. [...left, ...right] in JavaScript)
|
|
96
|
+
*/
|
|
97
|
+
// @ts-ignore: decorator
|
|
98
|
+
@external("tuples", "concat")
|
|
99
|
+
export declare function concat(left: tupleref, right: tupleref): tupleref
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Slice the given tuple from the given start index (inclusive) to the given until index (exclusive)
|
|
103
|
+
*/
|
|
104
|
+
// @ts-ignore: decorator
|
|
105
|
+
@external("tuples", "slice")
|
|
106
|
+
export declare function slice(tuple: tupleref, start: i32, until: i32): tupleref
|
|
107
|
+
|
|
108
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type wrapref = externref
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Tuples are external references to tuples of values (e.g. arrays in JavaScript)
|
|
5
|
+
*/
|
|
6
|
+
export namespace wraps {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Wrap a value into a wrapref
|
|
10
|
+
*/
|
|
11
|
+
// @ts-ignore: decorator
|
|
12
|
+
@external("wraps", "wrap")
|
|
13
|
+
export declare function wrap<T>(value: T): wrapref
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Unwrap a value or throw if it's null
|
|
17
|
+
*/
|
|
18
|
+
// @ts-ignore: decorator
|
|
19
|
+
@external("wraps", "unwrap")
|
|
20
|
+
export declare function unwrap<T>(wrap: wrapref): T
|
|
21
|
+
|
|
22
|
+
}
|
package/src/mods/packs/mod.ts
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export type packref = externref
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Packs are external references to tuples of values (e.g. arrays in JavaScript)
|
|
6
|
-
*/
|
|
7
|
-
export namespace packs {
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Concatenate two packs (e.g. [...left, ...right] in JavaScript)
|
|
11
|
-
* @param left
|
|
12
|
-
* @param right
|
|
13
|
-
*/
|
|
14
|
-
// @ts-ignore: decorator
|
|
15
|
-
@external("packs", "concat")
|
|
16
|
-
export declare function concat(left: packref, right: packref): packref
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Create a new pack with the given arguments
|
|
20
|
-
* @param arg0
|
|
21
|
-
*/
|
|
22
|
-
// @ts-ignore: decorator
|
|
23
|
-
@external("packs", "create")
|
|
24
|
-
export declare function create1<A>(arg0: A): packref
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Create a new pack with the given arguments
|
|
28
|
-
* @param arg0
|
|
29
|
-
*/
|
|
30
|
-
// @ts-ignore: decorator
|
|
31
|
-
@external("packs", "create")
|
|
32
|
-
export declare function create2<A, B>(arg0: A, arg1: B): packref
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Create a new pack with the given arguments
|
|
36
|
-
* @param arg0
|
|
37
|
-
*/
|
|
38
|
-
// @ts-ignore: decorator
|
|
39
|
-
@external("packs", "create")
|
|
40
|
-
export declare function create3<A, B, C>(arg0: A, arg1: B, arg2: C): packref
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Create a new pack with the given arguments
|
|
44
|
-
* @param arg0
|
|
45
|
-
*/
|
|
46
|
-
// @ts-ignore: decorator
|
|
47
|
-
@external("packs", "create")
|
|
48
|
-
export declare function create4<A, B, C, D>(arg0: A, arg1: B, arg2: C, arg3: D): packref
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Create a new pack with the given arguments
|
|
52
|
-
* @param arg0
|
|
53
|
-
*/
|
|
54
|
-
// @ts-ignore: decorator
|
|
55
|
-
@external("packs", "create")
|
|
56
|
-
export declare function create5<A, B, C, D, E>(arg0: A, arg1: B, arg2: C, arg3: D, arg4: E): packref
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Create a new pack with the given arguments
|
|
60
|
-
* @param arg0
|
|
61
|
-
*/
|
|
62
|
-
// @ts-ignore: decorator
|
|
63
|
-
@external("packs", "create")
|
|
64
|
-
export declare function create6<A, B, C, D, E, F>(arg0: A, arg1: B, arg2: C, arg3: D, arg4: E, arg5: F): packref
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Create a new pack with the given arguments
|
|
68
|
-
* @param arg0
|
|
69
|
-
*/
|
|
70
|
-
// @ts-ignore: decorator
|
|
71
|
-
@external("packs", "create")
|
|
72
|
-
export declare function create7<A, B, C, D, E, F, G>(arg0: A, arg1: B, arg2: C, arg3: D, arg4: E, arg5: F, arg6: G): packref
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Create a new pack with the given arguments
|
|
76
|
-
* @param arg0
|
|
77
|
-
*/
|
|
78
|
-
// @ts-ignore: decorator
|
|
79
|
-
@external("packs", "create")
|
|
80
|
-
export declare function create8<A, B, C, D, E, F, G, H>(arg0: A, arg1: B, arg2: C, arg3: D, arg4: E, arg5: F, arg6: G, arg7: H): packref
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Create a new pack with the given arguments
|
|
84
|
-
* @param arg0
|
|
85
|
-
*/
|
|
86
|
-
// @ts-ignore: decorator
|
|
87
|
-
@external("packs", "create")
|
|
88
|
-
export declare function create9<A, B, C, D, E, F, G, H, I>(arg0: A, arg1: B, arg2: C, arg3: D, arg4: E, arg5: F, arg6: G, arg7: H, arg8: I): packref
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Get the length of the given pack
|
|
92
|
-
* @param pack
|
|
93
|
-
*/
|
|
94
|
-
// @ts-ignore: decorator: decorator
|
|
95
|
-
@external("packs", "length")
|
|
96
|
-
export declare function length(pack: packref): i32
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Get the value at the given index in the given pack (throw if not found)
|
|
100
|
-
* @param pack
|
|
101
|
-
* @param index
|
|
102
|
-
*/
|
|
103
|
-
// @ts-ignore: decorator
|
|
104
|
-
@external("packs", "get")
|
|
105
|
-
export declare function get<T>(pack: packref, index: i32): T
|
|
106
|
-
|
|
107
|
-
}
|