1
1
import { runtime } from 'webextension-polyfill' ;
2
- import {
3
- cip30 ,
4
- consumeRemoteApi ,
5
- MessengerDependencies ,
6
- runContentScriptMessageProxy
7
- } from '@cardano-sdk/web-extension' ;
2
+ import { consumeRemoteApi , MessengerDependencies , runContentScriptMessageProxy } from '@cardano-sdk/web-extension' ;
8
3
import { consumeRemoteAuthenticatorApi , consumeRemoteWalletApi } from './api-consumers' ;
9
- import { laceFeaturesApiProperties , LACE_FEATURES_CHANNEL } from './injectUtil' ;
4
+ import { LACE_FEATURES_CHANNEL , laceFeaturesApiProperties } from './injectUtil' ;
10
5
11
6
// Disable logging in production for performance & security measures
12
7
if ( process . env . USE_DAPP_CONNECTOR === 'true' ) {
13
8
console . info ( 'initializing content script' ) ;
14
9
15
- const initializeContentScript = (
16
- { injectedScriptSrc, walletName } : cip30 . InitializeContentScriptProps ,
17
- dependencies : MessengerDependencies
18
- ) => {
10
+ const initializeContentScript = ( walletName : string , dependencies : MessengerDependencies ) => {
19
11
const apis = [
20
12
consumeRemoteAuthenticatorApi ( { walletName } , dependencies ) ,
21
13
consumeRemoteWalletApi ( { walletName } , dependencies ) ,
@@ -27,19 +19,9 @@ if (process.env.USE_DAPP_CONNECTOR === 'true') {
27
19
dependencies
28
20
)
29
21
] ;
30
- const proxy = runContentScriptMessageProxy ( apis , dependencies . logger ) ;
31
22
32
- const script = document . createElement ( 'script' ) ;
33
- script . async = false ;
34
- script . src = injectedScriptSrc ;
35
- script . addEventListener ( 'load' , ( ) => script . remove ( ) ) ;
36
- ( document . head || document . documentElement ) . append ( script ) ;
37
-
38
- return proxy ;
23
+ return runContentScriptMessageProxy ( apis , dependencies . logger ) ;
39
24
} ;
40
25
41
- initializeContentScript (
42
- { injectedScriptSrc : runtime . getURL ( './js/inject.js' ) , walletName : process . env . WALLET_NAME } ,
43
- { logger : console , runtime }
44
- ) ;
26
+ initializeContentScript ( process . env . WALLET_NAME , { logger : console , runtime } ) ;
45
27
}
0 commit comments