Skip to content

Commit

Permalink
WIP. Runtime most actions
Browse files Browse the repository at this point in the history
  • Loading branch information
evgenykuzyakov committed Aug 7, 2019
1 parent e5043f8 commit 807522b
Show file tree
Hide file tree
Showing 4 changed files with 340 additions and 374 deletions.
22 changes: 20 additions & 2 deletions core/primitives/src/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use crate::crypto::signature::PublicKey;
use crate::hash::CryptoHash;
use crate::logging;
use crate::serialize::{base_format, u128_dec_format, vec_base_format};
use crate::transaction::{Action, TransactionResult};
use crate::transaction::{Action, TransactionResult, TransferAction};
use crate::types::{AccountId, Balance, ShardId};
use crate::utils::{account_to_shard_id, proto_to_type, proto_to_vec};
use crate::utils::{account_to_shard_id, proto_to_type, proto_to_vec, system_account};

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct ReceiptInfo {
Expand Down Expand Up @@ -89,6 +89,24 @@ impl Receipt {
pub fn get_hash(&self) -> CryptoHash {
self.receipt_id
}

/// Generates a receipt with a transfer from system for a given balance without a receipt_id
pub fn new_refund(receiver_id: &AccountId, refund: Balance) -> Self {
Receipt {
predecessor_id: system_account(),
receiver_id: receiver_id.clone(),
receipt_id: CryptoHash::default(),

receipt: ReceiptEnum::Action(ActionReceipt {
signer_id: system_account(),
signer_public_key: PublicKey::empty(),
gas_price: 0,
output_data_receivers: vec![],
input_data_ids: vec![],
actions: vec![Action::Transfer(TransferAction { deposit: refund })],
}),
}
}
}

#[derive(Hash, Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
Expand Down
Loading

0 comments on commit 807522b

Please sign in to comment.