Skip to content
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

Add receiver field mainnet part #1294

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a690f28
Merge pull request #1241 from skalenetwork/beta
payvint Aug 19, 2022
922c7ca
Merge pull request #1260 from skalenetwork/hotfix/event
DimaStebaev Sep 1, 2022
5bc234d
Add DepositBoxes changes
payvint Sep 27, 2022
a91b900
Add interfaces and fix checks
payvint Sep 30, 2022
45e7d8d
Add tests
payvint Oct 3, 2022
a8e9335
Add SafeTransfer to DepositBox
payvint Aug 25, 2022
8cff934
Remove USDT constant
payvint Aug 25, 2022
d7cccc5
Add tests
payvint Aug 26, 2022
a1b4d6c
Merge pull request #1307 from skalenetwork/enhancement/safe-transfer
DimaStebaev Oct 25, 2022
b51def4
Fix the bug
DimaStebaev Oct 20, 2022
9222c83
Add test
DimaStebaev Oct 25, 2022
825275f
Merge pull request #1304 from skalenetwork/bug/impossible-wirhdrawals
DimaStebaev Oct 26, 2022
eace03f
Skip failed transfers
DimaStebaev Oct 24, 2022
7319130
Add a test
DimaStebaev Oct 27, 2022
af8ef69
Merge pull request #1310 from skalenetwork/bug/withdrawals-blocking
DimaStebaev Oct 28, 2022
dbf9ed1
Add events
DimaStebaev Oct 20, 2022
a0b01f0
Make events fields indexed
DimaStebaev Oct 28, 2022
4c0cefa
Update a test
DimaStebaev Oct 28, 2022
ac8955f
Merge pull request #1305 from skalenetwork/enhancement/pause-events
DimaStebaev Oct 28, 2022
766f23a
Add events
DimaStebaev Oct 20, 2022
c9a4f9a
Make events fields indexed
DimaStebaev Oct 28, 2022
06d0349
Update tests
DimaStebaev Oct 28, 2022
12b497f
Make token argument indexed
DimaStebaev Oct 31, 2022
39c75ac
Merge pull request #1306 from skalenetwork/enhancement/params-events
DimaStebaev Nov 1, 2022
b85d8e2
Add Goerli support
DimaStebaev Nov 8, 2022
76f6aea
Merge pull request #1321 from skalenetwork/enhancement/goerli
DimaStebaev Nov 9, 2022
5aaef71
Fix bug in verification script
DimaStebaev Nov 9, 2022
988d8e2
Merge pull request #1322 from skalenetwork/bug/verification
DimaStebaev Nov 9, 2022
cbdbd7b
Fix safe relay
DimaStebaev Nov 9, 2022
a00e083
Merge pull request #1323 from skalenetwork/enhancement/relay
DimaStebaev Nov 9, 2022
aae520c
Update mainnet.json
DimaStebaev Dec 1, 2022
2c8c9e9
Merge branch 'stable' into release-1.3.4
DimaStebaev Dec 1, 2022
d55997f
Add DepositBoxERC721WithMetadata
DimaStebaev Dec 1, 2022
e93cc84
Merge pull request #1346 from skalenetwork/release-1.3.4
DimaStebaev Dec 1, 2022
a4bfe3e
Merge branch 'stable' into feature/add-receiver-field
payvint Dec 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,761 changes: 1,753 additions & 8 deletions proxy/.openzeppelin/mainnet.json

Large diffs are not rendered by default.

134 changes: 88 additions & 46 deletions proxy/contracts/mainnet/DepositBoxes/DepositBoxERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,30 +77,8 @@ contract DepositBoxERC1155 is DepositBox, ERC1155ReceiverUpgradeable, IDepositBo
)
external
override
rightTransaction(schainName, msg.sender)
whenNotKilled(keccak256(abi.encodePacked(schainName)))
{
bytes32 schainHash = keccak256(abi.encodePacked(schainName));
address contractReceiver = schainLinks[schainHash];
require(contractReceiver != address(0), "Unconnected chain");
require(
IERC1155Upgradeable(erc1155OnMainnet).isApprovedForAll(msg.sender, address(this)),
"DepositBox was not approved for ERC1155 token"
);
bytes memory data = _receiveERC1155(
schainName,
erc1155OnMainnet,
msg.sender,
id,
amount
);
_saveTransferredAmount(schainHash, erc1155OnMainnet, _asSingletonArray(id), _asSingletonArray(amount));
IERC1155Upgradeable(erc1155OnMainnet).safeTransferFrom(msg.sender, address(this), id, amount, "");
messageProxy.postOutgoingMessage(
schainHash,
contractReceiver,
data
);
depositERC1155Direct(schainName, erc1155OnMainnet, id, amount, msg.sender);
}

/**
Expand All @@ -119,30 +97,8 @@ contract DepositBoxERC1155 is DepositBox, ERC1155ReceiverUpgradeable, IDepositBo
)
external
override
rightTransaction(schainName, msg.sender)
whenNotKilled(keccak256(abi.encodePacked(schainName)))
{
bytes32 schainHash = keccak256(abi.encodePacked(schainName));
address contractReceiver = schainLinks[schainHash];
require(contractReceiver != address(0), "Unconnected chain");
require(
IERC1155Upgradeable(erc1155OnMainnet).isApprovedForAll(msg.sender, address(this)),
"DepositBox was not approved for ERC1155 token Batch"
);
bytes memory data = _receiveERC1155Batch(
schainName,
erc1155OnMainnet,
msg.sender,
ids,
amounts
);
_saveTransferredAmount(schainHash, erc1155OnMainnet, ids, amounts);
IERC1155Upgradeable(erc1155OnMainnet).safeBatchTransferFrom(msg.sender, address(this), ids, amounts, "");
messageProxy.postOutgoingMessage(
schainHash,
contractReceiver,
data
);
depositERC1155BatchDirect(schainName, erc1155OnMainnet, ids, amounts, msg.sender);
}

/**
Expand Down Expand Up @@ -389,6 +345,92 @@ contract DepositBoxERC1155 is DepositBox, ERC1155ReceiverUpgradeable, IDepositBo
__ERC1155Receiver_init();
}

/**
* @dev Allows `msg.sender` to send ERC1155 token from mainnet to schain to specified receiver.
*
* Requirements:
*
* - Receiver contract should be defined.
* - `msg.sender` should approve their tokens for DepositBoxERC1155 address.
*/
function depositERC1155Direct(
string calldata schainName,
address erc1155OnMainnet,
uint256 id,
uint256 amount,
address receiver
)
public
override
rightTransaction(schainName, receiver)
whenNotKilled(keccak256(abi.encodePacked(schainName)))
{
bytes32 schainHash = keccak256(abi.encodePacked(schainName));
address contractReceiver = schainLinks[schainHash];
require(contractReceiver != address(0), "Unconnected chain");
require(
IERC1155Upgradeable(erc1155OnMainnet).isApprovedForAll(msg.sender, address(this)),
"DepositBox was not approved for ERC1155 token"
);
bytes memory data = _receiveERC1155(
schainName,
erc1155OnMainnet,
receiver,
id,
amount
);
_saveTransferredAmount(schainHash, erc1155OnMainnet, _asSingletonArray(id), _asSingletonArray(amount));
IERC1155Upgradeable(erc1155OnMainnet).safeTransferFrom(msg.sender, address(this), id, amount, "");
messageProxy.postOutgoingMessage(
schainHash,
contractReceiver,
data
);
}

/**
* @dev Allows `msg.sender` to send batch of ERC1155 tokens from mainnet to schain to specified receiver.
*
* Requirements:
*
* - Receiver contract should be defined.
* - `msg.sender` should approve their tokens for DepositBoxERC1155 address.
*/
function depositERC1155BatchDirect(
string calldata schainName,
address erc1155OnMainnet,
uint256[] calldata ids,
uint256[] calldata amounts,
address receiver
)
public
override
rightTransaction(schainName, receiver)
whenNotKilled(keccak256(abi.encodePacked(schainName)))
{
bytes32 schainHash = keccak256(abi.encodePacked(schainName));
address contractReceiver = schainLinks[schainHash];
require(contractReceiver != address(0), "Unconnected chain");
require(
IERC1155Upgradeable(erc1155OnMainnet).isApprovedForAll(msg.sender, address(this)),
"DepositBox was not approved for ERC1155 token Batch"
);
bytes memory data = _receiveERC1155Batch(
schainName,
erc1155OnMainnet,
receiver,
ids,
amounts
);
_saveTransferredAmount(schainHash, erc1155OnMainnet, ids, amounts);
IERC1155Upgradeable(erc1155OnMainnet).safeBatchTransferFrom(msg.sender, address(this), ids, amounts, "");
messageProxy.postOutgoingMessage(
schainHash,
contractReceiver,
data
);
}

/**
* @dev Checks whether contract supports such interface (first 4 bytes of method name and its params).
*/
Expand Down
Loading