Skip to content

Commit

Permalink
Merge branch 'v1.40.920'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhrusha committed Sep 22, 2021
2 parents e8ea40f + c22d9f9 commit e06e94d
Show file tree
Hide file tree
Showing 93 changed files with 6,430 additions and 2,211 deletions.
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.900"
versionName "1.40.910"

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 @@ -64,6 +64,12 @@
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="tw" android:host="pay" />
</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:scheme="wc" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<receiver android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
Expand Down
Binary file modified android/app/src/main/assets/fonts/icomoon.ttf
Binary file not shown.
1 change: 1 addition & 0 deletions app/appstores/DataSource/Currency/Currency.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export default {
const data = []
let row
for (row of res.array) {
if (row.currencyCode === 'NFT') continue
data.push(row.currencyCode)
}
data.push('BTC_SEGWIT')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,26 @@ export default function getTableQueries() {
tmp_val TEXT,
created_at DATETIME NULL
)`
}
},

{
tableName: 'custom_nfts',
queryString: `CREATE TABLE IF NOT EXISTS custom_nfts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
is_hidden INTEGER NOT NULL DEFAULT 0,
nft_code VARCHAR(32) NOT NULL,
nft_symbol VARCHAR(32) NOT NULL,
nft_name VARCHAR(256) NOT NULL,
nft_type VARCHAR(32) NOT NULL,
nft_address VARCHAR(256) NOT NULL,
nft_json TEXT NULL,
is_added_to_api INTEGER NULL DEFAULT 0
)`
},
]
}
}
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: 117,
maxVersion: 119,
updateQuery: {
1: {
queryString: `ALTER TABLE account ADD COLUMN transactions_scan_time INTEGER NULL`,
Expand Down Expand Up @@ -807,6 +807,29 @@ export default function getTableUpdateQueries() {
}
}
},

118 : {
queryString: `CREATE TABLE IF NOT EXISTS custom_nfts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
is_hidden INTEGER NOT NULL DEFAULT 0,
nft_code VARCHAR(32) NOT NULL,
nft_symbol VARCHAR(32) NOT NULL,
nft_name VARCHAR(256) NOT NULL,
nft_type VARCHAR(32) NOT NULL,
nft_address VARCHAR(256) NOT NULL,
nft_json TEXT NULL,
is_added_to_api INTEGER NULL DEFAULT 0
)`
},
119: {
afterFunction: async (dbInterface) => {
await dbInterface.query(`INSERT INTO currency (currency_code, is_hidden, currency_rate_json, currency_rate_scan_time) VALUES ('NFT', '0', '', '')`)
}
}
}
}
}
3 changes: 1 addition & 2 deletions app/appstores/DataSource/Database/core/init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,8 @@ export default class DBInit {
const insertObjs = []
let currencyCode
for (currencyCode of BlocksoftDict.Codes) {
const settings = BlocksoftDict.Currencies[currencyCode]
insertObjs.push({
currencyCode: settings.currencyCode,
currencyCode: currencyCode,
currencyRateUsd: 0,
currencyRateJson: '',
currencyRateScanTime: '',
Expand Down
36 changes: 36 additions & 0 deletions app/appstores/DataSource/NftCustomAssets/NftCustomAssets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @version 0.9
*/
import Database from '@app/appstores/DataSource/Database'

let CACHE = {}
class NftCustomAssets {

saveCustomAsset = async (tmp) => {
if (typeof CACHE[tmp.nftType] !== 'undefined' && typeof CACHE[tmp.nftType][tmp.nftAddress] !== 'undefined') {
return false
}
await Database.setTableName('custom_nfts').setInsertData({ insertObjs: [tmp]}).insert()
return true
}

getCustomAssets = async () => {
const sql = `SELECT id, nft_code AS nftCode, nft_symbol AS nftSymbol, nft_name AS nftName, nft_type AS nftType, nft_address AS nftAddress FROM custom_nfts`
const res = await Database.query(sql, true)
if (!res || !res.array || res.array.length === 0) {
return false
}
CACHE = {}
for (const tmp of res.array) {
tmp.nftName = Database.unEscapeString(tmp.nftName)
if (typeof CACHE[tmp.nftType] === 'undefined') {
CACHE[tmp.nftType] = {}
}
CACHE[tmp.nftType][tmp.nftAddress] = tmp
}
return CACHE
}

}

export default new NftCustomAssets()
76 changes: 76 additions & 0 deletions app/appstores/DataSource/Nfts/Nfts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* @version 0.9
*/
import Database from '@app/appstores/DataSource/Database'

import BlocksoftKeysUtils from '@crypto/actions/BlocksoftKeys/BlocksoftKeysUtils'
import Log from '@app/services/Log/Log'
import CashBackUtils from '@app/appstores/Stores/CashBack/CashBackUtils'
import UpdateWalletsDaemon from '@app/daemons/back/UpdateWalletsDaemon'

import store from '@app/store'


const CACHE = {
MATIC: {},
ETH: {},
ETH_ROPSTEN: {},
ETH_RINKEBY: {}
}


const CACHE_TIME = {
MATIC: {},
ETH: {},
ETH_ROPSTEN: {},
ETH_RINKEBY: {}
}

const CACHE_VALID_TIME = 60000 // 1 minute

class Nfts {

saveNfts = async (tokenBlockchainCode, address, nfts) => {
if (typeof CACHE[tokenBlockchainCode][address] !== 'undefined' && CACHE[tokenBlockchainCode][address] === nfts) return false
CACHE[tokenBlockchainCode][address] = nfts
CACHE_TIME[tokenBlockchainCode][address] = new Date().getTime()
const sql1 = `DELETE FROM transactions_scanners_tmp WHERE currency_code='${tokenBlockchainCode}' AND address='${address}' AND tmp_key='nfts'`
await Database.query(sql1, true)

const sql = `INSERT INTO transactions_scanners_tmp (
currency_code, address, tmp_key, tmp_val
) VALUES (
'${tokenBlockchainCode}', '${address}', 'nfts', '${Database.escapeString(JSON.stringify(nfts))}'
)`
await Database.query(sql, true)
}

getNfts = async (address) => {
const sql = `SELECT currency_code, tmp_val FROM transactions_scanners_tmp WHERE address='${address}' AND tmp_key='nfts'`
const res = await Database.query(sql, true)
if (!res || !res.array || res.array.length === 0) {
return false
}
for (const tmp of res.array) {
try {
CACHE[tmp.currency_code][address] = JSON.parse(Database.unEscapeString(tmp.tmp_val))
} catch (e) {
// do nothing
}
}
}

getNftsCache = (tokenBlockchainCode, address) => {
if (typeof CACHE[tokenBlockchainCode][address] === 'undefined') return false
if (typeof CACHE_TIME[tokenBlockchainCode][address] !== 'undefined') {
const now = new Date().getTime()
const diff = now - CACHE_TIME[tokenBlockchainCode][address]
if (diff < CACHE_VALID_TIME) {
return false
}
}
return CACHE[tokenBlockchainCode][address]
}
}

export default new Nfts()
31 changes: 19 additions & 12 deletions app/appstores/Stores/Currency/CurrencyActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@ const currencyActions = {

const currencies = await currencyDS.getCurrencies()

let currencyDBTmp
for (currencyDBTmp of currencies) {

function _push(prepare, currencyDBTmp) {
const settings = BlocksoftDict.Currencies[currencyDBTmp.currencyCode]

if (typeof settings === 'undefined') continue

if (typeof settings === 'undefined') return
let one
if (typeof settings.extendsProcessor === 'undefined') {
one = {
Expand All @@ -63,6 +59,14 @@ const currencyActions = {
one.currencyExplorerTxLink = BlocksoftPrettyLocalize.makeLink(one.currencyExplorerTxLink)
prepare.push(one)
}
for (const currencyDBTmp of currencies) {
if (currencyDBTmp.currencyCode !== 'NFT') continue
_push(prepare, currencyDBTmp)
}
for (const currencyDBTmp of currencies) {
if (currencyDBTmp.currencyCode === 'NFT') continue
_push(prepare, currencyDBTmp)
}

dispatch({
type: 'SET_CRYPTO_CURRENCIES',
Expand All @@ -79,9 +83,7 @@ const currencyActions = {
*/
checkIsCurrencySynchronized: (params) => {
try {

return !(typeof params.account === 'undefined' || !params.account.balanceScanTime)

} catch (e) {
Log.err('ACT/Currency checkIsCurrencySynchronized error ' + e.message, JSON.stringify(e))
}
Expand Down Expand Up @@ -218,18 +220,23 @@ const currencyActions = {
Log.log('ACT/Currency toggleCurrencyVisibility called ', params)

try {

let { walletNumber } = store.getState().mainStore.selectedWallet
if (typeof walletNumber === 'undefined' || !walletNumber) {
walletNumber = 1
} else {
walletNumber = walletNumber * 1
}

// binary from int - for support of old stored values
const selectedWalletNumber = store.getState().mainStore.selectedWallet.walletNumber
const currentIsHidden = Number(params.currentIsHidden || 0).toString(2).split('').reverse() // split to binary
for (let i = 0; i <= MarketingEvent.DATA.LOG_WALLETS_COUNT; i++) {
if (typeof currentIsHidden[i] === 'undefined') {
currentIsHidden[i] = 0
}
}
currentIsHidden[selectedWalletNumber] = params.newIsHidden
currentIsHidden[walletNumber] = params.newIsHidden
const isHidden = parseInt(currentIsHidden.reverse().join(''), 2)
Log.log('ACT/Currency toggleCurrencyVisibility selectedWalletNumber ' + selectedWalletNumber + ' isHidden ' + isHidden, JSON.stringify(currentIsHidden))
Log.log('ACT/Currency toggleCurrencyVisibility selectedWallet walletNumber ' + walletNumber + ' isHidden ' + isHidden, JSON.stringify(currentIsHidden))
await currencyDS.updateCurrency({
key: {
currencyCode: params.currencyCode
Expand Down
49 changes: 26 additions & 23 deletions app/appstores/Stores/Currency/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,30 @@ import store from '@app/store'
import Log from '@app/services/Log/Log'

export const getVisibleCurrencies = createSelector(
[state => state.currencyStore.cryptoCurrencies],
(currencies => {
let selectedWalletNumber = store.getState().mainStore.selectedWallet.walletNumber
if (typeof selectedWalletNumber === 'undefined' || !selectedWalletNumber) {
selectedWalletNumber = 0
} else {
selectedWalletNumber = selectedWalletNumber * 1
}
Log.log('ACT/Currency getVisibleCurrencies selectedWalletNumber ' + selectedWalletNumber)
return currencies.filter(c => {
if (c.isHidden === null) {
c.maskedHidden = true
} else {
const mask = Number(c.isHidden || 0).toString(2).split('').reverse() // split to binary
if (typeof mask[selectedWalletNumber] === 'undefined') {
c.maskedHidden = mask.length === 1 ? (mask[mask.length - 1] === '1') : false
} else {
c.maskedHidden = mask[selectedWalletNumber] === '1'
}
}
return !c.maskedHidden
})
})
[state => state.currencyStore.cryptoCurrencies],
(currencies => {
let { walletNumber } = store.getState().mainStore.selectedWallet
if (typeof walletNumber === 'undefined' || !walletNumber) {
walletNumber = 1
} else {
walletNumber = walletNumber * 1
}

Log.log('ACT/Currency getVisibleCurrencies selectedWallet walletNumber ' + walletNumber)

const tmp = currencies.filter(c => {
if (c.isHidden === null) {
c.maskedHidden = true
} else {
const mask = Number(c.isHidden || 0).toString(2).split('').reverse() // split to binary
if (typeof mask[walletNumber] === 'undefined') {
c.maskedHidden = mask.length === 1 ? (mask[mask.length - 1] === '1') : false
} else {
c.maskedHidden = mask[walletNumber] === '1'
}
}
return !c.maskedHidden
})
return [...tmp]
})
)
7 changes: 7 additions & 0 deletions app/appstores/Stores/Main/MainStoreActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ export async function setSelectedWallet(source, walletHash = false) {
await settingsActions.setSelectedWallet(walletHash)
}

dispatch({
type: 'SET_NFTS_LOADED',
loaded: false,
nfts : false,
address : false
})

dispatch({
type: 'SET_SELECTED_WALLET',
wallet
Expand Down
5 changes: 4 additions & 1 deletion app/appstores/Stores/Main/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export const getSelectedCryptoCurrencyData = createSelector(
currencyCode : data.currencyCode,
currencySymbol : data.currencySymbol,
currencyName : data.currencyName,
currencyType : data.currencyType,
tokenBlockchain : data.tokenBlockchain || 'ETHEREUM',
tokenBlockchainCode : data.tokenBlockchainCode || 'ETH',
decimals : data.decimals,
currencyExplorerLink : data.currencyExplorerLink,
mainColor : data.mainColor,
Expand Down Expand Up @@ -94,4 +97,4 @@ export const getLoaderStatusFromBse = createSelector(
export const getSolValidator = createSelector(
[state => state.mainStore.solValidator],
(data => data)
)
)
Loading

0 comments on commit e06e94d

Please sign in to comment.