Removed dead files.

This commit is contained in:
Richard Moore 2020-05-03 15:58:41 -04:00
parent 098d7efb21
commit 20a3d9b98d
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651
22 changed files with 0 additions and 749 deletions

@ -1,41 +0,0 @@
import { BytesLike } from "@ethersproject/bytes";
import { BigNumber, BigNumberish } from "@ethersproject/bignumber";
export declare type CoerceFunc = (type: string, value: any) => any;
export declare abstract class Coder {
readonly name: string;
readonly type: string;
readonly localName: string;
readonly dynamic: boolean;
constructor(name: string, type: string, localName: string, dynamic: boolean);
_throwError(message: string, value: any): void;
abstract encode(writer: Writer, value: any): number;
abstract decode(reader: Reader): any;
}
export declare class Writer {
readonly wordSize: number;
_data: Uint8Array;
_padding: Uint8Array;
constructor(wordSize?: number);
readonly data: string;
readonly length: number;
_writeData(data: Uint8Array): number;
writeBytes(value: BytesLike): number;
_getValue(value: BigNumberish): Uint8Array;
writeValue(value: BigNumberish): number;
writeUpdatableValue(): (value: BigNumberish) => void;
}
export declare class Reader {
readonly wordSize: number;
readonly _data: Uint8Array;
readonly _coerceFunc: CoerceFunc;
_offset: number;
constructor(data: BytesLike, wordSize?: number, coerceFunc?: CoerceFunc);
readonly data: string;
readonly consumed: number;
static coerce(name: string, value: any): any;
coerce(name: string, value: any): any;
_peekBytes(offset: number, length: number): Uint8Array;
subReader(offset: number): Reader;
readBytes(length: number): Uint8Array;
readValue(): BigNumber;
}

@ -1,134 +0,0 @@
"use trict";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var bytes_1 = require("@ethersproject/bytes");
var bignumber_1 = require("@ethersproject/bignumber");
var properties_1 = require("@ethersproject/properties");
var logger_1 = require("@ethersproject/logger");
var _version_1 = require("../_version");
var logger = new logger_1.Logger(_version_1.version);
var Coder = /** @class */ (function () {
function Coder(name, type, localName, dynamic) {
this.name = name;
this.type = type;
this.localName = localName;
this.dynamic = dynamic;
}
Coder.prototype._throwError = function (message, value) {
logger.throwArgumentError(message, this.localName, value);
};
return Coder;
}());
exports.Coder = Coder;
var Writer = /** @class */ (function () {
function Writer(wordSize) {
properties_1.defineReadOnly(this, "wordSize", wordSize || 32);
this._data = bytes_1.arrayify([]);
this._padding = new Uint8Array(wordSize);
}
Object.defineProperty(Writer.prototype, "data", {
get: function () { return bytes_1.hexlify(this._data); },
enumerable: true,
configurable: true
});
Object.defineProperty(Writer.prototype, "length", {
get: function () { return this._data.length; },
enumerable: true,
configurable: true
});
Writer.prototype._writeData = function (data) {
this._data = bytes_1.concat([this._data, data]);
return data.length;
};
// Arrayish items; padded on the right to wordSize
Writer.prototype.writeBytes = function (value) {
var bytes = bytes_1.arrayify(value);
if (bytes.length % this.wordSize) {
bytes = bytes_1.concat([bytes, this._padding.slice(bytes.length % this.wordSize)]);
}
return this._writeData(bytes);
};
Writer.prototype._getValue = function (value) {
var bytes = bytes_1.arrayify(bignumber_1.BigNumber.from(value));
if (bytes.length > this.wordSize) {
logger.throwError("value out-of-bounds", logger_1.Logger.errors.BUFFER_OVERRUN, {
length: this.wordSize,
offset: bytes.length
});
}
if (bytes.length % this.wordSize) {
bytes = bytes_1.concat([this._padding.slice(bytes.length % this.wordSize), bytes]);
}
return bytes;
};
// BigNumberish items; padded on the left to wordSize
Writer.prototype.writeValue = function (value) {
return this._writeData(this._getValue(value));
};
Writer.prototype.writeUpdatableValue = function () {
var _this = this;
var offset = this.length;
this.writeValue(0);
return function (value) {
_this._data.set(_this._getValue(value), offset);
};
};
return Writer;
}());
exports.Writer = Writer;
var Reader = /** @class */ (function () {
function Reader(data, wordSize, coerceFunc) {
properties_1.defineReadOnly(this, "_data", bytes_1.arrayify(data));
properties_1.defineReadOnly(this, "wordSize", wordSize || 32);
properties_1.defineReadOnly(this, "_coerceFunc", coerceFunc);
this._offset = 0;
}
Object.defineProperty(Reader.prototype, "data", {
get: function () { return bytes_1.hexlify(this._data); },
enumerable: true,
configurable: true
});
Object.defineProperty(Reader.prototype, "consumed", {
get: function () { return this._offset; },
enumerable: true,
configurable: true
});
// The default Coerce function
Reader.coerce = function (name, value) {
var match = name.match("^u?int([0-9]+)$");
if (match && parseInt(match[1]) <= 48) {
value = value.toNumber();
}
return value;
};
Reader.prototype.coerce = function (name, value) {
if (this._coerceFunc) {
return this._coerceFunc(name, value);
}
return Reader.coerce(name, value);
};
Reader.prototype._peekBytes = function (offset, length) {
var alignedLength = Math.ceil(length / this.wordSize) * this.wordSize;
if (this._offset + alignedLength > this._data.length) {
logger.throwError("data out-of-bounds", logger_1.Logger.errors.BUFFER_OVERRUN, {
length: this._data.length,
offset: this._offset + alignedLength
});
}
return this._data.slice(this._offset, this._offset + alignedLength);
};
Reader.prototype.subReader = function (offset) {
return new Reader(this._data.slice(this._offset + offset), this.wordSize, this._coerceFunc);
};
Reader.prototype.readBytes = function (length) {
var bytes = this._peekBytes(0, length);
this._offset += bytes.length;
// @TODO: Make sure the length..end bytes are all 0?
return bytes.slice(0, length);
};
Reader.prototype.readValue = function () {
return bignumber_1.BigNumber.from(this.readBytes(this.wordSize));
};
return Reader;
}());
exports.Reader = Reader;

@ -1,6 +0,0 @@
import { Coder, Reader, Writer } from "./abstract-coder";
export declare class AddressCoder extends Coder {
constructor(localName: string);
encode(writer: Writer, value: string): number;
decode(reader: Reader): any;
}

@ -1,38 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var address_1 = require("@ethersproject/address");
var bytes_1 = require("@ethersproject/bytes");
var abstract_coder_1 = require("./abstract-coder");
var AddressCoder = /** @class */ (function (_super) {
__extends(AddressCoder, _super);
function AddressCoder(localName) {
return _super.call(this, "address", "address", localName, false) || this;
}
AddressCoder.prototype.encode = function (writer, value) {
try {
address_1.getAddress(value);
}
catch (error) {
this._throwError(error.message, value);
}
return writer.writeValue(value);
};
AddressCoder.prototype.decode = function (reader) {
return address_1.getAddress(bytes_1.hexZeroPad(reader.readValue().toHexString(), 20));
};
return AddressCoder;
}(abstract_coder_1.Coder));
exports.AddressCoder = AddressCoder;

@ -1,7 +0,0 @@
import { Coder, Reader, Writer } from "./abstract-coder";
export declare class AnonymousCoder extends Coder {
private coder;
constructor(coder: Coder);
encode(writer: Writer, value: any): number;
decode(reader: Reader): any;
}

@ -1,33 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var abstract_coder_1 = require("./abstract-coder");
// Clones the functionality of an existing Coder, but without a localName
var AnonymousCoder = /** @class */ (function (_super) {
__extends(AnonymousCoder, _super);
function AnonymousCoder(coder) {
var _this = _super.call(this, coder.name, coder.type, undefined, coder.dynamic) || this;
_this.coder = coder;
return _this;
}
AnonymousCoder.prototype.encode = function (writer, value) {
return this.coder.encode(writer, value);
};
AnonymousCoder.prototype.decode = function (reader) {
return this.coder.decode(reader);
};
return AnonymousCoder;
}(abstract_coder_1.Coder));
exports.AnonymousCoder = AnonymousCoder;

@ -1,10 +0,0 @@
import { Coder, Reader, Writer } from "./abstract-coder";
export declare function pack(writer: Writer, coders: Array<Coder>, values: Array<any>): number;
export declare function unpack(reader: Reader, coders: Array<Coder>): Array<any>;
export declare class ArrayCoder extends Coder {
readonly coder: Coder;
readonly length: number;
constructor(coder: Coder, length: number, localName: string);
encode(writer: Writer, value: Array<any>): number;
decode(reader: Reader): any;
}

@ -1,147 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var logger_1 = require("@ethersproject/logger");
var _version_1 = require("../_version");
var logger = new logger_1.Logger(_version_1.version);
var abstract_coder_1 = require("./abstract-coder");
var anonymous_1 = require("./anonymous");
function pack(writer, coders, values) {
if (Array.isArray(values)) {
// do nothing
}
else if (values && typeof (values) === "object") {
var arrayValues_1 = [];
coders.forEach(function (coder) {
arrayValues_1.push(values[coder.localName]);
});
values = arrayValues_1;
}
else {
logger.throwArgumentError("invalid tuple value", "tuple", values);
}
if (coders.length !== values.length) {
logger.throwArgumentError("types/value length mismatch", "tuple", values);
}
var staticWriter = new abstract_coder_1.Writer(writer.wordSize);
var dynamicWriter = new abstract_coder_1.Writer(writer.wordSize);
var updateFuncs = [];
coders.forEach(function (coder, index) {
var value = values[index];
if (coder.dynamic) {
// Get current dynamic offset (for the future pointer)
var dynamicOffset_1 = dynamicWriter.length;
// Encode the dynamic value into the dynamicWriter
coder.encode(dynamicWriter, value);
// Prepare to populate the correct offset once we are done
var updateFunc_1 = staticWriter.writeUpdatableValue();
updateFuncs.push(function (baseOffset) {
updateFunc_1(baseOffset + dynamicOffset_1);
});
}
else {
coder.encode(staticWriter, value);
}
});
// Backfill all the dynamic offsets, now that we know the static length
updateFuncs.forEach(function (func) { func(staticWriter.length); });
var length = writer.writeBytes(staticWriter.data);
length += writer.writeBytes(dynamicWriter.data);
return length;
}
exports.pack = pack;
function unpack(reader, coders) {
var values = [];
// A reader anchored to this base
var baseReader = reader.subReader(0);
// The amount of dynamic data read; to consume later to synchronize
var dynamicLength = 0;
coders.forEach(function (coder) {
var value = null;
if (coder.dynamic) {
var offset = reader.readValue();
var offsetReader = baseReader.subReader(offset.toNumber());
value = coder.decode(offsetReader);
dynamicLength += offsetReader.consumed;
}
else {
value = coder.decode(reader);
}
if (value != undefined) {
values.push(value);
}
});
// @TODO: get rid of this an see if it still works?
// Consume the dynamic components in the main reader
reader.readBytes(dynamicLength);
// Add any named parameters (i.e. tuples)
coders.forEach(function (coder, index) {
var name = coder.localName;
if (!name) {
return;
}
if (name === "length") {
name = "_length";
}
if (values[name] != null) {
return;
}
values[name] = values[index];
});
return values;
}
exports.unpack = unpack;
var ArrayCoder = /** @class */ (function (_super) {
__extends(ArrayCoder, _super);
function ArrayCoder(coder, length, localName) {
var _this = this;
var type = (coder.type + "[" + (length >= 0 ? length : "") + "]");
var dynamic = (length === -1 || coder.dynamic);
_this = _super.call(this, "array", type, localName, dynamic) || this;
_this.coder = coder;
_this.length = length;
return _this;
}
ArrayCoder.prototype.encode = function (writer, value) {
if (!Array.isArray(value)) {
this._throwError("expected array value", value);
}
var count = this.length;
//let result = new Uint8Array(0);
if (count === -1) {
count = value.length;
writer.writeValue(value.length);
}
logger.checkArgumentCount(count, value.length, "coder array" + (this.localName ? (" " + this.localName) : ""));
var coders = [];
for (var i = 0; i < value.length; i++) {
coders.push(this.coder);
}
return pack(writer, coders, value);
};
ArrayCoder.prototype.decode = function (reader) {
var count = this.length;
if (count === -1) {
count = reader.readValue().toNumber();
}
var coders = [];
for (var i = 0; i < count; i++) {
coders.push(new anonymous_1.AnonymousCoder(this.coder));
}
return reader.coerce(this.name, unpack(reader, coders));
};
return ArrayCoder;
}(abstract_coder_1.Coder));
exports.ArrayCoder = ArrayCoder;

@ -1,6 +0,0 @@
import { Coder, Reader, Writer } from "./abstract-coder";
export declare class BooleanCoder extends Coder {
constructor(localName: string);
encode(writer: Writer, value: boolean): number;
decode(reader: Reader): any;
}

@ -1,30 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var abstract_coder_1 = require("./abstract-coder");
var BooleanCoder = /** @class */ (function (_super) {
__extends(BooleanCoder, _super);
function BooleanCoder(localName) {
return _super.call(this, "bool", "bool", localName, false) || this;
}
BooleanCoder.prototype.encode = function (writer, value) {
return writer.writeValue(value ? 1 : 0);
};
BooleanCoder.prototype.decode = function (reader) {
return reader.coerce(this.type, !reader.readValue().isZero());
};
return BooleanCoder;
}(abstract_coder_1.Coder));
exports.BooleanCoder = BooleanCoder;

@ -1,10 +0,0 @@
import { Coder, Reader, Writer } from "./abstract-coder";
export declare class DynamicBytesCoder extends Coder {
constructor(type: string, localName: string);
encode(writer: Writer, value: any): number;
decode(reader: Reader): any;
}
export declare class BytesCoder extends DynamicBytesCoder {
constructor(localName: string);
decode(reader: Reader): any;
}

@ -1,45 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var bytes_1 = require("@ethersproject/bytes");
var abstract_coder_1 = require("./abstract-coder");
var DynamicBytesCoder = /** @class */ (function (_super) {
__extends(DynamicBytesCoder, _super);
function DynamicBytesCoder(type, localName) {
return _super.call(this, type, type, localName, true) || this;
}
DynamicBytesCoder.prototype.encode = function (writer, value) {
value = bytes_1.arrayify(value);
var length = writer.writeValue(value.length);
length += writer.writeBytes(value);
return length;
};
DynamicBytesCoder.prototype.decode = function (reader) {
return reader.readBytes(reader.readValue().toNumber());
};
return DynamicBytesCoder;
}(abstract_coder_1.Coder));
exports.DynamicBytesCoder = DynamicBytesCoder;
var BytesCoder = /** @class */ (function (_super) {
__extends(BytesCoder, _super);
function BytesCoder(localName) {
return _super.call(this, "bytes", localName) || this;
}
BytesCoder.prototype.decode = function (reader) {
return reader.coerce(this.name, bytes_1.hexlify(_super.prototype.decode.call(this, reader)));
};
return BytesCoder;
}(DynamicBytesCoder));
exports.BytesCoder = BytesCoder;

@ -1,8 +0,0 @@
import { BytesLike } from "@ethersproject/bytes";
import { Coder, Reader, Writer } from "./abstract-coder";
export declare class FixedBytesCoder extends Coder {
readonly size: number;
constructor(size: number, localName: string);
encode(writer: Writer, value: BytesLike): number;
decode(reader: Reader): any;
}

@ -1,40 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var bytes_1 = require("@ethersproject/bytes");
var abstract_coder_1 = require("./abstract-coder");
// @TODO: Merge this with bytes
var FixedBytesCoder = /** @class */ (function (_super) {
__extends(FixedBytesCoder, _super);
function FixedBytesCoder(size, localName) {
var _this = this;
var name = "bytes" + String(size);
_this = _super.call(this, name, name, localName, false) || this;
_this.size = size;
return _this;
}
FixedBytesCoder.prototype.encode = function (writer, value) {
var data = bytes_1.arrayify(value);
if (data.length !== this.size) {
this._throwError("incorrect data length", value);
}
return writer.writeBytes(data);
};
FixedBytesCoder.prototype.decode = function (reader) {
return reader.coerce(this.name, bytes_1.hexlify(reader.readBytes(this.size)));
};
return FixedBytesCoder;
}(abstract_coder_1.Coder));
exports.FixedBytesCoder = FixedBytesCoder;

@ -1,6 +0,0 @@
import { Coder, Reader, Writer } from "./abstract-coder";
export declare class NullCoder extends Coder {
constructor(localName: string);
encode(writer: Writer, value: any): number;
decode(reader: Reader): any;
}

@ -1,34 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var abstract_coder_1 = require("./abstract-coder");
var NullCoder = /** @class */ (function (_super) {
__extends(NullCoder, _super);
function NullCoder(localName) {
return _super.call(this, "null", "", localName, false) || this;
}
NullCoder.prototype.encode = function (writer, value) {
if (value != null) {
this._throwError("not null", value);
}
return writer.writeBytes([]);
};
NullCoder.prototype.decode = function (reader) {
reader.readBytes(0);
return reader.coerce(this.name, null);
};
return NullCoder;
}(abstract_coder_1.Coder));
exports.NullCoder = NullCoder;

@ -1,9 +0,0 @@
import { BigNumberish } from "@ethersproject/bignumber";
import { Coder, Reader, Writer } from "./abstract-coder";
export declare class NumberCoder extends Coder {
readonly size: number;
readonly signed: boolean;
constructor(size: number, signed: boolean, localName: string);
encode(writer: Writer, value: BigNumberish): number;
decode(reader: Reader): any;
}

@ -1,57 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var bignumber_1 = require("@ethersproject/bignumber");
var constants_1 = require("@ethersproject/constants");
var abstract_coder_1 = require("./abstract-coder");
var NumberCoder = /** @class */ (function (_super) {
__extends(NumberCoder, _super);
function NumberCoder(size, signed, localName) {
var _this = this;
var name = ((signed ? "int" : "uint") + (size * 8));
_this = _super.call(this, name, name, localName, false) || this;
_this.size = size;
_this.signed = signed;
return _this;
}
NumberCoder.prototype.encode = function (writer, value) {
var v = bignumber_1.BigNumber.from(value);
// Check bounds are safe for encoding
var maxUintValue = constants_1.MaxUint256.maskn(writer.wordSize * 8);
if (this.signed) {
var bounds = maxUintValue.maskn(this.size * 8 - 1);
if (v.gt(bounds) || v.lt(bounds.add(constants_1.One).mul(constants_1.NegativeOne))) {
this._throwError("value out-of-bounds", value);
}
}
else if (v.lt(constants_1.Zero) || v.gt(maxUintValue.maskn(this.size * 8))) {
this._throwError("value out-of-bounds", value);
}
v = v.toTwos(this.size * 8).maskn(this.size * 8);
if (this.signed) {
v = v.fromTwos(this.size * 8).toTwos(8 * writer.wordSize);
}
return writer.writeValue(v);
};
NumberCoder.prototype.decode = function (reader) {
var value = reader.readValue().maskn(this.size * 8);
if (this.signed) {
value = value.fromTwos(this.size * 8);
}
return reader.coerce(this.name, value);
};
return NumberCoder;
}(abstract_coder_1.Coder));
exports.NumberCoder = NumberCoder;

@ -1,7 +0,0 @@
import { Reader, Writer } from "./abstract-coder";
import { DynamicBytesCoder } from "./bytes";
export declare class StringCoder extends DynamicBytesCoder {
constructor(localName: string);
encode(writer: Writer, value: any): number;
decode(reader: Reader): any;
}

@ -1,31 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var strings_1 = require("@ethersproject/strings");
var bytes_1 = require("./bytes");
var StringCoder = /** @class */ (function (_super) {
__extends(StringCoder, _super);
function StringCoder(localName) {
return _super.call(this, "string", localName) || this;
}
StringCoder.prototype.encode = function (writer, value) {
return _super.prototype.encode.call(this, writer, strings_1.toUtf8Bytes(value));
};
StringCoder.prototype.decode = function (reader) {
return strings_1.toUtf8String(_super.prototype.decode.call(this, reader));
};
return StringCoder;
}(bytes_1.DynamicBytesCoder));
exports.StringCoder = StringCoder;

@ -1,7 +0,0 @@
import { Coder, Reader, Writer } from "./abstract-coder";
export declare class TupleCoder extends Coder {
readonly coders: Array<Coder>;
constructor(coders: Array<Coder>, localName: string);
encode(writer: Writer, value: Array<any>): number;
decode(reader: Reader): any;
}

@ -1,43 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var abstract_coder_1 = require("./abstract-coder");
var array_1 = require("./array");
var TupleCoder = /** @class */ (function (_super) {
__extends(TupleCoder, _super);
function TupleCoder(coders, localName) {
var _this = this;
var dynamic = false;
var types = [];
coders.forEach(function (coder) {
if (coder.dynamic) {
dynamic = true;
}
types.push(coder.type);
});
var type = ("tuple(" + types.join(",") + ")");
_this = _super.call(this, "tuple", type, localName, dynamic) || this;
_this.coders = coders;
return _this;
}
TupleCoder.prototype.encode = function (writer, value) {
return array_1.pack(writer, this.coders, value);
};
TupleCoder.prototype.decode = function (reader) {
return reader.coerce(this.name, array_1.unpack(reader, this.coders));
};
return TupleCoder;
}(abstract_coder_1.Coder));
exports.TupleCoder = TupleCoder;