Module fadroma::prelude

source ·
Expand description

Start here. use fadroma::prelude::* to get the essentials for writing smart contracts with Fadroma.

Re-exports

Modules

Macros

  • Asserts that two expressions are approximately equal to each other.
  • Quick check for a guard. If the condition (first argument) is false, then return the second argument x wrapped in Err(x).
  • Quick check for a guard. Like assert_eq!, but rather than panic, it returns the third argument x wrapped in Err(x).
  • Quick check for a guard. Like assert_ne!, but rather than panic, it returns the third argument x wrapped in Err(x).

Structs

  • A human readable address.
  • DelegationsResponse is data format returned from StakingRequest::AllDelegations query
  • The data format returned from StakingRequest::AllValidators query
  • An key value pair that is used in the context of event attributes in logs
  • Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.
  • BondedDenomResponse is data format returned from StakingRequest::BondedDenom query
  • A blockchain address in its binary form.
  • The error returned by TryFrom conversions that overflow, for example when converting from Uint256 to Uint128.
  • A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0
  • A fixed-point decimal value with 18 fractional digits, i.e. Decimal256(1_000_000_000_000_000_000) == 1.0
  • Delegation is basic (cheap to query) data about a delegation.
  • DelegationResponse is data format returned from StakingRequest::Delegation query
  • An empty struct that serves as a placeholder in different places, such as contracts that don’t set a custom message.
  • FullDelegation is all the info on the delegation, some (like accumulated_reward and can_redelegate) is expensive to query.
  • This is a wrapper around Vec to add hex de/serialization with serde. It also adds some helper methods to help encode inline.
  • Additional information from MsgInstantiateContract and MsgExecuteContract, which is passed along with the contract execution message into the instantiate and execute entry points.
  • Holds all external dependencies of the contract. Designed to allow easy dependency injection at runtime. This cannot be copied or cloned since it would behave differently for mock storages and a bridge storage in the VM.
  • The result object returned to reply. We always get the ID from the submessage back and then must handle success and error cases ourselves.
  • A response of a contract entry point, such as instantiate, execute or migrate.
  • A submessage that will guarantee a reply call on success or error, depending on the reply_on setting. If you do not need to process the result, use regular messages instead.
  • The information we get back from a successful sub message execution, with full Cosmos SDK events.
  • A point in time in nanosecond precision.
  • A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.
  • A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.
  • An implementation of u256 that is using strings for JSON encoding/decoding, such that the full u256 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.
  • An implementation of u512 that is using strings for JSON encoding/decoding, such that the full u512 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.
  • Instances are created in the querier.
  • The data format returned from StakingRequest::Validator query

Enums

Traits

  • Api are callbacks to system functions implemented outside of the wasm modules. Currently it just supports address conversion but we could add eg. crypto functions here.
  • Like CustomQuery for better type clarity. Also makes it shorter to use as a trait bound.
  • A trait that is required to avoid conflicts with other query types like BankQuery and WasmQuery in generic implementations. You need to implement it in your custom query type.
  • A fraction p/q with integers p and q.
  • A trait for calculating the integer square root.
  • A type which can be described as a JSON Schema document.
  • Storage provides read and write access to a persistent storage. If you only want to provide read access, provide &Storage

Functions

  • Creates a new ENCRYPTED Attribute. Attribute::new is an alias for this.
  • Creates a new plaintext Attribute. Attribute::new_plaintext is an alias for this.
  • A shorthand constructor for Coin
  • A shortcut constructor for a set of one denomination of coins
  • has_coins returns true if the list of coins has at least the required amount
  • Shortcut helper as the construction of WasmMsg::Instantiate can be quite verbose in contract code
  • Shortcut helper as the construction of WasmMsg::Instantiate can be quite verbose in contract code.

Type Definitions

  • Alias for StdResult<Option<V>>.
  • A short-hand alias for the two-level query result (1. accessing the contract, 2. executing query in the contract)
  • A record of a key-value storage that is created through an iterator API. The first element (key) is always raw binary data. The second element (value) is binary by default but can be changed to a custom type. This allows contracts to reuse the type when deserializing database records.
  • The return type for init, execute and query. Since the error type cannot be serialized to JSON, this is only available within the contract and its unit tests.
  • Alias for StdResult<()>.

Attribute Macros

  • This attribute macro generates the boilerplate required to call into the contract-specific logic from the entry-points to the Wasm module.

Derive Macros