Skip to content

Commit 6f96500

Browse files
committed
change call to Call builder
1 parent 7247780 commit 6f96500

File tree

2 files changed

+211
-47
lines changed
  • rs/proposals/src/canisters

2 files changed

+211
-47
lines changed

rs/proposals/src/canisters/nns_governance/api.rs

Lines changed: 136 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#![allow(non_camel_case_types)]
77
#![allow(dead_code, unused_imports)]
88
use candid::{self, CandidType, Decode, Deserialize, Encode, Principal};
9-
use ic_cdk::api::call::CallResult;
9+
use ic_cdk::call::CallResult;
1010
use serde::Serialize;
1111

1212
#[derive(Serialize, CandidType, Deserialize)]
@@ -15,7 +15,7 @@ pub struct EmptyRecord {}
1515
// You may want to manually adjust some of the types.
1616
// #![allow(dead_code, unused_imports)]
1717
// use candid::{self, CandidType, Deserialize, Principal};
18-
// use ic_cdk::api::call::CallResult as Result;
18+
// use ic_cdk::call::CallResult as Result;
1919

2020
#[derive(Serialize, CandidType, Deserialize)]
2121
pub struct NeuronId {
@@ -1159,107 +1159,212 @@ pub struct UpdateNodeProvider {
11591159
pub struct Service(pub Principal);
11601160
impl Service {
11611161
pub async fn claim_gtc_neurons(&self, arg0: Principal, arg1: Vec<NeuronId>) -> CallResult<(Result_,)> {
1162-
ic_cdk::call(self.0, "claim_gtc_neurons", (arg0, arg1)).await
1162+
let response = Call::unbounded_wait(self.0, "claim_gtc_neurons")
1163+
.with_args((arg0, arg1))
1164+
.await?
1165+
.candid()?;
1166+
Ok(response)
11631167
}
11641168
pub async fn claim_or_refresh_neuron_from_account(
11651169
&self,
11661170
arg0: ClaimOrRefreshNeuronFromAccount,
11671171
) -> CallResult<(ClaimOrRefreshNeuronFromAccountResponse,)> {
1168-
ic_cdk::call(self.0, "claim_or_refresh_neuron_from_account", (arg0,)).await
1172+
let response = Call::unbounded_wait(self.0, "claim_or_refresh_neuron_from_account")
1173+
.with_arg(arg0)
1174+
.await?
1175+
.candid()?;
1176+
Ok(response)
11691177
}
11701178
pub async fn get_build_metadata(&self) -> CallResult<(String,)> {
1171-
ic_cdk::call(self.0, "get_build_metadata", ()).await
1179+
let response = Call::unbounded_wait(self.0, "get_build_metadata")
1180+
.await?
1181+
.candid()?;
1182+
Ok(response)
11721183
}
11731184
pub async fn get_full_neuron(&self, arg0: u64) -> CallResult<(Result2,)> {
1174-
ic_cdk::call(self.0, "get_full_neuron", (arg0,)).await
1185+
let response = Call::unbounded_wait(self.0, "get_full_neuron")
1186+
.with_arg(arg0)
1187+
.await?
1188+
.candid()?;
1189+
Ok(response)
11751190
}
11761191
pub async fn get_full_neuron_by_id_or_subaccount(&self, arg0: NeuronIdOrSubaccount) -> CallResult<(Result2,)> {
1177-
ic_cdk::call(self.0, "get_full_neuron_by_id_or_subaccount", (arg0,)).await
1192+
let response = Call::unbounded_wait(self.0, "get_full_neuron_by_id_or_subaccount")
1193+
.with_arg(arg0)
1194+
.await?
1195+
.candid()?;
1196+
Ok(response)
11781197
}
11791198
pub async fn get_latest_reward_event(&self) -> CallResult<(RewardEvent,)> {
1180-
ic_cdk::call(self.0, "get_latest_reward_event", ()).await
1199+
let response = Call::unbounded_wait(self.0, "get_latest_reward_event")
1200+
.await?
1201+
.candid()?;
1202+
Ok(response)
11811203
}
11821204
pub async fn get_metrics(&self) -> CallResult<(Result3,)> {
1183-
ic_cdk::call(self.0, "get_metrics", ()).await
1205+
let response = Call::unbounded_wait(self.0, "get_metrics")
1206+
.await?
1207+
.candid()?;
1208+
Ok(response)
11841209
}
11851210
pub async fn get_monthly_node_provider_rewards(&self) -> CallResult<(Result4,)> {
1186-
ic_cdk::call(self.0, "get_monthly_node_provider_rewards", ()).await
1211+
let response = Call::unbounded_wait(self.0, "get_monthly_node_provider_rewards")
1212+
.await?
1213+
.candid()?;
1214+
Ok(response)
11871215
}
11881216
pub async fn get_most_recent_monthly_node_provider_rewards(
11891217
&self,
11901218
) -> CallResult<(Option<MonthlyNodeProviderRewards>,)> {
1191-
ic_cdk::call(self.0, "get_most_recent_monthly_node_provider_rewards", ()).await
1219+
let response = Call::unbounded_wait(self.0, "get_most_recent_monthly_node_provider_rewards")
1220+
.await?
1221+
.candid()?;
1222+
Ok(response)
11921223
}
11931224
pub async fn get_network_economics_parameters(&self) -> CallResult<(NetworkEconomics,)> {
1194-
ic_cdk::call(self.0, "get_network_economics_parameters", ()).await
1225+
let response = Call::unbounded_wait(self.0, "get_network_economics_parameters")
1226+
.await?
1227+
.candid()?;
1228+
Ok(response)
11951229
}
11961230
pub async fn get_neuron_ids(&self) -> CallResult<(Vec<u64>,)> {
1197-
ic_cdk::call(self.0, "get_neuron_ids", ()).await
1231+
let response = Call::unbounded_wait(self.0, "get_neuron_ids")
1232+
.await?
1233+
.candid()?;
1234+
Ok(response)
11981235
}
11991236
pub async fn get_neuron_info(&self, arg0: u64) -> CallResult<(Result5,)> {
1200-
ic_cdk::call(self.0, "get_neuron_info", (arg0,)).await
1237+
let response = Call::unbounded_wait(self.0, "get_neuron_info")
1238+
.with_arg(arg0)
1239+
.await?
1240+
.candid()?;
1241+
Ok(response)
12011242
}
12021243
pub async fn get_neuron_info_by_id_or_subaccount(&self, arg0: NeuronIdOrSubaccount) -> CallResult<(Result5,)> {
1203-
ic_cdk::call(self.0, "get_neuron_info_by_id_or_subaccount", (arg0,)).await
1244+
let response = Call::unbounded_wait(self.0, "get_neuron_info_by_id_or_subaccount")
1245+
.with_arg(arg0)
1246+
.await?
1247+
.candid()?;
1248+
Ok(response)
12041249
}
12051250
pub async fn get_neurons_fund_audit_info(
12061251
&self,
12071252
arg0: GetNeuronsFundAuditInfoRequest,
12081253
) -> CallResult<(GetNeuronsFundAuditInfoResponse,)> {
1209-
ic_cdk::call(self.0, "get_neurons_fund_audit_info", (arg0,)).await
1254+
let response = Call::unbounded_wait(self.0, "get_neurons_fund_audit_info")
1255+
.with_arg(arg0)
1256+
.await?
1257+
.candid()?;
1258+
Ok(response)
12101259
}
12111260
pub async fn get_node_provider_by_caller(&self, arg0: ()) -> CallResult<(Result7,)> {
1212-
ic_cdk::call(self.0, "get_node_provider_by_caller", (arg0,)).await
1261+
let response = Call::unbounded_wait(self.0, "get_node_provider_by_caller")
1262+
.with_arg(arg0)
1263+
.await?
1264+
.candid()?;
1265+
Ok(response)
12131266
}
12141267
pub async fn get_pending_proposals(&self) -> CallResult<(Vec<ProposalInfo>,)> {
1215-
ic_cdk::call(self.0, "get_pending_proposals", ()).await
1268+
let response = Call::unbounded_wait(self.0, "get_pending_proposals")
1269+
.await?
1270+
.candid()?;
1271+
Ok(response)
12161272
}
12171273
pub async fn get_proposal_info(&self, arg0: u64) -> CallResult<(Option<ProposalInfo>,)> {
1218-
ic_cdk::call(self.0, "get_proposal_info", (arg0,)).await
1274+
let response = Call::unbounded_wait(self.0, "get_proposal_info")
1275+
.with_arg(arg0)
1276+
.await?
1277+
.candid()?;
1278+
Ok(response)
12191279
}
12201280
pub async fn get_restore_aging_summary(&self) -> CallResult<(RestoreAgingSummary,)> {
1221-
ic_cdk::call(self.0, "get_restore_aging_summary", ()).await
1281+
let response = Call::unbounded_wait(self.0, "get_restore_aging_summary")
1282+
.await?
1283+
.candid()?;
1284+
Ok(response)
12221285
}
12231286
pub async fn list_known_neurons(&self) -> CallResult<(ListKnownNeuronsResponse,)> {
1224-
ic_cdk::call(self.0, "list_known_neurons", ()).await
1287+
let response = Call::unbounded_wait(self.0, "list_known_neurons")
1288+
.await?
1289+
.candid()?;
1290+
Ok(response)
12251291
}
12261292
pub async fn list_neurons(&self, arg0: ListNeurons) -> CallResult<(ListNeuronsResponse,)> {
1227-
ic_cdk::call(self.0, "list_neurons", (arg0,)).await
1293+
let response = Call::unbounded_wait(self.0, "list_neurons")
1294+
.with_arg(arg0)
1295+
.await?
1296+
.candid()?;
1297+
Ok(response)
12281298
}
12291299
pub async fn list_node_provider_rewards(
12301300
&self,
12311301
arg0: ListNodeProviderRewardsRequest,
12321302
) -> CallResult<(ListNodeProviderRewardsResponse,)> {
1233-
ic_cdk::call(self.0, "list_node_provider_rewards", (arg0,)).await
1303+
let response = Call::unbounded_wait(self.0, "list_node_provider_rewards")
1304+
.with_arg(arg0)
1305+
.await?
1306+
.candid()?;
1307+
Ok(response)
12341308
}
12351309
pub async fn list_node_providers(&self) -> CallResult<(ListNodeProvidersResponse,)> {
1236-
ic_cdk::call(self.0, "list_node_providers", ()).await
1310+
let response = Call::unbounded_wait(self.0, "list_node_providers")
1311+
.await?
1312+
.candid()?;
1313+
Ok(response)
12371314
}
12381315
pub async fn list_proposals(&self, arg0: ListProposalInfo) -> CallResult<(ListProposalInfoResponse,)> {
1239-
ic_cdk::call(self.0, "list_proposals", (arg0,)).await
1316+
let response = Call::unbounded_wait(self.0, "list_proposals")
1317+
.with_arg(arg0)
1318+
.await?
1319+
.candid()?;
1320+
Ok(response)
12401321
}
12411322
pub async fn manage_neuron(&self, arg0: ManageNeuronRequest) -> CallResult<(ManageNeuronResponse,)> {
1242-
ic_cdk::call(self.0, "manage_neuron", (arg0,)).await
1323+
let response = Call::unbounded_wait(self.0, "manage_neuron")
1324+
.with_arg(arg0)
1325+
.await?
1326+
.candid()?;
1327+
Ok(response)
12431328
}
12441329
pub async fn settle_community_fund_participation(
12451330
&self,
12461331
arg0: SettleCommunityFundParticipation,
12471332
) -> CallResult<(Result_,)> {
1248-
ic_cdk::call(self.0, "settle_community_fund_participation", (arg0,)).await
1333+
let response = Call::unbounded_wait(self.0, "settle_community_fund_participation")
1334+
.with_arg(arg0)
1335+
.await?
1336+
.candid()?;
1337+
Ok(response)
12491338
}
12501339
pub async fn settle_neurons_fund_participation(
12511340
&self,
12521341
arg0: SettleNeuronsFundParticipationRequest,
12531342
) -> CallResult<(SettleNeuronsFundParticipationResponse,)> {
1254-
ic_cdk::call(self.0, "settle_neurons_fund_participation", (arg0,)).await
1343+
let response = Call::unbounded_wait(self.0, "settle_neurons_fund_participation")
1344+
.with_arg(arg0)
1345+
.await?
1346+
.candid()?;
1347+
Ok(response)
12551348
}
12561349
pub async fn simulate_manage_neuron(&self, arg0: ManageNeuronRequest) -> CallResult<(ManageNeuronResponse,)> {
1257-
ic_cdk::call(self.0, "simulate_manage_neuron", (arg0,)).await
1350+
let response = Call::unbounded_wait(self.0, "simulate_manage_neuron")
1351+
.with_arg(arg0)
1352+
.await?
1353+
.candid()?;
1354+
Ok(response)
12581355
}
12591356
pub async fn transfer_gtc_neuron(&self, arg0: NeuronId, arg1: NeuronId) -> CallResult<(Result_,)> {
1260-
ic_cdk::call(self.0, "transfer_gtc_neuron", (arg0, arg1)).await
1357+
let response = Call::unbounded_wait(self.0, "transfer_gtc_neuron")
1358+
.with_args((arg0, arg1))
1359+
.await?
1360+
.candid()?;
1361+
Ok(response)
12611362
}
12621363
pub async fn update_node_provider(&self, arg0: UpdateNodeProvider) -> CallResult<(Result_,)> {
1263-
ic_cdk::call(self.0, "update_node_provider", (arg0,)).await
1364+
let response = Call::unbounded_wait(self.0, "update_node_provider")
1365+
.with_arg(arg0)
1366+
.await?
1367+
.candid()?;
1368+
Ok(response)
12641369
}
12651370
}

0 commit comments

Comments
 (0)