Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DOBEN committed Apr 9, 2024
1 parent 6901426 commit a83affc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
6 changes: 0 additions & 6 deletions trackAndTrace/frontend/src/components/Explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,6 @@ export function Explorer() {
throw Error(`'itemID' input field is undefined`);
}

// // Clear table.
// const tableBody = document.getElementById('table');
// if (tableBody) {
// tableBody.innerHTML = '';
// }

try {
await getItemCreatedEvent(itemID, setItemCreated);
await getItemStatusChangedEvents(itemID, setItemChanged);
Expand Down
6 changes: 3 additions & 3 deletions trackAndTrace/indexer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Each event can be uniquely identified by the `transaction_hash` and `event_index
## Run the `indexer`

```console
cargo run --bin indexer -- --node https://grpc.testnet.concordium.com:20000 --contract "<8219,0>" --log-level debug
cargo run --bin indexer -- --node https://grpc.testnet.concordium.com:20000 --contract "<8527,0>" --log-level debug
```

## Configure the `indexer`
Expand All @@ -64,7 +64,7 @@ There are a few options to configure the indexer:

- `--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.

- `--contract` is the contract index of the track-and-trace smart contract, e.g. <8219,0>.
- `--contract` is the contract index of the track-and-trace smart contract, e.g. <8527,0>.

- `--db-connection` should specify your postgreSQL database connection. If not specified, the default value `host=localhost dbname=indexer user=postgres password=password port=5432` is used.

Expand Down Expand Up @@ -111,5 +111,5 @@ cargo run --bin server -- --contract-address <YOUR_CONTRACT_ADDRESS>
An example to run the service with some filled in example settings would be:

``` console
cargo run --bin server -- --contract-address "<8219,0>"
cargo run --bin server -- --contract-address "<8527,0>"
```
18 changes: 8 additions & 10 deletions trackAndTrace/smart-contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ pub enum CustomContractError {
/// Failed signature verification: Signature is expired.
Expired, // -15
/// Update of state machine was unsuccessful.
UnSuccessful, // -16
Unsuccessful, // -16
}

/// Mapping account signature error to CustomContractError
Expand Down Expand Up @@ -319,20 +319,18 @@ impl<S: HasStateApi> State<S> {
targets.insert(to)
}

/// Remove a transition. Return if the transition was removed successfully.
/// Remove a transition. Return if the transition was present.
pub fn remove(
&mut self,
builder: &mut StateBuilder<S>,
from: Status,
address: AccountAddress,
to: Status,
) -> bool {
let mut transition = self
.transitions
.entry(from)
.or_insert_with(|| StatusTransitions {
transitions: builder.new_map(),
});
let Some(mut transition) = self
.transitions
.get_mut(&from) else { return false; };

let mut targets = transition.targets(builder, address);
targets.remove(&to)
}
Expand Down Expand Up @@ -708,7 +706,7 @@ fn contract_update_state_machine(
params.address,
params.to_status,
);
ensure!(success, CustomContractError::UnSuccessful);
ensure!(success, CustomContractError::Unsuccessful);
}
Update::Remove => {
let success = state.remove(
Expand All @@ -718,7 +716,7 @@ fn contract_update_state_machine(
params.to_status,
);

ensure!(success, CustomContractError::UnSuccessful);
ensure!(success, CustomContractError::Unsuccessful);
}
};

Expand Down

0 comments on commit a83affc

Please sign in to comment.