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

fix: delete the temporary imported wallet path #17

Merged
merged 1 commit into from
Nov 20, 2023
Merged
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
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
Loading