pub struct Contract {
pub state: VersionedState<V1>,
}Fields§
§state: VersionedState<V1>Implementations§
Source§impl Contract
impl Contract
Sourcepub fn ext(account_id: AccountId) -> ContractExt
pub fn ext(account_id: AccountId) -> ContractExt
API for calling this contract’s functions in a subsequent execution.
pub fn ext_on(promise: Promise) -> ContractExt
Sourcepub fn ext_self() -> ContractExt
pub fn ext_self() -> ContractExt
Convenience method for creating a cross-contract call to the current contract.
Equivalent to Self::ext(near_sdk::env::current_account_id()).
Source§impl Contract
impl Contract
pub fn contract_source_metadata()
Source§impl Contract
impl Contract
Sourcepub const GAS_FOR_MIGRATE: Gas
pub const GAS_FOR_MIGRATE: Gas
Gas reserved for the batched migrate in Self::upgrade.
Enough for any migration this method can be asked to run. The expensive one — rewriting
every stored version blob out of a pre-1.1.0 layout, several MB on the live registries —
is not among them: those releases have no upgrade, so they are migrated by a batch their
key holder signs, where the gas is on the transaction rather than reserved here.
Sourcepub const MAX_CODE_CHUNK_LEN: u32 = 131_072u32
pub const MAX_CODE_CHUNK_LEN: u32 = 131_072u32
Most a single Self::get_version_code_chunk will return.
A view’s return value reaches the caller as a JSON array of one integer per byte, so the response body runs several times the payload; this keeps it inside what RPC providers serve.
pub fn new() -> Contract
Sourcepub fn upgrade(
&mut self,
code: UpgradeSource,
migrate_args: Base64VecU8,
) -> Promise
pub fn upgrade( &mut self, code: UpgradeSource, migrate_args: Base64VecU8, ) -> Promise
Atomically deploy new code and run its migrate in one receipt, so a failed migration
reverts the deploy with it. migrate_args selects the state::Migration matching the
layout this registry actually holds.
The only way to replace the code of a registry whose full-access keys have been removed.
pub fn list_versions( &self, count: Option<u32>, offset: Option<u32>, ) -> Vec<&String>
pub fn get_version_code_hash( &self, version_key: String, ) -> Option<Base58CryptoHash>
Sourcepub fn get_version(&self, version_key: String) -> Option<VersionInfo>
pub fn get_version(&self, version_key: String) -> Option<VersionInfo>
A registered version’s hash and whether Self::deploy can still use it.
list_versions keeps listing a version whose code remove_version cleared, and
get_version_code_hash keeps answering for it, so membership alone cannot tell a
deployable version from one that will panic partway through a deploy.
Sourcepub fn get_registry_entry(
&self,
account_id: AccountId,
) -> Option<RegistryEntryView>
pub fn get_registry_entry( &self, account_id: AccountId, ) -> Option<RegistryEntryView>
Whether a name is taken, and by what.
Self::deploy refuses any name already present, so a Reserved name is as unusable as a
deployed one — a state Self::get_deployment reports as absent.
Sourcepub fn get_version_code_chunk(
&self,
version_key: String,
offset: u32,
len: u32,
) -> Option<Vec<u8>>
pub fn get_version_code_chunk( &self, version_key: String, offset: u32, len: u32, ) -> Option<Vec<u8>>
Bytes [offset, offset + len) of a version’s stored code, or None if it has none.
Borsh-serialized and chunked: the JSON encoding would base64 the blob and the RPC would
then re-expand it to one integer per byte. Reading a whole contract back is the last
resort anyway — Self::get_version reports the hash, which usually resolves against a
released artifact without touching this at all.
An offset past the end reads empty, so a caller can loop until it stops making progress.
pub fn list_deployments( &self, count: Option<u32>, offset: Option<u32>, ) -> Vec<&AccountId>
pub fn get_deployment(&self, account_id: AccountId) -> Option<&Deployment>
pub fn add_version( &mut self, version_key: String, source: VersionSource, ) -> PromiseOrValue<()>
pub fn add_version_01_finalize( &mut self, version_key: String, ) -> PromiseOrValue<()>
pub fn remove_version(&mut self, version_key: String)
pub fn deploy( &mut self, name: String, version_key: String, init_args: Base64VecU8, full_access_keys: Option<Vec<PublicKey>>, ) -> Promise
pub fn deploy_01_finalize( &mut self, market_id: AccountId, deployment: Deployment, ) -> PromiseOrValue<AccountId>
pub fn fail(&self, message: String)
Trait Implementations§
Source§impl BorshDeserialize for Contract
impl BorshDeserialize for Contract
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSchema for Contract
impl BorshSchema for Contract
Source§fn declaration() -> Declaration
fn declaration() -> Declaration
Source§fn add_definitions_recursively(
definitions: &mut BTreeMap<Declaration, Definition>,
)
fn add_definitions_recursively( definitions: &mut BTreeMap<Declaration, Definition>, )
Source§impl ContractState for Contract
impl ContractState for Contract
fn state_key() -> &'static [u8] ⓘ
fn state_exists() -> bool
fn state_read() -> Option<Self>where
Self: BorshDeserialize,
fn state_write(&self) -> boolwhere
Self: BorshSerialize,
Source§impl MigrateExternalInterface for Contract
impl MigrateExternalInterface for Contract
fn get_stored_state_version() -> u32
fn get_target_state_version() -> u32
fn needs_migration() -> bool
Source§impl OwnerExternal for Contract
impl OwnerExternal for Contract
Source§fn own_get_owner(&self) -> Option<AccountId>
fn own_get_owner(&self) -> Option<AccountId>
Source§fn own_get_proposed_owner(&self) -> Option<AccountId>
fn own_get_proposed_owner(&self) -> Option<AccountId>
Source§fn own_renounce_owner(&mut self)
fn own_renounce_owner(&mut self)
None. Read moreSource§fn own_propose_owner(&mut self, account_id: Option<AccountId>)
fn own_propose_owner(&mut self, account_id: Option<AccountId>)
Source§fn own_accept_owner(&mut self)
fn own_accept_owner(&mut self)
Source§impl OwnerInternal for Contract
impl OwnerInternal for Contract
§fn slot_is_initialized() -> Slot<bool>
fn slot_is_initialized() -> Slot<bool>
§fn slot_owner() -> Slot<AccountId>
fn slot_owner() -> Slot<AccountId>
§fn slot_proposed_owner() -> Slot<AccountId>
fn slot_proposed_owner() -> Slot<AccountId>
Auto Trait Implementations§
impl !Freeze for Contract
impl !RefUnwindSafe for Contract
impl Send for Contract
impl !Sync for Contract
impl Unpin for Contract
impl UnwindSafe for Contract
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Owner for Twhere
T: OwnerInternal,
impl<T> Owner for Twhere
T: OwnerInternal,
§fn update_owner(&mut self, new: Option<AccountId>)
fn update_owner(&mut self, new: Option<AccountId>)
§fn update_proposed(&mut self, new: Option<AccountId>)
fn update_proposed(&mut self, new: Option<AccountId>)
§fn update_owner_unchecked(&mut self, new: Option<AccountId>)
fn update_owner_unchecked(&mut self, new: Option<AccountId>)
§fn update_proposed_unchecked(&mut self, new: Option<AccountId>)
fn update_proposed_unchecked(&mut self, new: Option<AccountId>)
§fn assert_owner(&self)
fn assert_owner(&self)
require_owner but as a method.§fn init(&mut self, owner_id: &AccountId)
fn init(&mut self, owner_id: &AccountId)
§fn require_owner()
fn require_owner()
§fn renounce_owner(&mut self)
fn renounce_owner(&mut self)
§fn propose_owner(&mut self, account_id: Option<AccountId>)
fn propose_owner(&mut self, account_id: Option<AccountId>)
§fn accept_owner(&mut self)
fn accept_owner(&mut self)
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn propagate_header(self, header: HeaderName) -> PropagateHeader<Self>where
Self: Sized,
fn propagate_header(self, header: HeaderName) -> PropagateHeader<Self>where
Self: Sized,
§fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
§fn map_request_body<F>(self, f: F) -> MapRequestBody<Self, F>where
Self: Sized,
fn map_request_body<F>(self, f: F) -> MapRequestBody<Self, F>where
Self: Sized,
§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
§fn compression(self) -> Compression<Self>where
Self: Sized,
fn compression(self) -> Compression<Self>where
Self: Sized,
§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
§fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
§fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
§fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
§fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
x-request-id as the header name. Read more§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
x-request-id as the header name. Read more§fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
500 Internal Server responses. Read more§fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
413 Payload Too Large responses. Read more§fn trim_trailing_slash(self) -> NormalizePath<Self>where
Self: Sized,
fn trim_trailing_slash(self) -> NormalizePath<Self>where
Self: Sized,
§fn append_trailing_slash(self) -> NormalizePath<Self>where
Self: Sized,
fn append_trailing_slash(self) -> NormalizePath<Self>where
Self: Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.