UNPKG

dotbit

Version:

A complete .bit SDK and utilities in TypeScript

85 lines (84 loc) 2.86 kB
import { CheckSubAccountStatus } from '../const'; import { ICharInfo } from '../tools/account'; import { Networking } from '../tools/Networking'; import { BitKeyInfo, KeyInfo } from './BitIndexer.type'; import { EditAccountRecord, SignTxListParams, SignTxListRes } from './RegisterAPI.type'; export interface SubAccount extends BitKeyInfo { account: string; register_years: number; } export interface SubAccountMintForAddress extends SubAccount { account_char_str: ICharInfo[]; } export interface SubAccountMintForAccount { account: string; mint_for_account: string; register_years: number; account_char_str: ICharInfo[]; } export type SubAccountMintParams = SubAccountMintForAddress | SubAccountMintForAccount; export interface CheckAccountsParams extends BitKeyInfo { account: string; sub_account_list: SubAccountMintParams[]; } export interface SubAccountWithStatus extends SubAccount { status: CheckSubAccountStatus; message: string; } export interface CreateSubAccountsParams extends CheckAccountsParams { } export interface SubAccountListParams { account: string; page: number; size: number; keyword: string; } export interface SubAccountListItem { account: string; owner: BitKeyInfo; manager: BitKeyInfo; registered_at: number; expired_at: number; status: number; enable_sub_account: number; renew_sub_account_price: number; nonce: number; } export interface SubAccountListRes { total: number; list: SubAccountListItem[]; } export type EditSubAccountEditKey = 'manager' | 'owner' | 'records'; export interface EditSubAccountParamsGeneric<T> { account: string; type: string; key_info: KeyInfo; edit_key: EditSubAccountEditKey; edit_value: T; } export type EditSubAccountManagerParams = EditSubAccountParamsGeneric<{ manager: BitKeyInfo; }>; export type EditSubAccountOwnerParams = EditSubAccountParamsGeneric<{ owner: BitKeyInfo; }>; export type EditSubAccountRecordsParams = EditSubAccountParamsGeneric<{ records: EditAccountRecord[]; }>; export type EditSubAccountParams = EditSubAccountOwnerParams | EditSubAccountManagerParams | EditSubAccountRecordsParams; export declare class SubAccountAPI { baseUri: string; net: Networking; constructor(baseUri: string); initSubAccount(account: string, keyInfo: KeyInfo): Promise<SignTxListParams>; sendTransaction(tx: SignTxListRes): Promise<{ hash?: string; hash_list: string[]; }>; subAccountList(params: SubAccountListParams): Promise<SubAccountListRes>; checkSubAccounts(params: CheckAccountsParams): Promise<{ result: SubAccountWithStatus[]; }>; createSubAccounts(params: CreateSubAccountsParams): Promise<SignTxListParams>; editSubAccount(params: EditSubAccountParams): Promise<SignTxListParams>; }