Skip to content

doc: document auto-generated <ContractType>Ext structs and their usage (created by #[near(contract_state)]) #1308

Open
@dj8yfo

Description

@dj8yfo

not very clear where to put <ContractType>Ext doc itself

EDIT: it should be a sub-heading under #[near] macro documentation, peer (at the same heading level as) to attributes such as #[private] and what not

This task should describe, that this structure is created for all contracts, and what's the purpose of each method,
and how its methods signatures can be looked up on generated cargo doc --lib for contract

#[must_use]
pub struct CrossContractExt {
    pub(crate) account_id: ::near_sdk::AccountId,
    pub(crate) deposit: ::near_sdk::NearToken,
    pub(crate) static_gas: ::near_sdk::Gas,
    pub(crate) gas_weight: ::near_sdk::GasWeight,
}
impl CrossContractExt {
    pub fn with_attached_deposit(mut self, amount: ::near_sdk::NearToken) -> Self {
        /// ...
    }
    pub fn with_static_gas(mut self, static_gas: ::near_sdk::Gas) -> Self {
        /// ...
    }
    pub fn with_unused_gas_weight(mut self, gas_weight: u64) -> Self {
        /// ...
    }
}
impl CrossContract {
    /// API for calling this contract's functions in a subsequent execution.
    pub fn ext(account_id: ::near_sdk::AccountId) -> CrossContractExt {
        /// ....
    }
}
impl CrossContractExt {
    pub fn contract_source_metadata(self) -> ::near_sdk::Promise {
        /// ...
    }
}
impl CrossContractExt {
    pub fn method_one(self, n: u32) -> ::near_sdk::Promise {}

    pub fn method_two(self, n: u32) -> ::near_sdk::Promise {
        /// ...
    }
}

links:

  1. <ContractType>Ext => [near_sdk::Promise]
  2. anchor of #[near(contract_state)] attribute => <ContractType>Ext , and mentions, what parts of it specifically get defined by contract_state
  3. anchor of #[near] on impl blocks => <ContractType>Ext , and mentions, what parts of it specifically get defined by #[near] on impl blocks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      NEW❗

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions