Ver Fonte

Fix flipper.sol example (#1206)

Signed-off-by: Lucas Steuernagel <lucas.tnagel@gmail.com>
Lucas Steuernagel há 2 anos atrás
pai
commit
91da9f3ae3
6 ficheiros alterados com 15 adições e 35 exclusões
  1. 7 27
      README.md
  2. 1 1
      docs/examples.rst
  3. 1 1
      docs/language/contracts.rst
  4. 1 1
      docs/targets/solana.rst
  5. 0 0
      examples/substrate/flipper.sol
  6. 5 5
      tests/cli.rs

+ 7 - 27
README.md

@@ -27,34 +27,14 @@ brew install hyperledger/solang/solang
 
 For other operating systems, please check the [installation guide](https://solang.readthedocs.io/en/latest/installing.html).
 
-## Simple example
+## Simple examples
 
-After installing the compiler, write the following to flipper.sol:
+### Build for Solana
 
-```solidity
-contract flipper {
-	bool private value;
-
-	constructor(bool initvalue) public {
-		value = initvalue;
-	}
-
-	function flip() public {
-		value = !value;
-	}
-
-	function get() public view returns (bool) {
-		return value;
-	}
-}
-```
-
-## Build for Solana
-
-Run:
+Run the following command, selecting the flipper example available in Solang's repository:
 
 ```bash
-solang compile --target solana flipper.sol
+solang compile --target solana examples/solana/flipper.sol
 ```
 
 Alternatively if you want to use the solang container, run:
@@ -129,12 +109,12 @@ export ANCHOR_PROVIDER_URL=http://127.0.0.1:8899
 node flipper.js
 ```
 
-## Build for Substrate
+### Build for Substrate
 
-Run:
+Run the following command, selecting the flipper example available on Solang's repository:
 
 ```bash
-solang compile --target substrate flipper.sol
+solang compile --target substrate examples/substrate/flipper.sol
 ```
 
 Alternatively if you want to use the solang container, run:

+ 1 - 1
docs/examples.rst

@@ -13,7 +13,7 @@ _______
 This is the `ink! flipper example <https://github.com/paritytech/ink/blob/v3.3.0/examples/flipper/lib.rs>`_
 written in Solidity:
 
-.. include:: ../examples/flipper.sol
+.. include:: ../examples/substrate/flipper.sol
   :code: solidity
 
 Example

+ 1 - 1
docs/language/contracts.rst

@@ -8,7 +8,7 @@ When a contract is deployed, the contract storage is initialized to the initiali
 and any constructor is called. A constructor is not required for a contract. A constructor is defined
 like so:
 
-.. include:: ../../examples/flipper.sol
+.. include:: ../../examples/substrate/flipper.sol
   :code: solidity
 
 A constructor can have any number of arguments.

+ 1 - 1
docs/targets/solana.rst

@@ -176,7 +176,7 @@ arguments. The ``@space`` should at least be the size given when you run ``solan
 
 .. code-block:: bash
 
-    $ solang compile --target solana -v examples/flipper.sol
+    $ solang compile --target solana -v examples/solana/flipper.sol
     ...
     info: contract flipper uses at least 17 bytes account data
     ...

+ 0 - 0
examples/flipper.sol → examples/substrate/flipper.sol


+ 5 - 5
tests/cli.rs

@@ -14,7 +14,7 @@ fn create_output_dir() {
 
     cmd.args([
         "compile",
-        "examples/flipper.sol",
+        "examples/solana/flipper.sol",
         "--target",
         "solana",
         "--output",
@@ -33,7 +33,7 @@ fn create_output_dir() {
 
     cmd.args([
         "compile",
-        "examples/flipper.sol",
+        "examples/solana/flipper.sol",
         "--target",
         "solana",
         "--contract",
@@ -53,11 +53,11 @@ fn create_output_dir() {
 
     cmd.args([
         "compile",
-        "examples/flipper.sol",
+        "examples/solana/flipper.sol",
         "--target",
         "solana",
         "--output",
-        "examples/flipper.sol",
+        "examples/solana/flipper.sol",
     ])
     .assert()
     .failure();
@@ -68,7 +68,7 @@ fn create_output_dir() {
 
     cmd.args([
         "compile",
-        "examples/flipper.sol",
+        "examples/solana/flipper.sol",
         "--target",
         "solana",
         "--contract",