airgap-coin-lib
Version:
The airgap-coin-lib is a protocol agnostic library to prepare, sign and broadcast cryptocurrency transactions.
52 lines • 2.79 kB
JavaScript
;
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 SCALEDecoder_1 = require("../../../../scale/SCALEDecoder");
var SCALEClass_1 = require("../../../../scale/type/SCALEClass");
var SCALEString_1 = require("../../../../scale/type/SCALEString");
var MetadataV11StorageEntryType_1 = require("./MetadataV11StorageEntryType");
var StorageEntryModifier;
(function (StorageEntryModifier) {
StorageEntryModifier[StorageEntryModifier["Optional"] = 0] = "Optional";
StorageEntryModifier[StorageEntryModifier["Default"] = 1] = "Default";
})(StorageEntryModifier || (StorageEntryModifier = {}));
var MetadataV11StorageEntry = /** @class */ (function (_super) {
__extends(MetadataV11StorageEntry, _super);
function MetadataV11StorageEntry(name, modifier, type, defaultValue, docs) {
var _this = _super.call(this) || this;
_this.name = name;
_this.modifier = modifier;
_this.type = type;
_this.defaultValue = defaultValue;
_this.docs = docs;
_this.scaleFields = [_this.name, _this.modifier, _this.type, _this.defaultValue];
return _this;
}
MetadataV11StorageEntry.decode = function (network, raw) {
var decoder = new SCALEDecoder_1.SCALEDecoder(network, raw);
var name = decoder.decodeNextString();
var modifier = decoder.decodeNextEnum(function (value) { return StorageEntryModifier[StorageEntryModifier[value]]; });
var type = decoder.decodeNextObject(MetadataV11StorageEntryType_1.MetadataV11StorageEntryType.decode);
var defaultValue = decoder.decodeNextBytes();
var docs = decoder.decodeNextArray(function (_, hex) { return SCALEString_1.SCALEString.decode(hex); });
return {
bytesDecoded: name.bytesDecoded + modifier.bytesDecoded + type.bytesDecoded + defaultValue.bytesDecoded + docs.bytesDecoded,
decoded: new MetadataV11StorageEntry(name.decoded, modifier.decoded, type.decoded, defaultValue.decoded, docs.decoded)
};
};
return MetadataV11StorageEntry;
}(SCALEClass_1.SCALEClass));
exports.MetadataV11StorageEntry = MetadataV11StorageEntry;
//# sourceMappingURL=MetadataV11StorageEntry.js.map