Skip to content

Commit

Permalink
release(wallet-mobile): v4.28.1 (#3597)
Browse files Browse the repository at this point in the history
  • Loading branch information
stackchain authored Sep 5, 2024
2 parents 6797e15 + fa5d5a5 commit a9431a6
Show file tree
Hide file tree
Showing 27 changed files with 195 additions and 198 deletions.
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions .husky/pre-commit

This file was deleted.

4 changes: 2 additions & 2 deletions apps/wallet-mobile/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ android {
applicationId "com.emurgo"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 690
versionName "4.28.0"
versionCode 707
versionName "4.28.1"
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
Expand Down
2 changes: 1 addition & 1 deletion apps/wallet-mobile/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
buildToolsVersion = "33.0.2"
minSdkVersion = 24
compileSdkVersion = 33
targetSdkVersion = 33
targetSdkVersion = 34
kotlinVersion = "1.7.0"
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"
Expand Down
16 changes: 8 additions & 8 deletions apps/wallet-mobile/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ PODS:
- react-native-config/App (= 1.5.1)
- react-native-config/App (1.5.1):
- React-Core
- react-native-haskell-shelley (6.0.0-alpha.9):
- react-native-haskell-shelley (6.1.0-beta.1):
- React
- react-native-mmkv (2.11.0):
- MMKV (>= 1.2.13)
Expand Down Expand Up @@ -495,10 +495,10 @@ PODS:
- SentryPrivate (= 8.9.3)
- SentryPrivate (8.9.3)
- Yoga (1.14.0)
- ZXingObjC/Core (3.6.5)
- ZXingObjC/OneD (3.6.5):
- ZXingObjC/Core (3.6.9)
- ZXingObjC/OneD (3.6.9):
- ZXingObjC/Core
- ZXingObjC/PDF417 (3.6.5):
- ZXingObjC/PDF417 (3.6.9):
- ZXingObjC/Core

DEPENDENCIES:
Expand Down Expand Up @@ -771,7 +771,7 @@ SPEC CHECKSUMS:
amplitude-react-native: 1ea3d5e1f80ccc357dd178c55c29e51c89f1cd11
boost: 57d2868c099736d80fcd648bf211b4431e51a558
BVLinearGradient: e3aad03778a456d77928f594a649e96995f1c872
DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
EXApplication: d8f53a7eee90a870a75656280e8d4b85726ea903
EXBarCodeScanner: 8e23fae8d267dbef9f04817833a494200f1fce35
EXCamera: 0fbfa338a3776af2722d626a3437abe33f708aad
Expand All @@ -787,7 +787,7 @@ SPEC CHECKSUMS:
FBLazyVector: 12ea01e587c9594e7b144e1bfc86ac4d9ac28fde
FBReactNativeSpec: faca7d16c37626ca5780a87adef703817722fe61
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
hermes-engine: d7cc127932c89c53374452d6f93473f1970d8e88
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
MMKV: f902fb6719da13c2ab0965233d8963a59416f911
Expand Down Expand Up @@ -816,7 +816,7 @@ SPEC CHECKSUMS:
react-native-background-timer: 17ea5e06803401a379ebf1f20505b793ac44d0fe
react-native-ble-plx: f10240444452dfb2d2a13a0e4f58d7783e92d76e
react-native-config: 86038147314e2e6d10ea9972022aa171e6b1d4d8
react-native-haskell-shelley: 4015aef14eca3ecf5e8d8718e8d1b47cdcf60f84
react-native-haskell-shelley: f3eaa102ff7b60063a4aff8bd36d23cb4de49c2e
react-native-mmkv: e97c0c79403fb94577e5d902ab1ebd42b0715b43
react-native-pager-view: 0ccb8bf60e2ebd38b1f3669fa3650ecce81db2df
react-native-quick-base64: 62290829c619fbabca4c41cfec75ae759d08fc1c
Expand Down Expand Up @@ -858,7 +858,7 @@ SPEC CHECKSUMS:
Sentry: 97161cac725da1ecbe77d1445bf8a61c1e5667f1
SentryPrivate: 9a76def09fb08f9501997b8df946e8097947b94f
Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9
ZXingObjC: fdbb269f25dd2032da343e06f10224d62f537bdb
ZXingObjC: 8898711ab495761b2dbbdec76d90164a6d7e14c5

PODFILE CHECKSUM: 31f344d67f1a9c35e34eb202e3cdfeb4907367e8

Expand Down
4 changes: 2 additions & 2 deletions apps/wallet-mobile/ios/nightly.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>4.28.0</string>
<string>4.28.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>577</string>
<string>594</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>
Expand Down
8 changes: 4 additions & 4 deletions apps/wallet-mobile/ios/yoroi.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@
CODE_SIGN_ENTITLEMENTS = yoroi/yoroi.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 577;
CURRENT_PROJECT_VERSION = 594;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = F8NVT2G2L4;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -884,7 +884,7 @@
CODE_SIGN_ENTITLEMENTS = yoroi/yoroi.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 577;
CURRENT_PROJECT_VERSION = 594;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = F8NVT2G2L4;
ENVFILE = "$(PODS_ROOT)/../../.env.production";
Expand Down Expand Up @@ -1079,7 +1079,7 @@
CODE_SIGN_ENTITLEMENTS = nightly.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 577;
CURRENT_PROJECT_VERSION = 594;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = F8NVT2G2L4;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -1124,7 +1124,7 @@
CODE_SIGN_ENTITLEMENTS = nightly.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 577;
CURRENT_PROJECT_VERSION = 594;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = F8NVT2G2L4;
ENVFILE = "$(PODS_ROOT)/../../.env.nightly";
Expand Down
4 changes: 2 additions & 2 deletions apps/wallet-mobile/ios/yoroi/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>4.28.0</string>
<string>4.28.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -34,7 +34,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>577</string>
<string>594</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>
Expand Down
4 changes: 2 additions & 2 deletions apps/wallet-mobile/ios/yoroiTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>4.28.0</string>
<string>4.28.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>577</string>
<string>594</string>
</dict>
</plist>
14 changes: 7 additions & 7 deletions apps/wallet-mobile/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yoroi/wallet-mobile",
"version": "4.28.0",
"version": "4.28.1",
"private": true,
"scripts": {
"android-bundle": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res",
Expand Down Expand Up @@ -94,12 +94,12 @@
"@cardano-foundation/ledgerjs-hw-app-cardano": "^7.1.3",
"@emurgo/cip14-js": "^3.0.1",
"@emurgo/cip4-js": "1.0.7",
"@emurgo/cross-csl-core": "4.4.0",
"@emurgo/cross-csl-mobile": "4.4.0",
"@emurgo/csl-mobile-bridge": "6.0.0-alpha.9",
"@emurgo/cross-csl-core": "^5.1.0-beta.1",
"@emurgo/cross-csl-mobile": "^5.1.0-beta.1",
"@emurgo/csl-mobile-bridge": "^6.1.0-beta.1",
"@emurgo/react-native-blockies-svg": "^0.0.2",
"@emurgo/react-native-hid": "^5.15.6",
"@emurgo/yoroi-lib": "^0.15.6",
"@emurgo/yoroi-lib": "^1.2.1",
"@formatjs/intl-datetimeformat": "^6.7.0",
"@formatjs/intl-getcanonicallocales": "^2.1.0",
"@formatjs/intl-locale": "^3.2.1",
Expand Down Expand Up @@ -214,8 +214,8 @@
"@babel/preset-env": "^7.20.0",
"@babel/preset-react": "^7.16.7",
"@babel/runtime": "^7.20.0",
"@emurgo/cardano-serialization-lib-nodejs": "12.0.0-alpha.28",
"@emurgo/cross-csl-nodejs": "4.4.0",
"@emurgo/cardano-serialization-lib-nodejs": "~12.1.0-beta.1",
"@emurgo/cross-csl-nodejs": "^5.1.0-beta.1",
"@formatjs/cli": "^6.1.0",
"@formatjs/ts-transformer": "^3.13.0",
"@react-navigation/devtools": "^6.0.13",
Expand Down
17 changes: 15 additions & 2 deletions apps/wallet-mobile/src/features/Swap/common/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {createTypeGuardFromSchema, parseSafe} from '@yoroi/common'
import {useTheme} from '@yoroi/theme'
import {Balance} from '@yoroi/types'
import {SwapApi} from '@yoroi/types/src/swap/api'
import {freeze} from 'immer'
import {useMutation, UseMutationOptions} from 'react-query'
import {z} from 'zod'

Expand Down Expand Up @@ -60,11 +61,23 @@ const isOrderTxMetadata = createTypeGuardFromSchema(OrderTxMetadataSchema)
* Parses and validates a JSON metadata string, transforming it into a structure compliant with MappedRawOrder['metadata'].
*
* @param metadataJson - The JSON string representation of metadata.
* @param primaryTokenId - The primary token ID to use when the metadata specifies a '.' or empty string.
* @returns The parsed metadata object or null if parsing fails or validation fails.
*/
export const parseOrderTxMetadata = (metadataJson: string): OrderTxMetadata | null => {
export const parseOrderTxMetadata = (metadataJson: string, primaryTokenId: string): OrderTxMetadata | null => {
const parsedMetadata = parseSafe(metadataJson)
return isOrderTxMetadata(parsedMetadata) ? parsedMetadata : null
if (!isOrderTxMetadata(parsedMetadata)) return null

return {
...parsedMetadata,
buyTokenId: normalisePrimaryTokenId(parsedMetadata.buyTokenId, primaryTokenId),
sellTokenId: normalisePrimaryTokenId(parsedMetadata.sellTokenId, primaryTokenId),
}
}

const swapPtTokenIds = freeze(['', '.'])
const normalisePrimaryTokenId = (tokenId: string, primaryTokenId: string) => {
return swapPtTokenIds.includes(tokenId) ? primaryTokenId : tokenId
}

function containsOnlyValidChars(str?: string): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const compareByDate = (a: MappedRawOrder, b: MappedRawOrder) => {
return new Date(b.date).getTime() - new Date(a.date).getTime()
}

const findCompletedOrderTx = (transactions: TransactionInfo[]): MappedRawOrder[] => {
const findCompletedOrderTx = (transactions: TransactionInfo[], primaryTokenId: string): MappedRawOrder[] => {
const sentTransactions = transactions.filter((tx) => tx.direction === 'SENT')
const receivedTransactions = transactions.filter((tx) => tx.direction === 'RECEIVED')

Expand All @@ -67,7 +67,7 @@ const findCompletedOrderTx = (transactions: TransactionInfo[]): MappedRawOrder[]
if (Boolean(input.id) && input?.id?.slice(0, -1) === sentTx?.id && receivedTx.inputs.length > 1) {
result['id'] = sentTx?.id
result['date'] = receivedTx?.lastUpdatedAt
const metadata = parseOrderTxMetadata(sentTx?.metadata?.['674'])
const metadata = parseOrderTxMetadata(sentTx?.metadata?.['674'], primaryTokenId)
if (metadata) {
result['metadata'] = metadata
return acc.push(result as MappedRawOrder)
Expand Down Expand Up @@ -114,7 +114,7 @@ export const CompletedOrders = () => {
}, [])

const transactionsInfos = useTransactionInfos(wallet)
const completeOrders = findCompletedOrderTx(Object.values(transactionsInfos))
const completeOrders = findCompletedOrderTx(Object.values(transactionsInfos), wallet.primaryTokenInfo.id)
const tokenIds = React.useMemo(
() => _.uniq(completeOrders?.flatMap((o) => [o.metadata.sellTokenId, o.metadata.buyTokenId])),
[completeOrders],
Expand Down
39 changes: 5 additions & 34 deletions apps/wallet-mobile/src/yoroi-wallets/cardano/MultiToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@ import {TokenEntry} from '@emurgo/yoroi-lib'
import {BigNumber} from 'bignumber.js'

import {DefaultAsset} from '../types'
import type {NetworkId} from '../types/other'

export type TokenLookupKey = {
identifier: string
networkId: number
}
export type TokenEntryPlain = TokenLookupKey & {
amount: string
isDefault: boolean
}
export type DefaultTokenEntry = {
defaultNetworkId: number
defaultIdentifier: string
}
export class MultiToken {
Expand All @@ -28,27 +25,16 @@ export class MultiToken {
this.defaults = defaults
this.add({
identifier: defaults.defaultIdentifier,
networkId: defaults.defaultNetworkId,
amount: new BigNumber(0),
})
values.forEach((value) => this.add(value))
}

_checkNetworkId: (arg0: number) => void = (networkId) => {
const ownNetworkId = this.defaults.defaultNetworkId

if (ownNetworkId !== networkId) {
throw new Error(`MultiToken:: network mismatch ${ownNetworkId} - ${networkId}`)
}
}

get: (arg0: string) => BigNumber | void = (identifier) => {
return this.values.find((value) => value.identifier === identifier)?.amount
}

add: (arg0: TokenEntry) => MultiToken = (entry) => {
this._checkNetworkId(entry.networkId)

const existingEntry = this.values.find((value) => value.identifier === entry.identifier)

if (existingEntry == null) {
Expand All @@ -64,7 +50,6 @@ export class MultiToken {
return this.add({
identifier: entry.identifier,
amount: entry.amount.negated(),
networkId: entry.networkId,
})
}

Expand Down Expand Up @@ -119,19 +104,13 @@ export class MultiToken {
}

getDefaultEntry: (arg0: void) => TokenEntry = () => {
return this.values.filter(
(value) =>
value.networkId === this.defaults.defaultNetworkId && value.identifier === this.defaults.defaultIdentifier,
)[0]
return this.values.filter((value) => value.identifier === this.defaults.defaultIdentifier)[0]
}

getDefaultId: (arg0: void) => string = () => this.defaults.defaultIdentifier

nonDefaultEntries: (arg0: void) => Array<TokenEntry> = () => {
return this.values.filter(
(value) =>
!(value.networkId === this.defaults.defaultNetworkId && value.identifier === this.defaults.defaultIdentifier),
)
return this.values.filter((value) => !(value.identifier === this.defaults.defaultIdentifier))
}

asMap: (arg0: void) => Map<string, BigNumber> = () => {
Expand Down Expand Up @@ -162,26 +141,20 @@ export class MultiToken {
asArray: (arg0: void) => Array<TokenEntryPlain> = () =>
this.values.map((value) => ({
identifier: value.identifier,
networkId: value.networkId,
amount: value.amount.toString(),
isDefault:
value.networkId === this.defaults.defaultNetworkId && value.identifier === this.defaults.defaultIdentifier,
isDefault: value.identifier === this.defaults.defaultIdentifier,
}))

static fromArray(entries: Array<TokenEntryPlain>): MultiToken {
const _asTokenEntry = (value: TokenEntryPlain) => ({
identifier: value.identifier,
networkId: value.networkId,
amount: new BigNumber(value.amount),
})

const values = entries.map(_asTokenEntry)
const defaults = entries
.filter((value) => value.isDefault)
.map((value) => ({
defaultNetworkId: value.networkId,
defaultIdentifier: value.identifier,
}))[0]
.map((value) => ({defaultIdentifier: value.identifier}))[0]
return new MultiToken(values, defaults)
}
}
Expand All @@ -191,17 +164,15 @@ export class MultiToken {
*/
export const getDefaultNetworkTokenEntry = (defaultAsset: DefaultAsset): DefaultTokenEntry => {
return {
defaultNetworkId: defaultAsset.networkId,
defaultIdentifier: defaultAsset.identifier,
}
}
export const strToDefaultMultiAsset = (amount: string, networkId: NetworkId, defaultAsset: DefaultAsset) => {
export const strToDefaultMultiAsset = (amount: string, defaultAsset: DefaultAsset) => {
const defaultTokenEntry = getDefaultNetworkTokenEntry(defaultAsset)
return new MultiToken(
[
{
identifier: defaultTokenEntry.defaultIdentifier,
networkId,
amount: new BigNumber(amount),
},
],
Expand Down
Loading

0 comments on commit a9431a6

Please sign in to comment.