Skip to content
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

AppKit is now part of the core solution #1259

Merged
merged 44 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
9bd8f5c
Everything is broken
kantagara Dec 9, 2024
d0dda2a
Added AppKit directly inside of our package.
kantagara Dec 10, 2024
7253ed7
Merge branch 'dev' into nikola/appkit-implementation-1210
kantagara Dec 10, 2024
fe9281c
Merges from dev
kantagara Dec 10, 2024
2c2efa0
Small tweaks
kantagara Dec 10, 2024
febbb7e
Starting the process of creation of the app kit package
kantagara Dec 11, 2024
4267b2f
REsuming the work
kantagara Dec 11, 2024
0d03c4e
Package successfully created!
kantagara Dec 12, 2024
de35fce
Upgraded our Reown in core project to the newer version
kantagara Dec 12, 2024
92c10cd
Removed AppKit, made it part of the core package! Yay!
kantagara Dec 12, 2024
e15a222
Cleaning things up.
kantagara Dec 12, 2024
ca0ef84
Fixing bugs!
kantagara Dec 12, 2024
37c010b
Adding debug log
kantagara Dec 12, 2024
2c0a4d6
Added loader package.
kantagara Dec 12, 2024
e2c7ce9
Added newget dependency
kantagara Dec 12, 2024
aa313c8
More testing
kantagara Dec 12, 2024
89122bd
Hmm
kantagara Dec 12, 2024
f9d605a
MOre
kantagara Dec 12, 2024
eae619a
Final test!
kantagara Dec 12, 2024
13ec809
dont remove the loader one
kantagara Dec 12, 2024
9ea1121
Fix
kantagara Dec 12, 2024
06eda18
Fixing import bugs
kantagara Dec 13, 2024
dd86f48
Removing anything related to the new input system because it can caus…
kantagara Dec 13, 2024
c064f59
Removing metamask provider
kantagara Dec 13, 2024
79b5aa7
moved the playerprefs check to the constructor, if the user wants to …
kantagara Dec 13, 2024
d5b9c80
Fixing compiler errors
kantagara Dec 13, 2024
f02c3f5
Merge branch 'dev' into nikola/appkit-implementation-1210
kantagara Dec 13, 2024
7798a4c
Run setup.sh
kantagara Dec 13, 2024
f03a42e
Fixing All the PR suggestions
kantagara Dec 16, 2024
8d4eda4
Fixing signmessage bug.
kantagara Dec 16, 2024
8346157
More descriptive names for classes.
kantagara Dec 16, 2024
d4cd87c
Fixing error Juan got.
kantagara Dec 16, 2024
2348664
Reverted this since we're already in editor
kantagara Dec 16, 2024
a306524
Prebuild process for webgl.
kantagara Dec 16, 2024
30d94fb
Fixing compiler errors with non-webgl platforms
kantagara Dec 16, 2024
437db49
Fixing build errors finally.
kantagara Dec 16, 2024
a239e9d
Fixing the switch network bug.
kantagara Dec 16, 2024
91b1f88
Addressing Oleks comments, fixing web3 unity prefab
kantagara Dec 17, 2024
5d2c3f3
Updated appkit to 1.2.0
kantagara Jan 8, 2025
15c761b
Merge remote-tracking branch 'origin/dev' into nikola/appkit-implemen…
kantagara Jan 14, 2025
8ab4fd7
Merge branch 'dev' into nikola/appkit-implementation-1210
kantagara Jan 16, 2025
90e6523
Fixing errors.
kantagara Jan 16, 2025
ac5ca60
Merge branch 'dev' into nikola/appkit-implementation-1210
kantagara Jan 16, 2025
c555c11
Fixing Merge Conflicts
kantagara Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#if UNITY_WEBGL
using ChainSafe.Gaming.UnityPackage.Connection;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;

namespace ChainSafe.Gaming.Editor.Reown
{
public class ReownWebGLPreBuild : IPreprocessBuildWithReport
{
public int callbackOrder { get; }

public void OnPreprocessBuild(BuildReport report)
{
// Use AssetDatabase to load the TextAsset from Editor/Resources
string assetPath = "Packages/io.chainsafe.web3-unity/Editor/Resources/ViemChain.txt";
TextAsset file = AssetDatabase.LoadAssetAtPath<TextAsset>(assetPath);

if (file != null)
{
Debug.Log($"Loaded ViemChain.txt: {file.text}");
// Call your custom method
ReownConnectionProvider provider = Resources.Load<ReownConnectionProvider>("ReownConnectionProvider");
provider.PopulateViemNames(file.text, true);
}
else
{
Debug.LogError($"Could not load ViemChain.txt from path: {assetPath}");
}
}

}
}
#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class ReownConnectionProvider : ConnectionProvider, IReownConfig, IConnec
public WalletLocationOption WalletLocationOption { get; private set; } = WalletLocationOption.LocalAndRemote;

[field:SerializeField]
[Tooltip("")]
public ViemNameChainId[] ChainIdAndViemNameArray { get; private set; }

[field: SerializeField]
Expand All @@ -73,10 +72,7 @@ public class ReownConnectionProvider : ConnectionProvider, IReownConfig, IConnec
public string SignTypedMessageRpcMethodName => "eth_signTypedData";
public override bool IsAvailable => true;

//We need to serialize this bad boy.
[SerializeField, HideInInspector] private ViemNameChainId[] allChainIdsAndViemNames;

public IConnectionBuilder ConnectionBuilder
public IConnectionBuilder ConnectionBuilder
{
get
{
Expand Down Expand Up @@ -108,7 +104,7 @@ public IConnectionBuilder ConnectionBuilder
}

#if UNITY_EDITOR
private void OnValidate()
public void OnValidate()
{
if (!connectionScreenPrefabs.LandscapePrefab && !connectionScreenPrefabs.PortraitPrefab)
{
Expand All @@ -118,16 +114,19 @@ private void OnValidate()


#if UNITY_WEBGL
if(allChainIdsAndViemNames == null || allChainIdsAndViemNames.Length == 0)
allChainIdsAndViemNames = JsonConvert.DeserializeObject<ViemNameChainId[]>(Resources.Load<TextAsset>("ViemChain").text);

if (ChainIdAndViemNameArray == null || ChainIdAndViemNameArray.Length == 0)
PopulateViemNames(Resources.Load<TextAsset>("ViemChain").text);
#endif
}

public void PopulateViemNames(string text, bool force = false)
{
var projectConfig = ProjectConfigUtilities.Load();
if (force || ChainIdAndViemNameArray == null || projectConfig.ChainConfigs.Count != ChainIdAndViemNameArray.Length)
{
var projectConfig = ProjectConfigUtilities.Load();
var allChainIdsAndViemNames = JsonConvert.DeserializeObject<ViemNameChainId[]>(text);
var dict = projectConfig.ChainConfigs.ToDictionary(x => x.ChainId, x => x);
ChainIdAndViemNameArray = allChainIdsAndViemNames.Where(x => dict.ContainsKey(x.ChainId)).ToArray();
}
#endif
}
#endif

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using ChainSafe.Gaming.Evm.Signers;
#if UNITY_WEBGL && !UNITY_EDITOR
using ChainSafe.Gaming.Web3.Build;
using ChainSafe.Gaming.Web3.Core;
using ChainSafe.Gaming.Web3.Core.Evm;
using ChainSafe.Gaming.Web3.Core.Logout;
using ChainSafe.Gaming.Web3.Evm.Wallet;
using Microsoft.Extensions.DependencyInjection;

Expand All @@ -24,4 +22,5 @@ public static IWeb3ServiceCollection UseAppKit(


}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public ValueTask WillStopAsync()
{
W3AppKit.AccountConnected -= AppKitAccountConnected;
W3AppKit.ModalController.OpenStateChanged -= OpenStateChanged;
W3AppKit.ModalController.OpenStateChanged -= OpenStateChanged;
return new ValueTask();
}

Expand All @@ -115,12 +116,20 @@ public override async Task<string> Connect()
{
await Initialize();
W3AppKit.AccountConnected += AppKitAccountConnected;
W3AppKit.NetworkController.ChainChanged += NetworkControllerOnChainChanged;
W3AppKit.ModalController.OpenStateChanged += OpenStateChanged;
W3AppKit.OpenModal();
var result = await _accountConnected.Task;
return result;
}

private void NetworkControllerOnChainChanged(object sender, NetworkController.ChainChangedEventArgs e)
{
Debug.Log("Chain changed");
kantagara marked this conversation as resolved.
Show resolved Hide resolved

W3AppKit.CloseModal();
}

private async void OpenStateChanged(object sender, ModalOpenStateChangedEventArgs e)
{
await Task.Delay(200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,28 @@ MonoBehaviour:
includeWalletIds: []
excludeWalletIds: []
<ProjectId>k__BackingField: f4bff60eb260841f46b1c77588cd8acb
<ProjectName>k__BackingField: Web3.Unity
<ProjectName>k__BackingField: Web3.unity
<AutoRenewSession>k__BackingField: 1
<BaseContext>k__BackingField: unity-game
<Metadata>k__BackingField:
Description: web3.unity is an open-source gaming SDK.
Icons:
- https://docs.gaming.chainsafe.io/img/logo.png
Name: Web3.Unity
Description: Web3.Unity SDK is an open source SDK that connects unity games to
the blockchain
Icons: []
Name: Web3.Unity SDK
Redirect:
Native:
Universal:
Url: https://chainsafe.io/
Url: https://chainsafe.io
VerifyUrl:
<OverrideRegistryUri>k__BackingField:
<LogLevel>k__BackingField: 1
<WalletLocationOption>k__BackingField: 0
<ChainIdAndViemNameArray>k__BackingField:
- <ChainId>k__BackingField: 1993
<ViewName>k__BackingField: b3Sepolia
- <ChainId>k__BackingField: 11155420
<ViewName>k__BackingField: optimismSepolia
- <ChainId>k__BackingField: 11155111
<ViewName>k__BackingField: sepolia
<ButtonIcon>k__BackingField: {fileID: 21300000, guid: 9af22e71d3035844ca8ae6e9f2a538f5, type: 3}
<ButtonText>k__BackingField: Reown
Original file line number Diff line number Diff line change
Expand Up @@ -1034,11 +1034,11 @@ PrefabInstance:
- target: {fileID: 5008553068369276269, guid: 6d183a51c0030794a8ff3fea5dbd6423, type: 3}
propertyPath: providers.Array.data[1]
value:
objectReference: {fileID: 11400000, guid: cad6fa48701480044a2a6f2d9c9dae1e, type: 2}
objectReference: {fileID: 0}
- target: {fileID: 5008553068369276269, guid: 6d183a51c0030794a8ff3fea5dbd6423, type: 3}
propertyPath: providers.Array.data[2]
value:
objectReference: {fileID: 11400000, guid: cad6fa48701480044a2a6f2d9c9dae1e, type: 2}
objectReference: {fileID: 0}
- target: {fileID: 8519303782652390544, guid: 6d183a51c0030794a8ff3fea5dbd6423, type: 3}
propertyPath: m_LocalPosition.x
value: 0
Expand Down