@pezkuwi/extension-dapp 0.62.14 → 0.62.16
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/cjs/packageInfo.js +1 -1
- package/package.json +5 -5
- package/packageInfo.js +1 -1
- package/bundle-pezkuwi-extension-dapp.js +0 -205
package/cjs/packageInfo.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.packageInfo = void 0;
|
|
4
|
-
exports.packageInfo = { name: '@pezkuwi/extension-dapp', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '0.62.
|
|
4
|
+
exports.packageInfo = { name: '@pezkuwi/extension-dapp', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '0.62.16' };
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"author": "
|
|
2
|
+
"author": "Kurdistan Tech Institute <dev@pezkuwichain.io> & PezkuwiChain Team <team@pezkuwichain.io>",
|
|
3
3
|
"bugs": "https://github.com/pezkuwichain/pezkuwi-extension/issues",
|
|
4
4
|
"description": "Provides an interfaces around the injected globals for ease of access by dapp developers.",
|
|
5
5
|
"engines": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"./cjs/packageDetect.js"
|
|
19
19
|
],
|
|
20
20
|
"type": "module",
|
|
21
|
-
"version": "0.62.
|
|
21
|
+
"version": "0.62.16",
|
|
22
22
|
"main": "./cjs/index.js",
|
|
23
23
|
"module": "./index.js",
|
|
24
24
|
"types": "./index.d.ts",
|
|
@@ -129,9 +129,9 @@
|
|
|
129
129
|
}
|
|
130
130
|
},
|
|
131
131
|
"dependencies": {
|
|
132
|
-
"@pezkuwi/extension-inject": "
|
|
133
|
-
"@pezkuwi/util": "^14.0.
|
|
134
|
-
"@pezkuwi/util-crypto": "^14.0.
|
|
132
|
+
"@pezkuwi/extension-inject": "^0.62.16",
|
|
133
|
+
"@pezkuwi/util": "^14.0.11",
|
|
134
|
+
"@pezkuwi/util-crypto": "^14.0.11",
|
|
135
135
|
"tslib": "^2.8.1"
|
|
136
136
|
},
|
|
137
137
|
"peerDependencies": {
|
package/packageInfo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const packageInfo = { name: '@pezkuwi/extension-dapp', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '0.62.
|
|
1
|
+
export const packageInfo = { name: '@pezkuwi/extension-dapp', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '0.62.16' };
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@pezkuwi/util'), require('@pezkuwi/util-crypto')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@pezkuwi/util', '@pezkuwi/util-crypto'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.pezkuwiExtensionDapp = {}, global.pezkuwiUtil, global.pezkuwiUtilCrypto));
|
|
5
|
-
})(this, (function (exports, util, utilCrypto) { 'use strict';
|
|
6
|
-
|
|
7
|
-
const global = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : window;
|
|
8
|
-
|
|
9
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
10
|
-
function documentReadyPromise(creator) {
|
|
11
|
-
return new Promise((resolve) => {
|
|
12
|
-
if (document.readyState === 'complete') {
|
|
13
|
-
resolve(creator());
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
window.addEventListener('load', () => resolve(creator()));
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const packageInfo = { name: '@pezkuwi/extension-dapp', path: (({ url: (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bundle-pezkuwi-extension-dapp.js', document.baseURI).href)) }) && (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bundle-pezkuwi-extension-dapp.js', document.baseURI).href))) ? new URL((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bundle-pezkuwi-extension-dapp.js', document.baseURI).href))).pathname.substring(0, new URL((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bundle-pezkuwi-extension-dapp.js', document.baseURI).href))).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '0.62.14' };
|
|
22
|
-
|
|
23
|
-
const unwrapBytes = util.u8aUnwrapBytes;
|
|
24
|
-
const wrapBytes = util.u8aWrapBytes;
|
|
25
|
-
|
|
26
|
-
const win = window;
|
|
27
|
-
win.injectedWeb3 = win.injectedWeb3 || {};
|
|
28
|
-
exports.isWeb3Injected = web3IsInjected();
|
|
29
|
-
exports.web3EnablePromise = null;
|
|
30
|
-
function web3IsInjected() {
|
|
31
|
-
return Object
|
|
32
|
-
.values(win.injectedWeb3)
|
|
33
|
-
.filter(({ connect, enable }) => !!(connect || enable))
|
|
34
|
-
.length !== 0;
|
|
35
|
-
}
|
|
36
|
-
function throwError(method) {
|
|
37
|
-
throw new Error(`${method}: web3Enable(originName) needs to be called before ${method}`);
|
|
38
|
-
}
|
|
39
|
-
function mapAccounts(source, list, ss58Format) {
|
|
40
|
-
return list.map(({ address, genesisHash, name, type }) => ({
|
|
41
|
-
address: address.length === 42
|
|
42
|
-
? address
|
|
43
|
-
: utilCrypto.encodeAddress(utilCrypto.decodeAddress(address), ss58Format),
|
|
44
|
-
meta: { genesisHash, name, source },
|
|
45
|
-
type
|
|
46
|
-
}));
|
|
47
|
-
}
|
|
48
|
-
function filterAccounts(list, genesisHash, type) {
|
|
49
|
-
return list.filter((a) => (!a.type || !type || type.includes(a.type)) &&
|
|
50
|
-
(!a.genesisHash || !genesisHash || a.genesisHash === genesisHash));
|
|
51
|
-
}
|
|
52
|
-
function getWindowExtensions(originName) {
|
|
53
|
-
return Promise
|
|
54
|
-
.all(Object
|
|
55
|
-
.entries(win.injectedWeb3)
|
|
56
|
-
.map(([nameOrHash, { connect, enable, version }]) => Promise
|
|
57
|
-
.resolve()
|
|
58
|
-
.then(() => connect
|
|
59
|
-
? connect(originName)
|
|
60
|
-
: enable
|
|
61
|
-
? enable(originName).then((e) => util.objectSpread({ name: nameOrHash, version: version || 'unknown' }, e))
|
|
62
|
-
: Promise.reject(new Error('No connect(..) or enable(...) hook found')))
|
|
63
|
-
.catch(({ message }) => {
|
|
64
|
-
console.error(`Error initializing ${nameOrHash}: ${message}`);
|
|
65
|
-
})))
|
|
66
|
-
.then((exts) => exts.filter((e) => !!e));
|
|
67
|
-
}
|
|
68
|
-
async function filterEnable(caller, extensions) {
|
|
69
|
-
if (!exports.web3EnablePromise) {
|
|
70
|
-
return throwError(caller);
|
|
71
|
-
}
|
|
72
|
-
const sources = await exports.web3EnablePromise;
|
|
73
|
-
return sources.filter(({ name }) => !extensions ||
|
|
74
|
-
extensions.includes(name));
|
|
75
|
-
}
|
|
76
|
-
function web3Enable(originName, compatInits = []) {
|
|
77
|
-
if (!originName) {
|
|
78
|
-
throw new Error('You must pass a name for your app to the web3Enable function');
|
|
79
|
-
}
|
|
80
|
-
const initCompat = compatInits.length
|
|
81
|
-
? Promise.all(compatInits.map((c) => c().catch(() => false)))
|
|
82
|
-
: Promise.resolve([true]);
|
|
83
|
-
exports.web3EnablePromise = documentReadyPromise(() => initCompat.then(() => getWindowExtensions(originName)
|
|
84
|
-
.then((values) => values.map((e) => {
|
|
85
|
-
if (!e.accounts.subscribe) {
|
|
86
|
-
e.accounts.subscribe = (cb) => {
|
|
87
|
-
e.accounts
|
|
88
|
-
.get()
|
|
89
|
-
.then(cb)
|
|
90
|
-
.catch(console.error);
|
|
91
|
-
return () => {
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
return e;
|
|
96
|
-
}))
|
|
97
|
-
.catch(() => [])
|
|
98
|
-
.then((values) => {
|
|
99
|
-
const names = values.map(({ name, version }) => `${name}/${version}`);
|
|
100
|
-
exports.isWeb3Injected = web3IsInjected();
|
|
101
|
-
console.info(`web3Enable: Enabled ${values.length} extension${values.length !== 1 ? 's' : ''}: ${names.join(', ')}`);
|
|
102
|
-
return values;
|
|
103
|
-
})));
|
|
104
|
-
return exports.web3EnablePromise;
|
|
105
|
-
}
|
|
106
|
-
async function web3Accounts({ accountType, extensions, genesisHash, ss58Format } = {}) {
|
|
107
|
-
const accounts = [];
|
|
108
|
-
const sources = await filterEnable('web3Accounts', extensions);
|
|
109
|
-
const retrieved = await Promise.all(sources.map(async ({ accounts, name: source }) => {
|
|
110
|
-
try {
|
|
111
|
-
const list = await accounts.get();
|
|
112
|
-
return mapAccounts(source, filterAccounts(list, genesisHash, accountType), ss58Format);
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
return [];
|
|
116
|
-
}
|
|
117
|
-
}));
|
|
118
|
-
retrieved.forEach((result) => {
|
|
119
|
-
accounts.push(...result);
|
|
120
|
-
});
|
|
121
|
-
console.info(`web3Accounts: Found ${accounts.length} address${accounts.length !== 1 ? 'es' : ''}`);
|
|
122
|
-
return accounts;
|
|
123
|
-
}
|
|
124
|
-
async function web3AccountsSubscribe(cb, { accountType, extensions, genesisHash, ss58Format } = {}) {
|
|
125
|
-
const sources = await filterEnable('web3AccountsSubscribe', extensions);
|
|
126
|
-
const accounts = {};
|
|
127
|
-
const triggerUpdate = () => cb(Object
|
|
128
|
-
.entries(accounts)
|
|
129
|
-
.reduce((result, [source, list]) => {
|
|
130
|
-
result.push(...mapAccounts(source, filterAccounts(list, genesisHash, accountType), ss58Format));
|
|
131
|
-
return result;
|
|
132
|
-
}, []));
|
|
133
|
-
const unsubs = sources.map(({ accounts: { subscribe }, name: source }) => subscribe((result) => {
|
|
134
|
-
accounts[source] = result;
|
|
135
|
-
try {
|
|
136
|
-
const result = triggerUpdate();
|
|
137
|
-
if (result && util.isPromise(result)) {
|
|
138
|
-
result.catch(console.error);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
catch (error) {
|
|
142
|
-
console.error(error);
|
|
143
|
-
}
|
|
144
|
-
}));
|
|
145
|
-
return () => {
|
|
146
|
-
unsubs.forEach((unsub) => {
|
|
147
|
-
unsub();
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
async function web3FromSource(source) {
|
|
152
|
-
if (!exports.web3EnablePromise) {
|
|
153
|
-
return throwError('web3FromSource');
|
|
154
|
-
}
|
|
155
|
-
const sources = await exports.web3EnablePromise;
|
|
156
|
-
const found = source && sources.find(({ name }) => name === source);
|
|
157
|
-
if (!found) {
|
|
158
|
-
throw new Error(`web3FromSource: Unable to find an injected ${source}`);
|
|
159
|
-
}
|
|
160
|
-
return found;
|
|
161
|
-
}
|
|
162
|
-
async function web3FromAddress(address) {
|
|
163
|
-
if (!exports.web3EnablePromise) {
|
|
164
|
-
return throwError('web3FromAddress');
|
|
165
|
-
}
|
|
166
|
-
const accounts = await web3Accounts();
|
|
167
|
-
let found;
|
|
168
|
-
if (address) {
|
|
169
|
-
const accountU8a = utilCrypto.decodeAddress(address);
|
|
170
|
-
found = accounts.find((account) => util.u8aEq(utilCrypto.decodeAddress(account.address), accountU8a));
|
|
171
|
-
}
|
|
172
|
-
if (!found) {
|
|
173
|
-
throw new Error(`web3FromAddress: Unable to find injected ${address}`);
|
|
174
|
-
}
|
|
175
|
-
return web3FromSource(found.meta.source);
|
|
176
|
-
}
|
|
177
|
-
async function web3ListRpcProviders(source) {
|
|
178
|
-
const { provider } = await web3FromSource(source);
|
|
179
|
-
if (!provider) {
|
|
180
|
-
console.warn(`Extension ${source} does not expose any provider`);
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
return provider.listProviders();
|
|
184
|
-
}
|
|
185
|
-
async function web3UseRpcProvider(source, key) {
|
|
186
|
-
const { provider } = await web3FromSource(source);
|
|
187
|
-
if (!provider) {
|
|
188
|
-
throw new Error(`Extension ${source} does not expose any provider`);
|
|
189
|
-
}
|
|
190
|
-
const meta = await provider.startProvider(key);
|
|
191
|
-
return { meta, provider };
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
exports.packageInfo = packageInfo;
|
|
195
|
-
exports.unwrapBytes = unwrapBytes;
|
|
196
|
-
exports.web3Accounts = web3Accounts;
|
|
197
|
-
exports.web3AccountsSubscribe = web3AccountsSubscribe;
|
|
198
|
-
exports.web3Enable = web3Enable;
|
|
199
|
-
exports.web3FromAddress = web3FromAddress;
|
|
200
|
-
exports.web3FromSource = web3FromSource;
|
|
201
|
-
exports.web3ListRpcProviders = web3ListRpcProviders;
|
|
202
|
-
exports.web3UseRpcProvider = web3UseRpcProvider;
|
|
203
|
-
exports.wrapBytes = wrapBytes;
|
|
204
|
-
|
|
205
|
-
}));
|