Skip to content

Commit

Permalink
feat(publisher): fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lostman committed Sep 19, 2024
1 parent b86de93 commit 545d857
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 31 deletions.
22 changes: 10 additions & 12 deletions crates/fuel-streams-core/src/outputs/subjects.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use fuel_core_types::fuel_types::{Address, Bytes32, ContractId};
use fuel_streams_macros::subject::{IntoSubject, Subject};

use crate::types::*;
Expand Down Expand Up @@ -231,7 +230,6 @@ pub struct OutputsContractCreatedSubject {
#[cfg(test)]
mod tests {
use fuel_core_types::fuel_types::{Address, Bytes32};
use fuel_streams_core::types::*;
use fuel_streams_macros::subject::SubjectBuildable;

use super::*;
Expand All @@ -250,9 +248,9 @@ mod tests {
#[test]
fn test_outputs_coin_subject_creation() {
let coin_subject = OutputsCoinSubject::new()
.with_tx_id(Some(Bytes32::zeroed()))
.with_tx_id(Some(Bytes32::zeroed().into()))
.with_index(Some(0))
.with_to(Some(Address::zeroed()))
.with_to(Some(Address::zeroed().into()))
.with_asset_id(Some(AssetId::zeroed()));
assert_eq!(
coin_subject.to_string(),
Expand All @@ -263,7 +261,7 @@ mod tests {
#[test]
fn test_outputs_contract_created_subject_creation() {
let contract_created_subject = OutputsContractCreatedSubject::new()
.with_tx_id(Some(Bytes32::zeroed()))
.with_tx_id(Some(Bytes32::zeroed().into()))
.with_index(Some(0))
.with_contract_id(Some(ContractId::zeroed()));
assert_eq!(
Expand All @@ -275,7 +273,7 @@ mod tests {
#[test]
fn test_output_all_subject_creation() {
let output_subject = OutputsAllSubject::new()
.with_tx_id(Some(Bytes32::zeroed()))
.with_tx_id(Some(Bytes32::zeroed().into()))
.with_index(Some(0));
assert_eq!(
output_subject.to_string(),
Expand All @@ -286,9 +284,9 @@ mod tests {
#[test]
fn test_output_subject_coin() {
let output_subject = OutputsCoinSubject::new()
.with_tx_id(Some(Bytes32::zeroed()))
.with_tx_id(Some(Bytes32::zeroed().into()))
.with_index(Some(0))
.with_to(Some(Address::zeroed()))
.with_to(Some(Address::zeroed().into()))
.with_asset_id(Some(AssetId::zeroed()));
assert_eq!(
output_subject.to_string(),
Expand All @@ -299,13 +297,13 @@ mod tests {
#[test]
fn test_output_subject_variable() {
let output_subject = OutputsVariableSubject::new()
.with_tx_id(Some(Bytes32::zeroed()))
.with_tx_id(Some(Bytes32::zeroed().into()))
.with_index(Some(0))
.with_to(Some(Address::zeroed()))
.with_asset_id(Some(Bytes32::from([1u8; 32])));
.with_to(Some(Address::zeroed().into()))
.with_asset_id(Some(AssetId::zeroed()));
assert_eq!(
output_subject.to_string(),
"outputs.variable.0x0000000000000000000000000000000000000000000000000000000000000000.0.0x0000000000000000000000000000000000000000000000000000000000000000.0x0101010101010101010101010101010101010101010101010101010101010101"
"outputs.variable.0x0000000000000000000000000000000000000000000000000000000000000000.0.0x0000000000000000000000000000000000000000000000000000000000000000.0x0000000000000000000000000000000000000000000000000000000000000000"
);
}
}
38 changes: 19 additions & 19 deletions crates/fuel-streams-publisher/src/outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ pub async fn publish(
) = match output {
Output::Coin { to, asset_id, .. } => (
OutputsCoinSubject::new()
.with_tx_id(Some(tx_id))
.with_tx_id(Some(tx_id.into()))
.with_index(Some(index as u16))
.with_to(Some(*to))
.with_to(Some((*to).into()))
.with_asset_id(Some((*asset_id).into()))
.boxed(),
OutputsByIdSubject::new()
.with_id_kind(Some(IdentifierKind::Address))
.with_id_value(Some(Bytes32::new((*to).into()))),
.with_id_value(Some(Bytes32::new((*to).into()).into())),
),
Output::Contract(contract) => {
let input_index = contract.input_index as usize;
Expand All @@ -79,50 +79,50 @@ pub async fn publish(
};
(
OutputsContractSubject::new()
.with_tx_id(Some(tx_id))
.with_tx_id(Some(tx_id.into()))
.with_index(Some(index as u16))
.with_contract_id(Some(contract_id))
.with_contract_id(Some(contract_id.into()))
.boxed(),
OutputsByIdSubject::new()
.with_id_kind(Some(IdentifierKind::ContractID))
.with_id_value(Some(Bytes32::new(
contract_id.into(),
))),
.with_id_value(Some(
Bytes32::new(contract_id.into()).into(),
)),
)
}
Output::Change { to, asset_id, .. } => (
OutputsChangeSubject::new()
.with_tx_id(Some(tx_id))
.with_tx_id(Some(tx_id.into()))
.with_index(Some(index as u16))
.with_to(Some(*to))
.with_to(Some((*to).into()))
.with_asset_id(Some((*asset_id).into()))
.boxed(),
OutputsByIdSubject::new()
.with_id_kind(Some(IdentifierKind::Address))
.with_id_value(Some(Bytes32::new((*to).into()))),
.with_id_value(Some(Bytes32::new((*to).into()).into())),
),
Output::Variable { to, asset_id, .. } => (
OutputsVariableSubject::new()
.with_tx_id(Some(tx_id))
.with_tx_id(Some(tx_id.into()))
.with_index(Some(index as u16))
.with_to(Some(*to))
.with_to(Some((*to).into()))
.with_asset_id(Some((*asset_id).into()))
.boxed(),
OutputsByIdSubject::new()
.with_id_kind(Some(IdentifierKind::Address))
.with_id_value(Some(Bytes32::new((*to).into()))),
.with_id_value(Some(Bytes32::new((*to).into()).into())),
),
Output::ContractCreated { contract_id, .. } => (
OutputsContractCreatedSubject::new()
.with_tx_id(Some(tx_id))
.with_tx_id(Some(tx_id.into()))
.with_index(Some(index as u16))
.with_contract_id(Some(*contract_id))
.with_contract_id(Some((*contract_id).into()))
.boxed(),
OutputsByIdSubject::new()
.with_id_kind(Some(IdentifierKind::ContractID))
.with_id_value(Some(Bytes32::new(
(*contract_id).into(),
))),
.with_id_value(Some(
Bytes32::new((*contract_id).into()).into(),
)),
),
};

Expand Down

0 comments on commit 545d857

Please sign in to comment.