bdcontract-sdk-javascript/types/httpClient.d.ts

57 lines
3.3 KiB
TypeScript
Raw Normal View History

2023-03-14 17:15:57 +00:00
import { type AxiosRequestConfig } from 'axios';
import type { KeyPairHex } from 'sm-crypto';
import type { ClientResponse, ConfigNodeArgs, ExecuteContractArgs, ListAllUsersResponseData, ListNodesResponse, ListProjectPermissionRequest, ListProjectPermissionResponseData, LoadNodeConfigResponseData, ExecuteContractResponse, PingResponse, SaveFileRequest, StartContractByYpkRequest } from './types';
export * from './types';
export declare class HttpClient {
private baseUrl;
private sm2Key;
private fetch;
constructor(baseUrl: string, sm2Key: KeyPairHex, config?: AxiosRequestConfig<any>);
requestWithSignature<Data>(path: string, init?: Partial<RequestInit>, sm2Key?: KeyPairHex): Promise<ClientResponse<Data>>;
retryRequestWithSignature<Data>(retryTimes: number, path: string, init?: Partial<RequestInit>, sm2Key?: KeyPairHex): Promise<ClientResponse<Data>>;
sign(data: string, privateKey?: string): string;
ping(): Promise<PingResponse>;
startContract(code: string): Promise<ClientResponse<string>>;
startContractByYPK(_request: StartContractByYpkRequest): Promise<ClientResponse<string>>;
executeContract(contractID: string, operation: string, arg: string, { method, withDynamicAnalysis, withSignature, }?: ExecuteContractArgs): Promise<ClientResponse<ExecuteContractResponse<string>>>;
killContractProcess(contractID: string, requestID?: string): Promise<ClientResponse<string>>;
killAllContract(): Promise<ClientResponse<string>>;
applyNodeRole(role: string): Promise<ClientResponse<{
action: string;
data: string;
role?: string;
}>>;
authNodeRole(isAccept: boolean, authorizedPubKey: string, managerPair?: KeyPairHex): Promise<ClientResponse<{
action: string;
data: string;
}>>;
distributeContract(nodeIDs: string, projectName: string, isPrivate: boolean): void;
saveFile(_request: SaveFileRequest): Promise<ClientResponse<string>>;
listProjectPermission(_request: ListProjectPermissionRequest): Promise<ClientResponse<ListProjectPermissionResponseData>>;
startContractMultiPoint(peersID: string, type: number, selectUnitNum: number, projectName: string, isPrivate: boolean, sponsorPeerID: string): Promise<ClientResponse<string>>;
loadNodeConfig(): Promise<ClientResponse<LoadNodeConfigResponseData>>;
updateConfig(key: string, val: string): Promise<ClientResponse<boolean>>;
resetNodeManager(): Promise<boolean>;
lockEdit(): Promise<ClientResponse<string>>;
unlockEdit(): Promise<ClientResponse<string>>;
addNode(nodePubKey: string): Promise<ClientResponse<string>>;
applyRole(role: string): Promise<ClientResponse<string>>;
authNodeManager(isAccept: boolean, authorizedPubKey: string): Promise<ClientResponse<string>>;
listAllUsers(): Promise<ClientResponse<ListAllUsersResponseData>>;
listNodes(): Promise<ListNodesResponse>;
createTrustUnit(data: {
nodeName: string;
pubkey: string;
}[], Msg: string): Promise<{
action: string;
status: string;
}>;
listTrustUnits(): Promise<ClientResponse<{
key: string;
value: string;
}[]>>;
listContractProcess(): Promise<ClientResponse<string>>;
downloadContract(projectName: string, isPrivate: boolean, timestamp: number): Promise<ClientResponse<string>>;
configNode(args: ConfigNodeArgs): Promise<boolean>;
}