-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from IOTA-NET/8-feat-computestoragedeposit
8 feat computestoragedeposit
- Loading branch information
Showing
4 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using JsonSubTypes; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
|
||
namespace IotaSDK.NET.Domain.Outputs | ||
{ | ||
[JsonConverter(typeof(JsonSubtypes), "Type")] | ||
//[JsonSubtypes.KnownSubType(typeof(AliasOutput), 4)] | ||
//[JsonSubtypes.KnownSubType(typeof(BasicOutput), 3)] | ||
//[JsonSubtypes.KnownSubType(typeof(FoundryOutput), 5)] | ||
//[JsonSubtypes.KnownSubType(typeof(NftOutput), 6)] | ||
//[JsonSubtypes.KnownSubType(typeof(TreasuryOutput), 2)] | ||
public abstract class Output | ||
{ | ||
public Output(string amount, int type) | ||
{ | ||
Amount = amount; | ||
Type = type; | ||
} | ||
|
||
public string Amount { get; } | ||
public int Type { get; } | ||
|
||
public OutputType GetOutputType() | ||
{ | ||
if (Enum.IsDefined(typeof(OutputType), this.Type)) | ||
{ | ||
return (OutputType)this.Type; | ||
} | ||
else | ||
{ | ||
// Handle the case where the input value doesn't match any enum value | ||
throw new ArgumentOutOfRangeException(nameof(this.Type), "Invalid OutputType value"); | ||
} | ||
} | ||
|
||
public ulong GetAmount() | ||
{ | ||
if(ulong.TryParse(this.Amount, out var value)) | ||
{ | ||
return value; | ||
} | ||
throw new ArgumentOutOfRangeException(nameof(this.Amount), $"Invalid Amount of {Amount}"); | ||
|
||
} | ||
} | ||
|
||
public abstract class CommonOutput : Output | ||
{ | ||
protected CommonOutput(string amount, int type) : base(amount, type) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
|
||
namespace IotaSDK.NET.Domain.UnlockConditions | ||
{ | ||
public abstract class UnlockCondition | ||
{ | ||
public UnlockCondition(int type) | ||
{ | ||
Type = type; | ||
} | ||
|
||
public int Type { get; } | ||
|
||
public UnlockConditionType GetUnlockConditionType() | ||
{ | ||
if (Enum.IsDefined(typeof(UnlockConditionType), this.Type)) | ||
{ | ||
return (UnlockConditionType)this.Type; | ||
} | ||
else | ||
{ | ||
// Handle the case where the input value doesn't match any enum value | ||
throw new ArgumentOutOfRangeException(nameof(this.Type), "Invalid UnlockConditionType value"); | ||
} | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
IotaSDK.NET/Domain/UnlockConditions/UnlockConditionType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using IotaSDK.NET.Domain.Outputs; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace IotaSDK.NET.Domain.UnlockConditions | ||
{ | ||
/** | ||
* All of the unlock condition types. | ||
*/ | ||
public enum UnlockConditionType | ||
{ | ||
/** An address unlock condition. */ | ||
Address = 0, | ||
/** A storage deposit return unlock condition. */ | ||
StorageDepositReturn = 1, | ||
/** A timelock unlock condition. */ | ||
Timelock = 2, | ||
/** An expiration unlock condition. */ | ||
Expiration = 3, | ||
/** A state controller address unlock condition. */ | ||
StateControllerAddress = 4, | ||
/** A governor address unlock condition. */ | ||
GovernorAddress = 5, | ||
/** An immutable alias address unlock condition. */ | ||
ImmutableAliasAddress = 6, | ||
} | ||
|
||
public class AddressUnlockCondition : UnlockCondition | ||
{ | ||
public AddressUnlockCondition(int type) : base(type) | ||
{ | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters