To ensure deterministic outcome, we ask contract developers to explicitly specify what other contract dependencies their contract has, during registration with the DEX module. Contract A is considered to depend on contract B if the response of any of contract A'ssudocalls may contain order placement/cancellation messages to contract B. For example, a perp contract might need to place orders on a spot contract during its own order placement process to support features like multi-collateral. In that case, the perp contract will need to specify its dependency on the spot contract. The CLI syntax to register a contract with dependencies is as follow:
In the above perp-spot example, assuming perp's address is sei14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sh9m79m and spot's address is sei1fzm6gzyccl8jvdv3qq6hp9vs6ylaruervs4m06c7k0ntzn2f8faq8un0p6, the CLI to register perp would be:
Note that the registration is an upsert operation, so registering the same contract multiple times will update its registration information.
注意注册是一个合并(upsert)操作,所以多次注册同一个合约会更新它的注册信息。
循环依赖 (Circular Dependency)
Circular dependency is not allowed and will be rejected if detected upon contract registration. For example, if contract A is already registered to depend on contract B, then a registration of contract B that specifies contract A as a dependency will fail.