Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Potential fixes on Reown and Metmask #1274

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ public Web3AuthProvider(
Web3AuthWalletConfig config,
Web3Environment environment,
IChainConfig chainConfig,
IOperationTracker operationTracker)
: base(environment, chainConfig, operationTracker)
IOperationTracker operationTracker,
IOperatingSystemMediator operatingSystemMediator)
: base(environment, chainConfig, operationTracker, operatingSystemMediator)
{
this.operationTracker = operationTracker;
_config = config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class Web3AuthWebGLProvider : Web3AuthProvider
{
private readonly Web3AuthWalletConfig _config;

public Web3AuthWebGLProvider(Web3AuthWalletConfig config, Web3Environment environment, IChainConfig chainConfig, IOperationTracker operationTracker)
: base(config, environment, chainConfig, operationTracker)
public Web3AuthWebGLProvider(Web3AuthWalletConfig config, Web3Environment environment, IChainConfig chainConfig, IOperationTracker operationTracker, IOperatingSystemMediator operatingSystemMediator)
: base(config, environment, chainConfig, operationTracker, operatingSystemMediator)
{
_config = config;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
"rootNamespace": "",
"references": [
"GUID:5426c6b788696eb4c88f4198b59839eb",
"Unity.TextMeshPro"
"GUID:6055be8ebefd69e48b49212b09b47b2f"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"precompiledReferences": [
"Nethereum.Signer.dll"
],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class ReownWebGLProvider : WalletProvider, ILifecycleParticipant, IConnec

public ReownWebGLProvider(ReownHttpClient httpClient, IChainConfigSet chains, IReownConfig reownConfig,
ILogWriter logWriter, Web3Environment web3Environment, IChainManager chainManager,
IOperationTracker operationTracker) : base(web3Environment, chainManager.Current, operationTracker)
IOperationTracker operationTracker, IOperatingSystemMediator operatingSystemMediator) : base(web3Environment, chainManager.Current, operationTracker, operatingSystemMediator)
{
_httpClient = httpClient;
_chains = chains;
Expand Down
6 changes: 4 additions & 2 deletions src/ChainSafe.Gaming.HyperPlay/HyperPlayProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ public class HyperPlayProvider : WalletProvider
/// <param name="environment">Injected <see cref="environment"/>.</param>
/// <param name="chainConfig">ChainConfig to fetch chain data.</param>
/// <param name="operationTracker">Injected <see cref="IOperationTracker"/>.</param>
/// <param name="operatingSystemMediator">Injected <see cref="IOperatingSystemMediator"/>.</param>
public HyperPlayProvider(
IHyperPlayConfig config,
IHyperPlayData data,
ILocalStorage localStorage,
Web3Environment environment,
IChainConfig chainConfig,
IOperationTracker operationTracker)
: base(environment, chainConfig, operationTracker)
IOperationTracker operationTracker,
IOperatingSystemMediator operatingSystemMediator)
: base(environment, chainConfig, operationTracker, operatingSystemMediator)
{
this.config = config;
this.data = data;
Expand Down
114 changes: 55 additions & 59 deletions src/ChainSafe.Gaming.Reown/ReownProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ public ReownProvider(
Web3Environment environment,
ReownHttpClient reownHttpClient,
IOperationTracker operationTracker,
IRpcProvider rpcProvider)
: base(environment, chainConfig, operationTracker)
IRpcProvider rpcProvider,
IOperatingSystemMediator operatingSystemMediator)
: base(environment, chainConfig, operationTracker, operatingSystemMediator)
{
this.operationTracker = operationTracker;
this.rpcProvider = rpcProvider;
Expand Down Expand Up @@ -139,62 +140,61 @@ private async Task Initialize()

ReownLogger.Instance = new ReownLogWriter(logWriter, config);

using (operationTracker.TrackOperation("Initializing the Reown module..."))
{
var storage = await ReownStorageFactory.Build(environment);
var signClientOptions = new SignClientOptions
{
ProjectId = config.ProjectId,
Name = config.ProjectName,
Metadata = config.Metadata,
BaseContext = config.BaseContext,
Storage = storage,
KeyChain = new KeyChain(storage),
ConnectionBuilder = config.ConnectionBuilder,
RelayUrlBuilder = config.RelayUrlBuilder,
};

SignClient = await SignClient.Init(signClientOptions);
await SignClient.AddressProvider.LoadDefaultsAsync();
var storage = await ReownStorageFactory.Build(environment);
var signClientOptions = new SignClientOptions
{
ProjectId = config.ProjectId,
Name = config.ProjectName,
Metadata = config.Metadata,
BaseContext = config.BaseContext,
Storage = storage,
KeyChain = new KeyChain(storage),
ConnectionBuilder = config.ConnectionBuilder,
RelayUrlBuilder = config.RelayUrlBuilder,
};

SignClient = await SignClient.Init(signClientOptions);
await SignClient.AddressProvider.LoadDefaultsAsync();

if (config.OnRelayErrored is not null)
{
SignClient.CoreClient.Relayer.OnErrored += config.OnRelayErrored;
}

if (config.OnRelayErrored is not null)
var optionalNamespace =
new ProposedNamespace // todo using optional namespaces like AppKit does, should they be required?
{
SignClient.CoreClient.Relayer.OnErrored += config.OnRelayErrored;
}

var optionalNamespace =
new ProposedNamespace // todo using optional namespaces like AppKit does, should they be required?
Chains = chainConfigSet.Configs
.Select(chainEntry => chainEntry.ChainId)
.ToArray(),
Methods = new[]
{
Chains = chainConfigSet.Configs
.Select(chainEntry => chainEntry.ChainId)
.ToArray(),
Methods = new[]
{
"eth_sign",
"personal_sign",
"eth_signTypedData",
"eth_signTransaction",
"eth_sendTransaction",
"eth_chainId",
"eth_getTransactionByHash",
"wallet_switchEthereumChain",
"wallet_addEthereumChain",
"eth_blockNumber",
},
Events = new[]
{
"chainChanged",
"accountsChanged",
},
};

optionalNamespaces = new Dictionary<string, ProposedNamespace>
{
{ EvmNamespace, optionalNamespace },
"eth_sign",
"personal_sign",
"eth_signTypedData",
"eth_signTransaction",
"eth_sendTransaction",
"eth_chainId",
"eth_getTransactionByHash",
"wallet_switchEthereumChain",
"wallet_addEthereumChain",
"eth_blockNumber",
},
Events = new[]
{
"chainChanged",
"accountsChanged",
},
};

initialized = true;
}
optionalNamespaces = new Dictionary<string, ProposedNamespace>
{
{ EvmNamespace, optionalNamespace },
};

initialized = true;

}

protected override Task<string> GetWalletChainId()
Expand Down Expand Up @@ -314,13 +314,9 @@ private async Task<Session> ConnectSession()
{
ConnectedData connectedData;
IConnectionHandler connectionHandler;

using (operationTracker.TrackOperation("Initializing a new Reown session..."))
{
var connectOptions = new ConnectOptions { OptionalNamespaces = optionalNamespaces };
connectedData = await SignClient.Connect(connectOptions);
connectionHandler = await config.ConnectionHandlerProvider.ProvideHandler();
}
var connectOptions = new ConnectOptions { OptionalNamespaces = optionalNamespaces };
connectedData = await SignClient.Connect(connectOptions);
connectionHandler = await config.ConnectionHandlerProvider.ProvideHandler();

try
{
Expand Down
7 changes: 5 additions & 2 deletions src/ChainSafe.Gaming.Unity.MetaMask/MetaMaskProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ public class MetaMaskProvider : WalletProvider
/// <param name="environment">Injected <see cref="Web3Environment"/>.</param>
/// <param name="chainConfig">Injected <see cref="IChainConfig"/>.</param>
/// <param name="chainRegistryProvider">Injected <see cref="ChainRegistryProvider"/>.</param>
/// <param name="operationTracker">Injected <see cref="IOperationTracker"/>.</param>
/// <param name="operatingSystemMediator">Injected <see cref="IOperatingSystemMediator"/></param>
public MetaMaskProvider(
Web3Environment environment,
IChainConfig chainConfig,
ChainRegistryProvider chainRegistryProvider,
IOperationTracker operationTracker)
: base(environment, chainConfig, operationTracker)
IOperationTracker operationTracker,
IOperatingSystemMediator operatingSystemMediator)
: base(environment, chainConfig, operationTracker, operatingSystemMediator)
{
logWriter = environment.LogWriter;
this.chainConfig = chainConfig;
Expand Down
Loading