@pezkuwi/ui-keyring 3.16.7 → 3.16.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/package.json +321 -7
  2. package/build/Base.js +0 -109
  3. package/build/Keyring.js +0 -304
  4. package/build/README.md +0 -136
  5. package/build/bundle.js +0 -4
  6. package/build/cjs/Base.d.ts +0 -30
  7. package/build/cjs/Base.js +0 -113
  8. package/build/cjs/Keyring.d.ts +0 -49
  9. package/build/cjs/Keyring.js +0 -308
  10. package/build/cjs/bundle.d.ts +0 -4
  11. package/build/cjs/bundle.js +0 -8
  12. package/build/cjs/defaults.js +0 -28
  13. package/build/cjs/index.js +0 -7
  14. package/build/cjs/observable/accounts.js +0 -6
  15. package/build/cjs/observable/addresses.js +0 -6
  16. package/build/cjs/observable/contracts.js +0 -6
  17. package/build/cjs/observable/env.js +0 -12
  18. package/build/cjs/observable/genericSubject.js +0 -47
  19. package/build/cjs/observable/index.js +0 -16
  20. package/build/cjs/observable/types.js +0 -2
  21. package/build/cjs/options/index.js +0 -116
  22. package/build/cjs/options/item.js +0 -16
  23. package/build/cjs/options/types.js +0 -2
  24. package/build/cjs/packageInfo.js +0 -4
  25. package/build/cjs/stores/Browser.js +0 -24
  26. package/build/cjs/stores/File.js +0 -72
  27. package/build/cjs/stores/index.js +0 -7
  28. package/build/cjs/types.js +0 -2
  29. package/build/defaults.d.ts +0 -6
  30. package/build/defaults.js +0 -22
  31. package/build/index.d.ts +0 -4
  32. package/build/index.js +0 -4
  33. package/build/observable/accounts.d.ts +0 -1
  34. package/build/observable/accounts.js +0 -3
  35. package/build/observable/addresses.d.ts +0 -1
  36. package/build/observable/addresses.js +0 -3
  37. package/build/observable/contracts.d.ts +0 -1
  38. package/build/observable/contracts.js +0 -3
  39. package/build/observable/env.d.ts +0 -6
  40. package/build/observable/env.js +0 -9
  41. package/build/observable/genericSubject.d.ts +0 -2
  42. package/build/observable/genericSubject.js +0 -44
  43. package/build/observable/index.d.ts +0 -8
  44. package/build/observable/index.js +0 -13
  45. package/build/observable/types.d.ts +0 -15
  46. package/build/observable/types.js +0 -1
  47. package/build/options/index.d.ts +0 -15
  48. package/build/options/index.js +0 -112
  49. package/build/options/item.d.ts +0 -2
  50. package/build/options/item.js +0 -13
  51. package/build/options/types.d.ts +0 -15
  52. package/build/options/types.js +0 -1
  53. package/build/package.json +0 -355
  54. package/build/packageDetect.d.ts +0 -1
  55. package/build/packageDetect.js +0 -4
  56. package/build/packageInfo.d.ts +0 -6
  57. package/build/packageInfo.js +0 -1
  58. package/build/stores/Browser.d.ts +0 -7
  59. package/build/stores/Browser.js +0 -19
  60. package/build/stores/File.d.ts +0 -12
  61. package/build/stores/File.js +0 -67
  62. package/build/stores/index.d.ts +0 -2
  63. package/build/stores/index.js +0 -2
  64. package/build/types.d.ts +0 -78
  65. package/build/types.js +0 -1
  66. package/build-tsc-cjs/packageDetect.js +0 -6
  67. package/src/Base.ts +0 -156
  68. package/src/Keyring.ts +0 -420
  69. package/src/bundle.ts +0 -10
  70. package/src/defaults.ts +0 -34
  71. package/src/index.ts +0 -10
  72. package/src/json.d.ts +0 -11
  73. package/src/observable/accounts.ts +0 -7
  74. package/src/observable/addresses.ts +0 -7
  75. package/src/observable/contracts.ts +0 -7
  76. package/src/observable/env.ts +0 -15
  77. package/src/observable/genericSubject.ts +0 -66
  78. package/src/observable/index.ts +0 -28
  79. package/src/observable/types.ts +0 -21
  80. package/src/options/index.ts +0 -150
  81. package/src/options/item.ts +0 -22
  82. package/src/options/types.ts +0 -23
  83. package/src/packageDetect.ts +0 -12
  84. package/src/packageInfo.ts +0 -6
  85. package/src/stores/Browser.ts +0 -28
  86. package/src/stores/File.ts +0 -94
  87. package/src/stores/index.ts +0 -5
  88. package/src/types.ts +0 -91
  89. package/tsconfig.build.json +0 -14
  90. package/tsconfig.build.tsbuildinfo +0 -1
  91. package/tsconfig.spec.json +0 -16
  92. /package/{build-tsc/Base.d.ts → Base.d.ts} +0 -0
  93. /package/{build-tsc-esm/Base.js → Base.js} +0 -0
  94. /package/{build-tsc/Keyring.d.ts → Keyring.d.ts} +0 -0
  95. /package/{build-tsc-esm/Keyring.js → Keyring.js} +0 -0
  96. /package/{build/LICENSE → LICENSE} +0 -0
  97. /package/{build/bundle-pezkuwi-ui-keyring.js → bundle-pezkuwi-ui-keyring.js} +0 -0
  98. /package/{build-tsc/bundle.d.ts → bundle.d.ts} +0 -0
  99. /package/{build-tsc-esm/bundle.js → bundle.js} +0 -0
  100. /package/{build → cjs}/Base.d.ts +0 -0
  101. /package/{build-tsc-cjs → cjs}/Base.js +0 -0
  102. /package/{build → cjs}/Keyring.d.ts +0 -0
  103. /package/{build-tsc-cjs → cjs}/Keyring.js +0 -0
  104. /package/{build → cjs}/bundle.d.ts +0 -0
  105. /package/{build-tsc-cjs → cjs}/bundle.js +0 -0
  106. /package/{build-tsc → cjs}/defaults.d.ts +0 -0
  107. /package/{build-tsc-cjs → cjs}/defaults.js +0 -0
  108. /package/{build-tsc → cjs}/index.d.ts +0 -0
  109. /package/{build-tsc-cjs → cjs}/index.js +0 -0
  110. /package/{build-tsc → cjs}/observable/accounts.d.ts +0 -0
  111. /package/{build-tsc-cjs → cjs}/observable/accounts.js +0 -0
  112. /package/{build-tsc → cjs}/observable/addresses.d.ts +0 -0
  113. /package/{build-tsc-cjs → cjs}/observable/addresses.js +0 -0
  114. /package/{build-tsc → cjs}/observable/contracts.d.ts +0 -0
  115. /package/{build-tsc-cjs → cjs}/observable/contracts.js +0 -0
  116. /package/{build-tsc → cjs}/observable/env.d.ts +0 -0
  117. /package/{build-tsc-cjs → cjs}/observable/env.js +0 -0
  118. /package/{build-tsc → cjs}/observable/genericSubject.d.ts +0 -0
  119. /package/{build-tsc-cjs → cjs}/observable/genericSubject.js +0 -0
  120. /package/{build-tsc → cjs}/observable/index.d.ts +0 -0
  121. /package/{build-tsc-cjs → cjs}/observable/index.js +0 -0
  122. /package/{build-tsc → cjs}/observable/types.d.ts +0 -0
  123. /package/{build-tsc-cjs → cjs}/observable/types.js +0 -0
  124. /package/{build-tsc → cjs}/options/index.d.ts +0 -0
  125. /package/{build-tsc-cjs → cjs}/options/index.js +0 -0
  126. /package/{build-tsc → cjs}/options/item.d.ts +0 -0
  127. /package/{build-tsc-cjs → cjs}/options/item.js +0 -0
  128. /package/{build-tsc → cjs}/options/types.d.ts +0 -0
  129. /package/{build-tsc-cjs → cjs}/options/types.js +0 -0
  130. /package/{build/cjs → cjs}/package.json +0 -0
  131. /package/{build-tsc → cjs}/packageDetect.d.ts +0 -0
  132. /package/{build/cjs → cjs}/packageDetect.js +0 -0
  133. /package/{build-tsc → cjs}/packageInfo.d.ts +0 -0
  134. /package/{build-tsc-cjs → cjs}/packageInfo.js +0 -0
  135. /package/{build-tsc → cjs}/stores/Browser.d.ts +0 -0
  136. /package/{build-tsc-cjs → cjs}/stores/Browser.js +0 -0
  137. /package/{build-tsc → cjs}/stores/File.d.ts +0 -0
  138. /package/{build-tsc-cjs → cjs}/stores/File.js +0 -0
  139. /package/{build-tsc → cjs}/stores/index.d.ts +0 -0
  140. /package/{build-tsc-cjs → cjs}/stores/index.js +0 -0
  141. /package/{build-tsc → cjs}/types.d.ts +0 -0
  142. /package/{build-tsc-cjs → cjs}/types.js +0 -0
  143. /package/{build/cjs/defaults.d.ts → defaults.d.ts} +0 -0
  144. /package/{build-tsc-esm/defaults.js → defaults.js} +0 -0
  145. /package/{build/cjs/index.d.ts → index.d.ts} +0 -0
  146. /package/{build-tsc-esm/index.js → index.js} +0 -0
  147. /package/{build/cjs/observable → observable}/accounts.d.ts +0 -0
  148. /package/{build-tsc-esm/observable → observable}/accounts.js +0 -0
  149. /package/{build/cjs/observable → observable}/addresses.d.ts +0 -0
  150. /package/{build-tsc-esm/observable → observable}/addresses.js +0 -0
  151. /package/{build/cjs/observable → observable}/contracts.d.ts +0 -0
  152. /package/{build-tsc-esm/observable → observable}/contracts.js +0 -0
  153. /package/{build/cjs/observable → observable}/env.d.ts +0 -0
  154. /package/{build-tsc-esm/observable → observable}/env.js +0 -0
  155. /package/{build/cjs/observable → observable}/genericSubject.d.ts +0 -0
  156. /package/{build-tsc-esm/observable → observable}/genericSubject.js +0 -0
  157. /package/{build/cjs/observable → observable}/index.d.ts +0 -0
  158. /package/{build-tsc-esm/observable → observable}/index.js +0 -0
  159. /package/{build/cjs/observable → observable}/types.d.ts +0 -0
  160. /package/{build-tsc-esm/observable → observable}/types.js +0 -0
  161. /package/{build/cjs/options → options}/index.d.ts +0 -0
  162. /package/{build-tsc-esm/options → options}/index.js +0 -0
  163. /package/{build/cjs/options → options}/item.d.ts +0 -0
  164. /package/{build-tsc-esm/options → options}/item.js +0 -0
  165. /package/{build/cjs/options → options}/types.d.ts +0 -0
  166. /package/{build-tsc-esm/options → options}/types.js +0 -0
  167. /package/{build/cjs/packageDetect.d.ts → packageDetect.d.ts} +0 -0
  168. /package/{build-tsc-esm/packageDetect.js → packageDetect.js} +0 -0
  169. /package/{build/cjs/packageInfo.d.ts → packageInfo.d.ts} +0 -0
  170. /package/{build-tsc-esm/packageInfo.js → packageInfo.js} +0 -0
  171. /package/{build/cjs/stores → stores}/Browser.d.ts +0 -0
  172. /package/{build-tsc-esm/stores → stores}/Browser.js +0 -0
  173. /package/{build/cjs/stores → stores}/File.d.ts +0 -0
  174. /package/{build-tsc-esm/stores → stores}/File.js +0 -0
  175. /package/{build/cjs/stores → stores}/index.d.ts +0 -0
  176. /package/{build-tsc-esm/stores → stores}/index.js +0 -0
  177. /package/{build/cjs/types.d.ts → types.d.ts} +0 -0
  178. /package/{build-tsc-esm/types.js → types.js} +0 -0
@@ -1,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileStore = void 0;
4
- const tslib_1 = require("tslib");
5
- const mkdirp_1 = require("mkdirp");
6
- const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
7
- const node_path_1 = tslib_1.__importDefault(require("node:path"));
8
- class FileStore {
9
- #path;
10
- constructor(path) {
11
- if (!node_fs_1.default.existsSync(path)) {
12
- (0, mkdirp_1.mkdirpSync)(path);
13
- }
14
- this.#path = path;
15
- }
16
- validateKey(key) {
17
- // Make sure the key has a .json extension
18
- if (!key.endsWith('.json')) {
19
- console.error('Non-JSON file requested: ', key);
20
- return false;
21
- }
22
- // Remove '.json'
23
- const keyWithoutExtension = key.slice(0, -5);
24
- // Only allow alphanumeric characters, hyphens, and underscores in the base filename
25
- const safeKeyRegex = /^[a-zA-Z0-9_-]+$/;
26
- if (!safeKeyRegex.test(keyWithoutExtension)) {
27
- console.error('Invalid key format detected: ', key);
28
- return false;
29
- }
30
- return true;
31
- }
32
- all(fn) {
33
- node_fs_1.default
34
- .readdirSync(this.#path)
35
- .filter((key) => !['.', '..', '.DS_Store'].includes(key))
36
- .forEach((key) => {
37
- const value = this._readKey(key);
38
- value?.address && fn(key, value);
39
- });
40
- }
41
- get(key, fn) {
42
- const value = this._readKey(key);
43
- if (!value?.address) {
44
- throw new Error(`Invalid JSON found for ${key}`);
45
- }
46
- fn(value);
47
- }
48
- remove(key, fn) {
49
- node_fs_1.default.unlinkSync(this._getPath(key));
50
- fn && fn();
51
- }
52
- set(key, value, fn) {
53
- node_fs_1.default.writeFileSync(this._getPath(key), Buffer.from(JSON.stringify(value), 'utf-8'));
54
- fn && fn();
55
- }
56
- _getPath(key) {
57
- if (!this.validateKey(key)) {
58
- throw new Error('Invalid key format');
59
- }
60
- return node_path_1.default.join(this.#path, key);
61
- }
62
- _readKey(key) {
63
- try {
64
- return JSON.parse(node_fs_1.default.readFileSync(this._getPath(key)).toString('utf-8'));
65
- }
66
- catch (error) {
67
- console.error(error);
68
- }
69
- return undefined;
70
- }
71
- }
72
- exports.FileStore = FileStore;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileStore = exports.BrowserStore = void 0;
4
- var Browser_js_1 = require("./Browser.js");
5
- Object.defineProperty(exports, "BrowserStore", { enumerable: true, get: function () { return Browser_js_1.BrowserStore; } });
6
- var File_js_1 = require("./File.js");
7
- Object.defineProperty(exports, "FileStore", { enumerable: true, get: function () { return File_js_1.FileStore; } });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +0,0 @@
1
- export declare function accountKey(address: string): string;
2
- export declare function addressKey(address: string): string;
3
- export declare function contractKey(address: string): string;
4
- export declare const accountRegex: RegExp;
5
- export declare const addressRegex: RegExp;
6
- export declare const contractRegex: RegExp;
package/build/defaults.js DELETED
@@ -1,22 +0,0 @@
1
- import { decodeAddress } from '@pezkuwi/keyring';
2
- import { u8aToHex } from '@pezkuwi/util';
3
- const ACCOUNT_PREFIX = 'account:';
4
- const ADDRESS_PREFIX = 'address:';
5
- const CONTRACT_PREFIX = 'contract:';
6
- function toHex(address) {
7
- return u8aToHex(
8
- // When saving pre-checksum changes, ensure that we can decode
9
- decodeAddress(address, true));
10
- }
11
- export function accountKey(address) {
12
- return `${ACCOUNT_PREFIX}${toHex(address)}`;
13
- }
14
- export function addressKey(address) {
15
- return `${ADDRESS_PREFIX}${toHex(address)}`;
16
- }
17
- export function contractKey(address) {
18
- return `${CONTRACT_PREFIX}${toHex(address)}`;
19
- }
20
- export const accountRegex = new RegExp(`^${ACCOUNT_PREFIX}0x[0-9a-f]*`, '');
21
- export const addressRegex = new RegExp(`^${ADDRESS_PREFIX}0x[0-9a-f]*`, '');
22
- export const contractRegex = new RegExp(`^${CONTRACT_PREFIX}0x[0-9a-f]*`, '');
package/build/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import './packageDetect.js';
2
- import { keyring } from './bundle.js';
3
- export * from './bundle.js';
4
- export default keyring;
package/build/index.js DELETED
@@ -1,4 +0,0 @@
1
- import './packageDetect.js';
2
- import { keyring } from './bundle.js';
3
- export * from './bundle.js';
4
- export default keyring;
@@ -1 +0,0 @@
1
- export declare const accounts: import("./types.js").AddressSubject;
@@ -1,3 +0,0 @@
1
- import { accountKey } from '../defaults.js';
2
- import { genericSubject } from './genericSubject.js';
3
- export const accounts = /*#__PURE__*/ genericSubject(accountKey, true);
@@ -1 +0,0 @@
1
- export declare const addresses: import("./types.js").AddressSubject;
@@ -1,3 +0,0 @@
1
- import { addressKey } from '../defaults.js';
2
- import { genericSubject } from './genericSubject.js';
3
- export const addresses = /*#__PURE__*/ genericSubject(addressKey);
@@ -1 +0,0 @@
1
- export declare const contracts: import("./types.js").AddressSubject;
@@ -1,3 +0,0 @@
1
- import { contractKey } from '../defaults.js';
2
- import { genericSubject } from './genericSubject.js';
3
- export const contracts = /*#__PURE__*/ genericSubject(contractKey);
@@ -1,6 +0,0 @@
1
- import { BehaviorSubject } from 'rxjs';
2
- export declare const env: {
3
- isDevelopment: () => boolean;
4
- set: (isDevelopment: boolean) => void;
5
- subject: BehaviorSubject<boolean>;
6
- };
@@ -1,9 +0,0 @@
1
- import { BehaviorSubject } from 'rxjs';
2
- const subject = new BehaviorSubject(false);
3
- export const env = {
4
- isDevelopment: () => subject.getValue(),
5
- set: (isDevelopment) => {
6
- subject.next(isDevelopment);
7
- },
8
- subject
9
- };
@@ -1,2 +0,0 @@
1
- import type { AddressSubject } from './types.js';
2
- export declare function genericSubject(keyCreator: (address: string) => string, withTest?: boolean): AddressSubject;
@@ -1,44 +0,0 @@
1
- import { BehaviorSubject } from 'rxjs';
2
- import { objectCopy, objectSpread } from '@pezkuwi/util';
3
- import { createOptionItem } from '../options/item.js';
4
- import { env } from './env.js';
5
- function callNext(current, subject, withTest) {
6
- const isDevMode = env.isDevelopment();
7
- const filtered = {};
8
- Object.keys(current).forEach((key) => {
9
- const { json: { meta: { isTesting = false } = {} } = {} } = current[key];
10
- if (!withTest || isDevMode || isTesting !== true) {
11
- filtered[key] = current[key];
12
- }
13
- });
14
- subject.next(filtered);
15
- }
16
- export function genericSubject(keyCreator, withTest = false) {
17
- let current = {};
18
- const subject = new BehaviorSubject({});
19
- const next = () => callNext(current, subject, withTest);
20
- env.subject.subscribe(next);
21
- return {
22
- add: (store, address, json, type) => {
23
- current = objectCopy(current);
24
- current[address] = {
25
- json: objectSpread({}, json, { address }),
26
- option: createOptionItem(address, json.meta.name),
27
- type
28
- };
29
- // we do not store dev or injected accounts (external/transient)
30
- if (!json.meta.isInjected && (!json.meta.isTesting || env.isDevelopment())) {
31
- store.set(keyCreator(address), json);
32
- }
33
- next();
34
- return current[address];
35
- },
36
- remove: (store, address) => {
37
- current = objectCopy(current);
38
- delete current[address];
39
- store.remove(keyCreator(address));
40
- next();
41
- },
42
- subject
43
- };
44
- }
@@ -1,8 +0,0 @@
1
- import type { SubjectInfo } from './types.js';
2
- interface Result {
3
- accounts: SubjectInfo;
4
- addresses: SubjectInfo;
5
- contracts: SubjectInfo;
6
- }
7
- export declare const obervableAll: import("rxjs").Observable<Result>;
8
- export {};
@@ -1,13 +0,0 @@
1
- import { combineLatest, map } from 'rxjs';
2
- import { accounts } from './accounts.js';
3
- import { addresses } from './addresses.js';
4
- import { contracts } from './contracts.js';
5
- export const obervableAll = /*#__PURE__*/ combineLatest([
6
- accounts.subject,
7
- addresses.subject,
8
- contracts.subject
9
- ]).pipe(map(([accounts, addresses, contracts]) => ({
10
- accounts,
11
- addresses,
12
- contracts
13
- })));
@@ -1,15 +0,0 @@
1
- import type { BehaviorSubject } from 'rxjs';
2
- import type { KeypairType } from '@pezkuwi/util-crypto/types';
3
- import type { KeyringSectionOption } from '../options/types.js';
4
- import type { KeyringJson, KeyringStore } from '../types.js';
5
- export interface SingleAddress {
6
- json: KeyringJson;
7
- option: KeyringSectionOption;
8
- type?: KeypairType | undefined;
9
- }
10
- export type SubjectInfo = Record<string, SingleAddress>;
11
- export interface AddressSubject {
12
- add: (store: KeyringStore, address: string, json: KeyringJson, type?: KeypairType) => SingleAddress;
13
- remove: (store: KeyringStore, address: string) => void;
14
- subject: BehaviorSubject<SubjectInfo>;
15
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- import type { KeyringStruct } from '../types.js';
2
- import type { KeyringOptionInstance, KeyringOptions, KeyringSectionOption } from './types.js';
3
- import { BehaviorSubject } from 'rxjs';
4
- export declare class KeyringOption implements KeyringOptionInstance {
5
- #private;
6
- readonly optionsSubject: BehaviorSubject<KeyringOptions>;
7
- createOptionHeader(name: string): KeyringSectionOption;
8
- init(keyring: KeyringStruct): void;
9
- clear(): void;
10
- private linkItems;
11
- private addAccounts;
12
- private addAddresses;
13
- private addContracts;
14
- private emptyOptions;
15
- }
@@ -1,112 +0,0 @@
1
- import { BehaviorSubject } from 'rxjs';
2
- import { obervableAll } from '../observable/index.js';
3
- let hasCalledInitOptions = false;
4
- const sortByName = (a, b) => {
5
- const valueA = a.option.name;
6
- const valueB = b.option.name;
7
- return valueA.localeCompare(valueB);
8
- };
9
- const sortByCreated = (a, b) => {
10
- const valueA = a.json.meta.whenCreated || 0;
11
- const valueB = b.json.meta.whenCreated || 0;
12
- if (valueA < valueB) {
13
- return 1;
14
- }
15
- if (valueA > valueB) {
16
- return -1;
17
- }
18
- return 0;
19
- };
20
- export class KeyringOption {
21
- #allSub = null;
22
- optionsSubject = new BehaviorSubject(this.emptyOptions());
23
- createOptionHeader(name) {
24
- return {
25
- key: `header-${name.toLowerCase()}`,
26
- name,
27
- value: null
28
- };
29
- }
30
- init(keyring) {
31
- if (hasCalledInitOptions) {
32
- throw new Error('Unable to initialise options more than once');
33
- }
34
- this.#allSub = obervableAll.subscribe(() => {
35
- const opts = this.emptyOptions();
36
- this.addAccounts(keyring, opts);
37
- this.addAddresses(keyring, opts);
38
- this.addContracts(keyring, opts);
39
- opts.address = this.linkItems({ Addresses: opts.address, Recent: opts.recent });
40
- opts.account = this.linkItems({ Accounts: opts.account, Development: opts.testing });
41
- opts.contract = this.linkItems({ Contracts: opts.contract });
42
- opts.all = [].concat(opts.account, opts.address);
43
- opts.allPlus = [].concat(opts.account, opts.address, opts.contract);
44
- this.optionsSubject.next(opts);
45
- });
46
- hasCalledInitOptions = true;
47
- }
48
- clear() {
49
- if (this.#allSub) {
50
- this.#allSub.unsubscribe();
51
- }
52
- }
53
- linkItems(items) {
54
- return Object.keys(items).reduce((result, header) => {
55
- const options = items[header];
56
- return result.concat(options.length
57
- ? [this.createOptionHeader(header)]
58
- : [], options);
59
- }, []);
60
- }
61
- addAccounts(keyring, options) {
62
- const available = keyring.accounts.subject.getValue();
63
- Object
64
- .values(available)
65
- .sort(sortByName)
66
- .forEach(({ json: { meta: { isTesting = false } }, option }) => {
67
- if (!isTesting) {
68
- options.account.push(option);
69
- }
70
- else {
71
- options.testing.push(option);
72
- }
73
- });
74
- }
75
- addAddresses(keyring, options) {
76
- const available = keyring.addresses.subject.getValue();
77
- Object
78
- .values(available)
79
- .filter(({ json }) => !!json.meta.isRecent)
80
- .sort(sortByCreated)
81
- .forEach(({ option }) => {
82
- options.recent.push(option);
83
- });
84
- Object
85
- .values(available)
86
- .filter(({ json }) => !json.meta.isRecent)
87
- .sort(sortByName)
88
- .forEach(({ option }) => {
89
- options.address.push(option);
90
- });
91
- }
92
- addContracts(keyring, options) {
93
- const available = keyring.contracts.subject.getValue();
94
- Object
95
- .values(available)
96
- .sort(sortByName)
97
- .forEach(({ option }) => {
98
- options.contract.push(option);
99
- });
100
- }
101
- emptyOptions() {
102
- return {
103
- account: [],
104
- address: [],
105
- all: [],
106
- allPlus: [],
107
- contract: [],
108
- recent: [],
109
- testing: []
110
- };
111
- }
112
- }
@@ -1,2 +0,0 @@
1
- import type { KeyringSectionOption } from './types.js';
2
- export declare function createOptionItem(address: string, _name?: string): KeyringSectionOption;
@@ -1,13 +0,0 @@
1
- import { isUndefined } from '@pezkuwi/util';
2
- export function createOptionItem(address, _name) {
3
- const name = isUndefined(_name)
4
- ? ((address.length > 15)
5
- ? `${address.slice(0, 6)}…${address.slice(-6)}`
6
- : address)
7
- : _name;
8
- return {
9
- key: address,
10
- name,
11
- value: address
12
- };
13
- }
@@ -1,15 +0,0 @@
1
- import type { KeyringItemType, KeyringStruct } from '../types.js';
2
- export interface KeyringSectionOption {
3
- key: string | null;
4
- name: string;
5
- value: string | null;
6
- }
7
- export type KeyringSectionOptions = KeyringSectionOption[];
8
- export type KeyringOptions = {
9
- [type in KeyringItemType | 'all' | 'allPlus' | 'recent' | 'testing']: KeyringSectionOptions;
10
- };
11
- export type KeyringOption$Type = keyof KeyringOptions;
12
- export interface KeyringOptionInstance {
13
- createOptionHeader: (name: string) => KeyringSectionOption;
14
- init: (keyring: KeyringStruct) => void;
15
- }
@@ -1 +0,0 @@
1
- export {};