ghost-keychain/packages/extension-base/src/stores/Accounts.ts
Tarik Gul b6d42c28b5
Transition from manifest v2 to v3 for chrome (#1367)
* Update manifest.json

* replace `extension.getUrl` to `runtime.getUrl`

* Update localStorage to async chrome.storage.local

* Change action to browserAction

* fix bug

* revert async changes

* revert test change

* Fix localStorage breaking change

* .extension -> .runtime

* fix undefined behaviour

* fixed tests

* lint

* Up some callbacks to async

* Change where extractMetadata is called

* fix  in mock

* Update background field to take in type

* Change background.js to service_worker.js

* Update id and request origin for service worker

* updated chrome mock

* 13 tests passing

* Fix async issue

* switch naming back to original

* linting

* Fix linting in base

* remove timeOut

* added permission to alarms in manifest

* fixed alarms uncaught errors

* Cleanup addr for tests

---------

Co-authored-by: bee344 <alberto.penayo@parity.io>
2024-07-07 22:32:42 -04:00

29 lines
865 B
TypeScript

// Copyright 2019-2024 @polkadot/extension-base authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { KeyringJson, KeyringStore } from '@polkadot/ui-keyring/types';
import { EXTENSION_PREFIX } from '../defaults.js';
import BaseStore from './Base.js';
export default class AccountsStore extends BaseStore<KeyringJson> implements KeyringStore {
constructor () {
super(
EXTENSION_PREFIX && EXTENSION_PREFIX !== 'polkadot{.js}'
? `${EXTENSION_PREFIX}accounts`
: null
);
}
public override async set (key: string, value: KeyringJson, update?: () => void): Promise<void> {
// shortcut, don't save testing accounts in extension storage
if (key.startsWith('account:') && value.meta && value.meta.isTesting) {
update && update();
return;
}
await super.set(key, value, update);
}
}