navio-blsct
Version:
TypeScript bindings for the `libblsct` library used by the [Navio](https://nav.io/) blockchain to construct confidential transactions based on the BLS12-381 curve.
47 lines (46 loc) • 1.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TokenId = void 0;
const blsct_1 = require("./blsct");
const managedObj_1 = require("./managedObj");
class TokenId extends managedObj_1.ManagedObj {
constructor(obj) {
super(obj);
}
static default() {
const rv = (0, blsct_1.genDefaultTokenId)();
return new TokenId(rv.value);
}
static fromToken(token) {
const rv = (0, blsct_1.genTokenId)(token);
const tokenId = TokenId.fromObj(rv.value);
(0, blsct_1.freeObj)(rv);
return tokenId;
}
static fromTokenAndSubid(token, subid) {
const rv = (0, blsct_1.genTokenIdWithSubid)(token, subid);
const tokenId = TokenId.fromObj(rv.value);
(0, blsct_1.freeObj)(rv);
return tokenId;
}
getToken() {
return (0, blsct_1.getTokenIdToken)(this.value());
}
getSubid() {
return (0, blsct_1.getTokenIdSubid)(this.value());
}
equals(other) {
return this.getToken() === other.getToken() &&
this.getSubid() === other.getSubid();
}
value() {
return (0, blsct_1.castToTokenId)(this.obj);
}
serialize() {
return (0, blsct_1.serializeTokenId)(this.value());
}
static deserialize(hex) {
return TokenId._deserialize(hex, blsct_1.deserializeTokenId);
}
}
exports.TokenId = TokenId;