Skip to content

Commit

Permalink
Merge pull request #772 from anistark/doc/rust-wasm-dir
Browse files Browse the repository at this point in the history
renamed all contracts/rust to new dir contracts/wasm
  • Loading branch information
fijter authored Feb 2, 2022
2 parents 9c9c08b + f1ffe01 commit cc7a412
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions contracts/wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ Prerequisites:
[downloaded here](https://rustwasm.github.io/wasm-pack/).

Building a Rust smart contract is very simple when using the Rust plugin in any
IntelliJ based development environment. Open the _contracts/rust_ sub folder in
IntelliJ based development environment. Open the _contracts/wasm_ sub folder in
your IntelliJ, which then provides you with the Rust workspace.

The easiest way to create a new contract is to copy the _helloworld_ folder to a
properly named new folder within the _rust_ sub folder. Next, change the fields
in the first section of the new folder's _cargo.toml_ file to match your
preferences. Make sure the package name equals the folder name. Finally, add the
new folder to the workspace in the _cargo.toml_ in the _contracts/rust_ folder.
new folder to the workspace in the _cargo.toml_ in the _contracts/wasm_ folder.

To build the new smart contract select _Run->Edit Configurations_. Add a new
configuration based on the _wasmpack_ template, type the _name_ of the new
Expand Down
2 changes: 1 addition & 1 deletion documentation/docs/guide/core_concepts/consensus.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The anchor transaction contains chain state transition, the AliasOutput and toke

**It is only possible to produce valid signatures of inputs of the anchor transaction by the quorum** of nodes. In this case, a confirmed anchor transaction becomes a cryptographical **proof of consensus** in the committee.

To archive this, IOTA Smart Contracts uses **BLS threshold signatures in combination with polynomial (Shamir) secret sharing** to identify the address controlling the chain state. In order for the secret keys to be distributed across the chain validators, a DKG (Distributed Key Generation) procedure is executed when starting a chain (using the Rabin-Gennaro algorithm).
To achieve this, IOTA Smart Contracts uses **BLS threshold signatures in combination with polynomial (Shamir) secret sharing** to identify the address controlling the chain state. In order for the secret keys to be distributed across the chain validators, a DKG (Distributed Key Generation) procedure is executed when starting a chain (using the Rabin-Gennaro algorithm).

## The Consensus Algorithm

Expand Down
10 changes: 5 additions & 5 deletions documentation/docs/guide/example_projects/fair_roulette.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Off-ledger requests are directly sent to Wasp nodes and do not require validatio
:::note
This example uses On-ledger requests to initiate a betting request. A method to invoke Off-ledger requests is implemented inside the frontend.

See: [placeBetOffLedger](https://github.com/iotaledger/wasp/blob/7b3ddc54891ccf021c7aaa32db35d88361fade16/contracts/rust/fairroulette/frontend/src/lib/fairroulette_client/fair_roulette_service.ts#L133)
See: [placeBetOffLedger](https://github.com/iotaledger/wasp/blob/7b3ddc54891ccf021c7aaa32db35d88361fade16/contracts/wasm/fairroulette/frontend/src/lib/fairroulette_client/fair_roulette_service.ts#L133)
:::

#### Funds
Expand Down Expand Up @@ -217,7 +217,7 @@ This service comprises two parts:

##### PlaceBetOnLedger

The [placeBetOnLedger](https://github.com/iotaledger/wasp/blob/7b3ddc54891ccf021c7aaa32db35d88361fade16/contracts/rust/fairroulette/frontend/src/lib/fairroulette_client/fair_roulette_service.ts#L149) function is responsible for sending On-Ledger bet requests. It constructs a simple OnLedger object containing:
The [placeBetOnLedger](https://github.com/iotaledger/wasp/blob/7b3ddc54891ccf021c7aaa32db35d88361fade16/contracts/wasm/fairroulette/frontend/src/lib/fairroulette_client/fair_roulette_service.ts#L149) function is responsible for sending On-Ledger bet requests. It constructs a simple OnLedger object containing:

* The smart contract ID: `fairroulette`
* The function to invoke: `placeBet`
Expand All @@ -235,7 +235,7 @@ See: [CoreTypes](https://wiki.iota.org/wasp/misc/coretypes) and [Invoking](https

##### CallView

The [callView](https://github.com/iotaledger/wasp/blob/7b3ddc54891ccf021c7aaa32db35d88361fade16/contracts/rust/fairroulette/frontend/src/lib/fairroulette_client/fair_roulette_service.ts#L165) function is responsible for calling smart contract view functions.
The [callView](https://github.com/iotaledger/wasp/blob/7b3ddc54891ccf021c7aaa32db35d88361fade16/contracts/wasm/fairroulette/frontend/src/lib/fairroulette_client/fair_roulette_service.ts#L165) function is responsible for calling smart contract view functions.

See: [Calling a view](https://wiki.iota.org/wasp/guide/solo/view-sc)

Expand All @@ -246,9 +246,9 @@ State changes that happen afterwards are published through the websocket event s

You can find examples to guide you in building similar functions in:

* Frontend: [getRoundStatus](https://github.com/iotaledger/wasp/blob/7b3ddc54891ccf021c7aaa32db35d88361fade16/contracts/rust/fairroulette/frontend/src/lib/fairroulette_client/fair_roulette_service.ts#L181)
* Frontend: [getRoundStatus](https://github.com/iotaledger/wasp/blob/7b3ddc54891ccf021c7aaa32db35d88361fade16/contracts/wasm/fairroulette/frontend/src/lib/fairroulette_client/fair_roulette_service.ts#L181)

* Smart Contract: [view_round_status](https://github.com/iotaledger/wasp/blob/7b3ddc54891ccf021c7aaa32db35d88361fade16/contracts/rust/fairroulette/src/fairroulette.rs#L312)
* Smart Contract: [view_round_status](https://github.com/iotaledger/wasp/blob/7b3ddc54891ccf021c7aaa32db35d88361fade16/contracts/wasm/fairroulette/src/fairroulette.rs#L312)

Since data returned by the views is encoded in Base64, the frontend needs to decode this by using simple `Buffer` methods.
The `view_round_status` view returns an `UInt16` which has a state of either `0` or `1`.
Expand Down
2 changes: 1 addition & 1 deletion documentation/temp/misc/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ environment with the Rust plugin is a good combination.

You can find example implementations of smart contracts (including source code
and tests) in the Wasp repository, in the
[contracts/rust folder](https://github.com/iotaledger/wasp/tree/master/contracts/rust).
[contracts/wasm folder](https://github.com/iotaledger/wasp/tree/master/contracts/wasm).

0 comments on commit cc7a412

Please sign in to comment.