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

Test getWrapped1155DeployBytecode dynamic names #4

Merged
merged 20 commits into from
Apr 13, 2021

Conversation

davizalpe
Copy link
Contributor

  • Replace Wrapped1155 bytecode for adapt dynamic names with diferent length.
  • Rename src to contract for truffle compile.

Resolves #3

- Replace Wrapped1155 bytecode for adapt dynamic names with diferent length.
- Rename `src` to `contract` for truffle compile.
@davizalpe davizalpe self-assigned this Feb 9, 2021
@davizalpe davizalpe added the enhancement New feature or request label Feb 9, 2021
contracts/Wrapped1155Factory.sol Outdated Show resolved Hide resolved
contracts/Wrapped1155Factory.sol Outdated Show resolved Hide resolved
contracts/Wrapped1155Factory.sol Outdated Show resolved Hide resolved
contracts/Wrapped1155Factory.sol Show resolved Hide resolved
contracts/Wrapped1155Factory.sol Outdated Show resolved Hide resolved
test/test-1155-to-20.js Outdated Show resolved Hide resolved
Copy link

@nlordell nlordell left a comment

Choose a reason for hiding this comment

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

On a side note unrelated to the changes: I'm not super familiar with the project, but I don't quite understand why the deployed bytecode needs to write EVM codes (instead of letting Solidity generate a constructor for example). Is this just a gas optimization?

Otherwise, changes look good.

edit: Ah I see now, its because we are using a minimal proxy implementation for the ERC20 wrapper.

contracts/Wrapped1155Factory.sol Outdated Show resolved Hide resolved
- Rename `tokenNameOffset` to `tokenNameLength`.
- Replace `bytes` type to `bytes31` and `uint8` for `tokenName` and
  `tokenLength`.
- Add `Deposit` event.

See #4 (comment)
Revert `tokenName` bytes31 to type bytes to be able to slice calldata
`data` on override methods `onERC1155Received` and `onERC1155BatchReceived`.
Add dynamic tokenName, symbol, and decimals into the
`getWrapped1155DeployBytecode` method as `bytes calldata` `data`
parameters to allow use them in `onERC1155Received` and `onERC1155BatchReceived`
1155 methods. This will allow to pass as bytes the encoded bytecode for
the `tokenName` and `tokenSymbol` as push bytes32 and
`tokenDecimals` as push bytes on the EVM:

To call methods with `bytes calldata` parameters it is required to
calculate the values on the client using the following steps:
- `tokenName`: bytes32, string in hexadecimal and the zero paddings and
  the length of the string in hexadecimal. eg: for "WrappedERC-1155"
  is "0x577261707065644552432d31313535000000000000000000000000000000001e".
- `tokenSymbol`: bytes32, the string in hexadecimal, zero paddings, and
  the length of the string in hex. eg: for "WMT" is
  "0x574d540000000000000000000000000000000000000000000000000000000006".
- `tokenDecimal`: bytes, the number in hexadecimal. eg: 18 as 0x12.
Add 1155-to-20-helper repository to generate the bytecode ERC-20 metadas
on tests.
- Remove the `abi.decode` receiver addresses and use `operator` as default
receiver address on `onERC1155Received` and `onERC1155BatchReceived`.

- Remove comments from `getWrapped1155DeployBytecode`.
@davizalpe davizalpe marked this pull request as ready for review February 26, 2021 13:18
- Add bytecode especification.
- Add More-Minimal Proxy bytecode.
- Include references.
- Add token `bytes calldata data` support on batch methods
`onERC1155BatchReceived` and `batchUnwrap` with requirement of
data.length should be module of 65 with the same size of `ids` and `tokenIds`
arrays.
- Add SafeMath for add, mul, and div operators.
- Add @openzeppelin/contracts `v3.4.0` dependency.
@davizalpe davizalpe merged commit 58e8750 into master Apr 13, 2021
@davizalpe davizalpe deleted the feature/support-dynamic-fields branch April 13, 2021 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to correctly identify each wrapped token
4 participants