Skip to content

Commit

Permalink
Adding support for tuple return types (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gekctek authored Apr 26, 2023
1 parent 6ea1d9e commit 45f9e1a
Show file tree
Hide file tree
Showing 31 changed files with 389 additions and 2,801 deletions.
4 changes: 2 additions & 2 deletions samples/Sample.Shared/Address/Address.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public class address

public string country { get; set; }

public address(string street, string city, UnboundedUInt zipCode, string country)
public address(string street, string city, UnboundedUInt zip_code, string country)
{
this.street = street;
this.city = city;
this.zip_code = zipCode;
this.zip_code = zip_code;
this.country = country;
}

Expand Down
8 changes: 8 additions & 0 deletions samples/Sample.Shared/Governance/GovernanceApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ public async System.Threading.Tasks.Task<string> GetBuildMetadata()
return reply.ToObjects<Models.Result_2>(this.Converter);
}

public async System.Threading.Tasks.Task<Models.RewardEvent> GetLatestRewardEvent()
{
CandidArg arg = CandidArg.FromCandid();
QueryResponse response = await this.Agent.QueryAsync(this.CanisterId, "get_latest_reward_event", arg);
CandidArg reply = response.ThrowOrGetReply();
return reply.ToObjects<Models.RewardEvent>(this.Converter);
}

public async System.Threading.Tasks.Task<Models.Result_3> GetMetrics()
{
CandidArg arg = CandidArg.FromCandid();
Expand Down
87 changes: 6 additions & 81 deletions samples/Sample.Shared/Governance/Models/Governance.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using EdjCase.ICP.Candid.Mapping;
using Sample.Shared.Governance.Models;
using System;
using System.Collections.Generic;
using EdjCase.ICP.Candid.Models;

Expand All @@ -8,7 +9,7 @@ namespace Sample.Shared.Governance.Models
public class Governance
{
[CandidName("default_followees")]
public List<Governance.DefaultFolloweesItemRecord> DefaultFollowees { get; set; }
public List<ValueTuple<int, Followees>> DefaultFollowees { get; set; }

[CandidName("most_recent_monthly_node_provider_rewards")]
public OptionalValue<MostRecentMonthlyNodeProviderRewards> MostRecentMonthlyNodeProviderRewards { get; set; }
Expand Down Expand Up @@ -44,18 +45,18 @@ public class Governance
public ulong ShortVotingPeriodSeconds { get; set; }

[CandidName("proposals")]
public List<Governance.ProposalsItemRecord> Proposals { get; set; }
public List<ValueTuple<ulong, ProposalData>> Proposals { get; set; }

[CandidName("in_flight_commands")]
public List<Governance.InFlightCommandsItemRecord> InFlightCommands { get; set; }
public List<ValueTuple<ulong, NeuronInFlightCommand>> InFlightCommands { get; set; }

[CandidName("neurons")]
public List<Governance.NeuronsItemRecord> Neurons { get; set; }
public List<ValueTuple<ulong, Neuron>> Neurons { get; set; }

[CandidName("genesis_timestamp_seconds")]
public ulong GenesisTimestampSeconds { get; set; }

public Governance(List<Governance.DefaultFolloweesItemRecord> defaultFollowees, OptionalValue<MostRecentMonthlyNodeProviderRewards> mostRecentMonthlyNodeProviderRewards, OptionalValue<ulong> maturityModulationLastUpdatedAtTimestampSeconds, ulong waitForQuietThresholdSeconds, OptionalValue<GovernanceCachedMetrics> metrics, List<NodeProvider> nodeProviders, OptionalValue<int> cachedDailyMaturityModulationBasisPoints, OptionalValue<NetworkEconomics> economics, OptionalValue<bool> spawningNeurons, OptionalValue<RewardEvent> latestRewardEvent, List<NeuronStakeTransfer> toClaimTransfers, ulong shortVotingPeriodSeconds, List<Governance.ProposalsItemRecord> proposals, List<Governance.InFlightCommandsItemRecord> inFlightCommands, List<Governance.NeuronsItemRecord> neurons, ulong genesisTimestampSeconds)
public Governance(List<ValueTuple<int, Followees>> defaultFollowees, OptionalValue<MostRecentMonthlyNodeProviderRewards> mostRecentMonthlyNodeProviderRewards, OptionalValue<ulong> maturityModulationLastUpdatedAtTimestampSeconds, ulong waitForQuietThresholdSeconds, OptionalValue<GovernanceCachedMetrics> metrics, List<NodeProvider> nodeProviders, OptionalValue<int> cachedDailyMaturityModulationBasisPoints, OptionalValue<NetworkEconomics> economics, OptionalValue<bool> spawningNeurons, OptionalValue<RewardEvent> latestRewardEvent, List<NeuronStakeTransfer> toClaimTransfers, ulong shortVotingPeriodSeconds, List<ValueTuple<ulong, ProposalData>> proposals, List<ValueTuple<ulong, NeuronInFlightCommand>> inFlightCommands, List<ValueTuple<ulong, Neuron>> neurons, ulong genesisTimestampSeconds)
{
this.DefaultFollowees = defaultFollowees;
this.MostRecentMonthlyNodeProviderRewards = mostRecentMonthlyNodeProviderRewards;
Expand All @@ -78,81 +79,5 @@ public Governance(List<Governance.DefaultFolloweesItemRecord> defaultFollowees,
public Governance()
{
}

public class DefaultFolloweesItemRecord
{
[CandidTag(0U)]
public int F0 { get; set; }

[CandidTag(1U)]
public Followees F1 { get; set; }

public DefaultFolloweesItemRecord(int f0, Followees f1)
{
this.F0 = f0;
this.F1 = f1;
}

public DefaultFolloweesItemRecord()
{
}
}

public class ProposalsItemRecord
{
[CandidTag(0U)]
public ulong F0 { get; set; }

[CandidTag(1U)]
public ProposalData F1 { get; set; }

public ProposalsItemRecord(ulong f0, ProposalData f1)
{
this.F0 = f0;
this.F1 = f1;
}

public ProposalsItemRecord()
{
}
}

public class InFlightCommandsItemRecord
{
[CandidTag(0U)]
public ulong F0 { get; set; }

[CandidTag(1U)]
public NeuronInFlightCommand F1 { get; set; }

public InFlightCommandsItemRecord(ulong f0, NeuronInFlightCommand f1)
{
this.F0 = f0;
this.F1 = f1;
}

public InFlightCommandsItemRecord()
{
}
}

public class NeuronsItemRecord
{
[CandidTag(0U)]
public ulong F0 { get; set; }

[CandidTag(1U)]
public Neuron F1 { get; set; }

public NeuronsItemRecord(ulong f0, Neuron f1)
{
this.F0 = f0;
this.F1 = f1;
}

public NeuronsItemRecord()
{
}
}
}
}
88 changes: 6 additions & 82 deletions samples/Sample.Shared/Governance/Models/GovernanceCachedMetrics.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using EdjCase.ICP.Candid.Mapping;
using Sample.Shared.Governance.Models;
using System;
using System.Collections.Generic;

namespace Sample.Shared.Governance.Models
{
public class GovernanceCachedMetrics
{
[CandidName("not_dissolving_neurons_e8s_buckets")]
public List<GovernanceCachedMetrics.NotDissolvingNeuronsE8sBucketsItemRecord> NotDissolvingNeuronsE8sBuckets { get; set; }
public List<ValueTuple<ulong, double>> NotDissolvingNeuronsE8sBuckets { get; set; }

[CandidName("garbage_collectable_neurons_count")]
public ulong GarbageCollectableNeuronsCount { get; set; }
Expand All @@ -16,7 +16,7 @@ public class GovernanceCachedMetrics
public ulong NeuronsWithInvalidStakeCount { get; set; }

[CandidName("not_dissolving_neurons_count_buckets")]
public List<GovernanceCachedMetrics.NotDissolvingNeuronsCountBucketsItemRecord> NotDissolvingNeuronsCountBuckets { get; set; }
public List<ValueTuple<ulong, ulong>> NotDissolvingNeuronsCountBuckets { get; set; }

[CandidName("total_supply_icp")]
public ulong TotalSupplyIcp { get; set; }
Expand Down Expand Up @@ -46,21 +46,21 @@ public class GovernanceCachedMetrics
public ulong NeuronsWithLessThan6MonthsDissolveDelayE8s { get; set; }

[CandidName("dissolving_neurons_count_buckets")]
public List<GovernanceCachedMetrics.DissolvingNeuronsCountBucketsItemRecord> DissolvingNeuronsCountBuckets { get; set; }
public List<ValueTuple<ulong, ulong>> DissolvingNeuronsCountBuckets { get; set; }

[CandidName("dissolving_neurons_count")]
public ulong DissolvingNeuronsCount { get; set; }

[CandidName("dissolving_neurons_e8s_buckets")]
public List<GovernanceCachedMetrics.DissolvingNeuronsE8sBucketsItemRecord> DissolvingNeuronsE8sBuckets { get; set; }
public List<ValueTuple<ulong, double>> DissolvingNeuronsE8sBuckets { get; set; }

[CandidName("community_fund_total_staked_e8s")]
public ulong CommunityFundTotalStakedE8s { get; set; }

[CandidName("timestamp_seconds")]
public ulong TimestampSeconds { get; set; }

public GovernanceCachedMetrics(List<GovernanceCachedMetrics.NotDissolvingNeuronsE8sBucketsItemRecord> notDissolvingNeuronsE8sBuckets, ulong garbageCollectableNeuronsCount, ulong neuronsWithInvalidStakeCount, List<GovernanceCachedMetrics.NotDissolvingNeuronsCountBucketsItemRecord> notDissolvingNeuronsCountBuckets, ulong totalSupplyIcp, ulong neuronsWithLessThan6MonthsDissolveDelayCount, ulong dissolvedNeuronsCount, ulong communityFundTotalMaturityE8sEquivalent, ulong totalStakedE8s, ulong notDissolvingNeuronsCount, ulong totalLockedE8s, ulong dissolvedNeuronsE8s, ulong neuronsWithLessThan6MonthsDissolveDelayE8s, List<GovernanceCachedMetrics.DissolvingNeuronsCountBucketsItemRecord> dissolvingNeuronsCountBuckets, ulong dissolvingNeuronsCount, List<GovernanceCachedMetrics.DissolvingNeuronsE8sBucketsItemRecord> dissolvingNeuronsE8sBuckets, ulong communityFundTotalStakedE8s, ulong timestampSeconds)
public GovernanceCachedMetrics(List<ValueTuple<ulong, double>> notDissolvingNeuronsE8sBuckets, ulong garbageCollectableNeuronsCount, ulong neuronsWithInvalidStakeCount, List<ValueTuple<ulong, ulong>> notDissolvingNeuronsCountBuckets, ulong totalSupplyIcp, ulong neuronsWithLessThan6MonthsDissolveDelayCount, ulong dissolvedNeuronsCount, ulong communityFundTotalMaturityE8sEquivalent, ulong totalStakedE8s, ulong notDissolvingNeuronsCount, ulong totalLockedE8s, ulong dissolvedNeuronsE8s, ulong neuronsWithLessThan6MonthsDissolveDelayE8s, List<ValueTuple<ulong, ulong>> dissolvingNeuronsCountBuckets, ulong dissolvingNeuronsCount, List<ValueTuple<ulong, double>> dissolvingNeuronsE8sBuckets, ulong communityFundTotalStakedE8s, ulong timestampSeconds)
{
this.NotDissolvingNeuronsE8sBuckets = notDissolvingNeuronsE8sBuckets;
this.GarbageCollectableNeuronsCount = garbageCollectableNeuronsCount;
Expand All @@ -85,81 +85,5 @@ public GovernanceCachedMetrics(List<GovernanceCachedMetrics.NotDissolvingNeurons
public GovernanceCachedMetrics()
{
}

public class NotDissolvingNeuronsE8sBucketsItemRecord
{
[CandidTag(0U)]
public ulong F0 { get; set; }

[CandidTag(1U)]
public double F1 { get; set; }

public NotDissolvingNeuronsE8sBucketsItemRecord(ulong f0, double f1)
{
this.F0 = f0;
this.F1 = f1;
}

public NotDissolvingNeuronsE8sBucketsItemRecord()
{
}
}

public class NotDissolvingNeuronsCountBucketsItemRecord
{
[CandidTag(0U)]
public ulong F0 { get; set; }

[CandidTag(1U)]
public ulong F1 { get; set; }

public NotDissolvingNeuronsCountBucketsItemRecord(ulong f0, ulong f1)
{
this.F0 = f0;
this.F1 = f1;
}

public NotDissolvingNeuronsCountBucketsItemRecord()
{
}
}

public class DissolvingNeuronsCountBucketsItemRecord
{
[CandidTag(0U)]
public ulong F0 { get; set; }

[CandidTag(1U)]
public ulong F1 { get; set; }

public DissolvingNeuronsCountBucketsItemRecord(ulong f0, ulong f1)
{
this.F0 = f0;
this.F1 = f1;
}

public DissolvingNeuronsCountBucketsItemRecord()
{
}
}

public class DissolvingNeuronsE8sBucketsItemRecord
{
[CandidTag(0U)]
public ulong F0 { get; set; }

[CandidTag(1U)]
public double F1 { get; set; }

public DissolvingNeuronsE8sBucketsItemRecord(ulong f0, double f1)
{
this.F0 = f0;
this.F1 = f1;
}

public DissolvingNeuronsE8sBucketsItemRecord()
{
}
}
}
}
24 changes: 3 additions & 21 deletions samples/Sample.Shared/Governance/Models/ListNeuronsResponse.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
using EdjCase.ICP.Candid.Mapping;
using Sample.Shared.Governance.Models;
using System;
using System.Collections.Generic;

namespace Sample.Shared.Governance.Models
{
public class ListNeuronsResponse
{
[CandidName("neuron_infos")]
public List<ListNeuronsResponse.NeuronInfosItemRecord> NeuronInfos { get; set; }
public List<ValueTuple<ulong, NeuronInfo>> NeuronInfos { get; set; }

[CandidName("full_neurons")]
public List<Neuron> FullNeurons { get; set; }

public ListNeuronsResponse(List<ListNeuronsResponse.NeuronInfosItemRecord> neuronInfos, List<Neuron> fullNeurons)
public ListNeuronsResponse(List<ValueTuple<ulong, NeuronInfo>> neuronInfos, List<Neuron> fullNeurons)
{
this.NeuronInfos = neuronInfos;
this.FullNeurons = fullNeurons;
Expand All @@ -21,24 +22,5 @@ public ListNeuronsResponse(List<ListNeuronsResponse.NeuronInfosItemRecord> neuro
public ListNeuronsResponse()
{
}

public class NeuronInfosItemRecord
{
[CandidTag(0U)]
public ulong F0 { get; set; }

[CandidTag(1U)]
public NeuronInfo F1 { get; set; }

public NeuronInfosItemRecord(ulong f0, NeuronInfo f1)
{
this.F0 = f0;
this.F1 = f1;
}

public NeuronInfosItemRecord()
{
}
}
}
}
24 changes: 3 additions & 21 deletions samples/Sample.Shared/Governance/Models/Neuron.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Sample.Shared.Governance.Models;
using EdjCase.ICP.Candid.Models;
using System.Collections.Generic;
using System;

namespace Sample.Shared.Governance.Models
{
Expand Down Expand Up @@ -53,7 +54,7 @@ public class Neuron
public OptionalValue<DissolveState> DissolveState { get; set; }

[CandidName("followees")]
public List<Neuron.FolloweesItemRecord> Followees { get; set; }
public List<ValueTuple<int, Followees>> Followees { get; set; }

[CandidName("neuron_fees_e8s")]
public ulong NeuronFeesE8s { get; set; }
Expand All @@ -67,7 +68,7 @@ public class Neuron
[CandidName("spawn_at_timestamp_seconds")]
public OptionalValue<ulong> SpawnAtTimestampSeconds { get; set; }

public Neuron(OptionalValue<NeuronId> id, OptionalValue<ulong> stakedMaturityE8sEquivalent, OptionalValue<Principal> controller, List<BallotInfo> recentBallots, bool kycVerified, bool notForProfit, ulong maturityE8sEquivalent, ulong cachedNeuronStakeE8s, ulong createdTimestampSeconds, OptionalValue<bool> autoStakeMaturity, ulong agingSinceTimestampSeconds, List<Principal> hotKeys, List<byte> account, OptionalValue<ulong> joinedCommunityFundTimestampSeconds, OptionalValue<DissolveState> dissolveState, List<Neuron.FolloweesItemRecord> followees, ulong neuronFeesE8s, OptionalValue<NeuronStakeTransfer> transfer, OptionalValue<KnownNeuronData> knownNeuronData, OptionalValue<ulong> spawnAtTimestampSeconds)
public Neuron(OptionalValue<NeuronId> id, OptionalValue<ulong> stakedMaturityE8sEquivalent, OptionalValue<Principal> controller, List<BallotInfo> recentBallots, bool kycVerified, bool notForProfit, ulong maturityE8sEquivalent, ulong cachedNeuronStakeE8s, ulong createdTimestampSeconds, OptionalValue<bool> autoStakeMaturity, ulong agingSinceTimestampSeconds, List<Principal> hotKeys, List<byte> account, OptionalValue<ulong> joinedCommunityFundTimestampSeconds, OptionalValue<DissolveState> dissolveState, List<ValueTuple<int, Followees>> followees, ulong neuronFeesE8s, OptionalValue<NeuronStakeTransfer> transfer, OptionalValue<KnownNeuronData> knownNeuronData, OptionalValue<ulong> spawnAtTimestampSeconds)
{
this.Id = id;
this.StakedMaturityE8sEquivalent = stakedMaturityE8sEquivalent;
Expand All @@ -94,24 +95,5 @@ public Neuron(OptionalValue<NeuronId> id, OptionalValue<ulong> stakedMaturityE8s
public Neuron()
{
}

public class FolloweesItemRecord
{
[CandidTag(0U)]
public int F0 { get; set; }

[CandidTag(1U)]
public Followees F1 { get; set; }

public FolloweesItemRecord(int f0, Followees f1)
{
this.F0 = f0;
this.F1 = f1;
}

public FolloweesItemRecord()
{
}
}
}
}
Loading

0 comments on commit 45f9e1a

Please sign in to comment.