-
Notifications
You must be signed in to change notification settings - Fork 6
fix: transfer to ZetaChain requires no gas error #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughThe pull request introduces a new error type, Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant C as Contract (UniversalNFTCore/UniversalTokenCore)
U->>C: transferCrossChain(destination, msg.value)
alt destination is zero and msg.value > 0
C->>U: Revert with TransferToZetaChainRequiresNoGas error
else
C->>U: Process transfer
end
Possibly related PRs
Suggested reviewers
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (2)
⏰ Context from checks skipped due to timeout of 90000ms (2)
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
I was thinking of splitting the function into two: one payable with /**
* @notice Transfers an NFT to ZetaChain.
* @dev Burns the NFT locally, then uses the Gateway to send a message to
* mint the same NFT on ZetaChain.
* @param tokenId The ID of the NFT to transfer.
* @param receiver The address on ZetaChain that will receive the NFT.
*/
function transferCrossChain(
uint256 tokenId,
address receiver
) external virtual {
if (receiver == address(0)) revert InvalidAddress();
string memory uri = tokenURI(tokenId);
_burn(tokenId);
bytes memory message = abi.encode(
address(0),
receiver,
tokenId,
uri,
msg.sender
);
emit TokenTransfer(address(0), receiver, tokenId, uri);
gateway.call(
universal,
message,
RevertOptions(address(this), false, universal, message, 0)
);
}
/**
* @notice Transfers an NFT to another chain.
* @dev Burns the NFT locally, then uses the Gateway to send a message to
* mint the same NFT on the destination chain.
* @param tokenId The ID of the NFT to transfer.
* @param receiver The address on the destination chain that will receive the NFT.
* @param destination The ZRC-20 address of the gas token of the destination chain.
*/
function transferCrossChain(
uint256 tokenId,
address receiver,
address destination
) external payable virtual {
if (receiver == address(0)) revert InvalidAddress();
if (destination == address(0)) revert InvalidAddress();
string memory uri = tokenURI(tokenId);
_burn(tokenId);
bytes memory message = abi.encode(
destination,
receiver,
tokenId,
uri,
msg.sender
);
emit TokenTransfer(destination, receiver, tokenId, uri);
gateway.depositAndCall{value: msg.value}(
universal,
message,
RevertOptions(
address(this),
true,
universal,
abi.encode(receiver, tokenId, uri, msg.sender),
gasLimitAmount
)
);
} I don't know if I like it or not, though. |
Looks good to me. I might keep the previous implementation with an additional check, but it's up to you. |
@s2imonovic yeah, probably having a check is enough. Can you, please, leave a review? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
Throw an error if the destination is ZetaChain, but
msg.value
> 0.Summary by CodeRabbit