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

[swaps] Enhancements #2741

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 13 additions & 5 deletions views/SwapDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ interface SwapDetailsProps {
navigation: StackNavigationProp<any, any>;
route: Route<
'SwapDetails',
{ swapData: any; keys: any; endpoint: any; invoice: any }
{
swapData: any;
keys: any;
endpoint: any;
invoice: any;
feeRate: any;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please define the types here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay pushed the changes

>;
NodeInfoStore?: NodeInfoStore;
SwapStore?: SwapStore;
Expand Down Expand Up @@ -229,7 +235,7 @@ export default class SwapDetails extends React.Component<
pollingInterval: number,
isSubmarineSwap: boolean
) => {
const { keys, endpoint, swapData } = this.props.route.params;
const { keys, endpoint, swapData, feeRate } = this.props.route.params;

if (!createdResponse || !createdResponse.id) {
console.error('Invalid response:', createdResponse);
Expand Down Expand Up @@ -295,7 +301,8 @@ export default class SwapDetails extends React.Component<
swapData.lockupAddress,
swapData.destinationAddress,
swapData.preimage,
data.transaction.hex
data.transaction.hex,
feeRate
);
} else if (
data.status === 'invoice.expired' ||
Expand Down Expand Up @@ -481,7 +488,8 @@ export default class SwapDetails extends React.Component<
lockupAddress: string,
destinationAddress: string,
preimage: any,
transactionHex: string
transactionHex: string,
feeRate: any
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too

) => {
try {
const dObject = keys.__D;
Expand All @@ -508,7 +516,7 @@ export default class SwapDetails extends React.Component<
transactionHex,
lockupAddress,
destinationAddress,
feeRate: 2, // TODO
feeRate,
isTestnet: this.props.NodeInfoStore!.nodeInfo.isTestNet
});

Expand Down
31 changes: 25 additions & 6 deletions views/Swaps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
ErrorMessage,
SuccessMessage
} from '../components/SuccessErrorMessage';
import OnchainFeeInput from '../components/OnchainFeeInput';

import { localeString } from '../utils/LocaleUtils';
import { themeColor } from '../utils/ThemeUtils';
Expand Down Expand Up @@ -58,6 +59,7 @@ interface SwapPaneState {
apiUpdates: any;
response: any;
fetchingInvoice: boolean;
fee: string;
}

@inject('SwapStore', 'UnitsStore', 'InvoicesStore')
Expand All @@ -76,7 +78,8 @@ export default class SwapPane extends React.PureComponent<
apiUpdates: '',
apiError: null,
response: null,
fetchingInvoice: false
fetchingInvoice: false,
fee: ''
};

async UNSAFE_componentWillMount() {
Expand All @@ -94,7 +97,8 @@ export default class SwapPane extends React.PureComponent<
apiUpdates,
invoice,
isValid,
fetchingInvoice
fetchingInvoice,
fee
} = this.state;
const { subInfo, reverseInfo, loading } = SwapStore;
const info: any = reverse ? reverseInfo : subInfo;
Expand Down Expand Up @@ -267,7 +271,8 @@ export default class SwapPane extends React.PureComponent<
swapData: responseData,
keys,
endpoint: HOST,
invoice: destinationAddress
invoice: destinationAddress,
feeRate: fee
});
});
} catch (error: any) {
Expand Down Expand Up @@ -904,6 +909,23 @@ export default class SwapPane extends React.PureComponent<
disabled={errorMsg}
/>
</View>
<View style={{ paddingHorizontal: 20 }}>
<Text
style={{
color: themeColor('secondaryText'),
marginTop: 10
}}
>
{localeString('views.Send.feeSatsVbyte')}
</Text>
<OnchainFeeInput
fee={fee}
onChangeFee={(text: string) =>
this.setState({ fee: text })
}
navigation={navigation}
/>
</View>

<View>
<Button
Expand All @@ -914,9 +936,6 @@ export default class SwapPane extends React.PureComponent<
? createReverseSwap(invoice)
: createSubmarineSwap(invoice);
}}
containerStyle={{
marginTop: 10
}}
disabled={!isValid}
/>
</View>
Expand Down