Skip to content

Commit

Permalink
Merge pull request #66 from keroro520/fix-mutant-opcode
Browse files Browse the repository at this point in the history
fix(contracts): pass correct opcodes
  • Loading branch information
ashuralyk authored Apr 10, 2024
2 parents 9e8663b + 55e7908 commit 2df9617
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions contracts/spore/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,18 +265,14 @@ fn verify_extension(mime: &MIME, op: Operation, argv: Vec<u8>) -> Result<(), Err

debug!("run mutant_id({mutant_index}): {mutant_id:?} <= {extension_hash:?}");
match op {
Operation::Mint | Operation::Burn => {
Operation::Mint => {
ckb_std::high_level::exec_cell(
&extension_hash,
ScriptHashType::Data1,
&[
CStr::from_bytes_with_nul([b'0', 0].as_slice()).unwrap_or_default(),
CStr::from_bytes_with_nul(
[b'0' + mutant_index as u8, 0].as_slice(),
)
.unwrap_or_default(),
CStr::from_bytes_with_nul([b'0' + argv[0], 0].as_slice())
.unwrap_or_default(),
CStr::from_bytes_with_nul([b'0' + mutant_index as u8, 0].as_slice(),) .unwrap_or_default(),
CStr::from_bytes_with_nul([b'0' + argv[0], 0].as_slice()) .unwrap_or_default(),
],
)?;
}
Expand All @@ -285,15 +281,21 @@ fn verify_extension(mime: &MIME, op: Operation, argv: Vec<u8>) -> Result<(), Err
&extension_hash,
ScriptHashType::Data1,
&[
CStr::from_bytes_with_nul([b'0', 0].as_slice()).unwrap_or_default(),
CStr::from_bytes_with_nul(
[b'0' + mutant_index as u8, 0].as_slice(),
)
.unwrap_or_default(),
CStr::from_bytes_with_nul([b'0' + argv[0], 0].as_slice())
.unwrap_or_default(),
CStr::from_bytes_with_nul([b'0' + argv[1], 0].as_slice())
.unwrap_or_default(),
CStr::from_bytes_with_nul([b'1', 0].as_slice()).unwrap_or_default(),
CStr::from_bytes_with_nul([b'0' + mutant_index as u8, 0].as_slice(),) .unwrap_or_default(),
CStr::from_bytes_with_nul([b'0' + argv[0], 0].as_slice()) .unwrap_or_default(),
CStr::from_bytes_with_nul([b'0' + argv[1], 0].as_slice()) .unwrap_or_default(),
],
)?;
}
Operation::Burn => {
ckb_std::high_level::exec_cell(
&extension_hash,
ScriptHashType::Data1,
&[
CStr::from_bytes_with_nul([b'2', 0].as_slice()).unwrap_or_default(),
CStr::from_bytes_with_nul([b'0' + mutant_index as u8, 0].as_slice(),) .unwrap_or_default(),
CStr::from_bytes_with_nul([b'0' + argv[0], 0].as_slice()) .unwrap_or_default(),
],
)?;
}
Expand Down

0 comments on commit 2df9617

Please sign in to comment.