From 11945ffdb43680c43cd5db7d1910e1016bb32901 Mon Sep 17 00:00:00 2001 From: "antonio@fulminlabs.org" Date: Tue, 11 Jul 2023 12:19:19 +0200 Subject: [PATCH 1/6] handling NotAContract() --- src/decoders/extensions/DecoderWithRegistry.sol | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/decoders/extensions/DecoderWithRegistry.sol b/src/decoders/extensions/DecoderWithRegistry.sol index 1616355..64278f9 100644 --- a/src/decoders/extensions/DecoderWithRegistry.sol +++ b/src/decoders/extensions/DecoderWithRegistry.sol @@ -25,14 +25,23 @@ contract DecoderWithRegistry is IDecoder, Ownable2Step { constructor() Ownable2Step() {} function setZone(uint8 zoneId, address zone) external onlyOwner { + if (zone.code.length == 0) { + revert NotAContract(); + } _zones.set(zoneId, zone); } function setFulfiller(uint8 fulfillerId, address fulfiller) external onlyOwner { + if (fullfiller.code.length == 0) { + revert NotAContract(); + } _fulfillers.set(fulfillerId, fulfiller); } function setToken(uint16 tokenId, address token) external onlyOwner { + if (token.code.length == 0) { + revert NotAContract(); + } _tokens.set(tokenId, token); } From 642d0b6c8b618e6488b9f4b545257ee7771c8d7a Mon Sep 17 00:00:00 2001 From: "antonio@fulminlabs.org" Date: Tue, 11 Jul 2023 12:29:28 +0200 Subject: [PATCH 2/6] importing NotAContract() --- src/decoders/extensions/DecoderWithRegistry.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/decoders/extensions/DecoderWithRegistry.sol b/src/decoders/extensions/DecoderWithRegistry.sol index 64278f9..33430b7 100644 --- a/src/decoders/extensions/DecoderWithRegistry.sol +++ b/src/decoders/extensions/DecoderWithRegistry.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.17; import {EnumerableMap} from "@openzeppelin/utils/structs/EnumerableMap.sol"; import {Ownable2Step} from "@openzeppelin/access/Ownable2Step.sol"; import {IDecoder} from "../IDecoder.sol"; -import {IFloodPlain} from "../../flood-plain/IFloodPlain.sol"; +import {IFloodPlain, NotAContract} from "../../flood-plain/IFloodPlain.sol"; struct IdToAddress { uint256 id; From bb8a0fc46a1c7e1787b6478b0e247e2c880a2e72 Mon Sep 17 00:00:00 2001 From: "antonio@fulminlabs.org" Date: Tue, 11 Jul 2023 12:37:51 +0200 Subject: [PATCH 3/6] fix linting --- test/utils/TokenFixture.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/utils/TokenFixture.sol b/test/utils/TokenFixture.sol index 1fc89aa..a0d0fbf 100644 --- a/test/utils/TokenFixture.sol +++ b/test/utils/TokenFixture.sol @@ -13,14 +13,14 @@ address constant ARBITRUM_DAI = 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1; address constant ARBITRUM_USDT = 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9; contract MockToken is ERC20 { - uint8 public immutable __decimals; + uint8 internal immutable privateDecimals; constructor(string memory name, string memory symbol, uint8 _decimals) ERC20(name, symbol) { - __decimals = _decimals; + privateDecimals = _decimals; } function decimals() public view override returns (uint8) { - return __decimals; + return privateDecimals; } } From cbfbee97c247bd9f708988dd4269170912464c58 Mon Sep 17 00:00:00 2001 From: "antonio@fulminlabs.org" Date: Tue, 11 Jul 2023 12:45:32 +0200 Subject: [PATCH 4/6] fix import --- src/decoders/extensions/DecoderWithRegistry.sol | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/decoders/extensions/DecoderWithRegistry.sol b/src/decoders/extensions/DecoderWithRegistry.sol index 33430b7..db7c0de 100644 --- a/src/decoders/extensions/DecoderWithRegistry.sol +++ b/src/decoders/extensions/DecoderWithRegistry.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.17; import {EnumerableMap} from "@openzeppelin/utils/structs/EnumerableMap.sol"; import {Ownable2Step} from "@openzeppelin/access/Ownable2Step.sol"; import {IDecoder} from "../IDecoder.sol"; -import {IFloodPlain, NotAContract} from "../../flood-plain/IFloodPlain.sol"; +import {IFloodPlain} from "../../flood-plain/IFloodPlain.sol"; struct IdToAddress { uint256 id; @@ -26,21 +26,21 @@ contract DecoderWithRegistry is IDecoder, Ownable2Step { function setZone(uint8 zoneId, address zone) external onlyOwner { if (zone.code.length == 0) { - revert NotAContract(); + revert IFloodPlain.NotAContract(); } _zones.set(zoneId, zone); } function setFulfiller(uint8 fulfillerId, address fulfiller) external onlyOwner { if (fullfiller.code.length == 0) { - revert NotAContract(); + revert IFloodPlain.NotAContract(); } _fulfillers.set(fulfillerId, fulfiller); } function setToken(uint16 tokenId, address token) external onlyOwner { if (token.code.length == 0) { - revert NotAContract(); + revert IFloodPlain.NotAContract(); } _tokens.set(tokenId, token); } From 30a939bc5f37dfabb5c4a331c4642debc3e455fb Mon Sep 17 00:00:00 2001 From: "antonio@fulminlabs.org" Date: Tue, 11 Jul 2023 12:48:14 +0200 Subject: [PATCH 5/6] fix typo --- src/decoders/extensions/DecoderWithRegistry.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/decoders/extensions/DecoderWithRegistry.sol b/src/decoders/extensions/DecoderWithRegistry.sol index db7c0de..c92a8df 100644 --- a/src/decoders/extensions/DecoderWithRegistry.sol +++ b/src/decoders/extensions/DecoderWithRegistry.sol @@ -32,7 +32,7 @@ contract DecoderWithRegistry is IDecoder, Ownable2Step { } function setFulfiller(uint8 fulfillerId, address fulfiller) external onlyOwner { - if (fullfiller.code.length == 0) { + if (fulfiller.code.length == 0) { revert IFloodPlain.NotAContract(); } _fulfillers.set(fulfillerId, fulfiller); From 67a594d0baf66d74a815ef8ce67bb5aac781d971 Mon Sep 17 00:00:00 2001 From: "antonio@fulminlabs.org" Date: Tue, 11 Jul 2023 12:50:10 +0200 Subject: [PATCH 6/6] renamed innerDecimals --- test/utils/TokenFixture.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/utils/TokenFixture.sol b/test/utils/TokenFixture.sol index a0d0fbf..811d36d 100644 --- a/test/utils/TokenFixture.sol +++ b/test/utils/TokenFixture.sol @@ -13,14 +13,14 @@ address constant ARBITRUM_DAI = 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1; address constant ARBITRUM_USDT = 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9; contract MockToken is ERC20 { - uint8 internal immutable privateDecimals; + uint8 internal immutable innerDecimals; constructor(string memory name, string memory symbol, uint8 _decimals) ERC20(name, symbol) { - privateDecimals = _decimals; + innerDecimals = _decimals; } function decimals() public view override returns (uint8) { - return privateDecimals; + return innerDecimals; } }