1 | import { providers } from "ethers";
|
2 |
|
3 | import { AppRegistry, DefaultApp, AppInstanceJson } from "./app";
|
4 | import { Address, Bytes32, DecString, PublicIdentifier } from "./basic";
|
5 | import { ChannelProviderConfig, IChannelProvider } from "./channelProvider";
|
6 | import { IChannelSigner } from "./crypto";
|
7 | import { EventName, EventPayload } from "./events";
|
8 | import { ILogger, ILoggerService } from "./logger";
|
9 | import { IMessagingService } from "./messaging";
|
10 | import { NodeResponses } from "./node";
|
11 | import { MethodResults, MethodParams } from "./methods";
|
12 | import { IStoreService } from "./store";
|
13 | import { PublicParams, PublicResults } from "./public";
|
14 | import { AppAction } from ".";
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | export interface ClientOptions {
|
20 | channelProvider?: IChannelProvider;
|
21 | ethProviderUrl: string;
|
22 | chainId?: number;
|
23 | signer?: string | IChannelSigner;
|
24 | store?: IStoreService;
|
25 | logger?: ILogger;
|
26 | loggerService?: ILoggerService;
|
27 | logLevel?: number;
|
28 | messaging?: IMessagingService;
|
29 | nodeUrl?: string;
|
30 | messagingUrl?: string;
|
31 | skipSync?: boolean;
|
32 | skipInitStore?: boolean;
|
33 | }
|
34 |
|
35 | export interface IConnextClient {
|
36 |
|
37 |
|
38 |
|
39 | appRegistry: AppRegistry;
|
40 | config: NodeResponses.GetConfig;
|
41 | channelProvider: IChannelProvider;
|
42 | ethProvider: providers.JsonRpcProvider;
|
43 | chainId: number;
|
44 | signerAddress: Address;
|
45 | multisigAddress: Address;
|
46 | nodeIdentifier: PublicIdentifier;
|
47 | nodeSignerAddress: Address;
|
48 | publicIdentifier: PublicIdentifier;
|
49 |
|
50 |
|
51 | messaging: IMessagingService;
|
52 | store: IStoreService;
|
53 |
|
54 |
|
55 |
|
56 |
|
57 | restart(): Promise<void>;
|
58 |
|
59 |
|
60 |
|
61 | on<T extends EventName>(
|
62 | event: T,
|
63 | callback: (payload: EventPayload[T]) => void | Promise<void>,
|
64 | filter?: (payload: EventPayload[T]) => boolean,
|
65 | ): void;
|
66 | once<T extends EventName>(
|
67 | event: T,
|
68 | callback: (payload: EventPayload[T]) => void | Promise<void>,
|
69 | filter?: (payload: EventPayload[T]) => boolean,
|
70 | ): void;
|
71 | waitFor<T extends EventName>(
|
72 | event: T,
|
73 | timeout: number,
|
74 | filter?: (payload: EventPayload[T]) => boolean,
|
75 | ): Promise<EventPayload[T]>;
|
76 | emit<T extends EventName>(event: T, payload: EventPayload[T]): boolean;
|
77 | off(): void;
|
78 |
|
79 |
|
80 |
|
81 | channelProviderConfig(): Promise<ChannelProviderConfig>;
|
82 | checkDepositRights(
|
83 | params: PublicParams.CheckDepositRights,
|
84 | ): Promise<PublicResults.CheckDepositRights>;
|
85 | conditionalTransfer(
|
86 | params: PublicParams.ConditionalTransfer,
|
87 | ): Promise<PublicResults.ConditionalTransfer>;
|
88 | deposit(params: PublicParams.Deposit): Promise<PublicResults.Deposit>;
|
89 | requestDepositRights(
|
90 | params: PublicParams.RequestDepositRights,
|
91 | ): Promise<MethodResults.RequestDepositRights>;
|
92 | rescindDepositRights(
|
93 | params: PublicParams.RescindDepositRights,
|
94 | ): Promise<PublicResults.RescindDepositRights>;
|
95 | resolveCondition(params: PublicParams.ResolveCondition): Promise<PublicResults.ResolveCondition>;
|
96 | restoreState(): Promise<void>;
|
97 | swap(params: PublicParams.Swap): Promise<PublicResults.Swap>;
|
98 | transfer(params: PublicParams.Transfer): Promise<PublicResults.ConditionalTransfer>;
|
99 | withdraw(params: PublicParams.Withdraw): Promise<PublicResults.Withdraw>;
|
100 |
|
101 |
|
102 |
|
103 |
|
104 | isAvailable(): Promise<void>;
|
105 | getChannel(): Promise<NodeResponses.GetChannel>;
|
106 | getLinkedTransfer(paymentId: Bytes32): Promise<NodeResponses.GetLinkedTransfer>;
|
107 | getHashLockTransfer(
|
108 | lockHash: Bytes32,
|
109 | assetId?: Address,
|
110 | ): Promise<NodeResponses.GetHashLockTransfer>;
|
111 | getSignedTransfer(paymentId: Bytes32): Promise<NodeResponses.GetSignedTransfer>;
|
112 | getGraphTransfer(paymentId: Bytes32): Promise<NodeResponses.GetSignedTransfer>;
|
113 | getAppRegistry(
|
114 | appDetails?:
|
115 | | {
|
116 | name: string;
|
117 | chainId: number;
|
118 | }
|
119 | | { appDefinitionAddress: Address },
|
120 | ): Promise<AppRegistry | DefaultApp | undefined>;
|
121 | createChannel(): Promise<NodeResponses.CreateChannel>;
|
122 | subscribeToSwapRates(from: Address, to: Address, callback: any): Promise<any>;
|
123 | getLatestSwapRate(from: Address, to: Address): Promise<DecString>;
|
124 | unsubscribeToSwapRates(from: Address, to: Address): Promise<void>;
|
125 | requestCollateral(tokenAddress: Address): Promise<NodeResponses.RequestCollateral | void>;
|
126 | getRebalanceProfile(assetId?: Address): Promise<NodeResponses.GetRebalanceProfile | undefined>;
|
127 | getTransferHistory(): Promise<NodeResponses.GetTransferHistory>;
|
128 | reclaimPendingAsyncTransfers(): Promise<void>;
|
129 |
|
130 |
|
131 |
|
132 | deployMultisig(): Promise<MethodResults.DeployStateDepositHolder>;
|
133 | getStateChannel(): Promise<MethodResults.GetStateChannel>;
|
134 | getFreeBalance(assetId?: Address): Promise<MethodResults.GetFreeBalanceState>;
|
135 | getAppInstances(): Promise<AppInstanceJson[]>;
|
136 | getAppInstance(
|
137 | appIdentityHash: Bytes32,
|
138 | ): Promise<MethodResults.GetAppInstanceDetails | undefined>;
|
139 | getProposedAppInstances(
|
140 | multisigAddress?: Address,
|
141 | ): Promise<MethodResults.GetProposedAppInstances | undefined>;
|
142 | getProposedAppInstance(
|
143 | appIdentityHash: Bytes32,
|
144 | ): Promise<MethodResults.GetProposedAppInstance | undefined>;
|
145 | proposeInstallApp(params: MethodParams.ProposeInstall): Promise<MethodResults.ProposeInstall>;
|
146 | installApp(appIdentityHash: Bytes32): Promise<MethodResults.Install>;
|
147 | rejectInstallApp(appIdentityHash: Bytes32, reason?: string): Promise<MethodResults.Uninstall>;
|
148 | takeAction(appIdentityHash: Bytes32, action: any): Promise<MethodResults.TakeAction>;
|
149 | uninstallApp(appIdentityHash: Bytes32, action?: AppAction): Promise<MethodResults.Uninstall>;
|
150 | }
|