Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Commit

Permalink
moved address_info_index to tx_data as according to spec (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpalvarezl authored May 6, 2021
1 parent 4634ced commit 71d0e9a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/models/converters/tests/data_decoded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,14 +510,14 @@ fn address_info_index_not_multi_send_address_array_value() {
.expect_full_address_info_search()
.with(eq("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"))
.times(1)
.return_once(move |address| bail!("no address"))
.return_once(move |_| bail!("no address"))
.in_sequence(&mut sequence);

mock_info_provider
.expect_full_address_info_search()
.with(eq("0xBc79855178842FDBA0c353494895DEEf509E26bB"))
.times(1)
.return_once(move |address| bail!("no address"))
.return_once(move |_| bail!("no address"))
.in_sequence(&mut sequence);

mock_info_provider
Expand Down
1 change: 0 additions & 1 deletion src/models/converters/tests/transfers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ fn transfer_dto_to_transaction_details() {
"0x41b610e8cce50bbe3aa06d6953ecc5f92a838aedc024a265c0afca7ec4f33bdf".to_string(),
),
safe_app_info: None,
address_info_index: None,
};

let actual = ether_transfer_dto
Expand Down
16 changes: 8 additions & 8 deletions src/models/converters/transactions/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ impl MultisigTransaction {
hex_data: self.data.to_owned(),
data_decoded: self.data_decoded.clone(),
operation: self.operation.unwrap_or(Operation::CALL),
address_info_index: self
.data_decoded
.as_ref()
.and_then(|data_decoded| data_decoded.build_address_info_index(info_provider)),
}),
tx_hash: self.transaction_hash.as_ref().map(|hash| hash.to_owned()),
detailed_execution_info: Some(DetailedExecutionInfo::Multisig(
Expand All @@ -42,10 +46,6 @@ impl MultisigTransaction {
.origin
.as_ref()
.and_then(|origin| safe_app_info_from(origin, info_provider)),
address_info_index: self
.data_decoded
.as_ref()
.and_then(|data_decoded| data_decoded.build_address_info_index(info_provider)),
})
}

Expand Down Expand Up @@ -111,16 +111,16 @@ impl ModuleTransaction {
hex_data: self.data.to_owned(),
data_decoded: self.data_decoded.clone(),
operation: self.operation,
address_info_index: self
.data_decoded
.as_ref()
.and_then(|data_decoded| data_decoded.build_address_info_index(info_provider)),
}),
tx_hash: Some(self.transaction_hash.to_owned()),
detailed_execution_info: Some(DetailedExecutionInfo::Module(ModuleExecutionDetails {
address: self.module.to_owned(),
})),
safe_app_info: None,
address_info_index: self
.data_decoded
.as_ref()
.and_then(|data_decoded| data_decoded.build_address_info_index(info_provider)),
})
}
}
7 changes: 3 additions & 4 deletions src/models/converters/transactions/tests/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ fn multisig_custom_transaction_to_transaction_details() {
to: "0xD9BA894E0097f8cC2BBc9D24D308b98e36dc6D02".to_string(),
value: Some(String::from("0")),
operation: Operation::CALL,
address_info_index: None
}),
detailed_execution_info: Some(DetailedExecutionInfo::Multisig(
MultisigExecutionDetails {
Expand Down Expand Up @@ -104,7 +105,6 @@ fn multisig_custom_transaction_to_transaction_details() {
gas_token_info: None,
})),
safe_app_info: None,
address_info_index: None
};

let actual =
Expand Down Expand Up @@ -145,13 +145,13 @@ fn module_transaction_to_transaction_details_success() {
to: "0xaAEb2035FF394fdB2C879190f95e7676f1A9444B".to_string(),
value: Some(String::from("0")),
operation: Operation::CALL,
address_info_index: None
}),
detailed_execution_info: Some(DetailedExecutionInfo::Module(
ModuleExecutionDetails {
address: "0xfa559f0932b7B60d90B4af0b8813d4088465096b".to_string()
})),
safe_app_info: None,
address_info_index: None
};

let actual =
Expand Down Expand Up @@ -192,13 +192,13 @@ fn module_transaction_to_transaction_details_failed() {
to: "0xaAEb2035FF394fdB2C879190f95e7676f1A9444B".to_string(),
value: Some(String::from("0")),
operation: Operation::CALL,
address_info_index: None
}),
detailed_execution_info: Some(DetailedExecutionInfo::Module(
ModuleExecutionDetails {
address: "0xfa559f0932b7B60d90B4af0b8813d4088465096b".to_string()
})),
safe_app_info: None,
address_info_index: None
};

let actual =
Expand Down Expand Up @@ -236,7 +236,6 @@ fn ethereum_tx_transfer_to_transaction_details() {
tx_data: None,
detailed_execution_info: None,
safe_app_info: None,
address_info_index: None
};

let mut mock_info_provider = MockInfoProvider::new();
Expand Down
1 change: 0 additions & 1 deletion src/models/converters/transfers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ impl TransferDto {
tx_hash: self.get_transaction_hash(),
detailed_execution_info: None,
safe_app_info: None,
address_info_index: None,
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/models/service/transactions/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ pub struct TransactionDetails {
pub tx_hash: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub safe_app_info: Option<SafeAppInfo>,
#[serde(skip_serializing_if = "Option::is_none")]
pub address_info_index: Option<HashMap<String, AddressInfo>>,
}

#[derive(Serialize, Debug, PartialEq)]
Expand Down Expand Up @@ -69,4 +67,6 @@ pub struct TransactionData {
pub to: String,
pub value: Option<String>,
pub operation: Operation,
#[serde(skip_serializing_if = "Option::is_none")]
pub address_info_index: Option<HashMap<String, AddressInfo>>,
}

0 comments on commit 71d0e9a

Please sign in to comment.