@subwallet/extension-base 1.1.52-0 → 1.1.53-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.
@@ -13,6 +13,6 @@ const packageInfo = {
13
13
  name: '@subwallet/extension-base',
14
14
  path: typeof __dirname === 'string' ? __dirname : 'auto',
15
15
  type: 'cjs',
16
- version: '1.1.52-0'
16
+ version: '1.1.53-0'
17
17
  };
18
18
  exports.packageInfo = packageInfo;
@@ -98,7 +98,8 @@ const subscribeWithSystemAccountPallet = async _ref => {
98
98
  if ((0, _utils2._isSubstrateRelayChain)(chainInfo) && substrateApi.query.nominationPools) {
99
99
  var _substrateApi$rx$quer;
100
100
  poolSubscribe = (_substrateApi$rx$quer = substrateApi.rx.query.nominationPools.poolMembers) === null || _substrateApi$rx$quer === void 0 ? void 0 : _substrateApi$rx$quer.multi(addresses);
101
- } else {
101
+ }
102
+ if (!poolSubscribe) {
102
103
  poolSubscribe = new _rxjs.Observable(subscriber => {
103
104
  subscriber.next(addresses.map(() => ({
104
105
  toPrimitive() {
@@ -59,7 +59,6 @@ class ConnectWCRequestHandler {
59
59
  ...request
60
60
  };
61
61
  this.updateIconConnectWC();
62
- this.#requestService.popupOpen();
63
62
  }
64
63
  resetWallet() {
65
64
  for (const request of Object.values(this.#connectWCRequests)) {
@@ -18,7 +18,7 @@ exports.getWCId = getWCId;
18
18
  const convertConnectRequest = request => {
19
19
  return {
20
20
  id: getWCId(request.id),
21
- isInternal: false,
21
+ isInternal: true,
22
22
  request: request,
23
23
  url: request.params.proposer.metadata.url
24
24
  };
@@ -21,6 +21,8 @@ var _types = require("./types");
21
21
  // SPDX-License-Identifier: Apache-2.0
22
22
 
23
23
  const storage = _storage.SWStorage.instance;
24
+ const methodDOTRequire = [_types.POLKADOT_SIGNING_METHODS.POLKADOT_SIGN_MESSAGE, _types.POLKADOT_SIGNING_METHODS.POLKADOT_SIGN_TRANSACTION];
25
+ const methodEVMRequire = [_types.EIP155_SIGNING_METHODS.PERSONAL_SIGN, _types.EIP155_SIGNING_METHODS.ETH_SIGN, _types.EIP155_SIGNING_METHODS.ETH_SEND_TRANSACTION];
24
26
  var _requestService = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("requestService");
25
27
  var _polkadotRequestHandler = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("polkadotRequestHandler");
26
28
  var _eip155RequestHandler = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("eip155RequestHandler");
@@ -125,6 +127,13 @@ class WalletConnectService {
125
127
  async approveSession(result) {
126
128
  var _classPrivateFieldLoo4;
127
129
  (0, _classPrivateFieldLooseBase2.default)(this, _checkClient)[_checkClient]();
130
+ Object.entries(result.namespaces).forEach(_ref => {
131
+ let [namespace, {
132
+ methods
133
+ }] = _ref;
134
+ methods = [...methods, ...this.findMethodsMissing(_constants.WALLET_CONNECT_EIP155_NAMESPACE === namespace ? methodEVMRequire : methodDOTRequire, methods)];
135
+ result.namespaces[namespace].methods = methods;
136
+ });
128
137
  await ((_classPrivateFieldLoo4 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo4 === void 0 ? void 0 : _classPrivateFieldLoo4.approve(result));
129
138
  (0, _classPrivateFieldLooseBase2.default)(this, _updateSessions)[_updateSessions]();
130
139
  }
@@ -193,6 +202,16 @@ class WalletConnectService {
193
202
  }));
194
203
  (0, _classPrivateFieldLooseBase2.default)(this, _updateSessions)[_updateSessions]();
195
204
  }
205
+ findMethodsMissing(methodRequire, methods) {
206
+ const methodMap = methods.reduce((obj, m) => ({
207
+ ...obj,
208
+ [m]: m
209
+ }), {});
210
+ return methodEVMRequire.reduce((methods, m) => {
211
+ !methodMap[m] && methods.push(m);
212
+ return methods;
213
+ }, []);
214
+ }
196
215
  }
197
216
  exports.default = WalletConnectService;
198
217
  function _get_haveData() {
@@ -93,8 +93,8 @@ const parseResult = (type, input, name) => {
93
93
  };
94
94
  } else {
95
95
  return {
96
- type: types,
97
96
  name: genName(name),
97
+ type: types,
98
98
  value: genInput(input)
99
99
  };
100
100
  }
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.1.52-0",
20
+ "version": "1.1.53-0",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -1817,10 +1817,10 @@
1817
1817
  "@sora-substrate/type-definitions": "^1.17.7",
1818
1818
  "@substrate/connect": "^0.7.26",
1819
1819
  "@subwallet/chain-list": "0.2.54",
1820
- "@subwallet/extension-base": "^1.1.52-0",
1821
- "@subwallet/extension-chains": "^1.1.52-0",
1822
- "@subwallet/extension-dapp": "^1.1.52-0",
1823
- "@subwallet/extension-inject": "^1.1.52-0",
1820
+ "@subwallet/extension-base": "^1.1.53-0",
1821
+ "@subwallet/extension-chains": "^1.1.53-0",
1822
+ "@subwallet/extension-dapp": "^1.1.53-0",
1823
+ "@subwallet/extension-inject": "^1.1.53-0",
1824
1824
  "@subwallet/keyring": "^0.1.3",
1825
1825
  "@subwallet/ui-keyring": "^0.1.3",
1826
1826
  "@walletconnect/sign-client": "^2.8.4",
package/packageInfo.js CHANGED
@@ -7,5 +7,5 @@ export const packageInfo = {
7
7
  name: '@subwallet/extension-base',
8
8
  path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
9
9
  type: 'esm',
10
- version: '1.1.52-0'
10
+ version: '1.1.53-0'
11
11
  };
@@ -90,7 +90,8 @@ const subscribeWithSystemAccountPallet = async ({
90
90
  if (_isSubstrateRelayChain(chainInfo) && substrateApi.query.nominationPools) {
91
91
  var _substrateApi$rx$quer;
92
92
  poolSubscribe = (_substrateApi$rx$quer = substrateApi.rx.query.nominationPools.poolMembers) === null || _substrateApi$rx$quer === void 0 ? void 0 : _substrateApi$rx$quer.multi(addresses);
93
- } else {
93
+ }
94
+ if (!poolSubscribe) {
94
95
  poolSubscribe = new Observable(subscriber => {
95
96
  subscriber.next(addresses.map(() => ({
96
97
  toPrimitive() {
@@ -51,7 +51,6 @@ export default class ConnectWCRequestHandler {
51
51
  ...request
52
52
  };
53
53
  this.updateIconConnectWC();
54
- this.#requestService.popupOpen();
55
54
  }
56
55
  resetWallet() {
57
56
  for (const request of Object.values(this.#connectWCRequests)) {
@@ -11,7 +11,7 @@ export const getWCId = id => {
11
11
  export const convertConnectRequest = request => {
12
12
  return {
13
13
  id: getWCId(request.id),
14
- isInternal: false,
14
+ isInternal: true,
15
15
  request: request,
16
16
  url: request.params.proposer.metadata.url
17
17
  };
@@ -16,4 +16,5 @@ export default class WalletConnectService {
16
16
  responseRequest(response: EngineTypes.RespondParams): Promise<void>;
17
17
  resetWallet(resetAll: boolean): Promise<void>;
18
18
  disconnect(topic: string): Promise<void>;
19
+ private findMethodsMissing;
19
20
  }
@@ -10,10 +10,12 @@ import SignClient from '@walletconnect/sign-client';
10
10
  import { getInternalError, getSdkError } from '@walletconnect/utils';
11
11
  import { BehaviorSubject } from 'rxjs';
12
12
  import PolkadotRequestHandler from "./handler/PolkadotRequestHandler.js";
13
- import { ALL_WALLET_CONNECT_EVENT, DEFAULT_WALLET_CONNECT_OPTIONS, WALLET_CONNECT_SUPPORTED_METHODS } from "./constants.js";
13
+ import { ALL_WALLET_CONNECT_EVENT, DEFAULT_WALLET_CONNECT_OPTIONS, WALLET_CONNECT_EIP155_NAMESPACE, WALLET_CONNECT_SUPPORTED_METHODS } from "./constants.js";
14
14
  import { convertConnectRequest, convertNotSupportRequest, isSupportWalletConnectChain } from "./helpers.js";
15
15
  import { EIP155_SIGNING_METHODS, POLKADOT_SIGNING_METHODS } from "./types.js";
16
16
  const storage = SWStorage.instance;
17
+ const methodDOTRequire = [POLKADOT_SIGNING_METHODS.POLKADOT_SIGN_MESSAGE, POLKADOT_SIGNING_METHODS.POLKADOT_SIGN_TRANSACTION];
18
+ const methodEVMRequire = [EIP155_SIGNING_METHODS.PERSONAL_SIGN, EIP155_SIGNING_METHODS.ETH_SIGN, EIP155_SIGNING_METHODS.ETH_SEND_TRANSACTION];
17
19
  var _requestService = /*#__PURE__*/_classPrivateFieldLooseKey("requestService");
18
20
  var _polkadotRequestHandler = /*#__PURE__*/_classPrivateFieldLooseKey("polkadotRequestHandler");
19
21
  var _eip155RequestHandler = /*#__PURE__*/_classPrivateFieldLooseKey("eip155RequestHandler");
@@ -117,6 +119,12 @@ export default class WalletConnectService {
117
119
  async approveSession(result) {
118
120
  var _classPrivateFieldLoo4;
119
121
  _classPrivateFieldLooseBase(this, _checkClient)[_checkClient]();
122
+ Object.entries(result.namespaces).forEach(([namespace, {
123
+ methods
124
+ }]) => {
125
+ methods = [...methods, ...this.findMethodsMissing(WALLET_CONNECT_EIP155_NAMESPACE === namespace ? methodEVMRequire : methodDOTRequire, methods)];
126
+ result.namespaces[namespace].methods = methods;
127
+ });
120
128
  await ((_classPrivateFieldLoo4 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo4 === void 0 ? void 0 : _classPrivateFieldLoo4.approve(result));
121
129
  _classPrivateFieldLooseBase(this, _updateSessions)[_updateSessions]();
122
130
  }
@@ -185,6 +193,16 @@ export default class WalletConnectService {
185
193
  }));
186
194
  _classPrivateFieldLooseBase(this, _updateSessions)[_updateSessions]();
187
195
  }
196
+ findMethodsMissing(methodRequire, methods) {
197
+ const methodMap = methods.reduce((obj, m) => ({
198
+ ...obj,
199
+ [m]: m
200
+ }), {});
201
+ return methodEVMRequire.reduce((methods, m) => {
202
+ !methodMap[m] && methods.push(m);
203
+ return methods;
204
+ }, []);
205
+ }
188
206
  }
189
207
  function _get_haveData() {
190
208
  const sessionStorage = storage.getItem('wc@2:client:0.3//session');
@@ -87,8 +87,8 @@ const parseResult = (type, input, name) => {
87
87
  };
88
88
  } else {
89
89
  return {
90
- type: types,
91
90
  name: genName(name),
91
+ type: types,
92
92
  value: genInput(input)
93
93
  };
94
94
  }