From 8a22e6bfe61a288951111219787c5cf092480d5b Mon Sep 17 00:00:00 2001 From: rouzwelt Date: Fri, 13 Dec 2024 02:57:11 +0000 Subject: [PATCH 1/2] init --- subgraph/src/clear.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subgraph/src/clear.ts b/subgraph/src/clear.ts index 1aafdc176..c78e7717e 100644 --- a/subgraph/src/clear.ts +++ b/subgraph/src/clear.ts @@ -35,7 +35,7 @@ export function makeClearBountyId( vaultEntityId: Bytes ): Bytes { return Bytes.fromByteArray( - crypto.keccak256(eventId(event).concat(vaultEntityId)) + crypto.keccak256(vaultEntityId.concat(eventId(event))) ); } From daa89e05304994660c7e3ace50fdbb08169af496 Mon Sep 17 00:00:00 2001 From: rouzwelt Date: Fri, 13 Dec 2024 03:26:02 +0000 Subject: [PATCH 2/2] add test --- .../tests/tradevaultbalancechange.test.ts | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/subgraph/tests/tradevaultbalancechange.test.ts b/subgraph/tests/tradevaultbalancechange.test.ts index 39b0f5274..6d3085597 100644 --- a/subgraph/tests/tradevaultbalancechange.test.ts +++ b/subgraph/tests/tradevaultbalancechange.test.ts @@ -8,7 +8,12 @@ import { assert, } from "matchstick-as"; import { BigInt, Address, Bytes, crypto } from "@graphprotocol/graph-ts"; -import { Evaluable, IO, createTakeOrderEvent } from "./event-mocks.test"; +import { + Evaluable, + IO, + createAfterClearEvent, + createTakeOrderEvent, +} from "./event-mocks.test"; import { eventId } from "../src/interfaces/event"; import { createTradeVaultBalanceChangeEntity, @@ -18,6 +23,7 @@ import { vaultEntityId } from "../src/vault"; import { orderHashFromTakeOrderEvent } from "../src/takeorder"; import { makeTradeId } from "../src/trade"; import { createMockERC20Functions } from "./erc20.test"; +import { makeClearBountyId } from "../src/clear"; describe("Deposits", () => { afterEach(() => { @@ -136,4 +142,28 @@ describe("Deposits", () => { event.transaction.hash.toHex() ); }); + + test("TradeVaultBalanceChangeEntity id should not be equal to ClearBounty id", () => { + const alice = Address.fromString( + "0x850c40aBf6e325231ba2DeD1356d1f2c267e63Ce" + ); + let aliceOutputAmount = BigInt.fromString("10"); + let bobOutputAmount = BigInt.fromString("20"); + let aliceInputAmount = BigInt.fromString("15"); + let bobInputAmount = BigInt.fromString("10"); + let vaultEntityId = Bytes.fromHexString( + "0x1234567890abcdef1234567890abcdef12345678" + ); + let event = createAfterClearEvent( + alice, + aliceOutputAmount, + bobOutputAmount, + aliceInputAmount, + bobInputAmount + ); + const id1 = tradeVaultBalanceChangeId(event, vaultEntityId); + const id2 = makeClearBountyId(event, vaultEntityId); + + assert.assertTrue(id1 !== id2); + }); });