@roochnetwork/rooch-sdk
Version:
55 lines (54 loc) • 1.94 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var rooch_exports = {};
__export(rooch_exports, {
RoochAddress: () => RoochAddress
});
module.exports = __toCommonJS(rooch_exports);
var import_base = require("@scure/base");
var import_utils = require("../utils/index.js");
var import_util = require("./util.js");
var import_address = require("./address.js");
class RoochAddress extends import_address.Address {
constructor(input) {
let bytes;
if (typeof input === "string") {
if ((0, import_utils.isHex)(input)) {
const normalizeAddress = (0, import_util.normalizeRoochAddress)(input);
bytes = (0, import_utils.fromHEX)(normalizeAddress);
} else {
bytes = import_base.bech32m.decodeToBytes(input).bytes;
}
} else {
bytes = input;
}
super(import_base.bech32m.encode(import_address.ROOCH_BECH32_PREFIX, import_base.bech32m.toWords(bytes), false));
this.bytes = bytes;
}
toBytes() {
return this.bytes;
}
toHexAddress() {
return (0, import_util.normalizeRoochAddress)((0, import_utils.toHEX)(this.bytes));
}
toBech32Address() {
return this.rawAddress;
}
}
//# sourceMappingURL=rooch.js.map