@mysten/suins
Version:
76 lines (75 loc) • 2.54 kB
text/typescript
import { CoinTypeDiscount, NameRecord, PackageInfo, SuinsClientConfig, SuinsPriceList } from "./types.mjs";
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
import { ClientWithCoreApi, SuiClientTypes } from "@mysten/sui/client";
//#region src/suins-client.d.ts
type SuinsExtensionOptions<Name extends string = 'suins'> = {
name?: Name;
packageInfo?: PackageInfo;
};
/**
* Creates a SuiNS client extension that can be used with `client.$extend()`.
*
* @example
* ```ts
* import { SuiJsonRpcClient, getJsonRpcFullnodeUrl } from '@mysten/sui/jsonRpc';
* import { suins } from '@mysten/suins';
*
* const client = new SuiJsonRpcClient({
* url: getJsonRpcFullnodeUrl('mainnet'),
* network: 'mainnet',
* }).$extend(suins());
*
* const nameRecord = await client.suins.getNameRecord('example.sui');
* ```
*/
declare function suins<const Name extends string = 'suins'>({
name,
packageInfo
}?: SuinsExtensionOptions<Name>): {
name: Name;
register: (client: ClientWithCoreApi) => SuinsClient;
};
declare class SuinsClient {
client: ClientWithCoreApi;
network: SuiClientTypes.Network;
config: PackageInfo;
constructor(config: SuinsClientConfig);
/**
* Returns the price list for SuiNS names in the base asset.
*/
getPriceList(): Promise<SuinsPriceList>;
/**
* Returns the renewal price list for SuiNS names in the base asset.
*/
getRenewalPriceList(): Promise<SuinsPriceList>;
/**
* Returns the coin discount list for SuiNS names.
*/
getCoinTypeDiscount(): Promise<CoinTypeDiscount>;
getNameRecord(name: string): Promise<NameRecord | null>;
/**
* Calculates the registration or renewal price for an SLD (Second Level Domain).
* It expects a domain name, the number of years and a `SuinsPriceList` object,
* as returned from `suinsClient.getPriceList()` function, or `suins.getRenewalPriceList()` function.
*
* It throws an error:
* 1. if the name is a subdomain
* 2. if the name is not a valid SuiNS name
* 3. if the years are not between 1 and 5
*/
calculatePrice({
name,
years,
isRegistration
}: {
name: string;
years: number;
isRegistration?: boolean;
}): Promise<number>;
getPriceInfoObject(tx: Transaction, feed: string, feeCoin?: TransactionObjectArgument): Promise<string[]>;
getPythBaseUpdateFee(): Promise<number>;
getObjectType(objectId: string): Promise<string>;
}
//#endregion
export { SuinsClient, SuinsExtensionOptions, suins };
//# sourceMappingURL=suins-client.d.mts.map