UNPKG

3.88 kBPlain TextView Raw
1import { Address, BigNumber, Bytes32, DecString, Network, PublicIdentifier } from "./basic";
2import {
3 ConditionalTransactionCommitmentJSON,
4 MinimalTransaction,
5 SetStateCommitmentJSON,
6} from "./commitments";
7import { MethodResults } from "./methods";
8import { PublicResults } from "./public";
9import { StateChannelJSON } from "./state";
10import { LinkedTransferStatus, HashLockTransferStatus, SignedTransferStatus } from "./transfers";
11import { Collateralizations, RebalanceProfile } from "./misc";
12import { ContractAddresses } from "./contracts";
13
14type GetRebalanceProfileResponse = RebalanceProfile;
15
16export type ContractAddressBook = {
17 [chainId: string]: ContractAddresses;
18};
19
20type GetHashLockTransferResponse =
21 | {
22 senderIdentifier: PublicIdentifier;
23 receiverIdentifier?: PublicIdentifier;
24 assetId: Address;
25 amount: DecString;
26 lockHash: Bytes32;
27 status: HashLockTransferStatus;
28 meta?: any;
29 preImage: Bytes32;
30 expiry: BigNumber;
31 }
32 | undefined;
33
34type GetSignedTransferResponse = {
35 senderIdentifier: PublicIdentifier;
36 receiverIdentifier?: PublicIdentifier;
37 assetId: Address;
38 amount: DecString;
39 paymentId: Bytes32;
40 status: SignedTransferStatus;
41 meta?: any;
42};
43
44type GetTransferResponse = {
45 paymentId: Bytes32;
46 amount: BigNumber;
47 assetId: Address;
48 senderIdentifier: PublicIdentifier;
49 receiverIdentifier: PublicIdentifier;
50 meta: any;
51};
52
53type GetConfigResponse = {
54 ethNetwork: Network;
55 contractAddresses: ContractAddressBook;
56 nodeIdentifier: PublicIdentifier;
57 messagingUrl: string[];
58 signerAddress: Address;
59 supportedTokenAddresses: { [chainId: number]: Address[] };
60};
61
62type GetChannelResponse = {
63 nodeIdentifier: PublicIdentifier;
64 userIdentifier: PublicIdentifier;
65 multisigAddress: Address;
66 available: boolean;
67 activeCollateralizations: Collateralizations;
68};
69
70// returns the transaction hash of the multisig deployment
71// TODO: this will likely change
72type CreateChannelResponse = {
73 transactionHash: Bytes32;
74};
75
76type RequestCollateralResponse = MethodResults.Deposit | undefined;
77
78// returned by the node when client calls channel.restore
79type ChannelRestoreResponse = {
80 channel: StateChannelJSON;
81 setupCommitment: MinimalTransaction | undefined;
82 setStateCommitments: [Bytes32, SetStateCommitmentJSON][]; // appIdentityHash, commitment
83 conditionalCommitments: [Bytes32, ConditionalTransactionCommitmentJSON][]; // appIdentityHash, commitment
84};
85
86type FetchedLinkedTransfer = {
87 paymentId: Bytes32;
88 createdAt: Date;
89 amount: BigNumber;
90 assetId: Address;
91 senderIdentifier: PublicIdentifier;
92 receiverIdentifier?: PublicIdentifier;
93 status: LinkedTransferStatus;
94 meta: any;
95 encryptedPreImage?: string;
96};
97
98type GetLinkedTransferResponse = FetchedLinkedTransfer;
99type GetPendingAsyncTransfersResponse = FetchedLinkedTransfer[];
100
101////////////////////////////////////
102// exports
103
104export namespace NodeResponses {
105 export type GetConfig = GetConfigResponse;
106 export type GetTransfer = GetTransferResponse;
107 export type GetTransferHistory = GetTransferResponse[];
108 export type GetLinkedTransfer = GetLinkedTransferResponse;
109 export type GetPendingAsyncTransfers = GetPendingAsyncTransfersResponse;
110 export type InstallConditionalTransferReceiverApp = PublicResults.ResolveCondition;
111 export type ResolveLinkedTransfer = PublicResults.ResolveLinkedTransfer;
112 export type ResolveSignedTransfer = PublicResults.ResolveSignedTransfer;
113 export type GetRebalanceProfile = GetRebalanceProfileResponse;
114 export type GetHashLockTransfer = GetHashLockTransferResponse;
115 export type GetSignedTransfer = GetSignedTransferResponse;
116 export type GetChannel = GetChannelResponse;
117 export type CreateChannel = CreateChannelResponse;
118 export type RequestCollateral = RequestCollateralResponse;
119 export type ChannelRestore = ChannelRestoreResponse;
120}