zkjson 0.1.28 → 0.1.30

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.
@@ -105,49 +105,70 @@ contract ZKQuery {
105
105
  if gt(v,0) {
106
106
  let p := 0
107
107
  let x := v
108
- let on := 0
108
+ let on := 0 // 0 = first, 1 = off, 2 = on, 3 = is9, 4 = to set zero, 5 = zero
109
109
  let cur := 0
110
110
  let len := 0
111
111
  let num := 0
112
- let is9 := 0
113
112
  for { } gt(v, 0) { } {
114
113
  v := div(v, 10)
115
114
  p := add(p, 1)
116
115
  }
117
116
  for { } gt(p, 0) { } {
118
117
  let n := div(x, exp(10, sub(p, 1)))
119
- let _on := on
120
- if and(iszero(_on), gt(n, 0)) {
121
- on := 1
122
- if eq(n, 9) {
123
- len := 8
124
- is9 := 0
125
- }
126
- if iszero(eq(n, 9)) {
127
- len := n
128
- }
118
+ let _on := on
119
+ if iszero(_on){
120
+ on := 1
121
+ }
122
+ if and(eq(_on, 1), iszero(n)) {
123
+ on := 4
124
+ }
125
+ if eq(_on, 4) {
126
+ on := 5
127
+ len := n
128
+ }
129
+ if and(eq(_on, 1), gt(n, 0)) {
130
+ if eq(n, 9) {
131
+ len := 8
132
+ on := 3
133
+ }
134
+ if and(iszero(iszero(n)), iszero(eq(n,9))) {
135
+ on := 2
136
+ len := n
137
+ }
129
138
  cur := 0
130
- }
131
- if eq(_on, 1) {
132
- num := add(num, mul(n, exp(10, sub(sub(len, cur), 1))))
133
- cur := add(cur, 1)
134
- if eq(cur, len) {
135
- prev := mul(prev, exp(10, len))
136
- if eq(is9, 1) {
137
- prev := add(prev, num)
138
- }
139
- if iszero(eq(is9, 1)) {
140
- num := add(num, prev)
141
- prev := 0
142
- mstore(add(_json0, ji), num)
143
- ji := add(ji, 0x20)
139
+ }
140
+ if gt(_on, 1) {
141
+ if eq(_on, 5){
142
+ mstore(add(_json0, ji), n)
143
+ len := sub(len, 1)
144
+ ji := add(ji, 0x20)
145
+ if iszero(len) {
146
+ cur := 0
147
+ on := 1
148
+ len := 0
149
+ num := 0
150
+ }
151
+ }
152
+ if iszero(eq(_on, 5)){
153
+ num := add(num, mul(n, exp(10, sub(sub(len, cur), 1))))
154
+ cur := add(cur, 1)
155
+ if eq(cur, len) {
156
+ prev := mul(prev, exp(10, len))
157
+ if eq(_on, 3) {
158
+ prev := add(prev, num)
159
+ }
160
+ if iszero(eq(_on, 3)) {
161
+ num := add(num, prev)
162
+ prev := 0
163
+ mstore(add(_json0, ji), num)
164
+ ji := add(ji, 0x20)
165
+ }
166
+ cur := 0
167
+ on := 1
168
+ len := 0
169
+ num := 0
144
170
  }
145
- cur := 0
146
- on := 0
147
- len := 0
148
- num := 0
149
- is9 := 0
150
- }
171
+ }
151
172
  }
152
173
  x := sub(x, mul(exp(10, sub(p, 1)), n))
153
174
  p := sub(p, 1)
@@ -184,7 +205,7 @@ contract ZKQuery {
184
205
  require(value[0] == 4, "not object or array");
185
206
  return value;
186
207
  }
187
-
208
+
188
209
  function _qString (uint[] memory value) internal pure returns (string memory) {
189
210
  require(value[0] == 3, "not string");
190
211
  uint8[] memory charCodes = new uint8[](value[1]);
package/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  const encoder = require("./encoder")
2
2
  const DB = require("./db")
3
3
  const Doc = require("./doc")
4
- const NFT = require("/.nft")
5
4
  const Collection = require("./collection")
6
-
5
+ const NFT = require("./nft")
7
6
  module.exports = { ...encoder, DB, Collection, Doc, NFT }
package/nft.js CHANGED
@@ -71,7 +71,7 @@ function toCID(source) {
71
71
  return str
72
72
  }
73
73
 
74
- class NFT {
74
+ module.exports = class NFT {
75
75
  constructor({
76
76
  size_val = 5,
77
77
  size_path = 5,
@@ -127,5 +127,3 @@ class NFT {
127
127
  return toCID(new Uint8Array([18, hash.length, ...Array.from(hash)]))
128
128
  }
129
129
  }
130
-
131
- module.exports = NFT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zkjson",
3
- "version": "0.1.28",
3
+ "version": "0.1.30",
4
4
  "description": "Zero Knowledge Provable JSON",
5
5
  "main": "index.js",
6
6
  "license": "MIT",