diff --git a/apps/wallet-mobile/ios/yoroi.xcodeproj/project.pbxproj b/apps/wallet-mobile/ios/yoroi.xcodeproj/project.pbxproj index 6b6a5cb0ab..5d01dbb393 100644 --- a/apps/wallet-mobile/ios/yoroi.xcodeproj/project.pbxproj +++ b/apps/wallet-mobile/ios/yoroi.xcodeproj/project.pbxproj @@ -761,7 +761,7 @@ "$(inherited)", ); INFOPLIST_FILE = yoroiTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -802,7 +802,7 @@ "DEVELOPMENT_TEAM[sdk=iphoneos*]" = F8NVT2G2L4; ENVFILE = "$(PODS_ROOT)/../../.env"; INFOPLIST_FILE = yoroiTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -970,7 +970,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( /usr/lib/swift, "$(inherited)", @@ -1044,7 +1044,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( /usr/lib/swift, "$(inherited)", @@ -1088,6 +1088,7 @@ ENVFILE = "$(PODS_ROOT)/../../.env.nightly"; INFOPLIST_FILE = nightly.plist; INFOPLIST_KEY_CFBundleDisplayName = "Yoroi Nightly"; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1132,6 +1133,7 @@ ENVFILE = "$(PODS_ROOT)/../../.env.nightly"; INFOPLIST_FILE = nightly.plist; INFOPLIST_KEY_CFBundleDisplayName = "Yoroi Nightly"; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/apps/wallet-mobile/src/features/Discover/common/ledger.ts b/apps/wallet-mobile/src/features/Discover/common/ledger.ts index 945ccaf39c..ebc008c17b 100644 --- a/apps/wallet-mobile/src/features/Discover/common/ledger.ts +++ b/apps/wallet-mobile/src/features/Discover/common/ledger.ts @@ -98,27 +98,47 @@ async function formatLedgerWithdrawals( ): Promise> { const result: Array = [] - const withdrawalKeys = await withdrawals.keys() - for (let i = 0; i < (await withdrawalKeys.len()); i++) { - const rewardAddress = await withdrawalKeys.get(i) + const keys = await withdrawals.keys() + const keysLength = await keys.len() + for (let i = 0; i < keysLength; i++) { + const rewardAddress = await keys.get(i) const withdrawalAmount = await withdrawals.get(rewardAddress) if (withdrawalAmount == null) { throw new Error(`formatLedgerWithdrawals should never happen`) } - - const rewardAddressPayload = Buffer.from(await rewardAddress.toAddress().then((a) => a.toBytes())).toString('hex') + const rewardAddressPayload = await (await rewardAddress.toAddress()).toHex() const addressing = addressingMap(rewardAddressPayload) - if (addressing == null) { - throw new Error(`formatLedgerWithdrawals Ledger can only withdraw from own address ${rewardAddressPayload}`) + let stakeCredential: null | Withdrawal['stakeCredential'] = null + if (addressing != null) { + stakeCredential = { + type: CredentialParamsType.KEY_PATH, + keyPath: addressing.path, + } + } else { + const cred = await rewardAddress.paymentCred() + const maybeKeyHash = await cred.toKeyhash() + const maybeScriptHash = await cred.toScripthash() + if (maybeKeyHash) { + stakeCredential = { + type: CredentialParamsType.KEY_HASH, + keyHashHex: await maybeKeyHash.toHex(), + } + } else if (maybeScriptHash) { + stakeCredential = { + type: CredentialParamsType.SCRIPT_HASH, + scriptHashHex: await maybeScriptHash.toHex(), + } + } + } + if (stakeCredential === null) { + throw new Error('Failed to resolve credential type for reward address: ' + rewardAddressPayload) } result.push({ amount: await withdrawalAmount.toStr(), - stakeCredential: { - type: CredentialParamsType.KEY_PATH, - keyPath: addressing.path, - }, + stakeCredential, }) } + return result } async function formatLedgerCertificates(