@polkadot/extension-dapp 0.44.8 → 0.44.9

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.
@@ -20,7 +20,7 @@
20
20
  name: '@polkadot/extension-dapp',
21
21
  path: (({ url: (typeof document === 'undefined' && typeof location === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.src || new URL('bundle-polkadot-extension-dapp.js', document.baseURI).href)) }) && (typeof document === 'undefined' && typeof location === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.src || new URL('bundle-polkadot-extension-dapp.js', document.baseURI).href))) ? new URL((typeof document === 'undefined' && typeof location === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.src || new URL('bundle-polkadot-extension-dapp.js', document.baseURI).href))).pathname.substring(0, new URL((typeof document === 'undefined' && typeof location === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.src || new URL('bundle-polkadot-extension-dapp.js', document.baseURI).href))).pathname.lastIndexOf('/') + 1) : 'auto',
22
22
  type: 'esm',
23
- version: '0.44.8'
23
+ version: '0.44.9'
24
24
  };
25
25
 
26
26
  const unwrapBytes = util.u8aUnwrapBytes;
@@ -28,6 +28,8 @@
28
28
 
29
29
  const win = window;
30
30
  win.injectedWeb3 = win.injectedWeb3 || {};
31
+ exports.isWeb3Injected = web3IsInjected();
32
+ exports.web3EnablePromise = null;
31
33
  function web3IsInjected() {
32
34
  return Object.values(win.injectedWeb3).filter(({
33
35
  connect,
@@ -56,8 +58,6 @@
56
58
  function filterAccounts(list, genesisHash, type) {
57
59
  return list.filter(a => (!a.type || !type || type.includes(a.type)) && (!a.genesisHash || !genesisHash || a.genesisHash === genesisHash));
58
60
  }
59
- exports.isWeb3Injected = web3IsInjected();
60
- exports.web3EnablePromise = null;
61
61
  function getWindowExtensions(originName) {
62
62
  return Promise.all(Object.entries(win.injectedWeb3).map(([nameOrHash, {
63
63
  connect,
@@ -74,6 +74,15 @@
74
74
  console.error(`Error initializing ${nameOrHash}: ${message}`);
75
75
  }))).then(exts => exts.filter(e => !!e));
76
76
  }
77
+ async function filterEnable(caller, extensions) {
78
+ if (!exports.web3EnablePromise) {
79
+ return throwError(caller);
80
+ }
81
+ const sources = await exports.web3EnablePromise;
82
+ return sources.filter(({
83
+ name
84
+ }) => !extensions || extensions.includes(name));
85
+ }
77
86
  function web3Enable(originName, compatInits = []) {
78
87
  if (!originName) {
79
88
  throw new Error('You must pass a name for your app to the web3Enable function');
@@ -105,14 +114,9 @@
105
114
  genesisHash,
106
115
  ss58Format
107
116
  } = {}) {
108
- if (!exports.web3EnablePromise) {
109
- return throwError('web3Accounts');
110
- }
111
117
  const accounts = [];
112
- const sources = await exports.web3EnablePromise;
113
- const retrieved = await Promise.all(sources.filter(({
114
- name: source
115
- }) => !extensions || extensions.includes(source)).map(async ({
118
+ const sources = await filterEnable('web3Accounts', extensions);
119
+ const retrieved = await Promise.all(sources.map(async ({
116
120
  accounts,
117
121
  name: source
118
122
  }) => {
@@ -135,18 +139,13 @@
135
139
  genesisHash,
136
140
  ss58Format
137
141
  } = {}) {
138
- if (!exports.web3EnablePromise) {
139
- return throwError('web3AccountsSubscribe');
140
- }
142
+ const sources = await filterEnable('web3AccountsSubscribe', extensions);
141
143
  const accounts = {};
142
144
  const triggerUpdate = () => cb(Object.entries(accounts).reduce((result, [source, list]) => {
143
145
  result.push(...mapAccounts(source, filterAccounts(list, genesisHash, accountType), ss58Format));
144
146
  return result;
145
147
  }, []));
146
- const sources = await exports.web3EnablePromise;
147
- const unsubs = sources.filter(({
148
- name: source
149
- }) => !extensions || extensions.includes(source)).map(({
148
+ const unsubs = sources.map(({
150
149
  accounts: {
151
150
  subscribe
152
151
  },
package/bundle.d.ts CHANGED
@@ -4,10 +4,58 @@ export { unwrapBytes, wrapBytes } from './wrapBytes';
4
4
  declare let isWeb3Injected: boolean;
5
5
  declare let web3EnablePromise: Promise<InjectedExtension[]> | null;
6
6
  export { isWeb3Injected, web3EnablePromise };
7
+ /**
8
+ * @summary Enables all the providers found on the injected window interface
9
+ * @description
10
+ * Enables all injected extensions that has been found on the page. This
11
+ * should be called before making use of any other web3* functions.
12
+ */
7
13
  export declare function web3Enable(originName: string, compatInits?: (() => Promise<boolean>)[]): Promise<InjectedExtension[]>;
14
+ /**
15
+ * @summary Retrieves all the accounts across all providers
16
+ * @description
17
+ * This returns the full list of account available (accross all extensions) to
18
+ * the page. Filtereing options are available of a per-extension, per type and
19
+ * per-genesisHash basis. Optionally the accounts can be encoded with the provided
20
+ * ss58Format
21
+ */
8
22
  export declare function web3Accounts({ accountType, extensions, genesisHash, ss58Format }?: Web3AccountsOptions): Promise<InjectedAccountWithMeta[]>;
23
+ /**
24
+ * @summary Subscribes to all the accounts across all providers
25
+ * @description
26
+ * This is the subscription version of the web3Accounts interface with
27
+ * updates as to when new accounts do become available. The list of filtering
28
+ * options are the same as for the web3Accounts interface.
29
+ */
9
30
  export declare function web3AccountsSubscribe(cb: (accounts: InjectedAccountWithMeta[]) => void | Promise<void>, { accountType, extensions, genesisHash, ss58Format }?: Web3AccountsOptions): Promise<Unsubcall>;
31
+ /**
32
+ * @summary Finds a specific provider based on the name
33
+ * @description
34
+ * This retrieves a specific source (extension) based on the name. In most
35
+ * cases it should not be needed to call it directly (e.g. it is used internally
36
+ * by calls such as web3FromAddress) but would allow operation on a specific
37
+ * known extension.
38
+ */
10
39
  export declare function web3FromSource(source: string): Promise<InjectedExtension>;
40
+ /**
41
+ * @summary Find a specific provider that provides a specific address
42
+ * @description
43
+ * Based on an address, return the provider that has makes this address
44
+ * available to the page.
45
+ */
11
46
  export declare function web3FromAddress(address: string): Promise<InjectedExtension>;
47
+ /**
48
+ * @summary List all providers exposed by one source
49
+ * @description
50
+ * For extensions that supply RPC providers, this call would return the list
51
+ * of RPC providers that any extension may supply.
52
+ */
12
53
  export declare function web3ListRpcProviders(source: string): Promise<ProviderList | null>;
54
+ /**
55
+ * @summary Start an RPC provider provider by a specific source
56
+ * @description
57
+ * For extensions that supply RPC providers, this call would return an
58
+ * enabled provider (initialized with the specific key) from the
59
+ * specified extension source.
60
+ */
13
61
  export declare function web3UseRpcProvider(source: string, key: string): Promise<InjectedProviderWithMeta>;
package/bundle.js CHANGED
@@ -15,7 +15,14 @@ const win = window;
15
15
  // don't clobber the existing object, but ensure non-undefined
16
16
  win.injectedWeb3 = win.injectedWeb3 || {};
17
17
 
18
- // true when anything has been injected and is available
18
+ // have we found a properly constructed window.injectedWeb3
19
+ let isWeb3Injected = web3IsInjected();
20
+
21
+ // we keep the last promise created around (for queries)
22
+ let web3EnablePromise = null;
23
+ export { isWeb3Injected, web3EnablePromise };
24
+
25
+ /** @internal true when anything has been injected and is available */
19
26
  function web3IsInjected() {
20
27
  return Object.values(win.injectedWeb3).filter(({
21
28
  connect,
@@ -23,12 +30,12 @@ function web3IsInjected() {
23
30
  }) => !!(connect || enable)).length !== 0;
24
31
  }
25
32
 
26
- // helper to throw a consistent error when not enabled
33
+ /** @internal throw a consistent error when not extensions have not been enabled */
27
34
  function throwError(method) {
28
35
  throw new Error(`${method}: web3Enable(originName) needs to be called before ${method}`);
29
36
  }
30
37
 
31
- // internal helper to map from Array<InjectedAccount> -> Array<InjectedAccountWithMeta>
38
+ /** @internal map from Array<InjectedAccount> to Array<InjectedAccountWithMeta> */
32
39
  function mapAccounts(source, list, ss58Format) {
33
40
  return list.map(({
34
41
  address,
@@ -46,17 +53,12 @@ function mapAccounts(source, list, ss58Format) {
46
53
  }));
47
54
  }
48
55
 
49
- // internal helper to filter accounts
56
+ /** @internal filter accounts based on genesisHash and type of account */
50
57
  function filterAccounts(list, genesisHash, type) {
51
58
  return list.filter(a => (!a.type || !type || type.includes(a.type)) && (!a.genesisHash || !genesisHash || a.genesisHash === genesisHash));
52
59
  }
53
60
 
54
- // have we found a properly constructed window.injectedWeb3
55
- let isWeb3Injected = web3IsInjected();
56
-
57
- // we keep the last promise created around (for queries)
58
- let web3EnablePromise = null;
59
- export { isWeb3Injected, web3EnablePromise };
61
+ /** @internal retrieves all the extensions available on the window */
60
62
  function getWindowExtensions(originName) {
61
63
  return Promise.all(Object.entries(win.injectedWeb3).map(([nameOrHash, {
62
64
  connect,
@@ -76,7 +78,23 @@ function getWindowExtensions(originName) {
76
78
  }))).then(exts => exts.filter(e => !!e));
77
79
  }
78
80
 
79
- // enables all the providers found on the injected window interface
81
+ /** @internal Ensure the enable promise is resolved and filter by extensions */
82
+ async function filterEnable(caller, extensions) {
83
+ if (!web3EnablePromise) {
84
+ return throwError(caller);
85
+ }
86
+ const sources = await web3EnablePromise;
87
+ return sources.filter(({
88
+ name
89
+ }) => !extensions || extensions.includes(name));
90
+ }
91
+
92
+ /**
93
+ * @summary Enables all the providers found on the injected window interface
94
+ * @description
95
+ * Enables all injected extensions that has been found on the page. This
96
+ * should be called before making use of any other web3* functions.
97
+ */
80
98
  export function web3Enable(originName, compatInits = []) {
81
99
  if (!originName) {
82
100
  throw new Error('You must pass a name for your app to the web3Enable function');
@@ -105,21 +123,23 @@ export function web3Enable(originName, compatInits = []) {
105
123
  return web3EnablePromise;
106
124
  }
107
125
 
108
- // retrieve all the accounts across all providers
126
+ /**
127
+ * @summary Retrieves all the accounts across all providers
128
+ * @description
129
+ * This returns the full list of account available (accross all extensions) to
130
+ * the page. Filtereing options are available of a per-extension, per type and
131
+ * per-genesisHash basis. Optionally the accounts can be encoded with the provided
132
+ * ss58Format
133
+ */
109
134
  export async function web3Accounts({
110
135
  accountType,
111
136
  extensions,
112
137
  genesisHash,
113
138
  ss58Format
114
139
  } = {}) {
115
- if (!web3EnablePromise) {
116
- return throwError('web3Accounts');
117
- }
118
140
  const accounts = [];
119
- const sources = await web3EnablePromise;
120
- const retrieved = await Promise.all(sources.filter(({
121
- name: source
122
- }) => !extensions || extensions.includes(source)).map(async ({
141
+ const sources = await filterEnable('web3Accounts', extensions);
142
+ const retrieved = await Promise.all(sources.map(async ({
123
143
  accounts,
124
144
  name: source
125
145
  }) => {
@@ -137,24 +157,27 @@ export async function web3Accounts({
137
157
  console.info(`web3Accounts: Found ${accounts.length} address${accounts.length !== 1 ? 'es' : ''}`);
138
158
  return accounts;
139
159
  }
160
+
161
+ /**
162
+ * @summary Subscribes to all the accounts across all providers
163
+ * @description
164
+ * This is the subscription version of the web3Accounts interface with
165
+ * updates as to when new accounts do become available. The list of filtering
166
+ * options are the same as for the web3Accounts interface.
167
+ */
140
168
  export async function web3AccountsSubscribe(cb, {
141
169
  accountType,
142
170
  extensions,
143
171
  genesisHash,
144
172
  ss58Format
145
173
  } = {}) {
146
- if (!web3EnablePromise) {
147
- return throwError('web3AccountsSubscribe');
148
- }
174
+ const sources = await filterEnable('web3AccountsSubscribe', extensions);
149
175
  const accounts = {};
150
176
  const triggerUpdate = () => cb(Object.entries(accounts).reduce((result, [source, list]) => {
151
177
  result.push(...mapAccounts(source, filterAccounts(list, genesisHash, accountType), ss58Format));
152
178
  return result;
153
179
  }, []));
154
- const sources = await web3EnablePromise;
155
- const unsubs = sources.filter(({
156
- name: source
157
- }) => !extensions || extensions.includes(source)).map(({
180
+ const unsubs = sources.map(({
158
181
  accounts: {
159
182
  subscribe
160
183
  },
@@ -177,7 +200,14 @@ export async function web3AccountsSubscribe(cb, {
177
200
  };
178
201
  }
179
202
 
180
- // find a specific provider based on the name
203
+ /**
204
+ * @summary Finds a specific provider based on the name
205
+ * @description
206
+ * This retrieves a specific source (extension) based on the name. In most
207
+ * cases it should not be needed to call it directly (e.g. it is used internally
208
+ * by calls such as web3FromAddress) but would allow operation on a specific
209
+ * known extension.
210
+ */
181
211
  export async function web3FromSource(source) {
182
212
  if (!web3EnablePromise) {
183
213
  return throwError('web3FromSource');
@@ -192,7 +222,12 @@ export async function web3FromSource(source) {
192
222
  return found;
193
223
  }
194
224
 
195
- // find a specific provider based on an address
225
+ /**
226
+ * @summary Find a specific provider that provides a specific address
227
+ * @description
228
+ * Based on an address, return the provider that has makes this address
229
+ * available to the page.
230
+ */
196
231
  export async function web3FromAddress(address) {
197
232
  if (!web3EnablePromise) {
198
233
  return throwError('web3FromAddress');
@@ -209,7 +244,12 @@ export async function web3FromAddress(address) {
209
244
  return web3FromSource(found.meta.source);
210
245
  }
211
246
 
212
- // retrieve all providers exposed by one source
247
+ /**
248
+ * @summary List all providers exposed by one source
249
+ * @description
250
+ * For extensions that supply RPC providers, this call would return the list
251
+ * of RPC providers that any extension may supply.
252
+ */
213
253
  export async function web3ListRpcProviders(source) {
214
254
  const {
215
255
  provider
@@ -221,7 +261,13 @@ export async function web3ListRpcProviders(source) {
221
261
  return provider.listProviders();
222
262
  }
223
263
 
224
- // retrieve all providers exposed by one source
264
+ /**
265
+ * @summary Start an RPC provider provider by a specific source
266
+ * @description
267
+ * For extensions that supply RPC providers, this call would return an
268
+ * enabled provider (initialized with the specific key) from the
269
+ * specified extension source.
270
+ */
225
271
  export async function web3UseRpcProvider(source, key) {
226
272
  const {
227
273
  provider
package/cjs/bundle.js CHANGED
@@ -46,7 +46,14 @@ const win = window;
46
46
  // don't clobber the existing object, but ensure non-undefined
47
47
  win.injectedWeb3 = win.injectedWeb3 || {};
48
48
 
49
- // true when anything has been injected and is available
49
+ // have we found a properly constructed window.injectedWeb3
50
+ let isWeb3Injected = web3IsInjected();
51
+
52
+ // we keep the last promise created around (for queries)
53
+ exports.isWeb3Injected = isWeb3Injected;
54
+ let web3EnablePromise = null;
55
+ exports.web3EnablePromise = web3EnablePromise;
56
+ /** @internal true when anything has been injected and is available */
50
57
  function web3IsInjected() {
51
58
  return Object.values(win.injectedWeb3).filter(_ref => {
52
59
  let {
@@ -57,12 +64,12 @@ function web3IsInjected() {
57
64
  }).length !== 0;
58
65
  }
59
66
 
60
- // helper to throw a consistent error when not enabled
67
+ /** @internal throw a consistent error when not extensions have not been enabled */
61
68
  function throwError(method) {
62
69
  throw new Error(`${method}: web3Enable(originName) needs to be called before ${method}`);
63
70
  }
64
71
 
65
- // internal helper to map from Array<InjectedAccount> -> Array<InjectedAccountWithMeta>
72
+ /** @internal map from Array<InjectedAccount> to Array<InjectedAccountWithMeta> */
66
73
  function mapAccounts(source, list, ss58Format) {
67
74
  return list.map(_ref2 => {
68
75
  let {
@@ -83,18 +90,12 @@ function mapAccounts(source, list, ss58Format) {
83
90
  });
84
91
  }
85
92
 
86
- // internal helper to filter accounts
93
+ /** @internal filter accounts based on genesisHash and type of account */
87
94
  function filterAccounts(list, genesisHash, type) {
88
95
  return list.filter(a => (!a.type || !type || type.includes(a.type)) && (!a.genesisHash || !genesisHash || a.genesisHash === genesisHash));
89
96
  }
90
97
 
91
- // have we found a properly constructed window.injectedWeb3
92
- let isWeb3Injected = web3IsInjected();
93
-
94
- // we keep the last promise created around (for queries)
95
- exports.isWeb3Injected = isWeb3Injected;
96
- let web3EnablePromise = null;
97
- exports.web3EnablePromise = web3EnablePromise;
98
+ /** @internal retrieves all the extensions available on the window */
98
99
  function getWindowExtensions(originName) {
99
100
  return Promise.all(Object.entries(win.injectedWeb3).map(_ref3 => {
100
101
  let [nameOrHash, {
@@ -118,7 +119,26 @@ function getWindowExtensions(originName) {
118
119
  })).then(exts => exts.filter(e => !!e));
119
120
  }
120
121
 
121
- // enables all the providers found on the injected window interface
122
+ /** @internal Ensure the enable promise is resolved and filter by extensions */
123
+ async function filterEnable(caller, extensions) {
124
+ if (!web3EnablePromise) {
125
+ return throwError(caller);
126
+ }
127
+ const sources = await web3EnablePromise;
128
+ return sources.filter(_ref5 => {
129
+ let {
130
+ name
131
+ } = _ref5;
132
+ return !extensions || extensions.includes(name);
133
+ });
134
+ }
135
+
136
+ /**
137
+ * @summary Enables all the providers found on the injected window interface
138
+ * @description
139
+ * Enables all injected extensions that has been found on the page. This
140
+ * should be called before making use of any other web3* functions.
141
+ */
122
142
  function web3Enable(originName) {
123
143
  let compatInits = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
124
144
  if (!originName) {
@@ -137,11 +157,11 @@ function web3Enable(originName) {
137
157
  }
138
158
  return e;
139
159
  })).catch(() => []).then(values => {
140
- const names = values.map(_ref5 => {
160
+ const names = values.map(_ref6 => {
141
161
  let {
142
162
  name,
143
163
  version
144
- } = _ref5;
164
+ } = _ref6;
145
165
  return `${name}/${version}`;
146
166
  });
147
167
  exports.isWeb3Injected = isWeb3Injected = web3IsInjected();
@@ -151,7 +171,14 @@ function web3Enable(originName) {
151
171
  return web3EnablePromise;
152
172
  }
153
173
 
154
- // retrieve all the accounts across all providers
174
+ /**
175
+ * @summary Retrieves all the accounts across all providers
176
+ * @description
177
+ * This returns the full list of account available (accross all extensions) to
178
+ * the page. Filtereing options are available of a per-extension, per type and
179
+ * per-genesisHash basis. Optionally the accounts can be encoded with the provided
180
+ * ss58Format
181
+ */
155
182
  async function web3Accounts() {
156
183
  let {
157
184
  accountType,
@@ -159,17 +186,9 @@ async function web3Accounts() {
159
186
  genesisHash,
160
187
  ss58Format
161
188
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
162
- if (!web3EnablePromise) {
163
- return throwError('web3Accounts');
164
- }
165
189
  const accounts = [];
166
- const sources = await web3EnablePromise;
167
- const retrieved = await Promise.all(sources.filter(_ref6 => {
168
- let {
169
- name: source
170
- } = _ref6;
171
- return !extensions || extensions.includes(source);
172
- }).map(async _ref7 => {
190
+ const sources = await filterEnable('web3Accounts', extensions);
191
+ const retrieved = await Promise.all(sources.map(async _ref7 => {
173
192
  let {
174
193
  accounts,
175
194
  name: source
@@ -188,6 +207,14 @@ async function web3Accounts() {
188
207
  console.info(`web3Accounts: Found ${accounts.length} address${accounts.length !== 1 ? 'es' : ''}`);
189
208
  return accounts;
190
209
  }
210
+
211
+ /**
212
+ * @summary Subscribes to all the accounts across all providers
213
+ * @description
214
+ * This is the subscription version of the web3Accounts interface with
215
+ * updates as to when new accounts do become available. The list of filtering
216
+ * options are the same as for the web3Accounts interface.
217
+ */
191
218
  async function web3AccountsSubscribe(cb) {
192
219
  let {
193
220
  accountType,
@@ -195,28 +222,20 @@ async function web3AccountsSubscribe(cb) {
195
222
  genesisHash,
196
223
  ss58Format
197
224
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
198
- if (!web3EnablePromise) {
199
- return throwError('web3AccountsSubscribe');
200
- }
225
+ const sources = await filterEnable('web3AccountsSubscribe', extensions);
201
226
  const accounts = {};
202
227
  const triggerUpdate = () => cb(Object.entries(accounts).reduce((result, _ref8) => {
203
228
  let [source, list] = _ref8;
204
229
  result.push(...mapAccounts(source, filterAccounts(list, genesisHash, accountType), ss58Format));
205
230
  return result;
206
231
  }, []));
207
- const sources = await web3EnablePromise;
208
- const unsubs = sources.filter(_ref9 => {
209
- let {
210
- name: source
211
- } = _ref9;
212
- return !extensions || extensions.includes(source);
213
- }).map(_ref10 => {
232
+ const unsubs = sources.map(_ref9 => {
214
233
  let {
215
234
  accounts: {
216
235
  subscribe
217
236
  },
218
237
  name: source
219
- } = _ref10;
238
+ } = _ref9;
220
239
  return subscribe(result => {
221
240
  accounts[source] = result;
222
241
  try {
@@ -236,16 +255,23 @@ async function web3AccountsSubscribe(cb) {
236
255
  };
237
256
  }
238
257
 
239
- // find a specific provider based on the name
258
+ /**
259
+ * @summary Finds a specific provider based on the name
260
+ * @description
261
+ * This retrieves a specific source (extension) based on the name. In most
262
+ * cases it should not be needed to call it directly (e.g. it is used internally
263
+ * by calls such as web3FromAddress) but would allow operation on a specific
264
+ * known extension.
265
+ */
240
266
  async function web3FromSource(source) {
241
267
  if (!web3EnablePromise) {
242
268
  return throwError('web3FromSource');
243
269
  }
244
270
  const sources = await web3EnablePromise;
245
- const found = source && sources.find(_ref11 => {
271
+ const found = source && sources.find(_ref10 => {
246
272
  let {
247
273
  name
248
- } = _ref11;
274
+ } = _ref10;
249
275
  return name === source;
250
276
  });
251
277
  if (!found) {
@@ -254,7 +280,12 @@ async function web3FromSource(source) {
254
280
  return found;
255
281
  }
256
282
 
257
- // find a specific provider based on an address
283
+ /**
284
+ * @summary Find a specific provider that provides a specific address
285
+ * @description
286
+ * Based on an address, return the provider that has makes this address
287
+ * available to the page.
288
+ */
258
289
  async function web3FromAddress(address) {
259
290
  if (!web3EnablePromise) {
260
291
  return throwError('web3FromAddress');
@@ -271,7 +302,12 @@ async function web3FromAddress(address) {
271
302
  return web3FromSource(found.meta.source);
272
303
  }
273
304
 
274
- // retrieve all providers exposed by one source
305
+ /**
306
+ * @summary List all providers exposed by one source
307
+ * @description
308
+ * For extensions that supply RPC providers, this call would return the list
309
+ * of RPC providers that any extension may supply.
310
+ */
275
311
  async function web3ListRpcProviders(source) {
276
312
  const {
277
313
  provider
@@ -283,7 +319,13 @@ async function web3ListRpcProviders(source) {
283
319
  return provider.listProviders();
284
320
  }
285
321
 
286
- // retrieve all providers exposed by one source
322
+ /**
323
+ * @summary Start an RPC provider provider by a specific source
324
+ * @description
325
+ * For extensions that supply RPC providers, this call would return an
326
+ * enabled provider (initialized with the specific key) from the
327
+ * specified extension source.
328
+ */
287
329
  async function web3UseRpcProvider(source, key) {
288
330
  const {
289
331
  provider
@@ -13,6 +13,6 @@ const packageInfo = {
13
13
  name: '@polkadot/extension-dapp',
14
14
  path: typeof __dirname === 'string' ? __dirname : 'auto',
15
15
  type: 'cjs',
16
- version: '0.44.8'
16
+ version: '0.44.9'
17
17
  };
18
18
  exports.packageInfo = packageInfo;
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "0.44.8",
20
+ "version": "0.44.9",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -67,10 +67,10 @@
67
67
  }
68
68
  },
69
69
  "dependencies": {
70
- "@babel/runtime": "^7.20.7",
71
- "@polkadot/extension-inject": "^0.44.8",
72
- "@polkadot/util": "^10.2.3",
73
- "@polkadot/util-crypto": "^10.2.3"
70
+ "@babel/runtime": "^7.20.13",
71
+ "@polkadot/extension-inject": "^0.44.9",
72
+ "@polkadot/util": "^10.4.2",
73
+ "@polkadot/util-crypto": "^10.4.2"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "@polkadot/api": "*",
package/packageInfo.js CHANGED
@@ -7,5 +7,5 @@ export const packageInfo = {
7
7
  name: '@polkadot/extension-dapp',
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: '0.44.8'
10
+ version: '0.44.9'
11
11
  };