@heliofi/withdraw-react 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/withdraw-react.es.d.ts +422 -0
- package/package.json +3 -3
- package/dist/apps/withdraw-react/src/api/errors.d.ts +0 -24
- package/dist/apps/withdraw-react/src/balance/useGetBalances.d.ts +0 -10
- package/dist/apps/withdraw-react/src/components/DebugPanel.d.ts +0 -4
- package/dist/apps/withdraw-react/src/components/moonPayCommerceWithdraw.d.ts +0 -3
- package/dist/apps/withdraw-react/src/config/useGetWithdraw.d.ts +0 -10
- package/dist/apps/withdraw-react/src/constants/steps.d.ts +0 -5
- package/dist/apps/withdraw-react/src/crypto-flow/WithdrawCryptoMachineProvider.d.ts +0 -6
- package/dist/apps/withdraw-react/src/crypto-flow/machine.d.ts +0 -107
- package/dist/apps/withdraw-react/src/crypto-flow/types.d.ts +0 -65
- package/dist/apps/withdraw-react/src/crypto-flow/withdrawCryptoSteps.d.ts +0 -2
- package/dist/apps/withdraw-react/src/crypto-form/AmountInput/constants.d.ts +0 -4
- package/dist/apps/withdraw-react/src/crypto-form/AmountInput/index.d.ts +0 -1
- package/dist/apps/withdraw-react/src/crypto-form/CryptoFormDisplay.d.ts +0 -11
- package/dist/apps/withdraw-react/src/crypto-form/CryptoFormScreen.d.ts +0 -1
- package/dist/apps/withdraw-react/src/crypto-form/CryptoFormStateProvider.d.ts +0 -14
- package/dist/apps/withdraw-react/src/crypto-form/QuoteSummaryCard.d.ts +0 -6
- package/dist/apps/withdraw-react/src/crypto-form/RecipientAddressInput.d.ts +0 -1
- package/dist/apps/withdraw-react/src/crypto-form/constants.d.ts +0 -2
- package/dist/apps/withdraw-react/src/crypto-form/fixtures.d.ts +0 -12
- package/dist/apps/withdraw-react/src/crypto-form/types.d.ts +0 -5
- package/dist/apps/withdraw-react/src/crypto-form/useCryptoForm.d.ts +0 -17
- package/dist/apps/withdraw-react/src/crypto-form/useQuoteManager.d.ts +0 -7
- package/dist/apps/withdraw-react/src/crypto-form/utils/index.d.ts +0 -4
- package/dist/apps/withdraw-react/src/crypto-form/utils/numbers.d.ts +0 -3
- package/dist/apps/withdraw-react/src/flow/CryptoCompletedScreen.d.ts +0 -1
- package/dist/apps/withdraw-react/src/flow/CryptoErrorScreen.d.ts +0 -6
- package/dist/apps/withdraw-react/src/flow/CryptoLoadErrorScreen.d.ts +0 -1
- package/dist/apps/withdraw-react/src/flow/CryptoLoadingScreen.d.ts +0 -1
- package/dist/apps/withdraw-react/src/flow/CryptoSigningScreen.d.ts +0 -1
- package/dist/apps/withdraw-react/src/flow/CryptoStatusScreen.d.ts +0 -1
- package/dist/apps/withdraw-react/src/flow/CryptoSubmitErrorScreen.d.ts +0 -1
- package/dist/apps/withdraw-react/src/flow/CryptoSubmittingScreen.d.ts +0 -1
- package/dist/apps/withdraw-react/src/flow/RouteSelectionScreen.d.ts +0 -1
- package/dist/apps/withdraw-react/src/flow/WithdrawFlowContent.d.ts +0 -3
- package/dist/apps/withdraw-react/src/flow/WithdrawFlowContext.d.ts +0 -1
- package/dist/apps/withdraw-react/src/flow/hooks/useErrorCallback.d.ts +0 -3
- package/dist/apps/withdraw-react/src/flow/hooks/useSigning.d.ts +0 -1
- package/dist/apps/withdraw-react/src/flow/hooks/useStatusPolling.d.ts +0 -3
- package/dist/apps/withdraw-react/src/flow/hooks/useSubmitting.d.ts +0 -1
- package/dist/apps/withdraw-react/src/flow/hooks/useSuccessCallback.d.ts +0 -3
- package/dist/apps/withdraw-react/src/flow/never.d.ts +0 -1
- package/dist/apps/withdraw-react/src/flow/types.d.ts +0 -70
- package/dist/apps/withdraw-react/src/flow/utils.d.ts +0 -1
- package/dist/apps/withdraw-react/src/index.d.ts +0 -21
- package/dist/apps/withdraw-react/src/main.d.ts +0 -0
- package/dist/apps/withdraw-react/src/provider/WithdrawProvider/WithdrawProvider.d.ts +0 -5
- package/dist/apps/withdraw-react/src/provider/WithdrawProvider/index.d.ts +0 -2
- package/dist/apps/withdraw-react/src/provider/WithdrawProvider/types.d.ts +0 -14
- package/dist/apps/withdraw-react/src/provider/WithdrawStoreProvider.d.ts +0 -7
- package/dist/apps/withdraw-react/src/quote/usePrepare.d.ts +0 -11
- package/dist/apps/withdraw-react/src/routes/useGetRoutes.d.ts +0 -13
- package/dist/apps/withdraw-react/src/select/WithdrawBlockchainSelect.d.ts +0 -7
- package/dist/apps/withdraw-react/src/select/WithdrawBlockchainSelectStep.d.ts +0 -1
- package/dist/apps/withdraw-react/src/select/WithdrawCurrencySelect.d.ts +0 -7
- package/dist/apps/withdraw-react/src/select/WithdrawCurrencySelectStep.d.ts +0 -1
- package/dist/apps/withdraw-react/src/select/deriveRouteOptions.d.ts +0 -8
- package/dist/apps/withdraw-react/src/setupTests.d.ts +0 -0
- package/dist/apps/withdraw-react/src/status/useGetStatus.d.ts +0 -10
- package/dist/apps/withdraw-react/src/submit/useSubmitWithdraw.d.ts +0 -11
- package/dist/apps/withdraw-react/src/test/fixtures.d.ts +0 -73
- package/dist/apps/withdraw-react/src/test/setupFetchMock.d.ts +0 -57
- package/dist/apps/withdraw-react/src/test/types.d.ts +0 -3
- package/dist/apps/withdraw-react/src/test-utils.d.ts +0 -5
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import { AnyActorRef } from 'xstate';
|
|
2
|
+
import { ApiClientConfig } from '@heliofi/withdraw-core';
|
|
3
|
+
import { BalanceResponse } from '@heliofi/withdraw-core';
|
|
4
|
+
import { EventObject } from 'xstate';
|
|
5
|
+
import { MetaObject } from 'xstate';
|
|
6
|
+
import { NonReducibleUnknown } from 'xstate';
|
|
7
|
+
import { ParameterizedObject } from 'xstate';
|
|
8
|
+
import { PolymarketWalletPreparedTransaction } from '@heliofi/withdraw-core';
|
|
9
|
+
import { PreparedTransaction } from '@heliofi/withdraw-core';
|
|
10
|
+
import { PrepareWithdrawalParams } from '@heliofi/withdraw-core';
|
|
11
|
+
import { ProvidedActor } from 'xstate';
|
|
12
|
+
import { QuoteResponse } from '@heliofi/withdraw-core';
|
|
13
|
+
import { QuoteSummary } from '@heliofi/withdraw-core';
|
|
14
|
+
import { RawPreparedTransaction } from '@heliofi/withdraw-core';
|
|
15
|
+
import { ReactNode } from 'react';
|
|
16
|
+
import { RoutesResponse } from '@heliofi/withdraw-core';
|
|
17
|
+
import { SignedTransactionKind } from '@heliofi/withdraw-core';
|
|
18
|
+
import { StateMachine } from 'xstate';
|
|
19
|
+
import { StateValue } from 'xstate';
|
|
20
|
+
import { StatusResponse } from '@heliofi/withdraw-core';
|
|
21
|
+
import { SubmitResponse } from '@heliofi/withdraw-core';
|
|
22
|
+
import { SubmitWithdrawalParams } from '@heliofi/withdraw-core';
|
|
23
|
+
import { TERMINAL_STATES } from '@heliofi/withdraw-core';
|
|
24
|
+
import type { useMachine } from '@xstate/react';
|
|
25
|
+
import { UserOpPreparedTransaction } from '@heliofi/withdraw-core';
|
|
26
|
+
import { WithdrawalApiError } from '@heliofi/withdraw-core';
|
|
27
|
+
import { WithdrawalConfig } from '@heliofi/withdraw-core';
|
|
28
|
+
import type { WithdrawalCustomerSwapRoute } from '@heliofi/withdraw-core';
|
|
29
|
+
import { WithdrawalErrorCode } from '@heliofi/withdraw-core';
|
|
30
|
+
import { WithdrawalJwtPayload } from '@heliofi/withdraw-core';
|
|
31
|
+
import type { WithdrawalSDK } from '@heliofi/withdraw-core';
|
|
32
|
+
import { WithdrawalState } from '@heliofi/withdraw-core';
|
|
33
|
+
|
|
34
|
+
export { ApiClientConfig }
|
|
35
|
+
|
|
36
|
+
export { BalanceResponse }
|
|
37
|
+
|
|
38
|
+
export declare type BlockchainEngineType = 'EVM' | 'SOL' | 'BTC' | 'TRON';
|
|
39
|
+
|
|
40
|
+
export declare enum FormInputState {
|
|
41
|
+
EDITING = "editing",
|
|
42
|
+
QUOTING = "quoting",
|
|
43
|
+
QUOTED = "quoted"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export declare const MoonPayCommerceWithdraw: (props: MoonPayCommerceWithdrawProps) => JSX.Element;
|
|
47
|
+
|
|
48
|
+
export declare interface MoonPayCommerceWithdrawProps {
|
|
49
|
+
withdrawalConfigId: string;
|
|
50
|
+
publicApiKey: string;
|
|
51
|
+
handleSign: (signingPayload: SigningPayload) => Promise<string>;
|
|
52
|
+
sourceWalletAddress: string;
|
|
53
|
+
onSuccess?: (result: WithdrawResult) => void;
|
|
54
|
+
onError?: (error: WithdrawError) => void;
|
|
55
|
+
connectedWalletAddress?: string;
|
|
56
|
+
connectedWalletEngineType?: BlockchainEngineType;
|
|
57
|
+
baseUrl?: string;
|
|
58
|
+
debug?: boolean;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { PolymarketWalletPreparedTransaction }
|
|
62
|
+
|
|
63
|
+
export { PreparedTransaction }
|
|
64
|
+
|
|
65
|
+
export { PrepareWithdrawalParams }
|
|
66
|
+
|
|
67
|
+
export { QuoteResponse }
|
|
68
|
+
|
|
69
|
+
export { QuoteSummary }
|
|
70
|
+
|
|
71
|
+
export { RawPreparedTransaction }
|
|
72
|
+
|
|
73
|
+
export { RoutesResponse }
|
|
74
|
+
|
|
75
|
+
export { SignedTransactionKind }
|
|
76
|
+
|
|
77
|
+
export declare interface SigningPayload {
|
|
78
|
+
kind: 'transaction' | 'typed_data';
|
|
79
|
+
data: unknown;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export { StatusResponse }
|
|
83
|
+
|
|
84
|
+
export { SubmitResponse }
|
|
85
|
+
|
|
86
|
+
export { SubmitWithdrawalParams }
|
|
87
|
+
|
|
88
|
+
export { TERMINAL_STATES }
|
|
89
|
+
|
|
90
|
+
declare interface UseGetBalanceResult {
|
|
91
|
+
data: BalanceResponse | undefined;
|
|
92
|
+
isLoading: boolean;
|
|
93
|
+
isError: boolean;
|
|
94
|
+
error: WithdrawQueryError | undefined;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export declare const useGetBalances: (fromWallet: string | undefined) => UseGetBalanceResult;
|
|
98
|
+
|
|
99
|
+
export declare const useGetRoutes: () => UseGetRoutesResult;
|
|
100
|
+
|
|
101
|
+
declare interface UseGetRoutesResult {
|
|
102
|
+
data: RoutesResponse | undefined;
|
|
103
|
+
availableRoutes: WithdrawalCustomerSwapRoute[];
|
|
104
|
+
routesById: Record<string, WithdrawalCustomerSwapRoute>;
|
|
105
|
+
isLoading: boolean;
|
|
106
|
+
isError: boolean;
|
|
107
|
+
isSuccess: boolean;
|
|
108
|
+
error: WithdrawQueryError | undefined;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export declare const useGetStatus: (withdrawalDetailId: string | undefined) => UseGetStatusResult;
|
|
112
|
+
|
|
113
|
+
declare interface UseGetStatusResult {
|
|
114
|
+
data: StatusResponse | undefined;
|
|
115
|
+
isLoading: boolean;
|
|
116
|
+
isError: boolean;
|
|
117
|
+
error: WithdrawQueryError | undefined;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export declare const useGetWithdraw: () => UseGetWithdrawResult;
|
|
121
|
+
|
|
122
|
+
declare interface UseGetWithdrawResult {
|
|
123
|
+
data: WithdrawalConfig | undefined;
|
|
124
|
+
isLoading: boolean;
|
|
125
|
+
isError: boolean;
|
|
126
|
+
error: WithdrawQueryError | undefined;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export declare const usePrepare: () => UsePrepareResult;
|
|
130
|
+
|
|
131
|
+
declare interface UsePrepareResult {
|
|
132
|
+
trigger: (params: PrepareWithdrawalParams) => Promise<QuoteResponse>;
|
|
133
|
+
data: QuoteResponse | undefined;
|
|
134
|
+
isLoading: boolean;
|
|
135
|
+
isError: boolean;
|
|
136
|
+
error: WithdrawQueryError | undefined;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export { UserOpPreparedTransaction }
|
|
140
|
+
|
|
141
|
+
export declare const useSubmitWithdraw: () => UseSubmitWithdrawResult;
|
|
142
|
+
|
|
143
|
+
declare interface UseSubmitWithdrawResult {
|
|
144
|
+
trigger: (params: SubmitWithdrawalParams) => Promise<SubmitResponse>;
|
|
145
|
+
data: SubmitResponse | undefined;
|
|
146
|
+
isLoading: boolean;
|
|
147
|
+
isError: boolean;
|
|
148
|
+
error: WithdrawQueryError | undefined;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
declare const useWithdrawContext: () => WithdrawFlowContextValue;
|
|
152
|
+
export { useWithdrawContext }
|
|
153
|
+
export { useWithdrawContext as useWithdrawFlowContext }
|
|
154
|
+
|
|
155
|
+
export declare const useWithdrawCryptoMachine: () => WithdrawCryptoMachineContextValue;
|
|
156
|
+
|
|
157
|
+
export { WithdrawalApiError }
|
|
158
|
+
|
|
159
|
+
export { WithdrawalConfig }
|
|
160
|
+
|
|
161
|
+
export { WithdrawalErrorCode }
|
|
162
|
+
|
|
163
|
+
export { WithdrawalJwtPayload }
|
|
164
|
+
|
|
165
|
+
export { WithdrawalState }
|
|
166
|
+
|
|
167
|
+
export declare interface WithdrawCryptoContext {
|
|
168
|
+
toCurrencyId?: string;
|
|
169
|
+
withdrawalDetailId?: string;
|
|
170
|
+
quote?: QuoteResponse;
|
|
171
|
+
signature?: string;
|
|
172
|
+
error?: WithdrawError;
|
|
173
|
+
result?: WithdrawResult;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export declare type WithdrawCryptoEvent = {
|
|
177
|
+
type: 'LOADED';
|
|
178
|
+
initialCurrencyId?: string;
|
|
179
|
+
} | {
|
|
180
|
+
type: 'LOAD_FAILED';
|
|
181
|
+
error: WithdrawError;
|
|
182
|
+
} | {
|
|
183
|
+
type: 'OPEN_CURRENCY_SELECT';
|
|
184
|
+
} | {
|
|
185
|
+
type: 'OPEN_BLOCKCHAIN_SELECT';
|
|
186
|
+
} | {
|
|
187
|
+
type: 'SELECT_CURRENCY';
|
|
188
|
+
toCurrencyId: string;
|
|
189
|
+
} | {
|
|
190
|
+
type: 'SELECT_BLOCKCHAIN';
|
|
191
|
+
toCurrencyId: string;
|
|
192
|
+
} | {
|
|
193
|
+
type: 'BACK';
|
|
194
|
+
} | {
|
|
195
|
+
type: 'FIELDS_CHANGED';
|
|
196
|
+
} | {
|
|
197
|
+
type: 'QUOTE_REQUESTED';
|
|
198
|
+
} | {
|
|
199
|
+
type: 'QUOTE_SUCCESS';
|
|
200
|
+
withdrawalDetailId: string;
|
|
201
|
+
quote: QuoteResponse;
|
|
202
|
+
} | {
|
|
203
|
+
type: 'QUOTE_ERROR';
|
|
204
|
+
error: WithdrawError;
|
|
205
|
+
} | {
|
|
206
|
+
type: 'CONTINUE';
|
|
207
|
+
} | {
|
|
208
|
+
type: 'SIGNED';
|
|
209
|
+
signedPayload: string;
|
|
210
|
+
} | {
|
|
211
|
+
type: 'SIGN_FAILED';
|
|
212
|
+
error: WithdrawError;
|
|
213
|
+
} | {
|
|
214
|
+
type: 'SUBMITTED';
|
|
215
|
+
} | {
|
|
216
|
+
type: 'SUBMIT_FAILED';
|
|
217
|
+
error: WithdrawError;
|
|
218
|
+
} | {
|
|
219
|
+
type: 'COMPLETED';
|
|
220
|
+
result: WithdrawResult;
|
|
221
|
+
} | {
|
|
222
|
+
type: 'FAILED';
|
|
223
|
+
error: WithdrawError;
|
|
224
|
+
} | {
|
|
225
|
+
type: 'BACK_TO_FORM';
|
|
226
|
+
} | {
|
|
227
|
+
type: 'RETRY';
|
|
228
|
+
} | {
|
|
229
|
+
type: 'RESET';
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export declare const withdrawCryptoEvents: {
|
|
233
|
+
loaded: (initialCurrencyId?: string) => WithdrawCryptoEvent;
|
|
234
|
+
loadFailed: (error: WithdrawError) => WithdrawCryptoEvent;
|
|
235
|
+
openCurrencySelect: () => WithdrawCryptoEvent;
|
|
236
|
+
openBlockchainSelect: () => WithdrawCryptoEvent;
|
|
237
|
+
selectCurrency: (toCurrencyId: string) => WithdrawCryptoEvent;
|
|
238
|
+
selectBlockchain: (toCurrencyId: string) => WithdrawCryptoEvent;
|
|
239
|
+
back: () => WithdrawCryptoEvent;
|
|
240
|
+
fieldsChanged: () => WithdrawCryptoEvent;
|
|
241
|
+
quoteRequested: () => WithdrawCryptoEvent;
|
|
242
|
+
quoteSuccess: (withdrawalDetailId: string, quote: QuoteResponse) => WithdrawCryptoEvent;
|
|
243
|
+
quoteError: (error: WithdrawError) => WithdrawCryptoEvent;
|
|
244
|
+
continue: () => WithdrawCryptoEvent;
|
|
245
|
+
signed: (signedPayload: string) => WithdrawCryptoEvent;
|
|
246
|
+
signFailed: (error: WithdrawError) => WithdrawCryptoEvent;
|
|
247
|
+
submitted: () => WithdrawCryptoEvent;
|
|
248
|
+
submitFailed: (error: WithdrawError) => WithdrawCryptoEvent;
|
|
249
|
+
completed: (result: WithdrawResult) => WithdrawCryptoEvent;
|
|
250
|
+
failed: (error: WithdrawError) => WithdrawCryptoEvent;
|
|
251
|
+
backToForm: () => WithdrawCryptoEvent;
|
|
252
|
+
retry: () => WithdrawCryptoEvent;
|
|
253
|
+
reset: () => WithdrawCryptoEvent;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
declare const withdrawCryptoMachine: StateMachine<WithdrawCryptoContext, {
|
|
257
|
+
type: "LOADED";
|
|
258
|
+
initialCurrencyId?: string | undefined;
|
|
259
|
+
} | {
|
|
260
|
+
type: "LOAD_FAILED";
|
|
261
|
+
error: WithdrawError;
|
|
262
|
+
} | {
|
|
263
|
+
type: "OPEN_CURRENCY_SELECT";
|
|
264
|
+
} | {
|
|
265
|
+
type: "OPEN_BLOCKCHAIN_SELECT";
|
|
266
|
+
} | {
|
|
267
|
+
type: "SELECT_CURRENCY";
|
|
268
|
+
toCurrencyId: string;
|
|
269
|
+
} | {
|
|
270
|
+
type: "SELECT_BLOCKCHAIN";
|
|
271
|
+
toCurrencyId: string;
|
|
272
|
+
} | {
|
|
273
|
+
type: "BACK";
|
|
274
|
+
} | {
|
|
275
|
+
type: "FIELDS_CHANGED";
|
|
276
|
+
} | {
|
|
277
|
+
type: "QUOTE_REQUESTED";
|
|
278
|
+
} | {
|
|
279
|
+
type: "QUOTE_SUCCESS";
|
|
280
|
+
withdrawalDetailId: string;
|
|
281
|
+
quote: QuoteResponse;
|
|
282
|
+
} | {
|
|
283
|
+
type: "QUOTE_ERROR";
|
|
284
|
+
error: WithdrawError;
|
|
285
|
+
} | {
|
|
286
|
+
type: "CONTINUE";
|
|
287
|
+
} | {
|
|
288
|
+
type: "SIGNED";
|
|
289
|
+
signedPayload: string;
|
|
290
|
+
} | {
|
|
291
|
+
type: "SIGN_FAILED";
|
|
292
|
+
error: WithdrawError;
|
|
293
|
+
} | {
|
|
294
|
+
type: "SUBMITTED";
|
|
295
|
+
} | {
|
|
296
|
+
type: "SUBMIT_FAILED";
|
|
297
|
+
error: WithdrawError;
|
|
298
|
+
} | {
|
|
299
|
+
type: "COMPLETED";
|
|
300
|
+
result: WithdrawResult;
|
|
301
|
+
} | {
|
|
302
|
+
type: "FAILED";
|
|
303
|
+
error: WithdrawError;
|
|
304
|
+
} | {
|
|
305
|
+
type: "BACK_TO_FORM";
|
|
306
|
+
} | {
|
|
307
|
+
type: "RETRY";
|
|
308
|
+
} | {
|
|
309
|
+
type: "RESET";
|
|
310
|
+
}, Record<string, AnyActorRef>, ProvidedActor, ParameterizedObject, ParameterizedObject, string, StateValue, string, unknown, NonReducibleUnknown, EventObject, MetaObject, any>;
|
|
311
|
+
|
|
312
|
+
declare interface WithdrawCryptoMachineContextValue {
|
|
313
|
+
state: ReturnType<typeof useMachine<typeof withdrawCryptoMachine>>[0];
|
|
314
|
+
send: ReturnType<typeof useMachine<typeof withdrawCryptoMachine>>[1];
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export declare const WithdrawCryptoMachineProvider: ({ children, }: {
|
|
318
|
+
children: ReactNode;
|
|
319
|
+
}) => JSX.Element;
|
|
320
|
+
|
|
321
|
+
export declare enum WithdrawCryptoState {
|
|
322
|
+
LOADING = "loading",
|
|
323
|
+
LOAD_ERROR = "loadError",
|
|
324
|
+
FORM_INPUT = "formInput",
|
|
325
|
+
CURRENCY_SELECT = "currencySelect",
|
|
326
|
+
BLOCKCHAIN_SELECT = "blockchainSelect",
|
|
327
|
+
SIGNING = "signing",
|
|
328
|
+
SIGN_ERROR = "signError",
|
|
329
|
+
SUBMITTING = "submitting",
|
|
330
|
+
SUBMIT_ERROR = "submitError",
|
|
331
|
+
STATUS = "status",
|
|
332
|
+
COMPLETED = "completed",
|
|
333
|
+
FAILED = "failed"
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export declare interface WithdrawError {
|
|
337
|
+
code: WithdrawErrorCode;
|
|
338
|
+
message: string;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
declare enum WithdrawErrorCode {
|
|
342
|
+
LOAD_FAILED = "LOAD_FAILED",
|
|
343
|
+
MISSING_ID = "MISSING_ID",
|
|
344
|
+
QUOTE_FAILED = "QUOTE_FAILED",
|
|
345
|
+
SIGN_FAILED = "SIGN_FAILED",
|
|
346
|
+
SUBMIT_FAILED = "SUBMIT_FAILED",
|
|
347
|
+
STATUS_FAILED = "STATUS_FAILED"
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export declare interface WithdrawFlowContextValue {
|
|
351
|
+
withdrawalConfigId: string | undefined;
|
|
352
|
+
withdrawalConfig: WithdrawalConfig | undefined;
|
|
353
|
+
withdrawalConfigLoading: boolean;
|
|
354
|
+
withdrawalConfigError: boolean;
|
|
355
|
+
sourceWalletAddress: string | undefined;
|
|
356
|
+
handleSign: (signingPayload: SigningPayload) => Promise<string>;
|
|
357
|
+
onSuccess?: (result: WithdrawResult) => void;
|
|
358
|
+
onError?: (error: WithdrawError) => void;
|
|
359
|
+
connectedWalletAddress?: string;
|
|
360
|
+
connectedWalletEngineType?: BlockchainEngineType;
|
|
361
|
+
activeFlow: WithdrawFlowType | null;
|
|
362
|
+
setActiveFlow: (flow: WithdrawFlowType | null) => void;
|
|
363
|
+
currentStep: WithdrawStepId;
|
|
364
|
+
setCurrentStep: (step: WithdrawStepId) => void;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export declare enum WithdrawFlowType {
|
|
368
|
+
CRYPTO = "crypto",
|
|
369
|
+
CARD_BANK = "card_bank"
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export declare const WithdrawProvider: ({ publicApiKey, baseUrl, ...rest }: WithdrawProviderProps) => JSX.Element;
|
|
373
|
+
|
|
374
|
+
export declare interface WithdrawProviderProps {
|
|
375
|
+
publicApiKey: string;
|
|
376
|
+
baseUrl?: string;
|
|
377
|
+
withdrawalConfigId?: string;
|
|
378
|
+
sourceWalletAddress?: string;
|
|
379
|
+
handleSign: (signingPayload: SigningPayload) => Promise<string>;
|
|
380
|
+
onSuccess?: (result: WithdrawResult) => void;
|
|
381
|
+
onError?: (error: WithdrawError) => void;
|
|
382
|
+
connectedWalletAddress?: string;
|
|
383
|
+
connectedWalletEngineType?: BlockchainEngineType;
|
|
384
|
+
children: ReactNode;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
declare interface WithdrawQueryError {
|
|
388
|
+
reason: string;
|
|
389
|
+
originalError: Error;
|
|
390
|
+
code?: WithdrawalErrorCode;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export declare interface WithdrawResult {
|
|
394
|
+
withdrawalDetailId: string;
|
|
395
|
+
status: string;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
export declare enum WithdrawStepId {
|
|
399
|
+
ROUTE_SELECT = "route_select",
|
|
400
|
+
CRYPTO_LOADING = "crypto_loading",
|
|
401
|
+
CRYPTO_LOAD_ERROR = "crypto_load_error",
|
|
402
|
+
CRYPTO_FORM = "crypto_form",
|
|
403
|
+
CRYPTO_CURRENCY_SELECT = "crypto_currency_select",
|
|
404
|
+
CRYPTO_BLOCKCHAIN_SELECT = "crypto_blockchain_select",
|
|
405
|
+
CRYPTO_SIGNING = "crypto_signing",
|
|
406
|
+
CRYPTO_SIGN_ERROR = "crypto_sign_error",
|
|
407
|
+
CRYPTO_SUBMITTING = "crypto_submitting",
|
|
408
|
+
CRYPTO_SUBMIT_ERROR = "crypto_submit_error",
|
|
409
|
+
CRYPTO_STATUS = "crypto_status",
|
|
410
|
+
CRYPTO_COMPLETED = "crypto_completed",
|
|
411
|
+
CRYPTO_FAILED = "crypto_failed",
|
|
412
|
+
CARD_BANK_COMING_SOON = "card_bank_coming_soon"
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export declare const WithdrawStoreProvider: ({ sdk, children, }: WithdrawStoreProviderProps) => JSX.Element;
|
|
416
|
+
|
|
417
|
+
export declare interface WithdrawStoreProviderProps {
|
|
418
|
+
sdk: WithdrawalSDK;
|
|
419
|
+
children: ReactNode;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export { }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heliofi/withdraw-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite --port=8097",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
},
|
|
21
21
|
"main": "./dist/withdraw-react.es.js",
|
|
22
22
|
"module": "./dist/withdraw-react.es.js",
|
|
23
|
-
"types": "./dist/
|
|
23
|
+
"types": "./dist/withdraw-react.es.d.ts",
|
|
24
24
|
"style": "./dist/withdraw-react.css",
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
27
|
-
"types": "./dist/
|
|
27
|
+
"types": "./dist/withdraw-react.es.d.ts",
|
|
28
28
|
"import": "./dist/withdraw-react.es.js"
|
|
29
29
|
},
|
|
30
30
|
"./dist/withdraw-react.css": "./dist/withdraw-react.css"
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { WithdrawalErrorCode } from '@heliofi/withdraw-core';
|
|
2
|
-
export interface WithdrawQueryError {
|
|
3
|
-
reason: string;
|
|
4
|
-
originalError: Error;
|
|
5
|
-
code?: WithdrawalErrorCode;
|
|
6
|
-
}
|
|
7
|
-
export declare enum RecoveryActionType {
|
|
8
|
-
GO_BACK = "GO_BACK"
|
|
9
|
-
}
|
|
10
|
-
export type ErrorRecoveryAction = {
|
|
11
|
-
type: RecoveryActionType;
|
|
12
|
-
};
|
|
13
|
-
export interface ErrorDisplay {
|
|
14
|
-
message: string;
|
|
15
|
-
buttonLabel: string;
|
|
16
|
-
recovery: ErrorRecoveryAction;
|
|
17
|
-
}
|
|
18
|
-
export declare const getErrorDisplay: (code: string) => ErrorDisplay;
|
|
19
|
-
export declare const returnData: <T>(data: T) => {
|
|
20
|
-
data: T;
|
|
21
|
-
};
|
|
22
|
-
export declare const returnError: (err: unknown, reason: string) => {
|
|
23
|
-
error: WithdrawQueryError;
|
|
24
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { BalanceResponse } from '@heliofi/withdraw-core';
|
|
2
|
-
import type { WithdrawQueryError } from '../api/errors';
|
|
3
|
-
interface UseGetBalanceResult {
|
|
4
|
-
data: BalanceResponse | undefined;
|
|
5
|
-
isLoading: boolean;
|
|
6
|
-
isError: boolean;
|
|
7
|
-
error: WithdrawQueryError | undefined;
|
|
8
|
-
}
|
|
9
|
-
export declare const useGetBalances: (fromWallet: string | undefined) => UseGetBalanceResult;
|
|
10
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { WithdrawalConfig } from '@heliofi/withdraw-core';
|
|
2
|
-
import type { WithdrawQueryError } from '../api/errors';
|
|
3
|
-
interface UseGetWithdrawResult {
|
|
4
|
-
data: WithdrawalConfig | undefined;
|
|
5
|
-
isLoading: boolean;
|
|
6
|
-
isError: boolean;
|
|
7
|
-
error: WithdrawQueryError | undefined;
|
|
8
|
-
}
|
|
9
|
-
export declare const useGetWithdraw: () => UseGetWithdrawResult;
|
|
10
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
import { type WithdrawCryptoMachineContextValue } from './machine';
|
|
3
|
-
export declare const WithdrawCryptoMachineProvider: ({ children, }: {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
}) => JSX.Element;
|
|
6
|
-
export declare const useWithdrawCryptoMachine: () => WithdrawCryptoMachineContextValue;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import type { QuoteResponse } from '@heliofi/withdraw-core';
|
|
2
|
-
import type { useMachine } from '@xstate/react';
|
|
3
|
-
import type { WithdrawCryptoContext, WithdrawCryptoEvent } from './types';
|
|
4
|
-
import type { WithdrawError, WithdrawResult } from '../flow/types';
|
|
5
|
-
import { WithdrawStepId } from '../flow/types';
|
|
6
|
-
export declare enum WithdrawCryptoState {
|
|
7
|
-
LOADING = "loading",
|
|
8
|
-
LOAD_ERROR = "loadError",
|
|
9
|
-
FORM_INPUT = "formInput",
|
|
10
|
-
CURRENCY_SELECT = "currencySelect",
|
|
11
|
-
BLOCKCHAIN_SELECT = "blockchainSelect",
|
|
12
|
-
SIGNING = "signing",
|
|
13
|
-
SIGN_ERROR = "signError",
|
|
14
|
-
SUBMITTING = "submitting",
|
|
15
|
-
SUBMIT_ERROR = "submitError",
|
|
16
|
-
STATUS = "status",
|
|
17
|
-
COMPLETED = "completed",
|
|
18
|
-
FAILED = "failed"
|
|
19
|
-
}
|
|
20
|
-
export declare enum FormInputState {
|
|
21
|
-
EDITING = "editing",
|
|
22
|
-
QUOTING = "quoting",
|
|
23
|
-
QUOTED = "quoted"
|
|
24
|
-
}
|
|
25
|
-
export declare const withdrawCryptoMachine: import("xstate").StateMachine<WithdrawCryptoContext, {
|
|
26
|
-
type: "LOADED";
|
|
27
|
-
initialCurrencyId?: string | undefined;
|
|
28
|
-
} | {
|
|
29
|
-
type: "LOAD_FAILED";
|
|
30
|
-
error: WithdrawError;
|
|
31
|
-
} | {
|
|
32
|
-
type: "OPEN_CURRENCY_SELECT";
|
|
33
|
-
} | {
|
|
34
|
-
type: "OPEN_BLOCKCHAIN_SELECT";
|
|
35
|
-
} | {
|
|
36
|
-
type: "SELECT_CURRENCY";
|
|
37
|
-
toCurrencyId: string;
|
|
38
|
-
} | {
|
|
39
|
-
type: "SELECT_BLOCKCHAIN";
|
|
40
|
-
toCurrencyId: string;
|
|
41
|
-
} | {
|
|
42
|
-
type: "BACK";
|
|
43
|
-
} | {
|
|
44
|
-
type: "FIELDS_CHANGED";
|
|
45
|
-
} | {
|
|
46
|
-
type: "QUOTE_REQUESTED";
|
|
47
|
-
} | {
|
|
48
|
-
type: "QUOTE_SUCCESS";
|
|
49
|
-
withdrawalDetailId: string;
|
|
50
|
-
quote: QuoteResponse;
|
|
51
|
-
} | {
|
|
52
|
-
type: "QUOTE_ERROR";
|
|
53
|
-
error: WithdrawError;
|
|
54
|
-
} | {
|
|
55
|
-
type: "CONTINUE";
|
|
56
|
-
} | {
|
|
57
|
-
type: "SIGNED";
|
|
58
|
-
signedPayload: string;
|
|
59
|
-
} | {
|
|
60
|
-
type: "SIGN_FAILED";
|
|
61
|
-
error: WithdrawError;
|
|
62
|
-
} | {
|
|
63
|
-
type: "SUBMITTED";
|
|
64
|
-
} | {
|
|
65
|
-
type: "SUBMIT_FAILED";
|
|
66
|
-
error: WithdrawError;
|
|
67
|
-
} | {
|
|
68
|
-
type: "COMPLETED";
|
|
69
|
-
result: WithdrawResult;
|
|
70
|
-
} | {
|
|
71
|
-
type: "FAILED";
|
|
72
|
-
error: WithdrawError;
|
|
73
|
-
} | {
|
|
74
|
-
type: "BACK_TO_FORM";
|
|
75
|
-
} | {
|
|
76
|
-
type: "RETRY";
|
|
77
|
-
} | {
|
|
78
|
-
type: "RESET";
|
|
79
|
-
}, Record<string, import("xstate").AnyActorRef>, import("xstate").ProvidedActor, import("xstate").ParameterizedObject, import("xstate").ParameterizedObject, string, import("xstate").StateValue, string, unknown, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, any>;
|
|
80
|
-
export declare const getStepIdFromMachineState: (stateValue: string | Record<string, unknown>) => WithdrawStepId | undefined;
|
|
81
|
-
export declare const withdrawCryptoEvents: {
|
|
82
|
-
loaded: (initialCurrencyId?: string) => WithdrawCryptoEvent;
|
|
83
|
-
loadFailed: (error: WithdrawError) => WithdrawCryptoEvent;
|
|
84
|
-
openCurrencySelect: () => WithdrawCryptoEvent;
|
|
85
|
-
openBlockchainSelect: () => WithdrawCryptoEvent;
|
|
86
|
-
selectCurrency: (toCurrencyId: string) => WithdrawCryptoEvent;
|
|
87
|
-
selectBlockchain: (toCurrencyId: string) => WithdrawCryptoEvent;
|
|
88
|
-
back: () => WithdrawCryptoEvent;
|
|
89
|
-
fieldsChanged: () => WithdrawCryptoEvent;
|
|
90
|
-
quoteRequested: () => WithdrawCryptoEvent;
|
|
91
|
-
quoteSuccess: (withdrawalDetailId: string, quote: QuoteResponse) => WithdrawCryptoEvent;
|
|
92
|
-
quoteError: (error: WithdrawError) => WithdrawCryptoEvent;
|
|
93
|
-
continue: () => WithdrawCryptoEvent;
|
|
94
|
-
signed: (signedPayload: string) => WithdrawCryptoEvent;
|
|
95
|
-
signFailed: (error: WithdrawError) => WithdrawCryptoEvent;
|
|
96
|
-
submitted: () => WithdrawCryptoEvent;
|
|
97
|
-
submitFailed: (error: WithdrawError) => WithdrawCryptoEvent;
|
|
98
|
-
completed: (result: WithdrawResult) => WithdrawCryptoEvent;
|
|
99
|
-
failed: (error: WithdrawError) => WithdrawCryptoEvent;
|
|
100
|
-
backToForm: () => WithdrawCryptoEvent;
|
|
101
|
-
retry: () => WithdrawCryptoEvent;
|
|
102
|
-
reset: () => WithdrawCryptoEvent;
|
|
103
|
-
};
|
|
104
|
-
export interface WithdrawCryptoMachineContextValue {
|
|
105
|
-
state: ReturnType<typeof useMachine<typeof withdrawCryptoMachine>>[0];
|
|
106
|
-
send: ReturnType<typeof useMachine<typeof withdrawCryptoMachine>>[1];
|
|
107
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { QuoteResponse } from '@heliofi/withdraw-core';
|
|
2
|
-
import type { WithdrawError, WithdrawResult } from '../flow/types';
|
|
3
|
-
export interface WithdrawCryptoContext {
|
|
4
|
-
toCurrencyId?: string;
|
|
5
|
-
withdrawalDetailId?: string;
|
|
6
|
-
quote?: QuoteResponse;
|
|
7
|
-
signature?: string;
|
|
8
|
-
error?: WithdrawError;
|
|
9
|
-
result?: WithdrawResult;
|
|
10
|
-
}
|
|
11
|
-
export type WithdrawCryptoEvent = {
|
|
12
|
-
type: 'LOADED';
|
|
13
|
-
initialCurrencyId?: string;
|
|
14
|
-
} | {
|
|
15
|
-
type: 'LOAD_FAILED';
|
|
16
|
-
error: WithdrawError;
|
|
17
|
-
} | {
|
|
18
|
-
type: 'OPEN_CURRENCY_SELECT';
|
|
19
|
-
} | {
|
|
20
|
-
type: 'OPEN_BLOCKCHAIN_SELECT';
|
|
21
|
-
} | {
|
|
22
|
-
type: 'SELECT_CURRENCY';
|
|
23
|
-
toCurrencyId: string;
|
|
24
|
-
} | {
|
|
25
|
-
type: 'SELECT_BLOCKCHAIN';
|
|
26
|
-
toCurrencyId: string;
|
|
27
|
-
} | {
|
|
28
|
-
type: 'BACK';
|
|
29
|
-
} | {
|
|
30
|
-
type: 'FIELDS_CHANGED';
|
|
31
|
-
} | {
|
|
32
|
-
type: 'QUOTE_REQUESTED';
|
|
33
|
-
} | {
|
|
34
|
-
type: 'QUOTE_SUCCESS';
|
|
35
|
-
withdrawalDetailId: string;
|
|
36
|
-
quote: QuoteResponse;
|
|
37
|
-
} | {
|
|
38
|
-
type: 'QUOTE_ERROR';
|
|
39
|
-
error: WithdrawError;
|
|
40
|
-
} | {
|
|
41
|
-
type: 'CONTINUE';
|
|
42
|
-
} | {
|
|
43
|
-
type: 'SIGNED';
|
|
44
|
-
signedPayload: string;
|
|
45
|
-
} | {
|
|
46
|
-
type: 'SIGN_FAILED';
|
|
47
|
-
error: WithdrawError;
|
|
48
|
-
} | {
|
|
49
|
-
type: 'SUBMITTED';
|
|
50
|
-
} | {
|
|
51
|
-
type: 'SUBMIT_FAILED';
|
|
52
|
-
error: WithdrawError;
|
|
53
|
-
} | {
|
|
54
|
-
type: 'COMPLETED';
|
|
55
|
-
result: WithdrawResult;
|
|
56
|
-
} | {
|
|
57
|
-
type: 'FAILED';
|
|
58
|
-
error: WithdrawError;
|
|
59
|
-
} | {
|
|
60
|
-
type: 'BACK_TO_FORM';
|
|
61
|
-
} | {
|
|
62
|
-
type: 'RETRY';
|
|
63
|
-
} | {
|
|
64
|
-
type: 'RESET';
|
|
65
|
-
};
|