@airgap/aeternity
Version:
The @airgap/aeternity is an Aeternity implementation of the ICoinProtocol interface from @airgap/coinlib-core.
24 lines • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertSignature = void 0;
var coinlib_core_1 = require("@airgap/coinlib-core");
var errors_1 = require("@airgap/coinlib-core/errors");
var module_kit_1 = require("@airgap/module-kit");
var convert_1 = require("./convert");
var SIG_PREFIX = 'sg_';
function convertSignature(signature, targetFormat) {
if (signature.format === targetFormat) {
return signature;
}
switch (signature.format) {
case 'encoded':
return (0, module_kit_1.newSignature)((0, convert_1.convertEncodedBytesString)(SIG_PREFIX, signature.value, targetFormat), targetFormat);
case 'hex':
return (0, module_kit_1.newSignature)((0, convert_1.convertHexBytesString)(SIG_PREFIX, signature.value, targetFormat), targetFormat);
default:
(0, coinlib_core_1.assertNever)(signature.format);
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.AETERNITY, 'Unsupported signature format.');
}
}
exports.convertSignature = convertSignature;
//# sourceMappingURL=signature.js.map