Skip to content

Commit

Permalink
fix: bump tap-core version to support rav camel case (#125)
Browse files Browse the repository at this point in the history
Signed-off-by: Gustavo Inacio <[email protected]>
  • Loading branch information
gusinacio authored Feb 26, 2024
1 parent 1e07510 commit b13bd8a
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 27 deletions.
34 changes: 29 additions & 5 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ thegraph = { git = "https://github.com/edgeandnode/toolshed", tag = "thegraph-v0
graphql-http = { git = "https://github.com/edgeandnode/toolshed", tag = "graphql-http-v0.2.1", features = [
"http-reqwest",
] }
tap_core = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", branch = "aasseman/tap_core_0_7_0_fix_toolshed_dep" }
tap_core = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", rev = "790e31f" }
axum = { version = "0.6.20", default_features = true, features = ["headers"] }
thiserror = "1.0.49"
async-trait = "0.1.74"
Expand Down
4 changes: 2 additions & 2 deletions tap-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ sqlx = { version = "0.7.2", features = [
"rust_decimal",
"chrono",
] }
tap_aggregator = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", branch = "aasseman/tap_core_0_7_0_fix_toolshed_dep" }
tap_core = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", branch = "aasseman/tap_core_0_7_0_fix_toolshed_dep" }
tap_aggregator = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", rev = "790e31f" }
tap_core = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", rev = "790e31f" }
thiserror = "1.0.44"
tokio = { version = "1.33.0" }
thegraph = { git = "https://github.com/edgeandnode/toolshed", tag = "thegraph-v0.5.0" }
Expand Down
10 changes: 5 additions & 5 deletions tap-agent/src/tap/rav_storage_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ impl RAVStorageAdapterTrait for RAVStorageAdapter {
self.sender.encode_hex::<String>(),
signature_bytes,
self.allocation_id.encode_hex::<String>(),
BigDecimal::from(rav.message.timestamp_ns),
BigDecimal::from(BigInt::from(rav.message.value_aggregate)),
BigDecimal::from(rav.message.timestampNs),
BigDecimal::from(BigInt::from(rav.message.valueAggregate)),
chrono::Utc::now()
)
.execute(&self.pgpool)
Expand Down Expand Up @@ -125,9 +125,9 @@ impl RAVStorageAdapterTrait for RAVStorageAdapter {
})?;

let rav = ReceiptAggregateVoucher {
allocation_id,
timestamp_ns,
value_aggregate,
allocationId: allocation_id,
timestampNs: timestamp_ns,
valueAggregate: value_aggregate,
};
Ok(Some(SignedRAV {
message: rav,
Expand Down
16 changes: 8 additions & 8 deletions tap-agent/src/tap/sender_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,11 +768,11 @@ mod tests {

let latest_rav = EIP712SignedMessage {
message: ReceiptAggregateVoucher {
allocation_id: Address::from_str(&latest_rav.allocation_id).unwrap(),
timestamp_ns: latest_rav.timestamp_ns.to_u64().unwrap(),
allocationId: Address::from_str(&latest_rav.allocation_id).unwrap(),
timestampNs: latest_rav.timestamp_ns.to_u64().unwrap(),
// Beware, BigDecimal::to_u128() actually uses to_u64() under the hood...
// So we're converting to BigInt to get a proper implementation of to_u128().
value_aggregate: latest_rav
valueAggregate: latest_rav
.value_aggregate
.to_bigint()
.map(|v| v.to_u128())
Expand All @@ -783,7 +783,7 @@ mod tests {
};

// Check that the latest RAV value is correct.
assert!(latest_rav.message.value_aggregate >= trigger_value);
assert!(latest_rav.message.valueAggregate >= trigger_value);

// Check that the allocation's unaggregated fees value is reduced.
assert!(
Expand Down Expand Up @@ -859,11 +859,11 @@ mod tests {

let latest_rav = EIP712SignedMessage {
message: ReceiptAggregateVoucher {
allocation_id: Address::from_str(&latest_rav.allocation_id).unwrap(),
timestamp_ns: latest_rav.timestamp_ns.to_u64().unwrap(),
allocationId: Address::from_str(&latest_rav.allocation_id).unwrap(),
timestampNs: latest_rav.timestamp_ns.to_u64().unwrap(),
// Beware, BigDecimal::to_u128() actually uses to_u64() under the hood...
// So we're converting to BigInt to get a proper implementation of to_u128().
value_aggregate: latest_rav
valueAggregate: latest_rav
.value_aggregate
.to_bigint()
.map(|v| v.to_u128())
Expand All @@ -875,7 +875,7 @@ mod tests {

// Check that the latest RAV value is correct.

assert!(latest_rav.message.value_aggregate >= trigger_value);
assert!(latest_rav.message.valueAggregate >= trigger_value);

// Check that the allocation's unaggregated fees value is reduced.
assert!(
Expand Down
12 changes: 6 additions & 6 deletions tap-agent/src/tap/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ pub async fn create_rav(
EIP712SignedMessage::new(
&TAP_EIP712_DOMAIN_SEPARATOR,
ReceiptAggregateVoucher {
allocation_id,
timestamp_ns,
value_aggregate,
allocationId: allocation_id,
timestampNs: timestamp_ns,
valueAggregate: value_aggregate,
},
&signer_wallet,
)
Expand Down Expand Up @@ -137,9 +137,9 @@ pub async fn store_rav(pgpool: &PgPool, signed_rav: SignedRAV, sender: Address)
"#,
sender.encode_hex::<String>(),
signature_bytes,
signed_rav.message.allocation_id.encode_hex::<String>(),
BigDecimal::from(signed_rav.message.timestamp_ns),
BigDecimal::from(BigInt::from(signed_rav.message.value_aggregate)),
signed_rav.message.allocationId.encode_hex::<String>(),
BigDecimal::from(signed_rav.message.timestampNs),
BigDecimal::from(BigInt::from(signed_rav.message.valueAggregate)),
)
.execute(pgpool)
.await?;
Expand Down

0 comments on commit b13bd8a

Please sign in to comment.