Skip to content

Commit

Permalink
Merge pull request #720 from juanky201271/dev_send_error_second_try
Browse files Browse the repository at this point in the history
Send error - second try with different server
  • Loading branch information
juanky201271 authored Oct 10, 2024
2 parents 5be8deb + c2372f5 commit 0888420
Show file tree
Hide file tree
Showing 18 changed files with 418 additions and 297 deletions.
1 change: 0 additions & 1 deletion .github/workflows/android-ubuntu-e2e-test-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ jobs:
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: 8.2
build-root-directory: ./android
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev'}}

- name: Native rust cache
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/android-ubuntu-integration-test-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ jobs:
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: 8.2
build-root-directory: ./android
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev'}}

- name: Native rust cache
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/old/android-e2e-test-actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ jobs:
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: 8.2
build-root-directory: ./android
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev'}}

- name: Native rust cache
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/old/android-e2e-test-script.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ jobs:
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: 8.2
build-root-directory: ./android
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }}

- name: AVD cache
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/old/android-macos-integration-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ jobs:
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: 8.2
build-root-directory: ./android
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }}

- name: AVD cache
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/old/android-ubuntu-integration-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ jobs:
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: 8.2
build-root-directory: ./android
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }}

- name: AVD cache
Expand Down
2 changes: 2 additions & 0 deletions __tests__/Send.snapshot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ describe('Component Send - test', () => {
setShieldingAmount={onFunction}
setScrollToTop={onFunction}
setScrollToBottom={onFunction}
setServerOption={onFunction}
/>
</ContextAppLoadedProvider>,
);
Expand Down Expand Up @@ -128,6 +129,7 @@ describe('Component Send - test', () => {
setShieldingAmount={onFunction}
setScrollToTop={onFunction}
setScrollToBottom={onFunction}
setServerOption={onFunction}
/>
</ContextAppLoadedProvider>,
);
Expand Down
3 changes: 2 additions & 1 deletion app/LoadedApp/LoadedApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ export class LoadedAppClass extends Component<LoadedAppClassProps, LoadedAppClas
});
}

// we need to restore the old server because the new doesn't have the seed of the current wallet.
// we need to restore the old server because the new one doesn't have the seed of the current wallet.
const oldSettings = await SettingsFileImpl.readSettings();
await RPCModule.execute(CommandEnum.changeserver, oldSettings.server.uri);

Expand Down Expand Up @@ -1911,6 +1911,7 @@ export class LoadedAppClass extends Component<LoadedAppClassProps, LoadedAppClas
setShieldingAmount={this.setShieldingAmount}
setScrollToTop={this.setScrollToTop}
setScrollToBottom={this.setScrollToBottom}
setServerOption={this.setServerOption}
/>
)}
</Tab.Screen>
Expand Down
23 changes: 21 additions & 2 deletions app/LoadingApp/LoadingApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -653,12 +653,12 @@ export class LoadingAppClass extends Component<LoadingAppClassProps, LoadingAppC
selectTheBestServer = async (aDifferentOne: boolean) => {
// avoiding obsolete ones
let withMessage: boolean = true;
const actualServer = this.state.server;
const server = await selectingServer(
serverUris(this.state.translate).filter(
(s: ServerUrisType) => !s.obsolete && s.uri !== (aDifferentOne ? actualServer.uri : ''),
),
);
const actualServer = this.state.server;
let fasterServer: ServerType = {} as ServerType;
if (server && server.latency) {
fasterServer = { uri: server.uri, chainName: server.chainName };
Expand Down Expand Up @@ -797,14 +797,33 @@ export class LoadingAppClass extends Component<LoadingAppClassProps, LoadingAppC
const chainName = this.state.customServerChainName;
if (uri.toLowerCase().startsWith(GlobalConst.error)) {
this.addLastSnackbar({ message: this.state.translate('settings.isuri') as string });
} else {
this.setState({ actionButtonsDisabled: false });
return;
}

this.state.addLastSnackbar({ message: this.state.translate('loadedapp.tryingnewserver') as string });

const cs = {
uri: uri,
chainName: chainName,
region: '',
default: false,
latency: null,
obsolete: false,
} as ServerUrisType;
const serverChecked = await selectingServer([cs]);
if (serverChecked && serverChecked.latency) {
await SettingsFileImpl.writeSettings(SettingsNameEnum.server, { uri, chainName });
this.setState({
server: { uri, chainName },
customServerShow: false,
customServerUri: '',
customServerChainName: ChainNameEnum.mainChainName,
});
} else {
this.state.addLastSnackbar({
message: (this.state.translate('loadedapp.changeservernew-error') as string) + uri,
});
}
this.setState({ actionButtonsDisabled: false });
};
Expand Down
4 changes: 2 additions & 2 deletions app/uris/parseZcashURI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const parseZcashURI = async (
//console.log(address);

if (address) {
const validAddress: boolean = await Utils.isValidAdress(address, server.chainName);
const validAddress: boolean = await Utils.isValidAddress(address, server.chainName);

if (!validAddress) {
return `"${address || ''}" ${translate('uris.notvalid')}`;
Expand Down Expand Up @@ -69,7 +69,7 @@ const parseZcashURI = async (
if (typeof target.address !== 'undefined') {
return `${translate('uris.duplicateparameter')} "${qName}"`;
}
const validAddress: boolean = await Utils.isValidAdress(value, server.chainName);
const validAddress: boolean = await Utils.isValidAddress(value, server.chainName);

if (!validAddress) {
return `"${value}" ${translate('uris.notvalid')}`;
Expand Down
2 changes: 1 addition & 1 deletion app/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export default class Utils {
return [...jsonFlat, ...donationTransaction];
}

static async isValidAdress(address: string, serverChainName: string): Promise<boolean> {
static async isValidAddress(address: string, serverChainName: string): Promise<boolean> {
const result: string = await RPCModule.execute(CommandEnum.parseAddress, address);
//console.log(result);
if (result) {
Expand Down
2 changes: 1 addition & 1 deletion components/Components/InputTextAddress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const InputTextAddress: React.FunctionComponent<InputTextAddressProps> = ({
addLastSnackbar({ message: translate('loadedapp.connection-error') as string });
return false;
}
return await Utils.isValidAdress(addr, server.chainName);
return await Utils.isValidAddress(addr, server.chainName);
};

if (address) {
Expand Down
170 changes: 102 additions & 68 deletions components/History/components/ValueTransferLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
faArrowUp,
faRefresh,
faComment,
faTriangleExclamation,
faComments,
faFileLines,
faPaperPlane,
Expand All @@ -34,6 +35,7 @@ import 'moment/locale/ru';

import { ContextAppLoaded } from '../../../app/context';
import AddressItem from '../../Components/AddressItem';
import { RPCValueTransfersStatusEnum } from '../../../app/rpc/enums/RPCValueTransfersStatusEnum';
import Utils from '../../../app/utils';

type ValueTransferLineProps = {
Expand Down Expand Up @@ -231,6 +233,15 @@ const ValueTransferLine: React.FunctionComponent<ValueTransferLineProps> = ({

//console.log('render ValueTransferLine - 5', index, messagesAddress);

//if (index === 0) {
// vt.confirmations = 0;
// vt.status = RPCValueTransfersStatusEnum.transmitted;
//}
//if (index === 1) {
// vt.confirmations = 0;
// vt.status = RPCValueTransfersStatusEnum.mempool;
//}

return (
<View testID={`vt-${index + 1}`} style={{ display: 'flex', flexDirection: 'column' }}>
{month !== '' && (
Expand Down Expand Up @@ -262,8 +273,8 @@ const ValueTransferLine: React.FunctionComponent<ValueTransferLineProps> = ({
<View
style={{
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
flexDirection: 'column',
alignItems: vt.status === RPCValueTransfersStatusEnum.transmitted ? 'center' : 'flex-start',
marginTop: 15,
paddingBottom: 10,
borderBottomWidth: nextLineWithSameTxid ? (Platform.OS === GlobalConst.platformOSandroid ? 1 : 0.5) : 1.5,
Expand All @@ -274,81 +285,104 @@ const ValueTransferLine: React.FunctionComponent<ValueTransferLineProps> = ({
: 'solid'
: 'solid',
}}>
<View style={{ display: 'flex' }}>
<FontAwesomeIcon
style={{ marginLeft: 5, marginRight: 5, marginTop: 0 }}
size={30}
icon={vtIcon}
<View style={{ display: 'flex', flexDirection: 'row', justifyContent: 'center', alignItems: 'center' }}>
<View style={{ display: 'flex' }}>
<FontAwesomeIcon
style={{ marginLeft: 5, marginRight: 5, marginTop: 0 }}
size={30}
icon={vtIcon}
color={vt.status === RPCValueTransfersStatusEnum.transmitted ? colors.syncing : amountColor}
/>
</View>
<View style={{ display: 'flex' }}>
{!!vt.address && vt.confirmations > 0 && (
<View>
<AddressItem address={vt.address} oneLine={true} closeModal={() => {}} openModal={() => {}} />
</View>
)}
<View
style={{
display: 'flex',
flexDirection: vt.kind === ValueTransferKindEnum.Sent && vt.confirmations > 0 ? 'row' : 'column',
alignItems:
vt.kind === ValueTransferKindEnum.Sent && vt.confirmations > 0 ? 'center' : 'flex-start',
}}>
<FadeText
style={{
opacity: 1,
fontWeight: 'bold',
color: amountColor,
fontSize: vt.confirmations === 0 ? 14 : 18,
}}>
{vt.kind === ValueTransferKindEnum.Sent && vt.confirmations === 0
? (translate('history.sending') as string)
: vt.kind === ValueTransferKindEnum.Sent && vt.confirmations > 0
? (translate('history.sent') as string)
: vt.kind === ValueTransferKindEnum.Received && vt.confirmations === 0
? (translate('history.receiving') as string)
: vt.kind === ValueTransferKindEnum.Received && vt.confirmations > 0
? (translate('history.received') as string)
: vt.kind === ValueTransferKindEnum.MemoToSelf && vt.confirmations === 0
? (translate('history.sendingtoself') as string)
: vt.kind === ValueTransferKindEnum.MemoToSelf && vt.confirmations > 0
? (translate('history.memotoself') as string)
: vt.kind === ValueTransferKindEnum.SendToSelf && vt.confirmations === 0
? (translate('history.sendingtoself') as string)
: vt.kind === ValueTransferKindEnum.SendToSelf && vt.confirmations > 0
? (translate('history.sendtoself') as string)
: vt.kind === ValueTransferKindEnum.Shield && vt.confirmations === 0
? (translate('history.shielding') as string)
: vt.kind === ValueTransferKindEnum.Shield && vt.confirmations > 0
? (translate('history.shield') as string)
: ''}
</FadeText>
<View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
<FadeText>{vt.time ? moment((vt.time || 0) * 1000).format('MMM D, h:mm a') : '--'}</FadeText>
{haveMemo && (
<FontAwesomeIcon
style={{ marginLeft: 10 }}
size={15}
icon={faComment}
color={colors.primaryDisabled}
/>
)}
</View>
</View>
</View>
<ZecAmount
style={{ flexGrow: 1, alignSelf: 'auto', justifyContent: 'flex-end', paddingRight: 5 }}
size={18}
currencyName={info.currencyName}
color={amountColor}
amtZec={vt.amount}
privacy={privacy}
/>
</View>
<View style={{ display: 'flex' }}>
{!!vt.address && (
<View>
<AddressItem address={vt.address} oneLine={true} closeModal={() => {}} openModal={() => {}} />
</View>
)}
<View
style={{
display: 'flex',
flexDirection: vt.kind === ValueTransferKindEnum.Sent ? 'row' : 'column',
alignItems: vt.kind === ValueTransferKindEnum.Sent ? 'center' : 'flex-start',
}}>
{vt.confirmations === 0 && (
<View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'center' }}>
{vt.status === RPCValueTransfersStatusEnum.transmitted && (
<FontAwesomeIcon
style={{ marginRight: 5 }}
icon={faTriangleExclamation}
color={colors.syncing}
size={15}
/>
)}
<FadeText
style={{
color:
vt.status === RPCValueTransfersStatusEnum.transmitted ? colors.primary : colors.primaryDisabled,
fontSize: 12,
opacity: 1,
fontWeight: 'bold',
color: amountColor,
fontSize: vt.confirmations === 0 ? 14 : 18,
fontWeight: '700',
textAlign: vt.status === RPCValueTransfersStatusEnum.transmitted ? 'center' : 'left',
textDecorationLine: vt.status === RPCValueTransfersStatusEnum.transmitted ? 'underline' : 'none',
marginLeft: vt.status === RPCValueTransfersStatusEnum.transmitted ? 0 : 40,
}}>
{vt.kind === ValueTransferKindEnum.Sent && vt.confirmations === 0
? (translate('history.sending') as string)
: vt.kind === ValueTransferKindEnum.Sent && vt.confirmations > 0
? (translate('history.sent') as string)
: vt.kind === ValueTransferKindEnum.Received && vt.confirmations === 0
? (translate('history.receiving') as string)
: vt.kind === ValueTransferKindEnum.Received && vt.confirmations > 0
? (translate('history.received') as string)
: vt.kind === ValueTransferKindEnum.MemoToSelf && vt.confirmations === 0
? (translate('history.sendingtoself') as string)
: vt.kind === ValueTransferKindEnum.MemoToSelf && vt.confirmations > 0
? (translate('history.memotoself') as string)
: vt.kind === ValueTransferKindEnum.SendToSelf && vt.confirmations === 0
? (translate('history.sendingtoself') as string)
: vt.kind === ValueTransferKindEnum.SendToSelf && vt.confirmations > 0
? (translate('history.sendtoself') as string)
: vt.kind === ValueTransferKindEnum.Shield && vt.confirmations === 0
? (translate('history.shielding') as string)
: vt.kind === ValueTransferKindEnum.Shield && vt.confirmations > 0
? (translate('history.shield') as string)
: ''}
{translate(`history.${vt.status}`) as string}
</FadeText>
{vt.confirmations === 0 && (
<FadeText style={{ color: colors.syncing, fontSize: 12, opacity: 1, fontWeight: '900' }}>
{('[ ' + translate('history.not-confirmed') + ' ]') as string}
</FadeText>
)}
<View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
<FadeText>{vt.time ? moment((vt.time || 0) * 1000).format('MMM D, h:mm a') : '--'}</FadeText>
{haveMemo && (
<FontAwesomeIcon
style={{ marginLeft: 10 }}
size={15}
icon={faComment}
color={colors.primaryDisabled}
/>
)}
</View>
</View>
</View>
<ZecAmount
style={{ flexGrow: 1, alignSelf: 'auto', justifyContent: 'flex-end', paddingRight: 5 }}
size={18}
currencyName={info.currencyName}
color={amountColor}
amtZec={vt.amount}
privacy={privacy}
/>
)}
</View>
</Swipeable>
</TouchableOpacity>
Expand Down
Loading

0 comments on commit 0888420

Please sign in to comment.