Skip to content

Commit

Permalink
Fix doc link.
Browse files Browse the repository at this point in the history
  • Loading branch information
abizjak committed Jan 22, 2024
1 parent 0a55bd8 commit c6d7ea5
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 103 deletions.
76 changes: 39 additions & 37 deletions contract-testing/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -579,24 +582,23 @@ impl Chain {
sender_account.balance.total -= transaction_fee;

// Construct the artifact.
let artifact =
match wasm::utils::instantiate_with_metering::<v1::ProcessedImports, _>(
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::<v1::ProcessedImports, _>(
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();

Expand Down
40 changes: 21 additions & 19 deletions contract-testing/src/invocation/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
);

Expand Down
27 changes: 16 additions & 11 deletions contract-testing/src/invocation/types.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
33 changes: 18 additions & 15 deletions contract-testing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
46 changes: 25 additions & 21 deletions contract-testing/src/types.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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)]
Expand Down

0 comments on commit c6d7ea5

Please sign in to comment.