@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 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.subWalletEthereum = evmProvider;
27
- windowInject.dispatchEvent(new Event('subwallet#initialized')); // Todo: need more discuss to set it global and not conflict with MetaMask
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.subWalletEthereum = evmProvider;
44
- windowInject.dispatchEvent(new Event('subwallet#initialized')); // Todo: need more discuss to set it global and not conflict with MetaMask
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
  }
@@ -11,6 +11,6 @@ const packageInfo = {
11
11
  name: '@subwallet/extension-inject',
12
12
  path: typeof __dirname === 'string' ? __dirname : 'auto',
13
13
  type: 'cjs',
14
- version: '0.4.6-0'
14
+ version: '0.4.8-0'
15
15
  };
16
16
  exports.packageInfo = packageInfo;
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "sideEffects": true,
16
16
  "type": "module",
17
- "version": "0.4.6-0",
17
+ "version": "0.4.8-0",
18
18
  "main": "./cjs/index.js",
19
19
  "module": "./index.js",
20
20
  "types": "./index.d.ts",
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.6-0'
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 extends AbstractProvider {
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
- subWalletEthereum: EvmProvider;
87
+ ethereum: EvmProvider;
88
+ SubWallet: EvmProvider;
89
89
  }
90
90
  export declare type InjectedExtension = InjectedExtensionInfo & Injected;
91
91
  export declare type InjectOptions = InjectedExtensionInfo;