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: Swap - confirm with password error reset #2745

Merged
merged 70 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
df9b7e8
reset password
SorinC6 Oct 9, 2023
039f307
chore: impr ffee - return
stackchain Oct 2, 2023
390a7f2
refactor: sonarqube complexity
stackchain Oct 2, 2023
8be34f1
wip: order calcs
stackchain Oct 2, 2023
c98f6bf
wip: liquidity prov fee + tests
stackchain Oct 2, 2023
97710be
wip: frontend fee + lptoken
stackchain Oct 2, 2023
f288900
wip: price
stackchain Oct 2, 2023
bf0a178
wip: sell/buy sides
stackchain Oct 2, 2023
29967e7
wip: prices
stackchain Oct 3, 2023
5df3ecb
wip: prices
stackchain Oct 3, 2023
3f0d54f
wip: helpers dealt with 0
stackchain Oct 3, 2023
787ae4b
wip: price with fees
stackchain Oct 3, 2023
d3f55db
wip: price difference
stackchain Oct 3, 2023
58c2168
wip: state
stackchain Oct 3, 2023
560402f
wip: state
stackchain Oct 3, 2023
1de4519
wip: state
stackchain Oct 3, 2023
ad8cd97
wip: tests
stackchain Oct 3, 2023
571554b
wip: state
stackchain Oct 3, 2023
189c8b3
wip: added getPrice
stackchain Oct 3, 2023
75ad5ce
wip: state
stackchain Oct 4, 2023
b3a7082
wip: calcs
stackchain Oct 4, 2023
578f680
Refactor calculaed state
jorbuedo Oct 5, 2023
1d9f1c9
Fix calculatedPool
jorbuedo Oct 5, 2023
0aa996b
Add getBestPool example
jorbuedo Oct 5, 2023
f2e2fbc
Add calc for fees without frontend fee
jorbuedo Oct 6, 2023
a44e95a
Show fees
jorbuedo Oct 6, 2023
d881a0c
Address comments
jorbuedo Oct 6, 2023
3596b4f
chore: dropped state pt prices in favor of pool pt price
stackchain Oct 7, 2023
bd31df3
chore: clean state
stackchain Oct 8, 2023
4fac8f6
chore: CR
stackchain Oct 8, 2023
c99c72d
chore: change sell/buy id
stackchain Oct 8, 2023
dbc4d74
wip: state
stackchain Oct 9, 2023
9f53c3a
wip: state
stackchain Oct 9, 2023
3d9b6b1
chore: effects
stackchain Oct 9, 2023
5890e81
wip: clean ups - get pt price
stackchain Oct 9, 2023
2542391
chore: state and behaviors
stackchain Oct 9, 2023
4513d04
add onPasswordChange prop
SorinC6 Oct 10, 2023
b3514e3
Merge branch 'swap/complete-orders' into passwoard-error-reset
SorinC6 Oct 10, 2023
1145faf
wip: order calcs
stackchain Oct 2, 2023
a2695e5
wip: liquidity prov fee + tests
stackchain Oct 2, 2023
5b43463
wip: frontend fee + lptoken
stackchain Oct 2, 2023
f88bb22
wip: price
stackchain Oct 2, 2023
4cbcd3e
wip: sell/buy sides
stackchain Oct 2, 2023
48650f8
wip: prices
stackchain Oct 3, 2023
4681062
wip: prices
stackchain Oct 3, 2023
9046dd7
wip: helpers dealt with 0
stackchain Oct 3, 2023
502a379
wip: price with fees
stackchain Oct 3, 2023
770fcd0
wip: price difference
stackchain Oct 3, 2023
ecf1db0
wip: state
stackchain Oct 3, 2023
44d773f
wip: state
stackchain Oct 3, 2023
e4377b4
wip: state
stackchain Oct 3, 2023
d619e4b
wip: added getPrice
stackchain Oct 3, 2023
3bdbd16
wip: state
stackchain Oct 4, 2023
8065df7
wip: calcs
stackchain Oct 4, 2023
4cc81b8
Refactor calculaed state
jorbuedo Oct 5, 2023
ca32efc
Fix calculatedPool
jorbuedo Oct 5, 2023
1d91ed9
Add calc for fees without frontend fee
jorbuedo Oct 6, 2023
9a99ede
chore: dropped state pt prices in favor of pool pt price
stackchain Oct 7, 2023
00c931d
chore: clean state
stackchain Oct 8, 2023
197d3c0
chore: CR
stackchain Oct 8, 2023
b727e9b
wip: state
stackchain Oct 9, 2023
b310ecf
wip: state
stackchain Oct 9, 2023
54ab57f
wip: clean ups - get pt price
stackchain Oct 9, 2023
7b5b98e
chore: state and behaviors
stackchain Oct 9, 2023
38768d0
New Crowdin updates (#2747)
vsubhuman Oct 10, 2023
0c86628
Min received with slippage
jorbuedo Oct 10, 2023
f7c4d1c
fix: edit limit price (#2748)
SorinC6 Oct 10, 2023
54e8ccb
Merge branch 'swap/complete-orders' into passwoard-error-reset
SorinC6 Oct 10, 2023
01ae09d
Fix lint issue
michaeljscript Oct 10, 2023
ae9152d
remove duplicate
SorinC6 Oct 10, 2023
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 @@ -7,13 +7,19 @@ import {COLORS} from '../../../../theme'
import {WrongPassword} from '../../../../yoroi-wallets/cardano/errors'
import {useStrings} from '../../common/strings'

export type ErrorData = {
errorMessage: string
errorLogs?: unknown
}

type Props = {
onSubmit?: (spendingPassword: string) => void
isLoading?: boolean
error?: Error
onPasswordChange?: () => void
}

export const ConfirmWithSpendingPassword = ({onSubmit, isLoading, error}: Props) => {
export const ConfirmWithSpendingPassword = ({onSubmit, isLoading, error, onPasswordChange}: Props) => {
const spendingPasswordRef = React.useRef<RNTextInput>(null)
const [spendingPassword, setSpendingPassword] = React.useState(
features.prefillWalletInfo ? debugWalletInfo.PASSWORD : '',
Expand All @@ -30,7 +36,10 @@ export const ConfirmWithSpendingPassword = ({onSubmit, isLoading, error}: Props)
enablesReturnKeyAutomatically
placeholder={strings.spendingPassword}
value={spendingPassword}
onChangeText={setSpendingPassword}
onChangeText={(text) => {
setSpendingPassword(text)
onPasswordChange && onPasswordChange()
}}
autoComplete="off"
/>

Expand All @@ -44,7 +53,13 @@ export const ConfirmWithSpendingPassword = ({onSubmit, isLoading, error}: Props)

<Spacer fill />

<Button testID="swapButton" shelleyTheme title={strings.sign} onPress={() => onSubmit?.(spendingPassword)} />
<Button
testID="swapButton"
shelleyTheme
title={strings.sign}
onPress={() => onSubmit?.(spendingPassword)}
disabled={spendingPassword.length === 0}
/>

{isLoading && (
<View style={styles.loading}>
Expand Down
1 change: 0 additions & 1 deletion apps/wallet-mobile/src/features/Swap/common/useSwapTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const useSwapTx = (options?: UseMutationOptions<YoroiUnsignedTx, Error, {
buyQuantity: orderData.amounts.buy.quantity,
feeTokenId: pool?.deposit.tokenId,
feeTokenId: pool?.deposit.tokenId,

}),
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ import {YoroiWallet} from '../../../../yoroi-wallets/cardano/types'
import {useSignWithPasswordAndSubmitTx} from '../../../../yoroi-wallets/hooks'
import {YoroiUnsignedTx} from '../../../../yoroi-wallets/types'
import {ConfirmWithSpendingPassword} from '../../common/ConfirmWithSpendingPassword'
import {ErrorData} from '../../common/ConfirmWithSpendingPassword/ConfirmWithSpendingPassword'
import {useStrings} from '../../common/strings'

type ErrorData = {
errorMessage: string
errorLogs?: unknown
}

type Props = {
wallet: YoroiWallet
unsignedTx: YoroiUnsignedTx
Expand Down Expand Up @@ -64,6 +60,7 @@ export const ConfirmTxWithPassword = ({wallet, onSuccess, unsignedTx}: Props) =>
onSubmit={onConfirm}
isLoading={isLoading}
error={errorData.errorMessage.length > 0 ? new Error(errorData.errorMessage) : undefined}
onPasswordChange={() => setErrorData({errorMessage: '', errorLogs: ''})}
/>
)
}
2 changes: 1 addition & 1 deletion packages/swap/src/adapters/openswap-api/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,4 @@ describe('swapApiMaker', () => {
expect(mockOpenSwapApi.getPrice).toHaveBeenCalledTimes(1)
})
})
})
})
Loading