From c6d7ea529c804cd1d8ad553e24505655ba4eca50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Bizjak?= Date: Mon, 22 Jan 2024 13:49:31 +0100 Subject: [PATCH] Fix doc link. --- contract-testing/src/impls.rs | 76 ++++++++++++------------ contract-testing/src/invocation/impls.rs | 40 +++++++------ contract-testing/src/invocation/types.rs | 27 +++++---- contract-testing/src/lib.rs | 33 +++++----- contract-testing/src/types.rs | 46 +++++++------- 5 files changed, 119 insertions(+), 103 deletions(-) diff --git a/contract-testing/src/impls.rs b/contract-testing/src/impls.rs index 0c8bf054..470a34bb 100644 --- a/contract-testing/src/impls.rs +++ b/contract-testing/src/impls.rs @@ -4,28 +4,31 @@ use crate::{ types::*, }; use anyhow::anyhow; -use concordium_rust_sdk::base::{ - base::{AccountThreshold, Energy, InsufficientEnergy}, - constants::MAX_WASM_MODULE_SIZE, - contracts_common::{ - self, AccountAddress, AccountBalance, Address, Amount, ChainMetadata, ContractAddress, - Deserial, Duration, ExchangeRate, ExchangeRates, ModuleReference, OwnedPolicy, ParseResult, - SlotTime, Timestamp, +use concordium_rust_sdk::{ + self as sdk, base, + base::{ + base::{AccountThreshold, Energy, InsufficientEnergy}, + constants::MAX_WASM_MODULE_SIZE, + contracts_common::{ + self, AccountAddress, AccountBalance, Address, Amount, ChainMetadata, ContractAddress, + Deserial, Duration, ExchangeRate, ExchangeRates, ModuleReference, OwnedPolicy, + ParseResult, SlotTime, Timestamp, + }, + hashes::BlockHash, + smart_contracts::{ContractEvent, ModuleSource, WasmModule, WasmVersion}, + transactions::{ + self, cost, AccountAccessStructure, InitContractPayload, UpdateContractPayload, + }, }, - hashes::BlockHash, - smart_contracts::{ContractEvent, ModuleSource, WasmModule, WasmVersion}, - transactions::{ - self, cost, AccountAccessStructure, InitContractPayload, UpdateContractPayload, + smart_contracts::engine::{ + v0, + v1::{self, DebugTracker, InvalidReturnCodeError, InvokeResponse}, + wasm, + wasm::validate::ValidationConfig, + DebugInfo, InterpreterEnergy, }, + v2::Endpoint, }; -use concordium_rust_sdk::{self as sdk, base, v2::Endpoint}; -use concordium_rust_sdk::smart_contracts::engine::{ - wasm, - v0, - v1::{self, DebugTracker, InvalidReturnCodeError, InvokeResponse}, - DebugInfo, InterpreterEnergy, -}; -use concordium_rust_sdk::smart_contracts::engine::wasm::validate::ValidationConfig; use num_bigint::BigUint; use num_integer::Integer; use sdk::types::smart_contracts::InvokeContractResult; @@ -579,24 +582,23 @@ impl Chain { sender_account.balance.total -= transaction_fee; // Construct the artifact. - let artifact = - match wasm::utils::instantiate_with_metering::( - ValidationConfig::V1, - &v1::ConcordiumAllowedImports { - support_upgrade: true, - enable_debug, - }, - wasm_module.source.as_ref(), - ) { - Ok(artifact) => artifact, - Err(err) => { - return Err(ModuleDeployError { - kind: ModuleInvalidError(err).into(), - energy_used, - transaction_fee, - }) - } - }; + let artifact = match wasm::utils::instantiate_with_metering::( + ValidationConfig::V1, + &v1::ConcordiumAllowedImports { + support_upgrade: true, + enable_debug, + }, + wasm_module.source.as_ref(), + ) { + Ok(artifact) => artifact, + Err(err) => { + return Err(ModuleDeployError { + kind: ModuleInvalidError(err).into(), + energy_used, + transaction_fee, + }) + } + }; let module_reference: ModuleReference = wasm_module.get_module_ref(); diff --git a/contract-testing/src/invocation/impls.rs b/contract-testing/src/invocation/impls.rs index bed0336e..72ff7ad5 100644 --- a/contract-testing/src/invocation/impls.rs +++ b/contract-testing/src/invocation/impls.rs @@ -8,25 +8,28 @@ use crate::{ types::{Account, BalanceError, Contract, ContractModule, TransferError}, AccountSignatures, DebugTraceElement, ExecutionError, InvokeExecutionError, }; -use concordium_rust_sdk::base::{ - self, - base::{AccountAddressEq, Energy, InsufficientEnergy}, - common, - contracts_common::{ - to_bytes, AccountAddress, AccountBalance, Address, Amount, ChainMetadata, ContractAddress, - ExchangeRates, ModuleReference, OwnedEntrypointName, OwnedReceiveName, +use concordium_rust_sdk::{ + base::{ + self, + base::{AccountAddressEq, Energy, InsufficientEnergy}, + common, + contracts_common::{ + to_bytes, AccountAddress, AccountBalance, Address, Amount, ChainMetadata, + ContractAddress, ExchangeRates, ModuleReference, OwnedEntrypointName, OwnedReceiveName, + }, + smart_contracts::{ + ContractTraceElement, InstanceUpdatedEvent, OwnedContractName, OwnedParameter, + WasmVersion, + }, + transactions::{verify_data_signature, AccountAccessStructure, UpdateContractPayload}, }, - smart_contracts::{ - ContractTraceElement, InstanceUpdatedEvent, OwnedContractName, OwnedParameter, WasmVersion, + smart_contracts::engine::{ + v0, + v1::{self, trie, DebugTracker, InvokeResponse}, + wasm::artifact::{self, CompiledFunction}, + DebugInfo, InterpreterEnergy, }, - transactions::{verify_data_signature, AccountAccessStructure, UpdateContractPayload}, }; -use concordium_rust_sdk::smart_contracts::engine::{ - v0, - v1::{self, trie, DebugTracker, InvokeResponse}, - DebugInfo, InterpreterEnergy, -}; -use concordium_rust_sdk::smart_contracts::engine::wasm::artifact::{self, CompiledFunction}; use std::collections::{btree_map, BTreeMap}; // Exit early with an out of energy error. @@ -522,9 +525,8 @@ impl<'a, 'b> EntrypointInvocationHandler<'a, 'b> { ); exit_ooe!( - self.remaining_energy.tick_energy( - base::transactions::cost::SIMPLE_TRANSFER - ), + self.remaining_energy + .tick_energy(base::transactions::cost::SIMPLE_TRANSFER), DebugTracker::empty_trace() ); diff --git a/contract-testing/src/invocation/types.rs b/contract-testing/src/invocation/types.rs index 4030fc60..1470d5c1 100644 --- a/contract-testing/src/invocation/types.rs +++ b/contract-testing/src/invocation/types.rs @@ -1,17 +1,22 @@ use crate::Chain; -use concordium_rust_sdk::base::{ - base::{AccountAddressEq, Energy}, - contracts_common::{ - AccountAddress, Address, Amount, ContractAddress, ModuleReference, OwnedContractName, - OwnedEntrypointName, +use concordium_rust_sdk::{ + base::{ + base::{AccountAddressEq, Energy}, + contracts_common::{ + AccountAddress, Address, Amount, ContractAddress, ModuleReference, OwnedContractName, + OwnedEntrypointName, + }, + smart_contracts::OwnedParameter, + transactions::UpdateContractPayload, + }, + smart_contracts::engine::{ + v1::{ + trie::MutableState, DebugTracker, InvokeResponse, ReceiveContext, + ReceiveInterruptedState, + }, + wasm::artifact::CompiledFunction, }, - smart_contracts::OwnedParameter, - transactions::UpdateContractPayload, -}; -use concordium_rust_sdk::smart_contracts::engine::v1::{ - trie::MutableState, DebugTracker, InvokeResponse, ReceiveContext, ReceiveInterruptedState, }; -use concordium_rust_sdk::smart_contracts::engine::wasm::artifact::CompiledFunction; use std::collections::BTreeMap; /// A type that supports invoking a contract entrypoint. diff --git a/contract-testing/src/lib.rs b/contract-testing/src/lib.rs index 77577988..05bb636a 100644 --- a/contract-testing/src/lib.rs +++ b/contract-testing/src/lib.rs @@ -93,20 +93,23 @@ pub use impls::{is_debug_enabled, module_load_v1, module_load_v1_raw}; pub use types::*; // Re-export types. -pub use concordium_rust_sdk::base::{ - base::Energy, - common::types::{CredentialIndex, KeyIndex}, - contracts_common::{ - from_bytes, to_bytes, AccountAddress, AccountBalance, AccountThreshold, Address, Amount, - ContractAddress, ContractName, Duration, EntrypointName, ExchangeRate, ModuleReference, - OwnedContractName, OwnedEntrypointName, OwnedParameter, OwnedReceiveName, Parameter, - ReceiveName, SignatureThreshold, SlotTime, Timestamp, +pub use concordium_rust_sdk::{ + base::{ + base::Energy, + common::types::{CredentialIndex, KeyIndex}, + contracts_common::{ + from_bytes, to_bytes, AccountAddress, AccountBalance, AccountThreshold, Address, + Amount, ContractAddress, ContractName, Duration, EntrypointName, ExchangeRate, + ModuleReference, OwnedContractName, OwnedEntrypointName, OwnedParameter, + OwnedReceiveName, Parameter, ReceiveName, SignatureThreshold, SlotTime, Timestamp, + }, + ed25519, + hashes::BlockHash, + id::types::{AccountKeys, CredentialPublicKeys, VerifyKey}, + smart_contracts::{ContractEvent, ContractTraceElement, InstanceUpdatedEvent, WasmVersion}, + transactions::{AccountAccessStructure, InitContractPayload, UpdateContractPayload}, }, - ed25519, - hashes::BlockHash, - id::types::{AccountKeys, CredentialPublicKeys, VerifyKey}, - smart_contracts::{ContractEvent, ContractTraceElement, InstanceUpdatedEvent, WasmVersion}, - transactions::{AccountAccessStructure, InitContractPayload, UpdateContractPayload}, + smart_contracts::engine::v1::InvokeFailure, + types::RejectReason, + v2::Endpoint, }; -pub use concordium_rust_sdk::{types::RejectReason, v2::Endpoint}; -pub use concordium_rust_sdk::smart_contracts::engine::v1::InvokeFailure; diff --git a/contract-testing/src/types.rs b/contract-testing/src/types.rs index b6db0015..55223508 100644 --- a/contract-testing/src/types.rs +++ b/contract-testing/src/types.rs @@ -1,26 +1,30 @@ -use concordium_rust_sdk::base::{ - base::{AccountAddressEq, Energy}, - common::types::{CredentialIndex, KeyIndex, Signature}, - constants::ED25519_SIGNATURE_LENGTH, - contracts_common::{ - self, AccountAddress, AccountBalance, Address, Amount, ContractAddress, Deserial, - EntrypointName, ExchangeRate, ModuleReference, OwnedContractName, OwnedEntrypointName, - OwnedPolicy, ParseResult, SlotTime, Timestamp, +use concordium_rust_sdk as sdk; +use concordium_rust_sdk::{ + base::{ + base::{AccountAddressEq, Energy}, + common::types::{CredentialIndex, KeyIndex, Signature}, + constants::ED25519_SIGNATURE_LENGTH, + contracts_common::{ + self, AccountAddress, AccountBalance, Address, Amount, ContractAddress, Deserial, + EntrypointName, ExchangeRate, ModuleReference, OwnedContractName, OwnedEntrypointName, + OwnedPolicy, ParseResult, SlotTime, Timestamp, + }, + hashes::BlockHash, + id::types::SchemeId, + smart_contracts::{ + ContractEvent, ContractTraceElement, InstanceUpdatedEvent, OwnedParameter, + OwnedReceiveName, WasmVersion, + }, + transactions::AccountAccessStructure, }, - hashes::BlockHash, - id::types::SchemeId, - smart_contracts::{ - ContractEvent, ContractTraceElement, InstanceUpdatedEvent, OwnedParameter, - OwnedReceiveName, WasmVersion, + smart_contracts::engine::{ + v1::{ + self, trie, DebugTracker, EmittedDebugStatement, HostCall, HostFunctionV1, ReturnValue, + }, + wasm::artifact, + InterpreterEnergy, }, - transactions::AccountAccessStructure, -}; -use concordium_rust_sdk as sdk; -use concordium_rust_sdk::smart_contracts::engine::{ - v1::{self, trie, DebugTracker, EmittedDebugStatement, HostCall, HostFunctionV1, ReturnValue}, - InterpreterEnergy, }; -use concordium_rust_sdk::smart_contracts::engine::wasm::artifact; use std::{ collections::{BTreeMap, BTreeSet}, path::PathBuf, @@ -1300,7 +1304,7 @@ impl ExternalAddress { /// Data needed to invoke an external smart contract instance. /// /// This is nearly identical to -/// [`UpdateContractPayload`](concordium_base::transactions::UpdateContractPayload) +/// [`UpdateContractPayload`](concordium_rust_sdk::base::transactions::UpdateContractPayload) /// except that it uses an [`ExternalContractAddress`] instead of an /// [`ContractAddress`]. #[derive(Debug, Clone)]