Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DOBEN committed Jan 29, 2024
1 parent f70585d commit 30aa561
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The following examples are available.
interactions of a store that sells restricted items, and supports payment in
EUROe tokens (or generally any CIS2 token).

- [track-and-trace](./track-and-trace/) demonstrates an example frontend, backend, and event indexer to track items along the supply chain.
- [track-and-trace](./track-and-trace/) demonstrates an example frontend, backend, smart contract and event indexer to track items along the supply chain.

## Setup

Expand Down
22 changes: 9 additions & 13 deletions trackAndTrace/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ This package contains a test script to facilitate filling the track and trace co

There are a few options to configure the script:

- `--node` is the endpoint to the Concordium node grpc v2 API.
- `--node` is the endpoint to the Concordium node grpc v2 API. If not specified the default value `https://grpc.testnet.concordium.com:20000` is used.

- `--module` must point to a compiled track-and-trace smart contract module with the name `track_and_trace.wasm.v1`.
This module will be used to create a new instance of the track-and-trace smart contract and fill it with data.
- `--module` should point to a compiled track-and-trace smart contract module with e.g. the name `module.wasm.v1`. If not specified the default value `../smart-contract/concordium-out/module.wasm.v1` is used. The given module will be used to create a new instance of the track-and-trace smart contract and fill it with data.

You can generate the `track-and-trace.wasm.v1` file as follows:
- Navigate into the folder `https://github.com/Concordium/concordium-rust-smart-contracts/tree/main/examples/track-and-trace`.
- Compile the track-and-trace contract: `cargo concordium build -e -o ./concordium-out/track_and_trace.wasm.v1`.
- You can find the file `track_and_trace.wasm.v1` in `./concordium-out/track_and_trace.wasm.v1`.
You can generate the `module.wasm.v1` file as follows:
- Navigate into the folder `../smart-contract`.
- Compile the track-and-trace contract: `cargo concordium build -e -o ./concordium-out/module.wasm.v1`.
- You can find the file `module.wasm.v1` in `./concordium-out/module.wasm.v1`.

- `--admin-key-file` **directory** with one key in the
browser wallet export format. This key is used for all transactions executed by the script.

- `--num-items` optional value to specify the number of items to be created in the track-and-trace smart contract. The default value is 1. The states of these items will be updated from 'Produced' -> 'InTransit' -> 'InStore' -> 'Sold'.
- `--num-items` is the number of items to be created in the track-and-trace smart contract. The states of these items will be updated from 'Produced' -> 'InTransit' -> 'InStore' -> 'Sold'.

## Build

Expand All @@ -42,17 +41,14 @@ which can be run.
To run the script use for example the following command in this folder:

```
cargo run --release -- --node http://node.testnet.concordium.com:20000 --admin-key-file ./4SizPU2ipqQQza9Xa6fUkQBCDjyd1vTNUNDGbBeiRGpaJQc6qX.export --module ./track_and_trace.wasm.v1 --num-items 2
cargo run --release -- --node https://grpc.testnet.concordium.com:20000 --admin-key-file ./4SizPU2ipqQQza9Xa6fUkQBCDjyd1vTNUNDGbBeiRGpaJQc6qX.export --module ../smart-contract/concordium-out/module.wasm.v1 --num-items 2
```

assuming the wallet export file `/4SizPU2ipqQQza9Xa6fUkQBCDjyd1vTNUNDGbBeiRGpaJQc6qX.export` is in this directory.


To get your account file (the `4SizPU2ipqQQza9Xa6fUkQBCDjyd1vTNUNDGbBeiRGpaJQc6qX.export` file in the above example), export it from the Concordium Browser wallet for web.
To get your account file (the `4SizPU2ipqQQza9Xa6fUkQBCDjyd1vTNUNDGbBeiRGpaJQc6qX.export` file in the above example), export it from the [Concordium Browser wallet for web](http://developer.concordium.software/en/mainnet/net/guides/export-key.html).

<img src="./pic/pic1.png" width="200" />
<img src="./pic/pic2.png" width="200" />
<img src="./pic/pic3.png" width="200" />

###

Expand Down
Binary file removed trackAndTrace/scripts/pic/pic1.png
Binary file not shown.
Binary file removed trackAndTrace/scripts/pic/pic2.png
Binary file not shown.
Binary file removed trackAndTrace/scripts/pic/pic3.png
Binary file not shown.
10 changes: 3 additions & 7 deletions trackAndTrace/scripts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use concordium_rust_sdk::{
},
v2::{self as sdk, BlockIdentifier},
};
use std::sync::Arc;
use track_and_trace::*;

pub enum TrackAndTraceContract {}
Expand All @@ -23,20 +22,19 @@ pub enum TrackAndTraceContract {}
struct Args {
#[arg(
long = "node",
default_value = "http://node.testnet.concordium.com:20000",
default_value = "https://grpc.testnet.concordium.com:20000",
help = "The endpoints are expected to point to concordium node grpc v2 API's.",
global = true
)]
node_endpoint: concordium_rust_sdk::v2::Endpoint,
#[arg(
long = "module",
default_value = "./track-and-trace.wasm.v1",
default_value = "../smart-contract/concordium-out/module.wasm.v1",
help = "Source module from which to initialize the contract instances."
)]
module: std::path::PathBuf,
#[arg(
long = "num-items",
default_value = "1",
help = "Number of items to be created in the contract."
)]
num_items: usize,
Expand Down Expand Up @@ -68,11 +66,9 @@ async fn main() -> anyhow::Result<()> {
.context("Unable to establish connection to the node.")?;

// Load account keys and sender address from a file
let keys: WalletAccount = WalletAccount::from_json_file(args.admin_keys_path)
let admin_key: WalletAccount = WalletAccount::from_json_file(args.admin_keys_path)
.context("Could not read the keys file.")?;

let admin_key = Arc::new(keys);

eprintln!("Starting script with admin account {}.", admin_key.address);

// Deploy module
Expand Down
Binary file removed trackAndTrace/scripts/track_and_trace.wasm.v1
Binary file not shown.

0 comments on commit 30aa561

Please sign in to comment.