Skip to content

Commit

Permalink
Merge prod on dev (#1408)
Browse files Browse the repository at this point in the history
* Support for Token metadata (#1403)

* Function to poll decimal metadata and save it in redux Store. Notes:

- So far we only fetched our backend for almost everything, so the same base url was shared in all calls. Adding a third party endpoint required to slightly refactor the fetch function to be more flexible.
- Token metadata is fetched when wallet is opened and only stored in redux's Store (not in persistent storage). We may add this functionality later

* Use token metadata from Store in UI, plus some fixes

* UI improvements

* use cdn for mainnet and minor fix

* trigger token metadata update when txs are received/updated

* fix: do not clear token info before fetching, plus a minor UI fix

* 4.1.4 (#1405)
  • Loading branch information
v-almonacid committed Jun 16, 2021
1 parent f40cf47 commit bd04820
Show file tree
Hide file tree
Showing 27 changed files with 403 additions and 116 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ android {
applicationId "com.emurgo"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 261
versionName "4.1.3"
versionCode 270
versionName "4.1.4"
ndk {
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
Expand Down
2 changes: 1 addition & 1 deletion ios/Nightly-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>260</string>
<string>270</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/Staging-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>260</string>
<string>270</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>
Expand Down
48 changes: 24 additions & 24 deletions ios/emurgo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@
BUNDLE_DISPLAY_NAME = Yoroi;
BUNDLE_ID_SUFFIX = "";
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 260;
CURRENT_PROJECT_VERSION = 270;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
Expand All @@ -995,7 +995,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 4.1.3;
MARKETING_VERSION = 4.1.4;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -1020,7 +1020,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 260;
CURRENT_PROJECT_VERSION = 270;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
HEADER_SEARCH_PATHS = (
Expand All @@ -1043,7 +1043,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 4.1.3;
MARKETING_VERSION = 4.1.4;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -1066,7 +1066,7 @@
BUNDLE_DISPLAY_NAME = Yoroi;
BUNDLE_ID_SUFFIX = "";
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 260;
CURRENT_PROJECT_VERSION = 270;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -1094,7 +1094,7 @@
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
MARKETING_VERSION = 4.1.3;
MARKETING_VERSION = 4.1.4;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -1117,7 +1117,7 @@
BUNDLE_DISPLAY_NAME = "Yoroi Staging";
BUNDLE_ID_SUFFIX = .staging;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 260;
CURRENT_PROJECT_VERSION = 270;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -1145,7 +1145,7 @@
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
MARKETING_VERSION = 4.1.3;
MARKETING_VERSION = 4.1.4;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -1170,7 +1170,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 260;
CURRENT_PROJECT_VERSION = 270;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
HEADER_SEARCH_PATHS = (
Expand All @@ -1197,7 +1197,7 @@
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
MARKETING_VERSION = 4.1.3;
MARKETING_VERSION = 4.1.4;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -1220,7 +1220,7 @@
BUNDLE_DISPLAY_NAME = "Yoroi Staging";
BUNDLE_ID_SUFFIX = .staging;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 260;
CURRENT_PROJECT_VERSION = 270;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
HEADER_SEARCH_PATHS = (
Expand All @@ -1247,7 +1247,7 @@
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
MARKETING_VERSION = 4.1.3;
MARKETING_VERSION = 4.1.4;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1455,7 +1455,7 @@
BUNDLE_DISPLAY_NAME = "Yoroi Staging";
BUNDLE_ID_SUFFIX = .staging;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 260;
CURRENT_PROJECT_VERSION = 270;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
Expand All @@ -1479,7 +1479,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 4.1.3;
MARKETING_VERSION = 4.1.4;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1601,7 +1601,7 @@
BUNDLE_DISPLAY_NAME = "Yoroi Staging";
BUNDLE_ID_SUFFIX = .staging;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 260;
CURRENT_PROJECT_VERSION = 270;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
HEADER_SEARCH_PATHS = (
Expand All @@ -1624,7 +1624,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 4.1.3;
MARKETING_VERSION = 4.1.4;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1684,7 +1684,7 @@
BUNDLE_DISPLAY_NAME = Yoroi;
BUNDLE_ID_SUFFIX = "";
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 260;
CURRENT_PROJECT_VERSION = 270;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
Expand All @@ -1708,7 +1708,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 4.1.3;
MARKETING_VERSION = 4.1.4;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -1731,7 +1731,7 @@
BUNDLE_DISPLAY_NAME = "Yoroi Staging";
BUNDLE_ID_SUFFIX = .staging;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 260;
CURRENT_PROJECT_VERSION = 270;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
Expand All @@ -1755,7 +1755,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 4.1.3;
MARKETING_VERSION = 4.1.4;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -1780,7 +1780,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 260;
CURRENT_PROJECT_VERSION = 270;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
HEADER_SEARCH_PATHS = (
Expand All @@ -1803,7 +1803,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 4.1.3;
MARKETING_VERSION = 4.1.4;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -1826,7 +1826,7 @@
BUNDLE_DISPLAY_NAME = "Yoroi Staging";
BUNDLE_ID_SUFFIX = .staging;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 260;
CURRENT_PROJECT_VERSION = 270;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
HEADER_SEARCH_PATHS = (
Expand All @@ -1849,7 +1849,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 4.1.3;
MARKETING_VERSION = 4.1.4;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
2 changes: 1 addition & 1 deletion ios/emurgo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>260</string>
<string>270</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/emurgoTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>260</string>
<string>270</string>
</dict>
</plist>
6 changes: 6 additions & 0 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import {changeAndSaveLanguage} from './actions/language'
import {clearUTXOs} from './actions/utxo'
import {clearAccountState} from './actions/account'
import {fetchTokenInfo} from './actions/tokenInfo'
import {
canBiometricEncryptionBeEnabled,
recreateAppSignInKeys,
Expand Down Expand Up @@ -354,9 +355,14 @@ export const setupHooks = () => (dispatch: Dispatch<any>) => {
walletManager.subscribeServerSync((status) =>
dispatch(_setServerStatus(status)),
)

walletManager.subscribeOnOpen(() => dispatch(fetchTokenInfo()))

walletManager.subscribeOnClose(() => dispatch(clearUTXOs()))
walletManager.subscribeOnClose(() => dispatch(clearAccountState()))

walletManager.subscribeOnTxHistoryUpdate(() => dispatch(fetchTokenInfo()))

Logger.debug('setting up app lock')
const onTimeoutAction = () => {
dispatch(logout())
Expand Down
2 changes: 1 addition & 1 deletion src/actions/pools.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const _clearPoolInfo = () => ({

const _setLastError = (error) => ({
type: 'SET_LAST_FETCHING_ERROR',
path: ['accountState', 'lastFetchingError'],
path: ['poolInfo', 'lastFetchingError'],
payload: error,
reducer: (state, error) => error,
})
Expand Down
99 changes: 99 additions & 0 deletions src/actions/tokenInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// @flow
import type {Dispatch} from 'redux'

import walletManager from '../crypto/walletManager'
import {availableAssetsSelector, tokenBalanceSelector} from '../selectors'
import {ObjectValues} from '../utils/flow'
import {Logger} from '../utils/logging'

import type {State} from '../state'
import type {Token} from '../types/HistoryTransaction'
import type {MultiToken} from '../crypto/MultiToken'
import type {TokenInfoRequest, TokenInfoResponse} from '../api/types'

const _startFetching = () => ({
type: 'START_FETCHING_TOKEN_INFO',
path: ['tokenInfo', 'isFetching'],
payload: null,
reducer: (_state, _isFetching) => true,
})

const _endFetching = () => ({
type: 'END_FETCHING_TOKEN_INFO',
path: ['tokenInfo', 'isFetching'],
payload: null,
reducer: (_state, _isFetching) => false,
})

const _setTokenInfo = (tokenInfo) => ({
type: 'SET_TOKEN_INFO',
path: ['tokenInfo', 'tokens'],
payload: tokenInfo,
reducer: (state, value) => value,
})

const _setLastError = (error) => ({
type: 'SET_LAST_FETCHING_ERROR',
path: ['tokenInfo', 'lastFetchingError'],
payload: error,
reducer: (state, error) => error,
})

export const fetchTokenInfo = () => async (
dispatch: Dispatch<any>,
getState: () => State,
) => {
const state = getState()
if (state.tokenInfo.isFetching) {
return
}
dispatch(_setTokenInfo(availableAssetsSelector(state)))
dispatch(_startFetching())
try {
const availableAssets: Dict<Token> = availableAssetsSelector(state)
const assetsBalance: MultiToken = tokenBalanceSelector(state)

// subject -> identifier
const subjectDict = ObjectValues(availableAssets)
.filter((asset) => {
const assetValue = assetsBalance.get(asset.identifier)
return assetValue && assetValue.gt(0)
})
.reduce((acc, curr: Token): Dict<string> => {
if (curr.identifier === '') return acc
acc[`${curr.metadata.policyId}${curr.metadata.assetName}`] =
curr.identifier
return acc
}, ({}: Dict<string>))
const tokenIds = Object.keys(subjectDict)
const tokenInfo: TokenInfoResponse = await walletManager.fetchTokenInfo(
({
tokenIds,
}: TokenInfoRequest),
)
const tokens = {...availableAssets}
for (const key of Object.keys(tokenInfo)) {
const _token = tokens[subjectDict[key]]
const newInfo = tokenInfo[key]
if (newInfo == null) continue
tokens[subjectDict[key]] = {
..._token,
metadata: {
..._token.metadata,
longName: newInfo.name || null,
numberOfDecimals: newInfo.decimals || 0,
},
}
}
Logger.info('saving token info in state....', tokens)
dispatch(_setTokenInfo(tokens))
dispatch(_setLastError(null))
} catch (err) {
Logger.warn('actions:tokenInfo::fetchTokenInfo', err)
dispatch(_setLastError(err))
} finally {
dispatch(_endFetching())
}
}

0 comments on commit bd04820

Please sign in to comment.