Expand description
Most of the CW* specs are focused on the public interfaces
of the contract. The APIs used for ExecuteMsg
or QueryMsg
.
However, when we wish to migrate or inspect smart contract info,
we need some form of smart contract information embedded on state.
This is where CW2 comes in. It specifies a special Item to
be stored on disk by all contracts on instantiate
.
ContractInfo
must be stored under the "contract_info"
key which translates
to "636F6E74726163745F696E666F"
in hex format.
Since the state is well defined, we do not need to support any “smart queries”.
We do provide a helper to construct a “raw query” to read the ContractInfo
of any CW2-compliant contract.
For more information on this specification, please check out the README.
Structs§
Enums§
Constants§
Functions§
- assert_
contract_ version - Assert that the stored contract version info matches the given value. This is useful during migrations, for making sure that the correct contract is being migrated, and it’s being migrated from the correct version.
- ensure_
from_ older_ version - This function not only validates that the right contract and version can be migrated, but also updates the contract version from the original (stored) version to the new version. It returns the original version for the convenience of doing external checks.
- get_
contract_ version - get_contract_version can be use in migrate to read the previous version of this contract
- query_
contract_ info - This will make a raw_query to another contract to determine the current version it claims to be. This should not be trusted, but could be used as a quick filter if the other contract exists and claims to be a cw20-base contract for example. (Note: you usually want to require interfaces not implementations of the contracts you compose with, so be careful of overuse)
- set_
contract_ version - set_contract_version should be used in instantiate to store the original version, and after a successful migrate to update it