Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dj8yfo opened this issue Feb 13, 2025 · 1 comment

Comments

@dj8yfo
Copy link
Collaborator

dj8yfo commented Feb 13, 2025

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
@TobieTom
Copy link
Contributor

Hola. I'm Tobias . I've already contributed to some projects concerning their documentation and would like to add this to my pool of experience plus I recently learned rust and cairo

@dj8yfo dj8yfo changed the title doc: document auto-generated <ContractType>Ext structs and their usage doc: document auto-generated <ContractType>Ext structs and their usage (created by contract_state) Feb 26, 2025
@dj8yfo dj8yfo changed the title doc: document auto-generated <ContractType>Ext structs and their usage (created by contract_state) doc: document auto-generated <ContractType>Ext structs and their usage (created by #[near(contract_state)]) Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: NEW❗
Development

No branches or pull requests

2 participants