@qevm/abi 5.7.1 → 5.7.2
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/lib/abi-coder.js +51 -46
- package/lib/abi-coder.js.map +1 -1
- package/lib/coders/abstract-coder.js +80 -60
- package/lib/coders/abstract-coder.js.map +1 -1
- package/lib/coders/address.js +30 -13
- package/lib/coders/address.js.map +1 -1
- package/lib/coders/anonymous.js +30 -12
- package/lib/coders/anonymous.js.map +1 -1
- package/lib/coders/array.js +82 -60
- package/lib/coders/array.js.map +1 -1
- package/lib/coders/boolean.js +28 -11
- package/lib/coders/boolean.js.map +1 -1
- package/lib/coders/bytes.js +39 -20
- package/lib/coders/bytes.js.map +1 -1
- package/lib/coders/fixed-bytes.js +34 -15
- package/lib/coders/fixed-bytes.js.map +1 -1
- package/lib/coders/null.js +28 -11
- package/lib/coders/null.js.map +1 -1
- package/lib/coders/number.js +39 -20
- package/lib/coders/number.js.map +1 -1
- package/lib/coders/string.js +31 -14
- package/lib/coders/string.js.map +1 -1
- package/lib/coders/tuple.js +42 -23
- package/lib/coders/tuple.js.map +1 -1
- package/lib/fragments.js +179 -142
- package/lib/fragments.js.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/interface.js +216 -169
- package/lib/interface.js.map +1 -1
- package/package.json +1 -1
- package/src.ts/coders/string.ts +1 -1
- package/src.ts/interface.ts +1 -1
package/lib/coders/array.js
CHANGED
|
@@ -1,22 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.ArrayCoder = void 0;
|
|
4
19
|
exports.pack = pack;
|
|
5
20
|
exports.unpack = unpack;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
21
|
+
var logger_1 = require("@ethersproject/logger");
|
|
22
|
+
var _version_1 = require("../_version");
|
|
23
|
+
var logger = new logger_1.Logger(_version_1.version);
|
|
24
|
+
var abstract_coder_1 = require("./abstract-coder");
|
|
25
|
+
var anonymous_1 = require("./anonymous");
|
|
11
26
|
function pack(writer, coders, values) {
|
|
12
|
-
|
|
27
|
+
var arrayValues = null;
|
|
13
28
|
if (Array.isArray(values)) {
|
|
14
29
|
arrayValues = values;
|
|
15
30
|
}
|
|
16
31
|
else if (values && typeof (values) === "object") {
|
|
17
|
-
|
|
18
|
-
arrayValues = coders.map((coder)
|
|
19
|
-
|
|
32
|
+
var unique_1 = {};
|
|
33
|
+
arrayValues = coders.map(function (coder) {
|
|
34
|
+
var name = coder.localName;
|
|
20
35
|
if (!name) {
|
|
21
36
|
logger.throwError("cannot encode object for signature with missing names", logger_1.Logger.errors.INVALID_ARGUMENT, {
|
|
22
37
|
argument: "values",
|
|
@@ -24,14 +39,14 @@ function pack(writer, coders, values) {
|
|
|
24
39
|
value: values
|
|
25
40
|
});
|
|
26
41
|
}
|
|
27
|
-
if (
|
|
42
|
+
if (unique_1[name]) {
|
|
28
43
|
logger.throwError("cannot encode object for signature with duplicate names", logger_1.Logger.errors.INVALID_ARGUMENT, {
|
|
29
44
|
argument: "values",
|
|
30
45
|
coder: coder,
|
|
31
46
|
value: values
|
|
32
47
|
});
|
|
33
48
|
}
|
|
34
|
-
|
|
49
|
+
unique_1[name] = true;
|
|
35
50
|
return values[name];
|
|
36
51
|
});
|
|
37
52
|
}
|
|
@@ -41,20 +56,20 @@ function pack(writer, coders, values) {
|
|
|
41
56
|
if (coders.length !== arrayValues.length) {
|
|
42
57
|
logger.throwArgumentError("types/value length mismatch", "tuple", values);
|
|
43
58
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
coders.forEach((coder, index)
|
|
48
|
-
|
|
59
|
+
var staticWriter = new abstract_coder_1.Writer(writer.wordSize);
|
|
60
|
+
var dynamicWriter = new abstract_coder_1.Writer(writer.wordSize);
|
|
61
|
+
var updateFuncs = [];
|
|
62
|
+
coders.forEach(function (coder, index) {
|
|
63
|
+
var value = arrayValues[index];
|
|
49
64
|
if (coder.dynamic) {
|
|
50
65
|
// Get current dynamic offset (for the future pointer)
|
|
51
|
-
|
|
66
|
+
var dynamicOffset_1 = dynamicWriter.length;
|
|
52
67
|
// Encode the dynamic value into the dynamicWriter
|
|
53
68
|
coder.encode(dynamicWriter, value);
|
|
54
69
|
// Prepare to populate the correct offset once we are done
|
|
55
|
-
|
|
56
|
-
updateFuncs.push((baseOffset)
|
|
57
|
-
|
|
70
|
+
var updateFunc_1 = staticWriter.writeUpdatableValue();
|
|
71
|
+
updateFuncs.push(function (baseOffset) {
|
|
72
|
+
updateFunc_1(baseOffset + dynamicOffset_1);
|
|
58
73
|
});
|
|
59
74
|
}
|
|
60
75
|
else {
|
|
@@ -62,20 +77,20 @@ function pack(writer, coders, values) {
|
|
|
62
77
|
}
|
|
63
78
|
});
|
|
64
79
|
// Backfill all the dynamic offsets, now that we know the static length
|
|
65
|
-
updateFuncs.forEach((func)
|
|
66
|
-
|
|
80
|
+
updateFuncs.forEach(function (func) { func(staticWriter.length); });
|
|
81
|
+
var length = writer.appendWriter(staticWriter);
|
|
67
82
|
length += writer.appendWriter(dynamicWriter);
|
|
68
83
|
return length;
|
|
69
84
|
}
|
|
70
85
|
function unpack(reader, coders) {
|
|
71
|
-
|
|
86
|
+
var values = [];
|
|
72
87
|
// A reader anchored to this base
|
|
73
|
-
|
|
74
|
-
coders.forEach((coder)
|
|
75
|
-
|
|
88
|
+
var baseReader = reader.subReader(0);
|
|
89
|
+
coders.forEach(function (coder) {
|
|
90
|
+
var value = null;
|
|
76
91
|
if (coder.dynamic) {
|
|
77
|
-
|
|
78
|
-
|
|
92
|
+
var offset = reader.readValue();
|
|
93
|
+
var offsetReader = baseReader.subReader(offset.toNumber());
|
|
79
94
|
try {
|
|
80
95
|
value = coder.decode(offsetReader);
|
|
81
96
|
}
|
|
@@ -110,8 +125,8 @@ function unpack(reader, coders) {
|
|
|
110
125
|
}
|
|
111
126
|
});
|
|
112
127
|
// We only output named properties for uniquely named coders
|
|
113
|
-
|
|
114
|
-
|
|
128
|
+
var uniqueNames = coders.reduce(function (accum, coder) {
|
|
129
|
+
var name = coder.localName;
|
|
115
130
|
if (name) {
|
|
116
131
|
if (!accum[name]) {
|
|
117
132
|
accum[name] = 0;
|
|
@@ -121,8 +136,8 @@ function unpack(reader, coders) {
|
|
|
121
136
|
return accum;
|
|
122
137
|
}, {});
|
|
123
138
|
// Add any named parameters (i.e. tuples)
|
|
124
|
-
coders.forEach((coder, index)
|
|
125
|
-
|
|
139
|
+
coders.forEach(function (coder, index) {
|
|
140
|
+
var name = coder.localName;
|
|
126
141
|
if (!name || uniqueNames[name] !== 1) {
|
|
127
142
|
return;
|
|
128
143
|
}
|
|
@@ -132,63 +147,69 @@ function unpack(reader, coders) {
|
|
|
132
147
|
if (values[name] != null) {
|
|
133
148
|
return;
|
|
134
149
|
}
|
|
135
|
-
|
|
150
|
+
var value = values[index];
|
|
136
151
|
if (value instanceof Error) {
|
|
137
152
|
Object.defineProperty(values, name, {
|
|
138
153
|
enumerable: true,
|
|
139
|
-
get: ()
|
|
154
|
+
get: function () { throw value; }
|
|
140
155
|
});
|
|
141
156
|
}
|
|
142
157
|
else {
|
|
143
158
|
values[name] = value;
|
|
144
159
|
}
|
|
145
160
|
});
|
|
146
|
-
|
|
147
|
-
|
|
161
|
+
var _loop_1 = function (i) {
|
|
162
|
+
var value = values[i];
|
|
148
163
|
if (value instanceof Error) {
|
|
149
164
|
Object.defineProperty(values, i, {
|
|
150
165
|
enumerable: true,
|
|
151
|
-
get: ()
|
|
166
|
+
get: function () { throw value; }
|
|
152
167
|
});
|
|
153
168
|
}
|
|
169
|
+
};
|
|
170
|
+
for (var i = 0; i < values.length; i++) {
|
|
171
|
+
_loop_1(i);
|
|
154
172
|
}
|
|
155
173
|
return Object.freeze(values);
|
|
156
174
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
175
|
+
var ArrayCoder = /** @class */ (function (_super) {
|
|
176
|
+
__extends(ArrayCoder, _super);
|
|
177
|
+
function ArrayCoder(coder, length, localName) {
|
|
178
|
+
var _this = this;
|
|
179
|
+
var type = (coder.type + "[" + (length >= 0 ? length : "") + "]");
|
|
180
|
+
var dynamic = (length === -1 || coder.dynamic);
|
|
181
|
+
_this = _super.call(this, "array", type, localName, dynamic) || this;
|
|
182
|
+
_this.coder = coder;
|
|
183
|
+
_this.length = length;
|
|
184
|
+
return _this;
|
|
164
185
|
}
|
|
165
|
-
defaultValue() {
|
|
186
|
+
ArrayCoder.prototype.defaultValue = function () {
|
|
166
187
|
// Verifies the child coder is valid (even if the array is dynamic or 0-length)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
for (
|
|
188
|
+
var defaultChild = this.coder.defaultValue();
|
|
189
|
+
var result = [];
|
|
190
|
+
for (var i = 0; i < this.length; i++) {
|
|
170
191
|
result.push(defaultChild);
|
|
171
192
|
}
|
|
172
193
|
return result;
|
|
173
|
-
}
|
|
174
|
-
encode(writer, value) {
|
|
194
|
+
};
|
|
195
|
+
ArrayCoder.prototype.encode = function (writer, value) {
|
|
175
196
|
if (!Array.isArray(value)) {
|
|
176
197
|
this._throwError("expected array value", value);
|
|
177
198
|
}
|
|
178
|
-
|
|
199
|
+
var count = this.length;
|
|
179
200
|
if (count === -1) {
|
|
180
201
|
count = value.length;
|
|
181
202
|
writer.writeValue(value.length);
|
|
182
203
|
}
|
|
183
204
|
logger.checkArgumentCount(value.length, count, "coder array" + (this.localName ? (" " + this.localName) : ""));
|
|
184
|
-
|
|
185
|
-
for (
|
|
205
|
+
var coders = [];
|
|
206
|
+
for (var i = 0; i < value.length; i++) {
|
|
186
207
|
coders.push(this.coder);
|
|
187
208
|
}
|
|
188
209
|
return pack(writer, coders, value);
|
|
189
|
-
}
|
|
190
|
-
decode(reader) {
|
|
191
|
-
|
|
210
|
+
};
|
|
211
|
+
ArrayCoder.prototype.decode = function (reader) {
|
|
212
|
+
var count = this.length;
|
|
192
213
|
if (count === -1) {
|
|
193
214
|
count = reader.readValue().toNumber();
|
|
194
215
|
// Check that there is *roughly* enough data to ensure
|
|
@@ -203,12 +224,13 @@ class ArrayCoder extends abstract_coder_1.Coder {
|
|
|
203
224
|
});
|
|
204
225
|
}
|
|
205
226
|
}
|
|
206
|
-
|
|
207
|
-
for (
|
|
227
|
+
var coders = [];
|
|
228
|
+
for (var i = 0; i < count; i++) {
|
|
208
229
|
coders.push(new anonymous_1.AnonymousCoder(this.coder));
|
|
209
230
|
}
|
|
210
231
|
return reader.coerce(this.name, unpack(reader, coders));
|
|
211
|
-
}
|
|
212
|
-
|
|
232
|
+
};
|
|
233
|
+
return ArrayCoder;
|
|
234
|
+
}(abstract_coder_1.Coder));
|
|
213
235
|
exports.ArrayCoder = ArrayCoder;
|
|
214
236
|
//# sourceMappingURL=array.js.map
|
package/lib/coders/array.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.js","sourceRoot":"","sources":["../../src.ts/coders/array.ts"],"names":[],"mappings":"AAAA,YAAY,CAA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AAC;QAEnE,OAAO,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED,2BAAM,GAAN,UAAO,MAAc;QACjB,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QACxB,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACf,KAAK,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC;YAEtC,sDAAsD;YACtD,wDAAwD;YACxD,yDAAyD;YACzD,sDAAsD;YACtD,4DAA4D;YAC5D,IAAI,KAAK,GAAG,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;gBACnC,MAAM,CAAC,UAAU,CAAC,0BAA0B,EAAE,eAAM,CAAC,MAAM,CAAC,cAAc,EAAE;oBACxE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM;oBAC3B,KAAK,EAAE,KAAK;iBACf,CAAC,CAAC;YACP,CAAC;QACL,CAAC;QACD,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;YAAC,MAAM,CAAC,IAAI,CAAC,IAAI,0BAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAAC,CAAC;QAEhF,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5D,CAAC;IACL,iBAAC;AAAD,CAAC,AAlED,CAAgC,sBAAK,GAkEpC;AAlEY,gCAAU"}
|
package/lib/coders/boolean.js
CHANGED
|
@@ -1,20 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.BooleanCoder = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
19
|
+
var abstract_coder_1 = require("./abstract-coder");
|
|
20
|
+
var BooleanCoder = /** @class */ (function (_super) {
|
|
21
|
+
__extends(BooleanCoder, _super);
|
|
22
|
+
function BooleanCoder(localName) {
|
|
23
|
+
return _super.call(this, "bool", "bool", localName, false) || this;
|
|
8
24
|
}
|
|
9
|
-
defaultValue() {
|
|
25
|
+
BooleanCoder.prototype.defaultValue = function () {
|
|
10
26
|
return false;
|
|
11
|
-
}
|
|
12
|
-
encode(writer, value) {
|
|
27
|
+
};
|
|
28
|
+
BooleanCoder.prototype.encode = function (writer, value) {
|
|
13
29
|
return writer.writeValue(value ? 1 : 0);
|
|
14
|
-
}
|
|
15
|
-
decode(reader) {
|
|
30
|
+
};
|
|
31
|
+
BooleanCoder.prototype.decode = function (reader) {
|
|
16
32
|
return reader.coerce(this.type, !reader.readValue().isZero());
|
|
17
|
-
}
|
|
18
|
-
|
|
33
|
+
};
|
|
34
|
+
return BooleanCoder;
|
|
35
|
+
}(abstract_coder_1.Coder));
|
|
19
36
|
exports.BooleanCoder = BooleanCoder;
|
|
20
37
|
//# sourceMappingURL=boolean.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../src.ts/coders/boolean.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../src.ts/coders/boolean.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;AAEb,mDAAyD;AAEzD;IAAkC,gCAAK;IAEnC,sBAAY,SAAiB;QACzB,OAAA,MAAK,YAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,SAAC;IAC5C,CAAC;IAED,mCAAY,GAAZ;QACI,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,6BAAM,GAAN,UAAO,MAAc,EAAE,KAAc;QACjC,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,6BAAM,GAAN,UAAO,MAAc;QACjB,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;IAClE,CAAC;IACL,mBAAC;AAAD,CAAC,AAjBD,CAAkC,sBAAK,GAiBtC;AAjBY,oCAAY"}
|
package/lib/coders/bytes.js
CHANGED
|
@@ -1,33 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.BytesCoder = exports.DynamicBytesCoder = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
19
|
+
var bytes_1 = require("@qevm/bytes");
|
|
20
|
+
var abstract_coder_1 = require("./abstract-coder");
|
|
21
|
+
var DynamicBytesCoder = /** @class */ (function (_super) {
|
|
22
|
+
__extends(DynamicBytesCoder, _super);
|
|
23
|
+
function DynamicBytesCoder(type, localName) {
|
|
24
|
+
return _super.call(this, type, type, localName, true) || this;
|
|
9
25
|
}
|
|
10
|
-
defaultValue() {
|
|
26
|
+
DynamicBytesCoder.prototype.defaultValue = function () {
|
|
11
27
|
return "0x";
|
|
12
|
-
}
|
|
13
|
-
encode(writer, value) {
|
|
28
|
+
};
|
|
29
|
+
DynamicBytesCoder.prototype.encode = function (writer, value) {
|
|
14
30
|
value = (0, bytes_1.arrayify)(value);
|
|
15
|
-
|
|
31
|
+
var length = writer.writeValue(value.length);
|
|
16
32
|
length += writer.writeBytes(value);
|
|
17
33
|
return length;
|
|
18
|
-
}
|
|
19
|
-
decode(reader) {
|
|
34
|
+
};
|
|
35
|
+
DynamicBytesCoder.prototype.decode = function (reader) {
|
|
20
36
|
return reader.readBytes(reader.readValue().toNumber(), true);
|
|
21
|
-
}
|
|
22
|
-
|
|
37
|
+
};
|
|
38
|
+
return DynamicBytesCoder;
|
|
39
|
+
}(abstract_coder_1.Coder));
|
|
23
40
|
exports.DynamicBytesCoder = DynamicBytesCoder;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
decode(reader) {
|
|
29
|
-
return reader.coerce(this.name, (0, bytes_1.hexlify)(super.decode(reader)));
|
|
41
|
+
var BytesCoder = /** @class */ (function (_super) {
|
|
42
|
+
__extends(BytesCoder, _super);
|
|
43
|
+
function BytesCoder(localName) {
|
|
44
|
+
return _super.call(this, "bytes", localName) || this;
|
|
30
45
|
}
|
|
31
|
-
|
|
46
|
+
BytesCoder.prototype.decode = function (reader) {
|
|
47
|
+
return reader.coerce(this.name, (0, bytes_1.hexlify)(_super.prototype.decode.call(this, reader)));
|
|
48
|
+
};
|
|
49
|
+
return BytesCoder;
|
|
50
|
+
}(DynamicBytesCoder));
|
|
32
51
|
exports.BytesCoder = BytesCoder;
|
|
33
52
|
//# sourceMappingURL=bytes.js.map
|
package/lib/coders/bytes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../src.ts/coders/bytes.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../src.ts/coders/bytes.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;AAEb,qCAAgD;AAEhD,mDAAyD;AAEzD;IAAuC,qCAAK;IACxC,2BAAY,IAAY,EAAE,SAAiB;QACxC,OAAA,MAAK,YAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,SAAC;IACtC,CAAC;IAED,wCAAY,GAAZ;QACI,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,kCAAM,GAAN,UAAO,MAAc,EAAE,KAAU;QAC7B,KAAK,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;QACxB,IAAI,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC7C,MAAM,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACnC,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,kCAAM,GAAN,UAAO,MAAc;QACjB,OAAO,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAC;IACjE,CAAC;IACL,wBAAC;AAAD,CAAC,AAnBD,CAAuC,sBAAK,GAmB3C;AAnBY,8CAAiB;AAqB9B;IAAgC,8BAAiB;IAC7C,oBAAY,SAAiB;QACzB,OAAA,MAAK,YAAC,OAAO,EAAE,SAAS,CAAC,SAAC;IAC9B,CAAC;IAED,2BAAM,GAAN,UAAO,MAAc;QACjB,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAA,eAAO,EAAC,gBAAK,CAAC,MAAM,YAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACnE,CAAC;IACL,iBAAC;AAAD,CAAC,AARD,CAAgC,iBAAiB,GAQhD;AARY,gCAAU"}
|
|
@@ -1,28 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.FixedBytesCoder = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
19
|
+
var bytes_1 = require("@qevm/bytes");
|
|
20
|
+
var abstract_coder_1 = require("./abstract-coder");
|
|
6
21
|
// @TODO: Merge this with bytes
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
22
|
+
var FixedBytesCoder = /** @class */ (function (_super) {
|
|
23
|
+
__extends(FixedBytesCoder, _super);
|
|
24
|
+
function FixedBytesCoder(size, localName) {
|
|
25
|
+
var _this = this;
|
|
26
|
+
var name = "bytes" + String(size);
|
|
27
|
+
_this = _super.call(this, name, name, localName, false) || this;
|
|
28
|
+
_this.size = size;
|
|
29
|
+
return _this;
|
|
12
30
|
}
|
|
13
|
-
defaultValue() {
|
|
31
|
+
FixedBytesCoder.prototype.defaultValue = function () {
|
|
14
32
|
return ("0x0000000000000000000000000000000000000000000000000000000000000000").substring(0, 2 + this.size * 2);
|
|
15
|
-
}
|
|
16
|
-
encode(writer, value) {
|
|
17
|
-
|
|
33
|
+
};
|
|
34
|
+
FixedBytesCoder.prototype.encode = function (writer, value) {
|
|
35
|
+
var data = (0, bytes_1.arrayify)(value);
|
|
18
36
|
if (data.length !== this.size) {
|
|
19
37
|
this._throwError("incorrect data length", value);
|
|
20
38
|
}
|
|
21
39
|
return writer.writeBytes(data);
|
|
22
|
-
}
|
|
23
|
-
decode(reader) {
|
|
40
|
+
};
|
|
41
|
+
FixedBytesCoder.prototype.decode = function (reader) {
|
|
24
42
|
return reader.coerce(this.name, (0, bytes_1.hexlify)(reader.readBytes(this.size)));
|
|
25
|
-
}
|
|
26
|
-
|
|
43
|
+
};
|
|
44
|
+
return FixedBytesCoder;
|
|
45
|
+
}(abstract_coder_1.Coder));
|
|
27
46
|
exports.FixedBytesCoder = FixedBytesCoder;
|
|
28
47
|
//# sourceMappingURL=fixed-bytes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixed-bytes.js","sourceRoot":"","sources":["../../src.ts/coders/fixed-bytes.ts"],"names":[],"mappings":"AA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
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.NullCoder = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
19
|
+
var abstract_coder_1 = require("./abstract-coder");
|
|
20
|
+
var NullCoder = /** @class */ (function (_super) {
|
|
21
|
+
__extends(NullCoder, _super);
|
|
22
|
+
function NullCoder(localName) {
|
|
23
|
+
return _super.call(this, "null", "", localName, false) || this;
|
|
8
24
|
}
|
|
9
|
-
defaultValue() {
|
|
25
|
+
NullCoder.prototype.defaultValue = function () {
|
|
10
26
|
return null;
|
|
11
|
-
}
|
|
12
|
-
encode(writer, value) {
|
|
27
|
+
};
|
|
28
|
+
NullCoder.prototype.encode = function (writer, value) {
|
|
13
29
|
if (value != null) {
|
|
14
30
|
this._throwError("not null", value);
|
|
15
31
|
}
|
|
16
32
|
return writer.writeBytes([]);
|
|
17
|
-
}
|
|
18
|
-
decode(reader) {
|
|
33
|
+
};
|
|
34
|
+
NullCoder.prototype.decode = function (reader) {
|
|
19
35
|
reader.readBytes(0);
|
|
20
36
|
return reader.coerce(this.name, null);
|
|
21
|
-
}
|
|
22
|
-
|
|
37
|
+
};
|
|
38
|
+
return NullCoder;
|
|
39
|
+
}(abstract_coder_1.Coder));
|
|
23
40
|
exports.NullCoder = NullCoder;
|
|
24
41
|
//# sourceMappingURL=null.js.map
|
package/lib/coders/null.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"null.js","sourceRoot":"","sources":["../../src.ts/coders/null.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"null.js","sourceRoot":"","sources":["../../src.ts/coders/null.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;AAEb,mDAAyD;AAEzD;IAA+B,6BAAK;IAEhC,mBAAY,SAAiB;QACzB,OAAA,MAAK,YAAC,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,SAAC;IACxC,CAAC;IAED,gCAAY,GAAZ;QACI,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,0BAAM,GAAN,UAAO,MAAc,EAAE,KAAU;QAC7B,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAAC,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAAC,CAAC;QAC3D,OAAO,MAAM,CAAC,UAAU,CAAC,EAAG,CAAC,CAAC;IAClC,CAAC;IAED,0BAAM,GAAN,UAAO,MAAc;QACjB,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACpB,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IACL,gBAAC;AAAD,CAAC,AAnBD,CAA+B,sBAAK,GAmBnC;AAnBY,8BAAS"}
|
package/lib/coders/number.js
CHANGED
|
@@ -1,25 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.NumberCoder = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
19
|
+
var bignumber_1 = require("@qevm/bignumber");
|
|
20
|
+
var constants_1 = require("@qevm/constants");
|
|
21
|
+
var abstract_coder_1 = require("./abstract-coder");
|
|
22
|
+
var NumberCoder = /** @class */ (function (_super) {
|
|
23
|
+
__extends(NumberCoder, _super);
|
|
24
|
+
function NumberCoder(size, signed, localName) {
|
|
25
|
+
var _this = this;
|
|
26
|
+
var name = ((signed ? "int" : "uint") + (size * 8));
|
|
27
|
+
_this = _super.call(this, name, name, localName, false) || this;
|
|
28
|
+
_this.size = size;
|
|
29
|
+
_this.signed = signed;
|
|
30
|
+
return _this;
|
|
13
31
|
}
|
|
14
|
-
defaultValue() {
|
|
32
|
+
NumberCoder.prototype.defaultValue = function () {
|
|
15
33
|
return 0;
|
|
16
|
-
}
|
|
17
|
-
encode(writer, value) {
|
|
18
|
-
|
|
34
|
+
};
|
|
35
|
+
NumberCoder.prototype.encode = function (writer, value) {
|
|
36
|
+
var v = bignumber_1.BigNumber.from(value);
|
|
19
37
|
// Check bounds are safe for encoding
|
|
20
|
-
|
|
38
|
+
var maxUintValue = constants_1.MaxUint256.mask(writer.wordSize * 8);
|
|
21
39
|
if (this.signed) {
|
|
22
|
-
|
|
40
|
+
var bounds = maxUintValue.mask(this.size * 8 - 1);
|
|
23
41
|
if (v.gt(bounds) || v.lt(bounds.add(constants_1.One).mul(constants_1.NegativeOne))) {
|
|
24
42
|
this._throwError("value out-of-bounds", value);
|
|
25
43
|
}
|
|
@@ -32,14 +50,15 @@ class NumberCoder extends abstract_coder_1.Coder {
|
|
|
32
50
|
v = v.fromTwos(this.size * 8).toTwos(8 * writer.wordSize);
|
|
33
51
|
}
|
|
34
52
|
return writer.writeValue(v);
|
|
35
|
-
}
|
|
36
|
-
decode(reader) {
|
|
37
|
-
|
|
53
|
+
};
|
|
54
|
+
NumberCoder.prototype.decode = function (reader) {
|
|
55
|
+
var value = reader.readValue().mask(this.size * 8);
|
|
38
56
|
if (this.signed) {
|
|
39
57
|
value = value.fromTwos(this.size * 8);
|
|
40
58
|
}
|
|
41
59
|
return reader.coerce(this.name, value);
|
|
42
|
-
}
|
|
43
|
-
|
|
60
|
+
};
|
|
61
|
+
return NumberCoder;
|
|
62
|
+
}(abstract_coder_1.Coder));
|
|
44
63
|
exports.NumberCoder = NumberCoder;
|
|
45
64
|
//# sourceMappingURL=number.js.map
|