Преглед на файлове

validator: Move DeployParamsV1 to darkfi-sdk

parazyd преди 2 години
родител
ревизия
fecab39d77

+ 1 - 2
src/contract/deployooor/src/client/deploy_v1.rs

@@ -21,11 +21,10 @@ use darkfi::{
     zkas::ZkBinary,
     Result,
 };
-use darkfi_sdk::crypto::Keypair;
+use darkfi_sdk::{crypto::Keypair, deploy::DeployParamsV1};
 use log::{debug, info};
 
 use super::create_derive_contractid_proof;
-use crate::model::DeployParamsV1;
 
 pub struct DeployCallDebris {
     pub params: DeployParamsV1,

+ 3 - 3
src/contract/deployooor/src/entrypoint/deploy_v1.rs

@@ -19,6 +19,7 @@
 use darkfi_sdk::{
     crypto::{ContractId, PublicKey},
     db::{db_get, db_lookup, db_set},
+    deploy::DeployParamsV1,
     error::{ContractError, ContractResult},
     msg,
     pasta::pallas,
@@ -31,9 +32,8 @@ use wasmparser::{
 };
 
 use crate::{
-    error::DeployError,
-    model::{DeployParamsV1, DeployUpdateV1},
-    DeployFunction, DEPLOY_CONTRACT_LOCK_TREE, DEPLOY_CONTRACT_ZKAS_DERIVE_NS_V1,
+    error::DeployError, model::DeployUpdateV1, DeployFunction, DEPLOY_CONTRACT_LOCK_TREE,
+    DEPLOY_CONTRACT_ZKAS_DERIVE_NS_V1,
 };
 
 /// `get_metadata` function for `Deploy::DeployV1`

+ 0 - 11
src/contract/deployooor/src/model.rs

@@ -22,17 +22,6 @@ use darkfi_serial::async_trait;
 use darkfi_sdk::crypto::{ContractId, PublicKey};
 use darkfi_serial::{SerialDecodable, SerialEncodable};
 
-/// Parameters for `Deploy::Deploy`
-#[derive(Clone, Debug, SerialEncodable, SerialDecodable)]
-pub struct DeployParamsV1 {
-    /// Webassembly bincode of the smart contract
-    pub wasm_bincode: Vec<u8>,
-    /// Public key used to sign the transaction and derive the `ContractId`
-    pub public_key: PublicKey,
-    /// Serialized deployment payload instruction
-    pub ix: Vec<u8>,
-}
-
 /// State update for `Deploy::Deploy`
 #[derive(Clone, Debug, SerialEncodable, SerialDecodable)]
 pub struct DeployUpdateV1 {

+ 5 - 4
src/validator/deploy.rs → src/sdk/src/deploy.rs

@@ -16,12 +16,13 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-use darkfi_sdk::crypto::PublicKey;
-use darkfi_serial::{async_trait, SerialDecodable, SerialEncodable};
+#[cfg(feature = "async")]
+use darkfi_serial::async_trait;
+use darkfi_serial::{SerialDecodable, SerialEncodable};
+
+use crate::crypto::PublicKey;
 
 /// Parameters for `Deploy::Deploy`
-///
-/// This is copied from `src/contract/deployooor.rs`
 #[derive(Clone, Debug, SerialEncodable, SerialDecodable)]
 pub struct DeployParamsV1 {
     /// Webassembly bincode of the smart contract

+ 3 - 0
src/sdk/src/lib.rs

@@ -27,6 +27,9 @@ pub mod blockchain;
 /// Database functions
 pub mod db;
 
+/// Contract deployment utilities
+pub mod deploy;
+
 /// Entrypoint used for the wasm binaries
 pub mod entrypoint;
 

+ 0 - 3
src/validator/mod.rs

@@ -63,9 +63,6 @@ pub mod validation;
 pub mod utils;
 use utils::deploy_native_contracts;
 
-/// Contract deployment utilities
-pub mod deploy;
-
 /// Base 10 big float implementation for high precision arithmetics
 pub mod float_10;
 

+ 1 - 1
src/validator/verification.rs

@@ -25,6 +25,7 @@ use darkfi_sdk::{
         DEPLOYOOOR_CONTRACT_ID, MONEY_CONTRACT_ID,
     },
     dark_tree::dark_forest_leaf_vec_integrity_check,
+    deploy::DeployParamsV1,
     pasta::pallas,
 };
 use darkfi_serial::{deserialize_async, AsyncDecodable, AsyncEncodable, AsyncWriteExt, WriteExt};
@@ -39,7 +40,6 @@ use crate::{
     util::time::TimeKeeper,
     validator::{
         consensus::{Consensus, Fork, Proposal, TXS_CAP},
-        deploy::DeployParamsV1,
         pow::PoWModule,
         validation::validate_block,
     },