-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix speed up/cancel transaction #1413
Changes from 46 commits
7898e28
6b32e94
99b864e
dac519e
834c563
05a56b8
43ba20e
a2dc063
457f15d
3ef0145
1bb36cf
51e3e59
dd8b1e4
d36e36b
479599c
025bea5
61aa208
6d08ffd
4668e70
b72110e
66595e2
d40aa48
7388695
72d4f13
5aeaf6e
fb3de63
321147f
6785c83
d7fb787
8b00ee2
c44de03
1fcee64
85aadcc
2bc997a
dbb442e
39a8577
b1b0acc
dfeea37
2685797
66e26fb
6c3bb39
04a7cb0
9c2c3aa
88915a2
4882311
3adb7da
ba4a429
cf00899
3d5fe56
6c4b248
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,11 @@ import { useApprovals } from '~/core/resources/approvals/approvals'; | |
import { useTransaction } from '~/core/resources/transactions/transaction'; | ||
import { useCurrentAddressStore, useCurrentCurrencyStore } from '~/core/state'; | ||
import { ChainId, ChainNameDisplay } from '~/core/types/chains'; | ||
import { RainbowTransaction, TxHash } from '~/core/types/transactions'; | ||
import { | ||
PendingTransaction, | ||
RainbowTransaction, | ||
TxHash, | ||
} from '~/core/types/transactions'; | ||
import { truncateAddress } from '~/core/utils/address'; | ||
import { findRainbowChainForChainId } from '~/core/utils/chains'; | ||
import { copy } from '~/core/utils/copy'; | ||
|
@@ -46,6 +50,7 @@ import { | |
DropdownMenuItem, | ||
DropdownMenuTrigger, | ||
} from '~/entries/popup/components/DropdownMenu/DropdownMenu'; | ||
import { ExplainerSheet } from '~/entries/popup/components/ExplainerSheet/ExplainerSheet'; | ||
import { Navbar } from '~/entries/popup/components/Navbar/Navbar'; | ||
import { useRainbowNavigate } from '~/entries/popup/hooks/useRainbowNavigate'; | ||
import { useWallets } from '~/entries/popup/hooks/useWallets'; | ||
|
@@ -288,13 +293,40 @@ function NetworkData({ transaction: tx }: { transaction: RainbowTransaction }) { | |
); | ||
} | ||
|
||
function SpeedUpErrorExplainer() { | ||
const [searchParams, setSearchParams] = useSearchParams(); | ||
const explainer = searchParams.get('explainer'); | ||
|
||
return ( | ||
<ExplainerSheet | ||
show={explainer === 'speed_up_error'} | ||
onClickOutside={() => setSearchParams({})} | ||
header={{ | ||
icon: <Symbol symbol="xmark.circle.fill" color="red" size={32} />, | ||
}} | ||
title="Failed to speed up transaction" | ||
description={[ | ||
'A speed up can fail when the state of the network changed since you first submitted the transaction', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DanielSinclair let's define a copy for this and I add to the translations There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @greg-schrammel Some copy: "Speed up failed" "Attempts to speed up a transaction can fail during network congestion, gas limit increases, or when the original transaction is confirmed first" |
||
]} | ||
actionButton={{ | ||
action: () => setSearchParams({ sheet: 'cancel' }), | ||
symbol: 'trash.fill', | ||
symbolSide: 'left', | ||
label: 'Cancel Transaction', | ||
labelColor: 'label', | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
const SpeedUpOrCancel = ({ | ||
transaction, | ||
}: { | ||
transaction: RainbowTransaction; | ||
transaction: PendingTransaction; | ||
}) => { | ||
const [searchParams] = useSearchParams(); | ||
const navigate = useRainbowNavigate(); | ||
const [searchParams] = useSearchParams(); | ||
|
||
const sheetParam = searchParams.get('sheet'); | ||
const sheet = | ||
sheetParam === 'speedUp' || sheetParam === 'cancel' ? sheetParam : 'none'; | ||
|
@@ -303,6 +335,7 @@ const SpeedUpOrCancel = ({ | |
state: { skipTransitionOnRoute: ROUTES.HOME }, | ||
}); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Box display="flex" flexDirection="column" gap="8px"> | ||
|
@@ -327,13 +360,12 @@ const SpeedUpOrCancel = ({ | |
{i18n.t('speed_up_and_cancel.cancel')} | ||
</Button> | ||
</Box> | ||
{sheet !== 'none' && ( | ||
<SpeedUpAndCancelSheet | ||
currentSheet={sheet} | ||
transaction={transaction} | ||
onClose={() => setSheet('none')} | ||
/> | ||
)} | ||
<SpeedUpAndCancelSheet | ||
currentSheet={sheet} | ||
transaction={transaction} | ||
onClose={() => setSheet('none')} | ||
/> | ||
<SpeedUpErrorExplainer /> | ||
</> | ||
); | ||
}; | ||
|
@@ -545,6 +577,8 @@ export function ActivityDetails() { | |
}); | ||
const navigate = useRainbowNavigate(); | ||
|
||
console.log(transaction); | ||
greg-schrammel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const { data: approvals } = useApprovals( | ||
{ | ||
address: currentAddress, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not 100% sure about this solution, open to suggestions
but
walletAction
bridges to the background worker and back, in this back and forth it serializes BigNumbers as{ type: 'BigNumber', _hex: "0x..." }
so sometimes we got an
[object Object]
instead of the bignumber in some placesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes i've seen this, maybe let's just use hex strings? only sending hex from popup to background and only sending hex from background to popup so we don't have to do this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started to do it and got afraid of changing the type and breaking in unexpected places, because it's being casted as
TransactionResponse
and that is why we didn't caught it for so long to begin withto do it without changing the type, I'd have to then deserialize by hand like
which is more error prone and effort
another idea is to do this generic BigNumber deserialization inside
walletAction
so we don't have to ever think about it again in other placesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okok sounds good, can we move this to a util file somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1