Skip to content
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(wallet-mobile): tx review wrong reference inputs display #3767

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const useFormattedInputs = (
inputUtxos: ReturnType<typeof useUtxos>,
) => {
const query = useQuery<FormattedInputs>(
['useFormattedInputs', inputs],
['useFormattedInputs', inputs, inputUtxos],
async () => formatInputs(wallet, inputs, tokenInfosResult, inputUtxos),
{
suspense: true,
Expand Down Expand Up @@ -124,6 +124,8 @@ const formatInputs = async (
portfolioTokenInfos: ReturnType<typeof usePortfolioTokenInfos>,
inputUtxos: ReturnType<typeof useUtxos>,
): Promise<FormattedInputs> => {
if (inputUtxos.length === 0) return Promise.resolve([])

return Promise.all(
inputs.map(async (input) => {
const receiveUTxO = inputUtxos.find(
Expand Down Expand Up @@ -309,7 +311,9 @@ const getUtxo = async (wallet: YoroiWallet, txHash: string, txIndex: number, get

if (!internalUtxo) {
const externalUtxo = await getUtxoData({txHash, txIndex})
return externalUtxo != null ? toRawUtxo(externalUtxo, txHash, txIndex) : null
if (externalUtxo == null) throw new Error('useUtxos: utxo not found')

return toRawUtxo(externalUtxo, txHash, txIndex)
}

return internalUtxo
Expand Down
18 changes: 1 addition & 17 deletions apps/wallet-mobile/src/features/ReviewTx/common/operations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ export type Operations = {
component: React.ReactNode
}>
totalFee: Balance.Quantity
operationCount: OperationsCount
}
export const useOperations = (certificates: FormattedTx['certificates']) => {
const {wallet} = useSelectedWallet()
Expand All @@ -307,7 +306,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => {
return {
components: [] as Operations['components'],
totalFee: Quantities.zero,
operationCount,
}

const certificatesTypes = certificates.map((cert) => cert.type)
Expand Down Expand Up @@ -341,7 +339,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => {
},
],
totalFee: Quantities.sum([fee, acc.totalFee]),
operationCount,
}
}

Expand All @@ -362,7 +359,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => {
},
],
totalFee: acc.totalFee,
operationCount,
}

case CertificateType.StakeDelegation: {
Expand All @@ -385,7 +381,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => {
},
],
totalFee: acc.totalFee,
operationCount,
}
}

Expand All @@ -409,7 +404,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => {
},
],
totalFee: acc.totalFee,
operationCount,
}
if (drep === 'AlwaysNoConfidence')
return {
Expand All @@ -428,7 +422,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => {
},
],
totalFee: acc.totalFee,
operationCount,
}

const drepId = ('KeyHash' in drep ? drep.KeyHash : drep.ScriptHash) ?? ''
Expand All @@ -449,7 +442,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => {
},
],
totalFee: acc.totalFee,
operationCount,
}
}

Expand All @@ -472,7 +464,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => {
},
],
totalFee: Quantities.sum([fee, acc.totalFee]),
operationCount,
}
}

Expand All @@ -493,7 +484,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => {
},
],
totalFee: acc.totalFee,
operationCount,
}
}

Expand All @@ -516,7 +506,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => {
},
],
totalFee: Quantities.sum([fee, acc.totalFee]),
operationCount,
}
}

Expand All @@ -537,7 +526,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => {
},
],
totalFee: acc.totalFee,
operationCount,
}
}

Expand All @@ -558,7 +546,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => {
},
],
totalFee: acc.totalFee,
operationCount,
}
}

Expand All @@ -579,7 +566,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => {
},
],
totalFee: acc.totalFee,
operationCount,
}
}

Expand All @@ -600,7 +586,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => {
},
],
totalFee: acc.totalFee,
operationCount,
}
}

Expand All @@ -621,15 +606,14 @@ export const useOperations = (certificates: FormattedTx['certificates']) => {
},
],
totalFee: acc.totalFee,
operationCount,
}
}

default:
return acc
}
},
{components: [], totalFee: Quantities.zero, operationCount: {} as OperationsCount},
{components: [], totalFee: Quantities.zero},
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@ export const OverviewTab = ({

const notOwnedOutputs = React.useMemo(() => tx.outputs.filter((output) => !output.ownAddress), [tx.outputs])
const ownedOutputs = React.useMemo(() => tx.outputs.filter((output) => output.ownAddress), [tx.outputs])
const componentsDuplicated = operations.components.find((component) => component.duplicated)
const operationsComponentsDuplicated = React.useMemo(
() => operations.components.find((component) => component.duplicated),
[operations.components],
)

return (
<View style={styles.root}>
<Space height="lg" />

{componentsDuplicated && (
{operationsComponentsDuplicated && (
<>
<Warning title={strings.operationsLogWarningTitle} content={strings.operationsLogWarningText} />

Expand Down Expand Up @@ -157,7 +160,7 @@ const MyWalletSection = ({
operationsFee: Balance.Quantity
}) => {
const strings = useStrings()
const {styles} = useStyles()
const {styles, colors} = useStyles()
const address = ownedOutputs[0]?.rewardAddress ?? ownedOutputs[0]?.address ?? '-'

return (
Expand All @@ -169,7 +172,7 @@ const MyWalletSection = ({
{address}
</Text>

{ownedOutputs[0]?.addressKind === CredKind.Script && <Icon.DigitalAsset size={24} />}
{ownedOutputs[0]?.addressKind === CredKind.Script && <Icon.DigitalAsset size={24} color={colors.icon} />}
</CopiableText>

<Space height="sm" />
Expand Down Expand Up @@ -249,7 +252,7 @@ const OneExternalPartySection = ({
receiverCustomTitle?: React.ReactNode
}) => {
const address = output?.rewardAddress ?? output?.address ?? '-'
const {styles} = useStyles()
const {styles, colors} = useStyles()
const strings = useStrings()

return (
Expand All @@ -274,7 +277,7 @@ const OneExternalPartySection = ({
{address}
</Text>

{output?.addressKind === CredKind.Script && <Icon.DigitalAsset size={24} />}
{output?.addressKind === CredKind.Script && <Icon.DigitalAsset size={24} color={colors.icon} />}
</CopiableText>
)}
</View>
Expand All @@ -283,7 +286,7 @@ const OneExternalPartySection = ({
}

const MultiExternalPartiesSection = ({outputs}: {outputs: FormattedOutputs}) => {
const {styles} = useStyles()
const {styles, colors} = useStyles()
const {wallet} = useSelectedWallet()
const strings = useStrings()

Expand All @@ -302,7 +305,7 @@ const MultiExternalPartiesSection = ({outputs}: {outputs: FormattedOutputs}) =>
{address}
</Text>

{output?.addressKind === CredKind.Script && <Icon.DigitalAsset size={24} />}
{output?.addressKind === CredKind.Script && <Icon.DigitalAsset size={24} color={colors.icon} />}
</CopiableText>

<Space height="sm" />
Expand Down Expand Up @@ -574,6 +577,7 @@ const useStyles = () => {
const colors = {
send: color.primary_500,
received: color.green_static,
icon: color.el_gray_medium,
}

return {styles, colors} as const
Expand Down
32 changes: 16 additions & 16 deletions apps/wallet-mobile/translations/messages/src/AppNavigator.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,59 @@
"defaultMessage": "!!!Enter PIN",
"file": "src/AppNavigator.tsx",
"start": {
"line": 254,
"line": 251,
"column": 17,
"index": 9784
"index": 9472
},
"end": {
"line": 257,
"line": 254,
"column": 3,
"index": 9874
"index": 9562
}
},
{
"id": "components.initialization.custompinscreen.title",
"defaultMessage": "!!!Set PIN",
"file": "src/AppNavigator.tsx",
"start": {
"line": 258,
"line": 255,
"column": 18,
"index": 9894
"index": 9582
},
"end": {
"line": 261,
"line": 258,
"column": 3,
"index": 9992
"index": 9680
}
},
{
"id": "global.actions.dialogs.walletKeysInvalidated.title",
"defaultMessage": "!!!Auth with OS changes",
"file": "src/AppNavigator.tsx",
"start": {
"line": 262,
"line": 259,
"column": 25,
"index": 10019
"index": 9707
},
"end": {
"line": 265,
"line": 262,
"column": 3,
"index": 10133
"index": 9821
}
},
{
"id": "global.actions.dialogs.biometricsChange.message",
"defaultMessage": "!!!Auth with OS changed detected",
"file": "src/AppNavigator.tsx",
"start": {
"line": 266,
"line": 263,
"column": 27,
"index": 10162
"index": 9850
},
"end": {
"line": 269,
"line": 266,
"column": 3,
"index": 10283
"index": 9971
}
}
]
Loading