zkjson 0.1.28 → 0.1.30
Sign up to get free protection for your applications and to get access to all the features.
- package/contracts/ZKQuery.sol +54 -33
- package/index.js +1 -2
- package/nft.js +1 -3
- package/package.json +1 -1
package/contracts/ZKQuery.sol
CHANGED
@@ -105,49 +105,70 @@ contract ZKQuery {
|
|
105
105
|
if gt(v,0) {
|
106
106
|
let p := 0
|
107
107
|
let x := v
|
108
|
-
|
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
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
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
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
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
|
-
|
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
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
|