UNPKG

@ar.io/sdk

Version:

[![codecov](https://codecov.io/gh/ar-io/ar-io-sdk/graph/badge.svg?token=7dXKcT7dJy)](https://codecov.io/gh/ar-io/ar-io-sdk)

348 lines (347 loc) 15.2 kB
import { AntReadOptions, AoANTHandler, AoANTInfo, AoANTRead, AoANTRecord, AoANTSetBaseNameRecordParams, AoANTSetUndernameRecordParams, AoANTState, AoANTVersionsRead, AoANTWrite, SortedANTRecords } from '../types/ant.js'; import { AoMessageResult, ProcessConfiguration, WalletAddress, WithSigner, WriteOptions } from '../types/index.js'; import { AOProcess } from './index.js'; type ANTConfigOptionalStrict = Required<ProcessConfiguration> & { strict?: boolean; }; type ANTConfigNoSigner = ANTConfigOptionalStrict; type ANTConfigWithSigner = WithSigner<ANTConfigOptionalStrict>; export declare class ANT { static versions: AoANTVersionsRead; static init(config: ANTConfigNoSigner): AoANTRead; static init(config: ANTConfigWithSigner): AoANTWrite; } export declare class AoANTReadable implements AoANTRead { protected process: AOProcess; readonly processId: string; private strict; constructor(config: ANTConfigOptionalStrict); getState({ strict }?: AntReadOptions): Promise<AoANTState>; getInfo({ strict }?: AntReadOptions): Promise<AoANTInfo>; /** * Returns the TX ID of the logo set for the ANT. */ getLogo(): Promise<string>; /** * @param undername @type {string} The domain name. * @returns {Promise<ANTRecord>} The record of the undername domain. * @example * Get the current record * ```ts * ant.getRecord({ undername: "john" }); * ``` */ getRecord({ undername }: { undername: string; }, { strict }?: AntReadOptions): Promise<AoANTRecord>; /** * @returns {Promise<SortedANTRecords>} All the undernames managed by the ANT. * @example * Get the current records * ```ts * ant.getRecords(); * ```` */ getRecords({ strict }?: AntReadOptions): Promise<SortedANTRecords>; /** * @returns {Promise<string>} The owner of the ANT. * @example * Get the current owner * ```ts * ant.getOwner(); * ``` */ getOwner({ strict }?: AntReadOptions): Promise<string>; /** * @returns {Promise<string[]>} The controllers of the ANT. * @example * Get the controllers of the ANT. * ```ts * ant.getControllers(); * ``` */ getControllers({ strict }?: AntReadOptions): Promise<WalletAddress[]>; /** * @returns {Promise<string>} The name of the ANT (not the same as ArNS name). * @example * Get the current name * ```ts * ant.getName(); * ``` */ getName({ strict }?: AntReadOptions): Promise<string>; /** * @returns {Promise<string>} The name of the ANT (not the same as ArNS name). * @example * The current ticker of the ANT. * ```ts * ant.getTicker(); * ``` */ getTicker({ strict }?: AntReadOptions): Promise<string>; /** * @returns {Promise<Record<WalletAddress, number>>} The balances of the ANT * @example * The current balances of the ANT. * ```ts * ant.getBalances(); * ``` */ getBalances({ strict }?: AntReadOptions): Promise<Record<string, number>>; /** * @param address @type {string} The address of the account you want the balance of. * @returns {Promise<number>} The balance of the provided address * @example * The current balance of the address. * ```ts * ant.getBalance({ address }); * ``` */ getBalance({ address }: { address: string; }, { strict }?: AntReadOptions): Promise<number>; /** * @returns {Promise<AoANTHandler[]>} The handlers of the ANT. * @example * Get the handlers of the ANT. * ```ts * const handlers = await ant.getHandlers(); * ``` */ getHandlers(): Promise<AoANTHandler[]>; } export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite { private signer; constructor({ signer, ...config }: WithSigner<Required<ProcessConfiguration>> & { strict?: boolean; }); /** * @param target @type {string} The address of the account you want to transfer the ANT to. * @returns {Promise<AoMessageResult>} The result of the interaction. * @example * ```ts * ant.transfer({ target: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" }); * ``` */ transfer({ target }: { target: string; }, options?: WriteOptions): Promise<AoMessageResult>; /** * @param controller @type {string} The address of the account you want to set as a controller. * @returns {Promise<AoMessageResult>} The result of the interaction. * @example * ```ts * ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" }); * ``` */ addController({ controller, }: { controller: string; }, options?: WriteOptions): Promise<AoMessageResult>; /** * @param controller @type {string} The address of the account you want to remove from the controllers list * @returns {Promise<AoMessageResult>} The result of the interaction. * @example * ```ts * ant.removeController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" }); * ``` */ removeController({ controller, }: { controller: string; }, options?: WriteOptions): Promise<AoMessageResult>; /** * Sets the transactionId and ttlSeconds of a record (for updating the top level name, use undername "@".) * * @deprecated Use setUndernameRecord instead for undernames, and setBaseNameRecord instead for the top level name (e.g. "@") * @param undername @type {string} The record you want to set the transactionId and ttlSeconds of. * @param transactionId @type {string} The transactionId of the record. * @param ttlSeconds @type {number} The time to live of the record. * @returns {Promise<AoMessageResult>} The result of the interaction. */ setRecord({ undername, transactionId, ttlSeconds }: AoANTSetUndernameRecordParams, options?: WriteOptions): Promise<AoMessageResult>; /** * Sets the top level name of the ANT. This is the name that will be used to resolve the ANT (e.g. ardrive.ar.io) * * @param transactionId @type {string} The transactionId of the record. * @param ttlSeconds @type {number} The time to live of the record. * @returns {Promise<AoMessageResult>} The result of the interaction. * @example * ```ts * ant.setBaseNameRecord({ transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM", ttlSeconds: 100 }); // ardrive.ar.io will resolve to the provided transaction id and be cached for 100 seconds by clients * ``` */ setBaseNameRecord({ transactionId, ttlSeconds }: AoANTSetBaseNameRecordParams, options?: WriteOptions): Promise<AoMessageResult>; /** * Adds or updates an undername of the ANT. An undername is appended to the base name of the ANT (e.g. ardrive.ar.io) to form a fully qualified name (e.g. dapp_ardrive.ar.io) * * @param undername @type {string} The undername of the ANT. * @param transactionId @type {string} The transactionId of the record. * @param ttlSeconds @type {number} The time to live of the record. * @returns {Promise<AoMessageResult>} The result of the interaction. * @example * ```ts * ant.setUndernameRecord({ undername: "dapp", transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM", ttlSeconds: 100 }); // dapp_ardrive.ar.io will resolve to the provided transaction id and be cached for 100 seconds by clients * ``` */ setUndernameRecord({ undername, transactionId, ttlSeconds }: AoANTSetUndernameRecordParams, options?: WriteOptions): Promise<AoMessageResult>; /** * Removes an undername from the ANT. This will remove the undername from the ANT. * * @param undername @type {string} The undername you want to remove. * @returns {Promise<AoMessageResult>} The result of the interaction. * @example * ```ts * ant.removeUndernameRecord({ undername: "dapp" }); // removes dapp_ardrive.ar.io * ``` */ removeUndernameRecord({ undername, }: { undername: string; }): Promise<AoMessageResult>; /** * Removes a record from the ANT. This will remove the record from the ANT. If '@' is provided, the top level name will be removed. * * @deprecated Use removeUndernameRecord instead. * @param undername @type {string} The record you want to remove. * @returns {Promise<AoMessageResult>} The result of the interaction. * @example * ```ts * ant.removeRecord({ undername: "dapp" }); // removes dapp_ardrive.ar.io * ``` */ removeRecord({ undername, }: { undername: string; }, options?: WriteOptions): Promise<AoMessageResult>; /** * Sets the ticker of the ANT. This is the abbreviation displayed in ecosystem apps. * * @param ticker @type {string} Sets the ANT Ticker. * @returns {Promise<AoMessageResult>} The result of the interaction. * @example * ```ts * ant.setTicker({ ticker: "KAPOW" }); * ``` */ setTicker({ ticker }: { ticker: string; }, options?: WriteOptions): Promise<AoMessageResult>; /** * Sets the name of the ANT. This is the display name of the ANT. This is NOT the base name record. * * @param name @type {string} Sets the Name of the ANT. * @returns {Promise<AoMessageResult>} The result of the interaction. * @example * ```ts * ant.setName({ name: "test" }); // results in the resolution of `test_<apexName>.ar.io` * ``` */ setName({ name }: { name: string; }, options?: WriteOptions): Promise<AoMessageResult>; /** * Sets the description of the ANT. This is the description of the ANT displayed in ecosystem apps. * * @param description @type {string} Sets the ANT Description. * @returns {Promise<AoMessageResult>} The result of the interaction. * @example * ```ts * ant.setDescription({ description: "This name is used for the ArDrive" }); * ``` */ setDescription({ description }: { description: string; }, options?: WriteOptions): Promise<AoMessageResult>; /** * Sets the keywords of the ANT. This is the keywords of the ANT displayed in ecosystem apps. * * @param keywords @type {string[]} Sets the ANT Keywords. * @returns {Promise<AoMessageResult>} The result of the interaction. * @example * ```ts * ant.setKeywords({ keywords: ['keyword1', 'keyword2', 'keyword3']}); * ``` */ setKeywords({ keywords }: { keywords: string[]; }, options?: WriteOptions): Promise<AoMessageResult>; /** * Sets the logo of the ANT. This is the logo of the ANT displayed in ecosystem apps. Additionally, this logo is displayed for any primary names affiliated with the ANT. * * @param txId @type {string} - Arweave transaction id of the logo we want to set * @param options @type {WriteOptions} - additional options to add to the write interaction (optional) * @returns {Promise<AoMessageResult>} The result of the interaction. * @example * ```ts * ant.setLogo({ logo: "U7RXcpaVShG4u9nIcPVmm2FJSM5Gru9gQCIiRaIPV7f" }); * ``` */ setLogo({ txId }: { txId: string; }, options?: WriteOptions): Promise<AoMessageResult>; /** * Releases an ArNS name associated with the ANT. This will release the name to the public and allow anyone to register it. All primary names must be removed before the name can be released. * * * @param name @type {string} The name you want to release. The name will be put up for as a recently returned name on the ARIO contract. 50% of the winning bid will be distributed to the ANT owner at the time of purchase. If no purchase in the recently returned name period (14 epochs), the name will be released and can be reregistered by anyone. * @param arioProcessId @type {string} The processId of the ARIO contract. This is where the ANT will send the message to release the name. * @returns {Promise<AoMessageResult>} The result of the interaction. * @example * ```ts * ant.releaseName({ name: "ardrive", arioProcessId: ARIO_MAINNET_PROCESS_ID }); * ``` */ releaseName({ name, arioProcessId }: { name: string; arioProcessId: string; }, options?: WriteOptions): Promise<AoMessageResult>; /** * Sends a message to the ARIO contract to reassign the the base ArNS name to a new ANT. This can only be done by the current owner of the ANT. * * @param name @type {string} The name you want to reassign. * @param arioProcessId @type {string} The processId of the ARIO contract. * @param antProcessId @type {string} The processId of the ANT contract. * @returns {Promise<AoMessageResult>} The result of the interaction. * @example * ```ts * ant.reassignName({ name: "ardrive", arioProcessId: ARIO_MAINNET_PROCESS_ID, antProcessId: NEW_ANT_PROCESS_ID }); * ``` */ reassignName({ name, arioProcessId, antProcessId, }: { name: string; arioProcessId: string; antProcessId: string; }, options?: WriteOptions): Promise<AoMessageResult>; /** * Approves a primary name request for a given name or address. * * @param name @type {string} The name you want to approve. * @param address @type {WalletAddress} The address you want to approve. * @param arioProcessId @type {string} The processId of the ARIO contract. * @returns {Promise<AoMessageResult>} The result of the interaction. * @example * ```ts * ant.approvePrimaryNameRequest({ name: "ardrive", address: "U7RXcpaVShG4u9nIcPVmm2FJSM5Gru9gQCIiRaIPV7f", arioProcessId: ARIO_MAINNET_PROCESS_ID }); // approves the request for ardrive.ar.io to be registered by the address * ``` */ approvePrimaryNameRequest({ name, address, arioProcessId, }: { name: string; address: WalletAddress; arioProcessId: string; }, options?: WriteOptions): Promise<AoMessageResult>; /** * Removes primary names from the ANT. This will remove the primary names associated with the base ArNS name controlled by this ANT. All primary names must be removed before the name can be released. * * @param names @type {string[]} The names you want to remove. * @param arioProcessId @type {string} The processId of the ARIO contract. * @param notifyOwners @type {boolean} Whether to notify the owners of the primary names. * @returns {Promise<AoMessageResult>} The result of the interaction. * @example * ```ts * ant.removePrimaryNames({ names: ["ardrive", "dapp_ardrive"], arioProcessId: ARIO_MAINNET_PROCESS_ID, notifyOwners: true }); // removes the primary names and associated wallet addresses assigned to "ardrive" and "dapp_ardrive" * ``` */ removePrimaryNames({ names, arioProcessId, notifyOwners, }: { names: string[]; arioProcessId: string; notifyOwners?: boolean; }, options?: WriteOptions): Promise<AoMessageResult>; } export {};