-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding enum variant types * Only decorating fields with changed names * Fixing type naming for anon types * Fixing tests * Removing language folders from client gen * Updating sample clients * Update Sample.Shared.csproj * Fixing namespace bug * Fixing tests
- Loading branch information
Showing
101 changed files
with
3,065 additions
and
2,484 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 |
---|---|---|
@@ -1,208 +1,124 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using System.Collections.Generic; | ||
using Token = EdjCase.ICP.Candid.Models.Principal; | ||
using OrderId = System.UInt32; | ||
using EdjCase.ICP.Agent.Agents; | ||
using EdjCase.ICP.Agent.Responses; | ||
using EdjCase.ICP.Candid.Models; | ||
using Sample.Shared.Dex.Models; | ||
using System.Threading.Tasks; | ||
using System.Collections.Generic; | ||
using EdjCase.ICP.Agent.Responses; | ||
|
||
namespace Sample.Shared.Dex | ||
{ | ||
public class DexApiClient | ||
{ | ||
public IAgent Agent { get; } | ||
|
||
public Principal CanisterId { get; } | ||
public DexApiClient(EdjCase.ICP.Agent.Agents.IAgent agent, EdjCase.ICP.Candid.Models.Principal canisterId) | ||
|
||
public DexApiClient(IAgent agent, Principal canisterId) | ||
{ | ||
this.Agent = agent ?? throw new ArgumentNullException(nameof(agent)); | ||
this.CanisterId = canisterId ?? throw new ArgumentNullException(nameof(canisterId)); | ||
this.Agent = agent; | ||
this.CanisterId = canisterId; | ||
} | ||
public async Task<CancelOrderReceipt> CancelOrder(OrderId arg0) | ||
|
||
public async System.Threading.Tasks.Task<CancelOrderReceipt> CancelOrder(OrderId arg0) | ||
{ | ||
string method = "cancelOrder"; | ||
CandidTypedValue p0 = CandidTypedValue.FromObject(arg0); | ||
var candidArgs = new List<CandidTypedValue> | ||
{ | ||
p0, | ||
}; | ||
CandidArg arg = CandidArg.FromCandid(candidArgs); | ||
CandidArg responseArg = await this.Agent.CallAndWaitAsync(this.CanisterId, method, arg, null, null); | ||
CancelOrderReceipt r0 = responseArg.Values[0].ToObject<CancelOrderReceipt>(); | ||
return (r0); | ||
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0)); | ||
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "cancelOrder", arg); | ||
return reply.ToObjects<CancelOrderReceipt>(); | ||
} | ||
|
||
public async Task Clear() | ||
{ | ||
string method = "clear"; | ||
var candidArgs = new List<CandidTypedValue> | ||
{ | ||
}; | ||
CandidArg arg = CandidArg.FromCandid(candidArgs); | ||
CandidArg responseArg = await this.Agent.CallAndWaitAsync(this.CanisterId, method, arg, null, null); | ||
CandidArg arg = CandidArg.FromCandid(); | ||
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "clear", arg); | ||
} | ||
public async Task Credit(EdjCase.ICP.Candid.Models.Principal arg0, Token arg1, UnboundedUInt arg2) | ||
|
||
public async Task Credit(Principal arg0, Token arg1, UnboundedUInt arg2) | ||
{ | ||
string method = "credit"; | ||
CandidTypedValue p0 = CandidTypedValue.FromObject(arg0); | ||
CandidTypedValue p1 = CandidTypedValue.FromObject(arg1); | ||
CandidTypedValue p2 = CandidTypedValue.FromObject(arg2); | ||
var candidArgs = new List<CandidTypedValue> | ||
{ | ||
p0, | ||
p1, | ||
p2, | ||
}; | ||
CandidArg arg = CandidArg.FromCandid(candidArgs); | ||
CandidArg responseArg = await this.Agent.CallAndWaitAsync(this.CanisterId, method, arg, null, null); | ||
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0), CandidTypedValue.FromObject(arg1), CandidTypedValue.FromObject(arg2)); | ||
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "credit", arg); | ||
} | ||
public async Task<DepositReceipt> Deposit(Token arg0) | ||
|
||
public async System.Threading.Tasks.Task<DepositReceipt> Deposit(Token arg0) | ||
{ | ||
string method = "deposit"; | ||
CandidTypedValue p0 = CandidTypedValue.FromObject(arg0); | ||
var candidArgs = new List<CandidTypedValue> | ||
{ | ||
p0, | ||
}; | ||
CandidArg arg = CandidArg.FromCandid(candidArgs); | ||
CandidArg responseArg = await this.Agent.CallAndWaitAsync(this.CanisterId, method, arg); | ||
DepositReceipt r0 = responseArg.Values[0].ToObject<DepositReceipt>(); | ||
return (r0); | ||
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0)); | ||
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "deposit", arg); | ||
return reply.ToObjects<DepositReceipt>(); | ||
} | ||
public async Task<System.Collections.Generic.List<Balance>> GetAllBalances() | ||
|
||
public async System.Threading.Tasks.Task<List<Balance>> GetAllBalances() | ||
{ | ||
string method = "getAllBalances"; | ||
var candidArgs = new List<CandidTypedValue> | ||
{ | ||
}; | ||
CandidArg arg = CandidArg.FromCandid(candidArgs); | ||
QueryResponse response = await this.Agent.QueryAsync(this.CanisterId, method, arg); | ||
CandidArg arg = CandidArg.FromCandid(); | ||
QueryResponse response = await this.Agent.QueryAsync(this.CanisterId, "getAllBalances", arg); | ||
CandidArg reply = response.ThrowOrGetReply(); | ||
System.Collections.Generic.List<Balance> r0 = reply.Values[0].ToObject<System.Collections.Generic.List<Balance>>(); | ||
return (r0); | ||
return reply.ToObjects<List<Balance>>(); | ||
} | ||
public async Task<UnboundedUInt> GetBalance(Token arg0) | ||
|
||
public async System.Threading.Tasks.Task<UnboundedUInt> GetBalance(Token arg0) | ||
{ | ||
string method = "getBalance"; | ||
CandidTypedValue p0 = CandidTypedValue.FromObject(arg0); | ||
var candidArgs = new List<CandidTypedValue> | ||
{ | ||
p0, | ||
}; | ||
CandidArg arg = CandidArg.FromCandid(candidArgs); | ||
QueryResponse response = await this.Agent.QueryAsync(this.CanisterId, method, arg); | ||
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0)); | ||
QueryResponse response = await this.Agent.QueryAsync(this.CanisterId, "getBalance", arg); | ||
CandidArg reply = response.ThrowOrGetReply(); | ||
UnboundedUInt r0 = reply.Values[0].ToObject<UnboundedUInt>(); | ||
return (r0); | ||
return reply.ToObjects<UnboundedUInt>(); | ||
} | ||
public async Task<System.Collections.Generic.List<Balance>> GetBalances() | ||
|
||
public async System.Threading.Tasks.Task<List<Balance>> GetBalances() | ||
{ | ||
string method = "getBalances"; | ||
var candidArgs = new List<CandidTypedValue> | ||
{ | ||
}; | ||
CandidArg arg = CandidArg.FromCandid(candidArgs); | ||
QueryResponse response = await this.Agent.QueryAsync(this.CanisterId, method, arg); | ||
CandidArg arg = CandidArg.FromCandid(); | ||
QueryResponse response = await this.Agent.QueryAsync(this.CanisterId, "getBalances", arg); | ||
CandidArg reply = response.ThrowOrGetReply(); | ||
System.Collections.Generic.List<Balance> r0 = reply.Values[0].ToObject<System.Collections.Generic.List<Balance>>(); | ||
return (r0); | ||
return reply.ToObjects<List<Balance>>(); | ||
} | ||
public async Task<System.Collections.Generic.List<byte>> GetDepositAddress() | ||
|
||
public async System.Threading.Tasks.Task<List<byte>> GetDepositAddress() | ||
{ | ||
string method = "getDepositAddress"; | ||
var candidArgs = new List<CandidTypedValue> | ||
{ | ||
}; | ||
CandidArg arg = CandidArg.FromCandid(candidArgs); | ||
CandidArg responseArg = await this.Agent.CallAndWaitAsync(this.CanisterId, method, arg, null, null); | ||
System.Collections.Generic.List<byte> r0 = responseArg.Values[0].ToObject<System.Collections.Generic.List<byte>>(); | ||
return (r0); | ||
CandidArg arg = CandidArg.FromCandid(); | ||
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "getDepositAddress", arg); | ||
return reply.ToObjects<List<byte>>(); | ||
} | ||
public async Task<EdjCase.ICP.Candid.Models.OptionalValue<Order>> GetOrder(OrderId arg0) | ||
|
||
public async System.Threading.Tasks.Task<OptionalValue<Order>> GetOrder(OrderId arg0) | ||
{ | ||
string method = "getOrder"; | ||
CandidTypedValue p0 = CandidTypedValue.FromObject(arg0); | ||
var candidArgs = new List<CandidTypedValue> | ||
{ | ||
p0, | ||
}; | ||
CandidArg arg = CandidArg.FromCandid(candidArgs); | ||
CandidArg responseArg = await this.Agent.CallAndWaitAsync(this.CanisterId, method, arg, null, null); | ||
EdjCase.ICP.Candid.Models.OptionalValue<Order> r0 = responseArg.Values[0].ToObject<EdjCase.ICP.Candid.Models.OptionalValue<Order>>(); | ||
return (r0); | ||
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0)); | ||
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "getOrder", arg); | ||
return reply.ToObjects<OptionalValue<Order>>(); | ||
} | ||
public async Task<System.Collections.Generic.List<Order>> GetOrders() | ||
|
||
public async System.Threading.Tasks.Task<List<Order>> GetOrders() | ||
{ | ||
string method = "getOrders"; | ||
var candidArgs = new List<CandidTypedValue> | ||
{ | ||
}; | ||
CandidArg arg = CandidArg.FromCandid(candidArgs); | ||
CandidArg responseArg = await this.Agent.CallAndWaitAsync(this.CanisterId, method, arg, null, null); | ||
System.Collections.Generic.List<Order> r0 = responseArg.Values[0].ToObject<System.Collections.Generic.List<Order>>(); | ||
return (r0); | ||
CandidArg arg = CandidArg.FromCandid(); | ||
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "getOrders", arg); | ||
return reply.ToObjects<List<Order>>(); | ||
} | ||
public async Task<string> GetSymbol(Token arg0) | ||
|
||
public async System.Threading.Tasks.Task<string> GetSymbol(Token arg0) | ||
{ | ||
string method = "getSymbol"; | ||
CandidTypedValue p0 = CandidTypedValue.FromObject(arg0); | ||
var candidArgs = new List<CandidTypedValue> | ||
{ | ||
p0, | ||
}; | ||
CandidArg arg = CandidArg.FromCandid(candidArgs); | ||
CandidArg responseArg = await this.Agent.CallAndWaitAsync(this.CanisterId, method, arg, null, null); | ||
string r0 = responseArg.Values[0].ToObject<string>(); | ||
return (r0); | ||
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0)); | ||
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "getSymbol", arg); | ||
return reply.ToObjects<string>(); | ||
} | ||
public async Task<OrderPlacementReceipt> PlaceOrder(Token arg0, UnboundedUInt arg1, Token arg2, UnboundedUInt arg3) | ||
|
||
public async System.Threading.Tasks.Task<OrderPlacementReceipt> PlaceOrder(Token arg0, UnboundedUInt arg1, Token arg2, UnboundedUInt arg3) | ||
{ | ||
string method = "placeOrder"; | ||
CandidTypedValue p0 = CandidTypedValue.FromObject(arg0); | ||
CandidTypedValue p1 = CandidTypedValue.FromObject(arg1); | ||
CandidTypedValue p2 = CandidTypedValue.FromObject(arg2); | ||
CandidTypedValue p3 = CandidTypedValue.FromObject(arg3); | ||
var candidArgs = new List<CandidTypedValue> | ||
{ | ||
p0, | ||
p1, | ||
p2, | ||
p3, | ||
}; | ||
CandidArg arg = CandidArg.FromCandid(candidArgs); | ||
CandidArg responseArg = await this.Agent.CallAndWaitAsync(this.CanisterId, method, arg, null, null); | ||
OrderPlacementReceipt r0 = responseArg.Values[0].ToObject<OrderPlacementReceipt>(); | ||
return (r0); | ||
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0), CandidTypedValue.FromObject(arg1), CandidTypedValue.FromObject(arg2), CandidTypedValue.FromObject(arg3)); | ||
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "placeOrder", arg); | ||
return reply.ToObjects<OrderPlacementReceipt>(); | ||
} | ||
public async Task<EdjCase.ICP.Candid.Models.Principal> Whoami() | ||
|
||
public async System.Threading.Tasks.Task<Principal> Whoami() | ||
{ | ||
string method = "whoami"; | ||
var candidArgs = new List<CandidTypedValue> | ||
{ | ||
}; | ||
CandidArg arg = CandidArg.FromCandid(candidArgs); | ||
QueryResponse response = await this.Agent.QueryAsync(this.CanisterId, method, arg); | ||
CandidArg arg = CandidArg.FromCandid(); | ||
QueryResponse response = await this.Agent.QueryAsync(this.CanisterId, "whoami", arg); | ||
CandidArg reply = response.ThrowOrGetReply(); | ||
EdjCase.ICP.Candid.Models.Principal r0 = reply.Values[0].ToObject<EdjCase.ICP.Candid.Models.Principal>(); | ||
return (r0); | ||
return reply.ToObjects<Principal>(); | ||
} | ||
public async Task<WithdrawReceipt> Withdraw(Token arg0, UnboundedUInt arg1, EdjCase.ICP.Candid.Models.Principal arg2) | ||
|
||
public async System.Threading.Tasks.Task<WithdrawReceipt> Withdraw(Token arg0, UnboundedUInt arg1, Principal arg2) | ||
{ | ||
string method = "withdraw"; | ||
CandidTypedValue p0 = CandidTypedValue.FromObject(arg0); | ||
CandidTypedValue p1 = CandidTypedValue.FromObject(arg1); | ||
CandidTypedValue p2 = CandidTypedValue.FromObject(arg2); | ||
var candidArgs = new List<CandidTypedValue> | ||
{ | ||
p0, | ||
p1, | ||
p2, | ||
}; | ||
CandidArg arg = CandidArg.FromCandid(candidArgs); | ||
CandidArg responseArg = await this.Agent.CallAndWaitAsync(this.CanisterId, method, arg, null, null); | ||
WithdrawReceipt r0 = responseArg.Values[0].ToObject<WithdrawReceipt>(); | ||
return (r0); | ||
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0), CandidTypedValue.FromObject(arg1), CandidTypedValue.FromObject(arg2)); | ||
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "withdraw", arg); | ||
return reply.ToObjects<WithdrawReceipt>(); | ||
} | ||
} | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1,19 +1,30 @@ | ||
using EdjCase.ICP.Candid.Models; | ||
using Token = EdjCase.ICP.Candid.Models.Principal; | ||
using OrderId = System.UInt32; | ||
using EdjCase.ICP.Candid.Mapping; | ||
using EdjCase.ICP.Candid.Models; | ||
|
||
namespace Sample.Shared.Dex.Models | ||
{ | ||
public class Balance | ||
{ | ||
[EdjCase.ICP.Candid.Mapping.CandidNameAttribute("amount")] | ||
[CandidName("amount")] | ||
public UnboundedUInt Amount { get; set; } | ||
[EdjCase.ICP.Candid.Mapping.CandidNameAttribute("owner")] | ||
public EdjCase.ICP.Candid.Models.Principal Owner { get; set; } | ||
[EdjCase.ICP.Candid.Mapping.CandidNameAttribute("token")] | ||
|
||
[CandidName("owner")] | ||
public Principal Owner { get; set; } | ||
|
||
[CandidName("token")] | ||
public Token Token { get; set; } | ||
|
||
} | ||
} | ||
|
||
public Balance(UnboundedUInt amount, Principal owner, Token token) | ||
{ | ||
this.Amount = amount; | ||
this.Owner = owner; | ||
this.Token = token; | ||
} | ||
|
||
public Balance() | ||
{ | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,39 +1,11 @@ | ||
using Token = EdjCase.ICP.Candid.Models.Principal; | ||
using OrderId = System.UInt32; | ||
|
||
namespace Sample.Shared.Dex.Models | ||
{ | ||
[EdjCase.ICP.Candid.Mapping.VariantAttribute(typeof(CancelOrderErrTag))] | ||
public class CancelOrderErr | ||
{ | ||
[EdjCase.ICP.Candid.Mapping.VariantTagPropertyAttribute] | ||
public CancelOrderErrTag Tag { get; set; } | ||
[EdjCase.ICP.Candid.Mapping.VariantValuePropertyAttribute] | ||
public object? Value { get; set; } | ||
private CancelOrderErr(CancelOrderErrTag tag, System.Object? value) | ||
{ | ||
this.Tag = tag; | ||
this.Value = value; | ||
} | ||
|
||
protected CancelOrderErr() | ||
{ | ||
} | ||
|
||
public static CancelOrderErr NotAllowed() | ||
{ | ||
return new CancelOrderErr(CancelOrderErrTag.NotAllowed, null); | ||
} | ||
|
||
public static CancelOrderErr NotExistingOrder() | ||
{ | ||
return new CancelOrderErr(CancelOrderErrTag.NotExistingOrder, null); | ||
} | ||
|
||
} | ||
public enum CancelOrderErrTag | ||
public enum CancelOrderErr | ||
{ | ||
[EdjCase.ICP.Candid.Mapping.CandidNameAttribute("NotAllowed")] | ||
NotAllowed, | ||
[EdjCase.ICP.Candid.Mapping.CandidNameAttribute("NotExistingOrder")] | ||
NotExistingOrder, | ||
NotExistingOrder | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.