UNPKG

@stricahq/typhonjs

Version:

Pure JS Cardano Wallet library

34 lines (33 loc) 1.37 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.EnterpriseAddress = void 0; /* eslint-disable no-bitwise */ const buffer_1 = require("buffer"); const types_1 = require("../types"); const ShelleyTypeAddress_1 = __importDefault(require("./ShelleyTypeAddress")); class EnterpriseAddress extends ShelleyTypeAddress_1.default { constructor(networkId, paymentCredential) { super(networkId, paymentCredential); this.computeHex(); } computeHex() { let payload = 96; if (this._paymentCredential.type === types_1.HashType.ADDRESS) { // set 4th bit to 0, which is set by default } else if (this._paymentCredential.type === types_1.HashType.SCRIPT) { const mask = 1 << 4; payload |= mask; } payload |= this.networkId; const address = `${payload.toString(16).padStart(2, "0")}${this._paymentCredential.hash.toString("hex")}`; this.addressHex = address; this.addressBytes = buffer_1.Buffer.from(address, "hex"); this.addressBech32 = this.computeBech32(this.addressBytes); } } exports.EnterpriseAddress = EnterpriseAddress; exports.default = EnterpriseAddress;