Skip to content

Commit

Permalink
feat(services): add StateProof APIs
Browse files Browse the repository at this point in the history
Update Algod and Indexer clients with the latest state proof APIs. Also add implicit conversions
between Unity and Dotnet model types.

BREAKING CHANGE: Algod no longer has `GetProof` method

fix #160, fix #162
  • Loading branch information
jasonboukheir committed Nov 16, 2022
1 parent 8810be2 commit f0eaaf0
Show file tree
Hide file tree
Showing 17 changed files with 2,977 additions and 831 deletions.
10 changes: 10 additions & 0 deletions Runtime/CareBoo.AlgoSdk/Accounts/Address.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ public static Address FromPublicKey(Ed25519.PublicKey publicKey)
return result;
}

public static implicit operator Algorand.Address(Address unityAddress)
{
return unityAddress.Convert().ToDotnet<Algorand.Address>();
}

public static implicit operator Address(Algorand.Address from)
{
return from.Convert().ToUnity<Address>();
}

public static bool operator ==(in Address a1, in Address a2)
{
return a1.Equals(a2);
Expand Down
126 changes: 111 additions & 15 deletions Runtime/CareBoo.AlgoSdk/Formatters.gen/AlgodTypes.gen.Formatters.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ namespace AlgoSdk.Algod
{


public partial struct StateProofMessage
{

private static bool @__generated__IsValid = StateProofMessage.@__generated__InitializeAlgoApiFormatters();

private static bool @__generated__InitializeAlgoApiFormatters()
{
AlgoSdk.AlgoApiFormatterLookup.Add<AlgoSdk.Algod.StateProofMessage>(new AlgoSdk.AlgoApiObjectFormatter<AlgoSdk.Algod.StateProofMessage>(false).Assign("BlockHeadersCommitment", (AlgoSdk.Algod.StateProofMessage x) => x.BlockHeadersCommitment, (ref AlgoSdk.Algod.StateProofMessage x, System.Byte[] value) => x.BlockHeadersCommitment = value, AlgoSdk.ArrayComparer<System.Byte>.Instance).Assign("VotersCommitment", (AlgoSdk.Algod.StateProofMessage x) => x.VotersCommitment, (ref AlgoSdk.Algod.StateProofMessage x, System.Byte[] value) => x.VotersCommitment = value, AlgoSdk.ArrayComparer<System.Byte>.Instance).Assign("LnProvenWeight", (AlgoSdk.Algod.StateProofMessage x) => x.LnProvenWeight, (ref AlgoSdk.Algod.StateProofMessage x, System.UInt64 value) => x.LnProvenWeight = value).Assign("FirstAttestedRound", (AlgoSdk.Algod.StateProofMessage x) => x.FirstAttestedRound, (ref AlgoSdk.Algod.StateProofMessage x, System.UInt64 value) => x.FirstAttestedRound = value).Assign("LastAttestedRound", (AlgoSdk.Algod.StateProofMessage x) => x.LastAttestedRound, (ref AlgoSdk.Algod.StateProofMessage x, System.UInt64 value) => x.LastAttestedRound = value));
return true;
}
}
}
namespace AlgoSdk.Algod
{


public partial struct ApplicationParams
{

Expand Down Expand Up @@ -140,6 +156,22 @@ namespace AlgoSdk.Algod
{


public partial struct StateProof
{

private static bool @__generated__IsValid = StateProof.@__generated__InitializeAlgoApiFormatters();

private static bool @__generated__InitializeAlgoApiFormatters()
{
AlgoSdk.AlgoApiFormatterLookup.Add<AlgoSdk.Algod.StateProof>(new AlgoSdk.AlgoApiObjectFormatter<AlgoSdk.Algod.StateProof>(false).Assign("Message", (AlgoSdk.Algod.StateProof x) => x.Message, (ref AlgoSdk.Algod.StateProof x, AlgoSdk.Algod.StateProofMessage value) => x.Message = value).Assign("StateProof", (AlgoSdk.Algod.StateProof x) => x.EncodedStateProof, (ref AlgoSdk.Algod.StateProof x, System.Byte[] value) => x.EncodedStateProof = value, AlgoSdk.ArrayComparer<System.Byte>.Instance));
return true;
}
}
}
namespace AlgoSdk.Algod
{


public partial struct Asset
{

Expand Down Expand Up @@ -268,6 +300,22 @@ namespace AlgoSdk.Algod
{


public partial struct LightBlockHeaderProof
{

private static bool @__generated__IsValid = LightBlockHeaderProof.@__generated__InitializeAlgoApiFormatters();

private static bool @__generated__InitializeAlgoApiFormatters()
{
AlgoSdk.AlgoApiFormatterLookup.Add<AlgoSdk.Algod.LightBlockHeaderProof>(new AlgoSdk.AlgoApiObjectFormatter<AlgoSdk.Algod.LightBlockHeaderProof>(false).Assign("index", (AlgoSdk.Algod.LightBlockHeaderProof x) => x.Index, (ref AlgoSdk.Algod.LightBlockHeaderProof x, System.UInt64 value) => x.Index = value).Assign("treedepth", (AlgoSdk.Algod.LightBlockHeaderProof x) => x.Treedepth, (ref AlgoSdk.Algod.LightBlockHeaderProof x, System.UInt64 value) => x.Treedepth = value).Assign("proof", (AlgoSdk.Algod.LightBlockHeaderProof x) => x.Proof, (ref AlgoSdk.Algod.LightBlockHeaderProof x, System.Byte[] value) => x.Proof = value, AlgoSdk.ArrayComparer<System.Byte>.Instance));
return true;
}
}
}
namespace AlgoSdk.Algod
{


public partial struct Application
{

Expand Down Expand Up @@ -412,14 +460,14 @@ namespace AlgoSdk.Algod
{


public partial struct CatchpointStartResponse
public partial struct TransactionProofResponse
{

private static bool @__generated__IsValid = CatchpointStartResponse.@__generated__InitializeAlgoApiFormatters();
private static bool @__generated__IsValid = TransactionProofResponse.@__generated__InitializeAlgoApiFormatters();

private static bool @__generated__InitializeAlgoApiFormatters()
{
AlgoSdk.AlgoApiFormatterLookup.Add<AlgoSdk.Algod.CatchpointStartResponse>(new AlgoSdk.AlgoApiObjectFormatter<AlgoSdk.Algod.CatchpointStartResponse>(false).Assign("catchup-message", (AlgoSdk.Algod.CatchpointStartResponse x) => x.CatchupMessage, (ref AlgoSdk.Algod.CatchpointStartResponse x, System.String value) => x.CatchupMessage = value, AlgoSdk.StringComparer.Instance));
AlgoSdk.AlgoApiFormatterLookup.Add<AlgoSdk.Algod.TransactionProofResponse>(new AlgoSdk.AlgoApiObjectFormatter<AlgoSdk.Algod.TransactionProofResponse>(false).Assign("proof", (AlgoSdk.Algod.TransactionProofResponse x) => x.Proof, (ref AlgoSdk.Algod.TransactionProofResponse x, System.Byte[] value) => x.Proof = value, AlgoSdk.ArrayComparer<System.Byte>.Instance).Assign("stibhash", (AlgoSdk.Algod.TransactionProofResponse x) => x.Stibhash, (ref AlgoSdk.Algod.TransactionProofResponse x, System.Byte[] value) => x.Stibhash = value, AlgoSdk.ArrayComparer<System.Byte>.Instance).Assign("treedepth", (AlgoSdk.Algod.TransactionProofResponse x) => x.Treedepth, (ref AlgoSdk.Algod.TransactionProofResponse x, System.UInt64 value) => x.Treedepth = value).Assign("idx", (AlgoSdk.Algod.TransactionProofResponse x) => x.Idx, (ref AlgoSdk.Algod.TransactionProofResponse x, System.UInt64 value) => x.Idx = value).Assign("hashtype", (AlgoSdk.Algod.TransactionProofResponse x) => x.Hashtype, (ref AlgoSdk.Algod.TransactionProofResponse x, System.String value) => x.Hashtype = value, AlgoSdk.StringComparer.Instance));
return true;
}
}
Expand All @@ -428,14 +476,14 @@ namespace AlgoSdk.Algod
{


public partial struct PostParticipationResponse
public partial struct BlockHashResponse
{

private static bool @__generated__IsValid = PostParticipationResponse.@__generated__InitializeAlgoApiFormatters();
private static bool @__generated__IsValid = BlockHashResponse.@__generated__InitializeAlgoApiFormatters();

private static bool @__generated__InitializeAlgoApiFormatters()
{
AlgoSdk.AlgoApiFormatterLookup.Add<AlgoSdk.Algod.PostParticipationResponse>(new AlgoSdk.AlgoApiObjectFormatter<AlgoSdk.Algod.PostParticipationResponse>(false).Assign("partId", (AlgoSdk.Algod.PostParticipationResponse x) => x.PartId, (ref AlgoSdk.Algod.PostParticipationResponse x, System.String value) => x.PartId = value, AlgoSdk.StringComparer.Instance));
AlgoSdk.AlgoApiFormatterLookup.Add<AlgoSdk.Algod.BlockHashResponse>(new AlgoSdk.AlgoApiObjectFormatter<AlgoSdk.Algod.BlockHashResponse>(false).Assign("blockHash", (AlgoSdk.Algod.BlockHashResponse x) => x.BlockHash, (ref AlgoSdk.Algod.BlockHashResponse x, System.String value) => x.BlockHash = value, AlgoSdk.StringComparer.Instance));
return true;
}
}
Expand All @@ -444,14 +492,14 @@ namespace AlgoSdk.Algod
{


public partial struct CompileResponse
public partial struct CatchpointStartResponse
{

private static bool @__generated__IsValid = CompileResponse.@__generated__InitializeAlgoApiFormatters();
private static bool @__generated__IsValid = CatchpointStartResponse.@__generated__InitializeAlgoApiFormatters();

private static bool @__generated__InitializeAlgoApiFormatters()
{
AlgoSdk.AlgoApiFormatterLookup.Add<AlgoSdk.Algod.CompileResponse>(new AlgoSdk.AlgoApiObjectFormatter<AlgoSdk.Algod.CompileResponse>(false).Assign("hash", (AlgoSdk.Algod.CompileResponse x) => x.Hash, (ref AlgoSdk.Algod.CompileResponse x, System.String value) => x.Hash = value, AlgoSdk.StringComparer.Instance).Assign("result", (AlgoSdk.Algod.CompileResponse x) => x.Result, (ref AlgoSdk.Algod.CompileResponse x, System.String value) => x.Result = value, AlgoSdk.StringComparer.Instance).Assign("sourcemap", (AlgoSdk.Algod.CompileResponse x) => x.Sourcemap, (ref AlgoSdk.Algod.CompileResponse x, AlgoSdk.AlgoApiObject value) => x.Sourcemap = value));
AlgoSdk.AlgoApiFormatterLookup.Add<AlgoSdk.Algod.CatchpointStartResponse>(new AlgoSdk.AlgoApiObjectFormatter<AlgoSdk.Algod.CatchpointStartResponse>(false).Assign("catchup-message", (AlgoSdk.Algod.CatchpointStartResponse x) => x.CatchupMessage, (ref AlgoSdk.Algod.CatchpointStartResponse x, System.String value) => x.CatchupMessage = value, AlgoSdk.StringComparer.Instance));
return true;
}
}
Expand All @@ -460,14 +508,30 @@ namespace AlgoSdk.Algod
{


public partial struct DisassembleResponse
public partial struct PostParticipationResponse
{

private static bool @__generated__IsValid = DisassembleResponse.@__generated__InitializeAlgoApiFormatters();
private static bool @__generated__IsValid = PostParticipationResponse.@__generated__InitializeAlgoApiFormatters();

private static bool @__generated__InitializeAlgoApiFormatters()
{
AlgoSdk.AlgoApiFormatterLookup.Add<AlgoSdk.Algod.DisassembleResponse>(new AlgoSdk.AlgoApiObjectFormatter<AlgoSdk.Algod.DisassembleResponse>(false).Assign("result", (AlgoSdk.Algod.DisassembleResponse x) => x.Result, (ref AlgoSdk.Algod.DisassembleResponse x, System.String value) => x.Result = value, AlgoSdk.StringComparer.Instance));
AlgoSdk.AlgoApiFormatterLookup.Add<AlgoSdk.Algod.PostParticipationResponse>(new AlgoSdk.AlgoApiObjectFormatter<AlgoSdk.Algod.PostParticipationResponse>(false).Assign("partId", (AlgoSdk.Algod.PostParticipationResponse x) => x.PartId, (ref AlgoSdk.Algod.PostParticipationResponse x, System.String value) => x.PartId = value, AlgoSdk.StringComparer.Instance));
return true;
}
}
}
namespace AlgoSdk.Algod
{


public partial struct CompileResponse
{

private static bool @__generated__IsValid = CompileResponse.@__generated__InitializeAlgoApiFormatters();

private static bool @__generated__InitializeAlgoApiFormatters()
{
AlgoSdk.AlgoApiFormatterLookup.Add<AlgoSdk.Algod.CompileResponse>(new AlgoSdk.AlgoApiObjectFormatter<AlgoSdk.Algod.CompileResponse>(false).Assign("hash", (AlgoSdk.Algod.CompileResponse x) => x.Hash, (ref AlgoSdk.Algod.CompileResponse x, System.String value) => x.Hash = value, AlgoSdk.StringComparer.Instance).Assign("result", (AlgoSdk.Algod.CompileResponse x) => x.Result, (ref AlgoSdk.Algod.CompileResponse x, System.String value) => x.Result = value, AlgoSdk.StringComparer.Instance).Assign("sourcemap", (AlgoSdk.Algod.CompileResponse x) => x.Sourcemap, (ref AlgoSdk.Algod.CompileResponse x, AlgoSdk.AlgoApiObject value) => x.Sourcemap = value));
return true;
}
}
Expand All @@ -476,14 +540,14 @@ namespace AlgoSdk.Algod
{


public partial struct ProofResponse
public partial struct DisassembleResponse
{

private static bool @__generated__IsValid = ProofResponse.@__generated__InitializeAlgoApiFormatters();
private static bool @__generated__IsValid = DisassembleResponse.@__generated__InitializeAlgoApiFormatters();

private static bool @__generated__InitializeAlgoApiFormatters()
{
AlgoSdk.AlgoApiFormatterLookup.Add<AlgoSdk.Algod.ProofResponse>(new AlgoSdk.AlgoApiObjectFormatter<AlgoSdk.Algod.ProofResponse>(false).Assign("proof", (AlgoSdk.Algod.ProofResponse x) => x.Proof, (ref AlgoSdk.Algod.ProofResponse x, System.Byte[] value) => x.Proof = value, AlgoSdk.ArrayComparer<System.Byte>.Instance).Assign("stibhash", (AlgoSdk.Algod.ProofResponse x) => x.Stibhash, (ref AlgoSdk.Algod.ProofResponse x, System.Byte[] value) => x.Stibhash = value, AlgoSdk.ArrayComparer<System.Byte>.Instance).Assign("treedepth", (AlgoSdk.Algod.ProofResponse x) => x.Treedepth, (ref AlgoSdk.Algod.ProofResponse x, System.UInt64 value) => x.Treedepth = value).Assign("idx", (AlgoSdk.Algod.ProofResponse x) => x.Idx, (ref AlgoSdk.Algod.ProofResponse x, System.UInt64 value) => x.Idx = value).Assign("hashtype", (AlgoSdk.Algod.ProofResponse x) => x.Hashtype, (ref AlgoSdk.Algod.ProofResponse x, System.String value) => x.Hashtype = value, AlgoSdk.StringComparer.Instance));
AlgoSdk.AlgoApiFormatterLookup.Add<AlgoSdk.Algod.DisassembleResponse>(new AlgoSdk.AlgoApiObjectFormatter<AlgoSdk.Algod.DisassembleResponse>(false).Assign("result", (AlgoSdk.Algod.DisassembleResponse x) => x.Result, (ref AlgoSdk.Algod.DisassembleResponse x, System.String value) => x.Result = value, AlgoSdk.StringComparer.Instance));
return true;
}
}
Expand Down Expand Up @@ -668,6 +732,22 @@ namespace AlgoSdk.Algod
{


public partial struct LightBlockHeaderProofResponse
{

private static bool @__generated__IsValid = LightBlockHeaderProofResponse.@__generated__InitializeAlgoApiFormatters();

private static bool @__generated__InitializeAlgoApiFormatters()
{
AlgoSdk.AlgoApiFormatterLookup.Add<AlgoSdk.Algod.LightBlockHeaderProofResponse>(new AlgoSdk.WrappedValueFormatter<AlgoSdk.Algod.LightBlockHeaderProofResponse, AlgoSdk.Algod.LightBlockHeaderProof>());
return true;
}
}
}
namespace AlgoSdk.Algod
{


public partial struct AssetResponse
{

Expand Down Expand Up @@ -700,6 +780,22 @@ namespace AlgoSdk.Algod
{


public partial struct StateProofResponse
{

private static bool @__generated__IsValid = StateProofResponse.@__generated__InitializeAlgoApiFormatters();

private static bool @__generated__InitializeAlgoApiFormatters()
{
AlgoSdk.AlgoApiFormatterLookup.Add<AlgoSdk.Algod.StateProofResponse>(new AlgoSdk.WrappedValueFormatter<AlgoSdk.Algod.StateProofResponse, AlgoSdk.Algod.StateProof>());
return true;
}
}
}
namespace AlgoSdk.Algod
{


public partial struct ParticipationKeysResponse
{

Expand Down
Loading

0 comments on commit f0eaaf0

Please sign in to comment.