Skip to content

Commit

Permalink
- LOTS of work done over past few days on new key/wallet API's as wel…
Browse files Browse the repository at this point in the history
…l as improvements to the OASIS Architecture.

- Added new None, StorageLocal, StorageLocalAndNetwork enum types to ProviderCategory (to be used in the new key/wallet api for storing private keys to local storage only.

- Added new LocalFileOASIS enum type to ProviderType and moved None, All & Default to the top.

- Save & SaveAsync methods on Avatar/IAvatar now take a optional providerType param.

- Added SendTrasaction & SendTrasactionAsync methods to IOASISBlockchainStorageProvider interface that blockchain OASIS Providers need to implmenet.

- Added new IOASISLocalStorageProvider interface that contains LoadProviderWallets, LoadProviderWalletsAsync, SaveProviderWallets & SaveProviderWalletsAsync methods that a Local Storage OASIS Provider need to implement such as HoloOASIS, SQLLiteDBOASIS & LocalFileOASIS. There will be more to come...

-  Added SendNFT & SendNFTAsync methods to IOASISNFTProvider interface.

- Added Import, ExportAllDataForAvatarById, ExportAllDataForAvatarByUsername, ExportAllDataForAvatarByEmail & ExportAll methods to IOASISStorageProvider interface.

- Added SendTransaction, SendTransactionAsync, SendNFT & SendNFTAsync methods to IOASISWallet & IProviderWallet interfaces & OASISWallet & ProviderWallet objects.

- Added new Instance properties to all OASISManagers such as AvatarManager, HolonManager, KeyManager, WalletManager & SearchManager allowing static instances to be used instead of having to create new instances (singleton pattern best practice).

- Moved OASISDNA & OASISDNAPath from OASISStorageProviderBase to OASISProvider abstract class because these are relevant to all providers, not just storage providers.

- Added Import, ExportAllDataForAvatarById, ExportAllDataForAvatarByUsername, ExportAllDataForAvatarByEmail & ExportAll methods to OASISStorageProviderBase.

- Added new LocalFileOASIS setting to OASISDNA.

- Added new Import, ExportAllDataForAvatarById, ExportAllDataForAvatarByUsername, ExportAllDataForAvatarByEmail & ExportAll methods to all OASIS Providers including ActivityPubOASIS, BlockstackOASIS, ChainLinkOASIS, EOSIOOASIS, EthereumOASIS, HashgraphOASIS, HoloOASIS, IPFSOASIS, LocalFileOASIS, MongoDBOASIS, Neo4jOASIS, PLANOASIS, ScuttlebuttOASIS, SolanaOASIS, SOLIDOASIS, SQLLiteDBOASIS, TelosOASIS, ThreeFoldOASIS& TRONOASIS.

- Added new LocalFileOASIS Provider which will serialize the avatar & holon data objects to a JSON file. Currently is serializes the Provider Wallets containing the private keys (encrypted) but will add additional encryption soon including quantum level encryption.

- Removed ProviderPrivateKey, ProviderPublicKey, ProviderUsername & ProviderWalletAddress properties from the AvatarDetail entity in MongoDBOASIS Provider.

- Added new LocalFileOASIS Provider to OASISBootLoader and fixed some other minor bugs.
  • Loading branch information
dellams committed Jun 1, 2022
1 parent 9c2add4 commit e4a2711
Show file tree
Hide file tree
Showing 53 changed files with 1,818 additions and 1,638 deletions.
3 changes: 3 additions & 0 deletions NextGenSoftware.OASIS.API.Core/Enums/ProviderCategory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ namespace NextGenSoftware.OASIS.API.Core.Enums
{
public enum ProviderCategory
{
None,
Storage,
StorageLocal,
Network,
StorageAndNetwork,
StorageLocalAndNetwork,
SmartContract,
NFT,
Application,
Expand Down
7 changes: 4 additions & 3 deletions NextGenSoftware.OASIS.API.Core/Enums/ProviderType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
{
public enum ProviderType
{
None,
All,
Default,
SolanaOASIS,
HoloOASIS,
EthereumOASIS,
Expand Down Expand Up @@ -31,9 +34,7 @@ public enum ProviderType
HoloWebOASIS,
TRONOASIS,
Neo4jOASIS,
All,
None,
Default,
CosmosBlockChainOASIS,
LocalFileOASIS
}
}
20 changes: 15 additions & 5 deletions NextGenSoftware.OASIS.API.Core/Holons/Avatar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,26 @@ public bool OwnsToken(string token)
return this.RefreshTokens?.Find(x => x.Token == token) != null;
}

public async Task<OASISResult<IAvatar>> SaveAsync()
public async Task<OASISResult<IAvatar>> SaveAsync(ProviderType providerType = ProviderType.Default)
{
OASISResult<IAvatar> result = await (ProviderManager.CurrentStorageProvider).SaveAvatarAsync(this);
return result;
return await AvatarManager.Instance.SaveAvatarAsync(this, providerType);
}
public OASISResult<IAvatar> Save()
public OASISResult<IAvatar> Save(ProviderType providerType = ProviderType.Default)
{
return (ProviderManager.CurrentStorageProvider).SaveAvatar(this);
return AvatarManager.Instance.SaveAvatar(this, providerType);
}

//public OASISResult<bool> SaveProviderWallets(ProviderType providerType = ProviderType.Default)
//{
// return AvatarManager.Instance.SaveProviderWallets(this, providerType);
//}

//TODO: Implement async version ASAP...
//public Task<OASISResult<bool>> SaveProviderWalletsAsync(ProviderType providerType = ProviderType.Default)
//{
// return await AvatarManager.Instance.SaveProviderWalletsAsync(this, providerType);
//}

/*
private int GetKarmaForType(KarmaTypePositive karmaType)
{
Expand Down
6 changes: 4 additions & 2 deletions NextGenSoftware.OASIS.API.Core/Interfaces/Avatar/IAvatar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public interface IAvatar : IHolonBase
//int Level { get; }
//int XP { get; set; }
bool OwnsToken(string token);
OASISResult<IAvatar> Save();
Task<OASISResult<IAvatar>> SaveAsync();
OASISResult<IAvatar> Save(ProviderType providerType = ProviderType.Default);
Task<OASISResult<IAvatar>> SaveAsync(ProviderType providerType = ProviderType.Default);
//OASISResult<bool> SaveProviderWallets(ProviderType providerType = ProviderType.Default);
//Task<OASISResult<bool>> SaveProviderWalletsAsync(ProviderType providerType = ProviderType.Default);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ public interface IOASISBlockchainStorageProvider : IOASISStorageProvider
//Central Storage/DB's by default can update the same record, if this flag is set below then they will act more like a Blockchain and store a new copy of the record and link to the previous version.
//public bool IsVersionControlEnabled { get; set; } //You cannot turn VersionControl off for Blockchains because it is built in.


public OASISResult<bool> SendTrasaction(IWalletTransaction transation);
public Task<OASISResult<bool>> SendTrasactionAsync(IWalletTransaction transation);
//public OASISResult<bool> SendNFT(IWalletTransaction transation);
//public Task<OASISResult<bool>> SendNFTAsync(IWalletTransaction transation);

//TODO: More specefic Blockchain options will appear here soon... ;-)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using NextGenSoftware.OASIS.API.Core.Enums;
using NextGenSoftware.OASIS.API.Core.Helpers;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace NextGenSoftware.OASIS.API.Core.Interfaces
{
// This interface is responsbile for persisting provider wallets (including private keys) to local storage ONLY.
public interface IOASISLocalStorageProvider //: IOASISStorageProvider
{
public OASISResult<Dictionary<ProviderType, List<IProviderWallet>>> LoadProviderWallets();
public Task<OASISResult<Dictionary<ProviderType, List<IProviderWallet>>>> LoadProviderWalletsAsync();
public OASISResult<bool> SaveProviderWallets(Dictionary<ProviderType, List<IProviderWallet>> providerWallets);
public Task<OASISResult<bool>> SaveProviderWalletsAsync(Dictionary<ProviderType, List<IProviderWallet>> providerWallets);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@

using NextGenSoftware.OASIS.API.Core.Helpers;
using System.Threading.Tasks;

namespace NextGenSoftware.OASIS.API.Core.Interfaces
{
public interface IOASISNFTProvider : IOASISProvider
{
//TODO: More to come soon... ;-)
public OASISResult<bool> SendNFT(IWalletTransaction transation);
public Task<OASISResult<bool>> SendNFTAsync(IWalletTransaction transation);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

using NextGenSoftware.OASIS.API.Core.Enums;
using NextGenSoftware.OASIS.API.Core.Enums;
using NextGenSoftware.OASIS.API.Core.Helpers;

namespace NextGenSoftware.OASIS.API.Core.Interfaces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using NextGenSoftware.OASIS.API.Core.Enums;
using NextGenSoftware.OASIS.API.Core.Helpers;
using NextGenSoftware.OASIS.API.Core.Objects;
using static NextGenSoftware.OASIS.API.Core.Managers.AvatarManager;
using static NextGenSoftware.OASIS.API.Core.Managers.OASISManager;

namespace NextGenSoftware.OASIS.API.Core.Interfaces
{
Expand All @@ -22,8 +22,6 @@ public interface IOASISStorageProvider : IOASISProvider
Task<OASISResult<IAvatar>> LoadAvatarByUsernameAsync(string avatarUsername, int version = 0);
OASISResult<IAvatar> LoadAvatar(string username, int version = 0);
Task<OASISResult<IAvatar>> LoadAvatarAsync(string username, int version = 0);
//OASISResult<IAvatar> LoadAvatar(string username, string password, int version = 0);
//Task<OASISResult<IAvatar>> LoadAvatarAsync(string username, string password, int version = 0);
OASISResult<IEnumerable<IAvatar>> LoadAllAvatars(int version = 0);
Task<OASISResult<IEnumerable<IAvatar>>> LoadAllAvatarsAsync(int version = 0);
OASISResult<IAvatarDetail> LoadAvatarDetail(Guid id, int version = 0);
Expand Down Expand Up @@ -75,16 +73,15 @@ public interface IOASISStorageProvider : IOASISProvider
Task<OASISResult<bool>> DeleteHolonAsync(string providerKey, bool softDelete = true);

//TODO: Implement these methods ASAP - this is how we can share data across silos, then merge, aggregate, sense-make, perform actions on the full internet data, etc...
//Task<OASISResult<bool>> Import(IEnumerable<IHolon> holons); //Imports all data into the OASIS from a given provider (will then be auto-replicated to all providers). NOTE: The Provider will need to convert the providers raw data into a list of holons (holonize the data).
//Task<OASISResult<IEnumerable<IHolon>>> ExportAllDataForAvatarById(Guid avatarId, int version = 0); //Exports all data for a given avatar and provider. Version = 0 - Latest version. Version = -1 All versions.
//Task<OASISResult<IEnumerable<IHolon>>> ExportAllDataForAvatarByUsername(string avatarUsername, int version = 0); //Exports all data for a given avatar and provider. Version = 0 - Latest version. Version = -1 All versions.
//Task<OASISResult<IEnumerable<IHolon>>> ExportAllDataForAvatarByEmail(string avatarEmailAddress, int version = 0); //Exports all data for a given avatar and provider. Version = 0 - Latest version. Version = -1 All versions.
//Task<OASISResult<IEnumerable<IHolon>>> ExportAll(int version = 0); //Exports all data for a given provider. Version = 0 - Latest version. Version = -1 All versions.
Task<OASISResult<bool>> Import(IEnumerable<IHolon> holons); //Imports all data into the OASIS from a given provider (will then be auto-replicated to all providers). NOTE: The Provider will need to convert the providers raw data into a list of holons (holonize the data).
Task<OASISResult<IEnumerable<IHolon>>> ExportAllDataForAvatarById(Guid avatarId, int version = 0); //Exports all data for a given avatar and provider. Version = 0 - Latest version. Version = -1 All versions.
Task<OASISResult<IEnumerable<IHolon>>> ExportAllDataForAvatarByUsername(string avatarUsername, int version = 0); //Exports all data for a given avatar and provider. Version = 0 - Latest version. Version = -1 All versions.
Task<OASISResult<IEnumerable<IHolon>>> ExportAllDataForAvatarByEmail(string avatarEmailAddress, int version = 0); //Exports all data for a given avatar and provider. Version = 0 - Latest version. Version = -1 All versions.
Task<OASISResult<IEnumerable<IHolon>>> ExportAll(int version = 0); //Exports all data for a given provider. Version = 0 - Latest version. Version = -1 All versions.

Task<OASISResult<ISearchResults>> SearchAsync(ISearchParams searchParams, bool loadChildren = true, bool recursive = true, int maxChildDepth = 0, bool continueOnError = true, int version = 0);

event StorageProviderError StorageProviderError;

public event StorageProviderError StorageProviderError;
//TODO: Lots more to come! ;-)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

using NextGenSoftware.OASIS.API.Core.Helpers;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace NextGenSoftware.OASIS.API.Core.Interfaces
{
Expand All @@ -8,5 +10,10 @@ public interface IOASISWallet
public List<IProviderWallet> Wallets { get; set; }
public List<IWalletTransaction> Transactions { get; set; }
public int Balance { get; set; }

public OASISResult<bool> SendTrasaction(IWalletTransaction transation);
public Task<OASISResult<bool>> SendTrasactionAsync(IWalletTransaction transation);
public OASISResult<bool> SendNFT(IWalletTransaction transation);
public Task<OASISResult<bool>> SendNFTAsync(IWalletTransaction transation);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

using NextGenSoftware.OASIS.API.Core.Enums;
using NextGenSoftware.OASIS.API.Core.Helpers;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace NextGenSoftware.OASIS.API.Core.Interfaces
{
Expand All @@ -20,5 +22,10 @@ public interface IProviderWallet : IHolonBase
public List<IWalletTransaction> Transactions {get;set;}
public ProviderType ProviderType { get; set; }
public int Balance { get; set; }

public OASISResult<bool> SendTrasaction(IWalletTransaction transation);
public Task<OASISResult<bool>> SendTrasactionAsync(IWalletTransaction transation);
public OASISResult<bool> SendNFT(IWalletTransaction transation);
public Task<OASISResult<bool>> SendNFTAsync(IWalletTransaction transation);
}
}
Loading

0 comments on commit e4a2711

Please sign in to comment.