Skip to content

Commit

Permalink
Merge branch 'dev_reply_to_only_orchard_UA' into dev_safe_communication
Browse files Browse the repository at this point in the history
  • Loading branch information
juanky201271 committed Jan 21, 2025
2 parents 102f0e4 + 91c870e commit 9a88c9c
Show file tree
Hide file tree
Showing 47 changed files with 758 additions and 516 deletions.
6 changes: 3 additions & 3 deletions __mocks__/dataMocks/mockAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import { AddressClass, AddressKindEnum, ReceiverEnum } from '../../app/AppState'

export const mockAddresses: AddressClass[] = [
{
uaAddress: 'UA-12345678901234567890',
uOrchardAddress: 'UA-12345678901234567890',
address: 'UA-12345678901234567890',
addressKind: AddressKindEnum.u,
receivers: ReceiverEnum.o + ReceiverEnum.z + ReceiverEnum.t,
},
{
uaAddress: 'UA-12345678901234567890',
uOrchardAddress: 'UA-12345678901234567890',
address: 'sapling-12345678901234567890',
addressKind: AddressKindEnum.z,
receivers: ReceiverEnum.z,
},
{
uaAddress: 'UA-12345678901234567890',
uOrchardAddress: 'UA-12345678901234567890',
address: 'transparent-12345678901234567890',
addressKind: AddressKindEnum.t,
receivers: ReceiverEnum.t,
Expand Down
2 changes: 1 addition & 1 deletion __tests__/History.snapshot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('Component History - test', () => {
//snapshot test
const state = defaultAppContextLoaded;
state.valueTransfers = mockValueTransfers;
state.uaAddress = mockAddresses[0].uaAddress;
state.uOrchardAddress = mockAddresses[0].uOrchardAddress;
state.addresses = mockAddresses;
state.translate = mockTranslate;
state.info = mockInfo;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/Messages.snapshot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('Component Messages - test', () => {
//snapshot test
const state = defaultAppContextLoaded;
state.valueTransfers = mockValueTransfers;
state.uaAddress = mockAddresses[0].uaAddress;
state.uOrchardAddress = mockAddresses[0].uOrchardAddress;
state.addresses = mockAddresses;
state.translate = mockTranslate;
state.info = mockInfo;
Expand Down
4 changes: 2 additions & 2 deletions __tests__/MessagesAddress.snapshot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('Component Messages Address - test', () => {
//snapshot test
const state = defaultAppContextLoaded;
state.valueTransfers = mockValueTransfers;
state.uaAddress = mockAddresses[0].uaAddress;
state.uOrchardAddress = mockAddresses[0].uOrchardAddress;
state.addresses = mockAddresses;
state.translate = mockTranslate;
state.info = mockInfo;
Expand All @@ -117,7 +117,7 @@ describe('Component Messages Address - test', () => {
setSendPageState={onFunction}
setScrollToBottom={onFunction}
scrollToBottom={false}
address={mockAddresses[0].uaAddress}
address={mockAddresses[0].uOrchardAddress}
closeModal={onFunction}
openModal={onFunction}
sendTransaction={onFunction}
Expand Down
4 changes: 2 additions & 2 deletions __tests__/Receive.snapshot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ describe('Component Receive - test', () => {
//snapshot test
test('Receive - snapshot', () => {
const state = defaultAppContextLoaded;
state.uaAddress = mockAddresses[0].uaAddress;
state.uOrchardAddress = mockAddresses[0].uOrchardAddress;
state.addresses = mockAddresses;
state.translate = mockTranslate;
state.info = mockInfo;
state.totalBalance = mockTotalBalance;
const onFunction = jest.fn();
const receive = render(
<ContextAppLoadedProvider value={state}>
<Receive setUaAddress={onFunction} toggleMenuDrawer={onFunction} syncingStatusMoreInfoOnClick={onFunction} />
<Receive toggleMenuDrawer={onFunction} syncingStatusMoreInfoOnClick={onFunction} alone={false} />
</ContextAppLoadedProvider>,
);
expect(receive.toJSON()).toMatchSnapshot();
Expand Down
2 changes: 1 addition & 1 deletion __tests__/Send.snapshot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('Component Send - test', () => {
//snapshot test
const state = defaultAppContextLoaded;
state.valueTransfers = mockValueTransfers;
state.uaAddress = mockAddresses[0].uaAddress;
state.uOrchardAddress = mockAddresses[0].uOrchardAddress;
state.addresses = mockAddresses;
state.translate = mockTranslate;
state.info = mockInfo;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/SingleAddress.snapshot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Component SingleAddress - test', () => {
const onPrev = jest.fn();
const onNext = jest.fn();
const single = render(
<SingleAddress address={mockAddresses[0].uaAddress} index={0} total={1} prev={onPrev} next={onNext} />,
<SingleAddress address={mockAddresses[0].uOrchardAddress} index={0} total={1} prev={onPrev} next={onNext} />,
);
expect(single.toJSON()).toMatchSnapshot();
});
Expand Down
28 changes: 3 additions & 25 deletions __tests__/__snapshots__/AddressBook.AbDetail.snapshot.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1187,28 +1187,6 @@ exports[`Component Address Book Details - test Address Book Datails - Modify - s
</View>
</View>
</View>
<View
style={
{
"alignItems": "center",
"flexDirection": "row",
"flexGrow": 1,
"justifyContent": "center",
"marginVertical": 5,
}
}
>
<Text
style={
{
"color": "#18bd18",
"opacity": 0.65,
}
}
>
text translated
</Text>
</View>
<View
style={
{
Expand All @@ -1225,7 +1203,7 @@ exports[`Component Address Book Details - test Address Book Datails - Modify - s
{
"busy": undefined,
"checked": undefined,
"disabled": true,
"disabled": false,
"expanded": undefined,
"selected": undefined,
}
Expand All @@ -1251,8 +1229,8 @@ exports[`Component Address Book Details - test Address Book Datails - Modify - s
style={
{
"alignItems": "center",
"backgroundColor": "#5a8c5a",
"borderColor": "#5a8c5a",
"backgroundColor": "#18bd18",
"borderColor": "#c3c3c3",
"borderRadius": 10,
"borderWidth": 2,
"justifyContent": "center",
Expand Down
6 changes: 1 addition & 5 deletions __tests__/__snapshots__/Receive.snapshot.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ exports[`Component Receive - test Receive - snapshot 1`] = `
"index": 0,
"routes": [
{
"key": "uaddr",
"title": "text translated",
},
{
"key": "zaddr",
"key": "uorchardaddr",
"title": "text translated",
},
{
Expand Down
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ android {
applicationId 'org.ZingoLabs.Zingo' // Real
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 208 // Real
versionCode 209 // Real
versionName "zingo-1.11.0" // Real
missingDimensionStrategy 'react-native-camera', 'general'
testBuildType System.getProperty('testBuildType', 'debug')
Expand Down
2 changes: 1 addition & 1 deletion app/AppState/AppContextLoaded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default interface AppContextLoaded {
wallet: WalletType;

// active UA in the wallet
uaAddress: string;
uOrchardAddress: string;

// zec price in USD from internet
zecPrice: ZecPriceType;
Expand Down
4 changes: 3 additions & 1 deletion app/AppState/classes/AddressBookFileClass.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
export default class AddressBookFileClass {
label: string;
address: string;
uOrchardAddress?: string;

constructor(label: string, address: string) {
constructor(label: string, address: string, uOrchardAddress?: string) {
this.label = label;
this.address = address;
this.uOrchardAddress = uOrchardAddress;
}
}
6 changes: 3 additions & 3 deletions app/AppState/classes/AddressClass.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { AddressKindEnum } from '../enums/AddressKindEnum';

export default class AddressClass {
uaAddress: string;
uOrchardAddress: string;
address: string;
addressKind: AddressKindEnum;
receivers: string;

constructor(uaAddress: string, address: string, addressKind: AddressKindEnum, receivers: string) {
this.uaAddress = uaAddress;
constructor(uOrchardAddress: string, address: string, addressKind: AddressKindEnum, receivers: string) {
this.uOrchardAddress = uOrchardAddress;
this.address = address;
this.addressKind = addressKind;
this.receivers = receivers;
Expand Down
1 change: 1 addition & 0 deletions app/AppState/const/GlobalConst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export const GlobalConst = {
background: '@background',
keyKeyChain: 'ZINGO_SEED_BIRTHDAY',
serviceKeyChain: 'ZINGO',
replyTo: '\nReply to: \n',
};
5 changes: 5 additions & 0 deletions app/AppState/enums/CommandAddressesEnum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum CommandAddressesEnum {
full = '',
shielded = 'shielded',
orchard = 'orchard',
}
6 changes: 6 additions & 0 deletions app/AppState/enums/ShieldedEnum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export enum ShieldedEnum {
uFull = 'uFull',
uOrchardSapling = 'uOrchardSapling',
uOrchard = 'uOrchard',
sapling = 'sapling',
}
49 changes: 35 additions & 14 deletions app/LoadedApp/LoadedApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,35 @@ export default function LoadedApp(props: LoadedAppProps) {
}

// adding `Zenny Tips` address always.
const ab = await AddressBookFileImpl.writeAddressBookItem(
let ab = await AddressBookFileImpl.writeAddressBookItem(
translate('zenny-tips-ab') as string,
await Utils.getZenniesDonationAddress(server.chainName),
'',
);

// reply-to change, from full UA to only orchard UA.
// we need to calculate the only orchard UA for all the
// contacts with a full UA stored in the Address Book.
// We need to identify the old transaction memos (with full UA)
// and we need to idenfify the new transaction memos (with only orchard UA)

// if some contact don't have the new field: `uOrchardAddress` then
// the App have to create and calculate it if needed.
const toUpdate = ab.filter((a: AddressBookFileClass) => !a.hasOwnProperty('uOrchardAddress'));
console.log('Address Book -> TO UPDATE', toUpdate);
if (toUpdate.length > 0) {
for (let i = 0; i < toUpdate.length; i++) {
const a = toUpdate[i];
const validAddress: { isValid: boolean; onlyOrchardUA: string } = await Utils.isValidAddress(
a.address,
server.chainName,
);
if (validAddress.isValid) {
//ab = await AddressBookFileImpl.removeAddressBookItem(a.label, a.address);
ab = await AddressBookFileImpl.writeAddressBookItem(a.label, a.address, validAddress.onlyOrchardUA);
}
}
}
setAddressBook(ab);

setLoading(false);
Expand Down Expand Up @@ -391,7 +416,7 @@ export class LoadedAppClass extends Component<LoadedAppClassProps, LoadedAppClas
zecPrice: 0,
date: 0,
} as ZecPriceType,
uaAddress: '',
uOrchardAddress: '',
sendPageState: new SendPageStateClass(new ToAddrClass(Utils.getNextToAddrID())),
receivePageState: {} as ReceivePageStateClass,
background: props.background,
Expand Down Expand Up @@ -913,11 +938,11 @@ export class LoadedAppClass extends Component<LoadedAppClassProps, LoadedAppClas
this.setState({ addresses });
}
if (addresses.length > 0) {
if (this.state.uaAddress !== addresses[0].uaAddress) {
this.setState({ uaAddress: addresses[0].uaAddress });
if (this.state.uOrchardAddress !== addresses[0].uOrchardAddress) {
this.setState({ uOrchardAddress: addresses[0].uOrchardAddress });
}
} else {
this.setState({ uaAddress: '' });
this.setState({ uOrchardAddress: '' });
}
};

Expand Down Expand Up @@ -987,10 +1012,10 @@ export class LoadedAppClass extends Component<LoadedAppClassProps, LoadedAppClas
sendTransaction = async (): Promise<String> => {
try {
// Construct a sendJson from the sendPage state
const { sendPageState, uaAddress, addresses, server, donation } = this.state;
const { sendPageState, uOrchardAddress, addresses, server, donation } = this.state;
const sendJson = await Utils.getSendManyJSON(
sendPageState,
uaAddress,
uOrchardAddress,
addresses ? addresses : ([] as AddressClass[]),
server,
donation,
Expand Down Expand Up @@ -1523,10 +1548,6 @@ export class LoadedAppClass extends Component<LoadedAppClassProps, LoadedAppClas
}
};

setUaAddress = (uaAddress: string) => {
this.setState({ uaAddress });
};

syncingStatusMoreInfoOnClick = async () => {
await this.fetchWallet();
this.setState({ syncReportModalVisible: true });
Expand Down Expand Up @@ -1633,7 +1654,7 @@ export class LoadedAppClass extends Component<LoadedAppClassProps, LoadedAppClas
syncingStatus: this.state.syncingStatus,
info: this.state.info,
zecPrice: this.state.zecPrice,
uaAddress: this.state.uaAddress,
uOrchardAddress: this.state.uOrchardAddress,
sendPageState: this.state.sendPageState,
receivePageState: this.state.receivePageState,
background: this.state.background,
Expand Down Expand Up @@ -2048,10 +2069,10 @@ export class LoadedAppClass extends Component<LoadedAppClassProps, LoadedAppClas
<Tab.Screen name={translate('loadedapp.receive-menu') as string}>
{() => (
<Receive
setUaAddress={this.setUaAddress}
toggleMenuDrawer={this.toggleMenuDrawer}
syncingStatusMoreInfoOnClick={this.syncingStatusMoreInfoOnClick}
setUfvkViewModalVisible={this.setUfvkViewModalVisible}
alone={false}
/>
)}
</Tab.Screen>
Expand Down Expand Up @@ -2093,10 +2114,10 @@ export class LoadedAppClass extends Component<LoadedAppClassProps, LoadedAppClas
<Tab.Screen name={translate('loadedapp.history-menu') as string}>
{() => (
<Receive
setUaAddress={this.setUaAddress}
toggleMenuDrawer={this.toggleMenuDrawer}
syncingStatusMoreInfoOnClick={this.syncingStatusMoreInfoOnClick}
setUfvkViewModalVisible={this.setUfvkViewModalVisible}
alone={true}
/>
)}
</Tab.Screen>
Expand Down
2 changes: 1 addition & 1 deletion app/context/contextAppLoaded.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const defaultAppContextLoaded: AppContextLoaded = {
info: {} as InfoType,
walletSettings: new WalletSettingsClass(),
wallet: {} as WalletType,
uaAddress: '',
uOrchardAddress: '',
server: {} as ServerType,
currency: CurrencyEnum.noCurrency,
language: LanguageEnum.en,
Expand Down
Loading

0 comments on commit 9a88c9c

Please sign in to comment.