Просмотр исходного кода

doc: fix missing code samples in smart_contracts.md

x 3 лет назад
Родитель
Сommit
00458ccd48
2 измененных файлов с 12 добавлено и 5 удалено
  1. 7 0
      bin/dao/daod/src/util.rs
  2. 5 5
      doc/src/architecture/smart_contracts.md

+ 7 - 0
bin/dao/daod/src/util.rs

@@ -121,10 +121,13 @@ impl ZkContractTable {
     }
     }
 }
 }
 
 
+// ANCHOR: transaction
 pub struct Transaction {
 pub struct Transaction {
     pub func_calls: Vec<FuncCall>,
     pub func_calls: Vec<FuncCall>,
+    // TODO: MUST be Vec<Vec<Signature>>, this is wrong
     pub signatures: Vec<Signature>,
     pub signatures: Vec<Signature>,
 }
 }
+// ANCHOR_END: transaction
 
 
 impl Transaction {
 impl Transaction {
     /// Verify ZK contracts for the entire tx
     /// Verify ZK contracts for the entire tx
@@ -200,12 +203,14 @@ pub fn sign(signature_secrets: Vec<SecretKey>, func_calls: &Vec<FuncCall>) -> Ve
 type ContractId = pallas::Base;
 type ContractId = pallas::Base;
 type FuncId = pallas::Base;
 type FuncId = pallas::Base;
 
 
+// ANCHOR: funccall
 pub struct FuncCall {
 pub struct FuncCall {
     pub contract_id: ContractId,
     pub contract_id: ContractId,
     pub func_id: FuncId,
     pub func_id: FuncId,
     pub call_data: Box<dyn CallDataBase + Send + Sync>,
     pub call_data: Box<dyn CallDataBase + Send + Sync>,
     pub proofs: Vec<Proof>,
     pub proofs: Vec<Proof>,
 }
 }
+// ANCHOR_END: funccall
 
 
 impl Encodable for FuncCall {
 impl Encodable for FuncCall {
     fn encode<W: std::io::Write>(&self, mut w: W) -> std::result::Result<usize, std::io::Error> {
     fn encode<W: std::io::Write>(&self, mut w: W) -> std::result::Result<usize, std::io::Error> {
@@ -218,6 +223,7 @@ impl Encodable for FuncCall {
     }
     }
 }
 }
 
 
+// ANCHOR: calldatabase_trait
 pub trait CallDataBase {
 pub trait CallDataBase {
     // Public values for verifying the proofs
     // Public values for verifying the proofs
     // Needed so we can convert internal types so they can be used in Proof::verify()
     // Needed so we can convert internal types so they can be used in Proof::verify()
@@ -234,6 +240,7 @@ pub trait CallDataBase {
         writer: &mut dyn std::io::Write,
         writer: &mut dyn std::io::Write,
     ) -> std::result::Result<usize, std::io::Error>;
     ) -> std::result::Result<usize, std::io::Error>;
 }
 }
+// ANCHOR_END: calldatabase_trait
 
 
 type GenericContractState = Box<dyn Any + Send>;
 type GenericContractState = Box<dyn Any + Send>;
 
 

+ 5 - 5
doc/src/architecture/smart_contracts.md

@@ -89,13 +89,13 @@ the entire tx is rejected. Additionally some smart contracts might impose additi
 on the transaction's structure or other function calls (such as their call data).
 on the transaction's structure or other function calls (such as their call data).
 
 
 ```rust
 ```rust
-{{#include ../../../bin/daod/src/demo.rs:transaction}}
+{{#include ../../../bin/dao/daod/src/util.rs:transaction}}
 ```
 ```
 
 
 Function calls represent mutations of the current active state to a new state.
 Function calls represent mutations of the current active state to a new state.
 
 
 ```rust
 ```rust
-{{#include ../../../bin/daod/src/demo.rs:funccall}}
+{{#include ../../../bin/dao/daod/src/util.rs:funccall}}
 ```
 ```
 
 
 The `contract_id` corresponds to the top level module for the contract which
 The `contract_id` corresponds to the top level module for the contract which
@@ -183,13 +183,13 @@ The transaction verification pipeline roughly looks like this:
 Lets review again the format of transactions.
 Lets review again the format of transactions.
 
 
 ```rust
 ```rust
-{{#include ../../../bin/daod/src/demo.rs:transaction}}
+{{#include ../../../bin/dao/daod/src/util.rs:transaction}}
 ```
 ```
 
 
 And corresponding function calls.
 And corresponding function calls.
 
 
 ```rust
 ```rust
-{{#include ../../../bin/daod/src/demo.rs:funccall}}
+{{#include ../../../bin/dao/daod/src/util.rs:funccall}}
 ```
 ```
 
 
 As we can see the ZK proofs and signatures are separate from the actuall `call_data` interpreted
 As we can see the ZK proofs and signatures are separate from the actuall `call_data` interpreted
@@ -200,7 +200,7 @@ the signatures need the public keys. We do this in the `CallDataBase` trait by e
 methods:
 methods:
 
 
 ```rust
 ```rust
-{{#include ../../../bin/daod/src/demo.rs:calldatabase_trait}}
+{{#include ../../../bin/dao/daod/src/util.rs:calldatabase_trait}}
 ```
 ```
 
 
 These methods export the required values needed for the ZK proofs and signature verification
 These methods export the required values needed for the ZK proofs and signature verification