Skip to content

Commit

Permalink
Merge branch v1.40.930
Browse files Browse the repository at this point in the history
  • Loading branch information
rhrusha committed Nov 10, 2021
2 parents e06e94d + 31bef39 commit f4b1e4c
Show file tree
Hide file tree
Showing 94 changed files with 1,397 additions and 1,339 deletions.
3 changes: 2 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.40.910"
versionName "1.40.930"

missingDimensionStrategy 'react-native-camera', 'general'
multiDexEnabled true
Expand Down Expand Up @@ -216,6 +216,7 @@ android {
}

dependencies {
implementation project(':react-native-branch')
implementation project(':react-native-vector-icons')
implementation 'androidx.multidex:multidex:2.0.1'

Expand Down
2 changes: 2 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

-dontwarn io.branch.**
14 changes: 14 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="wc" />
</intent-filter>
<intent-filter>
<data android:scheme="branchandroid" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="uobg.app.link" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<receiver android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
Expand All @@ -80,6 +92,8 @@
</intent-filter>
</receiver>
<service android:name="com.google.android.gms.analytics.CampaignTrackingService" android:enabled="true" android:exported="false" />
<meta-data android:name="io.branch.sdk.BranchKey" android:value="key_live_pdZCA7n8hLlwZdxQZnuxTplmyynGtAqP"/>
<meta-data android:name="io.branch.sdk.BranchKey.test" android:value="key_test_gc9DB1aZhVdyWpBQXcDFLokgytkHyvEX"/>
</application>

</manifest>
31 changes: 23 additions & 8 deletions android/app/src/main/java/com/trusteewallet/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

import android.graphics.Color;

import io.branch.rnbranch.*;
import android.content.Intent;

public class MainActivity extends ReactActivity {

@Override
Expand Down Expand Up @@ -48,14 +51,26 @@ public void onConfigurationChanged(Configuration newConfig) {
}

@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}

@Override
protected void onStart() {
super.onStart();
RNBranchModule.initSession(getIntent().getData(), this);
}

@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
RNBranchModule.onNewIntent(intent);
}

protected String getMainComponentName() {
return "TrusteeWallet";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import java.security.Security;
import android.webkit.WebView;

import io.branch.rnbranch.RNBranchModule;

public class MainApplication extends MultiDexApplication implements ReactApplication {

private final ReactNativeHost mReactNativeHost =
Expand Down Expand Up @@ -55,6 +57,7 @@ public void onCreate() {
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this); // Remove this line if you don't want Flipper enabled
WebView.setWebContentsDebuggingEnabled(true);
RNBranchModule.getAutoInstance(this);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.2")
classpath('com.android.tools.build:gradle:4.1.2')
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.25.4'

Expand Down
2 changes: 2 additions & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
rootProject.name = 'TrusteeWallet'
include ':react-native-branch'
project(':react-native-branch').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-branch/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
Expand Down
4 changes: 2 additions & 2 deletions app/appstores/Actions/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ class App {

await Log.log('ACT/App appRefreshWalletsStates called from ' + source + ' firstTimeCall ' + JSON.stringify(firstTimeCall))

await CashBackUtils.init({},'ACT/App appRefreshWalletsStates called from' + source)

await walletActions.setAvailableWallets()

await setSelectedWallet('ACT/App appRefreshWalletsStates called from ' + source)
Expand All @@ -177,8 +179,6 @@ class App {

// await UpdateCashBackDataDaemon.updateCashBackDataDaemon({source : 'UpdateCashBackDataDaemon.AppHomeScreen'})

await CashBackUtils.init({},'ACT/App appRefreshWalletsStates init ' + firstTimeCall)

} else {
await Daemon.forceAll(params)

Expand Down
2 changes: 1 addition & 1 deletion app/appstores/DataSource/Account/Account.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class Account {
}
SAVED_UNIQUE[uniqueDBKey] = 1
} else {
Log.daemon('DS/Account insert account ' + uniqueDBKey + '/' + privateStoregeKey + ' not ok / already in cache', SAVED_UNIQUE[privateStoregeKey])
Log.daemon('DS/Account insert account ' + uniqueDBKey + '/' + privateStorageKey + ' not ok / already in cache', SAVED_UNIQUE[privateStorageKey])
}
}
}
Expand Down
17 changes: 13 additions & 4 deletions app/appstores/DataSource/Database/core/init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,22 @@ export default class DBInit {
this.#db = dbInterface;
}

async init() {
async init(onlyUpdate = false) {
const { initQuery, isEmptyQuery } = this.#tableQueries;
const res = await this.#db.query(isEmptyQuery)
const { maxVersion } = this.#tableUpdateQueries

if (!onlyUpdate) {
const res = await this.#db.query(isEmptyQuery)
if (res && typeof res.array !== 'undefined' && res.array.length !== 0) {
onlyUpdate = true
}
}
let countError = 0;
let updateError = false
try {
if (res.array.length !== 0) {
if (onlyUpdate) {
await this.#update();
return;
return maxVersion;
}
} catch (e) {
Log.err('DBInit error on update');
Expand Down Expand Up @@ -74,6 +81,8 @@ export default class DBInit {
await this._initSettings();
await this._initCurrency();
}

return maxVersion;
}

/**
Expand Down
40 changes: 38 additions & 2 deletions app/appstores/DataSource/Database/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
toPreparedObjects,
} from './helpers';

import settingsActions from '@app/appstores/Stores/Settings/SettingsActions'

class Database {
/**
Expand Down Expand Up @@ -52,6 +53,10 @@ class Database {

#initStart = false;

#maxVersion = 0;

#checkTries = 0;

/**
* ### Database starting
*/
Expand All @@ -61,12 +66,39 @@ class Database {
if (!this.#initStart) {
this.#initStart = true
let dbInit = new DBInit(this);
await dbInit.init();
this.#maxVersion = await dbInit.init();
dbInit = null;
this.#initStart = false
}
}

async checkVersion() {
if (this.#checkTries > 100) return false

let savedVersion = settingsActions.getSettingStatic('dbVersion')
if (this.#maxVersion === 0) {
Log.log('DBI/checkVersion not inited maxVersion ' + this.#maxVersion + ' dbVersion ' + savedVersion)
return;
}
if (savedVersion.toString() === this.#maxVersion.toString()) {
this.#checkTries = 200
Log.log('DBI/checkVersion all ok maxVersion ' + this.#maxVersion + ' dbVersion ' + savedVersion)
return;
}
this.#checkTries++

Log.log('DBI/checkVersion checkTry ' + this.#checkTries + ' maxVersion ' + this.#maxVersion + ' dbVersion ' + savedVersion)
let dbInit = new DBInit(this);
this.#maxVersion = await dbInit.init(true)
dbInit = null;

savedVersion = await settingsActions.getSetting('dbVersion')
Log.log('DBI/checkVersion checkTry ' + this.#checkTries + ' newMaxVersion ' + this.#maxVersion + ' newDbVersion ' + savedVersion)
}




/**
* @param {string} badString
* @return {string}
Expand Down Expand Up @@ -104,7 +136,11 @@ class Database {
e.code = 'ERROR_SYSTEM';
// before db init sometimes
if (e.message.indexOf('notifsSavedToken') === -1) {
if (throwError) {
if (e.message.indexOf('no such column') !== -1) {
Log.err(e);
await this.checkVersion();
throw new Error('DB was updated: please try again');
} else if (throwError) {
throw e;
} else {
Log.err(e);
Expand Down
6 changes: 3 additions & 3 deletions app/appstores/DataSource/Wallet/WalletPub.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,9 @@ class WalletPub {
Log.daemon(`LINK1 ${trezorServer}/api/v2/xpub/${xpubs[0]}?details=tokens&tokens=used&gap=9999`)
Log.daemon(`LINK2 ${trezorServer}/api/v2/xpub/${xpubs[1]}?details=tokens&tokens=used&gap=9999`)
Log.daemon(`LINK2 ${trezorServer}/api/v2/xpub/${xpubs[2]}?details=tokens&tokens=used&gap=9999`)
const importCheckUsed = await BlocksoftAxios.getWithoutBraking(`${trezorServer}/api/v2/xpub/${xpubs[0]}?details=tokens&tokens=used&gap=9999`)
const importCheckUsed1 = await BlocksoftAxios.getWithoutBraking(`${trezorServer}/api/v2/xpub/${xpubs[1]}?details=tokens&tokens=used&gap=9999`)
const importCheckUsed2 = await BlocksoftAxios.getWithoutBraking(`${trezorServer}/api/v2/xpub/${xpubs[2]}?details=tokens&tokens=used&gap=9999`)
const importCheckUsed = await BlocksoftAxios.getWithoutBraking(`${trezorServer}/api/v2/xpub/${xpubs[0]}?details=tokens&tokens=used&gap=9999&pageSize=20`)
const importCheckUsed1 = await BlocksoftAxios.getWithoutBraking(`${trezorServer}/api/v2/xpub/${xpubs[1]}?details=tokens&tokens=used&gap=9999&pageSize=20`)
const importCheckUsed2 = await BlocksoftAxios.getWithoutBraking(`${trezorServer}/api/v2/xpub/${xpubs[2]}?details=tokens&tokens=used&gap=9999&pageSize=20`)
let toSave = false
const xPubBalances = [
{
Expand Down
2 changes: 1 addition & 1 deletion app/appstores/Stores/CashBack/CashBackActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { dispatch } = store

const cashBackActions = {

updateAll : async (data) => {
updateAll : async (data, source) => {
if (typeof data.cashbackLinkTitle !== 'undefined') {
data.cashbackLink = cashBackSettings.getLink(data.cashbackLinkTitle)
}
Expand Down
21 changes: 18 additions & 3 deletions app/appstores/Stores/CashBack/CashBackUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import store from '@app/store'
import trusteeAsyncStorage from '@appV2/services/trusteeAsyncStorage/trusteeAsyncStorage'
import settingsActions from '@app/appstores/Stores/Settings/SettingsActions'

import branch from 'react-native-branch'

const NativeLinking = require('../../../../node_modules/react-native/Libraries/Linking/NativeLinking').default

const CACHE_DATA_FROM_API = {}
Expand All @@ -43,12 +45,25 @@ class CashBackUtils {
const tmp2 = await NativeLinking.getInitialURL()
await Log.log('SRV/CashBack init NativeLinking.getInitialURL() ' + JSON.stringify(tmp2))

// Branch
let branchData
try {
branchData = await branch.getFirstReferringParams()
await Log.log('SRV/CashBack init branch.getFirstReferringParams() ' + JSON.stringify(branchData))
} catch (e) {
await Log.log('SRV/CashBack init branch.getFirstReferringParams() error ' + e.message)
}

if (firebaseUrl && typeof firebaseUrl !== 'undefined') {
if (typeof firebaseUrl.url !== 'undefined' && firebaseUrl.url) {
firebaseUrl = firebaseUrl.url
}
} else if (tmp2 && typeof tmp2 !== 'undefined' && tmp2 !== '') {
firebaseUrl = tmp2
} else if (branchData && typeof branchData !== 'undefined') {
if (branchData.$desktop_url && typeof branchData.$desktop_url !== 'undefined') {
firebaseUrl = branchData.$desktop_url
}
}

if (firebaseUrl && typeof firebaseUrl !== 'undefined' && firebaseUrl !== '') {
Expand Down Expand Up @@ -110,7 +125,7 @@ class CashBackUtils {
}
}
await Log.log('SRV/CashBack saved parent from AsyncStorage => ' + tmpParentToken, params)
await cashBackActions.updateAll(updateObj)
await cashBackActions.updateAll(updateObj, 'CashBackUtils.init')
this.inited = true
}

Expand All @@ -137,7 +152,7 @@ class CashBackUtils {
if (data.customToken) {
updateObj.cashbackLinkTitle = data.customToken
}
await cashBackActions.updateAll(updateObj)
await cashBackActions.updateAll(updateObj, 'CashBackUtils.fromApi')
}

setParentToken = async (parentToken) => {
Expand All @@ -146,7 +161,7 @@ class CashBackUtils {
}
this.parentToken = parentToken
await trusteeAsyncStorage.setCashbackParent(parentToken)
await cashBackActions.updateAll({ parentToken })
await cashBackActions.updateAll({ parentToken }, 'CashBackUtils.setParentToken')
}

getByHash = async (tmpHash, source) => {
Expand Down
12 changes: 9 additions & 3 deletions app/appstores/Stores/Send/SendActionsEnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,26 @@ export namespace SendActionsEnd {
export const saveTx = async (tx: any, sendScreenStore: any) => {
const { currencyCode, accountId, walletHash, addressFrom } = sendScreenStore.dict
const { addressTo, cryptoValue, memo, comment, bse, tbk, contractCallData } = sendScreenStore.ui
const { selectedFee } = sendScreenStore.fromBlockchain
const { selectedFee, countedFees } = sendScreenStore.fromBlockchain
const { bseMinCrypto } = bse
const { transactionAction, transactionBoost } = tbk

const now = new Date().toISOString()
console.log(' contractCallData ', contractCallData )

let value = cryptoValue
if (typeof countedFees.amountForTx !== 'undefined') {
value = countedFees.amountForTx
} else if (typeof selectedFee.amountForTx !== 'undefined' ) {
value = selectedFee.amountForTx
}

const logData = {
walletHash: walletHash,
currencyCode: currencyCode,
transactionHash: tx.transactionHash,
addressTo: addressTo,
addressFrom: addressFrom,
addressAmount: cryptoValue,
addressAmount: value,
fee: JSON.stringify(selectedFee)
}

Expand Down
4 changes: 2 additions & 2 deletions app/appstores/Stores/Send/SendActionsStart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ export namespace SendActionsStart {
if (typeof transaction.bseOrderId !== 'undefined') {
ui.bse.bseOrderId = transaction.bseOrderId
}
if (typeof transaction.transactionJson !== 'undefined' && transaction.transactionJson !== {}) {
if (transaction.transactionJson.comment !== 'undefined') {
if (typeof transaction.transactionJson !== 'undefined' && transaction.transactionJson && transaction.transactionJson !== {}) {
if (typeof transaction.transactionJson.comment !== 'undefined' && transaction.transactionJson.comment) {
ui.comment = transaction.transactionJson.comment
}
}
Expand Down
Loading

0 comments on commit f4b1e4c

Please sign in to comment.