forked from aptos-labs/aptos-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move rust transcation-builder into client/
Closes: aptos-labs#5801
- Loading branch information
1 parent
7cfd561
commit 6ed2378
Showing
20 changed files
with
75 additions
and
87 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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 |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
|
||
#![forbid(unsafe_code)] | ||
|
||
pub mod misc; | ||
pub mod stdlib; |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) The Libra Core Contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#![forbid(unsafe_code)] | ||
|
||
use compiled_stdlib::{transaction_scripts::StdlibScript, StdLibOptions}; | ||
use libra_types::{ | ||
access_path::AccessPath, | ||
block_metadata::BlockMetadata, | ||
transaction::{ChangeSet, Transaction}, | ||
write_set::{WriteOp, WriteSetMut}, | ||
}; | ||
use std::convert::TryFrom; | ||
|
||
// TODO: this should go away once we are no longer using it in tests | ||
pub fn encode_block_prologue_script(block_metadata: BlockMetadata) -> Transaction { | ||
Transaction::BlockMetadata(block_metadata) | ||
} | ||
|
||
/// Update WriteSet | ||
pub fn encode_stdlib_upgrade_transaction(option: StdLibOptions) -> ChangeSet { | ||
let mut write_set = WriteSetMut::new(vec![]); | ||
let stdlib = compiled_stdlib::stdlib_modules(option); | ||
for module in stdlib { | ||
let mut bytes = vec![]; | ||
module | ||
.serialize(&mut bytes) | ||
.expect("Failed to serialize module"); | ||
write_set.push(( | ||
AccessPath::code_access_path(&module.self_id()), | ||
WriteOp::Value(bytes), | ||
)); | ||
} | ||
ChangeSet::new( | ||
write_set.freeze().expect("Failed to create writeset"), | ||
vec![], | ||
) | ||
} | ||
|
||
// TODO: delete and use StdlibScript::try_from directly if it's ok to drop the "_transaction"? | ||
/// Returns a user friendly mnemonic for the transaction type if the transaction is | ||
/// for a known, white listed, transaction. | ||
pub fn get_transaction_name(code: &[u8]) -> String { | ||
StdlibScript::try_from(code).map_or("<unknown transaction>".to_string(), |name| { | ||
format!("{}_transaction", name) | ||
}) | ||
} |
File renamed without changes.
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
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
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
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
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
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
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
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
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
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
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
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