@safik/fk-plug-controller
Version:
Internet Computer Plug wallet's controller
91 lines (90 loc) • 2.52 kB
TypeScript
import { Principal } from '@dfinity/principal';
import { BinaryBlob } from '@dfinity/candid';
export declare type AccountIdentifier = string;
export declare type TokenIdentifier = string;
export declare type Balance = bigint;
export declare type SubAccount = number[];
export declare type Memo = number[];
export declare type Fee = bigint;
export declare type User = {
addres?: AccountIdentifier;
} | {
principal?: Principal;
};
export interface ResultOk<T> {
ok: T;
}
export interface ResultError<T> {
error: T;
}
export declare type Result<Ok, Error> = ResultOk<Ok> | ResultError<Error>;
export interface NotifyArgs {
canister_id: Principal;
method_name: string;
}
export interface TokenMetaData {
name: string;
decimals: number;
symbol: string;
}
export interface StandardToken extends TokenMetaData {
canisterId: string;
standard: string;
color?: string;
}
export declare type CommonError = {
InvalidToken: TokenIdentifier;
} | {
Other: string;
};
export declare type Extension = string;
export interface BalanceRequest {
user: User;
token: TokenIdentifier;
}
export declare type BalanceResponse = Result<Balance, CommonError>;
export declare type TransactionId = bigint;
export declare type TransferError = {
Unauthorized: AccountIdentifier;
} | {
InsufficientBalance: null;
} | {
Rejected: null;
} | {
InvalidToken: TokenIdentifier;
} | {
CannotNotify: AccountIdentifier;
} | {
Other: string;
};
export interface TransferRequest {
to: User;
from: User;
token: TokenIdentifier;
amount: Balance;
memo: Memo;
notify: boolean;
subacount?: SubAccount;
fee: Fee;
}
export declare type TransferResponse = Result<Balance, TransferError>;
export interface FungibleMetadata {
fungible: TokenMetaData & {
metadata?: BinaryBlob;
};
}
export interface NonFungibleMetadata {
nonfungible: {
metadata: BinaryBlob;
};
}
export declare type Metadata = FungibleMetadata | NonFungibleMetadata;
export declare type MetadataResponse = Result<Metadata, CommonError>;
export declare type SupplyResponse = Result<Balance, CommonError>;
export default interface _SERVICE {
extensions: () => Promise<Extension[]>;
balance: (arg_0: BalanceRequest) => Promise<BalanceResponse>;
transfer: (arg_0: TransferRequest) => Promise<TransferResponse>;
metadata: (token: TokenIdentifier) => Promise<MetadataResponse>;
supply: (token: TokenIdentifier) => Promise<SupplyResponse>;
}