Skip to content

Commit

Permalink
refactor: rename keys to storage key in storage ref helper
Browse files Browse the repository at this point in the history
  • Loading branch information
peronczyk committed Oct 4, 2023
1 parent 02665a8 commit e255040
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/composables/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ export function useAccounts() {
}
}

function setMnemonic(val: string) {
mnemonic.value = val;
function setMnemonic(newMnemonic: string) {
mnemonic.value = newMnemonic;
}

function setGeneratedMnemonic() {
Expand Down
8 changes: 4 additions & 4 deletions src/composables/composablesHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface ICreateStorageRefOptions<T> {
*/
export function useStorageRef<T = string | object | any[]>(
initialState: T,
keys: StorageKey,
storageKey: StorageKey,
options: ICreateStorageRefOptions<T> = {},
) {
const {
Expand All @@ -56,7 +56,7 @@ export function useStorageRef<T = string | object | any[]>(
watch(state, (val, oldVal) => {
// Arrays are not compared as there is a bug which makes the new and old val always the same.
if (!watcherDisabled && (Array.isArray(initialState) || !isEqual(val, oldVal))) {
WalletStorage.set(keys, (serializer?.write) ? serializer.write(val) : val);
WalletStorage.set(storageKey, (serializer?.write) ? serializer.write(val) : val);
}
}, { deep: true });

Expand All @@ -66,12 +66,12 @@ export function useStorageRef<T = string | object | any[]>(
* and synchronizes own state with the change.
*/
if (backgroundSync) {
WalletStorage.watch?.(keys, (val) => setState(val));
WalletStorage.watch?.(storageKey, (val) => setState(val));
}

if (!isRestored) {
(async () => {
const restoredValue = await WalletStorage.get<T | null>(keys);
const restoredValue = await WalletStorage.get<T | null>(storageKey);
setState(restoredValue);
isRestored = true;
})();
Expand Down
5 changes: 3 additions & 2 deletions src/composables/transactionTx.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { computed, ref } from 'vue';
import { Encoded, Tag } from '@aeternity/aepp-sdk';
import type {
IAccountOverview,
IDefaultComposableOptions,
ITokenList,
ITx,
Expand Down Expand Up @@ -172,7 +173,7 @@ export function useTransactionTx({
ownerAddress.value = address;
}

function getOwnershipAccount(externalOwnerAddress?: Encoded.AccountAddress): any {
function getOwnershipAccount(externalOwnerAddress?: Encoded.AccountAddress): IAccountOverview {
switch (ownershipStatus.value) {
case AE_TRANSACTION_OWNERSHIP_STATUS.current:
return activeAccount.value;
Expand All @@ -187,7 +188,7 @@ export function useTransactionTx({
return {
name: getPreferredName.value(address) || '',
address,
} as any; // TODO establish the required return type for the function
};
}
}
}
Expand Down

0 comments on commit e255040

Please sign in to comment.