@subwallet/extension-base 0.5.1 → 0.5.4-0

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.
@@ -4,7 +4,7 @@ import { ALLOWED_PATH, PASSWORD_EXPIRY_MS } from '@subwallet/extension-base/defa
4
4
  import { TypeRegistry } from '@polkadot/types';
5
5
  import keyring from '@polkadot/ui-keyring';
6
6
  import { accounts as accountsObservable } from '@polkadot/ui-keyring/observable/accounts';
7
- import { assert, isHex } from '@polkadot/util';
7
+ import { assert, isHex, u8aToHex } from '@polkadot/util';
8
8
  import { keyExtractSuri, mnemonicGenerate, mnemonicValidate } from '@polkadot/util-crypto';
9
9
  import { withErrorLog } from "./helpers.js";
10
10
  import { createSubscription, unsubscribe } from "./subscriptions.js";
@@ -475,6 +475,53 @@ export default class Extension {
475
475
  isLocked: pair.isLocked,
476
476
  remainingTime
477
477
  };
478
+ }
479
+
480
+ qrIsLocked({
481
+ address
482
+ }) {
483
+ const pair = keyring.getPair(address);
484
+ assert(pair, 'Unable to find pair');
485
+ const remainingTime = this.refreshAccountPasswordCache(pair);
486
+ return {
487
+ isLocked: pair.isLocked,
488
+ remainingTime
489
+ };
490
+ }
491
+
492
+ qrSignSubstrate({
493
+ address,
494
+ message,
495
+ password,
496
+ savePass
497
+ }) {
498
+ const pair = keyring.getPair(address);
499
+ assert(pair, 'Unable to find pair');
500
+
501
+ if (pair.isLocked && !password) {
502
+ throw new Error('Password needed to unlock the account');
503
+ }
504
+
505
+ if (pair.isLocked) {
506
+ try {
507
+ pair.decodePkcs8(password);
508
+ } catch (e) {
509
+ throw new Error('invalid password');
510
+ }
511
+ }
512
+
513
+ const signed = u8aToHex(pair.sign(message));
514
+ const _address = pair.address;
515
+
516
+ if (savePass) {
517
+ this.#cachedUnlocks[_address] = Date.now() + PASSWORD_EXPIRY_MS;
518
+ } else {
519
+ pair.lock();
520
+ }
521
+
522
+ return {
523
+ signature: signed
524
+ };
478
525
  } // FIXME This looks very much like what we have in authorization
479
526
 
480
527
 
@@ -662,6 +709,12 @@ export default class Extension {
662
709
  case 'pri(signing.isLocked)':
663
710
  return this.signingIsLocked(request);
664
711
 
712
+ case 'pri(qr.isLocked)':
713
+ return this.qrIsLocked(request);
714
+
715
+ case 'pri(qr.sign.substrate)':
716
+ return this.qrSignSubstrate(request);
717
+
665
718
  case 'pri(signing.requests)':
666
719
  return this.signingSubscribe(id, port);
667
720
 
@@ -5,7 +5,7 @@ import type { SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types'
5
5
  import type { KeyringPairs$Json } from '@polkadot/ui-keyring/types';
6
6
  import type { HexString } from '@polkadot/util/types';
7
7
  import type { KeypairType } from '@polkadot/util-crypto/types';
8
- import { CurrentNetworkInfo, KoniRequestSignatures } from '@subwallet/extension-base/background/KoniTypes';
8
+ import { CurrentNetworkInfo, KoniRequestSignatures, NetworkJson } from '@subwallet/extension-base/background/KoniTypes';
9
9
  import { TypeRegistry } from '@polkadot/types';
10
10
  import { ALLOWED_PATH } from '../defaults';
11
11
  import { AuthUrls } from './handlers/State';
@@ -25,6 +25,7 @@ export declare type SeedLengths = 12 | 24;
25
25
  export interface AccountJson extends KeyringPair$Meta {
26
26
  address: string;
27
27
  genesisHash?: string | null;
28
+ originGenesisHash?: string | null;
28
29
  isExternal?: boolean;
29
30
  isHardware?: boolean;
30
31
  isHidden?: boolean;
@@ -38,13 +39,20 @@ export interface AccountsWithCurrentAddress {
38
39
  accounts: AccountJson[];
39
40
  currentAddress?: string;
40
41
  }
42
+ export interface CurrentAccountInfo {
43
+ address: string;
44
+ }
41
45
  export declare type AccountWithChildren = AccountJson & {
42
46
  children?: AccountWithChildren[];
43
47
  };
48
+ export interface FindAccountFunction {
49
+ (networkMap: Record<string, NetworkJson>, address: string, genesisHash?: string): AccountJson | undefined;
50
+ }
44
51
  export declare type AccountsContext = {
45
52
  accounts: AccountJson[];
46
53
  hierarchy: AccountWithChildren[];
47
54
  master?: AccountJson;
55
+ getAccountByAddress: FindAccountFunction;
48
56
  };
49
57
  export declare type CurrentAccContext = {
50
58
  currentAccount: AccountJson | null;
@@ -276,18 +284,36 @@ export interface RequestSeedValidate {
276
284
  suri: string;
277
285
  type?: KeypairType;
278
286
  }
287
+ export interface RequestParseTransactionSubstrate {
288
+ genesisHash: string;
289
+ rawPayload: string;
290
+ specVersion: number;
291
+ }
292
+ export interface RequestQRIsLocked {
293
+ address: string;
294
+ }
295
+ export interface RequestQrSignSubstrate {
296
+ address: string;
297
+ message: string;
298
+ savePass: boolean;
299
+ password?: string;
300
+ }
279
301
  export declare type ResponseTypes = {
280
302
  [MessageType in keyof RequestSignatures]: RequestSignatures[MessageType][1];
281
303
  };
282
304
  export declare type ResponseType<TMessageType extends keyof RequestSignatures> = RequestSignatures[TMessageType][1];
283
305
  interface TransportResponseMessageSub<TMessageType extends MessageTypesWithSubscriptions> {
284
306
  error?: string;
307
+ errorCode?: number;
308
+ errorData?: unknown;
285
309
  id: string;
286
310
  response?: ResponseTypes[TMessageType];
287
311
  subscription?: SubscriptionMessageTypes[TMessageType];
288
312
  }
289
313
  interface TransportResponseMessageNoSub<TMessageType extends MessageTypesWithNoSubscriptions> {
290
314
  error?: string;
315
+ errorCode?: number;
316
+ errorData?: unknown;
291
317
  id: string;
292
318
  response?: ResponseTypes[TMessageType];
293
319
  }
@@ -349,4 +375,30 @@ export interface ResponseJsonGetAccountInfo {
349
375
  export interface ResponseAuthorizeList {
350
376
  list: AuthUrls;
351
377
  }
378
+ export interface FormattedMethod {
379
+ args?: ArgInfo[];
380
+ method: string;
381
+ }
382
+ export interface ArgInfo {
383
+ argName: string;
384
+ argValue: string | string[];
385
+ }
386
+ export interface EraInfo {
387
+ period: number;
388
+ phase: number;
389
+ }
390
+ export interface ResponseParseTransactionSubstrate {
391
+ era: EraInfo | string;
392
+ nonce: number;
393
+ method: string;
394
+ tip: number;
395
+ specVersion: number;
396
+ }
397
+ export interface ResponseQRIsLocked {
398
+ isLocked: boolean;
399
+ remainingTime: number;
400
+ }
401
+ export interface ResponseQrSignSubstrate {
402
+ signature: string;
403
+ }
352
404
  export {};
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.TransferStep = exports.TransferErrorCode = exports.RMRK_VER = exports.NETWORK_STATUS = exports.NETWORK_ERROR = exports.CrowdloanParaState = exports.ApiInitStatus = exports.APIItemState = void 0;
6
+ exports.TransferStep = exports.TransferErrorCode = exports.RMRK_VER = exports.NETWORK_STATUS = exports.NETWORK_ERROR = exports.ExternalRequestPromiseStatus = exports.CrowdloanParaState = exports.BasicTxErrorCode = exports.ApiInitStatus = exports.AccountExternalErrorCode = exports.APIItemState = void 0;
7
7
  // Copyright 2019-2022 @polkadot/extension-koni authors & contributors
8
8
  // SPDX-License-Identifier: Apache-2.0
9
9
  let ApiInitStatus;
@@ -77,19 +77,59 @@ exports.TransferErrorCode = TransferErrorCode;
77
77
  TransferErrorCode["NOT_ENOUGH_VALUE"] = "notEnoughValue";
78
78
  TransferErrorCode["INVALID_VALUE"] = "invalidValue";
79
79
  TransferErrorCode["INVALID_TOKEN"] = "invalidToken";
80
+ TransferErrorCode["INVALID_PARAM"] = "invalidParam";
80
81
  TransferErrorCode["KEYRING_ERROR"] = "keyringError";
81
82
  TransferErrorCode["TRANSFER_ERROR"] = "transferError";
82
83
  TransferErrorCode["TIMEOUT"] = "timeout";
83
84
  TransferErrorCode["UNSUPPORTED"] = "unsupported";
84
85
  })(TransferErrorCode || (exports.TransferErrorCode = TransferErrorCode = {}));
85
86
 
87
+ let BasicTxErrorCode;
88
+ exports.BasicTxErrorCode = BasicTxErrorCode;
89
+
90
+ (function (BasicTxErrorCode) {
91
+ BasicTxErrorCode["INVALID_FROM_ADDRESS"] = "invalidFromAccount";
92
+ BasicTxErrorCode["INVALID_TO_ADDRESS"] = "invalidToAccount";
93
+ BasicTxErrorCode["NOT_ENOUGH_VALUE"] = "notEnoughValue";
94
+ BasicTxErrorCode["INVALID_VALUE"] = "invalidValue";
95
+ BasicTxErrorCode["INVALID_TOKEN"] = "invalidToken";
96
+ BasicTxErrorCode["INVALID_PARAM"] = "invalidParam";
97
+ BasicTxErrorCode["KEYRING_ERROR"] = "keyringError";
98
+ BasicTxErrorCode["TRANSFER_ERROR"] = "transferError";
99
+ BasicTxErrorCode["STAKING_ERROR"] = "stakingError";
100
+ BasicTxErrorCode["UN_STAKING_ERROR"] = "unStakingError";
101
+ BasicTxErrorCode["WITHDRAW_STAKING_ERROR"] = "withdrawStakingError";
102
+ BasicTxErrorCode["TIMEOUT"] = "timeout";
103
+ BasicTxErrorCode["UNSUPPORTED"] = "unsupported";
104
+ })(BasicTxErrorCode || (exports.BasicTxErrorCode = BasicTxErrorCode = {}));
105
+
86
106
  let TransferStep;
87
107
  exports.TransferStep = TransferStep;
88
108
 
89
109
  (function (TransferStep) {
90
110
  TransferStep["READY"] = "ready";
111
+ TransferStep["SIGNING"] = "signing";
91
112
  TransferStep["START"] = "start";
92
113
  TransferStep["PROCESSING"] = "processing";
93
114
  TransferStep["SUCCESS"] = "success";
94
115
  TransferStep["ERROR"] = "error";
95
- })(TransferStep || (exports.TransferStep = TransferStep = {}));
116
+ })(TransferStep || (exports.TransferStep = TransferStep = {}));
117
+
118
+ let ExternalRequestPromiseStatus;
119
+ exports.ExternalRequestPromiseStatus = ExternalRequestPromiseStatus;
120
+
121
+ (function (ExternalRequestPromiseStatus) {
122
+ ExternalRequestPromiseStatus[ExternalRequestPromiseStatus["PENDING"] = 0] = "PENDING";
123
+ ExternalRequestPromiseStatus[ExternalRequestPromiseStatus["REJECTED"] = 1] = "REJECTED";
124
+ ExternalRequestPromiseStatus[ExternalRequestPromiseStatus["FAILED"] = 2] = "FAILED";
125
+ ExternalRequestPromiseStatus[ExternalRequestPromiseStatus["COMPLETED"] = 3] = "COMPLETED";
126
+ })(ExternalRequestPromiseStatus || (exports.ExternalRequestPromiseStatus = ExternalRequestPromiseStatus = {}));
127
+
128
+ let AccountExternalErrorCode;
129
+ exports.AccountExternalErrorCode = AccountExternalErrorCode;
130
+
131
+ (function (AccountExternalErrorCode) {
132
+ AccountExternalErrorCode["INVALID_ADDRESS"] = "invalidToAccount";
133
+ AccountExternalErrorCode["KEYRING_ERROR"] = "keyringError";
134
+ AccountExternalErrorCode["UNKNOWN_ERROR"] = "unknownError";
135
+ })(AccountExternalErrorCode || (exports.AccountExternalErrorCode = AccountExternalErrorCode = {}));
@@ -557,6 +557,59 @@ class Extension {
557
557
  isLocked: pair.isLocked,
558
558
  remainingTime
559
559
  };
560
+ }
561
+
562
+ qrIsLocked(_ref24) {
563
+ let {
564
+ address
565
+ } = _ref24;
566
+
567
+ const pair = _uiKeyring.default.getPair(address);
568
+
569
+ (0, _util.assert)(pair, 'Unable to find pair');
570
+ const remainingTime = this.refreshAccountPasswordCache(pair);
571
+ return {
572
+ isLocked: pair.isLocked,
573
+ remainingTime
574
+ };
575
+ }
576
+
577
+ qrSignSubstrate(_ref25) {
578
+ let {
579
+ address,
580
+ message,
581
+ password,
582
+ savePass
583
+ } = _ref25;
584
+
585
+ const pair = _uiKeyring.default.getPair(address);
586
+
587
+ (0, _util.assert)(pair, 'Unable to find pair');
588
+
589
+ if (pair.isLocked && !password) {
590
+ throw new Error('Password needed to unlock the account');
591
+ }
592
+
593
+ if (pair.isLocked) {
594
+ try {
595
+ pair.decodePkcs8(password);
596
+ } catch (e) {
597
+ throw new Error('invalid password');
598
+ }
599
+ }
600
+
601
+ const signed = (0, _util.u8aToHex)(pair.sign(message));
602
+ const _address = pair.address;
603
+
604
+ if (savePass) {
605
+ this.#cachedUnlocks[_address] = Date.now() + _defaults.PASSWORD_EXPIRY_MS;
606
+ } else {
607
+ pair.lock();
608
+ }
609
+
610
+ return {
611
+ signature: signed
612
+ };
560
613
  } // FIXME This looks very much like what we have in authorization
561
614
 
562
615
 
@@ -600,12 +653,12 @@ class Extension {
600
653
  }
601
654
  }
602
655
 
603
- derivationValidate(_ref24) {
656
+ derivationValidate(_ref26) {
604
657
  let {
605
658
  parentAddress,
606
659
  parentPassword,
607
660
  suri
608
- } = _ref24;
661
+ } = _ref26;
609
662
  const childPair = this.derive(parentAddress, suri, parentPassword, {});
610
663
  return {
611
664
  address: childPair.address,
@@ -613,7 +666,7 @@ class Extension {
613
666
  };
614
667
  }
615
668
 
616
- derivationCreate(_ref25) {
669
+ derivationCreate(_ref27) {
617
670
  let {
618
671
  genesisHash,
619
672
  name,
@@ -621,7 +674,7 @@ class Extension {
621
674
  parentPassword,
622
675
  password,
623
676
  suri
624
- } = _ref25;
677
+ } = _ref27;
625
678
  const childPair = this.derive(parentAddress, suri, parentPassword, {
626
679
  genesisHash,
627
680
  name,
@@ -748,6 +801,12 @@ class Extension {
748
801
  case 'pri(signing.isLocked)':
749
802
  return this.signingIsLocked(request);
750
803
 
804
+ case 'pri(qr.isLocked)':
805
+ return this.qrIsLocked(request);
806
+
807
+ case 'pri(qr.sign.substrate)':
808
+ return this.qrSignSubstrate(request);
809
+
751
810
  case 'pri(signing.requests)':
752
811
  return this.signingSubscribe(id, port);
753
812
 
package/cjs/defaults.js CHANGED
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.PORT_EXTENSION = exports.PORT_CONTENT = exports.PHISHING_PAGE_REDIRECT = exports.PASSWORD_EXPIRY_MS = exports.PASSWORD_EXPIRY_MIN = exports.MESSAGE_ORIGIN_PAGE = exports.MESSAGE_ORIGIN_CONTENT = exports.EXTENSION_PREFIX = exports.ALLOWED_PATH = void 0;
7
7
  // Copyright 2019-2022 @polkadot/extension-base authors & contributors
8
8
  // SPDX-License-Identifier: Apache-2.0
9
- const ALLOWED_PATH = ['/', '/account/import-ledger', '/account/restore-json', '/account/create'];
9
+ const ALLOWED_PATH = ['/', '/account/import-ledger', '/account/restore-json', '/account/create', '/account/settings'];
10
10
  exports.ALLOWED_PATH = ALLOWED_PATH;
11
11
  const PHISHING_PAGE_REDIRECT = '/phishing-page-detected';
12
12
  exports.PHISHING_PAGE_REDIRECT = PHISHING_PAGE_REDIRECT;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SubWalletProviderError = void 0;
7
+
8
+ // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
9
+ // SPDX-License-Identifier: Apache-2.0
10
+ class SubWalletProviderError extends Error {
11
+ constructor(message, code, data) {
12
+ super(message);
13
+ this.code = code;
14
+ this.data = data;
15
+ }
16
+
17
+ }
18
+
19
+ exports.SubWalletProviderError = SubWalletProviderError;
@@ -11,6 +11,6 @@ const packageInfo = {
11
11
  name: '@subwallet/extension-base',
12
12
  path: typeof __dirname === 'string' ? __dirname : 'auto',
13
13
  type: 'cjs',
14
- version: '0.5.1'
14
+ version: '0.5.4-0'
15
15
  };
16
16
  exports.packageInfo = packageInfo;
package/cjs/page/index.js CHANGED
@@ -9,6 +9,8 @@ exports.enable = enable;
9
9
  exports.handleResponse = handleResponse;
10
10
  exports.sendMessage = sendMessage;
11
11
 
12
+ var _SubWalletProviderError = require("@subwallet/extension-base/errors/SubWalletProviderError");
13
+
12
14
  var _defaults = require("../defaults");
13
15
 
14
16
  var _getId = require("../utils/getId");
@@ -62,7 +64,7 @@ function handleResponse(data) {
62
64
  // eslint-disable-next-line @typescript-eslint/ban-types
63
65
  handler.subscriber(data.subscription);
64
66
  } else if (data.error) {
65
- handler.reject(new Error(data.error));
67
+ handler.reject(new _SubWalletProviderError.SubWalletProviderError(data.error, data.errorCode, data.errorData));
66
68
  } else {
67
69
  handler.resolve(data.response);
68
70
  }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
9
+
10
+ var _util = require("@polkadot/util");
11
+
12
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
13
+ // SPDX-License-Identifier: Apache-2.0
14
+ class LedgerSigner {
15
+ #registry;
16
+ #callback;
17
+ #setState;
18
+ #id;
19
+
20
+ constructor(registry, callback, id, setState) {
21
+ this.#registry = registry;
22
+ this.#callback = callback;
23
+ this.#id = id;
24
+ this.#setState = setState;
25
+ }
26
+
27
+ async signPayload(payload) {
28
+ return new Promise((resolve, reject) => {
29
+ const raw = this.#registry.createType('ExtrinsicPayload', payload, {
30
+ version: payload.version
31
+ });
32
+ const ledgerPayload = raw.toU8a(true);
33
+ this.#setState({
34
+ reject: reject,
35
+ resolve: resolve,
36
+ status: _KoniTypes.ExternalRequestPromiseStatus.PENDING,
37
+ createdAt: new Date().getTime()
38
+ });
39
+ this.#callback({
40
+ ledgerState: {
41
+ ledgerPayload: (0, _util.u8aToHex)(ledgerPayload),
42
+ ledgerId: this.#id
43
+ }
44
+ });
45
+ });
46
+ }
47
+
48
+ }
49
+
50
+ exports.default = LedgerSigner;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
9
+
10
+ var _util = require("@polkadot/util");
11
+
12
+ var _utilCrypto = require("@polkadot/util-crypto");
13
+
14
+ // Copyright 2017-2022 @polkadot/react-signer authors & contributors
15
+ // SPDX-License-Identifier: Apache-2.0
16
+ class QrSigner {
17
+ #callback;
18
+ #id;
19
+ #registry;
20
+ #resolver;
21
+ #setState;
22
+
23
+ constructor(_ref) {
24
+ let {
25
+ callback,
26
+ id,
27
+ registry,
28
+ resolver,
29
+ setState
30
+ } = _ref;
31
+ this.#callback = callback;
32
+ this.#id = id;
33
+ this.#registry = registry;
34
+ this.#resolver = resolver;
35
+ this.#setState = setState;
36
+ }
37
+
38
+ async signPayload(payload) {
39
+ return new Promise((resolve, reject) => {
40
+ // limit size of the transaction
41
+ const isQrHashed = payload.method.length > 5000;
42
+ const wrapper = this.#registry.createType('ExtrinsicPayload', payload, {
43
+ version: payload.version
44
+ });
45
+ const qrPayload = isQrHashed ? (0, _utilCrypto.blake2AsU8a)(wrapper.toU8a(true)) : wrapper.toU8a();
46
+
47
+ const resolver = result => {
48
+ this.#resolver();
49
+ resolve(result);
50
+ };
51
+
52
+ this.#setState({
53
+ reject: reject,
54
+ resolve: resolver,
55
+ status: _KoniTypes.ExternalRequestPromiseStatus.PENDING,
56
+ createdAt: new Date().getTime()
57
+ });
58
+ this.#callback({
59
+ qrState: {
60
+ isQrHashed,
61
+ qrAddress: payload.address,
62
+ qrPayload: (0, _util.u8aToHex)(qrPayload),
63
+ qrId: this.#id,
64
+ isEthereum: false
65
+ }
66
+ });
67
+ });
68
+ }
69
+
70
+ }
71
+
72
+ exports.default = QrSigner;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
11
+
12
+ var _rlp = _interopRequireDefault(require("rlp"));
13
+
14
+ var _util = require("@polkadot/util");
15
+
16
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
17
+ // SPDX-License-Identifier: Apache-2.0
18
+ class QrSigner {
19
+ #callback;
20
+ #id;
21
+ #resolver;
22
+ #setState;
23
+
24
+ constructor(_ref) {
25
+ let {
26
+ callback,
27
+ id,
28
+ resolver,
29
+ setState
30
+ } = _ref;
31
+ this.#callback = callback;
32
+ this.#id = id;
33
+ this.#resolver = resolver;
34
+ this.#setState = setState;
35
+ }
36
+
37
+ async signTransaction(tx) {
38
+ return new Promise((resolve, reject) => {
39
+ const data = [tx.nonce, tx.gasPrice, tx.gasLimit, tx.to, tx.value, tx.data, tx.chainId, new Uint8Array([0x00]), new Uint8Array([0x00])];
40
+
41
+ const qrPayload = _rlp.default.encode(data);
42
+
43
+ const resolver = result => {
44
+ this.#resolver();
45
+ resolve(result);
46
+ };
47
+
48
+ this.#setState({
49
+ reject: reject,
50
+ resolve: resolver,
51
+ status: _KoniTypes.ExternalRequestPromiseStatus.PENDING,
52
+ createdAt: new Date().getTime()
53
+ });
54
+ this.#callback({
55
+ qrState: {
56
+ isQrHashed: false,
57
+ qrAddress: tx.from,
58
+ qrPayload: (0, _util.u8aToHex)(qrPayload),
59
+ qrId: this.#id,
60
+ isEthereum: true
61
+ }
62
+ });
63
+ });
64
+ }
65
+
66
+ }
67
+
68
+ exports.default = QrSigner;
package/defaults.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare const ALLOWED_PATH: readonly ["/", "/account/import-ledger", "/account/restore-json", "/account/create"];
1
+ declare const ALLOWED_PATH: readonly ["/", "/account/import-ledger", "/account/restore-json", "/account/create", "/account/settings"];
2
2
  declare const PHISHING_PAGE_REDIRECT = "/phishing-page-detected";
3
3
  declare const EXTENSION_PREFIX: string;
4
4
  declare const PORT_CONTENT: string;
package/defaults.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Copyright 2019-2022 @polkadot/extension-base authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- const ALLOWED_PATH = ['/', '/account/import-ledger', '/account/restore-json', '/account/create'];
3
+ const ALLOWED_PATH = ['/', '/account/import-ledger', '/account/restore-json', '/account/create', '/account/settings'];
4
4
  const PHISHING_PAGE_REDIRECT = '/phishing-page-detected';
5
5
  const EXTENSION_PREFIX = process.env.EXTENSION_PREFIX || '';
6
6
  const PORT_CONTENT = `${EXTENSION_PREFIX}koni-content`;
@@ -0,0 +1,6 @@
1
+ import { SubWalletProviderErrorInterface } from '@subwallet/extension-base/background/KoniTypes';
2
+ export declare class SubWalletProviderError extends Error implements SubWalletProviderErrorInterface {
3
+ code: number | undefined;
4
+ data: unknown | undefined;
5
+ constructor(message: string, code?: number, data?: unknown);
6
+ }
@@ -0,0 +1,10 @@
1
+ // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export class SubWalletProviderError extends Error {
4
+ constructor(message, code, data) {
5
+ super(message);
6
+ this.code = code;
7
+ this.data = data;
8
+ }
9
+
10
+ }