@proto-kit/module 0.1.1-develop.153 → 0.1.1-develop.156
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/method/assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAY,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/method/assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAY,MAAM,UAAU,CAAC;AAM1C;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,QAYvD"}
|
package/dist/method/assert.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Bool, Provable } from "snarkyjs";
|
|
2
2
|
import { container } from "tsyringe";
|
|
3
3
|
import { RuntimeMethodExecutionContext } from "./RuntimeMethodExecutionContext";
|
|
4
|
+
import { log } from "@proto-kit/common";
|
|
4
5
|
/**
|
|
5
6
|
* Maintains an execution status of the current runtime module method,
|
|
6
7
|
* while prioritizing one-time failures. The assertion won't change the
|
|
@@ -14,6 +15,9 @@ export function assert(condition, message) {
|
|
|
14
15
|
const executionContext = container.resolve(RuntimeMethodExecutionContext);
|
|
15
16
|
const previousStatus = executionContext.current().result.status;
|
|
16
17
|
const status = Provable.if(previousStatus, Bool, condition, previousStatus);
|
|
18
|
+
if (!status.toBoolean()) {
|
|
19
|
+
log.debug("Assertion failed: ", message);
|
|
20
|
+
}
|
|
17
21
|
// const status = previousStatus.and(condition);
|
|
18
22
|
executionContext.setStatus(status);
|
|
19
23
|
executionContext.setStatusMessage(message);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@proto-kit/module",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.1.1-develop.
|
|
5
|
+
"version": "0.1.1-develop.156+652fe76",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc -p tsconfig.json",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@proto-kit/common": "0.1.1-develop.
|
|
21
|
-
"@proto-kit/protocol": "0.1.1-develop.
|
|
20
|
+
"@proto-kit/common": "0.1.1-develop.156+652fe76",
|
|
21
|
+
"@proto-kit/protocol": "0.1.1-develop.156+652fe76",
|
|
22
22
|
"lodash": "^4.17.21",
|
|
23
23
|
"loglevel": "^1.8.1",
|
|
24
24
|
"reflect-metadata": "^0.1.13",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"snarkyjs": "0.11.0",
|
|
33
33
|
"tsyringe": "^4.7.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "652fe76e07de0e433f519d336367b3555f5eab20"
|
|
36
36
|
}
|
package/src/method/assert.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Bool, Provable } from "snarkyjs";
|
|
|
2
2
|
import { container } from "tsyringe";
|
|
3
3
|
|
|
4
4
|
import { RuntimeMethodExecutionContext } from "./RuntimeMethodExecutionContext";
|
|
5
|
+
import { log } from "@proto-kit/common";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Maintains an execution status of the current runtime module method,
|
|
@@ -17,6 +18,10 @@ export function assert(condition: Bool, message?: string) {
|
|
|
17
18
|
const previousStatus = executionContext.current().result.status;
|
|
18
19
|
const status = Provable.if(previousStatus, Bool, condition, previousStatus);
|
|
19
20
|
|
|
21
|
+
if (!status.toBoolean()) {
|
|
22
|
+
log.debug("Assertion failed: ", message);
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
// const status = previousStatus.and(condition);
|
|
21
26
|
executionContext.setStatus(status);
|
|
22
27
|
executionContext.setStatusMessage(message);
|