Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cargo-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
version: 0.9

- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.5
uses: Swatinem/rust-cache@v2.7.8

- name: cargo nextest
run: cargo nextest run
2 changes: 1 addition & 1 deletion .github/workflows/rust-clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
override: true

- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.5
uses: Swatinem/rust-cache@v2.7.8

- name: cargo clippy
run: cargo clippy --all-targets -- -D warnings -D clippy::pedantic -D clippy::correctness -D clippy::complexity -D clippy::perf
12 changes: 5 additions & 7 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ serde = { version = "1", features = ["derive", "rc"] }
tracing = "0.1"
scale-info = "2"
axum-macros = "0.4"
primitive-types = { version = "0.13", features = ["codec", "serde"] }
primitive-types = { version = "0.13.1", features = ["codec", "serde"] }
jsonrpsee = { version = "0.24", features = ["ws-client"] }
thiserror = "2"
frame-metadata = "18"
Expand Down Expand Up @@ -68,10 +68,10 @@ async-lock = "3"
time = "0.3"
reqwest = "0.12"

substrate_parser = "0.7.0"
substrate-constructor = "0.2.0"
substrate_parser = "0.7.1"
substrate-constructor = { version = "0.2.1", path = "../substrate-constructor" }
mnemonic-external = "0.1.0"
substrate-crypto-light = "0.1.0"
substrate-crypto-light = "0.2.0"

[build-dependencies]
# Don't forget to update me in `[dependencies]`!
Expand Down
16 changes: 16 additions & 0 deletions configs/dentnet.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
account-lifetime = 604800000 # 1 week.
debug = true
depth = 86400000 # 1 day.

[[chain]]
name = "dentnet"
native-token = "DENTX"
decimals = 18
endpoints = [
#"wss://dev.dentnet.io/ws"
"ws://127.0.0.1:9944/"
]

[[chain.asset]]
name = "DENT"
id = 1
9 changes: 1 addition & 8 deletions src/chain/payout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use crate::{
};
use frame_metadata::v15::RuntimeMetadataV15;
use jsonrpsee::ws_client::WsClientBuilder;
use substrate_constructor::fill_prepare::TypeContentToFill;
use substrate_crypto_light::common::AsBase58;

/// Single function that should completely handle payout attmept. Just do not call anything else.
Expand Down Expand Up @@ -141,13 +140,7 @@ pub async fn payout(

let signature = signer.sign(order.id.clone(), sign_this).await?;

if let TypeContentToFill::Variant(ref mut multisig) = batch_transaction.signature.content {
if let TypeContentToFill::ArrayU8(ref mut sr25519) =
multisig.selected.fields_to_fill[0].type_to_fill.content
{
sr25519.content = signature.0.to_vec();
}
}
batch_transaction.set_signature(&signature);

let extrinsic = batch_transaction
.send_this_signed::<(), RuntimeMetadataV15>(&chain.metadata)?
Expand Down
39 changes: 33 additions & 6 deletions src/chain/tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{
};
use frame_metadata::v15::RuntimeMetadataV15;
use jsonrpsee::ws_client::{WsClient, WsClientBuilder};
use serde_json::Value;
use serde_json::{Value, Value::Null};
use std::{
collections::{HashMap, HashSet},
time::SystemTime,
Expand Down Expand Up @@ -213,10 +213,21 @@ pub fn start_chain_watch(
for (id, invoice) in &watched_accounts {
match invoice.check(&client, &watcher, &block).await {
Ok(true) => {
state.order_paid(id.clone()).await;
match state.is_order_paid(id.clone()).await {
Ok(true) => {
tracing::debug!("Order {id} is already marked paid, removing from watch list");
// state.order_stuck(id.clone()).await;
id_remove_list.push(id.to_owned());
},
_ => state.order_paid(id.clone()).await
}
},
Err(e) => {
tracing::warn!("account fetch error: {0:?}", e);
match e {
ChainError::StorageValueFormat(v) if v == Null => (),
ChainError::BalanceNotFound => (),
_ => tracing::warn!("account fetch error: {0}", e),
}
}
_ => {}
}
Expand All @@ -232,7 +243,11 @@ pub fn start_chain_watch(
}
}
Err(e) => {
tracing::warn!("account fetch error: {0:?}", e);
match e {
ChainError::StorageValueFormat(v) if v == Null => (),
ChainError::BalanceNotFound => (),
_ => tracing::warn!("account fetch error: {0}", e),
}
}
}
}
Expand Down Expand Up @@ -264,7 +279,15 @@ pub fn start_chain_watch(
let signer_for_reaper = signer.interface();

task_tracker.clone().spawn(format!("Initiate payout for order {}", id.clone()), async move {
drop(payout(rpc, Invoice::from_request(request), reap_state_handle, watcher_for_reaper, signer_for_reaper).await);
let result = payout(rpc, Invoice::from_request(request), reap_state_handle, watcher_for_reaper, signer_for_reaper).await;
match result {
Ok(_) => {
tracing::info!("Payout for order {id} completed successfully");
}
Err(e) => {
tracing::warn!("Payout for order {id} failed: {e}");
}
}
Ok(format!("Payout attempt for order {id} terminated"))
});
}
Expand Down Expand Up @@ -411,7 +434,11 @@ impl ChainWatcher {
}
Ok(false) => (),
Err(e) => {
tracing::warn!("account fetch error: {0}", e);
match e {
ChainError::StorageValueFormat(v) if v == Null => (),
ChainError::BalanceNotFound => (),
_ => tracing::warn!("account fetch error: {0}", e),
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ impl Database {
.await;
rx.await.map_err(|_| DbError::DbEngineDown)?
}

pub async fn mark_forced(&self, order: String) -> Result<(), DbError> {
let (res, rx) = oneshot::channel();
let _unused = self
Expand Down
Loading