dotbit-sdk-allin
Version:
A complete .bit SDK and utilities in TypeScript
97 lines (96 loc) • 3.18 kB
TypeScript
import { CheckSubAccountStatus } from '../const';
import { ICharInfo } from '../tools/account';
import { Networking } from '../tools/Networking';
import { BitKeyInfo, KeyInfo } from './BitIndexer.type';
import { EditAccountRecord } from './RegisterAPI.type';
export interface SignList {
sign_type: number;
sign_msg: string;
}
export interface TxsList {
sign_list: SignList[];
}
export interface TxsSignedOrUnSigned {
action: string;
sign_key: string;
list: TxsList[];
}
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<TxsSignedOrUnSigned>;
sendTransaction(tx: TxsSignedOrUnSigned): Promise<{
hash?: string;
hash_list: string[];
}>;
subAccountList(params: SubAccountListParams): Promise<SubAccountListRes>;
checkSubAccounts(params: CheckAccountsParams): Promise<{
result: SubAccountWithStatus[];
}>;
createSubAccounts(params: CreateSubAccountsParams): Promise<TxsSignedOrUnSigned>;
editSubAccount(params: EditSubAccountParams): Promise<TxsSignedOrUnSigned>;
}