Skip to content

Commit d312c74

Browse files
committed
- Continued improving NFT API, fixing bugs etc.
- Added new PlacedOn property to IOASISGeoSpatialNFT interface in OASIS.API.Core. - Changed OffChainProvider and OnChainProvider on IMintNFTTransactionRequest/MintNFTTransactionReques in tOASIS.API.Core to use EnumValue<ProviderType instead of ProviderType (is now wrapped in EnumValue) so makes it easier to work with and display enum names etc. - Addded MintedOn property to IOASISNFT interface in OASIS.API.Core. - Started fixing the GenerateKeyPair function in KeyManger in OASIS.API.Core to use the correct prefix depending on what blockchain/provider it is generating the public/private keys for. Needs finishing... - Updated LinkProviderPublicKeyToAvatar function in OASIS.API.Core so it now also sets the WalletAddress to the public key. This will eventually calcualte and set the correct WalletAddress (derived from the public key). - Added new PlacedOn property to OASISGeoSpatialNFT object in OASIS.API.Core. - Addded MintedOn property to OASISNFT interface in OASIS.API.Core. - Updated MintNftAsync method in NFTManger to work with the now wrapped EnumValues. Also added additional error handling and reporting and fixed a bug. - Updated MintNft method in NFTManger to work with the now wrapped EnumValues. - Changed the providerType param to an optional one that defaults to ProviderType.Default in the functions LoadNftAsync, LoadNft, LoadAllNFTsForAvatarAsync, LoadAllNFTsForAvatar, LoadAllNFTsForMintAddressAsync, LoadAllNFTsForMintAddress, LoadAllGeoNFTsForAvatarAsync, LoadAllGeoNFTsForAvatar, LoadAllGeoNFTsForMintAddressAsync, LoadAllGeoNFTsForMintAddress, LoadAllNFTsAsync, LoadAllNFTs, LoadAllGeoNFTsAsyn &, LoadAllGeoNFTs in NFTManger in OASIS.API.ONODE.Core. - Updated CreateOASISNFT function in NFTManger to set the new MintedOn property in OASIS.API.ONODE.Core. - Updated CreateGeoSpatialNFT function in NFTManger to set the new MintedOn and PlacedOn properties in OASIS.API.ONODE.Core. - Updated the CreateNFTMetaDataHolon function in NFTManger to set the new NFT.MintedOn metadata in OASIS.API.ONODE.Core as well as the Name property now works with the EnumValue property type wrap. - Updated the CreateNFTMetaDataHolon function in NFTManger to set the new NFT.MintedOn metadata in OASIS.API.ONODE.Core. - Added GEONFT.PlacedByAvatarId and GEONFT.PlacedOn metadata to CreateGeoSpatialNFTMetaDataHolon function in OASIS.API.ONODE.Core. - Fixed a bug in DecodeNFTMetaData so the NFT metadata is now cast to a OASISNFT rather than IOASISNFT. Also fixed another bug where holon.MetaData was being used instead of holonRest.Result.MetaData. Finally fixed another bug where the metadata key being used was "OASISNFT" rather than "NFT.OASISNFT". - Fixed a bug in DecodeGeoNFTMetaData so the NFT metadata is now cast to a OASISGeoSpatialNFT rather than IOASISGeoSpatialNFT. Also fixed another bug where holon.MetaData was being used instead of holonRest.Result.MetaData. Finally fixed another bug where the metadata key being used was "OASISGEONFT" rather than "GEONFT.OASISGEONFT". - Updated MintNftAsync function in NFTController in OASIS.API.ONODE.WebApi to always set the MintedByAvatarId from the logged in avatar/user rather than allowing it to be passed in (improves security so people can not pretend to mint the NFT from another avatar). - Started fixing the functions/endpoints in NFTController to comform to OASIS standards. WIP... So far LoadNftByIdAsync, LoadNftByHashAsync & LoadAllNFTsForAvatarAsync have been fixed by adding additonal overloads so ProviderType can be passed in or if none is passed in it will use the current defaullt provider so will now work the same as the Avatar and Data API's... - Fided a bug in AttachAccountToContext function in JwtMiddleware in OASIS.API.ONODE.WebApi. - Removed MintWalletAddress and MintedByAvatarId proeprties from MintNFTTransactionRequest in OASIS.API.ONODE.WebApi because these are now retreived from the logged in avatar/user.
1 parent bc443d1 commit d312c74

14 files changed

Lines changed: 166 additions & 97 deletions

File tree

NextGenSoftware.OASIS.API.Core/Interfaces/NFT/GeoSpatialNFT/IOASISGeoSpatialNFT.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public interface IOASISGeoSpatialNFT : IOASISNFT
88
Guid PlacedByAvatarId { get; set; }
99
Guid OriginalOASISNFTId { get; set; }
1010
ProviderType OriginalOASISNFTProviderType { get; set; }
11+
DateTime PlacedOn { get; set; }
1112
long Lat { get; set; }
1213
long Long { get; set; }
1314
bool AllowOtherPlayersToAlsoCollect { get; set; }

NextGenSoftware.OASIS.API.Core/Interfaces/NFT/IOASISNFT.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using NextGenSoftware.OASIS.API.Core.Enums;
2+
using NextGenSoftware.OASIS.API.Core.Helpers;
23
using System;
34
using System.Collections.Generic;
45

@@ -8,6 +9,7 @@ public interface IOASISNFT
89
{
910
Guid Id { get; set; }
1011
Guid MintedByAvatarId { get; set; }
12+
DateTime MintedOn { get; set; }
1113
string MintedByAddress { get; set; }
1214
string Hash { get; set; }
1315
string URL { get; set; }
@@ -22,7 +24,7 @@ public interface IOASISNFT
2224
string ThumbnailUrl { get; set; }
2325
public string Token { get; set; } //TODO: Should be dervied from the OnChainProvider so may not need this?
2426
Dictionary<string, object> MetaData { get; set; }
25-
ProviderType OffChainProvider { get; set; }
26-
ProviderType OnChainProvider { get; set; }
27+
EnumValue<ProviderType> OffChainProvider { get; set; }
28+
EnumValue<ProviderType> OnChainProvider { get; set; }
2729
}
2830
}

NextGenSoftware.OASIS.API.Core/Interfaces/NFT/Requests/IMintNFTTransactionRequest.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using NextGenSoftware.OASIS.API.Core.Enums;
2+
using NextGenSoftware.OASIS.API.Core.Helpers;
23
using System;
34
using System.Collections.Generic;
45

@@ -21,7 +22,7 @@ public interface IMintNFTTransactionRequest
2122
public int NumberToMint { get; set; }
2223
public bool StoreNFTMetaDataOnChain { get; set; }
2324
public Dictionary<string, object> MetaData { get; set; }
24-
public ProviderType OffChainProvider { get; set; }
25-
public ProviderType OnChainProvider { get; set; }
25+
public EnumValue<ProviderType> OffChainProvider { get; set; }
26+
public EnumValue<ProviderType> OnChainProvider { get; set; }
2627
}
2728
}

NextGenSoftware.OASIS.API.Core/Interfaces/Providers/IOASISNFTProvider.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-

1+
using System.Threading.Tasks;
22
using NextGenSoftware.OASIS.API.Core.Helpers;
3-
using NextGenSoftware.OASIS.API.Core.Interfaces.NFT.GeoSpatialNFT;
43
using NextGenSoftware.OASIS.API.Core.Interfaces.NFT.Request;
54
using NextGenSoftware.OASIS.API.Core.Interfaces.NFT.Response;
6-
using System;
7-
using System.Collections.Generic;
8-
using System.Threading.Tasks;
95

106
namespace NextGenSoftware.OASIS.API.Core.Interfaces
117
{

NextGenSoftware.OASIS.API.Core/Managers/KeyManager.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,23 @@ public KeyManager(IOASISStorageProvider OASISStorageProvider, OASISDNA OASISDNA
8181
//TODO: Implement later (Cache Disabled).
8282
//public bool IsCacheEnabled { get; set; } = true;
8383

84-
public OASISResult<KeyPair> GenerateKeyPair(ProviderType provider)
84+
public OASISResult<KeyPair> GenerateKeyPair(ProviderType providerType)
8585
{
86-
return GenerateKeyPair(Enum.GetName(typeof(ProviderType), provider));
86+
string prefix = "";
87+
88+
//TODO: Need to look up and add all prefixes here!
89+
switch (providerType)
90+
{
91+
case ProviderType.EthereumOASIS:
92+
prefix = "1";
93+
break;
94+
95+
case ProviderType.SolanaOASIS:
96+
prefix = "2";
97+
break;
98+
}
99+
100+
return GenerateKeyPair(prefix);
87101
}
88102

89103
public OASISResult<KeyPair> GenerateKeyPair(string prefix)
@@ -279,13 +293,14 @@ public OASISResult<Guid> LinkProviderPublicKeyToAvatar(Guid walletId, IAvatar av
279293
{
280294
if (walletId == Guid.Empty)
281295
{
282-
ProviderWallet newWallet = new ProviderWallet()
283-
{
296+
ProviderWallet newWallet = new ProviderWallet()
297+
{
284298
WalletId = Guid.NewGuid(),
285299
AvatarId = avatar.Id,
286300
CreatedByAvatarId = avatar.Id,
287301
CreatedDate = DateTime.Now,
288-
PublicKey = providerKey
302+
PublicKey = providerKey,
303+
WalletAddress = providerKey //TODO: Need to calucalte the walletAddress from the PublicKey!
289304
};
290305

291306
result.Result = newWallet.WalletId;
@@ -303,6 +318,7 @@ public OASISResult<Guid> LinkProviderPublicKeyToAvatar(Guid walletId, IAvatar av
303318

304319
if (wallet != null)
305320
{
321+
wallet.WalletAddress = providerKey; //TODO: Need to calucalte the walletAddress from the PublicKey!
306322
wallet.PublicKey = providerKey;
307323
wallet.ModifiedByAvatarId = avatar.Id;
308324
wallet.ModifiedDate = DateTime.Now;

NextGenSoftware.OASIS.API.Core/Objects/NFT/Requests/MintNFTTransactionRequest.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using NextGenSoftware.OASIS.API.Core.Enums;
33
using System.Collections.Generic;
44
using NextGenSoftware.OASIS.API.Core.Interfaces.NFT.Request;
5+
using NextGenSoftware.OASIS.API.Core.Helpers;
56

67
namespace NextGenSoftware.OASIS.API.Core.Objects.NFT.Request
78
{
@@ -22,7 +23,7 @@ public class MintNFTTransactionRequest : IMintNFTTransactionRequest
2223
public int NumberToMint { get; set; }
2324
public bool StoreNFTMetaDataOnChain { get; set; }
2425
public Dictionary<string, object> MetaData { get; set; }
25-
public ProviderType OffChainProvider { get; set; }
26-
public ProviderType OnChainProvider { get; set; }
26+
public EnumValue<ProviderType> OffChainProvider { get; set; }
27+
public EnumValue<ProviderType> OnChainProvider { get; set; }
2728
}
2829
}

NextGenSoftware.OASIS.API.Core/Objects/OASISGeoSpatialNFT.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class OASISGeoSpatialNFT : OASISNFT, IOASISGeoSpatialNFT
99
public Guid PlacedByAvatarId { get; set; }
1010
public Guid OriginalOASISNFTId { get; set; }
1111
public ProviderType OriginalOASISNFTProviderType { get; set; }
12+
public DateTime PlacedOn { get; set; }
1213
public long Lat { get; set; }
1314
public long Long { get; set; }
1415

NextGenSoftware.OASIS.API.Core/Objects/OASISNFT.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using NextGenSoftware.OASIS.API.Core.Enums;
4+
using NextGenSoftware.OASIS.API.Core.Helpers;
45
using NextGenSoftware.OASIS.API.Core.Interfaces.NFT;
56

67
namespace NextGenSoftware.OASIS.API.Core.Objects
@@ -9,6 +10,7 @@ public class OASISNFT : IOASISNFT
910
{
1011
public Guid Id { get; set; }
1112
public Guid MintedByAvatarId { get; set; }
13+
public DateTime MintedOn { get; set; }
1214

1315
public string Title { get; set; }
1416
public string Description { get; set; }
@@ -32,11 +34,11 @@ public class OASISNFT : IOASISNFT
3234
/// <summary>
3335
/// The Blockchain to store the token on.
3436
/// </summary>
35-
public ProviderType OnChainProvider { get; set; } = ProviderType.EthereumOASIS;
37+
public EnumValue<ProviderType> OnChainProvider { get; set; }
3638

3739
/// <summary>
3840
/// Where the meta data is stored for the NFT (JSON Meta file and associated media etc) - For example HoloOASIS or IPFSOASIS etc.
3941
/// </summary>
40-
public ProviderType OffChainProvider { get; set; } = ProviderType.HoloOASIS;
42+
public EnumValue<ProviderType> OffChainProvider { get; set; }
4143
}
4244
}

0 commit comments

Comments
 (0)