Skip to content

Commit 4d2f4c3

Browse files
committed
update icrc3 to use timestamp parameter if provided
1 parent 8f2286a commit 4d2f4c3

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

Cargo.lock

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ bity-ic-utils = "0.1.0"
9797
bity-ic-subcanister-manager = "0.2.4"
9898
bity-ic-icrc3-archive-api = "0.1.0"
9999
bity-ic-icrc3-archive-c2c-client = "0.1.0"
100-
bity-ic-icrc3 = "0.1.0"
100+
bity-ic-icrc3 = "0.1.5"

src/icrc3/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bity-ic-icrc3"
3-
version = "0.1.5"
3+
version = "0.1.6"
44
edition = "2021"
55
license = "MIT"
66
description = "bity icrc3 library"

src/icrc3/src/interface.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ impl<T: TransactionType> ICRC3Interface<T> for ICRC3 {
100100
async fn add_transaction(&mut self, transaction: T) -> Result<u64, Icrc3Error> {
101101
let now = ic_cdk::api::time() as u128;
102102

103+
let timestamp = if transaction.timestamp().is_none() {
104+
now
105+
} else {
106+
transaction.timestamp().unwrap() as u128
107+
};
108+
103109
let num_pruned = self.purge_old_transactions(now);
104110

105111
// If we pruned some transactions, let this one through
@@ -178,8 +184,11 @@ impl<T: TransactionType> ICRC3Interface<T> for ICRC3 {
178184
self.last_index += 1;
179185
self.last_phash = Some(ByteBuf::from(checked_transaction.clone().hash().to_vec()));
180186

181-
let block =
182-
DefaultBlock::from_transaction(self.blockchain.last_hash, checked_transaction, now);
187+
let block = DefaultBlock::from_transaction(
188+
self.blockchain.last_hash,
189+
checked_transaction,
190+
timestamp,
191+
);
183192

184193
match self.blockchain.add_block(block).await {
185194
Ok(_) => (),

0 commit comments

Comments
 (0)