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

Custom ERC1155Predicate with generic ChainExit event #77

Merged
merged 22 commits into from
Aug 30, 2021

Conversation

itzmeanjan
Copy link
Contributor

@itzmeanjan itzmeanjan requested a review from imyourm8 April 26, 2021 10:39
@itzmeanjan itzmeanjan force-pushed the custom-erc1155-predicate-tsb branch 2 times, most recently from 73b8a7e to 966451e Compare April 28, 2021 05:43
@itzmeanjan itzmeanjan force-pushed the custom-erc1155-predicate-tsb branch from 966451e to 728dd21 Compare April 28, 2021 07:06
@nfurfaro
Copy link

nfurfaro commented Apr 29, 2021

Hello. I think a small change which makes this new event even more useful & generic would be to modify the types of 2 of the ChainExit event params to be arrays. So the new event would look like this:
ChainExit(address indexed to, uint256[] tokenIds, uint256[] amounts, bytes data)
This would let allow for both batch or single chain-exits. As it is currently written, this new predicate was creating arrays out of the single tokenId & amount anyway prior to calling token.mintBatch(...

@itzmeanjan
Copy link
Contributor Author

Hello. I think a small change which makes this new event even more useful & generic would be to modify the types of 2 of the ChainExit event params to be arrays. So the new event would look like this:
ChainExit(address indexed to, uint256[] tokenIds, uint256[] amounts, bytes data)
This would let allow for both batch or single chain-exits. As it is currently written, this new predicate was creating arrays out of the single tokenId & amount anyway prior to calling token.mintBatch(...

This is WIP. Thanks.

@itzmeanjan
Copy link
Contributor Author

Hello. I think a small change which makes this new event even more useful & generic would be to modify the types of 2 of the ChainExit event params to be arrays. So the new event would look like this:
ChainExit(address indexed to, uint256[] tokenIds, uint256[] amounts, bytes data)
This would let allow for both batch or single chain-exits. As it is currently written, this new predicate was creating arrays out of the single tokenId & amount anyway prior to calling token.mintBatch(...

This is attached in PR.

@itzmeanjan itzmeanjan force-pushed the custom-erc1155-predicate-tsb branch from a108732 to b722eb6 Compare April 29, 2021 13:19
IMintableERC1155 token = IMintableERC1155(rootToken);

uint256[] memory balances = token.balanceOfBatch(makeArrayWithAddress(address(this), ids.length), ids);
uint256[] memory toBeMinted = calculateAmountsToBeMinted(balances, amounts);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return bool flag if there is any token that should be minted, to avoid the unnecessary call to external contract.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can return a second bool flag, that indicates that tokens are only minted to avoid unnecessary transferFrom entirely in some cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done : 404745e

@imyourm8
Copy link

There are other artifacts that are committed, like MintableERC115Predicate, let's files only for the ChainExit predicate.

@itzmeanjan
Copy link
Contributor Author

There are other artifacts that are committed, like MintableERC115Predicate, let's files only for the ChainExit predicate.

Done : 16b832a

@mvanmeerbeck
Copy link

Hi there,

What's the state of this PR ? It is still required for Sandbox

Thanks!

@itzmeanjan itzmeanjan requested a review from reddyismav August 27, 2021 10:26
@itzmeanjan
Copy link
Contributor Author

Deployment in progress, I'm merging it.

@itzmeanjan itzmeanjan merged commit 2faeee3 into master Aug 30, 2021
@itzmeanjan itzmeanjan deleted the custom-erc1155-predicate-tsb branch August 30, 2021 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants