Skip to content

Commit

Permalink
isin to cusip, hash as nft id
Browse files Browse the repository at this point in the history
  • Loading branch information
Birua committed Oct 8, 2024
1 parent 8a6dab2 commit 935dcbe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/BondNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ contract BondNFT is ERC1155, Ownable, ERC1155Supply {
uint256 couponValue;
uint256 issueTimestamp;
uint256 expirationTimestamp;
string ISIN;
string CUSIP;
}

// Custom event
Expand Down
16 changes: 9 additions & 7 deletions test/BondNFT.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,22 @@ contract BondNFTTest is Test {

function testSetMetaData() public {
BondNFT.Metadata memory metadata = BondNFT.Metadata({
value: 100,
couponValue: 5,
value: 100_000_000,
couponValue: 0,
issueTimestamp: block.timestamp,
expirationTimestamp: block.timestamp + 365 days,
ISIN: "US1234567890"
CUSIP: "912797LX3"
});
bondNFT.setMetaData(1, metadata);
(uint256 value, uint256 couponValue, uint256 issueTimestamp, uint256 expirationTimestamp, string memory ISIN) =
bondNFT.metadata(1);
uint256 id = uint256(keccak256(abi.encodePacked(metadata.CUSIP)));
console.log("Bond id: ", id);
bondNFT.setMetaData(id, metadata);
(uint256 value, uint256 couponValue, uint256 issueTimestamp, uint256 expirationTimestamp, string memory CUSIP) =
bondNFT.metadata(id);
assertEq(value, metadata.value);
assertEq(couponValue, metadata.couponValue);
assertEq(issueTimestamp, metadata.issueTimestamp);
assertEq(expirationTimestamp, metadata.expirationTimestamp);
assertEq(ISIN, metadata.ISIN);
assertEq(CUSIP, metadata.CUSIP);
}

function testMint() public {
Expand Down

0 comments on commit 935dcbe

Please sign in to comment.