From 61c74acdcc76f731a7c7de0e0e9e1ed6017cae2c Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Wed, 2 Oct 2019 15:32:55 -0400 Subject: [PATCH] fix not default value for amount --- subgraph/build/Contract/Contract.wasm | Bin 12642 -> 12637 bytes subgraph/src/mapping.ts | 12 ++++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/subgraph/build/Contract/Contract.wasm b/subgraph/build/Contract/Contract.wasm index 3ff5d5b6c5694c8daba85d4d2d6f6e70a65ebf7d..940d182a176c0ce5301bdadae05419226b633a8e 100644 GIT binary patch delta 465 zcmXw#ze{655XWcsy_X-ih8sBJ8cuNXbLipPAlbM+KV6X1o3aY z;>``^a=>7(@{BY}q5CyF{DvQP`%F?==*ej|@5ptSJjJ9n!lRQeojv*6*#qTP4S@!p|myyX5 zrCTuk;Wdi``X)AOI-h(=)3|Q2U$u-&g;Q8{Kf-fdcX#2;$12rmOS*WH+@P8ZM!w=| z9F5#)w-GJ*1A1e^ZAP$)8l4LO;1JH>02*)%w)KWi1?~zu0GZT1PkbqMj4o(N cK7u{r+pr`1BAmjetOnSwaW?uK4^GbG3yGUndjJ3c delta 454 zcmXX>O)o=H5S@7+S}y5`y!R|LZ~D4GQI+^uNTfGdv8GB1A{L|)BzF7-aX0>fCM+Z` z5kI3_3-PhAllTedmc`ASIrq$*Gp~D}dyj9JaU3_3aWVbEGsKUy?k*0Q`*?h^rn11m zNJ{ky(ARPKIHqxJ|uF^)LkRdp*eiu2e?t2}^L1yt-T zdsPO?(K;a&3yv`C&<1-{r%lEJuxkan9k6Rn{0^q7tmH20rY))1(KoD~Gc>}ee*(_h zfC6triW1N`>(~>zALiVw_}QQ7=a75;RP0kp)@+OQwhHWt?SRG-@UBE#@ii!=Ec+f9 zOlGiV=8{X?GEd2Tu0{>o7h_lE52$fd9L0KCD&DD5pAP^hZ~;v?fKxlHI@Gz4M?y70 za;icOz^qKft|T=tllk~LR8fyiHepFb$MOzg7tW=gNvzPc%WGbwcFHCm%bTBaViu<2 Iw7;^7zpvs`YXATM diff --git a/subgraph/src/mapping.ts b/subgraph/src/mapping.ts index 14258b5..0e8f596 100644 --- a/subgraph/src/mapping.ts +++ b/subgraph/src/mapping.ts @@ -185,9 +185,14 @@ function createOrUpdatePledge(event: Transfer): void { ) let toPledge = Pledge.load(event.params.to.toHex()) let fromPledge = Pledge.load(event.params.from.toHex()) - if (toPledge == null) toPledge = new Pledge(event.params.to.toHex()) - if (fromPledge == null) fromPledge = new Pledge(event.params.from.toHex()) - fromPledge.amount = fromPledge.amount.minus(amount) + if (toPledge == null) { + toPledge = new Pledge(event.params.to.toHex()) + toPledge.amount = new BigInt(0) + } + if (fromPledge != null) { + fromPledge.amount = fromPledge.amount.minus(amount) + fromPledge.save() + } toPledge.owner = owner toPledge.token = token.toHexString() toPledge.amount = toPledge.amount.plus(amount) @@ -197,7 +202,6 @@ function createOrUpdatePledge(event: Transfer): void { toPledge.nDelegates = ndelegates toPledge.creationTime = timestamp toPledge.save() - fromPledge.save() } export function handleTransfer(event: Transfer): void {