44using HeathenEngineering . BGSDK . DataModel ;
55using HeathenEngineering . BGSDK . Engine ;
66using UnityEngine ;
7+ using UnityEngine . UI ;
78
89namespace 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:\n Returned " + walletResult . result . Count . ToString ( ) + " wallets. You can review the results in the inspector." ) ;
53+ }
54+ else
55+ {
56+ Debug . Log ( "Create Wallets Responce:\n Has Error: " + walletResult . hasError + "\n Message: " + walletResult . message + "\n Code:" + 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