pub trait ContractApi<Seal: RgbSeal> {
// Required methods
fn contract_id(&self) -> ContractId;
fn codex(&self) -> &Codex;
fn repo(&self) -> &impl LibRepo;
fn memory(&self) -> &impl Memory;
fn is_known(&self, opid: Opid) -> bool;
fn apply_operation(&mut self, op: VerifiedOperation);
fn apply_seals(
&mut self,
opid: Opid,
seals: SmallOrdMap<u16, Seal::Definition>,
);
fn apply_witness(&mut self, opid: Opid, witness: SealWitness<Seal>);
}
Expand description
API exposed by the contract required for evaluating and verifying the contract state (see
ContractVerify
).
NB: apply_operation
is called only after apply_witness
.
Required Methods§
Sourcefn contract_id(&self) -> ContractId
fn contract_id(&self) -> ContractId
Returns contract id for the processed contract.
Called only once during the operation verification.
Sourcefn codex(&self) -> &Codex
fn codex(&self) -> &Codex
Returns a codex against which the contract must be verified.
Called only once during the operation verification.
Sourcefn repo(&self) -> &impl LibRepo
fn repo(&self) -> &impl LibRepo
Returns repository providing script libraries used during the verification.
Called only once during the operation verification.
Sourcefn memory(&self) -> &impl Memory
fn memory(&self) -> &impl Memory
Returns a memory implementation providing read access to all the contract state cells, including immutable and destructible memory.
Sourcefn is_known(&self, opid: Opid) -> bool
fn is_known(&self, opid: Opid) -> bool
Detects whether an operation with a given id is already known as a valid operation for the ledger.
The method MUST return true
for genesis operation.
Sourcefn apply_operation(&mut self, op: VerifiedOperation)
fn apply_operation(&mut self, op: VerifiedOperation)
§Nota bene:
The method is called only for those operations which are not known (i.e. Self::is_known
returns false
for the operation id).
The method is NOT called for the genesis operation.
Sourcefn apply_seals(&mut self, opid: Opid, seals: SmallOrdMap<u16, Seal::Definition>)
fn apply_seals(&mut self, opid: Opid, seals: SmallOrdMap<u16, Seal::Definition>)
§Nota bene:
The method is called for all operations, including known ones, for which the consignment provides at least single seal definition information (thus, it may be called for the genesis operation as well).
Sourcefn apply_witness(&mut self, opid: Opid, witness: SealWitness<Seal>)
fn apply_witness(&mut self, opid: Opid, witness: SealWitness<Seal>)
§Nota bene:
The method is called for all operations, including known ones, which have a witness (i.e., except genesis or operations with no destroyed state).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.