Skip to content

Commit

Permalink
fix: temporary import wallet path (#17)
Browse files Browse the repository at this point in the history
Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
  • Loading branch information
sairanjit authored Nov 20, 2023
1 parent 7831900 commit 141e84a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/ssi/src/wallet/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// NOTE: We need to import these to be able to use the AskarWallet in this file.
import '@hyperledger/aries-askar-react-native'

import type { InitConfig } from '@aries-framework/core'
import type { InitConfig, WalletConfig, WalletExportImportConfig } from '@aries-framework/core'
import type { AgentModulesInput } from '@aries-framework/core/build/agent/AgentModules'

import { AskarWallet } from '@aries-framework/askar'
Expand All @@ -12,8 +12,7 @@ import {
LogLevel,
SigningProviderRegistry,
WsOutboundTransport,
type WalletConfig,
type WalletExportImportConfig
utils
} from '@aries-framework/core'
import { agentDependencies } from '@aries-framework/react-native'

Expand Down Expand Up @@ -71,8 +70,8 @@ export const isWalletImportable = async (
importConfig: WalletExportImportConfig
): Promise<boolean> => {
const fileSystem = new agentDependencies.FileSystem()
const tempImportPath = fileSystem.tempPath + '/' + utils.uuid()
try {
const tempImportPath = fileSystem.tempPath + '/importTemp'
// Add temp path to wallet config
walletConfig.storage = {
type: 'sqlite',
Expand All @@ -82,12 +81,12 @@ export const isWalletImportable = async (
const askarWallet = new AskarWallet(new ConsoleLogger(LogLevel.debug), fileSystem, new SigningProviderRegistry([]))
await askarWallet.import(walletConfig, importConfig)

await fileSystem.delete(importConfig.path)
await fileSystem.delete(tempImportPath)
return true
} catch (e) {
// eslint-disable-next-line no-console
console.log('Error importing wallet', e)
await fileSystem.delete(importConfig.path)
await fileSystem.delete(tempImportPath)
return false
}
}
Expand Down

0 comments on commit 141e84a

Please sign in to comment.