-
Notifications
You must be signed in to change notification settings - Fork 389
Closed
Labels
Breaking (interface)Breaks VM-contract interface, likely requires `cosmwasm_version` bumpBreaks VM-contract interface, likely requires `cosmwasm_version` bumpPerformanceLet's try to get things fasterLet's try to get things fastermaybequestionFurther information is requestedFurther information is requested
Milestone
Description
Current State
Currently Env is a nested json struct with 5 concrete fields (BlockInfo and ContractInfo).
This is very easy to construct and pass in tests, but it is a bunch of json parsing on every call, which is not ideal. It could also be more compile-time type-safe (not just relying on json parsing for that). This is referenced in each contract as a concrete type: env: Env.
Proposal
- Rename
EnvtoMockEnvand we use this just for the tests. - Make
trait Envwith accessors, which is implemented byMockEnv - Create an
ExternalEnv, which provides the same methods but makes calls wasm exports to get the values when needed handle/init/queryall now takeenv: &dyn Envfor the argument. And call eg.env.contract_address()instead ofenv.contract.address.clone()
Here is the trait I am thinking of, which is just flattened accessors from the current Env type.
pub trait Env {
fn block_height(&self) -> u64;
fn block_time(&self) -> u64;
fn block_time_nanos(&self) -> u64;
fn chain_id(&self) -> String;
fn contract_address(&self) -> HumanAddress;
}Proposing this for 0.14. Either we do it then, or we reject this.
Metadata
Metadata
Assignees
Labels
Breaking (interface)Breaks VM-contract interface, likely requires `cosmwasm_version` bumpBreaks VM-contract interface, likely requires `cosmwasm_version` bumpPerformanceLet's try to get things fasterLet's try to get things fastermaybequestionFurther information is requestedFurther information is requested