Skip to content

Commit 6e3482c

Browse files
committed
feat: ScheduleInfo associated fields
Notably `ScheduleInfo.scheduled_transaction_body` Signed-off-by: Skyler Ross <[email protected]>
1 parent afad8bc commit 6e3482c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1901
-714
lines changed

sdk/rust/src/account/account_allowance_approve_transaction.rs

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use crate::protobuf::FromProtobuf;
2626
use crate::transaction::{
2727
AnyTransactionData,
2828
ChunkInfo,
29+
ToSchedulableTransactionDataProtobuf,
2930
ToTransactionDataProtobuf,
3031
TransactionData,
3132
TransactionExecute,
@@ -254,19 +255,15 @@ impl ToTransactionDataProtobuf for AccountAllowanceApproveTransactionData {
254255
) -> services::transaction_body::Data {
255256
let _ = chunk_info.assert_single_transaction();
256257

257-
let crypto_allowances = self.hbar_allowances.to_protobuf();
258-
259-
let token_allowances = self.token_allowances.to_protobuf();
260-
261-
let nft_allowances = self.nft_allowances.to_protobuf();
258+
services::transaction_body::Data::CryptoApproveAllowance(self.to_protobuf())
259+
}
260+
}
262261

263-
services::transaction_body::Data::CryptoApproveAllowance(
264-
services::CryptoApproveAllowanceTransactionBody {
265-
crypto_allowances,
266-
nft_allowances,
267-
token_allowances,
268-
},
269-
)
262+
impl ToSchedulableTransactionDataProtobuf for AccountAllowanceApproveTransactionData {
263+
fn to_schedulable_transaction_data_protobuf(
264+
&self,
265+
) -> services::schedulable_transaction_body::Data {
266+
services::schedulable_transaction_body::Data::CryptoApproveAllowance(self.to_protobuf())
270267
}
271268
}
272269

@@ -288,6 +285,24 @@ impl FromProtobuf<services::CryptoApproveAllowanceTransactionBody>
288285
}
289286
}
290287

288+
impl ToProtobuf for AccountAllowanceApproveTransactionData {
289+
type Protobuf = services::CryptoApproveAllowanceTransactionBody;
290+
291+
fn to_protobuf(&self) -> Self::Protobuf {
292+
let crypto_allowances = self.hbar_allowances.to_protobuf();
293+
294+
let token_allowances = self.token_allowances.to_protobuf();
295+
296+
let nft_allowances = self.nft_allowances.to_protobuf();
297+
298+
services::CryptoApproveAllowanceTransactionBody {
299+
crypto_allowances,
300+
nft_allowances,
301+
token_allowances,
302+
}
303+
}
304+
}
305+
291306
impl FromProtobuf<services::CryptoAllowance> for HbarAllowance {
292307
fn from_protobuf(pb: services::CryptoAllowance) -> crate::Result<Self> {
293308
Ok(Self {

sdk/rust/src/account/account_allowance_delete_transaction.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use crate::protobuf::{
2929
use crate::transaction::{
3030
AnyTransactionData,
3131
ChunkInfo,
32+
ToSchedulableTransactionDataProtobuf,
3233
ToTransactionDataProtobuf,
3334
TransactionData,
3435
TransactionExecute,
@@ -133,11 +134,15 @@ impl ToTransactionDataProtobuf for AccountAllowanceDeleteTransactionData {
133134
) -> services::transaction_body::Data {
134135
let _ = chunk_info.assert_single_transaction();
135136

136-
let nft_allowances = self.nft_allowances.to_protobuf();
137+
services::transaction_body::Data::CryptoDeleteAllowance(self.to_protobuf())
138+
}
139+
}
137140

138-
services::transaction_body::Data::CryptoDeleteAllowance(
139-
services::CryptoDeleteAllowanceTransactionBody { nft_allowances },
140-
)
141+
impl ToSchedulableTransactionDataProtobuf for AccountAllowanceDeleteTransactionData {
142+
fn to_schedulable_transaction_data_protobuf(
143+
&self,
144+
) -> services::schedulable_transaction_body::Data {
145+
services::schedulable_transaction_body::Data::CryptoDeleteAllowance(self.to_protobuf())
141146
}
142147
}
143148

@@ -155,6 +160,16 @@ impl FromProtobuf<services::CryptoDeleteAllowanceTransactionBody>
155160
}
156161
}
157162

163+
impl ToProtobuf for AccountAllowanceDeleteTransactionData {
164+
type Protobuf = services::CryptoDeleteAllowanceTransactionBody;
165+
166+
fn to_protobuf(&self) -> Self::Protobuf {
167+
services::CryptoDeleteAllowanceTransactionBody {
168+
nft_allowances: self.nft_allowances.to_protobuf(),
169+
}
170+
}
171+
}
172+
158173
impl FromProtobuf<services::NftRemoveAllowance> for NftRemoveAllowance {
159174
fn from_protobuf(pb: services::NftRemoveAllowance) -> crate::Result<Self>
160175
where

sdk/rust/src/account/account_create_transaction.rs

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use crate::staked_id::StakedId;
3131
use crate::transaction::{
3232
AnyTransactionData,
3333
ChunkInfo,
34+
ToSchedulableTransactionDataProtobuf,
3435
ToTransactionDataProtobuf,
3536
TransactionData,
3637
TransactionExecute,
@@ -311,42 +312,15 @@ impl ToTransactionDataProtobuf for AccountCreateTransactionData {
311312
) -> services::transaction_body::Data {
312313
let _ = chunk_info.assert_single_transaction();
313314

314-
let key = self.key.to_protobuf();
315-
let auto_renew_period = self.auto_renew_period.to_protobuf();
316-
let auto_renew_account = self.auto_renew_account_id.to_protobuf();
317-
let staked_id = self.staked_id.map(|it| match it {
318-
StakedId::NodeId(id) => {
319-
services::crypto_create_transaction_body::StakedId::StakedNodeId(id as i64)
320-
}
321-
StakedId::AccountId(id) => {
322-
services::crypto_create_transaction_body::StakedId::StakedAccountId(
323-
id.to_protobuf(),
324-
)
325-
}
326-
});
315+
services::transaction_body::Data::CryptoCreateAccount(self.to_protobuf())
316+
}
317+
}
327318

328-
services::transaction_body::Data::CryptoCreateAccount(
329-
#[allow(deprecated)]
330-
services::CryptoCreateTransactionBody {
331-
key,
332-
initial_balance: self.initial_balance.to_tinybars() as u64,
333-
proxy_account_id: None,
334-
send_record_threshold: i64::MAX as u64,
335-
receive_record_threshold: i64::MAX as u64,
336-
receiver_sig_required: self.receiver_signature_required,
337-
auto_renew_period,
338-
auto_renew_account,
339-
shard_id: None,
340-
realm_id: None,
341-
new_realm_admin_key: None,
342-
memo: self.account_memo.clone(),
343-
max_automatic_token_associations: i32::from(self.max_automatic_token_associations),
344-
alias: self.alias.map_or(vec![], |key| key.to_bytes_raw()),
345-
evm_address: self.evm_address.map_or(vec![], Vec::from),
346-
decline_reward: self.decline_staking_reward,
347-
staked_id,
348-
},
349-
)
319+
impl ToSchedulableTransactionDataProtobuf for AccountCreateTransactionData {
320+
fn to_schedulable_transaction_data_protobuf(
321+
&self,
322+
) -> services::schedulable_transaction_body::Data {
323+
services::schedulable_transaction_body::Data::CryptoCreateAccount(self.to_protobuf())
350324
}
351325
}
352326

@@ -379,6 +353,47 @@ impl FromProtobuf<services::CryptoCreateTransactionBody> for AccountCreateTransa
379353
}
380354
}
381355

356+
impl ToProtobuf for AccountCreateTransactionData {
357+
type Protobuf = services::CryptoCreateTransactionBody;
358+
359+
fn to_protobuf(&self) -> Self::Protobuf {
360+
let key = self.key.to_protobuf();
361+
let auto_renew_period = self.auto_renew_period.to_protobuf();
362+
let auto_renew_account = self.auto_renew_account_id.to_protobuf();
363+
let staked_id = self.staked_id.map(|it| match it {
364+
StakedId::NodeId(id) => {
365+
services::crypto_create_transaction_body::StakedId::StakedNodeId(id as i64)
366+
}
367+
StakedId::AccountId(id) => {
368+
services::crypto_create_transaction_body::StakedId::StakedAccountId(
369+
id.to_protobuf(),
370+
)
371+
}
372+
});
373+
374+
#[allow(deprecated)]
375+
services::CryptoCreateTransactionBody {
376+
key,
377+
initial_balance: self.initial_balance.to_tinybars() as u64,
378+
proxy_account_id: None,
379+
send_record_threshold: i64::MAX as u64,
380+
receive_record_threshold: i64::MAX as u64,
381+
receiver_sig_required: self.receiver_signature_required,
382+
auto_renew_period,
383+
auto_renew_account,
384+
shard_id: None,
385+
realm_id: None,
386+
new_realm_admin_key: None,
387+
memo: self.account_memo.clone(),
388+
max_automatic_token_associations: i32::from(self.max_automatic_token_associations),
389+
alias: self.alias.map_or(vec![], |key| key.to_bytes_raw()),
390+
evm_address: self.evm_address.map_or(vec![], Vec::from),
391+
decline_reward: self.decline_staking_reward,
392+
staked_id,
393+
}
394+
}
395+
}
396+
382397
#[cfg(test)]
383398
mod tests {
384399
#[cfg(feature = "ffi")]

sdk/rust/src/account/account_delete_transaction.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use crate::protobuf::{
2929
use crate::transaction::{
3030
AnyTransactionData,
3131
ChunkInfo,
32+
ToSchedulableTransactionDataProtobuf,
3233
ToTransactionDataProtobuf,
3334
TransactionData,
3435
TransactionExecute,
@@ -113,13 +114,15 @@ impl ToTransactionDataProtobuf for AccountDeleteTransactionData {
113114
) -> services::transaction_body::Data {
114115
let _ = chunk_info.assert_single_transaction();
115116

116-
let account_id = self.account_id.to_protobuf();
117-
let transfer_account_id = self.transfer_account_id.to_protobuf();
117+
services::transaction_body::Data::CryptoDelete(self.to_protobuf())
118+
}
119+
}
118120

119-
services::transaction_body::Data::CryptoDelete(services::CryptoDeleteTransactionBody {
120-
transfer_account_id,
121-
delete_account_id: account_id,
122-
})
121+
impl ToSchedulableTransactionDataProtobuf for AccountDeleteTransactionData {
122+
fn to_schedulable_transaction_data_protobuf(
123+
&self,
124+
) -> services::schedulable_transaction_body::Data {
125+
services::schedulable_transaction_body::Data::CryptoDelete(self.to_protobuf())
123126
}
124127
}
125128

@@ -138,6 +141,17 @@ impl FromProtobuf<services::CryptoDeleteTransactionBody> for AccountDeleteTransa
138141
}
139142
}
140143

144+
impl ToProtobuf for AccountDeleteTransactionData {
145+
type Protobuf = services::CryptoDeleteTransactionBody;
146+
147+
fn to_protobuf(&self) -> Self::Protobuf {
148+
let account_id = self.account_id.to_protobuf();
149+
let transfer_account_id = self.transfer_account_id.to_protobuf();
150+
151+
services::CryptoDeleteTransactionBody { transfer_account_id, delete_account_id: account_id }
152+
}
153+
}
154+
141155
#[cfg(test)]
142156
mod tests {
143157
#[cfg(feature = "ffi")]

sdk/rust/src/account/account_update_transaction.rs

Lines changed: 54 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use crate::staked_id::StakedId;
3434
use crate::transaction::{
3535
AnyTransactionData,
3636
ChunkInfo,
37+
ToSchedulableTransactionDataProtobuf,
3738
ToTransactionDataProtobuf,
3839
TransactionData,
3940
TransactionExecute,
@@ -311,49 +312,15 @@ impl ToTransactionDataProtobuf for AccountUpdateTransactionData {
311312
) -> services::transaction_body::Data {
312313
let _ = chunk_info.assert_single_transaction();
313314

314-
let account_id = self.account_id.to_protobuf();
315-
let key = self.key.to_protobuf();
316-
let auto_renew_period = self.auto_renew_period.to_protobuf();
317-
let auto_renew_account = self.auto_renew_account_id.to_protobuf();
318-
let expiration_time = self.expiration_time.to_protobuf();
319-
320-
let receiver_signature_required = self.receiver_signature_required.map(|required| {
321-
services::crypto_update_transaction_body::ReceiverSigRequiredField::ReceiverSigRequiredWrapper(required)
322-
});
323-
324-
let staked_id = self.staked_id.map(|id| match id {
325-
StakedId::NodeId(id) => {
326-
services::crypto_update_transaction_body::StakedId::StakedNodeId(id as i64)
327-
}
328-
StakedId::AccountId(id) => {
329-
services::crypto_update_transaction_body::StakedId::StakedAccountId(
330-
id.to_protobuf(),
331-
)
332-
}
333-
});
315+
services::transaction_body::Data::CryptoUpdateAccount(self.to_protobuf())
316+
}
317+
}
334318

335-
services::transaction_body::Data::CryptoUpdateAccount(
336-
#[allow(deprecated)]
337-
services::CryptoUpdateTransactionBody {
338-
account_id_to_update: account_id,
339-
key,
340-
proxy_account_id: self.proxy_account_id.to_protobuf(),
341-
proxy_fraction: 0,
342-
auto_renew_period,
343-
auto_renew_account,
344-
expiration_time,
345-
memo: self.account_memo.clone(),
346-
max_automatic_token_associations: self
347-
.max_automatic_token_associations
348-
.map(Into::into),
349-
decline_reward: self.decline_staking_reward,
350-
send_record_threshold_field: None,
351-
receive_record_threshold_field: None,
352-
receiver_sig_required_field: receiver_signature_required,
353-
staked_id,
354-
virtual_address_update: None, // TODO
355-
},
356-
)
319+
impl ToSchedulableTransactionDataProtobuf for AccountUpdateTransactionData {
320+
fn to_schedulable_transaction_data_protobuf(
321+
&self,
322+
) -> services::schedulable_transaction_body::Data {
323+
services::schedulable_transaction_body::Data::CryptoUpdateAccount(self.to_protobuf())
357324
}
358325
}
359326

@@ -391,6 +358,51 @@ impl FromProtobuf<services::CryptoUpdateTransactionBody> for AccountUpdateTransa
391358
}
392359
}
393360

361+
impl ToProtobuf for AccountUpdateTransactionData {
362+
type Protobuf = services::CryptoUpdateTransactionBody;
363+
364+
fn to_protobuf(&self) -> Self::Protobuf {
365+
let account_id = self.account_id.to_protobuf();
366+
let key = self.key.to_protobuf();
367+
let auto_renew_period = self.auto_renew_period.to_protobuf();
368+
let auto_renew_account = self.auto_renew_account_id.to_protobuf();
369+
let expiration_time = self.expiration_time.to_protobuf();
370+
371+
let receiver_signature_required = self.receiver_signature_required.map(|required| {
372+
services::crypto_update_transaction_body::ReceiverSigRequiredField::ReceiverSigRequiredWrapper(required)
373+
});
374+
375+
let staked_id = self.staked_id.map(|id| match id {
376+
StakedId::NodeId(id) => {
377+
services::crypto_update_transaction_body::StakedId::StakedNodeId(id as i64)
378+
}
379+
StakedId::AccountId(id) => {
380+
services::crypto_update_transaction_body::StakedId::StakedAccountId(
381+
id.to_protobuf(),
382+
)
383+
}
384+
});
385+
386+
#[allow(deprecated)]
387+
services::CryptoUpdateTransactionBody {
388+
account_id_to_update: account_id,
389+
key,
390+
proxy_account_id: self.proxy_account_id.to_protobuf(),
391+
proxy_fraction: 0,
392+
auto_renew_period,
393+
auto_renew_account,
394+
expiration_time,
395+
memo: self.account_memo.clone(),
396+
max_automatic_token_associations: self.max_automatic_token_associations.map(Into::into),
397+
decline_reward: self.decline_staking_reward,
398+
send_record_threshold_field: None,
399+
receive_record_threshold_field: None,
400+
receiver_sig_required_field: receiver_signature_required,
401+
staked_id,
402+
virtual_address_update: None, // TODO
403+
}
404+
}
405+
}
394406
#[cfg(test)]
395407
mod tests {
396408
#[cfg(feature = "ffi")]

0 commit comments

Comments
 (0)