@hiero-ledger/sdk
Version:
77 lines (69 loc) • 1.78 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
// SPDX-License-Identifier: Apache-2.0
/**
* @namespace proto
* @typedef {import("@hiero-ledger/proto").proto.TokenType} HieroProto.proto.TokenType
*/
class TokenType {
/**
* @hideconstructor
* @internal
* @param {number} code
*/
constructor(code) {
/** @readonly */
this._code = code;
Object.freeze(this);
}
/**
* @returns {string}
*/
toString() {
switch (this) {
case TokenType.FungibleCommon:
return "FUNGIBLE_COMMON";
case TokenType.NonFungibleUnique:
return "NON_FUNGIBLE_UNIQUE";
default:
return `UNKNOWN (${this._code})`;
}
}
/**
* @internal
* @param {number} code
* @returns {TokenType}
*/
static _fromCode(code) {
switch (code) {
case 0:
return TokenType.FungibleCommon;
case 1:
return TokenType.NonFungibleUnique;
}
throw new Error(`(BUG) TokenType.fromCode() does not handle code: ${code}`);
}
/**
* @returns {HieroProto.proto.TokenType}
*/
valueOf() {
return this._code;
}
}
/**
* Interchangeable value with one another, where any quantity of them has the
* same value as another equal quantity if they are in the same class. Share
* a single set of properties, not distinct from one another. Simply represented
* as a balance or quantity to a given Hedera account.
*/
exports.default = TokenType;
TokenType.FungibleCommon = new TokenType(0);
/**
* Unique, not interchangeable with other tokens of the same type as they
* typically have different values. Individually traced and can carry unique
* properties (e.g. serial number).
*/
TokenType.NonFungibleUnique = new TokenType(1);