Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ljshwyykl committed Sep 27, 2023
1 parent cd99d3b commit a416f02
Show file tree
Hide file tree
Showing 184 changed files with 45,069 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

## Knexus CCIP
9 changes: 9 additions & 0 deletions contract/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
.env
coverage
coverage.json

# Hardhat files
cache
/artifacts

Empty file added contract/LICENSE
Empty file.
33 changes: 33 additions & 0 deletions contract/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

## Knexus CCIP




```
npx hardhat deploy-destination-minter --network polygonMumbai
ℹ️ Attempting to deploy MyNFT smart contract on the polygonMumbai blockchain using 0xD3420A3be0a1EFc0FBD13e87141c97B2C9AC9dD3 address
✅ MyNFT contract deployed at address 0xEFCA549833263eb624Cd94b4f42dd6EF0d34d0e0 on the polygonMumbai blockchain
ℹ️ Attempting to deploy DestinationMinter smart contract on the polygonMumbai blockchain using 0xD3420A3be0a1EFc0FBD13e87141c97B2C9AC9dD3 address, with the Router address 0x70499c328e1e2a3c41108bd3730f6670a44595d1 provided as constructor argument
✅ DestinationMinter contract deployed at address 0x1DcD208D120a55479eb41F6feCa61857f5A00D67 on the polygonMumbai blockchain
ℹ️ Attempting to grant the minter role to the DestinationMinter smart contract
npx hardhat deploy-source-minter --network bnbTestnet
ℹ️ Attempting to deploy SourceMinter smart contract on the bnbTestnet blockchain using 0xD3420A3be0a1EFc0FBD13e87141c97B2C9AC9dD3 address, with the Router address 0x70499c328e1e2a3c41108bd3730f6670a44595d1 and LINK address 0x84b9B910527Ad5C03A9Ca831909E21e236EA7b06 provided as constructor arguments
✅ SourceMinter contract deployed at address 0x7604028b2667f4aa2bd02F6d23810126f3f57AeA on the bnbTestnet blockchain
npx hardhat fill-sender --sender-address 0x7604028b2667f4aa2bd02F6d23810126f3f57AeA --blockchain bnbTestnet --amount 100000000000000000 --pay-fees-in LINK
npx hardhat cross-chain-mint --source-minter 0x7604028b2667f4aa2bd02F6d23810126f3f57AeA --source-blockchain bnbTestnet --destination-blockchain polygonMumbai --destination-minter 0x1DcD208D120a55479eb41F6feCa61857f5A00D67 --pay-fees-in LINK
https://ccip.chain.link/
```
29 changes: 29 additions & 0 deletions contract/contracts/DestinationMinter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import {CCIPReceiver} from "@chainlink/contracts-ccip/src/v0.8/ccip/applications/CCIPReceiver.sol";
import {Client} from "@chainlink/contracts-ccip/src/v0.8/ccip/libraries/Client.sol";
import {KnexusCCIP} from "./KnexusCCIP.sol";

/**
* THIS IS AN EXAMPLE CONTRACT THAT USES HARDCODED VALUES FOR CLARITY.
* THIS IS AN EXAMPLE CONTRACT THAT USES UN-AUDITED CODE.
* DO NOT USE THIS CODE IN PRODUCTION.
*/
contract DestinationMinter is CCIPReceiver {
KnexusCCIP nft;

event MintCallSuccessfull();

constructor(address router, address nftAddress) CCIPReceiver(router) {
nft = KnexusCCIP(nftAddress);
}

function _ccipReceive(
Client.Any2EVMMessage memory message
) internal override {
(bool success, ) = address(nft).call(message.data);
require(success);
emit MintCallSuccessfull();
}
}
86 changes: 86 additions & 0 deletions contract/contracts/KnexusCCIP.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract KnexusCCIP is ERC721, ERC721URIStorage, Ownable {
constructor() ERC721("KNexus_Test_img", "KNTEST") {}

string constant TOKEN_URI =
"ipfs://bafkreihrylz2yk2ujarbucmki523kitlohdzr45nqdmfqfn6cne2aizspe";
uint256 internal _tokenId;

mapping(address => bool) internal _dispatcherlisted;

event DispatcherlistedChanged(
address indexed dispatcher,
bool indexed whitelisted,
uint256 timestamp
);

modifier onlyDispatcher() {
require(_dispatcherlisted[msg.sender], "not permission");
_;
}

function isDispatcherlisted(
address dispatcher
) external view returns (bool) {
return _dispatcherlisted[dispatcher];
}

function dispatcherlistedCreator(
address dispatcher,
bool whitelist
) external onlyOwner {
_dispatcherlisted[dispatcher] = whitelist;
emit DispatcherlistedChanged(dispatcher, whitelist, block.timestamp);
}

// function ccipMint(address to) public onlyDispatcher {
// _safeMint(to, _tokenId);
// _setTokenURI(_tokenId, TOKEN_URI);
// unchecked {
// _tokenId++;
// }
// }

function mint(address to) public {
_safeMint(to, _tokenId);
_setTokenURI(_tokenId, TOKEN_URI);
unchecked {
_tokenId++;
}
}

function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal override {
require(from == address(0), "Token is not transferable");
super._beforeTokenTransfer(from, to, tokenId);
}

function _burn(
uint256 tokenId
) internal override(ERC721, ERC721URIStorage) {
super._burn(tokenId);
}

// The following functions are overrides required by Solidity.

function tokenURI(
uint256 tokenId
) public view override(ERC721, ERC721URIStorage) returns (string memory) {
return super.tokenURI(tokenId);
}

function supportsInterface(
bytes4 interfaceId
) public view override(ERC721) returns (bool) {
return super.supportsInterface(interfaceId);
}
}
Loading

0 comments on commit a416f02

Please sign in to comment.