Skip to content

Commit

Permalink
fix(transactions): add cryptocondition script type (#1991)
Browse files Browse the repository at this point in the history
  • Loading branch information
shamardy authored Oct 12, 2023
1 parent 1753849 commit 5df7db3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions mm2src/mm2_bitcoin/rpc/src/v1/types/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub enum ScriptType {
Create,
LelantusMint,
ColdStaking,
// Komodo smart chains specific
CryptoCondition,
}

impl From<GlobalScriptType> for ScriptType {
Expand All @@ -38,6 +40,7 @@ impl From<GlobalScriptType> for ScriptType {
GlobalScriptType::Call => ScriptType::Call,
GlobalScriptType::Create => ScriptType::Create,
GlobalScriptType::ColdStaking => ScriptType::ColdStaking,
GlobalScriptType::CryptoCondition => ScriptType::CryptoCondition,
}
}
}
Expand All @@ -62,6 +65,7 @@ impl Serialize for ScriptType {
ScriptType::Create => "create".serialize(serializer),
ScriptType::LelantusMint => "lelantusmint".serialize(serializer),
ScriptType::ColdStaking => "cold_staking".serialize(serializer),
ScriptType::CryptoCondition => "cryptocondition".serialize(serializer),
}
}
}
Expand Down Expand Up @@ -99,6 +103,7 @@ impl<'a> Deserialize<'a> for ScriptType {
"create" => Ok(ScriptType::Create),
"lelantusmint" => Ok(ScriptType::LelantusMint),
"cold_staking" => Ok(ScriptType::ColdStaking),
"cryptocondition" => Ok(ScriptType::CryptoCondition),
_ => Err(E::invalid_value(Unexpected::Str(value), &self)),
}
}
Expand Down Expand Up @@ -152,6 +157,10 @@ mod tests {
serde_json::to_string(&ScriptType::ColdStaking).unwrap(),
r#""cold_staking""#
);
assert_eq!(
serde_json::to_string(&ScriptType::CryptoCondition).unwrap(),
r#""cryptocondition""#
);
}

#[test]
Expand Down Expand Up @@ -208,5 +217,9 @@ mod tests {
serde_json::from_str::<ScriptType>(r#""cold_staking""#).unwrap(),
ScriptType::ColdStaking
);
assert_eq!(
serde_json::from_str::<ScriptType>(r#""cryptocondition""#).unwrap(),
ScriptType::CryptoCondition
);
}
}
5 changes: 5 additions & 0 deletions mm2src/mm2_bitcoin/script/src/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pub enum ScriptType {
Call,
Create,
ColdStaking,
// Komodo smart chains specific
CryptoCondition,
}

/// Address from Script
Expand Down Expand Up @@ -467,6 +469,9 @@ impl Script {
ScriptType::ColdStaking => {
Ok(vec![]) // TODO
},
ScriptType::CryptoCondition => {
Ok(vec![]) // TODO
},
}
}

Expand Down

0 comments on commit 5df7db3

Please sign in to comment.