Skip to content

Commit

Permalink
CoreAPI Upgrade (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
krzlabrdx authored Jan 11, 2023
1 parent df759d1 commit a9c961f
Show file tree
Hide file tree
Showing 11 changed files with 206 additions and 123 deletions.
5 changes: 3 additions & 2 deletions .github/actions/set-variables/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ runs:
GH_ACTION_NAME=${{ inputs.github_action_name }}
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD | sed 's/\//-/g')
GIT_COMMIT=$(git log -1 --format=%h )
DOCKER_TAG=${GIT_BRANCH}-${GIT_COMMIT}
VERSION_SUFFIX=${GIT_BRANCH}-${GIT_COMMIT}
NORMALIZED_SUFFIX=$(echo "${GIT_BRANCH}-${GIT_COMMIT}" | tr -cd '[:alnum:]-')
DOCKER_TAG=${NORMALIZED_SUFFIX}
VERSION_SUFFIX=${NORMALIZED_SUFFIX}
DOCKER_REPO_DATA_AGGREGATOR="eu.gcr.io/dev-container-repo/babylon-ng-data-aggregator"
DOCKER_REPO_GATEWAY_API="eu.gcr.io/dev-container-repo/babylon-ng-gateway-api"
Expand Down
51 changes: 39 additions & 12 deletions src/RadixDlt.CoreApiSdk/core-api-spec-copy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,8 @@ components:
$ref: "#/components/schemas/FeeSummary"
state_updates:
$ref: "#/components/schemas/StateUpdates"
next_epoch:
$ref: "#/components/schemas/NextEpoch"
output:
type: array
description: The manifest line-by-line engine return data (only present if status is Succeeded)
Expand Down Expand Up @@ -1111,6 +1113,22 @@ components:
type: array
items:
$ref: "#/components/schemas/GlobalEntityAssignment"
NextEpoch:
type: object
required:
- epoch
- validators
properties:
epoch:
type: integer
format: int64
minimum: 0
maximum: 10000000000
description: An integer between `0` and `10^10`
validators:
type: array
items:
$ref: "#/components/schemas/EcdsaSecp256k1PublicKey"
NewSubstateVersion:
type: object
required:
Expand Down Expand Up @@ -1424,19 +1442,16 @@ components:
type: string
enum:
- NativeMethod
- NativeFunction
- ScryptoMethod
LocalMethodReference:
oneOf:
- $ref: '#/components/schemas/LocalNativeMethodReference'
- $ref: '#/components/schemas/LocalNativeFunctionReference'
- $ref: '#/components/schemas/LocalScryptoMethodReference'
discriminator:
propertyName: type
mapping:
# NOTE: These need to match LocalMethodReferenceType options above
NativeMethod: '#/components/schemas/LocalNativeMethodReference'
NativeFunction: '#/components/schemas/LocalNativeFunctionReference'
ScryptoMethod: '#/components/schemas/LocalScryptoMethodReference'
LocalMethodReferenceBase:
type: object
Expand All @@ -1454,15 +1469,6 @@ components:
properties:
name:
type: string
LocalNativeFunctionReference:
allOf:
- $ref: '#/components/schemas/LocalMethodReferenceBase'
- type: object
required:
- name
properties:
name:
type: string
LocalScryptoMethodReference:
allOf:
- $ref: '#/components/schemas/LocalMethodReferenceBase'
Expand Down Expand Up @@ -2380,24 +2386,45 @@ components:
- type: object
required:
- epoch
- round
- rounds_per_epoch
properties:
epoch:
type: integer
format: int64
minimum: 0
maximum: 10000000000
description: An integer between `0` and `10^10`, marking the current epoch
round:
type: integer
format: int64
minimum: 0
maximum: 10000000000
description: An integer between `0` and `10^10`, marking the current round in an epoch
rounds_per_epoch:
type: integer
format: int64
minimum: 0
maximum: 10000000000
description: An integer between `0` and `10^10`, specifying the number of rounds per epoch
ValidatorSetSubstate:
allOf:
- $ref: '#/components/schemas/SubstateBase'
- type: object
required:
- validator_set
- epoch
properties:
validator_set:
type: array
items:
$ref: '#/components/schemas/EcdsaSecp256k1PublicKey'
epoch:
type: integer
format: int64
minimum: 0
maximum: 10000000000
description: An integer between `0` and `10^10`, marking the epoch the validator set is a part of
ClockCurrentMinuteSubstate:
allOf:
- $ref: '#/components/schemas/SubstateBase'
Expand Down
32 changes: 31 additions & 1 deletion src/RadixDlt.CoreApiSdk/generated/Model/EpochManagerSubstate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,14 @@ protected EpochManagerSubstate() { }
/// </summary>
/// <param name="substateType">substateType (required).</param>
/// <param name="epoch">An integer between &#x60;0&#x60; and &#x60;10^10&#x60;, marking the current epoch (required).</param>
public EpochManagerSubstate(SubstateType substateType = default(SubstateType), long epoch = default(long))
/// <param name="round">An integer between &#x60;0&#x60; and &#x60;10^10&#x60;, marking the current round in an epoch (required).</param>
/// <param name="roundsPerEpoch">An integer between &#x60;0&#x60; and &#x60;10^10&#x60;, specifying the number of rounds per epoch (required).</param>
public EpochManagerSubstate(SubstateType substateType = default(SubstateType), long epoch = default(long), long round = default(long), long roundsPerEpoch = default(long))
{
this.SubstateType = substateType;
this.Epoch = epoch;
this.Round = round;
this.RoundsPerEpoch = roundsPerEpoch;
}

/// <summary>
Expand All @@ -124,6 +128,20 @@ protected EpochManagerSubstate() { }
[DataMember(Name = "epoch", IsRequired = true, EmitDefaultValue = true)]
public long Epoch { get; set; }

/// <summary>
/// An integer between &#x60;0&#x60; and &#x60;10^10&#x60;, marking the current round in an epoch
/// </summary>
/// <value>An integer between &#x60;0&#x60; and &#x60;10^10&#x60;, marking the current round in an epoch</value>
[DataMember(Name = "round", IsRequired = true, EmitDefaultValue = true)]
public long Round { get; set; }

/// <summary>
/// An integer between &#x60;0&#x60; and &#x60;10^10&#x60;, specifying the number of rounds per epoch
/// </summary>
/// <value>An integer between &#x60;0&#x60; and &#x60;10^10&#x60;, specifying the number of rounds per epoch</value>
[DataMember(Name = "rounds_per_epoch", IsRequired = true, EmitDefaultValue = true)]
public long RoundsPerEpoch { get; set; }

/// <summary>
/// Returns the string presentation of the object
/// </summary>
Expand All @@ -134,6 +152,8 @@ public override string ToString()
sb.Append("class EpochManagerSubstate {\n");
sb.Append(" SubstateType: ").Append(SubstateType).Append("\n");
sb.Append(" Epoch: ").Append(Epoch).Append("\n");
sb.Append(" Round: ").Append(Round).Append("\n");
sb.Append(" RoundsPerEpoch: ").Append(RoundsPerEpoch).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
Expand Down Expand Up @@ -176,6 +196,14 @@ public bool Equals(EpochManagerSubstate input)
(
this.Epoch == input.Epoch ||
this.Epoch.Equals(input.Epoch)
) &&
(
this.Round == input.Round ||
this.Round.Equals(input.Round)
) &&
(
this.RoundsPerEpoch == input.RoundsPerEpoch ||
this.RoundsPerEpoch.Equals(input.RoundsPerEpoch)
);
}

Expand All @@ -190,6 +218,8 @@ public override int GetHashCode()
int hashCode = 41;
hashCode = (hashCode * 59) + this.SubstateType.GetHashCode();
hashCode = (hashCode * 59) + this.Epoch.GetHashCode();
hashCode = (hashCode * 59) + this.Round.GetHashCode();
hashCode = (hashCode * 59) + this.RoundsPerEpoch.GetHashCode();
return hashCode;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,13 @@ protected EpochManagerSubstateAllOf() { }
/// Initializes a new instance of the <see cref="EpochManagerSubstateAllOf" /> class.
/// </summary>
/// <param name="epoch">An integer between &#x60;0&#x60; and &#x60;10^10&#x60;, marking the current epoch (required).</param>
public EpochManagerSubstateAllOf(long epoch = default(long))
/// <param name="round">An integer between &#x60;0&#x60; and &#x60;10^10&#x60;, marking the current round in an epoch (required).</param>
/// <param name="roundsPerEpoch">An integer between &#x60;0&#x60; and &#x60;10^10&#x60;, specifying the number of rounds per epoch (required).</param>
public EpochManagerSubstateAllOf(long epoch = default(long), long round = default(long), long roundsPerEpoch = default(long))
{
this.Epoch = epoch;
this.Round = round;
this.RoundsPerEpoch = roundsPerEpoch;
}

/// <summary>
Expand All @@ -116,6 +120,20 @@ protected EpochManagerSubstateAllOf() { }
[DataMember(Name = "epoch", IsRequired = true, EmitDefaultValue = true)]
public long Epoch { get; set; }

/// <summary>
/// An integer between &#x60;0&#x60; and &#x60;10^10&#x60;, marking the current round in an epoch
/// </summary>
/// <value>An integer between &#x60;0&#x60; and &#x60;10^10&#x60;, marking the current round in an epoch</value>
[DataMember(Name = "round", IsRequired = true, EmitDefaultValue = true)]
public long Round { get; set; }

/// <summary>
/// An integer between &#x60;0&#x60; and &#x60;10^10&#x60;, specifying the number of rounds per epoch
/// </summary>
/// <value>An integer between &#x60;0&#x60; and &#x60;10^10&#x60;, specifying the number of rounds per epoch</value>
[DataMember(Name = "rounds_per_epoch", IsRequired = true, EmitDefaultValue = true)]
public long RoundsPerEpoch { get; set; }

/// <summary>
/// Returns the string presentation of the object
/// </summary>
Expand All @@ -125,6 +143,8 @@ public override string ToString()
StringBuilder sb = new StringBuilder();
sb.Append("class EpochManagerSubstateAllOf {\n");
sb.Append(" Epoch: ").Append(Epoch).Append("\n");
sb.Append(" Round: ").Append(Round).Append("\n");
sb.Append(" RoundsPerEpoch: ").Append(RoundsPerEpoch).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
Expand Down Expand Up @@ -163,6 +183,14 @@ public bool Equals(EpochManagerSubstateAllOf input)
(
this.Epoch == input.Epoch ||
this.Epoch.Equals(input.Epoch)
) &&
(
this.Round == input.Round ||
this.Round.Equals(input.Round)
) &&
(
this.RoundsPerEpoch == input.RoundsPerEpoch ||
this.RoundsPerEpoch.Equals(input.RoundsPerEpoch)
);
}

Expand All @@ -176,6 +204,8 @@ public override int GetHashCode()
{
int hashCode = 41;
hashCode = (hashCode * 59) + this.Epoch.GetHashCode();
hashCode = (hashCode * 59) + this.Round.GetHashCode();
hashCode = (hashCode * 59) + this.RoundsPerEpoch.GetHashCode();
return hashCode;
}
}
Expand Down
58 changes: 3 additions & 55 deletions src/RadixDlt.CoreApiSdk/generated/Model/LocalMethodReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,6 @@ public LocalMethodReference(LocalNativeMethodReference actualInstance)
this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
}

/// <summary>
/// Initializes a new instance of the <see cref="LocalMethodReference" /> class
/// with the <see cref="LocalNativeFunctionReference" /> class
/// </summary>
/// <param name="actualInstance">An instance of LocalNativeFunctionReference.</param>
public LocalMethodReference(LocalNativeFunctionReference actualInstance)
{
this.IsNullable = false;
this.SchemaType= "oneOf";
this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
}

/// <summary>
/// Initializes a new instance of the <see cref="LocalMethodReference" /> class
/// with the <see cref="LocalScryptoMethodReference" /> class
Expand All @@ -148,11 +136,7 @@ public override Object ActualInstance
}
set
{
if (value.GetType() == typeof(LocalNativeFunctionReference))
{
this._actualInstance = value;
}
else if (value.GetType() == typeof(LocalNativeMethodReference))
if (value.GetType() == typeof(LocalNativeMethodReference))
{
this._actualInstance = value;
}
Expand All @@ -162,7 +146,7 @@ public override Object ActualInstance
}
else
{
throw new ArgumentException("Invalid instance found. Must be the following types: LocalNativeFunctionReference, LocalNativeMethodReference, LocalScryptoMethodReference");
throw new ArgumentException("Invalid instance found. Must be the following types: LocalNativeMethodReference, LocalScryptoMethodReference");
}
}
}
Expand All @@ -177,16 +161,6 @@ public LocalNativeMethodReference GetLocalNativeMethodReference()
return (LocalNativeMethodReference)this.ActualInstance;
}

/// <summary>
/// Get the actual instance of `LocalNativeFunctionReference`. If the actual instance is not `LocalNativeFunctionReference`,
/// the InvalidClassException will be thrown
/// </summary>
/// <returns>An instance of LocalNativeFunctionReference</returns>
public LocalNativeFunctionReference GetLocalNativeFunctionReference()
{
return (LocalNativeFunctionReference)this.ActualInstance;
}

/// <summary>
/// Get the actual instance of `LocalScryptoMethodReference`. If the actual instance is not `LocalScryptoMethodReference`,
/// the InvalidClassException will be thrown
Expand Down Expand Up @@ -239,26 +213,20 @@ public static LocalMethodReference FromJson(string jsonString)
string discriminatorValue = discriminatorObj == null ?string.Empty :discriminatorObj.ToString();
switch (discriminatorValue)
{
case "LocalNativeFunctionReference":
newLocalMethodReference = new LocalMethodReference(JsonConvert.DeserializeObject<LocalNativeFunctionReference>(jsonString, LocalMethodReference.AdditionalPropertiesSerializerSettings));
return newLocalMethodReference;
case "LocalNativeMethodReference":
newLocalMethodReference = new LocalMethodReference(JsonConvert.DeserializeObject<LocalNativeMethodReference>(jsonString, LocalMethodReference.AdditionalPropertiesSerializerSettings));
return newLocalMethodReference;
case "LocalScryptoMethodReference":
newLocalMethodReference = new LocalMethodReference(JsonConvert.DeserializeObject<LocalScryptoMethodReference>(jsonString, LocalMethodReference.AdditionalPropertiesSerializerSettings));
return newLocalMethodReference;
case "NativeFunction":
newLocalMethodReference = new LocalMethodReference(JsonConvert.DeserializeObject<LocalNativeFunctionReference>(jsonString, LocalMethodReference.AdditionalPropertiesSerializerSettings));
return newLocalMethodReference;
case "NativeMethod":
newLocalMethodReference = new LocalMethodReference(JsonConvert.DeserializeObject<LocalNativeMethodReference>(jsonString, LocalMethodReference.AdditionalPropertiesSerializerSettings));
return newLocalMethodReference;
case "ScryptoMethod":
newLocalMethodReference = new LocalMethodReference(JsonConvert.DeserializeObject<LocalScryptoMethodReference>(jsonString, LocalMethodReference.AdditionalPropertiesSerializerSettings));
return newLocalMethodReference;
default:
System.Diagnostics.Debug.WriteLine(string.Format("Failed to lookup discriminator value `{0}` for LocalMethodReference. Possible values: LocalNativeFunctionReference LocalNativeMethodReference LocalScryptoMethodReference NativeFunction NativeMethod ScryptoMethod", discriminatorValue));
System.Diagnostics.Debug.WriteLine(string.Format("Failed to lookup discriminator value `{0}` for LocalMethodReference. Possible values: LocalNativeMethodReference LocalScryptoMethodReference NativeMethod ScryptoMethod", discriminatorValue));
break;
}
}
Expand All @@ -270,26 +238,6 @@ public static LocalMethodReference FromJson(string jsonString)
int match = 0;
List<string> matchedTypes = new List<string>();

try
{
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
if (typeof(LocalNativeFunctionReference).GetProperty("AdditionalProperties") == null)
{
newLocalMethodReference = new LocalMethodReference(JsonConvert.DeserializeObject<LocalNativeFunctionReference>(jsonString, LocalMethodReference.SerializerSettings));
}
else
{
newLocalMethodReference = new LocalMethodReference(JsonConvert.DeserializeObject<LocalNativeFunctionReference>(jsonString, LocalMethodReference.AdditionalPropertiesSerializerSettings));
}
matchedTypes.Add("LocalNativeFunctionReference");
match++;
}
catch (Exception exception)
{
// deserialization failed, try the next one
System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into LocalNativeFunctionReference: {1}", jsonString, exception.ToString()));
}

try
{
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,11 @@ public enum LocalMethodReferenceType
[EnumMember(Value = "NativeMethod")]
NativeMethod = 1,

/// <summary>
/// Enum NativeFunction for value: NativeFunction
/// </summary>
[EnumMember(Value = "NativeFunction")]
NativeFunction = 2,

/// <summary>
/// Enum ScryptoMethod for value: ScryptoMethod
/// </summary>
[EnumMember(Value = "ScryptoMethod")]
ScryptoMethod = 3
ScryptoMethod = 2

}

Expand Down
Loading

0 comments on commit a9c961f

Please sign in to comment.