UNPKG

@mysten/suins

Version:
45 lines (43 loc) 1.5 kB
import { normalizeSuiNSName } from "@mysten/sui/utils"; //#region src/helpers.ts function isSubName(name) { return normalizeSuiNSName(name, "dot").split(".").length > 2; } /** * Checks if a name is a nested subname. * A nested subdomain is a subdomain that is a subdomain of another subdomain. * @param name The name to check (e.g test.example.sub.sui) */ function isNestedSubName(name) { return normalizeSuiNSName(name, "dot").split(".").length > 3; } /** * The years must be between 1 and 5. */ function validateYears(years) { if (!(years > 0 && years < 6)) throw new Error("Years must be between 1 and 5"); } function zeroCoin(tx, type) { return tx.moveCall({ target: "0x2::coin::zero", typeArguments: [type] }); } function getConfigType(suinsPackageV1, innerType) { return `${suinsPackageV1}::suins::ConfigKey<${innerType}>`; } function getDomainType(suinsPackageV1) { return `${suinsPackageV1}::domain::Domain`; } function getPricelistConfigType(suinsPackageId) { return `${suinsPackageId}::pricing_config::PricingConfig`; } function getRenewalPricelistConfigType(suinsPackageId) { return `${suinsPackageId}::pricing_config::RenewalConfig`; } function getCoinDiscountConfigType(paymentPackageId) { return `${paymentPackageId}::payments::PaymentsConfig`; } //#endregion export { getCoinDiscountConfigType, getConfigType, getDomainType, getPricelistConfigType, getRenewalPricelistConfigType, isNestedSubName, isSubName, validateYears, zeroCoin }; //# sourceMappingURL=helpers.mjs.map