@polkadot/extension-base 0.59.1 → 0.60.1

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.
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "./cjs/packageDetect.js"
19
19
  ],
20
20
  "type": "module",
21
- "version": "0.59.1",
21
+ "version": "0.60.1",
22
22
  "main": "./cjs/index.js",
23
23
  "module": "./index.js",
24
24
  "types": "./index.d.ts",
@@ -479,19 +479,19 @@
479
479
  }
480
480
  },
481
481
  "dependencies": {
482
- "@polkadot/api": "^16.0.1",
483
- "@polkadot/extension-chains": "0.59.1",
484
- "@polkadot/extension-dapp": "0.59.1",
485
- "@polkadot/extension-inject": "0.59.1",
486
- "@polkadot/keyring": "^13.5.1",
487
- "@polkadot/networks": "^13.5.1",
488
- "@polkadot/phishing": "^0.25.11",
489
- "@polkadot/rpc-provider": "^16.0.1",
490
- "@polkadot/types": "^16.0.1",
491
- "@polkadot/ui-keyring": "^3.14.1",
492
- "@polkadot/ui-settings": "^3.14.1",
493
- "@polkadot/util": "^13.5.1",
494
- "@polkadot/util-crypto": "^13.5.1",
482
+ "@polkadot/api": "^16.2.2",
483
+ "@polkadot/extension-chains": "0.60.1",
484
+ "@polkadot/extension-dapp": "0.60.1",
485
+ "@polkadot/extension-inject": "0.60.1",
486
+ "@polkadot/keyring": "^13.5.2",
487
+ "@polkadot/networks": "^13.5.2",
488
+ "@polkadot/phishing": "^0.25.13",
489
+ "@polkadot/rpc-provider": "^16.2.2",
490
+ "@polkadot/types": "^16.2.2",
491
+ "@polkadot/ui-keyring": "^3.15.1",
492
+ "@polkadot/ui-settings": "^3.15.1",
493
+ "@polkadot/util": "^13.5.2",
494
+ "@polkadot/util-crypto": "^13.5.2",
495
495
  "eventemitter3": "^5.0.1",
496
496
  "rxjs": "^7.8.1",
497
497
  "tslib": "^2.8.1"
package/packageInfo.js CHANGED
@@ -1 +1 @@
1
- export const packageInfo = { name: '@polkadot/extension-base', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '0.59.1' };
1
+ export const packageInfo = { name: '@polkadot/extension-base', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '0.60.1' };
@@ -8,19 +8,19 @@ let sendRequest;
8
8
  * @description Extension provider to be used by dapps
9
9
  */
10
10
  export default class PostMessageProvider {
11
- __internal__eventemitter;
11
+ #eventemitter;
12
12
  // Whether or not the actual extension background provider is connected
13
- __internal__isConnected = false;
13
+ #isConnected = false;
14
14
  // Subscription IDs are (historically) not guaranteed to be globally unique;
15
15
  // only unique for a given subscription method; which is why we identify
16
16
  // the subscriptions based on subscription id + type
17
- __internal__subscriptions = {}; // {[(type,subscriptionId)]: callback}
17
+ #subscriptions = {}; // {[(type,subscriptionId)]: callback}
18
18
  /**
19
19
  * @param {function} sendRequest The function to be called to send requests to the node
20
20
  * @param {function} subscriptionNotificationHandler Channel for receiving subscription messages
21
21
  */
22
22
  constructor(_sendRequest) {
23
- this.__internal__eventemitter = new EventEmitter();
23
+ this.#eventemitter = new EventEmitter();
24
24
  sendRequest = _sendRequest;
25
25
  }
26
26
  get isClonable() {
@@ -60,7 +60,7 @@ export default class PostMessageProvider {
60
60
  * @return {boolean} true if connected
61
61
  */
62
62
  get isConnected() {
63
- return this.__internal__isConnected;
63
+ return this.#isConnected;
64
64
  }
65
65
  listProviders() {
66
66
  return sendRequest('pub(rpc.listProviders)', undefined);
@@ -72,9 +72,9 @@ export default class PostMessageProvider {
72
72
  * @return unsubscribe function
73
73
  */
74
74
  on(type, sub) {
75
- this.__internal__eventemitter.on(type, sub);
75
+ this.#eventemitter.on(type, sub);
76
76
  return () => {
77
- this.__internal__eventemitter.removeListener(type, sub);
77
+ this.#eventemitter.removeListener(type, sub);
78
78
  };
79
79
  }
80
80
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -84,7 +84,7 @@ export default class PostMessageProvider {
84
84
  const id = await sendRequest('pub(rpc.subscribe)', { method, params, type }, (res) => {
85
85
  subscription.callback(null, res);
86
86
  });
87
- this.__internal__subscriptions[`${type}::${id}`] = callback;
87
+ this.#subscriptions[`${type}::${id}`] = callback;
88
88
  return id;
89
89
  }
90
90
  return sendRequest('pub(rpc.send)', { method, params });
@@ -94,17 +94,17 @@ export default class PostMessageProvider {
94
94
  */
95
95
  async startProvider(key) {
96
96
  // Disconnect from the previous provider
97
- this.__internal__isConnected = false;
98
- this.__internal__eventemitter.emit('disconnected');
97
+ this.#isConnected = false;
98
+ this.#eventemitter.emit('disconnected');
99
99
  const meta = await sendRequest('pub(rpc.startProvider)', key);
100
100
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
101
101
  sendRequest('pub(rpc.subscribeConnected)', null, (connected) => {
102
- this.__internal__isConnected = connected;
102
+ this.#isConnected = connected;
103
103
  if (connected) {
104
- this.__internal__eventemitter.emit('connected');
104
+ this.#eventemitter.emit('connected');
105
105
  }
106
106
  else {
107
- this.__internal__eventemitter.emit('disconnected');
107
+ this.#eventemitter.emit('disconnected');
108
108
  }
109
109
  return true;
110
110
  });
@@ -122,11 +122,11 @@ export default class PostMessageProvider {
122
122
  // the assigned id now does not match what the API user originally received. It has
123
123
  // a slight complication in solving - since we cannot rely on the send id, but rather
124
124
  // need to find the actual subscription id to map it
125
- if (isUndefined(this.__internal__subscriptions[subscription])) {
125
+ if (isUndefined(this.#subscriptions[subscription])) {
126
126
  l.debug(() => `Unable to find active subscription=${subscription}`);
127
127
  return false;
128
128
  }
129
- delete this.__internal__subscriptions[subscription];
129
+ delete this.#subscriptions[subscription];
130
130
  return this.send(method, [id]);
131
131
  }
132
132
  }
package/stores/Base.js CHANGED
@@ -5,9 +5,9 @@ const lastError = (type) => {
5
5
  }
6
6
  };
7
7
  export default class BaseStore {
8
- __internal__prefix;
8
+ #prefix;
9
9
  constructor(prefix) {
10
- this.__internal__prefix = prefix ? `${prefix}:` : '';
10
+ this.#prefix = prefix ? `${prefix}:` : '';
11
11
  }
12
12
  async all(update) {
13
13
  await this.allMap(async (map) => {
@@ -25,8 +25,8 @@ export default class BaseStore {
25
25
  const map = {};
26
26
  for (let i = 0, count = entries.length; i < count; i++) {
27
27
  const [key, value] = entries[i];
28
- if (key.startsWith(this.__internal__prefix)) {
29
- map[key.replace(this.__internal__prefix, '')] = value;
28
+ if (key.startsWith(this.#prefix)) {
29
+ map[key.replace(this.#prefix, '')] = value;
30
30
  }
31
31
  }
32
32
  await update(map);
@@ -35,7 +35,7 @@ export default class BaseStore {
35
35
  });
36
36
  }
37
37
  async get(key, update) {
38
- const prefixedKey = `${this.__internal__prefix}${key}`;
38
+ const prefixedKey = `${this.#prefix}${key}`;
39
39
  await chrome.storage.local.get([prefixedKey]).then(async (result) => {
40
40
  lastError('get');
41
41
  // eslint-disable-next-line @typescript-eslint/await-thenable
@@ -45,7 +45,7 @@ export default class BaseStore {
45
45
  });
46
46
  }
47
47
  async remove(key, update) {
48
- const prefixedKey = `${this.__internal__prefix}${key}`;
48
+ const prefixedKey = `${this.#prefix}${key}`;
49
49
  await chrome.storage.local.remove(prefixedKey).then(async () => {
50
50
  lastError('remove');
51
51
  // eslint-disable-next-line @typescript-eslint/await-thenable
@@ -55,7 +55,7 @@ export default class BaseStore {
55
55
  });
56
56
  }
57
57
  async set(key, value, update) {
58
- const prefixedKey = `${this.__internal__prefix}${key}`;
58
+ const prefixedKey = `${this.#prefix}${key}`;
59
59
  await chrome.storage.local.set({ [prefixedKey]: value }).then(async () => {
60
60
  lastError('set');
61
61
  // eslint-disable-next-line @typescript-eslint/await-thenable