Skip to content

Commit

Permalink
V3 call (#137)
Browse files Browse the repository at this point in the history
* Call v3

* V2 -> Asynchronous

* Adding Wait on 202 of v3 calls

* V3Call testing
  • Loading branch information
Gekctek authored Nov 5, 2024
1 parent 7117394 commit 441fc02
Show file tree
Hide file tree
Showing 79 changed files with 757 additions and 526 deletions.
16 changes: 3 additions & 13 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,10 @@
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"name": "Sample.RestAPI",
"type": "dotnet",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/Sample/bin/Debug/net8.0/Sample.dll",
"args": [],
"cwd": "${workspaceFolder}/src/Sample",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
"projectPath": "${workspaceFolder}/samples/Sample.RestAPI/Sample.RestAPI.csproj"
},
{
"name": ".NET Core Attach",
Expand Down
6 changes: 5 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
"${workspaceFolder}",
"/property:GenerateFullPaths=true"
],
"problemMatcher": "$msCompile"
"problemMatcher": "$msCompile",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
4 changes: 2 additions & 2 deletions samples/Sample.PocketIC/PocketIc.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public async Task HttpGateway_CounterWasm__Basic__Valid()


CancellationTokenSource cts = new(TimeSpan.FromSeconds(5));
CandidArg incResponseArg = await agent.CallAndWaitAsync(canisterId, "inc", CandidArg.Empty(), cancellationToken: cts.Token);
CandidArg incResponseArg = await agent.CallAsync(canisterId, "inc", CandidArg.Empty(), cancellationToken: cts.Token);
Assert.Equal(CandidArg.Empty(), incResponseArg);

// This alternative also doesnt work
Expand All @@ -137,7 +137,7 @@ public async Task HttpGateway_CounterWasm__Basic__Valid()
Assert.Equal((UnboundedUInt)1, getResponseValue);

CandidArg setRequestArg = CandidArg.FromObjects((UnboundedUInt)10);
CandidArg setResponseArg = await agent.CallAndWaitAsync(canisterId, "set", setRequestArg);
CandidArg setResponseArg = await agent.CallAsync(canisterId, "set", setRequestArg);
Assert.Equal(CandidArg.Empty(), setResponseArg);

getResponse = await agent.QueryAsync(canisterId, "get", CandidArg.Empty());
Expand Down
8 changes: 8 additions & 0 deletions samples/Sample.RestAPI/Controllers/GovernanceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,13 @@ public async Task<IActionResult> GetProposalInfo(ulong id)
OptionalValue<ProposalInfo> info = await this.Client.GetProposalInfo(id);
return this.Ok(info);
}

[Route("rewards")]
[HttpGet]
public async Task<IActionResult> GetRewards()
{
Result4 rewards = await this.Client.GetMonthlyNodeProviderRewards();
return this.Ok(rewards);
}
}
}
2 changes: 1 addition & 1 deletion samples/Sample.Shared/Address/AddressBookApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public AddressBookApiClient(IAgent agent, Principal canisterId, CandidConverter?
public async Task _set_address(string name, Address addr)
{
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(name, this.Converter), CandidTypedValue.FromObject(addr, this.Converter));
await this.Agent.CallAndWaitAsync(this.CanisterId, "set_address", arg);
await this.Agent.CallAsync(this.CanisterId, "set_address", arg);
}

public async Task<OptionalValue<Address>> _get_address(string name)
Expand Down
16 changes: 8 additions & 8 deletions samples/Sample.Shared/Dex/DexApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public DexApiClient(IAgent agent, Principal canisterId, CandidConverter? convert
public async Task<Models.CancelOrderReceipt> CancelOrder(OrderId arg0)
{
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0, this.Converter));
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "cancelOrder", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "cancelOrder", arg);
return reply.ToObjects<Models.CancelOrderReceipt>(this.Converter);
}

Expand All @@ -47,7 +47,7 @@ public async Task Credit(Principal arg0, Token arg1, UnboundedUInt arg2)
public async Task<Models.DepositReceipt> Deposit(Token arg0)
{
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0, this.Converter));
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "deposit", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "deposit", arg);
return reply.ToObjects<Models.DepositReceipt>(this.Converter);
}

Expand Down Expand Up @@ -78,35 +78,35 @@ public async Task<UnboundedUInt> GetBalance(Token arg0)
public async Task<List<byte>> GetDepositAddress()
{
CandidArg arg = CandidArg.FromCandid();
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "getDepositAddress", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "getDepositAddress", arg);
return reply.ToObjects<List<byte>>(this.Converter);
}

public async Task<OptionalValue<Models.Order>> GetOrder(OrderId arg0)
{
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0, this.Converter));
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "getOrder", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "getOrder", arg);
return reply.ToObjects<OptionalValue<Models.Order>>(this.Converter);
}

public async Task<List<Models.Order>> GetOrders()
{
CandidArg arg = CandidArg.FromCandid();
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "getOrders", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "getOrders", arg);
return reply.ToObjects<List<Models.Order>>(this.Converter);
}

public async Task<string> GetSymbol(Token arg0)
{
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0, this.Converter));
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "getSymbol", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "getSymbol", arg);
return reply.ToObjects<string>(this.Converter);
}

public async Task<Models.OrderPlacementReceipt> PlaceOrder(Token arg0, UnboundedUInt arg1, Token arg2, UnboundedUInt arg3)
{
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0, this.Converter), CandidTypedValue.FromObject(arg1, this.Converter), CandidTypedValue.FromObject(arg2, this.Converter), CandidTypedValue.FromObject(arg3, this.Converter));
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "placeOrder", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "placeOrder", arg);
return reply.ToObjects<Models.OrderPlacementReceipt>(this.Converter);
}

Expand All @@ -121,7 +121,7 @@ public async Task<Principal> Whoami()
public async Task<Models.WithdrawReceipt> Withdraw(Token arg0, UnboundedUInt arg1, Principal arg2)
{
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0, this.Converter), CandidTypedValue.FromObject(arg1, this.Converter), CandidTypedValue.FromObject(arg2, this.Converter));
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "withdraw", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "withdraw", arg);
return reply.ToObjects<Models.WithdrawReceipt>(this.Converter);
}
}
Expand Down
16 changes: 8 additions & 8 deletions samples/Sample.Shared/Governance/GovernanceApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public GovernanceApiClient(IAgent agent, Principal canisterId, CandidConverter?
public async Task<Models.Result> ClaimGtcNeurons(Principal arg0, List<Models.NeuronId> arg1)
{
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0, this.Converter), CandidTypedValue.FromObject(arg1, this.Converter));
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "claim_gtc_neurons", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "claim_gtc_neurons", arg);
return reply.ToObjects<Models.Result>(this.Converter);
}

public async Task<Models.ClaimOrRefreshNeuronFromAccountResponse> ClaimOrRefreshNeuronFromAccount(Models.ClaimOrRefreshNeuronFromAccount arg0)
{
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0, this.Converter));
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "claim_or_refresh_neuron_from_account", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "claim_or_refresh_neuron_from_account", arg);
return reply.ToObjects<Models.ClaimOrRefreshNeuronFromAccountResponse>(this.Converter);
}

Expand Down Expand Up @@ -80,7 +80,7 @@ public async Task<string> GetBuildMetadata()
public async Task<Models.Result4> GetMonthlyNodeProviderRewards()
{
CandidArg arg = CandidArg.FromCandid();
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "get_monthly_node_provider_rewards", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "get_monthly_node_provider_rewards", arg);
return reply.ToObjects<Models.Result4>(this.Converter);
}

Expand Down Expand Up @@ -183,35 +183,35 @@ public async Task<List<ulong>> GetNeuronIds()
public async Task<Models.ManageNeuronResponse> ManageNeuron(Models.ManageNeuron arg0)
{
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0, this.Converter));
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "manage_neuron", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "manage_neuron", arg);
return reply.ToObjects<Models.ManageNeuronResponse>(this.Converter);
}

public async Task<Models.Result> SettleCommunityFundParticipation(Models.SettleCommunityFundParticipation arg0)
{
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0, this.Converter));
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "settle_community_fund_participation", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "settle_community_fund_participation", arg);
return reply.ToObjects<Models.Result>(this.Converter);
}

public async Task<Models.ManageNeuronResponse> SimulateManageNeuron(Models.ManageNeuron arg0)
{
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0, this.Converter));
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "simulate_manage_neuron", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "simulate_manage_neuron", arg);
return reply.ToObjects<Models.ManageNeuronResponse>(this.Converter);
}

public async Task<Models.Result> TransferGtcNeuron(Models.NeuronId arg0, Models.NeuronId arg1)
{
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0, this.Converter), CandidTypedValue.FromObject(arg1, this.Converter));
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "transfer_gtc_neuron", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "transfer_gtc_neuron", arg);
return reply.ToObjects<Models.Result>(this.Converter);
}

public async Task<Models.Result> UpdateNodeProvider(Models.UpdateNodeProvider arg0)
{
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0, this.Converter));
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "update_node_provider", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "update_node_provider", arg);
return reply.ToObjects<Models.Result>(this.Converter);
}
}
Expand Down
6 changes: 3 additions & 3 deletions samples/Sample.Shared/ICRC1Ledger/ICRC1LedgerApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public async Task<Tokens> Icrc1BalanceOf(Models.Account arg0)
public async Task<Models.TransferResult> Icrc1Transfer(Models.TransferArg arg0)
{
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0, this.Converter));
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "icrc1_transfer", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "icrc1_transfer", arg);
return reply.ToObjects<Models.TransferResult>(this.Converter);
}

Expand All @@ -130,7 +130,7 @@ public async Task<Tokens> Icrc1BalanceOf(Models.Account arg0)
public async Task<Models.ApproveResult> Icrc2Approve(Models.ApproveArgs arg0)
{
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0, this.Converter));
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "icrc2_approve", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "icrc2_approve", arg);
return reply.ToObjects<Models.ApproveResult>(this.Converter);
}

Expand All @@ -145,7 +145,7 @@ public async Task<Tokens> Icrc1BalanceOf(Models.Account arg0)
public async Task<Models.TransferFromResult> Icrc2TransferFrom(Models.TransferFromArgs arg0)
{
CandidArg arg = CandidArg.FromCandid(CandidTypedValue.FromObject(arg0, this.Converter));
CandidArg reply = await this.Agent.CallAndWaitAsync(this.CanisterId, "icrc2_transfer_from", arg);
CandidArg reply = await this.Agent.CallAsync(this.CanisterId, "icrc2_transfer_from", arg);
return reply.ToObjects<Models.TransferFromResult>(this.Converter);
}
}
Expand Down
54 changes: 51 additions & 3 deletions src/Agent/API.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 441fc02

Please sign in to comment.