1 | import { Address, AssetId, BigNumber, Bytes32, PublicIdentifier, SolidityValueType } from "./basic";
|
2 | import { AppState } from "./contracts";
|
3 |
|
4 | import { AppABIEncodings, AppInstanceJson } from "./app";
|
5 | import { OutcomeType } from "./contracts";
|
6 | import { PublicParams, PublicResults } from "./public";
|
7 | import { StateChannelJSON } from "./state";
|
8 | import { MinimalTransaction } from "./commitments";
|
9 | import { enumify } from "./utils";
|
10 |
|
11 |
|
12 |
|
13 | type CreateChannelParams = {
|
14 | owners: PublicIdentifier[];
|
15 | chainId: number;
|
16 | };
|
17 |
|
18 | type CreateChannelResult = {
|
19 | multisigAddress: Address;
|
20 | owners?: Address[];
|
21 | };
|
22 |
|
23 |
|
24 |
|
25 | type DepositParams = PublicParams.Deposit;
|
26 |
|
27 | type DepositResult = PublicResults.Deposit;
|
28 |
|
29 |
|
30 |
|
31 | type DeployStateDepositHolderParams = {
|
32 | multisigAddress: Address;
|
33 | retryCount?: number;
|
34 | };
|
35 |
|
36 | type DeployStateDepositHolderResult = {
|
37 | transactionHash: Bytes32;
|
38 | };
|
39 |
|
40 |
|
41 |
|
42 | type GetChannelAddressesParams = {};
|
43 |
|
44 | type GetChannelAddressesResult = {
|
45 | multisigAddresses: Address[];
|
46 | };
|
47 |
|
48 |
|
49 |
|
50 | type GetAppInstanceDetailsParams = {
|
51 | appIdentityHash: Bytes32;
|
52 | };
|
53 |
|
54 | type GetAppInstanceDetailsResult = {
|
55 | appInstance: AppInstanceJson;
|
56 | };
|
57 |
|
58 |
|
59 |
|
60 | type GetAppInstancesParams = {
|
61 | multisigAddress: Address;
|
62 | };
|
63 |
|
64 | type GetAppInstancesResult = {
|
65 | appInstances: AppInstanceJson[];
|
66 | };
|
67 |
|
68 |
|
69 |
|
70 | type GetStateDepositHolderAddressParams = {
|
71 | owners: Address[];
|
72 | chainId: number;
|
73 | };
|
74 |
|
75 | type GetStateDepositHolderAddressResult = {
|
76 | address: Address;
|
77 | };
|
78 |
|
79 |
|
80 |
|
81 | type GetFreeBalanceStateParams = {
|
82 | multisigAddress: Address;
|
83 | assetId?: Address;
|
84 | };
|
85 |
|
86 | type GetFreeBalanceStateResult = {
|
87 | [signerAddress: string]: BigNumber;
|
88 | };
|
89 |
|
90 |
|
91 |
|
92 | type GetTokenIndexedFreeBalanceStatesParams = {
|
93 | multisigAddress: Address;
|
94 | };
|
95 |
|
96 | type GetTokenIndexedFreeBalanceStatesResult = {
|
97 | [tokenAddress: string]: {
|
98 | [s: string]: BigNumber;
|
99 | };
|
100 | };
|
101 |
|
102 |
|
103 |
|
104 | type GetProposedAppInstanceParams = {
|
105 | appIdentityHash: Bytes32;
|
106 | };
|
107 |
|
108 | type GetProposedAppInstanceResult = {
|
109 | appInstance: AppInstanceJson;
|
110 | };
|
111 |
|
112 |
|
113 |
|
114 | type GetProposedAppInstancesParams = {
|
115 | multisigAddress: Address;
|
116 | };
|
117 |
|
118 | type GetProposedAppInstancesResult = {
|
119 | appInstances: AppInstanceJson[];
|
120 | };
|
121 |
|
122 |
|
123 |
|
124 | type GetStateChannelParams = {
|
125 | multisigAddress: Address;
|
126 | };
|
127 |
|
128 | type GetStateChannelResult = {
|
129 | data: StateChannelJSON;
|
130 | };
|
131 |
|
132 |
|
133 |
|
134 | type InstallParams = {
|
135 | appIdentityHash: Bytes32;
|
136 | multisigAddress: Address;
|
137 | protocolMeta?: any;
|
138 | };
|
139 |
|
140 | type InstallResult = {
|
141 | appInstance: AppInstanceJson;
|
142 | };
|
143 |
|
144 |
|
145 |
|
146 | type RequestDepositRightsParams = {
|
147 | assetId?: Address;
|
148 | multisigAddress: Address;
|
149 | };
|
150 |
|
151 | type RequestDepositRightsResult = {
|
152 | appIdentityHash: Bytes32;
|
153 | multisigAddress: Address;
|
154 | };
|
155 |
|
156 |
|
157 |
|
158 | type ProposeInstallParams = {
|
159 | abiEncodings: AppABIEncodings;
|
160 | appDefinition: Address;
|
161 | defaultTimeout: BigNumber;
|
162 | initialState: AppState;
|
163 | initiatorDeposit: BigNumber;
|
164 | initiatorDepositAssetId: AssetId;
|
165 | meta?: any;
|
166 | multisigAddress: Address;
|
167 | outcomeType: OutcomeType;
|
168 | responderIdentifier: PublicIdentifier;
|
169 | responderDeposit: BigNumber;
|
170 | responderDepositAssetId: AssetId;
|
171 | stateTimeout?: BigNumber;
|
172 | protocolMeta?: any;
|
173 | };
|
174 |
|
175 | type ProposeInstallResult = {
|
176 | appIdentityHash: Bytes32;
|
177 | };
|
178 |
|
179 |
|
180 |
|
181 | type RejectInstallParams = {
|
182 | appIdentityHash: Bytes32;
|
183 | multisigAddress: Address;
|
184 | reason?: string;
|
185 | };
|
186 |
|
187 | type RejectInstallResult = {};
|
188 |
|
189 |
|
190 |
|
191 | type TakeActionParams = {
|
192 | appIdentityHash: Bytes32;
|
193 | action: SolidityValueType;
|
194 | multisigAddress: Address;
|
195 | stateTimeout?: BigNumber;
|
196 | protocolMeta?: any;
|
197 | };
|
198 |
|
199 | type TakeActionResult = {
|
200 | newState: SolidityValueType;
|
201 | };
|
202 |
|
203 |
|
204 |
|
205 | type UninstallParams = {
|
206 | appIdentityHash: Bytes32;
|
207 | multisigAddress: Address;
|
208 | action?: SolidityValueType;
|
209 | protocolMeta?: any;
|
210 | };
|
211 |
|
212 | type UninstallResult = {
|
213 | appIdentityHash: Bytes32;
|
214 | multisigAddress: Address;
|
215 | uninstalledApp: AppInstanceJson;
|
216 | action?: SolidityValueType;
|
217 | };
|
218 |
|
219 |
|
220 |
|
221 | type RescindDepositRightsParams = {
|
222 | assetId?: Address;
|
223 | appIdentityHash?: Bytes32;
|
224 | multisigAddress: Address;
|
225 | };
|
226 |
|
227 | type RescindDepositRightsResult = {
|
228 | freeBalance: {
|
229 | [s: string]: BigNumber;
|
230 | };
|
231 | };
|
232 |
|
233 |
|
234 |
|
235 | type WithdrawParams = {
|
236 | multisigAddress: Address;
|
237 | recipient?: Address;
|
238 | amount: BigNumber;
|
239 | tokenAddress?: Address;
|
240 | };
|
241 |
|
242 | type WithdrawResult = {
|
243 | recipient: Address;
|
244 | txHash: Bytes32;
|
245 | };
|
246 |
|
247 |
|
248 |
|
249 | type WithdrawCommitmentParams = WithdrawParams;
|
250 |
|
251 | type WithdrawCommitmentResult = {
|
252 | transaction: MinimalTransaction;
|
253 | };
|
254 |
|
255 |
|
256 |
|
257 | type SyncParams = {
|
258 | multisigAddress: Address;
|
259 | protocolMeta?: any;
|
260 | };
|
261 |
|
262 | type SyncResult = {
|
263 | syncedChannel: StateChannelJSON;
|
264 | };
|
265 |
|
266 |
|
267 |
|
268 |
|
269 | export const MethodNames = enumify({
|
270 | chan_create: "chan_create",
|
271 | chan_deployStateDepositHolder: "chan_deployStateDepositHolder",
|
272 | chan_getAppInstance: "chan_getAppInstance",
|
273 | chan_getAppInstances: "chan_getAppInstances",
|
274 | chan_getChannelAddresses: "chan_getChannelAddresses",
|
275 | chan_getFreeBalanceState: "chan_getFreeBalanceState",
|
276 | chan_getProposedAppInstance: "chan_getProposedAppInstance",
|
277 | chan_getProposedAppInstances: "chan_getProposedAppInstances",
|
278 | chan_getStateChannel: "chan_getStateChannel",
|
279 | chan_getStateDepositHolderAddress: "chan_getStateDepositHolderAddress",
|
280 | chan_getTokenIndexedFreeBalanceStates: "chan_getTokenIndexedFreeBalanceStates",
|
281 | chan_install: "chan_install",
|
282 | chan_proposeInstall: "chan_proposeInstall",
|
283 | chan_rejectInstall: "chan_rejectInstall",
|
284 | chan_sync: "chan_sync",
|
285 | chan_takeAction: "chan_takeAction",
|
286 | chan_uninstall: "chan_uninstall",
|
287 | chan_withdraw: "chan_withdraw",
|
288 | chan_withdrawCommitment: "chan_withdrawCommitment",
|
289 | });
|
290 | type MethodNames = typeof MethodNames[keyof typeof MethodNames];
|
291 | export type MethodName = keyof typeof MethodNames;
|
292 |
|
293 | export namespace MethodParams {
|
294 | export type CreateChannel = CreateChannelParams;
|
295 | export type DeployStateDepositHolder = DeployStateDepositHolderParams;
|
296 | export type Deposit = DepositParams;
|
297 | export type GetAppInstanceDetails = GetAppInstanceDetailsParams;
|
298 | export type GetAppInstances = GetAppInstancesParams;
|
299 | export type GetChannelAddresses = GetChannelAddressesParams;
|
300 | export type GetFreeBalanceState = GetFreeBalanceStateParams;
|
301 | export type GetProposedAppInstance = GetProposedAppInstanceParams;
|
302 | export type GetProposedAppInstances = GetProposedAppInstancesParams;
|
303 | export type GetStateChannel = GetStateChannelParams;
|
304 | export type GetStateDepositHolderAddress = GetStateDepositHolderAddressParams;
|
305 | export type GetTokenIndexedFreeBalanceStates = GetTokenIndexedFreeBalanceStatesParams;
|
306 | export type Install = InstallParams;
|
307 | export type ProposeInstall = ProposeInstallParams;
|
308 | export type RejectInstall = RejectInstallParams;
|
309 | export type RequestDepositRights = RequestDepositRightsParams;
|
310 | export type RescindDepositRights = RescindDepositRightsParams;
|
311 | export type TakeAction = TakeActionParams;
|
312 | export type Sync = SyncParams;
|
313 | export type Uninstall = UninstallParams;
|
314 | export type Withdraw = WithdrawParams;
|
315 | export type WithdrawCommitment = WithdrawCommitmentParams;
|
316 | }
|
317 |
|
318 | export type MethodParam =
|
319 | | CreateChannelParams
|
320 | | DeployStateDepositHolderParams
|
321 | | DepositParams
|
322 | | GetAppInstanceDetailsParams
|
323 | | GetAppInstancesParams
|
324 | | GetChannelAddressesParams
|
325 | | GetFreeBalanceStateParams
|
326 | | GetProposedAppInstanceParams
|
327 | | GetProposedAppInstancesParams
|
328 | | GetStateChannelParams
|
329 | | GetStateDepositHolderAddressParams
|
330 | | GetTokenIndexedFreeBalanceStatesParams
|
331 | | InstallParams
|
332 | | ProposeInstallParams
|
333 | | RejectInstallParams
|
334 | | RequestDepositRightsParams
|
335 | | RescindDepositRightsParams
|
336 | | SyncParams
|
337 | | TakeActionParams
|
338 | | UninstallParams
|
339 | | WithdrawParams
|
340 | | WithdrawCommitmentParams;
|
341 |
|
342 | export namespace MethodResults {
|
343 | export type CreateChannel = CreateChannelResult;
|
344 | export type DeployStateDepositHolder = DeployStateDepositHolderResult;
|
345 | export type Deposit = DepositResult;
|
346 | export type GetAppInstanceDetails = GetAppInstanceDetailsResult;
|
347 | export type GetAppInstances = GetAppInstancesResult;
|
348 | export type GetChannelAddresses = GetChannelAddressesResult;
|
349 | export type GetFreeBalanceState = GetFreeBalanceStateResult;
|
350 | export type GetProposedAppInstance = GetProposedAppInstanceResult;
|
351 | export type GetProposedAppInstances = GetProposedAppInstancesResult;
|
352 | export type GetStateChannel = GetStateChannelResult;
|
353 | export type GetStateDepositHolderAddress = GetStateDepositHolderAddressResult;
|
354 | export type GetTokenIndexedFreeBalanceStates = GetTokenIndexedFreeBalanceStatesResult;
|
355 | export type Install = InstallResult;
|
356 | export type ProposeInstall = ProposeInstallResult;
|
357 | export type RejectInstall = RejectInstallResult;
|
358 | export type RequestDepositRights = RequestDepositRightsResult;
|
359 | export type RescindDepositRights = RescindDepositRightsResult;
|
360 | export type Sync = SyncResult;
|
361 | export type TakeAction = TakeActionResult;
|
362 | export type Uninstall = UninstallResult;
|
363 | export type Withdraw = WithdrawResult;
|
364 | export type WithdrawCommitment = WithdrawCommitmentResult;
|
365 | }
|
366 |
|
367 | export type MethodResult =
|
368 | | CreateChannelResult
|
369 | | DeployStateDepositHolderResult
|
370 | | DepositResult
|
371 | | GetAppInstanceDetailsResult
|
372 | | GetAppInstancesResult
|
373 | | GetChannelAddressesResult
|
374 | | GetFreeBalanceStateResult
|
375 | | GetProposedAppInstanceResult
|
376 | | GetProposedAppInstancesResult
|
377 | | GetStateChannelResult
|
378 | | GetStateDepositHolderAddressResult
|
379 | | GetTokenIndexedFreeBalanceStatesResult
|
380 | | InstallResult
|
381 | | ProposeInstallResult
|
382 | | RejectInstallResult
|
383 | | RequestDepositRightsResult
|
384 | | RescindDepositRightsResult
|
385 | | SyncResult
|
386 | | TakeActionResult
|
387 | | UninstallResult
|
388 | | WithdrawResult
|
389 | | WithdrawCommitmentResult;
|