Skip to content

Commit

Permalink
Merge branch v1.50.2
Browse files Browse the repository at this point in the history
  • Loading branch information
rhrusha committed Nov 19, 2021
2 parents f4b1e4c + 747126e commit cfa5480
Show file tree
Hide file tree
Showing 168 changed files with 4,091 additions and 1,964 deletions.
4 changes: 1 addition & 3 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import React from 'react'

import { Provider } from 'react-redux'
import { AppearanceProvider } from 'react-native-appearance'
import { Linking, Platform, UIManager } from 'react-native'
import { Platform, UIManager } from 'react-native'

import store from '@app/store'

import Router from '@app/router'
import { ThemeProvider } from '@app/theme/ThemeProvider'

import Application from '@app/appstores/Actions/App/App'
import { SendDeepLinking } from '@app/appstores/Stores/Send/SendDeepLinking'

import appsFlyer from 'react-native-appsflyer'

Expand All @@ -33,7 +32,6 @@ export default class App extends React.Component {

componentDidMount() {
Application.init({ source: 'App.mount', onMount : true })
Linking.addEventListener('url', (data) => SendDeepLinking.handleInitialURL(data.url))

if (Platform.OS === 'android') {
if (UIManager.setLayoutAnimationEnabledExperimental) {
Expand Down
2 changes: 1 addition & 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.930"
versionName "1.50.2"

missingDimensionStrategy 'react-native-camera', 'general'
multiDexEnabled true
Expand Down
6 changes: 6 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="trustee.app.link" android:scheme="https"/>
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
Expand Down
Binary file modified android/app/src/main/assets/fonts/icomoon.ttf
Binary file not shown.
10 changes: 10 additions & 0 deletions android/app/src/main/java/com/trusteewallet/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ protected void onStart() {
RNBranchModule.initSession(getIntent().getData(), this);
}

@Override
protected void onRestart() {
super.onRestart();
Intent intent = getIntent();
setIntent(intent);
intent.putExtras(this.getIntent());
intent.putExtra("branch_force_new_session", true);
}


@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
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,7 +158,7 @@ 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 CashBackUtils.init({}, 'ACT/App appRefreshWalletsStates called from' + source)

await walletActions.setAvailableWallets()

Expand All @@ -182,7 +182,7 @@ class App {
} else {
await Daemon.forceAll(params)

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

await Log.log('ACT/App appRefreshWalletsStates called from ' + source + ' firstTimeCall ' + JSON.stringify(firstTimeCall) + ' finished')
Expand Down
10 changes: 7 additions & 3 deletions app/appstores/Actions/CustomCurrencyActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ const customCurrencyActions = {
if (typeof (currencyToAdd.tokenType) === 'undefined') {
throw new Error('set tokenType')
}
if (currencyToAdd.tokenType !== 'ETH_ERC_20' && currencyToAdd.tokenType !== 'BNB_SMART_20' && currencyToAdd.tokenType !== 'TRX' && currencyToAdd.tokenType !== 'SOL') {
throw new Error('only ETH_ERC_20 / BNB_SMART_20 / SOL or TRX tokenType is supported')
if (currencyToAdd.tokenType !== 'ETH_ERC_20' && currencyToAdd.tokenType !== 'BNB_SMART_20'
&& currencyToAdd.tokenType !== 'MATIC_ERC_20' && currencyToAdd.tokenType !== 'FTM_ERC_20'
&& currencyToAdd.tokenType !== 'TRX' && currencyToAdd.tokenType !== 'SOL') {
throw new Error('only ETH_ERC_20 / BNB_SMART_20 / MATIC_ERC_20 / SOL or TRX tokenType is supported')
}
if (typeof (currencyToAdd.tokenAddress) === 'undefined') {
throw new Error('set tokenAddress')
Expand Down Expand Up @@ -59,7 +61,9 @@ const customCurrencyActions = {
if (typeof (currencyToAdd.tokenType) === 'undefined') {
throw new Error('set tokenType')
}
if (currencyToAdd.tokenType !== 'ETH_ERC_20' && currencyToAdd.tokenType !== 'TRX' && currencyToAdd.tokenType !== 'BNB_SMART_20' && currencyToAdd.tokenType !== 'SOL') {
if (currencyToAdd.tokenType !== 'ETH_ERC_20' && currencyToAdd.tokenType !== 'TRX'
&& currencyToAdd.tokenType !== 'MATIC_ERC_20' && currencyToAdd.tokenType !== 'FTM_ERC_20'
&& currencyToAdd.tokenType !== 'BNB_SMART_20' && currencyToAdd.tokenType !== 'SOL') {
throw new Error('only ETH_ERC_20 or TRX tokenType is supported')
}
if (typeof (currencyToAdd.currencyCode) === 'undefined') {
Expand Down
10 changes: 8 additions & 2 deletions app/appstores/DataSource/Account/Account.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class Account {

const tmpName = Database.escapeString('CREATED by ' + source + ' at ' + new Date().toISOString())

let settings
for (code of currencyCode) {
if (typeof accounts[code] === 'undefined') {
throw new Error('DS/Account discoverAddresses NO ACCOUNTS FOR ' + code)
Expand All @@ -138,7 +139,12 @@ class Account {
code = 'LTC'
}

const settings = BlocksoftDict.getCurrencyAllSettings(code)
try {
settings = BlocksoftDict.getCurrencyAllSettings(code, 'Account')
} catch (e) {
// do nothing
continue
}
if (typeof settings.addressCurrencyCode !== 'undefined' && typeof settings.tokenBlockchain !== 'undefined' && settings.tokenBlockchain !== 'BITCOIN' ) {
const { accountList } = store.getState().accountStore
if (typeof accountList[params.walletHash] !== 'undefined' && typeof accountList[params.walletHash][settings.addressCurrencyCode] !== 'undefined') {
Expand Down Expand Up @@ -200,7 +206,7 @@ class Account {
wallet_hash AS walletHash,
wallet_pub_id AS walletPubId
FROM ${tableName}
WHERE currency_code='${code}' AND address='${account.address}'`
WHERE currency_code='${code}' AND address='${account.address}' AND wallet_hash='${params.walletHash}'`

let find = await Database.query(findSql)
if (find.array.length === 0) {
Expand Down
6 changes: 5 additions & 1 deletion app/appstores/DataSource/Currency/Currency.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ export default {
* @returns {Promise<void>}
*/
insertCurrency: async (data) => {
await Database.setTableName(tableName).setInsertData(data).insert()
try {
await Database.setTableName(tableName).setInsertData(data).insert()
} catch (e) {
// do nothing
}
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import settingsActions from '@app/appstores/Stores/Settings/SettingsActions'

export default function getTableUpdateQueries() {
return {
maxVersion: 119,
maxVersion: 124,
updateQuery: {
1: {
queryString: `ALTER TABLE account ADD COLUMN transactions_scan_time INTEGER NULL`,
Expand Down Expand Up @@ -829,7 +829,71 @@ export default function getTableUpdateQueries() {
afterFunction: async (dbInterface) => {
await dbInterface.query(`INSERT INTO currency (currency_code, is_hidden, currency_rate_json, currency_rate_scan_time) VALUES ('NFT', '0', '', '')`)
}
}
},

120: {
afterFunction: async (dbInterface) => {
const res = await dbInterface.query(`SELECT currency_code FROM custom_currency WHERE token_type='TRX'`)
if (res && res.array) {
console.log('dbUpdate TRX tokens 1 ' + JSON.stringify(res.array))
for (const row of res.array) {
await dbInterface.query(`UPDATE currency SET currency_code='CUSTOM_TRX_${row.currency_code}' WHERE currency_code='CUSTOM_${row.currency_code}'`)
}
}
}
},

121: {
afterFunction: async (dbInterface) => {
const res = await dbInterface.query(`SELECT currency_code FROM custom_currency WHERE token_type='TRX'`)
if (res && res.array) {
console.log('dbUpdate TRX tokens 2 ' + JSON.stringify(res.array))
for (const row of res.array) {
await dbInterface.query(`UPDATE account SET currency_code='CUSTOM_TRX_${row.currency_code}' WHERE currency_code='CUSTOM_${row.currency_code}'`)
}
}
}
},

122: {
afterFunction: async (dbInterface) => {
const res = await dbInterface.query(`SELECT currency_code FROM custom_currency WHERE token_type='TRX'`)
if (res && res.array) {
console.log('dbUpdate TRX tokens 3 ' + JSON.stringify(res.array))
for (const row of res.array) {
await dbInterface.query(`UPDATE account_balance SET currency_code='CUSTOM_TRX_${row.currency_code}' WHERE currency_code='CUSTOM_${row.currency_code}'`)
}
}
}
},

123: {
afterFunction: async (dbInterface) => {
const res = await dbInterface.query(`SELECT currency_code FROM custom_currency WHERE token_type='TRX'`)
if (res && res.array) {
console.log('dbUpdate TRX tokens 4 ' + JSON.stringify(res.array))
for (const row of res.array) {
await dbInterface.query(`UPDATE transactions SET currency_code='CUSTOM_TRX_${row.currency_code}' WHERE currency_code='CUSTOM_${row.currency_code}'`)
}
}
}
},

124: {
afterFunction: async (dbInterface) => {
const res = await dbInterface.query(`SELECT currency_code, token_address FROM custom_currency WHERE token_type='TRX'`)
if (res && res.array) {
console.log('dbUpdate TRX tokens 5 ' + JSON.stringify(res.array))
for (const row of res.array) {
if (row.token_address.indexOf('0x') !== -1) {
await dbInterface.query(`DELETE FROM custom_currency WHERE token_type='TRX' AND token_address='${row.token_address}'`)
} else {
await dbInterface.query(`UPDATE custom_currency SET currency_code='CUSTOM_TRX_${row.currency_code}' WHERE currency_code='CUSTOM_${row.currency_code}'`)
}
}
}
}
},
}
}
}
27 changes: 19 additions & 8 deletions app/appstores/DataSource/Database/core/init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class DBInit {
return maxVersion;
}
} catch (e) {
Log.err('DBInit error on update');
Log.err('DBInit error on update ' + e.message);
updateError = true
countError++;
}
Expand Down Expand Up @@ -93,11 +93,23 @@ export default class DBInit {
const { updateQuery, maxVersion } = this.#tableUpdateQueries;
let currentVersion = 0;

const res = await this.#db.query(`SELECT [paramValue] FROM settings WHERE [paramKey]='dbVersion'`, true);
if (res.array && res.array.length) {
currentVersion = res.array[0].paramValue * 1; // this was THE TRICK
} else {
await this.#db.query(`INSERT INTO settings ([paramValue],[paramKey]) VALUES (1, 'dbVersion')`, true);
try {
const res = await this.#db.query(`SELECT [paramValue] FROM settings WHERE [paramKey]='dbVersion'`, true);
if (res.array && res.array.length) {
currentVersion = res.array[0].paramValue * 1; // this was THE TRICK
} else {
await this.#db.query(`INSERT INTO settings ([paramValue],[paramKey]) VALUES (1, 'dbVersion')`, true);
}
} catch (e) {
if (e.message.indexOf('no such table')) {
this.#db.query(`CREATE TABLE IF NOT EXISTS settings (
id INTEGER PRIMARY KEY AUTOINCREMENT,
[paramKey] VARCHAR(255),
[paramValue] VARCHAR(255)
)`, true)
} else {
throw new Error(e.message + ' in SELECT currentVersion')
}
}

for (let i = currentVersion + 1; i <= maxVersion; i++) {
Expand All @@ -120,12 +132,11 @@ export default class DBInit {
}
await this.#db.query(`UPDATE settings SET paramValue='${i}' WHERE paramKey='dbVersion'`)
} catch (e) {
console.log(e)
if (e.message.indexOf('duplicate column name') === -1) {
Log.err('DBInit._update error ' + e.message)
throw new Error('DB update error')
} else {
await this.#db.query(`UPDATE settings SET paramValue='${i}' WHERE paramKey='dbVersion'`).query()
await this.#db.query(`UPDATE settings SET paramValue='${i}' WHERE paramKey='dbVersion'`)
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions app/appstores/DataSource/Nfts/Nfts.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import store from '@app/store'
const CACHE = {
MATIC: {},
ETH: {},
BNB : {},
ETH_ROPSTEN: {},
ETH_RINKEBY: {}
}
Expand All @@ -22,6 +23,7 @@ const CACHE = {
const CACHE_TIME = {
MATIC: {},
ETH: {},
BNB : {},
ETH_ROPSTEN: {},
ETH_RINKEBY: {}
}
Expand Down
6 changes: 4 additions & 2 deletions app/appstores/Stores/CreateWallet/CreateWalletActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ export async function proceedSaveGeneratedWallet(wallet, source = 'GENERATION')

await walletActions.addAvailableWallets(fullWallet)

await cryptoWalletActions.setSelectedWallet(storedKey, 'ACT/MStore proceedSaveGeneratedWallet Revert', false)

await accountDS.discoverAccounts({ walletHash: storedKey, fullTree: false, source }, source)

await accountBalanceActions.initBalances(storedKey, source === 'IMPORT')

await cryptoWalletActions.setSelectedWallet(storedKey, 'ACT/MStore proceedSaveGeneratedWallet Revert', false)

await Log.log('ACT/MStore proceedSaveGeneratedWallet finished discover storedWallet ' + storedKey)
} catch (e) {
if (config.debug.appErrors) {
Expand All @@ -165,6 +165,8 @@ export async function proceedSaveGeneratedWallet(wallet, source = 'GENERATION')
await settingsActions.setSelectedWallet(prevWallet)
}

await walletActions.setAvailableWallets()

Log.log('ACT/MStore proceedSaveGeneratedWallet tryWallet ' + storedKey + ' prevWallet ' + prevWallet + ' error ' + e.message)

} catch (e2) {
Expand Down
8 changes: 7 additions & 1 deletion app/appstores/Stores/Currency/CurrencyActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ const currencyActions = {
await currencyActions.toggleCurrencyVisibility({ currencyCode : 'BNB_SMART', newIsHidden : 0, currentIsHidden : 0})
} else if (tokenType === 'ETH_ERC_20' || tokenType === 'ETHEREUM') {
await currencyActions.toggleCurrencyVisibility({ currencyCode : 'ETH', newIsHidden : 0, currentIsHidden : 0})
} else if (tokenType === 'MATIC_ERC_20' || tokenType === 'MATIC') {
await currencyActions.toggleCurrencyVisibility({ currencyCode : 'MATIC', newIsHidden : 0, currentIsHidden : 0})
} else if (tokenType === 'FTM_ERC_20' || tokenType === 'FTM') {
await currencyActions.toggleCurrencyVisibility({ currencyCode : 'FTM', newIsHidden : 0, currentIsHidden : 0})
}


},

addCurrency: async (currencyToAdd, isHidden = 0, isLoader = 1) => {
Expand Down Expand Up @@ -220,7 +226,7 @@ const currencyActions = {
Log.log('ACT/Currency toggleCurrencyVisibility called ', params)

try {

let { walletNumber } = store.getState().mainStore.selectedWallet
if (typeof walletNumber === 'undefined' || !walletNumber) {
walletNumber = 1
Expand Down
Loading

0 comments on commit cfa5480

Please sign in to comment.