Skip to content

Commit

Permalink
missing take order entity test
Browse files Browse the repository at this point in the history
  • Loading branch information
NanezX committed Nov 1, 2023
1 parent d94908b commit be3c832
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
5 changes: 1 addition & 4 deletions subgraph/src/orderBook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions subgraph/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
Expand Down
2 changes: 1 addition & 1 deletion subgraph/tests/subgraph/query/take_order_entity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl TakeOrderEntityResponse {
}
}

pub async fn get_vault_deposit(id: &String) -> Result<TakeOrderEntityResponse> {
pub async fn get_take_order_entity(id: &String) -> Result<TakeOrderEntityResponse> {
let variables = take_order_entity::Variables {
id: id.to_string().into(),
};
Expand Down
2 changes: 0 additions & 2 deletions subgraph/tests/utils/numbers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down

0 comments on commit be3c832

Please sign in to comment.