@@ -26,30 +26,54 @@ abstract contract BridgeERC1155 is BridgeMultiToken, ERC1155Holder {
2626 return _token;
2727 }
2828
29+ /// @dev Equivalent to `crosschainTransferFrom(from, to, id, value, "")`.
30+ function crosschainTransferFrom (address from , bytes memory to , uint256 id , uint256 value ) public returns (bytes32 ) {
31+ return crosschainTransferFrom (from, to, id, value, "" );
32+ }
33+
2934 /**
30- * @dev Transfer `amount` tokens to a crosschain receiver.
35+ * @dev Transfer `value` of token `id` to a crosschain receiver. `data` is forwarded to the destination-chain
36+ * ERC-1155 receiver's acceptance hook.
3137 *
3238 * Note: The `to` parameter is the full InteroperableAddress (chain ref + address).
3339 */
34- function crosschainTransferFrom (address from , bytes memory to , uint256 id , uint256 value ) public returns (bytes32 ) {
40+ function crosschainTransferFrom (
41+ address from ,
42+ bytes memory to ,
43+ uint256 id ,
44+ uint256 value ,
45+ bytes memory data
46+ ) public returns (bytes32 ) {
3547 uint256 [] memory ids = new uint256 [](1 );
3648 uint256 [] memory values = new uint256 [](1 );
3749 ids[0 ] = id;
3850 values[0 ] = value;
3951
40- return crosschainTransferFrom (from, to, ids, values);
52+ return crosschainTransferFrom (from, to, ids, values, data);
53+ }
54+
55+ /// @dev Equivalent to `crosschainTransferFrom(from, to, ids, values, "")`.
56+ function crosschainTransferFrom (
57+ address from ,
58+ bytes memory to ,
59+ uint256 [] memory ids ,
60+ uint256 [] memory values
61+ ) public returns (bytes32 ) {
62+ return crosschainTransferFrom (from, to, ids, values, "" );
4163 }
4264
4365 /**
44- * @dev Transfer `amount` tokens to a crosschain receiver.
66+ * @dev Transfer `values` of tokens `ids` to a crosschain receiver. `data` is forwarded to the destination-chain
67+ * ERC-1155 receiver's acceptance hook.
4568 *
4669 * Note: The `to` parameter is the full InteroperableAddress (chain ref + address).
4770 */
4871 function crosschainTransferFrom (
4972 address from ,
5073 bytes memory to ,
5174 uint256 [] memory ids ,
52- uint256 [] memory values
75+ uint256 [] memory values ,
76+ bytes memory data
5377 ) public virtual returns (bytes32 ) {
5478 // Permission is handled using the ERC1155's allowance system. This check replicates `ERC1155._checkAuthorized`.
5579 address spender = _msgSender ();
@@ -59,17 +83,22 @@ abstract contract BridgeERC1155 is BridgeMultiToken, ERC1155Holder {
5983 );
6084
6185 // Perform the crosschain transfer and return the handler
62- return _crosschainTransfer (from, to, ids, values);
86+ return _crosschainTransfer (from, to, ids, values, data );
6387 }
6488
65- /// @dev "Locking" tokens is done by taking custody
89+ /// @dev "Locking" tokens is done by taking custody.
6690 function _onSend (address from , uint256 [] memory ids , uint256 [] memory values ) internal virtual override {
6791 token ().safeBatchTransferFrom (from, address (this ), ids, values, "" );
6892 }
6993
70- /// @dev "Unlocking" tokens is done by releasing custody
71- function _onReceive (address to , uint256 [] memory ids , uint256 [] memory values ) internal virtual override {
72- token ().safeBatchTransferFrom (address (this ), to, ids, values, "" );
94+ /// @dev "Unlocking" tokens is done by releasing custody.
95+ function _onReceive (
96+ address to ,
97+ uint256 [] memory ids ,
98+ uint256 [] memory values ,
99+ bytes memory data
100+ ) internal virtual override {
101+ token ().safeBatchTransferFrom (address (this ), to, ids, values, data);
73102 }
74103
75104 /// @dev Support receiving tokens only if the transfer was initiated by the bridge itself.
0 commit comments