Skip to content

Commit

Permalink
chore: update to rc.34
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuditi committed May 5, 2023
1 parent 9f4793d commit 8653b67
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { OnboardingLayout } from '@components'
import { ImportFile, updateOnboardingProfile, validateBackupFile } from '@contexts/onboarding'
import { ImportFile, updateOnboardingProfile, validateBackupFile, onboardingProfile } from '@contexts/onboarding'
import { mobile } from '@core/app'
import { CLIENT_ERROR_REGEXES } from '@core/error/constants'
import { ClientError } from '@core/error/enums'
Expand Down Expand Up @@ -82,7 +82,7 @@
async function shouldMigrate(): Promise<boolean> {
try {
await restoreBackup(importFilePath, '')
await restoreBackup(importFilePath, '', $onboardingProfile.network.protocol.bech32Hrp)
} catch (err) {
const isMigrationRequired = CLIENT_ERROR_REGEXES[ClientError.MigrationRequired].test(err?.error)
return isMigrationRequired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { mobile } from '@core/app'
export async function restoreBackupFromStrongholdFile(strongholdPassword: string): Promise<void> {
const { id, importFilePath, clientOptions, network } = get(onboardingProfile)
try {
await restoreBackup(importFilePath, strongholdPassword)
await restoreBackup(importFilePath, strongholdPassword, network.protocol.bech32Hrp)
if (mobile) {
await validateStrongholdCoinType(profileManager, network?.id)
updateOnboardingProfile({ lastStrongholdBackupTime: new Date() })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type {
AccountMetadata,
SyncOptions,
Address,
AddressGenerationOptions,
AddressNativeTokens,
AddressNftId,
AddressWithAmount,
Expand Down Expand Up @@ -33,6 +32,7 @@ import type {
TransactionOptions,
ParticipationEventRegistrationOptions,
ParticipationEventMap,
GenerateAddressOptions,
} from '@iota/wallet'

export interface IAccount {
Expand Down Expand Up @@ -63,8 +63,8 @@ export interface IAccount {
deregisterParticipationEvent(eventId: string): Promise<void>
destroyAlias(aliasId: string, transactionOptions?: TransactionOptions): Promise<Transaction>
destroyFoundry(foundryId: string, transactionOptions?: TransactionOptions): Promise<Transaction>
generateAddress(options?: AddressGenerationOptions): Promise<Address>
generateAddresses(amount: number, options?: AddressGenerationOptions): Promise<Address[]>
generateAddress(options?: GenerateAddressOptions): Promise<Address>
generateAddresses(amount: number, options?: GenerateAddressOptions): Promise<Address[]>
getBalance(): Promise<AccountBalance>
getFoundryOutput(tokenId: string): Promise<IFoundryOutput>
getMetadata(): AccountMetadata
Expand Down Expand Up @@ -113,6 +113,7 @@ export interface IAccount {
sendNft(addressesAndNftIds: AddressNftId[], transactionOptions?: TransactionOptions): Promise<Transaction>
sendOutputs(outputs: OutputTypes[], transactionOptions?: TransactionOptions): Promise<Transaction>
setAlias(alias: string): Promise<void>
setDefaultSyncOptions(options: SyncOptions): Promise<void>
signTransactionEssence(preparedTransactionData: PreparedTransactionData): Promise<SignedTransactionEssence>
stopParticipating(eventId: string): Promise<Transaction>
submitAndStoreTransaction(signedTransactionData: SignedTransactionEssence): Promise<Transaction>
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/lib/core/profile-manager/api/restoreBackup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { profileManager } from '../stores'
// and accounts IF the cointype doesn't match
const IGNORE_IF_COIN_TYPE_MISMATCH = true

export async function restoreBackup(importFilePath: string, password: string): Promise<void> {
export async function restoreBackup(importFilePath: string, password: string, bech32Hrp: string): Promise<void> {
const manager = get(profileManager)
await manager.restoreBackup(importFilePath, password, IGNORE_IF_COIN_TYPE_MISMATCH)
await manager.restoreBackup(importFilePath, password, IGNORE_IF_COIN_TYPE_MISMATCH, bech32Hrp)
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ export interface IProfileManager {
listen(eventTypes: EventType[], callback: WalletApiEventHandler): Promise<void>
clearListeners(eventTypes: EventType[]): Promise<void>
removeLatestAccount(): Promise<void>
restoreBackup(source: string, password: string, ignoreIfCoinTypeMismatch?: boolean): Promise<void>
restoreBackup(
source: string,
password: string,
ignoreIfCoinTypeMismatch: boolean,
ignoreIfBech32Mismatch: string
): Promise<void>
setClientOptions(options: ClientOptions): Promise<void>
setStrongholdPassword(password: string): Promise<void>
setStrongholdPasswordClearInterval(intervalInMilliseconds?: number): Promise<void>
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/lib/core/profile-manager/tests/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ describe('File: api.test.ts', () => {
it('should call restoreBackup', async () => {
spy = jest.spyOn(profileManagerMock, 'restoreBackup')
const importFilePath = './backup.stronghold'
await restoreBackup(importFilePath, password)
expect(spy).toBeCalledWith(importFilePath, password, true)
await restoreBackup(importFilePath, password, 'rms')
expect(spy).toBeCalledWith(importFilePath, password, true, 'rms')
expect(spy).toBeCalledTimes(1)
spy.mockRestore()
})
Expand Down
7 changes: 6 additions & 1 deletion packages/shared/lib/tests/__mocks__/profile-manager.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,12 @@ export class ProfileManagerMock implements IProfileManager {
throw new Error('Method not implemented.')
}

restoreBackup(source: string, password: string, ignoreIfCoinTypeMismatch?: boolean): Promise<void> {
restoreBackup(
source: string,
password: string,
ignoreIfCoinTypeMismatch?: boolean,
ignoreIfBech32Mismatch?: strin
): Promise<void> {
return Promise.resolve()
}

Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@iota/transaction-converter": "^1.0.0-beta.30",
"@iota/unit-converter": "^1.0.0-beta.30",
"@iota/util.js": "^2.0.0-rc.1",
"@iota/wallet": "2.0.3-rc.32",
"@iota/wallet": "2.0.3-rc.34",
"@sveltejs/svelte-virtual-list": "^3.0.1",
"big-integer": "^1.6.51",
"big.js": "^6.0.3",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1114,10 +1114,10 @@
dependencies:
big-integer "^1.6.51"

"@iota/[email protected].32":
version "2.0.3-rc.32"
resolved "https://registry.yarnpkg.com/@iota/wallet/-/wallet-2.0.3-rc.32.tgz#ea1d452595b9c65d147259f108ebe94dc7c5a001"
integrity sha512-nvBDJca64EITtMNYcNIP0nUtaMSHc6c60FBQFldTpibK7fRwqbg9BJGeme0Lt+Mc7WRS7ZnuYnSGIEZFs/pzEA==
"@iota/[email protected].34":
version "2.0.3-rc.34"
resolved "https://registry.yarnpkg.com/@iota/wallet/-/wallet-2.0.3-rc.34.tgz#6bcfc8616f70feac12ebc8659398f19256b0dc95"
integrity sha512-kkLgnpilAUVSXLvZOXuei+u7my7K3oZLsMXUVXyU6IZ7Ddi3D3L7B3Nw5nRWLxjyNKK8/YJjzUu2N3bDgvRmzg==
dependencies:
"@iota/types" "^1.0.0-beta.15"
cargo-cp-artifact "^0.1.6"
Expand Down

0 comments on commit 8653b67

Please sign in to comment.