@polkadot/extension-base 0.40.5-4 → 0.41.2-2

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.
@@ -30,10 +30,15 @@ var _subscriptions = require("./subscriptions.cjs");
30
30
  // Copyright 2019-2021 @polkadot/extension authors & contributors
31
31
  // SPDX-License-Identifier: Apache-2.0
32
32
  const SEED_DEFAULT_LENGTH = 12;
33
- const SEED_LENGTHS = [12, 15, 18, 21, 24]; // a global registry to use internally
33
+ const SEED_LENGTHS = [12, 15, 18, 21, 24];
34
+ const ETH_DERIVE_DEFAULT = "/m/44'/60'/0'/0/0"; // a global registry to use internally
34
35
 
35
36
  const registry = new _types.TypeRegistry();
36
37
 
38
+ function getSuri(seed, type) {
39
+ return type === 'ethereum' ? `${seed}${ETH_DERIVE_DEFAULT}` : seed;
40
+ }
41
+
37
42
  function transformAccounts(accounts) {
38
43
  return Object.values(accounts).map(_ref => {
39
44
  let {
@@ -117,7 +122,7 @@ class Extension {
117
122
  type
118
123
  } = _ref4;
119
124
 
120
- _uiKeyring.default.addUri(suri, password, {
125
+ _uiKeyring.default.addUri(getSuri(suri, type), password, {
121
126
  genesisHash,
122
127
  name
123
128
  }, type);
@@ -435,7 +440,7 @@ class Extension {
435
440
  } = _ref19;
436
441
  const seed = (0, _utilCrypto.mnemonicGenerate)(length);
437
442
  return {
438
- address: _uiKeyring.default.createFromUri(seed, {}, type).address,
443
+ address: _uiKeyring.default.createFromUri(getSuri(seed, type), {}, type).address,
439
444
  seed
440
445
  };
441
446
  }
@@ -458,7 +463,7 @@ class Extension {
458
463
  }
459
464
 
460
465
  return {
461
- address: _uiKeyring.default.createFromUri(suri, {}, type).address,
466
+ address: _uiKeyring.default.createFromUri(getSuri(suri, type), {}, type).address,
462
467
  suri
463
468
  };
464
469
  }
@@ -11,10 +11,15 @@ import { assert, isHex } from '@polkadot/util';
11
11
  import { keyExtractSuri, mnemonicGenerate, mnemonicValidate } from '@polkadot/util-crypto';
12
12
  import { createSubscription, unsubscribe } from "./subscriptions.js";
13
13
  const SEED_DEFAULT_LENGTH = 12;
14
- const SEED_LENGTHS = [12, 15, 18, 21, 24]; // a global registry to use internally
14
+ const SEED_LENGTHS = [12, 15, 18, 21, 24];
15
+ const ETH_DERIVE_DEFAULT = "/m/44'/60'/0'/0/0"; // a global registry to use internally
15
16
 
16
17
  const registry = new TypeRegistry();
17
18
 
19
+ function getSuri(seed, type) {
20
+ return type === 'ethereum' ? `${seed}${ETH_DERIVE_DEFAULT}` : seed;
21
+ }
22
+
18
23
  function transformAccounts(accounts) {
19
24
  return Object.values(accounts).map(({
20
25
  json: {
@@ -87,7 +92,7 @@ export default class Extension {
87
92
  suri,
88
93
  type
89
94
  }) {
90
- keyring.addUri(suri, password, {
95
+ keyring.addUri(getSuri(suri, type), password, {
91
96
  genesisHash,
92
97
  name
93
98
  }, type);
@@ -361,7 +366,7 @@ export default class Extension {
361
366
  }) {
362
367
  const seed = mnemonicGenerate(length);
363
368
  return {
364
- address: keyring.createFromUri(seed, {}, type).address,
369
+ address: keyring.createFromUri(getSuri(seed, type), {}, type).address,
365
370
  seed
366
371
  };
367
372
  }
@@ -383,7 +388,7 @@ export default class Extension {
383
388
  }
384
389
 
385
390
  return {
386
- address: keyring.createFromUri(suri, {}, type).address,
391
+ address: keyring.createFromUri(getSuri(suri, type), {}, type).address,
387
392
  suri
388
393
  };
389
394
  }
package/package.json CHANGED
@@ -14,16 +14,16 @@
14
14
  },
15
15
  "sideEffects": false,
16
16
  "type": "module",
17
- "version": "0.40.5-4",
17
+ "version": "0.41.2-2",
18
18
  "main": "index.js",
19
19
  "dependencies": {
20
- "@babel/runtime": "^7.15.4",
21
- "@polkadot/api": "^6.7.1",
22
- "@polkadot/extension-dapp": "^0.40.5-4",
23
- "@polkadot/extension-inject": "^0.40.5-4",
24
- "@polkadot/keyring": "^7.8.2",
25
- "@polkadot/phishing": "^0.6.407",
26
- "@polkadot/ui-keyring": "^0.86.5"
20
+ "@babel/runtime": "^7.16.3",
21
+ "@polkadot/api": "^6.8.2-12",
22
+ "@polkadot/extension-dapp": "^0.41.2-2",
23
+ "@polkadot/extension-inject": "^0.41.2-2",
24
+ "@polkadot/keyring": "^7.8.3-27",
25
+ "@polkadot/phishing": "^0.6.442",
26
+ "@polkadot/ui-keyring": "^0.86.6-0"
27
27
  },
28
28
  "exports": {
29
29
  ".": {
package/packageInfo.cjs CHANGED
@@ -9,6 +9,6 @@ exports.packageInfo = void 0;
9
9
  // Auto-generated by @polkadot/dev, do not edit
10
10
  const packageInfo = {
11
11
  name: '@polkadot/extension-base',
12
- version: '0.40.5-4'
12
+ version: '0.41.2-2'
13
13
  };
14
14
  exports.packageInfo = packageInfo;
package/packageInfo.js CHANGED
@@ -3,5 +3,5 @@
3
3
  // Auto-generated by @polkadot/dev, do not edit
4
4
  export const packageInfo = {
5
5
  name: '@polkadot/extension-base',
6
- version: '0.40.5-4'
6
+ version: '0.41.2-2'
7
7
  };
@@ -126,7 +126,7 @@ class PostMessageProvider {
126
126
  } // eslint-disable-next-line @typescript-eslint/no-explicit-any
127
127
 
128
128
 
129
- async send(method, params, subscription) {
129
+ async send(method, params, _, subscription) {
130
130
  if (subscription) {
131
131
  const {
132
132
  callback,
@@ -176,7 +176,7 @@ class PostMessageProvider {
176
176
  }
177
177
 
178
178
  subscribe(type, method, params, callback) {
179
- return this.send(method, params, {
179
+ return this.send(method, params, false, {
180
180
  callback,
181
181
  type
182
182
  });
@@ -48,7 +48,7 @@ export default class PostMessageProvider implements InjectedProvider {
48
48
  * @return unsubscribe function
49
49
  */
50
50
  on(type: ProviderInterfaceEmitted, sub: ProviderInterfaceEmitCb): () => void;
51
- send(method: string, params: unknown[], subscription?: SubscriptionHandler): Promise<any>;
51
+ send(method: string, params: unknown[], _?: boolean, subscription?: SubscriptionHandler): Promise<any>;
52
52
  /**
53
53
  * @summary Spawn a provider on the extension background.
54
54
  */
@@ -113,7 +113,7 @@ export default class PostMessageProvider {
113
113
  } // eslint-disable-next-line @typescript-eslint/no-explicit-any
114
114
 
115
115
 
116
- async send(method, params, subscription) {
116
+ async send(method, params, _, subscription) {
117
117
  if (subscription) {
118
118
  const {
119
119
  callback,
@@ -163,7 +163,7 @@ export default class PostMessageProvider {
163
163
  }
164
164
 
165
165
  subscribe(type, method, params, callback) {
166
- return this.send(method, params, {
166
+ return this.send(method, params, false, {
167
167
  callback,
168
168
  type
169
169
  });