145 lines
4.9 KiB
TypeScript
145 lines
4.9 KiB
TypeScript
// 4NK SDK Client WASM Package - TypeScript Definitions
|
|
|
|
export interface WasmInstance {
|
|
// Add WASM instance interface as needed
|
|
}
|
|
|
|
// Core interfaces
|
|
export interface ApiReturn<T = any> {
|
|
success: boolean;
|
|
data?: T;
|
|
error?: string;
|
|
new_tx_to_send?: any;
|
|
commit_to_send?: any;
|
|
partial_tx?: any;
|
|
secrets?: any;
|
|
updated_process?: any;
|
|
push_to_storage?: any;
|
|
ciphers_to_send?: any;
|
|
}
|
|
|
|
export interface Device {
|
|
id: string;
|
|
name: string;
|
|
// Add other device properties as needed
|
|
}
|
|
|
|
export interface HandshakeMessage {
|
|
sp_address: string;
|
|
peers_list: Record<string, Member>;
|
|
processes_list: Record<string, Process>;
|
|
}
|
|
|
|
export interface Member {
|
|
sp_addresses: string[];
|
|
// Add other member properties
|
|
}
|
|
|
|
export interface MerkleProofResult {
|
|
root: string;
|
|
proof: string;
|
|
// Add other proof properties
|
|
}
|
|
|
|
export interface OutPointProcessMap {
|
|
[key: string]: Process;
|
|
}
|
|
|
|
export interface Process {
|
|
id: string;
|
|
state: ProcessState;
|
|
states: ProcessState[];
|
|
// Add other process properties
|
|
}
|
|
|
|
export interface ProcessState {
|
|
state_id: string;
|
|
public_data: Record<string, any>;
|
|
roles: Record<string, RoleDefinition>;
|
|
pcd_commitment?: any;
|
|
keys?: any;
|
|
commited_in?: any;
|
|
// Add other process state properties
|
|
}
|
|
|
|
export interface RoleDefinition {
|
|
members: string[];
|
|
validation_rules?: any;
|
|
storages?: any;
|
|
// Add other role definition properties
|
|
}
|
|
|
|
export interface SecretsStore {
|
|
// Add secrets store properties
|
|
}
|
|
|
|
export interface UserDiff {
|
|
// Add user diff properties
|
|
}
|
|
|
|
export interface AnkFlag {
|
|
// Add flag properties
|
|
}
|
|
|
|
// WASM functions
|
|
export async function init(): Promise<void>;
|
|
export function getWasmInstance(): WasmInstance | undefined;
|
|
|
|
// SDK functions - Synchronous versions
|
|
export function setup(): void;
|
|
export function create_transaction(addresses: any, amount: number): ApiReturn;
|
|
export function get_available_amount(): bigint;
|
|
export function create_faucet_msg(): string;
|
|
export function create_new_device(amount: number, network: string): string;
|
|
export function dump_device(): Device;
|
|
export function get_address(): string;
|
|
export function get_pairing_process_id(): string;
|
|
export function is_paired(): boolean;
|
|
export function encode_json(data: any): Record<string, any>;
|
|
export function encode_binary(data: any): Record<string, any>;
|
|
export function create_new_process(encodedPrivateData: any, roles: any, encodedPublicData: any, relayAddress: string, feeRate: any, members: any): ApiReturn;
|
|
export function parse_cipher(message: string, membersList: any, processes: any): ApiReturn;
|
|
export function parse_new_tx(tx: string, blockHeight: number, membersList: any): ApiReturn;
|
|
export function create_update_message(process: any, stateId: string, membersList: any): ApiReturn;
|
|
export function validate_state(process: any, stateId: string, membersList: any): ApiReturn;
|
|
export function update_process(process: any, stateId: string, roles: any, publicData: any, privateData: any): ApiReturn;
|
|
export function restore_device(params: any): void;
|
|
export function pair_device(params: any): void;
|
|
export function sign_transaction(params: any): ApiReturn;
|
|
export function request_data(processId: string, stateIds: any, roles: any, membersList: any): ApiReturn;
|
|
export function decrypt_data(params: any): ApiReturn;
|
|
export function decode_value(params: any): any;
|
|
export function unpair_device(params: any): void;
|
|
|
|
export interface SdkClient {
|
|
init(): Promise<void>;
|
|
getWasmInstance(): WasmInstance | undefined;
|
|
setup(): void;
|
|
create_transaction(addresses: any, amount: number): ApiReturn;
|
|
get_available_amount(): bigint;
|
|
create_faucet_msg(): string;
|
|
create_new_device(amount: number, network: string): string;
|
|
dump_device(): Device;
|
|
get_address(): string;
|
|
get_pairing_process_id(): string;
|
|
is_paired(): boolean;
|
|
encode_json(data: any): Record<string, any>;
|
|
encode_binary(data: any): Record<string, any>;
|
|
create_new_process(encodedPrivateData: any, roles: any, encodedPublicData: any, relayAddress: string, feeRate: any, members: any): ApiReturn;
|
|
parse_cipher(message: string, membersList: any, processes: any): ApiReturn;
|
|
parse_new_tx(tx: string, blockHeight: number, membersList: any): ApiReturn;
|
|
create_update_message(process: any, stateId: string, membersList: any): ApiReturn;
|
|
validate_state(process: any, stateId: string, membersList: any): ApiReturn;
|
|
update_process(process: any, stateId: string, roles: any, publicData: any, privateData: any): ApiReturn;
|
|
restore_device(params: any): void;
|
|
pair_device(params: any): void;
|
|
sign_transaction(params: any): ApiReturn;
|
|
request_data(processId: string, stateIds: any, roles: any, membersList: any): ApiReturn;
|
|
decrypt_data(params: any): ApiReturn;
|
|
decode_value(params: any): any;
|
|
unpair_device(params: any): void;
|
|
}
|
|
|
|
export const sdk_client: SdkClient;
|
|
export default sdk_client;
|