Open wootzappcom opened 3 years ago
The injected javascript code will trap all website calls and communicate with react-native https://github.com/rsksmart/rwallet/blob/8da44a5a68b156c07a99f522668e8ead95e63582/src/pages/dapp/browser.js#L301-L314
this will go through the Webview's "onMessage" function https://github.com/rsksmart/rwallet/blob/8da44a5a68b156c07a99f522668e8ead95e63582/src/pages/dapp/browser.js#L723
here you can handle all types of events https://github.com/rsksmart/rwallet/blob/8da44a5a68b156c07a99f522668e8ead95e63582/src/pages/dapp/browser.js#L636-L705
you can show popup at any event. Generally, "eth_requestAccounts" is the first event that is called.
behavior should look like this
Connect webview and react-native
this looks like a nicer and cleaner way to connect webview and react-native.
https://github.com/TryImpossible/react-native-diy/blob/ef6314f82179d9c3130468a9b440684f808d6ff0/webviewInvoker/example/App.js#L48-L58 (the difference is how the injectjavascript happens after webview init. this is explanation of why https://github.com/hieuandree/tcom-react-native-webview/blob/b50aa2bbe9f978f0fa744429af2a3f0e4ae4d4cd/docs/Guide.md#the-injectjavascript-method)
this is the injectscript. this is the init part - https://github.com/TryImpossible/react-native-diy/blob/ef6314f82179d9c3130468a9b440684f808d6ff0/webviewInvoker/src/invoker.js#L96-L102
and this is the inject part https://github.com/TryImpossible/react-native-diy/blob/ef6314f82179d9c3130468a9b440684f808d6ff0/webviewInvoker/src/invoker.js#L103-L110
inject javascript - https://github.com/kardiachain/kardia-web3-mobile-provider/blob/81453735a271f8b4be12acd4530b9de601aaf1a0/index.js
this is our existing code - https://github.com/wootzapp/browser
HINTS
which file to inject? https://github.com/rsksmart/rwallet/blob/8da44a5a68b156c07a99f522668e8ead95e63582/src/pages/dapp/browser.js#L82-L107
This shows which file to inject and how to read the file
https://github.com/rsksmart/rwallet/blob/8da44a5a68b156c07a99f522668e8ead95e63582/src/pages/dapp/browser.js#L153
this file shows how to inject this javascript page into a DOM. this is done on injectedJavaScriptBeforeContentLoaded https://github.com/rsksmart/rwallet/blob/8da44a5a68b156c07a99f522668e8ead95e63582/src/pages/dapp/browser.js#L721
Testing criteria: