@meshsdk/mesh-csl
Version:
Cardano Off-chain Code APIs built on cardano-serialization-lib
65 lines (64 loc) • 1.59 kB
JavaScript
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable max-classes-per-file */
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseBlueprintDefinition = exports.Constructor = exports.Int = exports.ByteArray = void 0;
class ByteArray {
constructor(bytes) {
this.bytes = '';
if (bytes)
this.bytes = bytes;
}
toObject() {
return {
bytes: this.bytes,
};
}
}
exports.ByteArray = ByteArray;
class Int {
constructor(int) {
this.int = 0;
if (int)
this.int = int;
}
toObject() {
return {
int: this.int,
};
}
}
exports.Int = Int;
class Constructor {
constructor(conStr, fields) {
this.conStr = 0;
this.fields = [];
if (conStr)
this.conStr = conStr;
if (fields)
this.fields = fields;
}
toObject() {
return {
constructor: this.conStr,
fields: this.fields,
};
}
}
exports.Constructor = Constructor;
const parseBlueprintDefinition = (item, args = []) => {
switch (item.dataType) {
case 'bytes':
return new ByteArray(...args);
case 'integer':
return new Int(...args);
// case 'constructor':
// return Constructor;
default:
throw new Error(`Unknown data type: ${item.dataType}`);
}
};
exports.parseBlueprintDefinition = parseBlueprintDefinition;
// export class MeshBlueprint {
// constructor() {}
// }
;