@iota/iota-names-sdk
Version:
IOTA-Names SDK
72 lines (71 loc) • 3.08 kB
TypeScript
import { IotaGraphQLClient } from '@iota/iota-sdk/graphql';
import type { Coupon, CouponHouse, IotaNamesClientConfig, IotaNamesCoreConfig, IotaNamesPriceList, IotaNamesSubnamesConfig, NameRecord, PackageInfo } from './types.js';
export declare class IotaNamesClient {
graphQlClient: IotaGraphQLClient;
config: PackageInfo;
constructor(config: IotaNamesClientConfig);
isMethodSupported(packageId: string, module: string, functionName: string): Promise<boolean>;
/**
* Get the corresponding address for the given package.
* Sometimes new versions might contain new types,
* so its important to use the package they were created on when reading them in e.g GraphQL.
*
* - If the package does not have any versioning then the value is returned directly.
* - If there are multiple versions available then the version passed as argument will be used to retrieve the package.
* - If none of above returned a version then the latest will be picked.
*
* @argument {string} key - Package key.
* @argument {string} [version=v1] - Optionally specify your desired version.
*/
getPackage(key: keyof PackageInfo, version?: `v${number}` | 'latest'): string;
/**
* Returns the core config of IOTA Names.
*/
getCoreConfig(): Promise<IotaNamesCoreConfig>;
/**
* Returns the subnames config of IOTA Names.
*/
getSubnamesConfig(): Promise<IotaNamesSubnamesConfig>;
/**
* Returns the price list for IOTA names in the base asset.
*/
getPriceList(): Promise<IotaNamesPriceList>;
/**
* Returns the renewal price list for IOTA names in the base asset.
*/
getRenewalPriceList(): Promise<IotaNamesPriceList>;
getPublicName(address: string): Promise<string | null>;
getDenyListTableIds(): Promise<{
reservedTableId: string | null;
blockedTableId: string | null;
}>;
/**
* Gets the full reserved/blocked list
*/
getRestrictedList(type: 'reserved' | 'blocked'): Promise<string[]>;
getNameRecord(name: string): Promise<NameRecord | null>;
getCouponHouse(): Promise<CouponHouse>;
resolveCoupon(couponCode: string): Promise<Coupon | null>;
/**
* Calculates the registration or renewal price for an SLN (Second Level Name).
* It expects a name, the number of years and a `IotaNamesPriceList` object,
* as returned from `iotaNamesClient.getPriceList()` function, or `iotaNames.getRenewalPriceList()` function.
*
* It throws an error:
* 1. if the name is a subname
* 2. if the name is not a valid IOTA name
* 3. if the years are not between 1 and 5
*/
calculatePrice({ name, years, isRegistration, }: {
name: string;
years: number;
isRegistration?: boolean;
}): Promise<number>;
calculateDiscountedPrice({ coupons, name, years, isRegistration, address, }: {
coupons: Coupon[] | string[];
name: string;
years: number;
isRegistration?: boolean;
address?: string;
}): Promise<number>;
}