Skip to content
This repository was archived by the owner on Jul 12, 2022. It is now read-only.

Commit d16d08c

Browse files
committed
Samples Update
- Added Create Wallet example - Added List Wallet example - Added Get NFTs example
1 parent cd9f218 commit d16d08c

File tree

2 files changed

+4083
-299
lines changed

2 files changed

+4083
-299
lines changed

Package/Samples~/Demo/ApiExamples.cs

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,57 @@
44
using HeathenEngineering.BGSDK.DataModel;
55
using HeathenEngineering.BGSDK.Engine;
66
using UnityEngine;
7+
using UnityEngine.UI;
78

89
namespace HeathenEngineering.BGSDK.Examples
910
{
1011
public class ApiExamples : MonoBehaviour
1112
{
12-
public string walletAddress;
13+
public InputField walletId;
14+
public InputField walletPin;
15+
public InputField walletAddress;
16+
public Dropdown createWalletType;
17+
public Dropdown listNFTWalletType;
1318
public SecretType chainType = SecretType.MATIC;
1419

1520
[Header("Results")]
1621
public List<Wallet> walletData;
1722
public List<NFTBalanceResult.Token> tokenData;
1823

24+
public void CreateWallet()
25+
{
26+
if (!string.IsNullOrEmpty(walletId.text)
27+
&& !string.IsNullOrEmpty(walletPin.text))
28+
{
29+
StartCoroutine(API.Server.Wallets.Create(walletPin.text, walletId.text, (SecretType)createWalletType.value, HandleCreateWalletResult));
30+
}
31+
else
32+
{
33+
Debug.LogWarning("You must provide a wallet ID and Pin in order to create a new wallet.");
34+
}
35+
}
36+
1937
public void FetchWallets()
2038
{
21-
StartCoroutine(API.Server.Wallets.List(HandleWalletResults));
39+
StartCoroutine(API.Server.Wallets.List(HandleListWalletResults));
2240
}
2341

2442
public void FetchNFTs()
2543
{
26-
StartCoroutine(API.Server.Wallets.NFTs(walletAddress, chainType, null, HandleNFTBalanceResult));
44+
StartCoroutine(API.Server.Wallets.NFTs(walletAddress.text, (SecretType)listNFTWalletType.value, null, HandleNFTBalanceResult));
45+
}
46+
47+
private void HandleCreateWalletResult(ListWalletResult walletResult)
48+
{
49+
if (!walletResult.hasError)
50+
{
51+
walletData = walletResult.result;
52+
Debug.Log("Create Wallets Responce:\nReturned " + walletResult.result.Count.ToString() + " wallets. You can review the results in the inspector.");
53+
}
54+
else
55+
{
56+
Debug.Log("Create Wallets Responce:\nHas Error: " + walletResult.hasError + "\nMessage: " + walletResult.message + "\nCode:" + walletResult.httpCode);
57+
}
2758
}
2859

2960
private void HandleNFTBalanceResult(NFTBalanceResult balanceResult)
@@ -39,7 +70,7 @@ private void HandleNFTBalanceResult(NFTBalanceResult balanceResult)
3970
}
4071
}
4172

42-
private void HandleWalletResults(ListWalletResult walletResult)
73+
private void HandleListWalletResults(ListWalletResult walletResult)
4374
{
4475
if (!walletResult.hasError)
4576
{

0 commit comments

Comments
 (0)