@subwallet/extension-base 0.3.6-0 → 0.3.6-3

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 (164) hide show
  1. package/{build/background → background}/KoniTypes.d.ts +0 -0
  2. package/{build/background → background}/KoniTypes.js +0 -0
  3. package/{build/background → background}/RequestBytesSign.d.ts +0 -0
  4. package/{build/background → background}/RequestBytesSign.js +0 -0
  5. package/{build/background → background}/RequestExtrinsicSign.d.ts +0 -0
  6. package/{build/background → background}/RequestExtrinsicSign.js +0 -0
  7. package/{build/background → background}/handlers/Extension.d.ts +1 -1
  8. package/{build/background → background}/handlers/Extension.js +2 -2
  9. package/{build/background → background}/handlers/State.d.ts +0 -0
  10. package/{build/background → background}/handlers/State.js +0 -0
  11. package/{build/background → background}/handlers/Tabs.d.ts +0 -0
  12. package/{build/background → background}/handlers/Tabs.js +0 -0
  13. package/{build/background → background}/handlers/helpers.d.ts +0 -0
  14. package/{build/background → background}/handlers/helpers.js +0 -0
  15. package/{build/background → background}/handlers/index.d.ts +0 -0
  16. package/{build/background → background}/handlers/index.js +0 -0
  17. package/{build/background → background}/handlers/subscriptions.d.ts +0 -0
  18. package/{build/background → background}/handlers/subscriptions.js +0 -0
  19. package/{build/background → background}/types.d.ts +0 -0
  20. package/{build/background → background}/types.js +0 -0
  21. package/{build/bundle.d.ts → bundle.d.ts} +0 -0
  22. package/{build/bundle.js → bundle.js} +0 -0
  23. package/{build-cjs → cjs}/background/KoniTypes.js +0 -0
  24. package/{build-cjs → cjs}/background/RequestBytesSign.js +0 -0
  25. package/{build-cjs → cjs}/background/RequestExtrinsicSign.js +0 -0
  26. package/{build/cjs → cjs}/background/handlers/Extension.js +4 -4
  27. package/{build-cjs → cjs}/background/handlers/State.js +0 -0
  28. package/{build-cjs → cjs}/background/handlers/Tabs.js +0 -0
  29. package/{build-cjs → cjs}/background/handlers/helpers.js +0 -0
  30. package/{build-cjs → cjs}/background/handlers/index.js +0 -0
  31. package/{build-cjs → cjs}/background/handlers/subscriptions.js +0 -0
  32. package/{build-cjs → cjs}/background/types.js +0 -0
  33. package/{build-cjs → cjs}/bundle.js +0 -0
  34. package/{build-cjs → cjs}/defaults.js +0 -0
  35. package/{build-cjs → cjs}/detectOther.js +0 -0
  36. package/{build-cjs → cjs}/detectPackage.js +0 -0
  37. package/{build-cjs → cjs}/index.js +0 -0
  38. package/{build/cjs → cjs}/package.json +0 -0
  39. package/{build-cjs → cjs}/packageInfo.js +1 -1
  40. package/{build-cjs → cjs}/page/Accounts.js +0 -0
  41. package/{build-cjs → cjs}/page/Injected.js +0 -0
  42. package/{build-cjs → cjs}/page/Metadata.js +0 -0
  43. package/{build-cjs → cjs}/page/PostMessageProvider.js +0 -0
  44. package/{build-cjs → cjs}/page/Signer.js +0 -0
  45. package/{build-cjs → cjs}/page/index.js +0 -0
  46. package/{build-cjs → cjs}/page/types.js +0 -0
  47. package/{build-cjs → cjs}/stores/Accounts.js +0 -0
  48. package/{build-cjs → cjs}/stores/Base.js +0 -0
  49. package/{build-cjs → cjs}/stores/Metadata.js +0 -0
  50. package/{build-cjs → cjs}/stores/index.js +0 -0
  51. package/{build-cjs → cjs}/types.js +0 -0
  52. package/{build-cjs → cjs}/utils/canDerive.js +0 -0
  53. package/{build-cjs → cjs}/utils/getId.js +0 -0
  54. package/{build-cjs → cjs}/utils/index.js +0 -0
  55. package/{build/defaults.d.ts → defaults.d.ts} +0 -0
  56. package/{build/defaults.js → defaults.js} +0 -0
  57. package/{build/detectOther.d.ts → detectOther.d.ts} +0 -0
  58. package/{build/detectOther.js → detectOther.js} +0 -0
  59. package/{build/detectPackage.d.ts → detectPackage.d.ts} +0 -0
  60. package/{build/detectPackage.js → detectPackage.js} +0 -0
  61. package/{build/index.d.ts → index.d.ts} +0 -0
  62. package/{build/index.js → index.js} +0 -0
  63. package/package.json +174 -10
  64. package/{build/packageInfo.d.ts → packageInfo.d.ts} +0 -0
  65. package/{build/packageInfo.js → packageInfo.js} +1 -1
  66. package/{build/page → page}/Accounts.d.ts +0 -0
  67. package/{build/page → page}/Accounts.js +0 -0
  68. package/{build/page → page}/Injected.d.ts +0 -0
  69. package/{build/page → page}/Injected.js +0 -0
  70. package/{build/page → page}/Metadata.d.ts +0 -0
  71. package/{build/page → page}/Metadata.js +0 -0
  72. package/{build/page → page}/PostMessageProvider.d.ts +0 -0
  73. package/{build/page → page}/PostMessageProvider.js +0 -0
  74. package/{build/page → page}/Signer.d.ts +0 -0
  75. package/{build/page → page}/Signer.js +0 -0
  76. package/{build/page → page}/index.d.ts +1 -1
  77. package/{build/page → page}/index.js +0 -0
  78. package/{build/page → page}/types.d.ts +0 -0
  79. package/{build/page → page}/types.js +0 -0
  80. package/{build/stores → stores}/Accounts.d.ts +0 -0
  81. package/{build/stores → stores}/Accounts.js +0 -0
  82. package/{build/stores → stores}/Base.d.ts +0 -0
  83. package/{build/stores → stores}/Base.js +0 -0
  84. package/{build/stores → stores}/Metadata.d.ts +0 -0
  85. package/{build/stores → stores}/Metadata.js +0 -0
  86. package/{build/stores → stores}/index.d.ts +0 -0
  87. package/{build/stores → stores}/index.js +0 -0
  88. package/{build/types.d.ts → types.d.ts} +0 -0
  89. package/{build/types.js → types.js} +0 -0
  90. package/{build/utils → utils}/canDerive.d.ts +0 -0
  91. package/{build/utils → utils}/canDerive.js +0 -0
  92. package/{build/utils → utils}/getId.d.ts +0 -0
  93. package/{build/utils → utils}/getId.js +0 -0
  94. package/{build/utils → utils}/index.d.ts +0 -0
  95. package/{build/utils → utils}/index.js +0 -0
  96. package/build/LICENSE +0 -201
  97. package/build/README.md +0 -10
  98. package/build/cjs/background/KoniTypes.js +0 -69
  99. package/build/cjs/background/RequestBytesSign.js +0 -27
  100. package/build/cjs/background/RequestExtrinsicSign.js +0 -23
  101. package/build/cjs/background/handlers/State.js +0 -472
  102. package/build/cjs/background/handlers/Tabs.js +0 -273
  103. package/build/cjs/background/handlers/helpers.js +0 -20
  104. package/build/cjs/background/handlers/index.js +0 -60
  105. package/build/cjs/background/handlers/subscriptions.js +0 -32
  106. package/build/cjs/background/types.js +0 -1
  107. package/build/cjs/bundle.js +0 -13
  108. package/build/cjs/defaults.js +0 -26
  109. package/build/cjs/detectOther.js +0 -17
  110. package/build/cjs/detectPackage.js +0 -14
  111. package/build/cjs/index.js +0 -18
  112. package/build/cjs/packageInfo.js +0 -16
  113. package/build/cjs/page/Accounts.js +0 -31
  114. package/build/cjs/page/Injected.js +0 -30
  115. package/build/cjs/page/Metadata.js +0 -27
  116. package/build/cjs/page/PostMessageProvider.js +0 -184
  117. package/build/cjs/page/Signer.js +0 -44
  118. package/build/cjs/page/index.js +0 -76
  119. package/build/cjs/page/types.js +0 -1
  120. package/build/cjs/stores/Accounts.js +0 -33
  121. package/build/cjs/stores/Base.js +0 -84
  122. package/build/cjs/stores/Metadata.js +0 -23
  123. package/build/cjs/stores/index.js +0 -23
  124. package/build/cjs/types.js +0 -1
  125. package/build/cjs/utils/canDerive.js +0 -12
  126. package/build/cjs/utils/getId.js +0 -16
  127. package/build/cjs/utils/index.js +0 -13
  128. package/build/package.json +0 -210
  129. package/build-cjs/background/handlers/Extension.js +0 -764
  130. package/src/background/KoniTypes.ts +0 -537
  131. package/src/background/RequestBytesSign.ts +0 -30
  132. package/src/background/RequestExtrinsicSign.ts +0 -23
  133. package/src/background/handlers/Extension.spec.ts +0 -456
  134. package/src/background/handlers/Extension.ts +0 -627
  135. package/src/background/handlers/State.ts +0 -513
  136. package/src/background/handlers/Tabs.ts +0 -223
  137. package/src/background/handlers/helpers.ts +0 -14
  138. package/src/background/handlers/index.ts +0 -49
  139. package/src/background/handlers/subscriptions.ts +0 -30
  140. package/src/background/types.ts +0 -437
  141. package/src/bundle.ts +0 -4
  142. package/src/defaults.ts +0 -24
  143. package/src/detectOther.ts +0 -8
  144. package/src/detectPackage.ts +0 -11
  145. package/src/index.ts +0 -7
  146. package/src/packageInfo.ts +0 -6
  147. package/src/page/Accounts.ts +0 -27
  148. package/src/page/Injected.ts +0 -27
  149. package/src/page/Metadata.ts +0 -22
  150. package/src/page/PostMessageProvider.ts +0 -178
  151. package/src/page/Signer.ts +0 -45
  152. package/src/page/index.ts +0 -87
  153. package/src/page/types.ts +0 -10
  154. package/src/stores/Accounts.ts +0 -24
  155. package/src/stores/Base.ts +0 -81
  156. package/src/stores/Metadata.ts +0 -13
  157. package/src/stores/index.ts +0 -5
  158. package/src/types.ts +0 -12
  159. package/src/utils/canDerive.ts +0 -8
  160. package/src/utils/getId.ts +0 -10
  161. package/src/utils/index.ts +0 -4
  162. package/tsconfig.build.json +0 -18
  163. package/tsconfig.build.tsbuildinfo +0 -1
  164. package/tsconfig.json +0 -14
@@ -1,472 +0,0 @@
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 = exports.NotificationOptions = void 0;
9
-
10
- var _getId = require("@subwallet/extension-base/utils/getId");
11
-
12
- var _extensionChains = require("@subwallet/extension-chains");
13
-
14
- var _rxjs = require("rxjs");
15
-
16
- var _defaults = require("@polkadot/networks/defaults");
17
-
18
- var _uiSettings = _interopRequireDefault(require("@polkadot/ui-settings"));
19
-
20
- var _util = require("@polkadot/util");
21
-
22
- var _stores = require("../../stores");
23
-
24
- var _helpers = require("./helpers");
25
-
26
- // Copyright 2019-2022 @subwallet/extension-bg authors & contributors
27
- // SPDX-License-Identifier: Apache-2.0
28
- const NOTIFICATION_URL = chrome.extension.getURL('notification.html');
29
- const POPUP_WINDOW_OPTS = {
30
- focused: true,
31
- height: 621,
32
- left: 150,
33
- top: 150,
34
- type: 'popup',
35
- url: NOTIFICATION_URL,
36
- width: 460
37
- };
38
- const NORMAL_WINDOW_OPTS = {
39
- focused: true,
40
- type: 'normal',
41
- url: NOTIFICATION_URL
42
- };
43
- let NotificationOptions;
44
- exports.NotificationOptions = NotificationOptions;
45
-
46
- (function (NotificationOptions) {
47
- NotificationOptions[NotificationOptions["None"] = 0] = "None";
48
- NotificationOptions[NotificationOptions["Normal"] = 1] = "Normal";
49
- NotificationOptions[NotificationOptions["PopUp"] = 2] = "PopUp";
50
- })(NotificationOptions || (exports.NotificationOptions = NotificationOptions = {}));
51
-
52
- const AUTH_URLS_KEY = 'authUrls';
53
-
54
- function extractMetadata(store) {
55
- store.allMap(map => {
56
- const knownEntries = Object.entries(_defaults.knownGenesis);
57
- const defs = {};
58
- const removals = [];
59
- Object.entries(map).forEach(_ref => {
60
- let [key, def] = _ref;
61
- const entry = knownEntries.find(_ref2 => {
62
- let [, hashes] = _ref2;
63
- return hashes.includes(def.genesisHash);
64
- });
65
-
66
- if (entry) {
67
- const [name, hashes] = entry;
68
- const index = hashes.indexOf(def.genesisHash); // flatten the known metadata based on the genesis index
69
- // (lower is better/newer)
70
-
71
- if (!defs[name] || defs[name].index > index) {
72
- if (defs[name]) {
73
- // remove the old version of the metadata
74
- removals.push(defs[name].key);
75
- }
76
-
77
- defs[name] = {
78
- def,
79
- index,
80
- key
81
- };
82
- }
83
- } else {
84
- // this is not a known entry, so we will just apply it
85
- defs[key] = {
86
- def,
87
- index: 0,
88
- key
89
- };
90
- }
91
- });
92
- removals.forEach(key => store.remove(key));
93
- Object.values(defs).forEach(_ref3 => {
94
- let {
95
- def
96
- } = _ref3;
97
- return (0, _extensionChains.addMetadata)(def);
98
- });
99
- });
100
- }
101
-
102
- class State {
103
- #authUrls = {};
104
- #authRequests = {};
105
- #metaStore = new _stores.MetadataStore(); // Map of providers currently injected in tabs
106
-
107
- #injectedProviders = new Map();
108
- #metaRequests = {};
109
- #notification = _uiSettings.default.notification; // Map of all providers exposed by the extension, they are retrievable by key
110
-
111
- #providers;
112
- #signRequests = {};
113
- #windows = [];
114
- authSubject = new _rxjs.BehaviorSubject([]);
115
- metaSubject = new _rxjs.BehaviorSubject([]);
116
- signSubject = new _rxjs.BehaviorSubject([]);
117
-
118
- constructor() {
119
- let providers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
120
- this.#providers = providers;
121
- extractMetadata(this.#metaStore); // retrieve previously set authorizations
122
-
123
- const authString = localStorage.getItem(AUTH_URLS_KEY) || '{}';
124
- const previousAuth = JSON.parse(authString);
125
- this.#authUrls = previousAuth;
126
- }
127
-
128
- get knownMetadata() {
129
- return (0, _extensionChains.knownMetadata)();
130
- }
131
-
132
- get numAuthRequests() {
133
- return Object.keys(this.#authRequests).length;
134
- }
135
-
136
- get numMetaRequests() {
137
- return Object.keys(this.#metaRequests).length;
138
- }
139
-
140
- get numSignRequests() {
141
- return Object.keys(this.#signRequests).length;
142
- }
143
-
144
- get allAuthRequests() {
145
- return Object.values(this.#authRequests).map(_ref4 => {
146
- let {
147
- id,
148
- request,
149
- url
150
- } = _ref4;
151
- return {
152
- id,
153
- request,
154
- url
155
- };
156
- });
157
- }
158
-
159
- get allMetaRequests() {
160
- return Object.values(this.#metaRequests).map(_ref5 => {
161
- let {
162
- id,
163
- request,
164
- url
165
- } = _ref5;
166
- return {
167
- id,
168
- request,
169
- url
170
- };
171
- });
172
- }
173
-
174
- get allSignRequests() {
175
- return Object.values(this.#signRequests).map(_ref6 => {
176
- let {
177
- account,
178
- id,
179
- request,
180
- url
181
- } = _ref6;
182
- return {
183
- account,
184
- id,
185
- request,
186
- url
187
- };
188
- });
189
- }
190
-
191
- get authUrls() {
192
- return this.#authUrls;
193
- }
194
-
195
- popupClose() {
196
- this.#windows.forEach(id => (0, _helpers.withErrorLog)(() => chrome.windows.remove(id)));
197
- this.#windows = [];
198
- }
199
-
200
- popupOpen() {
201
- this.#notification !== 'extension' && chrome.windows.create(this.#notification === 'window' ? NORMAL_WINDOW_OPTS : POPUP_WINDOW_OPTS, window => {
202
- if (window) {
203
- this.#windows.push(window.id || 0);
204
- }
205
- });
206
- }
207
-
208
- authComplete = (id, resolve, reject) => {
209
- const complete = result => {
210
- const isAllowed = result === true;
211
- const {
212
- idStr,
213
- request: {
214
- origin
215
- },
216
- url
217
- } = this.#authRequests[id];
218
- const isAllowedMap = {};
219
- this.#authUrls[this.stripUrl(url)] = {
220
- count: 0,
221
- id: idStr,
222
- isAllowed,
223
- isAllowedMap,
224
- origin,
225
- url
226
- };
227
- this.saveCurrentAuthList();
228
- delete this.#authRequests[id];
229
- this.updateIconAuth(true);
230
- };
231
-
232
- return {
233
- reject: error => {
234
- complete(error);
235
- reject(error);
236
- },
237
- resolve: result => {
238
- complete(result);
239
- resolve(result);
240
- }
241
- };
242
- };
243
-
244
- saveCurrentAuthList() {
245
- localStorage.setItem(AUTH_URLS_KEY, JSON.stringify(this.#authUrls));
246
- }
247
-
248
- metaComplete = (id, resolve, reject) => {
249
- const complete = () => {
250
- delete this.#metaRequests[id];
251
- this.updateIconMeta(true);
252
- };
253
-
254
- return {
255
- reject: error => {
256
- complete();
257
- reject(error);
258
- },
259
- resolve: result => {
260
- complete();
261
- resolve(result);
262
- }
263
- };
264
- };
265
- signComplete = (id, resolve, reject) => {
266
- const complete = () => {
267
- delete this.#signRequests[id];
268
- this.updateIconSign(true);
269
- };
270
-
271
- return {
272
- reject: error => {
273
- complete();
274
- reject(error);
275
- },
276
- resolve: result => {
277
- complete();
278
- resolve(result);
279
- }
280
- };
281
- };
282
-
283
- stripUrl(url) {
284
- (0, _util.assert)(url && (url.startsWith('http:') || url.startsWith('https:') || url.startsWith('ipfs:') || url.startsWith('ipns:')), `Invalid url ${url}, expected to start with http: or https: or ipfs: or ipns:`);
285
- const parts = url.split('/');
286
- return parts[2];
287
- }
288
-
289
- updateIcon(shouldClose) {
290
- const authCount = this.numAuthRequests;
291
- const metaCount = this.numMetaRequests;
292
- const signCount = this.numSignRequests;
293
- const text = authCount ? 'Auth' : metaCount ? 'Meta' : signCount ? `${signCount}` : '';
294
- (0, _helpers.withErrorLog)(() => chrome.browserAction.setBadgeText({
295
- text
296
- }));
297
-
298
- if (shouldClose && text === '') {
299
- this.popupClose();
300
- }
301
- }
302
-
303
- toggleAuthorization(url) {
304
- const entry = this.#authUrls[url];
305
- (0, _util.assert)(entry, `The source ${url} is not known`);
306
- this.#authUrls[url].isAllowed = !entry.isAllowed;
307
- this.saveCurrentAuthList();
308
- return this.#authUrls;
309
- }
310
-
311
- updateIconAuth(shouldClose) {
312
- this.authSubject.next(this.allAuthRequests);
313
- this.updateIcon(shouldClose);
314
- }
315
-
316
- updateIconMeta(shouldClose) {
317
- this.metaSubject.next(this.allMetaRequests);
318
- this.updateIcon(shouldClose);
319
- }
320
-
321
- updateIconSign(shouldClose) {
322
- this.signSubject.next(this.allSignRequests);
323
- this.updateIcon(shouldClose);
324
- }
325
-
326
- async authorizeUrl(url, request) {
327
- const idStr = this.stripUrl(url); // Do not enqueue duplicate authorization requests.
328
-
329
- const isDuplicate = Object.values(this.#authRequests).some(request => request.idStr === idStr);
330
- (0, _util.assert)(!isDuplicate, `The source ${url} has a pending authorization request`);
331
-
332
- if (this.#authUrls[idStr]) {
333
- // this url was seen in the past
334
- (0, _util.assert)(this.#authUrls[idStr].isAllowed, `The source ${url} is not allowed to interact with this extension`);
335
- return false;
336
- }
337
-
338
- return new Promise((resolve, reject) => {
339
- const id = (0, _getId.getId)();
340
- this.#authRequests[id] = { ...this.authComplete(id, resolve, reject),
341
- id,
342
- idStr,
343
- request,
344
- url
345
- };
346
- this.updateIconAuth();
347
- this.popupOpen();
348
- });
349
- }
350
-
351
- ensureUrlAuthorized(url) {
352
- const entry = this.#authUrls[this.stripUrl(url)];
353
- (0, _util.assert)(entry, `The source ${url} has not been enabled yet`);
354
- (0, _util.assert)(entry.isAllowed, `The source ${url} is not allowed to interact with this extension`);
355
- return true;
356
- }
357
-
358
- injectMetadata(url, request) {
359
- return new Promise((resolve, reject) => {
360
- const id = (0, _getId.getId)();
361
- this.#metaRequests[id] = { ...this.metaComplete(id, resolve, reject),
362
- id,
363
- request,
364
- url
365
- };
366
- this.updateIconMeta();
367
- this.popupOpen();
368
- });
369
- }
370
-
371
- getAuthRequest(id) {
372
- return this.#authRequests[id];
373
- }
374
-
375
- getMetaRequest(id) {
376
- return this.#metaRequests[id];
377
- }
378
-
379
- getSignRequest(id) {
380
- return this.#signRequests[id];
381
- } // List all providers the extension is exposing
382
-
383
-
384
- rpcListProviders() {
385
- return Promise.resolve(Object.keys(this.#providers).reduce((acc, key) => {
386
- acc[key] = this.#providers[key].meta;
387
- return acc;
388
- }, {}));
389
- }
390
-
391
- rpcSend(request, port) {
392
- const provider = this.#injectedProviders.get(port);
393
- (0, _util.assert)(provider, 'Cannot call pub(rpc.subscribe) before provider is set');
394
- return provider.send(request.method, request.params);
395
- } // Start a provider, return its meta
396
-
397
-
398
- rpcStartProvider(key, port) {
399
- (0, _util.assert)(Object.keys(this.#providers).includes(key), `Provider ${key} is not exposed by extension`);
400
-
401
- if (this.#injectedProviders.get(port)) {
402
- return Promise.resolve(this.#providers[key].meta);
403
- } // Instantiate the provider
404
-
405
-
406
- this.#injectedProviders.set(port, this.#providers[key].start()); // Close provider connection when page is closed
407
-
408
- port.onDisconnect.addListener(() => {
409
- const provider = this.#injectedProviders.get(port);
410
-
411
- if (provider) {
412
- (0, _helpers.withErrorLog)(() => provider.disconnect());
413
- }
414
-
415
- this.#injectedProviders.delete(port);
416
- });
417
- return Promise.resolve(this.#providers[key].meta);
418
- }
419
-
420
- rpcSubscribe(_ref7, cb, port) {
421
- let {
422
- method,
423
- params,
424
- type
425
- } = _ref7;
426
- const provider = this.#injectedProviders.get(port);
427
- (0, _util.assert)(provider, 'Cannot call pub(rpc.subscribe) before provider is set');
428
- return provider.subscribe(type, method, params, cb);
429
- }
430
-
431
- rpcSubscribeConnected(_request, cb, port) {
432
- const provider = this.#injectedProviders.get(port);
433
- (0, _util.assert)(provider, 'Cannot call pub(rpc.subscribeConnected) before provider is set');
434
- cb(null, provider.isConnected); // Immediately send back current isConnected
435
-
436
- provider.on('connected', () => cb(null, true));
437
- provider.on('disconnected', () => cb(null, false));
438
- }
439
-
440
- rpcUnsubscribe(request, port) {
441
- const provider = this.#injectedProviders.get(port);
442
- (0, _util.assert)(provider, 'Cannot call pub(rpc.unsubscribe) before provider is set');
443
- return provider.unsubscribe(request.type, request.method, request.subscriptionId);
444
- }
445
-
446
- saveMetadata(meta) {
447
- this.#metaStore.set(meta.genesisHash, meta);
448
- (0, _extensionChains.addMetadata)(meta);
449
- }
450
-
451
- setNotification(notification) {
452
- this.#notification = notification;
453
- return true;
454
- }
455
-
456
- sign(url, request, account) {
457
- const id = (0, _getId.getId)();
458
- return new Promise((resolve, reject) => {
459
- this.#signRequests[id] = { ...this.signComplete(id, resolve, reject),
460
- account,
461
- id,
462
- request,
463
- url
464
- };
465
- this.updateIconSign();
466
- this.popupOpen();
467
- });
468
- }
469
-
470
- }
471
-
472
- exports.default = State;