@subwallet/extension-inject 0.4.4-0 → 0.4.6-1

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.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  import type { Injected, InjectOptions } from './types';
2
+ import { EvmProvider } from './types';
2
3
  export { packageInfo } from './packageInfo';
3
4
  export declare function injectExtension(enable: (origin: string) => Promise<Injected>, { name, version }: InjectOptions): void;
5
+ export declare function injectEvmExtension(evmProvider: EvmProvider): void;
package/bundle.js CHANGED
@@ -17,4 +17,13 @@ export function injectExtension(enable, {
17
17
  enable: origin => enable(origin),
18
18
  version
19
19
  };
20
+ } // Inject EVM Provider
21
+
22
+ export function injectEvmExtension(evmProvider) {
23
+ // small helper with the typescript types, just cast window
24
+ const windowInject = window; // add our enable function
25
+
26
+ windowInject.SubWallet = evmProvider;
27
+ windowInject.dispatchEvent(new Event('subwallet#initialized')); // Todo: need more discuss to set it global and not conflict with MetaMask
28
+ // windowInject.dispatchEvent(new Event('ethereum#initialized'));
20
29
  }
package/cjs/bundle.js CHANGED
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.injectEvmExtension = injectEvmExtension;
6
7
  exports.injectExtension = injectExtension;
7
8
  Object.defineProperty(exports, "packageInfo", {
8
9
  enumerable: true,
@@ -32,4 +33,14 @@ function injectExtension(enable, _ref) {
32
33
  enable: origin => enable(origin),
33
34
  version
34
35
  };
36
+ } // Inject EVM Provider
37
+
38
+
39
+ function injectEvmExtension(evmProvider) {
40
+ // small helper with the typescript types, just cast window
41
+ const windowInject = window; // add our enable function
42
+
43
+ windowInject.SubWallet = evmProvider;
44
+ windowInject.dispatchEvent(new Event('subwallet#initialized')); // Todo: need more discuss to set it global and not conflict with MetaMask
45
+ // windowInject.dispatchEvent(new Event('ethereum#initialized'));
35
46
  }
@@ -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.4-0'
14
+ version: '0.4.6-1'
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.4-0",
17
+ "version": "0.4.6-1",
18
18
  "main": "./cjs/index.js",
19
19
  "module": "./index.js",
20
20
  "types": "./index.d.ts",
@@ -74,7 +74,8 @@
74
74
  "@polkadot/types": "^7.3.1",
75
75
  "@polkadot/util": "^8.3.1",
76
76
  "@polkadot/util-crypto": "^8.3.1",
77
- "@polkadot/x-global": "^8.3.1"
77
+ "@polkadot/x-global": "^8.3.1",
78
+ "web3-core": "^1.7.3"
78
79
  },
79
80
  "peerDependencies": {
80
81
  "@polkadot/api": "*"
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.4-0'
8
+ version: '0.4.6-1'
9
9
  };
package/types.d.ts CHANGED
@@ -2,6 +2,7 @@ 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';
5
6
  declare type This = typeof globalThis;
6
7
  export declare type Unsubcall = () => void;
7
8
  export interface InjectedAccount {
@@ -72,12 +73,19 @@ export interface Injected {
72
73
  provider?: InjectedProvider;
73
74
  signer: InjectedSigner;
74
75
  }
76
+ export interface EvmProvider extends AbstractProvider {
77
+ isMetaMask: boolean;
78
+ isSubWallet: boolean;
79
+ version: string;
80
+ isConnected(): boolean;
81
+ }
75
82
  export interface InjectedWindowProvider {
76
83
  enable: (origin: string) => Promise<Injected>;
77
84
  version: string;
78
85
  }
79
86
  export interface InjectedWindow extends This {
80
87
  injectedWeb3: Record<string, InjectedWindowProvider>;
88
+ SubWallet: EvmProvider;
81
89
  }
82
90
  export declare type InjectedExtension = InjectedExtensionInfo & Injected;
83
91
  export declare type InjectOptions = InjectedExtensionInfo;