It fails because the compiler is looking for the concat
function as a member of bytes
type.
You can use concat as a regular function
return string(concat(bytes(api0xUrl),
concat(bytes(sellStr),
...)));
Another alternative is move concat to a library and use the using for
mechanism.
library L {
function concat(bytes memory a, bytes memory b) internal pure returns (bytes memory) {
return abi.encodePacked(a, b);
}
}
contract Swaper0x {
using L for bytes; // X.concat(Y) => concat(X, Y)
Now it should work as expected
return string(bytes(api0xUrl) // ---> no error here
.concat(bytes(sellStr))