Skip to content

Commit ed7cfb9

Browse files
update lifecycle
1 parent 6278ae6 commit ed7cfb9

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

src/swap/components/FundSwapProvider.tsx

+40-3
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,16 @@ export function FundSwapProvider({
172172
fromETH.token === undefined ||
173173
fromUSDC.token === undefined
174174
) {
175-
// TODO: update status with required fields
175+
updateLifecycleStatus({
176+
statusName: 'amountChange',
177+
statusData: {
178+
amountETH: fromETH.amount,
179+
amountUSDC: fromUSDC.amount,
180+
amountTo: to.amount,
181+
tokenTo: to.token,
182+
isMissingRequiredField: true,
183+
},
184+
});
176185
return;
177186
}
178187

@@ -187,7 +196,22 @@ export function FundSwapProvider({
187196
fromETH.setLoading(true);
188197
fromUSDC.setLoading(true);
189198

190-
// TODO: update status with amount change
199+
updateLifecycleStatus({
200+
statusName: 'amountChange',
201+
statusData: {
202+
// when fetching quote, the previous
203+
// amount is irrelevant
204+
amountTo: amount,
205+
amountETH: '',
206+
amountUSDC: '',
207+
tokenFromETH: fromETH.token,
208+
tokenFromUSDC: fromUSDC.token,
209+
tokenTo: to.token,
210+
// when fetching quote, the destination
211+
// amount is missing
212+
isMissingRequiredField: true,
213+
},
214+
});
191215

192216
try {
193217
const maxSlippage = lifecycleStatus.statusData.maxSlippage;
@@ -248,7 +272,20 @@ export function FundSwapProvider({
248272
// TODO: revisit this
249273
to.setAmountUSD(responseETH.toAmountUSD);
250274

251-
// TODO: update status with amountChange
275+
updateLifecycleStatus({
276+
statusName: 'amountChange',
277+
statusData: {
278+
amountETH: formattedAmount,
279+
amountUSDC: formattedUSDCAmount,
280+
amountTo: amount,
281+
tokenFromETH: fromETH.token,
282+
tokenFromUSDC: fromUSDC.token,
283+
tokenTo: to.token,
284+
// if quote was fetched successfully, we
285+
// have all required fields
286+
isMissingRequiredField: !formattedAmount,
287+
},
288+
});
252289
} catch (err) {
253290
updateLifecycleStatus({
254291
statusName: 'error',

src/swap/types.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,13 @@ export type LifecycleStatus =
143143
| {
144144
statusName: 'amountChange';
145145
statusData: {
146-
amountFrom: string;
146+
amountFrom?: string;
147+
amountETH?: string;
148+
amountUSDC?: string;
147149
amountTo: string;
148150
tokenFrom?: Token;
151+
tokenFromETH?: Token;
152+
tokenFromUSDC?: Token;
149153
tokenTo?: Token;
150154
} & LifecycleStatusDataShared;
151155
}

0 commit comments

Comments
 (0)