@aeternity/aepp-calldata
Version:
Aeternity data serialization library
35 lines (33 loc) • 1.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _TypeResolver = _interopRequireDefault(require("../TypeResolver.cjs"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
class TypeResolver {
constructor() {
this._internalResolver = new _TypeResolver.default();
}
/**
* Resolves ACI type format to opaque (internal) type structure
* to allow usage of other library APIs that needs type information.
* The opaque type shouldn't be used for anything else (including storing) than passing it
* as library argument as its structure is not guaranteed.
*
* @example
* const type = resolver.resolveType({map: ['int', 'bool']})
* const encoded = ContractByteArrayEncoder.encode(new Map([[7n, false]]), type)
* console.log(`Encoded data: ${encoded}`)
* // Outputs:
* // Encoded data: cb_LwEOfzGit9U=
*
* @param {object} type - The type information in ACI format
* @param {object} vars - Additional type variables, templates etc.
* @returns {object} Opaque type information structure
*/
resolveType(type, vars = {}) {
return this._internalResolver.resolveType(type, vars);
}
}
var _default = exports.default = TypeResolver;