Skip to content

Commit

Permalink
fix: Fix resim compilation, run format
Browse files Browse the repository at this point in the history
  • Loading branch information
dhedey committed Jul 26, 2024
1 parent d72b76a commit 94f3c23
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 32 deletions.
25 changes: 14 additions & 11 deletions radix-clis/src/resim/cmd_publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,24 @@ impl Publish {
let original_code = PackageCodeOriginalCode { code };
let instrumented_code = PackageCodeInstrumentedCode { instrumented_code };
{
let key =
SpreadPrefixKeyMapper::map_to_db_sort_key(&scrypto_encode(&code_hash).unwrap());
let key = SpreadPrefixKeyMapper::map_to_db_sort_key(
&scrypto_encode_to_payload(&code_hash).unwrap(),
);
let update =
DatabaseUpdate::Set(scrypto_encode(&vm_type.into_locked_substate()).unwrap());
vm_type_updates.insert(key, update);

let key =
SpreadPrefixKeyMapper::map_to_db_sort_key(&scrypto_encode(&code_hash).unwrap());
let key = SpreadPrefixKeyMapper::map_to_db_sort_key(
&scrypto_encode_to_payload(&code_hash).unwrap(),
);
let update = DatabaseUpdate::Set(
scrypto_encode(&original_code.into_locked_substate()).unwrap(),
);
original_code_updates.insert(key, update);

let key =
SpreadPrefixKeyMapper::map_to_db_sort_key(&scrypto_encode(&code_hash).unwrap());
let key = SpreadPrefixKeyMapper::map_to_db_sort_key(
&scrypto_encode_to_payload(&code_hash).unwrap(),
);
let update = DatabaseUpdate::Set(
scrypto_encode(&instrumented_code.into_locked_substate()).unwrap(),
);
Expand All @@ -190,7 +193,7 @@ impl Publish {
let schema_hash = blueprint_schema.schema.generate_schema_hash();
schema_updates.insert(
SpreadPrefixKeyMapper::map_to_db_sort_key(
&scrypto_encode(&schema_hash).unwrap(),
&scrypto_encode_to_payload(&schema_hash).unwrap(),
),
DatabaseUpdate::Set(
scrypto_encode(&blueprint_schema.schema.into_locked_substate()).unwrap(),
Expand Down Expand Up @@ -264,13 +267,13 @@ impl Publish {
};
blueprint_updates.insert(
SpreadPrefixKeyMapper::map_to_db_sort_key(
&scrypto_encode(&blueprint_version_key.clone()).unwrap(),
&scrypto_encode_to_payload(&blueprint_version_key.clone()).unwrap(),
),
DatabaseUpdate::Set(scrypto_encode(&def.into_locked_substate()).unwrap()),
);
dependency_updates.insert(
SpreadPrefixKeyMapper::map_to_db_sort_key(
&scrypto_encode(&blueprint_version_key.clone()).unwrap(),
&scrypto_encode_to_payload(&blueprint_version_key.clone()).unwrap(),
),
DatabaseUpdate::Set(
scrypto_encode(
Expand All @@ -284,7 +287,7 @@ impl Publish {
);
auth_config_updates.insert(
SpreadPrefixKeyMapper::map_to_db_sort_key(
&scrypto_encode(&blueprint_version_key.clone()).unwrap(),
&scrypto_encode_to_payload(&blueprint_version_key.clone()).unwrap(),
),
DatabaseUpdate::Set(
scrypto_encode(&blueprint_definition.auth_config.into_locked_substate())
Expand All @@ -293,7 +296,7 @@ impl Publish {
);
royalty_config_updates.insert(
SpreadPrefixKeyMapper::map_to_db_sort_key(
&scrypto_encode(&blueprint_version_key.clone()).unwrap(),
&scrypto_encode_to_payload(&blueprint_version_key.clone()).unwrap(),
),
DatabaseUpdate::Set(
scrypto_encode(&blueprint_definition.royalty_config.into_locked_substate())
Expand Down
5 changes: 2 additions & 3 deletions radix-clis/src/resim/dumper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,8 @@ fn get_entity_metadata<T: SubstateDatabase>(
)
.unwrap()
.map(|(key, value)| {
let map_key = key.into_map();
let key = scrypto_decode::<String>(&map_key).unwrap();
let value = scrypto_decode::<MetadataEntryEntryPayload>(&value).unwrap();
let key: String = key.into_map().decode_as().unwrap();
let value: MetadataEntryEntryPayload = value.decode_as().unwrap();
(key, value.fully_update_and_into_latest_version())
})
.collect()
Expand Down
11 changes: 5 additions & 6 deletions radix-engine/src/system/system_db_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,8 @@ impl<'a, S: SubstateDatabase + ?Sized> SystemDatabaseReader<'a, S> {
node_id: &NodeId,
module_id: ModuleId,
collection_index: CollectionIndex,
) -> Result<
Box<dyn Iterator<Item = (SubstateKey, Option<ScryptoOwnedRawValue>)> + '_>,
SystemReaderError,
> {
) -> Result<Box<dyn Iterator<Item = (SubstateKey, ScryptoOwnedRawValue)> + '_>, SystemReaderError>
{
self.collection_iter_advanced(node_id, module_id, collection_index, None)
.map(|x| x.0)
}
Expand All @@ -389,7 +387,7 @@ impl<'a, S: SubstateDatabase + ?Sized> SystemDatabaseReader<'a, S> {
from_substate_key: Option<&SubstateKey>,
) -> Result<
(
Box<dyn Iterator<Item = (SubstateKey, Option<ScryptoOwnedRawValue>)> + '_>,
Box<dyn Iterator<Item = (SubstateKey, ScryptoOwnedRawValue)> + '_>,
PartitionNumber,
),
SystemReaderError,
Expand Down Expand Up @@ -447,7 +445,8 @@ impl<'a, S: SubstateDatabase + ?Sized> SystemDatabaseReader<'a, S> {
),
};

Some((key, value_option))
// Filter out values that don't exist
value_option.map(|value| (key, value))
});

Ok((Box::new(iter), partition_number))
Expand Down
3 changes: 1 addition & 2 deletions radix-substate-store-queries/src/query/traverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,8 @@ impl<'s, 'v, S: SubstateDatabase, V: StateTreeVisitor + 'v> StateTreeTraverser<'
)
.unwrap()
{
let map_key = key.into_map();
let non_fungible_local_id: NonFungibleLocalId =
map_key.decode_as().unwrap();
key.into_map().decode_as().unwrap();
visitor.visit_non_fungible(
node_id,
&ResourceAddress::new_or_panic(info.get_outer_object().into()),
Expand Down
2 changes: 1 addition & 1 deletion sbor/src/encoded_wrappers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::rust::hash::Hash;
use crate::rust::prelude::*;
use crate::rust::ops::Deref;
use crate::rust::prelude::*;
use crate::traversal::*;
use crate::*;

Expand Down
13 changes: 4 additions & 9 deletions scrypto-test/src/ledger_simulator/ledger_simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,8 @@ impl<E: NativeVmExtension, D: TestDatabase> LedgerSimulator<E, D> {
)
.unwrap()
.map(|(key, value)| {
let key = key.into_map();
let hash: SchemaHash = key.decode_as().unwrap();
let schema: PackageSchemaEntryPayload = value.unwrap().decode_as().unwrap();
let hash: SchemaHash = key.into_map().decode_as().unwrap();
let schema: PackageSchemaEntryPayload = value.decode_as().unwrap();
(hash, schema.into_content())
})
.collect()
Expand All @@ -670,7 +669,7 @@ impl<E: NativeVmExtension, D: TestDatabase> LedgerSimulator<E, D> {
let map_key = key.into_map();
let key: BlueprintVersionKey = map_key.decode_as().unwrap();
let definition: PackageBlueprintVersionDefinitionEntryPayload =
value.unwrap().decode_as().unwrap();
value.decode_as().unwrap();
(key, definition.fully_update_and_into_latest_version())
})
.collect()
Expand Down Expand Up @@ -755,11 +754,7 @@ impl<E: NativeVmExtension, D: TestDatabase> LedgerSimulator<E, D> {
NonFungibleVaultCollection::NonFungibleIndex.collection_index(),
)
.unwrap()
.map(|(key, _)| {
let map_key = key.into_map();
let id: NonFungibleLocalId = map_key.decode_as().unwrap();
id
})
.map(|(key, _)| key.into_map().decode_as().unwrap())
.collect();

Some((amount, Box::new(iter.into_iter())))
Expand Down

0 comments on commit 94f3c23

Please sign in to comment.