There is no law or precedent to prohibit someone from engaging in contracts because of holding public office. In fact there is even an ongoing movement to try to get more politicians to do exactly this so that campaign promises would be more likely to be executed. Again qualified immunity would probably make these contracts impossible to enforce against a politician, but in this case the agreement would work as a defense if for some reason Oracle et al faced legal threats or fines for continuing to work with TikTok.