@pezkuwi/extension-dapp 0.62.7 → 0.62.8
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.
- package/README.md +1 -1
- package/{cjs → build}/bundle.d.ts +1 -1
- package/build/bundle.js +395 -0
- package/build/index.js +5 -0
- package/build/packageDetect.js +8 -0
- package/build/packageInfo.js +4 -0
- package/build/util.js +12 -0
- package/{cjs → build}/wrapBytes.d.ts +1 -1
- package/build/wrapBytes.js +9 -0
- package/package.json +7 -112
- package/src/bundle.ts +319 -0
- package/src/index.ts +7 -0
- package/src/packageDetect.ts +12 -0
- package/src/packageInfo.ts +6 -0
- package/src/util.ts +12 -0
- package/src/wrapBytes.spec.ts +137 -0
- package/{wrapBytes.js → src/wrapBytes.ts} +6 -1
- package/tsconfig.build.json +14 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.spec.json +16 -0
- package/tsconfig.spec.tsbuildinfo +1 -0
- package/LICENSE +0 -201
- package/bundle-polkadot-extension-dapp.js +0 -205
- package/bundle.d.ts +0 -61
- package/bundle.js +0 -232
- package/cjs/bundle.js +0 -246
- package/cjs/index.js +0 -4
- package/cjs/package.json +0 -3
- package/cjs/packageDetect.js +0 -6
- package/cjs/packageInfo.js +0 -4
- package/cjs/util.js +0 -13
- package/cjs/wrapBytes.js +0 -10
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/packageDetect.d.ts +0 -1
- package/packageDetect.js +0 -4
- package/packageInfo.d.ts +0 -6
- package/packageInfo.js +0 -1
- package/util.d.ts +0 -1
- package/util.js +0 -10
- package/wrapBytes.d.ts +0 -7
- /package/{cjs → build}/index.d.ts +0 -0
- /package/{cjs → build}/packageDetect.d.ts +0 -0
- /package/{cjs → build}/packageInfo.d.ts +0 -0
- /package/{cjs → build}/util.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InjectedAccountWithMeta, InjectedExtension, InjectedProviderWithMeta, ProviderList, Unsubcall, Web3AccountsOptions } from '@
|
|
1
|
+
import type { InjectedAccountWithMeta, InjectedExtension, InjectedProviderWithMeta, ProviderList, Unsubcall, Web3AccountsOptions } from '@pezkuwi/extension-inject/types';
|
|
2
2
|
export { packageInfo } from './packageInfo.js';
|
|
3
3
|
export { unwrapBytes, wrapBytes } from './wrapBytes.js';
|
|
4
4
|
declare let isWeb3Injected: boolean;
|
package/build/bundle.js
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
// Copyright 2019-2025 @pezkuwi/extension-dapp authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
14
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
+
function step(op) {
|
|
17
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
19
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
20
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
+
switch (op[0]) {
|
|
22
|
+
case 0: case 1: t = op; break;
|
|
23
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
+
default:
|
|
27
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
+
if (t[2]) _.ops.pop();
|
|
32
|
+
_.trys.pop(); continue;
|
|
33
|
+
}
|
|
34
|
+
op = body.call(thisArg, _);
|
|
35
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
import { isPromise, objectSpread, u8aEq } from '@pezkuwi/util';
|
|
40
|
+
import { decodeAddress, encodeAddress } from '@pezkuwi/util-crypto';
|
|
41
|
+
import { documentReadyPromise } from './util.js';
|
|
42
|
+
// expose utility functions
|
|
43
|
+
export { packageInfo } from './packageInfo.js';
|
|
44
|
+
export { unwrapBytes, wrapBytes } from './wrapBytes.js';
|
|
45
|
+
// just a helper (otherwise we cast all-over, so shorter and more readable)
|
|
46
|
+
var win = window;
|
|
47
|
+
// don't clobber the existing object, but ensure non-undefined
|
|
48
|
+
win.injectedWeb3 = win.injectedWeb3 || {};
|
|
49
|
+
// have we found a properly constructed window.injectedWeb3
|
|
50
|
+
var isWeb3Injected = web3IsInjected();
|
|
51
|
+
// we keep the last promise created around (for queries)
|
|
52
|
+
var web3EnablePromise = null;
|
|
53
|
+
export { isWeb3Injected, web3EnablePromise };
|
|
54
|
+
/** @internal true when anything has been injected and is available */
|
|
55
|
+
function web3IsInjected() {
|
|
56
|
+
return Object
|
|
57
|
+
.values(win.injectedWeb3)
|
|
58
|
+
.filter(function (_a) {
|
|
59
|
+
var connect = _a.connect, enable = _a.enable;
|
|
60
|
+
return !!(connect || enable);
|
|
61
|
+
})
|
|
62
|
+
.length !== 0;
|
|
63
|
+
}
|
|
64
|
+
/** @internal throw a consistent error when not extensions have not been enabled */
|
|
65
|
+
function throwError(method) {
|
|
66
|
+
throw new Error("".concat(method, ": web3Enable(originName) needs to be called before ").concat(method));
|
|
67
|
+
}
|
|
68
|
+
/** @internal map from Array<InjectedAccount> to Array<InjectedAccountWithMeta> */
|
|
69
|
+
function mapAccounts(source, list, ss58Format) {
|
|
70
|
+
return list.map(function (_a) {
|
|
71
|
+
var address = _a.address, genesisHash = _a.genesisHash, name = _a.name, type = _a.type;
|
|
72
|
+
return ({
|
|
73
|
+
address: address.length === 42
|
|
74
|
+
? address
|
|
75
|
+
: encodeAddress(decodeAddress(address), ss58Format),
|
|
76
|
+
meta: { genesisHash: genesisHash, name: name, source: source },
|
|
77
|
+
type: type
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/** @internal filter accounts based on genesisHash and type of account */
|
|
82
|
+
function filterAccounts(list, genesisHash, type) {
|
|
83
|
+
return list.filter(function (a) {
|
|
84
|
+
return (!a.type || !type || type.includes(a.type)) &&
|
|
85
|
+
(!a.genesisHash || !genesisHash || a.genesisHash === genesisHash);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/** @internal retrieves all the extensions available on the window */
|
|
89
|
+
function getWindowExtensions(originName) {
|
|
90
|
+
return Promise
|
|
91
|
+
.all(Object
|
|
92
|
+
.entries(win.injectedWeb3)
|
|
93
|
+
.map(function (_a) {
|
|
94
|
+
var nameOrHash = _a[0], _b = _a[1], connect = _b.connect, enable = _b.enable, version = _b.version;
|
|
95
|
+
return Promise
|
|
96
|
+
.resolve()
|
|
97
|
+
.then(function () {
|
|
98
|
+
return connect
|
|
99
|
+
// new style, returning all info
|
|
100
|
+
? connect(originName)
|
|
101
|
+
: enable
|
|
102
|
+
// previous interface, leakages on name/version
|
|
103
|
+
? enable(originName).then(function (e) {
|
|
104
|
+
return objectSpread({ name: nameOrHash, version: version || 'unknown' }, e);
|
|
105
|
+
})
|
|
106
|
+
: Promise.reject(new Error('No connect(..) or enable(...) hook found'));
|
|
107
|
+
})
|
|
108
|
+
.catch(function (_a) {
|
|
109
|
+
var message = _a.message;
|
|
110
|
+
console.error("Error initializing ".concat(nameOrHash, ": ").concat(message));
|
|
111
|
+
});
|
|
112
|
+
}))
|
|
113
|
+
.then(function (exts) { return exts.filter(function (e) { return !!e; }); });
|
|
114
|
+
}
|
|
115
|
+
/** @internal Ensure the enable promise is resolved and filter by extensions */
|
|
116
|
+
function filterEnable(caller, extensions) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
+
var sources;
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
switch (_a.label) {
|
|
121
|
+
case 0:
|
|
122
|
+
if (!web3EnablePromise) {
|
|
123
|
+
return [2 /*return*/, throwError(caller)];
|
|
124
|
+
}
|
|
125
|
+
return [4 /*yield*/, web3EnablePromise];
|
|
126
|
+
case 1:
|
|
127
|
+
sources = _a.sent();
|
|
128
|
+
return [2 /*return*/, sources.filter(function (_a) {
|
|
129
|
+
var name = _a.name;
|
|
130
|
+
return !extensions ||
|
|
131
|
+
extensions.includes(name);
|
|
132
|
+
})];
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* @summary Enables all the providers found on the injected window interface
|
|
139
|
+
* @description
|
|
140
|
+
* Enables all injected extensions that has been found on the page. This
|
|
141
|
+
* should be called before making use of any other web3* functions.
|
|
142
|
+
*/
|
|
143
|
+
export function web3Enable(originName, compatInits) {
|
|
144
|
+
if (compatInits === void 0) { compatInits = []; }
|
|
145
|
+
if (!originName) {
|
|
146
|
+
throw new Error('You must pass a name for your app to the web3Enable function');
|
|
147
|
+
}
|
|
148
|
+
var initCompat = compatInits.length
|
|
149
|
+
? Promise.all(compatInits.map(function (c) { return c().catch(function () { return false; }); }))
|
|
150
|
+
: Promise.resolve([true]);
|
|
151
|
+
web3EnablePromise = documentReadyPromise(function () {
|
|
152
|
+
return initCompat.then(function () {
|
|
153
|
+
return getWindowExtensions(originName)
|
|
154
|
+
.then(function (values) {
|
|
155
|
+
return values.map(function (e) {
|
|
156
|
+
// if we don't have an accounts subscriber, add a single-shot version
|
|
157
|
+
if (!e.accounts.subscribe) {
|
|
158
|
+
e.accounts.subscribe = function (cb) {
|
|
159
|
+
e.accounts
|
|
160
|
+
.get()
|
|
161
|
+
.then(cb)
|
|
162
|
+
.catch(console.error);
|
|
163
|
+
return function () {
|
|
164
|
+
// no ubsubscribe needed, this is a single-shot
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
return e;
|
|
169
|
+
});
|
|
170
|
+
})
|
|
171
|
+
.catch(function () { return []; })
|
|
172
|
+
.then(function (values) {
|
|
173
|
+
var names = values.map(function (_a) {
|
|
174
|
+
var name = _a.name, version = _a.version;
|
|
175
|
+
return "".concat(name, "/").concat(version);
|
|
176
|
+
});
|
|
177
|
+
isWeb3Injected = web3IsInjected();
|
|
178
|
+
console.info("web3Enable: Enabled ".concat(values.length, " extension").concat(values.length !== 1 ? 's' : '', ": ").concat(names.join(', ')));
|
|
179
|
+
return values;
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
return web3EnablePromise;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* @summary Retrieves all the accounts across all providers
|
|
187
|
+
* @description
|
|
188
|
+
* This returns the full list of account available (across all extensions) to
|
|
189
|
+
* the page. Filtering options are available of a per-extension, per type and
|
|
190
|
+
* per-genesisHash basis. Optionally the accounts can be encoded with the provided
|
|
191
|
+
* ss58Format
|
|
192
|
+
*/
|
|
193
|
+
export function web3Accounts() {
|
|
194
|
+
return __awaiter(this, arguments, void 0, function (_a) {
|
|
195
|
+
var accounts, sources, retrieved;
|
|
196
|
+
var _this = this;
|
|
197
|
+
var _b = _a === void 0 ? {} : _a, accountType = _b.accountType, extensions = _b.extensions, genesisHash = _b.genesisHash, ss58Format = _b.ss58Format;
|
|
198
|
+
return __generator(this, function (_c) {
|
|
199
|
+
switch (_c.label) {
|
|
200
|
+
case 0:
|
|
201
|
+
accounts = [];
|
|
202
|
+
return [4 /*yield*/, filterEnable('web3Accounts', extensions)];
|
|
203
|
+
case 1:
|
|
204
|
+
sources = _c.sent();
|
|
205
|
+
return [4 /*yield*/, Promise.all(sources.map(function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
206
|
+
var list, _c;
|
|
207
|
+
var accounts = _b.accounts, source = _b.name;
|
|
208
|
+
return __generator(this, function (_d) {
|
|
209
|
+
switch (_d.label) {
|
|
210
|
+
case 0:
|
|
211
|
+
_d.trys.push([0, 2, , 3]);
|
|
212
|
+
return [4 /*yield*/, accounts.get()];
|
|
213
|
+
case 1:
|
|
214
|
+
list = _d.sent();
|
|
215
|
+
return [2 /*return*/, mapAccounts(source, filterAccounts(list, genesisHash, accountType), ss58Format)];
|
|
216
|
+
case 2:
|
|
217
|
+
_c = _d.sent();
|
|
218
|
+
// cannot handle this one
|
|
219
|
+
return [2 /*return*/, []];
|
|
220
|
+
case 3: return [2 /*return*/];
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}); }))];
|
|
224
|
+
case 2:
|
|
225
|
+
retrieved = _c.sent();
|
|
226
|
+
retrieved.forEach(function (result) {
|
|
227
|
+
accounts.push.apply(accounts, result);
|
|
228
|
+
});
|
|
229
|
+
console.info("web3Accounts: Found ".concat(accounts.length, " address").concat(accounts.length !== 1 ? 'es' : ''));
|
|
230
|
+
return [2 /*return*/, accounts];
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* @summary Subscribes to all the accounts across all providers
|
|
237
|
+
* @description
|
|
238
|
+
* This is the subscription version of the web3Accounts interface with
|
|
239
|
+
* updates as to when new accounts do become available. The list of filtering
|
|
240
|
+
* options are the same as for the web3Accounts interface.
|
|
241
|
+
*/
|
|
242
|
+
export function web3AccountsSubscribe(cb_1) {
|
|
243
|
+
return __awaiter(this, arguments, void 0, function (cb, _a) {
|
|
244
|
+
var sources, accounts, triggerUpdate, unsubs;
|
|
245
|
+
var _b = _a === void 0 ? {} : _a, accountType = _b.accountType, extensions = _b.extensions, genesisHash = _b.genesisHash, ss58Format = _b.ss58Format;
|
|
246
|
+
return __generator(this, function (_c) {
|
|
247
|
+
switch (_c.label) {
|
|
248
|
+
case 0: return [4 /*yield*/, filterEnable('web3AccountsSubscribe', extensions)];
|
|
249
|
+
case 1:
|
|
250
|
+
sources = _c.sent();
|
|
251
|
+
accounts = {};
|
|
252
|
+
triggerUpdate = function () {
|
|
253
|
+
return cb(Object
|
|
254
|
+
.entries(accounts)
|
|
255
|
+
.reduce(function (result, _a) {
|
|
256
|
+
var source = _a[0], list = _a[1];
|
|
257
|
+
result.push.apply(result, mapAccounts(source, filterAccounts(list, genesisHash, accountType), ss58Format));
|
|
258
|
+
return result;
|
|
259
|
+
}, []));
|
|
260
|
+
};
|
|
261
|
+
unsubs = sources.map(function (_a) {
|
|
262
|
+
var subscribe = _a.accounts.subscribe, source = _a.name;
|
|
263
|
+
return subscribe(function (result) {
|
|
264
|
+
accounts[source] = result;
|
|
265
|
+
try {
|
|
266
|
+
var result_1 = triggerUpdate();
|
|
267
|
+
if (result_1 && isPromise(result_1)) {
|
|
268
|
+
result_1.catch(console.error);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
catch (error) {
|
|
272
|
+
console.error(error);
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
return [2 /*return*/, function () {
|
|
277
|
+
unsubs.forEach(function (unsub) {
|
|
278
|
+
unsub();
|
|
279
|
+
});
|
|
280
|
+
}];
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* @summary Finds a specific provider based on the name
|
|
287
|
+
* @description
|
|
288
|
+
* This retrieves a specific source (extension) based on the name. In most
|
|
289
|
+
* cases it should not be needed to call it directly (e.g. it is used internally
|
|
290
|
+
* by calls such as web3FromAddress) but would allow operation on a specific
|
|
291
|
+
* known extension.
|
|
292
|
+
*/
|
|
293
|
+
export function web3FromSource(source) {
|
|
294
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
295
|
+
var sources, found;
|
|
296
|
+
return __generator(this, function (_a) {
|
|
297
|
+
switch (_a.label) {
|
|
298
|
+
case 0:
|
|
299
|
+
if (!web3EnablePromise) {
|
|
300
|
+
return [2 /*return*/, throwError('web3FromSource')];
|
|
301
|
+
}
|
|
302
|
+
return [4 /*yield*/, web3EnablePromise];
|
|
303
|
+
case 1:
|
|
304
|
+
sources = _a.sent();
|
|
305
|
+
found = source && sources.find(function (_a) {
|
|
306
|
+
var name = _a.name;
|
|
307
|
+
return name === source;
|
|
308
|
+
});
|
|
309
|
+
if (!found) {
|
|
310
|
+
throw new Error("web3FromSource: Unable to find an injected ".concat(source));
|
|
311
|
+
}
|
|
312
|
+
return [2 /*return*/, found];
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* @summary Find a specific provider that provides a specific address
|
|
319
|
+
* @description
|
|
320
|
+
* Based on an address, return the provider that has makes this address
|
|
321
|
+
* available to the page.
|
|
322
|
+
*/
|
|
323
|
+
export function web3FromAddress(address) {
|
|
324
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
325
|
+
var accounts, found, accountU8a_1;
|
|
326
|
+
return __generator(this, function (_a) {
|
|
327
|
+
switch (_a.label) {
|
|
328
|
+
case 0:
|
|
329
|
+
if (!web3EnablePromise) {
|
|
330
|
+
return [2 /*return*/, throwError('web3FromAddress')];
|
|
331
|
+
}
|
|
332
|
+
return [4 /*yield*/, web3Accounts()];
|
|
333
|
+
case 1:
|
|
334
|
+
accounts = _a.sent();
|
|
335
|
+
if (address) {
|
|
336
|
+
accountU8a_1 = decodeAddress(address);
|
|
337
|
+
found = accounts.find(function (account) { return u8aEq(decodeAddress(account.address), accountU8a_1); });
|
|
338
|
+
}
|
|
339
|
+
if (!found) {
|
|
340
|
+
throw new Error("web3FromAddress: Unable to find injected ".concat(address));
|
|
341
|
+
}
|
|
342
|
+
return [2 /*return*/, web3FromSource(found.meta.source)];
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* @summary List all providers exposed by one source
|
|
349
|
+
* @description
|
|
350
|
+
* For extensions that supply RPC providers, this call would return the list
|
|
351
|
+
* of RPC providers that any extension may supply.
|
|
352
|
+
*/
|
|
353
|
+
export function web3ListRpcProviders(source) {
|
|
354
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
355
|
+
var provider;
|
|
356
|
+
return __generator(this, function (_a) {
|
|
357
|
+
switch (_a.label) {
|
|
358
|
+
case 0: return [4 /*yield*/, web3FromSource(source)];
|
|
359
|
+
case 1:
|
|
360
|
+
provider = (_a.sent()).provider;
|
|
361
|
+
if (!provider) {
|
|
362
|
+
console.warn("Extension ".concat(source, " does not expose any provider"));
|
|
363
|
+
return [2 /*return*/, null];
|
|
364
|
+
}
|
|
365
|
+
return [2 /*return*/, provider.listProviders()];
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* @summary Start an RPC provider provider by a specific source
|
|
372
|
+
* @description
|
|
373
|
+
* For extensions that supply RPC providers, this call would return an
|
|
374
|
+
* enabled provider (initialized with the specific key) from the
|
|
375
|
+
* specified extension source.
|
|
376
|
+
*/
|
|
377
|
+
export function web3UseRpcProvider(source, key) {
|
|
378
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
379
|
+
var provider, meta;
|
|
380
|
+
return __generator(this, function (_a) {
|
|
381
|
+
switch (_a.label) {
|
|
382
|
+
case 0: return [4 /*yield*/, web3FromSource(source)];
|
|
383
|
+
case 1:
|
|
384
|
+
provider = (_a.sent()).provider;
|
|
385
|
+
if (!provider) {
|
|
386
|
+
throw new Error("Extension ".concat(source, " does not expose any provider"));
|
|
387
|
+
}
|
|
388
|
+
return [4 /*yield*/, provider.startProvider(key)];
|
|
389
|
+
case 2:
|
|
390
|
+
meta = _a.sent();
|
|
391
|
+
return [2 /*return*/, { meta: meta, provider: provider }];
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Copyright 2017-2025 @pezkuwi/extension-dapp authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// Do not edit, auto-generated by @pezkuwi/dev
|
|
4
|
+
// (packageInfo imports will be kept as-is, user-editable)
|
|
5
|
+
import { packageInfo as injectInfo } from '@pezkuwi/extension-inject/packageInfo';
|
|
6
|
+
import { detectPackage } from '@pezkuwi/util';
|
|
7
|
+
import { packageInfo } from './packageInfo.js';
|
|
8
|
+
detectPackage(packageInfo, null, [injectInfo]);
|
package/build/util.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright 2019-2025 @pezkuwi/extension-dapp authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export function documentReadyPromise(creator) {
|
|
4
|
+
return new Promise(function (resolve) {
|
|
5
|
+
if (document.readyState === 'complete') {
|
|
6
|
+
resolve(creator());
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
window.addEventListener('load', function () { return resolve(creator()); });
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { u8aIsWrapped, u8aUnwrapBytes, u8aWrapBytes } from '@
|
|
1
|
+
import { u8aIsWrapped, u8aUnwrapBytes, u8aWrapBytes } from '@pezkuwi/util';
|
|
2
2
|
export declare const ETHEREUM: Uint8Array<ArrayBufferLike>;
|
|
3
3
|
export declare const POSTFIX: Uint8Array<ArrayBufferLike>;
|
|
4
4
|
export declare const PREFIX: Uint8Array<ArrayBufferLike>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright 2019-2025 @pezkuwi/extension authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { U8A_WRAP_ETHEREUM, U8A_WRAP_POSTFIX, U8A_WRAP_PREFIX, u8aIsWrapped, u8aUnwrapBytes, u8aWrapBytes } from '@pezkuwi/util';
|
|
4
|
+
export var ETHEREUM = U8A_WRAP_ETHEREUM;
|
|
5
|
+
export var POSTFIX = U8A_WRAP_POSTFIX;
|
|
6
|
+
export var PREFIX = U8A_WRAP_PREFIX;
|
|
7
|
+
export var isWrapped = u8aIsWrapped;
|
|
8
|
+
export var unwrapBytes = u8aUnwrapBytes;
|
|
9
|
+
export var wrapBytes = u8aWrapBytes;
|
package/package.json
CHANGED
|
@@ -15,125 +15,20 @@
|
|
|
15
15
|
},
|
|
16
16
|
"sideEffects": [
|
|
17
17
|
"./packageDetect.js",
|
|
18
|
-
"./
|
|
18
|
+
"./packageDetect.cjs"
|
|
19
19
|
],
|
|
20
20
|
"type": "module",
|
|
21
|
-
"version": "0.62.
|
|
22
|
-
"main": "
|
|
23
|
-
"module": "./index.js",
|
|
24
|
-
"types": "./index.d.ts",
|
|
25
|
-
"exports": {
|
|
26
|
-
"./cjs/package.json": "./cjs/package.json",
|
|
27
|
-
"./cjs/*": "./cjs/*.js",
|
|
28
|
-
".": {
|
|
29
|
-
"module": {
|
|
30
|
-
"types": "./index.d.ts",
|
|
31
|
-
"default": "./index.js"
|
|
32
|
-
},
|
|
33
|
-
"require": {
|
|
34
|
-
"types": "./cjs/index.d.ts",
|
|
35
|
-
"default": "./cjs/index.js"
|
|
36
|
-
},
|
|
37
|
-
"default": {
|
|
38
|
-
"types": "./index.d.ts",
|
|
39
|
-
"default": "./index.js"
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
"./bundle": {
|
|
43
|
-
"module": {
|
|
44
|
-
"types": "./bundle.d.ts",
|
|
45
|
-
"default": "./bundle.js"
|
|
46
|
-
},
|
|
47
|
-
"require": {
|
|
48
|
-
"types": "./cjs/bundle.d.ts",
|
|
49
|
-
"default": "./cjs/bundle.js"
|
|
50
|
-
},
|
|
51
|
-
"default": {
|
|
52
|
-
"types": "./bundle.d.ts",
|
|
53
|
-
"default": "./bundle.js"
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
"./package.json": {
|
|
57
|
-
"require": "./cjs/package.json",
|
|
58
|
-
"default": "./package.json"
|
|
59
|
-
},
|
|
60
|
-
"./packageDetect": {
|
|
61
|
-
"module": {
|
|
62
|
-
"types": "./packageDetect.d.ts",
|
|
63
|
-
"default": "./packageDetect.js"
|
|
64
|
-
},
|
|
65
|
-
"require": {
|
|
66
|
-
"types": "./cjs/packageDetect.d.ts",
|
|
67
|
-
"default": "./cjs/packageDetect.js"
|
|
68
|
-
},
|
|
69
|
-
"default": {
|
|
70
|
-
"types": "./packageDetect.d.ts",
|
|
71
|
-
"default": "./packageDetect.js"
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
"./packageInfo.js": {
|
|
75
|
-
"module": {
|
|
76
|
-
"types": "./packageInfo.d.ts",
|
|
77
|
-
"default": "./packageInfo.js"
|
|
78
|
-
},
|
|
79
|
-
"require": {
|
|
80
|
-
"types": "./cjs/packageInfo.d.ts",
|
|
81
|
-
"default": "./cjs/packageInfo.js"
|
|
82
|
-
},
|
|
83
|
-
"default": {
|
|
84
|
-
"types": "./packageInfo.d.ts",
|
|
85
|
-
"default": "./packageInfo.js"
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
"./packageInfo": {
|
|
89
|
-
"module": {
|
|
90
|
-
"types": "./packageInfo.d.ts",
|
|
91
|
-
"default": "./packageInfo.js"
|
|
92
|
-
},
|
|
93
|
-
"require": {
|
|
94
|
-
"types": "./cjs/packageInfo.d.ts",
|
|
95
|
-
"default": "./cjs/packageInfo.js"
|
|
96
|
-
},
|
|
97
|
-
"default": {
|
|
98
|
-
"types": "./packageInfo.d.ts",
|
|
99
|
-
"default": "./packageInfo.js"
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
"./util": {
|
|
103
|
-
"module": {
|
|
104
|
-
"types": "./util.d.ts",
|
|
105
|
-
"default": "./util.js"
|
|
106
|
-
},
|
|
107
|
-
"require": {
|
|
108
|
-
"types": "./cjs/util.d.ts",
|
|
109
|
-
"default": "./cjs/util.js"
|
|
110
|
-
},
|
|
111
|
-
"default": {
|
|
112
|
-
"types": "./util.d.ts",
|
|
113
|
-
"default": "./util.js"
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
"./wrapBytes": {
|
|
117
|
-
"module": {
|
|
118
|
-
"types": "./wrapBytes.d.ts",
|
|
119
|
-
"default": "./wrapBytes.js"
|
|
120
|
-
},
|
|
121
|
-
"require": {
|
|
122
|
-
"types": "./cjs/wrapBytes.d.ts",
|
|
123
|
-
"default": "./cjs/wrapBytes.js"
|
|
124
|
-
},
|
|
125
|
-
"default": {
|
|
126
|
-
"types": "./wrapBytes.d.ts",
|
|
127
|
-
"default": "./wrapBytes.js"
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
},
|
|
21
|
+
"version": "0.62.8",
|
|
22
|
+
"main": "index.js",
|
|
131
23
|
"dependencies": {
|
|
132
|
-
"@pezkuwi/extension-inject": "0.62.
|
|
24
|
+
"@pezkuwi/extension-inject": "0.62.6",
|
|
133
25
|
"@pezkuwi/util": "^14.0.5",
|
|
134
26
|
"@pezkuwi/util-crypto": "^14.0.5",
|
|
135
27
|
"tslib": "^2.8.1"
|
|
136
28
|
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@pezkuwi/dev-test": "^0.84.3"
|
|
31
|
+
},
|
|
137
32
|
"peerDependencies": {
|
|
138
33
|
"@pezkuwi/api": "*",
|
|
139
34
|
"@pezkuwi/util": "*",
|