Skip to content

Commit

Permalink
Merge pull request #82 from ChainSafe/version-update
Browse files Browse the repository at this point in the history
2.5.3 updates
  • Loading branch information
nftpixels authored Nov 22, 2023
2 parents 1078b63 + 7e951d9 commit cf94512
Show file tree
Hide file tree
Showing 15 changed files with 130 additions and 218 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: /current/interacting-with-smart-contracts
sidebar_position: 11
sidebar_position: 10
sidebar_label: Interacting With Smart Contracts
---

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: /current/web2-like-authentication-using-web3auth
sidebar_position: 12
sidebar_position: 11
sidebar_label: Web2-Like Authentication Using Web3Auth
---

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: /current/gasless-transactions-using-Gelato
sidebar_position: 13
sidebar_position: 12
sidebar_label: Gasless Transactions Using Gelato
---

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: /current/extending-the-sdk
sidebar_position: 14
sidebar_position: 13
sidebar_label: Extending The SDK
---

Expand Down
2 changes: 1 addition & 1 deletion docs/v2.5/15_lootboxes.md → docs/v2.5/14_lootboxes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: /current/lootboxes
sidebar_position: 15
sidebar_position: 14
sidebar_label: Lootboxes
---

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: /current/block-racers-game
sidebar_position: 16
sidebar_position: 15
sidebar_label: Block Racers Game
---

Expand Down
2 changes: 1 addition & 1 deletion docs/v2.5/17_faq.md → docs/v2.5/16_faq.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: /current/faq
sidebar_position: 17
sidebar_position: 16
sidebar_label: FAQ
---

Expand Down
3 changes: 3 additions & 0 deletions docs/v2.5/1_getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ This page will walk you through the process of setting up a project ID and using
![](v2Assets/openupmInstall.png)
5. Packages will be installed and the SDK will be available to you.

### Updating via The Package Manager
Updating the SDK is easy. Simply go to window -> package manager -> select the ChainSafe SDK package & press update. The same can be done for any additional packages you have installed, web3auth, lootboxes etc.

### Set Project ID

As the package is installed, you'll be prompted with settings window.
Expand Down
115 changes: 115 additions & 0 deletions docs/v2.5/6_connecting-a-wallet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
slug: /current/connecting-a-wallet
sidebar_position: 6
sidebar_label: Connecting A Wallet
---


# Connecting a Wallet

:::info

This page teaches you how to connect a wallet and our how our system is initialized.

:::

There is no separate state to connect player wallet. Connection procedure is triggered as part
of Web3 build process. This is due to the fact that after Web3 build process is completed, your Web3 instance
and all of it's components have to have their states fully initialized. Starting from this point you can safely
use each and every component and not worry you missed an initialization step.

In simple words, wallet connection happens when you call `LaunchAsync()` on `Web3Builder` object.
So, to handle connection error as well as any other initialization error you should wrap `LaunchAsync`
call into a try/catch statement. Alternatively you can just use the login scene provided with the samples and it will do all of this for you.

```csharp
using System;
using System.Collections;
using System.Threading.Tasks;
using ChainSafe.Gaming.Evm.Contracts;
using ChainSafe.Gaming.Evm.JsonRpc;
using ChainSafe.Gaming.MultiCall;
using ChainSafe.Gaming.UnityPackage;
using ChainSafe.Gaming.Web3;
using ChainSafe.Gaming.Web3.Build;
using ChainSafe.Gaming.Web3.Unity;
using ChainSafe.GamingSdk.Gelato;
using Scripts.EVM.Token;
using UnityEngine;
using UnityEngine.SceneManagement;

namespace Scenes
{
public abstract class Login : MonoBehaviour
{
// Set this to your main scene
public const string MainSceneName = "SampleMain";

public static int LoginSceneIndex { get; private set; } = 0;

[SerializeField] private string gelatoApiKey = "";

[SerializeField] private ErrorPopup errorPopup;

private IEnumerator Start()
{
yield return Initialize();
}

protected abstract IEnumerator Initialize();

protected abstract Web3Builder ConfigureWeb3Services(Web3Builder web3Builder);

protected async Task TryLogin()
{
Web3 web3;

try
{
Web3Builder web3Builder = new Web3Builder(ProjectConfigUtilities.Load())
.Configure(ConfigureCommonServices);

web3Builder = ConfigureWeb3Services(web3Builder);

web3 = await web3Builder.LaunchAsync();
}

catch (Exception)
{
errorPopup.ShowError("Login failed, please try again\n(see console for more details)");
throw;
}

Web3Accessor.Set(web3);

LoginSceneIndex = SceneManager.GetActiveScene().buildIndex;

SceneManager.LoadScene(MainSceneName);
}

private void ConfigureCommonServices(IWeb3ServiceCollection services)
{
services
.UseUnityEnvironment()
.UseGelato(gelatoApiKey)
.UseMultiCall()
.UseRpcProvider();

/* As many contracts as needed may be registered here.
* It is better to register all contracts the application
* will be interacting with at configuration time if they
* are known in advance. We're just registering shiba
* here to show how it's done. You can look at the
* `Scripts/Prefabs/Wallet/RegisteredContract` script
* to see how it's used later on.
*/
services.ConfigureRegisteredContracts(contracts =>
contracts.RegisterContract("CsTestErc20", ABI.Erc20, Contracts.Erc20));

}
}
}
```

It also makes sense to retry building the Web3 object when the connection
fails. It's up to you if you wanna do it automatically or when a player presses the button.
103 changes: 0 additions & 103 deletions docs/v2.5/6_signers-and-wallets.md

This file was deleted.

103 changes: 0 additions & 103 deletions docs/v2.5/7_connecting-a-wallet.md

This file was deleted.

Loading

0 comments on commit cf94512

Please sign in to comment.