Skip to content

Commit

Permalink
Feat/accepted tokens (#1066)
Browse files Browse the repository at this point in the history
* feat(tokens): surface accepted tokens

* fix(tokens): acceptedTokens test and fix

* chore(address): update trader address graph

* fix(import): add bigint to import
  • Loading branch information
bitbeckers authored Sep 6, 2023
1 parent e27a63f commit e95571c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions graph/src/hypercert-trader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from "../generated/HypercertTrader/HypercertTrader";
import { Trade } from "../generated/schema";
import { getOrCreateOffer, getOrCreateOfferByID } from "./utils";
import { log } from "@graphprotocol/graph-ts";
import { log, BigInt } from "@graphprotocol/graph-ts";

export function handleOfferCancelled(event: OfferCancelledEvent): void {
const offer = getOrCreateOfferByID(
Expand All @@ -31,7 +31,6 @@ export function handleOfferCreated(event: OfferCreatedEvent): void {
event.params.offerID,
);

// TODO get accepted tokens
offer.save();
}

Expand Down Expand Up @@ -65,5 +64,10 @@ export function handleTrade(event: TradeEvent): void {
trade.offerID = offer.id;
}

offer.unitsAvailable = offer.unitsAvailable.minus(event.params.unitsBought);
if (offer.unitsAvailable.equals(BigInt.fromI32(0))) {
offer.status = "Fulfilled";
}

trade.save();
}
2 changes: 1 addition & 1 deletion graph/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dataSources:
name: HypercertTrader
network: goerli
source:
address: "0xFf3F27c6132c30d1098b97FfeC05C3150dA90432"
address: "0x689587461AA3103D3D7975c5e4B352Ab711C14C2"
abi: HypercertTrader
mapping:
kind: ethereum/events
Expand Down
2 changes: 1 addition & 1 deletion graph/tests/.latest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "0.5.4",
"timestamp": 1693949703219
"timestamp": 1694038457426
}

0 comments on commit e95571c

Please sign in to comment.