From be3c8323cf1daeef9d001e3336a8da64472c8787 Mon Sep 17 00:00:00 2001 From: NanezX Date: Wed, 1 Nov 2023 01:48:25 -0400 Subject: [PATCH] missing take order entity test --- subgraph/src/orderBook.ts | 5 +---- subgraph/src/utils.ts | 7 +++---- subgraph/tests/subgraph/query/take_order_entity/mod.rs | 2 +- subgraph/tests/utils/numbers.rs | 2 -- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/subgraph/src/orderBook.ts b/subgraph/src/orderBook.ts index 5ed2c3262..ae5d1bc57 100644 --- a/subgraph/src/orderBook.ts +++ b/subgraph/src/orderBook.ts @@ -718,10 +718,7 @@ export function handleTakeOrder(event: TakeOrder): void { // Adding the context const contextTakeOrder = ContextEntity.load("ContextTakeOrderTemp"); if (contextTakeOrder) { - const contextEntity = createContextEntity( - event.transaction.hash.toHex(), - event.logIndex.toHex() - ); + const contextEntity = createContextEntity(event.transaction.hash.toHex()); contextEntity.caller = contextTakeOrder.caller; contextEntity.contract = contextTakeOrder.contract; diff --git a/subgraph/src/utils.ts b/subgraph/src/utils.ts index aceffa10d..7a50a8706 100644 --- a/subgraph/src/utils.ts +++ b/subgraph/src/utils.ts @@ -377,13 +377,12 @@ export function createSignedContext( return new SignedContext(""); } export function createContextEntity( - txHash: string, - logIndex: string + txHash: string ): ContextEntity { for (let i = 0; ; i++) { - let contextEntity = ContextEntity.load(`${txHash}-${logIndex}-${i}`); + let contextEntity = ContextEntity.load(`${txHash}-${i}`); if (!contextEntity) { - return new ContextEntity(`${txHash}-${logIndex}-${i}`); + return new ContextEntity(`${txHash}-${i}`); } } return new ContextEntity(""); diff --git a/subgraph/tests/subgraph/query/take_order_entity/mod.rs b/subgraph/tests/subgraph/query/take_order_entity/mod.rs index 34e581bd8..153a4943c 100644 --- a/subgraph/tests/subgraph/query/take_order_entity/mod.rs +++ b/subgraph/tests/subgraph/query/take_order_entity/mod.rs @@ -77,7 +77,7 @@ impl TakeOrderEntityResponse { } } -pub async fn get_vault_deposit(id: &String) -> Result { +pub async fn get_take_order_entity(id: &String) -> Result { let variables = take_order_entity::Variables { id: id.to_string().into(), }; diff --git a/subgraph/tests/utils/numbers.rs b/subgraph/tests/utils/numbers.rs index a029519b8..aff5e9a12 100644 --- a/subgraph/tests/utils/numbers.rs +++ b/subgraph/tests/utils/numbers.rs @@ -3,8 +3,6 @@ use ethers::types::U256; use std::{ops::Mul, str::FromStr}; extern crate bigdecimal; use bigdecimal::BigDecimal; -use bigdecimal::FromPrimitive; -use bigdecimal::ToPrimitive; pub fn get_amount_tokens(amount: u64, decimals: u8) -> U256 { let result: U256 = U256::from(amount).mul(U256::from(10).pow(U256::from(decimals)));