Skip to content

Commit

Permalink
Merge pull request #425 from HathorNetwork/dev
Browse files Browse the repository at this point in the history
Merge dev changes into master
  • Loading branch information
r4mmer authored and alexruzenhack committed May 15, 2024
2 parents 2388237 + 4c4856f commit f9c8a4e
Show file tree
Hide file tree
Showing 10 changed files with 197 additions and 105 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ on:
push:
branches:
- master
- dev
- release
- release-candidate
tags:
- v*
pull_request:
branches:
- dev
- master
- release
- release-candidate
jobs:
test:
runs-on: 'ubuntu-latest'
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,6 @@ ios/HathorMobile.xcodeproj/project.xcworkspace/
.metro-health-check*
# testing
/coverage

# Env file used by pre_release.sh.
/env
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
];
packages = with pkgs; [
nixpkgs-fmt
nodejs-16_x
nodejs-18_x
ruby
gnumake
gettext
Expand Down
28 changes: 28 additions & 0 deletions pre_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
#
# Script to release new versions for iOS and Android. After running it, you still
# have to build the project on XCode and Android Studio.
#
# This script expects a file `./env` with exported envvars.
#

set -e # Exit on any command failure.
set -u # Exit on unset variables.
set -v # Verbose mode for better debugging

rm -rf node_modules/

rm -f ./android/app/google-services.json
rm -f ./android/app/GoogleService-Info.plist
rm -f ./notifications/GoogleService-Info.plist

npm ci

(cd ios/ && pod install)

make i18n

source ./env
mkdir -p ./notifications
aws s3 cp ${HATHOR_WALLET_MOBILE_S3_PATH}/google-services.json ./android/app
aws s3 cp ${HATHOR_WALLET_MOBILE_S3_PATH}/GoogleService-Info.plist ./notifications/
61 changes: 52 additions & 9 deletions scripts/check_version
Original file line number Diff line number Diff line change
@@ -1,31 +1,51 @@
#!/bin/bash

# Read the official version number from package.json file
PACKAGE_VERSION=`grep '"version":' ./package.json | cut -d '"' -f4`

# Read the version number from the Android Gradle build file
ANDROID_GRADLE_VERSION=`grep "versionName " ./android/app/build.gradle | cut -d '"' -f2`

# Read the version number (MARKETING_VERSION and CURRENT_PROJECT_VERSION) from the iOS project file
TEMP_IOS_VAR=`perl -n -e '/MARKETING_VERSION = (.*);/ && print "$1\n"' ./ios/HathorMobile.xcodeproj/project.pbxproj`
TEMP_IOS_PROJECT_VERSION=`perl -n -e '/CURRENT_PROJECT_VERSION = (.*);/ && print "$1\n"' ./ios/HathorMobile.xcodeproj/project.pbxproj`

# The iOS version number is repeated two times
IOS_MARKETING_VERSION_1=`echo $TEMP_IOS_VAR | awk '{print $1}'`
IOS_MARKETING_VERSION_2=`echo $TEMP_IOS_VAR | awk '{print $2}'`
IOS_PROJECT_VERSION_1=`echo $TEMP_IOS_PROJECT_VERSION | awk '{print $1}'`
IOS_PROJECT_VERSION_2=`echo $TEMP_IOS_PROJECT_VERSION | awk '{print $2}'`

# This will read everything of the string up to the first dash.
# The version number from the package.json file is split into two parts
STRIPPED_PACKAGE_VERSION=$(echo $PACKAGE_VERSION| cut -d- -f1);
if [[ "$PACKAGE_VERSION" == *-* ]]; then
# If the version contains a hyphen, extract the second part as the release candidate
STRIPPED_PACKAGE_CANDIDATE=$(echo $PACKAGE_VERSION | cut -d- -f2)
else
# Otherwise, the release candidate is empty
STRIPPED_PACKAGE_CANDIDATE=""
fi

# For debugging:
# Variables for debugging
# echo package: x${PACKAGE_VERSION}x
# echo stripped: x${STRIPPED_PACKAGE_VERSION}x
# echo stripped rc: x${STRIPPED_PACKAGE_CANDIDATE}x
# echo android: x${ANDROID_GRADLE_VERSION}x
# echo ios pv1: x${IOS_MARKETING_VERSION_1}x
# echo ios pv2: x${IOS_MARKETING_VERSION_2}x
# echo ios mv1: x${IOS_MARKETING_VERSION_1}x
# echo ios mv2: x${IOS_MARKETING_VERSION_2}x
# echo ios pv1: x${IOS_PROJECT_VERSION_1}x
# echo ios pv2: x${IOS_PROJECT_VERSION_2}x

# Initialize the error code with a success
EXITCODE=0

# Check if the version numbers from the package and Android are different
if [[ x${PACKAGE_VERSION}x != x${ANDROID_GRADLE_VERSION}x ]]; then
echo Version different in package.json \($PACKAGE_VERSION\) and android/app/build.gradle
EXITCODE=-1
fi

# Check if the version numbers from the package and iOS MARKETING_VERSION are different
if [[ x${STRIPPED_PACKAGE_VERSION}x != x${IOS_MARKETING_VERSION_1}x ]]; then
echo Version different in package.json \($PACKAGE_VERSION\) and first MARKETING_VERSION \($IOS_MARKETING_VERSION_1\) on ios/HathorMobile.xcodeproj/project.pbxproj
EXITCODE=-1
Expand All @@ -36,13 +56,36 @@ if [[ x${STRIPPED_PACKAGE_VERSION}x != x${IOS_MARKETING_VERSION_2}x ]]; then
EXITCODE=-1
fi

# This will check the format of IOS' CURRENT_PROJECT_VERSION
if [[ ! "$IOS_PROJECT_VERSION_1" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
echo "Invalid format (expected X.X.X) for first CURRENT_PROJECT_VERSION (${IOS_PROJECT_VERSION_1}) on ios/HathorMobile.xcodeproj/project.pbxproj"
# Check the format of iOS' CURRENT_PROJECT_VERSION
# If it's a release version (without hyphen in package version), it should be 1.0.X
# If it's a release candidate version (with hyphen in package version), it should be 0.rc.X, where rc is taken from package version
if [ -z "$STRIPPED_PACKAGE_CANDIDATE" ]; then
if [[ ! "$IOS_PROJECT_VERSION_1" =~ ^1\.0\.[0-9]{1,3}$ ]]; then
echo "Invalid format (expected 1.0.X) for first CURRENT_PROJECT_VERSION (${IOS_PROJECT_VERSION_1}) on ios/HathorMobile.xcodeproj/project.pbxproj"
EXITCODE=-1
fi

if [[ ! "$IOS_PROJECT_VERSION_2" =~ ^1\.0\.[0-9]{1,3}$ ]]; then
echo "Invalid format (expected 1.0.X) for second CURRENT_PROJECT_VERSION (${IOS_PROJECT_VERSION_2}) on ios/HathorMobile.xcodeproj/project.pbxproj"
EXITCODE=-1
fi
else
RCVERSION=${STRIPPED_PACKAGE_CANDIDATE//[^0-9]/}
# echo "RCVERSION: $RCVERSION"
if [[ ! "$IOS_PROJECT_VERSION_1" =~ ^0\.${RCVERSION}\.[0-9]{1,3}$ ]]; then
echo "Invalid format (expected 0.$RCVERSION.X) for first CURRENT_PROJECT_VERSION (${IOS_PROJECT_VERSION_1}) on ios/HathorMobile.xcodeproj/project.pbxproj"
EXITCODE=-1
fi

if [[ ! "$IOS_PROJECT_VERSION_2" =~ ^0\.${RCVERSION}\.[0-9]{1,3}$ ]]; then
echo "Invalid format (expected 0.$RCVERSION.X) for second CURRENT_PROJECT_VERSION (${IOS_PROJECT_VERSION_2}) on ios/HathorMobile.xcodeproj/project.pbxproj"
EXITCODE=-1
fi
fi

if [[ ! "$IOS_PROJECT_VERSION_2" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
echo "Invalid format (expected X.X.X) for second CURRENT_PROJECT_VERSION (${IOS_PROJECT_VERSION_2}) on ios/HathorMobile.xcodeproj/project.pbxproj"
if [[ x${EXITCODE}x != x0x ]]; then
echo "Check version failed. Consider using 'make bump updateType=xx' to update the version"
fi

# Exit the script with the error code
exit $EXITCODE
5 changes: 5 additions & 0 deletions src/sagas/featureToggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import { Platform } from 'react-native';
import VersionNumber from 'react-native-version-number';
import { UnleashClient, EVENTS as UnleashEvents } from 'unleash-proxy-client';
import { get } from 'lodash';

Expand Down Expand Up @@ -89,11 +90,15 @@ export function* monitorFeatureFlags(currentRetry = 0) {
disableRefresh: true, // Disable it, we will handle it ourselves
appName: `wallet-mobile-${Platform.OS}`,
});

const { appVersion } = VersionNumber;

const options = {
userId: getUniqueId(),
properties: {
platform: Platform.OS,
stage: STAGE,
appVersion,
},
};

Expand Down
78 changes: 40 additions & 38 deletions src/screens/CreateTokenAmount.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React from 'react';
import { KeyboardAvoidingView, Text, View } from 'react-native';
import { Keyboard, KeyboardAvoidingView, Pressable, Text, View } from 'react-native';
import { get } from 'lodash';
import { connect } from 'react-redux';
import { t, jt } from 'ttag';
Expand Down Expand Up @@ -115,44 +115,46 @@ class CreateTokenAmount extends React.Component {

return (
<View style={{ flex: 1 }}>
<HathorHeader
title={t`CREATE TOKEN`}
onBackPress={() => this.props.navigation.goBack()}
onCancel={() => this.props.navigation.getParent().goBack()}
/>
<KeyboardAvoidingView behavior='padding' style={{ flex: 1 }} keyboardVerticalOffset={getKeyboardAvoidingViewTopDistance()}>
<View style={{ flex: 1, padding: 16, justifyContent: 'space-between' }}>
<View style={{ marginTop: 24 }}>
<InputLabel style={{ textAlign: 'center', marginBottom: 16 }}>
{t`Amount of ${this.name} (${this.symbol})`}
</InputLabel>
<AmountTextInput
ref={this.inputRef}
autoFocus
onAmountUpdate={this.onAmountChange}
value={this.state.amount}
/>
<Pressable style={{ flex: 1 }} onPress={() => Keyboard.dismiss()}>
<HathorHeader
title={t`CREATE TOKEN`}
onBackPress={() => this.props.navigation.goBack()}
onCancel={() => this.props.navigation.getParent().goBack()}
/>
<KeyboardAvoidingView behavior='padding' style={{ flex: 1 }} keyboardVerticalOffset={getKeyboardAvoidingViewTopDistance()}>
<View style={{ flex: 1, padding: 16, justifyContent: 'space-between' }}>
<View style={{ marginTop: 24 }}>
<InputLabel style={{ textAlign: 'center', marginBottom: 16 }}>
{t`Amount of ${this.name} (${this.symbol})`}
</InputLabel>
<AmountTextInput
ref={this.inputRef}
autoFocus
onAmountUpdate={this.onAmountChange}
value={this.state.amount}
/>
</View>
<View>
<InfoBox
items={[
<Text>{t`Deposit:`} <Strong style={amountStyle}>
{hathorLib.numberUtils.prettyValue(this.state.deposit)} HTR
</Strong></Text>,
<Text>
{jt`You have ${amountAvailableText} HTR available`}
</Text>
]}
/>
<NewHathorButton
title={t`Next`}
disabled={this.isButtonDisabled()}
onPress={this.onButtonPress}
/>
</View>
</View>
<View>
<InfoBox
items={[
<Text>{t`Deposit:`} <Strong style={amountStyle}>
{hathorLib.numberUtils.prettyValue(this.state.deposit)} HTR
</Strong></Text>,
<Text>
{jt`You have ${amountAvailableText} HTR available`}
</Text>
]}
/>
<NewHathorButton
title={t`Next`}
disabled={this.isButtonDisabled()}
onPress={this.onButtonPress}
/>
</View>
</View>
<OfflineBar style={{ position: 'relative' }} />
</KeyboardAvoidingView>
<OfflineBar style={{ position: 'relative' }} />
</KeyboardAvoidingView>
</Pressable>
</View>
);
}
Expand Down
28 changes: 15 additions & 13 deletions src/screens/Receive.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React from 'react';
import { Dimensions, Keyboard, View } from 'react-native';
import { Dimensions, Keyboard, Pressable, View } from 'react-native';
import { t } from 'ttag';

import { TabBar, TabView } from 'react-native-tab-view';
Expand Down Expand Up @@ -102,18 +102,20 @@ class ReceiveScreen extends React.Component {

return (
<View style={{ flex: 1 }}>
<HathorHeader
title={t`RECEIVE`}
withBorder
/>
<TabView
renderTabBar={(props) => renderTabBar(props)}
navigationState={this.state}
renderScene={this.renderScene}
onIndexChange={this.handleIndexChange}
initialLayout={{ width: Dimensions.get('window').width }}
/>
<OfflineBar />
<Pressable style={{ flex: 1 }} onPress={() => Keyboard.dismiss()}>
<HathorHeader
title={t`RECEIVE`}
withBorder
/>
<TabView
renderTabBar={(props) => renderTabBar(props)}
navigationState={this.state}
renderScene={this.renderScene}
onIndexChange={this.handleIndexChange}
initialLayout={{ width: Dimensions.get('window').width }}
/>
<OfflineBar />
</Pressable>
</View>
);
}
Expand Down
Loading

0 comments on commit f9c8a4e

Please sign in to comment.