Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CU-86a218w2e - Error when trying to decrypt key in dev mode #32

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@cityofzion/bs-neo-legacy",
"comment": "Fixed bug preventing decryption in dev mode in React Native",
"type": "patch"
}
],
"packageName": "@cityofzion/bs-neo-legacy"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@cityofzion/bs-neo3",
"comment": "Fixed bug preventing decryption in dev mode in React Native",
"type": "patch"
}
],
"packageName": "@cityofzion/bs-neo3"
}
11 changes: 5 additions & 6 deletions packages/bs-neo-legacy/src/BSNeoLegacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import { keychain } from '@cityofzion/bs-asteroid-sdk'
import { DoraESNeoLegacy } from './DoraESNeoLegacy'

export class BSNeoLegacy<BSCustomName extends string = string>
implements BlockchainService, BSClaimable, BSWithExplorerService
{
implements BlockchainService, BSClaimable, BSWithExplorerService {
readonly blockchainName: BSCustomName
readonly feeToken: Token
readonly claimToken: Token
Expand Down Expand Up @@ -103,15 +102,15 @@ export class BSNeoLegacy<BSCustomName extends string = string>
try {
const { NativeModules } = require('react-native')
BsReactNativeDecrypt = NativeModules.BsReactNativeDecrypt

if (!BsReactNativeDecrypt) {
throw new Error('@CityOfZion/bs-react-native-decrypt is not installed')
}
} catch {
const key = await wallet.decrypt(encryptedKey, password)
return this.generateAccountFromKey(key)
}

if (!BsReactNativeDecrypt) {
throw new Error('@CityOfZion/bs-react-native-decrypt is not installed')
}

const privateKey = await BsReactNativeDecrypt.decryptNeoLegacy(encryptedKey, password)
return this.generateAccountFromKey(privateKey)
}
Expand Down
11 changes: 5 additions & 6 deletions packages/bs-neo3/src/BSNeo3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ import { keychain } from '@cityofzion/bs-asteroid-sdk'
import { DoraESNeo3 } from './DoraESNeo3'

export class BSNeo3<BSCustomName extends string = string>
implements BlockchainService, BSClaimable, BSWithNameService, BSCalculableFee, BSWithNft, BSWithExplorerService
{
implements BlockchainService, BSClaimable, BSWithNameService, BSCalculableFee, BSWithNft, BSWithExplorerService {
readonly blockchainName: BSCustomName
readonly feeToken: Token
readonly claimToken: Token
Expand Down Expand Up @@ -117,15 +116,15 @@ export class BSNeo3<BSCustomName extends string = string>
try {
const { NativeModules } = require('react-native')
BsReactNativeDecrypt = NativeModules.BsReactNativeDecrypt

if (!BsReactNativeDecrypt) {
throw new Error('@CityOfZion/bs-react-native-decrypt is not installed')
}
} catch {
const key = await wallet.decrypt(encryptedKey, password)
return this.generateAccountFromKey(key)
}

if (!BsReactNativeDecrypt) {
throw new Error('@CityOfZion/bs-react-native-decrypt is not installed')
}

const privateKey = await BsReactNativeDecrypt.decryptNeo3(encryptedKey, password)
return this.generateAccountFromKey(privateKey)
}
Expand Down