UNPKG

@stricahq/typhonjs

Version:

Pure JS Cardano Wallet library

35 lines (34 loc) 1.4 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.PointerAddress = void 0; /* eslint-disable no-bitwise */ const buffer_1 = require("buffer"); const types_1 = require("../types"); const ShelleyTypeAddress_1 = __importDefault(require("./ShelleyTypeAddress")); class PointerAddress extends ShelleyTypeAddress_1.default { constructor(networkId, paymentCredential, vlq) { super(networkId, paymentCredential); this._vlq = vlq; this.computeHex(); } computeHex() { let payload = 64; 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._vlq}`; this.addressHex = address; this.addressBytes = buffer_1.Buffer.from(address, "hex"); this.addressBech32 = this.computeBech32(this.addressBytes); } } exports.PointerAddress = PointerAddress; exports.default = PointerAddress;