Skip to content

Commit

Permalink
create mint function on source chain
Browse files Browse the repository at this point in the history
  • Loading branch information
Ginowine committed Dec 2, 2023
1 parent 94e7089 commit c15ada7
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions contracts/CrossNftSourceMinter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,42 @@ contract CrossNftSourceMinter is Withdraw {
i_link = link;
LinkTokenInterface(i_link).approve(i_router, type(uint256).max);
}

receive() external payable {}

function mint(
uint64 destinationChainSelector,
address receiver,
PayFeesIn payFeesIn
) external {
Client.EVM2AnyMessage memory message = Client.EVM2AnyMessage({
receiver: abi.encode(receiver),
data: abi.encodeWithSignature("mint(address)", msg.sender),
tokenAmounts: new Client.EVMTokenAmount[](0),
extraArgs: "",
feeToken: payFeesIn == PayFeesIn.LINK ? i_link : address(0)
});

uint256 fee = IRouterClient(i_router).getFee(
destinationChainSelector,
message
);

bytes32 messageId;

if (payFeesIn == PayFeesIn.LINK) {
// LinkTokenInterface(i_link).approve(i_router, fee);
messageId = IRouterClient(i_router).ccipSend(
destinationChainSelector,
message
);
} else {
messageId = IRouterClient(i_router).ccipSend{value: fee}(
destinationChainSelector,
message
);
}

emit MessageSent(messageId);
}
}

0 comments on commit c15ada7

Please sign in to comment.