-
Notifications
You must be signed in to change notification settings - Fork 243
Web3Auth WebGL Window Popup #1037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
48c6326
Web3Auth no modal works in webGL!!!!
kantagara 4e34db4
Reverted Countly
kantagara ce32638
Cleaning some stuff up.
kantagara f5d72cd
Trying to inject scripts dynamically
kantagara 6af9833
Injecting necessary scripts trough jspre. Cleaning up the code.
kantagara b5d6401
Removed unnecessary debug log
kantagara b01e7cd
Merge branch 'dev' into nikola/web3auth-webglmodal
kantagara 7794e80
Merge fix
kantagara f9caf7a
Merge branch 'dev' into nikola/web3auth-webglmodal
kantagara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
Packages/io.chainsafe.web3-unity.web3auth/Runtime/Plugins/Web3AuthInjectScripts.jspre
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // custom.jspre | ||
|
|
||
| Module.InjectExternalScripts = function() { | ||
| const scripts = [ | ||
| "https://cdn.jsdelivr.net/npm/@web3auth/no-modal", | ||
| "https://cdn.jsdelivr.net/npm/@web3auth/wallet-services-plugin", | ||
| "https://cdn.jsdelivr.net/npm/@web3auth/openlogin-adapter", | ||
| "https://cdn.jsdelivr.net/npm/@web3auth/ethereum-provider" | ||
| ]; | ||
|
|
||
| scripts.forEach(src => { | ||
| const script = document.createElement('script'); | ||
| script.src = src; | ||
| document.body.appendChild(script); | ||
| }); | ||
| }; | ||
|
|
||
| // Automatically call the function to inject the scripts | ||
| Module['onRuntimeInitialized'] = function() { | ||
| Module.InjectExternalScripts(); | ||
| }; |
11 changes: 5 additions & 6 deletions
11
...ProcessTransactionExecutor.Unity.dll.meta → .../Plugins/Web3AuthInjectScripts.jspre.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
Packages/io.chainsafe.web3-unity.web3auth/Runtime/Plugins/Web3AuthWebGLModal.jslib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| var Web3AuthWebGLNoModal = { | ||
| $Web3AuthWebGLNoModal : {}, | ||
|
|
||
| SetLoginCallback: function (login) { | ||
| Web3AuthWebGLNoModal.loginCallback = function(sessionId){ | ||
| var returnStr = sessionId; | ||
| var bufferSize = lengthBytesUTF8(returnStr) + 1; | ||
| var buffer = _malloc(bufferSize); | ||
| stringToUTF8(returnStr, buffer, bufferSize); | ||
| Module.dynCall_vi(login, [buffer]); | ||
| }; | ||
| }, | ||
| InitWeb3Auth: function (clientId, chainId, rpcTarget, displayName, blockExplorerUrl, ticker, tickerName, network) { | ||
| window.web3auth = null; | ||
| window.walletServicesPlugin = null; | ||
|
|
||
|
|
||
|
|
||
| (async function init() { | ||
| try { | ||
|
|
||
| console.log("Initializing Web3Auth..."); | ||
|
|
||
| const chainConfig = { | ||
| chainNamespace: "eip155", | ||
| chainId: UTF8ToString(chainId), | ||
| rpcTarget: UTF8ToString(rpcTarget), | ||
| displayName: UTF8ToString(displayName), | ||
| blockExplorerUrl: UTF8ToString(blockExplorerUrl), | ||
| ticker: UTF8ToString(ticker), | ||
| tickerName: UTF8ToString(tickerName), | ||
| }; | ||
|
|
||
| const privateKeyProvider = new window.EthereumProvider.EthereumPrivateKeyProvider({ config: { chainConfig } }); | ||
| window.web3auth = new window.NoModal.Web3AuthNoModal({ | ||
| clientId: UTF8ToString(clientId), | ||
| privateKeyProvider, | ||
| web3AuthNetwork: UTF8ToString(network), | ||
| }); | ||
|
|
||
| window.web3auth.on("connected", (data) => { | ||
| const openLoginStore = localStorage.getItem("openlogin_store"); | ||
| const openLoginStoreObj = openLoginStore ? JSON.parse(openLoginStore) : null; | ||
| if (openLoginStoreObj && openLoginStoreObj.sessionId) { | ||
| const sessionId = openLoginStoreObj.sessionId; | ||
| Web3AuthWebGLNoModal.loginCallback(sessionId); | ||
| } else { | ||
| console.log("No session ID found in localStorage."); | ||
| } | ||
| }); | ||
|
|
||
| const openloginAdapter = new window.OpenloginAdapter.OpenloginAdapter(); | ||
| window.web3auth.configureAdapter(openloginAdapter); | ||
|
|
||
| await window.web3auth.init(); | ||
| console.log("Web3Auth Initialized Successfully!"); | ||
| } catch (error) { | ||
| console.error("Error during Web3Auth initialization:", error); | ||
| } | ||
| })(); | ||
| }, | ||
|
|
||
| Web3AuthLogin: async function (provider, rememberMe) { | ||
| try { | ||
| await window.web3auth.connectTo("openlogin", { | ||
| loginProvider: UTF8ToString(provider) | ||
| }); | ||
| if (!rememberMe){ | ||
| localStorage.removeItem("openlogin_store"); | ||
| } | ||
| } catch (error) { | ||
| console.log(error.message); | ||
| } | ||
| }, | ||
| }; | ||
|
|
||
| autoAddDeps(Web3AuthWebGLNoModal, '$Web3AuthWebGLNoModal'); | ||
| mergeInto(LibraryManager.library,Web3AuthWebGLNoModal); |
32 changes: 32 additions & 0 deletions
32
Packages/io.chainsafe.web3-unity.web3auth/Runtime/Plugins/Web3AuthWebGLModal.jslib.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 0 additions & 92 deletions
92
Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.MetaMask.dll.meta
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
Packages/io.chainsafe.web3-unity/Runtime/Scripts/CountlyAnalytics.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sneaked this one in, forgot we didn't have analytics in Ramp and Jay needed it 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noice