This repository was archived by the owner on Dec 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy patherrors.ts
More file actions
174 lines (153 loc) · 6.25 KB
/
errors.ts
File metadata and controls
174 lines (153 loc) · 6.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import { EngineError, EngineParams, Values } from "@connext/vector-types";
export class DisputeError extends EngineError {
static readonly type = "DisputeError";
static readonly reasons = {
ChannelDefundTxFailed: "Failed to send defund channel tx",
ChannelDisputeTxFailed: "Failed to send dispute channel tx",
ChannelNotInDispute: "Channel is not in dispute",
ChannelNotFound: "Channel not found",
CouldNotGetActiveTransfers: "Failed to retrieve active transfers from store",
CouldNotGetChannel: "Failed to retrieve channel from store",
CouldNotGetTransfer: "Failed to retrieve transfer from store",
TransferNotFound: "Transfer not found",
TransferNotDisputed: "Transfer not in dispute",
TransferDefundTxFailed: "Failed to send defund transfer tx",
TransferDisputeTxFailed: "Failed to send dispute transfer tx",
Unknown: "Unknown dispute error",
} as const;
constructor(
public readonly message: Values<typeof DisputeError.reasons>,
channelAddress: string,
publicIdentifier: string,
context: any = {},
) {
super(message, channelAddress, publicIdentifier, context, DisputeError.type);
}
}
export class CheckInError extends EngineError {
static readonly type = "CheckInError";
static readonly reasons = {
ChannelNotFound: "Channel not found",
Unknown: "Unknown check-in error",
} as const;
constructor(
public readonly message: Values<typeof CheckInError.reasons>,
channelAddress: string,
publicIdentifier: string,
context: any = {},
) {
super(message, channelAddress, publicIdentifier, context, CheckInError.type);
}
}
export class RestoreError extends EngineError {
static readonly type = "RestoreError";
static readonly reasons = {
AckFailed: "Could not send restore ack",
AcquireLockError: "Failed to acquire restore lock",
ChannelNotFound: "Channel not found",
CouldNotGetActiveTransfers: "Failed to retrieve active transfers from store",
CouldNotGetChannel: "Failed to retrieve channel from store",
GetChannelAddressFailed: "Failed to calculate channel address for verification",
InvalidChannelAddress: "Failed to verify channel address",
InvalidMerkleRoot: "Failed to validate merkleRoot for restoration",
InvalidSignatures: "Failed to validate sigs on latestUpdate",
NoData: "No data sent from counterparty to restore",
ReceivedError: "Got restore error from counterparty",
ReleaseLockError: "Failed to release restore lock",
SaveChannelFailed: "Failed to save channel state",
SyncableState: "Cannot restore, state is syncable. Try reconcileDeposit",
} as const;
constructor(
public readonly message: Values<typeof RestoreError.reasons>,
channelAddress: string,
publicIdentifier: string,
context: any = {},
) {
super(message, channelAddress, publicIdentifier, context, RestoreError.type);
}
}
export class IsAliveError extends EngineError {
static readonly type = "IsAliveError";
static readonly reasons = {
ChannelNotFound: "Channel not found",
Unknown: "Unknown isAlive error",
} as const;
constructor(
public readonly message: Values<typeof IsAliveError.reasons>,
channelAddress: string,
publicIdentifier: string,
context: any = {},
) {
super(message, channelAddress, publicIdentifier, context, IsAliveError.type);
}
}
export class ParameterConversionError extends EngineError {
static readonly type = "ParameterConversionError";
static readonly reasons = {
BobDoesntSubmitAlice: "Bob cannot submit Alice's withdrawals",
CannotSendToSelf: "An initiator cannot be a receiver on the same chain",
CouldNotGetQuote: "Failed to get quote",
CouldNotSignWithdrawal: "Failed to sign withdrawal commitment",
FailedToGetRegisteredTransfer: "Could not get transfer registry information",
FeeGreaterThanAmount: "Fees charged are greater than amount",
NoOp: "Cannot create withdrawal with 0 amount and no call",
WithdrawToZero: "Cannot withdraw to AddressZero",
ChannelNotFound: "Channel not found",
TransferNotFound: "Transfer not found",
} as const;
constructor(
public readonly message: Values<typeof ParameterConversionError.reasons>,
channelAddress: string,
publicIdentifier: string,
context: any = {},
) {
super(message, channelAddress, publicIdentifier, context, ParameterConversionError.type);
}
}
export class RpcError extends EngineError {
static readonly type = "RpcError";
static readonly reasons = {
ChainServiceFailure: "Failed to execute chain service method",
ChannelNotFound: "Channel not found",
DecryptFailed: "Failed to decrypt",
EngineMethodFailure: "Failed to execute engine method",
InvalidParams: "Parameters from rpc request are malformed",
InvalidRpcSchema: "Rpc request is malformed",
InvalidMethod: "Rpc method is invalid",
ParamConversionFailed: "Failed to convert engine ",
ProtocolMethodFailed: "Failed to execute protocol method",
SignerNotInChannel: "Signer is not in channel",
StoreMethodFailed: "Failed to execute store method",
TransferNotFound: "Transfer not found",
SigningFailed: "Failed to sign message",
UtilitySigningFailed: "Failed to sign utility message",
WithdrawResolutionFailed: "Withdrawal commitment not found post-create",
TransactionFound: "Withdrawal transaction found",
CommitmentSingleSigned: "Withdrawal commitment single-signed",
} as const;
constructor(
public readonly message: Values<typeof RpcError.reasons>,
channelAddress: string,
publicIdentifier: string,
context: any = {},
) {
super(message, channelAddress, publicIdentifier, context, RpcError.type);
}
}
export class WithdrawQuoteError extends EngineError {
static readonly type = "WithdrawQuoteError";
static readonly reasons = {
ChannelNotFound: "Channel not found",
ChainServiceFailure: "Chain service method failed",
ExchangeRateError: "Calculating exchange failed",
SignatureFailure: "Signing quote failed",
} as const;
constructor(
public readonly message: Values<typeof WithdrawQuoteError.reasons>,
publicIdentifier: string,
request: EngineParams.GetWithdrawalQuote,
context: any = {},
) {
super(message, request.channelAddress, publicIdentifier, context, WithdrawQuoteError.type);
}
}