Updated length to match comment + added explicit test
This commit is contained in:
@@ -166,7 +166,7 @@ contract ERC1155Proxy is
|
|||||||
// Assert that the length of asset data:
|
// Assert that the length of asset data:
|
||||||
// 1. Must be at least 132 bytes (Table #2)
|
// 1. Must be at least 132 bytes (Table #2)
|
||||||
// 2. Must be a multiple of 32 (excluding the 4-byte selector)
|
// 2. Must be a multiple of 32 (excluding the 4-byte selector)
|
||||||
if or(lt(assetDataLength, 100), mod(sub(assetDataLength, 4), 32)) {
|
if or(lt(assetDataLength, 132), mod(sub(assetDataLength, 4), 32)) {
|
||||||
// Revert with `Error("INVALID_ASSET_DATA_LENGTH")`
|
// Revert with `Error("INVALID_ASSET_DATA_LENGTH")`
|
||||||
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
|
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
|
||||||
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
|
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
|
||||||
|
|||||||
@@ -1382,6 +1382,34 @@ describe('ERC1155Proxy', () => {
|
|||||||
RevertReason.InvalidAssetDataLength
|
RevertReason.InvalidAssetDataLength
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('should revert if length of assetData is less than 132 bytes', async () => {
|
||||||
|
// setup test parameters
|
||||||
|
const tokensToTransfer = fungibleTokens.slice(0, 1);
|
||||||
|
const valuesToTransfer = [fungibleValueToTransferLarge];
|
||||||
|
const valueMultiplier = valueMultiplierSmall;
|
||||||
|
// we'll construct asset data that has a 4 byte selector plus
|
||||||
|
// 96 byte payload. This results in asset data that is 100 bytes
|
||||||
|
// long and will trigger the `invalid length` error.
|
||||||
|
// we must be sure to use a # of bytes that is still %32
|
||||||
|
// so that we know the error is not triggered by another check in the code.
|
||||||
|
const zeros96Bytes = "0".repeat(188);
|
||||||
|
const assetData131Bytes = `${AssetProxyId.ERC1155}${zeros96Bytes}`;
|
||||||
|
// execute transfer
|
||||||
|
await expectTransactionFailedAsync(
|
||||||
|
erc1155ProxyWrapper.transferFromWithLogsAsync(
|
||||||
|
spender,
|
||||||
|
receiverContract,
|
||||||
|
erc1155Contract.address,
|
||||||
|
tokensToTransfer,
|
||||||
|
valuesToTransfer,
|
||||||
|
valueMultiplier,
|
||||||
|
receiverCallbackData,
|
||||||
|
authorized,
|
||||||
|
assetData131Bytes,
|
||||||
|
),
|
||||||
|
RevertReason.InvalidAssetDataLength
|
||||||
|
);
|
||||||
|
});
|
||||||
it('should transfer nothing if value is zero', async () => {
|
it('should transfer nothing if value is zero', async () => {
|
||||||
// setup test parameters
|
// setup test parameters
|
||||||
const tokenHolders = [spender, receiver];
|
const tokenHolders = [spender, receiver];
|
||||||
|
|||||||
Reference in New Issue
Block a user