Skip to content

Commit

Permalink
Potential fixes for iOS and Android
Browse files Browse the repository at this point in the history
  • Loading branch information
kantagara committed Jan 18, 2025
1 parent 9466b3a commit ef5fef1
Show file tree
Hide file tree
Showing 21 changed files with 21 additions and 18 deletions.
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

25 changes: 21 additions & 4 deletions src/ChainSafe.Gaming/Web3/Evm/Wallet/WalletProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ namespace ChainSafe.Gaming.Web3.Evm.Wallet
private readonly ILogWriter logWriter;
private readonly IChainConfig chainConfig;
private readonly IOperationTracker operationTracker;
private readonly IOperatingSystemMediator operatingSystemMediator;

/// <summary>
/// Initializes a new instance of the <see cref="WalletProvider"/> class.
/// </summary>
/// <param name="environment">Injected <see cref="Web3Environment"/>.</param>
/// <param name="chainConfig">Injected <see cref="chainConfig"/>.</param>
/// <param name="operationTracker">Injected <see cref="IOperationTracker"/>.</param>
protected WalletProvider(Web3Environment environment, IChainConfig chainConfig, IOperationTracker operationTracker)
/// <param name="operatingSystemMediator">Injected <see cref="IOperatingSystemMediator"/>.</param>
protected WalletProvider(Web3Environment environment, IChainConfig chainConfig, IOperationTracker operationTracker, IOperatingSystemMediator operatingSystemMediator)
: base(environment, chainConfig)
{
this.operationTracker = operationTracker;
this.operatingSystemMediator = operatingSystemMediator;
this.chainConfig = chainConfig;
this.logWriter = environment.LogWriter;
}
Expand Down Expand Up @@ -105,14 +108,28 @@ public virtual async Task SwitchChainAddIfMissing(IChainConfig config = null)
{
try
{
// this will switch to the network and add it to the wallet if it's missing
await Task.Run(() => Request<object[]>("wallet_addEthereumChain", addChainParameter));
if (operatingSystemMediator.IsMobilePlatform)
{
await Task.Run(() => Request<object[]>("wallet_addEthereumChain", addChainParameter));
}
else
{
await Request<object[]>("wallet_addEthereumChain", addChainParameter);
}
}
catch (Exception ex)
{
if (ex.Message.Contains("May not specify default MetaMask chain", StringComparison.InvariantCultureIgnoreCase))
{
await SwitchToDefaultMetaMaskChain();
if (operatingSystemMediator.IsMobilePlatform)
{
await Task.Run(SwitchToDefaultMetaMaskChain);
}
else
{
await SwitchToDefaultMetaMaskChain();
}

return;
}

Expand Down
7 changes: 0 additions & 7 deletions src/UnitySampleProject/Assets/csc.rsp.meta

This file was deleted.

0 comments on commit ef5fef1

Please # to comment.