Skip to content

Commit

Permalink
chore: cleanup logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuditi committed Sep 1, 2023
1 parent 5c1f8ae commit 9bd9b8a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
const sendFlowType = token.id === BASE_TOKEN_ID ? SendFlowType.BaseCoinTransfer : SendFlowType.TokenTransfer
setSendFlowParameters({
type: sendFlowType,
[sendFlowType === SendFlowType.BaseCoinTransfer ? 'baseCoinTransfer' : 'tokenTransfer']: {
token: token,
[sendFlowType]: {
token,
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@
let rawAmount: string
let amount: string
let unit: string
const tokenKey = $sendFlowParameters.type === SendFlowType.TokenTransfer ? 'tokenTransfer' : 'baseCoinTransfer'
if (
$sendFlowParameters.type === SendFlowType.BaseCoinTransfer ||
$sendFlowParameters.type === SendFlowType.TokenTransfer
) {
token = $sendFlowParameters[tokenKey].token
rawAmount = $sendFlowParameters[tokenKey].rawAmount
unit = $sendFlowParameters[tokenKey].unit || getUnitFromTokenMetadata(token?.metadata)
const sendFlowType = $sendFlowParameters.type
if (sendFlowType === SendFlowType.BaseCoinTransfer || sendFlowType === SendFlowType.TokenTransfer) {
token = $sendFlowParameters[sendFlowType].token
rawAmount = $sendFlowParameters[sendFlowType].rawAmount
unit = $sendFlowParameters[sendFlowType].unit || getUnitFromTokenMetadata(token?.metadata)
}
$: availableBalance = token?.balance?.available
Expand All @@ -38,7 +34,7 @@
updateSendFlowParameters({
type: $sendFlowParameters.type,
[tokenKey]: {
[sendFlowType]: {
token,
rawAmount,
unit,
Expand All @@ -53,7 +49,7 @@
function onBackClick(): void {
updateSendFlowParameters({
type: $sendFlowParameters.type,
[tokenKey]: {
[sendFlowType]: {
token,
rawAmount: undefined,
unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
setSendFlowParameters({
...previousSharedParameters,
type: sendFlowType,
[sendFlowType === SendFlowType.BaseCoinTransfer ? 'baseCoinTransfer' : 'tokenTransfer']: {
[sendFlowType]: {
token: selectedToken,
},
})
Expand Down

0 comments on commit 9bd9b8a

Please sign in to comment.