@subwallet/extension-inject 0.4.6-0 → 0.4.8-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.
- package/bundle.js +10 -2
- package/cjs/bundle.js +10 -2
- package/cjs/packageInfo.js +1 -1
- package/package.json +1 -1
- package/packageInfo.js +1 -1
- package/types.d.ts +3 -3
package/bundle.js
CHANGED
|
@@ -23,7 +23,15 @@ export function injectEvmExtension(evmProvider) {
|
|
|
23
23
|
// small helper with the typescript types, just cast window
|
|
24
24
|
const windowInject = window; // add our enable function
|
|
25
25
|
|
|
26
|
-
windowInject.
|
|
27
|
-
windowInject.dispatchEvent(new Event('subwallet#initialized')); //
|
|
26
|
+
windowInject.SubWallet = evmProvider;
|
|
27
|
+
windowInject.dispatchEvent(new Event('subwallet#initialized')); // Publish to global if window.ethereum is not available
|
|
28
|
+
|
|
29
|
+
windowInject.addEventListener('load', () => {
|
|
30
|
+
if (!windowInject.ethereum) {
|
|
31
|
+
windowInject.ethereum = evmProvider;
|
|
32
|
+
windowInject.dispatchEvent(new Event('ethereum#initialized'));
|
|
33
|
+
}
|
|
34
|
+
}); // Todo: Need more discuss to make SubWallet as global before window load because it can be conflict with MetaMask
|
|
35
|
+
// windowInject.ethereum = evmProvider;
|
|
28
36
|
// windowInject.dispatchEvent(new Event('ethereum#initialized'));
|
|
29
37
|
}
|
package/cjs/bundle.js
CHANGED
|
@@ -40,7 +40,15 @@ function injectEvmExtension(evmProvider) {
|
|
|
40
40
|
// small helper with the typescript types, just cast window
|
|
41
41
|
const windowInject = window; // add our enable function
|
|
42
42
|
|
|
43
|
-
windowInject.
|
|
44
|
-
windowInject.dispatchEvent(new Event('subwallet#initialized')); //
|
|
43
|
+
windowInject.SubWallet = evmProvider;
|
|
44
|
+
windowInject.dispatchEvent(new Event('subwallet#initialized')); // Publish to global if window.ethereum is not available
|
|
45
|
+
|
|
46
|
+
windowInject.addEventListener('load', () => {
|
|
47
|
+
if (!windowInject.ethereum) {
|
|
48
|
+
windowInject.ethereum = evmProvider;
|
|
49
|
+
windowInject.dispatchEvent(new Event('ethereum#initialized'));
|
|
50
|
+
}
|
|
51
|
+
}); // Todo: Need more discuss to make SubWallet as global before window load because it can be conflict with MetaMask
|
|
52
|
+
// windowInject.ethereum = evmProvider;
|
|
45
53
|
// windowInject.dispatchEvent(new Event('ethereum#initialized'));
|
|
46
54
|
}
|
package/cjs/packageInfo.js
CHANGED
package/package.json
CHANGED
package/packageInfo.js
CHANGED
|
@@ -5,5 +5,5 @@ export const packageInfo = {
|
|
|
5
5
|
name: '@subwallet/extension-inject',
|
|
6
6
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
7
7
|
type: 'esm',
|
|
8
|
-
version: '0.4.
|
|
8
|
+
version: '0.4.8-0'
|
|
9
9
|
};
|
package/types.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { Signer as InjectedSigner } from '@polkadot/api/types';
|
|
|
2
2
|
import type { ProviderInterface } from '@polkadot/rpc-provider/types';
|
|
3
3
|
import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
|
|
4
4
|
import type { KeypairType } from '@polkadot/util-crypto/types';
|
|
5
|
-
import { AbstractProvider } from 'web3-core';
|
|
6
5
|
declare type This = typeof globalThis;
|
|
7
6
|
export declare type Unsubcall = () => void;
|
|
8
7
|
export interface InjectedAccount {
|
|
@@ -73,7 +72,7 @@ export interface Injected {
|
|
|
73
72
|
provider?: InjectedProvider;
|
|
74
73
|
signer: InjectedSigner;
|
|
75
74
|
}
|
|
76
|
-
export interface EvmProvider
|
|
75
|
+
export interface EvmProvider {
|
|
77
76
|
isMetaMask: boolean;
|
|
78
77
|
isSubWallet: boolean;
|
|
79
78
|
version: string;
|
|
@@ -85,7 +84,8 @@ export interface InjectedWindowProvider {
|
|
|
85
84
|
}
|
|
86
85
|
export interface InjectedWindow extends This {
|
|
87
86
|
injectedWeb3: Record<string, InjectedWindowProvider>;
|
|
88
|
-
|
|
87
|
+
ethereum: EvmProvider;
|
|
88
|
+
SubWallet: EvmProvider;
|
|
89
89
|
}
|
|
90
90
|
export declare type InjectedExtension = InjectedExtensionInfo & Injected;
|
|
91
91
|
export declare type InjectOptions = InjectedExtensionInfo;
|