Skip to content

Commit

Permalink
modify bridge contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
photosssa committed Jan 10, 2024
1 parent 5410827 commit f8ea63b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions contracts/erc721_nft_bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ import "./public_data_storage.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

contract ERC721NFTBridge is IERCPublicDataContract {
address owner;
IERC721 nftAddress;

mapping (bytes32 => uint256) hashToTokenId;

constructor(IERC721 _nftAddress) {
nftAddress = _nftAddress;
owner = msg.sender;
}

function addTokenId(bytes32[] calldata dataMixedHash, uint256[] calldata tokenId) public {
require(msg.sender == owner);
for (uint i = 0; i < dataMixedHash.length; i++) {
hashToTokenId[dataMixedHash[i]] = tokenId[i];
}
Expand Down
6 changes: 4 additions & 2 deletions contracts/owned_nft_bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ contract OwnedNFTBridge is IERCPublicDataContract {
constructor() {
}

function setData(bytes32 dataMixedHash) public {
ownerData[dataMixedHash] = msg.sender;
function setData(bytes32[] calldata dataMixedHash) public {
for (uint i = 0; i < dataMixedHash.length; i++) {
ownerData[dataMixedHash[i]] = msg.sender;
}
}

function getDataOwner(bytes32 dataMixedHash) public view returns (address) {
Expand Down
2 changes: 1 addition & 1 deletion test/test_public_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe("PublicDataStorage", function () {
}

for (const data of TestDatas) {
await (await nftBridge.setData(data.hash)).wait();
await (await nftBridge.setData([data.hash])).wait();
}

// large balance
Expand Down

0 comments on commit f8ea63b

Please sign in to comment.