refactor: new endpoints for swap hosts
This commit is contained in:
@@ -18,6 +18,12 @@ export default class SwapStore {
|
||||
@observable public apiError = '';
|
||||
@observable public swapInfo = {};
|
||||
@observable public reverseSwapInfo = {};
|
||||
@observable public host = HOST;
|
||||
|
||||
@action
|
||||
public setHost = (newHost: string) => {
|
||||
this.host = newHost;
|
||||
};
|
||||
|
||||
@action
|
||||
public statusColor = (status: string) => {
|
||||
|
||||
@@ -11,10 +11,12 @@ import { localeString } from '../../utils/LocaleUtils';
|
||||
import { themeColor } from '../../utils/ThemeUtils';
|
||||
|
||||
import NodeInfoStore from '../../stores/NodeInfoStore';
|
||||
import SwapStore from '../../stores/SwapStore';
|
||||
|
||||
interface SwapSettingsProps {
|
||||
navigation: any;
|
||||
NodeInfoStore: NodeInfoStore;
|
||||
SwapStore: SwapStore;
|
||||
}
|
||||
|
||||
interface SwapSettingsState {
|
||||
@@ -22,7 +24,7 @@ interface SwapSettingsState {
|
||||
host: string;
|
||||
}
|
||||
|
||||
@inject('NodeInfoStore')
|
||||
@inject('NodeInfoStore', 'SwapStore')
|
||||
@observer
|
||||
export default class LSPS1Settings extends React.Component<
|
||||
SwapSettingsProps,
|
||||
@@ -36,7 +38,7 @@ export default class LSPS1Settings extends React.Component<
|
||||
};
|
||||
}
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
const { navigation, SwapStore } = this.props;
|
||||
const { serviceProvider, host } = this.state;
|
||||
const isTestnet = this.props.NodeInfoStore?.nodeInfo?.isTestNet;
|
||||
return (
|
||||
@@ -65,6 +67,10 @@ export default class LSPS1Settings extends React.Component<
|
||||
key: 'Boltz',
|
||||
value: 'Boltz'
|
||||
},
|
||||
{
|
||||
key: 'Swap Market',
|
||||
value: 'SwapMarket'
|
||||
},
|
||||
{
|
||||
key: 'Custom',
|
||||
translateKey: 'general.custom',
|
||||
@@ -81,17 +87,27 @@ export default class LSPS1Settings extends React.Component<
|
||||
host: host
|
||||
});
|
||||
} else if (value === 'ZEUS') {
|
||||
// zeus endpoints are in WIP
|
||||
const host = isTestnet ? '' : '';
|
||||
this.setState({
|
||||
serviceProvider: 'ZEUS',
|
||||
host: host
|
||||
});
|
||||
} else if (value === 'SwapMarket') {
|
||||
const host = isTestnet
|
||||
? 'https://api.testnet.boltz.exchange/v2/swap/submarine'
|
||||
: 'https://api.middleway.space/v2/swap/submarine';
|
||||
this.setState({
|
||||
serviceProvider: 'SwapMarket',
|
||||
host: host
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
serviceProvider: 'Custom',
|
||||
host: 'https://api.boltz.exchange/v2'
|
||||
});
|
||||
}
|
||||
SwapStore.setHost(host);
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -111,11 +127,12 @@ export default class LSPS1Settings extends React.Component<
|
||||
'views.SwapSettings.customHost'
|
||||
)}
|
||||
value={host}
|
||||
onChangeText={(text: string) =>
|
||||
onChangeText={(text: string) => {
|
||||
this.setState({
|
||||
host: text
|
||||
})
|
||||
}
|
||||
});
|
||||
SwapStore.setHost(host);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user