Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DOBEN committed Jan 11, 2024
1 parent 424b12e commit 5965919
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 60 deletions.
2 changes: 1 addition & 1 deletion sponsoredTransactionsAuction/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG node_base_image=node:18-slim
ARG rust_base_image=rust:1.67
ARG rust_base_image=rust:1.70

FROM ${node_base_image} AS front_end

Expand Down
2 changes: 1 addition & 1 deletion sponsoredTransactionsAuction/backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions sponsoredTransactionsAuction/backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ license-file = "../../LICENSE"

[dependencies]
anyhow = "1.0"
axum = "0.6"
axum = { version = "0.6", features = ["macros"] }
clap = { version = "4.3", features = ["derive", "env"] }
serde_json = "1.0"
tokio = { version = "1.29", features = ["rt-multi-thread", "signal"] }
tracing = "0.1"
tracing-subscriber = "0.3"
serde = { version = "1.0", features = ["derive"] }
futures = "0.3"
axum-macros = "0.3"
tower-http = { version = "0.4", features = [
"trace",
"limit",
Expand Down
4 changes: 2 additions & 2 deletions sponsoredTransactionsAuction/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The following parameters are supported
- `port` the port on which the server will listen for incoming requests, e.g., 127.0.0.1:8080.
- `log-level` maximum log level (defaults to `info` if not given).
- `frontend` the path to the folder, which should be served, defaults to the `../frontent/dist` folder.
- `account-key-file` the path to a file which contains the key credentials.
- `account-key-file` the path to a file which contains the key credentials for the sponsorer account.
- `cis2-token-smart-contract-index` the smart contract index which the sponsored transaction is submitted to.
- `auction-smart-contract-index` the smart contract index of the auction smart contract.
- `request-timeout` the request timeout (both of request to the node and server requests) in milliseconds. The node timeout is 500 ms less than the request-timeout to make sure we can fail properly in the server in case of connection timeout due to node connectivity problems.
Expand Down Expand Up @@ -59,7 +59,7 @@ Changes to any of the packages must be such that
- ```cargo clippy --all``` produces no warnings
- ```rust fmt``` makes no changes.

Everything in this repository should build with rust version 1.65 however the `fmt` tool must be from a nightly release since some of the configuration options are not stable. One way to run the `fmt` tool is
Everything in this repository should build with rust version 1.70 however the `fmt` tool must be from a nightly release since some of the configuration options are not stable. One way to run the `fmt` tool is
```
cargo +nightly-2023-04-01 fmt
```
Expand Down
26 changes: 5 additions & 21 deletions sponsoredTransactionsAuction/backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,8 @@ 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 = serde_json::from_str(
&std::fs::read_to_string(app.keys_path).context("Could not read the keys file.")?,
)
.context("Could not parse the keys file.")?;
let keys: WalletAccount =
WalletAccount::from_json_file(app.keys_path).context("Could not read the keys file.")?;

let sponsorer_key = Arc::new(keys);

Expand All @@ -166,9 +164,9 @@ async fn main() -> anyhow::Result<()> {
.context("NonceQueryError.")?;

tracing::debug!(
"Starting server with sponsorer {:?}. Current sponsorer nonce: {:?}.",
"Starting server with sponsorer {}. Current sponsorer nonce: {}.",
sponsorer_key.address,
nonce_response
nonce_response.nonce
);

let state = Server {
Expand Down Expand Up @@ -221,10 +219,6 @@ async fn handle_signature_bid(
) -> Result<Json<TransactionHash>, ServerError> {
let Json(request) = request?;

tracing::debug!("Request: {:?}", request);

tracing::debug!("Create payload ...");

let transfer = Transfer {
from: Address::Account(request.from),
to: Receiver::Contract(
Expand All @@ -240,8 +234,6 @@ async fn handle_signature_bid(

tracing::debug!("Created payload: {:?}", payload);

tracing::debug!("Create permitMessage ...");

let message: PermitMessage = PermitMessage {
contract_address: state.cis2_token_smart_contract,
nonce: request.nonce,
Expand All @@ -252,8 +244,6 @@ async fn handle_signature_bid(

tracing::debug!("Created {:?}", message);

tracing::debug!("Create signature map ...");

let mut signature = [0; 64];

if request.signature.len() != 128 {
Expand All @@ -272,8 +262,6 @@ async fn handle_signature_bid(

tracing::debug!("Created signature_map {:?}", signature_map);

tracing::debug!("Create parameter ...");

let param: PermitParam = PermitParam {
message,
signature: AccountSignatures {
Expand All @@ -287,8 +275,6 @@ async fn handle_signature_bid(

tracing::debug!("Created {:?}", parameter);

tracing::debug!("Simulate transaction to check its validity ...");

let payload = transactions::UpdateContractPayload {
amount: Amount::from_micro_ccd(0),
address: state.cis2_token_smart_contract,
Expand Down Expand Up @@ -385,8 +371,6 @@ async fn handle_signature_bid(

*limit += 1;

tracing::debug!("Create transaction ...");

let tx = transactions::send::make_and_sign_transaction(
&state.key.keys,
state.key.address,
Expand All @@ -401,7 +385,7 @@ async fn handle_signature_bid(
concordium_rust_sdk::types::transactions::Payload::Update { payload },
);

tracing::debug!("Submit transaction {:?} ...", tx.clone());
tracing::debug!("Submit transaction {:?} ...", tx);

let bi = transactions::BlockItem::AccountTransaction(tx);

Expand Down
2 changes: 1 addition & 1 deletion sponsoredTransactionsAuction/backend/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub struct RevertReason {
pub reason: RejectReason,
}

/// Paramters passed from the front end to this back end when calling the API
/// Parameters passed from the front end to this back end when calling the API
/// endpoint `/bid`.
#[derive(serde::Deserialize, serde::Serialize, Debug, Clone)]
pub struct BidParams {
Expand Down
1 change: 0 additions & 1 deletion sponsoredTransactionsAuction/frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module.exports = {
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:jsx-a11y/recommended',
'eslint-config-prettier',
'prettier',
],
parser: '@typescript-eslint/parser',
Expand Down
4 changes: 2 additions & 2 deletions sponsoredTransactionsAuction/frontend/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const NODE = 'http://node.testnet.concordium.com';

export const PORT = 20000;

export const REFRESH_INTERVAL = moment.duration(5, 'seconds');
export const REFRESH_INTERVAL = moment.duration(2, 'seconds');

export const SPONSORED_TX_CONTRACT_NAME = ContractName.fromString('cis2_multi');
export const AUCTION_CONTRACT_NAME = ContractName.fromString('sponsored_tx_enabled_auction');
Expand All @@ -21,7 +21,7 @@ export const CONTRACT_SUB_INDEX = 0n;
// allow an additional small amount of energy `EPSILON_ENERGY` to be consumed by
// the transaction to cover small variations (e.g. changes to the smart contract
// state) caused by transactions that have been executed meanwhile.
export const EPSILON_ENERGY = 1000n;
export const EPSILON_ENERGY = 200n;

export const AUCTION_START = '2000-01-01T12:00:00Z'; // Hardcoded value for simplicity for this demo dApp.
export const AUCTION_END = '2050-01-01T12:00:00Z'; // Hardcoded value for simplicity for this demo dApp.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,10 @@
@import 'bootstrap/scss/maps';
@import 'bootstrap/scss/mixins';
@import 'bootstrap/scss/utilities';

// Bootstrap layout & components - toggle components as needed
// @import 'bootstrap/scss/root';
// @import 'bootstrap/scss/reboot';
@import 'bootstrap/scss/type';
// @import 'bootstrap/scss/images';
// @import 'bootstrap/scss/containers';
// @import 'bootstrap/scss/grid';
// @import 'bootstrap/scss/tables';
@import 'bootstrap/scss/forms';
@import 'bootstrap/scss/buttons';
// @import 'bootstrap/scss/transitions';
// @import 'bootstrap/scss/dropdown';
// @import 'bootstrap/scss/button-group';
// @import 'bootstrap/scss/nav';
// @import 'bootstrap/scss/navbar';
// @import 'bootstrap/scss/card';
// @import 'bootstrap/scss/accordion';
// @import 'bootstrap/scss/breadcrumb';
// @import 'bootstrap/scss/pagination';
// @import 'bootstrap/scss/badge';
@import 'bootstrap/scss/alert';
// @import 'bootstrap/scss/progress';
// @import 'bootstrap/scss/list-group';
// @import 'bootstrap/scss/close';
// @import 'bootstrap/scss/toasts';
// @import 'bootstrap/scss/modal';
// @import 'bootstrap/scss/tooltip';
// @import 'bootstrap/scss/popover';
// @import 'bootstrap/scss/carousel';
// @import 'bootstrap/scss/spinners';
// @import 'bootstrap/scss/offcanvas';
// @import 'bootstrap/scss/placeholders';

// Bootstrap helpers
@import 'bootstrap/scss/helpers';
Expand Down

0 comments on commit 5965919

Please sign in to comment.