Skip to content

Commit

Permalink
chore: adding merge function
Browse files Browse the repository at this point in the history
Signed-off-by: MASDXI <[email protected]>
  • Loading branch information
MASDXI committed Feb 17, 2025
1 parent 0d99070 commit 1dc623d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
4 changes: 2 additions & 2 deletions blockchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

## What we measurement?

- Count step/effort to complete suspend all relevant fund/transaction.
- TBD
- Meantime to response. After the alert system triggers, how much time to freeze the fund that is relative to the fraudulent.
- Meantime to resolve. After the alert system triggers, how much time to freeze the fund that is relative to the fraudulent and funds are retrieved.

<!-- Response Time, Recovery Time and Post-Incident Analysis -->

Expand Down
9 changes: 7 additions & 2 deletions contracts/libraries/Forest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ pragma solidity >=0.8.0 <0.9.0;
* @author Sirawit Techavanitch ([email protected])
*/

// @TODO merging Tx (allowing only same root).

library Forest {
/**
* @dev Structure representing a transaction.
Expand Down Expand Up @@ -139,4 +137,11 @@ library Forest {

emit TransactionSpent(id, value);
}

/**
* @notice not suitable for use in production.
*/
function mergeTx(DAG storage self, bytes32 [] memory ids) internal {
// @TODO
}
}
16 changes: 14 additions & 2 deletions contracts/libraries/UTXO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ pragma solidity >=0.8.0 <0.9.0;
/**
* @title Unspent Transaction Output Model (UTXO)
* @notice This library implements the UTXO model for managing transactions on the blockchain.
* inspired from:
* https://gist.github.com/alex-miller-0/a5f4de3f811872b7272e66a3697f88de
* https://github.com/ProjectWyvern/wyvern-ethereum/blob/master/contracts/token/UTXORedeemableToken.sol
* https://github.com/olegfomenko/utxo
* @author Sirawit Techavanitch ([email protected])
*/

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";

// @TODO merging UTXO.

library UnspentTransactionOutput {
using ECDSA for bytes32;
using MessageHashUtils for bytes32;
Expand Down Expand Up @@ -188,6 +191,15 @@ library UnspentTransactionOutput {
emit TransactionConsumed(id);
}

/**
* @notice merge multiple transaction into single transaction.
* @param self The UTXO storage.
* @param ids The array of the identifiers of the transaction to merge.
*/
function mergeTx(UTXO storage self, bytes32 [] memory ids) internal {
// @TODO
}

/**
* @notice Retrieves the details of a transaction from the UTXO.
* @param self The UTXO storage.
Expand Down

0 comments on commit 1dc623d

Please sign in to comment.